quidproquo-actionprocessor-awslambda 0.0.116 → 0.0.117
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/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js +2 -2
- package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.js +2 -2
- package/lib/logic/dynamo/logs/utils/stringToLastEvaluatedKey.d.ts +2 -1
- package/lib/logic/dynamo/query.d.ts +2 -2
- package/lib/logic/dynamo/query.js +7 -4
- package/lib/logic/dynamo/scan.d.ts +2 -2
- package/lib/logic/dynamo/scan.js +7 -3
- package/lib/logic/dynamo/utils/itemsToQpqPagedData.d.ts +2 -0
- package/lib/logic/dynamo/utils/itemsToQpqPagedData.js +9 -0
- package/lib/logic/dynamo/utils/qpqPagedDataToItems.d.ts +4 -0
- package/lib/logic/dynamo/utils/qpqPagedDataToItems.js +9 -0
- package/package.json +1 -1
|
@@ -15,14 +15,14 @@ const quidproquo_core_2 = require("quidproquo-core");
|
|
|
15
15
|
const dynamo_1 = require("../../../logic/dynamo");
|
|
16
16
|
const qpqDynamoOrm_1 = require("../../../logic/dynamo/qpqDynamoOrm");
|
|
17
17
|
const getProcessKeyValueStoreQuery = (qpqConfig) => {
|
|
18
|
-
return ({ keyValueStoreName, keyCondition, filterCondition }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
return ({ keyValueStoreName, keyCondition, filterCondition, nextPageKey }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
const dynamoTableName = (0, awsNamingUtils_1.getKvsDynamoTableNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
|
|
20
20
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
21
21
|
const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
|
|
22
22
|
if (!storeConfig) {
|
|
23
23
|
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Could not find key value store with name "${keyValueStoreName}"`);
|
|
24
24
|
}
|
|
25
|
-
const items = yield (0, dynamo_1.query)(dynamoTableName, region, keyCondition, filterCondition, (0, qpqDynamoOrm_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition));
|
|
25
|
+
const items = yield (0, dynamo_1.query)(dynamoTableName, region, keyCondition, filterCondition, nextPageKey, (0, qpqDynamoOrm_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition));
|
|
26
26
|
return (0, quidproquo_core_2.actionResult)(items);
|
|
27
27
|
});
|
|
28
28
|
};
|
|
@@ -14,10 +14,10 @@ const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
|
14
14
|
const quidproquo_core_2 = require("quidproquo-core");
|
|
15
15
|
const scan_1 = require("../../../logic/dynamo/scan");
|
|
16
16
|
const getProcessKeyValueStoreScan = (qpqConfig) => {
|
|
17
|
-
return ({ keyValueStoreName, filterCondition }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return ({ keyValueStoreName, filterCondition, nextPageKey }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const dynamoTableName = (0, awsNamingUtils_1.getKvsDynamoTableNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
|
|
19
19
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
20
|
-
const items = yield (0, scan_1.scan)(dynamoTableName, region, filterCondition);
|
|
20
|
+
const items = yield (0, scan_1.scan)(dynamoTableName, region, filterCondition, nextPageKey);
|
|
21
21
|
return (0, quidproquo_core_2.actionResult)(items);
|
|
22
22
|
});
|
|
23
23
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { AttributeValue } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
export declare function stringToLastEvaluatedKey(encodedKey: string): Record<string, AttributeValue>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KvsQueryOperation } from 'quidproquo-core';
|
|
2
|
-
export declare function query<Item>(tableName: string, region: string, keyExpression: KvsQueryOperation, filterExpression?: KvsQueryOperation, indexName?: string): Promise<Item
|
|
1
|
+
import { KvsQueryOperation, QpqPagedData } from 'quidproquo-core';
|
|
2
|
+
export declare function query<Item>(tableName: string, region: string, keyExpression: KvsQueryOperation, filterExpression?: KvsQueryOperation, pageKey?: string, indexName?: string): Promise<QpqPagedData<Item>>;
|
|
@@ -12,8 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.query = void 0;
|
|
13
13
|
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
14
14
|
const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
|
|
15
|
+
const logs_1 = require("./logs");
|
|
16
|
+
const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
|
|
15
17
|
const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
|
|
16
|
-
function query(tableName, region, keyExpression, filterExpression, indexName) {
|
|
18
|
+
function query(tableName, region, keyExpression, filterExpression, pageKey, indexName) {
|
|
17
19
|
var _a;
|
|
18
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
21
|
// Instantiate DynamoDB client
|
|
@@ -26,13 +28,14 @@ function query(tableName, region, keyExpression, filterExpression, indexName) {
|
|
|
26
28
|
ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([keyExpression, filterExpression]),
|
|
27
29
|
IndexName: indexName,
|
|
28
30
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (pageKey) {
|
|
32
|
+
params.ExclusiveStartKey = (0, logs_1.stringToLastEvaluatedKey)(pageKey);
|
|
33
|
+
}
|
|
31
34
|
// Create QueryCommand
|
|
32
35
|
const command = new client_dynamodb_1.QueryCommand(params);
|
|
33
36
|
// TODO: Catch errors and throw QPQ ones
|
|
34
37
|
const data = yield dynamoClient.send(command);
|
|
35
|
-
return (((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []);
|
|
38
|
+
return (0, itemsToQpqPagedData_1.itemsToQpqPagedData)((((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []), data.LastEvaluatedKey);
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
exports.query = query;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KvsQueryOperation } from 'quidproquo-core';
|
|
2
|
-
export declare function scan<Item>(tableName: string, region: string, filterExpression?: KvsQueryOperation): Promise<Item
|
|
1
|
+
import { KvsQueryOperation, QpqPagedData } from 'quidproquo-core';
|
|
2
|
+
export declare function scan<Item>(tableName: string, region: string, filterExpression?: KvsQueryOperation, pageKey?: string): Promise<QpqPagedData<Item>>;
|
package/lib/logic/dynamo/scan.js
CHANGED
|
@@ -12,8 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.scan = void 0;
|
|
13
13
|
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
14
14
|
const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
|
|
15
|
+
const logs_1 = require("./logs");
|
|
16
|
+
const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
|
|
15
17
|
const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
|
|
16
|
-
function scan(tableName, region, filterExpression) {
|
|
18
|
+
function scan(tableName, region, filterExpression, pageKey) {
|
|
17
19
|
var _a;
|
|
18
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
21
|
// Instantiate DynamoDB client
|
|
@@ -24,12 +26,14 @@ function scan(tableName, region, filterExpression) {
|
|
|
24
26
|
ExpressionAttributeValues: (0, qpqDynamoOrm_1.buildExpressionAttributeValues)([filterExpression]),
|
|
25
27
|
ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([filterExpression]),
|
|
26
28
|
};
|
|
27
|
-
|
|
29
|
+
if (pageKey) {
|
|
30
|
+
params.ExclusiveStartKey = (0, logs_1.stringToLastEvaluatedKey)(pageKey);
|
|
31
|
+
}
|
|
28
32
|
// Create ScanCommand
|
|
29
33
|
const command = new client_dynamodb_1.ScanCommand(params);
|
|
30
34
|
// TODO: Catch errors and throw QPQ ones
|
|
31
35
|
const data = yield dynamoClient.send(command);
|
|
32
|
-
return (((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []);
|
|
36
|
+
return (0, itemsToQpqPagedData_1.itemsToQpqPagedData)((((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []), data.LastEvaluatedKey);
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
exports.scan = scan;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemsToQpqPagedData = void 0;
|
|
4
|
+
const logs_1 = require("../logs");
|
|
5
|
+
const itemsToQpqPagedData = (items, lastEvaluatedKey) => ({
|
|
6
|
+
items,
|
|
7
|
+
nextPageKey: lastEvaluatedKey ? (0, logs_1.lastEvaluatedKeyToString)(lastEvaluatedKey) : undefined,
|
|
8
|
+
});
|
|
9
|
+
exports.itemsToQpqPagedData = itemsToQpqPagedData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemsToQpqPagedData = void 0;
|
|
4
|
+
const logs_1 = require("../logs");
|
|
5
|
+
const itemsToQpqPagedData = (items, lastEvaluatedKey) => ({
|
|
6
|
+
items,
|
|
7
|
+
lastEvaluatedKey: lastEvaluatedKey && (0, logs_1.stringToLastEvaluatedKey)(lastEvaluatedKey),
|
|
8
|
+
});
|
|
9
|
+
exports.itemsToQpqPagedData = itemsToQpqPagedData;
|