quidproquo-actionprocessor-awslambda 0.0.213 → 0.0.215

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,10 +15,11 @@ const quidproquo_core_2 = require("quidproquo-core");
15
15
  const dynamo_1 = require("../../../logic/dynamo");
16
16
  const getProcessKeyValueStoreUpdate = (qpqConfig) => {
17
17
  return ({ keyValueStoreName, key, sortKey, updates, options }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ var _a;
18
19
  const dynamoTableName = (0, awsNamingUtils_1.getKvsDynamoTableNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
19
20
  const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
20
21
  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
+ const item = yield (0, dynamo_1.updateItem)(dynamoTableName, region, updates, storeConfig.partitionKey.key, key, (_a = storeConfig.sortKeys[0]) === null || _a === void 0 ? void 0 : _a.key, sortKey);
22
23
  return (0, quidproquo_core_2.actionResult)(item);
23
24
  });
24
25
  };
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const quidproquo_core_1 = require("quidproquo-core");
13
13
  const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
14
  const dynamo_1 = require("../../../logic/dynamo");
15
+ const src_1 = require("quidproquo-core/src");
15
16
  const getProcessKeyValueStoreUpsert = (qpqConfig) => {
16
17
  return ({ keyValueStoreName, item, options }) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  const dynamoTableName = (0, awsNamingUtils_1.getKvsDynamoTableNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
@@ -26,10 +27,17 @@ const getProcessKeyValueStoreUpsert = (qpqConfig) => {
26
27
  ...storeConfig.indexes.map((i) => i.partitionKey),
27
28
  ...storeConfig.indexes.filter((i) => !!i.sortKey).map((i) => i.sortKey),
28
29
  ];
29
- yield (0, dynamo_1.putItem)(dynamoTableName, item, keys, {
30
- expires: options === null || options === void 0 ? void 0 : options.ttlInSeconds,
31
- }, region);
32
- return (0, quidproquo_core_1.actionResult)(void 0);
30
+ try {
31
+ yield (0, dynamo_1.putItem)(dynamoTableName, item, keys, {
32
+ expires: options === null || options === void 0 ? void 0 : options.ttlInSeconds,
33
+ }, region);
34
+ return (0, quidproquo_core_1.actionResult)(void 0);
35
+ }
36
+ catch (error) {
37
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
38
+ InternalServerError: () => (0, quidproquo_core_1.actionResultError)(src_1.KeyValueStoreUpsertErrorTypeEnum.ServiceUnavailable, 'KVS Service Unavailable'),
39
+ });
40
+ }
33
41
  });
34
42
  };
