quidproquo-actionprocessor-node 0.1.7 → 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.
Files changed (83) hide show
  1. package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +4 -0
  2. package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js.map +1 -1
  3. package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +10 -2
  4. package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js.map +1 -1
  5. package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js +7 -3
  6. package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js.map +1 -1
  7. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +13 -3
  8. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map +1 -1
  9. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +13 -3
  10. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -1
  11. package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +3 -2
  12. package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js.map +1 -1
  13. package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +3 -2
  14. package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js.map +1 -1
  15. package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +5 -4
  16. package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js.map +1 -1
  17. package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +4 -3
  18. package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js.map +1 -1
  19. package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +3 -2
  20. package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js.map +1 -1
  21. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +3 -2
  22. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js.map +1 -1
  23. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +3 -2
  24. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js.map +1 -1
  25. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +3 -2
  26. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js.map +1 -1
  27. package/lib/commonjs/dynamicActionProcessor/file/utils.d.ts +1 -1
  28. package/lib/commonjs/dynamicActionProcessor/file/utils.js +9 -2
  29. package/lib/commonjs/dynamicActionProcessor/file/utils.js.map +1 -1
  30. package/lib/commonjs/traceStoryExecution/getSystemTraceStoryActionProcessor.d.ts +3 -2
  31. package/lib/commonjs/traceStoryExecution/getSystemTraceStoryActionProcessor.js +4 -3
  32. package/lib/commonjs/traceStoryExecution/getSystemTraceStoryActionProcessor.js.map +1 -1
  33. package/lib/commonjs/traceStoryExecution/index.d.ts +1 -0
  34. package/lib/commonjs/traceStoryExecution/index.js +1 -0
  35. package/lib/commonjs/traceStoryExecution/index.js.map +1 -1
  36. package/lib/commonjs/traceStoryExecution/resolveSourceMaps.d.ts +2 -1
  37. package/lib/commonjs/traceStoryExecution/resolveSourceMaps.js +24 -3
  38. package/lib/commonjs/traceStoryExecution/resolveSourceMaps.js.map +1 -1
  39. package/lib/commonjs/traceStoryExecution/traceStoryExecution.d.ts +1 -0
  40. package/lib/commonjs/traceStoryExecution/traceStoryExecution.js +1 -1
  41. package/lib/commonjs/traceStoryExecution/traceStoryExecution.js.map +1 -1
  42. package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +4 -0
  43. package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js.map +1 -1
  44. package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +10 -2
  45. package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js.map +1 -1
  46. package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js +8 -4
  47. package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js.map +1 -1
  48. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +14 -4
  49. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map +1 -1
  50. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +14 -4
  51. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -1
  52. package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +3 -2
  53. package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js.map +1 -1
  54. package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +3 -2
  55. package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js.map +1 -1
  56. package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +6 -5
  57. package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js.map +1 -1
  58. package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +5 -4
  59. package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js.map +1 -1
  60. package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +3 -2
  61. package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js.map +1 -1
  62. package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +3 -2
  63. package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js.map +1 -1
  64. package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +3 -2
  65. package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js.map +1 -1
  66. package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +3 -2
  67. package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js.map +1 -1
  68. package/lib/esm/dynamicActionProcessor/file/utils.d.ts +1 -1
  69. package/lib/esm/dynamicActionProcessor/file/utils.js +10 -3
  70. package/lib/esm/dynamicActionProcessor/file/utils.js.map +1 -1
  71. package/lib/esm/traceStoryExecution/getSystemTraceStoryActionProcessor.d.ts +3 -2
  72. package/lib/esm/traceStoryExecution/getSystemTraceStoryActionProcessor.js +4 -3
  73. package/lib/esm/traceStoryExecution/getSystemTraceStoryActionProcessor.js.map +1 -1
  74. package/lib/esm/traceStoryExecution/index.d.ts +1 -0
  75. package/lib/esm/traceStoryExecution/index.js +1 -0
  76. package/lib/esm/traceStoryExecution/index.js.map +1 -1
  77. package/lib/esm/traceStoryExecution/resolveSourceMaps.d.ts +2 -1
  78. package/lib/esm/traceStoryExecution/resolveSourceMaps.js +22 -2
  79. package/lib/esm/traceStoryExecution/resolveSourceMaps.js.map +1 -1
  80. package/lib/esm/traceStoryExecution/traceStoryExecution.d.ts +1 -0
  81. package/lib/esm/traceStoryExecution/traceStoryExecution.js +1 -1
  82. package/lib/esm/traceStoryExecution/traceStoryExecution.js.map +1 -1
  83. package/package.json +6 -5
@@ -31,6 +31,10 @@ const getProcessExecute = (qpqConfig) => {
31
31
  depth: (session.depth || 0) + 1,
32
32
  decodedAccessToken: session.decodedAccessToken,
33
33
  correlation: session.correlation,
34
+ // Inline functions run WITHIN the caller's function - carry its globals
35
+ // so stories like the tenant scope resolver can read route config (the
36
+ // runtime merges these under the inline function's own registration).
37
+ functionGlobals: session.functionGlobals,
34
38
  }, () => __awaiter(void 0, void 0, void 0, function* () { return actionProcessors; }), getDateNow, logger, `${moduleName}::${(0, crypto_1.randomUUID)()}`, quidproquo_core_1.QpqRuntimeType.EXECUTE_STORY, dynamicModuleLoader, inlineFunction.runtime, [], streamRegistry);
35
39
  const storyResult = yield resolveStory(story, [payload.payload]);
