@wooksjs/event-wf 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wooksjs/event-wf",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "@wooksjs/event-wf",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"typescript": "^5.9.3",
|
|
49
49
|
"vitest": "^3.2.4",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
50
|
+
"wooks": "^0.7.1",
|
|
51
|
+
"@wooksjs/event-core": "^0.7.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@prostojs/logger": "^0.4.3",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
55
|
+
"@wooksjs/event-core": "^0.7.1",
|
|
56
|
+
"wooks": "^0.7.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "rolldown -c ../../rolldown.config.mjs",
|
|
@@ -11,11 +11,11 @@ A composable workflow framework for Node.js built on async context (AsyncLocalSt
|
|
|
11
11
|
|
|
12
12
|
Read the domain file that matches the task. Do not load all files — only what you need.
|
|
13
13
|
|
|
14
|
-
| Domain | File | Load when...
|
|
15
|
-
| ------------------------------ | ------------------------------ |
|
|
14
|
+
| Domain | File | Load when... |
|
|
15
|
+
| ------------------------------ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
16
|
| Event context (core machinery) | [event-core.md](event-core.md) | Understanding `EventContext`, `key()`/`cached()`/`defineWook()`/`defineEventKind()`/`slot()`, creating custom composables, lazy evaluation and caching, building your own `use*()` functions |
|
|
17
|
-
| Workflow app setup | [core.md](core.md) | Creating a workflow app, `createWfApp`, starting/resuming workflows, error handling, spies, testing, logging, sharing parent event context (`eventContext`), HTTP integration
|
|
18
|
-
| Steps & flows | [workflows.md](workflows.md) | Defining steps (`app.step`), defining flows (`app.flow`), workflow schemas, conditions, loops, user input, parametric steps, `useWfState`, `StepRetriableError`, string-based handlers
|
|
17
|
+
| Workflow app setup | [core.md](core.md) | Creating a workflow app, `createWfApp`, starting/resuming workflows, error handling, spies, testing, logging, sharing parent event context (`eventContext`), HTTP integration |
|
|
18
|
+
| Steps & flows | [workflows.md](workflows.md) | Defining steps (`app.step`), defining flows (`app.flow`), workflow schemas, conditions, loops, user input, parametric steps, `useWfState`, `StepRetriableError`, string-based handlers |
|
|
19
19
|
|
|
20
20
|
## Quick reference
|
|
21
21
|
|
|
@@ -93,7 +93,7 @@ const getCookie = cachedBy((name: string, ctx) => {
|
|
|
93
93
|
|
|
94
94
|
getCookie('session') // extracts + caches
|
|
95
95
|
getCookie('session') // cache hit
|
|
96
|
-
getCookie('theme')
|
|
96
|
+
getCookie('theme') // extracts + caches (different key)
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### `slot<T>()` and `defineEventKind(name, schema)`
|
|
@@ -135,8 +135,8 @@ const childCtx = new EventContext({ logger, parent: parentCtx })
|
|
|
135
135
|
childCtx.seed(workflowKind, { triggerId: 'deploy-42' })
|
|
136
136
|
|
|
137
137
|
// Child sees both its own and parent data via the parent chain
|
|
138
|
-
childCtx.get(httpKind.keys.method)
|
|
139
|
-
childCtx.get(workflowKind.keys.triggerId)
|
|
138
|
+
childCtx.get(httpKind.keys.method) // 'POST' (from parent)
|
|
139
|
+
childCtx.get(workflowKind.keys.triggerId) // 'deploy-42' (local)
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
## EventContext
|
|
@@ -166,8 +166,8 @@ const childCtx = new EventContext({ logger, parent: parentCtx })
|
|
|
166
166
|
childCtx.seed(workflowKind, { triggerId: 'deploy-42' })
|
|
167
167
|
|
|
168
168
|
// child can see its own data AND parent data
|
|
169
|
-
childCtx.get(httpKind.keys.method)
|
|
170
|
-
childCtx.get(workflowKind.keys.triggerId)
|
|
169
|
+
childCtx.get(httpKind.keys.method) // 'GET' (found in parent)
|
|
170
|
+
childCtx.get(workflowKind.keys.triggerId) // 'deploy-42' (found locally)
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
**Methods:**
|
|
@@ -395,9 +395,7 @@ const myKind = defineEventKind('my-event', {
|
|
|
395
395
|
|
|
396
396
|
function handleEvent(data: unknown, source: string, handler: () => unknown) {
|
|
397
397
|
const ctx = new EventContext({ logger: console })
|
|
398
|
-
return run(ctx, () =>
|
|
399
|
-
ctx.seed(myKind, { data, source }, handler)
|
|
400
|
-
)
|
|
398
|
+
return run(ctx, () => ctx.seed(myKind, { data, source }, handler))
|
|
401
399
|
}
|
|
402
400
|
```
|
|
403
401
|
|
|
@@ -413,9 +411,9 @@ createEventContext({ logger }, httpKind, httpSeeds, () => {
|
|
|
413
411
|
run(childCtx, () =>
|
|
414
412
|
childCtx.seed(workflowKind, wfSeeds, () => {
|
|
415
413
|
// Both HTTP and workflow composables work
|
|
416
|
-
const { method } = useRequest()
|
|
417
|
-
const { ctx } = useWfState()
|
|
418
|
-
})
|
|
414
|
+
const { method } = useRequest() // found via parent chain
|
|
415
|
+
const { ctx } = useWfState() // found locally
|
|
416
|
+
}),
|
|
419
417
|
)
|
|
420
418
|
})
|
|
421
419
|
```
|