@microsoft/agents-hosting-storage-cosmos 1.9.0-beta.8.gf58e66b2ee → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- This package allows to configure Azure CosmosDB Storage as the backend for Agents conversation State
5
+ This package allows to configure Azure CosmosDB Storage as the backend for Agents conversation State
6
+
7
+ `CosmosDbPartitionedStorage` retains the legacy `Storage` contract. Use
8
+ `CosmosDbPartitionedStorageV2` for the separate `StorageV2` contract; V2 calls
9
+ return keyed operation results with `value`, `status`, and `version`.
6
10
 
7
11
  ## Usage
8
12
 
@@ -17,5 +21,9 @@ const cosmosDbStorageOptions = {
17
21
  } as CosmosDbPartitionedStorageOptions
18
22
  const cosmosStorage = new CosmosDbPartitionedStorage(cosmosDbStorageOptions)
19
23
  const conversationState = new ConversationState(cosmosStorage)
20
- const userState = new UserState(cosmosStorage)
21
- ```
24
+ const userState = new UserState(cosmosStorage)
25
+ ```
26
+
27
+ ```ts
28
+ const cosmosStorageV2 = new CosmosDbPartitionedStorageV2(cosmosDbStorageOptions)
29
+ ```
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@microsoft/agents-hosting-storage-cosmos",
4
- "version": "1.9.0-beta.8.gf58e66b2ee",
4
+ "version": "1.9.1",
5
5
  "homepage": "https://github.com/microsoft/Agents-for-js",
