mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-15 08:57:31 +01:00
add copy of cosmos node.js SDK as local dependency
This commit is contained in:
committed by
Chris Anderson
parent
ff1e733679
commit
ca396cdfbe
@@ -0,0 +1,66 @@
|
||||
import { CosmosDiagnostics, CosmosHeaders } from "../index";
|
||||
export interface ErrorBody {
|
||||
code: string;
|
||||
message: string;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
additionalErrorInfo?: PartitionedQueryExecutionInfo;
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface PartitionedQueryExecutionInfo {
|
||||
partitionedQueryExecutionInfoVersion: number;
|
||||
queryInfo: QueryInfo;
|
||||
queryRanges: QueryRange[];
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface QueryRange {
|
||||
min: string;
|
||||
max: string;
|
||||
isMinInclusive: boolean;
|
||||
isMaxInclusive: boolean;
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface QueryInfo {
|
||||
top?: any;
|
||||
orderBy?: any[];
|
||||
orderByExpressions?: any[];
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
aggregates?: AggregateType[];
|
||||
groupByExpressions?: GroupByExpressions;
|
||||
groupByAliasToAggregateType: GroupByAliasToAggregateType;
|
||||
rewrittenQuery?: any;
|
||||
distinctType: string;
|
||||
hasSelectValue: boolean;
|
||||
/**
|
||||
* determines whether the query is of non streaming orderby type.
|
||||
*/
|
||||
hasNonStreamingOrderBy: boolean;
|
||||
}
|
||||
export type GroupByExpressions = string[];
|
||||
export type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum";
|
||||
export interface GroupByAliasToAggregateType {
|
||||
[key: string]: AggregateType;
|
||||
}
|
||||
export declare class ErrorResponse extends Error {
|
||||
code?: number | string;
|
||||
substatus?: number;
|
||||
body?: ErrorBody;
|
||||
headers?: CosmosHeaders;
|
||||
activityId?: string;
|
||||
retryAfterInMs?: number;
|
||||
retryAfterInMilliseconds?: number;
|
||||
[key: string]: any;
|
||||
diagnostics?: CosmosDiagnostics;
|
||||
}
|
||||
export declare const nonStreamingEndpointEmptyResult: {
|
||||
result: string;
|
||||
};
|
||||
//# sourceMappingURL=ErrorResponse.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ErrorResponse.d.ts","sourceRoot":"","sources":["../../../src/request/ErrorResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,mBAAmB,CAAC,EAAE,6BAA6B,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,oCAAoC,EAAE,MAAM,CAAC;IAC7C,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,kBAAkB,CAAC,EAAE,GAAG,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,2BAA2B,EAAE,2BAA2B,CAAC;IACzD,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,EAAE,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAExE,MAAM,WAAW,2BAA2B;IAC1C,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,eAAO,MAAM,+BAA+B;;CAA+B,CAAC"}
|
||||
@@ -0,0 +1,4 @@
|
||||
export class ErrorResponse extends Error {
|
||||
}
|
||||
export const nonStreamingEndpointEmptyResult = { result: "empty response" };
|
||||
//# sourceMappingURL=ErrorResponse.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ErrorResponse.js","sourceRoot":"","sources":["../../../src/request/ErrorResponse.ts"],"names":[],"mappings":"AA6DA,MAAM,OAAO,aAAc,SAAQ,KAAK;CAUvC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics, CosmosHeaders } from \"../index\";\n\nexport interface ErrorBody {\n code: string;\n message: string;\n /**\n * @hidden\n */\n additionalErrorInfo?: PartitionedQueryExecutionInfo;\n}\n\n/**\n * @hidden\n */\nexport interface PartitionedQueryExecutionInfo {\n partitionedQueryExecutionInfoVersion: number;\n queryInfo: QueryInfo;\n queryRanges: QueryRange[];\n}\n\n/**\n * @hidden\n */\nexport interface QueryRange {\n min: string;\n max: string;\n isMinInclusive: boolean;\n isMaxInclusive: boolean;\n}\n\n/**\n * @hidden\n */\nexport interface QueryInfo {\n top?: any;\n orderBy?: any[];\n orderByExpressions?: any[];\n offset?: number;\n limit?: number;\n aggregates?: AggregateType[];\n groupByExpressions?: GroupByExpressions;\n groupByAliasToAggregateType: GroupByAliasToAggregateType;\n rewrittenQuery?: any;\n distinctType: string;\n hasSelectValue: boolean;\n /**\n * determines whether the query is of non streaming orderby type.\n */\n hasNonStreamingOrderBy: boolean;\n}\n\nexport type GroupByExpressions = string[];\n\nexport type AggregateType = \"Average\" | \"Count\" | \"Max\" | \"Min\" | \"Sum\";\n\nexport interface GroupByAliasToAggregateType {\n [key: string]: AggregateType;\n}\n\nexport class ErrorResponse extends Error {\n code?: number | string;\n substatus?: number;\n body?: ErrorBody;\n headers?: CosmosHeaders;\n activityId?: string;\n retryAfterInMs?: number;\n retryAfterInMilliseconds?: number;\n [key: string]: any;\n diagnostics?: CosmosDiagnostics;\n}\n\nexport const nonStreamingEndpointEmptyResult = { result: \"empty response\" };\n"]}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { PartitionKey } from "../documents";
|
||||
import { SharedOptions } from "./SharedOptions";
|
||||
/**
|
||||
* The feed options and query methods.
|
||||
*/
|
||||
export interface FeedOptions extends SharedOptions {
|
||||
/** Opaque token for continuing the enumeration. Default: undefined
|
||||
* @deprecated Use continuationToken instead.
|
||||
*/
|
||||
continuation?: string;
|
||||
/** Opaque token for continuing the enumeration. Default: undefined */
|
||||
continuationToken?: string;
|
||||
/**
|
||||
* Limits the size of the continuation token in the response. Default: undefined
|
||||
*
|
||||
* Continuation Tokens contain optional data that can be removed from the serialization before writing it out to a header.
|
||||
* By default we are capping this to 1kb to avoid long headers (Node.js has a global header size limit).
|
||||
* A user may set this field to allow for longer headers, which can help the backend optimize query execution."
|
||||
*/
|
||||
continuationTokenLimitInKB?: number;
|
||||
/**
|
||||
* Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths. Default: false
|
||||
*
|
||||
* In general, it is best to avoid using this setting. Scans are relatively expensive and take a long time to serve.
|
||||
*/
|
||||
enableScanInQuery?: boolean;
|
||||
/**
|
||||
* The maximum number of concurrent operations that run client side during parallel query execution in the
|
||||
* Azure Cosmos DB database service. Negative values make the system automatically decides the number of
|
||||
* concurrent operations to run. Default: 0 (no parallelism)
|
||||
*/
|
||||
maxDegreeOfParallelism?: number;
|
||||
/**
|
||||
* Max number of items to be returned in the enumeration operation. Default: undefined (server will defined payload)
|
||||
*
|
||||
* Expirimenting with this value can usually result in the biggest performance changes to the query.
|
||||
*
|
||||
* The smaller the item count, the faster the first result will be delivered (for non-aggregates). For larger amounts,
|
||||
* it will take longer to serve the request, but you'll usually get better throughput for large queries (i.e. if you need 1000 items
|
||||
* before you can do any other actions, set `maxItemCount` to 1000. If you can start doing work after the first 100, set `maxItemCount` to 100.)
|
||||
*/
|
||||
maxItemCount?: number;
|
||||
/**
|
||||
* Note: consider using changeFeed instead.
|
||||
*
|
||||
* Indicates a change feed request. Must be set to "Incremental feed", or omitted otherwise. Default: false
|
||||
*/
|
||||
useIncrementalFeed?: boolean;
|
||||
/** Conditions Associated with the request. */
|
||||
accessCondition?: {
|
||||
/** Conditional HTTP method header type (IfMatch or IfNoneMatch). */
|
||||
type: string;
|
||||
/** Conditional HTTP method header value (the _etag field from the last version you read). */
|
||||
condition: string;
|
||||
};
|
||||
/**
|
||||
* Enable returning query metrics in response headers. Default: false
|
||||
*
|
||||
* Used for debugging slow or expensive queries. Also increases response size and if you're using a low max header size in Node.js,
|
||||
* you can run into issues faster.
|
||||
*/
|
||||
populateQueryMetrics?: boolean;
|
||||
/**
|
||||
* Enable buffering additional items during queries. Default: false
|
||||
*
|
||||
* This will buffer an additional page at a time (multiplied by maxDegreeOfParallelism) from the server in the background.
|
||||
* This improves latency by fetching pages before they are needed by the client. If you're draining all of the results from the
|
||||
* server, like `.fetchAll`, you should usually enable this. If you're only fetching one page at a time via continuation token,
|
||||
* you should avoid this. If you're draining more than one page, but not the entire result set, it may help improve latency, but
|
||||
* it will increase the total amount of RU/s use to serve the entire query (as some pages will be fetched more than once).
|
||||
*/
|
||||
bufferItems?: boolean;
|
||||
/**
|
||||
* This setting forces the query to use a query plan. Default: false
|
||||
*
|
||||
* Note: this will disable continuation token support, even for single partition queries.
|
||||
*
|
||||
* For queries like aggregates and most cross partition queries, this happens anyway.
|
||||
* However, since the library doesn't know what type of query it is until we get back the first response,
|
||||
* some optimization can't happen until later.
|
||||
*
|
||||
* If this setting is enabled, it will force query plan for the query, which will save some network requests
|
||||
* and ensure parallelism can happen. Useful for when you know you're doing cross-partition or aggregate queries.
|
||||
*/
|
||||
forceQueryPlan?: boolean;
|
||||
/** Limits the query to a specific partition key. Default: undefined
|
||||
*
|
||||
* Scoping a query to a single partition can be accomplished two ways:
|
||||
*
|
||||
* `container.items.query('SELECT * from c', { partitionKey: "foo" }).toArray()`
|
||||
* `container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray()`
|
||||
*
|
||||
* The former is useful when the query body is out of your control
|
||||
* but you still want to restrict it to a single partition. Example: an end user specified query.
|
||||
*/
|
||||
partitionKey?: PartitionKey;
|
||||
/**
|
||||
* Enable returning index metrics in response headers. Default: false
|
||||
*/
|
||||
populateIndexMetrics?: boolean;
|
||||
/**
|
||||
* Specifies a custom maximum buffer size for storing final results for nonStreamingOrderBy queries.
|
||||
* This value is ignored if the query includes top/offset+limit clauses.
|
||||
*/
|
||||
vectorSearchBufferSize?: number;
|
||||
/**
|
||||
* Disable the nonStreamingOrderBy query feature in supported query features.
|
||||
* Default: false. Set to true to avoid error from an old gateway that doesn't support this feature.
|
||||
*/
|
||||
disableNonStreamingOrderByQuery?: boolean;
|
||||
}
|
||||
//# sourceMappingURL=FeedOptions.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FeedOptions.d.ts","sourceRoot":"","sources":["../../../src/request/FeedOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8CAA8C;IAC9C,eAAe,CAAC,EAAE;QAChB,oEAAoE;QACpE,IAAI,EAAE,MAAM,CAAC;QACb,6FAA6F;QAC7F,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=FeedOptions.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,16 @@
|
||||
import { CosmosHeaders } from "../queryExecutionContext/headerUtils";
|
||||
import { CosmosDiagnostics } from "../CosmosDiagnostics";
|
||||
export declare class FeedResponse<TResource> {
|
||||
readonly resources: TResource[];
|
||||
private readonly headers;
|
||||
readonly hasMoreResults: boolean;
|
||||
readonly diagnostics: CosmosDiagnostics;
|
||||
constructor(resources: TResource[], headers: CosmosHeaders, hasMoreResults: boolean, diagnostics: CosmosDiagnostics);
|
||||
get continuation(): string;
|
||||
get continuationToken(): string;
|
||||
get queryMetrics(): string;
|
||||
get requestCharge(): number;
|
||||
get activityId(): string;
|
||||
get indexMetrics(): string;
|
||||
}
|
||||
//# sourceMappingURL=FeedResponse.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FeedResponse.d.ts","sourceRoot":"","sources":["../../../src/request/FeedResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAyB,MAAM,sCAAsC,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,qBAAa,YAAY,CAAC,SAAS;aAEf,SAAS,EAAE,SAAS,EAAE;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;aACR,cAAc,EAAE,OAAO;aACvB,WAAW,EAAE,iBAAiB;gBAH9B,SAAS,EAAE,SAAS,EAAE,EACrB,OAAO,EAAE,aAAa,EACvB,cAAc,EAAE,OAAO,EACvB,WAAW,EAAE,iBAAiB;IAGhD,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD,IAAW,iBAAiB,IAAI,MAAM,CAErC;IACD,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD,IAAW,aAAa,IAAI,MAAM,CAEjC;IACD,IAAW,UAAU,IAAI,MAAM,CAE9B;IACD,IAAW,YAAY,IAAI,MAAM,CAOhC;CACF"}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { Constants } from "../common";
|
||||
import { getRequestChargeIfAny } from "../queryExecutionContext/headerUtils";
|
||||
import { IndexMetricWriter, IndexUtilizationInfo } from "../indexMetrics";
|
||||
export class FeedResponse {
|
||||
constructor(resources, headers, hasMoreResults, diagnostics) {
|
||||
this.resources = resources;
|
||||
this.headers = headers;
|
||||
this.hasMoreResults = hasMoreResults;
|
||||
this.diagnostics = diagnostics;
|
||||
}
|
||||
get continuation() {
|
||||
return this.continuationToken;
|
||||
}
|
||||
get continuationToken() {
|
||||
return this.headers[Constants.HttpHeaders.Continuation];
|
||||
}
|
||||
get queryMetrics() {
|
||||
return this.headers[Constants.HttpHeaders.QueryMetrics];
|
||||
}
|
||||
get requestCharge() {
|
||||
return getRequestChargeIfAny(this.headers);
|
||||
}
|
||||
get activityId() {
|
||||
return this.headers[Constants.HttpHeaders.ActivityId];
|
||||
}
|
||||
get indexMetrics() {
|
||||
const writer = new IndexMetricWriter();
|
||||
const indexUtilizationInfo = IndexUtilizationInfo.createFromString(this.headers[Constants.HttpHeaders.IndexUtilization], true);
|
||||
return writer.writeIndexMetrics(indexUtilizationInfo);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=FeedResponse.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FeedResponse.js","sourceRoot":"","sources":["../../../src/request/FeedResponse.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAiB,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG1E,MAAM,OAAO,YAAY;IACvB,YACkB,SAAsB,EACrB,OAAsB,EACvB,cAAuB,EACvB,WAA8B;QAH9B,cAAS,GAAT,SAAS,CAAa;QACrB,YAAO,GAAP,OAAO,CAAe;QACvB,mBAAc,GAAd,cAAc,CAAS;QACvB,gBAAW,GAAX,WAAW,CAAmB;IAC7C,CAAC;IAEJ,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IACD,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;IACD,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;IACD,IAAW,aAAa;QACtB,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IACD,IAAW,YAAY;QACrB,MAAM,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACvC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,gBAAgB,CAChE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,EACpD,IAAI,CACL,CAAC;QACF,OAAO,MAAM,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { CosmosHeaders, getRequestChargeIfAny } from \"../queryExecutionContext/headerUtils\";\nimport { IndexMetricWriter, IndexUtilizationInfo } from \"../indexMetrics\";\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\n\nexport class FeedResponse<TResource> {\n constructor(\n public readonly resources: TResource[],\n private readonly headers: CosmosHeaders,\n public readonly hasMoreResults: boolean,\n public readonly diagnostics: CosmosDiagnostics,\n ) {}\n\n public get continuation(): string {\n return this.continuationToken;\n }\n public get continuationToken(): string {\n return this.headers[Constants.HttpHeaders.Continuation];\n }\n public get queryMetrics(): string {\n return this.headers[Constants.HttpHeaders.QueryMetrics];\n }\n public get requestCharge(): number {\n return getRequestChargeIfAny(this.headers);\n }\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n public get indexMetrics(): string {\n const writer = new IndexMetricWriter();\n const indexUtilizationInfo = IndexUtilizationInfo.createFromString(\n this.headers[Constants.HttpHeaders.IndexUtilization],\n true,\n );\n return writer.writeIndexMetrics(indexUtilizationInfo);\n }\n}\n"]}
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface QueryOperationOptions {
|
||||
/**
|
||||
* Request Units(RU) Cap for a given request. Default: Undefined
|
||||
*/
|
||||
ruCapPerOperation?: number;
|
||||
}
|
||||
//# sourceMappingURL=OperationOptions.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OperationOptions.d.ts","sourceRoot":"","sources":["../../../src/request/OperationOptions.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=OperationOptions.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OperationOptions.js","sourceRoot":"","sources":["../../../src/request/OperationOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface QueryOperationOptions {\n /**\n * Request Units(RU) Cap for a given request. Default: Undefined\n */\n ruCapPerOperation?: number;\n}\n"]}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { ErrorResponse } from "./ErrorResponse";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare const RUCapPerOperationExceededErrorCode = "OPERATION_RU_LIMIT_EXCEEDED";
|
||||
export declare class RUCapPerOperationExceededError extends ErrorResponse {
|
||||
readonly code: string;
|
||||
fetchedResults: any[];
|
||||
constructor(message?: string, fetchedResults?: any[]);
|
||||
}
|
||||
//# sourceMappingURL=RUCapPerOperationExceededError.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RUCapPerOperationExceededError.d.ts","sourceRoot":"","sources":["../../../src/request/RUCapPerOperationExceededError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD;;GAEG;AACH,eAAO,MAAM,kCAAkC,gCAAgC,CAAC;AAEhF,qBAAa,8BAA+B,SAAQ,aAAa;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAsC;IACpD,cAAc,EAAE,GAAG,EAAE,CAAC;gBAE3B,OAAO,GAAE,MAAyD,EAClE,cAAc,GAAE,GAAG,EAAO;CAU7B"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { ErrorResponse } from "./ErrorResponse";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export const RUCapPerOperationExceededErrorCode = "OPERATION_RU_LIMIT_EXCEEDED";
|
||||
export class RUCapPerOperationExceededError extends ErrorResponse {
|
||||
constructor(message = "Request Unit limit per Operation call exceeded", fetchedResults = []) {
|
||||
super(message);
|
||||
this.code = RUCapPerOperationExceededErrorCode;
|
||||
this.code = RUCapPerOperationExceededErrorCode;
|
||||
this.body = {
|
||||
code: RUCapPerOperationExceededErrorCode,
|
||||
message,
|
||||
};
|
||||
this.fetchedResults = fetchedResults;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=RUCapPerOperationExceededError.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RUCapPerOperationExceededError.js","sourceRoot":"","sources":["../../../src/request/RUCapPerOperationExceededError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAA6B,CAAC;AAEhF,MAAM,OAAO,8BAA+B,SAAQ,aAAa;IAG/D,YACE,UAAkB,gDAAgD,EAClE,iBAAwB,EAAE;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QANR,SAAI,GAAW,kCAAkC,CAAC;QAOzD,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG;YACV,IAAI,EAAE,kCAAkC;YACxC,OAAO;SACR,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ErrorResponse } from \"./ErrorResponse\";\n/**\n * @hidden\n */\nexport const RUCapPerOperationExceededErrorCode = \"OPERATION_RU_LIMIT_EXCEEDED\";\n\nexport class RUCapPerOperationExceededError extends ErrorResponse {\n readonly code: string = RUCapPerOperationExceededErrorCode;\n public fetchedResults: any[];\n constructor(\n message: string = \"Request Unit limit per Operation call exceeded\",\n fetchedResults: any[] = [],\n ) {\n super(message);\n this.code = RUCapPerOperationExceededErrorCode;\n this.body = {\n code: RUCapPerOperationExceededErrorCode,\n message,\n };\n this.fetchedResults = fetchedResults;\n }\n}\n"]}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { ClientContext } from "../ClientContext";
|
||||
import { HTTPMethod, OperationType, ResourceType } from "../common";
|
||||
import { Agent } from "../CosmosClientOptions";
|
||||
import { ConnectionPolicy, PartitionKey } from "../documents";
|
||||
import { GlobalEndpointManager } from "../globalEndpointManager";
|
||||
import { PluginConfig } from "../plugins/Plugin";
|
||||
import { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders";
|
||||
import { FeedOptions } from "./FeedOptions";
|
||||
import { RequestOptions } from "./RequestOptions";
|
||||
import { Pipeline } from "@azure/core-rest-pipeline";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface RequestContext {
|
||||
path?: string;
|
||||
operationType?: OperationType;
|
||||
client?: ClientContext;
|
||||
retryCount?: number;
|
||||
resourceType?: ResourceType;
|
||||
resourceId?: string;
|
||||
globalEndpointManager: GlobalEndpointManager;
|
||||
connectionPolicy: ConnectionPolicy;
|
||||
requestAgent: Agent;
|
||||
body?: any;
|
||||
headers?: CosmosHeaders;
|
||||
endpoint?: string;
|
||||
method: HTTPMethod;
|
||||
partitionKeyRangeId?: string;
|
||||
options: FeedOptions | RequestOptions;
|
||||
plugins: PluginConfig[];
|
||||
partitionKey?: PartitionKey;
|
||||
pipeline?: Pipeline;
|
||||
}
|
||||
//# sourceMappingURL=RequestContext.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestContext.d.ts","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,KAAK,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IACtC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=RequestContext.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestContext.js","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { HTTPMethod, OperationType, ResourceType } from \"../common\";\nimport { Agent } from \"../CosmosClientOptions\";\nimport { ConnectionPolicy, PartitionKey } from \"../documents\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { PluginConfig } from \"../plugins/Plugin\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { FeedOptions } from \"./FeedOptions\";\nimport { RequestOptions } from \"./RequestOptions\";\nimport { Pipeline } from \"@azure/core-rest-pipeline\";\n\n/**\n * @hidden\n */\nexport interface RequestContext {\n path?: string;\n operationType?: OperationType;\n client?: ClientContext;\n retryCount?: number;\n resourceType?: ResourceType;\n resourceId?: string;\n globalEndpointManager: GlobalEndpointManager;\n connectionPolicy: ConnectionPolicy;\n requestAgent: Agent;\n body?: any;\n headers?: CosmosHeaders;\n endpoint?: string;\n method: HTTPMethod;\n partitionKeyRangeId?: string;\n options: FeedOptions | RequestOptions;\n plugins: PluginConfig[];\n partitionKey?: PartitionKey;\n pipeline?: Pipeline;\n}\n"]}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { RequestContext } from "./RequestContext";
|
||||
import { Response as CosmosResponse } from "./Response";
|
||||
import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
declare function request<T>(requestContext: RequestContext, diagnosticNode: DiagnosticNodeInternal): Promise<CosmosResponse<T>>;
|
||||
export declare const RequestHandler: {
|
||||
request: typeof request;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=RequestHandler.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestHandler.d.ts","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AA0JnG;;GAEG;AACH,iBAAe,OAAO,CAAC,CAAC,EACtB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAmB5B;AAED,eAAO,MAAM,cAAc;;CAE1B,CAAC"}
|
||||
@@ -0,0 +1,150 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { AbortController } from "node-abort-controller";
|
||||
import { createPipelineRequest, createHttpHeaders, } from "@azure/core-rest-pipeline";
|
||||
import { prepareURL } from "../common";
|
||||
import { Constants } from "../common/constants";
|
||||
import { executePlugins, PluginOn } from "../plugins/Plugin";
|
||||
import * as RetryUtility from "../retry/retryUtility";
|
||||
import { defaultHttpAgent, defaultHttpsAgent } from "./defaultAgent";
|
||||
import { ErrorResponse } from "./ErrorResponse";
|
||||
import { bodyFromData } from "./request";
|
||||
import { TimeoutError } from "./TimeoutError";
|
||||
import { getCachedDefaultHttpClient } from "../utils/cachedClient";
|
||||
import { createClientLogger } from "@azure/logger";
|
||||
import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal";
|
||||
import { addDignosticChild } from "../utils/diagnostics";
|
||||
import { getCurrentTimestampInMs } from "../utils/time";
|
||||
const logger = createClientLogger("RequestHandler");
|
||||
async function executeRequest(diagnosticNode, requestContext) {
|
||||
return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request);
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
async function httpRequest(requestContext, diagnosticNode) {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
// Wrap users passed abort events and call our own internal abort()
|
||||
const userSignal = requestContext.options && requestContext.options.abortSignal;
|
||||
if (userSignal) {
|
||||
if (userSignal.aborted) {
|
||||
controller.abort();
|
||||
}
|
||||
else {
|
||||
userSignal.addEventListener("abort", () => {
|
||||
controller.abort();
|
||||
});
|
||||
}
|
||||
}
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
}, requestContext.connectionPolicy.requestTimeout);
|
||||
let response;
|
||||
if (requestContext.body) {
|
||||
requestContext.body = bodyFromData(requestContext.body);
|
||||
}
|
||||
const httpsClient = getCachedDefaultHttpClient();
|
||||
const url = prepareURL(requestContext.endpoint, requestContext.path);
|
||||
const reqHeaders = createHttpHeaders(requestContext.headers);
|
||||
const pipelineRequest = createPipelineRequest({
|
||||
url,
|
||||
headers: reqHeaders,
|
||||
method: requestContext.method,
|
||||
abortSignal: signal,
|
||||
body: requestContext.body,
|
||||
});
|
||||
if (requestContext.requestAgent) {
|
||||
pipelineRequest.agent = requestContext.requestAgent;
|
||||
}
|
||||
else {
|
||||
const parsedUrl = new URL(url);
|
||||
pipelineRequest.agent = parsedUrl.protocol === "http" ? defaultHttpAgent : defaultHttpsAgent;
|
||||
}
|
||||
const startTimeUTCInMs = getCurrentTimestampInMs();
|
||||
try {
|
||||
if (requestContext.pipeline) {
|
||||
response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest);
|
||||
}
|
||||
else {
|
||||
response = await httpsClient.sendRequest(pipelineRequest);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (error.name === "AbortError") {
|
||||
// If the user passed signal caused the abort, cancel the timeout and rethrow the error
|
||||
if (userSignal && userSignal.aborted === true) {
|
||||
clearTimeout(timeout);
|
||||
throw error;
|
||||
}
|
||||
// If the user didn't cancel, it must be an abort we called due to timeout
|
||||
throw new TimeoutError(`Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
clearTimeout(timeout);
|
||||
const result = response.status === 204 || response.status === 304 || response.bodyAsText === ""
|
||||
? null
|
||||
: JSON.parse(response.bodyAsText);
|
||||
const responseHeaders = response.headers.toJSON();
|
||||
const substatus = responseHeaders[Constants.HttpHeaders.SubStatus]
|
||||
? parseInt(responseHeaders[Constants.HttpHeaders.SubStatus], 10)
|
||||
: undefined;
|
||||
diagnosticNode.recordSuccessfulNetworkCall(startTimeUTCInMs, requestContext, response, substatus, url);
|
||||
if (response.status >= 400) {
|
||||
const errorResponse = new ErrorResponse(result.message);
|
||||
logger.warning(response.status +
|
||||
" " +
|
||||
requestContext.endpoint +
|
||||
" " +
|
||||
requestContext.path +
|
||||
" " +
|
||||
result.message);
|
||||
errorResponse.code = response.status;
|
||||
errorResponse.body = result;
|
||||
errorResponse.headers = responseHeaders;
|
||||
if (Constants.HttpHeaders.ActivityId in responseHeaders) {
|
||||
errorResponse.activityId = responseHeaders[Constants.HttpHeaders.ActivityId];
|
||||
}
|
||||
if (Constants.HttpHeaders.SubStatus in responseHeaders) {
|
||||
errorResponse.substatus = substatus;
|
||||
}
|
||||
if (Constants.HttpHeaders.RetryAfterInMs in responseHeaders) {
|
||||
errorResponse.retryAfterInMs = parseInt(responseHeaders[Constants.HttpHeaders.RetryAfterInMs], 10);
|
||||
Object.defineProperty(errorResponse, "retryAfterInMilliseconds", {
|
||||
get: () => {
|
||||
return errorResponse.retryAfterInMs;
|
||||
},
|
||||
});
|
||||
}
|
||||
throw errorResponse;
|
||||
}
|
||||
return {
|
||||
headers: responseHeaders,
|
||||
result,
|
||||
code: response.status,
|
||||
substatus,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
async function request(requestContext, diagnosticNode) {
|
||||
if (requestContext.body) {
|
||||
requestContext.body = bodyFromData(requestContext.body);
|
||||
if (!requestContext.body) {
|
||||
throw new Error("parameter data must be a javascript object, string, or Buffer");
|
||||
}
|
||||
}
|
||||
return addDignosticChild(async (childNode) => {
|
||||
return RetryUtility.execute({
|
||||
diagnosticNode: childNode,
|
||||
requestContext,
|
||||
executeRequest,
|
||||
});
|
||||
}, diagnosticNode, DiagnosticNodeType.REQUEST_ATTEMPTS);
|
||||
}
|
||||
export const RequestHandler = {
|
||||
request,
|
||||
};
|
||||
//# sourceMappingURL=RequestHandler.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,45 @@
|
||||
import { SharedOptions } from "..";
|
||||
/**
|
||||
* Options that can be specified for a requested issued to the Azure Cosmos DB servers.=
|
||||
*/
|
||||
export interface RequestOptions extends SharedOptions {
|
||||
/** Conditions Associated with the request. */
|
||||
accessCondition?: {
|
||||
/** Conditional HTTP method header type (IfMatch or IfNoneMatch). */
|
||||
type: string;
|
||||
/** Conditional HTTP method header value (the _etag field from the last version you read). */
|
||||
condition: string;
|
||||
};
|
||||
/** Consistency level required by the client. */
|
||||
consistencyLevel?: string;
|
||||
/**
|
||||
* DisableRUPerMinuteUsage is used to enable/disable Request Units(RUs)/minute capacity
|
||||
* to serve the request if regular provisioned RUs/second is exhausted.
|
||||
*/
|
||||
disableRUPerMinuteUsage?: boolean;
|
||||
/** Enables or disables logging in JavaScript stored procedures. */
|
||||
enableScriptLogging?: boolean;
|
||||
/** Specifies indexing directives (index, do not index .. etc). */
|
||||
indexingDirective?: string;
|
||||
/** The offer throughput provisioned for a container in measurement of Requests-per-Unit. */
|
||||
offerThroughput?: number;
|
||||
/**
|
||||
* Offer type when creating document containers.
|
||||
*
|
||||
* This option is only valid when creating a document container.
|
||||
*/
|
||||
offerType?: string;
|
||||
/** Enables/disables getting document container quota related stats for document container read requests. */
|
||||
populateQuotaInfo?: boolean;
|
||||
/** Indicates what is the post trigger to be invoked after the operation. */
|
||||
postTriggerInclude?: string | string[];
|
||||
/** Indicates what is the pre trigger to be invoked before the operation. */
|
||||
preTriggerInclude?: string | string[];
|
||||
/** Expiry time (in seconds) for resource token associated with permission (applicable only for requests on permissions). */
|
||||
resourceTokenExpirySeconds?: number;
|
||||
/** (Advanced use case) The url to connect to. */
|
||||
urlConnection?: string;
|
||||
/** Disable automatic id generation (will cause creates to fail if id isn't on the definition) */
|
||||
disableAutomaticIdGeneration?: boolean;
|
||||
}
|
||||
//# sourceMappingURL=RequestOptions.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestOptions.d.ts","sourceRoot":"","sources":["../../../src/request/RequestOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,8CAA8C;IAC9C,eAAe,CAAC,EAAE;QAChB,oEAAoE;QACpE,IAAI,EAAE,MAAM,CAAC;QACb,6FAA6F;QAC7F,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mEAAmE;IACnE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4FAA4F;IAC5F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4GAA4G;IAC5G,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4EAA4E;IAC5E,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvC,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtC,4HAA4H;IAC5H,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iGAAiG;IACjG,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=RequestOptions.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestOptions.js","sourceRoot":"","sources":["../../../src/request/RequestOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { SharedOptions } from \"..\";\n\n/**\n * Options that can be specified for a requested issued to the Azure Cosmos DB servers.=\n */\nexport interface RequestOptions extends SharedOptions {\n /** Conditions Associated with the request. */\n accessCondition?: {\n /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */\n type: string;\n /** Conditional HTTP method header value (the _etag field from the last version you read). */\n condition: string;\n };\n /** Consistency level required by the client. */\n consistencyLevel?: string;\n /**\n * DisableRUPerMinuteUsage is used to enable/disable Request Units(RUs)/minute capacity\n * to serve the request if regular provisioned RUs/second is exhausted.\n */\n disableRUPerMinuteUsage?: boolean;\n /** Enables or disables logging in JavaScript stored procedures. */\n enableScriptLogging?: boolean;\n /** Specifies indexing directives (index, do not index .. etc). */\n indexingDirective?: string;\n /** The offer throughput provisioned for a container in measurement of Requests-per-Unit. */\n offerThroughput?: number;\n /**\n * Offer type when creating document containers.\n *\n * This option is only valid when creating a document container.\n */\n offerType?: string;\n /** Enables/disables getting document container quota related stats for document container read requests. */\n populateQuotaInfo?: boolean;\n /** Indicates what is the post trigger to be invoked after the operation. */\n postTriggerInclude?: string | string[];\n /** Indicates what is the pre trigger to be invoked before the operation. */\n preTriggerInclude?: string | string[];\n /** Expiry time (in seconds) for resource token associated with permission (applicable only for requests on permissions). */\n resourceTokenExpirySeconds?: number;\n /** (Advanced use case) The url to connect to. */\n urlConnection?: string;\n /** Disable automatic id generation (will cause creates to fail if id isn't on the definition) */\n disableAutomaticIdGeneration?: boolean;\n}\n"]}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { CosmosDiagnostics } from "../CosmosDiagnostics";
|
||||
import { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders";
|
||||
import { StatusCode, SubStatusCode } from "./StatusCodes";
|
||||
export declare class ResourceResponse<TResource> {
|
||||
readonly resource: TResource | undefined;
|
||||
readonly headers: CosmosHeaders;
|
||||
readonly statusCode: StatusCode;
|
||||
readonly diagnostics: CosmosDiagnostics;
|
||||
readonly substatus?: SubStatusCode;
|
||||
constructor(resource: TResource | undefined, headers: CosmosHeaders, statusCode: StatusCode, diagnostics: CosmosDiagnostics, substatus?: SubStatusCode);
|
||||
get requestCharge(): number;
|
||||
get activityId(): string;
|
||||
get etag(): string;
|
||||
}
|
||||
//# sourceMappingURL=ResourceResponse.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ResourceResponse.d.ts","sourceRoot":"","sources":["../../../src/request/ResourceResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1D,qBAAa,gBAAgB,CAAC,SAAS;aAEnB,QAAQ,EAAE,SAAS,GAAG,SAAS;aAC/B,OAAO,EAAE,aAAa;aACtB,UAAU,EAAE,UAAU;aACtB,WAAW,EAAE,iBAAiB;aAC9B,SAAS,CAAC,EAAE,aAAa;gBAJzB,QAAQ,EAAE,SAAS,GAAG,SAAS,EAC/B,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,aAAa;IAE3C,IAAW,aAAa,IAAI,MAAM,CAEjC;IACD,IAAW,UAAU,IAAI,MAAM,CAE9B;IACD,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Constants } from "../common";
|
||||
export class ResourceResponse {
|
||||
constructor(resource, headers, statusCode, diagnostics, substatus) {
|
||||
this.resource = resource;
|
||||
this.headers = headers;
|
||||
this.statusCode = statusCode;
|
||||
this.diagnostics = diagnostics;
|
||||
this.substatus = substatus;
|
||||
}
|
||||
get requestCharge() {
|
||||
return Number(this.headers[Constants.HttpHeaders.RequestCharge]) || 0;
|
||||
}
|
||||
get activityId() {
|
||||
return this.headers[Constants.HttpHeaders.ActivityId];
|
||||
}
|
||||
get etag() {
|
||||
return this.headers[Constants.HttpHeaders.ETag];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ResourceResponse.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ResourceResponse.js","sourceRoot":"","sources":["../../../src/request/ResourceResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,OAAO,gBAAgB;IAC3B,YACkB,QAA+B,EAC/B,OAAsB,EACtB,UAAsB,EACtB,WAA8B,EAC9B,SAAyB;QAJzB,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,YAAO,GAAP,OAAO,CAAe;QACtB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAmB;QAC9B,cAAS,GAAT,SAAS,CAAgB;IACxC,CAAC;IACJ,IAAW,aAAa;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC;IACD,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAW,CAAC;IAClE,CAAC;IACD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAW,CAAC;IAC5D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\nimport { Constants } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { StatusCode, SubStatusCode } from \"./StatusCodes\";\n\nexport class ResourceResponse<TResource> {\n constructor(\n public readonly resource: TResource | undefined,\n public readonly headers: CosmosHeaders,\n public readonly statusCode: StatusCode,\n public readonly diagnostics: CosmosDiagnostics,\n public readonly substatus?: SubStatusCode,\n ) {}\n public get requestCharge(): number {\n return Number(this.headers[Constants.HttpHeaders.RequestCharge]) || 0;\n }\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId] as string;\n }\n public get etag(): string {\n return this.headers[Constants.HttpHeaders.ETag] as string;\n }\n}\n"]}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { CosmosDiagnostics, CosmosHeaders } from "../index";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface Response<T> {
|
||||
headers: CosmosHeaders;
|
||||
result?: T;
|
||||
code?: number;
|
||||
substatus?: number;
|
||||
diagnostics?: CosmosDiagnostics;
|
||||
}
|
||||
//# sourceMappingURL=Response.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../src/request/Response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=Response.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../src/request/Response.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics, CosmosHeaders } from \"../index\";\n\n/**\n * @hidden\n */\nexport interface Response<T> {\n headers: CosmosHeaders;\n result?: T;\n code?: number;\n substatus?: number;\n diagnostics?: CosmosDiagnostics;\n}\n"]}
|
||||
@@ -0,0 +1,42 @@
|
||||
/// <reference lib="dom" />
|
||||
import { PriorityLevel } from "../documents/PriorityLevel";
|
||||
import { CosmosHeaders } from "../index";
|
||||
import { AbortSignal } from "node-abort-controller";
|
||||
/**
|
||||
* Options that can be specified for a requested issued to the Azure Cosmos DB servers.=
|
||||
*/
|
||||
export interface SharedOptions {
|
||||
/** Enables/disables getting document container quota related stats for document container read requests. */
|
||||
sessionToken?: string;
|
||||
/** (Advanced use case) Initial headers to start with when sending requests to Cosmos */
|
||||
initialHeaders?: CosmosHeaders;
|
||||
/**
|
||||
* abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
||||
* @example Cancel a read request
|
||||
* ```typescript
|
||||
* const controller = new AbortController()
|
||||
* const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal});
|
||||
* controller.abort()
|
||||
* ```
|
||||
*/
|
||||
abortSignal?: AbortSignal;
|
||||
/**
|
||||
* Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link
|
||||
* com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the
|
||||
* integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the
|
||||
* consistency level is not set, this property is ignored.
|
||||
*
|
||||
* <p>Default value is null</p>
|
||||
*
|
||||
* <p>Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.</p>
|
||||
*/
|
||||
maxIntegratedCacheStalenessInMs?: number;
|
||||
/**
|
||||
* Priority Level (Low/High) for each request.
|
||||
* Low priority requests are always throttled before any high priority requests.
|
||||
*
|
||||
* <p>Default value is null. By default all requests are of High priority</p>
|
||||
*/
|
||||
priorityLevel?: PriorityLevel;
|
||||
}
|
||||
//# sourceMappingURL=SharedOptions.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../../src/request/SharedOptions.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4GAA4G;IAC5G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;OASG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC;IAEzC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=SharedOptions.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../../src/request/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/// <reference lib=\"dom\" />\nimport { PriorityLevel } from \"../documents/PriorityLevel\";\nimport { CosmosHeaders } from \"../index\";\nimport { AbortSignal } from \"node-abort-controller\";\n\n/**\n * Options that can be specified for a requested issued to the Azure Cosmos DB servers.=\n */\nexport interface SharedOptions {\n /** Enables/disables getting document container quota related stats for document container read requests. */\n sessionToken?: string;\n /** (Advanced use case) Initial headers to start with when sending requests to Cosmos */\n initialHeaders?: CosmosHeaders;\n /**\n * abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController\n * @example Cancel a read request\n * ```typescript\n * const controller = new AbortController()\n * const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal});\n * controller.abort()\n * ```\n */\n abortSignal?: AbortSignal;\n /**\n * Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link\n * com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the\n * integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the\n * consistency level is not set, this property is ignored.\n *\n * <p>Default value is null</p>\n *\n * <p>Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.</p>\n */\n maxIntegratedCacheStalenessInMs?: number;\n\n /**\n * Priority Level (Low/High) for each request.\n * Low priority requests are always throttled before any high priority requests.\n *\n * <p>Default value is null. By default all requests are of High priority</p>\n */\n priorityLevel?: PriorityLevel;\n}\n"]}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export type StatusCode = number;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export type SubStatusCode = number;
|
||||
//# sourceMappingURL=StatusCodes.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"StatusCodes.d.ts","sourceRoot":"","sources":["../../../src/request/StatusCodes.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC"}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=StatusCodes.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"StatusCodes.js","sourceRoot":"","sources":["../../../src/request/StatusCodes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n */\nexport type StatusCode = number;\n/**\n * @hidden\n */\nexport type SubStatusCode = number;\n"]}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare const TimeoutErrorCode = "TimeoutError";
|
||||
export declare class TimeoutError extends Error {
|
||||
readonly code: string;
|
||||
constructor(message?: string);
|
||||
}
|
||||
//# sourceMappingURL=TimeoutError.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TimeoutError.d.ts","sourceRoot":"","sources":["../../../src/request/TimeoutError.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAoB;gBACpC,OAAO,GAAE,MAAwB;CAI9C"}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export const TimeoutErrorCode = "TimeoutError";
|
||||
export class TimeoutError extends Error {
|
||||
constructor(message = "Timeout Error") {
|
||||
super(message);
|
||||
this.code = TimeoutErrorCode;
|
||||
this.name = TimeoutErrorCode;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TimeoutError.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../../src/request/TimeoutError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,OAAO,YAAa,SAAQ,KAAK;IAErC,YAAY,UAAkB,eAAe;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QAFD,SAAI,GAAW,gBAAgB,CAAC;QAG9C,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * @hidden\n */\nexport const TimeoutErrorCode = \"TimeoutError\";\n\nexport class TimeoutError extends Error {\n public readonly code: string = TimeoutErrorCode;\n constructor(message: string = \"Timeout Error\") {\n super(message);\n this.name = TimeoutErrorCode;\n }\n}\n"]}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import { Agent } from "http";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare let defaultHttpAgent: Agent;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare let defaultHttpsAgent: Agent;
|
||||
//# sourceMappingURL=defaultAgent.browser.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultAgent.browser.d.ts","sourceRoot":"","sources":["../../../src/request/defaultAgent.browser.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B;;GAEG;AACH,eAAO,IAAI,gBAAgB,EAAE,KAAK,CAAC;AACnC;;GAEG;AACH,eAAO,IAAI,iBAAiB,EAAE,KAAK,CAAC"}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export let defaultHttpAgent;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export let defaultHttpsAgent;
|
||||
//# sourceMappingURL=defaultAgent.browser.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultAgent.browser.js","sourceRoot":"","sources":["../../../src/request/defaultAgent.browser.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,IAAI,gBAAuB,CAAC;AACnC;;GAEG;AACH,MAAM,CAAC,IAAI,iBAAwB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Agent } from \"http\";\n/**\n * @hidden\n */\nexport let defaultHttpAgent: Agent;\n/**\n * @hidden\n */\nexport let defaultHttpsAgent: Agent;\n"]}
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
import { Agent } from "http";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare let defaultHttpsAgent: Agent;
|
||||
//# sourceMappingURL=defaultAgent.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultAgent.d.ts","sourceRoot":"","sources":["../../../src/request/defaultAgent.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B;;GAEG;AACH,eAAO,IAAI,iBAAiB,EAAE,KAAK,CAAC"}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export let defaultHttpsAgent;
|
||||
const https = require("https"); // eslint-disable-line @typescript-eslint/no-require-imports
|
||||
const tls = require("tls"); // eslint-disable-line @typescript-eslint/no-require-imports
|
||||
// minVersion only available in Node 10+
|
||||
if (tls.DEFAULT_MIN_VERSION) {
|
||||
defaultHttpsAgent = new https.Agent({
|
||||
keepAlive: true,
|
||||
minVersion: "TLSv1.2",
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Remove when Node 8 support has been dropped
|
||||
defaultHttpsAgent = new https.Agent({
|
||||
keepAlive: true,
|
||||
secureProtocol: "TLSv1_2_method",
|
||||
});
|
||||
}
|
||||
const http = require("http"); // eslint-disable-line @typescript-eslint/no-require-imports
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const defaultHttpAgent = new http.Agent({
|
||||
keepAlive: true,
|
||||
});
|
||||
//# sourceMappingURL=defaultAgent.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultAgent.js","sourceRoot":"","sources":["../../../src/request/defaultAgent.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,IAAI,iBAAwB,CAAC;AAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,4DAA4D;AAC5F,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,4DAA4D;AAExF,wCAAwC;AACxC,IAAI,GAAG,CAAC,mBAAmB,EAAE;IAC3B,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,SAAS;KACtB,CAAC,CAAC;CACJ;KAAM;IACL,8CAA8C;IAC9C,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,IAAI;QACf,cAAc,EAAE,gBAAgB;KACjC,CAAC,CAAC;CACJ;AACD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,4DAA4D;AAC1F;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAU,IAAI,IAAI,CAAC,KAAK,CAAC;IACpD,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Agent } from \"http\";\n\n/**\n * @hidden\n */\nexport let defaultHttpsAgent: Agent;\n\nconst https = require(\"https\"); // eslint-disable-line @typescript-eslint/no-require-imports\nconst tls = require(\"tls\"); // eslint-disable-line @typescript-eslint/no-require-imports\n\n// minVersion only available in Node 10+\nif (tls.DEFAULT_MIN_VERSION) {\n defaultHttpsAgent = new https.Agent({\n keepAlive: true,\n minVersion: \"TLSv1.2\",\n });\n} else {\n // Remove when Node 8 support has been dropped\n defaultHttpsAgent = new https.Agent({\n keepAlive: true,\n secureProtocol: \"TLSv1_2_method\",\n });\n}\nconst http = require(\"http\"); // eslint-disable-line @typescript-eslint/no-require-imports\n/**\n * @internal\n */\nexport const defaultHttpAgent: Agent = new http.Agent({\n keepAlive: true,\n});\n"]}
|
||||
@@ -0,0 +1,13 @@
|
||||
export { ErrorResponse, ErrorBody, PartitionedQueryExecutionInfo, QueryInfo, QueryRange, AggregateType, GroupByExpressions, GroupByAliasToAggregateType, } from "./ErrorResponse";
|
||||
export { FeedOptions } from "./FeedOptions";
|
||||
export { RequestOptions } from "./RequestOptions";
|
||||
export { Response } from "./Response";
|
||||
export { ResourceResponse } from "./ResourceResponse";
|
||||
export { SharedOptions } from "./SharedOptions";
|
||||
export { StatusCode, SubStatusCode } from "./StatusCodes";
|
||||
export { FeedResponse } from "./FeedResponse";
|
||||
export { RequestContext } from "./RequestContext";
|
||||
export { TimeoutError } from "./TimeoutError";
|
||||
export { QueryOperationOptions } from "./OperationOptions";
|
||||
export { RUCapPerOperationExceededError } from "./RUCapPerOperationExceededError";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,SAAS,EACT,6BAA6B,EAC7B,SAAS,EACT,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC"}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export { ErrorResponse, } from "./ErrorResponse";
|
||||
export { ResourceResponse } from "./ResourceResponse";
|
||||
export { FeedResponse } from "./FeedResponse";
|
||||
export { TimeoutError } from "./TimeoutError";
|
||||
export { RUCapPerOperationExceededError } from "./RUCapPerOperationExceededError";
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/request/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EACL,aAAa,GAQd,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport {\n ErrorResponse,\n ErrorBody,\n PartitionedQueryExecutionInfo,\n QueryInfo,\n QueryRange,\n AggregateType,\n GroupByExpressions,\n GroupByAliasToAggregateType,\n} from \"./ErrorResponse\";\nexport { FeedOptions } from \"./FeedOptions\";\nexport { RequestOptions } from \"./RequestOptions\";\nexport { Response } from \"./Response\";\nexport { ResourceResponse } from \"./ResourceResponse\";\nexport { SharedOptions } from \"./SharedOptions\";\nexport { StatusCode, SubStatusCode } from \"./StatusCodes\";\nexport { FeedResponse } from \"./FeedResponse\";\nexport { RequestContext } from \"./RequestContext\";\nexport { TimeoutError } from \"./TimeoutError\";\nexport { QueryOperationOptions } from \"./OperationOptions\";\nexport { RUCapPerOperationExceededError } from \"./RUCapPerOperationExceededError\";\n"]}
|
||||
@@ -0,0 +1,29 @@
|
||||
/// <reference types="node" />
|
||||
import { HTTPMethod, ResourceType } from "../common";
|
||||
import { CosmosClientOptions } from "../CosmosClientOptions";
|
||||
import { PartitionKeyInternal } from "../documents";
|
||||
import { CosmosHeaders } from "../queryExecutionContext";
|
||||
import { FeedOptions, RequestOptions } from "./index";
|
||||
/** @hidden */
|
||||
export declare function bodyFromData(data: Buffer | string | Record<string, unknown>): string;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
interface GetHeadersOptions {
|
||||
clientOptions: CosmosClientOptions;
|
||||
defaultHeaders: CosmosHeaders;
|
||||
verb: HTTPMethod;
|
||||
path: string;
|
||||
resourceId: string;
|
||||
resourceType: ResourceType;
|
||||
options: RequestOptions & FeedOptions;
|
||||
partitionKeyRangeId?: string;
|
||||
useMultipleWriteLocations?: boolean;
|
||||
partitionKey?: PartitionKeyInternal;
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare function getHeaders({ clientOptions, defaultHeaders, verb, path, resourceId, resourceType, options, partitionKeyRangeId, useMultipleWriteLocations, partitionKey, }: GetHeadersOptions): Promise<CosmosHeaders>;
|
||||
export {};
|
||||
//# sourceMappingURL=request.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/request/request.ts"],"names":[],"mappings":";AAGA,OAAO,EAAa,UAAU,EAAkC,YAAY,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAetD,cAAc;AACd,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKpF;AAED;;GAEG;AACH,UAAU,iBAAiB;IACzB,aAAa,EAAE,mBAAmB,CAAC;IACnC,cAAc,EAAE,aAAa,CAAC;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,cAAc,GAAG,WAAW,CAAC;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAID;;GAEG;AACH,wBAAsB,UAAU,CAAC,EAC/B,aAAa,EACb,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,OAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CA0J5C"}
|
||||
@@ -0,0 +1,149 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { setAuthorizationHeader } from "../auth";
|
||||
import { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from "../common";
|
||||
import { defaultLogger } from "../common/logger";
|
||||
// ----------------------------------------------------------------------------
|
||||
// Utility methods
|
||||
//
|
||||
/** @hidden */
|
||||
function javaScriptFriendlyJSONStringify(s) {
|
||||
// two line terminators (Line separator and Paragraph separator) are not needed to be escaped in JSON
|
||||
// but are needed to be escaped in JavaScript.
|
||||
return JSON.stringify(s)
|
||||
.replace(/\u2028/g, "\\u2028")
|
||||
.replace(/\u2029/g, "\\u2029");
|
||||
}
|
||||
/** @hidden */
|
||||
export function bodyFromData(data) {
|
||||
if (typeof data === "object") {
|
||||
return javaScriptFriendlyJSONStringify(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
const JsonContentType = "application/json";
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export async function getHeaders({ clientOptions, defaultHeaders, verb, path, resourceId, resourceType, options = {}, partitionKeyRangeId, useMultipleWriteLocations, partitionKey, }) {
|
||||
const headers = Object.assign({ [Constants.HttpHeaders.ResponseContinuationTokenLimitInKB]: 1, [Constants.HttpHeaders.EnableCrossPartitionQuery]: true }, defaultHeaders);
|
||||
if (useMultipleWriteLocations) {
|
||||
headers[Constants.HttpHeaders.ALLOW_MULTIPLE_WRITES] = true;
|
||||
}
|
||||
if (options.continuationTokenLimitInKB) {
|
||||
headers[Constants.HttpHeaders.ResponseContinuationTokenLimitInKB] =
|
||||
options.continuationTokenLimitInKB;
|
||||
}
|
||||
if (options.continuationToken) {
|
||||
headers[Constants.HttpHeaders.Continuation] = options.continuationToken;
|
||||
}
|
||||
else if (options.continuation) {
|
||||
headers[Constants.HttpHeaders.Continuation] = options.continuation;
|
||||
}
|
||||
if (options.preTriggerInclude) {
|
||||
headers[Constants.HttpHeaders.PreTriggerInclude] =
|
||||
options.preTriggerInclude.constructor === Array
|
||||
? options.preTriggerInclude.join(",")
|
||||
: options.preTriggerInclude;
|
||||
}
|
||||
if (options.postTriggerInclude) {
|
||||
headers[Constants.HttpHeaders.PostTriggerInclude] =
|
||||
options.postTriggerInclude.constructor === Array
|
||||
? options.postTriggerInclude.join(",")
|
||||
: options.postTriggerInclude;
|
||||
}
|
||||
if (options.offerType) {
|
||||
headers[Constants.HttpHeaders.OfferType] = options.offerType;
|
||||
}
|
||||
if (options.offerThroughput) {
|
||||
headers[Constants.HttpHeaders.OfferThroughput] = options.offerThroughput;
|
||||
}
|
||||
if (options.maxItemCount) {
|
||||
headers[Constants.HttpHeaders.PageSize] = options.maxItemCount;
|
||||
}
|
||||
if (options.accessCondition) {
|
||||
if (options.accessCondition.type === "IfMatch") {
|
||||
headers[Constants.HttpHeaders.IfMatch] = options.accessCondition.condition;
|
||||
}
|
||||
else {
|
||||
headers[Constants.HttpHeaders.IfNoneMatch] = options.accessCondition.condition;
|
||||
}
|
||||
}
|
||||
if (options.useIncrementalFeed) {
|
||||
headers[Constants.HttpHeaders.A_IM] = "Incremental Feed";
|
||||
}
|
||||
if (options.indexingDirective) {
|
||||
headers[Constants.HttpHeaders.IndexingDirective] = options.indexingDirective;
|
||||
}
|
||||
if (options.consistencyLevel) {
|
||||
headers[Constants.HttpHeaders.ConsistencyLevel] = options.consistencyLevel;
|
||||
}
|
||||
if (options.priorityLevel) {
|
||||
headers[Constants.HttpHeaders.PriorityLevel] = options.priorityLevel;
|
||||
}
|
||||
if (options.maxIntegratedCacheStalenessInMs && resourceType === ResourceType.item) {
|
||||
if (typeof options.maxIntegratedCacheStalenessInMs === "number") {
|
||||
headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] =
|
||||
options.maxIntegratedCacheStalenessInMs.toString();
|
||||
}
|
||||
else {
|
||||
defaultLogger.error(`RangeError: maxIntegratedCacheStalenessInMs "${options.maxIntegratedCacheStalenessInMs}" is not a valid parameter.`);
|
||||
headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = "null";
|
||||
}
|
||||
}
|
||||
if (options.resourceTokenExpirySeconds) {
|
||||
headers[Constants.HttpHeaders.ResourceTokenExpiry] = options.resourceTokenExpirySeconds;
|
||||
}
|
||||
if (options.sessionToken) {
|
||||
headers[Constants.HttpHeaders.SessionToken] = options.sessionToken;
|
||||
}
|
||||
if (options.enableScanInQuery) {
|
||||
headers[Constants.HttpHeaders.EnableScanInQuery] = options.enableScanInQuery;
|
||||
}
|
||||
if (options.populateQuotaInfo) {
|
||||
headers[Constants.HttpHeaders.PopulateQuotaInfo] = options.populateQuotaInfo;
|
||||
}
|
||||
if (options.populateQueryMetrics) {
|
||||
headers[Constants.HttpHeaders.PopulateQueryMetrics] = options.populateQueryMetrics;
|
||||
}
|
||||
if (options.maxDegreeOfParallelism !== undefined) {
|
||||
headers[Constants.HttpHeaders.ParallelizeCrossPartitionQuery] = true;
|
||||
}
|
||||
if (options.populateQuotaInfo) {
|
||||
headers[Constants.HttpHeaders.PopulateQuotaInfo] = true;
|
||||
}
|
||||
if (partitionKey !== undefined && !headers[Constants.HttpHeaders.PartitionKey]) {
|
||||
headers[Constants.HttpHeaders.PartitionKey] = jsonStringifyAndEscapeNonASCII(partitionKey);
|
||||
}
|
||||
if (clientOptions.key || clientOptions.tokenProvider) {
|
||||
headers[Constants.HttpHeaders.XDate] = new Date().toUTCString();
|
||||
}
|
||||
if (verb === HTTPMethod.post || verb === HTTPMethod.put) {
|
||||
if (!headers[Constants.HttpHeaders.ContentType]) {
|
||||
headers[Constants.HttpHeaders.ContentType] = JsonContentType;
|
||||
}
|
||||
}
|
||||
if (!headers[Constants.HttpHeaders.Accept]) {
|
||||
headers[Constants.HttpHeaders.Accept] = JsonContentType;
|
||||
}
|
||||
if (partitionKeyRangeId !== undefined) {
|
||||
headers[Constants.HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId;
|
||||
}
|
||||
if (options.enableScriptLogging) {
|
||||
headers[Constants.HttpHeaders.EnableScriptLogging] = options.enableScriptLogging;
|
||||
}
|
||||
if (options.disableRUPerMinuteUsage) {
|
||||
headers[Constants.HttpHeaders.DisableRUPerMinuteUsage] = true;
|
||||
}
|
||||
if (options.populateIndexMetrics) {
|
||||
headers[Constants.HttpHeaders.PopulateIndexMetrics] = options.populateIndexMetrics;
|
||||
}
|
||||
if (clientOptions.key ||
|
||||
clientOptions.resourceTokens ||
|
||||
clientOptions.tokenProvider ||
|
||||
clientOptions.permissionFeed) {
|
||||
await setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
//# sourceMappingURL=request.js.map
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user