@bluelibs/runner 2.2.0 → 2.2.2
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/dist/define.js +40 -20
- package/dist/define.js.map +1 -1
- package/dist/defs.d.ts +1 -1
- package/dist/globalEvents.js +9 -9
- package/dist/globalEvents.js.map +1 -1
- package/dist/globalResources.js +4 -4
- package/dist/globalResources.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/typesafety.test.ts +13 -0
- package/src/define.ts +41 -20
- package/src/defs.ts +3 -1
- package/src/globalEvents.ts +9 -9
- package/src/globalResources.ts +4 -4
package/dist/define.js
CHANGED
|
@@ -14,33 +14,44 @@ const errors_1 = require("./errors");
|
|
|
14
14
|
const getCallerFile_1 = require("./tools/getCallerFile");
|
|
15
15
|
// Helper function to get the caller file
|
|
16
16
|
function defineTask(taskConfig) {
|
|
17
|
+
const filePath = (0, getCallerFile_1.getCallerFile)();
|
|
17
18
|
return {
|
|
18
19
|
[defs_1.symbols.task]: true,
|
|
19
|
-
[defs_1.symbols.filePath]:
|
|
20
|
+
[defs_1.symbols.filePath]: filePath,
|
|
20
21
|
id: taskConfig.id,
|
|
21
22
|
dependencies: taskConfig.dependencies || {},
|
|
22
23
|
middleware: taskConfig.middleware || [],
|
|
23
24
|
run: taskConfig.run,
|
|
24
25
|
on: taskConfig.on,
|
|
25
26
|
events: {
|
|
26
|
-
beforeRun:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
beforeRun: {
|
|
28
|
+
...defineEvent({
|
|
29
|
+
id: `${taskConfig.id}.events.beforeRun`,
|
|
30
|
+
}),
|
|
31
|
+
[defs_1.symbols.filePath]: (0, getCallerFile_1.getCallerFile)(),
|
|
32
|
+
},
|
|
33
|
+
afterRun: {
|
|
34
|
+
...defineEvent({
|
|
35
|
+
id: `${taskConfig.id}.events.afterRun`,
|
|
36
|
+
}),
|
|
37
|
+
[defs_1.symbols.filePath]: (0, getCallerFile_1.getCallerFile)(),
|
|
38
|
+
},
|
|
39
|
+
onError: {
|
|
40
|
+
...defineEvent({
|
|
41
|
+
id: `${taskConfig.id}.events.onError`,
|
|
42
|
+
}),
|
|
43
|
+
[defs_1.symbols.filePath]: (0, getCallerFile_1.getCallerFile)(),
|
|
44
|
+
},
|
|
35
45
|
},
|
|
36
46
|
meta: taskConfig.meta || {},
|
|
37
47
|
// autorun,
|
|
38
48
|
};
|
|
39
49
|
}
|
|
40
50
|
function defineResource(constConfig) {
|
|
51
|
+
const filePath = (0, getCallerFile_1.getCallerFile)();
|
|
41
52
|
return {
|
|
42
53
|
[defs_1.symbols.resource]: true,
|
|
43
|
-
[defs_1.symbols.filePath]:
|
|
54
|
+
[defs_1.symbols.filePath]: filePath,
|
|
44
55
|
id: constConfig.id,
|
|
45
56
|
dependencies: constConfig.dependencies,
|
|
46
57
|
dispose: constConfig.dispose,
|
|
@@ -56,15 +67,24 @@ function defineResource(constConfig) {
|
|
|
56
67
|
};
|
|
57
68
|
},
|
|
58
69
|
events: {
|
|
59
|
-
beforeInit:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
beforeInit: {
|
|
71
|
+
...defineEvent({
|
|
72
|
+
id: `${constConfig.id}.events.beforeInit`,
|
|
73
|
+
}),
|
|
74
|
+
[defs_1.symbols.filePath]: filePath,
|
|
75
|
+
},
|
|
76
|
+
afterInit: {
|
|
77
|
+
...defineEvent({
|
|
78
|
+
id: `${constConfig.id}.events.afterInit`,
|
|
79
|
+
}),
|
|
80
|
+
[defs_1.symbols.filePath]: filePath,
|
|
81
|
+
},
|
|
82
|
+
onError: {
|
|
83
|
+
...defineEvent({
|
|
84
|
+
id: `${constConfig.id}.events.onError`,
|
|
85
|
+
}),
|
|
86
|
+
[defs_1.symbols.filePath]: filePath,
|
|
87
|
+
},
|
|
68
88
|
},
|
|
69
89
|
meta: constConfig.meta || {},
|
|
70
90
|
middleware: constConfig.middleware || [],
|
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":";;AAuBA,gCAwCC;AAED,wCAkDC;AAED,kCAQC;AAED,4CAsBC;AAED,wBAEC;AAED,gCAEC;AAED,oDAIC;AAED,0BAEC;AAED,oCAEC;AA1KD,iCAgBgB;AAChB,qCAAkC;AAClC,yDAAsD;AAEtD,yCAAyC;AAEzC,SAAgB,UAAU,CAMxB,UAAqD;IAErD,MAAM,QAAQ,GAAG,IAAA,6BAAa,GAAE,CAAC;IACjC,OAAO;QACL,CAAC,cAAO,CAAC,IAAI,CAAC,EAAE,IAAI;QACpB,CAAC,cAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ;QAC5B,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,YAAY,EAAE,UAAU,CAAC,YAAY,IAAK,EAAW;QACrD,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,EAAE;QACvC,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,MAAM,EAAE;YACN,SAAS,EAAE;gBACT,GAAG,WAAW,CAAC;oBACb,EAAE,EAAE,GAAG,UAAU,CAAC,EAAE,mBAAmB;iBACxC,CAAC;gBACF,CAAC,cAAO,CAAC,QAAQ,CAAC,EAAE,IAAA,6BAAa,GAAE;aACpC;YACD,QAAQ,EAAE;gBACR,GAAG,WAAW,CAAC;oBACb,EAAE,EAAE,GAAG,UAAU,CAAC,EAAE,kBAAkB;iBACvC,CAAC;gBACF,CAAC,cAAO,CAAC,QAAQ,CAAC,EAAE,IAAA,6BAAa,GAAE;aACpC;YACD,O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Ef,OAAO,UAAU,IAAI,UAAU,CAAC,cAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAED,SAAgB,OAAO,CAAC,UAAe;IACrC,OAAO,UAAU,IAAI,UAAU,CAAC,cAAO,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,SAAgB,YAAY,CAAC,UAAe;IAC1C,OAAO,UAAU,IAAI,UAAU,CAAC,cAAO,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/defs.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export interface ITaskDefinition<TInput = any, TOutput extends Promise<any> = an
|
|
|
60
60
|
*/
|
|
61
61
|
listenerOrder?: number;
|
|
62
62
|
meta?: ITaskMeta;
|
|
63
|
-
run: (input: TOn extends undefined ? TInput : IEvent<ExtractEventParams<TOn>>, dependencies: DependencyValuesType<TDependencies>) => TOutput;
|
|
63
|
+
run: (input: TOn extends undefined ? TInput : IEvent<TOn extends "*" ? any : ExtractEventParams<TOn>>, dependencies: DependencyValuesType<TDependencies>) => TOutput;
|
|
64
64
|
}
|
|
65
65
|
export type BeforeRunEventPayload<TInput> = {
|
|
66
66
|
input: TInput;
|
package/dist/globalEvents.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.globalEventsArray = exports.globalEvents = void 0;
|
|
|
4
4
|
const define_1 = require("./define");
|
|
5
5
|
exports.globalEvents = {
|
|
6
6
|
beforeInit: (0, define_1.defineEvent)({
|
|
7
|
-
id: "global.beforeInit",
|
|
7
|
+
id: "global.events.beforeInit",
|
|
8
8
|
meta: {
|
|
9
9
|
title: "Before Initialization",
|
|
10
10
|
description: "Triggered before any resource or system-wide initialization occurs.",
|
|
@@ -12,7 +12,7 @@ exports.globalEvents = {
|
|
|
12
12
|
},
|
|
13
13
|
}),
|
|
14
14
|
afterInit: (0, define_1.defineEvent)({
|
|
15
|
-
id: "global.afterInit",
|
|
15
|
+
id: "global.events.afterInit",
|
|
16
16
|
meta: {
|
|
17
17
|
title: "After Initialization",
|
|
18
18
|
description: "Fired after the system or resource initialization is completed.",
|
|
@@ -20,7 +20,7 @@ exports.globalEvents = {
|
|
|
20
20
|
},
|
|
21
21
|
}),
|
|
22
22
|
log: (0, define_1.defineEvent)({
|
|
23
|
-
id: "global.log",
|
|
23
|
+
id: "global.events.log",
|
|
24
24
|
meta: {
|
|
25
25
|
title: "Log Event",
|
|
26
26
|
description: "Used to log events and messages across the system.",
|
|
@@ -29,7 +29,7 @@ exports.globalEvents = {
|
|
|
29
29
|
}),
|
|
30
30
|
tasks: {
|
|
31
31
|
beforeRun: (0, define_1.defineEvent)({
|
|
32
|
-
id: "global.tasks.beforeRun",
|
|
32
|
+
id: "global.events.tasks.beforeRun",
|
|
33
33
|
meta: {
|
|
34
34
|
title: "Before Task Execution",
|
|
35
35
|
description: "Triggered before a task starts running, providing access to the input data.",
|
|
@@ -37,7 +37,7 @@ exports.globalEvents = {
|
|
|
37
37
|
},
|
|
38
38
|
}),
|
|
39
39
|
afterRun: (0, define_1.defineEvent)({
|
|
40
|
-
id: "global.tasks.afterRun",
|
|
40
|
+
id: "global.events.tasks.afterRun",
|
|
41
41
|
meta: {
|
|
42
42
|
title: "After Task Execution",
|
|
43
43
|
description: "Fired after a task has completed, providing both the input and output data.",
|
|
@@ -45,7 +45,7 @@ exports.globalEvents = {
|
|
|
45
45
|
},
|
|
46
46
|
}),
|
|
47
47
|
onError: (0, define_1.defineEvent)({
|
|
48
|
-
id: "global.tasks.onError",
|
|
48
|
+
id: "global.events.tasks.onError",
|
|
49
49
|
meta: {
|
|
50
50
|
title: "Task Error",
|
|
51
51
|
description: "Triggered when an error occurs during task execution. Allows error suppression.",
|
|
@@ -55,7 +55,7 @@ exports.globalEvents = {
|
|
|
55
55
|
},
|
|
56
56
|
resources: {
|
|
57
57
|
beforeInit: (0, define_1.defineEvent)({
|
|
58
|
-
id: "global.resources.beforeInit",
|
|
58
|
+
id: "global.events.resources.beforeInit",
|
|
59
59
|
meta: {
|
|
60
60
|
title: "Before Resource Initialization",
|
|
61
61
|
description: "Fired before a resource is initialized, with access to the configuration.",
|
|
@@ -63,7 +63,7 @@ exports.globalEvents = {
|
|
|
63
63
|
},
|
|
64
64
|
}),
|
|
65
65
|
afterInit: (0, define_1.defineEvent)({
|
|
66
|
-
id: "global.resources.afterInit",
|
|
66
|
+
id: "global.events.resources.afterInit",
|
|
67
67
|
meta: {
|
|
68
68
|
title: "After Resource Initialization",
|
|
69
69
|
description: "Fired after a resource has been initialized, providing the final value.",
|
|
@@ -71,7 +71,7 @@ exports.globalEvents = {
|
|
|
71
71
|
},
|
|
72
72
|
}),
|
|
73
73
|
onError: (0, define_1.defineEvent)({
|
|
74
|
-
id: "global.resources.onError",
|
|
74
|
+
id: "global.events.resources.onError",
|
|
75
75
|
meta: {
|
|
76
76
|
title: "Resource Error",
|
|
77
77
|
description: "Triggered when an error occurs during resource initialization. Allows error suppression.",
|
package/dist/globalEvents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalEvents.js","sourceRoot":"","sources":["../src/globalEvents.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAI1B,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE,IAAA,oBAAW,EAAC;QACtB,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"globalEvents.js","sourceRoot":"","sources":["../src/globalEvents.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAI1B,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE,IAAA,oBAAW,EAAC;QACtB,EAAE,EAAE,0BAA0B;QAC9B,IAAI,EAAE;YACJ,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EACT,qEAAqE;YACvE,IAAI,EAAE,CAAC,QAAQ,CAAC;SACjB;KACF,CAAC;IACF,SAAS,EAAE,IAAA,oBAAW,EAAC;QACrB,EAAE,EAAE,yBAAyB;QAC7B,IAAI,EAAE;YACJ,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,iEAAiE;Y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QACF,OAAO,EAAE,IAAA,oBAAW,EAIjB;YACD,EAAE,EAAE,iCAAiC;YACrC,IAAI,EAAE;gBACJ,KAAK,EAAE,gBAAgB;gBACvB,WAAW,EACT,0FAA0F;gBAC5F,IAAI,EAAE,CAAC,QAAQ,CAAC;aACjB;SACF,CAAC;KACH;CACF,CAAC;AAEW,QAAA,iBAAiB,GAAG;IAC/B,oBAAY,CAAC,GAAG;IAChB,oBAAY,CAAC,UAAU;IACvB,oBAAY,CAAC,SAAS;IACtB,oBAAY,CAAC,KAAK,CAAC,SAAS;IAC5B,oBAAY,CAAC,KAAK,CAAC,QAAQ;IAC3B,oBAAY,CAAC,KAAK,CAAC,OAAO;IAC1B,oBAAY,CAAC,SAAS,CAAC,UAAU;IACjC,oBAAY,CAAC,SAAS,CAAC,SAAS;IAChC,oBAAY,CAAC,SAAS,CAAC,OAAO;CAC/B,CAAC"}
|
package/dist/globalResources.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.globalResources = void 0;
|
|
4
4
|
const define_1 = require("./define");
|
|
5
5
|
const store = (0, define_1.defineResource)({
|
|
6
|
-
id: "global.store",
|
|
6
|
+
id: "global.resources.store",
|
|
7
7
|
init: async (store) => store,
|
|
8
8
|
meta: {
|
|
9
9
|
title: "Store",
|
|
@@ -14,7 +14,7 @@ const store = (0, define_1.defineResource)({
|
|
|
14
14
|
exports.globalResources = {
|
|
15
15
|
store,
|
|
16
16
|
eventManager: (0, define_1.defineResource)({
|
|
17
|
-
id: "global.eventManager",
|
|
17
|
+
id: "global.resources.eventManager",
|
|
18
18
|
init: async (em) => em,
|
|
19
19
|
meta: {
|
|
20
20
|
title: "Event Manager",
|
|
@@ -23,7 +23,7 @@ exports.globalResources = {
|
|
|
23
23
|
},
|
|
24
24
|
}),
|
|
25
25
|
taskRunner: (0, define_1.defineResource)({
|
|
26
|
-
id: "global.taskRunner",
|
|
26
|
+
id: "global.resources.taskRunner",
|
|
27
27
|
init: async (runner) => runner,
|
|
28
28
|
meta: {
|
|
29
29
|
title: "Task Runner",
|
|
@@ -32,7 +32,7 @@ exports.globalResources = {
|
|
|
32
32
|
},
|
|
33
33
|
}),
|
|
34
34
|
logger: (0, define_1.defineResource)({
|
|
35
|
-
id: "global.logger",
|
|
35
|
+
id: "global.resources.logger",
|
|
36
36
|
init: async (logger) => logger,
|
|
37
37
|
meta: {
|
|
38
38
|
title: "Logger",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalResources.js","sourceRoot":"","sources":["../src/globalResources.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAM1C,MAAM,KAAK,GAAG,IAAA,uBAAc,EAAC;IAC3B,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"globalResources.js","sourceRoot":"","sources":["../src/globalResources.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAM1C,MAAM,KAAK,GAAG,IAAA,uBAAc,EAAC;IAC3B,EAAE,EAAE,wBAAwB;IAC5B,IAAI,EAAE,KAAK,EAAE,KAAY,EAAE,EAAE,CAAC,KAAK;IACnC,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;QACd,WAAW,EACT,+FAA+F;QACjG,IAAI,EAAE,CAAC,UAAU,CAAC;KACnB;CACF,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG;IAC7B,KAAK;IACL,YAAY,EAAE,IAAA,uBAAc,EAAC;QAC3B,EAAE,EAAE,+BAA+B;QACnC,IAAI,EAAE,KAAK,EAAE,EAAgB,EAAE,EAAE,CAAC,EAAE;QACpC,IAAI,EAAE;YACJ,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,iGAAiG;YACnG,IAAI,EAAE,CAAC,UAAU,CAAC;SACnB;KACF,CAAC;IACF,UAAU,EAAE,IAAA,uBAAc,EAAC;QACzB,EAAE,EAAE,6BAA6B;QACjC,IAAI,EAAE,KAAK,EAAE,MAAkB,EAAE,EAAE,CAAC,MAAM;QAC1C,IAAI,EAAE;YACJ,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,+GAA+G;YACjH,IAAI,EAAE,CAAC,UAAU,CAAC;SACnB;KACF,CAAC;IACF,MAAM,EAAE,IAAA,uBAAc,EAAC;QACrB,EAAE,EAAE,yBAAyB;QAC7B,IAAI,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE,CAAC,MAAM;QACtC,IAAI,EAAE;YACJ,KAAK,EAAE,QAAQ;YACf,WAAW,EACT,4HAA4H;SAC/H;KACF,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -126,6 +126,19 @@ describe("typesafety", () => {
|
|
|
126
126
|
},
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
const testResource2 = defineTask({
|
|
130
|
+
id: "test.resource",
|
|
131
|
+
dependencies: { task },
|
|
132
|
+
on: "*",
|
|
133
|
+
run: async (_, deps) => {
|
|
134
|
+
_.data.message;
|
|
135
|
+
_.data.messagex;
|
|
136
|
+
deps.task();
|
|
137
|
+
// @ts-expect-error
|
|
138
|
+
deps.task2;
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
129
142
|
expect(true).toBe(true);
|
|
130
143
|
});
|
|
131
144
|
});
|
package/src/define.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { get } from "node:http";
|
|
1
2
|
import {
|
|
2
3
|
ITask,
|
|
3
4
|
ITaskDefinition,
|
|
@@ -28,24 +29,34 @@ export function defineTask<
|
|
|
28
29
|
>(
|
|
29
30
|
taskConfig: ITaskDefinition<Input, Output, Deps, TOn>
|
|
30
31
|
): ITask<Input, Output, Deps, TOn> {
|
|
32
|
+
const filePath = getCallerFile();
|
|
31
33
|
return {
|
|
32
34
|
[symbols.task]: true,
|
|
33
|
-
[symbols.filePath]:
|
|
35
|
+
[symbols.filePath]: filePath,
|
|
34
36
|
id: taskConfig.id,
|
|
35
37
|
dependencies: taskConfig.dependencies || ({} as Deps),
|
|
36
38
|
middleware: taskConfig.middleware || [],
|
|
37
39
|
run: taskConfig.run,
|
|
38
40
|
on: taskConfig.on,
|
|
39
41
|
events: {
|
|
40
|
-
beforeRun:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
beforeRun: {
|
|
43
|
+
...defineEvent({
|
|
44
|
+
id: `${taskConfig.id}.events.beforeRun`,
|
|
45
|
+
}),
|
|
46
|
+
[symbols.filePath]: getCallerFile(),
|
|
47
|
+
},
|
|
48
|
+
afterRun: {
|
|
49
|
+
...defineEvent({
|
|
50
|
+
id: `${taskConfig.id}.events.afterRun`,
|
|
51
|
+
}),
|
|
52
|
+
[symbols.filePath]: getCallerFile(),
|
|
53
|
+
},
|
|
54
|
+
onError: {
|
|
55
|
+
...defineEvent({
|
|
56
|
+
id: `${taskConfig.id}.events.onError`,
|
|
57
|
+
}),
|
|
58
|
+
[symbols.filePath]: getCallerFile(),
|
|
59
|
+
},
|
|
49
60
|
},
|
|
50
61
|
meta: taskConfig.meta || {},
|
|
51
62
|
// autorun,
|
|
@@ -60,9 +71,10 @@ export function defineResource<
|
|
|
60
71
|
>(
|
|
61
72
|
constConfig: IResourceDefinition<TConfig, TValue, TDeps, THooks>
|
|
62
73
|
): IResource<TConfig, TValue, TDeps> {
|
|
74
|
+
const filePath = getCallerFile();
|
|
63
75
|
return {
|
|
64
76
|
[symbols.resource]: true,
|
|
65
|
-
[symbols.filePath]:
|
|
77
|
+
[symbols.filePath]: filePath,
|
|
66
78
|
id: constConfig.id,
|
|
67
79
|
dependencies: constConfig.dependencies,
|
|
68
80
|
dispose: constConfig.dispose,
|
|
@@ -79,15 +91,24 @@ export function defineResource<
|
|
|
79
91
|
},
|
|
80
92
|
|
|
81
93
|
events: {
|
|
82
|
-
beforeInit:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
beforeInit: {
|
|
95
|
+
...defineEvent({
|
|
96
|
+
id: `${constConfig.id}.events.beforeInit`,
|
|
97
|
+
}),
|
|
98
|
+
[symbols.filePath]: filePath,
|
|
99
|
+
},
|
|
100
|
+
afterInit: {
|
|
101
|
+
...defineEvent({
|
|
102
|
+
id: `${constConfig.id}.events.afterInit`,
|
|
103
|
+
}),
|
|
104
|
+
[symbols.filePath]: filePath,
|
|
105
|
+
},
|
|
106
|
+
onError: {
|
|
107
|
+
...defineEvent({
|
|
108
|
+
id: `${constConfig.id}.events.onError`,
|
|
109
|
+
}),
|
|
110
|
+
[symbols.filePath]: filePath,
|
|
111
|
+
},
|
|
91
112
|
},
|
|
92
113
|
meta: constConfig.meta || {},
|
|
93
114
|
middleware: constConfig.middleware || [],
|
package/src/defs.ts
CHANGED
|
@@ -112,7 +112,9 @@ export interface ITaskDefinition<
|
|
|
112
112
|
listenerOrder?: number;
|
|
113
113
|
meta?: ITaskMeta;
|
|
114
114
|
run: (
|
|
115
|
-
input: TOn extends undefined
|
|
115
|
+
input: TOn extends undefined
|
|
116
|
+
? TInput
|
|
117
|
+
: IEvent<TOn extends "*" ? any : ExtractEventParams<TOn>>,
|
|
116
118
|
// input: TOn extends "*"
|
|
117
119
|
// ? IEvent<any>
|
|
118
120
|
// : TEventDefinitionInput extends null | void
|
package/src/globalEvents.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ILog } from "./models/Logger";
|
|
|
4
4
|
|
|
5
5
|
export const globalEvents = {
|
|
6
6
|
beforeInit: defineEvent({
|
|
7
|
-
id: "global.beforeInit",
|
|
7
|
+
id: "global.events.beforeInit",
|
|
8
8
|
meta: {
|
|
9
9
|
title: "Before Initialization",
|
|
10
10
|
description:
|
|
@@ -13,7 +13,7 @@ export const globalEvents = {
|
|
|
13
13
|
},
|
|
14
14
|
}),
|
|
15
15
|
afterInit: defineEvent({
|
|
16
|
-
id: "global.afterInit",
|
|
16
|
+
id: "global.events.afterInit",
|
|
17
17
|
meta: {
|
|
18
18
|
title: "After Initialization",
|
|
19
19
|
description:
|
|
@@ -22,7 +22,7 @@ export const globalEvents = {
|
|
|
22
22
|
},
|
|
23
23
|
}),
|
|
24
24
|
log: defineEvent<ILog>({
|
|
25
|
-
id: "global.log",
|
|
25
|
+
id: "global.events.log",
|
|
26
26
|
meta: {
|
|
27
27
|
title: "Log Event",
|
|
28
28
|
description: "Used to log events and messages across the system.",
|
|
@@ -34,7 +34,7 @@ export const globalEvents = {
|
|
|
34
34
|
task: ITask<any, any, any>;
|
|
35
35
|
input: any;
|
|
36
36
|
}>({
|
|
37
|
-
id: "global.tasks.beforeRun",
|
|
37
|
+
id: "global.events.tasks.beforeRun",
|
|
38
38
|
meta: {
|
|
39
39
|
title: "Before Task Execution",
|
|
40
40
|
description:
|
|
@@ -47,7 +47,7 @@ export const globalEvents = {
|
|
|
47
47
|
input: any;
|
|
48
48
|
output: any;
|
|
49
49
|
}>({
|
|
50
|
-
id: "global.tasks.afterRun",
|
|
50
|
+
id: "global.events.tasks.afterRun",
|
|
51
51
|
meta: {
|
|
52
52
|
title: "After Task Execution",
|
|
53
53
|
description:
|
|
@@ -60,7 +60,7 @@ export const globalEvents = {
|
|
|
60
60
|
suppress: () => void;
|
|
61
61
|
task: ITask<any, any, any>;
|
|
62
62
|
}>({
|
|
63
|
-
id: "global.tasks.onError",
|
|
63
|
+
id: "global.events.tasks.onError",
|
|
64
64
|
meta: {
|
|
65
65
|
title: "Task Error",
|
|
66
66
|
description:
|
|
@@ -74,7 +74,7 @@ export const globalEvents = {
|
|
|
74
74
|
resource: IResource<any, any, any>;
|
|
75
75
|
config: any;
|
|
76
76
|
}>({
|
|
77
|
-
id: "global.resources.beforeInit",
|
|
77
|
+
id: "global.events.resources.beforeInit",
|
|
78
78
|
meta: {
|
|
79
79
|
title: "Before Resource Initialization",
|
|
80
80
|
description:
|
|
@@ -87,7 +87,7 @@ export const globalEvents = {
|
|
|
87
87
|
config: any;
|
|
88
88
|
value: any;
|
|
89
89
|
}>({
|
|
90
|
-
id: "global.resources.afterInit",
|
|
90
|
+
id: "global.events.resources.afterInit",
|
|
91
91
|
meta: {
|
|
92
92
|
title: "After Resource Initialization",
|
|
93
93
|
description:
|
|
@@ -100,7 +100,7 @@ export const globalEvents = {
|
|
|
100
100
|
suppress: () => void;
|
|
101
101
|
resource: IResource<any, any, any>;
|
|
102
102
|
}>({
|
|
103
|
-
id: "global.resources.onError",
|
|
103
|
+
id: "global.events.resources.onError",
|
|
104
104
|
meta: {
|
|
105
105
|
title: "Resource Error",
|
|
106
106
|
description:
|
package/src/globalResources.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Store } from "./models/Store";
|
|
|
5
5
|
import { TaskRunner } from "./models/TaskRunner";
|
|
6
6
|
|
|
7
7
|
const store = defineResource({
|
|
8
|
-
id: "global.store",
|
|
8
|
+
id: "global.resources.store",
|
|
9
9
|
init: async (store: Store) => store,
|
|
10
10
|
meta: {
|
|
11
11
|
title: "Store",
|
|
@@ -18,7 +18,7 @@ const store = defineResource({
|
|
|
18
18
|
export const globalResources = {
|
|
19
19
|
store,
|
|
20
20
|
eventManager: defineResource({
|
|
21
|
-
id: "global.eventManager",
|
|
21
|
+
id: "global.resources.eventManager",
|
|
22
22
|
init: async (em: EventManager) => em,
|
|
23
23
|
meta: {
|
|
24
24
|
title: "Event Manager",
|
|
@@ -28,7 +28,7 @@ export const globalResources = {
|
|
|
28
28
|
},
|
|
29
29
|
}),
|
|
30
30
|
taskRunner: defineResource({
|
|
31
|
-
id: "global.taskRunner",
|
|
31
|
+
id: "global.resources.taskRunner",
|
|
32
32
|
init: async (runner: TaskRunner) => runner,
|
|
33
33
|
meta: {
|
|
34
34
|
title: "Task Runner",
|
|
@@ -38,7 +38,7 @@ export const globalResources = {
|
|
|
38
38
|
},
|
|
39
39
|
}),
|
|
40
40
|
logger: defineResource({
|
|
41
|
-
id: "global.logger",
|
|
41
|
+
id: "global.resources.logger",
|
|
42
42
|
init: async (logger: Logger) => logger,
|
|
43
43
|
meta: {
|
|
44
44
|
title: "Logger",
|