6
6
  "repository": {
7
7
  "type": "git",
@@ -17,9 +17,9 @@
17
17
  "types": "dist/src/index.d.ts",
18
18
  "dependencies": {
19
19
  "@azure/cosmos": "4.9.3",
20
- "@microsoft/agents-hosting": "1.9.0-beta.8.gf58e66b2ee",
21
- "@microsoft/agents-activity": "1.9.0-beta.8.gf58e66b2ee",
22
- "@microsoft/agents-telemetry": "1.9.0-beta.8.gf58e66b2ee"
20
+ "@microsoft/agents-hosting": "1.9.1",
21
+ "@microsoft/agents-activity": "1.9.1",
22
+ "@microsoft/agents-telemetry": "1.9.1"
23
23
  },
24
24
  "license": "MIT",
25
25
  "files": [
@@ -1,13 +1,12 @@
1
+ import { Container } from '@azure/cosmos';
2
+ import { DocumentStoreItem } from './documentStoreItem';
1
3
  import { CosmosDbPartitionedStorageOptions } from './cosmosDbPartitionedStorageOptions';
2
- import { Storage, StoreItems } from '@microsoft/agents-hosting';
3
- /**
4
- * Implements storage using Cosmos DB partitioned storage.
5
- */
6
- export declare class CosmosDbPartitionedStorage implements Storage {
7
- private readonly cosmosDbStorageOptions;
8
- private container;
4
+ import { StorageDeleteOptions, StorageDeleteResults, StorageReadResults, StorageWriteOptions, StorageWriteResults, Storage, StorageV2, StoreItems } from '@microsoft/agents-hosting';
5
+ declare class CosmosDbPartitionedStorageInternals {
6
+ readonly cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions;
7
+ container: Container;
9
8
  private client;
10
- private compatibilityModePartitionKey;
9
+ compatibilityModePartitionKey: boolean;
11
10
  [key: string]: any;
12
11
  /**
13
12
  * The number of items in the storage. This property is not currently used.
@@ -16,29 +15,89 @@ export declare class CosmosDbPartitionedStorage implements Storage {
16
15
  /**
17
16
  * Initializes a new instance of the CosmosDbPartitionedStorage class.
18
17
  * @param cosmosDbStorageOptions The options for configuring Cosmos DB partitioned storage.
18
+ *
19
19
  */
20
20
  constructor(cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions);
21
21
  /**
22
- * Reads items from storage.
23
- * @param keys The keys of the items to read.
24
- * @returns A promise that resolves to the read items.
22
+ * Initializes the Cosmos DB container.
23
+ */
24
+ initialize(): Promise<void>;
25
+ private getOrCreateContainer;
26
+ getPartitionKey(key: string): string | undefined;
27
+ isExpired(item: DocumentStoreItem): boolean;
28
+ checkForNestingError(json: object, err: Error | Record<'message', string> | string): void;
29
+ }
30
+ /**
31
+ * Cosmos DB partitioned storage provider.
32
+ *
33
+ * This class implements the legacy {@link Storage} contract. Use
34
+ * {@link CosmosDbPartitionedStorageV2} for the structured StorageV2 contract.
35
+ */
36
+ export declare class CosmosDbPartitionedStorage extends CosmosDbPartitionedStorageInternals implements Storage {
37
+ /**
38
+ * Reads legacy items and attaches Cosmos DB ETags as `eTag` values.
39
+ *
40
+ * @param keys The keys to read.
41
+ * @returns The stored items; missing keys are omitted.
42
+ * @throws When the key input is invalid or Cosmos DB cannot complete the operation.
25
43
  */
26
44
  read(keys: string[]): Promise<StoreItems>;
27
45
  /**
28
- * Writes items to storage.
29
- * @param changes The items to write.
46
+ * Writes legacy items and applies `eTag` concurrency checks.
47
+ *
48
+ * @param changes The keyed legacy items to write.
49
+ * @throws When the input is invalid or Cosmos DB cannot complete the operation.
30
50
  */
31
51
  write(changes: StoreItems): Promise<void>;
32
52
  /**
33
- * Deletes items from storage.
34
- * @param keys The keys of the items to delete.
53
+ * Deletes legacy items and ignores missing documents.
54
+ *
55
+ * @param keys The keys to delete.
56
+ * @throws When Cosmos DB cannot complete the operation.
35
57
  */
36
58
  delete(keys: string[]): Promise<void>;
59
+ }
60
+ /**
61
+ * A Cosmos DB provider for the structured {@link StorageV2} contract.
62
+ *
63
+ * This is the V2 counterpart to {@link CosmosDbPartitionedStorage} and uses the same
64
+ * {@link CosmosDbPartitionedStorageOptions}. Each read, write, and delete returns an outcome for
65
+ * every requested key. Cosmos DB ETags are returned as separate storage versions, and writes
66
+ * support create-only, replace, and expected-version conditions for optimistic concurrency.
67
+ */
68
+ export declare class CosmosDbPartitionedStorageV2 extends StorageV2 {
69
+ private readonly internals;
37
70
  /**
38
- * Initializes the Cosmos DB container.
71
+ * Creates a V2 Cosmos DB storage provider.
72
+ *
73
+ * @param options The Cosmos DB connection, database, container, and partitioning options.
39
74
  */
40
- private initialize;
41
- private getOrCreateContainer;
42
- private getPartitionKey;
43
- private checkForNestingError;
75
+ constructor(options: CosmosDbPartitionedStorageOptions);
76
+ /**
77
+ * Reads V2 items with one status and Cosmos DB ETag version per requested key.
78
+ *
79
+ * @param keys The keys to read.
80
+ * @returns The keyed V2 read results.
81
+ * @throws When the key input is invalid or Cosmos DB cannot complete the operation.
82
+ */
83
+ read<T extends object = Record<string, unknown>>(keys: string[]): Promise<StorageReadResults<T>>;
84
+ /**
85
+ * Writes V2 items with mode and expected-version conditions.
86
+ *
87
+ * @param changes The keyed values to write.
88
+ * @param options The V2 write mode and expected version.
89
+ * @returns One keyed operation result per change.
90
+ * @throws When the input is invalid or Cosmos DB cannot complete the operation.
91
+ */
92
+ write<T extends object = Record<string, unknown>>(changes: Record<string, T>, options?: StorageWriteOptions): Promise<StorageWriteResults>;
93
+ /**
94
+ * Deletes V2 items with an optional expected-version condition.
95
+ *
96
+ * @param keys The keys to delete.
97
+ * @param options The optional expected version.
98
+ * @returns One keyed operation result per requested key.
99
+ * @throws When the key input is invalid or Cosmos DB cannot complete the operation.
100
+ */
101
+ delete(keys: string[], options?: StorageDeleteOptions): Promise<StorageDeleteResults>;
44
102
  }
103
+ export {};