quidproquo-actionprocessor-node 0.0.262 → 0.1.0

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 (169) hide show
  1. package/lib/commonjs/actionProcessor/core/index.d.ts +2 -12
  2. package/lib/commonjs/actionProcessor/core/index.js +10 -25
  3. package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.d.ts +2 -0
  4. package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +47 -0
  5. package/lib/commonjs/actionProcessor/core/{network/getNetworkRequestActionProcessor.d.ts → inlineFunction/index.d.ts} +1 -1
  6. package/lib/commonjs/actionProcessor/core/{error → inlineFunction}/index.js +5 -5
  7. package/lib/commonjs/actionProcessor/core/{context/getContextReadActionProcessor.d.ts → stream/getStreamCloseActionProcessor.d.ts} +1 -1
  8. package/lib/commonjs/actionProcessor/core/{context/getContextReadActionProcessor.js → stream/getStreamCloseActionProcessor.js} +8 -10
  9. package/lib/commonjs/actionProcessor/core/stream/getStreamReadActionProcessor.d.ts +2 -0
  10. package/lib/commonjs/actionProcessor/core/{math/getMathRandomNumberActionProcessor.js → stream/getStreamReadActionProcessor.js} +8 -7
  11. package/lib/commonjs/actionProcessor/core/{system → stream}/index.d.ts +1 -1
  12. package/lib/commonjs/actionProcessor/core/{system → stream}/index.js +6 -5
  13. package/lib/commonjs/actionProcessor/webserver/index.js +4 -2
  14. package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +7 -4
  15. package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js +10 -4
  16. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +1 -2
  17. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +1 -2
  18. package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +6 -9
  19. package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +4 -6
  20. package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +5 -9
  21. package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +4 -6
  22. package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.d.ts +3 -0
  23. package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +135 -0
  24. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +10 -3
  25. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +4 -3
  26. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +4 -3
  27. package/lib/commonjs/dynamicActionProcessor/file/index.js +2 -1
  28. package/lib/commonjs/dynamicActionProcessor/file/utils.d.ts +2 -1
  29. package/lib/commonjs/dynamicActionProcessor/file/utils.js +11 -1
  30. package/lib/esm/actionProcessor/core/index.d.ts +2 -12
  31. package/lib/esm/actionProcessor/core/index.js +12 -35
  32. package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.d.ts +2 -0
  33. package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +32 -0
  34. package/lib/esm/actionProcessor/core/{network/getNetworkRequestActionProcessor.d.ts → inlineFunction/index.d.ts} +1 -1
  35. package/lib/esm/actionProcessor/core/inlineFunction/index.js +4 -0
  36. package/lib/{commonjs/actionProcessor/core/context/getContextListActionProcessor.d.ts → esm/actionProcessor/core/stream/getStreamCloseActionProcessor.d.ts} +1 -1
  37. package/lib/esm/actionProcessor/core/stream/getStreamCloseActionProcessor.js +10 -0
  38. package/lib/esm/actionProcessor/core/stream/getStreamReadActionProcessor.d.ts +2 -0
  39. package/lib/esm/actionProcessor/core/stream/getStreamReadActionProcessor.js +10 -0
  40. package/lib/esm/actionProcessor/core/{config → stream}/index.d.ts +1 -1
  41. package/lib/esm/actionProcessor/core/stream/index.js +6 -0
  42. package/lib/esm/actionProcessor/webserver/index.js +4 -2
  43. package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +8 -5
  44. package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js +11 -5
  45. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +2 -3
  46. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +2 -3
  47. package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +7 -10
  48. package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +5 -7
  49. package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +6 -10
  50. package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +5 -7
  51. package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.d.ts +3 -0
  52. package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +37 -0
  53. package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +11 -4
  54. package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +5 -4
  55. package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +5 -4
  56. package/lib/esm/dynamicActionProcessor/file/index.js +2 -0
  57. package/lib/esm/dynamicActionProcessor/file/utils.d.ts +2 -1
  58. package/lib/esm/dynamicActionProcessor/file/utils.js +9 -1
  59. package/package.json +5 -9
  60. package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +0 -2
  61. package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -74
  62. package/lib/commonjs/actionProcessor/core/claudeAi/index.d.ts +0 -2
  63. package/lib/commonjs/actionProcessor/core/claudeAi/index.js +0 -17
  64. package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +0 -2
  65. package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +0 -30
  66. package/lib/commonjs/actionProcessor/core/config/index.d.ts +0 -2
  67. package/lib/commonjs/actionProcessor/core/config/index.js +0 -17
  68. package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.js +0 -24
  69. package/lib/commonjs/actionProcessor/core/context/index.d.ts +0 -2
  70. package/lib/commonjs/actionProcessor/core/context/index.js +0 -18
  71. package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +0 -2
  72. package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.js +0 -58
  73. package/lib/commonjs/actionProcessor/core/customActions/index.d.ts +0 -1
  74. package/lib/commonjs/actionProcessor/core/customActions/index.js +0 -18
  75. package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.d.ts +0 -2
  76. package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.js +0 -24
  77. package/lib/commonjs/actionProcessor/core/date/index.d.ts +0 -2
  78. package/lib/commonjs/actionProcessor/core/date/index.js +0 -17
  79. package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +0 -2
  80. package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +0 -24
  81. package/lib/commonjs/actionProcessor/core/error/index.d.ts +0 -2
  82. package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +0 -2
  83. package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.js +0 -25
  84. package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +0 -2
  85. package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +0 -25
  86. package/lib/commonjs/actionProcessor/core/guid/index.d.ts +0 -2
  87. package/lib/commonjs/actionProcessor/core/guid/index.js +0 -18
  88. package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +0 -2
  89. package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.js +0 -30
  90. package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +0 -2
  91. package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +0 -25
  92. package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +0 -2
  93. package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +0 -26
  94. package/lib/commonjs/actionProcessor/core/log/index.d.ts +0 -2
  95. package/lib/commonjs/actionProcessor/core/log/index.js +0 -19
  96. package/lib/commonjs/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +0 -2
  97. package/lib/commonjs/actionProcessor/core/math/index.d.ts +0 -2
  98. package/lib/commonjs/actionProcessor/core/math/index.js +0 -17
  99. package/lib/commonjs/actionProcessor/core/network/getNetworkRequestActionProcessor.js +0 -150
  100. package/lib/commonjs/actionProcessor/core/network/index.d.ts +0 -2
  101. package/lib/commonjs/actionProcessor/core/network/index.js +0 -17
  102. package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +0 -2
  103. package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +0 -24
  104. package/lib/commonjs/actionProcessor/core/platform/index.d.ts +0 -2
  105. package/lib/commonjs/actionProcessor/core/platform/index.js +0 -17
  106. package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +0 -2
  107. package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.js +0 -51
  108. package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +0 -2
  109. package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.js +0 -26
  110. package/lib/commonjs/actionProcessor/webserver/dns/index.d.ts +0 -2
  111. package/lib/commonjs/actionProcessor/webserver/dns/index.js +0 -17
  112. package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +0 -2
  113. package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -26
  114. package/lib/esm/actionProcessor/core/claudeAi/index.d.ts +0 -2
  115. package/lib/esm/actionProcessor/core/claudeAi/index.js +0 -4
  116. package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +0 -2
  117. package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +0 -15
  118. package/lib/esm/actionProcessor/core/config/index.js +0 -4
  119. package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.d.ts +0 -2
  120. package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.js +0 -9
  121. package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.d.ts +0 -2
  122. package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.js +0 -12
  123. package/lib/esm/actionProcessor/core/context/index.d.ts +0 -2
  124. package/lib/esm/actionProcessor/core/context/index.js +0 -6
  125. package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +0 -2
  126. package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.js +0 -43
  127. package/lib/esm/actionProcessor/core/customActions/index.d.ts +0 -1
  128. package/lib/esm/actionProcessor/core/customActions/index.js +0 -2
  129. package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.d.ts +0 -2
  130. package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.js +0 -9
  131. package/lib/esm/actionProcessor/core/date/index.d.ts +0 -2
  132. package/lib/esm/actionProcessor/core/date/index.js +0 -4
  133. package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +0 -2
  134. package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +0 -9
  135. package/lib/esm/actionProcessor/core/error/index.d.ts +0 -2
  136. package/lib/esm/actionProcessor/core/error/index.js +0 -4
  137. package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +0 -2
  138. package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.js +0 -10
  139. package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +0 -2
  140. package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +0 -10
  141. package/lib/esm/actionProcessor/core/guid/index.d.ts +0 -2
  142. package/lib/esm/actionProcessor/core/guid/index.js +0 -6
  143. package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +0 -2
  144. package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.js +0 -15
  145. package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +0 -2
  146. package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +0 -10
  147. package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +0 -2
  148. package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +0 -11
  149. package/lib/esm/actionProcessor/core/log/index.d.ts +0 -2
  150. package/lib/esm/actionProcessor/core/log/index.js +0 -8
  151. package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +0 -2
  152. package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.js +0 -9
  153. package/lib/esm/actionProcessor/core/math/index.d.ts +0 -2
  154. package/lib/esm/actionProcessor/core/math/index.js +0 -4
  155. package/lib/esm/actionProcessor/core/network/getNetworkRequestActionProcessor.js +0 -134
  156. package/lib/esm/actionProcessor/core/network/index.d.ts +0 -2
  157. package/lib/esm/actionProcessor/core/network/index.js +0 -4
  158. package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +0 -2
  159. package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +0 -9
  160. package/lib/esm/actionProcessor/core/platform/index.d.ts +0 -2
  161. package/lib/esm/actionProcessor/core/platform/index.js +0 -4
  162. package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +0 -2
  163. package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.js +0 -36
  164. package/lib/esm/actionProcessor/core/system/index.d.ts +0 -2
  165. package/lib/esm/actionProcessor/core/system/index.js +0 -4
  166. package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +0 -2
  167. package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.js +0 -11
  168. package/lib/esm/actionProcessor/webserver/dns/index.d.ts +0 -2
  169. package/lib/esm/actionProcessor/webserver/dns/index.js +0 -4
