quidproquo-actionprocessor-awslambda 0.0.138 → 0.0.140

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 (48) hide show
  1. package/lib/commonjs/getActionProcessor/core/event/getS3FileEventActionProcessor.d.ts +12 -0
  2. package/lib/commonjs/getActionProcessor/core/event/getS3FileEventActionProcessor.js +53 -0
  3. package/lib/commonjs/getActionProcessor/core/index.d.ts +1 -0
  4. package/lib/commonjs/getActionProcessor/core/index.js +3 -1
  5. package/lib/commonjs/logic/apiGateway/getApiKeys.js +2 -1
  6. package/lib/commonjs/logic/cloudFront/invalidateCache.js +3 -2
  7. package/lib/commonjs/logic/cloudformation/getExportedValue.js +2 -1
  8. package/lib/commonjs/logic/cognito/authenticateUser.js +2 -1
  9. package/lib/commonjs/logic/cognito/changePassword.js +2 -1
  10. package/lib/commonjs/logic/cognito/confirmForgotPassword.js +2 -1
  11. package/lib/commonjs/logic/cognito/createUser.js +2 -1
  12. package/lib/commonjs/logic/cognito/forgotPassword.js +2 -1
  13. package/lib/commonjs/logic/cognito/getUser.js +2 -1
  14. package/lib/commonjs/logic/cognito/getUserAttributes.js +2 -1
  15. package/lib/commonjs/logic/cognito/getUserAttributesBySub.js +2 -1
  16. package/lib/commonjs/logic/cognito/getUserPoolClientSecret.js +2 -1
  17. package/lib/commonjs/logic/cognito/listPagedUsers.js +2 -1
  18. package/lib/commonjs/logic/cognito/refreshToken.js +2 -1
  19. package/lib/commonjs/logic/cognito/requestEmailVerificationCode.js +2 -1
  20. package/lib/commonjs/logic/cognito/respondToAuthChallengeChallenge.js +2 -1
  21. package/lib/commonjs/logic/cognito/setUserAttributes.js +2 -1
  22. package/lib/commonjs/logic/cognito/setUserPassword.js +2 -1
  23. package/lib/commonjs/logic/cognito/verifyUserEmail.js +2 -1
  24. package/lib/commonjs/logic/dynamo/deleteItem.js +3 -2
  25. package/lib/commonjs/logic/dynamo/getAllItems.js +2 -1
  26. package/lib/commonjs/logic/dynamo/getItem.js +2 -1
  27. package/lib/commonjs/logic/dynamo/getLogByCorrelation.js +2 -1
  28. package/lib/commonjs/logic/dynamo/getLogChildrenByFromCorrelation.js +2 -1
  29. package/lib/commonjs/logic/dynamo/getPagedItemsOverRange.js +2 -1
  30. package/lib/commonjs/logic/dynamo/putItem.js +3 -2
  31. package/lib/commonjs/logic/dynamo/query.js +3 -2
  32. package/lib/commonjs/logic/dynamo/scan.js +3 -2
  33. package/lib/commonjs/logic/dynamo/updateItem.js +3 -2
  34. package/lib/commonjs/logic/lambda/executeLambdaByName.js +3 -2
  35. package/lib/commonjs/logic/parametersManager/getParameter.js +3 -4
  36. package/lib/commonjs/logic/parametersManager/getParameters.js +3 -2
  37. package/lib/commonjs/logic/parametersManager/setParameter.js +3 -4
  38. package/lib/commonjs/logic/s3/deleteFiles.js +2 -1
  39. package/lib/commonjs/logic/s3/listFiles.js +2 -1
  40. package/lib/commonjs/logic/s3/objectExists.js +2 -1
  41. package/lib/commonjs/logic/s3/readBinaryFile.js +2 -1
  42. package/lib/commonjs/logic/s3/readTextFile.js +2 -1
  43. package/lib/commonjs/logic/s3/writeBinaryFile.js +2 -1
  44. package/lib/commonjs/logic/s3/writeTextFile.js +2 -1
  45. package/lib/commonjs/logic/secretsManager/getSecret.js +3 -4
  46. package/lib/commonjs/logic/sns/publishMessage.js +1 -3
  47. package/lib/commonjs/logic/sqs/sendMessages.js +1 -3
  48. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ import { QPQConfig, MatchStoryResult, EventMatchStoryActionProcessor, EventTransformEventParamsActionProcessor, EventTransformResponseResultActionProcessor, EventAutoRespondActionProcessor } from 'quidproquo-core';