36
40
  if (storyResult.error) {
@@ -1 +1 @@
1
- {"version":3,"file":"getInlineFunctionExecuteActionProcessor.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAkByB;AAEzB,mCAAoC;AAEpC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAElD,MAAM,iBAAiB,GAAG,CAAO,SAAoB,EAA8C,EAAE;IACnG,MAAM,UAAU,GAAG,8BAAY,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAEpE,OAAO,CACL,OAA8C,EAC9C,OAAqB,EACrB,gBAAqC,EACrC,MAAiB,EACjB,aAAkC,EAClC,mBAAwC,EACxC,cAA8B,EAChB,EAAE;QAChB,MAAM,eAAe,GAAG,8BAAY,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;QAE5F,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,IAAA,mCAAiB,EAAC,+BAAa,CAAC,QAAQ,EAAE,+BAA+B,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;QAC3G,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,cAAc,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,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QACjJ,CAAC,0CAAwB,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC;KACjE,CAAC,CAAA;EAAA,CAAC;AAFU,QAAA,uCAAuC,2CAEjD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n createRuntime,\n DynamicModuleLoader,\n ErrorTypeEnum,\n InlineFunctionActionType,\n InlineFunctionExecuteActionPayload,\n InlineFunctionExecuteActionProcessor,\n QPQConfig,\n qpqCoreUtils,\n QpqLogger,\n QpqRuntimeType,\n StorySession,\n StorySessionUpdater,\n StreamRegistry,\n} from 'quidproquo-core';\n\nimport { randomUUID } from 'crypto';\n\nconst getDateNow = () => new Date().toISOString();\n\nconst getProcessExecute = <R, T>(qpqConfig: QPQConfig): InlineFunctionExecuteActionProcessor<R, T> => {\n const moduleName = qpqCoreUtils.getApplicationModuleName(qpqConfig);\n\n return async (\n payload: InlineFunctionExecuteActionPayload<T>,\n session: StorySession,\n actionProcessors: ActionProcessorList,\n logger: QpqLogger,\n updateSession: StorySessionUpdater,\n dynamicModuleLoader: DynamicModuleLoader,\n streamRegistry: StreamRegistry,\n ): Promise<any> => {\n const inlineFunctions = qpqCoreUtils.getAllInlineFunctions(qpqConfig);\n const inlineFunction = inlineFunctions.find((f) => f.functionName === payload.functionName);\n\n if (!inlineFunction) {\n return actionResultError(ErrorTypeEnum.NotFound, `Inline function not found: [${payload.functionName}]`);\n }\n\n const story = await dynamicModuleLoader(inlineFunction.runtime);\n\n if (!story) {\n return actionResultError(ErrorTypeEnum.NotFound, `Unable to dynamically load inline function: [${payload.functionName}]`);\n }\n\n const resolveStory = createRuntime(\n qpqConfig,\n {\n context: session.context,\n localContext: session.localContext,\n depth: (session.depth || 0) + 1,\n decodedAccessToken: session.decodedAccessToken,\n correlation: session.correlation,\n },\n async () => actionProcessors,\n getDateNow,\n logger,\n `${moduleName}::${randomUUID()}`,\n QpqRuntimeType.EXECUTE_STORY,\n dynamicModuleLoader,\n inlineFunction.runtime,\n [],\n streamRegistry,\n );\n\n const storyResult = await resolveStory(story, [payload.payload]);\n\n if (storyResult.error) {\n return actionResultError(\n storyResult.error.errorType,\n storyResult.error.errorText,\n storyResult.error.errorStack ? `${payload.functionName} -> [${storyResult.error.errorStack}]` : payload.functionName,\n );\n }\n\n return actionResult<R>(storyResult.result);\n };\n};\n\nexport const getInlineFunctionExecuteActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [InlineFunctionActionType.Execute]: getProcessExecute(qpqConfig),\n});\n"]}
1
+ {"version":3,"file":"getInlineFunctionExecuteActionProcessor.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAkByB;AAEzB,mCAAoC;AAEpC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAElD,MAAM,iBAAiB,GAAG,CAAO,SAAoB,EAA8C,EAAE;IACnG,MAAM,UAAU,GAAG,8BAAY,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAEpE,OAAO,CACL,OAA8C,EAC9C,OAAqB,EACrB,gBAAqC,EACrC,MAAiB,EACjB,aAAkC,EAClC,mBAAwC,EACxC,cAA8B,EAChB,EAAE;QAChB,MAAM,eAAe,GAAG,8BAAY,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;QAE5F,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,IAAA,mCAAiB,EAAC,+BAAa,CAAC,QAAQ,EAAE,+BAA+B,OAAO,CAAC,YAAY,GA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AY,CACrH,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,8BAAY,EAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,uCAAuC,GAAgC,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QACjJ,CAAC,0CAAwB,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC;KACjE,CAAC,CAAA;EAAA,CAAC;AAFU,QAAA,uCAAuC,2CAEjD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n createRuntime,\n DynamicModuleLoader,\n ErrorTypeEnum,\n InlineFunctionActionType,\n InlineFunctionExecuteActionPayload,\n InlineFunctionExecuteActionProcessor,\n QPQConfig,\n qpqCoreUtils,\n QpqLogger,\n QpqRuntimeType,\n StorySession,\n StorySessionUpdater,\n StreamRegistry,\n} from 'quidproquo-core';\n\nimport { randomUUID } from 'crypto';\n\nconst getDateNow = () => new Date().toISOString();\n\nconst getProcessExecute = <R, T>(qpqConfig: QPQConfig): InlineFunctionExecuteActionProcessor<R, T> => {\n const moduleName = qpqCoreUtils.getApplicationModuleName(qpqConfig);\n\n return async (\n payload: InlineFunctionExecuteActionPayload<T>,\n session: StorySession,\n actionProcessors: ActionProcessorList,\n logger: QpqLogger,\n updateSession: StorySessionUpdater,\n dynamicModuleLoader: DynamicModuleLoader,\n streamRegistry: StreamRegistry,\n ): Promise<any> => {\n const inlineFunctions = qpqCoreUtils.getAllInlineFunctions(qpqConfig);\n const inlineFunction = inlineFunctions.find((f) => f.functionName === payload.functionName);\n\n if (!inlineFunction) {\n return actionResultError(ErrorTypeEnum.NotFound, `Inline function not found: [${payload.functionName}]`);\n }\n\n const story = await dynamicModuleLoader(inlineFunction.runtime);\n\n if (!story) {\n return actionResultError(ErrorTypeEnum.NotFound, `Unable to dynamically load inline function: [${payload.functionName}]`);\n }\n\n const resolveStory = createRuntime(\n qpqConfig,\n {\n context: session.context,\n localContext: session.localContext,\n depth: (session.depth || 0) + 1,\n decodedAccessToken: session.decodedAccessToken,\n correlation: session.correlation,\n // Inline functions run WITHIN the caller's function - carry its globals\n // so stories like the tenant scope resolver can read route config (the\n // runtime merges these under the inline function's own registration).\n functionGlobals: session.functionGlobals,\n },\n async () => actionProcessors,\n getDateNow,\n logger,\n `${moduleName}::${randomUUID()}`,\n QpqRuntimeType.EXECUTE_STORY,\n dynamicModuleLoader,\n inlineFunction.runtime,\n [],\n streamRegistry,\n );\n\n const storyResult = await resolveStory(story, [payload.payload]);\n\n if (storyResult.error) {\n return actionResultError(\n storyResult.error.errorType,\n storyResult.error.errorText,\n storyResult.error.errorStack ? `${payload.functionName} -> [${storyResult.error.errorStack}]` : payload.functionName,\n );\n }\n\n return actionResult<R>(storyResult.result);\n };\n};\n\nexport const getInlineFunctionExecuteActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [InlineFunctionActionType.Execute]: getProcessExecute(qpqConfig),\n});\n"]}
@@ -47,12 +47,12 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileDelete = (qpqConfig, config) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepaths }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepaths, scope }) {
51
51
  const deletedFiles = [];
52
52
  const errors = [];
53
53
  for (const filepath of filepaths) {
54
54
  try {
55
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
55
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
56
56
  yield fs.unlink(fullPath);
57
57
  deletedFiles.push(filepath);
58
58
  }
@@ -66,6 +66,14 @@ const getProcessFileDelete = (qpqConfig, config) => {
66
66
  }
67
67
  }
68
68
  }
