quidproquo-actionprocessor-awslambda 0.0.139 → 0.0.141

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.
Files changed (56) hide show
  1. package/lib/commonjs/awsLambdaUtils.d.ts +3 -0
  2. package/lib/commonjs/awsLambdaUtils.js +23 -1
  3. package/lib/commonjs/awsNamingUtils.d.ts +1 -1
  4. package/lib/commonjs/awsNamingUtils.js +2 -4
  5. package/lib/commonjs/getActionProcessor/core/eventBus/getQueueSendMessageActionProcessor.js +7 -2
  6. package/lib/commonjs/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js +1 -2
  7. package/lib/commonjs/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js +3 -2
  8. package/lib/commonjs/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js +3 -2
  9. package/lib/commonjs/getActionProcessor/core/file/utils/resolveStorageDriveBucketName.d.ts +2 -3
  10. package/lib/commonjs/getActionProcessor/core/file/utils/resolveStorageDriveBucketName.js +8 -12
  11. package/lib/commonjs/logic/apiGateway/getApiKeys.js +2 -1
  12. package/lib/commonjs/logic/cloudFront/invalidateCache.js +3 -2
  13. package/lib/commonjs/logic/cloudformation/getExportedValue.js +2 -1
  14. package/lib/commonjs/logic/cognito/authenticateUser.js +2 -1
  15. package/lib/commonjs/logic/cognito/changePassword.js +2 -1
  16. package/lib/commonjs/logic/cognito/confirmForgotPassword.js +2 -1
  17. package/lib/commonjs/logic/cognito/createUser.js +2 -1
  18. package/lib/commonjs/logic/cognito/forgotPassword.js +2 -1
  19. package/lib/commonjs/logic/cognito/getUser.js +2 -1
  20. package/lib/commonjs/logic/cognito/getUserAttributes.js +2 -1
  21. package/lib/commonjs/logic/cognito/getUserAttributesBySub.js +2 -1
  22. package/lib/commonjs/logic/cognito/getUserPoolClientSecret.js +2 -1
  23. package/lib/commonjs/logic/cognito/listPagedUsers.js +2 -1
  24. package/lib/commonjs/logic/cognito/refreshToken.js +2 -1
  25. package/lib/commonjs/logic/cognito/requestEmailVerificationCode.js +2 -1
  26. package/lib/commonjs/logic/cognito/respondToAuthChallengeChallenge.js +2 -1
  27. package/lib/commonjs/logic/cognito/setUserAttributes.js +2 -1
  28. package/lib/commonjs/logic/cognito/setUserPassword.js +2 -1
  29. package/lib/commonjs/logic/cognito/verifyUserEmail.js +2 -1
  30. package/lib/commonjs/logic/dynamo/deleteItem.js +3 -2
  31. package/lib/commonjs/logic/dynamo/getAllItems.js +2 -1
  32. package/lib/commonjs/logic/dynamo/getItem.js +2 -1
  33. package/lib/commonjs/logic/dynamo/getLogByCorrelation.js +2 -1
  34. package/lib/commonjs/logic/dynamo/getLogChildrenByFromCorrelation.js +2 -1
  35. package/lib/commonjs/logic/dynamo/getPagedItemsOverRange.js +2 -1
  36. package/lib/commonjs/logic/dynamo/putItem.js +3 -2
  37. package/lib/commonjs/logic/dynamo/query.js +3 -2
  38. package/lib/commonjs/logic/dynamo/scan.js +3 -2
  39. package/lib/commonjs/logic/dynamo/updateItem.js +3 -2
  40. package/lib/commonjs/logic/lambda/executeLambdaByName.js +3 -2
  41. package/lib/commonjs/logic/parametersManager/getParameter.js +3 -4
  42. package/lib/commonjs/logic/parametersManager/getParameters.js +3 -2
  43. package/lib/commonjs/logic/parametersManager/setParameter.js +3 -4
  44. package/lib/commonjs/logic/s3/deleteFiles.js +2 -1
  45. package/lib/commonjs/logic/s3/listFiles.js +2 -1
  46. package/lib/commonjs/logic/s3/objectExists.js +2 -1
  47. package/lib/commonjs/logic/s3/readBinaryFile.js +2 -1
  48. package/lib/commonjs/logic/s3/readTextFile.js +2 -1
  49. package/lib/commonjs/logic/s3/writeBinaryFile.d.ts +2 -1
  50. package/lib/commonjs/logic/s3/writeBinaryFile.js +4 -2
  51. package/lib/commonjs/logic/s3/writeTextFile.d.ts +2 -1
  52. package/lib/commonjs/logic/s3/writeTextFile.js +4 -2
  53. package/lib/commonjs/logic/secretsManager/getSecret.js +3 -4
  54. package/lib/commonjs/logic/sns/publishMessage.js +1 -3
  55. package/lib/commonjs/logic/sqs/sendMessages.js +1 -3
  56. package/package.json +1 -1
@@ -1,6 +1,9 @@
1
+ import { StorageClass } from '@aws-sdk/client-s3';
2
+ import { StorageDriveTier } from 'quidproquo-core';
1
3
  export declare const randomGuid: () => `${string}-${string}-${string}-${string}-${string}`;
2
4
  export interface UrlMatch {
3
5
  didMatch: boolean;
4
6
  params: Record<string, string> | null;
5
7
  }
6
8
  export declare const matchUrl: (path: string, url: string) => UrlMatch;
9
+ export declare const getS3BucketStorageClassFromStorageDriveTier: (driveTier?: StorageDriveTier) => keyof typeof StorageClass;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.matchUrl = exports.randomGuid = void 0;
3
+ exports.getS3BucketStorageClassFromStorageDriveTier = exports.matchUrl = exports.randomGuid = void 0;
4
4
  const crypto_1 = require("crypto");
5
5
  const node_match_path_1 = require("node-match-path");
