@rotorsoft/act 1.37.8 → 2.0.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.
Files changed (52) hide show
  1. package/README.md +16 -3
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/act.d.ts +5 -4
  4. package/dist/@types/act.d.ts.map +1 -1
  5. package/dist/@types/adapters/in-memory-store.d.ts +2 -2
  6. package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
  7. package/dist/@types/builders/act-builder.d.ts.map +1 -1
  8. package/dist/@types/builders/merge.d.ts.map +1 -1
  9. package/dist/@types/builders/state-builder.d.ts +1 -1
  10. package/dist/@types/internal/classify.d.ts.map +1 -1
  11. package/dist/@types/internal/config.d.ts +11 -0
  12. package/dist/@types/internal/config.d.ts.map +1 -1
  13. package/dist/@types/internal/event-sourcing.d.ts +6 -2
  14. package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
  15. package/dist/@types/internal/tracing.d.ts.map +1 -1
  16. package/dist/@types/internal/zod.d.ts +2 -2
  17. package/dist/@types/ports.d.ts.map +1 -1
  18. package/dist/@types/types/act.d.ts +0 -9
  19. package/dist/@types/types/act.d.ts.map +1 -1
  20. package/dist/@types/types/action.d.ts +36 -32
  21. package/dist/@types/types/action.d.ts.map +1 -1
  22. package/dist/@types/types/builders.d.ts +126 -47
  23. package/dist/@types/types/builders.d.ts.map +1 -1
  24. package/dist/@types/types/errors.d.ts +11 -43
  25. package/dist/@types/types/errors.d.ts.map +1 -1
  26. package/dist/@types/types/ports.d.ts +65 -50
  27. package/dist/@types/types/ports.d.ts.map +1 -1
  28. package/dist/@types/types/reaction.d.ts +3 -3
  29. package/dist/@types/utils.d.ts +19 -11
  30. package/dist/@types/utils.d.ts.map +1 -1
  31. package/dist/{chunk-TSDQDT4S.js → chunk-33D5NQNQ.js} +52 -30
  32. package/dist/chunk-33D5NQNQ.js.map +1 -0
  33. package/dist/{chunk-BCA423WP.cjs → chunk-3CQWJ4UA.cjs} +8 -22
  34. package/dist/chunk-3CQWJ4UA.cjs.map +1 -0
  35. package/dist/{chunk-4UWU5FAN.cjs → chunk-S2BEPQ5Z.cjs} +63 -41
  36. package/dist/chunk-S2BEPQ5Z.cjs.map +1 -0
  37. package/dist/{chunk-I5RF2NFR.js → chunk-UO7HNLSH.js} +7 -21
  38. package/dist/chunk-UO7HNLSH.js.map +1 -0
  39. package/dist/index.cjs +451 -291
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.js +258 -98
  42. package/dist/index.js.map +1 -1
  43. package/dist/test/index.cjs +4 -4
  44. package/dist/test/index.js +2 -2
  45. package/dist/types/index.cjs +2 -4
  46. package/dist/types/index.cjs.map +1 -1
  47. package/dist/types/index.js +1 -3
  48. package/package.json +3 -3
  49. package/dist/chunk-4UWU5FAN.cjs.map +0 -1
  50. package/dist/chunk-BCA423WP.cjs.map +0 -1
  51. package/dist/chunk-I5RF2NFR.js.map +0 -1
  52. package/dist/chunk-TSDQDT4S.js.map +0 -1
package/README.md CHANGED
@@ -20,7 +20,7 @@ For the project-level overview, see the [root README](../../README.md).
20
20
  pnpm add @rotorsoft/act zod
21
21
  ```
22
22
 
23
- The package is ESM only (`"type": "module"`); the examples use top-level `await`.
23
+ The examples use top-level `await`, which needs ESM (`"type": "module"`).
24
24
 
25
25
  For production, also install one of the durable stores: [`@rotorsoft/act-pg`](https://www.npmjs.com/package/@rotorsoft/act-pg) (Postgres) or [`@rotorsoft/act-sqlite`](https://www.npmjs.com/package/@rotorsoft/act-sqlite) (SQLite). The bundled `InMemoryStore` is used by default and is intended for development and tests.
26
26
 
@@ -47,6 +47,19 @@ console.log(snap.state); // { count: 5 }
47
47
 
48
48
  Define state, declare actions, dispatch, load. Everything else — projections, reactions, slices, cross-process drain, time-travel — is more of the same builder calls.
49
49
 
50
+ ## Rules across streams
51
+
52
+ **New in 2.0.** A rule that spans streams, such as a unique email or a limited number of seats, needs no saga. An action loads the other stream with `.loads`, decides, and commits to every stream at once: all of it lands or none of it does.
53
+
54
+ ```ts no-check
55
+ .on({ Enroll })
56
+ .loads(Seats, (data) => `course-${data.course}`, ["SeatTaken"])
57
+ .requires([{ description: "a free seat", holds: (_, __, ___, { Seats }) => Seats.taken < Seats.capacity }])
58
+ .emit((data) => [["Enrolled", data], ["SeatTaken", {}]])
59
+ ```
60
+
61
+ Every pattern, what a race does and what it costs: [Rules across streams](https://rotorsoft.github.io/act-root/docs/guides/rules-across-streams). [Watch it play](https://rotorsoft.github.io/act-root/flows/rules-across-streams.html).
62
+
50
63
  ## API
51
64
 
52
65
  Top-level exports:
@@ -129,8 +142,8 @@ await app.unblock({ stream: "^webhooks-out-" }); // bulk
129
142
 
130
143
  ## Compatibility
131
144
 
132
- - **Node**: >=22.23.3
133
- - **Peer**: `zod` ^4.4.3
145
+ - **Node**: >=22.23.4
146
+ - **Peer**: `zod` ^4.6.7
134
147
  - **Bundled deps**: `@rotorsoft/act-patch` (state reducer)
135
148
  - **Module formats**: ESM + CJS
136
149
  - **TypeScript**: strict mode recommended for full inference