@@ -1,14 +1,4 @@
1
1
  import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export * from './claudeAi';
3
- export * from './config';
4
- export * from './context';
5
- export * from './date';
6
- export * from './error';
7
- export * from './guid';
8
- export * from './log';
9
- export * from './math';
10
- export * from './network';
11
- export * from './platform';
12
- export * from './system';
13
- export * from './customActions';
2
+ export * from './inlineFunction';
3
+ export * from './stream';
14
4
  export declare const getCoreActionProcessor: ActionProcessorListResolver;
@@ -24,31 +24,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getCoreActionProcessor = void 0;
27
- const claudeAi_1 = require("./claudeAi");
28
- const config_1 = require("./config");
29
- const context_1 = require("./context");
30
- const date_1 = require("./date");
31
- const error_1 = require("./error");
32
- const guid_1 = require("./guid");
33
- const log_1 = require("./log");
34
- const math_1 = require("./math");
35
- const network_1 = require("./network");
36
- const platform_1 = require("./platform");
37
- const system_1 = require("./system");
38
- __exportStar(require("./claudeAi"), exports);
39
- __exportStar(require("./config"), exports);
40
- __exportStar(require("./context"), exports);
41
- __exportStar(require("./date"), exports);
42
- __exportStar(require("./error"), exports);
43
- __exportStar(require("./guid"), exports);
44
- __exportStar(require("./log"), exports);
45
- __exportStar(require("./math"), exports);
46
- __exportStar(require("./network"), exports);
47
- __exportStar(require("./platform"), exports);
48
- __exportStar(require("./system"), exports);
49
- // Custom actions is not done here, as it has to be done last after all
50
- __exportStar(require("./customActions"), exports);
27
+ const quidproquo_actionprocessor_js_1 = require("quidproquo-actionprocessor-js");
28
+ const inlineFunction_1 = require("./inlineFunction");
29
+ const stream_1 = require("./stream");
30
+ // The shared core processors (config, context, claudeAi, date, error, guid, log,
31
+ // math, network, platform, system, customActions) are owned by
32
+ // quidproquo-actionprocessor-js. Node builds on top of js and only adds the
33
+ // processors that need a Node runtime (stream, inlineFunction).
34
+ __exportStar(require("./inlineFunction"), exports);
35
+ __exportStar(require("./stream"), exports);
51
36
  const getCoreActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
