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.
- package/lib/commonjs/actionProcessor/core/index.d.ts +2 -12
- package/lib/commonjs/actionProcessor/core/index.js +10 -25
- package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +47 -0
- package/lib/commonjs/actionProcessor/core/{network/getNetworkRequestActionProcessor.d.ts → inlineFunction/index.d.ts} +1 -1
- package/lib/commonjs/actionProcessor/core/{error → inlineFunction}/index.js +5 -5
- package/lib/commonjs/actionProcessor/core/{context/getContextReadActionProcessor.d.ts → stream/getStreamCloseActionProcessor.d.ts} +1 -1
- package/lib/commonjs/actionProcessor/core/{context/getContextReadActionProcessor.js → stream/getStreamCloseActionProcessor.js} +8 -10
- package/lib/commonjs/actionProcessor/core/stream/getStreamReadActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/{math/getMathRandomNumberActionProcessor.js → stream/getStreamReadActionProcessor.js} +8 -7
- package/lib/commonjs/actionProcessor/core/{system → stream}/index.d.ts +1 -1
- package/lib/commonjs/actionProcessor/core/{system → stream}/index.js +6 -5
- package/lib/commonjs/actionProcessor/webserver/index.js +4 -2
- package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +7 -4
- package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js +10 -4
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +1 -2
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +1 -2
- package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +6 -9
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +4 -6
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +5 -9
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +4 -6
- package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +135 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +10 -3
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +4 -3
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +4 -3
- package/lib/commonjs/dynamicActionProcessor/file/index.js +2 -1
- package/lib/commonjs/dynamicActionProcessor/file/utils.d.ts +2 -1
- package/lib/commonjs/dynamicActionProcessor/file/utils.js +11 -1
- package/lib/esm/actionProcessor/core/index.d.ts +2 -12
- package/lib/esm/actionProcessor/core/index.js +12 -35
- package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +32 -0
- package/lib/esm/actionProcessor/core/{network/getNetworkRequestActionProcessor.d.ts → inlineFunction/index.d.ts} +1 -1
- package/lib/esm/actionProcessor/core/inlineFunction/index.js +4 -0
- package/lib/{commonjs/actionProcessor/core/context/getContextListActionProcessor.d.ts → esm/actionProcessor/core/stream/getStreamCloseActionProcessor.d.ts} +1 -1
- package/lib/esm/actionProcessor/core/stream/getStreamCloseActionProcessor.js +10 -0
- package/lib/esm/actionProcessor/core/stream/getStreamReadActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/stream/getStreamReadActionProcessor.js +10 -0
- package/lib/esm/actionProcessor/core/{config → stream}/index.d.ts +1 -1
- package/lib/esm/actionProcessor/core/stream/index.js +6 -0
- package/lib/esm/actionProcessor/webserver/index.js +4 -2
- package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +8 -5
- package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js +11 -5
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +2 -3
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +2 -3
- package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +7 -10
- package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +5 -7
- package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +6 -10
- package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +5 -7
- package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +37 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +11 -4
- package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +5 -4
- package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +5 -4
- package/lib/esm/dynamicActionProcessor/file/index.js +2 -0
- package/lib/esm/dynamicActionProcessor/file/utils.d.ts +2 -1
- package/lib/esm/dynamicActionProcessor/file/utils.js +9 -1
- package/package.json +5 -9
- package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -74
- package/lib/commonjs/actionProcessor/core/claudeAi/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/claudeAi/index.js +0 -17
- package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +0 -30
- package/lib/commonjs/actionProcessor/core/config/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/config/index.js +0 -17
- package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.js +0 -24
- package/lib/commonjs/actionProcessor/core/context/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/context/index.js +0 -18
- package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.js +0 -58
- package/lib/commonjs/actionProcessor/core/customActions/index.d.ts +0 -1
- package/lib/commonjs/actionProcessor/core/customActions/index.js +0 -18
- package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.js +0 -24
- package/lib/commonjs/actionProcessor/core/date/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/date/index.js +0 -17
- package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +0 -24
- package/lib/commonjs/actionProcessor/core/error/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.js +0 -25
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +0 -25
- package/lib/commonjs/actionProcessor/core/guid/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/guid/index.js +0 -18
- package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.js +0 -30
- package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +0 -25
- package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +0 -26
- package/lib/commonjs/actionProcessor/core/log/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/log/index.js +0 -19
- package/lib/commonjs/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/math/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/math/index.js +0 -17
- package/lib/commonjs/actionProcessor/core/network/getNetworkRequestActionProcessor.js +0 -150
- package/lib/commonjs/actionProcessor/core/network/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/network/index.js +0 -17
- package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +0 -24
- package/lib/commonjs/actionProcessor/core/platform/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/platform/index.js +0 -17
- package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.js +0 -51
- package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.js +0 -26
- package/lib/commonjs/actionProcessor/webserver/dns/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/webserver/dns/index.js +0 -17
- package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -26
- package/lib/esm/actionProcessor/core/claudeAi/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/claudeAi/index.js +0 -4
- package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +0 -15
- package/lib/esm/actionProcessor/core/config/index.js +0 -4
- package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.js +0 -9
- package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.js +0 -12
- package/lib/esm/actionProcessor/core/context/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/context/index.js +0 -6
- package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.js +0 -43
- package/lib/esm/actionProcessor/core/customActions/index.d.ts +0 -1
- package/lib/esm/actionProcessor/core/customActions/index.js +0 -2
- package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.js +0 -9
- package/lib/esm/actionProcessor/core/date/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/date/index.js +0 -4
- package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +0 -9
- package/lib/esm/actionProcessor/core/error/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/error/index.js +0 -4
- package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.js +0 -10
- package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +0 -10
- package/lib/esm/actionProcessor/core/guid/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/guid/index.js +0 -6
- package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.js +0 -15
- package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +0 -10
- package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +0 -11
- package/lib/esm/actionProcessor/core/log/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/log/index.js +0 -8
- package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.js +0 -9
- package/lib/esm/actionProcessor/core/math/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/math/index.js +0 -4
- package/lib/esm/actionProcessor/core/network/getNetworkRequestActionProcessor.js +0 -134
- package/lib/esm/actionProcessor/core/network/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/network/index.js +0 -4
- package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +0 -9
- package/lib/esm/actionProcessor/core/platform/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/platform/index.js +0 -4
- package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.js +0 -36
- package/lib/esm/actionProcessor/core/system/index.d.ts +0 -2
- package/lib/esm/actionProcessor/core/system/index.js +0 -4
- package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +0 -2
- package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.js +0 -11
- package/lib/esm/actionProcessor/webserver/dns/index.d.ts +0 -2
- package/lib/esm/actionProcessor/webserver/dns/index.js +0 -4
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
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
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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(
|
|
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;
|
package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js
ADDED
|
@@ -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
|
|
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.
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
return (Object.assign({}, (yield (0,
|
|
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.
|
|
17
|
+
exports.getInlineFunctionActionProcessor = getInlineFunctionActionProcessor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
2
|
-
export declare const
|
|
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.
|
|
12
|
+
exports.getStreamCloseActionProcessor = void 0;
|
|
13
13
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
20
|
+
const getStreamCloseActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
21
|
return ({
|
|
24
|
-
[quidproquo_core_1.
|
|
22
|
+
[quidproquo_core_1.StreamActionType.Close]: getProcessStreamClose(qpqConfig),
|
|
25
23
|
});
|
|
26
24
|
});
|
|
27
|
-
exports.
|
|
25
|
+
exports.getStreamCloseActionProcessor = getStreamCloseActionProcessor;
|
|
@@ -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.
|
|
12
|
+
exports.getStreamReadActionProcessor = void 0;
|
|
13
13
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
-
const
|
|
15
|
-
return () => __awaiter(void 0,
|
|
16
|
-
|
|
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
|
|
20
|
+
const getStreamReadActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
21
|
return ({
|
|
21
|
-
[quidproquo_core_1.
|
|
22
|
+
[quidproquo_core_1.StreamActionType.Read]: getProcessStreamRead(qpqConfig),
|
|
22
23
|
});
|
|
23
24
|
});
|
|
24
|
-
exports.
|
|
25
|
+
exports.getStreamReadActionProcessor = getStreamReadActionProcessor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
2
|
-
export declare const
|
|
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.
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
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.
|
|
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
|
|
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,
|
|
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,
|
|
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(
|
|
65
|
+
errors.push({ filepath, error });
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
if (errors.length > 0 && deletedFiles.length === 0) {
|
|
71
|
-
|
|
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,
|
|
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 (
|
|
59
|
-
|
|
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) {
|
package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js
CHANGED
|
@@ -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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
};
|
package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
66
|
-
|
|
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,
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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,
|
|
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
|
-
|
|
59
|
-
|
|
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,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;
|
package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js
CHANGED
|
@@ -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,
|
|
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.
|
|
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
|
};
|