UNPKG

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