52
- return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, config_1.getConfigActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, context_1.getContextActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, claudeAi_1.getClaudeAiActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, date_1.getDateActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, error_1.getErrorActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, guid_1.getGuidProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, log_1.getLogActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, math_1.getMathActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, network_1.getNetworkActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, platform_1.getPlatformActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, system_1.getSystemActionProcessor)(qpqConfig, dynamicModuleLoader))));
37
+ return (Object.assign(Object.assign(Object.assign({}, (yield (0, quidproquo_actionprocessor_js_1.getCoreActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, stream_1.getStreamActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, inlineFunction_1.getInlineFunctionActionProcessor)(qpqConfig, dynamicModuleLoader))));
53
38
  });
54
39
  exports.getCoreActionProcessor = getCoreActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getInlineFunctionExecuteActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getInlineFunctionExecuteActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const crypto_1 = require("crypto");
15
+ const getDateNow = () => new Date().toISOString();
16
+ const getProcessExecute = (qpqConfig) => {
17
+ const moduleName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
18
+ return (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const inlineFunctions = quidproquo_core_1.qpqCoreUtils.getAllInlineFunctions(qpqConfig);
20
+ const inlineFunction = inlineFunctions.find((f) => f.functionName === payload.functionName);
21
+ if (!inlineFunction) {
22
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Inline function not found: [${payload.functionName}]`);
23
+ }
24
+ const story = yield dynamicModuleLoader(inlineFunction.runtime);
25
+ if (!story) {
26
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Unable to dynamically load inline function: [${payload.functionName}]`);
27
+ }
28
+ const resolveStory = (0, quidproquo_core_1.createRuntime)(qpqConfig, {
29
+ context: session.context,
30
+ localContext: session.localContext,
31
+ depth: (session.depth || 0) + 1,
32
+ decodedAccessToken: session.decodedAccessToken,
33
+ correlation: session.correlation,
34
+ }, () => __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
+ const storyResult = yield resolveStory(story, [payload.payload]);
36
+ if (storyResult.error) {
37
+ return (0, quidproquo_core_1.actionResultError)(storyResult.error.errorType, storyResult.error.errorText, storyResult.error.errorStack ? `${payload.functionName} -> [${storyResult.error.errorStack}]` : payload.functionName);
38
+ }
39
+ return (0, quidproquo_core_1.actionResult)(storyResult.result);
40
+ });
41
+ };
42
+ const getInlineFunctionExecuteActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
43
+ return ({
44
+ [quidproquo_core_1.InlineFunctionActionType.Execute]: getProcessExecute(qpqConfig),
45
+ });
46
+ });
47
+ exports.getInlineFunctionExecuteActionProcessor = getInlineFunctionExecuteActionProcessor;
@@ -1,2 +1,2 @@
1
1
  import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getNetworkRequestActionProcessor: ActionProcessorListResolver;
