quidproquo-core 0.0.9 → 0.0.11
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/event/EventActionRequester.d.ts +4 -0
- package/lib/actions/event/EventActionRequester.js +35 -0
- package/lib/actions/event/EventActionTypeEnum.d.ts +7 -0
- package/lib/actions/event/EventActionTypeEnum.js +11 -0
- package/lib/actions/system/SystemActionRequester.d.ts +1 -0
- package/lib/actions/system/SystemActionRequester.js +17 -5
- package/lib/actions/system/SystemActionTypeEnum.d.ts +2 -1
- package/lib/actions/system/SystemActionTypeEnum.js +1 -0
- package/lib/config/QPQConfig.d.ts +7 -0
- package/lib/config/QPQConfig.js +7 -0
- package/lib/config/settings/appName.d.ts +5 -0
- package/lib/config/settings/appName.js +9 -0
- package/lib/index.d.ts +8 -1
- package/lib/index.js +20 -7
- package/lib/qpqCoreUtils.d.ts +10 -0
- package/lib/qpqCoreUtils.js +27 -0
- package/lib/stories/askProcessEvent.d.ts +2 -0
- package/lib/stories/askProcessEvent.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function askEventTransformEventParams(...params: any): Generator<any, any, any>;
|
|
2
|
+
export declare function askEventTransformResponseResult(response: any): Generator<any, any, any>;
|
|
3
|
+
export declare function askEventMatchStory(transformedEventParams: any): Generator<any, any, any>;
|
|
4
|
+
export declare function askEventAutoRespond(transformedEventParams: any): Generator<any, any, any>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.askEventAutoRespond = exports.askEventMatchStory = exports.askEventTransformResponseResult = exports.askEventTransformEventParams = void 0;
|
|
7
|
+
const EventActionTypeEnum_1 = __importDefault(require("./EventActionTypeEnum"));
|
|
8
|
+
function* askEventTransformEventParams(...params) {
|
|
9
|
+
return yield {
|
|
10
|
+
type: EventActionTypeEnum_1.default.TransformEventParams,
|
|
11
|
+
payload: { params },
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.askEventTransformEventParams = askEventTransformEventParams;
|
|
15
|
+
function* askEventTransformResponseResult(response) {
|
|
16
|
+
return yield {
|
|
17
|
+
type: EventActionTypeEnum_1.default.TransformResponseResult,
|
|
18
|
+
payload: { response },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.askEventTransformResponseResult = askEventTransformResponseResult;
|
|
22
|
+
function* askEventMatchStory(transformedEventParams) {
|
|
23
|
+
return yield {
|
|
24
|
+
type: EventActionTypeEnum_1.default.MatchStory,
|
|
25
|
+
payload: { transformedEventParams },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.askEventMatchStory = askEventMatchStory;
|
|
29
|
+
function* askEventAutoRespond(transformedEventParams) {
|
|
30
|
+
return yield {
|
|
31
|
+
type: EventActionTypeEnum_1.default.AutoRespond,
|
|
32
|
+
payload: { transformedEventParams },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.askEventAutoRespond = askEventAutoRespond;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare enum EventActionTypeEnum {
|
|
2
|
+
TransformEventParams = "@quidproquo-core/event/TransformEventParams",
|
|
3
|
+
TransformResponseResult = "@quidproquo-core/event/TransformResponseResult",
|
|
4
|
+
AutoRespond = "@quidproquo-core/event/AutoRespond",
|
|
5
|
+
MatchStory = "@quidproquo-core/event/MatchStory"
|
|
6
|
+
}
|
|
7
|
+
export default EventActionTypeEnum;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventActionTypeEnum = void 0;
|
|
4
|
+
var EventActionTypeEnum;
|
|
5
|
+
(function (EventActionTypeEnum) {
|
|
6
|
+
EventActionTypeEnum["TransformEventParams"] = "@quidproquo-core/event/TransformEventParams";
|
|
7
|
+
EventActionTypeEnum["TransformResponseResult"] = "@quidproquo-core/event/TransformResponseResult";
|
|
8
|
+
EventActionTypeEnum["AutoRespond"] = "@quidproquo-core/event/AutoRespond";
|
|
9
|
+
EventActionTypeEnum["MatchStory"] = "@quidproquo-core/event/MatchStory";
|
|
10
|
+
})(EventActionTypeEnum = exports.EventActionTypeEnum || (exports.EventActionTypeEnum = {}));
|
|
11
|
+
exports.default = EventActionTypeEnum;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function askBatch(actions: Array<object>): Generator<any, Array<any>, Array<any>>;
|
|
2
2
|
export declare function askParallel(stories: Array<any>): Generator<any, any, any>;
|
|
3
|
+
export declare function askExecuteStory(type: string, src: string, runtime: string, ...params: any): Generator<any, any, any>;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.askParallel = exports.askBatch = void 0;
|
|
8
|
+
exports.askExecuteStory = exports.askParallel = exports.askBatch = void 0;
|
|
9
9
|
const SystemActionTypeEnum_1 = __importDefault(require("./SystemActionTypeEnum"));
|
|
10
10
|
// TODO: fix typing
|
|
11
11
|
function* askBatch(actions) {
|
|
@@ -18,13 +18,13 @@ exports.askBatch = askBatch;
|
|
|
18
18
|
function* askParallel(stories) {
|
|
19
19
|
const itt = stories.map((s) => s[0](...s.slice(1)));
|
|
20
20
|
let actions = itt.map((i) => i.next());
|
|
21
|
-
let values = actions.map(a => a.value);
|
|
21
|
+
let values = actions.map((a) => a.value);
|
|
22
22
|
while (true) {
|
|
23
23
|
// Batch any actions that we have not processed yet
|
|
24
|
-
const actionsToBatch = actions.map(a => !a.done ? a.value : null);
|
|
24
|
+
const actionsToBatch = actions.map((a) => (!a.done ? a.value : null));
|
|
25
25
|
// Only batch actions when there are some to batch
|
|
26
26
|
// People may batch stories together that actually dont have actions in them!?
|
|
27
|
-
if (actionsToBatch.filter(atb => !!atb).length) {
|
|
27
|
+
if (actionsToBatch.filter((atb) => !!atb).length) {
|
|
28
28
|
values = yield* askBatch(actionsToBatch);
|
|
29
29
|
}
|
|
30
30
|
// Calculate real values
|
|
@@ -38,8 +38,20 @@ function* askParallel(stories) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
if (done) {
|
|
41
|
-
return actions.map(a => a.value);
|
|
41
|
+
return actions.map((a) => a.value);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
exports.askParallel = askParallel;
|
|
46
|
+
function* askExecuteStory(type, src, runtime, ...params) {
|
|
47
|
+
return yield {
|
|
48
|
+
type: SystemActionTypeEnum_1.default.ExecuteStory,
|
|
49
|
+
payload: {
|
|
50
|
+
type,
|
|
51
|
+
src,
|
|
52
|
+
runtime,
|
|
53
|
+
params,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.askExecuteStory = askExecuteStory;
|
|
@@ -6,5 +6,6 @@ exports.SystemActionTypeEnum = void 0;
|
|
|
6
6
|
var SystemActionTypeEnum;
|
|
7
7
|
(function (SystemActionTypeEnum) {
|
|
8
8
|
SystemActionTypeEnum["Batch"] = "@quidproquo-core/System/Batch";
|
|
9
|
+
SystemActionTypeEnum["ExecuteStory"] = "@quidproquo-core/System/ExecuteStory";
|
|
9
10
|
})(SystemActionTypeEnum = exports.SystemActionTypeEnum || (exports.SystemActionTypeEnum = {}));
|
|
10
11
|
exports.default = SystemActionTypeEnum;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QPQCoreConfigSettingType = void 0;
|
|
4
|
+
var QPQCoreConfigSettingType;
|
|
5
|
+
(function (QPQCoreConfigSettingType) {
|
|
6
|
+
QPQCoreConfigSettingType["appName"] = "@quidproquo-core/config/AppName";
|
|
7
|
+
})(QPQCoreConfigSettingType = exports.QPQCoreConfigSettingType || (exports.QPQCoreConfigSettingType = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineAppName = void 0;
|
|
4
|
+
const QPQConfig_1 = require("../QPQConfig");
|
|
5
|
+
const defineAppName = (appName) => ({
|
|
6
|
+
configSettingType: QPQConfig_1.QPQCoreConfigSettingType.appName,
|
|
7
|
+
appName,
|
|
8
|
+
});
|
|
9
|
+
exports.defineAppName = defineAppName;
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { DateActionTypeEnum } from "./actions/date/DateActionTypeEnum";
|
|
2
|
+
export { GuidActionTypeEnum } from "./actions/guid/GuidActionTypeEnum";
|
|
3
|
+
export { EventActionTypeEnum } from "./actions/event/EventActionTypeEnum";
|
|
4
|
+
export { MathActionTypeEnum } from "./actions/math/MathActionTypeEnum";
|
|
5
|
+
export { PlatformActionTypeEnum } from "./actions/platform/PlatformActionTypeEnum";
|
|
6
|
+
export { SystemActionTypeEnum } from "./actions/system/SystemActionTypeEnum";
|
|
7
|
+
export { QPQCoreConfigSettingType, QPQConfigSetting, QPQConfig, } from "./config/QPQConfig";
|
|
8
|
+
export { default as qpqCoreUtils } from "./qpqCoreUtils";
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const hello = (what) => {
|
|
5
|
-
const newVar = `Hello ${what}`;
|
|
6
|
-
console.log(newVar);
|
|
7
|
-
return newVar;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
4
|
};
|
|
9
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.qpqCoreUtils = exports.QPQCoreConfigSettingType = exports.SystemActionTypeEnum = exports.PlatformActionTypeEnum = exports.MathActionTypeEnum = exports.EventActionTypeEnum = exports.GuidActionTypeEnum = exports.DateActionTypeEnum = void 0;
|
|
7
|
+
var DateActionTypeEnum_1 = require("./actions/date/DateActionTypeEnum");
|
|
8
|
+
Object.defineProperty(exports, "DateActionTypeEnum", { enumerable: true, get: function () { return DateActionTypeEnum_1.DateActionTypeEnum; } });
|
|
9
|
+
var GuidActionTypeEnum_1 = require("./actions/guid/GuidActionTypeEnum");
|
|
10
|
+
Object.defineProperty(exports, "GuidActionTypeEnum", { enumerable: true, get: function () { return GuidActionTypeEnum_1.GuidActionTypeEnum; } });
|
|
11
|
+
var EventActionTypeEnum_1 = require("./actions/event/EventActionTypeEnum");
|
|
12
|
+
Object.defineProperty(exports, "EventActionTypeEnum", { enumerable: true, get: function () { return EventActionTypeEnum_1.EventActionTypeEnum; } });
|
|
13
|
+
var MathActionTypeEnum_1 = require("./actions/math/MathActionTypeEnum");
|
|
14
|
+
Object.defineProperty(exports, "MathActionTypeEnum", { enumerable: true, get: function () { return MathActionTypeEnum_1.MathActionTypeEnum; } });
|
|
15
|
+
var PlatformActionTypeEnum_1 = require("./actions/platform/PlatformActionTypeEnum");
|
|
16
|
+
Object.defineProperty(exports, "PlatformActionTypeEnum", { enumerable: true, get: function () { return PlatformActionTypeEnum_1.PlatformActionTypeEnum; } });
|
|
17
|
+
var SystemActionTypeEnum_1 = require("./actions/system/SystemActionTypeEnum");
|
|
18
|
+
Object.defineProperty(exports, "SystemActionTypeEnum", { enumerable: true, get: function () { return SystemActionTypeEnum_1.SystemActionTypeEnum; } });
|
|
19
|
+
var QPQConfig_1 = require("./config/QPQConfig");
|
|
20
|
+
Object.defineProperty(exports, "QPQCoreConfigSettingType", { enumerable: true, get: function () { return QPQConfig_1.QPQCoreConfigSettingType; } });
|
|
21
|
+
var qpqCoreUtils_1 = require("./qpqCoreUtils");
|
|
22
|
+
Object.defineProperty(exports, "qpqCoreUtils", { enumerable: true, get: function () { return __importDefault(qpqCoreUtils_1).default; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QPQConfig, QPQConfigSetting } from "./config/QPQConfig";
|
|
2
|
+
export declare const getConfigSettings: <T extends QPQConfigSetting>(configs: QPQConfig, configSettingType: string) => T[];
|
|
3
|
+
export declare const getConfigSetting: <T extends QPQConfigSetting>(configs: QPQConfig, serviceInfrastructureConfigType: string) => T | undefined;
|
|
4
|
+
export declare const getAppName: (configs: QPQConfig) => string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
getConfigSettings: <T extends QPQConfigSetting>(configs: QPQConfig, configSettingType: string) => T[];
|
|
7
|
+
getConfigSetting: <T_1 extends QPQConfigSetting>(configs: QPQConfig, serviceInfrastructureConfigType: string) => T_1 | undefined;
|
|
8
|
+
getAppName: (configs: QPQConfig) => string;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppName = exports.getConfigSetting = exports.getConfigSettings = void 0;
|
|
4
|
+
const QPQConfig_1 = require("./config/QPQConfig");
|
|
5
|
+
const getConfigSettings = (configs, configSettingType) => {
|
|
6
|
+
return configs.filter((c) => c.configSettingType === configSettingType);
|
|
7
|
+
};
|
|
8
|
+
exports.getConfigSettings = getConfigSettings;
|
|
9
|
+
const getConfigSetting = (configs, serviceInfrastructureConfigType) => {
|
|
10
|
+
const [setting] = (0, exports.getConfigSettings)(configs, serviceInfrastructureConfigType);
|
|
11
|
+
return setting;
|
|
12
|
+
};
|
|
13
|
+
exports.getConfigSetting = getConfigSetting;
|
|
14
|
+
const getAppName = (configs) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const appName = (_a = (0, exports.getConfigSetting)(configs, QPQConfig_1.QPQCoreConfigSettingType.appName)) === null || _a === void 0 ? void 0 : _a.appName;
|
|
17
|
+
if (!appName) {
|
|
18
|
+
throw new Error("please use defineAppName in your QPQ config");
|
|
19
|
+
}
|
|
20
|
+
return appName;
|
|
21
|
+
};
|
|
22
|
+
exports.getAppName = getAppName;
|
|
23
|
+
exports.default = {
|
|
24
|
+
getConfigSettings: exports.getConfigSettings,
|
|
25
|
+
getConfigSetting: exports.getConfigSetting,
|
|
26
|
+
getAppName: exports.getAppName,
|
|
27
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const EventActionRequester_1 = require("../actions/event/EventActionRequester");
|
|
4
|
+
const SystemActionRequester_1 = require("../actions/system/SystemActionRequester");
|
|
5
|
+
function* askProcessEvent(...args) {
|
|
6
|
+
// Transform event params
|
|
7
|
+
const http = yield* (0, EventActionRequester_1.askEventTransformEventParams)(...args);
|
|
8
|
+
// See if we want to exit early (validation / auth etc)
|
|
9
|
+
const earlyExitResponse = yield* (0, EventActionRequester_1.askEventAutoRespond)(http);
|
|
10
|
+
if (earlyExitResponse) {
|
|
11
|
+
// Transform the early exit response if needed
|
|
12
|
+
return yield* (0, EventActionRequester_1.askEventTransformResponseResult)(earlyExitResponse);
|
|
13
|
+
}
|
|
14
|
+
// Try and match a story to execute
|
|
15
|
+
const { src, runtime } = yield* (0, EventActionRequester_1.askEventMatchStory)(http);
|
|
16
|
+
// Execute the story
|
|
17
|
+
const result = yield* (0, SystemActionRequester_1.askExecuteStory)("route", src, runtime, [http]);
|
|
18
|
+
// return the result of the story back to the event caller
|
|
19
|
+
return yield* (0, EventActionRequester_1.askEventTransformResponseResult)(result);
|
|
20
|
+
}
|
|
21
|
+
exports.default = askProcessEvent;
|