69
+ // Scope is shared by every filepath in the request, so a bad scope fails the
70
+ // whole call regardless of any deletes that a different code path allowed.
71
+ // Name-keyed, not instanceof: under npm link / module federation the error
72
+ // can come from another copy of quidproquo-core.
73
+ const invalidScope = errors.find(({ error }) => (error === null || error === void 0 ? void 0 : error.name) === 'InvalidScopeError');
74
+ if (invalidScope) {
75
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileDeleteErrorTypeEnum.InvalidScope, invalidScope.error.message);
76
+ }
69
77
  if (errors.length > 0 && deletedFiles.length === 0) {
70
78
  // EACCES maps to the same typed error the S3 processor returns for AccessDenied
71
79
  if (errors.some(({ error }) => error.code === 'EACCES')) {
@@ -1 +1 @@
1
- {"version":3,"file":"getFileDeleteActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileDeleteActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAA6B,EAAE;IAC1G,OAAO,KAA6B,EAAE,4CAAxB,EAAE,KAAK,EAAE,SAAS,EAAE;QAChC,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,MAAM,MAAM,GAAuC,EAAE,CAAC;QAEtD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAErE,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,0DAA0D;gBAC1D,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC9B,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACnC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnD,gFAAgF;YAChF,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;gBACxD,OAAO,IAAA,mCAAiB,EAAC,yCAAuB,CAAC,YAAY,EAAE,8BAA8B,CAAC,CAAC;YACjG,CAAC;YACD,OAAO,IAAA,mCAAiB,EACtB,+BAAa,CAAC,YAAY,EAC1B,2BAA2B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,oBAAoB,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9H,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,8BAAY,EAAC,YAAY,CAAC,CAAC;IACpC,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,4BAA4B,GACvC,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC;KACjE,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,4BAA4B,gCAIpC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileDeleteActionProcessor,\n FileDeleteErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileDelete = (qpqConfig: QPQConfig, config: FileStorageConfig): FileDeleteActionProcessor => {\n return async ({ drive, filepaths }) => {\n const deletedFiles: string[] = [];\n const errors: { filepath: string; error: any }[] = [];\n\n for (const filepath of filepaths) {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n\n await fs.unlink(fullPath);\n deletedFiles.push(filepath);\n } catch (error: any) {\n // If file doesn't exist, consider it successfully deleted\n if (error.code === 'ENOENT') {\n deletedFiles.push(filepath);\n } else {\n errors.push({ filepath, error });\n }\n }\n }\n\n if (errors.length > 0 && deletedFiles.length === 0) {\n // EACCES maps to the same typed error the S3 processor returns for AccessDenied\n if (errors.some(({ error }) => error.code === 'EACCES')) {\n return actionResultError(FileDeleteErrorTypeEnum.AccessDenied, 'Access denied deleting files');\n }\n return actionResultError(\n ErrorTypeEnum.GenericError,\n `Failed to delete files: ${errors.map(({ filepath, error }) => `Failed to delete ${filepath}: ${error.message}`).join(', ')}`,\n );\n }\n\n return actionResult(deletedFiles);\n };\n};\n\nexport const getFileDeleteActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Delete]: getProcessFileDelete(qpqConfig, config),\n });\n"]}
1
+ {"version":3,"file":"getFileDeleteActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileDeleteActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAA6B,EAAE;IAC1G,OAAO,KAAoC,EAAE,4CAA/B,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE;QACv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I,KAAK,QAAQ,CAAC,EAAE,CAAC;gBACxD,OAAO,IAAA,mCAAiB,EAAC,yCAAuB,CAAC,YAAY,EAAE,8BAA8B,CAAC,CAAC;YACjG,CAAC;YACD,OAAO,IAAA,mCAAiB,EACtB,+BAAa,CAAC,YAAY,EAC1B,2BAA2B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,oBAAoB,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9H,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,8BAAY,EAAC,YAAY,CAAC,CAAC;IACpC,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,4BAA4B,GACvC,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC;KACjE,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,4BAA4B,gCAIpC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileDeleteActionProcessor,\n FileDeleteErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileDelete = (qpqConfig: QPQConfig, config: FileStorageConfig): FileDeleteActionProcessor => {\n return async ({ drive, filepaths, scope }) => {\n const deletedFiles: string[] = [];\n const errors: { filepath: string; error: any }[] = [];\n\n for (const filepath of filepaths) {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n\n await fs.unlink(fullPath);\n deletedFiles.push(filepath);\n } catch (error: any) {\n // If file doesn't exist, consider it successfully deleted\n if (error.code === 'ENOENT') {\n deletedFiles.push(filepath);\n } else {\n errors.push({ filepath, error });\n }\n }\n }\n\n // Scope is shared by every filepath in the request, so a bad scope fails the\n // whole call regardless of any deletes that a different code path allowed.\n // Name-keyed, not instanceof: under npm link / module federation the error\n // can come from another copy of quidproquo-core.\n const invalidScope = errors.find(({ error }) => error?.name === 'InvalidScopeError');\n if (invalidScope) {\n return actionResultError(FileDeleteErrorTypeEnum.InvalidScope, invalidScope.error.message);\n }\n\n if (errors.length > 0 && deletedFiles.length === 0) {\n // EACCES maps to the same typed error the S3 processor returns for AccessDenied\n if (errors.some(({ error }) => error.code === 'EACCES')) {\n return actionResultError(FileDeleteErrorTypeEnum.AccessDenied, 'Access denied deleting files');\n }\n return actionResultError(\n ErrorTypeEnum.GenericError,\n `Failed to delete files: ${errors.map(({ filepath, error }) => `Failed to delete ${filepath}: ${error.message}`).join(', ')}`,\n );\n }\n\n return actionResult(deletedFiles);\n };\n};\n\nexport const getFileDeleteActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Delete]: getProcessFileDelete(qpqConfig, config),\n });\n"]}
@@ -47,9 +47,9 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileExists = (qpqConfig, config) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, scope }) {
51
51
  try {
52
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
53
53
  try {
54
54
  yield fs.access(fullPath);
55
55
  return (0, quidproquo_core_1.actionResult)(true);
@@ -66,7 +66,11 @@ const getProcessFileExists = (qpqConfig, config) => {
66
66
  }
67
67
  }
68
68
  catch (error) {
69
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error checking file existence: ${error.message}`);
69
+ // Name-keyed, not instanceof: under npm link / module federation the
70
+ // error can come from another copy of quidproquo-core.
71
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
72
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileExistsErrorTypeEnum.InvalidScope, error.message),
73
+ });
70
74
  }
71
75
  });
72
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getFileExistsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileExistsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAA6B,EAAE;IAC1G,OAAO,KAA4B,EAAE,4CAAvB,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YAErE,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,OAAO,IAAA,8BAAY,EAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,wEAAwE;gBACxE,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;gBACD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,OAAO,IAAA,mCAAiB,EAAC,yCAAuB,CAAC,YAAY,EAAE,0CAA0C,QAAQ,EAAE,CAAC,CAAC;gBACvH,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,IAAA,mCAAiB,EAAC,+BAAa,CAAC,YAAY,EAAE,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,4BAA4B,GACvC,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC;KACjE,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,4BAA4B,gCAIpC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileExistsActionProcessor,\n FileExistsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileExists = (qpqConfig: QPQConfig, config: FileStorageConfig): FileExistsActionProcessor => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n\n try {\n await fs.access(fullPath);\n return actionResult(true);\n } catch (error: any) {\n // Missing file is a definitive false; permission problems must surface.\n if (error.code === 'ENOENT') {\n return actionResult(false);\n }\n if (error.code === 'EACCES') {\n return actionResultError(FileExistsErrorTypeEnum.AccessDenied, `Access denied checking file existence: ${filepath}`);\n }\n throw error;\n }\n } catch (error: any) {\n return actionResultError(ErrorTypeEnum.GenericError, `Error checking file existence: ${error.message}`);\n }\n };\n};\n\nexport const getFileExistsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Exists]: getProcessFileExists(qpqConfig, config),\n });\n"]}
1
+ {"version":3,"file":"getFileExistsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileExistsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAA6B,EAAE;IAC1G,OAAO,KAAmC,EAAE,4CAA9B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAE5E,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,OAAO,IAAA,8BAAY,EAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,wEAAwE;gBACxE,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;gBACD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,OAAO,IAAA,mCAAiB,EAAC,yCAAuB,CAAC,YAAY,EAAE,0CAA0C,QAAQ,EAAE,CAAC,CAAC;gBACvH,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,qEAAqE;YACrE,uDAAuD;YACvD,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAiB,EAAC,yCAAuB,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aACrG,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,4BAA4B,GACvC,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC;KACjE,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,4BAA4B,gCAIpC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileExistsActionProcessor,\n FileExistsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileExists = (qpqConfig: QPQConfig, config: FileStorageConfig): FileExistsActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n\n try {\n await fs.access(fullPath);\n return actionResult(true);\n } catch (error: any) {\n // Missing file is a definitive false; permission problems must surface.\n if (error.code === 'ENOENT') {\n return actionResult(false);\n }\n if (error.code === 'EACCES') {\n return actionResultError(FileExistsErrorTypeEnum.AccessDenied, `Access denied checking file existence: ${filepath}`);\n }\n throw error;\n }\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(FileExistsErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileExistsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Exists]: getProcessFileExists(qpqConfig, config),\n });\n"]}
@@ -13,12 +13,18 @@ exports.getFileGenerateTemporarySecureUrlActionProcessor = void 0;
13
13
  const quidproquo_core_1 = require("quidproquo-core");
14
14
  const secureUrlUtils_1 = require("./secureUrlUtils");
15
15
  const utils_1 = require("./utils");
16
+ // Mirror the AWS processor's SigV4 limit (7 days) so a story that would fail
17
+ // in production fails the same way on the dev server.
18
+ const maxExpirationMs = 7 * 24 * 60 * 60 * 1000;
16
19
  const getProcessFileGenerateTemporarySecureUrl = (qpqConfig, config) => {
17
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs }) {
20
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs, scope }) {
21
+ if (expirationMs > maxExpirationMs) {
22
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileGenerateTemporarySecureUrlErrorTypeEnum.ExpirationTooLong, 'Expiration exceeds the 7 day maximum for presigned URLs');
23
+ }
18
24
  try {
19
25
  // Create a token for download
20
26
  const token = (0, secureUrlUtils_1.createSecureUrlToken)({
21
- fullFilepath: (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath),
27
+ fullFilepath: (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope),
22
28
  operation: 'download',
23
29
  expiresAt: Date.now() + expirationMs,
24
30
  }, config.secureUrlSecret);
@@ -28,7 +34,11 @@ const getProcessFileGenerateTemporarySecureUrl = (qpqConfig, config) => {
28
34
  return (0, quidproquo_core_1.actionResult)(url);
29
35
  }
30
36
  catch (error) {
31
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Unable to generate temporary secure URL: ${error.message}`);
37
+ // Name-keyed, not instanceof: under npm link / module federation the
38
+ // error can come from another copy of quidproquo-core.
39
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
40
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileGenerateTemporarySecureUrlErrorTypeEnum.InvalidScope, error.message),
41
+ });
32
42
  }