2
+ export declare const getInlineFunctionActionProcessor: ActionProcessorListResolver;
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getErrorActionProcessor = void 0;
13
- const getErrorThrowErrorActionProcessor_1 = require("./getErrorThrowErrorActionProcessor");
14
- const getErrorActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (Object.assign({}, (yield (0, getErrorThrowErrorActionProcessor_1.getErrorThrowErrorActionProcessor)(qpqConfig, dynamicModuleLoader))));
12
+ exports.getInlineFunctionActionProcessor = void 0;
13
+ const getInlineFunctionExecuteActionProcessor_1 = require("./getInlineFunctionExecuteActionProcessor");
14
+ const getInlineFunctionActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
+ return (Object.assign({}, (yield (0, getInlineFunctionExecuteActionProcessor_1.getInlineFunctionExecuteActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
16
  });
17
- exports.getErrorActionProcessor = getErrorActionProcessor;
17
+ exports.getInlineFunctionActionProcessor = getInlineFunctionActionProcessor;
@@ -1,2 +1,2 @@
1
1
  import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getContextReadActionProcessor: ActionProcessorListResolver;
2
+ export declare const getStreamCloseActionProcessor: ActionProcessorListResolver;
@@ -9,19 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getContextReadActionProcessor = void 0;
12
+ exports.getStreamCloseActionProcessor = void 0;
13
13
  const quidproquo_core_1 = require("quidproquo-core");
14
- const getContextValue = (context, contextIdentifier) => {
15
- return contextIdentifier.uniqueName in context ? context[contextIdentifier.uniqueName] : contextIdentifier.defaultValue;
16
- };
17
- const getProcessContextRead = (qpqConfig) => {
18
- return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ contextIdentifier }, session) {
19
- return (0, quidproquo_core_1.actionResult)(getContextValue(session.context, contextIdentifier));
14
+ const getProcessStreamClose = (qpqConfig) => {
15
+ 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* ({ streamId }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) {
16
+ streamRegistry.close(streamId);
17
+ return (0, quidproquo_core_1.actionResult)(undefined);
20
18
  });
21
19
  };
22
- const getContextReadActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const getStreamCloseActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
23
21
  return ({
24
- [quidproquo_core_1.ContextActionType.Read]: getProcessContextRead(qpqConfig),
22
+ [quidproquo_core_1.StreamActionType.Close]: getProcessStreamClose(qpqConfig),
25
23
  });
26
24
  });
