@gesslar/actioneer 2.1.0 → 2.3.1
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 +212 -13
- package/package.json +4 -4
- package/src/browser/lib/ActionBuilder.js +91 -59
- package/src/browser/lib/ActionHooks.js +19 -21
- package/src/browser/lib/ActionRunner.js +104 -65
- package/src/browser/lib/ActionWrapper.js +37 -12
- package/src/browser/lib/Activity.js +52 -17
- package/src/browser/lib/Piper.js +37 -17
- package/src/types/browser/lib/ActionBuilder.d.ts +82 -60
- package/src/types/browser/lib/ActionBuilder.d.ts.map +1 -1
- package/src/types/browser/lib/ActionHooks.d.ts +24 -25
- package/src/types/browser/lib/ActionHooks.d.ts.map +1 -1
- package/src/types/browser/lib/ActionRunner.d.ts +10 -7
- package/src/types/browser/lib/ActionRunner.d.ts.map +1 -1
- package/src/types/browser/lib/ActionWrapper.d.ts +22 -7
- package/src/types/browser/lib/ActionWrapper.d.ts.map +1 -1
- package/src/types/browser/lib/Activity.d.ts +45 -18
- package/src/types/browser/lib/Activity.d.ts.map +1 -1
- package/src/types/browser/lib/Piper.d.ts +7 -5
- package/src/types/browser/lib/Piper.d.ts.map +1 -1
|
@@ -2,21 +2,31 @@
|
|
|
2
2
|
* *
|
|
3
3
|
*/
|
|
4
4
|
export type ACTIVITY = number;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* @import {default as ActionBuilder} from "./ActionBuilder.js"
|
|
7
|
+
* @import {default as ActionHooks} from "./ActionHooks.js"
|
|
8
|
+
* @import {default as ActionWrapper} from "./ActionWrapper.js"
|
|
9
|
+
**/
|
|
6
10
|
/**
|
|
7
11
|
* Activity bit flags recognised by the builder. The flag decides
|
|
8
12
|
* loop semantics for an activity.
|
|
9
13
|
*
|
|
10
14
|
* @readonly
|
|
11
15
|
* @enum {number}
|
|
12
|
-
* @property {number} WHILE - Execute activity while predicate returns true
|
|
13
|
-
* @property {number} UNTIL - Execute activity until predicate returns true
|
|
14
|
-
* @property {number} SPLIT - Execute activity with split/rejoin pattern for parallel execution
|
|
16
|
+
* @property {number} WHILE - Execute activity while predicate returns true 1
|
|
17
|
+
* @property {number} UNTIL - Execute activity until predicate returns true 2
|
|
18
|
+
* @property {number} SPLIT - Execute activity with split/rejoin pattern for parallel execution 3
|
|
19
|
+
* @property {number} IF - Execute activity if predicate returns true 4
|
|
20
|
+
* @property {number} BREAK - Break out of a WHILE/UNTIL if predicate returns true 5
|
|
21
|
+
* @property {number} CONTINUE - Returns to the top of a WHILE/UNTIL if predicate returns true 6
|
|
15
22
|
*/
|
|
16
23
|
export const ACTIVITY: Readonly<{
|
|
17
|
-
WHILE:
|
|
18
|
-
UNTIL:
|
|
19
|
-
SPLIT:
|
|
24
|
+
WHILE: 1;
|
|
25
|
+
UNTIL: 2;
|
|
26
|
+
SPLIT: 3;
|
|
27
|
+
IF: 4;
|
|
28
|
+
BREAK: 5;
|
|
29
|
+
CONTINUE: 6;
|
|
20
30
|
}>;
|
|
21
31
|
export default class Activity {
|
|
22
32
|
/**
|
|
@@ -25,23 +35,31 @@ export default class Activity {
|
|
|
25
35
|
* @param {object} init - Initial properties describing the activity operation, loop semantics, and predicate
|
|
26
36
|
* @param {unknown} init.action - Parent action instance
|
|
27
37
|
* @param {string|symbol} init.name - Activity identifier
|
|
28
|
-
* @param {(context: unknown) => unknown|Promise<unknown>|
|
|
38
|
+
* @param {(context: unknown) => unknown|Promise<unknown>|ActionBuilder} init.op - Operation to execute
|
|
29
39
|
* @param {number} [init.kind] - Optional loop semantics flags
|
|
30
40
|
* @param {(context: unknown) => boolean|Promise<boolean>} [init.pred] - Optional predicate for WHILE/UNTIL
|
|
31
41
|
* @param {ActionHooks} [init.hooks] - Optional hooks instance
|
|
32
42
|
* @param {(context: unknown) => unknown} [init.splitter] - Optional splitter function for SPLIT activities
|
|
33
43
|
* @param {(originalContext: unknown, splitResults: unknown) => unknown} [init.rejoiner] - Optional rejoiner function for SPLIT activities
|
|
44
|
+
* @param {ActionWrapper} [init.wrapper] - Optional wrapper containing this activity
|
|
34
45
|
*/
|
|
35
|
-
constructor({ action, name, op, kind, pred, hooks, splitter, rejoiner }: {
|
|
46
|
+
constructor({ action, name, op, kind, pred, hooks, splitter, rejoiner, wrapper }: {
|
|
36
47
|
action: unknown;
|
|
37
48
|
name: string | symbol;
|
|
38
|
-
op: (context: unknown) => unknown | Promise<unknown> |
|
|
49
|
+
op: (context: unknown) => unknown | Promise<unknown> | ActionBuilder;
|
|
39
50
|
kind?: number | undefined;
|
|
40
51
|
pred?: ((context: unknown) => boolean | Promise<boolean>) | undefined;
|
|
41
|
-
hooks?:
|
|
52
|
+
hooks?: ActionHooks | undefined;
|
|
42
53
|
splitter?: ((context: unknown) => unknown) | undefined;
|
|
43
54
|
rejoiner?: ((originalContext: unknown, splitResults: unknown) => unknown) | undefined;
|
|
55
|
+
wrapper?: ActionWrapper | undefined;
|
|
44
56
|
});
|
|
57
|
+
/**
|
|
58
|
+
* Unique identifier for this activity instance.
|
|
59
|
+
*
|
|
60
|
+
* @returns {symbol} Unique symbol identifier
|
|
61
|
+
*/
|
|
62
|
+
get id(): symbol;
|
|
45
63
|
/**
|
|
46
64
|
* The activity name.
|
|
47
65
|
*
|
|
@@ -55,7 +73,7 @@ export default class Activity {
|
|
|
55
73
|
*/
|
|
56
74
|
get kind(): number | null;
|
|
57
75
|
/**
|
|
58
|
-
* The predicate function for WHILE/UNTIL flows.
|
|
76
|
+
* The predicate function for WHILE/UNTIL/IF flows.
|
|
59
77
|
*
|
|
60
78
|
* @returns {(context: unknown) => boolean|Promise<boolean>|undefined} - Predicate used to continue/stop loops
|
|
61
79
|
*/
|
|
@@ -75,19 +93,19 @@ export default class Activity {
|
|
|
75
93
|
/**
|
|
76
94
|
* The operator to execute (function or nested ActionBuilder).
|
|
77
95
|
*
|
|
78
|
-
* @returns {(context: unknown) => unknown|Promise<unknown>|
|
|
96
|
+
* @returns {(context: unknown) => unknown|Promise<unknown>|ActionBuilder} - Activity operation
|
|
79
97
|
*/
|
|
80
|
-
get op(): (context: unknown) => unknown | Promise<unknown> |
|
|
98
|
+
get op(): (context: unknown) => unknown | Promise<unknown> | ActionBuilder;
|
|
81
99
|
/**
|
|
82
100
|
* The splitter function for SPLIT activities.
|
|
83
101
|
*
|
|
84
|
-
* @returns {((context: unknown) => unknown)
|
|
102
|
+
* @returns {((context: unknown) => unknown)?} Splitter function or null
|
|
85
103
|
*/
|
|
86
104
|
get splitter(): ((context: unknown) => unknown) | null;
|
|
87
105
|
/**
|
|
88
106
|
* The rejoiner function for SPLIT activities.
|
|
89
107
|
*
|
|
90
|
-
* @returns {((originalContext: unknown, splitResults: unknown) => unknown)
|
|
108
|
+
* @returns {((originalContext: unknown, splitResults: unknown) => unknown)?} Rejoiner function or null
|
|
91
109
|
*/
|
|
92
110
|
get rejoiner(): ((originalContext: unknown, splitResults: unknown) => unknown) | null;
|
|
93
111
|
/**
|
|
@@ -96,6 +114,13 @@ export default class Activity {
|
|
|
96
114
|
* @returns {unknown} - Bound action instance
|
|
97
115
|
*/
|
|
98
116
|
get action(): unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Get the ActionWrapper containing this activity.
|
|
119
|
+
* Used by BREAK/CONTINUE to signal the parent loop.
|
|
120
|
+
*
|
|
121
|
+
* @returns {ActionWrapper?} The wrapper or null
|
|
122
|
+
*/
|
|
123
|
+
get wrapper(): ActionWrapper | null;
|
|
99
124
|
/**
|
|
100
125
|
* Execute the activity with before/after hooks.
|
|
101
126
|
*
|
|
@@ -113,10 +138,12 @@ export default class Activity {
|
|
|
113
138
|
/**
|
|
114
139
|
* Get the hooks instance attached to this activity.
|
|
115
140
|
*
|
|
116
|
-
* @returns {ActionHooks
|
|
141
|
+
* @returns {ActionHooks?} The hooks instance or null
|
|
117
142
|
*/
|
|
118
143
|
get hooks(): ActionHooks | null;
|
|
119
144
|
#private;
|
|
120
145
|
}
|
|
121
|
-
|
|
146
|
+
import type { default as ActionBuilder } from "./ActionBuilder.js";
|
|
147
|
+
import type { default as ActionWrapper } from "./ActionWrapper.js";
|
|
148
|
+
import type { default as ActionHooks } from "./ActionHooks.js";
|
|
122
149
|
//# sourceMappingURL=Activity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Activity.d.ts","sourceRoot":"","sources":["../../../browser/lib/Activity.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Activity.d.ts","sourceRoot":"","sources":["../../../browser/lib/Activity.js"],"names":[],"mappings":";;;uBAaU,MAAM;AAXhB;;;;IAII;AAEJ;;;;;;;;;;;;GAYG;AACH;;;;;;;GAOE;AAEF;IAwBE;;;;;;;;;;;;;OAaG;IACH,kFAVG;QAAsB,MAAM,EAApB,OAAO;QACa,IAAI,EAAxB,MAAM,GAAC,MAAM;QACsD,EAAE,EAArE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,aAAa;QAC9C,IAAI;QACoC,IAAI,cAAhD,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;QAC3B,KAAK;QACa,QAAQ,cAAnC,OAAO,KAAK,OAAO;QACuC,QAAQ,sBAA1D,OAAO,gBAAgB,OAAO,KAAK,OAAO;QACvC,OAAO;KACtC,EAWA;IAED;;;;OAIG;IACH,UAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;OAIG;IACH,YAFa,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,SAAS,CAIpE;IAED;;;;OAIG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,UAFa,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,aAAa,CAIxE;IAED;;;;OAIG;IACH,gBAFa,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAC,CAI5C;IAED;;;;OAIG;IACH,gBAFa,CAAC,CAAC,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,OAAC,CAI3E;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAFa,aAAa,OAAC,CAI1B;IAED;;;;;OAKG;IACH,aAHW,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,CAa5B;IAED;;;;;OAKG;IACH,sBAHW,WAAW,GACT,IAAI,CAOhB;IAED;;;;OAIG;IACH,aAFa,WAAW,OAAC,CAIxB;;CACF;8CAzN0C,oBAAoB;8CAEpB,oBAAoB;4CADtB,kBAAkB"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
export default class Piper {
|
|
1
|
+
export default class Piper extends NotifyClass {
|
|
2
2
|
/**
|
|
3
3
|
* Create a Piper instance.
|
|
4
4
|
*
|
|
5
|
-
* @param {{debug?: (message: string, level?: number, ...args: Array<unknown>) => void}} [config] Optional configuration with debug function
|
|
5
|
+
* @param {{debug?: (message: string, level?: number, ...args: Array<unknown>) => void}} [config] - Optional configuration with debug function
|
|
6
6
|
*/
|
|
7
7
|
constructor({ debug }?: {
|
|
8
8
|
debug?: (message: string, level?: number, ...args: Array<unknown>) => void;
|
|
9
9
|
});
|
|
10
|
+
get reason(): any;
|
|
10
11
|
/**
|
|
11
12
|
* Add a processing step to the pipeline
|
|
12
13
|
*
|
|
13
|
-
* @param {(context: unknown) => Promise<unknown>|unknown} fn Function that processes an item
|
|
14
|
-
* @param {{name?: string, required?: boolean}} [options] Step options
|
|
15
|
-
* @param {unknown} [newThis] Optional this binding
|
|
14
|
+
* @param {(context: unknown) => Promise<unknown>|unknown} fn - Function that processes an item
|
|
15
|
+
* @param {{name?: string, required?: boolean}} [options] - Step options
|
|
16
|
+
* @param {unknown} [newThis] - Optional this binding
|
|
16
17
|
* @returns {Piper} The pipeline instance (for chaining)
|
|
17
18
|
*/
|
|
18
19
|
addStep(fn: (context: unknown) => Promise<unknown> | unknown, options?: {
|
|
@@ -49,4 +50,5 @@ export default class Piper {
|
|
|
49
50
|
}>>;
|
|
50
51
|
#private;
|
|
51
52
|
}
|
|
53
|
+
import { NotifyClass } from "@gesslar/toolkit";
|
|
52
54
|
//# sourceMappingURL=Piper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Piper.d.ts","sourceRoot":"","sources":["../../../browser/lib/Piper.js"],"names":[],"mappings":"AAaA;
|
|
1
|
+
{"version":3,"file":"Piper.d.ts","sourceRoot":"","sources":["../../../browser/lib/Piper.js"],"names":[],"mappings":"AAaA;IAWE;;;;OAIG;IACH,wBAFW;QAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;KAAC,EAUtF;IAMD,kBAEC;IAED;;;;;;;OAOG;IACH,YALW,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAC,OAAO,YAC9C;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,YACnC,OAAO,GACL,KAAK,CAWjB;IAED;;;;;;OAMG;IACH,aAJW,MAAM,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI,YACxB,OAAO,GACL,KAAK,CAMjB;IAED;;;;;;OAMG;IACH,eAJW,MAAM,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI,YACxB,OAAO,GACL,KAAK,CAMjB;IAED;;;;;;OAMG;IACH,YAJW,KAAK,CAAC,OAAO,CAAC,GAAC,OAAO,kBACtB,MAAM,GACJ,OAAO,CAAC,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC,CAAC,CA6D/E;;CAuCF;4BA1LkE,kBAAkB"}
|