@encodeagent/platform-helper-data 1.2510.1282253 → 1.2511.1011152
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/cosmosdb/index.d.ts +2 -1
- package/dist/cosmosdb/index.d.ts.map +1 -1
- package/dist/cosmosdb/index.js +104 -8
- package/dist/cosmosdb/index.js.map +1 -1
- package/dist/dynamodb/index.d.ts +7 -6
- package/dist/dynamodb/index.d.ts.map +1 -1
- package/dist/dynamodb/index.js +210 -19
- package/dist/dynamodb/index.js.map +1 -1
- package/dist/firestore/index.d.ts +5 -4
- package/dist/firestore/index.d.ts.map +1 -1
- package/dist/firestore/index.js +174 -25
- package/dist/firestore/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mongodb/index.d.ts +2 -1
- package/dist/mongodb/index.d.ts.map +1 -1
- package/dist/mongodb/index.js +150 -40
- package/dist/mongodb/index.js.map +1 -1
- package/dist/util.d.ts +24 -16
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +20 -5
- package/dist/util.js.map +1 -1
- package/dist/wrapper/index.d.ts +11 -1
- package/dist/wrapper/index.d.ts.map +1 -1
- package/dist/wrapper/index.js +187 -20
- package/dist/wrapper/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cosmosdb/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Azure Cosmos DB implementation
|
|
3
3
|
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult,
|
|
4
|
+
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveProps, ICreateProps, ICreateResult, IQueryProps, IQueryResult, IUpsertProps, IUpsertResult, IUpdateProps, IUpdateResult } from '../util';
|
|
5
5
|
/**
|
|
6
6
|
* Create Azure Cosmos DB connection
|
|
7
7
|
* @param props Connection properties with URI and key
|
|
@@ -22,4 +22,5 @@ export declare function create(props: ICreateProps): Promise<ICreateResult>;
|
|
|
22
22
|
* @returns Promise<IUpsertResult>
|
|
23
23
|
*/
|
|
24
24
|
export declare function upsert(props: IUpsertProps): Promise<IUpsertResult>;
|
|
25
|
+
export declare function update(props: IUpdateProps): Promise<IUpdateResult>;
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cosmosdb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cosmosdb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,0BAA0B,EAAE,iBAAiB,EAC7C,eAAe,EAAE,cAAc,EAC/B,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,aAAa,EAG9B,MAAM,SAAS,CAAC;AAWjB;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8C3F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAuD9E;AAGD,wBAAsB,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAsDrE;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAyCxE;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAkDxE;AAGD,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAsDxE"}
|
package/dist/cosmosdb/index.js
CHANGED
|
@@ -8,11 +8,16 @@ exports.retrieve = retrieve;
|
|
|
8
8
|
exports.query = query;
|
|
9
9
|
exports.create = create;
|
|
10
10
|
exports.upsert = upsert;
|
|
11
|
-
|
|
11
|
+
exports.update = update;
|
|
12
12
|
const util_1 = require("../util");
|
|
13
|
+
const platform_helper_util_1 = require("@encodeagent/platform-helper-util");
|
|
13
14
|
const cosmos_1 = require("@azure/cosmos");
|
|
14
15
|
const query_builder_1 = require("./query-builder");
|
|
15
16
|
const ENGINE = "cosmosdb";
|
|
17
|
+
const ERROR_INFO = {
|
|
18
|
+
package: util_1.PACKAGE,
|
|
19
|
+
module: "database-cosmosdb"
|
|
20
|
+
};
|
|
16
21
|
/**
|
|
17
22
|
* Create Azure Cosmos DB connection
|
|
18
23
|
* @param props Connection properties with URI and key
|
|
@@ -24,13 +29,23 @@ async function connect(props) {
|
|
|
24
29
|
if (!uri) {
|
|
25
30
|
return {
|
|
26
31
|
engine: ENGINE,
|
|
27
|
-
error:
|
|
32
|
+
error: {
|
|
33
|
+
...ERROR_INFO,
|
|
34
|
+
source: "connect",
|
|
35
|
+
code: "require-db-uri",
|
|
36
|
+
message: "Azure Cosmos DB URI is required"
|
|
37
|
+
}
|
|
28
38
|
};
|
|
29
39
|
}
|
|
30
40
|
if (!key) {
|
|
31
41
|
return {
|
|
32
42
|
engine: ENGINE,
|
|
33
|
-
error:
|
|
43
|
+
error: {
|
|
44
|
+
...ERROR_INFO,
|
|
45
|
+
source: "connect",
|
|
46
|
+
code: "require-db-key",
|
|
47
|
+
message: "Azure Cosmos DB key is required"
|
|
48
|
+
}
|
|
34
49
|
};
|
|
35
50
|
}
|
|
36
51
|
// Create Azure Cosmos DB client
|
|
@@ -43,7 +58,12 @@ async function connect(props) {
|
|
|
43
58
|
catch (error) {
|
|
44
59
|
return {
|
|
45
60
|
engine: ENGINE,
|
|
46
|
-
error:
|
|
61
|
+
error: {
|
|
62
|
+
...ERROR_INFO,
|
|
63
|
+
source: "connect",
|
|
64
|
+
code: "database-connect",
|
|
65
|
+
message: error instanceof Error ? error.message : 'Failed to connect to Azure Cosmos DB'
|
|
66
|
+
}
|
|
47
67
|
};
|
|
48
68
|
}
|
|
49
69
|
}
|
|
@@ -56,6 +76,8 @@ async function retrieve(props) {
|
|
|
56
76
|
try {
|
|
57
77
|
const { client, id, partitionKey, databaseId, containerId } = props;
|
|
58
78
|
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
79
|
+
engine: ENGINE,
|
|
80
|
+
...ERROR_INFO,
|
|
59
81
|
databaseId,
|
|
60
82
|
containerId,
|
|
61
83
|
checkDatabaseId: true,
|
|
@@ -92,7 +114,12 @@ async function retrieve(props) {
|
|
|
92
114
|
catch (error) {
|
|
93
115
|
return {
|
|
94
116
|
engine: ENGINE,
|
|
95
|
-
error:
|
|
117
|
+
error: {
|
|
118
|
+
...ERROR_INFO,
|
|
119
|
+
source: "retrieve",
|
|
120
|
+
code: "database-retrieve",
|
|
121
|
+
message: error instanceof Error ? error.message : 'Failed to retrieve document from Cosmos DB'
|
|
122
|
+
}
|
|
96
123
|
};
|
|
97
124
|
}
|
|
98
125
|
}
|
|
@@ -101,6 +128,8 @@ async function query(props) {
|
|
|
101
128
|
const { client, databaseId, containerId, query } = props;
|
|
102
129
|
try {
|
|
103
130
|
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
131
|
+
engine: ENGINE,
|
|
132
|
+
...ERROR_INFO,
|
|
104
133
|
databaseId,
|
|
105
134
|
containerId,
|
|
106
135
|
checkDatabaseId: true,
|
|
@@ -131,7 +160,12 @@ async function query(props) {
|
|
|
131
160
|
engine: ENGINE,
|
|
132
161
|
query,
|
|
133
162
|
dbQuery,
|
|
134
|
-
error:
|
|
163
|
+
error: {
|
|
164
|
+
...ERROR_INFO,
|
|
165
|
+
source: "query",
|
|
166
|
+
code: "database-query",
|
|
167
|
+
message: error instanceof Error ? error.message : 'Failed to query documents from Cosmos DB'
|
|
168
|
+
}
|
|
135
169
|
};
|
|
136
170
|
}
|
|
137
171
|
}
|
|
@@ -139,6 +173,8 @@ async function create(props) {
|
|
|
139
173
|
try {
|
|
140
174
|
const { client, databaseId, containerId, record } = props;
|
|
141
175
|
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
176
|
+
engine: ENGINE,
|
|
177
|
+
...ERROR_INFO,
|
|
142
178
|
databaseId,
|
|
143
179
|
containerId,
|
|
144
180
|
checkDatabaseId: true,
|
|
@@ -161,7 +197,12 @@ async function create(props) {
|
|
|
161
197
|
catch (error) {
|
|
162
198
|
return {
|
|
163
199
|
engine: ENGINE,
|
|
164
|
-
error:
|
|
200
|
+
error: {
|
|
201
|
+
...ERROR_INFO,
|
|
202
|
+
source: "create",
|
|
203
|
+
code: "database-create",
|
|
204
|
+
message: error instanceof Error ? error.message : 'Failed to create record in Cosmos DB'
|
|
205
|
+
}
|
|
165
206
|
};
|
|
166
207
|
}
|
|
167
208
|
}
|
|
@@ -174,6 +215,8 @@ async function upsert(props) {
|
|
|
174
215
|
try {
|
|
175
216
|
const { client, databaseId, containerId, record } = props;
|
|
176
217
|
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
218
|
+
engine: ENGINE,
|
|
219
|
+
...ERROR_INFO,
|
|
177
220
|
databaseId,
|
|
178
221
|
containerId,
|
|
179
222
|
checkDatabaseId: true,
|
|
@@ -203,7 +246,60 @@ async function upsert(props) {
|
|
|
203
246
|
catch (error) {
|
|
204
247
|
return {
|
|
205
248
|
engine: ENGINE,
|
|
206
|
-
error:
|
|
249
|
+
error: {
|
|
250
|
+
...ERROR_INFO,
|
|
251
|
+
source: "upsert",
|
|
252
|
+
code: "database-upsert",
|
|
253
|
+
message: error instanceof Error ? error.message : 'Failed to upsert record in Cosmos DB'
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function update(props) {
|
|
259
|
+
try {
|
|
260
|
+
const { client, databaseId, containerId, record, partitionKey } = props;
|
|
261
|
+
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
262
|
+
engine: ENGINE,
|
|
263
|
+
...ERROR_INFO,
|
|
264
|
+
databaseId,
|
|
265
|
+
containerId,
|
|
266
|
+
checkDatabaseId: true,
|
|
267
|
+
checkContainerId: true
|
|
268
|
+
});
|
|
269
|
+
if (errorResult) {
|
|
270
|
+
return errorResult;
|
|
271
|
+
}
|
|
272
|
+
if (!record?.id || !(0, platform_helper_util_1.isNonEmptyString)(String(record.id))) {
|
|
273
|
+
return {
|
|
274
|
+
engine: ENGINE,
|
|
275
|
+
error: {
|
|
276
|
+
...ERROR_INFO,
|
|
277
|
+
source: "update",
|
|
278
|
+
code: "require-record-id",
|
|
279
|
+
message: "Record id is required for update"
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
const database = client.database(databaseId);
|
|
284
|
+
const container = database.container(containerId);
|
|
285
|
+
const item = (0, platform_helper_util_1.isNonEmptyString)(partitionKey)
|
|
286
|
+
? container.item(record.id, partitionKey)
|
|
287
|
+
: container.item(record.id);
|
|
288
|
+
const response = await item.replace(record);
|
|
289
|
+
return {
|
|
290
|
+
engine: ENGINE,
|
|
291
|
+
data: response.resource
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
return {
|
|
296
|
+
engine: ENGINE,
|
|
297
|
+
error: {
|
|
298
|
+
...ERROR_INFO,
|
|
299
|
+
source: "update",
|
|
300
|
+
code: "database-update",
|
|
301
|
+
message: error instanceof Error ? error.message : 'Failed to update record in Cosmos DB'
|
|
302
|
+
}
|
|
207
303
|
};
|
|
208
304
|
}
|
|
209
305
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cosmosdb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cosmosdb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA2BH,0BA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AQ,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAElD,MAAM,IAAI,GAAG,IAAA,uCAAgB,EAAC,YAAY,CAAC;YACvC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC;YACzC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE5C,OAAO;YACH,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,QAAQ,CAAC,QAAQ;SAC1B,CAAC;IAEN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM,EAAE,MAAM;YACd,KAAK,EAAE;gBACH,GAAG,UAAU;gBACb,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sCAAsC;aAC3F;SACJ,CAAC;IACN,CAAC;AACL,CAAC"}
|
package/dist/dynamodb/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview AWS DynamoDB implementation
|
|
3
3
|
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveProps, ICreateProps, IUpsertProps, IUpsertResult } from '../util';
|
|
4
|
+
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveProps, ICreateProps, ICreateResult, IUpsertProps, IUpsertResult, IUpdateProps, IUpdateResult } from '../util';
|
|
5
5
|
/**
|
|
6
6
|
* Create AWS DynamoDB connection
|
|
7
7
|
* @param props Connection properties with URI and key
|
|
@@ -11,14 +11,15 @@ export declare function connect(props: IConnectionForServiceProps): Promise<ICon
|
|
|
11
11
|
/**
|
|
12
12
|
* Retrieve document by ID from AWS DynamoDB
|
|
13
13
|
* @param props Retrieve properties with client, collection (table), and id
|
|
14
|
-
* @returns Promise<IRetrieveResult
|
|
14
|
+
* @returns Promise<IRetrieveResult>
|
|
15
15
|
*/
|
|
16
|
-
export declare function retrieve
|
|
17
|
-
export declare function create
|
|
16
|
+
export declare function retrieve(props: IRetrieveProps): Promise<IRetrieveResult>;
|
|
17
|
+
export declare function create(props: ICreateProps): Promise<ICreateResult>;
|
|
18
18
|
/**
|
|
19
19
|
* Upsert (create or update) a document in AWS DynamoDB
|
|
20
20
|
* @param props Upsert properties with client, containerId (table name), and record
|
|
21
|
-
* @returns Promise<IUpsertResult
|
|
21
|
+
* @returns Promise<IUpsertResult>
|
|
22
22
|
*/
|
|
23
|
-
export declare function upsert
|
|
23
|
+
export declare function upsert(props: IUpsertProps): Promise<IUpsertResult>;
|
|
24
|
+
export declare function update(props: IUpdateProps): Promise<IUpdateResult>;
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dynamodb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dynamodb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEH,0BAA0B,EAAE,iBAAiB,EAC7C,eAAe,EAAE,cAAc,EAC/B,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,aAAa,EAC9B,MAAM,SAAS,CAAC;AAYjB;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuE3F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAmD9E;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAqExE;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAoFxE;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CA4GxE"}
|
package/dist/dynamodb/index.js
CHANGED
|
@@ -7,10 +7,17 @@ exports.connect = connect;
|
|
|
7
7
|
exports.retrieve = retrieve;
|
|
8
8
|
exports.create = create;
|
|
9
9
|
exports.upsert = upsert;
|
|
10
|
+
exports.update = update;
|
|
11
|
+
const util_1 = require("../util");
|
|
10
12
|
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
11
13
|
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
12
14
|
const platform_helper_util_1 = require("@encodeagent/platform-helper-util");
|
|
15
|
+
const util_2 = require("../util");
|
|
13
16
|
const ENGINE = "dynamodb";
|
|
17
|
+
const ERROR_INFO = {
|
|
18
|
+
package: util_2.PACKAGE,
|
|
19
|
+
module: "database-dynamodb"
|
|
20
|
+
};
|
|
14
21
|
/**
|
|
15
22
|
* Create AWS DynamoDB connection
|
|
16
23
|
* @param props Connection properties with URI and key
|
|
@@ -21,14 +28,24 @@ async function connect(props) {
|
|
|
21
28
|
const { uri, key } = props;
|
|
22
29
|
if (!uri) {
|
|
23
30
|
return {
|
|
24
|
-
engine:
|
|
25
|
-
error:
|
|
31
|
+
engine: ENGINE,
|
|
32
|
+
error: {
|
|
33
|
+
...ERROR_INFO,
|
|
34
|
+
source: "connect",
|
|
35
|
+
code: "require-db-uri",
|
|
36
|
+
message: "AWS DynamoDB URI is required"
|
|
37
|
+
}
|
|
26
38
|
};
|
|
27
39
|
}
|
|
28
40
|
if (!key) {
|
|
29
41
|
return {
|
|
30
42
|
engine: ENGINE,
|
|
31
|
-
error:
|
|
43
|
+
error: {
|
|
44
|
+
...ERROR_INFO,
|
|
45
|
+
source: "connect",
|
|
46
|
+
code: "require-db-key",
|
|
47
|
+
message: "AWS DynamoDB access key is required"
|
|
48
|
+
}
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
51
|
// Parse AWS credentials from key (format: accessKeyId:secretAccessKey)
|
|
@@ -36,7 +53,12 @@ async function connect(props) {
|
|
|
36
53
|
if (!accessKeyId || !secretAccessKey) {
|
|
37
54
|
return {
|
|
38
55
|
engine: ENGINE,
|
|
39
|
-
error:
|
|
56
|
+
error: {
|
|
57
|
+
...ERROR_INFO,
|
|
58
|
+
source: "connect",
|
|
59
|
+
code: "invalid-db-key",
|
|
60
|
+
message: "AWS key must be in format: accessKeyId:secretAccessKey"
|
|
61
|
+
}
|
|
40
62
|
};
|
|
41
63
|
}
|
|
42
64
|
// Create DynamoDB client configuration
|
|
@@ -57,18 +79,34 @@ async function connect(props) {
|
|
|
57
79
|
catch (error) {
|
|
58
80
|
return {
|
|
59
81
|
engine: ENGINE,
|
|
60
|
-
error:
|
|
82
|
+
error: {
|
|
83
|
+
...ERROR_INFO,
|
|
84
|
+
source: "connect",
|
|
85
|
+
code: "database-connect",
|
|
86
|
+
message: error instanceof Error ? error.message : 'Failed to connect to AWS DynamoDB'
|
|
87
|
+
}
|
|
61
88
|
};
|
|
62
89
|
}
|
|
63
90
|
}
|
|
64
91
|
/**
|
|
65
92
|
* Retrieve document by ID from AWS DynamoDB
|
|
66
93
|
* @param props Retrieve properties with client, collection (table), and id
|
|
67
|
-
* @returns Promise<IRetrieveResult
|
|
94
|
+
* @returns Promise<IRetrieveResult>
|
|
68
95
|
*/
|
|
69
96
|
async function retrieve(props) {
|
|
70
97
|
try {
|
|
71
|
-
const { client, id, containerId } = props;
|
|
98
|
+
const { client, id, containerId, databaseId } = props;
|
|
99
|
+
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
100
|
+
engine: ENGINE,
|
|
101
|
+
...ERROR_INFO,
|
|
102
|
+
databaseId,
|
|
103
|
+
containerId,
|
|
104
|
+
checkDatabaseId: true,
|
|
105
|
+
checkContainerId: true
|
|
106
|
+
});
|
|
107
|
+
if (errorResult) {
|
|
108
|
+
return errorResult;
|
|
109
|
+
}
|
|
72
110
|
// Create GetItem command
|
|
73
111
|
const command = new client_dynamodb_1.GetItemCommand({
|
|
74
112
|
TableName: containerId,
|
|
@@ -78,8 +116,7 @@ async function retrieve(props) {
|
|
|
78
116
|
const response = await client.send(command);
|
|
79
117
|
if (!response.Item) {
|
|
80
118
|
return {
|
|
81
|
-
engine: ENGINE
|
|
82
|
-
error: `Document with ID '${id}' not found in table '${containerId}'`
|
|
119
|
+
engine: ENGINE
|
|
83
120
|
};
|
|
84
121
|
}
|
|
85
122
|
// Unmarshall the DynamoDB item to regular object
|
|
@@ -92,23 +129,49 @@ async function retrieve(props) {
|
|
|
92
129
|
catch (error) {
|
|
93
130
|
return {
|
|
94
131
|
engine: ENGINE,
|
|
95
|
-
error:
|
|
132
|
+
error: {
|
|
133
|
+
...ERROR_INFO,
|
|
134
|
+
source: "retrieve",
|
|
135
|
+
code: "database-retrieve",
|
|
136
|
+
message: error instanceof Error ? error.message : 'Failed to retrieve document from DynamoDB'
|
|
137
|
+
}
|
|
96
138
|
};
|
|
97
139
|
}
|
|
98
140
|
}
|
|
99
141
|
async function create(props) {
|
|
100
142
|
try {
|
|
101
|
-
const { client, containerId, record } = props;
|
|
143
|
+
const { client, containerId, record, databaseId } = props;
|
|
144
|
+
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
145
|
+
engine: ENGINE,
|
|
146
|
+
...ERROR_INFO,
|
|
147
|
+
databaseId,
|
|
148
|
+
containerId,
|
|
149
|
+
checkDatabaseId: true,
|
|
150
|
+
checkContainerId: true
|
|
151
|
+
});
|
|
152
|
+
if (errorResult) {
|
|
153
|
+
return errorResult;
|
|
154
|
+
}
|
|
102
155
|
if (!containerId) {
|
|
103
156
|
return {
|
|
104
157
|
engine: ENGINE,
|
|
105
|
-
error:
|
|
158
|
+
error: {
|
|
159
|
+
...ERROR_INFO,
|
|
160
|
+
source: "create",
|
|
161
|
+
code: "require-container-id",
|
|
162
|
+
message: "The containerId (table name) is required"
|
|
163
|
+
}
|
|
106
164
|
};
|
|
107
165
|
}
|
|
108
166
|
if (!record) {
|
|
109
167
|
return {
|
|
110
168
|
engine: ENGINE,
|
|
111
|
-
error:
|
|
169
|
+
error: {
|
|
170
|
+
...ERROR_INFO,
|
|
171
|
+
source: "create",
|
|
172
|
+
code: "require-record",
|
|
173
|
+
message: "The record is required"
|
|
174
|
+
}
|
|
112
175
|
};
|
|
113
176
|
}
|
|
114
177
|
const item = {
|
|
@@ -128,28 +191,54 @@ async function create(props) {
|
|
|
128
191
|
catch (error) {
|
|
129
192
|
return {
|
|
130
193
|
engine: ENGINE,
|
|
131
|
-
error:
|
|
194
|
+
error: {
|
|
195
|
+
...ERROR_INFO,
|
|
196
|
+
source: "create",
|
|
197
|
+
code: "database-create",
|
|
198
|
+
message: error instanceof Error ? error.message : 'Failed to create record in DynamoDB'
|
|
199
|
+
}
|
|
132
200
|
};
|
|
133
201
|
}
|
|
134
202
|
}
|
|
135
203
|
/**
|
|
136
204
|
* Upsert (create or update) a document in AWS DynamoDB
|
|
137
205
|
* @param props Upsert properties with client, containerId (table name), and record
|
|
138
|
-
* @returns Promise<IUpsertResult
|
|
206
|
+
* @returns Promise<IUpsertResult>
|
|
139
207
|
*/
|
|
140
208
|
async function upsert(props) {
|
|
141
209
|
try {
|
|
142
|
-
const { client, containerId, record } = props;
|
|
210
|
+
const { client, containerId, record, databaseId } = props;
|
|
211
|
+
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
212
|
+
engine: ENGINE,
|
|
213
|
+
...ERROR_INFO,
|
|
214
|
+
databaseId,
|
|
215
|
+
containerId,
|
|
216
|
+
checkDatabaseId: true,
|
|
217
|
+
checkContainerId: true
|
|
218
|
+
});
|
|
219
|
+
if (errorResult) {
|
|
220
|
+
return errorResult;
|
|
221
|
+
}
|
|
143
222
|
if (!containerId) {
|
|
144
223
|
return {
|
|
145
224
|
engine: ENGINE,
|
|
146
|
-
error:
|
|
225
|
+
error: {
|
|
226
|
+
...ERROR_INFO,
|
|
227
|
+
source: "upsert",
|
|
228
|
+
code: "require-container-id",
|
|
229
|
+
message: "The containerId (table name) is required"
|
|
230
|
+
}
|
|
147
231
|
};
|
|
148
232
|
}
|
|
149
233
|
if (!record) {
|
|
150
234
|
return {
|
|
151
235
|
engine: ENGINE,
|
|
152
|
-
error:
|
|
236
|
+
error: {
|
|
237
|
+
...ERROR_INFO,
|
|
238
|
+
source: "upsert",
|
|
239
|
+
code: "require-record",
|
|
240
|
+
message: "The record is required"
|
|
241
|
+
}
|
|
153
242
|
};
|
|
154
243
|
}
|
|
155
244
|
// Ensure the record has an id
|
|
@@ -182,7 +271,109 @@ async function upsert(props) {
|
|
|
182
271
|
catch (error) {
|
|
183
272
|
return {
|
|
184
273
|
engine: ENGINE,
|
|
185
|
-
error:
|
|
274
|
+
error: {
|
|
275
|
+
...ERROR_INFO,
|
|
276
|
+
source: "upsert",
|
|
277
|
+
code: "database-upsert",
|
|
278
|
+
message: error instanceof Error ? error.message : 'Failed to upsert record in DynamoDB'
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async function update(props) {
|
|
284
|
+
try {
|
|
285
|
+
const { client, containerId, record } = props;
|
|
286
|
+
const errorResult = (0, util_1.validateDatabaseSetting)({
|
|
287
|
+
engine: ENGINE,
|
|
288
|
+
...ERROR_INFO,
|
|
289
|
+
containerId,
|
|
290
|
+
checkDatabaseId: true,
|
|
291
|
+
checkContainerId: true
|
|
292
|
+
});
|
|
293
|
+
if (errorResult) {
|
|
294
|
+
return errorResult;
|
|
295
|
+
}
|
|
296
|
+
if (!containerId) {
|
|
297
|
+
return {
|
|
298
|
+
engine: ENGINE,
|
|
299
|
+
error: {
|
|
300
|
+
...ERROR_INFO,
|
|
301
|
+
source: "update",
|
|
302
|
+
code: "require-container-id",
|
|
303
|
+
message: "The containerId (table name) is required"
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
if (!record) {
|
|
308
|
+
return {
|
|
309
|
+
engine: ENGINE,
|
|
310
|
+
error: {
|
|
311
|
+
...ERROR_INFO,
|
|
312
|
+
source: "update",
|
|
313
|
+
code: "require-record",
|
|
314
|
+
message: "The record is required"
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const id = record.id;
|
|
319
|
+
if (!id) {
|
|
320
|
+
return {
|
|
321
|
+
engine: ENGINE,
|
|
322
|
+
error: {
|
|
323
|
+
...ERROR_INFO,
|
|
324
|
+
source: "update",
|
|
325
|
+
code: "require-record-id",
|
|
326
|
+
message: "The record.id is required for update"
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
const entries = Object.entries(record).filter(([k]) => k !== 'id');
|
|
331
|
+
if (entries.length === 0) {
|
|
332
|
+
return {
|
|
333
|
+
engine: ENGINE,
|
|
334
|
+
error: {
|
|
335
|
+
...ERROR_INFO,
|
|
336
|
+
source: "update",
|
|
337
|
+
code: "no-update-fields",
|
|
338
|
+
message: "No fields to update"
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
const ExpressionAttributeNames = {};
|
|
343
|
+
const ExpressionAttributeValues = {};
|
|
344
|
+
const assignments = [];
|
|
345
|
+
entries.forEach(([key, value], idx) => {
|
|
346
|
+
const nameKey = `#n${idx}`;
|
|
347
|
+
const valueKey = `:v${idx}`;
|
|
348
|
+
ExpressionAttributeNames[nameKey] = key;
|
|
349
|
+
ExpressionAttributeValues[valueKey] = value;
|
|
350
|
+
assignments.push(`${nameKey} = ${valueKey}`);
|
|
351
|
+
});
|
|
352
|
+
const UpdateExpression = `SET ${assignments.join(', ')}`;
|
|
353
|
+
const command = new client_dynamodb_1.UpdateItemCommand({
|
|
354
|
+
TableName: containerId,
|
|
355
|
+
Key: (0, util_dynamodb_1.marshall)({ id }),
|
|
356
|
+
UpdateExpression,
|
|
357
|
+
ExpressionAttributeNames,
|
|
358
|
+
ExpressionAttributeValues: (0, util_dynamodb_1.marshall)(ExpressionAttributeValues),
|
|
359
|
+
ReturnValues: 'ALL_NEW'
|
|
360
|
+
});
|
|
361
|
+
const resp = await client.send(command);
|
|
362
|
+
const data = resp.Attributes ? ((0, util_dynamodb_1.unmarshall)(resp.Attributes)) : (record);
|
|
363
|
+
return {
|
|
364
|
+
engine: ENGINE,
|
|
365
|
+
data
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
return {
|
|
370
|
+
engine: ENGINE,
|
|
371
|
+
error: {
|
|
372
|
+
...ERROR_INFO,
|
|
373
|
+
source: "update",
|
|
374
|
+
code: "database-update",
|
|
375
|
+
message: error instanceof Error ? error.message : 'Failed to update record in DynamoDB'
|
|
376
|
+
}
|
|
186
377
|
};
|
|
187
378
|
}
|
|
188
379
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dynamodb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dynamodb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA0BH,0BAuEC;AAOD,4BAmDC;AAED,wBAqEC;AAOD,wBAoFC;AAED,wBA4GC;AAzaD,kCAOiB;AACjB,8DAA6G;AAC7G,0DAA8D;AAC9D,4EAA4D;AAC5D,kCAAkC;AAClC,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B,MAAM,UAAU,GAAG;IACf,OAAO,EAAE,cAAO;IAChB,MAAM,EAAE,mBAAmB;CAC9B,CAAC;AAEF;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,KAAiC;IAC3D,IAAI,C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,MAAM,CAAC,CAAC;QAExE,OAAO;YACH,MAAM,EAAE,MAAM;YACd,IAAI;SACP,CAAC;IAEN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM,EAAE,MAAM;YACd,KAAK,EAAE;gBACH,GAAG,UAAU;gBACb,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAqC;aAC1F;SACJ,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview GCP Firestore implementation
|
|
3
3
|
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveProps, ICreateProps, ICreateResult, IUpsertProps, IUpsertResult } from '../util';
|
|
4
|
+
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveProps, ICreateProps, ICreateResult, IUpsertProps, IUpsertResult, IUpdateProps, IUpdateResult } from '../util';
|
|
5
5
|
export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
|
|
6
|
-
export declare function retrieve
|
|
7
|
-
export declare function create
|
|
8
|
-
export declare function upsert
|
|
6
|
+
export declare function retrieve(props: IRetrieveProps): Promise<IRetrieveResult>;
|
|
7
|
+
export declare function create(props: ICreateProps): Promise<ICreateResult>;
|
|
8
|
+
export declare function upsert(props: IUpsertProps): Promise<IUpsertResult>;
|
|
9
|
+
export declare function update(props: IUpdateProps): Promise<IUpdateResult>;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|