@substrat-run/engine-workorder 0.3.0 → 0.3.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/README.md +20 -25
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -7,36 +7,27 @@ machine, append-only reporting, and a billable snapshot frozen at completion.
|
|
|
7
7
|
It deliberately knows nothing about pricing (the vertical's job) or invoicing (a
|
|
8
8
|
sibling engine, reached only via events).
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## What it owns
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- **The state machine cannot skip states.**
|
|
15
|
-
`planned → in_progress → completed → closed`; invalid transitions throw. No caller
|
|
16
|
-
can complete a planned order or restart a completed one.
|
|
17
|
-
- **Time and material are append-only.** There is no update or delete operation for
|
|
18
|
-
reported entries; corrections are compensating entries, never silent edits.
|
|
12
|
+
- **The state machine cannot skip states** — `planned → in_progress → completed → closed`.
|
|
13
|
+
- **Time and material are append-only** — corrections are compensating entries, never edits.
|
|
19
14
|
- **Attribution comes from the ambient principal**, never from the input.
|
|
20
|
-
- **Every mutation emits a fat event** — `workorder.completed` carries the full
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## The pricing boundary
|
|
15
|
+
- **Every mutation emits a fat event** — `workorder.completed` carries the full billable
|
|
16
|
+
snapshot, so consumers never query back.
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
each with provenance (`sourceType`, `sourceId`) back to the reported entry — validates
|
|
27
|
-
them with exact decimal arithmetic, sums the total, and freezes the snapshot into the
|
|
28
|
-
`workorder.completed` payload.
|
|
18
|
+
## Install
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`report-material`, `complete`, `close`) are default bindings. For custom flows, call
|
|
34
|
-
the exported in-scope functions inside your own operations — same transaction, your
|
|
35
|
-
permission check:
|
|
20
|
+
```sh
|
|
21
|
+
pnpm add @substrat-run/engine-workorder
|
|
22
|
+
```
|
|
36
23
|
|
|
37
24
|
```ts
|
|
38
|
-
import { createWorkOrder, PERM } from '@substrat-run/engine-workorder';
|
|
25
|
+
import { createWorkOrder, PERM, workorderModule } from '@substrat-run/engine-workorder';
|
|
39
26
|
|
|
27
|
+
host.registerModule(workorderModule);
|
|
28
|
+
|
|
29
|
+
// Note: the engine registers no `workorder/create` operation. Creation is an
|
|
30
|
+
// in-scope function, because the vertical must price and label the order first.
|
|
40
31
|
host.defineOperation('acme/ticket-to-order', async (ctx, input) => {
|
|
41
32
|
assertAllowed(await ctx.check(PERM.create));
|
|
42
33
|
return createWorkOrder(ctx, {
|
|
@@ -48,8 +39,12 @@ host.defineOperation('acme/ticket-to-order', async (ctx, input) => {
|
|
|
48
39
|
});
|
|
49
40
|
```
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
**https://substrat.ahlstrand.es/engines/workorder/** — the domain model and invariants, the
|
|
45
|
+
full operation/permission surface, event contracts, and how to compose or extend it.
|
|
46
|
+
|
|
47
|
+
The docs site is the single source of truth; this README deliberately doesn't restate it.
|
|
53
48
|
|
|
54
49
|
## Related packages
|
|
55
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/engine-workorder",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Substrat engine: work orders + time + material — one engine, one state machine, append-only reporting",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -26,14 +26,17 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"zod": "^4.4.3",
|
|
29
|
-
"@substrat-run/contracts": "^0.
|
|
30
|
-
"@substrat-run/kernel": "^0.
|
|
29
|
+
"@substrat-run/contracts": "^0.5.0",
|
|
30
|
+
"@substrat-run/kernel": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"typescript": "^5.6.0"
|
|
33
|
+
"typescript": "^5.6.0",
|
|
34
|
+
"vitest": "^3.0.0",
|
|
35
|
+
"@substrat-run/engine-test-kit": "^0.0.3"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
36
38
|
"build": "tsc -p tsconfig.json",
|
|
37
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
40
|
+
"test": "vitest run"
|
|
38
41
|
}
|
|
39
42
|
}
|