;
/**
* Options that can be specified for a requested issued to the Azure Cosmos DB servers.=
*/
export declare interface SharedOptions {
/** Enables/disables getting document container quota related stats for document container read requests. */
sessionToken?: string;
/** (Advanced use case) Initial headers to start with when sending requests to Cosmos */
initialHeaders?: CosmosHeaders;
/**
* abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController
* @example Cancel a read request
* ```typescript
* const controller = new AbortController()
* const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal});
* controller.abort()
* ```
*/
abortSignal?: AbortSignal_2;
/**
* Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link
* com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the
* integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the
* consistency level is not set, this property is ignored.
*
* Default value is null
*
* Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.
*/
maxIntegratedCacheStalenessInMs?: number;
/**
* Priority Level (Low/High) for each request.
* Low priority requests are always throttled before any high priority requests.
*
* Default value is null. By default all requests are of High priority
*/
priorityLevel?: PriorityLevel;
}
export declare interface SpatialIndex {
path: string;
types: SpatialType[];
boundingBox: {
xmin: number;
ymin: number;
xmax: number;
ymax: number;
};
}
export declare enum SpatialType {
LineString = "LineString",
MultiPolygon = "MultiPolygon",
Point = "Point",
Polygon = "Polygon"
}
/**
* Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec}
*/
export declare interface SqlParameter {
/** Name of the parameter. (i.e. `@lastName`) */
name: string;
/** Value of the parameter (this is safe to come from users, assuming they are authorized) */
value: JSONValue;
}
/**
* Represents a SQL query in the Azure Cosmos DB service.
*
* Queries with inputs should be parameterized to protect against SQL injection.
*
* @example Parameterized SQL Query
* ```typescript
* const query: SqlQuerySpec = {
* query: "SELECT * FROM Families f where f.lastName = @lastName",
* parameters: [
* {name: "@lastName", value: "Wakefield"}
* ]
* };
* ```
*/
export declare interface SqlQuerySpec {
/** The text of the SQL query */
query: string;
/** The parameters you provide in the query */
parameters?: SqlParameter[];
}
/**
* @hidden
*/
export declare type StatusCode = number;
/**
* @hidden
*/
export declare const StatusCodes: StatusCodesType;
/**
* @hidden
*/
export declare interface StatusCodesType {
Ok: 200;
Created: 201;
Accepted: 202;
NoContent: 204;
NotModified: 304;
BadRequest: 400;
Unauthorized: 401;
Forbidden: 403;
NotFound: 404;
MethodNotAllowed: 405;
RequestTimeout: 408;
Conflict: 409;
Gone: 410;
PreconditionFailed: 412;
RequestEntityTooLarge: 413;
TooManyRequests: 429;
RetryWith: 449;
InternalServerError: 500;
ServiceUnavailable: 503;
ENOTFOUND: "ENOTFOUND";
OperationPaused: 1200;
OperationCancelled: 1201;
}
/**
* Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id.
*
* For operations to create, read all, or query Stored Procedures,
*/
export declare class StoredProcedure {
readonly container: Container;
readonly id: string;
private readonly clientContext;
/**
* Returns a reference URL to the resource. Used for linking in Permissions.
*/
get url(): string;
/**
* Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}.
* @param container - The parent {@link Container}.
* @param id - The id of the given {@link StoredProcedure}.
* @hidden
*/
constructor(container: Container, id: string, clientContext: ClientContext);
/**
* Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}.
*/
read(options?: RequestOptions): Promise;
/**
* Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}.
* @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition.
*/
replace(body: StoredProcedureDefinition, options?: RequestOptions): Promise;
/**
* Delete the given {@link StoredProcedure}.
*/
delete(options?: RequestOptions): Promise;
/**
* Execute the given {@link StoredProcedure}.
*
* The specified type, T, is not enforced by the client.
* Be sure to validate the response from the stored procedure matches the type, T, you provide.
*
* @param partitionKey - The partition key to use when executing the stored procedure
* @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}.
* @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on.
*/
execute(partitionKey: PartitionKey, params?: any[], options?: RequestOptions): Promise>;
}
export declare interface StoredProcedureDefinition {
/**
* The id of the {@link StoredProcedure}.
*/
id?: string;
/**
* The body of the {@link StoredProcedure}. This is a JavaScript function.
*/
body?: string | ((...inputs: any[]) => void);
}
export declare class StoredProcedureResponse extends ResourceResponse {
constructor(resource: StoredProcedureDefinition & Resource, headers: CosmosHeaders, statusCode: number, storedProcedure: StoredProcedure, diagnostics: CosmosDiagnostics);
/**
* A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.
*/
readonly storedProcedure: StoredProcedure;
/**
* Alias for storedProcedure.
*
* A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.
*/
get sproc(): StoredProcedure;
}
/**
* Operations for creating, upserting, or reading/querying all Stored Procedures.
*
* For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`.
*/
export declare class StoredProcedures {
readonly container: Container;
private readonly clientContext;
/**
* @param container - The parent {@link Container}.
* @hidden
*/
constructor(container: Container, clientContext: ClientContext);
/**
* Query all Stored Procedures.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
* @example Read all stored procedures to array.
* ```typescript
* const querySpec: SqlQuerySpec = {
* query: "SELECT * FROM root r WHERE r.id = @sproc",
* parameters: [
* {name: "@sproc", value: "Todo"}
* ]
* };
* const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();
* ```
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Query all Stored Procedures.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
* @example Read all stored procedures to array.
* ```typescript
* const querySpec: SqlQuerySpec = {
* query: "SELECT * FROM root r WHERE r.id = @sproc",
* parameters: [
* {name: "@sproc", value: "Todo"}
* ]
* };
* const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();
* ```
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Read all stored procedures.
* @example Read all stored procedures to array.
* ```typescript
* const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll();
* ```
*/
readAll(options?: FeedOptions): QueryIterator;
/**
* Create a StoredProcedure.
*
* Azure Cosmos DB allows stored procedures to be executed in the storage tier,
* directly against an item container. The script
* gets executed under ACID transactions on the primary storage partition of the
* specified container. For additional details,
* refer to the server-side JavaScript API documentation.
*/
create(body: StoredProcedureDefinition, options?: RequestOptions): Promise;
}
/**
* @hidden
*/
export declare type SubStatusCode = number;
export declare class TimeoutError extends Error {
readonly code: string;
constructor(message?: string);
}
/**
* Represents a time interval.
*
* @param days - Number of days.
* @param hours - Number of hours.
* @param minutes - Number of minutes.
* @param seconds - Number of seconds.
* @param milliseconds - Number of milliseconds.
* @hidden
*/
export declare class TimeSpan {
protected _ticks: number;
constructor(days: number, hours: number, minutes: number, seconds: number, milliseconds: number);
/**
* Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.
* @param ts - The time interval to add.
*/
add(ts: TimeSpan): TimeSpan;
/**
* Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance.
* @param ts - The time interval to subtract.
*/
subtract(ts: TimeSpan): TimeSpan;
/**
* Compares this instance to a specified object and returns an integer that indicates whether this
* instance is shorter than, equal to, or longer than the specified object.
* @param value - The time interval to add.
*/
compareTo(value: TimeSpan): 1 | -1 | 0;
/**
* Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.
*/
duration(): TimeSpan;
/**
* Returns a value indicating whether this instance is equal to a specified object.
* @param value - The time interval to check for equality.
*/
equals(value: TimeSpan): boolean;
/**
* Returns a new TimeSpan object whose value is the negated value of this instance.
* @param value - The time interval to check for equality.
*/
negate(): TimeSpan;
days(): number;
hours(): number;
milliseconds(): number;
seconds(): number;
ticks(): number;
totalDays(): number;
totalHours(): number;
totalMilliseconds(): number;
totalMinutes(): number;
totalSeconds(): number;
static fromTicks(value: number): TimeSpan;
static readonly zero: TimeSpan;
static readonly maxValue: TimeSpan;
static readonly minValue: TimeSpan;
static isTimeSpan(timespan: TimeSpan): number;
static additionDoesOverflow(a: number, b: number): boolean;
static subtractionDoesUnderflow(a: number, b: number): boolean;
static compare(t1: TimeSpan, t2: TimeSpan): 1 | 0 | -1;
static interval(value: number, scale: number): TimeSpan;
static fromMilliseconds(value: number): TimeSpan;
static fromSeconds(value: number): TimeSpan;
static fromMinutes(value: number): TimeSpan;
static fromHours(value: number): TimeSpan;
static fromDays(value: number): TimeSpan;
}
export declare type TokenProvider = (requestInfo: RequestInfo_2) => Promise;
/**
* Operations to read, replace, or delete a {@link Trigger}.
*
* Use `container.triggers` to create, upsert, query, or read all.
*/
export declare class Trigger {
readonly container: Container;
readonly id: string;
private readonly clientContext;
/**
* Returns a reference URL to the resource. Used for linking in Permissions.
*/
get url(): string;
/**
* @hidden
* @param container - The parent {@link Container}.
* @param id - The id of the given {@link Trigger}.
*/
constructor(container: Container, id: string, clientContext: ClientContext);
/**
* Read the {@link TriggerDefinition} for the given {@link Trigger}.
*/
read(options?: RequestOptions): Promise;
/**
* Replace the given {@link Trigger} with the specified {@link TriggerDefinition}.
* @param body - The specified {@link TriggerDefinition} to replace the existing definition with.
*/
replace(body: TriggerDefinition, options?: RequestOptions): Promise;
/**
* Delete the given {@link Trigger}.
*/
delete(options?: RequestOptions): Promise;
}
export declare interface TriggerDefinition {
/** The id of the trigger. */
id?: string;
/** The body of the trigger, it can also be passed as a stringifed function */
body: (() => void) | string;
/** The type of the trigger, should be one of the values of {@link TriggerType}. */
triggerType: TriggerType;
/** The trigger operation, should be one of the values of {@link TriggerOperation}. */
triggerOperation: TriggerOperation;
}
/**
* Enum for trigger operation values.
* specifies the operations on which a trigger should be executed.
*/
export declare enum TriggerOperation {
/** All operations. */
All = "all",
/** Create operations only. */
Create = "create",
/** Update operations only. */
Update = "update",
/** Delete operations only. */
Delete = "delete",
/** Replace operations only. */
Replace = "replace"
}
export declare class TriggerResponse extends ResourceResponse {
constructor(resource: TriggerDefinition & Resource, headers: CosmosHeaders, statusCode: number, trigger: Trigger, diagnostics: CosmosDiagnostics);
/** A reference to the {@link Trigger} corresponding to the returned {@link TriggerDefinition}. */
readonly trigger: Trigger;
}
/**
* Operations to create, upsert, query, and read all triggers.
*
* Use `container.triggers` to read, replace, or delete a {@link Trigger}.
*/
export declare class Triggers {
readonly container: Container;
private readonly clientContext;
/**
* @hidden
* @param container - The parent {@link Container}.
*/
constructor(container: Container, clientContext: ClientContext);
/**
* Query all Triggers.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Query all Triggers.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Read all Triggers.
* @example Read all trigger to array.
* ```typescript
* const {body: triggerList} = await container.triggers.readAll().fetchAll();
* ```
*/
readAll(options?: FeedOptions): QueryIterator;
/**
* Create a trigger.
*
* Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed
* on creates, updates and deletes.
*
* For additional details, refer to the server-side JavaScript API documentation.
*/
create(body: TriggerDefinition, options?: RequestOptions): Promise;
}
/**
* Enum for trigger type values.
* Specifies the type of the trigger.
*/
export declare enum TriggerType {
/** Trigger should be executed before the associated operation(s). */
Pre = "pre",
/** Trigger should be executed after the associated operation(s). */
Post = "post"
}
/** Interface for a single unique key passed as part of UniqueKeyPolicy */
export declare interface UniqueKey {
paths: string[];
}
/** Interface for setting unique keys on container creation */
export declare interface UniqueKeyPolicy {
uniqueKeys: UniqueKey[];
}
export declare type UpsertOperation = OperationWithItem & {
operationType: typeof BulkOperationType.Upsert;
};
export declare interface UpsertOperationInput {
partitionKey?: PartitionKey;
ifMatch?: string;
ifNoneMatch?: string;
operationType: typeof BulkOperationType.Upsert;
resourceBody: JSONObject;
}
/**
* Used to read, replace, and delete Users.
*
* Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`.
*
* @see {@link Users} to create, upsert, query, or read all.
*/
export declare class User {
readonly database: Database;
readonly id: string;
private readonly clientContext;
/**
* Operations for creating, upserting, querying, or reading all operations.
*
* See `client.permission(id)` to read, replace, or delete a specific Permission by id.
*/
readonly permissions: Permissions_2;
/**
* Returns a reference URL to the resource. Used for linking in Permissions.
*/
get url(): string;
/**
* @hidden
* @param database - The parent {@link Database}.
*/
constructor(database: Database, id: string, clientContext: ClientContext);
/**
* Operations to read, replace, or delete a specific Permission by id.
*
* See `client.permissions` for creating, upserting, querying, or reading all operations.
*/
permission(id: string): Permission;
/**
* Read the {@link UserDefinition} for the given {@link User}.
*/
read(options?: RequestOptions): Promise;
/**
* Replace the given {@link User}'s definition with the specified {@link UserDefinition}.
* @param body - The specified {@link UserDefinition} to replace the definition.
*/
replace(body: UserDefinition, options?: RequestOptions): Promise;
/**
* Delete the given {@link User}.
*/
delete(options?: RequestOptions): Promise;
}
/**
* Used to read, replace, or delete a specified User Definied Function by id.
*
* @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions.
*/
export declare class UserDefinedFunction {
readonly container: Container;
readonly id: string;
private readonly clientContext;
/**
* Returns a reference URL to the resource. Used for linking in Permissions.
*/
get url(): string;
/**
* @hidden
* @param container - The parent {@link Container}.
* @param id - The id of the given {@link UserDefinedFunction}.
*/
constructor(container: Container, id: string, clientContext: ClientContext);
/**
* Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}.
*/
read(options?: RequestOptions): Promise;
/**
* Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}.
* @param options -
*/
replace(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise;
/**
* Delete the given {@link UserDefined}.
*/
delete(options?: RequestOptions): Promise;
}
export declare interface UserDefinedFunctionDefinition {
/** The id of the {@link UserDefinedFunction} */
id?: string;
/** The body of the user defined function, it can also be passed as a stringifed function */
body?: string | (() => void);
}
export declare class UserDefinedFunctionResponse extends ResourceResponse {
constructor(resource: UserDefinedFunctionDefinition & Resource, headers: CosmosHeaders, statusCode: number, udf: UserDefinedFunction, diagnostics: CosmosDiagnostics);
/** A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. */
readonly userDefinedFunction: UserDefinedFunction;
/**
* Alias for `userDefinedFunction(id)`.
*
* A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}.
*/
get udf(): UserDefinedFunction;
}
/**
* Used to create, upsert, query, or read all User Defined Functions.
*
* @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id.
*/
export declare class UserDefinedFunctions {
readonly container: Container;
private readonly clientContext;
/**
* @hidden
* @param container - The parent {@link Container}.
*/
constructor(container: Container, clientContext: ClientContext);
/**
* Query all User Defined Functions.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Query all User Defined Functions.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Read all User Defined Functions.
* @example Read all User Defined Functions to array.
* ```typescript
* const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll();
* ```
*/
readAll(options?: FeedOptions): QueryIterator;
/**
* Create a UserDefinedFunction.
*
* Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.
*
* For additional details, refer to the server-side JavaScript API documentation.
*
*/
create(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise;
}
/**
* Enum for udf type values.
* Specifies the types of user defined functions.
*/
export declare enum UserDefinedFunctionType {
/** The User Defined Function is written in JavaScript. This is currently the only option. */
Javascript = "Javascript"
}
export declare interface UserDefinition {
/** The id of the user. */
id?: string;
}
export declare class UserResponse extends ResourceResponse {
constructor(resource: UserDefinition & Resource, headers: CosmosHeaders, statusCode: number, user: User, diagnostics: CosmosDiagnostics);
/** A reference to the {@link User} corresponding to the returned {@link UserDefinition}. */
readonly user: User;
}
/**
* Used to create, upsert, query, and read all users.
*
* @see {@link User} to read, replace, or delete a specific User by id.
*/
export declare class Users {
readonly database: Database;
private readonly clientContext;
/**
* @hidden
* @param database - The parent {@link Database}.
*/
constructor(database: Database, clientContext: ClientContext);
/**
* Query all users.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Query all users.
* @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.
*/
query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;
/**
* Read all users.-
* @example Read all users to array.
* ```typescript
* const {body: usersList} = await database.users.readAll().fetchAll();
* ```
*/
readAll(options?: FeedOptions): QueryIterator;
/**
* Create a database user with the specified {@link UserDefinition}.
* @param body - The specified {@link UserDefinition}.
*/
create(body: UserDefinition, options?: RequestOptions): Promise;
/**
* Upsert a database user with a specified {@link UserDefinition}.
* @param body - The specified {@link UserDefinition}.
*/
upsert(body: UserDefinition, options?: RequestOptions): Promise;
}
declare type VerboseOmit = Pick>;
export { }