quidproquo-actionprocessor-awslambda 0.1.6 → 0.1.8
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.
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptActionProcessor.js +8 -3
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js +23 -5
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/createDriveFileResolver.js +2 -2
- package/lib/commonjs/getActionProcessor/core/ai/logic/createDriveFileResolver.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/index.d.ts +3 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/index.js +3 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/index.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/mapAiStreamFinish.js +2 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/mapAiStreamFinish.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/mapAiStreamFinishStep.js +2 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/mapAiStreamFinishStep.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/prepareAiPromptCall.js +10 -12
- package/lib/commonjs/getActionProcessor/core/ai/logic/prepareAiPromptCall.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/toAiStreamFinishReason.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toAiStreamFinishReason.js +10 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toAiStreamFinishReason.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toCacheableMessages.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toCacheableMessages.js +19 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toCacheableMessages.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toCacheableSystem.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toCacheableSystem.js +23 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toCacheableSystem.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/ai/logic/toSdkMessages.d.ts +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/toSdkMessages.js +1 -1
- package/lib/commonjs/getActionProcessor/core/ai/logic/toSdkMessages.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.d.ts +2 -2
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.js +10 -6
- package/lib/commonjs/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileDeleteActionProcessor.js +4 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileDeleteActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileExistsActionProcessor.js +4 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileExistsActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.js +7 -3
- package/lib/commonjs/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +7 -3
- package/lib/commonjs/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileIsColdStorageActionProcessor.js +4 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileIsColdStorageActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js +6 -4
- package/lib/commonjs/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.js +4 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileReadObjectJsonActionProcessor.js +7 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileReadObjectJsonActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.js +6 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileStreamOpenActionProcessor.js +3 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileStreamOpenActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js +3 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteObjectJsonActionProcessor.js +3 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteObjectJsonActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js +3 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreDeleteActionProcessor.js +11 -9
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreDeleteActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreGetActionProcessor.js +7 -3
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreGetActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreGetAllActionProcessor.js +8 -3
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreGetAllActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js +9 -5
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.js +9 -2
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreUpdateActionProcessor.js +10 -8
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreUpdateActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js +13 -11
- package/lib/commonjs/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/index.js +2 -1
- package/lib/commonjs/getActionProcessor/core/keyValueStore/index.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryRequestEmailVerificationActionProcessor.js +2 -2
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryRequestEmailVerificationActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectorySetAccessTokenActionProcessor.js +11 -1
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectorySetAccessTokenActionProcessor.js.map +1 -1
- package/lib/commonjs/lambdaHandlers/getSqsEvent_queueEvent.js +3 -3
- package/lib/commonjs/lambdaHandlers/getSqsEvent_queueEvent.js.map +1 -1
- package/lib/commonjs/logic/cognito/requestEmailVerificationCode.d.ts +2 -1
- package/lib/commonjs/logic/cognito/requestEmailVerificationCode.js +8 -1
- package/lib/commonjs/logic/cognito/requestEmailVerificationCode.js.map +1 -1
- package/lib/commonjs/logic/dynamo/getAllItems.d.ts +2 -1
- package/lib/commonjs/logic/dynamo/getAllItems.js +7 -2
- package/lib/commonjs/logic/dynamo/getAllItems.js.map +1 -1
- package/lib/commonjs/logic/dynamo/getItem.d.ts +2 -1
- package/lib/commonjs/logic/dynamo/getItem.js +8 -5
- package/lib/commonjs/logic/dynamo/getItem.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/getAiPromptActionProcessor.js +9 -4
- package/lib/esm/getActionProcessor/core/ai/getAiPromptActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js +21 -5
- package/lib/esm/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/createDriveFileResolver.js +2 -2
- package/lib/esm/getActionProcessor/core/ai/logic/createDriveFileResolver.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/index.d.ts +3 -0
- package/lib/esm/getActionProcessor/core/ai/logic/index.js +3 -0
- package/lib/esm/getActionProcessor/core/ai/logic/index.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/mapAiStreamFinish.js +2 -1
- package/lib/esm/getActionProcessor/core/ai/logic/mapAiStreamFinish.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/mapAiStreamFinishStep.js +2 -1
- package/lib/esm/getActionProcessor/core/ai/logic/mapAiStreamFinishStep.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/prepareAiPromptCall.js +13 -8
- package/lib/esm/getActionProcessor/core/ai/logic/prepareAiPromptCall.js.map +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/toAiStreamFinishReason.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toAiStreamFinishReason.js +6 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toAiStreamFinishReason.js.map +1 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toCacheableMessages.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toCacheableMessages.js +21 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toCacheableMessages.js.map +1 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toCacheableSystem.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toCacheableSystem.js +19 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toCacheableSystem.js.map +1 -0
- package/lib/esm/getActionProcessor/core/ai/logic/toSdkMessages.d.ts +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/toSdkMessages.js +1 -1
- package/lib/esm/getActionProcessor/core/ai/logic/toSdkMessages.js.map +1 -1
- package/lib/esm/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.d.ts +2 -2
- package/lib/esm/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.js +10 -6
- package/lib/esm/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileDeleteActionProcessor.js +5 -3
- package/lib/esm/getActionProcessor/core/file/getFileDeleteActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileExistsActionProcessor.js +5 -3
- package/lib/esm/getActionProcessor/core/file/getFileExistsActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.js +9 -5
- package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +9 -5
- package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileIsColdStorageActionProcessor.js +5 -3
- package/lib/esm/getActionProcessor/core/file/getFileIsColdStorageActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js +7 -4
- package/lib/esm/getActionProcessor/core/file/getFileListDirectoryActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.js +5 -3
- package/lib/esm/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileReadObjectJsonActionProcessor.js +8 -3
- package/lib/esm/getActionProcessor/core/file/getFileReadObjectJsonActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.js +7 -3
- package/lib/esm/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileStreamOpenActionProcessor.js +4 -3
- package/lib/esm/getActionProcessor/core/file/getFileStreamOpenActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js +4 -3
- package/lib/esm/getActionProcessor/core/file/getFileWriteBinaryContentsActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileWriteObjectJsonActionProcessor.js +4 -3
- package/lib/esm/getActionProcessor/core/file/getFileWriteObjectJsonActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js +4 -3
- package/lib/esm/getActionProcessor/core/file/getFileWriteTextContentsActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreDeleteActionProcessor.js +7 -5
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreDeleteActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreGetActionProcessor.js +8 -4
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreGetActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreGetAllActionProcessor.js +9 -4
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreGetAllActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js +10 -6
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.js +11 -4
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreUpdateActionProcessor.js +7 -5
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreUpdateActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js +14 -12
- package/lib/esm/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/keyValueStore/index.js +2 -0
- package/lib/esm/getActionProcessor/core/keyValueStore/index.js.map +1 -1
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryRequestEmailVerificationActionProcessor.js +2 -2
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryRequestEmailVerificationActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectorySetAccessTokenActionProcessor.js +12 -2
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectorySetAccessTokenActionProcessor.js.map +1 -1
- package/lib/esm/lambdaHandlers/getSqsEvent_queueEvent.js +3 -3
- package/lib/esm/lambdaHandlers/getSqsEvent_queueEvent.js.map +1 -1
- package/lib/esm/logic/cognito/requestEmailVerificationCode.d.ts +2 -1
- package/lib/esm/logic/cognito/requestEmailVerificationCode.js +7 -1
- package/lib/esm/logic/cognito/requestEmailVerificationCode.js.map +1 -1
- package/lib/esm/logic/dynamo/getAllItems.d.ts +2 -1
- package/lib/esm/logic/dynamo/getAllItems.js +7 -2
- package/lib/esm/logic/dynamo/getAllItems.js.map +1 -1
- package/lib/esm/logic/dynamo/getItem.d.ts +2 -1
- package/lib/esm/logic/dynamo/getItem.js +8 -5
- package/lib/esm/logic/dynamo/getItem.js.map +1 -1
- package/lib/extension-layer/qpq-log-extension/index.js +37 -37
- package/package.json +7 -7
package/lib/esm/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { actionResult, actionResultError, ErrorTypeEnum, EventActionType, qpqCoreUtils, } from 'quidproquo-core';
|
|
2
2
|
import { matchUrl } from '../../../../../awsLambdaUtils';
|
|
3
|
-
export const getQueueConfigSetting = () => {
|
|
4
|
-
|
|
5
|
-
//
|
|
3
|
+
export const getQueueConfigSetting = (qpqConfig) => {
|
|
4
|
+
// Only the queue name travels via the environment - the full setting lives in
|
|
5
|
+
// the bundled qpqConfig (serializing it into env blows the lambda 4KB limit).
|
|
6
|
+
const queueName = process.env.queueName;
|
|
7
|
+
const queueQPQConfigSetting = qpqCoreUtils.getQueueConfigSettingByName(queueName, qpqConfig);
|
|
8
|
+
if (!queueQPQConfigSetting) {
|
|
9
|
+
throw new Error(`No queue config setting found for queue [${queueName}]`);
|
|
10
|
+
}
|
|
6
11
|
return queueQPQConfigSetting;
|
|
7
12
|
};
|
|
8
13
|
const getProcessMatchStory = (qpqConfig) => {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const queueQueueProcessors = qpqCoreUtils.getQueueQueueProcessors(queueQPQConfigSetting.name, qpqConfig);
|
|
14
|
+
const queueQPQConfigSetting = getQueueConfigSetting(qpqConfig);
|
|
15
|
+
const queueQueueProcessors = queueQPQConfigSetting.qpqQueueProcessors;
|
|
12
16
|
const queueTypes = Object.keys(queueQueueProcessors).sort();
|
|
13
17
|
return async ({ qpqEventRecord }) => {
|
|
14
18
|
console.log('qpqEventRecord', JSON.stringify(qpqEventRecord, null, 2));
|
package/lib/esm/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEventMatchStoryActionProcessor.js","sourceRoot":"","sources":["../../../../../../../src/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EAGf,YAAY,GAEb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,
|
|
1
|
+
{"version":3,"file":"getEventMatchStoryActionProcessor.js","sourceRoot":"","sources":["../../../../../../../src/getActionProcessor/core/event/sqs/queue/getEventMatchStoryActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EAGf,YAAY,GAEb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAoB,EAAyB,EAAE;IACnF,8EAA8E;IAC9E,8EAA8E;IAC9E,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAmB,CAAC;IAClD,MAAM,qBAAqB,GAAG,YAAY,CAAC,2BAA2B,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAE7F,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,4CAA4C,SAAS,GAAG,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAgF,EAAE;IAClI,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/D,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC;IACtE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAAC;IAE5D,OAAO,KAAK,EAAE,EAAE,cAA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ProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n EventActionType,\n EventMatchStoryActionProcessor,\n QPQConfig,\n qpqCoreUtils,\n QueueQPQConfigSetting,\n} from 'quidproquo-core';\n\nimport { matchUrl } from '../../../../../awsLambdaUtils';\nimport { EventInput, InternalEventRecord, MatchResult } from './types';\n\nexport const getQueueConfigSetting = (qpqConfig: QPQConfig): QueueQPQConfigSetting => {\n // Only the queue name travels via the environment - the full setting lives in\n // the bundled qpqConfig (serializing it into env blows the lambda 4KB limit).\n const queueName = process.env.queueName as string;\n const queueQPQConfigSetting = qpqCoreUtils.getQueueConfigSettingByName(queueName, qpqConfig);\n\n if (!queueQPQConfigSetting) {\n throw new Error(`No queue config setting found for queue [${queueName}]`);\n }\n\n return queueQPQConfigSetting;\n};\n\nconst getProcessMatchStory = (qpqConfig: QPQConfig): EventMatchStoryActionProcessor<InternalEventRecord, MatchResult, EventInput> => {\n const queueQPQConfigSetting = getQueueConfigSetting(qpqConfig);\n const queueQueueProcessors = queueQPQConfigSetting.qpqQueueProcessors;\n const queueTypes = Object.keys(queueQueueProcessors).sort();\n\n return async ({ qpqEventRecord }) => {\n console.log('qpqEventRecord', JSON.stringify(qpqEventRecord, null, 2));\n\n // Find the most relevant match\n const matchedQueueType = queueTypes\n .map((qt) => ({\n match: matchUrl(qt, qpqEventRecord.message.type),\n queueType: qt,\n }))\n .find((m) => m.match.didMatch);\n\n if (!matchedQueueType) {\n // If we have event bus subscriptions then we don't want to error if we can't match\n // early exit will just exit gracefully\n if (queueQPQConfigSetting.eventBusSubscriptions.length > 0) {\n return actionResult<MatchResult>({});\n }\n\n return actionResultError(ErrorTypeEnum.NotFound, `queue type not found ${qpqEventRecord.message.type}`);\n }\n\n const sourceEntry = queueQueueProcessors[matchedQueueType.queueType];\n\n return actionResult<MatchResult>({\n runtime: sourceEntry,\n runtimeOptions: matchedQueueType.match.params || {},\n config: matchedQueueType.queueType,\n });\n };\n};\n\nexport const getEventMatchStoryActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [EventActionType.MatchStory]: getProcessMatchStory(qpqConfig),\n});\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileDeleteErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileDeleteErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { deleteFiles } from '../../../logic/s3/s3Utils';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileDelete = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, filepaths }) => {
|
|
6
|
+
return async ({ drive, filepaths, scope }) => {
|
|
7
7
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
8
8
|
try {
|
|
9
|
-
const
|
|
9
|
+
const keys = filepaths.map((filepath) => composeScopedFilePath(scope, filepath));
|
|
10
|
+
const errored = await deleteFiles(s3BucketName, keys, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
10
11
|
// errored deletes are a graceful success ~ Retry
|
|
11
12
|
// if (errored.length > 0) {
|
|
12
13
|
// return actionResultError(
|
|
@@ -20,6 +21,7 @@ const getProcessFileDelete = (qpqConfig) => {
|
|
|
20
21
|
return actionResultErrorFromCaughtError(error, {
|
|
21
22
|
AccessDenied: () => actionResultError(FileDeleteErrorTypeEnum.AccessDenied, 'Access denied deleting files'),
|
|
22
23
|
NoSuchBucket: () => actionResultError(FileDeleteErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),
|
|
24
|
+
InvalidScopeError: (error) => actionResultError(FileDeleteErrorTypeEnum.InvalidScope, error.message),
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileDeleteActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileDeleteActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAA6B,EAAE;IAC/E,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileDeleteActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileDeleteActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAA6B,EAAE;IAC/E,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;QAC3C,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;YACjF,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,YAAY,EAAE,IAAI,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAC;YAErH,iDAAiD;YACjD,4BAA4B;YAC5B,8BAA8B;YAC9B,kCAAkC;YAClC,kDAAkD;YAClD,OAAO;YACP,IAAI;YAEJ,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,YAAY,EAAE,8BAA8B,CAAC;gBAC3G,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,aAAa,EAAE,4BAA4B,KAAK,EAAE,CAAC;gBACjH,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aACrG,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IACtI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC;CACzD,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport { ActionProcessorList, ActionProcessorListResolver, QPQConfig } from 'quidproquo-core';\nimport {\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileDeleteActionProcessor,\n FileDeleteErrorTypeEnum,\n} from 'quidproquo-core';\n\nimport { deleteFiles } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileDelete = (qpqConfig: QPQConfig): FileDeleteActionProcessor => {\n return async ({ drive, filepaths, scope }) => {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n\n try {\n const keys = filepaths.map((filepath) => composeScopedFilePath(scope, filepath));\n const errored = await deleteFiles(s3BucketName, keys, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig));\n\n // errored deletes are a graceful success ~ Retry\n // if (errored.length > 0) {\n // return actionResultError(\n // ErrorTypeEnum.GenericError,\n // `Could not delete files ${errored.length}`,\n // );\n // }\n\n return actionResult(errored);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n AccessDenied: () => actionResultError(FileDeleteErrorTypeEnum.AccessDenied, 'Access denied deleting files'),\n NoSuchBucket: () => actionResultError(FileDeleteErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),\n InvalidScopeError: (error) => actionResultError(FileDeleteErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileDeleteActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Delete]: getProcessFileDelete(qpqConfig),\n});\n"]}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileExistsErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileExistsErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { objectExists } from '../../../logic/s3/s3Utils';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileExists = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, filepath }) => {
|
|
6
|
+
return async ({ drive, filepath, scope }) => {
|
|
7
7
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
const key = composeScopedFilePath(scope, filepath);
|
|
10
|
+
return actionResult(await objectExists(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig)));
|
|
10
11
|
}
|
|
11
12
|
catch (error) {
|
|
12
13
|
return actionResultErrorFromCaughtError(error, {
|
|
13
14
|
AccessDenied: () => actionResultError(FileExistsErrorTypeEnum.AccessDenied, 'Access denied checking file existence'),
|
|
14
15
|
Forbidden: () => actionResultError(FileExistsErrorTypeEnum.AccessDenied, 'Access denied checking file existence'),
|
|
16
|
+
InvalidScopeError: (error) => actionResultError(FileExistsErrorTypeEnum.InvalidScope, error.message),
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileExistsActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileExistsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,uBAAuB,GAExB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAA6B,EAAE;IAC/E,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileExistsActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileExistsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,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orList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileExistsActionProcessor,\n FileExistsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { objectExists } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileExists = (qpqConfig: QPQConfig): FileExistsActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n\n try {\n const key = composeScopedFilePath(scope, filepath);\n return actionResult(await objectExists(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig)));\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n AccessDenied: () => actionResultError(FileExistsErrorTypeEnum.AccessDenied, 'Access denied checking file existence'),\n Forbidden: () => actionResultError(FileExistsErrorTypeEnum.AccessDenied, 'Access denied checking file existence'),\n InvalidScopeError: (error) => actionResultError(FileExistsErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileExistsActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Exists]: getProcessFileExists(qpqConfig),\n});\n"]}
|
package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResultError,
|
|
3
|
-
import { actionResult, FileActionType, FileGenerateTemporarySecureUrlErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResultError, actionResultErrorFromCaughtError } from 'quidproquo-core';
|
|
3
|
+
import { actionResult, composeScopedFilePath, FileActionType, FileGenerateTemporarySecureUrlErrorTypeEnum, } from 'quidproquo-core';
|
|
4
4
|
import { generatePresignedUrl } from '../../../logic/s3/generatePresignedUrl';
|
|
5
5
|
import { resolveStorageDriveBucketName } from './utils';
|
|
6
6
|
// SigV4 presigned URLs cannot expire more than 7 days in the future
|
|
7
7
|
const maxExpirationMs = 7 * 24 * 60 * 60 * 1000;
|
|
8
8
|
const getProcessFileGenerateTemporarySecureUrl = (qpqConfig) => {
|
|
9
|
-
return async ({ drive, filepath, expirationMs }) => {
|
|
9
|
+
return async ({ drive, filepath, expirationMs, scope }) => {
|
|
10
10
|
if (expirationMs > maxExpirationMs) {
|
|
11
11
|
return actionResultError(FileGenerateTemporarySecureUrlErrorTypeEnum.ExpirationTooLong, 'Expiration exceeds the 7 day maximum for presigned URLs');
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
15
|
-
const url = await generatePresignedUrl(s3BucketName, filepath, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs);
|
|
15
|
+
const url = await generatePresignedUrl(s3BucketName, composeScopedFilePath(scope, filepath), qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs);
|
|
16
16
|
return actionResult(url);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
|
-
|
|
19
|
+
// Name-keyed, not instanceof: under npm link / module federation the
|
|
20
|
+
// error can come from another copy of quidproquo-core.
|
|
21
|
+
return actionResultErrorFromCaughtError(error, {
|
|
22
|
+
InvalidScopeError: (error) => actionResultError(FileGenerateTemporarySecureUrlErrorTypeEnum.InvalidScope, error.message),
|
|
23
|
+
});
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
26
|
};
|
package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileGenerateTemporarySecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAoD,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"getFileGenerateTemporarySecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileGenerateTemporarySecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAoD,iBAAiB,EAAE,gCAAgC,EAAa,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EAEd,2CAA2C,GAC5C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,oEAAoE;AACpE,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,wCAAwC,GAAG,CAAC,SAAoB,EAAiD,EAAE;IACvH,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE;QACxD,IAAI,YAAY,GAAG,eAAe,EAAE,CAAC;YACnC,OAAO,iBAAiB,CACtB,2CAA2C,CAAC,iBAAiB,EAC7D,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACrE,MAAM,GAAG,GAAG,MAAM,oBAAoB,CACpC,YAAY,EACZ,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,EACtC,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,EAC7D,YAAY,CACb,CAAC;YAEF,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,qEAAqE;YACrE,uDAAuD;YACvD,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,2CAA2C,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aACzH,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gDAAgD,GAAgC,KAAK,EAChG,SAAoB,EACU,EAAE,CAAC,CAAC;IAClC,CAAC,cAAc,CAAC,0BAA0B,CAAC,EAAE,wCAAwC,CAAC,SAAS,CAAC;CACjG,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport { ActionProcessorList, ActionProcessorListResolver, actionResultError, actionResultErrorFromCaughtError, QPQConfig } from 'quidproquo-core';\nimport {\n actionResult,\n composeScopedFilePath,\n FileActionType,\n FileGenerateTemporarySecureUrlActionProcessor,\n FileGenerateTemporarySecureUrlErrorTypeEnum,\n} from 'quidproquo-core';\n\nimport { generatePresignedUrl } from '../../../logic/s3/generatePresignedUrl';\nimport { resolveStorageDriveBucketName } from './utils';\n\n// SigV4 presigned URLs cannot expire more than 7 days in the future\nconst maxExpirationMs = 7 * 24 * 60 * 60 * 1000;\n\nconst getProcessFileGenerateTemporarySecureUrl = (qpqConfig: QPQConfig): FileGenerateTemporarySecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs, scope }) => {\n if (expirationMs > maxExpirationMs) {\n return actionResultError(\n FileGenerateTemporarySecureUrlErrorTypeEnum.ExpirationTooLong,\n 'Expiration exceeds the 7 day maximum for presigned URLs',\n );\n }\n\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const url = await generatePresignedUrl(\n s3BucketName,\n composeScopedFilePath(scope, filepath),\n qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig),\n expirationMs,\n );\n\n return actionResult(url);\n } catch (error: unknown) {\n // Name-keyed, not instanceof: under npm link / module federation the\n // error can come from another copy of quidproquo-core.\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileGenerateTemporarySecureUrlErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileGenerateTemporarySecureUrlActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig),\n});\n"]}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResultError,
|
|
3
|
-
import { actionResult, FileActionType, FileGenerateTemporaryUploadSecureUrlErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResultError, actionResultErrorFromCaughtError } from 'quidproquo-core';
|
|
3
|
+
import { actionResult, composeScopedFilePath, FileActionType, FileGenerateTemporaryUploadSecureUrlErrorTypeEnum, } from 'quidproquo-core';
|
|
4
4
|
import { generatePresignedUploadUrl } from '../../../logic/s3/generatePresignedUploadUrl';
|
|
5
5
|
import { resolveStorageDriveBucketName } from './utils';
|
|
6
6
|
// SigV4 presigned URLs cannot expire more than 7 days in the future
|
|
7
7
|
const maxExpirationMs = 7 * 24 * 60 * 60 * 1000;
|
|
8
8
|
const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig) => {
|
|
9
|
-
return async ({ drive, filepath, expirationMs, contentType }, session) => {
|
|
9
|
+
return async ({ drive, filepath, expirationMs, contentType, scope }, session) => {
|
|
10
10
|
if (expirationMs > maxExpirationMs) {
|
|
11
11
|
return actionResultError(FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.ExpirationTooLong, 'Expiration exceeds the 7 day maximum for presigned URLs');
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
15
|
-
const url = await generatePresignedUploadUrl(s3BucketName, filepath, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs, session.correlation, contentType);
|
|
15
|
+
const url = await generatePresignedUploadUrl(s3BucketName, composeScopedFilePath(scope, filepath), qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs, session.correlation, contentType);
|
|
16
16
|
return actionResult(url);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
|
-
|
|
19
|
+
// Name-keyed, not instanceof: under npm link / module federation the
|
|
20
|
+
// error can come from another copy of quidproquo-core.
|
|
21
|
+
return actionResultErrorFromCaughtError(error, {
|
|
22
|
+
InvalidScopeError: (error) => actionResultError(FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.InvalidScope, error.message),
|
|
23
|
+
});
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAoD,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAoD,iBAAiB,EAAE,gCAAgC,EAAa,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EAEd,iDAAiD,GAClD,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,C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AC;CAC7G,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport { ActionProcessorList, ActionProcessorListResolver, actionResultError, actionResultErrorFromCaughtError, QPQConfig } from 'quidproquo-core';\nimport {\n actionResult,\n composeScopedFilePath,\n FileActionType,\n FileGenerateTemporaryUploadSecureUrlActionProcessor,\n FileGenerateTemporaryUploadSecureUrlErrorTypeEnum,\n} from 'quidproquo-core';\n\nimport { generatePresignedUploadUrl } from '../../../logic/s3/generatePresignedUploadUrl';\nimport { resolveStorageDriveBucketName } from './utils';\n\n// SigV4 presigned URLs cannot expire more than 7 days in the future\nconst maxExpirationMs = 7 * 24 * 60 * 60 * 1000;\n\nconst getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig: QPQConfig): FileGenerateTemporaryUploadSecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs, contentType, scope }, session) => {\n if (expirationMs > maxExpirationMs) {\n return actionResultError(\n FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.ExpirationTooLong,\n 'Expiration exceeds the 7 day maximum for presigned URLs',\n );\n }\n\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const url = await generatePresignedUploadUrl(\n s3BucketName,\n composeScopedFilePath(scope, filepath),\n qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig),\n expirationMs,\n session.correlation,\n contentType,\n );\n\n return actionResult(url);\n } catch (error: unknown) {\n // Name-keyed, not instanceof: under npm link / module federation the\n // error can come from another copy of quidproquo-core.\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileGenerateTemporaryUploadSecureUrlActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig),\n});\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileIsColdStorageErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileIsColdStorageErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { getObjectStorageClass } from '../../../logic/s3/getObjectStorageClass';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileIsColdStorage = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, filepath }) => {
|
|
6
|
+
return async ({ drive, filepath, scope }) => {
|
|
7
7
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
8
8
|
try {
|
|
9
|
-
const
|
|
9
|
+
const key = composeScopedFilePath(scope, filepath);
|
|
10
|
+
const isColdStorage = (await getObjectStorageClass(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig))) === 'cold_storage';
|
|
10
11
|
return actionResult(isColdStorage);
|
|
11
12
|
}
|
|
12
13
|
catch (error) {
|
|
@@ -16,6 +17,7 @@ const getProcessFileIsColdStorage = (qpqConfig) => {
|
|
|
16
17
|
NotFound: () => actionResultError(FileIsColdStorageErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
17
18
|
NoSuchKey: () => actionResultError(FileIsColdStorageErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
18
19
|
NoSuchBucket: () => actionResultError(FileIsColdStorageErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),
|
|
20
|
+
InvalidScopeError: (error) => actionResultError(FileIsColdStorageErrorTypeEnum.InvalidScope, error.message),
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileIsColdStorageActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileIsColdStorageActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,8BAA8B,GAE/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,2BAA2B,GAAG,CAAC,SAAoB,EAAoC,EAAE;IAC7F,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileIsColdStorageActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileIsColdStorageActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,8BAA8B,GAE/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,2BAA2B,GAAG,CAAC,SAAoB,EAAoC,EAAE;IAC7F,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1C,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACnD,MAAM,aAAa,GACjB,CAAC,MAAM,qBAAqB,CAAC,YAAY,EAAE,GAAG,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC;YAErI,OAAO,YAAY,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,0CAA0C,CAAC;gBAC9H,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,0CAA0C,CAAC;gBAC3H,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBAC7G,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBAC9G,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,aAAa,EAAE,4BAA4B,KAAK,EAAE,CAAC;gBACxH,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aAC5G,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mCAAmC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7I,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAC,SAAS,CAAC;CACvE,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileIsColdStorageActionProcessor,\n FileIsColdStorageErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { getObjectStorageClass } from '../../../logic/s3/getObjectStorageClass';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileIsColdStorage = (qpqConfig: QPQConfig): FileIsColdStorageActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n\n try {\n const key = composeScopedFilePath(scope, filepath);\n const isColdStorage =\n (await getObjectStorageClass(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig))) === 'cold_storage';\n\n return actionResult(isColdStorage);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n AccessDenied: () => actionResultError(FileIsColdStorageErrorTypeEnum.AccessDenied, 'Access denied reading file storage class'),\n Forbidden: () => actionResultError(FileIsColdStorageErrorTypeEnum.AccessDenied, 'Access denied reading file storage class'),\n NotFound: () => actionResultError(FileIsColdStorageErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n NoSuchKey: () => actionResultError(FileIsColdStorageErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n NoSuchBucket: () => actionResultError(FileIsColdStorageErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),\n InvalidScopeError: (error) => actionResultError(FileIsColdStorageErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileIsColdStorageActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.IsColdStorage]: getProcessFileIsColdStorage(qpqConfig),\n});\n"]}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileListDirectoryErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileListDirectoryErrorTypeEnum, stripScopedFilePath, } from 'quidproquo-core';
|
|
3
3
|
import { listFiles } from '../../../logic/s3/s3Utils';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileListDirectory = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, folderPath, maxFiles, pageToken }) => {
|
|
6
|
+
return async ({ drive, folderPath, maxFiles, pageToken, scope }) => {
|
|
7
7
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
8
8
|
try {
|
|
9
|
-
const s3FileList = await listFiles(s3BucketName, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), folderPath, maxFiles, pageToken);
|
|
10
|
-
//
|
|
9
|
+
const s3FileList = await listFiles(s3BucketName, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), composeScopedFilePath(scope, folderPath), maxFiles, pageToken);
|
|
10
|
+
// S3 keys carry the scope prefix; strip it so callers see the same
|
|
11
|
+
// scope-relative paths they passed in. Add the drive onto the list.
|
|
11
12
|
const fileInfos = s3FileList.fileInfos.map((s3fi) => ({
|
|
12
13
|
...s3fi,
|
|
14
|
+
filepath: stripScopedFilePath(scope, s3fi.filepath),
|
|
13
15
|
drive,
|
|
14
16
|
}));
|
|
15
17
|
return actionResult({
|
|
@@ -22,6 +24,7 @@ const getProcessFileListDirectory = (qpqConfig) => {
|
|
|
22
24
|
AccessDenied: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, 'Access denied listing directory'),
|
|
23
25
|
Forbidden: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, 'Access denied listing directory'),
|
|
24
26
|
NoSuchBucket: () => actionResultError(FileListDirectoryErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),
|
|
27
|
+
InvalidScopeError: (error) => actionResultError(FileListDirectoryErrorTypeEnum.InvalidScope, error.message),
|
|
25
28
|
});
|
|
26
29
|
}
|
|
27
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileListDirectoryActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileListDirectoryActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,8BAA8B,
|
|
1
|
+
{"version":3,"file":"getFileListDirectoryActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileListDirectoryActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,8BAA8B,EAE9B,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,2BAA2B,GAAG,CAAC,SAAoB,EAAoC,EAAE;IAC7F,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;QACjE,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,SAAS,CAChC,YAAY,EACZ,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,EAC7D,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,EACxC,QAAQ,EACR,SAAS,CACV,CAAC;YAEF,mEAAmE;YACnE,oEAAoE;YACpE,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACpD,GAAG,IAAI;gBACP,QAAQ,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;gBACnD,KAAK;aACN,CAAC,CAAC,CAAC;YAEJ,OAAO,YAAY,CAAC;gBAClB,SAAS;gBACT,SAAS,EAAE,UAAU,CAAC,SAAS;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,iCAAiC,CAAC;gBACrH,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,iCAAiC,CAAC;gBAClH,YAAY,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,aAAa,EAAE,4BAA4B,KAAK,EAAE,CAAC;gBACxH,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aAC5G,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mCAAmC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7I,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAC,SAAS,CAAC;CACvE,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileListDirectoryActionProcessor,\n FileListDirectoryErrorTypeEnum,\n QPQConfig,\n stripScopedFilePath,\n} from 'quidproquo-core';\n\nimport { listFiles } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileListDirectory = (qpqConfig: QPQConfig): FileListDirectoryActionProcessor => {\n return async ({ drive, folderPath, maxFiles, pageToken, scope }) => {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n\n try {\n const s3FileList = await listFiles(\n s3BucketName,\n qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig),\n composeScopedFilePath(scope, folderPath),\n maxFiles,\n pageToken,\n );\n\n // S3 keys carry the scope prefix; strip it so callers see the same\n // scope-relative paths they passed in. Add the drive onto the list.\n const fileInfos = s3FileList.fileInfos.map((s3fi) => ({\n ...s3fi,\n filepath: stripScopedFilePath(scope, s3fi.filepath),\n drive,\n }));\n\n return actionResult({\n fileInfos,\n pageToken: s3FileList.pageToken,\n });\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n AccessDenied: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, 'Access denied listing directory'),\n Forbidden: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, 'Access denied listing directory'),\n NoSuchBucket: () => actionResultError(FileListDirectoryErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),\n InvalidScopeError: (error) => actionResultError(FileListDirectoryErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileListDirectoryActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ListDirectory]: getProcessFileListDirectory(qpqConfig),\n});\n"]}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileReadBinaryContentsErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileReadBinaryContentsErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { readBinaryFile } from '../../../logic/s3/s3Utils';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileReadBinaryContents = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, filepath }) => {
|
|
6
|
+
return async ({ drive, filepath, scope }) => {
|
|
7
7
|
try {
|
|
8
8
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
9
|
-
|
|
9
|
+
const key = composeScopedFilePath(scope, filepath);
|
|
10
|
+
return actionResult(await readBinaryFile(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig)));
|
|
10
11
|
}
|
|
11
12
|
catch (error) {
|
|
12
13
|
return actionResultErrorFromCaughtError(error, {
|
|
13
14
|
InvalidObjectState: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),
|
|
14
15
|
NoSuchKey: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
15
16
|
NotFound: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
17
|
+
InvalidScopeError: (error) => actionResultError(FileReadBinaryContentsErrorTypeEnum.InvalidScope, error.message),
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
};
|
package/lib/esm/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileReadBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,mCAAmC,GAEpC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,gCAAgC,GAAG,CAAC,SAAoB,EAAyC,EAAE;IACvG,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileReadBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileReadBinaryContentsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,mCAAmC,GAEpC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,gCAAgC,GAAG,CAAC,SAAoB,EAAyC,EAAE;IACvG,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1C,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACrE,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAEnD,OAAO,YAAY,CAAC,MAAM,cAAc,CAAC,YAAY,EAAE,GAAG,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC9H,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,kBAAkB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,mBAAmB,EAAE,oCAAoC,CAAC;gBAC1I,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBACnH,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBAClH,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aACjH,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAClJ,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,gCAAgC,CAAC,SAAS,CAAC;CACjF,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileReadBinaryContentsActionProcessor,\n FileReadBinaryContentsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { readBinaryFile } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileReadBinaryContents = (qpqConfig: QPQConfig): FileReadBinaryContentsActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const key = composeScopedFilePath(scope, filepath);\n\n return actionResult(await readBinaryFile(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig)));\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidObjectState: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),\n NoSuchKey: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n NotFound: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n InvalidScopeError: (error) => actionResultError(FileReadBinaryContentsErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileReadBinaryContentsActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadBinaryContents]: getProcessFileReadBinaryContents(qpqConfig),\n});\n"]}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileReadObjectJsonErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileReadObjectJsonErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { readTextFile } from '../../../logic/s3/s3Utils';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileReadObjectJson = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, filepath }) => {
|
|
6
|
+
return async ({ drive, filepath, scope }) => {
|
|
7
7
|
try {
|
|
8
8
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
9
|
-
const
|
|
9
|
+
const key = composeScopedFilePath(scope, filepath);
|
|
10
|
+
const json = await readTextFile(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig));
|
|
10
11
|
const obj = JSON.parse(json);
|
|
11
12
|
return actionResult(obj);
|
|
12
13
|
}
|
|
13
14
|
catch (error) {
|
|
14
15
|
return actionResultErrorFromCaughtError(error, {
|
|
15
16
|
InvalidObjectState: () => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),
|
|
17
|
+
NoSuchKey: () => actionResultError(FileReadObjectJsonErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
18
|
+
NotFound: () => actionResultError(FileReadObjectJsonErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
19
|
+
SyntaxError: () => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidJson, `Invalid JSON in file: ${filepath}`), // JSON.parse failure
|
|
20
|
+
InvalidScopeError: (error) => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidScope, error.message),
|
|
16
21
|
});
|
|
17
22
|
}
|
|
18
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileReadObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileReadObjectJsonActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,+BAA+B,GAEhC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,4BAA4B,GAAG,CAAC,SAAoB,EAA6C,EAAE;IACvG,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileReadObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileReadObjectJsonActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,+BAA+B,GAEhC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;A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C,MAAM,oCAAoC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC9I,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,4BAA4B,CAAC,SAAS,CAAC;CACzE,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileReadObjectJsonActionProcessor,\n FileReadObjectJsonErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { readTextFile } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileReadObjectJson = (qpqConfig: QPQConfig): FileReadObjectJsonActionProcessor<object> => {\n return async ({ drive, filepath, scope }) => {\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const key = composeScopedFilePath(scope, filepath);\n\n const json = await readTextFile(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig));\n\n const obj = JSON.parse(json);\n\n return actionResult(obj);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidObjectState: () => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),\n NoSuchKey: () => actionResultError(FileReadObjectJsonErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n NotFound: () => actionResultError(FileReadObjectJsonErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n SyntaxError: () => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidJson, `Invalid JSON in file: ${filepath}`), // JSON.parse failure\n InvalidScopeError: (error) => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileReadObjectJsonActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadObjectJson]: getProcessFileReadObjectJson(qpqConfig),\n});\n"]}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileReadTextContentsErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileReadTextContentsErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { readTextFile } from '../../../logic/s3/s3Utils';
|
|
4
4
|
import { resolveStorageDriveBucketName } from './utils';
|
|
5
5
|
const getProcessFileReadTextContents = (qpqConfig) => {
|
|
6
|
-
return async ({ drive, filepath }) => {
|
|
6
|
+
return async ({ drive, filepath, scope }) => {
|
|
7
7
|
try {
|
|
8
8
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
9
|
-
|
|
9
|
+
const key = composeScopedFilePath(scope, filepath);
|
|
10
|
+
return actionResult(await readTextFile(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig)));
|
|
10
11
|
}
|
|
11
12
|
catch (error) {
|
|
12
13
|
return actionResultErrorFromCaughtError(error, {
|
|
13
14
|
InvalidObjectState: () => actionResultError(FileReadTextContentsErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),
|
|
15
|
+
NoSuchKey: () => actionResultError(FileReadTextContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
16
|
+
NotFound: () => actionResultError(FileReadTextContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
17
|
+
InvalidScopeError: (error) => actionResultError(FileReadTextContentsErrorTypeEnum.InvalidScope, error.message),
|
|
14
18
|
});
|
|
15
19
|
}
|
|
16
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileReadTextContentsActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,iCAAiC,GAElC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,8BAA8B,GAAG,CAAC,SAAoB,EAAuC,EAAE;IACnG,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileReadTextContentsActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileReadTextContentsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,cAAc,EAEd,iCAAiC,GAElC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,8BAA8B,GAAG,CAAC,SAAoB,EAAuC,EAAE;IACnG,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1C,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACrE,MAAM,GAAG,GAAG,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAEnD,OAAO,YAAY,CAAC,MAAM,YAAY,CAAC,YAAY,EAAE,GAAG,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC5H,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,kBAAkB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,iCAAiC,CAAC,mBAAmB,EAAE,oCAAoC,CAAC;gBACxI,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,iCAAiC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBACjH,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,iCAAiC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBAChH,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,iCAAiC,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aAC/G,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sCAAsC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAChJ,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,8BAA8B,CAAC,SAAS,CAAC;CAC7E,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n FileActionType,\n FileReadTextContentsActionProcessor,\n FileReadTextContentsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { readTextFile } from '../../../logic/s3/s3Utils';\nimport { resolveStorageDriveBucketName } from './utils';\n\nconst getProcessFileReadTextContents = (qpqConfig: QPQConfig): FileReadTextContentsActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const key = composeScopedFilePath(scope, filepath);\n\n return actionResult(await readTextFile(s3BucketName, key, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig)));\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidObjectState: () => actionResultError(FileReadTextContentsErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),\n NoSuchKey: () => actionResultError(FileReadTextContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n NotFound: () => actionResultError(FileReadTextContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n InvalidScopeError: (error) => actionResultError(FileReadTextContentsErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileReadTextContentsActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadTextContents]: getProcessFileReadTextContents(qpqConfig),\n});\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, ErrorTypeEnum, FileActionType, FileStreamOpenErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, ErrorTypeEnum, FileActionType, FileStreamOpenErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
4
4
|
import { randomGuid } from '../../../awsLambdaUtils';
|
|
5
5
|
import { createAwsClient } from '../../../logic/createAwsClient';
|
|
@@ -19,13 +19,13 @@ async function* chunkedReadableIterator(stream, chunkSize, transform) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
const getProcessFileStreamOpen = (qpqConfig) => {
|
|
22
|
-
return async ({ drive, filepath, encoding, chunkSize }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {
|
|
22
|
+
return async ({ drive, filepath, encoding, chunkSize, scope }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {
|
|
23
23
|
try {
|
|
24
24
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
25
25
|
const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
26
26
|
const s3Client = createAwsClient(S3Client, { region });
|
|
27
27
|
const response = await s3Client.send(new GetObjectCommand({
|
|
28
|
-
Key: filepath,
|
|
28
|
+
Key: composeScopedFilePath(scope, filepath),
|
|
29
29
|
Bucket: s3BucketName,
|
|
30
30
|
}));
|
|
31
31
|
if (!response.Body) {
|
|
@@ -44,6 +44,7 @@ const getProcessFileStreamOpen = (qpqConfig) => {
|
|
|
44
44
|
InvalidObjectState: () => actionResultError(FileStreamOpenErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),
|
|
45
45
|
NoSuchKey: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
46
46
|
NotFound: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),
|
|
47
|
+
InvalidScopeError: (error) => actionResultError(FileStreamOpenErrorTypeEnum.InvalidScope, error.message),
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileStreamOpenActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileStreamOpenActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,aAAa,EACb,cAAc,EAEd,2BAA2B,GAE5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,KAAK,SAAS,CAAC,CAAC,uBAAuB,CAAC,MAAgB,EAAE,SAAiB,EAAE,SAAkC;IAC7G,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE7B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAE,KAAgB,CAAC;QAC5F,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE3C,OAAO,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YAClC,MAAM,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;YAC/C,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,SAAoB,EAAiC,EAAE;IACvF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"getFileStreamOpenActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileStreamOpenActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,aAAa,EACb,cAAc,EAEd,2BAA2B,GAE5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,gBA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AE;gBAC7C,kBAAkB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,mBAAmB,EAAE,oCAAoC,CAAC;gBAClI,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBAC3G,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;gBAC1G,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aACzG,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC1I,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,wBAAwB,CAAC,SAAS,CAAC;CACjE,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n composeScopedFilePath,\n ErrorTypeEnum,\n FileActionType,\n FileStreamOpenActionProcessor,\n FileStreamOpenErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { Readable } from 'stream';\nimport { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';\n\nimport { randomGuid } from '../../../awsLambdaUtils';\nimport { createAwsClient } from '../../../logic/createAwsClient';\nimport { resolveStorageDriveBucketName } from './utils';\n\nasync function* chunkedReadableIterator(stream: Readable, chunkSize: number, transform: (buf: Buffer) => string): AsyncIterableIterator<string> {\n let buffer = Buffer.alloc(0);\n\n for await (const chunk of stream) {\n const incoming = typeof chunk === 'string' ? Buffer.from(chunk, 'utf8') : (chunk as Buffer);\n buffer = Buffer.concat([buffer, incoming]);\n\n while (buffer.length >= chunkSize) {\n yield transform(buffer.subarray(0, chunkSize));\n buffer = buffer.subarray(chunkSize);\n }\n }\n\n if (buffer.length > 0) {\n yield transform(buffer);\n }\n}\n\nconst getProcessFileStreamOpen = (qpqConfig: QPQConfig): FileStreamOpenActionProcessor => {\n return async (\n { drive, filepath, encoding, chunkSize, scope },\n session,\n actionProcessors,\n logger,\n updateSession,\n dynamicModuleLoader,\n streamRegistry,\n ) => {\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);\n const s3Client = createAwsClient(S3Client, { region });\n\n const response = await s3Client.send(\n new GetObjectCommand({\n Key: composeScopedFilePath(scope, filepath),\n Bucket: s3BucketName,\n }),\n );\n\n if (!response.Body) {\n return actionResultError(ErrorTypeEnum.GenericError, `Empty response body for: ${filepath}`);\n }\n\n const streamId = `s3-${randomGuid()}`;\n const isText = encoding === 'text';\n const size = chunkSize ?? 65536;\n const transform = isText ? (buf: Buffer) => buf.toString('utf8') : (buf: Buffer) => buf.toString('base64');\n const iterator = chunkedReadableIterator(response.Body as Readable, size, transform);\n streamRegistry.register(streamId, iterator);\n\n return actionResult({ id: streamId, encoding });\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidObjectState: () => actionResultError(FileStreamOpenErrorTypeEnum.InvalidStorageClass, 'File is in the wrong storage class'),\n NoSuchKey: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n NotFound: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`),\n InvalidScopeError: (error) => actionResultError(FileStreamOpenErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileStreamOpenActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.StreamOpen]: getProcessFileStreamOpen(qpqConfig),\n});\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileWriteBinaryContentsErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, composeScopedFilePath, FileActionType, FileWriteBinaryContentsErrorTypeEnum, } from 'quidproquo-core';
|
|
3
3
|
import { getS3BucketStorageClassFromStorageDriveTier } from '../../../awsLambdaUtils';
|
|
4
4
|
import { writeBinaryFile } from '../../../logic/s3/s3Utils';
|
|
5
5
|
import { resolveStorageDriveBucketName } from './utils';
|
|
6
6
|
const getProcessFileWriteBinaryContents = (qpqConfig) => {
|
|
7
|
-
return async ({ drive, filepath, data, storageDriveAdvancedWriteOptions }) => {
|
|
7
|
+
return async ({ drive, filepath, data, storageDriveAdvancedWriteOptions, scope }) => {
|
|
8
8
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
9
9
|
try {
|
|
10
|
-
await writeBinaryFile(s3BucketName, filepath, data, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), getS3BucketStorageClassFromStorageDriveTier(storageDriveAdvancedWriteOptions?.storageDriveTier));
|
|
10
|
+
await writeBinaryFile(s3BucketName, composeScopedFilePath(scope, filepath), data, qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), getS3BucketStorageClassFromStorageDriveTier(storageDriveAdvancedWriteOptions?.storageDriveTier));
|
|
11
11
|
return actionResult(void 0);
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
@@ -15,6 +15,7 @@ const getProcessFileWriteBinaryContents = (qpqConfig) => {
|
|
|
15
15
|
AccessDenied: () => actionResultError(FileWriteBinaryContentsErrorTypeEnum.AccessDenied, 'Access denied writing file'),
|
|
16
16
|
Forbidden: () => actionResultError(FileWriteBinaryContentsErrorTypeEnum.AccessDenied, 'Access denied writing file'),
|
|
17
17
|
NoSuchBucket: () => actionResultError(FileWriteBinaryContentsErrorTypeEnum.DriveNotFound, `Storage drive not found: ${drive}`),
|
|
18
|
+
InvalidScopeError: (error) => actionResultError(FileWriteBinaryContentsErrorTypeEnum.InvalidScope, error.message),
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
};
|