@gesslar/actioneer 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,8 +28,8 @@ class MyAction {
28
28
  }
29
29
  }
30
30
 
31
- const wrapper = new ActionBuilder(new MyAction()).build()
32
- const runner = new ActionRunner(wrapper)
31
+ const builder = new ActionBuilder(new MyAction())
32
+ const runner = new ActionRunner(builder)
33
33
  const result = await runner.pipe([{}], 4) // run up to 4 contexts concurrently
34
34
  console.log(result)
35
35
  ```
@@ -44,6 +44,132 @@ import { ActionBuilder, ActionRunner } from "@gesslar/actioneer"
44
44
 
45
45
  If you'd like more complete typings or additional JSDoc, open an issue or send a PR — contributions welcome.
46
46
 
47
+ ## ActionHooks
48
+
49
+ Actioneer supports lifecycle hooks that can execute before and after each activity in your pipeline. Hooks are loaded from a module and can be configured either by file path or by providing a pre-instantiated hooks object.
50
+
51
+ ### Hook System Overview
52
+
53
+ The hook system allows you to:
54
+
55
+ - Execute code before and after each activity in your pipeline
56
+ - Implement setup and cleanup logic
57
+ - Add observability and logging to your pipelines
58
+ - Modify or inspect the context flowing through activities
59
+
60
+ ### Configuring Hooks
61
+
62
+ You can attach hooks to an ActionBuilder in two ways:
63
+
64
+ #### 1. Load hooks from a file
65
+
66
+ ```js
67
+ import { ActionBuilder, ActionRunner } from "@gesslar/actioneer"
68
+
69
+ class MyAction {
70
+ setup(builder) {
71
+ builder
72
+ .withHooksFile("./hooks/MyActionHooks.js", "MyActionHooks")
73
+ .do("prepare", ctx => { ctx.count = 0 })
74
+ .do("work", ctx => { ctx.count += 1 })
75
+ }
76
+ }
77
+
78
+ const builder = new ActionBuilder(new MyAction())
79
+ const runner = new ActionRunner(builder)
80
+ const result = await runner.pipe([{}], 4)
81
+ ```
82
+
83
+ #### 2. Provide a pre-instantiated hooks object
84
+
85
+ ```js
86
+ import { ActionBuilder, ActionRunner } from "@gesslar/actioneer"
87
+ import { MyActionHooks } from "./hooks/MyActionHooks.js"
88
+
89
+ const hooks = new MyActionHooks({ debug: console.log })
90
+
91
+ class MyAction {
92
+ setup(builder) {
93
+ builder
94
+ .withHooks(hooks)
95
+ .do("prepare", ctx => { ctx.count = 0 })
96
+ .do("work", ctx => { ctx.count += 1 })
97
+ }
98
+ }
99
+
100
+ const builder = new ActionBuilder(new MyAction())
101
+ const runner = new ActionRunner(builder)
102
+ const result = await runner.pipe([{}], 4)
103
+ ```
104
+
105
+ ### Writing Hooks
106
+
107
+ Hooks are classes exported from a module. The hook methods follow a naming convention: `event$activityName`.
108
+
109
+ ```js
110
+ // hooks/MyActionHooks.js
111
+ export class MyActionHooks {
112
+ constructor({ debug }) {
113
+ this.debug = debug
114
+ }
115
+
116
+ // Hook that runs before the "prepare" activity
117
+ async before$prepare(context) {
118
+ this.debug("About to prepare", context)
119
+ }
120
+
121
+ // Hook that runs after the "prepare" activity
122
+ async after$prepare(context) {
123
+ this.debug("Finished preparing", context)
124
+ }
125
+
126
+ // Hook that runs before the "work" activity
127
+ async before$work(context) {
128
+ this.debug("Starting work", context)
129
+ }
130
+
131
+ // Hook that runs after the "work" activity
132
+ async after$work(context) {
133
+ this.debug("Work complete", context)
134
+ }
135
+
136
+ // Optional: setup hook runs once at initialization
137
+ async setup(args) {
138
+ this.debug("Hooks initialized")
139
+ }
140
+
141
+ // Optional: cleanup hook for teardown
142
+ async cleanup(args) {
143
+ this.debug("Hooks cleaned up")
144
+ }
145
+ }
146
+ ```
147
+
148
+ ### Hook Naming Convention
149
+
150
+ Activity names are transformed to hook method names:
151
+
152
+ - Spaces are removed and words are camelCased: `"do work"` → `before$doWork` / `after$doWork`
153
+ - Non-word characters are stripped: `"step-1"` → `before$step1` / `after$step1`
154
+ - First word stays lowercase: `"Prepare Data"` → `before$prepareData` / `after$prepareData`
155
+
156
+ ### Hook Timeout
157
+
158
+ By default, hooks have a 1-second (1000ms) timeout. If a hook exceeds this timeout, the pipeline will throw a `Sass` error. You can configure the timeout when creating the hooks:
159
+
160
+ ```js
161
+ new ActionHooks({
162
+ actionKind: "MyActionHooks",
163
+ hooksFile: "./hooks.js",
164
+ hookTimeout: 5000, // 5 seconds
165
+ debug: console.log
166
+ })
167
+ ```
168
+
169
+ ### Nested Pipelines and Hooks
170
+
171
+ When you nest ActionBuilders (for branching or parallel execution), the parent's hooks are automatically passed to all children, ensuring consistent hook behavior throughout the entire pipeline hierarchy.
172
+
47
173
  ### Optional TypeScript (local, opt-in)
48
174
 
49
175
  This project intentionally avoids committing TypeScript tool configuration. If you'd like to use TypeScript's checker locally (for editor integration or optional JSDoc checking), you can drop a `tsconfig.json` in your working copy — `tsconfig.json` is already in the repository `.gitignore`, so feel free to typecheck yourselves into oblivion.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gesslar/actioneer",
3
- "version": "0.1.2",
4
- "description": "Ready? Set?? ACTION!! pew!pew!pew!pew!",
3
+ "version": "0.2.0",
4
+ "description": "Ready? Set?? ACTION!! pew! pew! pew!",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
7
7
  "exports": {
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "sideEffects": false,
19
19
  "engines": {
20
- "node": ">=20"
20
+ "node": ">=22"
21
21
  },
22
22
  "scripts": {
23
23
  "lint": "eslint src/",
@@ -47,15 +47,15 @@
47
47
  "license": "Unlicense",
48
48
  "homepage": "https://github.com/gesslar/toolkit#readme",
49
49
  "devDependencies": {
50
- "@stylistic/eslint-plugin": "^5.4.0",
51
- "@types/node": "^24.6.2",
52
- "@typescript-eslint/eslint-plugin": "^8.45.0",
53
- "@typescript-eslint/parser": "^8.45.0",
54
- "eslint": "^9.36.0",
55
- "eslint-plugin-jsdoc": "^60.7.1",
50
+ "@stylistic/eslint-plugin": "^5.5.0",
51
+ "@types/node": "^24.9.1",
52
+ "@typescript-eslint/eslint-plugin": "^8.46.2",
53
+ "@typescript-eslint/parser": "^8.46.2",
54
+ "eslint": "^9.38.0",
55
+ "eslint-plugin-jsdoc": "^61.1.8",
56
56
  "typescript": "^5.9.3"
57
57
  },
58
58
  "dependencies": {
59
- "@gesslar/toolkit": "^0.6.0"
59
+ "@gesslar/toolkit": "^0.7.0"
60
60
  }
61
61
  }
@@ -1,6 +1,7 @@
1
1
  import {Data, Sass, Valid} from "@gesslar/toolkit"
2
2
 
3
3
  import ActionWrapper from "./ActionWrapper.js"
4
+ import ActionHooks from "./ActionHooks.js"
4
5
 
5
6
  /** @typedef {import("./ActionRunner.js").default} ActionRunner */
6
7
  /** @typedef {typeof import("./Activity.js").ACTIVITY} ActivityFlags */
@@ -38,8 +39,8 @@ import ActionWrapper from "./ActionWrapper.js"
38
39
  /**
39
40
  * Fluent builder for describing how an action should process the context that
40
41
  * flows through the {@link ActionRunner}. Consumers register named activities,
41
- * optional hook pairs, and nested parallel pipelines before handing the
42
- * builder back to the runner for execution.
42
+ * and nested parallel pipelines before handing the builder back to the runner
43
+ * for execution.
43
44
  *
44
45
  * Typical usage:
45
46
  *
@@ -64,6 +65,9 @@ export default class ActionBuilder {
64
65
  #debug = null
65
66
  /** @type {symbol|null} */
66
67
  #tag = null
68
+ #hooksFile = null
69
+ #hooksKind = null
70
+ #hooks = null
67
71
 
68
72
  /**
69
73
  * Creates a new ActionBuilder instance with the provided action callback.
@@ -138,7 +142,7 @@ export default class ActionBuilder {
138
142
 
139
143
  Valid.type(kind, "Number")
140
144
  Valid.type(pred, "Function")
141
- Valid.type(op, "Function|ActionWrapper")
145
+ Valid.type(op, "Function|ActionBuilder")
142
146
 
143
147
  Object.assign(activityDefinition, {kind, pred, op})
144
148
  } else {
@@ -150,6 +154,42 @@ export default class ActionBuilder {
150
154
  return this
151
155
  }
152
156
 
157
+ /**
158
+ * Configure hooks to be loaded from a file when the action is built.
159
+ *
160
+ * @param {string} hooksFile Path to the hooks module file.
161
+ * @param {string} hooksKind Name of the exported hooks class to instantiate.
162
+ * @returns {ActionBuilder} The builder instance for chaining.
163
+ * @throws {Sass} If hooks have already been configured.
164
+ */
165
+ withHooksFile(hooksFile, hooksKind) {
166
+ Valid.assert(this.#hooksFile === null, "Hooks have already been configured.")
167
+ Valid.assert(this.#hooksKind === null, "Hooks have already been configured.")
168
+ Valid.assert(this.#hooks === null, "Hooks have already been configured.")
169
+
170
+ this.#hooksFile = hooksFile
171
+ this.#hooksKind = hooksKind
172
+
173
+ return this
174
+ }
175
+
176
+ /**
177
+ * Configure hooks using a pre-instantiated hooks object.
178
+ *
179
+ * @param {import("./ActionHooks.js").default} hooks An already-instantiated hooks instance.
180
+ * @returns {ActionBuilder} The builder instance for chaining.
181
+ * @throws {Sass} If hooks have already been configured.
182
+ */
183
+ withHooks(hooks) {
184
+ Valid.assert(this.#hooksFile === null, "Hooks have already been configured.")
185
+ Valid.assert(this.#hooksKind === null, "Hooks have already been configured.")
186
+ Valid.assert(this.#hooks === null, "Hooks have already been configured.")
187
+
188
+ this.#hooks = hooks
189
+
190
+ return this
191
+ }
192
+
153
193
  /**
154
194
  * Validates that an activity name has not been reused.
155
195
  *
@@ -167,9 +207,9 @@ export default class ActionBuilder {
167
207
  * Finalises the builder and returns a payload that can be consumed by the
168
208
  * runner.
169
209
  *
170
- * @returns {import("./ActionWrapper.js").default} Payload consumed by the {@link ActionRunner} constructor.
210
+ * @returns {Promise<import("./ActionWrapper.js").default>} Payload consumed by the {@link ActionRunner} constructor.
171
211
  */
172
- build() {
212
+ async build() {
173
213
  const action = this.#action
174
214
 
175
215
  if(!action.tag) {
@@ -178,9 +218,27 @@ export default class ActionBuilder {
178
218
  action.setup.call(action, this)
179
219
  }
180
220
 
221
+ // All children in a branch also get the same hooks.
222
+ const hooks = await this.#getHooks()
223
+
181
224
  return new ActionWrapper({
182
225
  activities: this.#activities,
183
226
  debug: this.#debug,
227
+ hooks,
184
228
  })
185
229
  }
230
+
231
+ async #getHooks() {
232
+ const newHooks = ActionHooks.new
233
+
234
+ const hooks = this.#hooks
235
+ if(hooks)
236
+ return await newHooks({hooks}, this.#debug)
237
+
238
+ const hooksFile = this.#hooksFile
239
+ const hooksKind = this.#hooksKind
240
+
241
+ if(hooksFile && hooksKind)
242
+ return await newHooks({hooksFile,hooksKind}, this.#debug)
243
+ }
186
244
  }
@@ -1,5 +1,5 @@
1
1
  import {setTimeout as timeout} from "timers/promises"
2
- import {FileObject, Sass, Util, Valid} from "@gesslar/toolkit"
2
+ import {Data, FileObject, Sass, Util, Valid} from "@gesslar/toolkit"
3
3
 
4
4
  /**
5
5
  * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
@@ -31,7 +31,7 @@ export default class ActionHooks {
31
31
  /** @type {string|null} */
32
32
  #actionKind = null
33
33
  /** @type {number} */
34
- #timeout = 1000 // Default 1 second timeout
34
+ #timeout = 1_000 // Default 1 second timeout
35
35
  /** @type {DebugFn|null} */
36
36
  #debug = null
37
37
 
@@ -40,7 +40,7 @@ export default class ActionHooks {
40
40
  *
41
41
  * @param {ActionHooksConfig} config Configuration values describing how to load the hooks.
42
42
  */
43
- constructor({actionKind, hooksFile, hooks, hookTimeout = 1000, debug}) {
43
+ constructor({actionKind, hooksFile, hooks, hookTimeout = 1_000, debug}) {
44
44
  this.#actionKind = actionKind
45
45
  this.#hooksFile = hooksFile
46
46
  this.#hooks = hooks
@@ -114,42 +114,44 @@ export default class ActionHooks {
114
114
  static async new(config, debug) {
115
115
  debug("Creating new HookManager instance with args: %o", 2, config)
116
116
 
117
- const instance = new this(config, debug)
118
- const hooksFile = instance.hooksFile
117
+ const instance = new ActionHooks(config, debug)
118
+ if(!instance.#hooks) {
119
+ const hooksFile = new FileObject(instance.#hooksFile)
119
120
 
120
- debug("Loading hooks from %o", 2, hooksFile.uri)
121
+ debug("Loading hooks from %o", 2, hooksFile.uri)
121
122
 
122
- debug("Checking hooks file exists: %o", 2, hooksFile.uri)
123
- if(!await hooksFile.exists)
124
- throw Sass.new(`No such hooks file, ${hooksFile.uri}`)
123
+ debug("Checking hooks file exists: %o", 2, hooksFile.uri)
124
+ if(!await hooksFile.exists)
125
+ throw Sass.new(`No such hooks file, ${hooksFile.uri}`)
125
126
 
126
- try {
127
- const hooksImport = await hooksFile.import()
127
+ try {
128
+ const hooksImport = await hooksFile.import()
128
129
 
129
- if(!hooksImport)
130
- return null
130
+ if(!hooksImport)
131
+ return null
131
132
 
132
- debug("Hooks file imported successfully as a module", 2)
133
+ debug("Hooks file imported successfully as a module", 2)
133
134
 
134
- const actionKind = instance.actionKind
135
- if(!hooksImport[actionKind])
136
- return null
135
+ const actionKind = instance.actionKind
136
+ if(!hooksImport[actionKind])
137
+ return null
137
138
 
138
- const hooks = new hooksImport[actionKind]({debug})
139
+ const hooks = new hooksImport[actionKind]({debug})
139
140
 
140
- debug(hooks.constructor.name, 4)
141
+ debug(hooks.constructor.name, 4)
141
142
 
142
- // Attach common properties to hooks
143
- instance.#hooks = hooks
143
+ instance.#hooks = hooks
144
+ debug("Hooks %o loaded successfully for %o", 2, hooksFile.uri, instance.actionKind)
144
145
 
145
- debug("Hooks %o loaded successfully for %o", 2, hooksFile.uri, instance.actionKind)
146
-
147
- return instance
148
- } catch(error) {
149
- debug("Failed to load hooks %o: %o", 1, hooksFile.uri, error.message)
146
+ return instance
147
+ } catch(error) {
148
+ debug("Failed to load hooks %o: %o", 1, hooksFile.uri, error.message)
150
149
 
151
- return null
150
+ return null
151
+ }
152
152
  }
153
+
154
+ return this
153
155
  }
154
156
 
155
157
  /**
@@ -168,7 +170,11 @@ export default class ActionHooks {
168
170
  if(!hooks)
169
171
  return
170
172
 
171
- const hookName = `${kind}$${activityName}`
173
+ const stringActivityName = Data.isType("Symbol")
174
+ ? activityName.description()
175
+ : activityName
176
+
177
+ const hookName = this.#getActivityHookName(kind, stringActivityName)
172
178
 
173
179
  debug("Looking for hook: %o", 4, hookName)
174
180
 
@@ -211,4 +217,22 @@ export default class ActionHooks {
211
217
  throw Sass.new(`Processing hook ${kind}$${activityName}`, error)
212
218
  }
213
219
  }
220
+
221
+ #getActivityHookName(event, activityName) {
222
+ const name = activityName
223
+ .split(" ")
224
+ .map(a => a.trim())
225
+ .filter(Boolean)
226
+ .map(a => a
227
+ .split("")
228
+ .filter(b => /[\w]/.test(b))
229
+ .filter(Boolean)
230
+ .join("")
231
+ )
232
+ .map(a => a.toLowerCase())
233
+ .map((a, i) => i === 0 ? a : Util.capitalize(a))
234
+ .join("")
235
+
236
+ return `${event}$${name}`
237
+ }
214
238
  }
@@ -1,18 +1,15 @@
1
- import {FileObject, Sass, Valid} from "@gesslar/toolkit"
1
+ import {Sass, Valid} from "@gesslar/toolkit"
2
2
 
3
3
  import ActionBuilder from "./ActionBuilder.js"
4
4
  import {ACTIVITY} from "./Activity.js"
5
5
  import Piper from "./Piper.js"
6
6
 
7
- /** @typedef {import("./ActionHooks.js").default} ActionHooks */
8
-
9
7
  /**
10
8
  * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
11
9
  */
12
10
 
13
11
  /**
14
12
  * @typedef {object} ActionRunnerOptions
15
- * @property {ActionHooks} [hooks] Pre-configured hooks.
16
13
  * @property {DebugFn} [debug] Logger function.
17
14
  */
18
15
  /**
@@ -23,68 +20,33 @@ import Piper from "./Piper.js"
23
20
  * context object under `result.value` that can be replaced or enriched.
24
21
  */
25
22
  export default class ActionRunner extends Piper {
26
- /**
27
- * Pipeline produced by the builder.
28
- *
29
- * @type {import("./ActionWrapper.js").default|null}
30
- */
31
- #actionWrapper = null
23
+ #actionBuilder = null
24
+
32
25
  /**
33
26
  * Logger invoked for diagnostics.
34
27
  *
35
28
  * @type {DebugFn}
36
29
  */
37
30
  #debug = () => {}
38
- /**
39
- * Filesystem path to a hooks module.
40
- *
41
- * @type {string|null}
42
- */
43
- #hooksPath = null
44
- /**
45
- * Constructor name exported by the hooks module.
46
- *
47
- * @type {string|null}
48
- */
49
- #hooksClassName = null
50
- /**
51
- * Lazily instantiated hooks implementation.
52
- *
53
- * @type {ActionHooks|null}
54
- */
55
- #hooks = null
56
- /**
57
- * Unique tag for log correlation.
58
- *
59
- * @type {symbol|null}
60
- */
61
- #tag = null
62
31
 
63
32
  /**
64
33
  * Instantiate a runner over an optional action wrapper.
65
34
  *
66
- * @param {import("./ActionWrapper.js").default|null} wrappedAction Output of {@link ActionBuilder#build}.
67
- * @param {ActionRunnerOptions} [options] Optional hooks/debug overrides.
35
+ * @param {import("./ActionBuilder.js").default|null} actionBuilder ActionBuilder to build.
36
+ * @param {ActionRunnerOptions} [options] Optional debug overrides.
68
37
  */
69
- constructor(wrappedAction, {hooks,debug=(() => {})} = {}) {
38
+ constructor(actionBuilder, {debug=(() => {})} = {}) {
70
39
  super({debug})
71
40
 
72
- this.#tag = Symbol(performance.now())
73
-
74
41
  this.#debug = debug
75
42
 
76
- if(!wrappedAction)
43
+ if(!actionBuilder)
77
44
  return this
78
45
 
79
- if(wrappedAction?.constructor?.name !== "ActionWrapper")
80
- throw Sass.new("ActionRunner takes an instance of an ActionWrapper")
46
+ if(actionBuilder?.constructor?.name !== "ActionBuilder")
47
+ throw Sass.new("ActionRunner takes an instance of an ActionBuilder")
81
48
 
82
- this.#actionWrapper = wrappedAction
83
-
84
- if(hooks)
85
- this.#hooks = hooks
86
- else
87
- this.addSetup(this.#loadHooks)
49
+ this.#actionBuilder = actionBuilder
88
50
 
89
51
  this.addStep(this.run)
90
52
  }
@@ -97,13 +59,10 @@ export default class ActionRunner extends Piper {
97
59
  * @throws {Sass} When no activities are registered or required parallel builders are missing.
98
60
  */
99
61
  async run(context) {
100
- this.#debug(this.#tag.description)
101
- const actionWrapper = this.#actionWrapper
62
+ const actionWrapper = await this.#actionBuilder.build()
102
63
  const activities = actionWrapper.activities
103
64
 
104
65
  for(const activity of activities) {
105
- activity.setActionHooks(this.#hooks)
106
-
107
66
  const kind = activity.kind
108
67
 
109
68
  // If we have no kind, then it's just a once.
@@ -112,7 +71,6 @@ export default class ActionRunner extends Piper {
112
71
  context = await this.#executeActivity(activity, context)
113
72
  } else {
114
73
  const {WHILE,UNTIL} = ACTIVITY
115
-
116
74
  const pred = activity.pred
117
75
  const kindWhile = kind & WHILE
118
76
  const kindUntil = kind & UNTIL
@@ -156,21 +114,17 @@ export default class ActionRunner extends Piper {
156
114
  */
157
115
  async #executeActivity(activity, context) {
158
116
  // What kind of op are we looking at? Is it a function?
159
- // Or a class instance of type ActionWrapper?
117
+ // Or a class instance of type ActionBuilder?
160
118
  const opKind = activity.opKind
161
- if(opKind === "ActionWrapper") {
162
- const runner = new this.constructor(activity.op, {
163
- debug: this.#debug,
164
- hooks: this.#hooks,
165
- })
166
- .setHooks(this.#hooksPath, this.#hooksClassName)
119
+ if(opKind === "ActionBuilder") {
120
+ const runner = new this.constructor(activity.op, {debug: this.#debug})
167
121
 
168
122
  return await runner.run(context, true)
169
123
  } else if(opKind === "Function") {
170
124
  return await activity.run(context)
171
125
  }
172
126
 
173
- throw Sass.new("We buy Functions and ActionWrappers. Only. Not whatever that was.")
127
+ throw Sass.new("We buy Functions and ActionBuilders. Only. Not whatever that was.")
174
128
  }
175
129
 
176
130
  /**
@@ -191,46 +145,4 @@ export default class ActionRunner extends Piper {
191
145
  toString() {
192
146
  return `[object ${this.constructor.name}]`
193
147
  }
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
- */
202
- setHooks(hooksPath, className) {
203
- this.#hooksPath = hooksPath
204
- this.#hooksClassName = className
205
-
206
- this.addSetup(() => this.#loadHooks())
207
-
208
- return this
209
- }
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
- */
217
- async #loadHooks() {
218
- if(!this.#hooksPath)
219
- return null
220
-
221
- const file = new FileObject(this.#hooksPath)
222
- if(!await file.exists)
223
- throw Sass.new(`File '${file.uri} does not exist.`)
224
-
225
- const module = await file.import()
226
- const hooksClassName = this.#hooksClassName
227
-
228
- Valid.type(module[hooksClassName], "Function")
229
-
230
- const loaded = new module[hooksClassName]({
231
- debug: this.#debug
232
- })
233
-
234
- this.#hooks = loaded
235
- }
236
148
  }
