quidproquo-actionprocessor-awslambda 0.0.160 → 0.0.162

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.
@@ -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, nextPageKey }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ return ({ keyValueStoreName, keyCondition, options }) => __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, nextPageKey, (0, qpqDynamoOrm_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition));
25
+ const items = yield (0, dynamo_1.query)(dynamoTableName, region, keyCondition, options === null || options === void 0 ? void 0 : options.filter, options === null || options === void 0 ? void 0 : options.nextPageKey, (0, qpqDynamoOrm_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition), options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.sortAscending);
26
26
  return (0, quidproquo_core_2.actionResult)(items);
27
27
  });
28
28
  };
@@ -17,8 +17,9 @@ const getProcessKeyValueStoreUpdate = (qpqConfig) => {
17
17
  return ({ keyValueStoreName, key, sortKey, updates, options }) => __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
- yield (0, dynamo_1.updateItem)(dynamoTableName, region, updates, key, sortKey);
21
- return (0, quidproquo_core_2.actionResult)(void 0);
20
+ const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
21
+ const item = yield (0, dynamo_1.updateItem)(dynamoTableName, region, updates, storeConfig.partitionKey.key, key, sortKey);
22
+ return (0, quidproquo_core_2.actionResult)(item);
22
23
  });
23
24
  };
24
25
  exports.default = (qpqConfig) => ({
@@ -1,2 +1,2 @@
1
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>>;
2
+ export declare function query<Item>(tableName: string, region: string, keyExpression: KvsQueryOperation, filterExpression?: KvsQueryOperation, pageKey?: string, indexName?: string, limit?: number, sortAscending?: boolean): Promise<QpqPagedData<Item>>;
@@ -16,7 +16,7 @@ const logs_1 = require("./logs");
16
16
  const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
17
17
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
18
18
  const createAwsClient_1 = require("../createAwsClient");
19
- function query(tableName, region, keyExpression, filterExpression, pageKey, indexName) {
19
+ function query(tableName, region, keyExpression, filterExpression, pageKey, indexName, limit, sortAscending) {
20
20
  var _a;
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  // Instantiate DynamoDB client
@@ -28,6 +28,8 @@ function query(tableName, region, keyExpression, filterExpression, pageKey, inde
28
28
  ExpressionAttributeValues: (0, qpqDynamoOrm_1.buildExpressionAttributeValues)([keyExpression, filterExpression]),
29
29
  ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([keyExpression, filterExpression]),
30
30
  IndexName: indexName,
31
+ Limit: limit,
32
+ ScanIndexForward: sortAscending,
31
33
  };
32
34
  if (pageKey) {
33
35
  params.ExclusiveStartKey = (0, logs_1.stringToLastEvaluatedKey)(pageKey);
@@ -1,2 +1,2 @@
1
1
  import { KvsUpdate, KvsCoreDataType } from 'quidproquo-core';
2
- export declare function updateItem(tableName: string, region: string, update: KvsUpdate, key: KvsCoreDataType, sortKey?: KvsCoreDataType): Promise<void>;
2
+ export declare function updateItem<Item>(tableName: string, region: string, update: KvsUpdate, keyName: string, key: KvsCoreDataType, sortKey?: KvsCoreDataType): Promise<Item>;
@@ -13,22 +13,25 @@ exports.updateItem = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
15
15
  const createAwsClient_1 = require("../createAwsClient");
16
- function updateItem(tableName, region, update, key, sortKey) {
16
+ const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
17
+ function updateItem(tableName, region, update, keyName, key, sortKey) {
17
18
  return __awaiter(this, void 0, void 0, function* () {
18
19
  const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
19
20
  const params = {
20
21
  TableName: tableName,
21
22
  Key: {
22
- id: (0, qpqDynamoOrm_1.buildAttributeValue)(key),
23
+ [keyName]: (0, qpqDynamoOrm_1.buildAttributeValue)(key),
23
24
  },
24
25
  UpdateExpression: (0, qpqDynamoOrm_1.buildDynamoUpdateExpression)(update),
25
26
  ExpressionAttributeValues: (0, qpqDynamoOrm_1.buildUpdateExpressionAttributeValues)(update),
26
27
  ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildUpdateExpressionAttributeNames)(update),
28
+ ReturnValues: client_dynamodb_1.ReturnValue.ALL_NEW,
27
29
  };
28
30
  if (sortKey) {
29
31
  params.Key['sk'] = (0, qpqDynamoOrm_1.buildAttributeValue)(sortKey);
30
32
  }
31
- console.log(yield dynamoDBClient.send(new client_dynamodb_1.UpdateItemCommand(params)));
33
+ const result = yield dynamoDBClient.send(new client_dynamodb_1.UpdateItemCommand(params));
34
+ return (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(result.Attributes);
32
35
  });
33
36
  }
34
37
  exports.updateItem = updateItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.160",
3
+ "version": "0.0.162",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "types": "./lib/commonjs/index.d.js",