quidproquo-actionprocessor-awslambda 0.0.170 → 0.0.172

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.
@@ -19,3 +19,4 @@ export declare const getBaseStackName: (qpqConfig: QPQConfig) => string;
19
19
  export declare const getInfStackName: (qpqConfig: QPQConfig) => string;
20
20
  export declare const getWebStackName: (qpqConfig: QPQConfig) => string;
21
21
  export declare const getApiStackName: (qpqConfig: QPQConfig) => string;
22
+ export declare const getBootstrapStackName: (qpqConfig: QPQConfig) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getApiStackName = exports.getWebStackName = exports.getInfStackName = exports.getBaseStackName = exports.getEventBusSnsTopicArn = exports.getCFExportNameWebsocketApiIdFromConfig = exports.getCFExportNameDistributionIdArnFromConfig = exports.getCFExportNameSnsTopicArnFromConfig = exports.getCFExportNameApiKeyIdFromConfig = exports.getCFExportNameUserPoolClientIdFromConfig = exports.getCFExportNameCachePolicyIdFromConfig = exports.getCFExportNameUserPoolIdFromConfig = exports.getKvsDynamoTableNameFromConfig = exports.getQpqRuntimeResourceNameFromConfig = exports.getQpqRuntimeResourceName = exports.getConfigRuntimeResourceNameFromConfigWithServiceOverride = exports.getConfigRuntimeResourceNameFromConfig = exports.getConfigRuntimeResourceName = exports.getGlobalQpqRuntimeResourceName = exports.getGlobalConfigRuntimeResourceName = void 0;
3
+ exports.getBootstrapStackName = exports.getApiStackName = exports.getWebStackName = exports.getInfStackName = exports.getBaseStackName = exports.getEventBusSnsTopicArn = exports.getCFExportNameWebsocketApiIdFromConfig = exports.getCFExportNameDistributionIdArnFromConfig = exports.getCFExportNameSnsTopicArnFromConfig = exports.getCFExportNameApiKeyIdFromConfig = exports.getCFExportNameUserPoolClientIdFromConfig = exports.getCFExportNameCachePolicyIdFromConfig = exports.getCFExportNameUserPoolIdFromConfig = exports.getKvsDynamoTableNameFromConfig = exports.getQpqRuntimeResourceNameFromConfig = exports.getQpqRuntimeResourceName = exports.getConfigRuntimeResourceNameFromConfigWithServiceOverride = exports.getConfigRuntimeResourceNameFromConfig = exports.getConfigRuntimeResourceName = exports.getGlobalQpqRuntimeResourceName = exports.getGlobalConfigRuntimeResourceName = void 0;
4
4
  const quidproquo_core_1 = require("quidproquo-core");
5
5
  const quidproquo_config_aws_1 = require("quidproquo-config-aws");
