quidproquo-actionprocessor-web 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.
- package/README.md +112 -0
- package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +64 -0
- package/lib/commonjs/actionProcessor/core/claudeAi/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/claudeAi/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +30 -0
- package/lib/commonjs/actionProcessor/core/config/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/config/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.js +24 -0
- package/lib/commonjs/actionProcessor/core/context/getContextReadActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/context/getContextReadActionProcessor.js +27 -0
- package/lib/commonjs/actionProcessor/core/context/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/context/index.js +18 -0
- package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.js +58 -0
- package/lib/commonjs/actionProcessor/core/customActions/index.d.ts +1 -0
- package/lib/commonjs/actionProcessor/core/customActions/index.js +18 -0
- package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.js +24 -0
- package/lib/commonjs/actionProcessor/core/date/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/date/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +24 -0
- package/lib/commonjs/actionProcessor/core/error/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/error/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.js +25 -0
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +25 -0
- package/lib/commonjs/actionProcessor/core/guid/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/guid/index.js +18 -0
- package/lib/commonjs/actionProcessor/core/index.d.ts +14 -0
- package/lib/commonjs/actionProcessor/core/index.js +54 -0
- package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.js +30 -0
- package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +25 -0
- package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +26 -0
- package/lib/commonjs/actionProcessor/core/log/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/log/index.js +19 -0
- package/lib/commonjs/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/math/getMathRandomNumberActionProcessor.js +24 -0
- package/lib/commonjs/actionProcessor/core/math/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/math/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/network/getNetworkRequestActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/network/getNetworkRequestActionProcessor.js +150 -0
- package/lib/commonjs/actionProcessor/core/network/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/network/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +24 -0
- package/lib/commonjs/actionProcessor/core/platform/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/platform/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.js +51 -0
- package/lib/commonjs/actionProcessor/core/system/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/system/index.js +17 -0
- package/lib/commonjs/actionProcessor/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/index.js +18 -0
- package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.js +26 -0
- package/lib/commonjs/actionProcessor/webserver/dns/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/webserver/dns/index.js +17 -0
- package/lib/commonjs/actionProcessor/webserver/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/webserver/index.js +17 -0
- package/lib/commonjs/getWebActionProcessors.d.ts +2 -0
- package/lib/commonjs/getWebActionProcessors.js +18 -0
- package/lib/commonjs/insdex.d.ts +1 -0
- package/lib/commonjs/insdex.js +17 -0
- package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +26 -0
- package/lib/esm/actionProcessor/core/claudeAi/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/claudeAi/index.js +4 -0
- package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +15 -0
- package/lib/esm/actionProcessor/core/config/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/config/index.js +4 -0
- package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.js +9 -0
- package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.js +12 -0
- package/lib/esm/actionProcessor/core/context/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/context/index.js +6 -0
- package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.js +43 -0
- package/lib/esm/actionProcessor/core/customActions/index.d.ts +1 -0
- package/lib/esm/actionProcessor/core/customActions/index.js +2 -0
- package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.js +9 -0
- package/lib/esm/actionProcessor/core/date/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/date/index.js +4 -0
- package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +9 -0
- package/lib/esm/actionProcessor/core/error/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/error/index.js +4 -0
- package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.js +10 -0
- package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +10 -0
- package/lib/esm/actionProcessor/core/guid/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/guid/index.js +6 -0
- package/lib/esm/actionProcessor/core/index.d.ts +14 -0
- package/lib/esm/actionProcessor/core/index.js +37 -0
- package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.js +15 -0
- package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +10 -0
- package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +11 -0
- package/lib/esm/actionProcessor/core/log/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/log/index.js +8 -0
- package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.js +9 -0
- package/lib/esm/actionProcessor/core/math/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/math/index.js +4 -0
- package/lib/esm/actionProcessor/core/network/getNetworkRequestActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/network/getNetworkRequestActionProcessor.js +134 -0
- package/lib/esm/actionProcessor/core/network/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/network/index.js +4 -0
- package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +9 -0
- package/lib/esm/actionProcessor/core/platform/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/platform/index.js +4 -0
- package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.js +36 -0
- package/lib/esm/actionProcessor/core/system/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/system/index.js +4 -0
- package/lib/esm/actionProcessor/index.d.ts +2 -0
- package/lib/esm/actionProcessor/index.js +2 -0
- package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.js +11 -0
- package/lib/esm/actionProcessor/webserver/dns/index.d.ts +2 -0
- package/lib/esm/actionProcessor/webserver/dns/index.js +4 -0
- package/lib/esm/actionProcessor/webserver/index.d.ts +2 -0
- package/lib/esm/actionProcessor/webserver/index.js +4 -0
- package/lib/esm/getWebActionProcessors.d.ts +2 -0
- package/lib/esm/getWebActionProcessors.js +8 -0
- package/lib/esm/insdex.d.ts +1 -0
- package/lib/esm/insdex.js +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,17 @@
|
|
|
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.getWebserverActionProcessor = void 0;
|
|
13
|
+
const dns_1 = require("./dns");
|
|
14
|
+
const getWebserverActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, dns_1.getDnsActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
16
|
+
});
|
|
17
|
+
exports.getWebserverActionProcessor = getWebserverActionProcessor;
|
|
@@ -0,0 +1,18 @@
|
|
|
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.getWebActionProcessors = void 0;
|
|
13
|
+
const quidproquo_actionprocessor_js_1 = require("quidproquo-actionprocessor-js");
|
|
14
|
+
const actionProcessor_1 = require("./actionProcessor");
|
|
15
|
+
const getWebActionProcessors = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
return (Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, quidproquo_actionprocessor_js_1.getCoreActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, quidproquo_actionprocessor_js_1.getWebserverActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, actionProcessor_1.getCoreActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, actionProcessor_1.getWebserverActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
17
|
+
});
|
|
18
|
+
exports.getWebActionProcessors = getWebActionProcessors;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getWebActionProcessors';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getWebActionProcessors"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getClaudeAiMessagesApiActionProcessor } from './getClaudeAiMessagesApiActionProcessor';
|
|
2
|
+
export const getClaudeAiActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
+
...(await getClaudeAiMessagesApiActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
4
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getConfigGetApplicationInfoActionProcessor } from './getConfigGetApplicationInfoActionProcessor';
|
|
2
|
+
export const getConfigActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
+
...(await getConfigGetApplicationInfoActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
4
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getCustomActionActionProcessor';
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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';
|
|
14
|
+
export declare const getCoreActionProcessor: ActionProcessorListResolver;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getClaudeAiActionProcessor } from './claudeAi';
|
|
2
|
+
import { getConfigActionProcessor } from './config';
|
|
3
|
+
import { getContextActionProcessor } from './context';
|
|
4
|
+
import { getDateActionProcessor } from './date';
|
|
5
|
+
import { getErrorActionProcessor } from './error';
|
|
6
|
+
import { getGuidProcessor } from './guid';
|
|
7
|
+
import { getLogActionProcessor } from './log';
|
|
8
|
+
import { getMathActionProcessor } from './math';
|
|
9
|
+
import { getNetworkActionProcessor } from './network';
|
|
10
|
+
import { getPlatformActionProcessor } from './platform';
|
|
11
|
+
import { getSystemActionProcessor } from './system';
|
|
12
|
+
export * from './claudeAi';
|
|
13
|
+
export * from './config';
|
|
14
|
+
export * from './context';
|
|
15
|
+
export * from './date';
|
|
16
|
+
export * from './error';
|
|
17
|
+
export * from './guid';
|
|
18
|
+
export * from './log';
|
|
19
|
+
export * from './math';
|
|
20
|
+
export * from './network';
|
|
21
|
+
export * from './platform';
|
|
22
|
+
export * from './system';
|
|
23
|
+
// Custom actions is not done here, as it has to be done last after all
|
|
24
|
+
export * from './customActions';
|
|
25
|
+
export const getCoreActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
26
|
+
...(await getConfigActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
27
|
+
...(await getContextActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
28
|
+
...(await getClaudeAiActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
29
|
+
...(await getDateActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
30
|
+
...(await getErrorActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
31
|
+
...(await getGuidProcessor(qpqConfig, dynamicModuleLoader)),
|
|
32
|
+
...(await getLogActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
33
|
+
...(await getMathActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
34
|
+
...(await getNetworkActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
35
|
+
...(await getPlatformActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
36
|
+
...(await getSystemActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
37
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
});
|