UNPKG

botbuilder-azure

Version:

Azure extensions for Microsoft BotBuilder.

103 lines 3.51 kB
/** * @module botbuilder-azure */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { CosmosClientOptions } from '@azure/cosmos'; import { Storage, StoreItems } from 'botbuilder'; /** * Cosmos DB Partitioned Storage Options. */ export interface CosmosDbPartitionedStorageOptions { /** * The CosmosDB endpoint. */ cosmosDbEndpoint?: string; /** * The authentication key for Cosmos DB. */ authKey?: string; /** * The database identifier for Cosmos DB instance. */ databaseId: string; /** * The container identifier. */ containerId: string; /** * The options for the CosmosClient. */ cosmosClientOptions?: CosmosClientOptions; /** * The throughput set when creating the Container. Defaults to 400. */ containerThroughput?: number; /** * The suffix to be added to every key. See cosmosDbKeyEscape.escapeKey * * Note: compatibilityMode must be set to 'false' to use a KeySuffix. * When KeySuffix is used, keys will NOT be truncated but an exception will * be thrown if the key length is longer than allowed by CosmosDb. * * The keySuffix must contain only valid CosmosDb key characters. * (e.g. not: '\\', '?', '/', '#', '*') */ keySuffix?: string; /** * Early version of CosmosDb had a max key length of 255. Keys longer than * this were truncated in cosmosDbKeyEscape.escapeKey. This remains the default * behavior of cosmosDbPartitionedStorage, but can be overridden by setting * compatibilityMode to false. * * compatibilityMode cannot be true if keySuffix is used. */ compatibilityMode?: boolean; } /** * Implements a CosmosDB based storage provider using partitioning for a bot. */ export declare class CosmosDbPartitionedStorage implements Storage { private readonly cosmosDbStorageOptions; private container; private client; private compatibilityModePartitionKey; /** * Initializes a new instance of the <see cref="CosmosDbPartitionedStorage"/> class. * using the provided CosmosDB credentials, database ID, and container ID. * * @param {CosmosDbPartitionedStorageOptions} cosmosDbStorageOptions Cosmos DB partitioned storage configuration options. */ constructor(cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions); private toJSON; /** * Read one or more items with matching keys from the Cosmos DB container. * * @param {string[]} keys A collection of Ids for each item to be retrieved. * @returns {Promise<StoreItems>} The read items. */ read(keys: string[]): Promise<StoreItems>; /** * Insert or update one or more items into the Cosmos DB container. * * @param {StoreItems} changes Dictionary of items to be inserted or updated indexed by key. */ write(changes: StoreItems): Promise<void>; /** * Delete one or more items from the Cosmos DB container. * * @param {string[]} keys Array of Ids for the items to be deleted. */ delete(keys: string[]): Promise<void>; /** * Connects to the CosmosDB database and creates / gets the container. */ initialize(): Promise<void>; private getOrCreateContainer; private getPartitionKey; private checkForNestingError; private throwInformativeError; } //# sourceMappingURL=cosmosDbPartitionedStorage.d.ts.map