UNPKG

211 kBTypeScriptView Raw
1/// <reference lib="dom" />
2/// <reference lib="esnext.asynciterable" />
3
4import { AbortError } from '@azure/abort-controller';
5import { AbortSignal as AbortSignal_2 } from 'node-abort-controller';
6import { Pipeline } from '@azure/core-rest-pipeline';
7import { RestError } from '@azure/core-rest-pipeline';
8import { TokenCredential } from '@azure/core-auth';
9
10export { AbortError }
11
12export declare interface Agent {
13 maxFreeSockets: number;
14 maxSockets: number;
15 sockets: any;
16 requests: any;
17 destroy(): void;
18}
19
20export declare type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum";
21
22export declare type BulkOperationResponse = OperationResponse[] & {
23 diagnostics: CosmosDiagnostics;
24};
25
26export declare const BulkOperationType: {
27 readonly Create: "Create";
28 readonly Upsert: "Upsert";
29 readonly Read: "Read";
30 readonly Delete: "Delete";
31 readonly Replace: "Replace";
32 readonly Patch: "Patch";
33};
34
35/**
36 * Options object used to modify bulk execution.
37 * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE
38 */
39export declare interface BulkOptions {
40 continueOnError?: boolean;
41}
42
43export declare type BulkPatchOperation = OperationBase & {
44 operationType: typeof BulkOperationType.Patch;
45 id: string;
46};
47
48/**
49 * Provides iterator for change feed.
50 *
51 * Use `Items.changeFeed()` to get an instance of the iterator.
52 */
53export declare class ChangeFeedIterator<T> {
54 private clientContext;
55 private resourceId;
56 private resourceLink;
57 private partitionKey;
58 private changeFeedOptions;
59 private static readonly IfNoneMatchAllHeaderValue;
60 private nextIfNoneMatch;
61 private ifModifiedSince;
62 private lastStatusCode;
63 private isPartitionSpecified;
64 /**
65 * Gets a value indicating whether there are potentially additional results that can be retrieved.
66 *
67 * Initially returns true. This value is set based on whether the last execution returned a continuation token.
68 *
69 * @returns Boolean value representing if whether there are potentially additional results that can be retrieved.
70 */
71 get hasMoreResults(): boolean;
72 /**
73 * Gets an async iterator which will yield pages of results from Azure Cosmos DB.
74 */
75 getAsyncIterator(): AsyncIterable<ChangeFeedResponse<Array<T & Resource>>>;
76 /**
77 * Read feed and retrieves the next page of results in Azure Cosmos DB.
78 */
79 fetchNext(): Promise<ChangeFeedResponse<Array<T & Resource>>>;
80 private getFeedResponse;
81}
82
83/**
84 * Specifies options for the change feed
85 *
86 * If none of those options are set, it will start reading changes from now for the entire container.
87 */
88export declare interface ChangeFeedIteratorOptions {
89 /**
90 * Max amount of items to return per page
91 */
92 maxItemCount?: number;
93 /**
94 * The session token to use. If not specified, will use the most recent captured session token to start with.
95 */
96 sessionToken?: string;
97 /**
98 * Signals where to start from in the change feed.
99 */
100 changeFeedStartFrom?: ChangeFeedStartFrom;
101}
102
103/**
104 * A single response page from the Azure Cosmos DB Change Feed
105 */
106export declare class ChangeFeedIteratorResponse<T> {
107 /**
108 * Gets the items returned in the response from Azure Cosmos DB
109 */
110 readonly result: T;
111 /**
112 * Gets the number of items returned in the response from Azure Cosmos DB
113 */
114 readonly count: number;
115 /**
116 * Gets the status code of the response from Azure Cosmos DB
117 */
118 readonly statusCode: number;
119 /**
120 * Cosmos Diagnostic Object.
121 */
122 readonly diagnostics: CosmosDiagnostics;
123 /**
124 * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone.
125 */
126 readonly subStatusCode?: number;
127 /**
128 * Gets the request charge for this request from the Azure Cosmos DB service.
129 */
130 get requestCharge(): number;
131 /**
132 * Gets the activity ID for the request from the Azure Cosmos DB service.
133 */
134 get activityId(): string;
135 /**
136 * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.
137 */
138 get continuationToken(): string;
139 /**
140 * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.
141 */
142 get sessionToken(): string;
143 /**
144 * Response headers of the response from Azure Cosmos DB
145 */
146 headers: CosmosHeaders;
147}
148
149/**
150 * Specifies options for the change feed
151 *
152 * Some of these options control where and when to start reading from the change feed. The order of precedence is:
153 * - continuation
154 * - startTime
155 * - startFromBeginning
156 *
157 * If none of those options are set, it will start reading changes from the first `ChangeFeedIterator.fetchNext()` call.
158 */
159export declare interface ChangeFeedOptions {
160 /**
161 * Max amount of items to return per page
162 */
163 maxItemCount?: number;
164 /**
165 * The continuation token to start from.
166 *
167 * This is equivalent to the etag and continuation value from the `ChangeFeedResponse`
168 */
169 continuation?: string;
170 /**
171 * The session token to use. If not specified, will use the most recent captured session token to start with.
172 */
173 sessionToken?: string;
174 /**
175 * Signals whether to start from the beginning or not.
176 */
177 startFromBeginning?: boolean;
178 /**
179 * Specified the start time to start reading changes from.
180 */
181 startTime?: Date;
182}
183
184/**
185 * Use `Items.getChangeFeedIterator()` to return an iterator that can iterate over all the changes for a partition key, feed range or an entire container.
186 */
187export declare interface ChangeFeedPullModelIterator<T> {
188 /**
189 * Always returns true, changefeed is an infinite stream.
190 */
191 readonly hasMoreResults: boolean;
192 /**
193 * Returns next set of results for the change feed.
194 */
195 readNext(): Promise<ChangeFeedIteratorResponse<Array<T & Resource>>>;
196 /**
197 * Gets an async iterator which will yield change feed results.
198 * @example Get changefeed for an entire container from now
199 * ```typescript
200 * const options = { changeFeedStartFrom: ChangeFeedStartFrom.Now() };
201 * for await(const res of container.items.getChangeFeedIterator(options).getAsyncIterator()) {
202 * //process res
203 * }
204 * ```
205 */
206 getAsyncIterator(): AsyncIterable<ChangeFeedIteratorResponse<Array<T & Resource>>>;
207}
208
209/**
210 * A single response page from the Azure Cosmos DB Change Feed
211 */
212export declare class ChangeFeedResponse<T> {
213 /**
214 * Gets the items returned in the response from Azure Cosmos DB
215 */
216 readonly result: T;
217 /**
218 * Gets the number of items returned in the response from Azure Cosmos DB
219 */
220 readonly count: number;
221 /**
222 * Gets the status code of the response from Azure Cosmos DB
223 */
224 readonly statusCode: number;
225 readonly diagnostics: CosmosDiagnostics;
226 /**
227 * Gets the request charge for this request from the Azure Cosmos DB service.
228 */
229 get requestCharge(): number;
230 /**
231 * Gets the activity ID for the request from the Azure Cosmos DB service.
232 */
233 get activityId(): string;
234 /**
235 * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.
236 *
237 * This is equivalent to the `etag` property.
238 */
239 get continuation(): string;
240 /**
241 * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.
242 */
243 get sessionToken(): string;
244 /**
245 * Gets the entity tag associated with last transaction in the Azure Cosmos DB service,
246 * which can be used as If-Non-Match Access condition for ReadFeed REST request or
247 * `continuation` property of `ChangeFeedOptions` parameter for
248 * `Items.changeFeed()`
249 * to get feed changes since the transaction specified by this entity tag.
250 *
251 * This is equivalent to the `continuation` property.
252 */
253 get etag(): string;
254 /**
255 * Response headers of the response from Azure Cosmos DB
256 */
257 headers: CosmosHeaders;
258}
259
260/**
261 * Base class for where to start a ChangeFeedIterator.
262 */
263export declare abstract class ChangeFeedStartFrom {
264 /**
265 * Returns an object that tells the ChangeFeedIterator to start from the beginning of time.
266 * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.
267 */
268 static Beginning(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromBeginning;
269 /**
270 * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward.
271 * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.
272 **/
273 static Now(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromNow;
274 /**
275 * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward.
276 * @param startTime - Date object specfiying the time to start reading changes from.
277 * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.
278 */
279 static Time(startTime: Date, cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromTime;
280 /**
281 * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point.
282 * @param continuation - The continuation to resume from.
283 */
284 static Continuation(continuationToken: string): ChangeFeedStartFromContinuation;
285}
286
287/**
288 * @hidden
289 * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time.
290 */
291declare class ChangeFeedStartFromBeginning {
292 private cfResource?;
293 constructor(cfResource?: PartitionKey | FeedRange);
294 getCfResource(): PartitionKey | FeedRange | undefined;
295}
296
297/**
298 * @hidden
299 * Class which specifies the ChangeFeedIterator to start reading changes from a saved point.
300 */
301declare class ChangeFeedStartFromContinuation {
302 private continuationToken;
303 constructor(continuation: string);
304 getCfResource(): string;
305 getCfResourceJson(): any;
306 getResourceType(): any;
307}
308
309/**
310 * @hidden
311 * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time.
312 */
313declare class ChangeFeedStartFromNow {
314 cfResource?: PartitionKey | FeedRange;
315 constructor(cfResource?: PartitionKey | FeedRange);
316 getCfResource(): PartitionKey | FeedRange | undefined;
317}
318
319/**
320 * @hidden
321 * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time.
322 */
323declare class ChangeFeedStartFromTime {
324 private cfResource?;
325 private startTime;
326 constructor(startTime: Date, cfResource?: PartitionKey | FeedRange);
327 getCfResource(): PartitionKey | FeedRange | undefined;
328 getStartTime(): Date;
329}
330
331/**
332 * This type holds information related to initialization of `CosmosClient`
333 */
334export declare type ClientConfigDiagnostic = {
335 /**
336 * End point configured during client initialization.
337 */
338 endpoint: string;
339 /**
340 * True if `resourceTokens` was supplied during client initialization.
341 */
342 resourceTokensConfigured: boolean;
343 /**
344 * True if `tokenProvider` was supplied during client initialization.
345 */
346 tokenProviderConfigured: boolean;
347 /**
348 * True if `aadCredentials` was supplied during client initialization.
349 */
350 aadCredentialsConfigured: boolean;
351 /**
352 * True if `connectionPolicy` was supplied during client initialization.
353 */
354 connectionPolicyConfigured: boolean;
355 /**
356 * `consistencyLevel` supplied during client initialization.
357 */
358 consistencyLevel?: keyof typeof ConsistencyLevel;
359 /**
360 * `defaultHeaders` supplied during client initialization.
361 */
362 defaultHeaders?: {
363 [key: string]: any;
364 };
365 /**
366 * True if `connectionPolicy` were supplied during client initialization.
367 */
368 agentConfigured: boolean;
369 /**
370 * `userAgentSuffix` supplied during client initialization.
371 */
372 userAgentSuffix: string;
373 /**
374 * `diagnosticLevel` supplied during client initialization.
375 */
376 diagnosticLevel?: CosmosDbDiagnosticLevel;
377 /**
378 * True if `plugins` were supplied during client initialization.
379 */
380 pluginsConfigured: boolean;
381 /**
382 * SDK version
383 */
384 sDKVersion: string;
385};
386
387/**
388 * @hidden
389 * @hidden
390 */
391export declare class ClientContext {
392 private cosmosClientOptions;
393 private globalEndpointManager;
394 private clientConfig;
395 diagnosticLevel: CosmosDbDiagnosticLevel;
396 private readonly sessionContainer;
397 private connectionPolicy;
398 private pipeline;
399 private diagnosticWriter;
400 private diagnosticFormatter;
401 partitionKeyDefinitionCache: {
402 [containerUrl: string]: any;
403 };
404 constructor(cosmosClientOptions: CosmosClientOptions, globalEndpointManager: GlobalEndpointManager, clientConfig: ClientConfigDiagnostic, diagnosticLevel: CosmosDbDiagnosticLevel);
405 /** @hidden */
406 read<T>({ path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
407 path: string;
408 resourceType: ResourceType;
409 resourceId: string;
410 options?: RequestOptions;
411 partitionKey?: PartitionKey;
412 diagnosticNode: DiagnosticNodeInternal;
413 }): Promise<Response_2<T & Resource>>;
414 queryFeed<T>({ path, resourceType, resourceId, resultFn, query, options, diagnosticNode, partitionKeyRangeId, partitionKey, startEpk, endEpk, }: {
415 path: string;
416 resourceType: ResourceType;
417 resourceId: string;
418 resultFn: (result: {
419 [key: string]: any;
420 }) => any[];
421 query: SqlQuerySpec | string;
422 options: FeedOptions;
423 diagnosticNode: DiagnosticNodeInternal;
424 partitionKeyRangeId?: string;
425 partitionKey?: PartitionKey;
426 startEpk?: string | undefined;
427 endEpk?: string | undefined;
428 }): Promise<Response_2<T & Resource>>;
429 getQueryPlan(path: string, resourceType: ResourceType, resourceId: string, query: SqlQuerySpec | string, options: FeedOptions, diagnosticNode: DiagnosticNodeInternal): Promise<Response_2<PartitionedQueryExecutionInfo>>;
430 queryPartitionKeyRanges(collectionLink: string, query?: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<PartitionKeyRange>;
431 delete<T>({ path, resourceType, resourceId, options, partitionKey, method, diagnosticNode, }: {
432 path: string;
433 resourceType: ResourceType;
434 resourceId: string;
435 options?: RequestOptions;
436 partitionKey?: PartitionKey;
437 method?: HTTPMethod;
438 diagnosticNode: DiagnosticNodeInternal;
439 }): Promise<Response_2<T & Resource>>;
440 patch<T>({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
441 body: any;
442 path: string;
443 resourceType: ResourceType;
444 resourceId: string;
445 options?: RequestOptions;
446 partitionKey?: PartitionKey;
447 diagnosticNode: DiagnosticNodeInternal;
448 }): Promise<Response_2<T & Resource>>;
449 create<T, U = T>({ body, path, resourceType, resourceId, diagnosticNode, options, partitionKey, }: {
450 body: T;
451 path: string;
452 resourceType: ResourceType;
453 resourceId: string;
454 diagnosticNode: DiagnosticNodeInternal;
455 options?: RequestOptions;
456 partitionKey?: PartitionKey;
457 }): Promise<Response_2<T & U & Resource>>;
458 private processQueryFeedResponse;
459 private applySessionToken;
460 replace<T>({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
461 body: any;
462 path: string;
463 resourceType: ResourceType;
464 resourceId: string;
465 options?: RequestOptions;
466 partitionKey?: PartitionKey;
467 diagnosticNode: DiagnosticNodeInternal;
468 }): Promise<Response_2<T & Resource>>;
469 upsert<T, U = T>({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
470 body: T;
471 path: string;
472 resourceType: ResourceType;
473 resourceId: string;
474 options?: RequestOptions;
475 partitionKey?: PartitionKey;
476 diagnosticNode: DiagnosticNodeInternal;
477 }): Promise<Response_2<T & U & Resource>>;
478 execute<T>({ sprocLink, params, options, partitionKey, diagnosticNode, }: {
479 sprocLink: string;
480 params?: any[];
481 options?: RequestOptions;
482 partitionKey?: PartitionKey;
483 diagnosticNode: DiagnosticNodeInternal;
484 }): Promise<Response_2<T>>;
485 /**
486 * Gets the Database account information.
487 * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved.
488 * If not present, current client's url will be used.
489 */
490 getDatabaseAccount(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<Response_2<DatabaseAccount>>;
491 getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
492 getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
493 getWriteEndpoints(): Promise<readonly string[]>;
494 getReadEndpoints(): Promise<readonly string[]>;
495 batch<T>({ body, path, partitionKey, resourceId, options, diagnosticNode, }: {
496 body: T;
497 path: string;
498 partitionKey: PartitionKey;
499 resourceId: string;
500 options?: RequestOptions;
501 diagnosticNode: DiagnosticNodeInternal;
502 }): Promise<Response_2<any>>;
503 bulk<T>({ body, path, partitionKeyRangeId, resourceId, bulkOptions, options, diagnosticNode, }: {
504 body: T;
505 path: string;
506 partitionKeyRangeId: string;
507 resourceId: string;
508 bulkOptions?: BulkOptions;
509 options?: RequestOptions;
510 diagnosticNode: DiagnosticNodeInternal;
511 }): Promise<Response_2<any>>;
512 private captureSessionToken;
513 clearSessionToken(path: string): void;
514 recordDiagnostics(diagnostic: CosmosDiagnostics): void;
515 initializeDiagnosticSettings(diagnosticLevel: CosmosDbDiagnosticLevel): void;
516 private getSessionParams;
517 private isMasterResource;
518 private buildHeaders;
519 /**
520 * Returns collection of properties which are derived from the context for Request Creation.
521 * These properties have client wide scope, as opposed to request specific scope.
522 * @returns
523 */
524 private getContextDerivedPropsForRequestCreation;
525 getClientConfig(): ClientConfigDiagnostic;
526}
527
528export declare class ClientSideMetrics {
529 readonly requestCharge: number;
530 constructor(requestCharge: number);
531 /**
532 * Adds one or more ClientSideMetrics to a copy of this instance and returns the result.
533 */
534 add(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics;
535 static readonly zero: ClientSideMetrics;
536 static createFromArray(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics;
537}
538
539/**
540 * This is a collection type for all client side diagnostic information.
541 */
542export declare type ClientSideRequestStatistics = {
543 /**
544 * This is the UTC timestamp for start of client operation.
545 */
546 requestStartTimeUTCInMs: number;
547 /**
548 * This is the duration in milli seconds taken by client operation.
549 */
550 requestDurationInMs: number;
551 /**
552 * This is the list of Location Endpoints contacted during the client operation.
553 */
554 locationEndpointsContacted: string[];
555 /**
556 * This field captures diagnostic information for retries happened during client operation.
557 */
558 retryDiagnostics: RetryDiagnostics;
559 /**
560 * This field captures diagnostic information for meta data lookups happened during client operation.
561 */
562 metadataDiagnostics: MetadataLookUpDiagnostics;
563 /**
564 * These are the statistics for main point look operation.
565 */
566 gatewayStatistics: GatewayStatistics[];
567 /**
568 * This is the cumulated Request Payload Length n bytes, this includes metadata calls along with the main operation.
569 */
570 totalRequestPayloadLengthInBytes: number;
571 /**
572 * This is the cumulated Response Payload Length n bytes, this includes metadata calls along with the main operation.
573 */
574 totalResponsePayloadLengthInBytes: number;
575};
576
577/**
578 * Use to read or delete a given {@link Conflict} by id.
579 *
580 * @see {@link Conflicts} to query or read all conflicts.
581 */
582export declare class Conflict {
583 readonly container: Container;
584 readonly id: string;
585 private readonly clientContext;
586 private partitionKey?;
587 /**
588 * Returns a reference URL to the resource. Used for linking in Permissions.
589 */
590 get url(): string;
591 /**
592 * @hidden
593 * @param container - The parent {@link Container}.
594 * @param id - The id of the given {@link Conflict}.
595 */
596 constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey);
597 /**
598 * Read the {@link ConflictDefinition} for the given {@link Conflict}.
599 */
600 read(options?: RequestOptions): Promise<ConflictResponse>;
601 /**
602 * Delete the given {@link ConflictDefinition}.
603 */
604 delete(options?: RequestOptions): Promise<ConflictResponse>;
605}
606
607export declare interface ConflictDefinition {
608 /** The id of the conflict */
609 id?: string;
610 /** Source resource id */
611 resourceId?: string;
612 resourceType?: ResourceType;
613 operationType?: OperationType;
614 content?: string;
615}
616
617export declare enum ConflictResolutionMode {
618 Custom = "Custom",
619 LastWriterWins = "LastWriterWins"
620}
621
622/**
623 * Represents the conflict resolution policy configuration for specifying how to resolve conflicts
624 * in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service.
625 */
626export declare interface ConflictResolutionPolicy {
627 /**
628 * Gets or sets the <see cref="ConflictResolutionMode"/> in the Azure Cosmos DB service. By default it is {@link ConflictResolutionMode.LastWriterWins}.
629 */
630 mode?: keyof typeof ConflictResolutionMode;
631 /**
632 * Gets or sets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution.
633 * This path must be present in each document and must be an integer value.
634 * In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked.
635 * If the path is unspecified, by default the timestamp path will be used.
636 *
637 * This value should only be set when using {@link ConflictResolutionMode.LastWriterWins}.
638 *
639 * ```typescript
640 * conflictResolutionPolicy.ConflictResolutionPath = "/name/first";
641 * ```
642 *
643 */
644 conflictResolutionPath?: string;
645 /**
646 * Gets or sets the {@link StoredProcedure} which is used for conflict resolution in the Azure Cosmos DB service.
647 * This stored procedure may be created after the {@link Container} is created and can be changed as required.
648 *
649 * 1. This value should only be set when using {@link ConflictResolutionMode.Custom}.
650 * 2. In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed.
651 *
652 * ```typescript
653 * conflictResolutionPolicy.ConflictResolutionProcedure = "resolveConflict"
654 * ```
655 */
656 conflictResolutionProcedure?: string;
657}
658
659export declare class ConflictResponse extends ResourceResponse<ConflictDefinition & Resource> {
660 constructor(resource: ConflictDefinition & Resource, headers: CosmosHeaders, statusCode: number, conflict: Conflict, diagnostics: CosmosDiagnostics);
661 /** A reference to the {@link Conflict} corresponding to the returned {@link ConflictDefinition}. */
662 readonly conflict: Conflict;
663}
664
665/**
666 * Use to query or read all conflicts.
667 *
668 * @see {@link Conflict} to read or delete a given {@link Conflict} by id.
669 */
670export declare class Conflicts {
671 readonly container: Container;
672 private readonly clientContext;
673 constructor(container: Container, clientContext: ClientContext);
674 /**
675 * Queries all conflicts.
676 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
677 * @param options - Use to set options like response page size, continuation tokens, etc.
678 * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.
679 */
680 query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
681 /**
682 * Queries all conflicts.
683 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
684 * @param options - Use to set options like response page size, continuation tokens, etc.
685 * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.
686 */
687 query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
688 /**
689 * Reads all conflicts
690 * @param options - Use to set options like response page size, continuation tokens, etc.
691 */
692 readAll(options?: FeedOptions): QueryIterator<ConflictDefinition & Resource>;
693 }
694
695 /** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */
696 export declare enum ConnectionMode {
697 /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */
698 Gateway = 0
699 }
700
701 /**
702 * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service.
703 */
704 export declare interface ConnectionPolicy {
705 /** Determines which mode to connect to Cosmos with. (Currently only supports Gateway option) */
706 connectionMode?: ConnectionMode;
707 /** Request timeout (time to wait for response from network peer). Represented in milliseconds. */
708 requestTimeout?: number;
709 /**
710 * Flag to enable/disable automatic redirecting of requests based on read/write operations. Default true.
711 * Required to call client.dispose() when this is set to true after destroying the CosmosClient inside another process or in the browser.
712 */
713 enableEndpointDiscovery?: boolean;
714 /** List of azure regions to be used as preferred locations for read requests. */
715 preferredLocations?: string[];
716 /** RetryOptions object which defines several configurable properties used during retry. */
717 retryOptions?: RetryOptions;
718 /**
719 * The flag that enables writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
720 * Default is `false`.
721 */
722 useMultipleWriteLocations?: boolean;
723 /** Rate in milliseconds at which the client will refresh the endpoints list in the background */
724 endpointRefreshRateInMs?: number;
725 /** Flag to enable/disable background refreshing of endpoints. Defaults to false.
726 * Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */
727 enableBackgroundEndpointRefreshing?: boolean;
728 }
729
730 /**
731 * Represents the consistency levels supported for Azure Cosmos DB client operations.<br>
732 * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account.
733 * Consistency levels.
734 *
735 * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual.
736 *
737 * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels.
738 */
739 export declare enum ConsistencyLevel {
740 /**
741 * Strong Consistency guarantees that read operations always return the value that was last written.
742 */
743 Strong = "Strong",
744 /**
745 * Bounded Staleness guarantees that reads are not too out-of-date.
746 * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds).
747 */
748 BoundedStaleness = "BoundedStaleness",
749 /**
750 * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again),
751 * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads)
752 * within any single session.
753 */
754 Session = "Session",
755 /**
756 * Eventual Consistency guarantees that reads will return a subset of writes.
757 * All writes will be eventually be available for reads.
758 */
759 Eventual = "Eventual",
760 /**
761 * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps.
762 * All writes will be eventually be available for reads.
763 */
764 ConsistentPrefix = "ConsistentPrefix"
765 }
766
767 /**
768 * @hidden
769 */
770 export declare const Constants: {
771 HttpHeaders: {
772 Authorization: string;
773 ETag: string;
774 MethodOverride: string;
775 Slug: string;
776 ContentType: string;
777 LastModified: string;
778 ContentEncoding: string;
779 CharacterSet: string;
780 UserAgent: string;
781 IfModifiedSince: string;
782 IfMatch: string;
783 IfNoneMatch: string;
784 ContentLength: string;
785 AcceptEncoding: string;
786 KeepAlive: string;
787 CacheControl: string;
788 TransferEncoding: string;
789 ContentLanguage: string;
790 ContentLocation: string;
791 ContentMd5: string;
792 ContentRange: string;
793 Accept: string;
794 AcceptCharset: string;
795 AcceptLanguage: string;
796 IfRange: string;
797 IfUnmodifiedSince: string;
798 MaxForwards: string;
799 ProxyAuthorization: string;
800 AcceptRanges: string;
801 ProxyAuthenticate: string;
802 RetryAfter: string;
803 SetCookie: string;
804 WwwAuthenticate: string;
805 Origin: string;
806 Host: string;
807 AccessControlAllowOrigin: string;
808 AccessControlAllowHeaders: string;
809 KeyValueEncodingFormat: string;
810 WrapAssertionFormat: string;
811 WrapAssertion: string;
812 WrapScope: string;
813 SimpleToken: string;
814 HttpDate: string;
815 Prefer: string;
816 Location: string;
817 Referer: string;
818 A_IM: string;
819 Query: string;
820 IsQuery: string;
821 IsQueryPlan: string;
822 SupportedQueryFeatures: string;
823 QueryVersion: string;
824 Continuation: string;
825 ContinuationToken: string;
826 PageSize: string;
827 ItemCount: string;
828 ActivityId: string;
829 PreTriggerInclude: string;
830 PreTriggerExclude: string;
831 PostTriggerInclude: string;
832 PostTriggerExclude: string;
833 IndexingDirective: string;
834 SessionToken: string;
835 ConsistencyLevel: string;
836 XDate: string;
837 CollectionPartitionInfo: string;
838 CollectionServiceInfo: string;
839 RetryAfterInMilliseconds: string;
840 RetryAfterInMs: string;
841 IsFeedUnfiltered: string;
842 ResourceTokenExpiry: string;
843 EnableScanInQuery: string;
844 EmitVerboseTracesInQuery: string;
845 EnableCrossPartitionQuery: string;
846 ParallelizeCrossPartitionQuery: string;
847 ResponseContinuationTokenLimitInKB: string;
848 PopulateQueryMetrics: string;
849 QueryMetrics: string;
850 PopulateIndexMetrics: string;
851 IndexUtilization: string;
852 Version: string;
853 OwnerFullName: string;
854 OwnerId: string;
855 PartitionKey: string;
856 PartitionKeyRangeID: string;
857 StartEpk: string;
858 EndEpk: string;
859 ReadFeedKeyType: string;
860 MaxEntityCount: string;
861 CurrentEntityCount: string;
862 CollectionQuotaInMb: string;
863 CollectionCurrentUsageInMb: string;
864 MaxMediaStorageUsageInMB: string;
865 CurrentMediaStorageUsageInMB: string;
866 RequestCharge: string;
867 PopulateQuotaInfo: string;
868 MaxResourceQuota: string;
869 OfferType: string;
870 OfferThroughput: string;
871 AutoscaleSettings: string;
872 DisableRUPerMinuteUsage: string;
873 IsRUPerMinuteUsed: string;
874 OfferIsRUPerMinuteThroughputEnabled: string;
875 IndexTransformationProgress: string;
876 LazyIndexingProgress: string;
877 IsUpsert: string;
878 SubStatus: string;
879 EnableScriptLogging: string;
880 ScriptLogResults: string;
881 ALLOW_MULTIPLE_WRITES: string;
882 IsBatchRequest: string;
883 IsBatchAtomic: string;
884 BatchContinueOnError: string;
885 DedicatedGatewayPerRequestCacheStaleness: string;
886 ForceRefresh: string;
887 PriorityLevel: string;
888 };
889 WritableLocations: string;
890 ReadableLocations: string;
891 LocationUnavailableExpirationTimeInMs: number;
892 ENABLE_MULTIPLE_WRITABLE_LOCATIONS: string;
893 DefaultUnavailableLocationExpirationTimeMS: number;
894 ThrottleRetryCount: string;
895 ThrottleRetryWaitTimeInMs: string;
896 CurrentVersion: string;
897 AzureNamespace: string;
898 AzurePackageName: string;
899 SDKName: string;
900 SDKVersion: string;
901 CosmosDbDiagnosticLevelEnvVarName: string;
902 DefaultMaxBulkRequestBodySizeInBytes: number;
903 Quota: {
904 CollectionSize: string;
905 };
906 Path: {
907 Root: string;
908 DatabasesPathSegment: string;
909 CollectionsPathSegment: string;
910 UsersPathSegment: string;
911 DocumentsPathSegment: string;
912 PermissionsPathSegment: string;
913 StoredProceduresPathSegment: string;
914 TriggersPathSegment: string;
915 UserDefinedFunctionsPathSegment: string;
916 ConflictsPathSegment: string;
917 AttachmentsPathSegment: string;
918 PartitionKeyRangesPathSegment: string;
919 SchemasPathSegment: string;
920 OffersPathSegment: string;
921 TopologyPathSegment: string;
922 DatabaseAccountPathSegment: string;
923 };
924 PartitionKeyRange: PartitionKeyRangePropertiesNames;
925 QueryRangeConstants: {
926 MinInclusive: string;
927 MaxExclusive: string;
928 min: string;
929 };
930 /**
931 * @deprecated Use EffectivePartitionKeyConstants instead
932 */
933 EffectiveParitionKeyConstants: {
934 MinimumInclusiveEffectivePartitionKey: string;
935 MaximumExclusiveEffectivePartitionKey: string;
936 };
937 EffectivePartitionKeyConstants: {
938 MinimumInclusiveEffectivePartitionKey: string;
939 MaximumExclusiveEffectivePartitionKey: string;
940 };
941 };
942
943 /**
944 * Operations for reading, replacing, or deleting a specific, existing container by id.
945 *
946 * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`.
947 *
948 * Note: all these operations make calls against a fixed budget.
949 * You should design your system such that these calls scale sublinearly with your application.
950 * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists;
951 * do this once on application start up.
952 */
953 export declare class Container {
954 readonly database: Database;
955 readonly id: string;
956 private readonly clientContext;
957 private $items;
958 /**
959 * Operations for creating new items, and reading/querying all items
960 *
961 * For reading, replacing, or deleting an existing item, use `.item(id)`.
962 *
963 * @example Create a new item
964 * ```typescript
965 * const {body: createdItem} = await container.items.create({id: "<item id>", properties: {}});
966 * ```
967 */
968 get items(): Items;
969 private $scripts;
970 /**
971 * All operations for Stored Procedures, Triggers, and User Defined Functions
972 */
973 get scripts(): Scripts;
974 private $conflicts;
975 /**
976 * Operations for reading and querying conflicts for the given container.
977 *
978 * For reading or deleting a specific conflict, use `.conflict(id)`.
979 */
980 get conflicts(): Conflicts;
981 /**
982 * Returns a reference URL to the resource. Used for linking in Permissions.
983 */
984 get url(): string;
985 /**
986 * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object.
987 * @param database - The parent {@link Database}.
988 * @param id - The id of the given container.
989 * @hidden
990 */
991 constructor(database: Database, id: string, clientContext: ClientContext);
992 /**
993 * Used to read, replace, or delete a specific, existing {@link Item} by id.
994 *
995 * Use `.items` for creating new items, or querying/reading all items.
996 *
997 * @param id - The id of the {@link Item}.
998 * @param partitionKeyValue - The value of the {@link Item} partition key
999 * @example Replace an item
1000 * `const {body: replacedItem} = await container.item("<item id>", "<partition key value>").replace({id: "<item id>", title: "Updated post", authorID: 5});`
1001 */
1002 item(id: string, partitionKeyValue?: PartitionKey): Item;
1003 /**
1004 * Used to read, replace, or delete a specific, existing {@link Conflict} by id.
1005 *
1006 * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts.
1007 * @param id - The id of the {@link Conflict}.
1008 */
1009 conflict(id: string, partitionKey?: PartitionKey): Conflict;
1010 /** Read the container's definition */
1011 read(options?: RequestOptions): Promise<ContainerResponse>;
1012 /**
1013 * @hidden
1014 */
1015 readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<ContainerResponse>;
1016 /** Replace the container's definition */
1017 replace(body: ContainerDefinition, options?: RequestOptions): Promise<ContainerResponse>;
1018 /** Delete the container */
1019 delete(options?: RequestOptions): Promise<ContainerResponse>;
1020 /**
1021 * Gets the partition key definition first by looking into the cache otherwise by reading the collection.
1022 * @deprecated This method has been renamed to readPartitionKeyDefinition.
1023 */
1024 getPartitionKeyDefinition(): Promise<ResourceResponse<PartitionKeyDefinition>>;
1025 /**
1026 * Gets the partition key definition first by looking into the cache otherwise by reading the collection.
1027 * @hidden
1028 */
1029 readPartitionKeyDefinition(diagnosticNode: DiagnosticNodeInternal): Promise<ResourceResponse<PartitionKeyDefinition>>;
1030 /**
1031 * Gets offer on container. If none exists, returns an OfferResponse with undefined.
1032 */
1033 readOffer(options?: RequestOptions): Promise<OfferResponse>;
1034 getQueryPlan(query: string | SqlQuerySpec): Promise<Response_2<PartitionedQueryExecutionInfo>>;
1035 readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator<PartitionKeyRange>;
1036 /**
1037 *
1038 * @returns all the feed ranges for which changefeed could be fetched.
1039 */
1040 getFeedRanges(): Promise<ReadonlyArray<FeedRange>>;
1041 /**
1042 * Delete all documents belong to the container for the provided partition key value
1043 * @param partitionKey - The partition key value of the items to be deleted
1044 */
1045 deleteAllItemsForPartitionKey(partitionKey: PartitionKey, options?: RequestOptions): Promise<ContainerResponse>;
1046 }
1047
1048 export declare interface ContainerDefinition {
1049 /** The id of the container. */
1050 id?: string;
1051 /** The partition key for the container. */
1052 partitionKey?: PartitionKeyDefinition;
1053 /** The indexing policy associated with the container. */
1054 indexingPolicy?: IndexingPolicy;
1055 /** The default time to live in seconds for items in a container. */
1056 defaultTtl?: number;
1057 /** The conflict resolution policy used to resolve conflicts in a container. */
1058 conflictResolutionPolicy?: ConflictResolutionPolicy;
1059 /** Policy for additional keys that must be unique per partition key */
1060 uniqueKeyPolicy?: UniqueKeyPolicy;
1061 /** Geospatial configuration for a collection. Type is set to Geography by default */
1062 geospatialConfig?: {
1063 type: GeospatialType;
1064 };
1065 }
1066
1067 export declare interface ContainerRequest extends VerboseOmit<ContainerDefinition, "partitionKey"> {
1068 throughput?: number;
1069 maxThroughput?: number;
1070 autoUpgradePolicy?: {
1071 throughputPolicy: {
1072 incrementPercent: number;
1073 };
1074 };
1075 partitionKey?: string | PartitionKeyDefinition;
1076 }
1077
1078 /** Response object for Container operations */
1079 export declare class ContainerResponse extends ResourceResponse<ContainerDefinition & Resource> {
1080 constructor(resource: ContainerDefinition & Resource, headers: CosmosHeaders, statusCode: number, container: Container, diagnostics: CosmosDiagnostics);
1081 /** A reference to the {@link Container} that the returned {@link ContainerDefinition} corresponds to. */
1082 readonly container: Container;
1083 }
1084
1085 /**
1086 * Operations for creating new containers, and reading/querying all containers
1087 *
1088 * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`.
1089 *
1090 * Note: all these operations make calls against a fixed budget.
1091 * You should design your system such that these calls scale sublinearly with your application.
1092 * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists;
1093 * do this once on application start up.
1094 */
1095 export declare class Containers {
1096 readonly database: Database;
1097 private readonly clientContext;
1098 constructor(database: Database, clientContext: ClientContext);
1099 /**
1100 * Queries all containers.
1101 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1102 * @param options - Use to set options like response page size, continuation tokens, etc.
1103 * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.
1104 * @example Read all containers to array.
1105 * ```typescript
1106 * const querySpec: SqlQuerySpec = {
1107 * query: "SELECT * FROM root r WHERE r.id = @container",
1108 * parameters: [
1109 * {name: "@container", value: "Todo"}
1110 * ]
1111 * };
1112 * const {body: containerList} = await client.database("<db id>").containers.query(querySpec).fetchAll();
1113 * ```
1114 */
1115 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
1116 /**
1117 * Queries all containers.
1118 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1119 * @param options - Use to set options like response page size, continuation tokens, etc.
1120 * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.
1121 * @example Read all containers to array.
1122 * ```typescript
1123 * const querySpec: SqlQuerySpec = {
1124 * query: "SELECT * FROM root r WHERE r.id = @container",
1125 * parameters: [
1126 * {name: "@container", value: "Todo"}
1127 * ]
1128 * };
1129 * const {body: containerList} = await client.database("<db id>").containers.query(querySpec).fetchAll();
1130 * ```
1131 */
1132 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
1133 /**
1134 * Creates a container.
1135 *
1136 * A container is a named logical container for items.
1137 *
1138 * A database may contain zero or more named containers and each container consists of
1139 * zero or more JSON items.
1140 *
1141 * Being schema-free, the items in a container do not need to share the same structure or fields.
1142 *
1143 *
1144 * Since containers are application resources, they can be authorized using either the
1145 * master key or resource keys.
1146 *
1147 * @param body - Represents the body of the container.
1148 * @param options - Use to set options like response page size, continuation tokens, etc.
1149 */
1150 create(body: ContainerRequest, options?: RequestOptions): Promise<ContainerResponse>;
1151 /**
1152 * @hidden
1153 */
1154 createInternal(diagnosticNode: DiagnosticNodeInternal, body: ContainerRequest, options?: RequestOptions): Promise<ContainerResponse>;
1155 /**
1156 * Checks if a Container exists, and, if it doesn't, creates it.
1157 * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.
1158 * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.)
1159 *
1160 * A container is a named logical container for items.
1161 *
1162 * A database may contain zero or more named containers and each container consists of
1163 * zero or more JSON items.
1164 *
1165 * Being schema-free, the items in a container do not need to share the same structure or fields.
1166 *
1167 *
1168 * Since containers are application resources, they can be authorized using either the
1169 * master key or resource keys.
1170 *
1171 * @param body - Represents the body of the container.
1172 * @param options - Use to set options like response page size, continuation tokens, etc.
1173 */
1174 createIfNotExists(body: ContainerRequest, options?: RequestOptions): Promise<ContainerResponse>;
1175 /**
1176 * Read all containers.
1177 * @param options - Use to set options like response page size, continuation tokens, etc.
1178 * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time.
1179 * @example Read all containers to array.
1180 * ```typescript
1181 * const {body: containerList} = await client.database("<db id>").containers.readAll().fetchAll();
1182 * ```
1183 */
1184 readAll(options?: FeedOptions): QueryIterator<ContainerDefinition & Resource>;
1185 }
1186
1187 /**
1188 * Provides a client-side logical representation of the Azure Cosmos DB database account.
1189 * This client is used to configure and execute requests in the Azure Cosmos DB database service.
1190 * @example Instantiate a client and create a new database
1191 * ```typescript
1192 * const client = new CosmosClient({endpoint: "<URL HERE>", auth: {masterKey: "<KEY HERE>"}});
1193 * await client.databases.create({id: "<datbase name here>"});
1194 * ```
1195 * @example Instantiate a client with custom Connection Policy
1196 * ```typescript
1197 * const connectionPolicy = new ConnectionPolicy();
1198 * connectionPolicy.RequestTimeout = 10000;
1199 * const client = new CosmosClient({
1200 * endpoint: "<URL HERE>",
1201 * auth: {masterKey: "<KEY HERE>"},
1202 * connectionPolicy
1203 * });
1204 * ```
1205 */
1206 export declare class CosmosClient {
1207 /**
1208 * Used for creating new databases, or querying/reading all databases.
1209 *
1210 * Use `.database(id)` to read, replace, or delete a specific, existing database by id.
1211 *
1212 * @example Create a new database
1213 * ```typescript
1214 * const {resource: databaseDefinition, database} = await client.databases.create({id: "<name here>"});
1215 * ```
1216 */
1217 readonly databases: Databases;
1218 /**
1219 * Used for querying & reading all offers.
1220 *
1221 * Use `.offer(id)` to read, or replace existing offers.
1222 */
1223 readonly offers: Offers;
1224 private clientContext;
1225 private endpointRefresher;
1226 /**
1227 * Creates a new {@link CosmosClient} object from a connection string. Your database connection string can be found in the Azure Portal
1228 */
1229 constructor(connectionString: string);
1230 /**
1231 * Creates a new {@link CosmosClient} object. See {@link CosmosClientOptions} for more details on what options you can use.
1232 * @param options - bag of options; require at least endpoint and auth to be configured
1233 */
1234 constructor(options: CosmosClientOptions);
1235 private initializeClientConfigDiagnostic;
1236 /**
1237 * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.)
1238 */
1239 getDatabaseAccount(options?: RequestOptions): Promise<ResourceResponse<DatabaseAccount>>;
1240 /**
1241 * @hidden
1242 */
1243 getDatabaseAccountInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<ResourceResponse<DatabaseAccount>>;
1244 /**
1245 * Gets the currently used write endpoint url. Useful for troubleshooting purposes.
1246 *
1247 * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1248 */
1249 getWriteEndpoint(): Promise<string>;
1250 /**
1251 * Gets the currently used read endpoint. Useful for troubleshooting purposes.
1252 *
1253 * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1254 */
1255 getReadEndpoint(): Promise<string>;
1256 /**
1257 * Gets the known write endpoints. Useful for troubleshooting purposes.
1258 *
1259 * The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1260 */
1261 getWriteEndpoints(): Promise<readonly string[]>;
1262 /**
1263 * Gets the currently used read endpoint. Useful for troubleshooting purposes.
1264 *
1265 * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1266 */
1267 getReadEndpoints(): Promise<readonly string[]>;
1268 /**
1269 * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database.
1270 *
1271 * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object.
1272 *
1273 * @param id - The id of the database.
1274 * @example Create a new container off of an existing database
1275 * ```typescript
1276 * const container = client.database("<database id>").containers.create("<container id>");
1277 * ```
1278 *
1279 * @example Delete an existing database
1280 * ```typescript
1281 * await client.database("<id here>").delete();
1282 * ```
1283 */
1284 database(id: string): Database;
1285 /**
1286 * Used for reading, or updating a existing offer by id.
1287 * @param id - The id of the offer.
1288 */
1289 offer(id: string): Offer;
1290 /**
1291 * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process.
1292 */
1293 dispose(): void;
1294 private backgroundRefreshEndpointList;
1295 }
1296
1297 export declare interface CosmosClientOptions {
1298 /** The service endpoint to use to create the client. */
1299 endpoint: string;
1300 /** The account master or readonly key */
1301 key?: string;
1302 /** An object that contains resources tokens.
1303 * Keys for the object are resource Ids and values are the resource tokens.
1304 */
1305 resourceTokens?: {
1306 [resourcePath: string]: string;
1307 };
1308 /** A user supplied function for resolving header authorization tokens.
1309 * Allows users to generating their own auth tokens, potentially using a separate service
1310 */
1311 tokenProvider?: TokenProvider;
1312 /** AAD token from `@azure/identity`
1313 * Obtain a credential object by creating an `@azure/identity` credential object
1314 * We will then use your credential object and a scope URL (your cosmos db endpoint)
1315 * to authenticate requests to Cosmos
1316 */
1317 aadCredentials?: TokenCredential;
1318 /** An array of {@link Permission} objects. */
1319 permissionFeed?: PermissionDefinition[];
1320 /** An instance of {@link ConnectionPolicy} class.
1321 * This parameter is optional and the default connectionPolicy will be used if omitted.
1322 */
1323 connectionPolicy?: ConnectionPolicy;
1324 /** An optional parameter that represents the consistency level.
1325 * It can take any value from {@link ConsistencyLevel}.
1326 */
1327 consistencyLevel?: keyof typeof ConsistencyLevel;
1328 defaultHeaders?: CosmosHeaders_2;
1329 /** An optional custom http(s) Agent to be used in NodeJS enironments
1330 * Use an agent such as https://github.com/TooTallNate/node-proxy-agent if you need to connect to Cosmos via a proxy
1331 */
1332 agent?: Agent;
1333 /** A custom string to append to the default SDK user agent. */
1334 userAgentSuffix?: string;
1335 diagnosticLevel?: CosmosDbDiagnosticLevel;
1336 }
1337
1338 /**
1339 * @hidden
1340 */
1341 declare enum CosmosContainerChildResourceKind {
1342 Item = "ITEM",
1343 StoredProcedure = "STORED_PROCEDURE",
1344 UserDefinedFunction = "USER_DEFINED_FUNCTION",
1345 Trigger = "TRIGGER"
1346 }
1347
1348 /**
1349 * Cosmos DB Diagnostic Level
1350 */
1351 export declare enum CosmosDbDiagnosticLevel {
1352 info = "info",
1353 debug = "debug",
1354 debugUnsafe = "debug-unsafe"
1355 }
1356
1357 /**
1358 * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create().
1359 * It has three members -
1360 * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including -
1361 * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls.
1362 * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call.
1363 * - retries
1364 * - endpoints contacted.
1365 * - request, response payload stats.
1366 * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations
1367 * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation.
1368 *
1369 * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be
1370 * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`.
1371 * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments.
1372 * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used
1373 * in production environment.
1374 * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads.
1375 * Is not meant to be used in production environment.
1376 * 3. clientConfig - Captures information related to how client was configured during initialization.
1377 */
1378 export declare class CosmosDiagnostics {
1379 readonly clientSideRequestStatistics: ClientSideRequestStatistics;
1380 readonly diagnosticNode: DiagnosticNode;
1381 readonly clientConfig?: ClientConfigDiagnostic;
1382 }
1383
1384 export declare interface CosmosHeaders {
1385 [key: string]: any;
1386 }
1387
1388 declare interface CosmosHeaders_2 {
1389 [key: string]: string | boolean | number;
1390 }
1391
1392 /**
1393 * @hidden
1394 */
1395 declare enum CosmosKeyType {
1396 PrimaryMaster = "PRIMARY_MASTER",
1397 SecondaryMaster = "SECONDARY_MASTER",
1398 PrimaryReadOnly = "PRIMARY_READONLY",
1399 SecondaryReadOnly = "SECONDARY_READONLY"
1400 }
1401
1402 /**
1403 * Experimental internal only
1404 * Generates the payload representing the permission configuration for the sas token.
1405 */
1406 export declare function createAuthorizationSasToken(masterKey: string, sasTokenProperties: SasTokenProperties): Promise<string>;
1407
1408 export declare type CreateOperation = OperationWithItem & {
1409 operationType: typeof BulkOperationType.Create;
1410 };
1411
1412 export declare interface CreateOperationInput {
1413 partitionKey?: PartitionKey;
1414 ifMatch?: string;
1415 ifNoneMatch?: string;
1416 operationType: typeof BulkOperationType.Create;
1417 resourceBody: JSONObject;
1418 }
1419
1420 /**
1421 * Operations for reading or deleting an existing database.
1422 *
1423 * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`.
1424 *
1425 * Note: all these operations make calls against a fixed budget.
1426 * You should design your system such that these calls scale sublinearly with your application.
1427 * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists;
1428 * do this once on application start up.
1429 */
1430 export declare class Database {
1431 readonly client: CosmosClient;
1432 readonly id: string;
1433 private clientContext;
1434 /**
1435 * Used for creating new containers, or querying/reading all containers.
1436 *
1437 * Use `.database(id)` to read, replace, or delete a specific, existing {@link Database} by id.
1438 *
1439 * @example Create a new container
1440 * ```typescript
1441 * const {body: containerDefinition, container} = await client.database("<db id>").containers.create({id: "<container id>"});
1442 * ```
1443 */
1444 readonly containers: Containers;
1445 /**
1446 * Used for creating new users, or querying/reading all users.
1447 *
1448 * Use `.user(id)` to read, replace, or delete a specific, existing {@link User} by id.
1449 */
1450 readonly users: Users;
1451 /**
1452 * Returns a reference URL to the resource. Used for linking in Permissions.
1453 */
1454 get url(): string;
1455 /** Returns a new {@link Database} instance.
1456 *
1457 * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself.
1458 */
1459 constructor(client: CosmosClient, id: string, clientContext: ClientContext);
1460 /**
1461 * Used to read, replace, or delete a specific, existing {@link Database} by id.
1462 *
1463 * Use `.containers` creating new containers, or querying/reading all containers.
1464 *
1465 * @example Delete a container
1466 * ```typescript
1467 * await client.database("<db id>").container("<container id>").delete();
1468 * ```
1469 */
1470 container(id: string): Container;
1471 /**
1472 * Used to read, replace, or delete a specific, existing {@link User} by id.
1473 *
1474 * Use `.users` for creating new users, or querying/reading all users.
1475 */
1476 user(id: string): User;
1477 /** Read the definition of the given Database. */
1478 read(options?: RequestOptions): Promise<DatabaseResponse>;
1479 /**
1480 * @hidden
1481 */
1482 readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<DatabaseResponse>;
1483 /** Delete the given Database. */
1484 delete(options?: RequestOptions): Promise<DatabaseResponse>;
1485 /**
1486 * Gets offer on database. If none exists, returns an OfferResponse with undefined.
1487 */
1488 readOffer(options?: RequestOptions): Promise<OfferResponse>;
1489 }
1490
1491 /**
1492 * Represents a DatabaseAccount in the Azure Cosmos DB database service.
1493 */
1494 export declare class DatabaseAccount {
1495 /** The list of writable locations for a geo-replicated database account. */
1496 readonly writableLocations: Location_2[];
1497 /** The list of readable locations for a geo-replicated database account. */
1498 readonly readableLocations: Location_2[];
1499 /**
1500 * The self-link for Databases in the databaseAccount.
1501 * @deprecated Use `databasesLink`
1502 */
1503 get DatabasesLink(): string;
1504 /** The self-link for Databases in the databaseAccount. */
1505 readonly databasesLink: string;
1506 /**
1507 * The self-link for Media in the databaseAccount.
1508 * @deprecated Use `mediaLink`
1509 */
1510 get MediaLink(): string;
1511 /** The self-link for Media in the databaseAccount. */
1512 readonly mediaLink: string;
1513 /**
1514 * Attachment content (media) storage quota in MBs ( Retrieved from gateway ).
1515 * @deprecated use `maxMediaStorageUsageInMB`
1516 */
1517 get MaxMediaStorageUsageInMB(): number;
1518 /** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */
1519 readonly maxMediaStorageUsageInMB: number;
1520 /**
1521 * Current attachment content (media) usage in MBs (Retrieved from gateway )
1522 *
1523 * Value is returned from cached information updated periodically and is not guaranteed
1524 * to be real time.
1525 *
1526 * @deprecated use `currentMediaStorageUsageInMB`
1527 */
1528 get CurrentMediaStorageUsageInMB(): number;
1529 /**
1530 * Current attachment content (media) usage in MBs (Retrieved from gateway )
1531 *
1532 * Value is returned from cached information updated periodically and is not guaranteed
1533 * to be real time.
1534 */
1535 readonly currentMediaStorageUsageInMB: number;
1536 /**
1537 * Gets the UserConsistencyPolicy settings.
1538 * @deprecated use `consistencyPolicy`
1539 */
1540 get ConsistencyPolicy(): ConsistencyLevel;
1541 /** Gets the UserConsistencyPolicy settings. */
1542 readonly consistencyPolicy: ConsistencyLevel;
1543 readonly enableMultipleWritableLocations: boolean;
1544 constructor(body: {
1545 [key: string]: any;
1546 }, headers: CosmosHeaders);
1547 }
1548
1549 export declare interface DatabaseDefinition {
1550 /** The id of the database. */
1551 id?: string;
1552 }
1553
1554 export declare interface DatabaseRequest extends DatabaseDefinition {
1555 /** Throughput for this database. */
1556 throughput?: number;
1557 maxThroughput?: number;
1558 autoUpgradePolicy?: {
1559 throughputPolicy: {
1560 incrementPercent: number;
1561 };
1562 };
1563 }
1564
1565 /** Response object for Database operations */
1566 export declare class DatabaseResponse extends ResourceResponse<DatabaseDefinition & Resource> {
1567 constructor(resource: DatabaseDefinition & Resource, headers: CosmosHeaders, statusCode: number, database: Database, diagnostics: CosmosDiagnostics);
1568 /** A reference to the {@link Database} that the returned {@link DatabaseDefinition} corresponds to. */
1569 readonly database: Database;
1570 }
1571
1572 /**
1573 * Operations for creating new databases, and reading/querying all databases
1574 *
1575 * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`.
1576 *
1577 * Note: all these operations make calls against a fixed budget.
1578 * You should design your system such that these calls scale sublinearly with your application.
1579 * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists;
1580 * do this once on application start up.
1581 */
1582 export declare class Databases {
1583 readonly client: CosmosClient;
1584 private readonly clientContext;
1585 /**
1586 * @hidden
1587 * @param client - The parent {@link CosmosClient} for the Database.
1588 */
1589 constructor(client: CosmosClient, clientContext: ClientContext);
1590 /**
1591 * Queries all databases.
1592 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1593 * @param options - Use to set options like response page size, continuation tokens, etc.
1594 * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.
1595 * @example Read all databases to array.
1596 * ```typescript
1597 * const querySpec: SqlQuerySpec = {
1598 * query: "SELECT * FROM root r WHERE r.id = @db",
1599 * parameters: [
1600 * {name: "@db", value: "Todo"}
1601 * ]
1602 * };
1603 * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();
1604 * ```
1605 */
1606 query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
1607 /**
1608 * Queries all databases.
1609 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1610 * @param options - Use to set options like response page size, continuation tokens, etc.
1611 * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.
1612 * @example Read all databases to array.
1613 * ```typescript
1614 * const querySpec: SqlQuerySpec = {
1615 * query: "SELECT * FROM root r WHERE r.id = @db",
1616 * parameters: [
1617 * {name: "@db", value: "Todo"}
1618 * ]
1619 * };
1620 * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();
1621 * ```
1622 */
1623 query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
1624 /**
1625 * Send a request for creating a database.
1626 *
1627 * A database manages users, permissions and a set of containers.
1628 * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,
1629 * with the database being the logical container for data.
1630 *
1631 * Each Database consists of one or more containers, each of which in turn contain one or more
1632 * documents. Since databases are an administrative resource, the Service Master Key will be
1633 * required in order to access and successfully complete any action using the User APIs.
1634 *
1635 * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.
1636 * @param options - Use to set options like response page size, continuation tokens, etc.
1637 */
1638 create(body: DatabaseRequest, options?: RequestOptions): Promise<DatabaseResponse>;
1639 /**
1640 * @hidden
1641 */
1642 createInternal(diagnosticNode: DiagnosticNodeInternal, body: DatabaseRequest, options?: RequestOptions): Promise<DatabaseResponse>;
1643 /**
1644 * Check if a database exists, and if it doesn't, create it.
1645 * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.
1646 *
1647 * A database manages users, permissions and a set of containers.
1648 * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,
1649 * with the database being the logical container for data.
1650 *
1651 * Each Database consists of one or more containers, each of which in turn contain one or more
1652 * documents. Since databases are an an administrative resource, the Service Master Key will be
1653 * required in order to access and successfully complete any action using the User APIs.
1654 *
1655 * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.
1656 * @param options - Additional options for the request
1657 */
1658 createIfNotExists(body: DatabaseRequest, options?: RequestOptions): Promise<DatabaseResponse>;
1659 /**
1660 * Reads all databases.
1661 * @param options - Use to set options like response page size, continuation tokens, etc.
1662 * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.
1663 * @example Read all databases to array.
1664 * ```typescript
1665 * const {body: databaseList} = await client.databases.readAll().fetchAll();
1666 * ```
1667 */
1668 readAll(options?: FeedOptions): QueryIterator<DatabaseDefinition & Resource>;
1669 }
1670
1671 /** Defines a target data type of an index path specification in the Azure Cosmos DB service. */
1672 export declare enum DataType {
1673 /** Represents a numeric data type. */
1674 Number = "Number",
1675 /** Represents a string data type. */
1676 String = "String",
1677 /** Represents a point data type. */
1678 Point = "Point",
1679 /** Represents a line string data type. */
1680 LineString = "LineString",
1681 /** Represents a polygon data type. */
1682 Polygon = "Polygon",
1683 /** Represents a multi-polygon data type. */
1684 MultiPolygon = "MultiPolygon"
1685 }
1686
1687 export declare const DEFAULT_PARTITION_KEY_PATH: "/_partitionKey";
1688
1689 export declare type DeleteOperation = OperationBase & {
1690 operationType: typeof BulkOperationType.Delete;
1691 id: string;
1692 };
1693
1694 export declare interface DeleteOperationInput {
1695 partitionKey?: PartitionKey;
1696 operationType: typeof BulkOperationType.Delete;
1697 id: string;
1698 }
1699
1700 /**
1701 * @hidden
1702 */
1703 export declare type DiagnosticDataValue = {
1704 selectedLocation: string;
1705 activityId: string;
1706 requestAttempNumber: number;
1707 requestPayloadLengthInBytes: number;
1708 responsePayloadLengthInBytes: number;
1709 responseStatus: number;
1710 readFromCache: boolean;
1711 operationType: OperationType;
1712 metadatOperationType: MetadataLookUpType;
1713 resourceType: ResourceType;
1714 failedAttempty: boolean;
1715 successfulRetryPolicy: string;
1716 partitionKeyRangeId: string;
1717 stateful: boolean;
1718 queryRecordsRead: number;
1719 queryMethodIdentifier: string;
1720 log: string[];
1721 failure: boolean;
1722 startTimeUTCInMs: number;
1723 durationInMs: number;
1724 requestData: Partial<{
1725 requestPayloadLengthInBytes: number;
1726 responsePayloadLengthInBytes: number;
1727 operationType: OperationType;
1728 resourceType: ResourceType;
1729 headers: CosmosHeaders_2;
1730 requestBody: any;
1731 responseBody: any;
1732 url: string;
1733 }>;
1734 };
1735
1736 /**
1737 * Represents a tree like structure, for capturing diagnostic information.
1738 */
1739 export declare interface DiagnosticNode {
1740 id: string;
1741 nodeType: string;
1742 children: DiagnosticNode[];
1743 data: {
1744 [key: string]: any;
1745 };
1746 startTimeUTCInMs: number;
1747 durationInMs: number;
1748 }
1749
1750 /**
1751 * @hidden
1752 * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect
1753 * diagnostic information throughout the lifetime of Diagnostic session.
1754 * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart.
1755 */
1756 export declare class DiagnosticNodeInternal implements DiagnosticNode {
1757 id: string;
1758 nodeType: DiagnosticNodeType;
1759 parent: DiagnosticNodeInternal;
1760 children: DiagnosticNodeInternal[];
1761 data: Partial<DiagnosticDataValue>;
1762 startTimeUTCInMs: number;
1763 durationInMs: number;
1764 diagnosticLevel: CosmosDbDiagnosticLevel;
1765 private diagnosticCtx;
1766 }
1767
1768 /**
1769 * @hidden
1770 */
1771 export declare enum DiagnosticNodeType {
1772 CLIENT_REQUEST_NODE = "CLIENT_REQUEST_NODE",
1773 METADATA_REQUEST_NODE = "METADATA_REQUEST_NODE",
1774 HTTP_REQUEST = "HTTP_REQUEST",
1775 BATCH_REQUEST = "BATCH_REQUEST",
1776 PARALLEL_QUERY_NODE = "PARALLEL_QUERY_NODE",
1777 DEFAULT_QUERY_NODE = "DEFAULT_QUERY_NODE",
1778 QUERY_REPAIR_NODE = "QUERY_REPAIR_NODE",
1779 BACKGROUND_REFRESH_THREAD = "BACKGROUND_REFRESH_THREAD",
1780 REQUEST_ATTEMPTS = "REQUEST_ATTEMPTS"
1781 }
1782
1783 export declare interface ErrorBody {
1784 code: string;
1785 message: string;
1786 /**
1787 * @hidden
1788 */
1789 additionalErrorInfo?: PartitionedQueryExecutionInfo;
1790 }
1791
1792 export declare class ErrorResponse extends Error {
1793 code?: number | string;
1794 substatus?: number;
1795 body?: ErrorBody;
1796 headers?: CosmosHeaders;
1797 activityId?: string;
1798 retryAfterInMs?: number;
1799 retryAfterInMilliseconds?: number;
1800 [key: string]: any;
1801 diagnostics?: CosmosDiagnostics;
1802 }
1803
1804 export declare type ExistingKeyOperation = {
1805 op: keyof typeof PatchOperationType;
1806 value: any;
1807 path: string;
1808 };
1809
1810 /**
1811 * This type captures diagnostic information regarding a failed request to server api.
1812 */
1813 export declare interface FailedRequestAttemptDiagnostic {
1814 attemptNumber: number;
1815 activityId: string;
1816 startTimeUTCInMs: number;
1817 durationInMs: number;
1818 operationType?: OperationType;
1819 resourceType?: ResourceType;
1820 statusCode: number;
1821 substatusCode?: number;
1822 requestPayloadLengthInBytes: number;
1823 responsePayloadLengthInBytes: number;
1824 }
1825
1826 /**
1827 * The feed options and query methods.
1828 */
1829 export declare interface FeedOptions extends SharedOptions {
1830 /** Opaque token for continuing the enumeration. Default: undefined
1831 * @deprecated Use continuationToken instead.
1832 */
1833 continuation?: string;
1834 /** Opaque token for continuing the enumeration. Default: undefined */
1835 continuationToken?: string;
1836 /**
1837 * Limits the size of the continuation token in the response. Default: undefined
1838 *
1839 * Continuation Tokens contain optional data that can be removed from the serialization before writing it out to a header.
1840 * By default we are capping this to 1kb to avoid long headers (Node.js has a global header size limit).
1841 * A user may set this field to allow for longer headers, which can help the backend optimize query execution."
1842 */
1843 continuationTokenLimitInKB?: number;
1844 /**
1845 * Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths. Default: false
1846 *
1847 * In general, it is best to avoid using this setting. Scans are relatively expensive and take a long time to serve.
1848 */
1849 enableScanInQuery?: boolean;
1850 /**
1851 * The maximum number of concurrent operations that run client side during parallel query execution in the
1852 * Azure Cosmos DB database service. Negative values make the system automatically decides the number of
1853 * concurrent operations to run. Default: 0 (no parallelism)
1854 */
1855 maxDegreeOfParallelism?: number;
1856 /**
1857 * Max number of items to be returned in the enumeration operation. Default: undefined (server will defined payload)
1858 *
1859 * Expirimenting with this value can usually result in the biggest performance changes to the query.
1860 *
1861 * The smaller the item count, the faster the first result will be delivered (for non-aggregates). For larger amounts,
1862 * 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
1863 * 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.)
1864 */
1865 maxItemCount?: number;
1866 /**
1867 * Note: consider using changeFeed instead.
1868 *
1869 * Indicates a change feed request. Must be set to "Incremental feed", or omitted otherwise. Default: false
1870 */
1871 useIncrementalFeed?: boolean;
1872 /** Conditions Associated with the request. */
1873 accessCondition?: {
1874 /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */
1875 type: string;
1876 /** Conditional HTTP method header value (the _etag field from the last version you read). */
1877 condition: string;
1878 };
1879 /**
1880 * Enable returning query metrics in response headers. Default: false
1881 *
1882 * Used for debugging slow or expensive queries. Also increases response size and if you're using a low max header size in Node.js,
1883 * you can run into issues faster.
1884 */
1885 populateQueryMetrics?: boolean;
1886 /**
1887 * Enable buffering additional items during queries. Default: false
1888 *
1889 * This will buffer an additional page at a time (multiplied by maxDegreeOfParallelism) from the server in the background.
1890 * This improves latency by fetching pages before they are needed by the client. If you're draining all of the results from the
1891 * server, like `.fetchAll`, you should usually enable this. If you're only fetching one page at a time via continuation token,
1892 * you should avoid this. If you're draining more than one page, but not the entire result set, it may help improve latency, but
1893 * it will increase the total amount of RU/s use to serve the entire query (as some pages will be fetched more than once).
1894 */
1895 bufferItems?: boolean;
1896 /**
1897 * This setting forces the query to use a query plan. Default: false
1898 *
1899 * Note: this will disable continuation token support, even for single partition queries.
1900 *
1901 * For queries like aggregates and most cross partition queries, this happens anyway.
1902 * However, since the library doesn't know what type of query it is until we get back the first response,
1903 * some optimization can't happen until later.
1904 *
1905 * If this setting is enabled, it will force query plan for the query, which will save some network requests
1906 * and ensure parallelism can happen. Useful for when you know you're doing cross-partition or aggregate queries.
1907 */
1908 forceQueryPlan?: boolean;
1909 /** Limits the query to a specific partition key. Default: undefined
1910 *
1911 * Scoping a query to a single partition can be accomplished two ways:
1912 *
1913 * `container.items.query('SELECT * from c', { partitionKey: "foo" }).toArray()`
1914 * `container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray()`
1915 *
1916 * The former is useful when the query body is out of your control
1917 * but you still want to restrict it to a single partition. Example: an end user specified query.
1918 */
1919 partitionKey?: PartitionKey;
1920 /**
1921 * Enable returning index metrics in response headers. Default: false
1922 */
1923 populateIndexMetrics?: boolean;
1924 }
1925
1926 /**
1927 * Specifies a feed range for the changefeed.
1928 */
1929 export declare abstract class FeedRange {
1930 /**
1931 * Min value for the feed range.
1932 */
1933 readonly minInclusive: string;
1934 /**
1935 * Max value for the feed range.
1936 */
1937 readonly maxExclusive: string;
1938 }
1939
1940 export declare class FeedResponse<TResource> {
1941 readonly resources: TResource[];
1942 private readonly headers;
1943 readonly hasMoreResults: boolean;
1944 readonly diagnostics: CosmosDiagnostics;
1945 constructor(resources: TResource[], headers: CosmosHeaders, hasMoreResults: boolean, diagnostics: CosmosDiagnostics);
1946 get continuation(): string;
1947 get continuationToken(): string;
1948 get queryMetrics(): string;
1949 get requestCharge(): number;
1950 get activityId(): string;
1951 get indexMetrics(): string;
1952 }
1953
1954 /** @hidden */
1955 declare type FetchFunctionCallback = (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions) => Promise<Response_2<any>>;
1956
1957 export declare type GatewayStatistics = {
1958 /**
1959 * This is the activityId for request, made to server for fetching the requested resource. (As opposed to other potential meta data requests)
1960 */
1961 activityId?: string;
1962 startTimeUTCInMs: number;
1963 durationInMs: number;
1964 operationType?: OperationType;
1965 resourceType?: ResourceType;
1966 statusCode?: number;
1967 subStatusCode?: number;
1968 requestCharge?: number;
1969 requestPayloadLengthInBytes: number;
1970 responsePayloadLengthInBytes: number;
1971 };
1972
1973 export declare enum GeospatialType {
1974 /** Represents data in round-earth coordinate system. */
1975 Geography = "Geography",
1976 /** Represents data in Eucledian(flat) coordinate system. */
1977 Geometry = "Geometry"
1978 }
1979
1980 /**
1981 * @hidden
1982 * This internal class implements the logic for endpoint management for geo-replicated database accounts.
1983 */
1984 export declare class GlobalEndpointManager {
1985 private readDatabaseAccount;
1986 /**
1987 * The endpoint used to create the client instance.
1988 */
1989 private defaultEndpoint;
1990 /**
1991 * Flag to enable/disable automatic redirecting of requests based on read/write operations.
1992 */
1993 enableEndpointDiscovery: boolean;
1994 private isRefreshing;
1995 private options;
1996 /**
1997 * List of azure regions to be used as preferred locations for read requests.
1998 */
1999 private preferredLocations;
2000 private writeableLocations;
2001 private readableLocations;
2002 private unavailableReadableLocations;
2003 private unavailableWriteableLocations;
2004 preferredLocationsCount: number;
2005 /**
2006 * Gets the current read endpoint from the endpoint cache.
2007 */
2008 getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
2009 /**
2010 * Gets the current write endpoint from the endpoint cache.
2011 */
2012 getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
2013 getReadEndpoints(): Promise<ReadonlyArray<string>>;
2014 getWriteEndpoints(): Promise<ReadonlyArray<string>>;
2015 markCurrentLocationUnavailableForRead(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise<void>;
2016 markCurrentLocationUnavailableForWrite(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise<void>;
2017 canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean;
2018 resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise<string>;
2019 /**
2020 * Refreshes the endpoint list by clearning stale unavailability and then
2021 * retrieving the writable and readable locations from the geo-replicated database account
2022 * and then updating the locations cache.
2023 * We skip the refreshing if enableEndpointDiscovery is set to False
2024 */
2025 refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise<void>;
2026 private refreshEndpoints;
2027 private refreshStaleUnavailableLocations;
2028 /**
2029 * update the locationUnavailability to undefined if the location is available again
2030 * @param now - current time
2031 * @param unavailableLocations - list of unavailable locations
2032 * @param allLocations - list of all locations
2033 */
2034 private updateLocation;
2035 private cleanUnavailableLocationList;
2036 /**
2037 * Gets the database account first by using the default endpoint, and if that doesn't returns
2038 * use the endpoints for the preferred locations in the order they are specified to get
2039 * the database account.
2040 */
2041 private getDatabaseAccountFromAnyEndpoint;
2042 /**
2043 * Gets the locational endpoint using the location name passed to it using the default endpoint.
2044 *
2045 * @param defaultEndpoint - The default endpoint to use for the endpoint.
2046 * @param locationName - The location name for the azure region like "East US".
2047 */
2048 private static getLocationalEndpoint;
2049 }
2050
2051 export declare interface GroupByAliasToAggregateType {
2052 [key: string]: AggregateType;
2053 }
2054
2055 export declare type GroupByExpressions = string[];
2056
2057 /**
2058 * @hidden
2059 */
2060 export declare enum HTTPMethod {
2061 get = "GET",
2062 patch = "PATCH",
2063 post = "POST",
2064 put = "PUT",
2065 delete = "DELETE"
2066 }
2067
2068 export declare interface Index {
2069 kind: keyof typeof IndexKind;
2070 dataType: keyof typeof DataType;
2071 precision?: number;
2072 }
2073
2074 export declare interface IndexedPath {
2075 path: string;
2076 indexes?: Index[];
2077 }
2078
2079 /**
2080 * Specifies the supported indexing modes.
2081 */
2082 export declare enum IndexingMode {
2083 /**
2084 * Index is updated synchronously with a create or update operation.
2085 *
2086 * With consistent indexing, query behavior is the same as the default consistency level for the container.
2087 * The index is always kept up to date with the data.
2088 */
2089 consistent = "consistent",
2090 /**
2091 * Index is updated asynchronously with respect to a create or update operation.
2092 *
2093 * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle.
2094 */
2095 lazy = "lazy",
2096 /** No Index is provided. */
2097 none = "none"
2098 }
2099
2100 export declare interface IndexingPolicy {
2101 /** The indexing mode (consistent or lazy) {@link IndexingMode}. */
2102 indexingMode?: keyof typeof IndexingMode;
2103 automatic?: boolean;
2104 /** An array of {@link IncludedPath} represents the paths to be included for indexing. */
2105 includedPaths?: IndexedPath[];
2106 /** An array of {@link IncludedPath} represents the paths to be excluded for indexing. */
2107 excludedPaths?: IndexedPath[];
2108 spatialIndexes?: SpatialIndex[];
2109 }
2110
2111 /**
2112 * Specifies the supported Index types.
2113 */
2114 export declare enum IndexKind {
2115 /**
2116 * This is supplied for a path which requires sorting.
2117 */
2118 Range = "Range",
2119 /**
2120 * This is supplied for a path which requires geospatial indexing.
2121 */
2122 Spatial = "Spatial"
2123 }
2124
2125 /**
2126 * Used to perform operations on a specific item.
2127 *
2128 * @see {@link Items} for operations on all items; see `container.items`.
2129 */
2130 export declare class Item {
2131 readonly container: Container;
2132 readonly id: string;
2133 private readonly clientContext;
2134 private partitionKey;
2135 /**
2136 * Returns a reference URL to the resource. Used for linking in Permissions.
2137 */
2138 get url(): string;
2139 /**
2140 * @hidden
2141 * @param container - The parent {@link Container}.
2142 * @param id - The id of the given {@link Item}.
2143 * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers).
2144 */
2145 constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey);
2146 /**
2147 * Read the item's definition.
2148 *
2149 * Any provided type, T, is not necessarily enforced by the SDK.
2150 * You may get more or less properties and it's up to your logic to enforce it.
2151 * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype.
2152 * It's recommended to only use interfaces.
2153 *
2154 * There is no set schema for JSON items. They may contain any number of custom properties.
2155 *
2156 * @param options - Additional options for the request
2157 *
2158 * @example Using custom type for response
2159 * ```typescript
2160 * interface TodoItem {
2161 * title: string;
2162 * done: bool;
2163 * id: string;
2164 * }
2165 *
2166 * let item: TodoItem;
2167 * ({body: item} = await item.read<TodoItem>());
2168 * ```
2169 */
2170 read<T extends ItemDefinition = any>(options?: RequestOptions): Promise<ItemResponse<T>>;
2171 /**
2172 * Replace the item's definition.
2173 *
2174 * There is no set schema for JSON items. They may contain any number of custom properties.
2175 *
2176 * @param body - The definition to replace the existing {@link Item}'s definition with.
2177 * @param options - Additional options for the request
2178 */
2179 replace(body: ItemDefinition, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>;
2180 /**
2181 * Replace the item's definition.
2182 *
2183 * Any provided type, T, is not necessarily enforced by the SDK.
2184 * You may get more or less properties and it's up to your logic to enforce it.
2185 *
2186 * There is no set schema for JSON items. They may contain any number of custom properties.
2187 *
2188 * @param body - The definition to replace the existing {@link Item}'s definition with.
2189 * @param options - Additional options for the request
2190 */
2191 replace<T extends ItemDefinition>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
2192 /**
2193 * Delete the item.
2194 *
2195 * Any provided type, T, is not necessarily enforced by the SDK.
2196 * You may get more or less properties and it's up to your logic to enforce it.
2197 *
2198 * @param options - Additional options for the request
2199 */
2200 delete<T extends ItemDefinition = any>(options?: RequestOptions): Promise<ItemResponse<T>>;
2201 /**
2202 * Perform a JSONPatch on the item.
2203 *
2204 * Any provided type, T, is not necessarily enforced by the SDK.
2205 * You may get more or less properties and it's up to your logic to enforce it.
2206 *
2207 * @param options - Additional options for the request
2208 */
2209 patch<T extends ItemDefinition = any>(body: PatchRequestBody, options?: RequestOptions): Promise<ItemResponse<T>>;
2210 }
2211
2212 /**
2213 * Items in Cosmos DB are simply JSON objects.
2214 * Most of the Item operations allow for your to provide your own type
2215 * that extends the very simple ItemDefinition.
2216 *
2217 * You cannot use any reserved keys. You can see the reserved key list
2218 * in {@link ItemBody}
2219 */
2220 export declare interface ItemDefinition {
2221 /** The id of the item. User settable property. Uniquely identifies the item along with the partition key */
2222 id?: string;
2223 /** Time to live in seconds for collections with TTL enabled */
2224 ttl?: number;
2225 [key: string]: any;
2226 }
2227
2228 export declare class ItemResponse<T extends ItemDefinition> extends ResourceResponse<T & Resource> {
2229 constructor(resource: T & Resource, headers: CosmosHeaders, statusCode: number, subsstatusCode: number, item: Item, diagnostics: CosmosDiagnostics);
2230 /** Reference to the {@link Item} the response corresponds to. */
2231 readonly item: Item;
2232 }
2233
2234 /**
2235 * Operations for creating new items, and reading/querying all items
2236 *
2237 * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`.
2238 */
2239 export declare class Items {
2240 readonly container: Container;
2241 private readonly clientContext;
2242 private partitionKeyRangeCache;
2243 /**
2244 * Create an instance of {@link Items} linked to the parent {@link Container}.
2245 * @param container - The parent container.
2246 * @hidden
2247 */
2248 constructor(container: Container, clientContext: ClientContext);
2249 /**
2250 * Queries all items.
2251 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2252 * @param options - Used for modifying the request (for instance, specifying the partition key).
2253 * @example Read all items to array.
2254 * ```typescript
2255 * const querySpec: SqlQuerySpec = {
2256 * query: "SELECT * FROM Families f WHERE f.lastName = @lastName",
2257 * parameters: [
2258 * {name: "@lastName", value: "Hendricks"}
2259 * ]
2260 * };
2261 * const {result: items} = await items.query(querySpec).fetchAll();
2262 * ```
2263 */
2264 query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
2265 /**
2266 * Queries all items.
2267 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2268 * @param options - Used for modifying the request (for instance, specifying the partition key).
2269 * @example Read all items to array.
2270 * ```typescript
2271 * const querySpec: SqlQuerySpec = {
2272 * query: "SELECT firstname FROM Families f WHERE f.lastName = @lastName",
2273 * parameters: [
2274 * {name: "@lastName", value: "Hendricks"}
2275 * ]
2276 * };
2277 * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll();
2278 * ```
2279 */
2280 query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
2281 /**
2282 * Create a `ChangeFeedIterator` to iterate over pages of changes
2283 *
2284 * @deprecated Use `changeFeed` instead.
2285 *
2286 * @example Read from the beginning of the change feed.
2287 * ```javascript
2288 * const iterator = items.readChangeFeed({ startFromBeginning: true });
2289 * const firstPage = await iterator.fetchNext();
2290 * const firstPageResults = firstPage.result
2291 * const secondPage = await iterator.fetchNext();
2292 * ```
2293 */
2294 readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2295 /**
2296 * Create a `ChangeFeedIterator` to iterate over pages of changes
2297 * @deprecated Use `changeFeed` instead.
2298 *
2299 */
2300 readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2301 /**
2302 * Create a `ChangeFeedIterator` to iterate over pages of changes
2303 * @deprecated Use `changeFeed` instead.
2304 */
2305 readChangeFeed<T>(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2306 /**
2307 * Create a `ChangeFeedIterator` to iterate over pages of changes
2308 * @deprecated Use `changeFeed` instead.
2309 */
2310 readChangeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2311 /**
2312 * Create a `ChangeFeedIterator` to iterate over pages of changes
2313 *
2314 * @example Read from the beginning of the change feed.
2315 * ```javascript
2316 * const iterator = items.readChangeFeed({ startFromBeginning: true });
2317 * const firstPage = await iterator.fetchNext();
2318 * const firstPageResults = firstPage.result
2319 * const secondPage = await iterator.fetchNext();
2320 * ```
2321 */
2322 changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2323 /**
2324 * Create a `ChangeFeedIterator` to iterate over pages of changes
2325 */
2326 changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2327 /**
2328 * Create a `ChangeFeedIterator` to iterate over pages of changes
2329 */
2330 changeFeed<T>(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2331 /**
2332 * Create a `ChangeFeedIterator` to iterate over pages of changes
2333 */
2334 changeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2335 /**
2336 * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container.
2337 */
2338 getChangeFeedIterator<T>(changeFeedIteratorOptions?: ChangeFeedIteratorOptions): ChangeFeedPullModelIterator<T>;
2339 /**
2340 * Read all items.
2341 *
2342 * There is no set schema for JSON items. They may contain any number of custom properties.
2343 *
2344 * @param options - Used for modifying the request (for instance, specifying the partition key).
2345 * @example Read all items to array.
2346 * ```typescript
2347 * const {body: containerList} = await items.readAll().fetchAll();
2348 * ```
2349 */
2350 readAll(options?: FeedOptions): QueryIterator<ItemDefinition>;
2351 /**
2352 * Read all items.
2353 *
2354 * Any provided type, T, is not necessarily enforced by the SDK.
2355 * You may get more or less properties and it's up to your logic to enforce it.
2356 *
2357 * There is no set schema for JSON items. They may contain any number of custom properties.
2358 *
2359 * @param options - Used for modifying the request (for instance, specifying the partition key).
2360 * @example Read all items to array.
2361 * ```typescript
2362 * const {body: containerList} = await items.readAll().fetchAll();
2363 * ```
2364 */
2365 readAll<T extends ItemDefinition>(options?: FeedOptions): QueryIterator<T>;
2366 /**
2367 * Create an item.
2368 *
2369 * Any provided type, T, is not necessarily enforced by the SDK.
2370 * You may get more or less properties and it's up to your logic to enforce it.
2371 *
2372 * There is no set schema for JSON items. They may contain any number of custom properties.
2373 *
2374 * @param body - Represents the body of the item. Can contain any number of user defined properties.
2375 * @param options - Used for modifying the request (for instance, specifying the partition key).
2376 */
2377 create<T extends ItemDefinition = any>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
2378 /**
2379 * Upsert an item.
2380 *
2381 * There is no set schema for JSON items. They may contain any number of custom properties.
2382 *
2383 * @param body - Represents the body of the item. Can contain any number of user defined properties.
2384 * @param options - Used for modifying the request (for instance, specifying the partition key).
2385 */
2386 upsert(body: unknown, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>;
2387 /**
2388 * Upsert an item.
2389 *
2390 * Any provided type, T, is not necessarily enforced by the SDK.
2391 * You may get more or less properties and it's up to your logic to enforce it.
2392 *
2393 * There is no set schema for JSON items. They may contain any number of custom properties.
2394 *
2395 * @param body - Represents the body of the item. Can contain any number of user defined properties.
2396 * @param options - Used for modifying the request (for instance, specifying the partition key).
2397 */
2398 upsert<T extends ItemDefinition>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
2399 /**
2400 * Execute bulk operations on items.
2401 *
2402 * Bulk takes an array of Operations which are typed based on what the operation does.
2403 * The choices are: Create, Upsert, Read, Replace, and Delete
2404 *
2405 * Usage example:
2406 * ```typescript
2407 * // partitionKey is optional at the top level if present in the resourceBody
2408 * const operations: OperationInput[] = [
2409 * {
2410 * operationType: "Create",
2411 * resourceBody: { id: "doc1", name: "sample", key: "A" }
2412 * },
2413 * {
2414 * operationType: "Upsert",
2415 * partitionKey: 'A',
2416 * resourceBody: { id: "doc2", name: "other", key: "A" }
2417 * }
2418 * ]
2419 *
2420 * await database.container.items.bulk(operations)
2421 * ```
2422 *
2423 * @param operations - List of operations. Limit 100
2424 * @param bulkOptions - Optional options object to modify bulk behavior. Pass \{ continueOnError: true \} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE
2425 * @param options - Used for modifying the request.
2426 */
2427 bulk(operations: OperationInput[], bulkOptions?: BulkOptions, options?: RequestOptions): Promise<BulkOperationResponse>;
2428 /**
2429 * Function to create batches based of partition key Ranges.
2430 * @param operations - operations to group
2431 * @param partitionDefinition - PartitionKey definition of container.
2432 * @param options - Request options for bulk request.
2433 * @param batches - Groups to be filled with operations.
2434 */
2435 private groupOperationsBasedOnPartitionKey;
2436 /**
2437 * Execute transactional batch operations on items.
2438 *
2439 * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails.
2440 * The choices are: Create, Upsert, Read, Replace, and Delete
2441 *
2442 * Usage example:
2443 * ```typescript
2444 * // partitionKey is required as a second argument to batch, but defaults to the default partition key
2445 * const operations: OperationInput[] = [
2446 * {
2447 * operationType: "Create",
2448 * resourceBody: { id: "doc1", name: "sample", key: "A" }
2449 * },
2450 * {
2451 * operationType: "Upsert",
2452 * partitionKey: 'A',
2453 * resourceBody: { id: "doc2", name: "other", key: "A" }
2454 * }
2455 * ]
2456 *
2457 * await database.container.items.batch(operations)
2458 * ```
2459 *
2460 * @param operations - List of operations. Limit 100
2461 * @param options - Used for modifying the request
2462 */
2463 batch(operations: OperationInput[], partitionKey?: PartitionKey, options?: RequestOptions): Promise<Response_2<OperationResponse[]>>;
2464 }
2465
2466 export declare interface JSONArray extends ArrayLike<JSONValue> {
2467 }
2468
2469 export declare interface JSONObject {
2470 [key: string]: JSONValue;
2471 }
2472
2473 export declare type JSONValue = boolean | number | string | null | JSONArray | JSONObject;
2474
2475 /**
2476 * Used to specify the locations that are available, read is index 1 and write is index 0.
2477 */
2478 declare interface Location_2 {
2479 name: string;
2480 databaseAccountEndpoint: string;
2481 unavailable?: boolean;
2482 lastUnavailabilityTimestampInMs?: number;
2483 }
2484 export { Location_2 as Location }
2485
2486 /**
2487 * This type contains diagnostic information regarding a single metadata request to server.
2488 */
2489 export declare interface MetadataLookUpDiagnostic {
2490 activityId: string;
2491 startTimeUTCInMs: number;
2492 durationInMs: number;
2493 operationType?: OperationType;
2494 resourceType?: ResourceType;
2495 metaDataType: MetadataLookUpType;
2496 requestPayloadLengthInBytes: number;
2497 responsePayloadLengthInBytes: number;
2498 }
2499
2500 /**
2501 * This type contains diagnostic information regarding all metadata request to server during an CosmosDB client operation.
2502 */
2503 export declare type MetadataLookUpDiagnostics = {
2504 metadataLookups: MetadataLookUpDiagnostic[];
2505 };
2506
2507 /**
2508 * This is enum for Type of Metadata lookups possible.
2509 */
2510 export declare enum MetadataLookUpType {
2511 PartitionKeyRangeLookUp = "PARTITION_KEY_RANGE_LOOK_UP",
2512 DatabaseAccountLookUp = "DATABASE_ACCOUNT_LOOK_UP",
2513 QueryPlanLookUp = "QUERY_PLAN_LOOK_UP",
2514 DatabaseLookUp = "DATABASE_LOOK_UP",
2515 ContainerLookUp = "CONTAINER_LOOK_UP"
2516 }
2517
2518 /**
2519 * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins,
2520 * allowing you to log those results or handle errors.
2521 * @hidden
2522 */
2523 export declare type Next<T> = (context: RequestContext) => Promise<Response_2<T>>;
2524
2525 /**
2526 * The returned object represents a partition key value that allows creating and accessing items
2527 * without a value for partition key
2528 */
2529 export declare type NonePartitionKeyType = {
2530 [K in any]: never;
2531 };
2532
2533 /**
2534 * The returned object represents a partition key value that allows creating and accessing items
2535 * with a null value for the partition key.
2536 */
2537 export declare type NullPartitionKeyType = null;
2538
2539 /**
2540 * Use to read or replace an existing {@link Offer} by id.
2541 *
2542 * @see {@link Offers} to query or read all offers.
2543 */
2544 export declare class Offer {
2545 readonly client: CosmosClient;
2546 readonly id: string;
2547 private readonly clientContext;
2548 /**
2549 * Returns a reference URL to the resource. Used for linking in Permissions.
2550 */
2551 get url(): string;
2552 /**
2553 * @hidden
2554 * @param client - The parent {@link CosmosClient} for the Database Account.
2555 * @param id - The id of the given {@link Offer}.
2556 */
2557 constructor(client: CosmosClient, id: string, clientContext: ClientContext);
2558 /**
2559 * Read the {@link OfferDefinition} for the given {@link Offer}.
2560 */
2561 read(options?: RequestOptions): Promise<OfferResponse>;
2562 /**
2563 * Replace the given {@link Offer} with the specified {@link OfferDefinition}.
2564 * @param body - The specified {@link OfferDefinition}
2565 */
2566 replace(body: OfferDefinition, options?: RequestOptions): Promise<OfferResponse>;
2567 }
2568
2569 export declare interface OfferDefinition {
2570 id?: string;
2571 offerType?: string;
2572 offerVersion?: string;
2573 resource?: string;
2574 offerResourceId?: string;
2575 content?: {
2576 offerThroughput: number;
2577 offerIsRUPerMinuteThroughputEnabled: boolean;
2578 offerMinimumThroughputParameters?: {
2579 maxThroughputEverProvisioned: number;
2580 maxConsumedStorageEverInKB: number;
2581 };
2582 offerAutopilotSettings?: {
2583 tier: number;
2584 maximumTierThroughput: number;
2585 autoUpgrade: boolean;
2586 maxThroughput: number;
2587 };
2588 };
2589 }
2590
2591 export declare class OfferResponse extends ResourceResponse<OfferDefinition & Resource> {
2592 constructor(resource: OfferDefinition & Resource, headers: CosmosHeaders, statusCode: number, diagnostics: CosmosDiagnostics, offer?: Offer);
2593 /** A reference to the {@link Offer} corresponding to the returned {@link OfferDefinition}. */
2594 readonly offer: Offer;
2595 }
2596
2597 /**
2598 * Use to query or read all Offers.
2599 *
2600 * @see {@link Offer} to read or replace an existing {@link Offer} by id.
2601 */
2602 export declare class Offers {
2603 readonly client: CosmosClient;
2604 private readonly clientContext;
2605 /**
2606 * @hidden
2607 * @param client - The parent {@link CosmosClient} for the offers.
2608 */
2609 constructor(client: CosmosClient, clientContext: ClientContext);
2610 /**
2611 * Query all offers.
2612 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2613 */
2614 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
2615 /**
2616 * Query all offers.
2617 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2618 */
2619 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
2620 /**
2621 * Read all offers.
2622 * @example Read all offers to array.
2623 * ```typescript
2624 * const {body: offerList} = await client.offers.readAll().fetchAll();
2625 * ```
2626 */
2627 readAll(options?: FeedOptions): QueryIterator<OfferDefinition & Resource>;
2628 }
2629
2630 export declare type Operation = CreateOperation | UpsertOperation | ReadOperation | DeleteOperation | ReplaceOperation | BulkPatchOperation;
2631
2632 export declare interface OperationBase {
2633 partitionKey?: string;
2634 ifMatch?: string;
2635 ifNoneMatch?: string;
2636 }
2637
2638 export declare type OperationInput = CreateOperationInput | UpsertOperationInput | ReadOperationInput | DeleteOperationInput | ReplaceOperationInput | PatchOperationInput;
2639
2640 export declare interface OperationResponse {
2641 statusCode: number;
2642 requestCharge: number;
2643 eTag?: string;
2644 resourceBody?: JSONObject;
2645 }
2646
2647 /**
2648 * @hidden
2649 */
2650 export declare enum OperationType {
2651 Create = "create",
2652 Replace = "replace",
2653 Upsert = "upsert",
2654 Delete = "delete",
2655 Read = "read",
2656 Query = "query",
2657 Execute = "execute",
2658 Batch = "batch",
2659 Patch = "patch"
2660 }
2661
2662 export declare type OperationWithItem = OperationBase & {
2663 resourceBody: JSONObject;
2664 };
2665
2666 /**
2667 * @hidden
2668 */
2669 export declare interface PartitionedQueryExecutionInfo {
2670 partitionedQueryExecutionInfoVersion: number;
2671 queryInfo: QueryInfo;
2672 queryRanges: QueryRange[];
2673 }
2674
2675 /**
2676 * PartitionKey of a container.
2677 * @remarks
2678 * - PartitionKeyDefinition is no longer part of PartitionKey. So please use PartitionKeyDefinition
2679 * type directly where appropriate.
2680 */
2681 export declare type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[];
2682
2683 /**
2684 * Builder class for building PartitionKey.
2685 */
2686 export declare class PartitionKeyBuilder {
2687 readonly values: PrimitivePartitionKeyValue[];
2688 addValue(value: string | boolean | number): PartitionKeyBuilder;
2689 addNullValue(): PartitionKeyBuilder;
2690 addNoneValue(): PartitionKeyBuilder;
2691 build(): PartitionKey;
2692 }
2693
2694 export declare interface PartitionKeyDefinition {
2695 /**
2696 * An array of paths for which data within the collection can be partitioned. Paths must not contain a wildcard or
2697 * a trailing slash. For example, the JSON property “AccountNumber” is specified as “/AccountNumber”. The array must
2698 * contain only a single value.
2699 */
2700 paths: string[];
2701 /**
2702 * An optional field, if not specified the default value is 1. To use the large partition key set the version to 2.
2703 * To learn about large partition keys, see [how to create containers with large partition key](https://docs.microsoft.com/en-us/azure/cosmos-db/large-partition-keys) article.
2704 */
2705 version?: PartitionKeyDefinitionVersion;
2706 systemKey?: boolean;
2707 /**
2708 * What kind of partition key is being defined (default: "Hash")
2709 */
2710 kind?: PartitionKeyKind;
2711 }
2712
2713 /**
2714 * PartitionKey Definition Version
2715 */
2716 export declare enum PartitionKeyDefinitionVersion {
2717 V1 = 1,
2718 V2 = 2
2719 }
2720
2721 /**
2722 * Type of PartitionKey i.e. Hash, MultiHash
2723 */
2724 export declare enum PartitionKeyKind {
2725 Hash = "Hash",
2726 MultiHash = "MultiHash"
2727 }
2728
2729 /**
2730 * @hidden
2731 */
2732 export declare interface PartitionKeyRange {
2733 id: string;
2734 minInclusive: string;
2735 maxExclusive: string;
2736 ridPrefix: number;
2737 throughputFraction: number;
2738 status: string;
2739 parents: string[];
2740 }
2741
2742 export declare interface PartitionKeyRangePropertiesNames {
2743 MinInclusive: "minInclusive";
2744 MaxExclusive: "maxExclusive";
2745 Id: "id";
2746 }
2747
2748 export declare type PatchOperation = ExistingKeyOperation | RemoveOperation;
2749
2750 export declare interface PatchOperationInput {
2751 partitionKey?: PartitionKey;
2752 ifMatch?: string;
2753 ifNoneMatch?: string;
2754 operationType: typeof BulkOperationType.Patch;
2755 resourceBody: PatchRequestBody;
2756 id: string;
2757 }
2758
2759 export declare const PatchOperationType: {
2760 readonly add: "add";
2761 readonly replace: "replace";
2762 readonly remove: "remove";
2763 readonly set: "set";
2764 readonly incr: "incr";
2765 };
2766
2767 export declare type PatchRequestBody = {
2768 operations: PatchOperation[];
2769 condition?: string;
2770 } | PatchOperation[];
2771
2772 /**
2773 * Use to read, replace, or delete a given {@link Permission} by id.
2774 *
2775 * @see {@link Permissions} to create, upsert, query, or read all Permissions.
2776 */
2777 export declare class Permission {
2778 readonly user: User;
2779 readonly id: string;
2780 private readonly clientContext;
2781 /**
2782 * Returns a reference URL to the resource. Used for linking in Permissions.
2783 */
2784 get url(): string;
2785 /**
2786 * @hidden
2787 * @param user - The parent {@link User}.
2788 * @param id - The id of the given {@link Permission}.
2789 */
2790 constructor(user: User, id: string, clientContext: ClientContext);
2791 /**
2792 * Read the {@link PermissionDefinition} of the given {@link Permission}.
2793 */
2794 read(options?: RequestOptions): Promise<PermissionResponse>;
2795 /**
2796 * Replace the given {@link Permission} with the specified {@link PermissionDefinition}.
2797 * @param body - The specified {@link PermissionDefinition}.
2798 */
2799 replace(body: PermissionDefinition, options?: RequestOptions): Promise<PermissionResponse>;
2800 /**
2801 * Delete the given {@link Permission}.
2802 */
2803 delete(options?: RequestOptions): Promise<PermissionResponse>;
2804 }
2805
2806 export declare interface PermissionBody {
2807 /** System generated resource token for the particular resource and user */
2808 _token: string;
2809 }
2810
2811 export declare interface PermissionDefinition {
2812 /** The id of the permission */
2813 id: string;
2814 /** The mode of the permission, must be a value of {@link PermissionMode} */
2815 permissionMode: PermissionMode;
2816 /** The link of the resource that the permission will be applied to. */
2817 resource: string;
2818 resourcePartitionKey?: string | any[];
2819 }
2820
2821 /**
2822 * Enum for permission mode values.
2823 */
2824 export declare enum PermissionMode {
2825 /** Permission not valid. */
2826 None = "none",
2827 /** Permission applicable for read operations only. */
2828 Read = "read",
2829 /** Permission applicable for all operations. */
2830 All = "all"
2831 }
2832
2833 export declare class PermissionResponse extends ResourceResponse<PermissionDefinition & PermissionBody & Resource> {
2834 constructor(resource: PermissionDefinition & PermissionBody & Resource, headers: CosmosHeaders, statusCode: number, permission: Permission, diagnostics: CosmosDiagnostics);
2835 /** A reference to the {@link Permission} corresponding to the returned {@link PermissionDefinition}. */
2836 readonly permission: Permission;
2837 }
2838
2839 /**
2840 * Use to create, replace, query, and read all Permissions.
2841 *
2842 * @see {@link Permission} to read, replace, or delete a specific permission by id.
2843 */
2844 declare class Permissions_2 {
2845 readonly user: User;
2846 private readonly clientContext;
2847 /**
2848 * @hidden
2849 * @param user - The parent {@link User}.
2850 */
2851 constructor(user: User, clientContext: ClientContext);
2852 /**
2853 * Query all permissions.
2854 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2855 */
2856 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
2857 /**
2858 * Query all permissions.
2859 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2860 */
2861 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
2862 /**
2863 * Read all permissions.
2864 * @example Read all permissions to array.
2865 * ```typescript
2866 * const {body: permissionList} = await user.permissions.readAll().fetchAll();
2867 * ```
2868 */
2869 readAll(options?: FeedOptions): QueryIterator<PermissionDefinition & Resource>;
2870 /**
2871 * Create a permission.
2872 *
2873 * A permission represents a per-User Permission to access a specific resource
2874 * e.g. Item or Container.
2875 * @param body - Represents the body of the permission.
2876 */
2877 create(body: PermissionDefinition, options?: RequestOptions): Promise<PermissionResponse>;
2878 /**
2879 * Upsert a permission.
2880 *
2881 * A permission represents a per-User Permission to access a
2882 * specific resource e.g. Item or Container.
2883 */
2884 upsert(body: PermissionDefinition, options?: RequestOptions): Promise<PermissionResponse>;
2885 }
2886 export { Permissions_2 as Permissions }
2887
2888 /**
2889 * Plugins allow you to customize the behavior of the SDk with additional logging, retry, or additional functionality.
2890 *
2891 * A plugin is a function which returns a `Promise<Response<T>>`, and is passed a RequestContext and Next object.
2892 *
2893 * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins,
2894 * allowing you to log those results or handle errors.
2895 *
2896 * RequestContext is an object which controls what operation is happening, against which endpoint, and more. Modifying this and passing it along via next is how
2897 * you modify future SDK behavior.
2898 *
2899 * @hidden
2900 */
2901 declare type Plugin_2<T> = (context: RequestContext, diagnosticNode: DiagnosticNodeInternal, next: Next<T>) => Promise<Response_2<T>>;
2902 export { Plugin_2 as Plugin }
2903
2904 /**
2905 * Specifies which event to run for the specified plugin
2906 *
2907 * @hidden
2908 */
2909 export declare interface PluginConfig {
2910 /**
2911 * The event to run the plugin on
2912 */
2913 on: keyof typeof PluginOn;
2914 /**
2915 * The plugin to run
2916 */
2917 plugin: Plugin_2<any>;
2918 }
2919
2920 /**
2921 * Used to specify which type of events to execute this plug in on.
2922 *
2923 * @hidden
2924 */
2925 export declare enum PluginOn {
2926 /**
2927 * Will be executed per network request
2928 */
2929 request = "request",
2930 /**
2931 * Will be executed per API operation
2932 */
2933 operation = "operation"
2934 }
2935
2936 /**
2937 * A primitive Partition Key value.
2938 */
2939 export declare type PrimitivePartitionKeyValue = string | number | boolean | NullPartitionKeyType | NonePartitionKeyType;
2940
2941 /**
2942 * Represents Priority Level associated with each Azure Cosmos DB client requests.<br>
2943 * The Low priority requests are always throttled before any High priority requests.
2944 *
2945 * By default all requests are considered as High priority requests.
2946 *
2947 * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling.
2948 */
2949 export declare enum PriorityLevel {
2950 /**
2951 * High Priority requests are throttled after Low priority requests.
2952 */
2953 High = "High",
2954 /**
2955 * Low Priority requests are throttled before High priority requests.
2956 */
2957 Low = "Low"
2958 }
2959
2960 /**
2961 * @hidden
2962 */
2963 export declare interface QueryInfo {
2964 top?: any;
2965 orderBy?: any[];
2966 orderByExpressions?: any[];
2967 offset?: number;
2968 limit?: number;
2969 aggregates?: AggregateType[];
2970 groupByExpressions?: GroupByExpressions;
2971 groupByAliasToAggregateType: GroupByAliasToAggregateType;
2972 rewrittenQuery?: any;
2973 distinctType: string;
2974 hasSelectValue: boolean;
2975 }
2976
2977 /**
2978 * Represents a QueryIterator Object, an implementation of feed or query response that enables
2979 * traversal and iterating over the response
2980 * in the Azure Cosmos DB database service.
2981 */
2982 export declare class QueryIterator<T> {
2983 private clientContext;
2984 private query;
2985 private options;
2986 private fetchFunctions;
2987 private resourceLink?;
2988 private resourceType?;
2989 private fetchAllTempResources;
2990 private fetchAllLastResHeaders;
2991 private queryExecutionContext;
2992 private queryPlanPromise;
2993 private isInitialized;
2994 /**
2995 * @hidden
2996 */
2997 constructor(clientContext: ClientContext, query: SqlQuerySpec | string, options: FeedOptions, fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[], resourceLink?: string, resourceType?: ResourceType);
2998 /**
2999 * Gets an async iterator that will yield results until completion.
3000 *
3001 * NOTE: AsyncIterators are a very new feature and you might need to
3002 * use polyfils/etc. in order to use them in your code.
3003 *
3004 * If you're using TypeScript, you can use the following polyfill as long
3005 * as you target ES6 or higher and are running on Node 6 or higher.
3006 *
3007 * ```typescript
3008 * if (!Symbol || !Symbol.asyncIterator) {
3009 * (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator");
3010 * }
3011 * ```
3012 *
3013 * @example Iterate over all databases
3014 * ```typescript
3015 * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) {
3016 * console.log(`Got ${db} from AsyncIterator`);
3017 * }
3018 * ```
3019 */
3020 getAsyncIterator(): AsyncIterable<FeedResponse<T>>;
3021 /**
3022 * Determine if there are still remaining resources to process based on the value of the continuation token or the
3023 * elements remaining on the current batch in the QueryIterator.
3024 * @returns true if there is other elements to process in the QueryIterator.
3025 */
3026 hasMoreResults(): boolean;
3027 /**
3028 * Fetch all pages for the query and return a single FeedResponse.
3029 */
3030 fetchAll(): Promise<FeedResponse<T>>;
3031 /**
3032 * @hidden
3033 */
3034 fetchAllInternal(diagnosticNode: DiagnosticNodeInternal): Promise<FeedResponse<T>>;
3035 /**
3036 * Retrieve the next batch from the feed.
3037 *
3038 * This may or may not fetch more pages from the backend depending on your settings
3039 * and the type of query. Aggregate queries will generally fetch all backend pages
3040 * before returning the first batch of responses.
3041 */
3042 fetchNext(): Promise<FeedResponse<T>>;
3043 /**
3044 * Reset the QueryIterator to the beginning and clear all the resources inside it
3045 */
3046 reset(): void;
3047 private toArrayImplementation;
3048 private createPipelinedExecutionContext;
3049 private fetchQueryPlan;
3050 private needsQueryPlan;
3051 private initPromise;
3052 private init;
3053 private _init;
3054 private handleSplitError;
3055 }
3056
3057 export declare class QueryMetrics {
3058 readonly retrievedDocumentCount: number;
3059 readonly retrievedDocumentSize: number;
3060 readonly outputDocumentCount: number;
3061 readonly outputDocumentSize: number;
3062 readonly indexHitDocumentCount: number;
3063 readonly totalQueryExecutionTime: TimeSpan;
3064 readonly queryPreparationTimes: QueryPreparationTimes;
3065 readonly indexLookupTime: TimeSpan;
3066 readonly documentLoadTime: TimeSpan;
3067 readonly vmExecutionTime: TimeSpan;
3068 readonly runtimeExecutionTimes: RuntimeExecutionTimes;
3069 readonly documentWriteTime: TimeSpan;
3070 readonly clientSideMetrics: ClientSideMetrics;
3071 constructor(retrievedDocumentCount: number, retrievedDocumentSize: number, outputDocumentCount: number, outputDocumentSize: number, indexHitDocumentCount: number, totalQueryExecutionTime: TimeSpan, queryPreparationTimes: QueryPreparationTimes, indexLookupTime: TimeSpan, documentLoadTime: TimeSpan, vmExecutionTime: TimeSpan, runtimeExecutionTimes: RuntimeExecutionTimes, documentWriteTime: TimeSpan, clientSideMetrics: ClientSideMetrics);
3072 /**
3073 * Gets the IndexHitRatio
3074 * @hidden
3075 */
3076 get indexHitRatio(): number;
3077 /**
3078 * returns a new QueryMetrics instance that is the addition of this and the arguments.
3079 */
3080 add(queryMetricsArray: QueryMetrics[]): QueryMetrics;
3081 /**
3082 * Output the QueryMetrics as a delimited string.
3083 * @hidden
3084 */
3085 toDelimitedString(): string;
3086 static readonly zero: QueryMetrics;
3087 /**
3088 * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics.
3089 */
3090 static createFromArray(queryMetricsArray: QueryMetrics[]): QueryMetrics;
3091 /**
3092 * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string.
3093 */
3094 static createFromDelimitedString(delimitedString: string, clientSideMetrics?: ClientSideMetrics): QueryMetrics;
3095 }
3096
3097 export declare const QueryMetricsConstants: {
3098 RetrievedDocumentCount: string;
3099 RetrievedDocumentSize: string;
3100 OutputDocumentCount: string;
3101 OutputDocumentSize: string;
3102 IndexHitRatio: string;
3103 IndexHitDocumentCount: string;
3104 TotalQueryExecutionTimeInMs: string;
3105 QueryCompileTimeInMs: string;
3106 LogicalPlanBuildTimeInMs: string;
3107 PhysicalPlanBuildTimeInMs: string;
3108 QueryOptimizationTimeInMs: string;
3109 IndexLookupTimeInMs: string;
3110 DocumentLoadTimeInMs: string;
3111 VMExecutionTimeInMs: string;
3112 DocumentWriteTimeInMs: string;
3113 QueryEngineTimes: string;
3114 SystemFunctionExecuteTimeInMs: string;
3115 UserDefinedFunctionExecutionTimeInMs: string;
3116 RetrievedDocumentCountText: string;
3117 RetrievedDocumentSizeText: string;
3118 OutputDocumentCountText: string;
3119 OutputDocumentSizeText: string;
3120 IndexUtilizationText: string;
3121 TotalQueryExecutionTimeText: string;
3122 QueryPreparationTimesText: string;
3123 QueryCompileTimeText: string;
3124 LogicalPlanBuildTimeText: string;
3125 PhysicalPlanBuildTimeText: string;
3126 QueryOptimizationTimeText: string;
3127 QueryEngineTimesText: string;
3128 IndexLookupTimeText: string;
3129 DocumentLoadTimeText: string;
3130 WriteOutputTimeText: string;
3131 RuntimeExecutionTimesText: string;
3132 TotalExecutionTimeText: string;
3133 SystemFunctionExecuteTimeText: string;
3134 UserDefinedFunctionExecutionTimeText: string;
3135 ClientSideQueryMetricsText: string;
3136 RetriesText: string;
3137 RequestChargeText: string;
3138 FetchExecutionRangesText: string;
3139 SchedulingMetricsText: string;
3140 };
3141
3142 export declare class QueryPreparationTimes {
3143 readonly queryCompilationTime: TimeSpan;
3144 readonly logicalPlanBuildTime: TimeSpan;
3145 readonly physicalPlanBuildTime: TimeSpan;
3146 readonly queryOptimizationTime: TimeSpan;
3147 constructor(queryCompilationTime: TimeSpan, logicalPlanBuildTime: TimeSpan, physicalPlanBuildTime: TimeSpan, queryOptimizationTime: TimeSpan);
3148 /**
3149 * returns a new QueryPreparationTimes instance that is the addition of this and the arguments.
3150 */
3151 add(...queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes;
3152 /**
3153 * Output the QueryPreparationTimes as a delimited string.
3154 */
3155 toDelimitedString(): string;
3156 static readonly zero: QueryPreparationTimes;
3157 /**
3158 * Returns a new instance of the QueryPreparationTimes class that is the
3159 * aggregation of an array of QueryPreparationTimes.
3160 */
3161 static createFromArray(queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes;
3162 /**
3163 * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string.
3164 */
3165 static createFromDelimitedString(delimitedString: string): QueryPreparationTimes;
3166 }
3167
3168 /**
3169 * @hidden
3170 */
3171 export declare interface QueryRange {
3172 min: string;
3173 max: string;
3174 isMinInclusive: boolean;
3175 isMaxInclusive: boolean;
3176 }
3177
3178 export declare type ReadOperation = OperationBase & {
3179 operationType: typeof BulkOperationType.Read;
3180 id: string;
3181 };
3182
3183 export declare interface ReadOperationInput {
3184 partitionKey?: PartitionKey;
3185 operationType: typeof BulkOperationType.Read;
3186 id: string;
3187 }
3188
3189 export declare type RemoveOperation = {
3190 op: "remove";
3191 path: string;
3192 };
3193
3194 export declare type ReplaceOperation = OperationWithItem & {
3195 operationType: typeof BulkOperationType.Replace;
3196 id: string;
3197 };
3198
3199 export declare interface ReplaceOperationInput {
3200 partitionKey?: PartitionKey;
3201 ifMatch?: string;
3202 ifNoneMatch?: string;
3203 operationType: typeof BulkOperationType.Replace;
3204 resourceBody: JSONObject;
3205 id: string;
3206 }
3207
3208 /**
3209 * @hidden
3210 */
3211 export declare interface RequestContext {
3212 path?: string;
3213 operationType?: OperationType;
3214 client?: ClientContext;
3215 retryCount?: number;
3216 resourceType?: ResourceType;
3217 resourceId?: string;
3218 globalEndpointManager: GlobalEndpointManager;
3219 connectionPolicy: ConnectionPolicy;
3220 requestAgent: Agent;
3221 body?: any;
3222 headers?: CosmosHeaders_2;
3223 endpoint?: string;
3224 method: HTTPMethod;
3225 partitionKeyRangeId?: string;
3226 options: FeedOptions | RequestOptions;
3227 plugins: PluginConfig[];
3228 partitionKey?: PartitionKey;
3229 pipeline?: Pipeline;
3230 }
3231
3232 /** @hidden */
3233 declare interface RequestInfo_2 {
3234 verb: HTTPMethod;
3235 path: string;
3236 resourceId: string;
3237 resourceType: ResourceType;
3238 headers: CosmosHeaders;
3239 }
3240 export { RequestInfo_2 as RequestInfo }
3241
3242 /**
3243 * Options that can be specified for a requested issued to the Azure Cosmos DB servers.=
3244 */
3245 export declare interface RequestOptions extends SharedOptions {
3246 /** Conditions Associated with the request. */
3247 accessCondition?: {
3248 /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */
3249 type: string;
3250 /** Conditional HTTP method header value (the _etag field from the last version you read). */
3251 condition: string;
3252 };
3253 /** Consistency level required by the client. */
3254 consistencyLevel?: string;
3255 /**
3256 * DisableRUPerMinuteUsage is used to enable/disable Request Units(RUs)/minute capacity
3257 * to serve the request if regular provisioned RUs/second is exhausted.
3258 */
3259 disableRUPerMinuteUsage?: boolean;
3260 /** Enables or disables logging in JavaScript stored procedures. */
3261 enableScriptLogging?: boolean;
3262 /** Specifies indexing directives (index, do not index .. etc). */
3263 indexingDirective?: string;
3264 /** The offer throughput provisioned for a container in measurement of Requests-per-Unit. */
3265 offerThroughput?: number;
3266 /**
3267 * Offer type when creating document containers.
3268 *
3269 * This option is only valid when creating a document container.
3270 */
3271 offerType?: string;
3272 /** Enables/disables getting document container quota related stats for document container read requests. */
3273 populateQuotaInfo?: boolean;
3274 /** Indicates what is the post trigger to be invoked after the operation. */
3275 postTriggerInclude?: string | string[];
3276 /** Indicates what is the pre trigger to be invoked before the operation. */
3277 preTriggerInclude?: string | string[];
3278 /** Expiry time (in seconds) for resource token associated with permission (applicable only for requests on permissions). */
3279 resourceTokenExpirySeconds?: number;
3280 /** (Advanced use case) The url to connect to. */
3281 urlConnection?: string;
3282 /** Disable automatic id generation (will cause creates to fail if id isn't on the definition) */
3283 disableAutomaticIdGeneration?: boolean;
3284 }
3285
3286 export declare interface Resource {
3287 /** Required. User settable property. Unique name that identifies the item, that is, no two items share the same ID within a database. The id must not exceed 255 characters. */
3288 id: string;
3289 /** System generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the item resource. */
3290 _rid: string;
3291 /** System generated property. Specifies the last updated timestamp of the resource. The value is a timestamp. */
3292 _ts: number;
3293 /** System generated property. The unique addressable URI for the resource. */
3294 _self: string;
3295 /** System generated property. Represents the resource etag required for optimistic concurrency control. */
3296 _etag: string;
3297 }
3298
3299 export declare class ResourceResponse<TResource> {
3300 readonly resource: TResource | undefined;
3301 readonly headers: CosmosHeaders_2;
3302 readonly statusCode: StatusCode;
3303 readonly diagnostics: CosmosDiagnostics;
3304 readonly substatus?: SubStatusCode;
3305 constructor(resource: TResource | undefined, headers: CosmosHeaders_2, statusCode: StatusCode, diagnostics: CosmosDiagnostics, substatus?: SubStatusCode);
3306 get requestCharge(): number;
3307 get activityId(): string;
3308 get etag(): string;
3309 }
3310
3311 /**
3312 * @hidden
3313 */
3314 export declare enum ResourceType {
3315 none = "",
3316 database = "dbs",
3317 offer = "offers",
3318 user = "users",
3319 permission = "permissions",
3320 container = "colls",
3321 conflicts = "conflicts",
3322 sproc = "sprocs",
3323 udf = "udfs",
3324 trigger = "triggers",
3325 item = "docs",
3326 pkranges = "pkranges",
3327 partitionkey = "partitionKey"
3328 }
3329
3330 /**
3331 * @hidden
3332 */
3333 declare interface Response_2<T> {
3334 headers: CosmosHeaders;
3335 result?: T;
3336 code?: number;
3337 substatus?: number;
3338 diagnostics?: CosmosDiagnostics;
3339 }
3340 export { Response_2 as Response }
3341
3342 export { RestError }
3343
3344 /**
3345 * This type captures diagnostic information regarding retries attempt during an CosmosDB client operation.
3346 */
3347 export declare type RetryDiagnostics = {
3348 failedAttempts: FailedRequestAttemptDiagnostic[];
3349 };
3350
3351 /**
3352 * Represents the Retry policy assocated with throttled requests in the Azure Cosmos DB database service.
3353 */
3354 export declare interface RetryOptions {
3355 /** Max number of retries to be performed for a request. Default value 9. */
3356 maxRetryAttemptCount: number;
3357 /** Fixed retry interval in milliseconds to wait between each retry ignoring the retryAfter returned as part of the response. */
3358 fixedRetryIntervalInMilliseconds: number;
3359 /** Max wait time in seconds to wait for a request while the retries are happening. Default value 30 seconds. */
3360 maxWaitTimeInSeconds: number;
3361 }
3362
3363 export declare class RuntimeExecutionTimes {
3364 readonly queryEngineExecutionTime: TimeSpan;
3365 readonly systemFunctionExecutionTime: TimeSpan;
3366 readonly userDefinedFunctionExecutionTime: TimeSpan;
3367 constructor(queryEngineExecutionTime: TimeSpan, systemFunctionExecutionTime: TimeSpan, userDefinedFunctionExecutionTime: TimeSpan);
3368 /**
3369 * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments.
3370 */
3371 add(...runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes;
3372 /**
3373 * Output the RuntimeExecutionTimes as a delimited string.
3374 */
3375 toDelimitedString(): string;
3376 static readonly zero: RuntimeExecutionTimes;
3377 /**
3378 * Returns a new instance of the RuntimeExecutionTimes class that is
3379 * the aggregation of an array of RuntimeExecutionTimes.
3380 */
3381 static createFromArray(runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes;
3382 /**
3383 * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string.
3384 */
3385 static createFromDelimitedString(delimitedString: string): RuntimeExecutionTimes;
3386 }
3387
3388 /**
3389 * @hidden
3390 */
3391 export declare enum SasTokenPermissionKind {
3392 ContainerCreateItems = 1,
3393 ContainerReplaceItems = 2,
3394 ContainerUpsertItems = 4,
3395 ContainerDeleteItems = 128,
3396 ContainerExecuteQueries = 1,
3397 ContainerReadFeeds = 2,
3398 ContainerCreateStoreProcedure = 16,
3399 ContainerReadStoreProcedure = 4,
3400 ContainerReplaceStoreProcedure = 32,
3401 ContainerDeleteStoreProcedure = 64,
3402 ContainerCreateTriggers = 256,
3403 ContainerReadTriggers = 16,
3404 ContainerReplaceTriggers = 512,
3405 ContainerDeleteTriggers = 1024,
3406 ContainerCreateUserDefinedFunctions = 2048,
3407 ContainerReadUserDefinedFunctions = 8,
3408 ContainerReplaceUserDefinedFunctions = 4096,
3409 ContainerDeleteUserDefinedFunctions = 8192,
3410 ContainerExecuteStoredProcedure = 128,
3411 ContainerReadConflicts = 32,
3412 ContainerDeleteConflicts = 16384,
3413 ContainerReadAny = 64,
3414 ContainerFullAccess = 4294967295,
3415 ItemReadAny = 65536,
3416 ItemFullAccess = 65,
3417 ItemRead = 64,
3418 ItemReplace = 65536,
3419 ItemUpsert = 131072,
3420 ItemDelete = 262144,
3421 StoreProcedureRead = 128,
3422 StoreProcedureReplace = 1048576,
3423 StoreProcedureDelete = 2097152,
3424 StoreProcedureExecute = 4194304,
3425 UserDefinedFuntionRead = 256,
3426 UserDefinedFuntionReplace = 8388608,
3427 UserDefinedFuntionDelete = 16777216,
3428 TriggerRead = 512,
3429 TriggerReplace = 33554432,
3430 TriggerDelete = 67108864
3431 }
3432
3433 export declare class SasTokenProperties {
3434 user: string;
3435 userTag: string;
3436 databaseName: string;
3437 containerName: string;
3438 resourceName: string;
3439 resourcePath: string;
3440 resourceKind: CosmosContainerChildResourceKind;
3441 partitionKeyValueRanges: string[];
3442 startTime: Date;
3443 expiryTime: Date;
3444 keyType: CosmosKeyType | number;
3445 controlPlaneReaderScope: number;
3446 controlPlaneWriterScope: number;
3447 dataPlaneReaderScope: number;
3448 dataPlaneWriterScope: number;
3449 cosmosContainerChildResourceKind: CosmosContainerChildResourceKind;
3450 cosmosKeyType: CosmosKeyType;
3451 }
3452
3453 export declare class Scripts {
3454 readonly container: Container;
3455 private readonly clientContext;
3456 /**
3457 * @param container - The parent {@link Container}.
3458 * @hidden
3459 */
3460 constructor(container: Container, clientContext: ClientContext);
3461 /**
3462 * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id.
3463 *
3464 * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures.
3465 * @param id - The id of the {@link StoredProcedure}.
3466 */
3467 storedProcedure(id: string): StoredProcedure;
3468 /**
3469 * Used to read, replace, or delete a specific, existing {@link Trigger} by id.
3470 *
3471 * Use `.triggers` for creating new triggers, or querying/reading all triggers.
3472 * @param id - The id of the {@link Trigger}.
3473 */
3474 trigger(id: string): Trigger;
3475 /**
3476 * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id.
3477 *
3478 * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions.
3479 * @param id - The id of the {@link UserDefinedFunction}.
3480 */
3481 userDefinedFunction(id: string): UserDefinedFunction;
3482 private $sprocs;
3483 /**
3484 * Operations for creating new stored procedures, and reading/querying all stored procedures.
3485 *
3486 * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`.
3487 */
3488 get storedProcedures(): StoredProcedures;
3489 private $triggers;
3490 /**
3491 * Operations for creating new triggers, and reading/querying all triggers.
3492 *
3493 * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`.
3494 */
3495 get triggers(): Triggers;
3496 private $udfs;
3497 /**
3498 * Operations for creating new user defined functions, and reading/querying all user defined functions.
3499 *
3500 * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`.
3501 */
3502 get userDefinedFunctions(): UserDefinedFunctions;
3503 }
3504
3505 /**
3506 * The default function for setting header token using the masterKey
3507 * @hidden
3508 */
3509 export declare function setAuthorizationTokenHeaderUsingMasterKey(verb: HTTPMethod, resourceId: string, resourceType: ResourceType, headers: CosmosHeaders, masterKey: string): Promise<void>;
3510
3511 /**
3512 * Options that can be specified for a requested issued to the Azure Cosmos DB servers.=
3513 */
3514 export declare interface SharedOptions {
3515 /** Enables/disables getting document container quota related stats for document container read requests. */
3516 sessionToken?: string;
3517 /** (Advanced use case) Initial headers to start with when sending requests to Cosmos */
3518 initialHeaders?: CosmosHeaders;
3519 /**
3520 * abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController
3521 * @example Cancel a read request
3522 * ```typescript
3523 * const controller = new AbortController()
3524 * const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal});
3525 * controller.abort()
3526 * ```
3527 */
3528 abortSignal?: AbortSignal_2;
3529 /**
3530 * Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link
3531 * com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the
3532 * integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the
3533 * consistency level is not set, this property is ignored.
3534 *
3535 * <p>Default value is null</p>
3536 *
3537 * <p>Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.</p>
3538 */
3539 maxIntegratedCacheStalenessInMs?: number;
3540 /**
3541 * Priority Level (Low/High) for each request.
3542 * Low priority requests are always throttled before any high priority requests.
3543 *
3544 * <p>Default value is null. By default all requests are of High priority</p>
3545 */
3546 priorityLevel?: PriorityLevel;
3547 }
3548
3549 export declare interface SpatialIndex {
3550 path: string;
3551 types: SpatialType[];
3552 boundingBox: {
3553 xmin: number;
3554 ymin: number;
3555 xmax: number;
3556 ymax: number;
3557 };
3558 }
3559
3560 export declare enum SpatialType {
3561 LineString = "LineString",
3562 MultiPolygon = "MultiPolygon",
3563 Point = "Point",
3564 Polygon = "Polygon"
3565 }
3566
3567 /**
3568 * Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec}
3569 */
3570 export declare interface SqlParameter {
3571 /** Name of the parameter. (i.e. `@lastName`) */
3572 name: string;
3573 /** Value of the parameter (this is safe to come from users, assuming they are authorized) */
3574 value: JSONValue;
3575 }
3576
3577 /**
3578 * Represents a SQL query in the Azure Cosmos DB service.
3579 *
3580 * Queries with inputs should be parameterized to protect against SQL injection.
3581 *
3582 * @example Parameterized SQL Query
3583 * ```typescript
3584 * const query: SqlQuerySpec = {
3585 * query: "SELECT * FROM Families f where f.lastName = @lastName",
3586 * parameters: [
3587 * {name: "@lastName", value: "Wakefield"}
3588 * ]
3589 * };
3590 * ```
3591 */
3592 export declare interface SqlQuerySpec {
3593 /** The text of the SQL query */
3594 query: string;
3595 /** The parameters you provide in the query */
3596 parameters?: SqlParameter[];
3597 }
3598
3599 /**
3600 * @hidden
3601 */
3602 export declare type StatusCode = number;
3603
3604 /**
3605 * @hidden
3606 */
3607 export declare const StatusCodes: StatusCodesType;
3608
3609 /**
3610 * @hidden
3611 */
3612 export declare interface StatusCodesType {
3613 Ok: 200;
3614 Created: 201;
3615 Accepted: 202;
3616 NoContent: 204;
3617 NotModified: 304;
3618 BadRequest: 400;
3619 Unauthorized: 401;
3620 Forbidden: 403;
3621 NotFound: 404;
3622 MethodNotAllowed: 405;
3623 RequestTimeout: 408;
3624 Conflict: 409;
3625 Gone: 410;
3626 PreconditionFailed: 412;
3627 RequestEntityTooLarge: 413;
3628 TooManyRequests: 429;
3629 RetryWith: 449;
3630 InternalServerError: 500;
3631 ServiceUnavailable: 503;
3632 ENOTFOUND: "ENOTFOUND";
3633 OperationPaused: 1200;
3634 OperationCancelled: 1201;
3635 }
3636
3637 /**
3638 * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id.
3639 *
3640 * For operations to create, read all, or query Stored Procedures,
3641 */
3642 export declare class StoredProcedure {
3643 readonly container: Container;
3644 readonly id: string;
3645 private readonly clientContext;
3646 /**
3647 * Returns a reference URL to the resource. Used for linking in Permissions.
3648 */
3649 get url(): string;
3650 /**
3651 * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}.
3652 * @param container - The parent {@link Container}.
3653 * @param id - The id of the given {@link StoredProcedure}.
3654 * @hidden
3655 */
3656 constructor(container: Container, id: string, clientContext: ClientContext);
3657 /**
3658 * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}.
3659 */
3660 read(options?: RequestOptions): Promise<StoredProcedureResponse>;
3661 /**
3662 * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}.
3663 * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition.
3664 */
3665 replace(body: StoredProcedureDefinition, options?: RequestOptions): Promise<StoredProcedureResponse>;
3666 /**
3667 * Delete the given {@link StoredProcedure}.
3668 */
3669 delete(options?: RequestOptions): Promise<StoredProcedureResponse>;
3670 /**
3671 * Execute the given {@link StoredProcedure}.
3672 *
3673 * The specified type, T, is not enforced by the client.
3674 * Be sure to validate the response from the stored procedure matches the type, T, you provide.
3675 *
3676 * @param partitionKey - The partition key to use when executing the stored procedure
3677 * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}.
3678 * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on.
3679 */
3680 execute<T = any>(partitionKey: PartitionKey, params?: any[], options?: RequestOptions): Promise<ResourceResponse<T>>;
3681 }
3682
3683 export declare interface StoredProcedureDefinition {
3684 /**
3685 * The id of the {@link StoredProcedure}.
3686 */
3687 id?: string;
3688 /**
3689 * The body of the {@link StoredProcedure}. This is a JavaScript function.
3690 */
3691 body?: string | ((...inputs: any[]) => void);
3692 }
3693
3694 export declare class StoredProcedureResponse extends ResourceResponse<StoredProcedureDefinition & Resource> {
3695 constructor(resource: StoredProcedureDefinition & Resource, headers: CosmosHeaders, statusCode: number, storedProcedure: StoredProcedure, diagnostics: CosmosDiagnostics);
3696 /**
3697 * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.
3698 */
3699 readonly storedProcedure: StoredProcedure;
3700 /**
3701 * Alias for storedProcedure.
3702 *
3703 * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.
3704 */
3705 get sproc(): StoredProcedure;
3706 }
3707
3708 /**
3709 * Operations for creating, upserting, or reading/querying all Stored Procedures.
3710 *
3711 * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`.
3712 */
3713 export declare class StoredProcedures {
3714 readonly container: Container;
3715 private readonly clientContext;
3716 /**
3717 * @param container - The parent {@link Container}.
3718 * @hidden
3719 */
3720 constructor(container: Container, clientContext: ClientContext);
3721 /**
3722 * Query all Stored Procedures.
3723 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
3724 * @example Read all stored procedures to array.
3725 * ```typescript
3726 * const querySpec: SqlQuerySpec = {
3727 * query: "SELECT * FROM root r WHERE r.id = @sproc",
3728 * parameters: [
3729 * {name: "@sproc", value: "Todo"}
3730 * ]
3731 * };
3732 * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();
3733 * ```
3734 */
3735 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
3736 /**
3737 * Query all Stored Procedures.
3738 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
3739 * @example Read all stored procedures to array.
3740 * ```typescript
3741 * const querySpec: SqlQuerySpec = {
3742 * query: "SELECT * FROM root r WHERE r.id = @sproc",
3743 * parameters: [
3744 * {name: "@sproc", value: "Todo"}
3745 * ]
3746 * };
3747 * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();
3748 * ```
3749 */
3750 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
3751 /**
3752 * Read all stored procedures.
3753 * @example Read all stored procedures to array.
3754 * ```typescript
3755 * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll();
3756 * ```
3757 */
3758 readAll(options?: FeedOptions): QueryIterator<StoredProcedureDefinition & Resource>;
3759 /**
3760 * Create a StoredProcedure.
3761 *
3762 * Azure Cosmos DB allows stored procedures to be executed in the storage tier,
3763 * directly against an item container. The script
3764 * gets executed under ACID transactions on the primary storage partition of the
3765 * specified container. For additional details,
3766 * refer to the server-side JavaScript API documentation.
3767 */
3768 create(body: StoredProcedureDefinition, options?: RequestOptions): Promise<StoredProcedureResponse>;
3769 }
3770
3771 /**
3772 * @hidden
3773 */
3774 export declare type SubStatusCode = number;
3775
3776 export declare class TimeoutError extends Error {
3777 readonly code: string;
3778 constructor(message?: string);
3779 }
3780
3781 /**
3782 * Represents a time interval.
3783 *
3784 * @param days - Number of days.
3785 * @param hours - Number of hours.
3786 * @param minutes - Number of minutes.
3787 * @param seconds - Number of seconds.
3788 * @param milliseconds - Number of milliseconds.
3789 * @hidden
3790 */
3791 export declare class TimeSpan {
3792 protected _ticks: number;
3793 constructor(days: number, hours: number, minutes: number, seconds: number, milliseconds: number);
3794 /**
3795 * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.
3796 * @param ts - The time interval to add.
3797 */
3798 add(ts: TimeSpan): TimeSpan;
3799 /**
3800 * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance.
3801 * @param ts - The time interval to subtract.
3802 */
3803 subtract(ts: TimeSpan): TimeSpan;
3804 /**
3805 * Compares this instance to a specified object and returns an integer that indicates whether this
3806 * instance is shorter than, equal to, or longer than the specified object.
3807 * @param value - The time interval to add.
3808 */
3809 compareTo(value: TimeSpan): 1 | -1 | 0;
3810 /**
3811 * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.
3812 */
3813 duration(): TimeSpan;
3814 /**
3815 * Returns a value indicating whether this instance is equal to a specified object.
3816 * @param value - The time interval to check for equality.
3817 */
3818 equals(value: TimeSpan): boolean;
3819 /**
3820 * Returns a new TimeSpan object whose value is the negated value of this instance.
3821 * @param value - The time interval to check for equality.
3822 */
3823 negate(): TimeSpan;
3824 days(): number;
3825 hours(): number;
3826 milliseconds(): number;
3827 seconds(): number;
3828 ticks(): number;
3829 totalDays(): number;
3830 totalHours(): number;
3831 totalMilliseconds(): number;
3832 totalMinutes(): number;
3833 totalSeconds(): number;
3834 static fromTicks(value: number): TimeSpan;
3835 static readonly zero: TimeSpan;
3836 static readonly maxValue: TimeSpan;
3837 static readonly minValue: TimeSpan;
3838 static isTimeSpan(timespan: TimeSpan): number;
3839 static additionDoesOverflow(a: number, b: number): boolean;
3840 static subtractionDoesUnderflow(a: number, b: number): boolean;
3841 static compare(t1: TimeSpan, t2: TimeSpan): 1 | 0 | -1;
3842 static interval(value: number, scale: number): TimeSpan;
3843 static fromMilliseconds(value: number): TimeSpan;
3844 static fromSeconds(value: number): TimeSpan;
3845 static fromMinutes(value: number): TimeSpan;
3846 static fromHours(value: number): TimeSpan;
3847 static fromDays(value: number): TimeSpan;
3848 }
3849
3850 export declare type TokenProvider = (requestInfo: RequestInfo_2) => Promise<string>;
3851
3852 /**
3853 * Operations to read, replace, or delete a {@link Trigger}.
3854 *
3855 * Use `container.triggers` to create, upsert, query, or read all.
3856 */
3857 export declare class Trigger {
3858 readonly container: Container;
3859 readonly id: string;
3860 private readonly clientContext;
3861 /**
3862 * Returns a reference URL to the resource. Used for linking in Permissions.
3863 */
3864 get url(): string;
3865 /**
3866 * @hidden
3867 * @param container - The parent {@link Container}.
3868 * @param id - The id of the given {@link Trigger}.
3869 */
3870 constructor(container: Container, id: string, clientContext: ClientContext);
3871 /**
3872 * Read the {@link TriggerDefinition} for the given {@link Trigger}.
3873 */
3874 read(options?: RequestOptions): Promise<TriggerResponse>;
3875 /**
3876 * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}.
3877 * @param body - The specified {@link TriggerDefinition} to replace the existing definition with.
3878 */
3879 replace(body: TriggerDefinition, options?: RequestOptions): Promise<TriggerResponse>;
3880 /**
3881 * Delete the given {@link Trigger}.
3882 */
3883 delete(options?: RequestOptions): Promise<TriggerResponse>;
3884 }
3885
3886 export declare interface TriggerDefinition {
3887 /** The id of the trigger. */
3888 id?: string;
3889 /** The body of the trigger, it can also be passed as a stringifed function */
3890 body: (() => void) | string;
3891 /** The type of the trigger, should be one of the values of {@link TriggerType}. */
3892 triggerType: TriggerType;
3893 /** The trigger operation, should be one of the values of {@link TriggerOperation}. */
3894 triggerOperation: TriggerOperation;
3895 }
3896
3897 /**
3898 * Enum for trigger operation values.
3899 * specifies the operations on which a trigger should be executed.
3900 */
3901 export declare enum TriggerOperation {
3902 /** All operations. */
3903 All = "all",
3904 /** Create operations only. */
3905 Create = "create",
3906 /** Update operations only. */
3907 Update = "update",
3908 /** Delete operations only. */
3909 Delete = "delete",
3910 /** Replace operations only. */
3911 Replace = "replace"
3912 }
3913
3914 export declare class TriggerResponse extends ResourceResponse<TriggerDefinition & Resource> {
3915 constructor(resource: TriggerDefinition & Resource, headers: CosmosHeaders, statusCode: number, trigger: Trigger, diagnostics: CosmosDiagnostics);
3916 /** A reference to the {@link Trigger} corresponding to the returned {@link TriggerDefinition}. */
3917 readonly trigger: Trigger;
3918 }
3919
3920 /**
3921 * Operations to create, upsert, query, and read all triggers.
3922 *
3923 * Use `container.triggers` to read, replace, or delete a {@link Trigger}.
3924 */
3925 export declare class Triggers {
3926 readonly container: Container;
3927 private readonly clientContext;
3928 /**
3929 * @hidden
3930 * @param container - The parent {@link Container}.
3931 */
3932 constructor(container: Container, clientContext: ClientContext);
3933 /**
3934 * Query all Triggers.
3935 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
3936 */
3937 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
3938 /**
3939 * Query all Triggers.
3940 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
3941 */
3942 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
3943 /**
3944 * Read all Triggers.
3945 * @example Read all trigger to array.
3946 * ```typescript
3947 * const {body: triggerList} = await container.triggers.readAll().fetchAll();
3948 * ```
3949 */
3950 readAll(options?: FeedOptions): QueryIterator<TriggerDefinition & Resource>;
3951 /**
3952 * Create a trigger.
3953 *
3954 * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed
3955 * on creates, updates and deletes.
3956 *
3957 * For additional details, refer to the server-side JavaScript API documentation.
3958 */
3959 create(body: TriggerDefinition, options?: RequestOptions): Promise<TriggerResponse>;
3960 }
3961
3962 /**
3963 * Enum for trigger type values.
3964 * Specifies the type of the trigger.
3965 */
3966 export declare enum TriggerType {
3967 /** Trigger should be executed before the associated operation(s). */
3968 Pre = "pre",
3969 /** Trigger should be executed after the associated operation(s). */
3970 Post = "post"
3971 }
3972
3973 /** Interface for a single unique key passed as part of UniqueKeyPolicy */
3974 export declare interface UniqueKey {
3975 paths: string[];
3976 }
3977
3978 /** Interface for setting unique keys on container creation */
3979 export declare interface UniqueKeyPolicy {
3980 uniqueKeys: UniqueKey[];
3981 }
3982
3983 export declare type UpsertOperation = OperationWithItem & {
3984 operationType: typeof BulkOperationType.Upsert;
3985 };
3986
3987 export declare interface UpsertOperationInput {
3988 partitionKey?: PartitionKey;
3989 ifMatch?: string;
3990 ifNoneMatch?: string;
3991 operationType: typeof BulkOperationType.Upsert;
3992 resourceBody: JSONObject;
3993 }
3994
3995 /**
3996 * Used to read, replace, and delete Users.
3997 *
3998 * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`.
3999 *
4000 * @see {@link Users} to create, upsert, query, or read all.
4001 */
4002 export declare class User {
4003 readonly database: Database;
4004 readonly id: string;
4005 private readonly clientContext;
4006 /**
4007 * Operations for creating, upserting, querying, or reading all operations.
4008 *
4009 * See `client.permission(id)` to read, replace, or delete a specific Permission by id.
4010 */
4011 readonly permissions: Permissions_2;
4012 /**
4013 * Returns a reference URL to the resource. Used for linking in Permissions.
4014 */
4015 get url(): string;
4016 /**
4017 * @hidden
4018 * @param database - The parent {@link Database}.
4019 */
4020 constructor(database: Database, id: string, clientContext: ClientContext);
4021 /**
4022 * Operations to read, replace, or delete a specific Permission by id.
4023 *
4024 * See `client.permissions` for creating, upserting, querying, or reading all operations.
4025 */
4026 permission(id: string): Permission;
4027 /**
4028 * Read the {@link UserDefinition} for the given {@link User}.
4029 */
4030 read(options?: RequestOptions): Promise<UserResponse>;
4031 /**
4032 * Replace the given {@link User}'s definition with the specified {@link UserDefinition}.
4033 * @param body - The specified {@link UserDefinition} to replace the definition.
4034 */
4035 replace(body: UserDefinition, options?: RequestOptions): Promise<UserResponse>;
4036 /**
4037 * Delete the given {@link User}.
4038 */
4039 delete(options?: RequestOptions): Promise<UserResponse>;
4040 }
4041
4042 /**
4043 * Used to read, replace, or delete a specified User Definied Function by id.
4044 *
4045 * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions.
4046 */
4047 export declare class UserDefinedFunction {
4048 readonly container: Container;
4049 readonly id: string;
4050 private readonly clientContext;
4051 /**
4052 * Returns a reference URL to the resource. Used for linking in Permissions.
4053 */
4054 get url(): string;
4055 /**
4056 * @hidden
4057 * @param container - The parent {@link Container}.
4058 * @param id - The id of the given {@link UserDefinedFunction}.
4059 */
4060 constructor(container: Container, id: string, clientContext: ClientContext);
4061 /**
4062 * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}.
4063 */
4064 read(options?: RequestOptions): Promise<UserDefinedFunctionResponse>;
4065 /**
4066 * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}.
4067 * @param options -
4068 */
4069 replace(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise<UserDefinedFunctionResponse>;
4070 /**
4071 * Delete the given {@link UserDefined}.
4072 */
4073 delete(options?: RequestOptions): Promise<UserDefinedFunctionResponse>;
4074 }
4075
4076 export declare interface UserDefinedFunctionDefinition {
4077 /** The id of the {@link UserDefinedFunction} */
4078 id?: string;
4079 /** The body of the user defined function, it can also be passed as a stringifed function */
4080 body?: string | (() => void);
4081 }
4082
4083 export declare class UserDefinedFunctionResponse extends ResourceResponse<UserDefinedFunctionDefinition & Resource> {
4084 constructor(resource: UserDefinedFunctionDefinition & Resource, headers: CosmosHeaders, statusCode: number, udf: UserDefinedFunction, diagnostics: CosmosDiagnostics);
4085 /** A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. */
4086 readonly userDefinedFunction: UserDefinedFunction;
4087 /**
4088 * Alias for `userDefinedFunction(id)`.
4089 *
4090 * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}.
4091 */
4092 get udf(): UserDefinedFunction;
4093 }
4094
4095 /**
4096 * Used to create, upsert, query, or read all User Defined Functions.
4097 *
4098 * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id.
4099 */
4100 export declare class UserDefinedFunctions {
4101 readonly container: Container;
4102 private readonly clientContext;
4103 /**
4104 * @hidden
4105 * @param container - The parent {@link Container}.
4106 */
4107 constructor(container: Container, clientContext: ClientContext);
4108 /**
4109 * Query all User Defined Functions.
4110 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
4111 */
4112 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
4113 /**
4114 * Query all User Defined Functions.
4115 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
4116 */
4117 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
4118 /**
4119 * Read all User Defined Functions.
4120 * @example Read all User Defined Functions to array.
4121 * ```typescript
4122 * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll();
4123 * ```
4124 */
4125 readAll(options?: FeedOptions): QueryIterator<UserDefinedFunctionDefinition & Resource>;
4126 /**
4127 * Create a UserDefinedFunction.
4128 *
4129 * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.
4130 *
4131 * For additional details, refer to the server-side JavaScript API documentation.
4132 *
4133 */
4134 create(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise<UserDefinedFunctionResponse>;
4135 }
4136
4137 /**
4138 * Enum for udf type values.
4139 * Specifies the types of user defined functions.
4140 */
4141 export declare enum UserDefinedFunctionType {
4142 /** The User Defined Function is written in JavaScript. This is currently the only option. */
4143 Javascript = "Javascript"
4144 }
4145
4146 export declare interface UserDefinition {
4147 /** The id of the user. */
4148 id?: string;
4149 }
4150
4151 export declare class UserResponse extends ResourceResponse<UserDefinition & Resource> {
4152 constructor(resource: UserDefinition & Resource, headers: CosmosHeaders, statusCode: number, user: User, diagnostics: CosmosDiagnostics);
4153 /** A reference to the {@link User} corresponding to the returned {@link UserDefinition}. */
4154 readonly user: User;
4155 }
4156
4157 /**
4158 * Used to create, upsert, query, and read all users.
4159 *
4160 * @see {@link User} to read, replace, or delete a specific User by id.
4161 */
4162 export declare class Users {
4163 readonly database: Database;
4164 private readonly clientContext;
4165 /**
4166 * @hidden
4167 * @param database - The parent {@link Database}.
4168 */
4169 constructor(database: Database, clientContext: ClientContext);
4170 /**
4171 * Query all users.
4172 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
4173 */
4174 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
4175 /**
4176 * Query all users.
4177 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
4178 */
4179 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
4180 /**
4181 * Read all users.-
4182 * @example Read all users to array.
4183 * ```typescript
4184 * const {body: usersList} = await database.users.readAll().fetchAll();
4185 * ```
4186 */
4187 readAll(options?: FeedOptions): QueryIterator<UserDefinition & Resource>;
4188 /**
4189 * Create a database user with the specified {@link UserDefinition}.
4190 * @param body - The specified {@link UserDefinition}.
4191 */
4192 create(body: UserDefinition, options?: RequestOptions): Promise<UserResponse>;
4193 /**
4194 * Upsert a database user with a specified {@link UserDefinition}.
4195 * @param body - The specified {@link UserDefinition}.
4196 */
4197 upsert(body: UserDefinition, options?: RequestOptions): Promise<UserResponse>;
4198 }
4199
4200 declare type VerboseOmit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
4201
4202 export { }
4203
\No newline at end of file