27
- exports.getContextReadActionProcessor = getContextReadActionProcessor;
25
+ exports.getStreamCloseActionProcessor = getStreamCloseActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getStreamReadActionProcessor: ActionProcessorListResolver;
@@ -9,16 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getMathRandomNumberActionProcessor = void 0;
12
+ exports.getStreamReadActionProcessor = void 0;
13
13
  const quidproquo_core_1 = require("quidproquo-core");
14
- const getProcessMathRandomNumber = (qpqConfig) => {
15
- return () => __awaiter(void 0, void 0, void 0, function* () {
16
- return (0, quidproquo_core_1.actionResult)(Math.random());
14
+ const getProcessStreamRead = (qpqConfig) => {
15
+ 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* ({ streamId, noWait }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) {
16
+ const chunk = yield streamRegistry.read(streamId, noWait);
17
+ return (0, quidproquo_core_1.actionResult)(chunk);
17
18
  });
18
19
  };
19
- const getMathRandomNumberActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const getStreamReadActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
20
21
  return ({
21
- [quidproquo_core_1.MathActionType.RandomNumber]: getProcessMathRandomNumber(qpqConfig),
22
+ [quidproquo_core_1.StreamActionType.Read]: getProcessStreamRead(qpqConfig),
22
23
  });
23
24
  });
24
- exports.getMathRandomNumberActionProcessor = getMathRandomNumberActionProcessor;
25
+ exports.getStreamReadActionProcessor = getStreamReadActionProcessor;
@@ -1,2 +1,2 @@
1
1
  import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getSystemActionProcessor: ActionProcessorListResolver;
