@gesslar/actioneer 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gesslar/actioneer",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Ready? Set?? ACTION!! pew!pew!pew!pew!",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "scripts": {
23
23
  "lint": "eslint src/",
24
24
  "lint:fix": "eslint src/ --fix",
25
+ "types:build": "tsc -p tsconfig.types.json && eslint --fix \"src/types/**/*.d.ts\"",
25
26
  "submit": "npm publish --access public",
26
27
  "update": "npx npm-check-updates -u && npm install",
27
28
  "test": "node --test tests/unit/*.test.js",
@@ -3,6 +3,37 @@ import {Data, Sass, Valid} from "@gesslar/toolkit"
3
3
  import ActionWrapper from "./ActionWrapper.js"
4
4
 
5
5
  /** @typedef {import("./ActionRunner.js").default} ActionRunner */
6
+ /** @typedef {typeof import("./Activity.js").ACTIVITY} ActivityFlags */
7
+
8
+ /**
9
+ * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
10
+ */
11
+
12
+ /**
13
+ * @typedef {object} ActionBuilderAction
14
+ * @property {(builder: ActionBuilder) => void} setup Function invoked during {@link ActionBuilder#build} to register activities.
15
+ * @property {symbol} [tag] Optional tag to reuse when reconstructing builders.
16
+ */
17
+
18
+ /**
19
+ * @typedef {object} ActionBuilderConfig
20
+ * @property {symbol} [tag] Optional tag for the builder instance.
21
+ * @property {DebugFn} [debug] Logger used by the pipeline internals.
22
+ */
23
+
24
+ /**
25
+ * @typedef {object} ActivityDefinition
26
+ * @property {ActionBuilderAction|null} action Parent action instance when available.
27
+ * @property {DebugFn|null} debug Logger function.
28
+ * @property {string|symbol} name Activity identifier.
29
+ * @property {ActionFunction|import("./ActionWrapper.js").default} op Operation to execute.
30
+ * @property {number} [kind] Optional kind flags from {@link ActivityFlags}.
31
+ * @property {(context: unknown) => boolean|Promise<boolean>} [pred] Loop predicate.
32
+ */
33
+
34
+ /**
35
+ * @typedef {(context: unknown) => unknown|Promise<unknown>} ActionFunction
36
+ */
6
37
 
7
38
  /**
8
39
  * Fluent builder for describing how an action should process the context that
@@ -25,16 +56,20 @@ import ActionWrapper from "./ActionWrapper.js"
25
56
  * @class ActionBuilder
26
57
  */
27
58
  export default class ActionBuilder {
59
+ /** @type {ActionBuilderAction|null} */
28
60
  #action = null
61
+ /** @type {Map<string|symbol, ActivityDefinition>} */
29
62
  #activities = new Map([])
63
+ /** @type {DebugFn|null} */
30
64
  #debug = null
65
+ /** @type {symbol|null} */
31
66
  #tag = null
32
67
 
33
68
  /**
34
69
  * Creates a new ActionBuilder instance with the provided action callback.
35
70
  *
36
- * @param {(ctx: unknown) => unknown} action Base action invoked by the runner when a block satisfies the configured structure.
37
- * @param {{tag?: symbol, debug?: (message: string, level?: number, ...args: Array<unknown>) => void}} [config] Options
71
+ * @param {ActionBuilderAction} [action] Base action invoked by the runner when a block satisfies the configured structure.
72
+ * @param {ActionBuilderConfig} [config] Options
38
73
  */
39
74
  constructor(
40
75
  action,
@@ -52,12 +87,30 @@ export default class ActionBuilder {
52
87
  }
53
88
 
54
89
  /**
55
- * Register an activity.
90
+ * Register an activity that the runner can execute.
56
91
  *
57
92
  * Overloads:
58
93
  * - do(name, op)
59
94
  * - do(name, kind, pred, opOrWrapper)
60
95
  *
96
+ * @overload
97
+ * @param {string|symbol} name Activity name
98
+ * @param {ActionFunction} op Operation to execute once.
99
+ * @returns {ActionBuilder}
100
+ */
101
+
102
+ /**
103
+ * @overload
104
+ * @param {string|symbol} name Activity name
105
+ * @param {number} kind Kind bitfield from {@link ActivityFlags}.
106
+ * @param {(context: unknown) => boolean|Promise<boolean>} pred Predicate executed before/after the op.
107
+ * @param {ActionFunction|import("./ActionWrapper.js").default} op Operation or nested wrapper to execute.
108
+ * @returns {ActionBuilder}
109
+ */
110
+
111
+ /**
112
+ * Handles runtime dispatch across the documented overloads.
113
+ *
61
114
  * @param {string|symbol} name Activity name
62
115
  * @param {...unknown} args See overloads
63
116
  * @returns {ActionBuilder} The builder instance for chaining
@@ -114,7 +167,7 @@ export default class ActionBuilder {
114
167
  * Finalises the builder and returns a payload that can be consumed by the
115
168
  * runner.
116
169
  *
117
- * @returns {{action: (context: unknown) => unknown, build: ActionBuilder}} Payload consumed by the {@link ActionRunner} constructor.
170
+ * @returns {import("./ActionWrapper.js").default} Payload consumed by the {@link ActionRunner} constructor.
118
171
  */
119
172
  build() {
120
173
  const action = this.#action
@@ -1,27 +1,44 @@
1
1
  import {setTimeout as timeout} from "timers/promises"
2
2
  import {FileObject, Sass, Util, Valid} from "@gesslar/toolkit"
3
3
 
4
+ /**
5
+ * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
6
+ */
7
+
8
+ /**
9
+ * @typedef {object} ActionHooksConfig
10
+ * @property {string} actionKind Action identifier shared between runner and hooks.
11
+ * @property {FileObject} hooksFile File handle used to import the hooks module.
12
+ * @property {unknown} [hooks] Already-instantiated hooks implementation (skips loading).
13
+ * @property {number} [hookTimeout] Timeout applied to hook execution in milliseconds.
14
+ * @property {DebugFn} debug Logger to emit diagnostics.
15
+ */
16
+
17
+ /**
18
+ * @typedef {Record<string, (context: unknown) => Promise<unknown>|unknown>} HookModule
19
+ */
20
+
4
21
  /**
5
22
  * Generic base class for managing hooks with configurable event types.
6
23
  * Provides common functionality for hook registration, execution, and lifecycle management.
7
24
  * Designed to be extended by specific implementations.
8
25
  */
9
26
  export default class ActionHooks {
27
+ /** @type {FileObject|null} */
10
28
  #hooksFile = null
29
+ /** @type {HookModule|null} */
11
30
  #hooks = null
31
+ /** @type {string|null} */
12
32
  #actionKind = null
33
+ /** @type {number} */
13
34
  #timeout = 1000 // Default 1 second timeout
35
+ /** @type {DebugFn|null} */
14
36
  #debug = null
15
37
 
16
38
  /**
17
39
  * Creates a new ActionHook instance.
18
40
  *
19
- * @param {object} config - Configuration object
20
- * @param {string} config.actionKind - Action identifier
21
- * @param {FileObject} config.hooksFile - File object containing hooks with uri property
22
- * @param {number} [config.hookTimeout] - Hook execution timeout in milliseconds
23
- * @param {unknown} [config.hooks] - The hooks object
24
- * @param {(message: string, level?: number, ...args: Array<unknown>) => void} config.debug - Debug function from Glog.
41
+ * @param {ActionHooksConfig} config Configuration values describing how to load the hooks.
25
42
  */
26
43
  constructor({actionKind, hooksFile, hooks, hookTimeout = 1000, debug}) {
27
44
  this.#actionKind = actionKind
@@ -90,11 +107,8 @@ export default class ActionHooks {
90
107
  * Loads hooks from the specified file and returns an initialized instance.
91
108
  * Override loadHooks() in subclasses to customize hook loading logic.
92
109
  *
93
- * @param {object} config - Same configuration object as constructor
94
- * @param {string|object} config.actionKind - Action identifier or instance
95
- * @param {FileObject} config.hooksFile - File object containing hooks with uri property
96
- * @param {number} [config.timeOut] - Hook execution timeout in milliseconds
97
- * @param {(message: string, level?: number, ...args: Array<unknown>) => void} debug - The debug function.
110
+ * @param {ActionHooksConfig} config Same configuration object as constructor
111
+ * @param {DebugFn} debug The debug function.
98
112
  * @returns {Promise<ActionHooks|null>} Initialized hook manager or null if no hooks found
99
113
  */
100
114
  static async new(config, debug) {
@@ -138,6 +152,14 @@ export default class ActionHooks {
138
152
  }
139
153
  }
140
154
 
155
+ /**
156
+ * Invoke a dynamically-named hook such as `before$foo`.
157
+ *
158
+ * @param {'before'|'after'|'setup'|'cleanup'|string} kind Hook namespace.
159
+ * @param {string|symbol} activityName Activity identifier.
160
+ * @param {unknown} context Pipeline context supplied to the hook.
161
+ * @returns {Promise<void>}
162
+ */
141
163
  async callHook(kind, activityName, context) {
142
164
  try {
143
165
  const debug = this.#debug
@@ -3,6 +3,18 @@ import {FileObject, Sass, Valid} from "@gesslar/toolkit"
3
3
  import ActionBuilder from "./ActionBuilder.js"
4
4
  import {ACTIVITY} from "./Activity.js"
5
5
  import Piper from "./Piper.js"
6
+
7
+ /** @typedef {import("./ActionHooks.js").default} ActionHooks */
8
+
9
+ /**
10
+ * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
11
+ */
12
+
13
+ /**
14
+ * @typedef {object} ActionRunnerOptions
15
+ * @property {ActionHooks} [hooks] Pre-configured hooks.
16
+ * @property {DebugFn} [debug] Logger function.
17
+ */
6
18
  /**
7
19
  * Orchestrates execution of {@link ActionBuilder}-produced pipelines.
8
20
  *
@@ -11,13 +23,49 @@ import Piper from "./Piper.js"
11
23
  * context object under `result.value` that can be replaced or enriched.
12
24
  */
13
25
  export default class ActionRunner extends Piper {
26
+ /**
27
+ * Pipeline produced by the builder.
28
+ *
29
+ * @type {import("./ActionWrapper.js").default|null}
30
+ */
14
31
  #actionWrapper = null
15
- #debug = null
32
+ /**
33
+ * Logger invoked for diagnostics.
34
+ *
35
+ * @type {DebugFn}
36
+ */
37
+ #debug = () => {}
38
+ /**
39
+ * Filesystem path to a hooks module.
40
+ *
41
+ * @type {string|null}
42
+ */
16
43
  #hooksPath = null
44
+ /**
45
+ * Constructor name exported by the hooks module.
46
+ *
47
+ * @type {string|null}
48
+ */
17
49
  #hooksClassName = null
50
+ /**
51
+ * Lazily instantiated hooks implementation.
52
+ *
53
+ * @type {ActionHooks|null}
54
+ */
18
55
  #hooks = null
56
+ /**
57
+ * Unique tag for log correlation.
58
+ *
59
+ * @type {symbol|null}
60
+ */
19
61
  #tag = null
20
62
 
63
+ /**
64
+ * Instantiate a runner over an optional action wrapper.
65
+ *
66
+ * @param {import("./ActionWrapper.js").default|null} wrappedAction Output of {@link ActionBuilder#build}.
67
+ * @param {ActionRunnerOptions} [options] Optional hooks/debug overrides.
68
+ */
21
69
  constructor(wrappedAction, {hooks,debug=(() => {})} = {}) {
22
70
  super({debug})
23
71
 
@@ -106,6 +154,14 @@ export default class ActionRunner extends Piper {
106
154
  return context
107
155
  }
108
156
 
157
+ /**
158
+ * Execute a single activity, recursing into nested action wrappers when needed.
159
+ *
160
+ * @param {import("./Activity.js").default} activity Pipeline activity descriptor.
161
+ * @param {unknown} context Current pipeline context.
162
+ * @returns {Promise<unknown>} Resolved activity result.
163
+ * @private
164
+ */
109
165
  async #executeActivity(activity, context) {
110
166
  // What kind of op are we looking at? Is it a function?
111
167
  // Or a class instance of type ActionWrapper?
@@ -125,6 +181,15 @@ export default class ActionRunner extends Piper {
125
181
  throw Sass.new("We buy Functions and ActionWrappers. Only. Not whatever that was.")
126
182
  }
127
183
 
184
+ /**
185
+ * Evaluate the predicate for WHILE/UNTIL activity kinds.
186
+ *
187
+ * @param {import("./Activity.js").default} activity Activity currently executing.
188
+ * @param {(context: unknown) => boolean|Promise<boolean>} predicate Predicate to evaluate.
189
+ * @param {unknown} context Current pipeline context.
190
+ * @returns {Promise<boolean>} True when the predicate allows another iteration.
191
+ * @private
192
+ */
128
193
  async #predicateCheck(activity,predicate,context) {
129
194
  Valid.type(predicate, "Function")
130
195
 
@@ -135,6 +200,13 @@ export default class ActionRunner extends Piper {
135
200
  return `[object ${this.constructor.name}]`
136
201
  }
137
202
 
203
+ /**
204
+ * Configure hooks to be lazily loaded when the pipeline runs.
205
+ *
206
+ * @param {string} hooksPath Absolute path to the module exporting the hooks class.
207
+ * @param {string} className Constructor to instantiate from the hooks module.
208
+ * @returns {this} Runner instance for chaining.
209
+ */
138
210
  setHooks(hooksPath, className) {
139
211
  this.#hooksPath = hooksPath
140
212
  this.#hooksClassName = className
@@ -144,6 +216,12 @@ export default class ActionRunner extends Piper {
144
216
  return this
145
217
  }
146
218
 
219
+ /**
220
+ * Import and instantiate the configured hooks module.
221
+ *
222
+ * @returns {Promise<null|void>} Null when hooks are disabled, otherwise void.
223
+ * @private
224
+ */
147
225
  async #loadHooks() {
148
226
  if(!this.#hooksPath)
149
227
  return null
@@ -1,9 +1,41 @@
1
1
  import Activity from "./Activity.js"
2
2
 
3
+ /**
4
+ * @typedef {object} WrappedActivityConfig
5
+ * @property {string|symbol} name Activity identifier used by hooks/logs.
6
+ * @property {(context: unknown) => unknown|Promise<unknown>|ActionWrapper} op Operation or nested wrapper to execute.
7
+ * @property {number} [kind] Optional loop semantic flags.
8
+ * @property {(context: unknown) => boolean|Promise<boolean>} [pred] Predicate tied to WHILE/UNTIL semantics.
9
+ * @property {unknown} [action] Parent action instance supplied when invoking the op.
10
+ * @property {(message: string, level?: number, ...args: Array<unknown>) => void} [debug] Optional logger reference.
11
+ */
12
+
13
+ /**
14
+ * @typedef {Generator<Activity, void, unknown>} ActivityIterator
15
+ */
16
+
17
+ /**
18
+ * Thin wrapper that materialises {@link Activity} instances on demand.
19
+ */
3
20
  export default class ActionWrapper {
21
+ /**
22
+ * Registry of activities supplied by the builder.
23
+ *
24
+ * @type {Map<string|symbol, WrappedActivityConfig>}
25
+ */
4
26
  #activities = new Map()
5
- #debug = null
27
+ /**
28
+ * Logger invoked for wrapper lifecycle events.
29
+ *
30
+ * @type {(message: string, level?: number, ...args: Array<unknown>) => void}
31
+ */
32
+ #debug = () => {}
6
33
 
34
+ /**
35
+ * Create a wrapper from the builder payload.
36
+ *
37
+ * @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
38
+ */
7
39
  constructor({activities,debug}) {
8
40
  this.#debug = debug
9
41
  this.#activities = activities
@@ -15,13 +47,15 @@ export default class ActionWrapper {
15
47
  }
16
48
 
17
49
  *#_activities() {
18
- for(const [_,activity] of this.#activities) {
19
- const result = new Activity(activity)
20
-
21
- yield result
22
- }
50
+ for(const [,activity] of this.#activities)
51
+ yield new Activity(activity)
23
52
  }
24
53
 
54
+ /**
55
+ * Iterator over the registered activities.
56
+ *
57
+ * @returns {ActivityIterator} Lazy iterator yielding Activity instances.
58
+ */
25
59
  get activities() {
26
60
  return this.#_activities()
27
61
  }
@@ -1,6 +1,7 @@
1
- export {default as ActionBuilder} from './ActionBuilder'
2
- export {default as ActionHooks} from './ActionHooks'
3
- export {default as ActionRunner} from './ActionRunner'
4
- export {default as ActionWrapper} from './ActionWrapper'
5
- export {default as Activity, ACTIVITY} from './Activity'
6
- export {default as Piper} from './Piper'
1
+ export { default as ActionBuilder } from './lib/ActionBuilder.js'
2
+ export { default as ActionHooks } from './lib/ActionHooks.js'
3
+ export { default as ActionRunner } from './lib/ActionRunner.js'
4
+ export { default as ActionWrapper } from './lib/ActionWrapper.js'
5
+ export { default as Piper } from './lib/Piper.js'
6
+ export { default as Activity, ACTIVITY } from './lib/Activity.js'
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":""}
@@ -0,0 +1,137 @@
1
+ /** @typedef {import("./ActionRunner.js").default} ActionRunner */
2
+ /** @typedef {typeof import("./Activity.js").ACTIVITY} ActivityFlags */
3
+ /**
4
+ * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
5
+ */
6
+ /**
7
+ * @typedef {object} ActionBuilderAction
8
+ * @property {(builder: ActionBuilder) => void} setup Function invoked during {@link ActionBuilder#build} to register activities.
9
+ * @property {symbol} [tag] Optional tag to reuse when reconstructing builders.
10
+ */
11
+ /**
12
+ * @typedef {object} ActionBuilderConfig
13
+ * @property {symbol} [tag] Optional tag for the builder instance.
14
+ * @property {DebugFn} [debug] Logger used by the pipeline internals.
15
+ */
16
+ /**
17
+ * @typedef {object} ActivityDefinition
18
+ * @property {ActionBuilderAction|null} action Parent action instance when available.
19
+ * @property {DebugFn|null} debug Logger function.
20
+ * @property {string|symbol} name Activity identifier.
21
+ * @property {ActionFunction|import("./ActionWrapper.js").default} op Operation to execute.
22
+ * @property {number} [kind] Optional kind flags from {@link ActivityFlags}.
23
+ * @property {(context: unknown) => boolean|Promise<boolean>} [pred] Loop predicate.
24
+ */
25
+ /**
26
+ * @typedef {(context: unknown) => unknown|Promise<unknown>} ActionFunction
27
+ */
28
+ /**
29
+ * Fluent builder for describing how an action should process the context that
30
+ * flows through the {@link ActionRunner}. Consumers register named activities,
31
+ * optional hook pairs, and nested parallel pipelines before handing the
32
+ * builder back to the runner for execution.
33
+ *
34
+ * Typical usage:
35
+ *
36
+ * ```js
37
+ * const pipeline = new ActionBuilder(myAction)
38
+ * .act("prepare", ACTIVITY.ONCE, ctx => ctx.initialise())
39
+ * .parallel(parallel => parallel
40
+ * .act("step", ACTIVITY.MANY, ctx => ctx.consume())
41
+ * )
42
+ * .act("finalise", ACTIVITY.ONCE, ctx => ctx.complete())
43
+ * .build()
44
+ * ```
45
+ *
46
+ * @class ActionBuilder
47
+ */
48
+ export default class ActionBuilder {
49
+ /**
50
+ * Creates a new ActionBuilder instance with the provided action callback.
51
+ *
52
+ * @param {ActionBuilderAction} [action] Base action invoked by the runner when a block satisfies the configured structure.
53
+ * @param {ActionBuilderConfig} [config] Options
54
+ */
55
+ constructor(action?: ActionBuilderAction, { tag, debug }?: ActionBuilderConfig)
56
+ /**
57
+ * Register an activity that the runner can execute.
58
+ *
59
+ * Overloads:
60
+ * - do(name, op)
61
+ * - do(name, kind, pred, opOrWrapper)
62
+ *
63
+ * @overload
64
+ * @param {string|symbol} name Activity name
65
+ * @param {ActionFunction} op Operation to execute once.
66
+ * @returns {ActionBuilder}
67
+ */
68
+ do(name: string | symbol, op: ActionFunction): ActionBuilder
69
+ /**
70
+ * @overload
71
+ * @param {string|symbol} name Activity name
72
+ * @param {number} kind Kind bitfield from {@link ActivityFlags}.
73
+ * @param {(context: unknown) => boolean|Promise<boolean>} pred Predicate executed before/after the op.
74
+ * @param {ActionFunction|import("./ActionWrapper.js").default} op Operation or nested wrapper to execute.
75
+ * @returns {ActionBuilder}
76
+ */
77
+ do(name: string | symbol, kind: number, pred: (context: unknown) => boolean | Promise<boolean>, op: ActionFunction | import('./ActionWrapper.js').default): ActionBuilder
78
+ /**
79
+ * Finalises the builder and returns a payload that can be consumed by the
80
+ * runner.
81
+ *
82
+ * @returns {import("./ActionWrapper.js").default} Payload consumed by the {@link ActionRunner} constructor.
83
+ */
84
+ build(): import('./ActionWrapper.js').default
85
+ #private
86
+ }
87
+ export type ActionRunner = import('./ActionRunner.js').default
88
+ export type ActivityFlags = typeof import('./Activity.js').ACTIVITY
89
+ export type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
90
+ export type ActionBuilderAction = {
91
+ /**
92
+ * Function invoked during {@link ActionBuilder#build} to register activities.
93
+ */
94
+ setup: (builder: ActionBuilder) => void;
95
+ /**
96
+ * Optional tag to reuse when reconstructing builders.
97
+ */
98
+ tag?: symbol | undefined;
99
+ }
100
+ export type ActionBuilderConfig = {
101
+ /**
102
+ * Optional tag for the builder instance.
103
+ */
104
+ tag?: symbol | undefined;
105
+ /**
106
+ * Logger used by the pipeline internals.
107
+ */
108
+ debug?: DebugFn | undefined;
109
+ }
110
+ export type ActivityDefinition = {
111
+ /**
112
+ * Parent action instance when available.
113
+ */
114
+ action: ActionBuilderAction | null;
115
+ /**
116
+ * Logger function.
117
+ */
118
+ debug: DebugFn | null;
119
+ /**
120
+ * Activity identifier.
121
+ */
122
+ name: string | symbol;
123
+ /**
124
+ * Operation to execute.
125
+ */
126
+ op: ActionFunction | import('./ActionWrapper.js').default;
127
+ /**
128
+ * Optional kind flags from {@link ActivityFlags}.
129
+ */
130
+ kind?: number | undefined;
131
+ /**
132
+ * Loop predicate.
133
+ */
134
+ pred?: ((context: unknown) => boolean | Promise<boolean>) | undefined;
135
+ }
136
+ export type ActionFunction = (context: unknown) => unknown | Promise<unknown>
137
+ //# sourceMappingURL=ActionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionBuilder.d.ts","sourceRoot":"","sources":["../../lib/ActionBuilder.js"],"names":[],"mappings":"AAIA,kEAAkE;AAClE,uEAAuE;AAEvE;;GAEG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAUE;;;;;OAKG;IACH,qBAHW,mBAAmB,mBACnB,mBAAmB,EAe7B;;;;;;;;;;;;;IASE,SACQ,MAAM,GAAC,MAAM,MACb,cAAc,GACZ,aAAa,CACzB;;;;;;;;;IAGE,SACQ,MAAM,GAAC,MAAM,QACb,MAAM,QACN,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,MAC9C,cAAc,GAAC,OAAO,oBAAoB,EAAE,OAAO,GACjD,aAAa,CACzB;IAyDD;;;;;OAKG;IACH,SAFa,OAAO,oBAAoB,EAAE,OAAO,CAehD;;CACF;2BArLa,OAAO,mBAAmB,EAAE,OAAO;4BACnC,cAAc,eAAe,EAAE,QAAQ;sBAGxC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;;;;WAKjE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;YAYhC,mBAAmB,GAAC,IAAI;;;;WACxB,OAAO,GAAC,IAAI;;;;UACZ,MAAM,GAAC,MAAM;;;;QACb,cAAc,GAAC,OAAO,oBAAoB,EAAE,OAAO;;;;;;;;sBAEzC,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;;6BAI/C,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
3
+ */
4
+ /**
5
+ * @typedef {object} ActionHooksConfig
6
+ * @property {string} actionKind Action identifier shared between runner and hooks.
7
+ * @property {FileObject} hooksFile File handle used to import the hooks module.
8
+ * @property {unknown} [hooks] Already-instantiated hooks implementation (skips loading).
9
+ * @property {number} [hookTimeout] Timeout applied to hook execution in milliseconds.
10
+ * @property {DebugFn} debug Logger to emit diagnostics.
11
+ */
12
+ /**
13
+ * @typedef {Record<string, (context: unknown) => Promise<unknown>|unknown>} HookModule
14
+ */
15
+ /**
16
+ * Generic base class for managing hooks with configurable event types.
17
+ * Provides common functionality for hook registration, execution, and lifecycle management.
18
+ * Designed to be extended by specific implementations.
19
+ */
20
+ export default class ActionHooks {
21
+ /**
22
+ * Static factory method to create and initialize a hook manager.
23
+ * Loads hooks from the specified file and returns an initialized instance.
24
+ * Override loadHooks() in subclasses to customize hook loading logic.
25
+ *
26
+ * @param {ActionHooksConfig} config Same configuration object as constructor
27
+ * @param {DebugFn} debug The debug function.
28
+ * @returns {Promise<ActionHooks|null>} Initialized hook manager or null if no hooks found
29
+ */
30
+ static 'new'(config: ActionHooksConfig, debug: DebugFn): Promise<ActionHooks | null>
31
+ /**
32
+ * Creates a new ActionHook instance.
33
+ *
34
+ * @param {ActionHooksConfig} config Configuration values describing how to load the hooks.
35
+ */
36
+ constructor({ actionKind, hooksFile, hooks, hookTimeout, debug }: ActionHooksConfig)
37
+ /**
38
+ * Gets the action identifier.
39
+ *
40
+ * @returns {string} Action identifier or instance
41
+ */
42
+ get actionKind(): string
43
+ /**
44
+ * Gets the hooks file object.
45
+ *
46
+ * @returns {FileObject} File object containing hooks
47
+ */
48
+ get hooksFile(): FileObject
49
+ /**
50
+ * Gets the loaded hooks object.
51
+ *
52
+ * @returns {object|null} Hooks object or null if not loaded
53
+ */
54
+ get hooks(): object | null
55
+ /**
56
+ * Gets the hook execution timeout in milliseconds.
57
+ *
58
+ * @returns {number} Timeout in milliseconds
59
+ */
60
+ get timeout(): number
61
+ /**
62
+ * Gets the setup hook function if available.
63
+ *
64
+ * @returns {(args: object) => unknown|null} Setup hook function or null
65
+ */
66
+ get setup(): (args: object) => unknown | null
67
+ /**
68
+ * Gets the cleanup hook function if available.
69
+ *
70
+ * @returns {(args: object) => unknown|null} Cleanup hook function or null
71
+ */
72
+ get cleanup(): (args: object) => unknown | null
73
+ /**
74
+ * Invoke a dynamically-named hook such as `before$foo`.
75
+ *
76
+ * @param {'before'|'after'|'setup'|'cleanup'|string} kind Hook namespace.
77
+ * @param {string|symbol} activityName Activity identifier.
78
+ * @param {unknown} context Pipeline context supplied to the hook.
79
+ * @returns {Promise<void>}
80
+ */
81
+ callHook(kind: 'before' | 'after' | 'setup' | 'cleanup' | string, activityName: string | symbol, context: unknown): Promise<void>
82
+ #private
83
+ }
84
+ export type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
85
+ export type ActionHooksConfig = {
86
+ /**
87
+ * Action identifier shared between runner and hooks.
88
+ */
89
+ actionKind: string;
90
+ /**
91
+ * File handle used to import the hooks module.
92
+ */
93
+ hooksFile: FileObject;
94
+ /**
95
+ * Already-instantiated hooks implementation (skips loading).
96
+ */
97
+ hooks?: unknown;
98
+ /**
99
+ * Timeout applied to hook execution in milliseconds.
100
+ */
101
+ hookTimeout?: number | undefined;
102
+ /**
103
+ * Logger to emit diagnostics.
104
+ */
105
+ debug: DebugFn;
106
+ }
107
+ export type HookModule = Record<string, (context: unknown) => Promise<unknown> | unknown>
108
+ import { FileObject } from '@gesslar/toolkit'
109
+ //# sourceMappingURL=ActionHooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionHooks.d.ts","sourceRoot":"","sources":["../../lib/ActionHooks.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AAEH;;;;GAIG;AACH;IA+EE;;;;;;;;OAQG;IACH,qBAJW,iBAAiB,SACjB,OAAO,GACL,OAAO,CAAC,WAAW,GAAC,IAAI,CAAC,CAyCrC;IAnHD;;;;OAIG;IACH,kEAFW,iBAAiB,EAQ3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,UAAU,CAItB;IAED;;;;OAIG;IACH,aAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;OAIG;IACH,eAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,aAFa,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAC,IAAI,CAI1C;IAED;;;;OAIG;IACH,eAFa,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAC,IAAI,CAI1C;IAoDD;;;;;;;OAOG;IACH,eALW,QAAQ,GAAC,OAAO,GAAC,OAAO,GAAC,SAAS,GAAC,MAAM,gBACzC,MAAM,GAAC,MAAM,WACb,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CAoDzB;;CACF;sBAjNY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;;;;gBAKjE,MAAM;;;;eACN,UAAU;;;;YACV,OAAO;;;;;;;;WAEP,OAAO;;yBAIR,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAC,OAAO,CAAC;2BAhB/B,kBAAkB"}
@@ -0,0 +1,57 @@
1
+ /** @typedef {import("./ActionHooks.js").default} ActionHooks */
2
+ /**
3
+ * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
4
+ */
5
+ /**
6
+ * @typedef {object} ActionRunnerOptions
7
+ * @property {ActionHooks} [hooks] Pre-configured hooks.
8
+ * @property {DebugFn} [debug] Logger function.
9
+ */
10
+ /**
11
+ * Orchestrates execution of {@link ActionBuilder}-produced pipelines.
12
+ *
13
+ * Activities run in insertion order, with support for once-off work, repeated
14
+ * loops, and nested parallel pipelines. Each activity receives a mutable
15
+ * context object under `result.value` that can be replaced or enriched.
16
+ */
17
+ export default class ActionRunner extends Piper {
18
+ /**
19
+ * Instantiate a runner over an optional action wrapper.
20
+ *
21
+ * @param {import("./ActionWrapper.js").default|null} wrappedAction Output of {@link ActionBuilder#build}.
22
+ * @param {ActionRunnerOptions} [options] Optional hooks/debug overrides.
23
+ */
24
+ constructor(wrappedAction: import('./ActionWrapper.js').default | null, { hooks, debug }?: ActionRunnerOptions)
25
+ /**
26
+ * Executes the configured action pipeline.
27
+ *
28
+ * @param {unknown} context - Seed value passed to the first activity.
29
+ * @param {boolean} asIs - When true, do not wrap context in {value} (internal nested runners)
30
+ * @returns {Promise<unknown>} Final value produced by the pipeline, or null when a parallel stage reports failures.
31
+ * @throws {Sass} When no activities are registered or required parallel builders are missing.
32
+ */
33
+ run(context: unknown, asIs?: boolean): Promise<unknown>
34
+ /**
35
+ * Configure hooks to be lazily loaded when the pipeline runs.
36
+ *
37
+ * @param {string} hooksPath Absolute path to the module exporting the hooks class.
38
+ * @param {string} className Constructor to instantiate from the hooks module.
39
+ * @returns {this} Runner instance for chaining.
40
+ */
41
+ setHooks(hooksPath: string, className: string): this
42
+ #private
43
+ }
44
+ export type ActionHooks = import('./ActionHooks.js').default
45
+ export type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
46
+ export type ActionRunnerOptions = {
47
+ /**
48
+ * Pre-configured hooks.
49
+ */
50
+ hooks?: import('./ActionHooks.js').default | undefined;
51
+ /**
52
+ * Logger function.
53
+ */
54
+ debug?: DebugFn | undefined;
55
+ }
56
+ import Piper from './Piper.js'
57
+ //# sourceMappingURL=ActionRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionRunner.d.ts","sourceRoot":"","sources":["../../lib/ActionRunner.js"],"names":[],"mappings":"AAMA,gEAAgE;AAEhE;;GAEG;AAEH;;;;GAIG;AACH;;;;;;GAMG;AACH;IAsCE;;;;;OAKG;IACH,2BAHW,OAAO,oBAAoB,EAAE,OAAO,GAAC,IAAI,qBACzC,mBAAmB,EAuB7B;IAED;;;;;;;OAOG;IACH,aALW,OAAO,SACP,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,CA0D5B;IAgDD;;;;;;OAMG;IACH,oBAJW,MAAM,aACN,MAAM,GACJ,IAAI,CAShB;;CA2BF;0BA7Oa,OAAO,kBAAkB,EAAE,OAAO;sBAGnC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;;;;;;;;;;kBAL7D,YAAY"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @typedef {object} WrappedActivityConfig
3
+ * @property {string|symbol} name Activity identifier used by hooks/logs.
4
+ * @property {(context: unknown) => unknown|Promise<unknown>|ActionWrapper} op Operation or nested wrapper to execute.
5
+ * @property {number} [kind] Optional loop semantic flags.
6
+ * @property {(context: unknown) => boolean|Promise<boolean>} [pred] Predicate tied to WHILE/UNTIL semantics.
7
+ * @property {unknown} [action] Parent action instance supplied when invoking the op.
8
+ * @property {(message: string, level?: number, ...args: Array<unknown>) => void} [debug] Optional logger reference.
9
+ */
10
+ /**
11
+ * @typedef {Generator<Activity, void, unknown>} ActivityIterator
12
+ */
13
+ /**
14
+ * Thin wrapper that materialises {@link Activity} instances on demand.
15
+ */
16
+ export default class ActionWrapper {
17
+ /**
18
+ * Create a wrapper from the builder payload.
19
+ *
20
+ * @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
21
+ */
22
+ constructor({ activities, debug }: {
23
+ activities: Map<string | symbol, WrappedActivityConfig>;
24
+ debug: (message: string, level?: number, ...args: Array<unknown>) => void;
25
+ })
26
+ /**
27
+ * Iterator over the registered activities.
28
+ *
29
+ * @returns {ActivityIterator} Lazy iterator yielding Activity instances.
30
+ */
31
+ get activities(): ActivityIterator
32
+ #private
33
+ }
34
+ export type WrappedActivityConfig = {
35
+ /**
36
+ * Activity identifier used by hooks/logs.
37
+ */
38
+ name: string | symbol;
39
+ /**
40
+ * Operation or nested wrapper to execute.
41
+ */
42
+ op: (context: unknown) => unknown | Promise<unknown> | ActionWrapper;
43
+ /**
44
+ * Optional loop semantic flags.
45
+ */
46
+ kind?: number | undefined;
47
+ /**
48
+ * Predicate tied to WHILE/UNTIL semantics.
49
+ */
50
+ pred?: ((context: unknown) => boolean | Promise<boolean>) | undefined;
51
+ /**
52
+ * Parent action instance supplied when invoking the op.
53
+ */
54
+ action?: unknown;
55
+ /**
56
+ * Optional logger reference.
57
+ */
58
+ debug?: ((message: string, level?: number, ...args: Array<unknown>) => void) | undefined;
59
+ }
60
+ export type ActivityIterator = Generator<Activity, void, unknown>
61
+ import Activity from './Activity.js'
62
+ //# sourceMappingURL=ActionWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionWrapper.d.ts","sourceRoot":"","sources":["../../lib/ActionWrapper.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;GAEG;AACH;IAcE;;;;OAIG;IACH,mCAFW;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,EAU5I;IAOD;;;;OAIG;IACH,kBAFa,gBAAgB,CAI5B;;CACF;;;;;UAzDa,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,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC;qBAb1B,eAAe"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Activity bit flags recognised by the builder. The flag decides
3
+ * loop semantics for an activity.
4
+ */
5
+ export type ACTIVITY = number
6
+ /**
7
+ * Activity bit flags recognised by the builder. The flag decides
8
+ * loop semantics for an activity.
9
+ *
10
+ * @readonly
11
+ * @enum {number}
12
+ */
13
+ export const ACTIVITY: Readonly<{
14
+ WHILE: number;
15
+ UNTIL: number;
16
+ }>
17
+ export default class Activity {
18
+ /**
19
+ * Construct an Activity definition wrapper.
20
+ *
21
+ * @param {{action: unknown, name: string, op: (context: unknown) => unknown|Promise<unknown>|unknown, kind?: number, pred?: (context: unknown) => boolean|Promise<boolean>}} init - Initial properties describing the activity operation, loop semantics, and predicate
22
+ */
23
+ constructor({ action, name, op, kind, pred }: {
24
+ action: unknown;
25
+ name: string;
26
+ op: (context: unknown) => unknown | Promise<unknown> | unknown;
27
+ kind?: number;
28
+ pred?: (context: unknown) => boolean | Promise<boolean>;
29
+ })
30
+ /**
31
+ * The activity name.
32
+ *
33
+ * @returns {string} - Activity identifier
34
+ */
35
+ get name(): string
36
+ /**
37
+ * Bitflag kind for loop semantics.
38
+ *
39
+ * @returns {number|null} - Combined flags (e.g., WHILE or UNTIL)
40
+ */
41
+ get kind(): number | null
42
+ /**
43
+ * The predicate function for WHILE/UNTIL flows.
44
+ *
45
+ * @returns {(context: unknown) => boolean|Promise<boolean>|undefined} - Predicate used to continue/stop loops
46
+ */
47
+ get pred(): (context: unknown) => boolean | Promise<boolean> | undefined
48
+ /**
49
+ * The operator kind name (Function or ActionWrapper).
50
+ *
51
+ * @returns {string} - Kind name extracted via Data.typeOf
52
+ */
53
+ get opKind(): string
54
+ /**
55
+ * The operator to execute (function or nested wrapper).
56
+ *
57
+ * @returns {unknown} - Activity operation
58
+ */
59
+ get op(): unknown
60
+ /**
61
+ * The action instance this activity belongs to.
62
+ *
63
+ * @returns {unknown} - Bound action instance
64
+ */
65
+ get action(): unknown
66
+ /**
67
+ * Execute the activity with before/after hooks.
68
+ *
69
+ * @param {unknown} context - Mutable context flowing through the pipeline
70
+ * @returns {Promise<{activityResult: unknown}>} - Activity result wrapper with new context
71
+ */
72
+ run(context: unknown): Promise<{
73
+ activityResult: unknown;
74
+ }>
75
+ /**
76
+ * Attach hooks to this activity instance.
77
+ *
78
+ * @param {unknown} hooks - Hooks instance with optional before$/after$ methods
79
+ * @returns {this} - This activity for chaining
80
+ */
81
+ setActionHooks(hooks: unknown): this
82
+ #private
83
+ }
84
+ //# sourceMappingURL=Activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Activity.d.ts","sourceRoot":"","sources":["../../lib/Activity.js"],"names":[],"mappings":";;;;uBAOU,MAAM;AALhB;;;;;;GAMG;AACH;;;GAGE;AAEF;IAQE;;;;OAIG;IACH,8CAFW;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,CAAA;KAAC,EAQ3K;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,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,UAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,aAHW,OAAO,GACL,OAAO,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAC,CAAC,CAkB9C;IAED;;;;;OAKG;IACH,sBAHW,OAAO,GACL,IAAI,CAOhB;;CACF"}
@@ -0,0 +1,48 @@
1
+ export default class Piper {
2
+ /**
3
+ * Create a Piper instance.
4
+ *
5
+ * @param {{debug?: (message: string, level?: number, ...args: Array<unknown>) => void}} [config] Optional configuration with debug function
6
+ */
7
+ constructor({ debug }?: {
8
+ debug?: (message: string, level?: number, ...args: Array<unknown>) => void;
9
+ })
10
+ /**
11
+ * Add a processing step to the pipeline
12
+ *
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
16
+ * @returns {Piper} The pipeline instance (for chaining)
17
+ */
18
+ addStep(fn: (context: unknown) => Promise<unknown> | unknown, options?: {
19
+ name?: string;
20
+ required?: boolean;
21
+ }, newThis?: unknown): Piper
22
+ /**
23
+ * Add setup hook that runs before processing starts.
24
+ *
25
+ * @param {() => Promise<void>|void} fn - Setup function executed before processing
26
+ * @param {unknown} [thisArg] - Optional this binding for the setup function
27
+ * @returns {Piper} - The pipeline instance
28
+ */
29
+ addSetup(fn: () => Promise<void> | void, thisArg?: unknown): Piper
30
+ /**
31
+ * Add cleanup hook that runs after processing completes
32
+ *
33
+ * @param {() => Promise<void>|void} fn - Cleanup function executed after processing
34
+ * @param {unknown} [thisArg] - Optional this binding for the cleanup function
35
+ * @returns {Piper} - The pipeline instance
36
+ */
37
+ addCleanup(fn: () => Promise<void> | void, thisArg?: unknown): Piper
38
+ /**
39
+ * Process items through the pipeline with concurrency control
40
+ *
41
+ * @param {Array<unknown>|unknown} items - Items to process
42
+ * @param {number} maxConcurrent - Maximum concurrent items to process
43
+ * @returns {Promise<Array<unknown>>} - Collected results from steps
44
+ */
45
+ pipe(items: Array<unknown> | unknown, maxConcurrent?: number): Promise<Array<unknown>>
46
+ #private
47
+ }
48
+ //# sourceMappingURL=Piper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Piper.d.ts","sourceRoot":"","sources":["../../lib/Piper.js"],"names":[],"mappings":"AAaA;IASE;;;;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,EAItF;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,OAAO,CAAC,CAAC,CAmDnC;;CAyCF"}
@@ -1,32 +0,0 @@
1
- import type ActionWrapper from './ActionWrapper'
2
-
3
- declare type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
4
- import type { ActionFunction } from './ActionWrapper'
5
-
6
- declare class ActionBuilder {
7
- /**
8
- * @param action An object with a `setup(builder)` method or undefined for an empty builder
9
- */
10
- constructor(
11
- action?: { setup?: (builder: ActionBuilder) => void } | unknown,
12
- config?: { tag?: symbol, debug?: DebugFn }
13
- )
14
-
15
- // Overload: once-off activity
16
- do(name: string | symbol, op: ActionFunction): this
17
-
18
- // Overload: controlled activity with kind, predicate and op (function or nested ActionWrapper)
19
- do(
20
- name: string | symbol,
21
- kind: number,
22
- pred: (context: unknown) => Promise<boolean>,
23
- op: ActionFunction | ActionWrapper
24
- ): this
25
-
26
- // Generic fallback
27
- do(name: string | symbol, ...args: Array<unknown>): this
28
-
29
- build(): ActionWrapper
30
- }
31
-
32
- export default ActionBuilder
@@ -1,24 +0,0 @@
1
- declare type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
2
-
3
- declare class ActionHooks {
4
- constructor(config: {
5
- actionKind: unknown,
6
- hooksFile: unknown,
7
- hooks?: unknown,
8
- hookTimeout?: number,
9
- debug?: DebugFn
10
- })
11
- static new(
12
- config: { actionKind: unknown, hooksFile: unknown, timeOut?: number },
13
- debug?: DebugFn
14
- ): Promise<ActionHooks | null>
15
- callHook(kind: string, activityName: string, context: unknown): Promise<void>
16
- get actionKind(): unknown
17
- get hooksFile(): unknown
18
- get hooks(): unknown | null
19
- get timeout(): number
20
- get setup(): ((args: object) => unknown) | null
21
- get cleanup(): ((args: object) => unknown) | null
22
- }
23
-
24
- export default ActionHooks
@@ -1,18 +0,0 @@
1
- import Piper from './Piper'
2
-
3
- declare type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
4
-
5
- declare class ActionRunner extends Piper {
6
- constructor(wrappedAction?: unknown, config?: { hooks?: unknown, debug?: DebugFn })
7
-
8
- /**
9
- * Execute the pipeline. When asIs is true, the context is not wrapped in {value}.
10
- */
11
- run(context: unknown, asIs?: boolean): Promise<unknown>
12
-
13
- setHooks(hooksPath: string, className: string): this
14
-
15
- toString(): string
16
- }
17
-
18
- export default ActionRunner
@@ -1,27 +0,0 @@
1
- import type Activity from './Activity'
2
-
3
- /** Operation function signature used by activities */
4
- export type ActionFunction = (context: unknown) => unknown | Promise<unknown>
5
-
6
- import type { ActionFunction as _AF } from './ActionBuilder'
7
-
8
- declare type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
9
-
10
- declare class ActionWrapper {
11
- constructor(config: {
12
- activities: Map<unknown, {
13
- name: string,
14
- /** operation: either a function(context) or a nested ActionWrapper */
15
- op: ActionFunction | ActionWrapper,
16
- kind?: number,
17
- /** predicate used for WHILE/UNTIL, returns Promise<boolean> */
18
- pred?: (context: unknown) => Promise<boolean>,
19
- action?: unknown,
20
- debug?: DebugFn
21
- }>,
22
- debug?: DebugFn
23
- })
24
- get activities(): IterableIterator<Activity>
25
- }
26
-
27
- export default ActionWrapper
@@ -1,21 +0,0 @@
1
- export const ACTIVITY: { WHILE: number; UNTIL: number }
2
-
3
- declare class Activity {
4
- constructor(init: {
5
- action: unknown,
6
- name: string,
7
- op: (context: unknown) => unknown | Promise<unknown> | unknown,
8
- kind?: number,
9
- pred?: (context: unknown) => Promise<boolean>
10
- })
11
- get name(): string
12
- get kind(): number | null
13
- get pred(): ((context: unknown) => boolean | Promise<boolean>) | undefined
14
- get opKind(): string
15
- get op(): unknown
16
- get action(): unknown
17
- run(context: unknown): Promise<{ activityResult: unknown }>
18
- setActionHooks(hooks: unknown): this
19
- }
20
-
21
- export default Activity
@@ -1,15 +0,0 @@
1
- declare type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
2
-
3
- declare class Piper {
4
- constructor(config?: { debug?: DebugFn })
5
- addStep(
6
- fn: (context: unknown) => Promise<unknown> | unknown,
7
- options?: { name?: string, required?: boolean },
8
- newThis?: unknown
9
- ): this
10
- addSetup(fn: () => Promise<void> | void, thisArg?: unknown): this
11
- addCleanup(fn: () => Promise<void> | void, thisArg?: unknown): this
12
- pipe(items: Array<unknown> | unknown, maxConcurrent?: number): Promise<Array<unknown>>
13
- }
14
-
15
- export default Piper