quidproquo-actionprocessor-node 0.0.249 → 0.0.251
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.
|
@@ -11,17 +11,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getCustomActionActionProcessor = void 0;
|
|
13
13
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
function getActionProcessorListLoader(dynamicModuleLoader, qpqConfig) {
|
|
15
|
+
return function loadModule(qpqFunctionRuntime) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
try {
|
|
18
|
+
const possibleModule = yield dynamicModuleLoader(qpqFunctionRuntime);
|
|
19
|
+
if (typeof possibleModule !== 'function') {
|
|
20
|
+
throw new Error(`Expected module to be a function, but got ${typeof possibleModule}`);
|
|
21
|
+
}
|
|
22
|
+
const apl = yield possibleModule(qpqConfig, dynamicModuleLoader);
|
|
23
|
+
if (typeof apl !== 'object') {
|
|
24
|
+
throw new Error(`Expected action processor list to be an object, but got ${typeof apl}`);
|
|
25
|
+
}
|
|
26
|
+
if (Object.values(apl).find((aplv) => typeof aplv !== 'function')) {
|
|
27
|
+
throw new Error('Expected all action processors to be functions');
|
|
28
|
+
}
|
|
29
|
+
return apl;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
console.log(`Unable to dynamically load action processors: [${e}] ${JSON.stringify(qpqFunctionRuntime)}`);
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
14
38
|
const getProcessCustomAction = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
39
|
try {
|
|
40
|
+
const actionProcessorListLoader = getActionProcessorListLoader(dynamicModuleLoader, qpqConfig);
|
|
16
41
|
const getCustomActionProcessors = quidproquo_core_1.qpqCoreUtils.getActionProcessorSources(qpqConfig);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
const possibleModuleResults = yield Promise.allSettled(getCustomActionProcessors.map(actionProcessorListLoader));
|
|
43
|
+
// Filter out successfully loaded modules that are functions
|
|
44
|
+
const actionProcessorLists = possibleModuleResults
|
|
45
|
+
.filter((result) => result.status === 'fulfilled')
|
|
46
|
+
.map((result) => result.value);
|
|
47
|
+
return actionProcessorLists.reduce((acc, cur) => (Object.assign(Object.assign({}, acc), cur)), {});
|
|
22
48
|
}
|
|
23
|
-
catch (
|
|
24
|
-
|
|
49
|
+
catch (e) {
|
|
50
|
+
// This should never get hit, but just in case
|
|
51
|
+
console.log(`Unable to dynamically load action processors: [${e}]`);
|
|
25
52
|
return {};
|
|
26
53
|
}
|
|
27
54
|
});
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { qpqCoreUtils } from 'quidproquo-core';
|
|
2
|
+
function getActionProcessorListLoader(dynamicModuleLoader, qpqConfig) {
|
|
3
|
+
return async function loadModule(qpqFunctionRuntime) {
|
|
4
|
+
try {
|
|
5
|
+
const possibleModule = await dynamicModuleLoader(qpqFunctionRuntime);
|
|
6
|
+
if (typeof possibleModule !== 'function') {
|
|
7
|
+
throw new Error(`Expected module to be a function, but got ${typeof possibleModule}`);
|
|
8
|
+
}
|
|
9
|
+
const apl = await possibleModule(qpqConfig, dynamicModuleLoader);
|
|
10
|
+
if (typeof apl !== 'object') {
|
|
11
|
+
throw new Error(`Expected action processor list to be an object, but got ${typeof apl}`);
|
|
12
|
+
}
|
|
13
|
+
if (Object.values(apl).find((aplv) => typeof aplv !== 'function')) {
|
|
14
|
+
throw new Error('Expected all action processors to be functions');
|
|
15
|
+
}
|
|
16
|
+
return apl;
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.log(`Unable to dynamically load action processors: [${e}] ${JSON.stringify(qpqFunctionRuntime)}`);
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
2
24
|
const getProcessCustomAction = async (qpqConfig, dynamicModuleLoader) => {
|
|
3
25
|
try {
|
|
26
|
+
const actionProcessorListLoader = getActionProcessorListLoader(dynamicModuleLoader, qpqConfig);
|
|
4
27
|
const getCustomActionProcessors = qpqCoreUtils.getActionProcessorSources(qpqConfig);
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
28
|
+
const possibleModuleResults = await Promise.allSettled(getCustomActionProcessors.map(actionProcessorListLoader));
|
|
29
|
+
// Filter out successfully loaded modules that are functions
|
|
30
|
+
const actionProcessorLists = possibleModuleResults
|
|
31
|
+
.filter((result) => result.status === 'fulfilled')
|
|
32
|
+
.map((result) => result.value);
|
|
33
|
+
return actionProcessorLists.reduce((acc, cur) => ({ ...acc, ...cur }), {});
|
|
10
34
|
}
|
|
11
|
-
catch {
|
|
12
|
-
|
|
35
|
+
catch (e) {
|
|
36
|
+
// This should never get hit, but just in case
|
|
37
|
+
console.log(`Unable to dynamically load action processors: [${e}]`);
|
|
13
38
|
return {};
|
|
14
39
|
}
|
|
15
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.251",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"@anthropic-ai/sdk": "^0.19.1",
|
|
36
36
|
"axios": "^1.2.1",
|
|
37
37
|
"mime-types": "^2.1.35",
|
|
38
|
-
"quidproquo-core": "0.0.
|
|
39
|
-
"quidproquo-webserver": "0.0.
|
|
38
|
+
"quidproquo-core": "0.0.251",
|
|
39
|
+
"quidproquo-webserver": "0.0.251",
|
|
40
40
|
"uuid": "^9.0.0",
|
|
41
41
|
"uuidv7": "^1.0.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/mime-types": "^2.1.1",
|
|
45
45
|
"@types/uuid": "^9.0.0",
|
|
46
|
-
"quidproquo-tsconfig": "0.0.
|
|
46
|
+
"quidproquo-tsconfig": "0.0.251",
|
|
47
47
|
"typescript": "^4.9.3"
|
|
48
48
|
}
|
|
49
49
|
}
|