2
+ export declare const getStreamActionProcessor: ActionProcessorListResolver;
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getSystemActionProcessor = void 0;
13
- const getSystemBatchActionProcessor_1 = require("./getSystemBatchActionProcessor");
14
- const getSystemActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (Object.assign({}, (yield (0, getSystemBatchActionProcessor_1.getSystemBatchActionProcessor)(qpqConfig, dynamicModuleLoader))));
12
+ exports.getStreamActionProcessor = void 0;
13
+ const getStreamCloseActionProcessor_1 = require("./getStreamCloseActionProcessor");
14
+ const getStreamReadActionProcessor_1 = require("./getStreamReadActionProcessor");
15
+ const getStreamActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
16
+ return (Object.assign(Object.assign({}, (yield (0, getStreamCloseActionProcessor_1.getStreamCloseActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getStreamReadActionProcessor_1.getStreamReadActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
17
  });
17
- exports.getSystemActionProcessor = getSystemActionProcessor;
18
+ exports.getStreamActionProcessor = getStreamActionProcessor;
@@ -10,8 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getWebserverActionProcessor = void 0;
13
- const dns_1 = require("./dns");
13
+ const quidproquo_actionprocessor_js_1 = require("quidproquo-actionprocessor-js");
14
+ // The shared webserver processors (dns, ...) are owned by quidproquo-actionprocessor-js.
15
+ // Node builds on top of js; it currently adds no node-specific webserver processors.
14
16
  const getWebserverActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (Object.assign({}, (yield (0, dns_1.getDnsActionProcessor)(qpqConfig, dynamicModuleLoader))));
17
+ return (Object.assign({}, (yield (0, quidproquo_actionprocessor_js_1.getWebserverActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
18
  });
17
19
  exports.getWebserverActionProcessor = getWebserverActionProcessor;
@@ -47,13 +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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
51
50
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepaths }) {
52
51
  const deletedFiles = [];
53
52
  const errors = [];
54
53
  for (const filepath of filepaths) {
55
54
  try {
56
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
55
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
57
56
  yield fs.unlink(fullPath);
58
57
  deletedFiles.push(filepath);
59
58
  }
@@ -63,12 +62,16 @@ const getProcessFileDelete = (qpqConfig, config) => {
63
62
  deletedFiles.push(filepath);
64
63
  }
65
64
  else {
66
- errors.push(`Failed to delete ${filepath}: ${error.message}`);
65
+ errors.push({ filepath, error });
67
66
  }
68
67
  }
69
68
  }
70
69
  if (errors.length > 0 && deletedFiles.length === 0) {
71
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Failed to delete files: ${errors.join(', ')}`);
70
+ // EACCES maps to the same typed error the S3 processor returns for AccessDenied
71
+ if (errors.some(({ error }) => error.code === 'EACCES')) {
72
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileDeleteErrorTypeEnum.AccessDenied, 'Access denied deleting files');
73
+ }
74
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Failed to delete files: ${errors.map(({ filepath, error }) => `Failed to delete ${filepath}: ${error.message}`).join(', ')}`);
72
75
  }
73
76
  return (0, quidproquo_core_1.actionResult)(deletedFiles);
74
77
  });
@@ -47,16 +47,22 @@ 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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
51
50
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
52
51
  try {
53
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
54
53
  try {
55
54
  yield fs.access(fullPath);
56
55
  return (0, quidproquo_core_1.actionResult)(true);
57
56
  }
58
- catch (_b) {
59
- return (0, quidproquo_core_1.actionResult)(false);
57
+ catch (error) {
58
+ // Missing file is a definitive false; permission problems must surface.
59
+ if (error.code === 'ENOENT') {
60
+ return (0, quidproquo_core_1.actionResult)(false);
61
+ }
62
+ if (error.code === 'EACCES') {
63
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileExistsErrorTypeEnum.AccessDenied, `Access denied checking file existence: ${filepath}`);
64
+ }
65
+ throw error;
60
66
  }
61
67
  }