@@ -31,13 +31,16 @@ export default class ActionWrapper {
31
31
  */
32
32
  #debug = () => {}
33
33
 
34
+ #hooks = null
35
+
34
36
  /**
35
37
  * Create a wrapper from the builder payload.
36
38
  *
37
39
  * @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
38
40
  */
39
- constructor({activities,debug}) {
41
+ constructor({activities,hooks,debug}) {
40
42
  this.#debug = debug
43
+ this.#hooks = hooks
41
44
  this.#activities = activities
42
45
  this.#debug(
43
46
  "Instantiating ActionWrapper with %o activities.",
@@ -48,7 +51,7 @@ export default class ActionWrapper {
48
51
 
49
52
  *#_activities() {
50
53
  for(const [,activity] of this.#activities)
51
- yield new Activity(activity)
54
+ yield new Activity({...activity, hooks: this.#hooks})
52
55
  }
53
56
 
54
57
  /**
@@ -1,5 +1,7 @@
1
1
  import {Data} from "@gesslar/toolkit"
2
2
 
3
+ /** @typedef {import("./ActionHooks.js").default} ActionHooks */
4
+
3
5
  /**
4
6
  * Activity bit flags recognised by the builder. The flag decides
5
7
  * loop semantics for an activity.
@@ -23,14 +25,15 @@ export default class Activity {
23
25
  /**
24
26
  * Construct an Activity definition wrapper.
25
27
  *
26
- * @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
28
+ * @param {{action: unknown, name: string, op: (context: unknown) => unknown|Promise<unknown>|unknown, kind?: number, pred?: (context: unknown) => boolean|Promise<boolean>, hooks?: ActionHooks}} init - Initial properties describing the activity operation, loop semantics, and predicate
27
29
  */
28
- constructor({action,name,op,kind,pred}) {
30
+ constructor({action,name,op,kind,pred,hooks}) {
29
31
  this.#name = name
30
32
  this.#op = op
31
33
  this.#kind = kind
32
34
  this.#action = action
33
35
  this.#pred = pred
36
+ this.#hooks = hooks
34
37
  }
35
38
 
36
39
  /**
@@ -94,19 +97,14 @@ export default class Activity {
94
97
  * @returns {Promise<{activityResult: unknown}>} - Activity result wrapper with new context
95
98
  */
96
99
  async run(context) {
97
- const hooks = this.#hooks
98
-
99
100
  // before hook
100
- const before = hooks?.[`before$${this.#name}`]
101
- if(Data.typeOf(before) === "Function")
102
- await before.call(hooks,context)
101
+ await this.#hooks?.callHook("before", this.#name, context)
103
102
 
103
+ // not a hook
104
104
  const result = await this.#op.call(this.#action,context)
105
105
 
106
106
  // after hook
107
- const after = hooks?.[`after$${this.#name}`]
108
- if(Data.typeOf(after) === "Function")
109
- await after.call(hooks,context)
107
+ await this.#hooks?.callHook("after", this.#name, context)
110
108
 
111
109
  return result
112
110
  }
package/src/lib/Piper.js CHANGED
@@ -158,8 +158,7 @@ export default class Piper {
158
158
  let result = item
159
159
 
160
160
  for(const step of this.#lifeCycle.get("process")) {
161
- if(typeof this.#debug === "function")
162
- this.#debug("Executing step: %o", 4, step.name)
161
+ this.#debug("Executing step: %o", 4, step.name)
163
162
 
164
163
  result = await step.fn(result) ?? result
165
164
  }
@@ -28,8 +28,8 @@
28
28
  /**
29
29
  * Fluent builder for describing how an action should process the context that
30
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.
31
+ * and nested parallel pipelines before handing the builder back to the runner
32
+ * for execution.
33
33
  *
34
34
  * Typical usage:
35
35
  *
@@ -75,13 +75,30 @@ export default class ActionBuilder {
75
75
  * @returns {ActionBuilder}
76
76
  */
77
77
  do(name: string | symbol, kind: number, pred: (context: unknown) => boolean | Promise<boolean>, op: ActionFunction | import('./ActionWrapper.js').default): ActionBuilder
78
+ /**
79
+ * Configure hooks to be loaded from a file when the action is built.
80
+ *
81
+ * @param {string} hooksFile Path to the hooks module file.
82
+ * @param {string} hooksKind Name of the exported hooks class to instantiate.
83
+ * @returns {ActionBuilder} The builder instance for chaining.
84
+ * @throws {Sass} If hooks have already been configured.
85
+ */
86
+ withHooksFile(hooksFile: string, hooksKind: string): ActionBuilder
87
+ /**
88
+ * Configure hooks using a pre-instantiated hooks object.
89
+ *
90
+ * @param {import("./ActionHooks.js").default} hooks An already-instantiated hooks instance.
91
+ * @returns {ActionBuilder} The builder instance for chaining.
92
+ * @throws {Sass} If hooks have already been configured.
93
+ */
94
+ withHooks(hooks: import('./ActionHooks.js').default): ActionBuilder
78
95
  /**
79
96
  * Finalises the builder and returns a payload that can be consumed by the
80
97
  * runner.
81
98
  *
82
- * @returns {import("./ActionWrapper.js").default} Payload consumed by the {@link ActionRunner} constructor.
99
+ * @returns {Promise<import("./ActionWrapper.js").default>} Payload consumed by the {@link ActionRunner} constructor.
83
100
  */
84
- build(): import('./ActionWrapper.js').default
101
+ build(): Promise<import('./ActionWrapper.js').default>
85
102
  #private
86
103
  }
87
104
  export type ActionRunner = import('./ActionRunner.js').default
@@ -1 +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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AAS,GAAC,MAAM,gBACzC,MAAM,GAAC,MAAM,WACb,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CAwDzB;;CAmBF;sBAzOY,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;2BAhBzB,kBAAkB"}
@@ -1,10 +1,8 @@
1
- /** @typedef {import("./ActionHooks.js").default} ActionHooks */
2
1
  /**
3
2
  * @typedef {(message: string, level?: number, ...args: Array<unknown>) => void} DebugFn
4
3
  */
5
4
  /**
6
5
  * @typedef {object} ActionRunnerOptions
7
- * @property {ActionHooks} [hooks] Pre-configured hooks.
8
6
  * @property {DebugFn} [debug] Logger function.
9
7
  */
10
8
  /**
@@ -18,10 +16,10 @@ export default class ActionRunner extends Piper {
18
16
  /**
19
17
  * Instantiate a runner over an optional action wrapper.
20
18
  *
21
- * @param {import("./ActionWrapper.js").default|null} wrappedAction Output of {@link ActionBuilder#build}.
22
- * @param {ActionRunnerOptions} [options] Optional hooks/debug overrides.
19
+ * @param {import("./ActionBuilder.js").default|null} actionBuilder ActionBuilder to build.
20
+ * @param {ActionRunnerOptions} [options] Optional debug overrides.
23
21
  */
24
- constructor(wrappedAction: import('./ActionWrapper.js').default | null, { hooks, debug }?: ActionRunnerOptions)
22
+ constructor(actionBuilder: import('./ActionBuilder.js').default | null, { debug }?: ActionRunnerOptions)
25
23
  /**
26
24
  * Executes the configured action pipeline.
27
25
  *
@@ -30,23 +28,10 @@ export default class ActionRunner extends Piper {
30
28
  * @throws {Sass} When no activities are registered or required parallel builders are missing.
31
29
  */
32
30
  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
31
  #private
42
32
  }
43
- export type ActionHooks = import('./ActionHooks.js').default
44
33
  export type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void
45
34
  export type ActionRunnerOptions = {
46
- /**
47
- * Pre-configured hooks.
48
- */
49
- hooks?: import('./ActionHooks.js').default | undefined;
50
35
  /**
51
36
  * Logger function.
52
37
  */
@@ -1 +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"}
1
+ {"version":3,"file":"ActionRunner.d.ts","sourceRoot":"","sources":["../../lib/ActionRunner.js"],"names":[],"mappings":"AAMA;;GAEG;AAEH;;;GAGG;AACH;;;;;;GAMG;AACH;IAUE;;;;;OAKG;IACH,2BAHW,OAAO,oBAAoB,EAAE,OAAO,GAAC,IAAI,cACzC,mBAAmB,EAgB7B;IAED;;;;;;OAMG;IACH,aAJW,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,CA+C5B;;CA2CF;sBA5IY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;;;;;;kBAH7D,YAAY"}
@@ -19,7 +19,7 @@ export default class ActionWrapper {
19
19
  *
20
20
  * @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
21
21
  */
22
- constructor({ activities, debug }: {
22
+ constructor({ activities, hooks, debug }: {
23
23
  activities: Map<string | symbol, WrappedActivityConfig>;
24
24
  debug: (message: string, level?: number, ...args: Array<unknown>) => void;
25
25
  })
@@ -1 +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"}
1
+ {"version":3,"file":"ActionWrapper.d.ts","sourceRoot":"","sources":["../../lib/ActionWrapper.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;GAEG;AAEH;;GAEG;AACH;IAgBE;;;;OAIG;IACH,0CAFW;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,EAW5I;IAOD;;;;OAIG;IACH,kBAFa,gBAAgB,CAI5B;;CACF;;;;;UA5Da,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"}
@@ -3,6 +3,7 @@
3
3
  * loop semantics for an activity.
4
4
  */
5
5
  export type ACTIVITY = number
6
+ /** @typedef {import("./ActionHooks.js").default} ActionHooks */
6
7
  /**
7
8
  * Activity bit flags recognised by the builder. The flag decides
8
9
  * loop semantics for an activity.
@@ -18,14 +19,15 @@ export default class Activity {
18
19
  /**
19
20
  * Construct an Activity definition wrapper.
20
21
  *
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
+ * @param {{action: unknown, name: string, op: (context: unknown) => unknown|Promise<unknown>|unknown, kind?: number, pred?: (context: unknown) => boolean|Promise<boolean>, hooks?: ActionHooks}} init - Initial properties describing the activity operation, loop semantics, and predicate
22
23
  */
23
- constructor({ action, name, op, kind, pred }: {
24
+ constructor({ action, name, op, kind, pred, hooks }: {
24
25
  action: unknown;
25
26
  name: string;
26
27
  op: (context: unknown) => unknown | Promise<unknown> | unknown;
27
28
  kind?: number;
28
29
  pred?: (context: unknown) => boolean | Promise<boolean>;
30
+ hooks?: ActionHooks;
29
31
  })
30
32
  /**
31
33
  * The activity name.
@@ -81,4 +83,5 @@ export default class Activity {
81
83
  setActionHooks(hooks: unknown): this
82
84
  #private
83
85
  }
86
+ export type ActionHooks = import('./ActionHooks.js').default
84
87
  //# sourceMappingURL=Activity.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"Activity.d.ts","sourceRoot":"","sources":["../../lib/Activity.js"],"names":[],"mappings":";;;;uBASU,MAAM;AAPhB,gEAAgE;AAEhE;;;;;;GAMG;AACH;;;GAGE;AAEF;IAQE;;;;OAIG;IACH,qDAFW;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,CAAC;QAAC,KAAK,CAAC,EAAE,WAAW,CAAA;KAAC,EAShM;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,CAa9C;IAED;;;;;OAKG;IACH,sBAHW,OAAO,GACL,IAAI,CAOhB;;CACF;0BAzHa,OAAO,kBAAkB,EAAE,OAAO"}
@@ -1 +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
+ {"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,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