33
43
  });
34
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getFileGenerateTemporarySecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDASyB;AAEzB,qDAA6E;AAE7E,mCAA0C;AAE1C,MAAM,wCAAwC,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAAiD,EAAE;IAClJ,OAAO,KAA0C,EAAE,4CAArC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE;QAC7C,IAAI,CAAC;YACH,8BAA8B;YAC9B,MAAM,KAAK,GAAG,IAAA,qCAAoB,EAChC;gBACE,YAAY,EAAE,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;gBACjE,SAAS,EAAE,UAAU;gBACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY;aACrC,EACD,MAAM,CAAC,eAAe,CACvB,CAAC;YAEF,uBAAuB;YACvB,MAAM,OAAO,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,GAAG,OAAO,0BAA0B,KAAK,EAAE,CAAC;YAExD,OAAO,IAAA,8BAAY,EAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,IAAA,mCAAiB,EAAC,+BAAa,CAAC,YAAY,EAAE,4CAA4C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpH,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,gDAAgD,GAC3D,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,0BAA0B,CAAC,EAAE,wCAAwC,CAAC,SAAS,EAAE,MAAM,CAAC;KACzG,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,gDAAgD,oDAIxD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileGenerateTemporarySecureUrlActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileGenerateTemporarySecureUrl = (qpqConfig: QPQConfig, config: FileStorageConfig): FileGenerateTemporarySecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs }) => {\n try {\n // Create a token for download\n const token = createSecureUrlToken(\n {\n fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath),\n operation: 'download',\n expiresAt: Date.now() + expirationMs,\n },\n config.secureUrlSecret,\n );\n\n // Build the secure URL\n const baseUrl = getSecureUrlBaseUrl(config);\n const url = `${baseUrl}/secure-download?token=${token}`;\n\n return actionResult(url);\n } catch (error: any) {\n return actionResultError(ErrorTypeEnum.GenericError, `Unable to generate temporary secure URL: ${error.message}`);\n }\n };\n};\n\nexport const getFileGenerateTemporarySecureUrlActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig, config),\n });\n"]}
1
+ {"version":3,"file":"getFileGenerateTemporarySecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAUyB;AAEzB,qDAA6E;AAE7E,mCAA0C;AAE1C,6EAA6E;AAC7E,sDAAsD;AACtD,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,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AAC,0BAA0B,CAAC,EAAE,wCAAwC,CAAC,SAAS,EAAE,MAAM,CAAC;KACzG,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,gDAAgD,oDAIxD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileGenerateTemporarySecureUrlActionProcessor,\n FileGenerateTemporarySecureUrlErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\n// Mirror the AWS processor's SigV4 limit (7 days) so a story that would fail\n// in production fails the same way on the dev server.\nconst maxExpirationMs = 7 * 24 * 60 * 60 * 1000;\n\nconst getProcessFileGenerateTemporarySecureUrl = (qpqConfig: QPQConfig, config: FileStorageConfig): 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 // Create a token for download\n const token = createSecureUrlToken(\n {\n fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath, scope),\n operation: 'download',\n expiresAt: Date.now() + expirationMs,\n },\n config.secureUrlSecret,\n );\n\n // Build the secure URL\n const baseUrl = getSecureUrlBaseUrl(config);\n const url = `${baseUrl}/secure-download?token=${token}`;\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 =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig, config),\n });\n"]}
@@ -13,13 +13,19 @@ exports.getFileGenerateTemporaryUploadSecureUrlActionProcessor = void 0;
13
13
  const quidproquo_core_1 = require("quidproquo-core");
14
14
  const secureUrlUtils_1 = require("./secureUrlUtils");
15
15
  const utils_1 = require("./utils");
16
+ // Mirror the AWS processor's SigV4 limit (7 days) so a story that would fail
17
+ // in production fails the same way on the dev server.
18
+ const maxExpirationMs = 7 * 24 * 60 * 60 * 1000;
16
19
  const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig, config) => {
17
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs, contentType }) {
20
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs, contentType, scope }) {
21
+ if (expirationMs > maxExpirationMs) {
22
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.ExpirationTooLong, 'Expiration exceeds the 7 day maximum for presigned URLs');
23
+ }
18
24
  try {
19
25
  const expiresAt = Date.now() + expirationMs;
20
26
  // Create a token for upload
21
27
  const token = (0, secureUrlUtils_1.createSecureUrlToken)({
22
- fullFilepath: (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath),
28
+ fullFilepath: (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope),
23
29
  operation: 'upload',
24
30
  expiresAt,
25
31
  contentType,
@@ -31,7 +37,11 @@ const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig, config) => {
31
37
  return (0, quidproquo_core_1.actionResult)(url);
32
38
  }
33
39
  catch (error) {
34
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Unable to generate temporary upload secure URL: ${error.message}`);
40
+ // Name-keyed, not instanceof: under npm link / module federation the
41
+ // error can come from another copy of quidproquo-core.
42
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
43
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.InvalidScope, error.message),
44
+ });
35
45
  }
36
46
  });
37
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDASyB;AAEzB,qDAA6E;AAE7E,mCAA0C;AAE1C,MAAM,8CAA8C,GAAG,CACrD,SAAoB,EACpB,MAAyB,EAC4B,EAAE;IACvD,OAAO,KAAuD,EAAE,4CAAlD,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE;QAC1D,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC;YAE5C,4BAA4B;YAC5B,MAAM,KAAK,GAAG,IAAA,qCAAoB,EAChC;gBACE,YAAY,EAAE,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;gBACjE,SAAS,EAAE,QAAQ;gBACnB,SAAS;gBACT,WAAW;aACZ,EACD,MAAM,CAAC,eAAe,CACvB,CAAC;YAEF,uBAAuB;YACvB,MAAM,OAAO,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,GAAG,OAAO,wBAAwB,KAAK,EAAE,CAAC;YAEtD,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,aAAa,KAAK,gBAAgB,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAEvH,OAAO,IAAA,8BAAY,EAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,IAAA,mCAAiB,EAAC,+BAAa,CAAC,YAAY,EAAE,mDAAmD,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,sDAAsD,GACjE,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,gCAAgC,CAAC,EAAE,8CAA8C,CAAC,SAAS,EAAE,MAAM,CAAC;KACrH,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,sDAAsD,0DAI9D","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileGenerateTemporaryUploadSecureUrlActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileGenerateTemporaryUploadSecureUrl = (\n qpqConfig: QPQConfig,\n config: FileStorageConfig,\n): FileGenerateTemporaryUploadSecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs, contentType }) => {\n try {\n const expiresAt = Date.now() + expirationMs;\n\n // Create a token for upload\n const token = createSecureUrlToken(\n {\n fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath),\n operation: 'upload',\n expiresAt,\n contentType,\n },\n config.secureUrlSecret,\n );\n\n // Build the secure URL\n const baseUrl = getSecureUrlBaseUrl(config);\n const url = `${baseUrl}/secure-upload?token=${token}`;\n\n console.log(`Generated upload URL for ${filepath} in drive ${drive}, expires at ${new Date(expiresAt).toISOString()}`);\n\n return actionResult(url);\n } catch (error: any) {\n return actionResultError(ErrorTypeEnum.GenericError, `Unable to generate temporary upload secure URL: ${error.message}`);\n }\n };\n};\n\nexport const getFileGenerateTemporaryUploadSecureUrlActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig, config),\n });\n"]}
1
+ {"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAUyB;AAEzB,qDAA6E;AAE7E,mCAA0C;AAE1C,6EAA6E;AAC7E,sDAAsD;AACtD,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,8CAA8C,GAAG,CACrD,SAAoB,EACpB,MAAyB,EAC4B,EAAE;IACvD,OAAO,KAA8D,EAAE,4CAAzD,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE;QACjE,IAAI,YAAY,GAAG,eAAe,EAAE,CAAC;YACnC,OAAO,IAAA,mCAAiB,EACtB,mEAAiD,CAAC,iBAAiB,EACnE,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC;YAE5C,4BAA4B;YAC5B,MAAM,KAAK,GAAG,IAAA,qCAAoB,EAChC;gBACE,YAAY,EAAE,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC;gBACxE,SAAS,EAAE,QAAQ;gBACnB,SAAS;gBACT,WAAW;aACZ,EACD,MAAM,CAAC,eAAe,CACvB,CAAC;YAEF,uBAAuB;YACvB,MAAM,OAAO,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,GAAG,OAAO,wBAAwB,KAAK,EAAE,CAAC;YAEtD,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,aAAa,KAAK,gBAAgB,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAEvH,OAAO,IAAA,8BAAY,EAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,qEAAqE;YACrE,uDAAuD;YACvD,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAiB,EAAC,mEAAiD,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aAC/H,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,sDAAsD,GACjE,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,gCAAgC,CAAC,EAAE,8CAA8C,CAAC,SAAS,EAAE,MAAM,CAAC;KACrH,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,sDAAsD,0DAI9D","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileGenerateTemporaryUploadSecureUrlActionProcessor,\n FileGenerateTemporaryUploadSecureUrlErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\n// Mirror the AWS processor's SigV4 limit (7 days) so a story that would fail\n// in production fails the same way on the dev server.\nconst maxExpirationMs = 7 * 24 * 60 * 60 * 1000;\n\nconst getProcessFileGenerateTemporaryUploadSecureUrl = (\n qpqConfig: QPQConfig,\n config: FileStorageConfig,\n): FileGenerateTemporaryUploadSecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs, contentType, scope }) => {\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 expiresAt = Date.now() + expirationMs;\n\n // Create a token for upload\n const token = createSecureUrlToken(\n {\n fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath, scope),\n operation: 'upload',\n expiresAt,\n contentType,\n },\n config.secureUrlSecret,\n );\n\n // Build the secure URL\n const baseUrl = getSecureUrlBaseUrl(config);\n const url = `${baseUrl}/secure-upload?token=${token}`;\n\n console.log(`Generated upload URL for ${filepath} in drive ${drive}, expires at ${new Date(expiresAt).toISOString()}`);\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 =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig, config),\n });\n"]}
@@ -48,9 +48,9 @@ const fs = __importStar(require("fs/promises"));
48
48
  const path = __importStar(require("path"));
49
49
  const utils_1 = require("./utils");
50
50
  const getProcessFileListDirectory = (config) => (qpqConfig) => {
51
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, folderPath, maxFiles, pageToken }) {
51
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, folderPath, maxFiles, pageToken, scope }) {
52
52
  try {
53
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, folderPath || '');
53
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, folderPath || '', scope);
54
54
  // Read all entries in the directory
55
55
  const entries = yield fs.readdir(fullPath, { withFileTypes: true });
56
56
  // Build file info list
@@ -80,6 +80,7 @@ const getProcessFileListDirectory = (config) => (qpqConfig) => {
80
80
  }
81
81
  catch (error) {
82
82
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
83
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.InvalidScope, error.message),
83
84
  ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.DirectoryNotFound, `Directory not found: ${folderPath}`), // node fs code
84
85
  ENOTDIR: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.NotADirectory, `Path is not a directory: ${folderPath}`), // node fs code
85
86
  EACCES: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.AccessDenied, `Access denied listing directory: ${folderPath}`), // node fs code
@@ -1 +1 @@
1
- {"version":3,"file":"getFileListDirectoryActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAYyB;AAEzB,gDAAkC;AAClC,2CAA6B;AAG7B,mCAA0C;AAE1C,MAAM,2BAA2B,GAC/B,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAAoC,EAAE;IACzD,OAAO,KAAmD,EAAE,4CAA9C,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE;QACtD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UA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AAM,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,gDAA8B,CAAC,iBAAiB,EAAE,wBAAwB,UAAU,EAAE,CAAC,EAAE,eAAe;gBACxI,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,gDAA8B,CAAC,aAAa,EAAE,4BAA4B,UAAU,EAAE,CAAC,EAAE,eAAe;gBACzI,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,gDAA8B,CAAC,YAAY,EAAE,oCAAoC,UAAU,EAAE,CAAC,EAAE,eAAe;aAChJ,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,mCAAmC,GAC9C,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KAC/E,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,mCAAmC,uCAI3C","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n DirectoryList,\n FileActionType,\n FileInfo,\n FileListDirectoryActionProcessor,\n FileListDirectoryErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileListDirectory =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileListDirectoryActionProcessor => {\n return async ({ drive, folderPath, maxFiles, pageToken }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, folderPath || '');\n\n // Read all entries in the directory\n const entries = await fs.readdir(fullPath, { withFileTypes: true });\n\n // Build file info list\n const allFiles: FileInfo[] = [];\n for (const entry of entries) {\n allFiles.push({\n filepath: path.join(folderPath || '', entry.name),\n drive: drive,\n isDir: entry.isDirectory(),\n hashMd5: undefined,\n });\n }\n\n // Sort by filepath for consistent pagination\n allFiles.sort((a, b) => a.filepath.localeCompare(b.filepath));\n\n // Handle pagination\n const startIndex = pageToken ? parseInt(pageToken, 10) : 0;\n const endIndex = Math.min(startIndex + maxFiles, allFiles.length);\n const paginatedFiles = allFiles.slice(startIndex, endIndex);\n\n const result: DirectoryList = {\n fileInfos: paginatedFiles,\n };\n\n // Add page token if there are more files\n if (endIndex < allFiles.length) {\n result.pageToken = endIndex.toString();\n }\n\n return actionResult(result);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(FileListDirectoryErrorTypeEnum.DirectoryNotFound, `Directory not found: ${folderPath}`), // node fs code\n ENOTDIR: () => actionResultError(FileListDirectoryErrorTypeEnum.NotADirectory, `Path is not a directory: ${folderPath}`), // node fs code\n EACCES: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, `Access denied listing directory: ${folderPath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileListDirectoryActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ListDirectory]: getProcessFileListDirectory(config)(qpqConfig),\n });\n"]}
1
+ {"version":3,"file":"getFileListDirectoryActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAYyB;AAEzB,gDAAkC;AAClC,2CAA6B;AAG7B,mCAA0C;AAE1C,MAAM,2BAA2B,GAC/B,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC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orFromCaughtError,\n DirectoryList,\n FileActionType,\n FileInfo,\n FileListDirectoryActionProcessor,\n FileListDirectoryErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileListDirectory =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileListDirectoryActionProcessor => {\n return async ({ drive, folderPath, maxFiles, pageToken, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, folderPath || '', scope);\n\n // Read all entries in the directory\n const entries = await fs.readdir(fullPath, { withFileTypes: true });\n\n // Build file info list\n const allFiles: FileInfo[] = [];\n for (const entry of entries) {\n allFiles.push({\n filepath: path.join(folderPath || '', entry.name),\n drive: drive,\n isDir: entry.isDirectory(),\n hashMd5: undefined,\n });\n }\n\n // Sort by filepath for consistent pagination\n allFiles.sort((a, b) => a.filepath.localeCompare(b.filepath));\n\n // Handle pagination\n const startIndex = pageToken ? parseInt(pageToken, 10) : 0;\n const endIndex = Math.min(startIndex + maxFiles, allFiles.length);\n const paginatedFiles = allFiles.slice(startIndex, endIndex);\n\n const result: DirectoryList = {\n fileInfos: paginatedFiles,\n };\n\n // Add page token if there are more files\n if (endIndex < allFiles.length) {\n result.pageToken = endIndex.toString();\n }\n\n return actionResult(result);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileListDirectoryErrorTypeEnum.InvalidScope, error.message),\n ENOENT: () => actionResultError(FileListDirectoryErrorTypeEnum.DirectoryNotFound, `Directory not found: ${folderPath}`), // node fs code\n ENOTDIR: () => actionResultError(FileListDirectoryErrorTypeEnum.NotADirectory, `Path is not a directory: ${folderPath}`), // node fs code\n EACCES: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, `Access denied listing directory: ${folderPath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileListDirectoryActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ListDirectory]: getProcessFileListDirectory(config)(qpqConfig),\n });\n"]}
@@ -48,9 +48,9 @@ const fs = __importStar(require("fs/promises"));
48
48
  const path = __importStar(require("path"));