6
6
  const getGlobalConfigRuntimeResourceName = (resourceName, application, environment, feature) => {
@@ -155,3 +155,14 @@ const getApiStackName = (qpqConfig) => {
155
155
  return `${(0, exports.getBaseStackName)(qpqConfig)}-api`;
156
156
  };
157
157
  exports.getApiStackName = getApiStackName;
158
+ const getBootstrapStackName = (qpqConfig) => {
159
+ const appName = quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
160
+ const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
161
+ const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
162
+ const baseName = `${appName}-${environment}`;
163
+ if (feature) {
164
+ return `${baseName}-${feature}-bs`;
165
+ }
166
+ return `${baseName}-bs`;
167
+ };
168
+ exports.getBootstrapStackName = getBootstrapStackName;
@@ -21,8 +21,14 @@ const transformHttpEventHeadersToAPIGatewayProxyResultHeaders = (headers) => {
21
21
  };
22
22
  const getProcessTransformEventParams = (serviceName) => {
23
23
  return ({ eventParams: [apiGatewayEvent, context] }) => __awaiter(void 0, void 0, void 0, function* () {
24
- // The comment here was for when we use base path as our service name, its now in the domain
25
- const path = apiGatewayEvent.path || '/'; // (apiGatewayEvent.path || '').replace(new RegExp(`^(\/${serviceName})/`), '/');
24
+ // const path = (apiGatewayEvent.path || '/').replace(new RegExp(`^(\/${serviceName})/`), '/');
25
+ // Initialize `path` by removing the service name prefix from `apiGatewayEvent.path`.
26
+ // This adjustment is necessary because the API gateway routes requests to services based on
27
+ // a base path that includes the service name. By subtracting `serviceName.length + 1` from the
28
+ // substring method's start index, we effectively strip the leading `/<serviceName>` segment,
29
+ // accounting for the leading slash. This ensures `path` reflects the intended resource location
30
+ // after the service name. Defaults to '/' if `apiGatewayEvent.path` is not provided.
31
+ const path = (apiGatewayEvent.path || '/').substring(serviceName.length + 1);
26
32
  const transformedEventParams = {
27
33
  path,
28
34
  query: Object.assign(Object.assign({}, (apiGatewayEvent.multiValueQueryStringParameters || {})), (apiGatewayEvent.queryStringParameters || {})),
@@ -0,0 +1,6 @@
1
+ import { QPQConfig } from 'quidproquo-core';
2
+ import { FileGenerateTemporarySecureUrlActionProcessor } from 'quidproquo-core';
3
+ declare const _default: (qpqConfig: QPQConfig) => {
4
+ "@quidproquo-core/File/GenerateTemporarySecureUrl": FileGenerateTemporarySecureUrlActionProcessor;
5
+ };
6
+ export default _default;
@@ -0,0 +1,30 @@
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_core_2 = require("quidproquo-core");
14
+ const generatePresignedUrl_1 = require("../../../logic/s3/generatePresignedUrl");
15
+ const utils_1 = require("./utils");
16
+ const getProcessFileGenerateTemporarySecureUrl = (qpqConfig) => {
17
+ return ({ drive, filepath, expirationMs }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ try {
19
+ const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
20
+ const url = yield (0, generatePresignedUrl_1.generatePresignedUrl)(s3BucketName, filepath, quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs);
21
+ return (0, quidproquo_core_2.actionResult)(url);
22
+ }
23
+ catch (error) {
24
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, 'Unable to generate temporary secure URL', error);
25
+ }
26
+ });
27
+ };
28
+ exports.default = (qpqConfig) => ({
29
+ [quidproquo_core_2.FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig),
30
+ });
@@ -5,6 +5,7 @@ declare const _default: (qpqConfig: QPQConfig) => {
5
5
  "@quidproquo-core/File/WriteTextContents": import("quidproquo-core").FileWriteTextContentsActionProcessor;
6
6
  "@quidproquo-core/File/ReadTextContents": import("quidproquo-core").FileReadTextContentsActionProcessor;
7
7
  "@quidproquo-core/File/ListDirectory": import("quidproquo-core").FileListDirectoryActionProcessor;
8
+ "@quidproquo-core/File/GenerateTemporarySecureUrl": import("quidproquo-core").FileGenerateTemporarySecureUrlActionProcessor;
8
9
  "@quidproquo-core/File/Exists": import("quidproquo-core").FileExistsActionProcessor;
9
10
  "@quidproquo-core/File/Delete": import("quidproquo-core").FileDeleteActionProcessor;
10
11
  };
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getFileDeleteActionProcessor_1 = __importDefault(require("./getFileDeleteActionProcessor"));
7
7
  const getFileExistsActionProcessor_1 = __importDefault(require("./getFileExistsActionProcessor"));
8
+ const getFileGenerateTemporarySecureUrlActionProcessor_1 = __importDefault(require("./getFileGenerateTemporarySecureUrlActionProcessor"));
8
9
  const getFileListDirectoryActionProcessor_1 = __importDefault(require("./getFileListDirectoryActionProcessor"));
9
10
  const getFileReadTextContentsActionProcessor_1 = __importDefault(require("./getFileReadTextContentsActionProcessor"));
10
11
  const getFileWriteTextContentsActionProcessor_1 = __importDefault(require("./getFileWriteTextContentsActionProcessor"));
11
12
  const getFileReadBinaryContentsActionProcessor_1 = __importDefault(require("./getFileReadBinaryContentsActionProcessor"));
12
13
  const getFileWriteBinaryContentsActionProcessor_1 = __importDefault(require("./getFileWriteBinaryContentsActionProcessor"));
13
- exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getFileDeleteActionProcessor_1.default)(qpqConfig)), (0, getFileExistsActionProcessor_1.default)(qpqConfig)), (0, getFileListDirectoryActionProcessor_1.default)(qpqConfig)), (0, getFileReadTextContentsActionProcessor_1.default)(qpqConfig)), (0, getFileWriteTextContentsActionProcessor_1.default)(qpqConfig)), (0, getFileReadBinaryContentsActionProcessor_1.default)(qpqConfig)), (0, getFileWriteBinaryContentsActionProcessor_1.default)(qpqConfig)));
14
+ exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getFileDeleteActionProcessor_1.default)(qpqConfig)), (0, getFileExistsActionProcessor_1.default)(qpqConfig)), (0, getFileGenerateTemporarySecureUrlActionProcessor_1.default)(qpqConfig)), (0, getFileListDirectoryActionProcessor_1.default)(qpqConfig)), (0, getFileReadTextContentsActionProcessor_1.default)(qpqConfig)), (0, getFileWriteTextContentsActionProcessor_1.default)(qpqConfig)), (0, getFileReadBinaryContentsActionProcessor_1.default)(qpqConfig)), (0, getFileWriteBinaryContentsActionProcessor_1.default)(qpqConfig)));
@@ -28,12 +28,11 @@ function createAwsClient(ClientClass, args) {
28
28
  const originalSend = newClient.send;
29
29
  newClient.send = function (...sendArgs) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- const paramsText = JSON.stringify(sendArgs);
32
31
  try {
33
32
  return yield originalSend.apply(this, sendArgs);
34
33
  }
35
34
  catch (error) {
36
- error.message = `aws client (${argsKey}) send with args: ${paramsText}\n\n${error.message}`;
35
+ console.log(ClientClass.name || 'aws client', args, 'send args', sendArgs, 'error', error.message);
37
36
  throw error;
38
37
  }
39
38
  });