62
68
  catch (error) {
@@ -14,12 +14,11 @@ const quidproquo_core_1 = require("quidproquo-core");
14
14
  const secureUrlUtils_1 = require("./secureUrlUtils");
15
15
  const utils_1 = require("./utils");
16
16
  const getProcessFileGenerateTemporarySecureUrl = (qpqConfig, config) => {
17
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
18
17
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs }) {
19
18
  try {
20
19
  // Create a token for download
21
20
  const token = (0, secureUrlUtils_1.createSecureUrlToken)({
22
- fullFilepath: (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath),
21
+ fullFilepath: (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath),
23
22
  operation: 'download',
24
23
  expiresAt: Date.now() + expirationMs,
25
24
  }, config.secureUrlSecret);
@@ -14,13 +14,12 @@ const quidproquo_core_1 = require("quidproquo-core");
14
14
  const secureUrlUtils_1 = require("./secureUrlUtils");
15
15
  const utils_1 = require("./utils");
16
16
  const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig, config) => {
17
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
18
17
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs, contentType }) {
19
18
  try {
20
19
  const expiresAt = Date.now() + expirationMs;
21
20
  // Create a token for upload
22
21
  const token = (0, secureUrlUtils_1.createSecureUrlToken)({
23
- fullFilepath: (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath),
22
+ fullFilepath: (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath),
24
23
  operation: 'upload',
25
24
  expiresAt,
26
25
  contentType,
@@ -48,10 +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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
52
51
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, folderPath, maxFiles, pageToken }) {
53
52
  try {
54
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, folderPath || '');
53
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, folderPath || '');
55
54
  // Read all entries in the directory
56
55
  const entries = yield fs.readdir(fullPath, { withFileTypes: true });
57
56
  // Build file info list
@@ -80,13 +79,11 @@ const getProcessFileListDirectory = (config) => (qpqConfig) => {
80
79
  return (0, quidproquo_core_1.actionResult)(result);
81
80
  }
82
81
  catch (error) {
83
- if (error.code === 'ENOENT') {
84
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Directory not found: ${folderPath}`);
85
- }
86
- if (error.code === 'ENOTDIR') {
87
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Path is not a directory: ${folderPath}`);
88
- }
89
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error listing directory: ${error.message}`);
82
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
83
+ ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.DirectoryNotFound, `Directory not found: ${folderPath}`), // node fs code
84
+ ENOTDIR: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.NotADirectory, `Path is not a directory: ${folderPath}`), // node fs code
85
+ EACCES: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileListDirectoryErrorTypeEnum.AccessDenied, `Access denied listing directory: ${folderPath}`), // node fs code
86
+ });
90
87
  }
91
88
  });
92
89
  };
@@ -48,10 +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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
52
51
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
53
52
  try {
54
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
53
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
55
54
  const buffer = yield fs.readFile(fullPath);
56
55
  // Convert Buffer to QPQBinaryData
57
56
  const binaryData = {
@@ -62,10 +61,9 @@ const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
62
61
  return (0, quidproquo_core_1.actionResult)(binaryData);
63
62
  }
64
63
  catch (error) {
65
- if (error.code === 'ENOENT') {
66
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
67
- }
68
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error reading binary file: ${error.message}`);
64
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
65
+ ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
66
+ });
69
67
  }
70
68
  });
71
69
  };
@@ -47,22 +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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
51
50
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
52
51
  try {
53
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
54
53
  const content = yield fs.readFile(fullPath, 'utf8');
55
54
  const jsonObject = JSON.parse(content);
56
55
  return (0, quidproquo_core_1.actionResult)(jsonObject);
57
56
  }
58
57
  catch (error) {
59
- if (error.code === 'ENOENT') {
60
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
61
- }
62
- if (error instanceof SyntaxError) {
63
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`);
64
- }
65
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error reading JSON file: ${error.message}`);
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
61
+ });
66
62
  }
67
63
  });
68
64
  };
@@ -47,18 +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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
51
50
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
52
51
  try {
53
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
54
53
  const content = yield fs.readFile(fullPath, 'utf8');
55
54
  return (0, quidproquo_core_1.actionResult)(content);
56
55
  }
