quidproquo-actionprocessor-awslambda 0.0.159 → 0.0.161

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.
@@ -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 { 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.159",
3
+ "version": "0.0.161",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "types": "./lib/commonjs/index.d.js",