@gesslar/actioneer 2.0.2 → 2.2.0
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 +5 -5
- package/src/browser/lib/ActionBuilder.js +44 -7
- package/src/browser/lib/ActionRunner.js +139 -90
- package/src/browser/lib/ActionWrapper.js +52 -8
- package/src/browser/lib/Activity.js +39 -8
- package/src/browser/lib/Piper.js +2 -2
- package/src/lib/ActionHooks.js +8 -0
- package/src/types/browser/lib/ActionBuilder.d.ts +24 -8
- package/src/types/browser/lib/ActionBuilder.d.ts.map +1 -1
- package/src/types/browser/lib/ActionRunner.d.ts +7 -2
- package/src/types/browser/lib/ActionRunner.d.ts.map +1 -1
- package/src/types/browser/lib/ActionWrapper.d.ts +24 -5
- package/src/types/browser/lib/ActionWrapper.d.ts.map +1 -1
- package/src/types/browser/lib/Activity.d.ts +29 -8
- package/src/types/browser/lib/Activity.d.ts.map +1 -1
- package/src/types/lib/ActionBuilder.d.ts +7 -0
- package/src/types/lib/ActionHooks.d.ts +25 -1
- package/src/types/lib/ActionHooks.d.ts.map +1 -1
- package/src/types/lib/ActionWrapper.d.ts +7 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @property {(message: string, level?: number, ...args: Array<unknown>) => void} [debug] Optional logger reference.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* @typedef {Generator<Activity, void, unknown>} ActivityIterator
|
|
11
|
+
* @typedef {import("@gesslar/toolkit").Generator<Activity, void, unknown>} ActivityIterator
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* Thin wrapper that materialises {@link Activity} instances on demand.
|
|
@@ -19,16 +19,35 @@ export default class ActionWrapper {
|
|
|
19
19
|
*
|
|
20
20
|
* @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
|
|
21
21
|
*/
|
|
22
|
-
constructor({ activities, hooks, debug }: {
|
|
22
|
+
constructor({ activities, hooks, debug, done: doneCallback, action }: {
|
|
23
23
|
activities: Map<string | symbol, WrappedActivityConfig>;
|
|
24
24
|
debug: (message: string, level?: number, ...args: Array<unknown>) => void;
|
|
25
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* Unique identifier for this wrapper instance.
|
|
28
|
+
* Used by BREAK/CONTINUE to match events to the correct loop.
|
|
29
|
+
*
|
|
30
|
+
* @returns {symbol} Unique symbol identifier
|
|
31
|
+
*/
|
|
32
|
+
get id(): symbol;
|
|
26
33
|
/**
|
|
27
34
|
* Iterator over the registered activities.
|
|
28
35
|
*
|
|
29
|
-
* @returns {
|
|
36
|
+
* @returns {Iterator<Activity>} Iterator yielding Activity instances.
|
|
37
|
+
*/
|
|
38
|
+
get activities(): Iterator<Activity>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the done callback if registered.
|
|
41
|
+
*
|
|
42
|
+
* @returns {((context: unknown) => unknown|Promise<unknown>)|null} Done callback or null.
|
|
43
|
+
*/
|
|
44
|
+
get done(): ((context: unknown) => unknown | Promise<unknown>) | null;
|
|
45
|
+
/**
|
|
46
|
+
* Get the action instance.
|
|
47
|
+
*
|
|
48
|
+
* @returns {unknown|null} Action instance or null.
|
|
30
49
|
*/
|
|
31
|
-
get
|
|
50
|
+
get action(): unknown | null;
|
|
32
51
|
#private;
|
|
33
52
|
}
|
|
34
53
|
export type WrappedActivityConfig = {
|
|
@@ -57,6 +76,6 @@ export type WrappedActivityConfig = {
|
|
|
57
76
|
*/
|
|
58
77
|
debug?: ((message: string, level?: number, ...args: Array<unknown>) => void) | undefined;
|
|
59
78
|
};
|
|
60
|
-
export type ActivityIterator = Generator<Activity, void, unknown>;
|
|
79
|
+
export type ActivityIterator = import("@gesslar/toolkit").Generator<Activity, void, unknown>;
|
|
61
80
|
import Activity from "./Activity.js";
|
|
62
81
|
//# sourceMappingURL=ActionWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionWrapper.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionWrapper.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;GAEG;AACH;
|
|
1
|
+
{"version":3,"file":"ActionWrapper.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionWrapper.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;GAEG;AACH;IAwBE;;;;OAIG;IACH,sEAFW;QAAC,UAAU,EAAE,GAAG,CAAC,MAAM,GAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;QAAC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;KAAC,EAwB5I;IAED;;;;;OAKG;IACH,UAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,kBAFa,QAAQ,CAAC,QAAQ,CAAC,CAI9B;IAED;;;;OAIG;IACH,YAFa,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAC,IAAI,CAIjE;IAED;;;;OAIG;IACH,cAFa,OAAO,GAAC,IAAI,CAIxB;;CACF;;;;;UAxGa,MAAM,GAAC,MAAM;;;;QACb,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,aAAa;;;;;;;;sBAElD,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;;;;aAC9C,OAAO;;;;uBACG,MAAM,UAAU,MAAM,WAAW,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;+BAInE,OAAO,kBAAkB,EAAE,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC;qBAbrD,eAAe"}
|
|
@@ -9,14 +9,20 @@ export type ACTIVITY = number;
|
|
|
9
9
|
*
|
|
10
10
|
* @readonly
|
|
11
11
|
* @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
|
|
12
|
+
* @property {number} WHILE - Execute activity while predicate returns true 1
|
|
13
|
+
* @property {number} UNTIL - Execute activity until predicate returns true 2
|
|
14
|
+
* @property {number} SPLIT - Execute activity with split/rejoin pattern for parallel execution 3
|
|
15
|
+
* @property {number} IF - Execute activity if predicate returns true 4
|
|
16
|
+
* @property {number} BREAK - Break out of a WHILE/UNTIL if predicate returns true 5
|
|
17
|
+
* @property {number} CONTINUE - Returns to the top of a WHILE/UNTIL if predicate returns true 6
|
|
15
18
|
*/
|
|
16
19
|
export const ACTIVITY: Readonly<{
|
|
17
|
-
WHILE:
|
|
18
|
-
UNTIL:
|
|
19
|
-
SPLIT:
|
|
20
|
+
WHILE: 1;
|
|
21
|
+
UNTIL: 2;
|
|
22
|
+
SPLIT: 3;
|
|
23
|
+
IF: 4;
|
|
24
|
+
BREAK: 5;
|
|
25
|
+
CONTINUE: 6;
|
|
20
26
|
}>;
|
|
21
27
|
export default class Activity {
|
|
22
28
|
/**
|
|
@@ -31,8 +37,9 @@ export default class Activity {
|
|
|
31
37
|
* @param {ActionHooks} [init.hooks] - Optional hooks instance
|
|
32
38
|
* @param {(context: unknown) => unknown} [init.splitter] - Optional splitter function for SPLIT activities
|
|
33
39
|
* @param {(originalContext: unknown, splitResults: unknown) => unknown} [init.rejoiner] - Optional rejoiner function for SPLIT activities
|
|
40
|
+
* @param {import("./ActionWrapper.js").default} [init.wrapper] - Optional wrapper containing this activity
|
|
34
41
|
*/
|
|
35
|
-
constructor({ action, name, op, kind, pred, hooks, splitter, rejoiner }: {
|
|
42
|
+
constructor({ action, name, op, kind, pred, hooks, splitter, rejoiner, wrapper }: {
|
|
36
43
|
action: unknown;
|
|
37
44
|
name: string | symbol;
|
|
38
45
|
op: (context: unknown) => unknown | Promise<unknown> | import("./ActionBuilder.js").default;
|
|
@@ -41,7 +48,14 @@ export default class Activity {
|
|
|
41
48
|
hooks?: import("./ActionHooks.js").default | undefined;
|
|
42
49
|
splitter?: ((context: unknown) => unknown) | undefined;
|
|
43
50
|
rejoiner?: ((originalContext: unknown, splitResults: unknown) => unknown) | undefined;
|
|
51
|
+
wrapper?: import("./ActionWrapper.js").default | undefined;
|
|
44
52
|
});
|
|
53
|
+
/**
|
|
54
|
+
* Unique identifier for this activity instance.
|
|
55
|
+
*
|
|
56
|
+
* @returns {symbol} Unique symbol identifier
|
|
57
|
+
*/
|
|
58
|
+
get id(): symbol;
|
|
45
59
|
/**
|
|
46
60
|
* The activity name.
|
|
47
61
|
*
|
|
@@ -55,7 +69,7 @@ export default class Activity {
|
|
|
55
69
|
*/
|
|
56
70
|
get kind(): number | null;
|
|
57
71
|
/**
|
|
58
|
-
* The predicate function for WHILE/UNTIL flows.
|
|
72
|
+
* The predicate function for WHILE/UNTIL/IF flows.
|
|
59
73
|
*
|
|
60
74
|
* @returns {(context: unknown) => boolean|Promise<boolean>|undefined} - Predicate used to continue/stop loops
|
|
61
75
|
*/
|
|
@@ -96,6 +110,13 @@ export default class Activity {
|
|
|
96
110
|
* @returns {unknown} - Bound action instance
|
|
97
111
|
*/
|
|
98
112
|
get action(): unknown;
|
|
113
|
+
/**
|
|
114
|
+
* Get the ActionWrapper containing this activity.
|
|
115
|
+
* Used by BREAK/CONTINUE to signal the parent loop.
|
|
116
|
+
*
|
|
117
|
+
* @returns {import("./ActionWrapper.js").default|null} The wrapper or null
|
|
118
|
+
*/
|
|
119
|
+
get wrapper(): import("./ActionWrapper.js").default | null;
|
|
99
120
|
/**
|
|
100
121
|
* Execute the activity with before/after hooks.
|
|
101
122
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Activity.d.ts","sourceRoot":"","sources":["../../../browser/lib/Activity.js"],"names":[],"mappings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E,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,GAAC,IAAI,CAI/E;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAFa,OAAO,oBAAoB,EAAE,OAAO,GAAC,IAAI,CAIrD;IAED;;;;;OAKG;IACH,aAHW,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,CAa5B;IAED;;;;;OAKG;IACH,sBAHW,WAAW,GACT,IAAI,CAOhB;IAED;;;;OAIG;IACH,aAFa,WAAW,GAAC,IAAI,CAI5B;;CACF;0BAtNa,OAAO,kBAAkB,EAAE,OAAO"}
|
|
@@ -112,6 +112,13 @@ export default class ActionBuilder {
|
|
|
112
112
|
* @returns {ActionBuilder} The builder instance for chaining.
|
|
113
113
|
*/
|
|
114
114
|
withAction(action: ActionBuilderAction): ActionBuilder
|
|
115
|
+
/**
|
|
116
|
+
* Register a callback to be executed after all activities complete.
|
|
117
|
+
*
|
|
118
|
+
* @param {ActionFunction} callback Function to execute at the end of the pipeline.
|
|
119
|
+
* @returns {ActionBuilder} The builder instance for chaining.
|
|
120
|
+
*/
|
|
121
|
+
done(callback: ActionFunction): ActionBuilder
|
|
115
122
|
/**
|
|
116
123
|
* Finalises the builder and returns a payload that can be consumed by the
|
|
117
124
|
* runner.
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* Inherits all browser functionality and adds FileObject-based hook import capability.
|
|
15
15
|
*/
|
|
16
16
|
export default class ActionHooks extends BrowserActionHooks {
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} ActionHooksConfig
|
|
19
|
+
* @property {string} [hooksFile] Path to the hooks file
|
|
20
|
+
* @property {string} [hooksKind] Name of the hooks class to instantiate
|
|
21
|
+
* @property {object} [hooks] Pre-instantiated hooks object
|
|
22
|
+
* @property {number} [timeout] Timeout for hook execution
|
|
23
|
+
*/
|
|
17
24
|
/**
|
|
18
25
|
* Static factory method to create and initialize a hook manager.
|
|
19
26
|
* Loads hooks from the specified file and returns an initialized instance.
|
|
@@ -23,7 +30,24 @@ export default class ActionHooks extends BrowserActionHooks {
|
|
|
23
30
|
* @param {DebugFn} debug The debug function.
|
|
24
31
|
* @returns {Promise<ActionHooks|null>} Initialized hook manager or null if no hooks found
|
|
25
32
|
*/
|
|
26
|
-
static "new"(config:
|
|
33
|
+
static "new"(config: {
|
|
34
|
+
/**
|
|
35
|
+
* Path to the hooks file
|
|
36
|
+
*/
|
|
37
|
+
hooksFile?: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Name of the hooks class to instantiate
|
|
40
|
+
*/
|
|
41
|
+
hooksKind?: string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Pre-instantiated hooks object
|
|
44
|
+
*/
|
|
45
|
+
hooks?: object | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Timeout for hook execution
|
|
48
|
+
*/
|
|
49
|
+
timeout?: number | undefined;
|
|
50
|
+
}, debug: DebugFn): Promise<ActionHooks | null>;
|
|
27
51
|
/**
|
|
28
52
|
* Creates a new ActionHook instance.
|
|
29
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionHooks.d.ts","sourceRoot":"","sources":["../../lib/ActionHooks.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AACH;IAuBE;;;;;;;;OAQG;IACH,
|
|
1
|
+
{"version":3,"file":"ActionHooks.d.ts","sourceRoot":"","sources":["../../lib/ActionHooks.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AACH;IAuBE;;;;;;OAMG;IAEH;;;;;;;;OAQG;IACH;;;;;;;;;;;;;;;;;cAHW,OAAO,GACL,OAAO,CAAC,WAAW,GAAC,IAAI,CAAC,CAgDrC;IAlFD;;;;OAIG;IACH,kEAFW,qBAAqB,EAK/B;IAED;;;;OAIG;IACH,iBAFa,UAAU,CAItB;;CAmEF;sBAxGY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;;;;gBAKjE,MAAM;;;;;;;;YAEN,OAAO;;;;;;;;WAEP,OAAO;;kDAZ2B,qBAAqB;2BADtC,kBAAkB"}
|
|
@@ -19,7 +19,7 @@ export default class ActionWrapper {
|
|
|
19
19
|
*
|
|
20
20
|
* @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
|
|
21
21
|
*/
|
|
22
|
-
constructor({ activities, hooks, debug }: {
|
|
22
|
+
constructor({ activities, hooks, debug, done: doneCallback }: {
|
|
23
23
|
activities: Map<string | symbol, WrappedActivityConfig>;
|
|
24
24
|
debug: (message: string, level?: number, ...args: Array<unknown>) => void;
|
|
25
25
|
})
|
|
@@ -29,6 +29,12 @@ export default class ActionWrapper {
|
|
|
29
29
|
* @returns {ActivityIterator} Lazy iterator yielding Activity instances.
|
|
30
30
|
*/
|
|
31
31
|
get activities(): ActivityIterator
|
|
32
|
+
/**
|
|
33
|
+
* Get the done callback if registered.
|
|
34
|
+
*
|
|
35
|
+
* @returns {((context: unknown) => unknown|Promise<unknown>)|null} Done callback or null.
|
|
36
|
+
*/
|
|
37
|
+
get done(): ((context: unknown) => unknown | Promise<unknown>) | null
|
|
32
38
|
#private
|
|
33
39
|
}
|
|
34
40
|
export type WrappedActivityConfig = {
|