@openstax/ts-utils 1.15.2 → 1.15.4
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/cjs/services/documentStore/unversioned/dynamodb.js +9 -2
- package/dist/cjs/services/documentStore/unversioned/file-system.js +2 -1
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/documentStore/unversioned/dynamodb.js +9 -2
- package/dist/esm/services/documentStore/unversioned/file-system.js +2 -1
- package/dist/esm/services/documentStore/versioned/file-system.js +1 -1
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.dynamoUnversionedDocumentStore = void 0;
|
|
|
4
4
|
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
5
5
|
const __1 = require("../../..");
|
|
6
6
|
const config_1 = require("../../../config");
|
|
7
|
+
const errors_1 = require("../../../errors");
|
|
7
8
|
const guards_1 = require("../../../guards");
|
|
8
9
|
const dynamoEncoding_1 = require("../dynamoEncoding");
|
|
9
10
|
const dynamodb = (0, __1.once)(() => new client_dynamodb_1.DynamoDB({ apiVersion: '2012-08-10' }));
|
|
@@ -62,9 +63,12 @@ const dynamoUnversionedDocumentStore = (initializer) => () => (configProvider) =
|
|
|
62
63
|
var _a;
|
|
63
64
|
const result = (_a = item.Attributes) === null || _a === void 0 ? void 0 : _a[field]['N'];
|
|
64
65
|
if (!result) {
|
|
65
|
-
throw new
|
|
66
|
+
throw new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`);
|
|
66
67
|
}
|
|
67
68
|
return parseFloat(result);
|
|
69
|
+
}).catch((error) => {
|
|
70
|
+
throw error.name === 'ConditionalCheckFailedException' ?
|
|
71
|
+
new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`) : error;
|
|
68
72
|
});
|
|
69
73
|
},
|
|
70
74
|
/* replaces only specified attributes with the given data */
|
|
@@ -97,9 +101,12 @@ const dynamoUnversionedDocumentStore = (initializer) => () => (configProvider) =
|
|
|
97
101
|
});
|
|
98
102
|
return dynamodb().send(cmd).then((item) => {
|
|
99
103
|
if (!item.Attributes) {
|
|
100
|
-
throw new
|
|
104
|
+
throw new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`);
|
|
101
105
|
}
|
|
102
106
|
return (0, dynamoEncoding_1.decodeDynamoDocument)(item.Attributes);
|
|
107
|
+
}).catch((error) => {
|
|
108
|
+
throw error.name === 'ConditionalCheckFailedException' ?
|
|
109
|
+
new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`) : error;
|
|
103
110
|
});
|
|
104
111
|
},
|
|
105
112
|
/* replaces the entire document with the given data */
|
|
@@ -31,6 +31,7 @@ const fsModule = __importStar(require("fs"));
|
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const __1 = require("../../..");
|
|
33
33
|
const config_1 = require("../../../config");
|
|
34
|
+
const errors_1 = require("../../../errors");
|
|
34
35
|
const guards_1 = require("../../../guards");
|
|
35
36
|
const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey) => {
|
|
36
37
|
const tableName = (0, config_1.resolveConfigValue)(configProvider[initializer.configSpace || 'fileSystem'].tableName);
|
|
@@ -101,7 +102,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
|
|
|
101
102
|
await mkTableDir;
|
|
102
103
|
const data = await load(filename);
|
|
103
104
|
if (!data) {
|
|
104
|
-
throw new
|
|
105
|
+
throw new errors_1.NotFoundError(`Item with ${hashKey.toString()} "${id}" does not exist`);
|
|
105
106
|
}
|
|
106
107
|
const newItem = { ...data, ...item };
|
|
107
108
|
return new Promise((resolve, reject) => {
|