49
49
  const utils_1 = require("./utils");
50
50
  const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
51
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
51
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, scope }) {
52
52
  try {
53
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
53
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
54
54
  const buffer = yield fs.readFile(fullPath);
55
55
  // Convert Buffer to QPQBinaryData
56
56
  const binaryData = {
@@ -62,6 +62,7 @@ const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
62
62
  }
63
63
  catch (error) {
64
64
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
65
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadBinaryContentsErrorTypeEnum.InvalidScope, error.message),
65
66
  ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
66
67
  });
67
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getFileReadBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAWyB;AAEzB,gDAAkC;AAClC,2CAA6B;AAG7B,mCAA0C;AAE1C,MAAM,gCAAgC,GACpC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAAyC,EAAE;IAC9D,OAAO,KAA4B,EAAE,4CAAvB,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAE3C,kCAAkC;YAClC,MAAM,UAAU,GAAkB;gBAChC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACrC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACjC,QAAQ,EAAE,0BAA0B,EAAE,oCAAoC;aAC3E,CAAC;YAEF,OAAO,IAAA,8BAAY,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,qDAAmC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;aAClI,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,wCAAwC,GACnD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,kBAAkB,CAAC,EAAE,gCAAgC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KACzF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,wCAAwC,4CAIhD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileReadBinaryContentsActionProcessor,\n FileReadBinaryContentsErrorTypeEnum,\n QPQBinaryData,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadBinaryContents =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileReadBinaryContentsActionProcessor => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n const buffer = await fs.readFile(fullPath);\n\n // Convert Buffer to QPQBinaryData\n const binaryData: QPQBinaryData = {\n base64Data: buffer.toString('base64'),\n filename: path.basename(filepath),\n mimetype: 'application/octet-stream', // Default mimetype for binary files\n };\n\n return actionResult(binaryData);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileReadBinaryContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadBinaryContents]: getProcessFileReadBinaryContents(config)(qpqConfig),\n });\n"]}
1
+ {"version":3,"file":"getFileReadBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAWyB;AAEzB,gDAAkC;AAClC,2CAA6B;AAG7B,mCAA0C;AAE1C,MAAM,gCAAgC,GACpC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAAyC,EAAE;IAC9D,OAAO,KAAmC,EAAE,4CAA9B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC5E,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAE3C,kCAAkC;YAClC,MAAM,UAAU,GAAkB;gBAChC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACrC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACjC,QAAQ,EAAE,0BAA0B,EAAE,oCAAoC;aAC3E,CAAC;YAEF,OAAO,IAAA,8BAAY,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAiB,EAAC,qDAAmC,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;gBAChH,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,qDAAmC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;aAClI,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,wCAAwC,GACnD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,kBAAkB,CAAC,EAAE,gCAAgC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KACzF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,wCAAwC,4CAIhD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileReadBinaryContentsActionProcessor,\n FileReadBinaryContentsErrorTypeEnum,\n QPQBinaryData,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadBinaryContents =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileReadBinaryContentsActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n const buffer = await fs.readFile(fullPath);\n\n // Convert Buffer to QPQBinaryData\n const binaryData: QPQBinaryData = {\n base64Data: buffer.toString('base64'),\n filename: path.basename(filepath),\n mimetype: 'application/octet-stream', // Default mimetype for binary files\n };\n\n return actionResult(binaryData);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileReadBinaryContentsErrorTypeEnum.InvalidScope, error.message),\n ENOENT: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileReadBinaryContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadBinaryContents]: getProcessFileReadBinaryContents(config)(qpqConfig),\n });\n"]}
@@ -47,17 +47,18 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileReadObjectJson = (config) => (qpqConfig) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, scope }) {
51
51
  try {
52
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
53
53
  const content = yield fs.readFile(fullPath, 'utf8');
54
54
  const jsonObject = JSON.parse(content);
55
55
  return (0, quidproquo_core_1.actionResult)(jsonObject);
56
56
  }
57
57
  catch (error) {
58
58
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
59
- ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code
60
- SyntaxError: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`), // JSON.parse failure
59
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadObjectJsonErrorTypeEnum.InvalidScope, error.message),
60
+ ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadObjectJsonErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
61
+ SyntaxError: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadObjectJsonErrorTypeEnum.InvalidJson, `Invalid JSON in file: ${filepath}`), // JSON.parse failure
61
62
  });
62
63
  }
63
64
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getFileReadObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,4BAA4B,GAChC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAA0C,EAAE;IAC/D,OAAO,KAA4B,EAAE,4CAAvB,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvC,OAAO,IAAA,8BAAY,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,+BAAa,CAAC,QAAQ,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;gBACvG,WAAW,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,+BAAa,CAAC,YAAY,EAAE,yBAAyB,QAAQ,EAAE,CAAC,EAAE,qBAAqB;aAC7H,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,oCAAoC,GAC/C,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,cAAc,CAAC,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KACjF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,oCAAoC,wCAI5C","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n ErrorTypeEnum,\n FileActionType,\n FileReadObjectJsonActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadObjectJson =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileReadObjectJsonActionProcessor<any> => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n const content = await fs.readFile(fullPath, 'utf8');\n const jsonObject = JSON.parse(content);\n return actionResult(jsonObject);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code\n SyntaxError: () => actionResultError(ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`), // JSON.parse failure\n });\n }\n };\n };\n\nexport const getFileReadObjectJsonActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadObjectJson]: getProcessFileReadObjectJson(config)(qpqConfig),\n });\n"]}
1
+ {"version":3,"file":"getFileReadObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,4BAA4B,GAChC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAA0C,EAAE;IAC/D,OAAO,KAAmC,EAAE,4CAA9B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC5E,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvC,OAAO,IAAA,8BAAY,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAiB,EAAC,iDAA+B,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;gBAC5G,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,iDAA+B,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;gBAC7H,WAAW,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,iDAA+B,CAAC,WAAW,EAAE,yBAAyB,QAAQ,EAAE,CAAC,EAAE,qBAAqB;aAC9I,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,oCAAoC,GAC/C,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,cAAc,CAAC,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KACjF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,oCAAoC,wCAI5C","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileReadObjectJsonActionProcessor,\n FileReadObjectJsonErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadObjectJson =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileReadObjectJsonActionProcessor<any> => {\n return async ({ drive, filepath, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n const content = await fs.readFile(fullPath, 'utf8');\n const jsonObject = JSON.parse(content);\n return actionResult(jsonObject);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidScope, error.message),\n ENOENT: () => actionResultError(FileReadObjectJsonErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n SyntaxError: () => actionResultError(FileReadObjectJsonErrorTypeEnum.InvalidJson, `Invalid JSON in file: ${filepath}`), // JSON.parse failure\n });\n }\n };\n };\n\nexport const getFileReadObjectJsonActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadObjectJson]: getProcessFileReadObjectJson(config)(qpqConfig),\n });\n"]}
@@ -47,15 +47,16 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileReadTextContents = (qpqConfig, config) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, scope }) {
51
51
  try {
52
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
53
53
  const content = yield fs.readFile(fullPath, 'utf8');
54
54
  return (0, quidproquo_core_1.actionResult)(content);
55
55
  }
56
56
  catch (error) {
57
57
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
58
- ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code
58
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadTextContentsErrorTypeEnum.InvalidScope, error.message),
59
+ ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadTextContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
59
60
  });