2
+ import { StorageDriveEvent } from 'quidproquo-webserver';
3
+ import { S3Event, Context } from 'aws-lambda';
4
+ type EventInput = [S3Event, Context];
5
+ type MatchResult = MatchStoryResult<any, any>;
6
+ declare const _default: (qpqConfig: QPQConfig) => {
7
+ "@quidproquo-core/event/TransformEventParams": EventTransformEventParamsActionProcessor<EventInput, StorageDriveEvent>;
8
+ "@quidproquo-core/event/TransformResponseResult": EventTransformResponseResultActionProcessor<void, StorageDriveEvent, void>;
9
+ "@quidproquo-core/event/AutoRespond": EventAutoRespondActionProcessor<StorageDriveEvent, MatchResult, boolean>;
10
+ "@quidproquo-core/event/MatchStory": EventMatchStoryActionProcessor<StorageDriveEvent, MatchResult>;
11
+ };
12
+ export default _default;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const quidproquo_webserver_1 = require("quidproquo-webserver");
14
+ // TODO: Don't use Globals like this
15
+ console.log(process.env.storageDriveCreateEntry);
16
+ const GLOBAL_STORAGE_DRIVE_NAME = process.env.storageDriveName;
17
+ const GLOBAL_STORAGE_DRIVE_RUNTIME = JSON.parse(process.env.storageDriveCreateEntry || "{}");
18
+ const getProcessTransformEventParams = () => {
19
+ return ({ eventParams: [s3Event, context] }) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const transformedEventParams = {
21
+ driveName: GLOBAL_STORAGE_DRIVE_NAME,
22
+ filePaths: s3Event.Records.map(r => decodeURIComponent(r.s3.object.key)),
23
+ eventType: quidproquo_webserver_1.StorageDriveEventType.Create,
24
+ };
25
+ return (0, quidproquo_core_1.actionResult)(transformedEventParams);
26
+ });
27
+ };
28
+ const getProcessTransformResponseResult = (qpqConfig) => {
29
+ // We might need to JSON.stringify the body.
30
+ return (payload) => __awaiter(void 0, void 0, void 0, function* () {
31
+ // always success
32
+ return (0, quidproquo_core_1.actionResult)(void 0);
33
+ });
34
+ };
35
+ const getProcessAutoRespond = (qpqConfig) => {
36
+ return (payload) => __awaiter(void 0, void 0, void 0, function* () {
37
+ // always allow
38
+ return (0, quidproquo_core_1.actionResult)(false);
39
+ });
40
+ };
41
+ const getProcessMatchStory = (qpqConfig) => {
42
+ return () => __awaiter(void 0, void 0, void 0, function* () {
43
+ return (0, quidproquo_core_1.actionResult)(GLOBAL_STORAGE_DRIVE_RUNTIME);
44
+ });
45
+ };
46
+ exports.default = (qpqConfig) => {
47
+ return {
48
+ [quidproquo_core_1.EventActionType.TransformEventParams]: getProcessTransformEventParams(),
49
+ [quidproquo_core_1.EventActionType.TransformResponseResult]: getProcessTransformResponseResult(qpqConfig),
50
+ [quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
51
+ [quidproquo_core_1.EventActionType.MatchStory]: getProcessMatchStory(qpqConfig),
52
+ };
53
+ };
@@ -11,6 +11,7 @@ export { default as getEventBridgeEventStackDeployActionProcessor } from './even
11
11
  export { default as getEventBridgeEventActionProcessor } from './event/getEventBridgeEventActionProcessor';
12
12
  export { default as getLambdaCognitoCustomMessage } from './event/getLambdaCognitoCustomMessage';
13
13
  export { default as getWebsocketAPIGatewayEventActionProcessor } from './event/getWebsocketAPIGatewayEventActionProcessor';
14
+ export { default as getS3FileEventActionProcessor } from './event/getS3FileEventActionProcessor';
14
15
  export { default as getSystemActionProcessor } from './system';
15
16
  export { default as getFileActionProcessor } from './file';
16
17
  export { default as getKeyValueStoreActionProcessor } from './keyValueStore';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getEventBusActionProcessor = exports.getUserDirectoryActionProcessor = exports.getQueueActionProcessor = exports.getKeyValueStoreActionProcessor = exports.getFileActionProcessor = exports.getSystemActionProcessor = exports.getWebsocketAPIGatewayEventActionProcessor = exports.getLambdaCognitoCustomMessage = exports.getEventBridgeEventActionProcessor = exports.getEventBridgeEventStackDeployActionProcessor = exports.getServiceFunctionExecuteEventActionProcessor = exports.getSQSEventRecordActionProcessor = exports.getCloudFrontOriginRequestEventActionProcessor = exports.getAPIGatewayEventActionProcessor = exports.getConfigSetParameterActionProcessor = exports.getConfigGetGlobalActionProcessor = exports.getConfigGetParametersActionProcessor = exports.getConfigGetParameterActionProcessor = exports.getConfigGetSecretActionProcessor = void 0;
6
+ exports.getEventBusActionProcessor = exports.getUserDirectoryActionProcessor = exports.getQueueActionProcessor = exports.getKeyValueStoreActionProcessor = exports.getFileActionProcessor = exports.getSystemActionProcessor = exports.getS3FileEventActionProcessor = exports.getWebsocketAPIGatewayEventActionProcessor = exports.getLambdaCognitoCustomMessage = exports.getEventBridgeEventActionProcessor = exports.getEventBridgeEventStackDeployActionProcessor = exports.getServiceFunctionExecuteEventActionProcessor = exports.getSQSEventRecordActionProcessor = exports.getCloudFrontOriginRequestEventActionProcessor = exports.getAPIGatewayEventActionProcessor = exports.getConfigSetParameterActionProcessor = exports.getConfigGetGlobalActionProcessor = exports.getConfigGetParametersActionProcessor = exports.getConfigGetParameterActionProcessor = exports.getConfigGetSecretActionProcessor = void 0;
7
7
  var getConfigGetSecretActionProcessor_1 = require("./config/getConfigGetSecretActionProcessor");
8
8
  Object.defineProperty(exports, "getConfigGetSecretActionProcessor", { enumerable: true, get: function () { return __importDefault(getConfigGetSecretActionProcessor_1).default; } });
9
9
  var getConfigGetParameterActionProcessor_1 = require("./config/getConfigGetParameterActionProcessor");
@@ -30,6 +30,8 @@ var getLambdaCognitoCustomMessage_1 = require("./event/getLambdaCognitoCustomMes
30
30
  Object.defineProperty(exports, "getLambdaCognitoCustomMessage", { enumerable: true, get: function () { return __importDefault(getLambdaCognitoCustomMessage_1).default; } });
31
31
  var getWebsocketAPIGatewayEventActionProcessor_1 = require("./event/getWebsocketAPIGatewayEventActionProcessor");
32
32
  Object.defineProperty(exports, "getWebsocketAPIGatewayEventActionProcessor", { enumerable: true, get: function () { return __importDefault(getWebsocketAPIGatewayEventActionProcessor_1).default; } });
33
+ var getS3FileEventActionProcessor_1 = require("./event/getS3FileEventActionProcessor");
34
+ Object.defineProperty(exports, "getS3FileEventActionProcessor", { enumerable: true, get: function () { return __importDefault(getS3FileEventActionProcessor_1).default; } });
33
35
  var system_1 = require("./system");
34
36
  Object.defineProperty(exports, "getSystemActionProcessor", { enumerable: true, get: function () { return __importDefault(system_1).default; } });
35
37
  var file_1 = require("./file");
@@ -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,
@@ -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.writeBinaryFile = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const writeBinaryFile = (bucketName, key, data, 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
  yield s3Client.send(new client_s3_1.PutObjectCommand({
17
18
  Key: key,
18
19
  Bucket: bucketName,
@@ -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.writeTextFile = void 0;
13
13
  const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const createAwsClient_1 = require("../createAwsClient");
14
15
  const writeTextFile = (bucketName, key, data, 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
  yield s3Client.send(new client_s3_1.PutObjectCommand({
17
18
  Key: key,
18
19
  Bucket: bucketName,
@@ -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.138",
3
+ "version": "0.0.140",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "types": "./lib/commonjs/index.d.js",