UNPKG

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