quidproquo-core 0.0.91 → 0.0.92
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/actions/keyValueStore/KeyValueStoreGetAllActionRequester.d.ts +1 -1
- package/lib/actions/keyValueStore/KeyValueStoreGetAllActionRequester.js +1 -2
- package/lib/actions/keyValueStore/KeyValueStoreGetAllActionTypes.d.ts +0 -1
- package/lib/config/QPQConfig.d.ts +5 -2
- package/lib/config/QPQConfig.js +1 -0
- package/lib/config/settings/configValue.d.ts +6 -0
- package/lib/config/settings/configValue.js +11 -0
- package/lib/config/settings/index.d.ts +1 -0
- package/lib/config/settings/index.js +1 -0
- package/lib/config/settings/queue.d.ts +2 -0
- package/lib/config/settings/queue.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/qpqCoreUtils.d.ts +32 -2
- package/lib/qpqCoreUtils.js +56 -5
- package/lib/qpqExecuteLog.d.ts +2 -0
- package/lib/qpqExecuteLog.js +30 -0
- package/lib/qpqRuntime.d.ts +3 -2
- package/lib/qpqRuntime.js +18 -8
- package/lib/types/Action.d.ts +2 -2
- package/lib/types/StorySession.d.ts +20 -0
- package/lib/types/StorySession.js +10 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { KeyValueStoreGetAllActionRequester, KeyValueStoreGetAllOptions } from './KeyValueStoreGetAllActionTypes';
|
|
2
|
-
export declare function askKeyValueStoreGetAll<Value>(keyValueStoreName: string,
|
|
2
|
+
export declare function askKeyValueStoreGetAll<Value>(keyValueStoreName: string, options?: KeyValueStoreGetAllOptions): KeyValueStoreGetAllActionRequester<Value>;
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.askKeyValueStoreGetAll = void 0;
|
|
4
4
|
const KeyValueStoreActionType_1 = require("./KeyValueStoreActionType");
|
|
5
|
-
function* askKeyValueStoreGetAll(keyValueStoreName,
|
|
5
|
+
function* askKeyValueStoreGetAll(keyValueStoreName, options) {
|
|
6
6
|
return yield {
|
|
7
7
|
type: KeyValueStoreActionType_1.KeyValueStoreActionType.GetAll,
|
|
8
8
|
payload: {
|
|
9
9
|
keyValueStoreName,
|
|
10
|
-
key,
|
|
11
10
|
options,
|
|
12
11
|
},
|
|
13
12
|
};
|
|
@@ -4,7 +4,6 @@ export interface KeyValueStoreGetAllOptions {
|
|
|
4
4
|
}
|
|
5
5
|
export interface KeyValueStoreGetAllActionPayload {
|
|
6
6
|
keyValueStoreName: string;
|
|
7
|
-
key: string;
|
|
8
7
|
options?: KeyValueStoreGetAllOptions;
|
|
9
8
|
}
|
|
10
9
|
export interface KeyValueStoreGetAllAction<Value> extends Action<KeyValueStoreGetAllActionPayload> {
|
|
@@ -9,7 +9,8 @@ export declare enum QPQCoreConfigSettingType {
|
|
|
9
9
|
queue = "@quidproquo-core/config/Queue",
|
|
10
10
|
eventBus = "@quidproquo-core/config/EventBus",
|
|
11
11
|
userDirectory = "@quidproquo-core/config/UserDirectory",
|
|
12
|
-
keyValueStore = "@quidproquo-core/config/KeyValueStore"
|
|
12
|
+
keyValueStore = "@quidproquo-core/config/KeyValueStore",
|
|
13
|
+
configValue = "@quidproquo-core/config/ConfigValue"
|
|
13
14
|
}
|
|
14
15
|
export interface QPQConfigSetting {
|
|
15
16
|
configSettingType: string;
|
|
@@ -18,4 +19,6 @@ export interface QPQConfigSetting {
|
|
|
18
19
|
export interface QPQConfigAdvancedSettings {
|
|
19
20
|
deprecated?: boolean;
|
|
20
21
|
}
|
|
21
|
-
export type
|
|
22
|
+
export type QPQConfigSettings = QPQConfigSetting[];
|
|
23
|
+
export type QPQConfigItem = QPQConfigSetting | QPQConfigSettings;
|
|
24
|
+
export type QPQConfig = QPQConfigItem[];
|
package/lib/config/QPQConfig.js
CHANGED
|
@@ -14,4 +14,5 @@ var QPQCoreConfigSettingType;
|
|
|
14
14
|
QPQCoreConfigSettingType["eventBus"] = "@quidproquo-core/config/EventBus";
|
|
15
15
|
QPQCoreConfigSettingType["userDirectory"] = "@quidproquo-core/config/UserDirectory";
|
|
16
16
|
QPQCoreConfigSettingType["keyValueStore"] = "@quidproquo-core/config/KeyValueStore";
|
|
17
|
+
QPQCoreConfigSettingType["configValue"] = "@quidproquo-core/config/ConfigValue";
|
|
17
18
|
})(QPQCoreConfigSettingType = exports.QPQCoreConfigSettingType || (exports.QPQCoreConfigSettingType = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { QPQConfigSetting } from '../QPQConfig';
|
|
2
|
+
export interface ConfigValueQPQConfigSetting<T> extends QPQConfigSetting {
|
|
3
|
+
configValueName: string;
|
|
4
|
+
configValue: T;
|
|
5
|
+
}
|
|
6
|
+
export declare const defineConfigValue: <T>(configValueName: string, configValue: T) => ConfigValueQPQConfigSetting<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineConfigValue = void 0;
|
|
4
|
+
const QPQConfig_1 = require("../QPQConfig");
|
|
5
|
+
const defineConfigValue = (configValueName, configValue) => ({
|
|
6
|
+
configSettingType: QPQConfig_1.QPQCoreConfigSettingType.configValue,
|
|
7
|
+
uniqueKey: configValueName,
|
|
8
|
+
configValueName,
|
|
9
|
+
configValue,
|
|
10
|
+
});
|
|
11
|
+
exports.defineConfigValue = defineConfigValue;
|
|
@@ -2,6 +2,7 @@ export * from './emailTemplates';
|
|
|
2
2
|
export * from './actionProcessors';
|
|
3
3
|
export * from './applicationModule';
|
|
4
4
|
export * from './buildPath';
|
|
5
|
+
export * from './configValue';
|
|
5
6
|
export * from './eventBus';
|
|
6
7
|
export * from './keyValueStore';
|
|
7
8
|
export * from './parameter';
|
|
@@ -18,6 +18,7 @@ __exportStar(require("./emailTemplates"), exports);
|
|
|
18
18
|
__exportStar(require("./actionProcessors"), exports);
|
|
19
19
|
__exportStar(require("./applicationModule"), exports);
|
|
20
20
|
__exportStar(require("./buildPath"), exports);
|
|
21
|
+
__exportStar(require("./configValue"), exports);
|
|
21
22
|
__exportStar(require("./eventBus"), exports);
|
|
22
23
|
__exportStar(require("./keyValueStore"), exports);
|
|
23
24
|
__exportStar(require("./parameter"), exports);
|
|
@@ -14,6 +14,7 @@ export interface QPQConfigAdvancedQueueSettings extends QPQConfigAdvancedSetting
|
|
|
14
14
|
ttRetryInSeconds?: number;
|
|
15
15
|
hasDeadLetterQueue?: boolean;
|
|
16
16
|
eventBusSubscriptions?: string[];
|
|
17
|
+
maxConcurrentExecutions?: number;
|
|
17
18
|
}
|
|
18
19
|
export interface QueueQPQConfigSetting extends QPQConfigSetting {
|
|
19
20
|
name: string;
|
|
@@ -26,5 +27,6 @@ export interface QueueQPQConfigSetting extends QPQConfigSetting {
|
|
|
26
27
|
hasDeadLetterQueue: boolean;
|
|
27
28
|
qpqQueueProcessors: QpqQueueProcessors;
|
|
28
29
|
eventBusSubscriptions: string[];
|
|
30
|
+
maxConcurrentExecutions?: number;
|
|
29
31
|
}
|
|
30
32
|
export declare const defineQueue: (name: string, buildPath: string, processors: QpqQueueProcessors, options?: QPQConfigAdvancedQueueSettings) => QueueQPQConfigSetting;
|
|
@@ -15,5 +15,6 @@ const defineQueue = (name, buildPath, processors, options) => ({
|
|
|
15
15
|
hasDeadLetterQueue: (options === null || options === void 0 ? void 0 : options.hasDeadLetterQueue) || true,
|
|
16
16
|
qpqQueueProcessors: processors,
|
|
17
17
|
eventBusSubscriptions: (options === null || options === void 0 ? void 0 : options.eventBusSubscriptions) || [],
|
|
18
|
+
maxConcurrentExecutions: options === null || options === void 0 ? void 0 : options.maxConcurrentExecutions,
|
|
18
19
|
});
|
|
19
20
|
exports.defineQueue = defineQueue;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/qpqCoreUtils.d.ts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { QPQConfig, QPQConfigSetting } from './config/QPQConfig';
|
|
2
2
|
import { ApplicationModuleQPQConfigSetting, StorageDriveQPQConfigSetting, EventBusQPQConfigSetting, ScheduleQPQConfigSetting, SecretQPQConfigSetting, ParameterQPQConfigSetting, QueueQPQConfigSetting, QpqQueueProcessors, UserDirectoryQPQConfigSetting, KeyValueStoreQPQConfigSetting } from './config/settings';
|
|
3
3
|
import { EmailTemplates } from './config/settings/emailTemplates/types';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Flattens a QPQConfig array into a single array of QPQConfigSetting objects.
|
|
6
|
+
* @function
|
|
7
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array to be flattened.
|
|
8
|
+
* @returns {QPQConfigSetting[]} - The flattened array of QPQConfigSetting objects.
|
|
9
|
+
*/
|
|
10
|
+
export declare const flattenQpqConfig: (qpqConfig: QPQConfig) => QPQConfigSetting[];
|
|
11
|
+
/**
|
|
12
|
+
* Filters and returns the config settings of a specific type from a QPQConfig array.
|
|
13
|
+
* @function
|
|
14
|
+
* @template T - The specific type of QPQConfigSetting to filter.
|
|
15
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array.
|
|
16
|
+
* @param {string} configSettingType - The specific config setting type to filter.
|
|
17
|
+
* @returns {T[]} - An array of filtered config settings of the specified type.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getConfigSettings: <T extends QPQConfigSetting>(qpqConfig: QPQConfig, configSettingType: string) => T[];
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves a single config setting of a specific type from a QPQConfig array.
|
|
22
|
+
* @function
|
|
23
|
+
* @template T - The specific type of QPQConfigSetting to retrieve.
|
|
24
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array.
|
|
25
|
+
* @param {string} serviceInfrastructureConfigType - The specific config setting type to retrieve.
|
|
26
|
+
* @returns {T | undefined} - The found config setting of the specified type or undefined if not found.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getConfigSetting: <T extends QPQConfigSetting>(qpqConfig: QPQConfig, serviceInfrastructureConfigType: string) => T | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the ApplicationModuleSetting from a QPQConfig array.
|
|
31
|
+
* @function
|
|
32
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array.
|
|
33
|
+
* @returns {ApplicationModuleQPQConfigSetting} - The ApplicationModuleQPQConfigSetting from the QPQConfig array.
|
|
34
|
+
* @throws {Error} - If the ApplicationModuleQPQConfigSetting is not found in the QPQConfig array.
|
|
35
|
+
*/
|
|
6
36
|
export declare const getApplicationModuleSetting: (qpqConfig: QPQConfig) => ApplicationModuleQPQConfigSetting;
|
|
7
37
|
export declare const getApplicationName: (qpqConfig: QPQConfig) => string;
|
|
8
38
|
export declare const getApplicationModuleName: (qpqConfig: QPQConfig) => string;
|
package/lib/qpqCoreUtils.js
CHANGED
|
@@ -23,18 +23,69 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getQueueQueueProcessors = exports.getUserDirectoryEntryFullPath = exports.getQueueEntryFullPath = exports.getStorageDriveUploadFullPath = exports.getScheduleEntryFullPath = exports.getUniqueKeyForSetting = exports.getSharedSecrets = exports.getOwnedParameters = exports.getUserDirectories = exports.getOwnedSecrets = exports.getAllSrcEntries = exports.getQueueSrcEntries = exports.getScheduleEvents = exports.getUserDirectoryEmailTemplates = exports.getActionProcessorSources = exports.getAllKeyValueStores = exports.getAllEventBusConfigs = exports.getStorageDriveNames = exports.getQueues = exports.getStorageDrives = exports.getApplicationModuleDeployRegion = exports.getApplicationModuleEnvironment = exports.getConfigRoot = exports.getApplicationModuleFeature = exports.getApplicationModuleName = exports.getApplicationName = exports.getApplicationModuleSetting = exports.getConfigSetting = exports.getConfigSettings = void 0;
|
|
26
|
+
exports.getQueueQueueProcessors = exports.getUserDirectoryEntryFullPath = exports.getQueueEntryFullPath = exports.getStorageDriveUploadFullPath = exports.getScheduleEntryFullPath = exports.getUniqueKeyForSetting = exports.getSharedSecrets = exports.getOwnedParameters = exports.getUserDirectories = exports.getOwnedSecrets = exports.getAllSrcEntries = exports.getQueueSrcEntries = exports.getScheduleEvents = exports.getUserDirectoryEmailTemplates = exports.getActionProcessorSources = exports.getAllKeyValueStores = exports.getAllEventBusConfigs = exports.getStorageDriveNames = exports.getQueues = exports.getStorageDrives = exports.getApplicationModuleDeployRegion = exports.getApplicationModuleEnvironment = exports.getConfigRoot = exports.getApplicationModuleFeature = exports.getApplicationModuleName = exports.getApplicationName = exports.getApplicationModuleSetting = exports.getConfigSetting = exports.getConfigSettings = exports.flattenQpqConfig = void 0;
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
28
|
const QPQConfig_1 = require("./config/QPQConfig");
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Flattens a QPQConfig array into a single array of QPQConfigSetting objects.
|
|
31
|
+
* @function
|
|
32
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array to be flattened.
|
|
33
|
+
* @returns {QPQConfigSetting[]} - The flattened array of QPQConfigSetting objects.
|
|
34
|
+
*/
|
|
35
|
+
const flattenQpqConfig = (qpqConfig) => {
|
|
36
|
+
/**
|
|
37
|
+
* A recursive helper function that flattens an array of QPQConfigItem objects.
|
|
38
|
+
* @function
|
|
39
|
+
* @param {QPQConfigItem[]} configItems - An array of QPQConfigItem objects to be flattened.
|
|
40
|
+
* @param {QPQConfigSetting[]} accumulator - An accumulator array for storing the flattened QPQConfigSetting objects.
|
|
41
|
+
* @returns {QPQConfigSetting[]} - The flattened array of QPQConfigSetting objects.
|
|
42
|
+
*/
|
|
43
|
+
const flatten = (configItems, accumulator = []) => {
|
|
44
|
+
return configItems.reduce((acc, item) => {
|
|
45
|
+
if (Array.isArray(item)) {
|
|
46
|
+
return flatten(item, acc);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return [...acc, item];
|
|
50
|
+
}
|
|
51
|
+
}, accumulator);
|
|
52
|
+
};
|
|
53
|
+
return flatten(qpqConfig);
|
|
54
|
+
};
|
|
55
|
+
exports.flattenQpqConfig = flattenQpqConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Filters and returns the config settings of a specific type from a QPQConfig array.
|
|
58
|
+
* @function
|
|
59
|
+
* @template T - The specific type of QPQConfigSetting to filter.
|
|
60
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array.
|
|
61
|
+
* @param {string} configSettingType - The specific config setting type to filter.
|
|
62
|
+
* @returns {T[]} - An array of filtered config settings of the specified type.
|
|
63
|
+
*/
|
|
64
|
+
const getConfigSettings = (qpqConfig, configSettingType) => {
|
|
65
|
+
const flatConfig = (0, exports.flattenQpqConfig)(qpqConfig);
|
|
66
|
+
return flatConfig.filter((c) => c.configSettingType === configSettingType);
|
|
31
67
|
};
|
|
32
68
|
exports.getConfigSettings = getConfigSettings;
|
|
33
|
-
|
|
34
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves a single config setting of a specific type from a QPQConfig array.
|
|
71
|
+
* @function
|
|
72
|
+
* @template T - The specific type of QPQConfigSetting to retrieve.
|
|
73
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array.
|
|
74
|
+
* @param {string} serviceInfrastructureConfigType - The specific config setting type to retrieve.
|
|
75
|
+
* @returns {T | undefined} - The found config setting of the specified type or undefined if not found.
|
|
76
|
+
*/
|
|
77
|
+
const getConfigSetting = (qpqConfig, serviceInfrastructureConfigType) => {
|
|
78
|
+
const [setting] = (0, exports.getConfigSettings)(qpqConfig, serviceInfrastructureConfigType);
|
|
35
79
|
return setting;
|
|
36
80
|
};
|
|
37
81
|
exports.getConfigSetting = getConfigSetting;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the ApplicationModuleSetting from a QPQConfig array.
|
|
84
|
+
* @function
|
|
85
|
+
* @param {QPQConfig} qpqConfig - The input QPQConfig array.
|
|
86
|
+
* @returns {ApplicationModuleQPQConfigSetting} - The ApplicationModuleQPQConfigSetting from the QPQConfig array.
|
|
87
|
+
* @throws {Error} - If the ApplicationModuleQPQConfigSetting is not found in the QPQConfig array.
|
|
88
|
+
*/
|
|
38
89
|
const getApplicationModuleSetting = (qpqConfig) => {
|
|
39
90
|
const applicationModuleSetting = (0, exports.getConfigSetting)(qpqConfig, QPQConfig_1.QPQCoreConfigSettingType.appName);
|
|
40
91
|
if (!applicationModuleSetting) {
|
|
@@ -0,0 +1,30 @@
|
|
|
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.qpqExecuteLog = void 0;
|
|
13
|
+
const qpqRuntime_1 = require("./qpqRuntime");
|
|
14
|
+
const config_1 = require("./config");
|
|
15
|
+
const qpqExecuteLog = (storyResult, runtime) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
// Create a proxy that just resolves all actions to reading from the history
|
|
17
|
+
var logIndex = 0;
|
|
18
|
+
const storyActionProcessor = new Proxy({}, {
|
|
19
|
+
get: (target, property) => {
|
|
20
|
+
return () => __awaiter(void 0, void 0, void 0, function* () { return storyResult.history[logIndex++].res; });
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
// Generate an empty story resolver
|
|
24
|
+
const resolveStory = (0, qpqRuntime_1.createRuntime)([(0, config_1.defineApplicationModule)('Debugger', storyResult.moduleName, 'development', __dirname)], {}, storyActionProcessor, () => new Date().toISOString(), () => __awaiter(void 0, void 0, void 0, function* () { }), () => '', storyResult.runtimeType);
|
|
25
|
+
// Execute it with the initial input
|
|
26
|
+
debugger;
|
|
27
|
+
const result = yield resolveStory(runtime, storyResult.input);
|
|
28
|
+
return result;
|
|
29
|
+
});
|
|
30
|
+
exports.qpqExecuteLog = qpqExecuteLog;
|
package/lib/qpqRuntime.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Action, ActionProcessorList } from './types/Action';
|
|
2
|
-
import { StoryResult, StorySession } from './types/StorySession';
|
|
3
|
-
|
|
2
|
+
import { StoryResult, StorySession, QpqRuntimeType } from './types/StorySession';
|
|
3
|
+
import { QPQConfig } from './config';
|
|
4
|
+
export declare const createRuntime: (qpqConfig: QPQConfig, session: StorySession, actionProcessors: ActionProcessorList, getTimeNow: () => string, logger: (res: StoryResult<any>) => Promise<void>, newGuid: () => string, runtimeType: QpqRuntimeType, initialTags?: string[]) => <TArgs extends any[]>(story: (...args: TArgs) => Generator<any, any, Action<any>>, args: TArgs) => Promise<StoryResult<any>>;
|
package/lib/qpqRuntime.js
CHANGED
|
@@ -13,13 +13,14 @@ exports.createRuntime = void 0;
|
|
|
13
13
|
const ErrorTypeEnum_1 = require("./types/ErrorTypeEnum");
|
|
14
14
|
const SystemActionType_1 = require("./actions/system/SystemActionType");
|
|
15
15
|
const actionLogic_1 = require("./logic/actionLogic");
|
|
16
|
+
const qpqCoreUtils_1 = require("./qpqCoreUtils");
|
|
16
17
|
// Make this type safe omg.
|
|
17
|
-
function processAction(action, actionProcessors, session) {
|
|
18
|
+
function processAction(action, actionProcessors, session, logger) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
20
|
// Special action ~ batch - needs access to the processAction / actionProcessor context
|
|
20
21
|
if (action.type === SystemActionType_1.SystemActionType.Batch) {
|
|
21
22
|
const batchRes = yield Promise.all(action.payload.actions.map((a) => {
|
|
22
|
-
return a ? processAction(a, actionProcessors, session) : null;
|
|
23
|
+
return a ? processAction(a, actionProcessors, session, logger) : null;
|
|
23
24
|
}));
|
|
24
25
|
// If there was an error, throw that error back
|
|
25
26
|
const erroredBatchItem = batchRes.find((br) => (0, actionLogic_1.isErroredActionResult)(br));
|
|
@@ -34,10 +35,10 @@ function processAction(action, actionProcessors, session) {
|
|
|
34
35
|
if (!processor) {
|
|
35
36
|
throw new Error(`Unable to process action: ${action === null || action === void 0 ? void 0 : action.type} from ${Object.keys(actionProcessors).join(', ')}`);
|
|
36
37
|
}
|
|
37
|
-
return yield processor(action.payload, session, actionProcessors);
|
|
38
|
+
return yield processor(action.payload, session, actionProcessors, logger);
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
const createRuntime = (session, actionProcessors, getTimeNow, logger, newGuid) => {
|
|
41
|
+
const createRuntime = (qpqConfig, session, actionProcessors, getTimeNow, logger, newGuid, runtimeType, initialTags) => {
|
|
41
42
|
function resolveStory(story, args) {
|
|
42
43
|
var _a;
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -48,14 +49,17 @@ const createRuntime = (session, actionProcessors, getTimeNow, logger, newGuid) =
|
|
|
48
49
|
session: Object.assign({}, session),
|
|
49
50
|
history: [],
|
|
50
51
|
startedAt: getTimeNow(),
|
|
51
|
-
|
|
52
|
+
tags: initialTags || [],
|
|
53
|
+
moduleName: (0, qpqCoreUtils_1.getApplicationModuleName)(qpqConfig),
|
|
52
54
|
correlation: newGuid(),
|
|
55
|
+
fromCorrelation: session.correlation,
|
|
56
|
+
runtimeType: runtimeType,
|
|
53
57
|
};
|
|
54
58
|
try {
|
|
55
59
|
action = reader.next();
|
|
56
60
|
while (!action.done) {
|
|
57
61
|
const executionTime = getTimeNow();
|
|
58
|
-
const actionResult = yield processAction(action.value, actionProcessors, session);
|
|
62
|
+
const actionResult = yield processAction(action.value, actionProcessors, session, logger);
|
|
59
63
|
const history = {
|
|
60
64
|
act: action.value,
|
|
61
65
|
res: actionResult,
|
|
@@ -88,11 +92,17 @@ const createRuntime = (session, actionProcessors, getTimeNow, logger, newGuid) =
|
|
|
88
92
|
} });
|
|
89
93
|
}
|
|
90
94
|
const storyResult = Object.assign(Object.assign({}, response), { finishedAt: getTimeNow(), result: action.value });
|
|
91
|
-
yield logger(storyResult);
|
|
92
95
|
console.log(`story took took ${new Date(storyResult.finishedAt).getTime() - new Date(storyResult.startedAt).getTime()}ms`);
|
|
93
96
|
return storyResult;
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
|
-
|
|
99
|
+
function resolveStoryWithLogs(story, args) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const storyResult = yield resolveStory(story, args);
|
|
102
|
+
yield logger(storyResult);
|
|
103
|
+
return storyResult;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return resolveStoryWithLogs;
|
|
97
107
|
};
|
|
98
108
|
exports.createRuntime = createRuntime;
|
package/lib/types/Action.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { QPQError } from './ErrorTypeEnum';
|
|
2
|
-
import { StorySession } from './StorySession';
|
|
2
|
+
import { StoryResult, StorySession } from './StorySession';
|
|
3
3
|
export interface Action<T> {
|
|
4
4
|
type: string;
|
|
5
5
|
payload?: T;
|
|
6
6
|
}
|
|
7
7
|
export type ActionProcessorResult<T> = [T?, QPQError?];
|
|
8
|
-
export type ActionProcessor<TAction extends Action<any>, TReturn = any, TActionPayload = TAction['payload']> = (payload: TActionPayload, session: StorySession, actionProcessors: ActionProcessorList) => Promise<ActionProcessorResult<TReturn>>;
|
|
8
|
+
export type ActionProcessor<TAction extends Action<any>, TReturn = any, TActionPayload = TAction['payload']> = (payload: TActionPayload, session: StorySession, actionProcessors: ActionProcessorList, logger: (result: StoryResult<any>) => Promise<void>) => Promise<ActionProcessorResult<TReturn>>;
|
|
9
9
|
export type ActionRequester<TAction extends Action<any>, TReturn = undefined, TQPQReturn = TReturn> = Generator<TAction, TReturn, TQPQReturn>;
|
|
10
10
|
export type ActionProcessorList = {
|
|
11
11
|
[key: string]: ActionProcessor<any, any, any>;
|
|
@@ -15,6 +15,14 @@ export interface ActionHistory<T = any> {
|
|
|
15
15
|
startedAt: string;
|
|
16
16
|
finishedAt: string;
|
|
17
17
|
}
|
|
18
|
+
export declare enum QpqRuntimeType {
|
|
19
|
+
API = "API",
|
|
20
|
+
EXECUTE_STORY = "EXECUTE_STORY",
|
|
21
|
+
EVENT_BRIDGE_EVENT = "EVENT_BRIDGE_EVENT",
|
|
22
|
+
QUEUE_EVENT = "QUEUE_EVENT",
|
|
23
|
+
EVENT_SEO_OR = "EVENT_SEO_OR",
|
|
24
|
+
SERVICE_FUNCTION_EXE = "SERVICE_FUNCTION_EXE"
|
|
25
|
+
}
|
|
18
26
|
export interface StoryResult<TArgs extends Array<any>, TResult = any> {
|
|
19
27
|
input: TArgs;
|
|
20
28
|
session: StorySession;
|
|
@@ -23,6 +31,18 @@ export interface StoryResult<TArgs extends Array<any>, TResult = any> {
|
|
|
23
31
|
finishedAt?: string;
|
|
24
32
|
fromCorrelation?: string;
|
|
25
33
|
correlation: string;
|
|
34
|
+
tags: string[];
|
|
35
|
+
moduleName: string;
|
|
26
36
|
result?: TResult;
|
|
27
37
|
error?: StoryError;
|
|
38
|
+
runtimeType: QpqRuntimeType;
|
|
39
|
+
}
|
|
40
|
+
export interface StoryResultMetadata {
|
|
41
|
+
correlation: string;
|
|
42
|
+
fromCorrelation?: string;
|
|
43
|
+
moduleName: string;
|
|
44
|
+
runtimeType: QpqRuntimeType;
|
|
45
|
+
startedAt: string;
|
|
46
|
+
generic: string;
|
|
47
|
+
error?: string;
|
|
28
48
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QpqRuntimeType = void 0;
|
|
4
|
+
var QpqRuntimeType;
|
|
5
|
+
(function (QpqRuntimeType) {
|
|
6
|
+
QpqRuntimeType["API"] = "API";
|
|
7
|
+
QpqRuntimeType["EXECUTE_STORY"] = "EXECUTE_STORY";
|
|
8
|
+
QpqRuntimeType["EVENT_BRIDGE_EVENT"] = "EVENT_BRIDGE_EVENT";
|
|
9
|
+
QpqRuntimeType["QUEUE_EVENT"] = "QUEUE_EVENT";
|
|
10
|
+
QpqRuntimeType["EVENT_SEO_OR"] = "EVENT_SEO_OR";
|
|
11
|
+
QpqRuntimeType["SERVICE_FUNCTION_EXE"] = "SERVICE_FUNCTION_EXE";
|
|
12
|
+
})(QpqRuntimeType = exports.QpqRuntimeType || (exports.QpqRuntimeType = {}));
|