@microsoft/agents-hosting-storage-cosmos 1.1.4-geb1c05c291 → 1.2.0-alpha.19.g9aeee229e8
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/dist/src/cosmosDbKeyEscape.js +3 -1
- package/dist/src/cosmosDbKeyEscape.js.map +1 -1
- package/dist/src/cosmosDbPartitionedStorage.d.ts +0 -1
- package/dist/src/cosmosDbPartitionedStorage.js +39 -31
- package/dist/src/cosmosDbPartitionedStorage.js.map +1 -1
- package/dist/src/errorHelper.d.ts +19 -0
- package/dist/src/errorHelper.js +163 -0
- package/dist/src/errorHelper.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
- package/src/cosmosDbKeyEscape.ts +6 -1
- package/src/cosmosDbPartitionedStorage.ts +101 -41
- package/src/errorHelper.ts +181 -0
- package/src/index.ts +2 -0
|
@@ -4,6 +4,8 @@ exports.CosmosDbKeyEscape = void 0;
|
|
|
4
4
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
5
|
// Licensed under the MIT License.
|
|
6
6
|
const crypto_1 = require("crypto");
|
|
7
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
8
|
+
const errorHelper_1 = require("./errorHelper");
|
|
7
9
|
/**
|
|
8
10
|
* Provides methods for escaping keys for Cosmos DB.
|
|
9
11
|
*/
|
|
@@ -24,7 +26,7 @@ var CosmosDbKeyEscape;
|
|
|
24
26
|
*/
|
|
25
27
|
function escapeKey(key, keySuffix, compatibilityMode) {
|
|
26
28
|
if (!key) {
|
|
27
|
-
throw
|
|
29
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.MissingKeyParameter);
|
|
28
30
|
}
|
|
29
31
|
const keySplitted = key.split('');
|
|
30
32
|
const firstIllegalCharIndex = keySplitted.findIndex((c) => illegalKeys.some((i) => i === c));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosDbKeyEscape.js","sourceRoot":"","sources":["../../src/cosmosDbKeyEscape.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,kCAAkC;AAClC,mCAAmC;
|
|
1
|
+
{"version":3,"file":"cosmosDbKeyEscape.js","sourceRoot":"","sources":["../../src/cosmosDbKeyEscape.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,kCAAkC;AAClC,mCAAmC;AACnC,gEAA4D;AAC5D,+CAAsC;AAEtC;;GAEG;AACH,IAAiB,iBAAiB,CA4DjC;AA5DD,WAAiB,iBAAiB;IAChC,MAAM,YAAY,GAAW,GAAG,CAAA;IAChC,MAAM,WAAW,GAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IACnF,MAAM,iCAAiC,GAAwB,WAAW,CAAC,MAAM,CAC/E,CAAC,GAAwB,EAAE,CAAS,EAAE,EAAE;QACtC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QAC9C,OAAO,GAAG,CAAA;IACZ,CAAC,EACD,IAAI,GAAG,EAAE,CACV,CAAA;IAED;;;;;;OAMG;IACH,SAAgB,SAAS,CAAE,GAAW,EAAE,SAAkB,EAAE,iBAA2B;QACrF,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,iCAAe,CAAC,iBAAiB,CACrC,KAAK,EACL,oBAAM,CAAC,mBAAmB,CAC3B,CAAA;QACH,CAAC;QAED,MAAM,WAAW,GAAa,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC3C,MAAM,qBAAqB,GAAW,WAAW,CAAC,SAAS,CAAC,CAAC,CAAS,EAAW,EAAE,CACjF,WAAW,CAAC,IAAI,CA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mos_1 = require("@azure/cosmos");
|
|
7
7
|
const cosmosDbKeyEscape_1 = require("./cosmosDbKeyEscape");
|
|
8
8
|
const documentStoreItem_1 = require("./documentStoreItem");
|
|
9
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
10
|
+
const errorHelper_1 = require("./errorHelper");
|
|
9
11
|
/**
|
|
10
12
|
* A utility class to ensure that a specific asynchronous task is executed only once for a given key.
|
|
11
13
|
* @typeParam T The type of the result returned by the asynchronous task.
|
|
@@ -47,29 +49,29 @@ class CosmosDbPartitionedStorage {
|
|
|
47
49
|
*/
|
|
48
50
|
this.length = 0;
|
|
49
51
|
if (!cosmosDbStorageOptions) {
|
|
50
|
-
throw
|
|
52
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingCosmosDbStorageOptions);
|
|
51
53
|
}
|
|
52
54
|
const { cosmosClientOptions } = cosmosDbStorageOptions;
|
|
53
55
|
if (!(cosmosClientOptions === null || cosmosClientOptions === void 0 ? void 0 : cosmosClientOptions.endpoint)) {
|
|
54
|
-
throw
|
|
56
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingCosmosEndpoint);
|
|
55
57
|
}
|
|
56
58
|
if (!(cosmosClientOptions === null || cosmosClientOptions === void 0 ? void 0 : cosmosClientOptions.key) && !(cosmosClientOptions === null || cosmosClientOptions === void 0 ? void 0 : cosmosClientOptions.tokenProvider)) {
|
|
57
|
-
throw
|
|
59
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingCosmosCredentials);
|
|
58
60
|
}
|
|
59
61
|
if (!cosmosDbStorageOptions.databaseId) {
|
|
60
|
-
throw
|
|
62
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingDatabaseId);
|
|
61
63
|
}
|
|
62
64
|
if (!cosmosDbStorageOptions.containerId) {
|
|
63
|
-
throw
|
|
65
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingContainerId);
|
|
64
66
|
}
|
|
65
67
|
(_a = cosmosDbStorageOptions.compatibilityMode) !== null && _a !== void 0 ? _a : (cosmosDbStorageOptions.compatibilityMode = true);
|
|
66
68
|
if (cosmosDbStorageOptions.keySuffix) {
|
|
67
69
|
if (cosmosDbStorageOptions.compatibilityMode) {
|
|
68
|
-
throw
|
|
70
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.InvalidCompatibilityModeWithKeySuffix);
|
|
69
71
|
}
|
|
70
72
|
const suffixEscaped = cosmosDbKeyEscape_1.CosmosDbKeyEscape.escapeKey(cosmosDbStorageOptions.keySuffix);
|
|
71
73
|
if (cosmosDbStorageOptions.keySuffix !== suffixEscaped) {
|
|
72
|
-
throw
|
|
74
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.InvalidKeySuffixCharacters, undefined, { keySuffix: cosmosDbStorageOptions.keySuffix });
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
@@ -80,7 +82,7 @@ class CosmosDbPartitionedStorage {
|
|
|
80
82
|
*/
|
|
81
83
|
async read(keys) {
|
|
82
84
|
if (!keys) {
|
|
83
|
-
throw
|
|
85
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingReadKeys);
|
|
84
86
|
}
|
|
85
87
|
else if (keys.length === 0) {
|
|
86
88
|
return {};
|
|
@@ -101,14 +103,13 @@ class CosmosDbPartitionedStorage {
|
|
|
101
103
|
}
|
|
102
104
|
catch (err) {
|
|
103
105
|
if (err.code === 404) {
|
|
104
|
-
|
|
106
|
+
// Not Found is not an error during read operations, just skip
|
|
105
107
|
}
|
|
106
108
|
else if (err.code === 400) {
|
|
107
|
-
|
|
108
|
-
container or a container that does not use '/id' as the partitionKeyPath`, err);
|
|
109
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ContainerReadBadRequest, err);
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
111
|
-
|
|
112
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ContainerReadError, err);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}));
|
|
@@ -120,7 +121,7 @@ class CosmosDbPartitionedStorage {
|
|
|
120
121
|
*/
|
|
121
122
|
async write(changes) {
|
|
122
123
|
if (!changes) {
|
|
123
|
-
throw
|
|
124
|
+
throw agents_activity_1.ExceptionHelper.generateException(ReferenceError, errorHelper_1.Errors.MissingWriteChanges);
|
|
124
125
|
}
|
|
125
126
|
else if (changes.length === 0) {
|
|
126
127
|
return;
|
|
@@ -140,7 +141,7 @@ class CosmosDbPartitionedStorage {
|
|
|
140
141
|
}
|
|
141
142
|
catch (err) {
|
|
142
143
|
this.checkForNestingError(change, err);
|
|
143
|
-
|
|
144
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.DocumentUpsertError, err);
|
|
144
145
|
}
|
|
145
146
|
}));
|
|
146
147
|
}
|
|
@@ -157,10 +158,10 @@ class CosmosDbPartitionedStorage {
|
|
|
157
158
|
}
|
|
158
159
|
catch (err) {
|
|
159
160
|
if (err.code === 404) {
|
|
160
|
-
|
|
161
|
+
// Not Found is not an error during delete operations, just skip
|
|
161
162
|
}
|
|
162
163
|
else {
|
|
163
|
-
|
|
164
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.DocumentDeleteError, err);
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
}));
|
|
@@ -195,7 +196,10 @@ class CosmosDbPartitionedStorage {
|
|
|
195
196
|
this.compatibilityModePartitionKey = true;
|
|
196
197
|
}
|
|
197
198
|
else if (paths.indexOf(documentStoreItem_1.DocumentStoreItem.partitionKeyPath) === -1) {
|
|
198
|
-
throw
|
|
199
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.UnsupportedCustomPartitionKeyPath, undefined, {
|
|
200
|
+
containerId: this.cosmosDbStorageOptions.containerId,
|
|
201
|
+
partitionKeyPath: paths[0]
|
|
202
|
+
});
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
else {
|
|
@@ -218,13 +222,15 @@ class CosmosDbPartitionedStorage {
|
|
|
218
222
|
return result.container;
|
|
219
223
|
}
|
|
220
224
|
if (!container) {
|
|
221
|
-
throw
|
|
225
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ContainerNotFound, undefined, { containerId: this.cosmosDbStorageOptions.containerId });
|
|
222
226
|
}
|
|
223
227
|
return container;
|
|
224
228
|
}
|
|
225
229
|
catch (err) {
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.InitializationError, err, {
|
|
231
|
+
databaseId: this.cosmosDbStorageOptions.databaseId,
|
|
232
|
+
containerId: this.cosmosDbStorageOptions.containerId
|
|
233
|
+
});
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
getPartitionKey(key) {
|
|
@@ -233,17 +239,26 @@ class CosmosDbPartitionedStorage {
|
|
|
233
239
|
checkForNestingError(json, err) {
|
|
234
240
|
const checkDepth = (obj, depth, isInDialogState) => {
|
|
235
241
|
if (depth > maxDepthAllowed) {
|
|
236
|
-
let
|
|
242
|
+
let additionalMessage = '';
|
|
237
243
|
if (isInDialogState) {
|
|
238
|
-
|
|
244
|
+
additionalMessage =
|
|
239
245
|
' This is most likely caused by recursive component dialogs. ' +
|
|
240
246
|
'Try reworking your dialog code to make sure it does not keep dialogs on the stack ' +
|
|
241
247
|
"that it's not using. For example, consider using replaceDialog instead of beginDialog.";
|
|
242
248
|
}
|
|
243
249
|
else {
|
|
244
|
-
|
|
250
|
+
additionalMessage = ' Please check your data for signs of unintended recursion.';
|
|
245
251
|
}
|
|
246
|
-
|
|
252
|
+
// Convert err to Error if needed
|
|
253
|
+
const errorObj = typeof err === 'string'
|
|
254
|
+
? new Error(err)
|
|
255
|
+
: err instanceof Error
|
|
256
|
+
? err
|
|
257
|
+
: new Error(err.message);
|
|
258
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.MaxNestingDepthExceeded, errorObj, {
|
|
259
|
+
maxDepth: maxDepthAllowed.toString(),
|
|
260
|
+
additionalMessage
|
|
261
|
+
});
|
|
247
262
|
}
|
|
248
263
|
else if (obj && typeof obj === 'object') {
|
|
249
264
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -253,13 +268,6 @@ class CosmosDbPartitionedStorage {
|
|
|
253
268
|
};
|
|
254
269
|
checkDepth(json, 0, false);
|
|
255
270
|
}
|
|
256
|
-
throwInformativeError(prependedMessage, err) {
|
|
257
|
-
if (typeof err === 'string') {
|
|
258
|
-
err = new Error(err);
|
|
259
|
-
}
|
|
260
|
-
err.message = `[${prependedMessage}] ${err.message}`;
|
|
261
|
-
throw err;
|
|
262
|
-
}
|
|
263
271
|
}
|
|
264
272
|
exports.CosmosDbPartitionedStorage = CosmosDbPartitionedStorage;
|
|
265
273
|
//# sourceMappingURL=cosmosDbPartitionedStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosDbPartitionedStorage.js","sourceRoot":"","sources":["../../src/cosmosDbPartitionedStorage.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,0CAAuD;AACvD,2DAAuD;AACvD,2DAAuD;
|
|
1
|
+
{"version":3,"file":"cosmosDbPartitionedStorage.js","sourceRoot":"","sources":["../../src/cosmosDbPartitionedStorage.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,0CAAuD;AACvD,2DAAuD;AACvD,2DAAuD;AAGvD,gEAA4D;AAC5D,+CAAsC;AAEtC;;;GAGG;AACH,MAAa,MAAM;IAAnB;QACU,SAAI,GAER,EAAE,CAAA;IAeR,CAAC;IAbC;;;;;OAKG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.
|
|
4
|
+
* This contains localized error codes for the CosmosDB storage subsystem of the AgentSDK.
|
|
5
|
+
*
|
|
6
|
+
* Each error definition includes an error code (starting from -100000), a description, and a help link
|
|
7
|
+
* pointing to an AKA link to get help for the given error.
|
|
8
|
+
*
|
|
9
|
+
* Usage example:
|
|
10
|
+
* ```
|
|
11
|
+
* throw ExceptionHelper.generateException(
|
|
12
|
+
* ReferenceError,
|
|
13
|
+
* Errors.MissingCosmosDbStorageOptions
|
|
14
|
+
* );
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const Errors: {
|
|
18
|
+
[key: string]: AgentErrorDefinition;
|
|
19
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Errors = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Error definitions for the CosmosDB storage system.
|
|
8
|
+
* This contains localized error codes for the CosmosDB storage subsystem of the AgentSDK.
|
|
9
|
+
*
|
|
10
|
+
* Each error definition includes an error code (starting from -100000), a description, and a help link
|
|
11
|
+
* pointing to an AKA link to get help for the given error.
|
|
12
|
+
*
|
|
13
|
+
* Usage example:
|
|
14
|
+
* ```
|
|
15
|
+
* throw ExceptionHelper.generateException(
|
|
16
|
+
* ReferenceError,
|
|
17
|
+
* Errors.MissingCosmosDbStorageOptions
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
exports.Errors = {
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when CosmosDbPartitionedStorageOptions is not provided.
|
|
24
|
+
*/
|
|
25
|
+
MissingCosmosDbStorageOptions: {
|
|
26
|
+
code: -100000,
|
|
27
|
+
description: 'CosmosDbPartitionedStorageOptions is required.'
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when endpoint in cosmosClientOptions is not provided.
|
|
31
|
+
*/
|
|
32
|
+
MissingCosmosEndpoint: {
|
|
33
|
+
code: -100001,
|
|
34
|
+
description: 'endpoint in cosmosClientOptions is required.'
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown when neither key nor tokenProvider is provided in cosmosClientOptions.
|
|
38
|
+
*/
|
|
39
|
+
MissingCosmosCredentials: {
|
|
40
|
+
code: -100002,
|
|
41
|
+
description: 'key or tokenProvider in cosmosClientOptions is required.'
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when databaseId is not provided.
|
|
45
|
+
*/
|
|
46
|
+
MissingDatabaseId: {
|
|
47
|
+
code: -100003,
|
|
48
|
+
description: 'databaseId for CosmosDB is required.'
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when containerId is not provided.
|
|
52
|
+
*/
|
|
53
|
+
MissingContainerId: {
|
|
54
|
+
code: -100004,
|
|
55
|
+
description: 'containerId for CosmosDB is required.'
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when compatibilityMode is enabled with a keySuffix.
|
|
59
|
+
*/
|
|
60
|
+
InvalidCompatibilityModeWithKeySuffix: {
|
|
61
|
+
code: -100005,
|
|
62
|
+
description: 'compatibilityMode cannot be true while using a keySuffix.'
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Error thrown when keySuffix contains invalid Row Key characters.
|
|
66
|
+
*/
|
|
67
|
+
InvalidKeySuffixCharacters: {
|
|
68
|
+
code: -100006,
|
|
69
|
+
description: 'Cannot use invalid Row Key characters: {keySuffix} in keySuffix'
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Error thrown when keys are not provided for reading.
|
|
73
|
+
*/
|
|
74
|
+
MissingReadKeys: {
|
|
75
|
+
code: -100007,
|
|
76
|
+
description: 'Keys are required when reading.'
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* Error thrown when changes are not provided for writing.
|
|
80
|
+
*/
|
|
81
|
+
MissingWriteChanges: {
|
|
82
|
+
code: -100008,
|
|
83
|
+
description: 'Changes are required when writing.'
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* Error thrown when attempting to use a custom partition key path.
|
|
87
|
+
*/
|
|
88
|
+
UnsupportedCustomPartitionKeyPath: {
|
|
89
|
+
code: -100009,
|
|
90
|
+
description: 'Custom Partition Key Paths are not supported. {containerId} has a custom Partition Key Path of {partitionKeyPath}.'
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Error thrown when the specified container is not found.
|
|
94
|
+
*/
|
|
95
|
+
ContainerNotFound: {
|
|
96
|
+
code: -100010,
|
|
97
|
+
description: 'Container {containerId} not found.'
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Error thrown when the key parameter is missing in CosmosDbKeyEscape.
|
|
101
|
+
*/
|
|
102
|
+
MissingKeyParameter: {
|
|
103
|
+
code: -100011,
|
|
104
|
+
description: "The 'key' parameter is required.",
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Error thrown when there is an error reading from the container (404 Not Found).
|
|
108
|
+
*/
|
|
109
|
+
ContainerReadNotFound: {
|
|
110
|
+
code: -100012,
|
|
111
|
+
description: 'Not Found'
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Error thrown when there is an error reading from container (400 Bad Request).
|
|
115
|
+
*/
|
|
116
|
+
ContainerReadBadRequest: {
|
|
117
|
+
code: -100013,
|
|
118
|
+
description: 'Error reading from container. You might be attempting to read from a non-partitioned container or a container that does not use \'/id\' as the partitionKeyPath'
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Error thrown when there is a general error reading from the container.
|
|
122
|
+
*/
|
|
123
|
+
ContainerReadError: {
|
|
124
|
+
code: -100014,
|
|
125
|
+
description: 'Error reading from container'
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* Error thrown when there is an error upserting a document.
|
|
129
|
+
*/
|
|
130
|
+
DocumentUpsertError: {
|
|
131
|
+
code: -100015,
|
|
132
|
+
description: 'Error upserting document'
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* Error thrown when there is an error deleting a document (404 Not Found).
|
|
136
|
+
*/
|
|
137
|
+
DocumentDeleteNotFound: {
|
|
138
|
+
code: -100016,
|
|
139
|
+
description: 'Not Found'
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* Error thrown when unable to delete a document.
|
|
143
|
+
*/
|
|
144
|
+
DocumentDeleteError: {
|
|
145
|
+
code: -100017,
|
|
146
|
+
description: 'Unable to delete document'
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* Error thrown when failing to initialize CosmosDB database/container.
|
|
150
|
+
*/
|
|
151
|
+
InitializationError: {
|
|
152
|
+
code: -100018,
|
|
153
|
+
description: 'Failed to initialize Cosmos DB database/container: {databaseId}/{containerId}'
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* Error thrown when maximum nesting depth is exceeded.
|
|
157
|
+
*/
|
|
158
|
+
MaxNestingDepthExceeded: {
|
|
159
|
+
code: -100019,
|
|
160
|
+
description: 'Maximum nesting depth of {maxDepth} exceeded. {additionalMessage}'
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=errorHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHelper.js","sourceRoot":"","sources":["../../src/errorHelper.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAIlC;;;;;;;;;;;;;;GAcG;AACU,QAAA,MAAM,GAA4C;IAC7D;;OAEG;IACH,6BAA6B,EAAE;QAC7B,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,gDAAgD;KAC9D;IAED;;OAEG;IACH,qBAAqB,EAAE;QACrB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,8CAA8C;KAC5D;I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E;QACnB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,0BAA0B;KACxC;IAED;;OAEG;IACH,sBAAsB,EAAE;QACtB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,WAAW;KACzB;IAED;;OAEG;IACH,mBAAmB,EAAE;QACnB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,2BAA2B;KACzC;IAED;;OAEG;IACH,mBAAmB,EAAE;QACnB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,+EAA+E;KAC7F;IAED;;OAEG;IACH,uBAAuB,EAAE;QACvB,IAAI,EAAE,CAAC,MAAM;QACb,WAAW,EAAE,mEAAmE;KACjF;CACF,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -16,8 +16,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.CosmosDbPartitionedStorage = void 0;
|
|
19
|
+
exports.ExceptionHelper = exports.Errors = exports.CosmosDbPartitionedStorage = void 0;
|
|
20
20
|
var cosmosDbPartitionedStorage_1 = require("./cosmosDbPartitionedStorage");
|
|
21
21
|
Object.defineProperty(exports, "CosmosDbPartitionedStorage", { enumerable: true, get: function () { return cosmosDbPartitionedStorage_1.CosmosDbPartitionedStorage; } });
|
|
22
22
|
__exportStar(require("./cosmosDbPartitionedStorageOptions"), exports);
|
|
23
|
+
var errorHelper_1 = require("./errorHelper");
|
|
24
|
+
Object.defineProperty(exports, "Errors", { enumerable: true, get: function () { return errorHelper_1.Errors; } });
|
|
25
|
+
var agents_activity_1 = require("@microsoft/agents-activity");
|
|
26
|
+
Object.defineProperty(exports, "ExceptionHelper", { enumerable: true, get: function () { return agents_activity_1.ExceptionHelper; } });
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;AAElC,2EAAyE;AAAhE,wIAAA,0BAA0B,OAAA;AACnC,sEAAmD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;AAElC,2EAAyE;AAAhE,wIAAA,0BAA0B,OAAA;AACnC,sEAAmD;AACnD,6CAAsC;AAA7B,qGAAA,MAAM,OAAA;AACf,8DAA8F;AAAnD,kHAAA,eAAe,OAAA"}
|
package/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.
|
|
4
|
+
"version": "1.2.0-alpha.19.g9aeee229e8",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"main": "dist/index.js",
|
|
17
17
|
"types": "dist/src/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@azure/cosmos": "^4.
|
|
20
|
-
"@microsoft/agents-hosting": "1.
|
|
19
|
+
"@azure/cosmos": "^4.9.0",
|
|
20
|
+
"@microsoft/agents-hosting": "1.2.0-alpha.19.g9aeee229e8"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"files": [
|
package/src/cosmosDbKeyEscape.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { createHash } from 'crypto'
|
|
4
|
+
import { ExceptionHelper } from '@microsoft/agents-activity'
|
|
5
|
+
import { Errors } from './errorHelper'
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Provides methods for escaping keys for Cosmos DB.
|
|
@@ -25,7 +27,10 @@ export namespace CosmosDbKeyEscape {
|
|
|
25
27
|
*/
|
|
26
28
|
export function escapeKey (key: string, keySuffix?: string, compatibilityMode?: boolean): string {
|
|
27
29
|
if (!key) {
|
|
28
|
-
throw
|
|
30
|
+
throw ExceptionHelper.generateException(
|
|
31
|
+
Error,
|
|
32
|
+
Errors.MissingKeyParameter
|
|
33
|
+
)
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
const keySplitted: string[] = key.split('')
|
|
@@ -6,6 +6,8 @@ import { CosmosDbKeyEscape } from './cosmosDbKeyEscape'
|
|
|
6
6
|
import { DocumentStoreItem } from './documentStoreItem'
|
|
7
7
|
import { CosmosDbPartitionedStorageOptions } from './cosmosDbPartitionedStorageOptions'
|
|
8
8
|
import { Storage, StoreItems } from '@microsoft/agents-hosting'
|
|
9
|
+
import { ExceptionHelper } from '@microsoft/agents-activity'
|
|
10
|
+
import { Errors } from './errorHelper'
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* A utility class to ensure that a specific asynchronous task is executed only once for a given key.
|
|
@@ -55,30 +57,51 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
55
57
|
*/
|
|
56
58
|
constructor (private readonly cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions) {
|
|
57
59
|
if (!cosmosDbStorageOptions) {
|
|
58
|
-
throw
|
|
60
|
+
throw ExceptionHelper.generateException(
|
|
61
|
+
ReferenceError,
|
|
62
|
+
Errors.MissingCosmosDbStorageOptions
|
|
63
|
+
)
|
|
59
64
|
}
|
|
60
65
|
const { cosmosClientOptions } = cosmosDbStorageOptions
|
|
61
66
|
if (!cosmosClientOptions?.endpoint) {
|
|
62
|
-
throw
|
|
67
|
+
throw ExceptionHelper.generateException(
|
|
68
|
+
ReferenceError,
|
|
69
|
+
Errors.MissingCosmosEndpoint
|
|
70
|
+
)
|
|
63
71
|
}
|
|
64
72
|
if (!cosmosClientOptions?.key && !cosmosClientOptions?.tokenProvider) {
|
|
65
|
-
throw
|
|
73
|
+
throw ExceptionHelper.generateException(
|
|
74
|
+
ReferenceError,
|
|
75
|
+
Errors.MissingCosmosCredentials
|
|
76
|
+
)
|
|
66
77
|
}
|
|
67
78
|
if (!cosmosDbStorageOptions.databaseId) {
|
|
68
|
-
throw
|
|
79
|
+
throw ExceptionHelper.generateException(
|
|
80
|
+
ReferenceError,
|
|
81
|
+
Errors.MissingDatabaseId
|
|
82
|
+
)
|
|
69
83
|
}
|
|
70
84
|
if (!cosmosDbStorageOptions.containerId) {
|
|
71
|
-
throw
|
|
85
|
+
throw ExceptionHelper.generateException(
|
|
86
|
+
ReferenceError,
|
|
87
|
+
Errors.MissingContainerId
|
|
88
|
+
)
|
|
72
89
|
}
|
|
73
90
|
cosmosDbStorageOptions.compatibilityMode ??= true
|
|
74
91
|
if (cosmosDbStorageOptions.keySuffix) {
|
|
75
92
|
if (cosmosDbStorageOptions.compatibilityMode) {
|
|
76
|
-
throw
|
|
93
|
+
throw ExceptionHelper.generateException(
|
|
94
|
+
ReferenceError,
|
|
95
|
+
Errors.InvalidCompatibilityModeWithKeySuffix
|
|
96
|
+
)
|
|
77
97
|
}
|
|
78
98
|
const suffixEscaped = CosmosDbKeyEscape.escapeKey(cosmosDbStorageOptions.keySuffix)
|
|
79
99
|
if (cosmosDbStorageOptions.keySuffix !== suffixEscaped) {
|
|
80
|
-
throw
|
|
81
|
-
|
|
100
|
+
throw ExceptionHelper.generateException(
|
|
101
|
+
ReferenceError,
|
|
102
|
+
Errors.InvalidKeySuffixCharacters,
|
|
103
|
+
undefined,
|
|
104
|
+
{ keySuffix: cosmosDbStorageOptions.keySuffix }
|
|
82
105
|
)
|
|
83
106
|
}
|
|
84
107
|
}
|
|
@@ -91,7 +114,10 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
91
114
|
*/
|
|
92
115
|
async read (keys: string[]): Promise<StoreItems> {
|
|
93
116
|
if (!keys) {
|
|
94
|
-
throw
|
|
117
|
+
throw ExceptionHelper.generateException(
|
|
118
|
+
ReferenceError,
|
|
119
|
+
Errors.MissingReadKeys
|
|
120
|
+
)
|
|
95
121
|
} else if (keys.length === 0) {
|
|
96
122
|
return {}
|
|
97
123
|
}
|
|
@@ -119,16 +145,19 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
119
145
|
}
|
|
120
146
|
} catch (err: any) {
|
|
121
147
|
if (err.code === 404) {
|
|
122
|
-
|
|
123
|
-
err)
|
|
148
|
+
// Not Found is not an error during read operations, just skip
|
|
124
149
|
} else if (err.code === 400) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
150
|
+
throw ExceptionHelper.generateException(
|
|
151
|
+
Error,
|
|
152
|
+
Errors.ContainerReadBadRequest,
|
|
153
|
+
err
|
|
129
154
|
)
|
|
130
155
|
} else {
|
|
131
|
-
|
|
156
|
+
throw ExceptionHelper.generateException(
|
|
157
|
+
Error,
|
|
158
|
+
Errors.ContainerReadError,
|
|
159
|
+
err
|
|
160
|
+
)
|
|
132
161
|
}
|
|
133
162
|
}
|
|
134
163
|
})
|
|
@@ -143,7 +172,10 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
143
172
|
*/
|
|
144
173
|
async write (changes: StoreItems): Promise<void> {
|
|
145
174
|
if (!changes) {
|
|
146
|
-
throw
|
|
175
|
+
throw ExceptionHelper.generateException(
|
|
176
|
+
ReferenceError,
|
|
177
|
+
Errors.MissingWriteChanges
|
|
178
|
+
)
|
|
147
179
|
} else if (changes.length === 0) {
|
|
148
180
|
return
|
|
149
181
|
}
|
|
@@ -171,7 +203,11 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
171
203
|
await this.container.items.upsert(document, accessCondition)
|
|
172
204
|
} catch (err: any) {
|
|
173
205
|
this.checkForNestingError(change, err)
|
|
174
|
-
|
|
206
|
+
throw ExceptionHelper.generateException(
|
|
207
|
+
Error,
|
|
208
|
+
Errors.DocumentUpsertError,
|
|
209
|
+
err
|
|
210
|
+
)
|
|
175
211
|
}
|
|
176
212
|
})
|
|
177
213
|
)
|
|
@@ -195,9 +231,13 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
195
231
|
await this.container.item(escapedKey, this.getPartitionKey(escapedKey)).delete()
|
|
196
232
|
} catch (err: any) {
|
|
197
233
|
if (err.code === 404) {
|
|
198
|
-
|
|
234
|
+
// Not Found is not an error during delete operations, just skip
|
|
199
235
|
} else {
|
|
200
|
-
|
|
236
|
+
throw ExceptionHelper.generateException(
|
|
237
|
+
Error,
|
|
238
|
+
Errors.DocumentDeleteError,
|
|
239
|
+
err
|
|
240
|
+
)
|
|
201
241
|
}
|
|
202
242
|
}
|
|
203
243
|
})
|
|
@@ -239,8 +279,14 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
239
279
|
if (paths.includes('/_partitionKey')) {
|
|
240
280
|
this.compatibilityModePartitionKey = true
|
|
241
281
|
} else if (paths.indexOf(DocumentStoreItem.partitionKeyPath) === -1) {
|
|
242
|
-
throw
|
|
243
|
-
|
|
282
|
+
throw ExceptionHelper.generateException(
|
|
283
|
+
Error,
|
|
284
|
+
Errors.UnsupportedCustomPartitionKeyPath,
|
|
285
|
+
undefined,
|
|
286
|
+
{
|
|
287
|
+
containerId: this.cosmosDbStorageOptions.containerId,
|
|
288
|
+
partitionKeyPath: paths[0]
|
|
289
|
+
}
|
|
244
290
|
)
|
|
245
291
|
}
|
|
246
292
|
} else {
|
|
@@ -264,15 +310,24 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
264
310
|
}
|
|
265
311
|
|
|
266
312
|
if (!container) {
|
|
267
|
-
throw
|
|
313
|
+
throw ExceptionHelper.generateException(
|
|
314
|
+
Error,
|
|
315
|
+
Errors.ContainerNotFound,
|
|
316
|
+
undefined,
|
|
317
|
+
{ containerId: this.cosmosDbStorageOptions.containerId }
|
|
318
|
+
)
|
|
268
319
|
}
|
|
269
320
|
return container
|
|
270
321
|
} catch (err: any) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
322
|
+
throw ExceptionHelper.generateException(
|
|
323
|
+
Error,
|
|
324
|
+
Errors.InitializationError,
|
|
325
|
+
err,
|
|
326
|
+
{
|
|
327
|
+
databaseId: this.cosmosDbStorageOptions.databaseId,
|
|
328
|
+
containerId: this.cosmosDbStorageOptions.containerId
|
|
329
|
+
}
|
|
274
330
|
)
|
|
275
|
-
throw err
|
|
276
331
|
}
|
|
277
332
|
}
|
|
278
333
|
|
|
@@ -283,18 +338,33 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
283
338
|
private checkForNestingError (json: object, err: Error | Record<'message', string> | string): void {
|
|
284
339
|
const checkDepth = (obj: unknown, depth: number, isInDialogState: boolean): void => {
|
|
285
340
|
if (depth > maxDepthAllowed) {
|
|
286
|
-
let
|
|
341
|
+
let additionalMessage = ''
|
|
287
342
|
|
|
288
343
|
if (isInDialogState) {
|
|
289
|
-
|
|
344
|
+
additionalMessage =
|
|
290
345
|
' This is most likely caused by recursive component dialogs. ' +
|
|
291
346
|
'Try reworking your dialog code to make sure it does not keep dialogs on the stack ' +
|
|
292
347
|
"that it's not using. For example, consider using replaceDialog instead of beginDialog."
|
|
293
348
|
} else {
|
|
294
|
-
|
|
349
|
+
additionalMessage = ' Please check your data for signs of unintended recursion.'
|
|
295
350
|
}
|
|
296
351
|
|
|
297
|
-
|
|
352
|
+
// Convert err to Error if needed
|
|
353
|
+
const errorObj = typeof err === 'string'
|
|
354
|
+
? new Error(err)
|
|
355
|
+
: err instanceof Error
|
|
356
|
+
? err
|
|
357
|
+
: new Error(err.message)
|
|
358
|
+
|
|
359
|
+
throw ExceptionHelper.generateException(
|
|
360
|
+
Error,
|
|
361
|
+
Errors.MaxNestingDepthExceeded,
|
|
362
|
+
errorObj,
|
|
363
|
+
{
|
|
364
|
+
maxDepth: maxDepthAllowed.toString(),
|
|
365
|
+
additionalMessage
|
|
366
|
+
}
|
|
367
|
+
)
|
|
298
368
|
} else if (obj && typeof obj === 'object') {
|
|
299
369
|
for (const [key, value] of Object.entries(obj)) {
|
|
300
370
|
checkDepth(value, depth + 1, key === 'dialogStack' || isInDialogState)
|
|
@@ -304,14 +374,4 @@ export class CosmosDbPartitionedStorage implements Storage {
|
|
|
304
374
|
|
|
305
375
|
checkDepth(json, 0, false)
|
|
306
376
|
}
|
|
307
|
-
|
|
308
|
-
private throwInformativeError (prependedMessage: string, err: Error | Record<'message', string> | string): void {
|
|
309
|
-
if (typeof err === 'string') {
|
|
310
|
-
err = new Error(err)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
err.message = `[${prependedMessage}] ${err.message}`
|
|
314
|
-
|
|
315
|
-
throw err
|
|
316
|
-
}
|
|
317
377
|
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { AgentErrorDefinition } from '@microsoft/agents-activity'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Error definitions for the CosmosDB storage system.
|
|
8
|
+
* This contains localized error codes for the CosmosDB storage subsystem of the AgentSDK.
|
|
9
|
+
*
|
|
10
|
+
* Each error definition includes an error code (starting from -100000), a description, and a help link
|
|
11
|
+
* pointing to an AKA link to get help for the given error.
|
|
12
|
+
*
|
|
13
|
+
* Usage example:
|
|
14
|
+
* ```
|
|
15
|
+
* throw ExceptionHelper.generateException(
|
|
16
|
+
* ReferenceError,
|
|
17
|
+
* Errors.MissingCosmosDbStorageOptions
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when CosmosDbPartitionedStorageOptions is not provided.
|
|
24
|
+
*/
|
|
25
|
+
MissingCosmosDbStorageOptions: {
|
|
26
|
+
code: -100000,
|
|
27
|
+
description: 'CosmosDbPartitionedStorageOptions is required.'
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when endpoint in cosmosClientOptions is not provided.
|
|
32
|
+
*/
|
|
33
|
+
MissingCosmosEndpoint: {
|
|
34
|
+
code: -100001,
|
|
35
|
+
description: 'endpoint in cosmosClientOptions is required.'
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when neither key nor tokenProvider is provided in cosmosClientOptions.
|
|
40
|
+
*/
|
|
41
|
+
MissingCosmosCredentials: {
|
|
42
|
+
code: -100002,
|
|
43
|
+
description: 'key or tokenProvider in cosmosClientOptions is required.'
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when databaseId is not provided.
|
|
48
|
+
*/
|
|
49
|
+
MissingDatabaseId: {
|
|
50
|
+
code: -100003,
|
|
51
|
+
description: 'databaseId for CosmosDB is required.'
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown when containerId is not provided.
|
|
56
|
+
*/
|
|
57
|
+
MissingContainerId: {
|
|
58
|
+
code: -100004,
|
|
59
|
+
description: 'containerId for CosmosDB is required.'
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Error thrown when compatibilityMode is enabled with a keySuffix.
|
|
64
|
+
*/
|
|
65
|
+
InvalidCompatibilityModeWithKeySuffix: {
|
|
66
|
+
code: -100005,
|
|
67
|
+
description: 'compatibilityMode cannot be true while using a keySuffix.'
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Error thrown when keySuffix contains invalid Row Key characters.
|
|
72
|
+
*/
|
|
73
|
+
InvalidKeySuffixCharacters: {
|
|
74
|
+
code: -100006,
|
|
75
|
+
description: 'Cannot use invalid Row Key characters: {keySuffix} in keySuffix'
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Error thrown when keys are not provided for reading.
|
|
80
|
+
*/
|
|
81
|
+
MissingReadKeys: {
|
|
82
|
+
code: -100007,
|
|
83
|
+
description: 'Keys are required when reading.'
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Error thrown when changes are not provided for writing.
|
|
88
|
+
*/
|
|
89
|
+
MissingWriteChanges: {
|
|
90
|
+
code: -100008,
|
|
91
|
+
description: 'Changes are required when writing.'
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Error thrown when attempting to use a custom partition key path.
|
|
96
|
+
*/
|
|
97
|
+
UnsupportedCustomPartitionKeyPath: {
|
|
98
|
+
code: -100009,
|
|
99
|
+
description: 'Custom Partition Key Paths are not supported. {containerId} has a custom Partition Key Path of {partitionKeyPath}.'
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Error thrown when the specified container is not found.
|
|
104
|
+
*/
|
|
105
|
+
ContainerNotFound: {
|
|
106
|
+
code: -100010,
|
|
107
|
+
description: 'Container {containerId} not found.'
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Error thrown when the key parameter is missing in CosmosDbKeyEscape.
|
|
112
|
+
*/
|
|
113
|
+
MissingKeyParameter: {
|
|
114
|
+
code: -100011,
|
|
115
|
+
description: "The 'key' parameter is required.",
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Error thrown when there is an error reading from the container (404 Not Found).
|
|
120
|
+
*/
|
|
121
|
+
ContainerReadNotFound: {
|
|
122
|
+
code: -100012,
|
|
123
|
+
description: 'Not Found'
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Error thrown when there is an error reading from container (400 Bad Request).
|
|
128
|
+
*/
|
|
129
|
+
ContainerReadBadRequest: {
|
|
130
|
+
code: -100013,
|
|
131
|
+
description: 'Error reading from container. You might be attempting to read from a non-partitioned container or a container that does not use \'/id\' as the partitionKeyPath'
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Error thrown when there is a general error reading from the container.
|
|
136
|
+
*/
|
|
137
|
+
ContainerReadError: {
|
|
138
|
+
code: -100014,
|
|
139
|
+
description: 'Error reading from container'
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Error thrown when there is an error upserting a document.
|
|
144
|
+
*/
|
|
145
|
+
DocumentUpsertError: {
|
|
146
|
+
code: -100015,
|
|
147
|
+
description: 'Error upserting document'
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Error thrown when there is an error deleting a document (404 Not Found).
|
|
152
|
+
*/
|
|
153
|
+
DocumentDeleteNotFound: {
|
|
154
|
+
code: -100016,
|
|
155
|
+
description: 'Not Found'
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Error thrown when unable to delete a document.
|
|
160
|
+
*/
|
|
161
|
+
DocumentDeleteError: {
|
|
162
|
+
code: -100017,
|
|
163
|
+
description: 'Unable to delete document'
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Error thrown when failing to initialize CosmosDB database/container.
|
|
168
|
+
*/
|
|
169
|
+
InitializationError: {
|
|
170
|
+
code: -100018,
|
|
171
|
+
description: 'Failed to initialize Cosmos DB database/container: {databaseId}/{containerId}'
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Error thrown when maximum nesting depth is exceeded.
|
|
176
|
+
*/
|
|
177
|
+
MaxNestingDepthExceeded: {
|
|
178
|
+
code: -100019,
|
|
179
|
+
description: 'Maximum nesting depth of {maxDepth} exceeded. {additionalMessage}'
|
|
180
|
+
}
|
|
181
|
+
}
|
package/src/index.ts
CHANGED