57
56
  catch (error) {
58
- if (error.code === 'ENOENT') {
59
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
60
- }
61
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error reading file: ${error.message}`);
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
59
+ });
62
60
  }
63
61
  });
64
62
  };
@@ -0,0 +1,3 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ import { FileStorageConfig } from './types';
3
+ export declare const getFileStreamOpenActionProcessor: (config: FileStorageConfig) => ActionProcessorListResolver;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
45
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
46
+ var m = o[Symbol.asyncIterator], i;
47
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
48
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
49
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
50
+ };
51
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
52
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
53
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
54
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
55
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
56
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
57
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
58
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
59
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
60
+ function fulfill(value) { resume("next", value); }
61
+ function reject(value) { resume("throw", value); }
62
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.getFileStreamOpenActionProcessor = void 0;
66
+ const quidproquo_core_1 = require("quidproquo-core");
67
+ const crypto_1 = require("crypto");
68
+ const fs = __importStar(require("fs"));
69
+ const utils_1 = require("./utils");
70
+ function textStreamIterator(stream) {
71
+ return __asyncGenerator(this, arguments, function* textStreamIterator_1() {
72
+ var _a, e_1, _b, _c;
73
+ try {
74
+ for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
75
+ _c = stream_1_1.value;
76
+ _d = false;
77
+ const chunk = _c;
78
+ yield yield __await(typeof chunk === 'string' ? chunk : chunk.toString('utf8'));
79
+ }
80
+ }
81
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
82
+ finally {
83
+ try {
84
+ if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
85
+ }
86
+ finally { if (e_1) throw e_1.error; }
87
+ }
88
+ });
89
+ }
90
+ function binaryStreamIterator(stream) {
91
+ return __asyncGenerator(this, arguments, function* binaryStreamIterator_1() {
92
+ var _a, e_2, _b, _c;
93
+ try {
94
+ for (var _d = true, stream_2 = __asyncValues(stream), stream_2_1; stream_2_1 = yield __await(stream_2.next()), _a = stream_2_1.done, !_a; _d = true) {
95
+ _c = stream_2_1.value;
96
+ _d = false;
97
+ const chunk = _c;
98
+ const buffer = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
99
+ yield yield __await(buffer.toString('base64'));
100
+ }
101
+ }
102
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
103
+ finally {
104
+ try {
105
+ if (!_d && !_a && (_b = stream_2.return)) yield __await(_b.call(stream_2));
106
+ }
107
+ finally { if (e_2) throw e_2.error; }
108
+ }
109
+ });
110
+ }
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) {
113
+ try {
114
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
115
+ const isText = encoding === 'text';
116
+ const highWaterMark = chunkSize !== null && chunkSize !== void 0 ? chunkSize : 65536;
117
+ const readStream = fs.createReadStream(fullPath, isText ? { encoding: 'utf8', highWaterMark } : { highWaterMark });
118
+ const streamId = `file-${(0, crypto_1.randomUUID)()}`;
119
+ const iterator = isText ? textStreamIterator(readStream) : binaryStreamIterator(readStream);
120
+ streamRegistry.register(streamId, iterator);
121
+ return (0, quidproquo_core_1.actionResult)({ id: streamId, encoding });
122
+ }
123
+ catch (error) {
124
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
125
+ ENOENT: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
126
+ });
127
+ }
128
+ });
129
+ };
130
+ const getFileStreamOpenActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
131
+ return ({
132
+ [quidproquo_core_1.FileActionType.StreamOpen]: getProcessFileStreamOpen(qpqConfig, config),
133
+ });
134
+ });
135
+ exports.getFileStreamOpenActionProcessor = getFileStreamOpenActionProcessor;
@@ -47,18 +47,25 @@ 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
- const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
51
50
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, data }) {
52
51
  try {
53
- const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
52
+ const fullPath = (0, utils_1.resolveFilePath)(config, qpqConfig, drive, filepath);
54
53
  yield (0, utils_1.ensureParentDirectoryExists)(fullPath);
55
54
  // Convert QPQBinaryData to Buffer
56
55
  const buffer = Buffer.from(data.base64Data, 'base64');
57
56
  yield fs.writeFile(fullPath, buffer);
57
+ if (data.mimetype || data.contentDisposition) {
58
+ yield fs.writeFile(`${fullPath}.qpqmeta.json`, JSON.stringify({
59
+ mimetype: data.mimetype,
60
+ contentDisposition: data.contentDisposition,
61
+ }));
62
+ }
58
63
  return (0, quidproquo_core_1.actionResult)(void 0);
59
64
  }
60
65
  catch (error) {
61
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error writing binary file: ${error.message}`);
66
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {
67
+ EACCES: () => (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.FileWriteBinaryContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
68
+ });
62
69
  }
63
70
  });
64
71
  };