@@ -0,0 +1 @@
1
+ export declare const generatePresignedUrl: (bucketName: string, objectKey: string, region: string, expirationMs: number) => Promise<string>;
@@ -0,0 +1,32 @@
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
+ exports.generatePresignedUrl = void 0;
13
+ const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
15
+ const createAwsClient_1 = require("../createAwsClient");
16
+ const generatePresignedUrl = (bucketName, objectKey, region, expirationMs) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
18
+ // Define the command for getting an object, which will be presigned
19
+ const getObjectCommand = new client_s3_1.GetObjectCommand({
20
+ Bucket: bucketName,
21
+ Key: objectKey,
22
+ });
23
+ try {
24
+ const url = yield (0, s3_request_presigner_1.getSignedUrl)(s3Client, getObjectCommand, { expiresIn: expirationMs / 1000 });
25
+ return url;
26
+ }
27
+ catch (error) {
28
+ console.error('Error generating presigned URL', error);
29
+ throw error;
30
+ }
31
+ });
32
+ exports.generatePresignedUrl = generatePresignedUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.170",
3
+ "version": "0.0.172",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "types": "./lib/commonjs/index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "@aws-sdk/client-sns": "^3.379.1",
39
39
  "@aws-sdk/client-sqs": "^3.379.1",
40
40
  "@aws-sdk/client-ssm": "^3.379.1",
41
+ "@aws-sdk/s3-request-presigner": "^3.379.1",
41
42
  "aws-jwt-verify": "^3.4.0",
42
43
  "aws-sdk": "^2.1322.0",
43
44
  "busboy": "^1.6.0",
@@ -46,9 +47,9 @@
46
47
  "lodash": "^4.17.21",
47
48
  "node-cache": "^5.1.2",
48
49
  "node-match-path": "^0.6.3",
49
- "quidproquo-config-aws": "0.0.170",
50
- "quidproquo-core": "0.0.170",
51
- "quidproquo-webserver": "0.0.170"
50
+ "quidproquo-config-aws": "0.0.172",
51
+ "quidproquo-core": "0.0.172",
52
+ "quidproquo-webserver": "0.0.172"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@types/aws-lambda": "^8.10.109",
@@ -56,7 +57,7 @@
56
57
  "@types/jsonwebtoken": "^9.0.2",
57
58
  "@types/lodash": "^4.14.194",
58
59
  "@types/node": "^18.11.9",
59
- "quidproquo-tsconfig": "0.0.170",
60
+ "quidproquo-tsconfig": "0.0.172",
60
61
  "typescript": "^4.9.3"
61
62
  }
62
63
  }