60
61
  }
61
62
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getFileReadTextContentsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,8BAA8B,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAAuC,EAAE;IAC9H,OAAO,KAA4B,EAAE,4CAAvB,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpD,OAAO,IAAA,8BAAY,EAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,+BAAa,CAAC,QAAQ,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;aACxG,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,sCAAsC,GACjD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,gBAAgB,CAAC,EAAE,8BAA8B,CAAC,SAAS,EAAE,MAAM,CAAC;KACrF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,sCAAsC,0CAI9C","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n ErrorTypeEnum,\n FileActionType,\n FileReadTextContentsActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadTextContents = (qpqConfig: QPQConfig, config: FileStorageConfig): FileReadTextContentsActionProcessor => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n const content = await fs.readFile(fullPath, 'utf8');\n return actionResult(content);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n};\n\nexport const getFileReadTextContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadTextContents]: getProcessFileReadTextContents(qpqConfig, config),\n });\n"]}
1
+ {"version":3,"file":"getFileReadTextContentsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAA0C;AAE1C,MAAM,8BAA8B,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAAuC,EAAE;IAC9H,OAAO,KAAmC,EAAE,4CAA9B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC5E,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpD,OAAO,IAAA,8BAAY,EAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAiB,EAAC,mDAAiC,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;gBAC9G,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,mDAAiC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;aAChI,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,sCAAsC,GACjD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,gBAAgB,CAAC,EAAE,8BAA8B,CAAC,SAAS,EAAE,MAAM,CAAC;KACrF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,sCAAsC,0CAI9C","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileReadTextContentsActionProcessor,\n FileReadTextContentsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadTextContents = (qpqConfig: QPQConfig, config: FileStorageConfig): FileReadTextContentsActionProcessor => {\n return async ({ drive, filepath, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n const content = await fs.readFile(fullPath, 'utf8');\n return actionResult(content);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileReadTextContentsErrorTypeEnum.InvalidScope, error.message),\n ENOENT: () => actionResultError(FileReadTextContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n};\n\nexport const getFileReadTextContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadTextContents]: getProcessFileReadTextContents(qpqConfig, config),\n });\n"]}
@@ -109,9 +109,9 @@ function binaryStreamIterator(stream) {
109
109
  });
