@gesslar/actioneer 0.1.0 → 0.1.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/package.json +2 -1
- package/src/lib/ActionBuilder.js +57 -4
- package/src/lib/ActionHooks.js +33 -11
- package/src/lib/ActionRunner.js +81 -11
- package/src/lib/ActionWrapper.js +40 -6
- package/src/lib/Activity.js +1 -1
- package/src/lib/Piper.js +4 -6
- package/src/types/index.d.ts +7 -6
- package/src/types/index.d.ts.map +1 -0
- package/src/types/lib/ActionBuilder.d.ts +137 -0
- package/src/types/lib/ActionBuilder.d.ts.map +1 -0
- package/src/types/lib/ActionHooks.d.ts +109 -0
- package/src/types/lib/ActionHooks.d.ts.map +1 -0
- package/src/types/lib/ActionRunner.d.ts +56 -0
- package/src/types/lib/ActionRunner.d.ts.map +1 -0
- package/src/types/lib/ActionWrapper.d.ts +62 -0
- package/src/types/lib/ActionWrapper.d.ts.map +1 -0
- package/src/types/lib/Activity.d.ts +84 -0
- package/src/types/lib/Activity.d.ts.map +1 -0
- package/src/types/lib/Piper.d.ts +48 -0
- package/src/types/lib/Piper.d.ts.map +1 -0
- package/src/types/ActionBuilder.d.ts +0 -32
- package/src/types/ActionHooks.d.ts +0 -24
- package/src/types/ActionRunner.d.ts +0 -18
- package/src/types/ActionWrapper.d.ts +0 -27
- package/src/types/Activity.d.ts +0 -21
- package/src/types/Piper.d.ts +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/actioneer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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",
|
package/src/lib/ActionBuilder.js
CHANGED
|
@@ -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 {
|
|
37
|
-
* @param {
|
|
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 {
|
|
170
|
+
* @returns {import("./ActionWrapper.js").default} Payload consumed by the {@link ActionRunner} constructor.
|
|
118
171
|
*/
|
|
119
172
|
build() {
|
|
120
173
|
const action = this.#action
|
package/src/lib/ActionHooks.js
CHANGED
|
@@ -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 {
|
|
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 {
|
|
94
|
-
* @param {
|
|
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
|
package/src/lib/ActionRunner.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
|
@@ -45,20 +93,14 @@ export default class ActionRunner extends Piper {
|
|
|
45
93
|
* Executes the configured action pipeline.
|
|
46
94
|
*
|
|
47
95
|
* @param {unknown} context - Seed value passed to the first activity.
|
|
48
|
-
* @param {boolean} asIs - When true, do not wrap context in {value} (internal nested runners)
|
|
49
96
|
* @returns {Promise<unknown>} Final value produced by the pipeline, or null when a parallel stage reports failures.
|
|
50
97
|
* @throws {Sass} When no activities are registered or required parallel builders are missing.
|
|
51
98
|
*/
|
|
52
|
-
async run(context
|
|
99
|
+
async run(context) {
|
|
53
100
|
this.#debug(this.#tag.description)
|
|
54
101
|
const actionWrapper = this.#actionWrapper
|
|
55
102
|
const activities = actionWrapper.activities
|
|
56
103
|
|
|
57
|
-
if(!asIs)
|
|
58
|
-
context = {value: context}
|
|
59
|
-
|
|
60
|
-
context
|
|
61
|
-
|
|
62
104
|
for(const activity of activities) {
|
|
63
105
|
activity.setActionHooks(this.#hooks)
|
|
64
106
|
|
|
@@ -89,7 +131,6 @@ export default class ActionRunner extends Piper {
|
|
|
89
131
|
break
|
|
90
132
|
|
|
91
133
|
context = await this.#executeActivity(activity,context)
|
|
92
|
-
context
|
|
93
134
|
|
|
94
135
|
if(kindUntil)
|
|
95
136
|
if(!await this.#predicateCheck(activity,pred,context))
|
|
@@ -97,7 +138,6 @@ export default class ActionRunner extends Piper {
|
|
|
97
138
|
}
|
|
98
139
|
} else {
|
|
99
140
|
context = await this.#executeActivity(activity, context)
|
|
100
|
-
context
|
|
101
141
|
}
|
|
102
142
|
}
|
|
103
143
|
|
|
@@ -106,6 +146,14 @@ export default class ActionRunner extends Piper {
|
|
|
106
146
|
return context
|
|
107
147
|
}
|
|
108
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Execute a single activity, recursing into nested action wrappers when needed.
|
|
151
|
+
*
|
|
152
|
+
* @param {import("./Activity.js").default} activity Pipeline activity descriptor.
|
|
153
|
+
* @param {unknown} context Current pipeline context.
|
|
154
|
+
* @returns {Promise<unknown>} Resolved activity result.
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
109
157
|
async #executeActivity(activity, context) {
|
|
110
158
|
// What kind of op are we looking at? Is it a function?
|
|
111
159
|
// Or a class instance of type ActionWrapper?
|
|
@@ -119,12 +167,21 @@ export default class ActionRunner extends Piper {
|
|
|
119
167
|
|
|
120
168
|
return await runner.run(context, true)
|
|
121
169
|
} else if(opKind === "Function") {
|
|
122
|
-
return
|
|
170
|
+
return await activity.run(context)
|
|
123
171
|
}
|
|
124
172
|
|
|
125
173
|
throw Sass.new("We buy Functions and ActionWrappers. Only. Not whatever that was.")
|
|
126
174
|
}
|
|
127
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Evaluate the predicate for WHILE/UNTIL activity kinds.
|
|
178
|
+
*
|
|
179
|
+
* @param {import("./Activity.js").default} activity Activity currently executing.
|
|
180
|
+
* @param {(context: unknown) => boolean|Promise<boolean>} predicate Predicate to evaluate.
|
|
181
|
+
* @param {unknown} context Current pipeline context.
|
|
182
|
+
* @returns {Promise<boolean>} True when the predicate allows another iteration.
|
|
183
|
+
* @private
|
|
184
|
+
*/
|
|
128
185
|
async #predicateCheck(activity,predicate,context) {
|
|
129
186
|
Valid.type(predicate, "Function")
|
|
130
187
|
|
|
@@ -135,6 +192,13 @@ export default class ActionRunner extends Piper {
|
|
|
135
192
|
return `[object ${this.constructor.name}]`
|
|
136
193
|
}
|
|
137
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Configure hooks to be lazily loaded when the pipeline runs.
|
|
197
|
+
*
|
|
198
|
+
* @param {string} hooksPath Absolute path to the module exporting the hooks class.
|
|
199
|
+
* @param {string} className Constructor to instantiate from the hooks module.
|
|
200
|
+
* @returns {this} Runner instance for chaining.
|
|
201
|
+
*/
|
|
138
202
|
setHooks(hooksPath, className) {
|
|
139
203
|
this.#hooksPath = hooksPath
|
|
140
204
|
this.#hooksClassName = className
|
|
@@ -144,6 +208,12 @@ export default class ActionRunner extends Piper {
|
|
|
144
208
|
return this
|
|
145
209
|
}
|
|
146
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Import and instantiate the configured hooks module.
|
|
213
|
+
*
|
|
214
|
+
* @returns {Promise<null|void>} Null when hooks are disabled, otherwise void.
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
147
217
|
async #loadHooks() {
|
|
148
218
|
if(!this.#hooksPath)
|
|
149
219
|
return null
|
package/src/lib/ActionWrapper.js
CHANGED
|
@@ -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
|
-
|
|
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 [
|
|
19
|
-
|
|
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
|
}
|
package/src/lib/Activity.js
CHANGED
package/src/lib/Piper.js
CHANGED
|
@@ -106,9 +106,8 @@ export default class Piper {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
const setupResult = await Util.settleAll(
|
|
109
|
-
[...this.#lifeCycle.get("setup")
|
|
110
|
-
|
|
111
|
-
].map(e => e()))
|
|
109
|
+
[...this.#lifeCycle.get("setup")].map(e => e())
|
|
110
|
+
)
|
|
112
111
|
this.#processResult("Setting up the pipeline.", setupResult)
|
|
113
112
|
|
|
114
113
|
// Start workers up to maxConcurrent limit
|
|
@@ -124,9 +123,8 @@ export default class Piper {
|
|
|
124
123
|
|
|
125
124
|
// Run cleanup hooks
|
|
126
125
|
const teardownResult = await Util.settleAll(
|
|
127
|
-
[...this.#lifeCycle.get("teardown")
|
|
128
|
-
|
|
129
|
-
].map(e => e()))
|
|
126
|
+
[...this.#lifeCycle.get("teardown")].map(e => e())
|
|
127
|
+
)
|
|
130
128
|
this.#processResult("Tearing down the pipeline.", teardownResult)
|
|
131
129
|
|
|
132
130
|
return allResults
|
package/src/types/index.d.ts
CHANGED
|
@@ -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
|
|
6
|
-
export {default as
|
|
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,56 @@
|
|
|
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
|
+
* @returns {Promise<unknown>} Final value produced by the pipeline, or null when a parallel stage reports failures.
|
|
30
|
+
* @throws {Sass} When no activities are registered or required parallel builders are missing.
|
|
31
|
+
*/
|
|
32
|
+
run(context: unknown): Promise<unknown>
|
|
33
|
+
/**
|
|
34
|
+
* Configure hooks to be lazily loaded when the pipeline runs.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} hooksPath Absolute path to the module exporting the hooks class.
|
|
37
|
+
* @param {string} className Constructor to instantiate from the hooks module.
|
|
38
|
+
* @returns {this} Runner instance for chaining.
|
|
39
|
+
*/
|
|
40
|
+
setHooks(hooksPath: string, className: string): this
|
|
41
|
+
#private
|
|
42
|
+
}
|
|
43
|
+
export type ActionHooks = import('./ActionHooks.js').default
|
|
44
|
+
export type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
|
|
45
|
+
export type ActionRunnerOptions = {
|
|
46
|
+
/**
|
|
47
|
+
* Pre-configured hooks.
|
|
48
|
+
*/
|
|
49
|
+
hooks?: import('./ActionHooks.js').default | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Logger function.
|
|
52
|
+
*/
|
|
53
|
+
debug?: DebugFn | undefined;
|
|
54
|
+
}
|
|
55
|
+
import Piper from './Piper.js'
|
|
56
|
+
//# 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;;;;;;OAMG;IACH,aAJW,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,CAmD5B;IAgDD;;;;;;OAMG;IACH,oBAJW,MAAM,aACN,MAAM,GACJ,IAAI,CAShB;;CA2BF;0BArOa,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,CAiDnC;;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
|
package/src/types/Activity.d.ts
DELETED
|
@@ -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
|
package/src/types/Piper.d.ts
DELETED
|
@@ -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
|