6
+ const quidproquo_core_1 = require("quidproquo-core");
6
7
  const randomGuid = () => {
7
8
  return (0, crypto_1.randomUUID)();
8
9
  };
@@ -17,3 +18,24 @@ const matchUrl = (path, url) => {
17
18
  };
18
19
  };
19
20
  exports.matchUrl = matchUrl;
21
+ const getS3BucketStorageClassFromStorageDriveTier = (driveTier) => {
22
+ switch (driveTier) {
23
+ case quidproquo_core_1.StorageDriveTier.REGULAR:
24
+ return "STANDARD";
25
+ case quidproquo_core_1.StorageDriveTier.OCCASIONAL_ACCESS:
26
+ return "STANDARD_IA";
27
+ case quidproquo_core_1.StorageDriveTier.SINGLE_ZONE_OCCASIONAL_ACCESS:
28
+ return "ONEZONE_IA";
29
+ case quidproquo_core_1.StorageDriveTier.COLD_STORAGE:
30
+ return "GLACIER";
31
+ case quidproquo_core_1.StorageDriveTier.COLD_STORAGE_INSTANT_ACCESS:
32
+ return "GLACIER_IR";
33
+ case quidproquo_core_1.StorageDriveTier.DEEP_COLD_STORAGE:
34
+ return "DEEP_ARCHIVE";
35
+ case quidproquo_core_1.StorageDriveTier.SMART_TIERING:
36
+ return "INTELLIGENT_TIERING";
37
+ default:
38
+ return "INTELLIGENT_TIERING";
39
+ }
40
+ };
41
+ exports.getS3BucketStorageClassFromStorageDriveTier = getS3BucketStorageClassFromStorageDriveTier;
@@ -6,7 +6,7 @@ export declare const getConfigRuntimeResourceNameFromConfig: (resourceName: stri
6
6
  export declare const getConfigRuntimeResourceNameFromConfigWithServiceOverride: (resourceName: string, qpqConfig: QPQConfig, serviceOverride?: string) => string;
7
7
  export declare const getQpqRuntimeResourceName: (resourceName: string, application: string, service: string, environment: string, feature?: string, resourceType?: string) => string;
8
8
  export declare const getQpqRuntimeResourceNameFromConfig: (resourceName: ResourceName, qpqConfig: QPQConfig, resourceType?: string) => string;
9
- export declare const getKvsDynamoTableNameFromConfig: (resourceName: ResourceName, qpqConfig: QPQConfig, resourceType?: string) => string;
9
+ export declare const getKvsDynamoTableNameFromConfig: (resourceName: string, qpqConfig: QPQConfig, resourceType?: string) => string;
10
10
  export declare const getCFExportNameUserPoolIdFromConfig: (userDirectoryName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
11
11
  export declare const getCFExportNameUserPoolClientIdFromConfig: (userDirectoryName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
12
12
  export declare const getCFExportNameApiKeyIdFromConfig: (apiKeyName: string, qpqConfig: QPQConfig, serviceOverride?: string, applicationOverride?: string) => string;
@@ -57,14 +57,12 @@ exports.getQpqRuntimeResourceNameFromConfig = getQpqRuntimeResourceNameFromConfi
57
57
  const getKvsDynamoTableNameFromConfig = (resourceName, qpqConfig, resourceType = '') => {
58
58
  var _a;
59
59
  const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, resourceName);
60
- const crossServiceResourceName = quidproquo_core_1.qpqCoreUtils.resolveCrossServiceResourceName(resourceName);
61
60
  const application = quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
62
- const service = crossServiceResourceName.service ||
63
- ((_a = storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.owner) === null || _a === void 0 ? void 0 : _a.module) ||
61
+ const service = ((_a = storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.owner) === null || _a === void 0 ? void 0 : _a.module) ||
64
62
  quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
65
63
  const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
66
64
  const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
67
- return (0, exports.getQpqRuntimeResourceName)(crossServiceResourceName.name, application, service, environment, feature, resourceType);
65
+ return (0, exports.getQpqRuntimeResourceName)(resourceName, application, service, environment, feature, resourceType);
68
66
  };
69
67
  exports.getKvsDynamoTableNameFromConfig = getKvsDynamoTableNameFromConfig;
70
68
  const getCFExportNameUserPoolIdFromConfig = (userDirectoryName, qpqConfig, serviceOverride, applicationOverride) => {
@@ -14,9 +14,14 @@ const quidproquo_core_2 = require("quidproquo-core");
14
14
  const publishMessage_1 = require("../../../logic/sns/publishMessage");
15
15
  const awsNamingUtils_1 = require("../../../awsNamingUtils");
16
16
  const getProcessEventBusSendMessage = (qpqConfig) => {
17
- return ({ eventBusName, eventBusMessages, moduleOverride, environmentOverride, featureOverride, applicationOverride, context }, session) => __awaiter(void 0, void 0, void 0, function* () {
17
+ return ({ eventBusName, eventBusMessages, context }, session) => __awaiter(void 0, void 0, void 0, function* () {
18
+ var _a, _b, _c, _d, _e;
18
19
  const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
19
- const topicArn = (0, awsNamingUtils_1.getEventBusSnsTopicArn)(eventBusName, qpqConfig, moduleOverride || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig), environmentOverride || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), applicationOverride || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig), featureOverride || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
20
+ const eventBusConfig = quidproquo_core_1.qpqCoreUtils.getEventBusConfigByName(eventBusName, qpqConfig);
21
+ if (!eventBusConfig) {
22
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Event bus ${eventBusName} not found`);
23
+ }
24
+ const topicArn = (0, awsNamingUtils_1.getEventBusSnsTopicArn)(((_a = eventBusConfig.owner) === null || _a === void 0 ? void 0 : _a.resourceNameOverride) || eventBusName, qpqConfig, ((_b = eventBusConfig.owner) === null || _b === void 0 ? void 0 : _b.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig), ((_c = eventBusConfig.owner) === null || _c === void 0 ? void 0 : _c.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), ((_d = eventBusConfig.owner) === null || _d === void 0 ? void 0 : _d.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig), ((_e = eventBusConfig.owner) === null || _e === void 0 ? void 0 : _e.feature) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
20
25
  yield (0, publishMessage_1.publishMessage)(topicArn, region, eventBusMessages.map((message) => {
21
26
  const eventBusMessageWithSession = Object.assign(Object.assign({}, message), { storySession: Object.assign(Object.assign({}, session), { context }) });
22
27
  return JSON.stringify(eventBusMessageWithSession);
@@ -14,11 +14,10 @@ const utils_1 = require("./utils");
14
14
  const s3Utils_1 = require("../../../logic/s3/s3Utils");
15
15
  const getProcessFileListDirectory = (qpqConfig) => {
16
16
  return ({ drive, folderPath, maxFiles, pageToken }) => __awaiter(void 0, void 0, void 0, function* () {
17
- const xServiceDriveName = (0, utils_1.resolveCrossServiceDriveName)(drive);
18
17
  const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
19
18
  const s3FileList = yield (0, s3Utils_1.listFiles)(s3BucketName, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), folderPath, maxFiles, pageToken);
20
19
  // Add the drive onto the list
21
- const fileInfos = s3FileList.fileInfos.map((s3fi) => (Object.assign(Object.assign({}, s3fi), { drive: xServiceDriveName })));
20
+ const fileInfos = s3FileList.fileInfos.map((s3fi) => (Object.assign(Object.assign({}, s3fi), { drive })));
22
21
  return (0, quidproquo_core_1.actionResult)({
23
22
  fileInfos,
24
23
  pageToken: s3FileList.pageToken,
@@ -12,10 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const quidproquo_core_1 = require("quidproquo-core");
13
13
  const utils_1 = require("./utils");
14
14
  const s3Utils_1 = require("../../../logic/s3/s3Utils");
15
+ const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
15
16
  const getProcessFileWriteBinaryContents = (qpqConfig) => {
16
- return ({ drive, filepath, data }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ return ({ drive, filepath, data, storageDriveAdvancedWriteOptions }) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
18
- yield (0, s3Utils_1.writeBinaryFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
19
+ yield (0, s3Utils_1.writeBinaryFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), (0, awsLambdaUtils_1.getS3BucketStorageClassFromStorageDriveTier)(storageDriveAdvancedWriteOptions === null || storageDriveAdvancedWriteOptions === void 0 ? void 0 : storageDriveAdvancedWriteOptions.storageDriveTier));
19
20
  return (0, quidproquo_core_1.actionResult)(void 0);
20
21
  });
21
22
  };
@@ -12,10 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const quidproquo_core_1 = require("quidproquo-core");
13
13
  const utils_1 = require("./utils");
14
14
  const s3Utils_1 = require("../../../logic/s3/s3Utils");
15
+ const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
15
16
  const getProcessFileWriteTextContents = (qpqConfig) => {
16
- return ({ drive, filepath, data }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ return ({ drive, filepath, data, storageDriveAdvancedWriteOptions }) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
18
- yield (0, s3Utils_1.writeTextFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig));
19
+ yield (0, s3Utils_1.writeTextFile)(s3BucketName, filepath, data, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), (0, awsLambdaUtils_1.getS3BucketStorageClassFromStorageDriveTier)(storageDriveAdvancedWriteOptions === null || storageDriveAdvancedWriteOptions === void 0 ? void 0 : storageDriveAdvancedWriteOptions.storageDriveTier));
19
20
  return (0, quidproquo_core_1.actionResult)(void 0);
20
21
  });
21
22
  };
@@ -1,3 +1,2 @@
1
- import { QPQConfig, DriveName, CrossServiceResourceName } from 'quidproquo-core';
2
- export declare const resolveCrossServiceDriveName: (drive: DriveName) => CrossServiceResourceName;
3
- export declare const resolveStorageDriveBucketName: (drive: DriveName, qpqConfig: QPQConfig) => string;
1
+ import { QPQConfig } from 'quidproquo-core';
2
+ export declare const resolveStorageDriveBucketName: (drive: string, qpqConfig: QPQConfig) => string;
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveStorageDriveBucketName = exports.resolveCrossServiceDriveName = void 0;
3
+ exports.resolveStorageDriveBucketName = void 0;
4
+ const quidproquo_core_1 = require("quidproquo-core");
4
5
  const awsNamingUtils_1 = require("../../../../awsNamingUtils");
5
- const resolveCrossServiceDriveName = (drive) => {
6
- if (typeof drive === 'string') {
7
- return {
8
- name: drive,
9
- };
10
- }
11
- return drive;
12
- };
13
- exports.resolveCrossServiceDriveName = resolveCrossServiceDriveName;
14
6
  const resolveStorageDriveBucketName = (drive, qpqConfig) => {
15
- const xServiceDriveName = (0, exports.resolveCrossServiceDriveName)(drive);
16
- return (0, awsNamingUtils_1.getConfigRuntimeResourceNameFromConfigWithServiceOverride)(xServiceDriveName.name, qpqConfig, xServiceDriveName.service);
7
+ var _a, _b;
8
+ const storageDriveConfig = quidproquo_core_1.qpqCoreUtils.getStorageDriveByName(drive, qpqConfig);
9
+ if (!storageDriveConfig) {
10
+ throw new Error(`Could not find storage drive config for [${drive}]`);
11
+ }
12
+ return (0, awsNamingUtils_1.getConfigRuntimeResourceNameFromConfigWithServiceOverride)(((_a = storageDriveConfig.owner) === null || _a === void 0 ? void 0 : _a.resourceNameOverride) || drive, qpqConfig, (_b = storageDriveConfig.owner) === null || _b === void 0 ? void 0 : _b.module);
17
13
  };
18
14
  exports.resolveStorageDriveBucketName = resolveStorageDriveBucketName;
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getApiKeys = void 0;
13
13
  const client_api_gateway_1 = require("@aws-sdk/client-api-gateway");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const getApiKeys = (region, ...keyNames) => __awaiter(void 0, void 0, void 0, function* () {
15
16
  var _a;
16
- const apiGatewayClient = new client_api_gateway_1.APIGatewayClient({ region });
17
+ const apiGatewayClient = (0, createAwsClient_1.createAwsClient)(client_api_gateway_1.APIGatewayClient, { region });
17
18
  const input = {
18
19
  includeValues: true,
19
20
  limit: 500,
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.invalidateCache = exports.getInvalidationCallerReference = void 0;
16
16
  const client_cloudfront_1 = require("@aws-sdk/client-cloudfront");
17
17
  const crypto_1 = __importDefault(require("crypto"));
18
+ const createAwsClient_1 = require("../createAwsClient");
18
19
  const getInvalidationCallerReference = (paths) => {
19
20
  const allPaths = paths.join('');
20
21
  // All paths as a hash
@@ -24,7 +25,7 @@ const getInvalidationCallerReference = (paths) => {
24
25
  };
25
26
  exports.getInvalidationCallerReference = getInvalidationCallerReference;
26
27
  const invalidateCache = (distributionId, region, paths) => __awaiter(void 0, void 0, void 0, function* () {
27
- const cloudformation = new client_cloudfront_1.CloudFrontClient({ region });
28
+ const cloudFrontClient = (0, createAwsClient_1.createAwsClient)(client_cloudfront_1.CloudFrontClient, { region });
28
29
  const input = {
29
30
  DistributionId: distributionId,
30
31
  InvalidationBatch: {
@@ -35,6 +36,6 @@ const invalidateCache = (distributionId, region, paths) => __awaiter(void 0, voi
35
36
  CallerReference: (0, exports.getInvalidationCallerReference)(paths),
36
37
  },
37
38
  };
38
- yield cloudformation.send(new client_cloudfront_1.CreateInvalidationCommand(input));
39
+ yield cloudFrontClient.send(new client_cloudfront_1.CreateInvalidationCommand(input));
39
40
  });
40
41
  exports.invalidateCache = invalidateCache;
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getExportedValue = void 0;
13
13
  const client_cloudformation_1 = require("@aws-sdk/client-cloudformation");
14
14
  const memoFuncAsync_1 = require("../cache/memoFuncAsync");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  exports.getExportedValue = (0, memoFuncAsync_1.memoFuncAsync)((variableName, region) => __awaiter(void 0, void 0, void 0, function* () {
16
17
  var _a;
17
- const cloudformation = new client_cloudformation_1.CloudFormationClient({ region });
18
+ const cloudformation = (0, createAwsClient_1.createAwsClient)(client_cloudformation_1.CloudFormationClient, { region });
18
19
  const listCommandParams = {};
19
20
  do {
20
21
  const result = yield cloudformation.send(new client_cloudformation_1.ListExportsCommand(listCommandParams));
@@ -14,9 +14,10 @@ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-iden
14
14
  const calculateSecretHash_1 = require("./utils/calculateSecretHash");
15
15
  const getUserPoolClientSecret_1 = require("./getUserPoolClientSecret");
16
16
  const transformCognitoResponse_1 = require("./utils/transformCognitoResponse");
17
+ const createAwsClient_1 = require("../createAwsClient");
17
18
  // TODO: retry for TooManyRequestsException
18
19
  const authenticateUser = (userPoolId, clientId, region, username, password) => __awaiter(void 0, void 0, void 0, function* () {
19
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
20
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
20
21
  const clientSecret = yield (0, getUserPoolClientSecret_1.getUserPoolClientSecret)(userPoolId, clientId, region);
21
22
  const secretHash = (0, calculateSecretHash_1.calculateSecretHash)(username, clientId, clientSecret);
22
23
  // Time we issued the request
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.changePassword = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const changePassword = (accessToken, previousPassword, proposedPassword, region) => __awaiter(void 0, void 0, void 0, function* () {
15
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
16
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
16
17
  const params = {
17
18
  AccessToken: accessToken,
18
19
  PreviousPassword: previousPassword,
@@ -14,8 +14,9 @@ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-iden
14
14
  const calculateSecretHash_1 = require("./utils/calculateSecretHash");
15
15
  const getUserPoolClientSecret_1 = require("./getUserPoolClientSecret");
16
16
  const authenticateUser_1 = require("./authenticateUser");
17
+ const createAwsClient_1 = require("../createAwsClient");
17
18
  const confirmForgotPassword = (userPoolId, clientId, region, code, username, password) => __awaiter(void 0, void 0, void 0, function* () {
18
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
19
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
19
20
  const clientSecret = yield (0, getUserPoolClientSecret_1.getUserPoolClientSecret)(userPoolId, clientId, region);
20
21
  const secretHash = (0, calculateSecretHash_1.calculateSecretHash)(username, clientId, clientSecret);
21
22
  const params = {
@@ -14,9 +14,10 @@ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-iden
14
14
  const authenticateUser_1 = require("./authenticateUser");
15
15
  const setUserPassword_1 = require("./setUserPassword");
16
16
  const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
17
+ const createAwsClient_1 = require("../createAwsClient");
17
18
  const createUser = (userPoolId, region, clientId, createUserRequest) => __awaiter(void 0, void 0, void 0, function* () {
18
19
  var _a;
19
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
20
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
20
21
  const params = {
21
22
  UserPoolId: userPoolId,
22
23
  Username: createUserRequest.email,
@@ -13,8 +13,9 @@ exports.forgotPassword = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
14
  const calculateSecretHash_1 = require("./utils/calculateSecretHash");
15
15
  const getUserPoolClientSecret_1 = require("./getUserPoolClientSecret");
16
+ const createAwsClient_1 = require("../createAwsClient");
16
17
  const forgotPassword = (userPoolId, clientId, region, username) => __awaiter(void 0, void 0, void 0, function* () {
17
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
18
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
18
19
  const clientSecret = yield (0, getUserPoolClientSecret_1.getUserPoolClientSecret)(userPoolId, clientId, region);
19
20
  const secretHash = (0, calculateSecretHash_1.calculateSecretHash)(username, clientId, clientSecret);
20
21
  const params = {
@@ -11,13 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getUser = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const getUserAttribute = (attributeName, userAttributes) => {
15
16
  const lowerAttributeName = attributeName.toLowerCase();
16
17
  const attribute = userAttributes.find((k) => { var _a; return ((_a = k.Name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === lowerAttributeName; });
17
18
  return attribute === null || attribute === void 0 ? void 0 : attribute.Value;
18
19
  };
19
20
  const getUser = (accessToken, region) => __awaiter(void 0, void 0, void 0, function* () {
20
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
21
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
21
22
  const params = {
22
23
  AccessToken: accessToken,
23
24
  };
@@ -12,8 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getUserAttributes = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
14
  const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  const getUserAttributes = (userPoolId, region, username) => __awaiter(void 0, void 0, void 0, function* () {
16
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
17
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
17
18
  const params = {
18
19
  UserPoolId: userPoolId,
19
20
  Username: username,
@@ -12,8 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getUserAttributesBySub = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
14
  const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  const getUserAttributesBySub = (userPoolId, region, sub) => __awaiter(void 0, void 0, void 0, function* () {
16
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
17
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
17
18
  const response = yield cognitoClient.send(new client_cognito_identity_provider_1.ListUsersCommand({
18
19
  UserPoolId: userPoolId,
19
20
  Filter: `sub = "${sub}"`,
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getUserPoolClientSecret = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const getUserPoolClientSecret = (userPoolId, clientId, region) => __awaiter(void 0, void 0, void 0, function* () {
15
16
  var _a, _b;
16
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
17
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
17
18
  const params = {
18
19
  ClientId: clientId,
19
20
  UserPoolId: userPoolId,
@@ -13,8 +13,9 @@ exports.listPagedUsers = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
14
  const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
15
15
  const utils_1 = require("./utils");
16
+ const createAwsClient_1 = require("../createAwsClient");
16
17
  const listPagedUsers = (userPoolId, region, pageKey) => __awaiter(void 0, void 0, void 0, function* () {
17
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
18
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
18
19
  const response = yield cognitoClient.send(new client_cognito_identity_provider_1.ListUsersCommand({
19
20
  UserPoolId: userPoolId,
20
21
  PaginationToken: (0, utils_1.pageKeyToPaginationToken)(pageKey),
@@ -14,8 +14,9 @@ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-iden
14
14
  const calculateSecretHash_1 = require("./utils/calculateSecretHash");
15
15
  const getUserPoolClientSecret_1 = require("./getUserPoolClientSecret");
16
16
  const transformCognitoResponse_1 = require("./utils/transformCognitoResponse");
17
+ const createAwsClient_1 = require("../createAwsClient");
17
18
  const refreshToken = (userPoolId, clientId, region, username, refreshToken) => __awaiter(void 0, void 0, void 0, function* () {
18
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
19
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
19
20
  const clientSecret = yield (0, getUserPoolClientSecret_1.getUserPoolClientSecret)(userPoolId, clientId, region);
20
21
  const secretHash = (0, calculateSecretHash_1.calculateSecretHash)(username, clientId, clientSecret);
21
22
  const params = {
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.requestEmailVerificationCode = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const requestEmailVerificationCode = (region, accessToken) => __awaiter(void 0, void 0, void 0, function* () {
15
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
16
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
16
17
  const params = {
17
18
  AccessToken: accessToken,
18
19
  AttributeName: 'email', // Request verification for the email attribute
@@ -14,8 +14,9 @@ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-iden
14
14
  const calculateSecretHash_1 = require("./utils/calculateSecretHash");
15
15
  const getUserPoolClientSecret_1 = require("./getUserPoolClientSecret");
16
16
  const transformCognitoResponse_1 = require("./utils/transformCognitoResponse");
17
+ const createAwsClient_1 = require("../createAwsClient");
17
18
  const respondToAuthChallengeChallenge = (userPoolId, clientId, region, username, session, attributes) => __awaiter(void 0, void 0, void 0, function* () {
18
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
19
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
19
20
  const clientSecret = yield (0, getUserPoolClientSecret_1.getUserPoolClientSecret)(userPoolId, clientId, region);
20
21
  const secretHash = (0, calculateSecretHash_1.calculateSecretHash)(username, clientId, clientSecret);
21
22
  const params = {
@@ -23,8 +23,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.setUserAttributes = void 0;
24
24
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
25
25
  const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
26
+ const createAwsClient_1 = require("../createAwsClient");
26
27
  const setUserAttributes = (userPoolId, region, username, userAttributes) => __awaiter(void 0, void 0, void 0, function* () {
27
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
28
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
28
29
  const { userId } = userAttributes, writeableUserAttributes = __rest(userAttributes, ["userId"]);
29
30
  const params = {
30
31
  UserPoolId: userPoolId,
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.setUserPassword = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const setUserPassword = (region, userPoolId, username, password) => __awaiter(void 0, void 0, void 0, function* () {
15
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
16
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
16
17
  // There has to be a better way than this?
17
18
  const passwordParams = {
18
19
  Password: password,
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.verifyUserEmail = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const verifyUserEmail = (region, accessToken, verificationCode) => __awaiter(void 0, void 0, void 0, function* () {
15
- const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
16
+ const cognitoClient = (0, createAwsClient_1.createAwsClient)(client_cognito_identity_provider_1.CognitoIdentityProviderClient, { region });
16
17
  const params = {
17
18
  AccessToken: accessToken,
18
19
  AttributeName: 'email',
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.deleteItem = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  function deleteItem(tableName, region, key, keyName, sortKey, sortKeyName) {
16
17
  return __awaiter(this, void 0, void 0, function* () {
17
- const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
18
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
18
19
  const deleteItemParams = {
19
20
  TableName: tableName,
20
21
  Key: {
@@ -24,7 +25,7 @@ function deleteItem(tableName, region, key, keyName, sortKey, sortKeyName) {
24
25
  if (sortKey && sortKeyName) {
25
26
  deleteItemParams.Key[sortKeyName] = (0, qpqDynamoOrm_1.buildAttributeValue)(sortKey);
26
27
  }
27
- yield dynamoClient.send(new client_dynamodb_1.DeleteItemCommand(deleteItemParams));
28
+ yield dynamoDBClient.send(new client_dynamodb_1.DeleteItemCommand(deleteItemParams));
28
29
  });
29
30
  }
30
31
  exports.deleteItem = deleteItem;
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getAllItems = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  function getAllItems(tableName, region) {
15
16
  return __awaiter(this, void 0, void 0, function* () {
16
- const dynamoDBClient = new client_dynamodb_1.DynamoDBClient({ region });
17
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
17
18
  let records = [];
18
19
  let lastEvaluatedKey;
19
20
  do {
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getItem = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  function getItem(tableName, key, region) {
15
16
  return __awaiter(this, void 0, void 0, function* () {
16
- const dynamoDBClient = new client_dynamodb_1.DynamoDBClient({ region });
17
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
17
18
  const getItemParams = {
18
19
  TableName: tableName,
19
20
  Key: {
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getLogByCorrelation = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  function getLogByCorrelation(tableName, region, correlation) {
15
16
  return __awaiter(this, void 0, void 0, function* () {
16
- const dynamoDBClient = new client_dynamodb_1.DynamoDBClient({ region });
17
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
17
18
  const queryParams = {
18
19
  TableName: tableName,
19
20
  IndexName: 'CorrelationIndex',
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getLogChildrenByFromCorrelation = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const logs_1 = require("./logs");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  function getLogChildrenByFromCorrelation(tableName, region, fromCorrelation, pageKey) {
16
17
  return __awaiter(this, void 0, void 0, function* () {
17
- const dynamoDBClient = new client_dynamodb_1.DynamoDBClient({ region });
18
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
18
19
  const queryParams = {
19
20
  TableName: tableName,
20
21
  // removed IndexName
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getPagedItemsOverRange = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const logs_1 = require("./logs");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  function getPagedItemsOverRange(tableName, region, runtimeType, startIsoDateTime, endIsoDateTime, pageKey) {
16
17
  return __awaiter(this, void 0, void 0, function* () {
17
- const dynamoDBClient = new client_dynamodb_1.DynamoDBClient({ region });
18
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
18
19
  const queryParams = {
19
20
  TableName: tableName,
20
21
  KeyConditionExpression: 'runtimeType = :runtimeType AND startedAtWithCorrelation BETWEEN :startIsoDateTime AND :endIsoDateTime',
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.putItem = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  // We currently only support objects as root items in dynamo
16
17
  // Storing a list (array) as the root of your DynamoDB record is indeed possible,
17
18
  // but there are some caveats. One of the main challenges is that DynamoDB doesn't support
@@ -37,8 +38,8 @@ const convertObjectToDynamoItem = (obj) => {
37
38
  };
38
39
  function putItem(tableName, item, attributes, options, region) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
- const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
41
- yield dynamoClient.send(new client_dynamodb_1.PutItemCommand({
41
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
42
+ yield dynamoDBClient.send(new client_dynamodb_1.PutItemCommand({
42
43
  TableName: tableName,
43
44
  Item: convertObjectToDynamoItem(item),
44
45
  }));
@@ -15,11 +15,12 @@ const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
15
15
  const logs_1 = require("./logs");
16
16
  const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
17
17
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
18
+ const createAwsClient_1 = require("../createAwsClient");
18
19
  function query(tableName, region, keyExpression, filterExpression, pageKey, indexName) {
19
20
  var _a;
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  // Instantiate DynamoDB client
22
- const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
23
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
23
24
  const params = {
24
25
  TableName: tableName,
25
26
  KeyConditionExpression: (0, qpqDynamoOrm_1.buildDynamoQueryExpression)(keyExpression),
@@ -34,7 +35,7 @@ function query(tableName, region, keyExpression, filterExpression, pageKey, inde
34
35
  // Create QueryCommand
35
36
  const command = new client_dynamodb_1.QueryCommand(params);
36
37
  // TODO: Catch errors and throw QPQ ones
37
- const data = yield dynamoClient.send(command);
38
+ const data = yield dynamoDBClient.send(command);
38
39
  return (0, itemsToQpqPagedData_1.itemsToQpqPagedData)((((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []), data.LastEvaluatedKey);
39
40
  });
40
41
  }
@@ -15,11 +15,12 @@ const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
15
15
  const logs_1 = require("./logs");
16
16
  const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
17
17
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
18
+ const createAwsClient_1 = require("../createAwsClient");
18
19
  function scan(tableName, region, filterExpression, pageKey) {
19
20
  var _a;
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  // Instantiate DynamoDB client
22
- const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
23
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
23
24
  const params = {
24
25
  TableName: tableName,
25
26
  FilterExpression: (0, qpqDynamoOrm_1.buildDynamoQueryExpression)(filterExpression),
@@ -32,7 +33,7 @@ function scan(tableName, region, filterExpression, pageKey) {
32
33
  // Create ScanCommand
33
34
  const command = new client_dynamodb_1.ScanCommand(params);
34
35
  // TODO: Catch errors and throw QPQ ones
35
- const data = yield dynamoClient.send(command);
36
+ const data = yield dynamoDBClient.send(command);
36
37
  return (0, itemsToQpqPagedData_1.itemsToQpqPagedData)((((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []), data.LastEvaluatedKey);
37
38
  });
38
39
  }
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.updateItem = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
14
  const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  function updateItem(tableName, region, update, key, sortKey) {
16
17
  return __awaiter(this, void 0, void 0, function* () {
17
- const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
18
+ const dynamoDBClient = (0, createAwsClient_1.createAwsClient)(client_dynamodb_1.DynamoDBClient, { region });
18
19
  const params = {
19
20
  TableName: tableName,
20
21
  Key: {
@@ -27,7 +28,7 @@ function updateItem(tableName, region, update, key, sortKey) {
27
28
  if (sortKey) {
28
29
  params.Key['sk'] = (0, qpqDynamoOrm_1.buildAttributeValue)(sortKey);
29
30
  }
30
- console.log(yield dynamoClient.send(new client_dynamodb_1.UpdateItemCommand(params)));
31
+ console.log(yield dynamoDBClient.send(new client_dynamodb_1.UpdateItemCommand(params)));
31
32
  });
32
33
  }
33
34
  exports.updateItem = updateItem;
@@ -11,11 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.executeLambdaByName = void 0;
13
13
  const client_lambda_1 = require("@aws-sdk/client-lambda");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const executeLambdaByName = (functionName, region, payload, isAsync) => __awaiter(void 0, void 0, void 0, function* () {
15
- const lambda = new client_lambda_1.LambdaClient({ region });
16
+ const lambdaClient = (0, createAwsClient_1.createAwsClient)(client_lambda_1.LambdaClient, { region });
16
17
  const encoder = new TextEncoder();
17
18
  const encodedPayload = encoder.encode(JSON.stringify(payload));
18
- const response = yield lambda.send(new client_lambda_1.InvokeCommand({
19
+ const response = yield lambdaClient.send(new client_lambda_1.InvokeCommand({
19
20
  FunctionName: functionName,
20
21
  Payload: encodedPayload,
21
22
  InvocationType: isAsync ? 'Event' : 'RequestResponse',
@@ -12,12 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getParameter = void 0;
13
13
  const client_ssm_1 = require("@aws-sdk/client-ssm");
14
14
  const memoFuncAsync_1 = require("../cache/memoFuncAsync");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  exports.getParameter = (0, memoFuncAsync_1.memoFuncAsync)((parameterName, region) => __awaiter(void 0, void 0, void 0, function* () {
16
17
  var _a;
17
- const smClient = new client_ssm_1.SSMClient({
18
- region,
19
- });
20
- const response = yield smClient.send(new client_ssm_1.GetParameterCommand({
18
+ const ssmClient = (0, createAwsClient_1.createAwsClient)(client_ssm_1.SSMClient, { region });
19
+ const response = yield ssmClient.send(new client_ssm_1.GetParameterCommand({
21
20
  Name: parameterName,
22
21
  }));
23
22
  return ((_a = response.Parameter) === null || _a === void 0 ? void 0 : _a.Value) || '';
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getParameters = void 0;
13
13
  const client_ssm_1 = require("@aws-sdk/client-ssm");
14
14
  const memoFuncAsync_1 = require("../cache/memoFuncAsync");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  exports.getParameters = (0, memoFuncAsync_1.memoFuncAsync)((parameterNames, region) => __awaiter(void 0, void 0, void 0, function* () {
16
- const smClient = new client_ssm_1.SSMClient({ region });
17
- const response = yield smClient.send(new client_ssm_1.GetParametersCommand({
17
+ const ssmClient = (0, createAwsClient_1.createAwsClient)(client_ssm_1.SSMClient, { region });
18
+ const response = yield ssmClient.send(new client_ssm_1.GetParametersCommand({
18
19
  Names: parameterNames,
19
20
  }));
20
21
  const resolvedParams = response.Parameters || [];
@@ -11,11 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.setParameter = void 0;
13
13
  const client_ssm_1 = require("@aws-sdk/client-ssm");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const setParameter = (parameterName, region, value) => __awaiter(void 0, void 0, void 0, function* () {
15
- const smClient = new client_ssm_1.SSMClient({
16
- region,
17
- });
18
- yield smClient.send(new client_ssm_1.PutParameterCommand({
16
+ const ssmClient = (0, createAwsClient_1.createAwsClient)(client_ssm_1.SSMClient, { region });
17
+ yield ssmClient.send(new client_ssm_1.PutParameterCommand({
19
18
  Name: parameterName,
20
19
  Value: value,
21
20
  Overwrite: true,
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.deleteFiles = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const deleteFiles = (drive, filepaths, region) => __awaiter(void 0, void 0, void 0, function* () {
15
- const s3Client = new client_s3_1.S3Client({ region });
16
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
16
17
  const bucketParams = {
17
18
  Bucket: drive,
18
19
  Delete: {
@@ -13,6 +13,7 @@ exports.listFiles = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
14
  const client_s3_2 = require("@aws-sdk/client-s3");
15
15
  const quidproquo_core_1 = require("quidproquo-core");
16
+ const createAwsClient_1 = require("../createAwsClient");
16
17
  const listFiles = (bucketName, region, folder = '', maxKeys = 1000, pageToken) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  const validatedPrefix = `${folder}${folder.endsWith(quidproquo_core_1.filePathDelimiter) || !folder ? '' : quidproquo_core_1.filePathDelimiter}`;
18
19
  const bucketParams = {
@@ -24,7 +25,7 @@ const listFiles = (bucketName, region, folder = '', maxKeys = 1000, pageToken) =
24
25
  };
25
26
  // Declare truncated as a flag that the while loop is based on.
26
27
  let files = [];
27
- const s3Client = new client_s3_1.S3Client({ region });
28
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
28
29
  const response = yield s3Client.send(new client_s3_2.ListObjectsV2Command(bucketParams));
29
30
  if (response.CommonPrefixes && !bucketParams.ContinuationToken) {
30
31
  files = [
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.objectExists = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
14
  const client_s3_2 = require("@aws-sdk/client-s3");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  const objectExists = (bucketName, key, region) => __awaiter(void 0, void 0, void 0, function* () {
16
17
  try {
17
- const s3Client = new client_s3_1.S3Client({ region });
18
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
18
19
  yield s3Client.send(new client_s3_2.HeadObjectCommand({
19
20
  Key: key,
20
21
  Bucket: bucketName,
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.readBinaryFile = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const readBinaryFile = (bucketName, key, region) => __awaiter(void 0, void 0, void 0, function* () {
15
16
  var _a;
16
- const s3Client = new client_s3_1.S3Client({ region });
17
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
17
18
  const response = yield s3Client.send(new client_s3_1.GetObjectCommand({
18
19
  Key: key,
19
20
  Bucket: bucketName,
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.readTextFile = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const readTextFile = (bucketName, key, region) => __awaiter(void 0, void 0, void 0, function* () {
15
16
  var _a;
16
- const s3Client = new client_s3_1.S3Client({ region });
17
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
17
18
  const response = yield s3Client.send(new client_s3_1.GetObjectCommand({
18
19
  Key: key,
19
20
  Bucket: bucketName,
@@ -1,2 +1,3 @@
1
1
  import { QPQBinaryData } from 'quidproquo-core';
2
- export declare const writeBinaryFile: (bucketName: string, key: string, data: QPQBinaryData, region: string) => Promise<void>;
2
+ import { StorageClass } from '@aws-sdk/client-s3';
3
+ export declare const writeBinaryFile: (bucketName: string, key: string, data: QPQBinaryData, region: string, storageClass: keyof typeof StorageClass) => Promise<void>;
@@ -11,14 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.writeBinaryFile = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
- const writeBinaryFile = (bucketName, key, data, region) => __awaiter(void 0, void 0, void 0, function* () {
15
- const s3Client = new client_s3_1.S3Client({ region });
14
+ const createAwsClient_1 = require("../createAwsClient");
15
+ const writeBinaryFile = (bucketName, key, data, region, storageClass) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
16
17
  yield s3Client.send(new client_s3_1.PutObjectCommand({
17
18
  Key: key,
18
19
  Bucket: bucketName,
19
20
  Body: Buffer.from(data.base64Data, 'base64'),
20
21
  ContentType: data.mimetype,
21
22
  ContentDisposition: data.contentDisposition,
23
+ StorageClass: storageClass
22
24
  }));
23
25
  });
24
26
  exports.writeBinaryFile = writeBinaryFile;
@@ -1 +1,2 @@
1
- export declare const writeTextFile: (bucketName: string, key: string, data: string, region: string) => Promise<void>;
1
+ import { StorageClass } from '@aws-sdk/client-s3';
2
+ export declare const writeTextFile: (bucketName: string, key: string, data: string, region: string, storageClass: keyof typeof StorageClass) => Promise<void>;
@@ -11,12 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.writeTextFile = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
- const writeTextFile = (bucketName, key, data, region) => __awaiter(void 0, void 0, void 0, function* () {
15
- const s3Client = new client_s3_1.S3Client({ region });
14
+ const createAwsClient_1 = require("../createAwsClient");
15
+ const writeTextFile = (bucketName, key, data, region, storageClass) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
16
17
  yield s3Client.send(new client_s3_1.PutObjectCommand({
17
18
  Key: key,
18
19
  Bucket: bucketName,
19
20
  Body: Buffer.from(data),
21
+ StorageClass: storageClass
20
22
  }));
21
23
  });
22
24
  exports.writeTextFile = writeTextFile;
@@ -12,11 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getSecret = void 0;
13
13
  const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
14
14
  const memoFuncAsync_1 = require("../cache/memoFuncAsync");
15
+ const createAwsClient_1 = require("../createAwsClient");
15
16
  exports.getSecret = (0, memoFuncAsync_1.memoFuncAsync)((secretName, region) => __awaiter(void 0, void 0, void 0, function* () {
16
- const smClient = new client_secrets_manager_1.SecretsManagerClient({
17
- region,
18
- });
19
- const response = yield smClient.send(new client_secrets_manager_1.GetSecretValueCommand({
17
+ const secretsManagerClient = (0, createAwsClient_1.createAwsClient)(client_secrets_manager_1.SecretsManagerClient, { region });
18
+ const response = yield secretsManagerClient.send(new client_secrets_manager_1.GetSecretValueCommand({
20
19
  SecretId: secretName,
21
20
  }));
22
21
  return response.SecretString || '';
@@ -13,9 +13,7 @@ exports.publishMessage = void 0;
13
13
  const client_sns_1 = require("@aws-sdk/client-sns");
14
14
  const createAwsClient_1 = require("../createAwsClient");
15
15
  const publishMessage = (topicArn, region, messages) => __awaiter(void 0, void 0, void 0, function* () {
16
- const sqsClient = (0, createAwsClient_1.createAwsClient)(client_sns_1.SNSClient, {
17
- region,
18
- });
16
+ const sqsClient = (0, createAwsClient_1.createAwsClient)(client_sns_1.SNSClient, { region });
19
17
  // Convert them to entries
20
18
  const entries = messages.map((message, index) => ({
21
19
  Message: message,
@@ -14,9 +14,7 @@ const client_sqs_1 = require("@aws-sdk/client-sqs");
14
14
  const getQueueUrl_1 = require("./getQueueUrl");
15
15
  const createAwsClient_1 = require("../createAwsClient");
16
16
  const sendMessages = (queueName, region, messages) => __awaiter(void 0, void 0, void 0, function* () {
17
- const sqsClient = (0, createAwsClient_1.createAwsClient)(client_sqs_1.SQSClient, {
18
- region,
19
- });
17
+ const sqsClient = (0, createAwsClient_1.createAwsClient)(client_sqs_1.SQSClient, { region });
20
18
  const url = yield (0, getQueueUrl_1.getQueueUrl)(queueName, sqsClient);
21
19
  // Convert them to entries
22
20
  const entries = messages.map((message, index) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.139",
3
+ "version": "0.0.141",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "types": "./lib/commonjs/index.d.js",