@pi-r/aws 0.9.4 → 0.10.0
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/client/index.js +22 -11
- package/package.json +5 -5
- package/types/index.d.ts +2 -1
package/client/index.js
CHANGED
|
@@ -112,7 +112,7 @@ function createDatabaseClient(credential) {
|
|
|
112
112
|
let options;
|
|
113
113
|
if (fromPath) {
|
|
114
114
|
try {
|
|
115
|
-
options = JSON.parse(this.readFile(fromPath, { encoding: '
|
|
115
|
+
options = JSON.parse(this.readFile(fromPath, { encoding: 'utf8', ownPermissionOnly: true, cache: false }));
|
|
116
116
|
}
|
|
117
117
|
catch {
|
|
118
118
|
}
|
|
@@ -354,21 +354,32 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
354
354
|
rows = Responses[TableName];
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
else if (TableName) {
|
|
358
|
-
|
|
359
|
-
if (
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
357
|
+
else if (TableName || item.params) {
|
|
358
|
+
const params = (item.params || {});
|
|
359
|
+
if (!params.TransactItems) {
|
|
360
|
+
if (TableName) {
|
|
361
|
+
params.TableName = TableName;
|
|
362
|
+
}
|
|
363
|
+
else if (!params.TableName) {
|
|
364
|
+
throw (0, util_1.formatError)(item, "Missing database table");
|
|
365
|
+
}
|
|
364
366
|
}
|
|
365
367
|
if (useCache && (rows = this.getCacheResult(service, credential, queryString = Cloud.asString(params, true), cacheValue, ignoreCache))) {
|
|
366
368
|
result[i] = rows;
|
|
367
369
|
continue;
|
|
368
370
|
}
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
|
|
371
|
+
const db = createClient();
|
|
372
|
+
if (params.TransactItems) {
|
|
373
|
+
const { Responses } = await db.transactGet(params).promise();
|
|
374
|
+
if (Responses) {
|
|
375
|
+
rows = Responses.map(value => value.Item || {});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
const { Count, Items } = await db.scan(params).promise();
|
|
380
|
+
if (Count && Items) {
|
|
381
|
+
rows = Items;
|
|
382
|
+
}
|
|
372
383
|
}
|
|
373
384
|
}
|
|
374
385
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/aws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "AWS V2 cloud functions for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.
|
|
24
|
-
"@e-mc/module": "^0.
|
|
25
|
-
"@e-mc/types": "^0.
|
|
26
|
-
"@pi-r/aws-lib": "^0.
|
|
23
|
+
"@e-mc/cloud": "^0.12.0",
|
|
24
|
+
"@e-mc/module": "^0.12.0",
|
|
25
|
+
"@e-mc/types": "^0.12.0",
|
|
26
|
+
"@pi-r/aws-lib": "^0.10.0",
|
|
27
27
|
"aws-sdk": "^2.1692.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type QueryInput = DocumentClient.QueryInput;
|
|
|
11
11
|
export type UpdateItemInput = DocumentClient.UpdateItemInput;
|
|
12
12
|
export type ScanInput = DocumentClient.ScanInput;
|
|
13
13
|
export type BatchGetItemInput = DocumentClient.BatchGetItemInput;
|
|
14
|
+
export type TransactGetItemsInput = DocumentClient.TransactGetItemsInput;
|
|
14
15
|
export type DynamoDBClientConfig = Types.ClientConfiguration & DocumentClient.DocumentClientOptions;
|
|
15
16
|
|
|
16
17
|
export type AWSStorage = CloudStorage<AWSStorageCredential, "aws">;
|
|
@@ -20,7 +21,7 @@ export interface AWSStorageCredential extends ConfigurationOptions {
|
|
|
20
21
|
fromPath?: string;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export interface AWSDatabaseQuery extends CloudDatabase<QueryInput | Key[], Record<string, unknown>, UpdateItemInput, BatchGetItemInput | ScanInput, AWSDatabaseCredential> {
|
|
24
|
+
export interface AWSDatabaseQuery extends CloudDatabase<QueryInput | Key[], Record<string, unknown>, UpdateItemInput, BatchGetItemInput | ScanInput | TransactGetItemsInput, AWSDatabaseCredential> {
|
|
24
25
|
source: "cloud";
|
|
25
26
|
service: "aws";
|
|
26
27
|
key?: string | Key;
|