quidproquo-actionprocessor-web 0.0.251 → 0.0.252
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/{log/getLogTemplateLiteralActionProcessor.d.ts → config/getConfigGetParameterActionProcessor.d.ts} +1 -1
- package/lib/commonjs/actionProcessor/core/config/getConfigGetParameterActionProcessor.js +30 -0
- package/lib/commonjs/actionProcessor/core/{claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts → config/getConfigGetParametersActionProcessor.d.ts} +1 -1
- package/lib/commonjs/actionProcessor/core/config/getConfigGetParametersActionProcessor.js +37 -0
- package/lib/{esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts → commonjs/actionProcessor/core/config/getConfigSetParameterActionProcessor.d.ts} +1 -1
- package/lib/commonjs/actionProcessor/core/{log/getLogTemplateLiteralActionProcessor.js → config/getConfigSetParameterActionProcessor.js} +13 -9
- package/lib/commonjs/actionProcessor/core/config/index.js +4 -2
- package/lib/commonjs/actionProcessor/core/index.d.ts +0 -12
- package/lib/commonjs/actionProcessor/core/index.js +1 -38
- package/lib/commonjs/{insdex.d.ts → index.d.ts} +1 -0
- package/lib/commonjs/{insdex.js → index.js} +1 -0
- package/lib/esm/actionProcessor/core/config/getConfigGetParameterActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/config/getConfigGetParameterActionProcessor.js +15 -0
- package/lib/esm/actionProcessor/core/{claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts → config/getConfigGetParametersActionProcessor.d.ts} +1 -1
- package/lib/esm/actionProcessor/core/config/getConfigGetParametersActionProcessor.js +22 -0
- package/lib/esm/actionProcessor/core/config/getConfigSetParameterActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/config/getConfigSetParameterActionProcessor.js +15 -0
- package/lib/esm/actionProcessor/core/config/index.js +6 -2
- package/lib/esm/actionProcessor/core/index.d.ts +0 -12
- package/lib/esm/actionProcessor/core/index.js +0 -33
- package/lib/esm/{insdex.d.ts → index.d.ts} +1 -0
- package/lib/esm/{insdex.js → index.js} +1 -0
- package/package.json +6 -6
- package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -64
- 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/context/getContextListActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.js +0 -24
- package/lib/commonjs/actionProcessor/core/context/getContextReadActionProcessor.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/context/getContextReadActionProcessor.js +0 -27
- 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/error/index.js +0 -17
- 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/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/getMathRandomNumberActionProcessor.js +0 -24
- 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.d.ts +0 -2
- 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/core/system/index.d.ts +0 -2
- package/lib/commonjs/actionProcessor/core/system/index.js +0 -17
- 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/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.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.d.ts +0 -2
- 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
|
@@ -1,17 +0,0 @@
|
|
|
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.getPlatformActionProcessor = void 0;
|
|
13
|
-
const getPlatformDelayActionProcessor_1 = require("./getPlatformDelayActionProcessor");
|
|
14
|
-
const getPlatformActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
return (Object.assign({}, (yield (0, getPlatformDelayActionProcessor_1.getPlatformDelayActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
16
|
-
});
|
|
17
|
-
exports.getPlatformActionProcessor = getPlatformActionProcessor;
|
|
@@ -1,51 +0,0 @@
|
|
|
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.getSystemBatchActionProcessor = void 0;
|
|
13
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
-
const getProcessSystemBatch = (qpqConfig) => {
|
|
15
|
-
return (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
// console.log('~~~~~~~~~~~ RUNNING BATCH ~~~~~~~~~: ', payload);
|
|
17
|
-
const batchRes = yield Promise.all(payload.actions.map((a) => (0, quidproquo_core_1.processAction)(a, actionProcessors, session, logger, updateSession, dynamicModuleLoader)));
|
|
18
|
-
// console.log('~~~~~~~~~~~ RESULT BATCH ~~~~~~~~~: ', batchRes);
|
|
19
|
-
// If there was an error, that does not want to be returned, throw that error back
|
|
20
|
-
const erroredBatchItem = batchRes.find((br, i) => (0, quidproquo_core_1.isErroredActionResult)(br) && !payload.actions[i].returnErrors);
|
|
21
|
-
if (erroredBatchItem) {
|
|
22
|
-
const error = (0, quidproquo_core_1.resolveActionResultError)(erroredBatchItem);
|
|
23
|
-
return (0, quidproquo_core_1.actionResultError)(error.errorType, error.errorText, error.errorStack);
|
|
24
|
-
}
|
|
25
|
-
// unwrap the values
|
|
26
|
-
return (0, quidproquo_core_1.actionResult)(batchRes.map((br, i) => {
|
|
27
|
-
// If we want to return errors, return the either result.
|
|
28
|
-
if (payload.actions[i].returnErrors) {
|
|
29
|
-
const isSuccess = !(0, quidproquo_core_1.isErroredActionResult)(br);
|
|
30
|
-
const result = isSuccess
|
|
31
|
-
? {
|
|
32
|
-
success: true,
|
|
33
|
-
result: (0, quidproquo_core_1.resolveActionResult)(br),
|
|
34
|
-
}
|
|
35
|
-
: {
|
|
36
|
-
success: false,
|
|
37
|
-
error: (0, quidproquo_core_1.resolveActionResultError)(br),
|
|
38
|
-
};
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
// return the resolved result
|
|
42
|
-
return (0, quidproquo_core_1.resolveActionResult)(br);
|
|
43
|
-
}));
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const getSystemBatchActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
return ({
|
|
48
|
-
[quidproquo_core_1.SystemActionType.Batch]: getProcessSystemBatch(qpqConfig),
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
exports.getSystemBatchActionProcessor = getSystemBatchActionProcessor;
|
|
@@ -1,17 +0,0 @@
|
|
|
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.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))));
|
|
16
|
-
});
|
|
17
|
-
exports.getSystemActionProcessor = getSystemActionProcessor;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { actionResult, actionResultError, ClaudeAiActionType, ErrorTypeEnum, } from 'quidproquo-core';
|
|
2
|
-
import Anthropic, { AuthenticationError } from '@anthropic-ai/sdk';
|
|
3
|
-
const getProcessMessagesApi = (qpqConfig) => {
|
|
4
|
-
return async ({ body, apiKey }) => {
|
|
5
|
-
const anthropic = new Anthropic({ apiKey });
|
|
6
|
-
try {
|
|
7
|
-
const msg = await anthropic.messages.create(body);
|
|
8
|
-
return actionResult(msg);
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
console.log(error);
|
|
12
|
-
if (error instanceof AuthenticationError) {
|
|
13
|
-
return actionResultError(ErrorTypeEnum.Unauthorized, 'Invalid API key.');
|
|
14
|
-
}
|
|
15
|
-
else if (error instanceof Error) {
|
|
16
|
-
return actionResultError(ErrorTypeEnum.GenericError, error.message);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return actionResultError(ErrorTypeEnum.GenericError, 'An error occurred while processing your request.');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export const getClaudeAiMessagesApiActionProcessor = async (qpqConfig) => ({
|
|
25
|
-
[ClaudeAiActionType.MessagesApi]: getProcessMessagesApi(qpqConfig),
|
|
26
|
-
});
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { getClaudeAiMessagesApiActionProcessor } from './getClaudeAiMessagesApiActionProcessor';
|
|
2
|
-
export const getClaudeAiActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
-
...(await getClaudeAiMessagesApiActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
4
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { actionResult, ConfigActionType, qpqCoreUtils, } from 'quidproquo-core';
|
|
2
|
-
const getProcessConfigGetApplicationConfig = (qpqConfig) => {
|
|
3
|
-
return async () => {
|
|
4
|
-
const appInfo = {
|
|
5
|
-
environment: qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
|
|
6
|
-
feature: qpqCoreUtils.getApplicationModuleFeature(qpqConfig),
|
|
7
|
-
module: qpqCoreUtils.getApplicationModuleName(qpqConfig),
|
|
8
|
-
name: qpqCoreUtils.getApplicationName(qpqConfig),
|
|
9
|
-
};
|
|
10
|
-
return actionResult(appInfo);
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const getConfigGetApplicationInfoActionProcessor = async (qpqConfig) => ({
|
|
14
|
-
[ConfigActionType.GetApplicationInfo]: getProcessConfigGetApplicationConfig(qpqConfig),
|
|
15
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { actionResult, ContextActionType, } from 'quidproquo-core';
|
|
2
|
-
const getProcessContextList = (qpqConfig) => {
|
|
3
|
-
return async (payload, session) => {
|
|
4
|
-
return actionResult(session.context);
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export const getContextListActionProcessor = async (qpqConfig) => ({
|
|
8
|
-
[ContextActionType.List]: getProcessContextList(qpqConfig),
|
|
9
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { actionResult, ContextActionType, } from 'quidproquo-core';
|
|
2
|
-
const getContextValue = (context, contextIdentifier) => {
|
|
3
|
-
return contextIdentifier.uniqueName in context ? context[contextIdentifier.uniqueName] : contextIdentifier.defaultValue;
|
|
4
|
-
};
|
|
5
|
-
const getProcessContextRead = (qpqConfig) => {
|
|
6
|
-
return async ({ contextIdentifier }, session) => {
|
|
7
|
-
return actionResult(getContextValue(session.context, contextIdentifier));
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export const getContextReadActionProcessor = async (qpqConfig) => ({
|
|
11
|
-
[ContextActionType.Read]: getProcessContextRead(qpqConfig),
|
|
12
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { getContextListActionProcessor } from './getContextListActionProcessor';
|
|
2
|
-
import { getContextReadActionProcessor } from './getContextReadActionProcessor';
|
|
3
|
-
export const getContextActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
4
|
-
...(await getContextListActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
5
|
-
...(await getContextReadActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
6
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|
|
24
|
-
const getProcessCustomAction = async (qpqConfig, dynamicModuleLoader) => {
|
|
25
|
-
try {
|
|
26
|
-
const actionProcessorListLoader = getActionProcessorListLoader(dynamicModuleLoader, qpqConfig);
|
|
27
|
-
const getCustomActionProcessors = qpqCoreUtils.getActionProcessorSources(qpqConfig);
|
|
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 }), {});
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
// This should never get hit, but just in case
|
|
37
|
-
console.log(`Unable to dynamically load action processors: [${e}]`);
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export const getCustomActionActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
42
|
-
...(await getProcessCustomAction(qpqConfig, dynamicModuleLoader)),
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './getCustomActionActionProcessor';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { actionResult, DateActionType } from 'quidproquo-core';
|
|
2
|
-
const getProcessDateNow = (qpqConfig) => {
|
|
3
|
-
return async () => {
|
|
4
|
-
return actionResult(new Date().toISOString());
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export const getDateNowActionProcessor = async (qpqConfig) => ({
|
|
8
|
-
[DateActionType.Now]: getProcessDateNow(qpqConfig),
|
|
9
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { actionResultError, ErrorActionType, } from 'quidproquo-core';
|
|
2
|
-
const getProcessErrorThrowError = (qpqConfig) => {
|
|
3
|
-
return async ({ errorStack, errorText, errorType }) => {
|
|
4
|
-
return actionResultError(errorType, errorText, errorStack);
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export const getErrorThrowErrorActionProcessor = async (qpqConfig) => ({
|
|
8
|
-
[ErrorActionType.ThrowError]: getProcessErrorThrowError(qpqConfig),
|
|
9
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { actionResult, GuidActionType } from 'quidproquo-core';
|
|
2
|
-
import { v4 as uuidV4 } from 'uuid';
|
|
3
|
-
const getProcessGuidNew = (qpqConfig) => {
|
|
4
|
-
return async () => {
|
|
5
|
-
return actionResult(uuidV4());
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export const getGuidNewActionProcessor = async (qpqConfig) => ({
|
|
9
|
-
[GuidActionType.New]: getProcessGuidNew(qpqConfig),
|
|
10
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { actionResult, GuidActionType, } from 'quidproquo-core';
|
|
2
|
-
import { uuidv7 } from 'uuidv7';
|
|
3
|
-
const getProcessGuidNewSortable = (qpqConfig) => {
|
|
4
|
-
return async () => {
|
|
5
|
-
return actionResult(uuidv7());
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export const getGuidNewSortableActionProcessor = async (qpqConfig) => ({
|
|
9
|
-
[GuidActionType.NewSortable]: getProcessGuidNewSortable(qpqConfig),
|
|
10
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { getGuidNewActionProcessor } from './getGuidNewActionProcessor';
|
|
2
|
-
import { getGuidNewSortableActionProcessor } from './getGuidNewSortableActionProcessor';
|
|
3
|
-
export const getGuidProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
4
|
-
...(await getGuidNewActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
5
|
-
...(await getGuidNewSortableActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
6
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { actionResult, LogActionType } from 'quidproquo-core';
|
|
2
|
-
const getProcessLogCreate = (qpqConfig) => {
|
|
3
|
-
return async ({ msg, logLevel, data }) => {
|
|
4
|
-
if (data) {
|
|
5
|
-
console.log(`${logLevel}: ${msg}`, data);
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
console.log(`${logLevel}: ${msg}`);
|
|
9
|
-
}
|
|
10
|
-
return actionResult(void 0);
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const getLogCreateActionProcessor = async (qpqConfig) => ({
|
|
14
|
-
[LogActionType.Create]: getProcessLogCreate(qpqConfig),
|
|
15
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { actionResult, LogActionType, } from 'quidproquo-core';
|
|
2
|
-
const getProcessLogDisableEventHistory = (qpqConfig) => {
|
|
3
|
-
return async ({ enable, reason }, session, _actionProcessors, logger) => {
|
|
4
|
-
await logger.enableLogs(enable, reason, session.correlation || '');
|
|
5
|
-
return actionResult(void 0);
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export const getLogDisableEventHistoryActionProcessor = async (qpqConfig) => ({
|
|
9
|
-
[LogActionType.DisableEventHistory]: getProcessLogDisableEventHistory(qpqConfig),
|
|
10
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { actionResult, decomposedStringToString, LogActionType, } from 'quidproquo-core';
|
|
2
|
-
const getProcessLogTemplateLiteral = (qpqConfig) => {
|
|
3
|
-
return async ({ messageParts }) => {
|
|
4
|
-
const message = decomposedStringToString(messageParts);
|
|
5
|
-
console.log(message);
|
|
6
|
-
return actionResult(void 0);
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export const getLogTemplateLiteralActionProcessor = async (qpqConfig) => ({
|
|
10
|
-
[LogActionType.TemplateLiteral]: getProcessLogTemplateLiteral(qpqConfig),
|
|
11
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { getLogCreateActionProcessor } from './getLogCreateActionProcessor';
|
|
2
|
-
import { getLogDisableEventHistoryActionProcessor } from './getLogDisableEventHistoryActionProcessor';
|
|
3
|
-
import { getLogTemplateLiteralActionProcessor } from './getLogTemplateLiteralActionProcessor';
|
|
4
|
-
export const getLogActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
5
|
-
...(await getLogCreateActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
6
|
-
...(await getLogDisableEventHistoryActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
7
|
-
...(await getLogTemplateLiteralActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
8
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { actionResult, MathActionType, } from 'quidproquo-core';
|
|
2
|
-
const getProcessMathRandomNumber = (qpqConfig) => {
|
|
3
|
-
return async () => {
|
|
4
|
-
return actionResult(Math.random());
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export const getMathRandomNumberActionProcessor = async (qpqConfig) => ({
|
|
8
|
-
[MathActionType.RandomNumber]: getProcessMathRandomNumber(qpqConfig),
|
|
9
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { actionResult, actionResultError, ErrorTypeEnum, NetworkActionType, } from 'quidproquo-core';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { extension } from 'mime-types';
|
|
4
|
-
const getAxiosResponseType = (responseType) => {
|
|
5
|
-
if (responseType === 'binary') {
|
|
6
|
-
return 'arraybuffer';
|
|
7
|
-
}
|
|
8
|
-
return 'json';
|
|
9
|
-
};
|
|
10
|
-
const transformResponse = (payload, response) => {
|
|
11
|
-
if (payload.responseType === 'binary') {
|
|
12
|
-
const headers = response.headers || {};
|
|
13
|
-
const mimeType = headers['content-type'] || 'application/octet-stream';
|
|
14
|
-
const filename = headers['content-disposition']?.match(/filename="([^"]+)"/)?.[1] || `file.${extension(mimeType)}`;
|
|
15
|
-
return {
|
|
16
|
-
...response,
|
|
17
|
-
data: {
|
|
18
|
-
base64Data: Buffer.from(response.data).toString('base64'),
|
|
19
|
-
mimetype: mimeType,
|
|
20
|
-
filename,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return response;
|
|
25
|
-
};
|
|
26
|
-
const axiosInstance = axios.create({
|
|
27
|
-
timeout: 25000,
|
|
28
|
-
headers: {
|
|
29
|
-
// Fixes: https://github.com/axios/axios/issues/5346
|
|
30
|
-
'Accept-Encoding': 'gzip,deflate,compress',
|
|
31
|
-
},
|
|
32
|
-
validateStatus: () => true,
|
|
33
|
-
});
|
|
34
|
-
const processNetworkRequestGet = async (payload) => {
|
|
35
|
-
const response = await axiosInstance.get(payload.url, {
|
|
36
|
-
baseURL: payload.basePath,
|
|
37
|
-
headers: payload.headers,
|
|
38
|
-
params: payload.params,
|
|
39
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
40
|
-
});
|
|
41
|
-
return transformResponse(payload, response);
|
|
42
|
-
};
|
|
43
|
-
const processNetworkRequestPost = async (payload) => {
|
|
44
|
-
const response = await axiosInstance.post(payload.url, payload.body, {
|
|
45
|
-
baseURL: payload.basePath,
|
|
46
|
-
headers: payload.headers,
|
|
47
|
-
params: payload.params,
|
|
48
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
49
|
-
});
|
|
50
|
-
return transformResponse(payload, response);
|
|
51
|
-
};
|
|
52
|
-
const processNetworkRequestDelete = async (payload) => {
|
|
53
|
-
const response = await axiosInstance.delete(payload.url, {
|
|
54
|
-
baseURL: payload.basePath,
|
|
55
|
-
headers: payload.headers,
|
|
56
|
-
params: payload.params,
|
|
57
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
58
|
-
});
|
|
59
|
-
return transformResponse(payload, response);
|
|
60
|
-
};
|
|
61
|
-
const processNetworkRequestHead = async (payload) => {
|
|
62
|
-
const response = await axiosInstance.head(payload.url, {
|
|
63
|
-
baseURL: payload.basePath,
|
|
64
|
-
headers: payload.headers,
|
|
65
|
-
params: payload.params,
|
|
66
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
67
|
-
});
|
|
68
|
-
return transformResponse(payload, response);
|
|
69
|
-
};
|
|
70
|
-
const processNetworkRequestOptions = async (payload) => {
|
|
71
|
-
const response = await axiosInstance.options(payload.url, {
|
|
72
|
-
baseURL: payload.basePath,
|
|
73
|
-
headers: payload.headers,
|
|
74
|
-
params: payload.params,
|
|
75
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
76
|
-
});
|
|
77
|
-
return transformResponse(payload, response);
|
|
78
|
-
};
|
|
79
|
-
const processNetworkRequestPut = async (payload) => {
|
|
80
|
-
const response = await axiosInstance.put(payload.url, payload.body, {
|
|
81
|
-
baseURL: payload.basePath,
|
|
82
|
-
headers: payload.headers,
|
|
83
|
-
params: payload.params,
|
|
84
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
85
|
-
});
|
|
86
|
-
return transformResponse(payload, response);
|
|
87
|
-
};
|
|
88
|
-
const processNetworkRequestPatch = async (payload) => {
|
|
89
|
-
const response = await axiosInstance.patch(payload.url, payload.body, {
|
|
90
|
-
baseURL: payload.basePath,
|
|
91
|
-
headers: payload.headers,
|
|
92
|
-
params: payload.params,
|
|
93
|
-
responseType: getAxiosResponseType(payload.responseType),
|
|
94
|
-
});
|
|
95
|
-
return transformResponse(payload, response);
|
|
96
|
-
};
|
|
97
|
-
const processNetworkRequestConnect = async (payload) => {
|
|
98
|
-
throw new Error('Function not implemented.');
|
|
99
|
-
};
|
|
100
|
-
const requestMethodMap = {
|
|
101
|
-
GET: processNetworkRequestGet,
|
|
102
|
-
POST: processNetworkRequestPost,
|
|
103
|
-
DELETE: processNetworkRequestDelete,
|
|
104
|
-
HEAD: processNetworkRequestHead,
|
|
105
|
-
OPTIONS: processNetworkRequestOptions,
|
|
106
|
-
PUT: processNetworkRequestPut,
|
|
107
|
-
PATCH: processNetworkRequestPatch,
|
|
108
|
-
CONNECT: processNetworkRequestConnect,
|
|
109
|
-
};
|
|
110
|
-
const getProcessNetworkRequest = (qpqConfig) => {
|
|
111
|
-
return async (payload) => {
|
|
112
|
-
const requestMethod = requestMethodMap[payload.method];
|
|
113
|
-
if (!requestMethod) {
|
|
114
|
-
return actionResultError(ErrorTypeEnum.NotImplemented, `${payload.method}: Not implemented`);
|
|
115
|
-
}
|
|
116
|
-
console.log(payload.url);
|
|
117
|
-
try {
|
|
118
|
-
const response = await requestMethod(payload);
|
|
119
|
-
return actionResult({
|
|
120
|
-
headers: response.headers,
|
|
121
|
-
status: response.status,
|
|
122
|
-
statusText: response.statusText,
|
|
123
|
-
data: response.data,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
console.log(err);
|
|
128
|
-
return actionResultError(ErrorTypeEnum.GenericError, err.stack);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
export const getNetworkRequestActionProcessor = async (qpqConfig) => ({
|
|
133
|
-
[NetworkActionType.Request]: getProcessNetworkRequest(qpqConfig),
|
|
134
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { actionResult, PlatformActionType, } from 'quidproquo-core';
|
|
2
|
-
const getProcessPlatformDelay = (qpqConfig) => {
|
|
3
|
-
return async ({ timeMs }) => {
|
|
4
|
-
return new Promise((resolve) => setTimeout(() => resolve(actionResult(undefined)), timeMs));
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export const getPlatformDelayActionProcessor = async (qpqConfig) => ({
|
|
8
|
-
[PlatformActionType.Delay]: getProcessPlatformDelay(qpqConfig),
|
|
9
|
-
});
|