35
43
  exports.default = (qpqConfig) => ({
@@ -1,2 +1,2 @@
1
1
  import { KvsUpdate, KvsCoreDataType } from 'quidproquo-core';
2
- export declare function updateItem<Item>(tableName: string, region: string, update: KvsUpdate, keyName: string, key: KvsCoreDataType, sortKey?: KvsCoreDataType): Promise<Item>;
2
+ export declare function updateItem<Item>(tableName: string, region: string, update: KvsUpdate, keyName: string, key: KvsCoreDataType, sortkeyName?: string, sortKey?: KvsCoreDataType): Promise<Item>;
@@ -14,7 +14,7 @@ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
15
15
  const createAwsClient_1 = require("../createAwsClient");
16
16
  const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
17
- function updateItem(tableName, region, update, keyName, key, sortKey) {
17
+ function updateItem(tableName, region, update, keyName, key, sortkeyName, sortKey) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
20
20
  const params = {
@@ -27,8 +27,8 @@ function updateItem(tableName, region, update, keyName, key, sortKey) {
27
27
  ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildUpdateExpressionAttributeNames)(update),
28
28
  ReturnValues: client_dynamodb_1.ReturnValue.ALL_NEW,
29
29
  };
30
- if (sortKey) {
31
- params.Key['sk'] = (0, qpqDynamoOrm_1.buildAttributeValue)(sortKey);
30
+ if (sortkeyName && sortKey !== undefined) {
31
+ params.Key[sortkeyName] = (0, qpqDynamoOrm_1.buildAttributeValue)(sortKey);
32
32
  }
33
33
  const result = yield dynamoDBClient.send(new client_dynamodb_1.UpdateItemCommand(params));
34
34
  return (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(result.Attributes);
@@ -1,13 +1,13 @@
1
1
  import { qpqCoreUtils } from 'quidproquo-core';
2
2
  import { getKvsDynamoTableNameFromConfig } from '../../../awsNamingUtils';
3
- import { actionResult, KeyValueStoreActionType, } from 'quidproquo-core';
3
+ import { actionResult, KeyValueStoreActionType } from 'quidproquo-core';
4
4
  import { updateItem } from '../../../logic/dynamo';
5
5
  const getProcessKeyValueStoreUpdate = (qpqConfig) => {
6
6
  return async ({ keyValueStoreName, key, sortKey, updates, options }) => {
7
7
  const dynamoTableName = getKvsDynamoTableNameFromConfig(keyValueStoreName, qpqConfig, 'kvs');
8
8
  const region = qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
9
9
  const storeConfig = qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
10
- const item = await updateItem(dynamoTableName, region, updates, storeConfig.partitionKey.key, key, sortKey);
10
+ const item = await updateItem(dynamoTableName, region, updates, storeConfig.partitionKey.key, key, storeConfig.sortKeys[0]?.key, sortKey);
11
11
  return actionResult(item);
12
12
  };
13
13
  };
@@ -1,6 +1,7 @@
1
- import { qpqCoreUtils, actionResult, KeyValueStoreActionType, ErrorTypeEnum, actionResultError, } from 'quidproquo-core';
1
+ import { qpqCoreUtils, actionResult, KeyValueStoreActionType, ErrorTypeEnum, actionResultError, actionResultErrorFromCaughtError, } from 'quidproquo-core';
2
2
  import { getKvsDynamoTableNameFromConfig } from '../../../awsNamingUtils';
3
3
  import { putItem } from '../../../logic/dynamo';
4
+ import { KeyValueStoreUpsertErrorTypeEnum } from 'quidproquo-core/src';
4
5
  const getProcessKeyValueStoreUpsert = (qpqConfig) => {
5
6
  return async ({ keyValueStoreName, item, options }) => {
6
7
  const dynamoTableName = getKvsDynamoTableNameFromConfig(keyValueStoreName, qpqConfig, 'kvs');
@@ -15,10 +16,17 @@ const getProcessKeyValueStoreUpsert = (qpqConfig) => {
15
16
  ...storeConfig.indexes.map((i) => i.partitionKey),
16
17
  ...storeConfig.indexes.filter((i) => !!i.sortKey).map((i) => i.sortKey),
17
18
  ];
18
- await putItem(dynamoTableName, item, keys, {
19
- expires: options?.ttlInSeconds,
20
- }, region);
21
- return actionResult(void 0);
19
+ try {
20
+ await putItem(dynamoTableName, item, keys, {
21
+ expires: options?.ttlInSeconds,
22
+ }, region);
23
+ return actionResult(void 0);
24
+ }
25
+ catch (error) {
26
+ return actionResultErrorFromCaughtError(error, {
27
+ InternalServerError: () => actionResultError(KeyValueStoreUpsertErrorTypeEnum.ServiceUnavailable, 'KVS Service Unavailable'),
28
+ });
29
+ }
22
30
  };
23
31
  };
24
32
  export default (qpqConfig) => ({
@@ -1,2 +1,2 @@
1
1
  import { KvsUpdate, KvsCoreDataType } from 'quidproquo-core';
2
- export declare function updateItem<Item>(tableName: string, region: string, update: KvsUpdate, keyName: string, key: KvsCoreDataType, sortKey?: KvsCoreDataType): Promise<Item>;
2
+ export declare function updateItem<Item>(tableName: string, region: string, update: KvsUpdate, keyName: string, key: KvsCoreDataType, sortkeyName?: string, sortKey?: KvsCoreDataType): Promise<Item>;
@@ -1,8 +1,8 @@
1
- import { DynamoDBClient, ReturnValue, UpdateItemCommand, } from '@aws-sdk/client-dynamodb';
1
+ import { DynamoDBClient, ReturnValue, UpdateItemCommand } from '@aws-sdk/client-dynamodb';
2
2
  import { buildAttributeValue, buildDynamoUpdateExpression, buildUpdateExpressionAttributeNames, buildUpdateExpressionAttributeValues, } from './qpqDynamoOrm';
3
3
  import { createAwsClient } from '../createAwsClient';
4
4
  import { convertDynamoMapToObject } from './convertObjectToDynamoMap';
5
- export async function updateItem(tableName, region, update, keyName, key, sortKey) {
5
+ export async function updateItem(tableName, region, update, keyName, key, sortkeyName, sortKey) {
6
6
  const dynamoDBClient = createAwsClient(DynamoDBClient, { region });
7
7
  const params = {
8
8
  TableName: tableName,
@@ -14,8 +14,8 @@ export async function updateItem(tableName, region, update, keyName, key, sortKe
14
14
  ExpressionAttributeNames: buildUpdateExpressionAttributeNames(update),
15
15
  ReturnValues: ReturnValue.ALL_NEW,
16
16
  };
17
- if (sortKey) {
18
- params.Key['sk'] = buildAttributeValue(sortKey);
17
+ if (sortkeyName && sortKey !== undefined) {
18
+ params.Key[sortkeyName] = buildAttributeValue(sortKey);
19
19
  }
20
20
  const result = await dynamoDBClient.send(new UpdateItemCommand(params));
21
21
  return convertDynamoMapToObject(result.Attributes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.213",
3
+ "version": "0.0.215",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -51,9 +51,9 @@
51
51
  "lodash": "^4.17.21",
52
52
  "node-cache": "^5.1.2",
53
53
  "node-match-path": "^0.6.3",
54
- "quidproquo-config-aws": "0.0.213",
55
- "quidproquo-core": "0.0.213",
56
- "quidproquo-webserver": "0.0.213"
54
+ "quidproquo-config-aws": "0.0.215",
55
+ "quidproquo-core": "0.0.215",
56
+ "quidproquo-webserver": "0.0.215"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/aws-lambda": "^8.10.109",
@@ -61,7 +61,7 @@
61
61
  "@types/jsonwebtoken": "^9.0.2",
62
62
  "@types/lodash": "^4.14.194",
63
63
  "@types/node": "^18.11.9",
64
- "quidproquo-tsconfig": "0.0.213",
64
+ "quidproquo-tsconfig": "0.0.215",
65
65
  "typescript": "^4.9.3"
66
66
  }
67
67
  }