110
110
  }
111
111
  const getProcessFileStreamOpen = (qpqConfig, config) => {
112
- return (_a, session_1, actionProcessors_1, logger_1, updateSession_1, dynamicModuleLoader_1, streamRegistry_1) => __awaiter(void 0, [_a, session_1, actionProcessors_1, logger_1, updateSession_1, dynamicModuleLoader_1, streamRegistry_1], void 0, function* ({ drive, filepath, encoding, chunkSize }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) {
112
+ return (_a, session_1, actionProcessors_1, logger_1, updateSession_1, dynamicModuleLoader_1, streamRegistry_1) => __awaiter(void 0, [_a, session_1, actionProcessors_1, logger_1, updateSession_1, dynamicModuleLoader_1, streamRegistry_1], void 0, function* ({ drive, filepath, encoding, chunkSize, scope }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) {
113
113
  try {
114
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
114
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
115
115
  const isText = encoding === 'text';
116
116
  const highWaterMark = chunkSize !== null && chunkSize !== void 0 ? chunkSize : 65536;
117
117
  const readStream = fs.createReadStream(fullPath, isText ? { encoding: 'utf8', highWaterMark } : { highWaterMark });
@@ -122,6 +122,7 @@ const getProcessFileStreamOpen = (qpqConfig, config) => {
122
122
  }
123
123
  catch (error) {
124
124
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
125
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileStreamOpenErrorTypeEnum.InvalidScope, error.message),
125
126
  ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
126
127
  });
127
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getFileStreamOpenActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileStreamOp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ver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileStreamOpenActionProcessor,\n FileStreamOpenErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { randomUUID } from 'crypto';\nimport * as fs from 'fs';\nimport { Readable } from 'stream';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nasync function* textStreamIterator(stream: Readable): AsyncIterableIterator<string> {\n for await (const chunk of stream) {\n yield typeof chunk === 'string' ? chunk : (chunk as Buffer).toString('utf8');\n }\n}\n\nasync function* binaryStreamIterator(stream: Readable): AsyncIterableIterator<string> {\n for await (const chunk of stream) {\n const buffer = typeof chunk === 'string' ? Buffer.from(chunk) : (chunk as Buffer);\n yield buffer.toString('base64');\n }\n}\n\nconst getProcessFileStreamOpen = (qpqConfig: QPQConfig, config: FileStorageConfig): FileStreamOpenActionProcessor => {\n return async ({ drive, filepath, encoding, chunkSize }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n const isText = encoding === 'text';\n const highWaterMark = chunkSize ?? 65536;\n const readStream = fs.createReadStream(fullPath, isText ? { encoding: 'utf8', highWaterMark } : { highWaterMark });\n const streamId = `file-${randomUUID()}`;\n\n const iterator = isText ? textStreamIterator(readStream) : binaryStreamIterator(readStream);\n streamRegistry.register(streamId, iterator);\n\n return actionResult({ id: streamId, encoding });\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n};\n\nexport const getFileStreamOpenActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.StreamOpen]: getProcessFileStreamOpen(qpqConfig, config),\n });\n"]}
1
+ {"version":3,"file":"getFileStreamOpenActionProcessor.js","sourceRoot":"","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7D,CAAC,gCAAc,CAAC,UAAU,CAAC,EAAE,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC;KACzE,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,gCAAgC,oCAIxC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileStreamOpenActionProcessor,\n FileStreamOpenErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { randomUUID } from 'crypto';\nimport * as fs from 'fs';\nimport { Readable } from 'stream';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nasync function* textStreamIterator(stream: Readable): AsyncIterableIterator<string> {\n for await (const chunk of stream) {\n yield typeof chunk === 'string' ? chunk : (chunk as Buffer).toString('utf8');\n }\n}\n\nasync function* binaryStreamIterator(stream: Readable): AsyncIterableIterator<string> {\n for await (const chunk of stream) {\n const buffer = typeof chunk === 'string' ? Buffer.from(chunk) : (chunk as Buffer);\n yield buffer.toString('base64');\n }\n}\n\nconst getProcessFileStreamOpen = (qpqConfig: QPQConfig, config: FileStorageConfig): 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 fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n const isText = encoding === 'text';\n const highWaterMark = chunkSize ?? 65536;\n const readStream = fs.createReadStream(fullPath, isText ? { encoding: 'utf8', highWaterMark } : { highWaterMark });\n const streamId = `file-${randomUUID()}`;\n\n const iterator = isText ? textStreamIterator(readStream) : binaryStreamIterator(readStream);\n streamRegistry.register(streamId, iterator);\n\n return actionResult({ id: streamId, encoding });\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileStreamOpenErrorTypeEnum.InvalidScope, error.message),\n ENOENT: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n};\n\nexport const getFileStreamOpenActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.StreamOpen]: getProcessFileStreamOpen(qpqConfig, config),\n });\n"]}
@@ -47,9 +47,9 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileWriteBinaryContents = (config) => (qpqConfig) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data, scope }) {
51
51
  try {
52
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
53
53
  yield (0, utils_1.ensureParentDirectoryExists)(fullPath);
54
54
  // Convert QPQBinaryData to Buffer
55
55
  const buffer = Buffer.from(data.base64Data, 'base64');
@@ -64,6 +64,7 @@ const getProcessFileWriteBinaryContents = (config) => (qpqConfig) => {
64
64
  }
65
65
  catch (error) {
66
66
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
67
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteBinaryContentsErrorTypeEnum.InvalidScope, error.message),
67
68
  EACCES: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteBinaryContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
68
69
  });
