UNPKG

225 kBTypeScriptView Raw
1import { AbortError } from '@azure/abort-controller';
2import type { HttpClient } from '@azure/core-rest-pipeline';
3import type { Pipeline } from '@azure/core-rest-pipeline';
4import { RestError } from '@azure/core-rest-pipeline';
5import type { TokenCredential } from '@azure/core-auth';
6
7export { AbortError }
8
9export declare interface Agent {
10 maxFreeSockets: number;
11 maxSockets: number;
12 sockets: any;
13 requests: any;
14 destroy(): void;
15}
16
17export declare type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum" | "MakeSet" | "MakeList";
18
19export declare type BulkOperationResponse = OperationResponse[] & {
20 diagnostics: CosmosDiagnostics;
21};
22
23export declare const BulkOperationType: {
24 readonly Create: "Create";
25 readonly Upsert: "Upsert";
26 readonly Read: "Read";
27 readonly Delete: "Delete";
28 readonly Replace: "Replace";
29 readonly Patch: "Patch";
30};
31
32/**
33 * Options object used to modify bulk execution.
34 * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE
35 */
36export declare interface BulkOptions {
37 continueOnError?: boolean;
38}
39
40export declare type BulkPatchOperation = OperationBase & {
41 operationType: typeof BulkOperationType.Patch;
42 id: string;
43};
44
45/**
46 * Provides iterator for change feed.
47 *
48 * Use `Items.changeFeed()` to get an instance of the iterator.
49 */
50export declare class ChangeFeedIterator<T> {
51 private clientContext;
52 private resourceId;
53 private resourceLink;
54 private partitionKey;
55 private changeFeedOptions;
56 private static readonly IfNoneMatchAllHeaderValue;
57 private nextIfNoneMatch;
58 private ifModifiedSince;
59 private lastStatusCode;
60 private isPartitionSpecified;
61 /**
62 * Gets a value indicating whether there are potentially additional results that can be retrieved.
63 *
64 * Initially returns true. This value is set based on whether the last execution returned a continuation token.
65 *
66 * @returns Boolean value representing if whether there are potentially additional results that can be retrieved.
67 */
68 get hasMoreResults(): boolean;
69 /**
70 * Gets an async iterator which will yield pages of results from Azure Cosmos DB.
71 */
72 getAsyncIterator(): AsyncIterable<ChangeFeedResponse<Array<T & Resource>>>;
73 /**
74 * Read feed and retrieves the next page of results in Azure Cosmos DB.
75 */
76 fetchNext(): Promise<ChangeFeedResponse<Array<T & Resource>>>;
77 private getFeedResponse;
78}
79
80/**
81 * Specifies options for the change feed
82 *
83 * If none of those options are set, it will start reading changes from now for the entire container.
84 */
85export declare interface ChangeFeedIteratorOptions {
86 /**
87 * Max amount of items to return per page
88 */
89 maxItemCount?: number;
90 /**
91 * The session token to use. If not specified, will use the most recent captured session token to start with.
92 */
93 sessionToken?: string;
94 /**
95 * Signals where to start from in the change feed.
96 */
97 changeFeedStartFrom?: ChangeFeedStartFrom;
98 /**
99 * Signals the mode in which the change feed needs to start.
100 */
101 changeFeedMode?: ChangeFeedMode;
102}
103
104/**
105 * A single response page from the Azure Cosmos DB Change Feed
106 */
107export declare class ChangeFeedIteratorResponse<T> {
108 /**
109 * Gets the items returned in the response from Azure Cosmos DB
110 */
111 readonly result: T;
112 /**
113 * Gets the number of items returned in the response from Azure Cosmos DB
114 */
115 readonly count: number;
116 /**
117 * Gets the status code of the response from Azure Cosmos DB
118 */
119 readonly statusCode: number;
120 /**
121 * Cosmos Diagnostic Object.
122 */
123 readonly diagnostics: CosmosDiagnostics;
124 /**
125 * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone.
126 */
127 readonly subStatusCode?: number;
128 /**
129 * Gets the request charge for this request from the Azure Cosmos DB service.
130 */
131 get requestCharge(): number;
132 /**
133 * Gets the activity ID for the request from the Azure Cosmos DB service.
134 */
135 get activityId(): string;
136 /**
137 * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.
138 */
139 get continuationToken(): string;
140 /**
141 * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.
142 */
143 get sessionToken(): string;
144 /**
145 * Response headers of the response from Azure Cosmos DB
146 */
147 headers: CosmosHeaders;
148}
149
150export declare enum ChangeFeedMode {
151 LatestVersion = "Incremental Feed",
152 AllVersionsAndDeletes = "Full-Fidelity Feed"
153}
154
155/**
156 * Specifies options for the change feed
157 *
158 * Some of these options control where and when to start reading from the change feed. The order of precedence is:
159 * - continuation
160 * - startTime
161 * - startFromBeginning
162 *
163 * If none of those options are set, it will start reading changes from the first `ChangeFeedIterator.fetchNext()` call.
164 */
165export declare interface ChangeFeedOptions {
166 /**
167 * Max amount of items to return per page
168 */
169 maxItemCount?: number;
170 /**
171 * The continuation token to start from.
172 *
173 * This is equivalent to the etag and continuation value from the `ChangeFeedResponse`
174 */
175 continuation?: string;
176 /**
177 * The session token to use. If not specified, will use the most recent captured session token to start with.
178 */
179 sessionToken?: string;
180 /**
181 * Signals whether to start from the beginning or not.
182 */
183 startFromBeginning?: boolean;
184 /**
185 * Specified the start time to start reading changes from.
186 */
187 startTime?: Date;
188}
189
190/**
191 * Represents the change feed policy configuration for a container in the Azure Cosmos DB service.
192 */
193export declare class ChangeFeedPolicy {
194 retentionDuration: number;
195 constructor(retentionDuration: ChangeFeedRetentionTimeSpan);
196}
197
198/**
199 * Use `Items.getChangeFeedIterator()` to return an iterator that can iterate over all the changes for a partition key, feed range or an entire container.
200 */
201export declare interface ChangeFeedPullModelIterator<T> {
202 /**
203 * Always returns true, changefeed is an infinite stream.
204 */
205 readonly hasMoreResults: boolean;
206 /**
207 * Returns next set of results for the change feed.
208 */
209 readNext(): Promise<ChangeFeedIteratorResponse<Array<T & Resource>>>;
210 /**
211 * Gets an async iterator which will yield change feed results.
212 * @example Get changefeed for an entire container from now
213 * ```typescript
214 * const options = { changeFeedStartFrom: ChangeFeedStartFrom.Now() };
215 * for await(const res of container.items.getChangeFeedIterator(options).getAsyncIterator()) {
216 * //process res
217 * }
218 * ```
219 */
220 getAsyncIterator(): AsyncIterable<ChangeFeedIteratorResponse<Array<T & Resource>>>;
221}
222
223/**
224 * A single response page from the Azure Cosmos DB Change Feed
225 */
226export declare class ChangeFeedResponse<T> {
227 /**
228 * Gets the items returned in the response from Azure Cosmos DB
229 */
230 readonly result: T;
231 /**
232 * Gets the number of items returned in the response from Azure Cosmos DB
233 */
234 readonly count: number;
235 /**
236 * Gets the status code of the response from Azure Cosmos DB
237 */
238 readonly statusCode: number;
239 readonly diagnostics: CosmosDiagnostics;
240 /**
241 * Gets the request charge for this request from the Azure Cosmos DB service.
242 */
243 get requestCharge(): number;
244 /**
245 * Gets the activity ID for the request from the Azure Cosmos DB service.
246 */
247 get activityId(): string;
248 /**
249 * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.
250 *
251 * This is equivalent to the `etag` property.
252 */
253 get continuation(): string;
254 /**
255 * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.
256 */
257 get sessionToken(): string;
258 /**
259 * Gets the entity tag associated with last transaction in the Azure Cosmos DB service,
260 * which can be used as If-Non-Match Access condition for ReadFeed REST request or
261 * `continuation` property of `ChangeFeedOptions` parameter for
262 * `Items.changeFeed()`
263 * to get feed changes since the transaction specified by this entity tag.
264 *
265 * This is equivalent to the `continuation` property.
266 */
267 get etag(): string;
268 /**
269 * Response headers of the response from Azure Cosmos DB
270 */
271 headers: CosmosHeaders;
272}
273
274export declare class ChangeFeedRetentionTimeSpan {
275 private retentionInMinutes;
276 /**
277 * Specifies the retention window in minutes for which processing the change feed with allVersionsAndDeletes mode will be available.
278 */
279 static fromMinutes(minutes: number): ChangeFeedRetentionTimeSpan;
280}
281
282/**
283 * Base class for where to start a ChangeFeedIterator.
284 */
285export declare abstract class ChangeFeedStartFrom {
286 /**
287 * Returns an object that tells the ChangeFeedIterator to start from the beginning of time.
288 * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.
289 */
290 static Beginning(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromBeginning;
291 /**
292 * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward.
293 * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.
294 **/
295 static Now(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromNow;
296 /**
297 * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward.
298 * @param startTime - Date object specfiying the time to start reading changes from.
299 * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.
300 */
301 static Time(startTime: Date, cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromTime;
302 /**
303 * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point.
304 * @param continuation - The continuation to resume from.
305 */
306 static Continuation(continuationToken: string): ChangeFeedStartFromContinuation;
307}
308
309/**
310 * @hidden
311 * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time.
312 */
313declare class ChangeFeedStartFromBeginning {
314 private cfResource?;
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 saved point.
322 */
323declare class ChangeFeedStartFromContinuation {
324 private continuationToken;
325 constructor(continuation: string);
326 getCfResource(): string;
327 getCfResourceJson(): any;
328 getResourceType(): any;
329}
330
331/**
332 * @hidden
333 * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time.
334 */
335declare class ChangeFeedStartFromNow {
336 cfResource?: PartitionKey | FeedRange;
337 constructor(cfResource?: PartitionKey | FeedRange);
338 getCfResource(): PartitionKey | FeedRange | undefined;
339}
340
341/**
342 * @hidden
343 * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time.
344 */
345declare class ChangeFeedStartFromTime {
346 private cfResource?;
347 private startTime;
348 constructor(startTime: Date, cfResource?: PartitionKey | FeedRange);
349 getCfResource(): PartitionKey | FeedRange | undefined;
350 getStartTime(): Date;
351}
352
353/**
354 * This type holds information related to initialization of `CosmosClient`
355 */
356export declare type ClientConfigDiagnostic = {
357 /**
358 * End point configured during client initialization.
359 */
360 endpoint: string;
361 /**
362 * True if `resourceTokens` was supplied during client initialization.
363 */
364 resourceTokensConfigured: boolean;
365 /**
366 * True if `tokenProvider` was supplied during client initialization.
367 */
368 tokenProviderConfigured: boolean;
369 /**
370 * True if `aadCredentials` was supplied during client initialization.
371 */
372 aadCredentialsConfigured: boolean;
373 /**
374 * True if `connectionPolicy` was supplied during client initialization.
375 */
376 connectionPolicyConfigured: boolean;
377 /**
378 * `consistencyLevel` supplied during client initialization.
379 */
380 consistencyLevel?: keyof typeof ConsistencyLevel;
381 /**
382 * `defaultHeaders` supplied during client initialization.
383 */
384 defaultHeaders?: {
385 [key: string]: any;
386 };
387 /**
388 * True if `connectionPolicy` were supplied during client initialization.
389 */
390 agentConfigured: boolean;
391 /**
392 * `userAgentSuffix` supplied during client initialization.
393 */
394 userAgentSuffix: string;
395 /**
396 * `diagnosticLevel` supplied during client initialization.
397 */
398 diagnosticLevel?: CosmosDbDiagnosticLevel;
399 /**
400 * True if `plugins` were supplied during client initialization.
401 */
402 pluginsConfigured: boolean;
403 /**
404 * SDK version
405 */
406 sDKVersion: string;
407};
408
409/**
410 * @hidden
411 * @hidden
412 */
413export declare class ClientContext {
414 private cosmosClientOptions;
415 private globalEndpointManager;
416 private clientConfig;
417 diagnosticLevel: CosmosDbDiagnosticLevel;
418 private readonly sessionContainer;
419 private connectionPolicy;
420 private pipeline;
421 private diagnosticWriter;
422 private diagnosticFormatter;
423 partitionKeyDefinitionCache: {
424 [containerUrl: string]: any;
425 };
426 constructor(cosmosClientOptions: CosmosClientOptions, globalEndpointManager: GlobalEndpointManager, clientConfig: ClientConfigDiagnostic, diagnosticLevel: CosmosDbDiagnosticLevel);
427 /** @hidden */
428 read<T>({ path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
429 path: string;
430 resourceType: ResourceType;
431 resourceId: string;
432 options?: RequestOptions;
433 partitionKey?: PartitionKey;
434 diagnosticNode: DiagnosticNodeInternal;
435 }): Promise<Response_2<T & Resource>>;
436 queryFeed<T>({ path, resourceType, resourceId, resultFn, query, options, diagnosticNode, partitionKeyRangeId, partitionKey, startEpk, endEpk, correlatedActivityId, }: {
437 path: string;
438 resourceType: ResourceType;
439 resourceId: string;
440 resultFn: (result: {
441 [key: string]: any;
442 }) => any[];
443 query: SqlQuerySpec | string;
444 options: FeedOptions;
445 diagnosticNode: DiagnosticNodeInternal;
446 partitionKeyRangeId?: string;
447 partitionKey?: PartitionKey;
448 startEpk?: string | undefined;
449 endEpk?: string | undefined;
450 correlatedActivityId?: string;
451 }): Promise<Response_2<T & Resource>>;
452 getQueryPlan(path: string, resourceType: ResourceType, resourceId: string, query: SqlQuerySpec | string, options: FeedOptions, diagnosticNode: DiagnosticNodeInternal, correlatedActivityId?: string): Promise<Response_2<PartitionedQueryExecutionInfo>>;
453 queryPartitionKeyRanges(collectionLink: string, query?: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<PartitionKeyRange>;
454 delete<T>({ path, resourceType, resourceId, options, partitionKey, method, diagnosticNode, }: {
455 path: string;
456 resourceType: ResourceType;
457 resourceId: string;
458 options?: RequestOptions;
459 partitionKey?: PartitionKey;
460 method?: HTTPMethod;
461 diagnosticNode: DiagnosticNodeInternal;
462 }): Promise<Response_2<T & Resource>>;
463 patch<T>({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
464 body: any;
465 path: string;
466 resourceType: ResourceType;
467 resourceId: string;
468 options?: RequestOptions;
469 partitionKey?: PartitionKey;
470 diagnosticNode: DiagnosticNodeInternal;
471 }): Promise<Response_2<T & Resource>>;
472 create<T, U = T>({ body, path, resourceType, resourceId, diagnosticNode, options, partitionKey, }: {
473 body: T;
474 path: string;
475 resourceType: ResourceType;
476 resourceId: string;
477 diagnosticNode: DiagnosticNodeInternal;
478 options?: RequestOptions;
479 partitionKey?: PartitionKey;
480 }): Promise<Response_2<T & U & Resource>>;
481 private processQueryFeedResponse;
482 private applySessionToken;
483 replace<T>({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
484 body: any;
485 path: string;
486 resourceType: ResourceType;
487 resourceId: string;
488 options?: RequestOptions;
489 partitionKey?: PartitionKey;
490 diagnosticNode: DiagnosticNodeInternal;
491 }): Promise<Response_2<T & Resource>>;
492 upsert<T, U = T>({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: {
493 body: T;
494 path: string;
495 resourceType: ResourceType;
496 resourceId: string;
497 options?: RequestOptions;
498 partitionKey?: PartitionKey;
499 diagnosticNode: DiagnosticNodeInternal;
500 }): Promise<Response_2<T & U & Resource>>;
501 execute<T>({ sprocLink, params, options, partitionKey, diagnosticNode, }: {
502 sprocLink: string;
503 params?: any[];
504 options?: RequestOptions;
505 partitionKey?: PartitionKey;
506 diagnosticNode: DiagnosticNodeInternal;
507 }): Promise<Response_2<T>>;
508 /**
509 * Gets the Database account information.
510 * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved.
511 * If not present, current client's url will be used.
512 */
513 getDatabaseAccount(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<Response_2<DatabaseAccount>>;
514 getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
515 getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
516 getWriteEndpoints(): Promise<readonly string[]>;
517 getReadEndpoints(): Promise<readonly string[]>;
518 batch<T>({ body, path, partitionKey, resourceId, options, diagnosticNode, }: {
519 body: T;
520 path: string;
521 partitionKey: PartitionKey;
522 resourceId: string;
523 options?: RequestOptions;
524 diagnosticNode: DiagnosticNodeInternal;
525 }): Promise<Response_2<any>>;
526 bulk<T>({ body, path, partitionKeyRangeId, resourceId, bulkOptions, options, diagnosticNode, }: {
527 body: T;
528 path: string;
529 partitionKeyRangeId: string;
530 resourceId: string;
531 bulkOptions?: BulkOptions;
532 options?: RequestOptions;
533 diagnosticNode: DiagnosticNodeInternal;
534 }): Promise<Response_2<any>>;
535 private captureSessionToken;
536 clearSessionToken(path: string): void;
537 recordDiagnostics(diagnostic: CosmosDiagnostics): void;
538 initializeDiagnosticSettings(diagnosticLevel: CosmosDbDiagnosticLevel): void;
539 private getSessionParams;
540 private isMasterResource;
541 private buildHeaders;
542 /**
543 * Returns collection of properties which are derived from the context for Request Creation.
544 * These properties have client wide scope, as opposed to request specific scope.
545 * @returns
546 */
547 private getContextDerivedPropsForRequestCreation;
548 getClientConfig(): ClientConfigDiagnostic;
549}
550
551export declare class ClientSideMetrics {
552 readonly requestCharge: number;
553 constructor(requestCharge: number);
554 /**
555 * Adds one or more ClientSideMetrics to a copy of this instance and returns the result.
556 */
557 add(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics;
558 static readonly zero: ClientSideMetrics;
559 static createFromArray(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics;
560}
561
562/**
563 * This is a collection type for all client side diagnostic information.
564 */
565export declare type ClientSideRequestStatistics = {
566 /**
567 * This is the UTC timestamp for start of client operation.
568 */
569 requestStartTimeUTCInMs: number;
570 /**
571 * This is the duration in milli seconds taken by client operation.
572 */
573 requestDurationInMs: number;
574 /**
575 * This is the list of Location Endpoints contacted during the client operation.
576 */
577 locationEndpointsContacted: string[];
578 /**
579 * This field captures diagnostic information for retries happened during client operation.
580 */
581 retryDiagnostics: RetryDiagnostics;
582 /**
583 * This field captures diagnostic information for meta data lookups happened during client operation.
584 */
585 metadataDiagnostics: MetadataLookUpDiagnostics;
586 /**
587 * These are the statistics for main point look operation.
588 */
589 gatewayStatistics: GatewayStatistics[];
590 /**
591 * This is the cumulated Request Payload Length n bytes, this includes metadata calls along with the main operation.
592 */
593 totalRequestPayloadLengthInBytes: number;
594 /**
595 * This is the cumulated Response Payload Length n bytes, this includes metadata calls along with the main operation.
596 */
597 totalResponsePayloadLengthInBytes: number;
598};
599
600/**
601 * Represents a composite path in the indexing policy.
602 */
603export declare interface CompositePath {
604 /** The path in the JSON document to include in the composite index. */
605 path: string;
606 /** The order of the composite index, either "ascending" or "descending". */
607 order: "ascending" | "descending";
608}
609
610export declare interface ComputedProperty {
611 /**
612 * The name of the computed property. Name of the computed property
613 * should be chosen such that it does not collide with any existing
614 * or future document properties.
615 */
616 name: string;
617 query: string;
618 [key: string]: any;
619}
620
621/**
622 * Use to read or delete a given {@link Conflict} by id.
623 *
624 * @see {@link Conflicts} to query or read all conflicts.
625 */
626export declare class Conflict {
627 readonly container: Container;
628 readonly id: string;
629 private readonly clientContext;
630 private partitionKey?;
631 /**
632 * Returns a reference URL to the resource. Used for linking in Permissions.
633 */
634 get url(): string;
635 /**
636 * @hidden
637 * @param container - The parent {@link Container}.
638 * @param id - The id of the given {@link Conflict}.
639 */
640 constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey);
641 /**
642 * Read the {@link ConflictDefinition} for the given {@link Conflict}.
643 */
644 read(options?: RequestOptions): Promise<ConflictResponse>;
645 /**
646 * Delete the given {@link ConflictDefinition}.
647 */
648 delete(options?: RequestOptions): Promise<ConflictResponse>;
649}
650
651export declare interface ConflictDefinition {
652 /** The id of the conflict */
653 id?: string;
654 /** Source resource id */
655 resourceId?: string;
656 resourceType?: ResourceType;
657 operationType?: OperationType;
658 content?: string;
659}
660
661export declare enum ConflictResolutionMode {
662 Custom = "Custom",
663 LastWriterWins = "LastWriterWins"
664}
665
666/**
667 * Represents the conflict resolution policy configuration for specifying how to resolve conflicts
668 * in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service.
669 */
670export declare interface ConflictResolutionPolicy {
671 /**
672 * Gets or sets the <see cref="ConflictResolutionMode"/> in the Azure Cosmos DB service. By default it is {@link ConflictResolutionMode.LastWriterWins}.
673 */
674 mode?: keyof typeof ConflictResolutionMode;
675 /**
676 * Gets or sets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution.
677 * This path must be present in each document and must be an integer value.
678 * In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked.
679 * If the path is unspecified, by default the timestamp path will be used.
680 *
681 * This value should only be set when using {@link ConflictResolutionMode.LastWriterWins}.
682 *
683 * ```typescript
684 * conflictResolutionPolicy.ConflictResolutionPath = "/name/first";
685 * ```
686 *
687 */
688 conflictResolutionPath?: string;
689 /**
690 * Gets or sets the {@link StoredProcedure} which is used for conflict resolution in the Azure Cosmos DB service.
691 * This stored procedure may be created after the {@link Container} is created and can be changed as required.
692 *
693 * 1. This value should only be set when using {@link ConflictResolutionMode.Custom}.
694 * 2. In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed.
695 *
696 * ```typescript
697 * conflictResolutionPolicy.ConflictResolutionProcedure = "resolveConflict"
698 * ```
699 */
700 conflictResolutionProcedure?: string;
701}
702
703export declare class ConflictResponse extends ResourceResponse<ConflictDefinition & Resource> {
704 constructor(resource: ConflictDefinition & Resource, headers: CosmosHeaders, statusCode: number, conflict: Conflict, diagnostics: CosmosDiagnostics);
705 /** A reference to the {@link Conflict} corresponding to the returned {@link ConflictDefinition}. */
706 readonly conflict: Conflict;
707}
708
709/**
710 * Use to query or read all conflicts.
711 *
712 * @see {@link Conflict} to read or delete a given {@link Conflict} by id.
713 */
714export declare class Conflicts {
715 readonly container: Container;
716 private readonly clientContext;
717 constructor(container: Container, clientContext: ClientContext);
718 /**
719 * Queries all conflicts.
720 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
721 * @param options - Use to set options like response page size, continuation tokens, etc.
722 * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.
723 */
724 query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
725 /**
726 * Queries all conflicts.
727 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
728 * @param options - Use to set options like response page size, continuation tokens, etc.
729 * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.
730 */
731 query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
732 /**
733 * Reads all conflicts
734 * @param options - Use to set options like response page size, continuation tokens, etc.
735 */
736 readAll(options?: FeedOptions): QueryIterator<ConflictDefinition & Resource>;
737 }
738
739 /** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */
740 export declare enum ConnectionMode {
741 /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */
742 Gateway = 0
743 }
744
745 /**
746 * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service.
747 */
748 export declare interface ConnectionPolicy {
749 /** Determines which mode to connect to Cosmos with. (Currently only supports Gateway option) */
750 connectionMode?: ConnectionMode;
751 /** Request timeout (time to wait for response from network peer). Represented in milliseconds. */
752 requestTimeout?: number;
753 /**
754 * Flag to enable/disable automatic redirecting of requests based on read/write operations. Default true.
755 * Required to call client.dispose() when this is set to true after destroying the CosmosClient inside another process or in the browser.
756 */
757 enableEndpointDiscovery?: boolean;
758 /** List of azure regions to be used as preferred locations for read requests. */
759 preferredLocations?: string[];
760 /** RetryOptions object which defines several configurable properties used during retry. */
761 retryOptions?: RetryOptions;
762 /**
763 * The flag that enables writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
764 * Default is `false`.
765 */
766 useMultipleWriteLocations?: boolean;
767 /** Rate in milliseconds at which the client will refresh the endpoints list in the background */
768 endpointRefreshRateInMs?: number;
769 /** Flag to enable/disable background refreshing of endpoints. Defaults to false.
770 * Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */
771 enableBackgroundEndpointRefreshing?: boolean;
772 }
773
774 /**
775 * Represents the consistency levels supported for Azure Cosmos DB client operations.<br>
776 * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account.
777 * Consistency levels.
778 *
779 * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual.
780 *
781 * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels.
782 */
783 export declare enum ConsistencyLevel {
784 /**
785 * Strong Consistency guarantees that read operations always return the value that was last written.
786 */
787 Strong = "Strong",
788 /**
789 * Bounded Staleness guarantees that reads are not too out-of-date.
790 * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds).
791 */
792 BoundedStaleness = "BoundedStaleness",
793 /**
794 * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again),
795 * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads)
796 * within any single session.
797 */
798 Session = "Session",
799 /**
800 * Eventual Consistency guarantees that reads will return a subset of writes.
801 * All writes will be eventually be available for reads.
802 */
803 Eventual = "Eventual",
804 /**
805 * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps.
806 * All writes will be eventually be available for reads.
807 */
808 ConsistentPrefix = "ConsistentPrefix"
809 }
810
811 /**
812 * @hidden
813 */
814 export declare const Constants: {
815 HttpHeaders: {
816 Authorization: string;
817 ETag: string;
818 MethodOverride: string;
819 Slug: string;
820 ContentType: string;
821 LastModified: string;
822 ContentEncoding: string;
823 CharacterSet: string;
824 UserAgent: string;
825 IfModifiedSince: string;
826 IfMatch: string;
827 IfNoneMatch: string;
828 ContentLength: string;
829 AcceptEncoding: string;
830 KeepAlive: string;
831 CacheControl: string;
832 TransferEncoding: string;
833 ContentLanguage: string;
834 ContentLocation: string;
835 ContentMd5: string;
836 ContentRange: string;
837 Accept: string;
838 AcceptCharset: string;
839 AcceptLanguage: string;
840 IfRange: string;
841 IfUnmodifiedSince: string;
842 MaxForwards: string;
843 ProxyAuthorization: string;
844 AcceptRanges: string;
845 ProxyAuthenticate: string;
846 RetryAfter: string;
847 SetCookie: string;
848 WwwAuthenticate: string;
849 Origin: string;
850 Host: string;
851 AccessControlAllowOrigin: string;
852 AccessControlAllowHeaders: string;
853 KeyValueEncodingFormat: string;
854 WrapAssertionFormat: string;
855 WrapAssertion: string;
856 WrapScope: string;
857 SimpleToken: string;
858 HttpDate: string;
859 Prefer: string;
860 Location: string;
861 Referer: string;
862 A_IM: string;
863 Query: string;
864 IsQuery: string;
865 IsQueryPlan: string;
866 SupportedQueryFeatures: string;
867 QueryVersion: string;
868 Continuation: string;
869 ContinuationToken: string;
870 PageSize: string;
871 ItemCount: string;
872 ChangeFeedWireFormatVersion: string;
873 ActivityId: string;
874 CorrelatedActivityId: string;
875 PreTriggerInclude: string;
876 PreTriggerExclude: string;
877 PostTriggerInclude: string;
878 PostTriggerExclude: string;
879 IndexingDirective: string;
880 SessionToken: string;
881 ConsistencyLevel: string;
882 XDate: string;
883 CollectionPartitionInfo: string;
884 CollectionServiceInfo: string;
885 RetryAfterInMilliseconds: string;
886 RetryAfterInMs: string;
887 IsFeedUnfiltered: string;
888 ResourceTokenExpiry: string;
889 EnableScanInQuery: string;
890 EmitVerboseTracesInQuery: string;
891 EnableCrossPartitionQuery: string;
892 ParallelizeCrossPartitionQuery: string;
893 ResponseContinuationTokenLimitInKB: string;
894 PopulateQueryMetrics: string;
895 QueryMetrics: string;
896 PopulateIndexMetrics: string;
897 IndexUtilization: string;
898 Version: string;
899 OwnerFullName: string;
900 OwnerId: string;
901 PartitionKey: string;
902 PartitionKeyRangeID: string;
903 StartEpk: string;
904 EndEpk: string;
905 ReadFeedKeyType: string;
906 MaxEntityCount: string;
907 CurrentEntityCount: string;
908 CollectionQuotaInMb: string;
909 CollectionCurrentUsageInMb: string;
910 MaxMediaStorageUsageInMB: string;
911 CurrentMediaStorageUsageInMB: string;
912 RequestCharge: string;
913 PopulateQuotaInfo: string;
914 MaxResourceQuota: string;
915 OfferType: string;
916 OfferThroughput: string;
917 AutoscaleSettings: string;
918 DisableRUPerMinuteUsage: string;
919 IsRUPerMinuteUsed: string;
920 OfferIsRUPerMinuteThroughputEnabled: string;
921 IndexTransformationProgress: string;
922 LazyIndexingProgress: string;
923 IsUpsert: string;
924 SubStatus: string;
925 EnableScriptLogging: string;
926 ScriptLogResults: string;
927 ALLOW_MULTIPLE_WRITES: string;
928 IsBatchRequest: string;
929 IsBatchAtomic: string;
930 BatchContinueOnError: string;
931 DedicatedGatewayPerRequestCacheStaleness: string;
932 DedicatedGatewayPerRequestBypassCache: string;
933 ForceRefresh: string;
934 PriorityLevel: string;
935 };
936 WritableLocations: string;
937 ReadableLocations: string;
938 LocationUnavailableExpirationTimeInMs: number;
939 ENABLE_MULTIPLE_WRITABLE_LOCATIONS: string;
940 DefaultUnavailableLocationExpirationTimeMS: number;
941 ThrottleRetryCount: string;
942 ThrottleRetryWaitTimeInMs: string;
943 CurrentVersion: string;
944 AzureNamespace: string;
945 AzurePackageName: string;
946 SDKName: string;
947 SDKVersion: string;
948 CosmosDbDiagnosticLevelEnvVarName: string;
949 DefaultMaxBulkRequestBodySizeInBytes: number;
950 Quota: {
951 CollectionSize: string;
952 };
953 Path: {
954 Root: string;
955 DatabasesPathSegment: string;
956 CollectionsPathSegment: string;
957 UsersPathSegment: string;
958 DocumentsPathSegment: string;
959 PermissionsPathSegment: string;
960 StoredProceduresPathSegment: string;
961 TriggersPathSegment: string;
962 UserDefinedFunctionsPathSegment: string;
963 ConflictsPathSegment: string;
964 AttachmentsPathSegment: string;
965 PartitionKeyRangesPathSegment: string;
966 SchemasPathSegment: string;
967 OffersPathSegment: string;
968 TopologyPathSegment: string;
969 DatabaseAccountPathSegment: string;
970 };
971 PartitionKeyRange: PartitionKeyRangePropertiesNames;
972 QueryRangeConstants: {
973 MinInclusive: string;
974 MaxExclusive: string;
975 min: string;
976 };
977 /**
978 * @deprecated Use EffectivePartitionKeyConstants instead
979 */
980 EffectiveParitionKeyConstants: {
981 MinimumInclusiveEffectivePartitionKey: string;
982 MaximumExclusiveEffectivePartitionKey: string;
983 };
984 EffectivePartitionKeyConstants: {
985 MinimumInclusiveEffectivePartitionKey: string;
986 MaximumExclusiveEffectivePartitionKey: string;
987 };
988 AllVersionsAndDeletesChangeFeedWireFormatVersion: string;
989 ChangeFeedIfNoneMatchStartFromNowHeader: string;
990 };
991
992 /**
993 * Operations for reading, replacing, or deleting a specific, existing container by id.
994 *
995 * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`.
996 *
997 * Note: all these operations make calls against a fixed budget.
998 * You should design your system such that these calls scale sublinearly with your application.
999 * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists;
1000 * do this once on application start up.
1001 */
1002 export declare class Container {
1003 readonly database: Database;
1004 readonly id: string;
1005 private readonly clientContext;
1006 private $items;
1007 /**
1008 * Operations for creating new items, and reading/querying all items
1009 *
1010 * For reading, replacing, or deleting an existing item, use `.item(id)`.
1011 *
1012 * @example Create a new item
1013 * ```typescript
1014 * const {body: createdItem} = await container.items.create({id: "<item id>", properties: {}});
1015 * ```
1016 */
1017 get items(): Items;
1018 private $scripts;
1019 /**
1020 * All operations for Stored Procedures, Triggers, and User Defined Functions
1021 */
1022 get scripts(): Scripts;
1023 private $conflicts;
1024 /**
1025 * Operations for reading and querying conflicts for the given container.
1026 *
1027 * For reading or deleting a specific conflict, use `.conflict(id)`.
1028 */
1029 get conflicts(): Conflicts;
1030 /**
1031 * Returns a reference URL to the resource. Used for linking in Permissions.
1032 */
1033 get url(): string;
1034 /**
1035 * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object.
1036 * @param database - The parent {@link Database}.
1037 * @param id - The id of the given container.
1038 * @hidden
1039 */
1040 constructor(database: Database, id: string, clientContext: ClientContext);
1041 /**
1042 * Used to read, replace, or delete a specific, existing {@link Item} by id.
1043 *
1044 * Use `.items` for creating new items, or querying/reading all items.
1045 *
1046 * @param id - The id of the {@link Item}.
1047 * @param partitionKeyValue - The value of the {@link Item} partition key
1048 * @example Replace an item
1049 * `const {body: replacedItem} = await container.item("<item id>", "<partition key value>").replace({id: "<item id>", title: "Updated post", authorID: 5});`
1050 */
1051 item(id: string, partitionKeyValue?: PartitionKey): Item;
1052 /**
1053 * Used to read, replace, or delete a specific, existing {@link Conflict} by id.
1054 *
1055 * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts.
1056 * @param id - The id of the {@link Conflict}.
1057 */
1058 conflict(id: string, partitionKey?: PartitionKey): Conflict;
1059 /** Read the container's definition */
1060 read(options?: RequestOptions): Promise<ContainerResponse>;
1061 /**
1062 * @hidden
1063 */
1064 readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<ContainerResponse>;
1065 /** Replace the container's definition */
1066 replace(body: ContainerDefinition, options?: RequestOptions): Promise<ContainerResponse>;
1067 /** Delete the container */
1068 delete(options?: RequestOptions): Promise<ContainerResponse>;
1069 /**
1070 * Gets the partition key definition first by looking into the cache otherwise by reading the collection.
1071 * @deprecated This method has been renamed to readPartitionKeyDefinition.
1072 */
1073 getPartitionKeyDefinition(): Promise<ResourceResponse<PartitionKeyDefinition>>;
1074 /**
1075 * Gets the partition key definition first by looking into the cache otherwise by reading the collection.
1076 * @hidden
1077 */
1078 readPartitionKeyDefinition(diagnosticNode: DiagnosticNodeInternal): Promise<ResourceResponse<PartitionKeyDefinition>>;
1079 /**
1080 * Gets offer on container. If none exists, returns an OfferResponse with undefined.
1081 */
1082 readOffer(options?: RequestOptions): Promise<OfferResponse>;
1083 getQueryPlan(query: string | SqlQuerySpec): Promise<Response_2<PartitionedQueryExecutionInfo>>;
1084 readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator<PartitionKeyRange>;
1085 /**
1086 *
1087 * @returns all the feed ranges for which changefeed could be fetched.
1088 */
1089 getFeedRanges(): Promise<ReadonlyArray<FeedRange>>;
1090 /**
1091 * Delete all documents belong to the container for the provided partition key value
1092 * @param partitionKey - The partition key value of the items to be deleted
1093 */
1094 deleteAllItemsForPartitionKey(partitionKey: PartitionKey, options?: RequestOptions): Promise<ContainerResponse>;
1095 }
1096
1097 export declare interface ContainerDefinition {
1098 /** The id of the container. */
1099 id?: string;
1100 /** The partition key for the container. */
1101 partitionKey?: PartitionKeyDefinition;
1102 /** The indexing policy associated with the container. */
1103 indexingPolicy?: IndexingPolicy;
1104 /** The default time to live in seconds for items in a container. */
1105 defaultTtl?: number;
1106 /** The conflict resolution policy used to resolve conflicts in a container. */
1107 conflictResolutionPolicy?: ConflictResolutionPolicy;
1108 /** Policy for additional keys that must be unique per partition key */
1109 uniqueKeyPolicy?: UniqueKeyPolicy;
1110 /** Geospatial configuration for a collection. Type is set to Geography by default */
1111 geospatialConfig?: {
1112 type: GeospatialType;
1113 };
1114 /** Change feed policy related to the container */
1115 changeFeedPolicy?: ChangeFeedPolicy;
1116 /** The computed properties of the container */
1117 computedProperties?: ComputedProperty[];
1118 /** The vector embedding policy information for storing items in a container. */
1119 vectorEmbeddingPolicy?: VectorEmbeddingPolicy;
1120 /** The full text policy information for storing items in a container. */
1121 fullTextPolicy?: FullTextPolicy;
1122 }
1123
1124 export declare interface ContainerRequest extends VerboseOmit<ContainerDefinition, "partitionKey"> {
1125 throughput?: number;
1126 maxThroughput?: number;
1127 autoUpgradePolicy?: {
1128 throughputPolicy: {
1129 incrementPercent: number;
1130 };
1131 };
1132 partitionKey?: string | PartitionKeyDefinition;
1133 }
1134
1135 /** Response object for Container operations */
1136 export declare class ContainerResponse extends ResourceResponse<ContainerDefinition & Resource> {
1137 constructor(resource: ContainerDefinition & Resource, headers: CosmosHeaders, statusCode: number, container: Container, diagnostics: CosmosDiagnostics);
1138 /** A reference to the {@link Container} that the returned {@link ContainerDefinition} corresponds to. */
1139 readonly container: Container;
1140 }
1141
1142 /**
1143 * Operations for creating new containers, and reading/querying all containers
1144 *
1145 * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`.
1146 *
1147 * Note: all these operations make calls against a fixed budget.
1148 * You should design your system such that these calls scale sublinearly with your application.
1149 * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists;
1150 * do this once on application start up.
1151 */
1152 export declare class Containers {
1153 readonly database: Database;
1154 private readonly clientContext;
1155 constructor(database: Database, clientContext: ClientContext);
1156 /**
1157 * Queries all containers.
1158 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1159 * @param options - Use to set options like response page size, continuation tokens, etc.
1160 * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.
1161 * @example Read all containers to array.
1162 * ```typescript
1163 * const querySpec: SqlQuerySpec = {
1164 * query: "SELECT * FROM root r WHERE r.id = @container",
1165 * parameters: [
1166 * {name: "@container", value: "Todo"}
1167 * ]
1168 * };
1169 * const {body: containerList} = await client.database("<db id>").containers.query(querySpec).fetchAll();
1170 * ```
1171 */
1172 query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
1173 /**
1174 * Queries all containers.
1175 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1176 * @param options - Use to set options like response page size, continuation tokens, etc.
1177 * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.
1178 * @example Read all containers to array.
1179 * ```typescript
1180 * const querySpec: SqlQuerySpec = {
1181 * query: "SELECT * FROM root r WHERE r.id = @container",
1182 * parameters: [
1183 * {name: "@container", value: "Todo"}
1184 * ]
1185 * };
1186 * const {body: containerList} = await client.database("<db id>").containers.query(querySpec).fetchAll();
1187 * ```
1188 */
1189 query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
1190 /**
1191 * Creates a container.
1192 *
1193 * A container is a named logical container for items.
1194 *
1195 * A database may contain zero or more named containers and each container consists of
1196 * zero or more JSON items.
1197 *
1198 * Being schema-free, the items in a container do not need to share the same structure or fields.
1199 *
1200 *
1201 * Since containers are application resources, they can be authorized using either the
1202 * master key or resource keys.
1203 *
1204 * @param body - Represents the body of the container.
1205 * @param options - Use to set options like response page size, continuation tokens, etc.
1206 */
1207 create(body: ContainerRequest, options?: RequestOptions): Promise<ContainerResponse>;
1208 /**
1209 * @hidden
1210 */
1211 createInternal(diagnosticNode: DiagnosticNodeInternal, body: ContainerRequest, options?: RequestOptions): Promise<ContainerResponse>;
1212 /**
1213 * Checks if a Container exists, and, if it doesn't, creates it.
1214 * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.
1215 * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.)
1216 *
1217 * A container is a named logical container for items.
1218 *
1219 * A database may contain zero or more named containers and each container consists of
1220 * zero or more JSON items.
1221 *
1222 * Being schema-free, the items in a container do not need to share the same structure or fields.
1223 *
1224 *
1225 * Since containers are application resources, they can be authorized using either the
1226 * master key or resource keys.
1227 *
1228 * @param body - Represents the body of the container.
1229 * @param options - Use to set options like response page size, continuation tokens, etc.
1230 */
1231 createIfNotExists(body: ContainerRequest, options?: RequestOptions): Promise<ContainerResponse>;
1232 /**
1233 * Read all containers.
1234 * @param options - Use to set options like response page size, continuation tokens, etc.
1235 * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time.
1236 * @example Read all containers to array.
1237 * ```typescript
1238 * const {body: containerList} = await client.database("<db id>").containers.readAll().fetchAll();
1239 * ```
1240 */
1241 readAll(options?: FeedOptions): QueryIterator<ContainerDefinition & Resource>;
1242 }
1243
1244 /**
1245 * Provides a client-side logical representation of the Azure Cosmos DB database account.
1246 * This client is used to configure and execute requests in the Azure Cosmos DB database service.
1247 * @example Instantiate a client and create a new database
1248 * ```typescript
1249 * const client = new CosmosClient({endpoint: "<URL HERE>", key: "<KEY HERE>"});
1250 * await client.databases.create({id: "<database name here>"});
1251 * ```
1252 * @example Instantiate a client with custom Connection Policy
1253 * ```typescript
1254 * const client = new CosmosClient({
1255 * endpoint: "<URL HERE>",
1256 * key: "<KEY HERE>",
1257 * connectionPolicy: {
1258 * requestTimeout: 10000,
1259 * },
1260 * });
1261 * ```
1262 */
1263 export declare class CosmosClient {
1264 /**
1265 * Used for creating new databases, or querying/reading all databases.
1266 *
1267 * Use `.database(id)` to read, replace, or delete a specific, existing database by id.
1268 *
1269 * @example Create a new database
1270 * ```typescript
1271 * const {resource: databaseDefinition, database} = await client.databases.create({id: "<name here>"});
1272 * ```
1273 */
1274 readonly databases: Databases;
1275 /**
1276 * Used for querying & reading all offers.
1277 *
1278 * Use `.offer(id)` to read, or replace existing offers.
1279 */
1280 readonly offers: Offers;
1281 private clientContext;
1282 private endpointRefresher;
1283 /**
1284 * Creates a new {@link CosmosClient} object from a connection string. Your database connection string can be found in the Azure Portal
1285 */
1286 constructor(connectionString: string);
1287 /**
1288 * Creates a new {@link CosmosClient} object. See {@link CosmosClientOptions} for more details on what options you can use.
1289 * @param options - bag of options; require at least endpoint and auth to be configured
1290 */
1291 constructor(options: CosmosClientOptions);
1292 private initializeClientConfigDiagnostic;
1293 /**
1294 * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.)
1295 */
1296 getDatabaseAccount(options?: RequestOptions): Promise<ResourceResponse<DatabaseAccount>>;
1297 /**
1298 * @hidden
1299 */
1300 getDatabaseAccountInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<ResourceResponse<DatabaseAccount>>;
1301 /**
1302 * Gets the currently used write endpoint url. Useful for troubleshooting purposes.
1303 *
1304 * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1305 */
1306 getWriteEndpoint(): Promise<string>;
1307 /**
1308 * Gets the currently used read endpoint. Useful for troubleshooting purposes.
1309 *
1310 * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1311 */
1312 getReadEndpoint(): Promise<string>;
1313 /**
1314 * Gets the known write endpoints. Useful for troubleshooting purposes.
1315 *
1316 * The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1317 */
1318 getWriteEndpoints(): Promise<readonly string[]>;
1319 /**
1320 * Gets the currently used read endpoint. Useful for troubleshooting purposes.
1321 *
1322 * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.
1323 */
1324 getReadEndpoints(): Promise<readonly string[]>;
1325 /**
1326 * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database.
1327 *
1328 * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object.
1329 *
1330 * @param id - The id of the database.
1331 * @example Create a new container off of an existing database
1332 * ```typescript
1333 * const container = client.database("<database id>").containers.create("<container id>");
1334 * ```
1335 *
1336 * @example Delete an existing database
1337 * ```typescript
1338 * await client.database("<id here>").delete();
1339 * ```
1340 */
1341 database(id: string): Database;
1342 /**
1343 * Used for reading, or updating a existing offer by id.
1344 * @param id - The id of the offer.
1345 */
1346 offer(id: string): Offer;
1347 /**
1348 * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process.
1349 */
1350 dispose(): void;
1351 private backgroundRefreshEndpointList;
1352 }
1353
1354 export declare interface CosmosClientOptions {
1355 /** The service endpoint to use to create the client. */
1356 endpoint: string;
1357 /** The account master or readonly key */
1358 key?: string;
1359 /** An object that contains resources tokens.
1360 * Keys for the object are resource Ids and values are the resource tokens.
1361 */
1362 resourceTokens?: {
1363 [resourcePath: string]: string;
1364 };
1365 /** A user supplied function for resolving header authorization tokens.
1366 * Allows users to generating their own auth tokens, potentially using a separate service
1367 */
1368 tokenProvider?: TokenProvider;
1369 /** AAD token from `@azure/identity`
1370 * Obtain a credential object by creating an `@azure/identity` credential object
1371 * We will then use your credential object and a scope URL (your cosmos db endpoint)
1372 * to authenticate requests to Cosmos
1373 */
1374 aadCredentials?: TokenCredential;
1375 /** An array of {@link Permission} objects. */
1376 permissionFeed?: PermissionDefinition[];
1377 /** An instance of {@link ConnectionPolicy} class.
1378 * This parameter is optional and the default connectionPolicy will be used if omitted.
1379 */
1380 connectionPolicy?: ConnectionPolicy;
1381 /** An optional parameter that represents the consistency level.
1382 * It can take any value from {@link ConsistencyLevel}.
1383 */
1384 consistencyLevel?: keyof typeof ConsistencyLevel;
1385 defaultHeaders?: CosmosHeaders_2;
1386 /** An optional custom http(s) Agent to be used in NodeJS enironments
1387 * Use an agent such as https://github.com/TooTallNate/node-proxy-agent if you need to connect to Cosmos via a proxy
1388 */
1389 agent?: Agent;
1390 /** An optional custom `HttpClient` shape to customize how requests are made by the HTTP pipeline.
1391 * See `@azure/core-rest-pipeline` for details on how to implement this interface. */
1392 httpClient?: HttpClient;
1393 /** A custom string to append to the default SDK user agent. */
1394 userAgentSuffix?: string;
1395 diagnosticLevel?: CosmosDbDiagnosticLevel;
1396 }
1397
1398 /**
1399 * @hidden
1400 */
1401 declare enum CosmosContainerChildResourceKind {
1402 Item = "ITEM",
1403 StoredProcedure = "STORED_PROCEDURE",
1404 UserDefinedFunction = "USER_DEFINED_FUNCTION",
1405 Trigger = "TRIGGER"
1406 }
1407
1408 /**
1409 * Cosmos DB Diagnostic Level
1410 */
1411 export declare enum CosmosDbDiagnosticLevel {
1412 info = "info",
1413 debug = "debug",
1414 debugUnsafe = "debug-unsafe"
1415 }
1416
1417 /**
1418 * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create().
1419 * It has three members -
1420 * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including -
1421 * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls.
1422 * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call.
1423 * - retries
1424 * - endpoints contacted.
1425 * - request, response payload stats.
1426 * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations
1427 * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation.
1428 *
1429 * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be
1430 * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`.
1431 * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments.
1432 * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used
1433 * in production environment.
1434 * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads.
1435 * Is not meant to be used in production environment.
1436 * 3. clientConfig - Captures information related to how client was configured during initialization.
1437 */
1438 export declare class CosmosDiagnostics {
1439 readonly clientSideRequestStatistics: ClientSideRequestStatistics;
1440 readonly diagnosticNode: DiagnosticNode;
1441 readonly clientConfig?: ClientConfigDiagnostic;
1442 }
1443
1444 export declare interface CosmosHeaders {
1445 [key: string]: any;
1446 }
1447
1448 declare interface CosmosHeaders_2 {
1449 [key: string]: string | boolean | number;
1450 }
1451
1452 /**
1453 * @hidden
1454 */
1455 declare enum CosmosKeyType {
1456 PrimaryMaster = "PRIMARY_MASTER",
1457 SecondaryMaster = "SECONDARY_MASTER",
1458 PrimaryReadOnly = "PRIMARY_READONLY",
1459 SecondaryReadOnly = "SECONDARY_READONLY"
1460 }
1461
1462 /**
1463 * Experimental internal only
1464 * Generates the payload representing the permission configuration for the sas token.
1465 */
1466 export declare function createAuthorizationSasToken(masterKey: string, sasTokenProperties: SasTokenProperties): Promise<string>;
1467
1468 export declare type CreateOperation = OperationWithItem & {
1469 operationType: typeof BulkOperationType.Create;
1470 };
1471
1472 export declare interface CreateOperationInput {
1473 partitionKey?: PartitionKey;
1474 ifMatch?: string;
1475 ifNoneMatch?: string;
1476 operationType: typeof BulkOperationType.Create;
1477 resourceBody: JSONObject;
1478 }
1479
1480 /**
1481 * Operations for reading or deleting an existing database.
1482 *
1483 * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`.
1484 *
1485 * Note: all these operations make calls against a fixed budget.
1486 * You should design your system such that these calls scale sublinearly with your application.
1487 * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists;
1488 * do this once on application start up.
1489 */
1490 export declare class Database {
1491 readonly client: CosmosClient;
1492 readonly id: string;
1493 private clientContext;
1494 /**
1495 * Used for creating new containers, or querying/reading all containers.
1496 *
1497 * Use `.database(id)` to read, replace, or delete a specific, existing {@link Database} by id.
1498 *
1499 * @example Create a new container
1500 * ```typescript
1501 * const {body: containerDefinition, container} = await client.database("<db id>").containers.create({id: "<container id>"});
1502 * ```
1503 */
1504 readonly containers: Containers;
1505 /**
1506 * Used for creating new users, or querying/reading all users.
1507 *
1508 * Use `.user(id)` to read, replace, or delete a specific, existing {@link User} by id.
1509 */
1510 readonly users: Users;
1511 /**
1512 * Returns a reference URL to the resource. Used for linking in Permissions.
1513 */
1514 get url(): string;
1515 /** Returns a new {@link Database} instance.
1516 *
1517 * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself.
1518 */
1519 constructor(client: CosmosClient, id: string, clientContext: ClientContext);
1520 /**
1521 * Used to read, replace, or delete a specific, existing {@link Database} by id.
1522 *
1523 * Use `.containers` creating new containers, or querying/reading all containers.
1524 *
1525 * @example Delete a container
1526 * ```typescript
1527 * await client.database("<db id>").container("<container id>").delete();
1528 * ```
1529 */
1530 container(id: string): Container;
1531 /**
1532 * Used to read, replace, or delete a specific, existing {@link User} by id.
1533 *
1534 * Use `.users` for creating new users, or querying/reading all users.
1535 */
1536 user(id: string): User;
1537 /** Read the definition of the given Database. */
1538 read(options?: RequestOptions): Promise<DatabaseResponse>;
1539 /**
1540 * @hidden
1541 */
1542 readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise<DatabaseResponse>;
1543 /** Delete the given Database. */
1544 delete(options?: RequestOptions): Promise<DatabaseResponse>;
1545 /**
1546 * Gets offer on database. If none exists, returns an OfferResponse with undefined.
1547 */
1548 readOffer(options?: RequestOptions): Promise<OfferResponse>;
1549 }
1550
1551 /**
1552 * Represents a DatabaseAccount in the Azure Cosmos DB database service.
1553 */
1554 export declare class DatabaseAccount {
1555 /** The list of writable locations for a geo-replicated database account. */
1556 readonly writableLocations: Location[];
1557 /** The list of readable locations for a geo-replicated database account. */
1558 readonly readableLocations: Location[];
1559 /**
1560 * The self-link for Databases in the databaseAccount.
1561 * @deprecated Use `databasesLink`
1562 */
1563 get DatabasesLink(): string;
1564 /** The self-link for Databases in the databaseAccount. */
1565 readonly databasesLink: string;
1566 /**
1567 * The self-link for Media in the databaseAccount.
1568 * @deprecated Use `mediaLink`
1569 */
1570 get MediaLink(): string;
1571 /** The self-link for Media in the databaseAccount. */
1572 readonly mediaLink: string;
1573 /**
1574 * Attachment content (media) storage quota in MBs ( Retrieved from gateway ).
1575 * @deprecated use `maxMediaStorageUsageInMB`
1576 */
1577 get MaxMediaStorageUsageInMB(): number;
1578 /** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */
1579 readonly maxMediaStorageUsageInMB: number;
1580 /**
1581 * Current attachment content (media) usage in MBs (Retrieved from gateway )
1582 *
1583 * Value is returned from cached information updated periodically and is not guaranteed
1584 * to be real time.
1585 *
1586 * @deprecated use `currentMediaStorageUsageInMB`
1587 */
1588 get CurrentMediaStorageUsageInMB(): number;
1589 /**
1590 * Current attachment content (media) usage in MBs (Retrieved from gateway )
1591 *
1592 * Value is returned from cached information updated periodically and is not guaranteed
1593 * to be real time.
1594 */
1595 readonly currentMediaStorageUsageInMB: number;
1596 /**
1597 * Gets the UserConsistencyPolicy settings.
1598 * @deprecated use `consistencyPolicy`
1599 */
1600 get ConsistencyPolicy(): ConsistencyLevel;
1601 /** Gets the UserConsistencyPolicy settings. */
1602 readonly consistencyPolicy: ConsistencyLevel;
1603 readonly enableMultipleWritableLocations: boolean;
1604 constructor(body: {
1605 [key: string]: any;
1606 }, headers: CosmosHeaders);
1607 }
1608
1609 export declare interface DatabaseDefinition {
1610 /** The id of the database. */
1611 id?: string;
1612 }
1613
1614 export declare interface DatabaseRequest extends DatabaseDefinition {
1615 /** Throughput for this database. */
1616 throughput?: number;
1617 maxThroughput?: number;
1618 autoUpgradePolicy?: {
1619 throughputPolicy: {
1620 incrementPercent: number;
1621 };
1622 };
1623 }
1624
1625 /** Response object for Database operations */
1626 export declare class DatabaseResponse extends ResourceResponse<DatabaseDefinition & Resource> {
1627 constructor(resource: DatabaseDefinition & Resource, headers: CosmosHeaders, statusCode: number, database: Database, diagnostics: CosmosDiagnostics);
1628 /** A reference to the {@link Database} that the returned {@link DatabaseDefinition} corresponds to. */
1629 readonly database: Database;
1630 }
1631
1632 /**
1633 * Operations for creating new databases, and reading/querying all databases
1634 *
1635 * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`.
1636 *
1637 * Note: all these operations make calls against a fixed budget.
1638 * You should design your system such that these calls scale sublinearly with your application.
1639 * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists;
1640 * do this once on application start up.
1641 */
1642 export declare class Databases {
1643 readonly client: CosmosClient;
1644 private readonly clientContext;
1645 /**
1646 * @hidden
1647 * @param client - The parent {@link CosmosClient} for the Database.
1648 */
1649 constructor(client: CosmosClient, clientContext: ClientContext);
1650 /**
1651 * Queries all databases.
1652 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1653 * @param options - Use to set options like response page size, continuation tokens, etc.
1654 * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.
1655 * @example Read all databases to array.
1656 * ```typescript
1657 * const querySpec: SqlQuerySpec = {
1658 * query: "SELECT * FROM root r WHERE r.id = @db",
1659 * parameters: [
1660 * {name: "@db", value: "Todo"}
1661 * ]
1662 * };
1663 * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();
1664 * ```
1665 */
1666 query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
1667 /**
1668 * Queries all databases.
1669 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
1670 * @param options - Use to set options like response page size, continuation tokens, etc.
1671 * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.
1672 * @example Read all databases to array.
1673 * ```typescript
1674 * const querySpec: SqlQuerySpec = {
1675 * query: "SELECT * FROM root r WHERE r.id = @db",
1676 * parameters: [
1677 * {name: "@db", value: "Todo"}
1678 * ]
1679 * };
1680 * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();
1681 * ```
1682 */
1683 query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
1684 /**
1685 * Send a request for creating a database.
1686 *
1687 * A database manages users, permissions and a set of containers.
1688 * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,
1689 * with the database being the logical container for data.
1690 *
1691 * Each Database consists of one or more containers, each of which in turn contain one or more
1692 * documents. Since databases are an administrative resource, the Service Master Key will be
1693 * required in order to access and successfully complete any action using the User APIs.
1694 *
1695 * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.
1696 * @param options - Use to set options like response page size, continuation tokens, etc.
1697 */
1698 create(body: DatabaseRequest, options?: RequestOptions): Promise<DatabaseResponse>;
1699 /**
1700 * @hidden
1701 */
1702 createInternal(diagnosticNode: DiagnosticNodeInternal, body: DatabaseRequest, options?: RequestOptions): Promise<DatabaseResponse>;
1703 /**
1704 * Check if a database exists, and if it doesn't, create it.
1705 * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.
1706 *
1707 * A database manages users, permissions and a set of containers.
1708 * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,
1709 * with the database being the logical container for data.
1710 *
1711 * Each Database consists of one or more containers, each of which in turn contain one or more
1712 * documents. Since databases are an an administrative resource, the Service Master Key will be
1713 * required in order to access and successfully complete any action using the User APIs.
1714 *
1715 * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.
1716 * @param options - Additional options for the request
1717 */
1718 createIfNotExists(body: DatabaseRequest, options?: RequestOptions): Promise<DatabaseResponse>;
1719 /**
1720 * Reads all databases.
1721 * @param options - Use to set options like response page size, continuation tokens, etc.
1722 * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.
1723 * @example Read all databases to array.
1724 * ```typescript
1725 * const {body: databaseList} = await client.databases.readAll().fetchAll();
1726 * ```
1727 */
1728 readAll(options?: FeedOptions): QueryIterator<DatabaseDefinition & Resource>;
1729 }
1730
1731 /** Defines a target data type of an index path specification in the Azure Cosmos DB service. */
1732 export declare enum DataType {
1733 /** Represents a numeric data type. */
1734 Number = "Number",
1735 /** Represents a string data type. */
1736 String = "String",
1737 /** Represents a point data type. */
1738 Point = "Point",
1739 /** Represents a line string data type. */
1740 LineString = "LineString",
1741 /** Represents a polygon data type. */
1742 Polygon = "Polygon",
1743 /** Represents a multi-polygon data type. */
1744 MultiPolygon = "MultiPolygon"
1745 }
1746
1747 export declare const DEFAULT_PARTITION_KEY_PATH: "/_partitionKey";
1748
1749 export declare type DeleteOperation = OperationBase & {
1750 operationType: typeof BulkOperationType.Delete;
1751 id: string;
1752 };
1753
1754 export declare interface DeleteOperationInput {
1755 partitionKey?: PartitionKey;
1756 operationType: typeof BulkOperationType.Delete;
1757 id: string;
1758 }
1759
1760 /**
1761 * @hidden
1762 */
1763 export declare type DiagnosticDataValue = {
1764 selectedLocation: string;
1765 activityId: string;
1766 requestAttempNumber: number;
1767 requestPayloadLengthInBytes: number;
1768 responsePayloadLengthInBytes: number;
1769 responseStatus: number;
1770 readFromCache: boolean;
1771 operationType: OperationType;
1772 metadatOperationType: MetadataLookUpType;
1773 resourceType: ResourceType;
1774 failedAttempty: boolean;
1775 successfulRetryPolicy: string;
1776 partitionKeyRangeId: string;
1777 stateful: boolean;
1778 queryRecordsRead: number;
1779 queryMethodIdentifier: string;
1780 log: string[];
1781 failure: boolean;
1782 startTimeUTCInMs: number;
1783 durationInMs: number;
1784 requestData: Partial<{
1785 requestPayloadLengthInBytes: number;
1786 responsePayloadLengthInBytes: number;
1787 operationType: OperationType;
1788 resourceType: ResourceType;
1789 headers: CosmosHeaders_2;
1790 requestBody: any;
1791 responseBody: any;
1792 url: string;
1793 }>;
1794 };
1795
1796 /**
1797 * Represents a tree like structure, for capturing diagnostic information.
1798 */
1799 export declare interface DiagnosticNode {
1800 id: string;
1801 nodeType: string;
1802 children: DiagnosticNode[];
1803 data: {
1804 [key: string]: any;
1805 };
1806 startTimeUTCInMs: number;
1807 durationInMs: number;
1808 }
1809
1810 /**
1811 * @hidden
1812 * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect
1813 * diagnostic information throughout the lifetime of Diagnostic session.
1814 * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart.
1815 */
1816 export declare class DiagnosticNodeInternal implements DiagnosticNode {
1817 id: string;
1818 nodeType: DiagnosticNodeType;
1819 parent: DiagnosticNodeInternal;
1820 children: DiagnosticNodeInternal[];
1821 data: Partial<DiagnosticDataValue>;
1822 startTimeUTCInMs: number;
1823 durationInMs: number;
1824 diagnosticLevel: CosmosDbDiagnosticLevel;
1825 private diagnosticCtx;
1826 }
1827
1828 /**
1829 * @hidden
1830 */
1831 export declare enum DiagnosticNodeType {
1832 CLIENT_REQUEST_NODE = "CLIENT_REQUEST_NODE",// Top most node representing client operations.
1833 METADATA_REQUEST_NODE = "METADATA_REQUEST_NODE",// Node representing a metadata request.
1834 HTTP_REQUEST = "HTTP_REQUEST",// Node representing REST call to backend services.
1835 BATCH_REQUEST = "BATCH_REQUEST",// Node representing batch request.
1836 PARALLEL_QUERY_NODE = "PARALLEL_QUERY_NODE",// Node representing parallel query execution.
1837 DEFAULT_QUERY_NODE = "DEFAULT_QUERY_NODE",// Node representing default query execution.
1838 QUERY_REPAIR_NODE = "QUERY_REPAIR_NODE",// Node representing query repair.
1839 BACKGROUND_REFRESH_THREAD = "BACKGROUND_REFRESH_THREAD",// Node representing background refresh.
1840 REQUEST_ATTEMPTS = "REQUEST_ATTEMPTS"
1841 }
1842
1843 export declare interface ErrorBody {
1844 code: string;
1845 message: string;
1846 /**
1847 * @hidden
1848 */
1849 additionalErrorInfo?: PartitionedQueryExecutionInfo;
1850 }
1851
1852 export declare class ErrorResponse extends Error {
1853 code?: number | string;
1854 substatus?: number;
1855 body?: ErrorBody;
1856 headers?: CosmosHeaders;
1857 activityId?: string;
1858 retryAfterInMs?: number;
1859 retryAfterInMilliseconds?: number;
1860 [key: string]: any;
1861 diagnostics?: CosmosDiagnostics;
1862 }
1863
1864 export declare type ExistingKeyOperation = {
1865 op: keyof typeof PatchOperationType;
1866 value: any;
1867 path: string;
1868 };
1869
1870 /**
1871 * This type captures diagnostic information regarding a failed request to server api.
1872 */
1873 export declare interface FailedRequestAttemptDiagnostic {
1874 attemptNumber: number;
1875 activityId: string;
1876 startTimeUTCInMs: number;
1877 durationInMs: number;
1878 operationType?: OperationType;
1879 resourceType?: ResourceType;
1880 statusCode: number;
1881 substatusCode?: number;
1882 requestPayloadLengthInBytes: number;
1883 responsePayloadLengthInBytes: number;
1884 }
1885
1886 /**
1887 * The feed options and query methods.
1888 */
1889 export declare interface FeedOptions extends SharedOptions {
1890 /** Opaque token for continuing the enumeration. Default: undefined
1891 * @deprecated Use continuationToken instead.
1892 */
1893 continuation?: string;
1894 /** Opaque token for continuing the enumeration. Default: undefined */
1895 continuationToken?: string;
1896 /**
1897 * Limits the size of the continuation token in the response. Default: undefined
1898 *
1899 * Continuation Tokens contain optional data that can be removed from the serialization before writing it out to a header.
1900 * By default we are capping this to 1kb to avoid long headers (Node.js has a global header size limit).
1901 * A user may set this field to allow for longer headers, which can help the backend optimize query execution."
1902 */
1903 continuationTokenLimitInKB?: number;
1904 /**
1905 * Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths. Default: false
1906 *
1907 * In general, it is best to avoid using this setting. Scans are relatively expensive and take a long time to serve.
1908 */
1909 enableScanInQuery?: boolean;
1910 /**
1911 * The maximum number of concurrent operations that run client side during parallel query execution in the
1912 * Azure Cosmos DB database service. Negative values make the system automatically decides the number of
1913 * concurrent operations to run. Default: 0 (no parallelism)
1914 */
1915 maxDegreeOfParallelism?: number;
1916 /**
1917 * Max number of items to be returned in the enumeration operation. Default: undefined (server will defined payload)
1918 *
1919 * Expirimenting with this value can usually result in the biggest performance changes to the query.
1920 *
1921 * The smaller the item count, the faster the first result will be delivered (for non-aggregates). For larger amounts,
1922 * 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
1923 * 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.)
1924 */
1925 maxItemCount?: number;
1926 /**
1927 * Note: consider using changeFeed instead.
1928 *
1929 * Indicates a change feed request. Must be set to "Incremental feed", or omitted otherwise. Default: false
1930 */
1931 useIncrementalFeed?: boolean;
1932 /** Conditions Associated with the request. */
1933 accessCondition?: {
1934 /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */
1935 type: string;
1936 /** Conditional HTTP method header value (the _etag field from the last version you read). */
1937 condition: string;
1938 };
1939 /**
1940 * Enable returning query metrics in response headers. Default: false
1941 *
1942 * Used for debugging slow or expensive queries. Also increases response size and if you're using a low max header size in Node.js,
1943 * you can run into issues faster.
1944 */
1945 populateQueryMetrics?: boolean;
1946 /**
1947 * Enable buffering additional items during queries. Default: false
1948 *
1949 * This will buffer an additional page at a time (multiplied by maxDegreeOfParallelism) from the server in the background.
1950 * This improves latency by fetching pages before they are needed by the client. If you're draining all of the results from the
1951 * server, like `.fetchAll`, you should usually enable this. If you're only fetching one page at a time via continuation token,
1952 * you should avoid this. If you're draining more than one page, but not the entire result set, it may help improve latency, but
1953 * it will increase the total amount of RU/s use to serve the entire query (as some pages will be fetched more than once).
1954 */
1955 bufferItems?: boolean;
1956 /**
1957 * This setting forces the query to use a query plan. Default: false
1958 *
1959 * Note: this will disable continuation token support, even for single partition queries.
1960 *
1961 * For queries like aggregates and most cross partition queries, this happens anyway.
1962 * However, since the library doesn't know what type of query it is until we get back the first response,
1963 * some optimization can't happen until later.
1964 *
1965 * If this setting is enabled, it will force query plan for the query, which will save some network requests
1966 * and ensure parallelism can happen. Useful for when you know you're doing cross-partition or aggregate queries.
1967 */
1968 forceQueryPlan?: boolean;
1969 /** Limits the query to a specific partition key. Default: undefined
1970 *
1971 * Scoping a query to a single partition can be accomplished two ways:
1972 *
1973 * `container.items.query('SELECT * from c', { partitionKey: "foo" }).toArray()`
1974 * `container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray()`
1975 *
1976 * The former is useful when the query body is out of your control
1977 * but you still want to restrict it to a single partition. Example: an end user specified query.
1978 */
1979 partitionKey?: PartitionKey;
1980 /**
1981 * Enable returning index metrics in response headers. Default: false
1982 */
1983 populateIndexMetrics?: boolean;
1984 /**
1985 * Specifies a custom maximum buffer size for storing final results for nonStreamingOrderBy queries.
1986 * This value is ignored if the query includes top/offset+limit clauses.
1987 */
1988 vectorSearchBufferSize?: number;
1989 /**
1990 * Disable the nonStreamingOrderBy query feature in supported query features.
1991 * Default: false. Set to true to avoid error from an old gateway that doesn't support this feature.
1992 */
1993 disableNonStreamingOrderByQuery?: boolean;
1994 /**
1995 * Valid only for non streaming order by query.
1996 * Default: false; When set to true, it allows queries to bypass the default behavior that blocks nonStreaming queries without top or limit clauses.
1997 */
1998 allowUnboundedNonStreamingQueries?: boolean;
1999 }
2000
2001 /**
2002 * Specifies a feed range for the changefeed.
2003 */
2004 export declare abstract class FeedRange {
2005 /**
2006 * Min value for the feed range.
2007 */
2008 readonly minInclusive: string;
2009 /**
2010 * Max value for the feed range.
2011 */
2012 readonly maxExclusive: string;
2013 }
2014
2015 export declare class FeedResponse<TResource> {
2016 readonly resources: TResource[];
2017 private readonly headers;
2018 readonly hasMoreResults: boolean;
2019 readonly diagnostics: CosmosDiagnostics;
2020 constructor(resources: TResource[], headers: CosmosHeaders, hasMoreResults: boolean, diagnostics: CosmosDiagnostics);
2021 get continuation(): string;
2022 get continuationToken(): string;
2023 get queryMetrics(): string;
2024 get requestCharge(): number;
2025 get activityId(): string;
2026 get correlatedActivityId(): string;
2027 get indexMetrics(): string;
2028 }
2029
2030 /** @hidden */
2031 declare type FetchFunctionCallback = (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions, correlatedActivityId: string) => Promise<Response_2<any>>;
2032
2033 /**
2034 * Represents a full text index in the indexing policy.
2035 */
2036 export declare interface FullTextIndex {
2037 /** The path in the JSON document to index. */
2038 path: string;
2039 }
2040
2041 /**
2042 * Represents a full text path to be indexed in the Azure Cosmos DB service.
2043 */
2044 export declare interface FullTextPath {
2045 /**
2046 * The path to be indexed for full text search.
2047 */
2048 path: string;
2049 /**
2050 * The language for the full text path.
2051 */
2052 language: string;
2053 }
2054
2055 /**
2056 * Represents a full text policy for a collection in the Azure Cosmos DB service.
2057 */
2058 export declare interface FullTextPolicy {
2059 /**
2060 * The default language for the full text .
2061 */
2062 defaultLanguage: string;
2063 /**
2064 * The paths to be indexed for full text search.
2065 */
2066 fullTextPaths: FullTextPath[];
2067 }
2068
2069 export declare type GatewayStatistics = {
2070 /**
2071 * This is the activityId for request, made to server for fetching the requested resource. (As opposed to other potential meta data requests)
2072 */
2073 activityId?: string;
2074 correlatedActivityId?: string;
2075 startTimeUTCInMs: number;
2076 durationInMs: number;
2077 operationType?: OperationType;
2078 resourceType?: ResourceType;
2079 statusCode?: number;
2080 subStatusCode?: number;
2081 requestCharge?: number;
2082 requestPayloadLengthInBytes: number;
2083 responsePayloadLengthInBytes: number;
2084 };
2085
2086 export declare enum GeospatialType {
2087 /** Represents data in round-earth coordinate system. */
2088 Geography = "Geography",
2089 /** Represents data in Eucledian(flat) coordinate system. */
2090 Geometry = "Geometry"
2091 }
2092
2093 /**
2094 * @hidden
2095 * This internal class implements the logic for endpoint management for geo-replicated database accounts.
2096 */
2097 export declare class GlobalEndpointManager {
2098 private readDatabaseAccount;
2099 /**
2100 * The endpoint used to create the client instance.
2101 */
2102 private defaultEndpoint;
2103 /**
2104 * Flag to enable/disable automatic redirecting of requests based on read/write operations.
2105 */
2106 enableEndpointDiscovery: boolean;
2107 private isRefreshing;
2108 private options;
2109 /**
2110 * List of azure regions to be used as preferred locations for read requests.
2111 */
2112 private preferredLocations;
2113 private writeableLocations;
2114 private readableLocations;
2115 private unavailableReadableLocations;
2116 private unavailableWriteableLocations;
2117 preferredLocationsCount: number;
2118 /**
2119 * Gets the current read endpoint from the endpoint cache.
2120 */
2121 getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
2122 /**
2123 * Gets the current write endpoint from the endpoint cache.
2124 */
2125 getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string>;
2126 getReadEndpoints(): Promise<ReadonlyArray<string>>;
2127 getWriteEndpoints(): Promise<ReadonlyArray<string>>;
2128 markCurrentLocationUnavailableForRead(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise<void>;
2129 markCurrentLocationUnavailableForWrite(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise<void>;
2130 canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean;
2131 resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise<string>;
2132 /**
2133 * Refreshes the endpoint list by clearning stale unavailability and then
2134 * retrieving the writable and readable locations from the geo-replicated database account
2135 * and then updating the locations cache.
2136 * We skip the refreshing if enableEndpointDiscovery is set to False
2137 */
2138 refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise<void>;
2139 private refreshEndpoints;
2140 private refreshStaleUnavailableLocations;
2141 /**
2142 * update the locationUnavailability to undefined if the location is available again
2143 * @param now - current time
2144 * @param unavailableLocations - list of unavailable locations
2145 * @param allLocations - list of all locations
2146 */
2147 private updateLocation;
2148 private cleanUnavailableLocationList;
2149 /**
2150 * Gets the database account first by using the default endpoint, and if that doesn't returns
2151 * use the endpoints for the preferred locations in the order they are specified to get
2152 * the database account.
2153 */
2154 private getDatabaseAccountFromAnyEndpoint;
2155 /**
2156 * Gets the locational endpoint using the location name passed to it using the default endpoint.
2157 *
2158 * @param defaultEndpoint - The default endpoint to use for the endpoint.
2159 * @param locationName - The location name for the azure region like "East US".
2160 */
2161 private static getLocationalEndpoint;
2162 }
2163
2164 export declare interface GroupByAliasToAggregateType {
2165 [key: string]: AggregateType;
2166 }
2167
2168 export declare type GroupByExpressions = string[];
2169
2170 /**
2171 * @hidden
2172 */
2173 export declare enum HTTPMethod {
2174 get = "GET",
2175 patch = "PATCH",
2176 post = "POST",
2177 put = "PUT",
2178 delete = "DELETE"
2179 }
2180
2181 /**
2182 * @hidden
2183 * Represents the hybrid search query information
2184 */
2185 export declare interface HybridSearchQueryInfo {
2186 /**
2187 * The query to be used for fetching global statistics
2188 */
2189 globalStatisticsQuery: string;
2190 /**
2191 * Query information for the subsequent queries
2192 */
2193 componentQueryInfos: QueryInfo[];
2194 /**
2195 * The number of results in the final result set
2196 */
2197 take: number;
2198 /**
2199 * The number of results to skip in the final result set
2200 */
2201 skip: number;
2202 /**
2203 * Whether the query requires global statistics
2204 */
2205 requiresGlobalStatistics: boolean;
2206 }
2207
2208 export declare interface Index {
2209 kind: keyof typeof IndexKind;
2210 dataType: keyof typeof DataType;
2211 precision?: number;
2212 }
2213
2214 export declare interface IndexedPath {
2215 path: string;
2216 indexes?: Index[];
2217 }
2218
2219 /**
2220 * Specifies the supported indexing modes.
2221 */
2222 export declare enum IndexingMode {
2223 /**
2224 * Index is updated synchronously with a create or update operation.
2225 *
2226 * With consistent indexing, query behavior is the same as the default consistency level for the container.
2227 * The index is always kept up to date with the data.
2228 */
2229 consistent = "consistent",
2230 /**
2231 * Index is updated asynchronously with respect to a create or update operation.
2232 *
2233 * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle.
2234 */
2235 lazy = "lazy",
2236 /** No Index is provided. */
2237 none = "none"
2238 }
2239
2240 export declare interface IndexingPolicy {
2241 /** The indexing mode (consistent or lazy) {@link IndexingMode}. */
2242 indexingMode?: keyof typeof IndexingMode;
2243 automatic?: boolean;
2244 /** An array of {@link IncludedPath} represents the paths to be included for indexing. */
2245 includedPaths?: IndexedPath[];
2246 /** An array of {@link IncludedPath} represents the paths to be excluded for indexing. */
2247 excludedPaths?: IndexedPath[];
2248 spatialIndexes?: SpatialIndex[];
2249 /** An array of {@link VectorIndex} represents the vector index paths to be included for indexing. */
2250 vectorIndexes?: VectorIndex[];
2251 /** An array of {@link CompositeIndexes} representing composite indexes to be included. */
2252 compositeIndexes?: CompositePath[][];
2253 /** An array of {@link FullTextIndex} representing full text indexes to be included. */
2254 fullTextIndexes?: FullTextIndex[];
2255 }
2256
2257 /**
2258 * Specifies the supported Index types.
2259 */
2260 export declare enum IndexKind {
2261 /**
2262 * This is supplied for a path which requires sorting.
2263 */
2264 Range = "Range",
2265 /**
2266 * This is supplied for a path which requires geospatial indexing.
2267 */
2268 Spatial = "Spatial"
2269 }
2270
2271 /**
2272 * Used to perform operations on a specific item.
2273 *
2274 * @see {@link Items} for operations on all items; see `container.items`.
2275 */
2276 export declare class Item {
2277 readonly container: Container;
2278 readonly id: string;
2279 private readonly clientContext;
2280 private partitionKey;
2281 /**
2282 * Returns a reference URL to the resource. Used for linking in Permissions.
2283 */
2284 get url(): string;
2285 /**
2286 * @hidden
2287 * @param container - The parent {@link Container}.
2288 * @param id - The id of the given {@link Item}.
2289 * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers).
2290 */
2291 constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey);
2292 /**
2293 * Read the item's definition.
2294 *
2295 * Any provided type, T, is not necessarily enforced by the SDK.
2296 * You may get more or less properties and it's up to your logic to enforce it.
2297 * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype.
2298 * It's recommended to only use interfaces.
2299 *
2300 * There is no set schema for JSON items. They may contain any number of custom properties.
2301 *
2302 * @param options - Additional options for the request
2303 *
2304 * @example Using custom type for response
2305 * ```typescript
2306 * interface TodoItem {
2307 * title: string;
2308 * done: bool;
2309 * id: string;
2310 * }
2311 *
2312 * let item: TodoItem;
2313 * ({body: item} = await item.read<TodoItem>());
2314 * ```
2315 */
2316 read<T extends ItemDefinition = any>(options?: RequestOptions): Promise<ItemResponse<T>>;
2317 /**
2318 * Replace the item's definition.
2319 *
2320 * There is no set schema for JSON items. They may contain any number of custom properties.
2321 *
2322 * @param body - The definition to replace the existing {@link Item}'s definition with.
2323 * @param options - Additional options for the request
2324 */
2325 replace(body: ItemDefinition, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>;
2326 /**
2327 * Replace the item's definition.
2328 *
2329 * Any provided type, T, is not necessarily enforced by the SDK.
2330 * You may get more or less properties and it's up to your logic to enforce it.
2331 *
2332 * There is no set schema for JSON items. They may contain any number of custom properties.
2333 *
2334 * @param body - The definition to replace the existing {@link Item}'s definition with.
2335 * @param options - Additional options for the request
2336 */
2337 replace<T extends ItemDefinition>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
2338 /**
2339 * Delete the item.
2340 *
2341 * Any provided type, T, is not necessarily enforced by the SDK.
2342 * You may get more or less properties and it's up to your logic to enforce it.
2343 *
2344 * @param options - Additional options for the request
2345 */
2346 delete<T extends ItemDefinition = any>(options?: RequestOptions): Promise<ItemResponse<T>>;
2347 /**
2348 * Perform a JSONPatch on the item.
2349 *
2350 * Any provided type, T, is not necessarily enforced by the SDK.
2351 * You may get more or less properties and it's up to your logic to enforce it.
2352 *
2353 * @param options - Additional options for the request
2354 */
2355 patch<T extends ItemDefinition = any>(body: PatchRequestBody, options?: RequestOptions): Promise<ItemResponse<T>>;
2356 }
2357
2358 /**
2359 * Items in Cosmos DB are simply JSON objects.
2360 * Most of the Item operations allow for your to provide your own type
2361 * that extends the very simple ItemDefinition.
2362 *
2363 * You cannot use any reserved keys. You can see the reserved key list
2364 * in {@link ItemBody}
2365 */
2366 export declare interface ItemDefinition {
2367 /** The id of the item. User settable property. Uniquely identifies the item along with the partition key */
2368 id?: string;
2369 /** Time to live in seconds for collections with TTL enabled */
2370 ttl?: number;
2371 [key: string]: any;
2372 }
2373
2374 export declare class ItemResponse<T extends ItemDefinition> extends ResourceResponse<T & Resource> {
2375 constructor(resource: T & Resource, headers: CosmosHeaders, statusCode: number, subsstatusCode: number, item: Item, diagnostics: CosmosDiagnostics);
2376 /** Reference to the {@link Item} the response corresponds to. */
2377 readonly item: Item;
2378 }
2379
2380 /**
2381 * Operations for creating new items, and reading/querying all items
2382 *
2383 * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`.
2384 */
2385 export declare class Items {
2386 readonly container: Container;
2387 private readonly clientContext;
2388 private partitionKeyRangeCache;
2389 /**
2390 * Create an instance of {@link Items} linked to the parent {@link Container}.
2391 * @param container - The parent container.
2392 * @hidden
2393 */
2394 constructor(container: Container, clientContext: ClientContext);
2395 /**
2396 * Queries all items.
2397 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2398 * @param options - Used for modifying the request (for instance, specifying the partition key).
2399 * @example Read all items to array.
2400 * ```typescript
2401 * const querySpec: SqlQuerySpec = {
2402 * query: "SELECT * FROM Families f WHERE f.lastName = @lastName",
2403 * parameters: [
2404 * {name: "@lastName", value: "Hendricks"}
2405 * ]
2406 * };
2407 * const {result: items} = await items.query(querySpec).fetchAll();
2408 * ```
2409 */
2410 query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>;
2411 /**
2412 * Queries all items.
2413 * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
2414 * @param options - Used for modifying the request (for instance, specifying the partition key).
2415 * @example Read all items to array.
2416 * ```typescript
2417 * const querySpec: SqlQuerySpec = {
2418 * query: "SELECT firstname FROM Families f WHERE f.lastName = @lastName",
2419 * parameters: [
2420 * {name: "@lastName", value: "Hendricks"}
2421 * ]
2422 * };
2423 * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll();
2424 * ```
2425 */
2426 query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>;
2427 /**
2428 * Create a `ChangeFeedIterator` to iterate over pages of changes
2429 *
2430 * @deprecated Use `changeFeed` instead.
2431 *
2432 * @example Read from the beginning of the change feed.
2433 * ```javascript
2434 * const iterator = items.readChangeFeed({ startFromBeginning: true });
2435 * const firstPage = await iterator.fetchNext();
2436 * const firstPageResults = firstPage.result
2437 * const secondPage = await iterator.fetchNext();
2438 * ```
2439 */
2440 readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2441 /**
2442 * Create a `ChangeFeedIterator` to iterate over pages of changes
2443 * @deprecated Use `changeFeed` instead.
2444 *
2445 */
2446 readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2447 /**
2448 * Create a `ChangeFeedIterator` to iterate over pages of changes
2449 * @deprecated Use `changeFeed` instead.
2450 */
2451 readChangeFeed<T>(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2452 /**
2453 * Create a `ChangeFeedIterator` to iterate over pages of changes
2454 * @deprecated Use `changeFeed` instead.
2455 */
2456 readChangeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2457 /**
2458 * Create a `ChangeFeedIterator` to iterate over pages of changes
2459 *
2460 * @example Read from the beginning of the change feed.
2461 * ```javascript
2462 * const iterator = items.readChangeFeed({ startFromBeginning: true });
2463 * const firstPage = await iterator.fetchNext();
2464 * const firstPageResults = firstPage.result
2465 * const secondPage = await iterator.fetchNext();
2466 * ```
2467 */
2468 changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2469 /**
2470 * Create a `ChangeFeedIterator` to iterate over pages of changes
2471 */
2472 changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
2473 /**
2474 * Create a `ChangeFeedIterator` to iterate over pages of changes
2475 */
2476 changeFeed<T>(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2477 /**
2478 * Create a `ChangeFeedIterator` to iterate over pages of changes
2479 */
2480 changeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
2481 /**
2482 * 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.
2483 */
2484 getChangeFeedIterator<T>(changeFeedIteratorOptions?: ChangeFeedIteratorOptions): ChangeFeedPullModelIterator<T>;
2485 /**
2486 * Read all items.
2487 *
2488 * There is no set schema for JSON items. They may contain any number of custom properties.
2489 *
2490 * @param options - Used for modifying the request (for instance, specifying the partition key).
2491 * @example Read all items to array.
2492 * ```typescript
2493 * const {body: containerList} = await items.readAll().fetchAll();
2494 * ```
2495 */
2496 readAll(options?: FeedOptions): QueryIterator<ItemDefinition>;
2497 /**
2498 * Read all items.
2499 *
2500 * Any provided type, T, is not necessarily enforced by the SDK.
2501 * You may get more or less properties and it's up to your logic to enforce it.
2502 *
2503 * There is no set schema for JSON items. They may contain any number of custom properties.
2504 *
2505 * @param options - Used for modifying the request (for instance, specifying the partition key).
2506 * @example Read all items to array.
2507 * ```typescript
2508 * const {body: containerList} = await items.readAll().fetchAll();
2509 * ```
2510 */
2511 readAll<T extends ItemDefinition>(options?: FeedOptions): QueryIterator<T>;
2512 /**
2513 * Create an item.
2514 *
2515 * Any provided type, T, is not necessarily enforced by the SDK.
2516 * You may get more or less properties and it's up to your logic to enforce it.
2517 *
2518 * There is no set schema for JSON items. They may contain any number of custom properties.
2519 *
2520 * @param body - Represents the body of the item. Can contain any number of user defined properties.
2521 * @param options - Used for modifying the request (for instance, specifying the partition key).
2522 */
2523 create<T extends ItemDefinition = any>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
2524 /**
2525 * Upsert an item.
2526 *
2527 * There is no set schema for JSON items. They may contain any number of custom properties.
2528 *
2529 * @param body - Represents the body of the item. Can contain any number of user defined properties.
2530 * @param options - Used for modifying the request (for instance, specifying the partition key).
2531 */
2532 upsert(body: unknown, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>;
2533 /**
2534 * Upsert an item.
2535 *
2536 * Any provided type, T, is not necessarily enforced by the SDK.
2537 * You may get more or less properties and it's up to your logic to enforce it.
2538 *
2539 * There is no set schema for JSON items. They may contain any number of custom properties.
2540 *
2541 * @param body - Represents the body of the item. Can contain any number of user defined properties.
2542 * @param options - Used for modifying the request (for instance, specifying the partition key).
2543 */
2544 upsert<T extends ItemDefinition>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>;
2545 /**
2546 * Execute bulk operations on items.
2547 *
2548 * Bulk takes an array of Operations which are typed based on what the operation does.
2549 * The choices are: Create, Upsert, Read, Replace, and Delete
2550 *
2551 * Usage example:
2552 * ```typescript
2553 * // partitionKey is optional at the top level if present in the resourceBody
2554 * const operations: OperationInput[] = [
2555 * {
2556 * operationType: "Create",
2557 * resourceBody: { id: "doc1", name: "sample", key: "A" }
2558 * },
2559 * {
2560 * operationType: "Upsert",
2561 * partitionKey: 'A',
2562 * resourceBody: { id: "doc2", name: "other", key: "A" }
2563 * }
2564 * ]
2565 *
2566 * await database.container.items.bulk(operations)
2567 * ```
2568 *
2569 * @param operations - List of operations. Limit 100
2570 * @param bulkOptions - Optional options object to modify bulk behavior. Pass \{ continueOnError: false \} to stop executing operations when one fails. (Defaults to true)
2571 * @param options - Used for modifying the request.
2572 */
2573 bulk(operations: OperationInput[], bulkOptions?: BulkOptions, options?: RequestOptions): Promise<BulkOperationResponse>;
2574 private executeBatchOperations;
2575 /**
2576 * Function to create new batches based of partition key Ranges.
2577 *
2578 * @param overlappingRanges - Overlapping partition key ranges.
2579 * @param batch - Batch to be split.
2580 * @param partitionKeyDefinition - PartitionKey definition of container.
2581 * @returns Array of new batches.
2582 */
2583 private createNewBatches;
2584 /**
2585 * Function to create batches based of partition key Ranges.
2586 * @param operations - operations to group
2587 * @param partitionDefinition - PartitionKey definition of container.
2588 * @param options - Request options for bulk request.
2589 * @param batches - Groups to be filled with operations.
2590 */
2591 private groupOperationsBasedOnPartitionKey;
2592 /**
2593 * Execute transactional batch operations on items.
2594 *
2595 * 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.
2596 * The choices are: Create, Upsert, Read, Replace, and Delete
2597 *
2598 * Usage example:
2599 * ```typescript
2600 * // The partitionKey is a required second argument. If it’s undefined, it defaults to the expected partition key format.
2601 * const operations: OperationInput[] = [
2602 * {
2603 * operationType: "Create",
2604 * resourceBody: { id: "doc1", name: "sample", key: "A" }
2605 * },
2606 * {
2607 * operationType: "Upsert",
2608 * resourceBody: { id: "doc2", name: "other", key: "A" }
2609 * }
2610 * ]
2611 *
2612 * await database.container.items.batch(operations, "A")
2613 * ```
2614 *
2615 * @param operations - List of operations. Limit 100
2616 * @param options - Used for modifying the request
2617 */
2618 batch(operations: OperationInput[], partitionKey?: PartitionKey, options?: RequestOptions): Promise<Response_2<OperationResponse[]>>;
2619 }
2620
2621 export declare interface JSONArray extends ArrayLike<JSONValue> {
2622 }
2623
2624 export declare interface JSONObject {
2625 [key: string]: JSONValue;
2626 }
2627
2628 export declare type JSONValue = boolean | number | string | null | JSONArray | JSONObject;
2629
2630 /**
2631 * Used to specify the locations that are available, read is index 1 and write is index 0.
2632 */
2633 export declare interface Location {
2634 name: string;
2635 databaseAccountEndpoint: string;
2636 unavailable?: boolean;
2637 lastUnavailabilityTimestampInMs?: number;
2638 }
2639
2640 /**
2641 * This type contains diagnostic information regarding a single metadata request to server.
2642 */
2643 export declare interface MetadataLookUpDiagnostic {
2644 activityId: string;
2645 startTimeUTCInMs: number;
2646 durationInMs: number;
2647 operationType?: OperationType;
2648 resourceType?: ResourceType;
2649 metaDataType: MetadataLookUpType;
2650 requestPayloadLengthInBytes: number;
2651 responsePayloadLengthInBytes: number;
2652 }
2653
2654 /**
2655 * This type contains diagnostic information regarding all metadata request to server during an CosmosDB client operation.
2656 */
2657 export declare type MetadataLookUpDiagnostics = {
2658 metadataLookups: MetadataLookUpDiagnostic[];
2659 };
2660
2661 /**
2662 * This is enum for Type of Metadata lookups possible.
2663 */
2664 export declare enum MetadataLookUpType {
2665 PartitionKeyRangeLookUp = "PARTITION_KEY_RANGE_LOOK_UP",
2666 DatabaseAccountLookUp = "DATABASE_ACCOUNT_LOOK_UP",
2667 QueryPlanLookUp = "QUERY_PLAN_LOOK_UP",
2668 DatabaseLookUp = "DATABASE_LOOK_UP",
2669 ContainerLookUp = "CONTAINER_LOOK_UP"
2670 }
2671
2672 /**
2673 * 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,
2674 * allowing you to log those results or handle errors.
2675 * @hidden
2676 */
2677 export declare type Next<T> = (context: RequestContext) => Promise<Response_2<T>>;
2678
2679 /**
2680 * The returned object represents a partition key value that allows creating and accessing items
2681 * without a value for partition key
2682 */
2683 export declare type NonePartitionKeyType = {
2684 [K in any]: never;
2685 };
2686
2687 /**
2688 * The returned object represents a partition key value that allows creating and accessing items
2689 * with a null value for the partition key.
2690 */
2691 export declare type NullPartitionKeyType = null;
2692
2693 /**
2694 * Use to read or replace an existing {@link Offer} by id.
2695 *
2696 * @see {@link Offers} to query or read all offers.
2697 */
2698 export declare class Offer {
2699 readonly client: CosmosClient;
2700 readonly id: string;
2701 private readonly clientContext;
2702 /**
2703 * Returns a reference URL to the resource. Used for linking in Permissions.
2704 */
2705 get url(): string;
2706 /**
2707 * @hidden
2708 * @param client - The parent {@link CosmosClient} for the Database Account.
2709 * @param id - The id of the given {@link Offer}.
2710 */
2711 constructor(client: CosmosClient, id: string, clientContext: ClientContext);
2712 /**
2713 * Read the {@link OfferDefinition} for the given {@link Offer}.
2714 */
2715 read(options?: RequestOptions): Promise<OfferResponse>;
2716 /**
2717 * Replace the given {@link Offer} with the specified {@link OfferDefinition}.
2718 * @param body - The specified {@link OfferDefinition}
2719 */
2720 replace(body: OfferDefinition, options?: RequestOptions): Promise<OfferResponse>;
2721 }
2722
2723 export declare interface OfferDefinition {
2724 id?: string;
2725 offerType?: string;
2726 offerVersion?: string;
2727 resource?: string;
2728 offerResourceId?: string;
2729 content?: {
2730 offerThroughput: number;
2731 offerIsRUPerMinuteThroughputEnabled: boolean;
2732 offerMinimumThroughputParameters?: {
2733 maxThroughputEverProvisioned: number;
2734 maxConsumedStorageEverInKB: number;
2735 };
2736 offerAutopilotSettings?: {
2737 tier: number;
2738 maximumTierThroughput: number;
2739 autoUpgrade: boolean;
2740 maxThroughput: number;
2741 };
2742 };
2743 }
2744
2745 export declare class OfferResponse extends ResourceResponse<OfferDefinition & Resource> {
2746 constructor(resource: OfferDefinition & Resource, headers: CosmosHeaders, statusCode: number, diagnostics: CosmosDiagnostics, offer?: Offer);
2747 /** A reference to the {@link Offer} corresponding to the returned {@link OfferDefinition}. */
2748 readonly offer: Offer;
2749 }
2750
2751 /**
2752 * Use to query or read all Offers.
2753 *
2754 * @see {@link Offer} to read or replace an existing {@link Offer} by id.
2755 */
2756 export declare class Offers {