69
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getFileWriteBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,mBAAmB,CAAC,EAAE,iCAAiC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KAC3F,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,yCAAyC,6CAIjD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileWriteBinaryContentsActionProcessor,\n FileWriteBinaryContentsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { ensureParentDirectoryExists, resolveFilePath } from './utils';\n\nconst getProcessFileWriteBinaryContents =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileWriteBinaryContentsActionProcessor => {\n return async ({ drive, filepath, data }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n await ensureParentDirectoryExists(fullPath);\n\n // Convert QPQBinaryData to Buffer\n const buffer = Buffer.from(data.base64Data, 'base64');\n await fs.writeFile(fullPath, buffer);\n\n if (data.mimetype || data.contentDisposition) {\n await fs.writeFile(\n `${fullPath}.qpqmeta.json`,\n JSON.stringify({\n mimetype: data.mimetype,\n contentDisposition: data.contentDisposition,\n }),\n );\n }\n\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n EACCES: () => actionResultError(FileWriteBinaryContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileWriteBinaryContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.WriteBinaryContents]: getProcessFileWriteBinaryContents(config)(qpqConfig),\n });\n"]}
1
+ {"version":3,"file":"getFileWriteBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../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AAC;gBACjH,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,sDAAoC,CAAC,YAAY,EAAE,+BAA+B,QAAQ,EAAE,CAAC,EAAE,eAAe;aAC/I,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,yCAAyC,GACpD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,mBAAmB,CAAC,EAAE,iCAAiC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KAC3F,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,yCAAyC,6CAIjD","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileWriteBinaryContentsActionProcessor,\n FileWriteBinaryContentsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { ensureParentDirectoryExists, resolveFilePath } from './utils';\n\nconst getProcessFileWriteBinaryContents =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileWriteBinaryContentsActionProcessor => {\n return async ({ drive, filepath, data, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n await ensureParentDirectoryExists(fullPath);\n\n // Convert QPQBinaryData to Buffer\n const buffer = Buffer.from(data.base64Data, 'base64');\n await fs.writeFile(fullPath, buffer);\n\n if (data.mimetype || data.contentDisposition) {\n await fs.writeFile(\n `${fullPath}.qpqmeta.json`,\n JSON.stringify({\n mimetype: data.mimetype,\n contentDisposition: data.contentDisposition,\n }),\n );\n }\n\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileWriteBinaryContentsErrorTypeEnum.InvalidScope, error.message),\n EACCES: () => actionResultError(FileWriteBinaryContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileWriteBinaryContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.WriteBinaryContents]: getProcessFileWriteBinaryContents(config)(qpqConfig),\n });\n"]}
@@ -47,9 +47,9 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileWriteObjectJson = (config) => (qpqConfig) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data, scope }) {
51
51
  try {
52
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
53
53
  yield (0, utils_1.ensureParentDirectoryExists)(fullPath);
54
54
  const jsonString = JSON.stringify(data, null, 2);
55
55
  yield fs.writeFile(fullPath, jsonString, 'utf8');
@@ -57,6 +57,7 @@ const getProcessFileWriteObjectJson = (config) => (qpqConfig) => {
57
57
  }
58
58
  catch (error) {
59
59
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
60
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteObjectJsonErrorTypeEnum.InvalidScope, error.message),
60
61
  EACCES: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteObjectJsonErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
61
62
  });
62
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getFileWriteObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.ts"],"names":[],"m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cessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileWriteObjectJsonActionProcessor,\n FileWriteObjectJsonErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { ensureParentDirectoryExists, resolveFilePath } from './utils';\n\nconst getProcessFileWriteObjectJson =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileWriteObjectJsonActionProcessor<any> => {\n return async ({ drive, filepath, data }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n await ensureParentDirectoryExists(fullPath);\n const jsonString = JSON.stringify(data, null, 2);\n await fs.writeFile(fullPath, jsonString, 'utf8');\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n EACCES: () => actionResultError(FileWriteObjectJsonErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileWriteObjectJsonActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.WriteObjectJson]: getProcessFileWriteObjectJson(config)(qpqConfig),\n });\n"]}
1
+ {"version":3,"file":"getFileWriteObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUyB;AAEzB,gDAAkC;AAGlC,mCAAuE;AAEvE,MAAM,6BAA6B,GACjC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAA2C,EAAE;IAChE,OAAO,KAAyC,EAAE,4CAApC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;QAC5C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC5E,MAAM,IAAA,mCAA2B,EAAC,QAAQ,CAAC,CAAC;YAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACjD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;YACjD,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,IAAA,kDAAgC,EAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mCAAiB,EAAC,kDAAgC,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;gBAC7G,MAAM,EAAE,GAAG,EAAE,CAAC,IAAA,mCAAiB,EAAC,kDAAgC,CAAC,YAAY,EAAE,+BAA+B,QAAQ,EAAE,CAAC,EAAE,eAAe;aAC3I,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEG,MAAM,qCAAqC,GAChD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,CAAO,SAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QAC7D,CAAC,gCAAc,CAAC,eAAe,CAAC,EAAE,6BAA6B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;KACnF,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,qCAAqC,yCAI7C","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileWriteObjectJsonActionProcessor,\n FileWriteObjectJsonErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { ensureParentDirectoryExists, resolveFilePath } from './utils';\n\nconst getProcessFileWriteObjectJson =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileWriteObjectJsonActionProcessor<any> => {\n return async ({ drive, filepath, data, scope }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath, scope);\n await ensureParentDirectoryExists(fullPath);\n const jsonString = JSON.stringify(data, null, 2);\n await fs.writeFile(fullPath, jsonString, 'utf8');\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileWriteObjectJsonErrorTypeEnum.InvalidScope, error.message),\n EACCES: () => actionResultError(FileWriteObjectJsonErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileWriteObjectJsonActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.WriteObjectJson]: getProcessFileWriteObjectJson(config)(qpqConfig),\n });\n"]}
@@ -47,15 +47,16 @@ const quidproquo_core_1 = require("quidproquo-core");
47
47
  const fs = __importStar(require("fs/promises"));
48
48
  const utils_1 = require("./utils");
49
49
  const getProcessFileWriteTextContents = (qpqConfig, config) => {
50
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data }) {
50
+ return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data, scope }) {
51
51
  try {
52
- const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath, scope);
53
53
  yield (0, utils_1.ensureParentDirectoryExists)(fullPath);
54
54
  yield fs.writeFile(fullPath, data, 'utf8');
55
55
  return (0, quidproquo_core_1.actionResult)(void 0);
56
56
  }
57
57
  catch (error) {
58
58
  return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
59
+ InvalidScopeError: (error) => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteTextContentsErrorTypeEnum.InvalidScope, error.message),
59
60
  EACCES: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteTextContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
60
61
  });
61
62
  }