@rotorsoft/act 0.33.3 → 0.34.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.
Files changed (83) hide show
  1. package/README.md +26 -2
  2. package/package.json +1 -1
  3. package/dist/.tsbuildinfo +0 -1
  4. package/dist/@types/act.d.ts +0 -598
  5. package/dist/@types/act.d.ts.map +0 -1
  6. package/dist/@types/adapters/console-logger.d.ts +0 -41
  7. package/dist/@types/adapters/console-logger.d.ts.map +0 -1
  8. package/dist/@types/adapters/in-memory-cache.d.ts +0 -34
  9. package/dist/@types/adapters/in-memory-cache.d.ts.map +0 -1
  10. package/dist/@types/adapters/in-memory-store.d.ts +0 -181
  11. package/dist/@types/adapters/in-memory-store.d.ts.map +0 -1
  12. package/dist/@types/adapters/index.d.ts +0 -4
  13. package/dist/@types/adapters/index.d.ts.map +0 -1
  14. package/dist/@types/builders/act-builder.d.ts +0 -160
  15. package/dist/@types/builders/act-builder.d.ts.map +0 -1
  16. package/dist/@types/builders/index.d.ts +0 -13
  17. package/dist/@types/builders/index.d.ts.map +0 -1
  18. package/dist/@types/builders/projection-builder.d.ts +0 -101
  19. package/dist/@types/builders/projection-builder.d.ts.map +0 -1
  20. package/dist/@types/builders/slice-builder.d.ts +0 -109
  21. package/dist/@types/builders/slice-builder.d.ts.map +0 -1
  22. package/dist/@types/builders/state-builder.d.ts +0 -424
  23. package/dist/@types/builders/state-builder.d.ts.map +0 -1
  24. package/dist/@types/config.d.ts +0 -119
  25. package/dist/@types/config.d.ts.map +0 -1
  26. package/dist/@types/index.d.ts +0 -14
  27. package/dist/@types/index.d.ts.map +0 -1
  28. package/dist/@types/internal/build-classify.d.ts +0 -44
  29. package/dist/@types/internal/build-classify.d.ts.map +0 -1
  30. package/dist/@types/internal/close-cycle.d.ts +0 -38
  31. package/dist/@types/internal/close-cycle.d.ts.map +0 -1
  32. package/dist/@types/internal/correlate-cycle.d.ts +0 -73
  33. package/dist/@types/internal/correlate-cycle.d.ts.map +0 -1
  34. package/dist/@types/internal/drain-cycle.d.ts +0 -113
  35. package/dist/@types/internal/drain-cycle.d.ts.map +0 -1
  36. package/dist/@types/internal/drain-ratio.d.ts +0 -26
  37. package/dist/@types/internal/drain-ratio.d.ts.map +0 -1
  38. package/dist/@types/internal/drain.d.ts +0 -41
  39. package/dist/@types/internal/drain.d.ts.map +0 -1
  40. package/dist/@types/internal/event-sourcing.d.ts +0 -96
  41. package/dist/@types/internal/event-sourcing.d.ts.map +0 -1
  42. package/dist/@types/internal/index.d.ts +0 -29
  43. package/dist/@types/internal/index.d.ts.map +0 -1
  44. package/dist/@types/internal/merge.d.ts +0 -31
  45. package/dist/@types/internal/merge.d.ts.map +0 -1
  46. package/dist/@types/internal/reactions.d.ts +0 -54
  47. package/dist/@types/internal/reactions.d.ts.map +0 -1
  48. package/dist/@types/internal/settle.d.ts +0 -60
  49. package/dist/@types/internal/settle.d.ts.map +0 -1
  50. package/dist/@types/internal/tracing.d.ts +0 -45
  51. package/dist/@types/internal/tracing.d.ts.map +0 -1
  52. package/dist/@types/lru-map.d.ts +0 -50
  53. package/dist/@types/lru-map.d.ts.map +0 -1
  54. package/dist/@types/ports.d.ts +0 -196
  55. package/dist/@types/ports.d.ts.map +0 -1
  56. package/dist/@types/signals.d.ts +0 -2
  57. package/dist/@types/signals.d.ts.map +0 -1
  58. package/dist/@types/types/action.d.ts +0 -444
  59. package/dist/@types/types/action.d.ts.map +0 -1
  60. package/dist/@types/types/errors.d.ts +0 -284
  61. package/dist/@types/types/errors.d.ts.map +0 -1
  62. package/dist/@types/types/index.d.ts +0 -39
  63. package/dist/@types/types/index.d.ts.map +0 -1
  64. package/dist/@types/types/ports.d.ts +0 -485
  65. package/dist/@types/types/ports.d.ts.map +0 -1
  66. package/dist/@types/types/reaction.d.ts +0 -291
  67. package/dist/@types/types/reaction.d.ts.map +0 -1
  68. package/dist/@types/types/registry.d.ts +0 -74
  69. package/dist/@types/types/registry.d.ts.map +0 -1
  70. package/dist/@types/types/schemas.d.ts +0 -117
  71. package/dist/@types/types/schemas.d.ts.map +0 -1
  72. package/dist/@types/utils.d.ts +0 -54
  73. package/dist/@types/utils.d.ts.map +0 -1
  74. package/dist/chunk-AGWZY6YT.js +0 -127
  75. package/dist/chunk-AGWZY6YT.js.map +0 -1
  76. package/dist/index.cjs +0 -2985
  77. package/dist/index.cjs.map +0 -1
  78. package/dist/index.js +0 -2816
  79. package/dist/index.js.map +0 -1
  80. package/dist/types/index.cjs +0 -166
  81. package/dist/types/index.cjs.map +0 -1
  82. package/dist/types/index.js +0 -33
  83. package/dist/types/index.js.map +0 -1
@@ -1,34 +0,0 @@
1
- import type { Cache, CacheEntry, Schema } from "../types/index.js";
2
- /**
3
- * In-memory LRU cache for stream snapshots.
4
- *
5
- * Backed by an internal `LruMap` for O(1) get/set with LRU eviction.
6
- * Configurable `maxSize` bounds memory usage.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { cache } from "@rotorsoft/act";
11
- * import { InMemoryCache } from "@rotorsoft/act";
12
- *
13
- * cache(new InMemoryCache({ maxSize: 500 }));
14
- * ```
15
- */
16
- export declare class InMemoryCache implements Cache {
17
- private readonly _entries;
18
- constructor(options?: {
19
- maxSize?: number;
20
- });
21
- /** @inheritDoc */
22
- get<TState extends Schema>(stream: string): Promise<CacheEntry<TState> | undefined>;
23
- /** @inheritDoc */
24
- set<TState extends Schema>(stream: string, entry: CacheEntry<TState>): Promise<void>;
25
- /** @inheritDoc */
26
- invalidate(stream: string): Promise<void>;
27
- /** @inheritDoc */
28
- clear(): Promise<void>;
29
- /** @inheritDoc */
30
- dispose(): Promise<void>;
31
- /** Current number of entries held by the LRU. */
32
- get size(): number;
33
- }
34
- //# sourceMappingURL=in-memory-cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"in-memory-cache.d.ts","sourceRoot":"","sources":["../../../src/adapters/in-memory-cache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;;;;;;;GAaG;AAEH,qBAAa,aAAc,YAAW,KAAK;IAIzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;gBAE/C,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAI1C,kBAAkB;IACZ,GAAG,CAAC,MAAM,SAAS,MAAM,EAC7B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAI1C,kBAAkB;IACZ,GAAG,CAAC,MAAM,SAAS,MAAM,EAC7B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GACxB,OAAO,CAAC,IAAI,CAAC;IAIhB,kBAAkB;IACZ,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,kBAAkB;IACZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,kBAAkB;IACZ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,iDAAiD;IACjD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -1,181 +0,0 @@
1
- import type { BlockedLease, Committed, EventMeta, Lease, Message, Query, QueryStreams, QueryStreamsResult, Schema, Schemas, Store, StreamPosition } from "../types/index.js";
2
- /**
3
- * In-memory event store implementation.
4
- *
5
- * This is the default store used by Act when no other store is injected.
6
- * It stores all events in memory and is suitable for:
7
- * - Development and prototyping
8
- * - Unit and integration testing
9
- * - Demonstrations and examples
10
- *
11
- * **Not suitable for production** - all data is lost when the process exits.
12
- * Use {@link PostgresStore} for production deployments.
13
- *
14
- * The in-memory store provides:
15
- * - Full {@link Store} interface implementation
16
- * - Optimistic concurrency control
17
- * - Stream leasing for distributed processing simulation
18
- * - Snapshot support
19
- * - Fast performance (no I/O overhead)
20
- *
21
- * @example Using in tests
22
- * ```typescript
23
- * import { store } from "@rotorsoft/act";
24
- *
25
- * describe("Counter", () => {
26
- * beforeEach(async () => {
27
- * // Reset store between tests
28
- * await store().seed();
29
- * });
30
- *
31
- * it("increments", async () => {
32
- * await app.do("increment", target, { by: 5 });
33
- * const snapshot = await app.load(Counter, "counter-1");
34
- * expect(snapshot.state.count).toBe(5);
35
- * });
36
- * });
37
- * ```
38
- *
39
- * @example Explicit instantiation
40
- * ```typescript
41
- * import { InMemoryStore } from "@rotorsoft/act";
42
- *
43
- * const testStore = new InMemoryStore();
44
- * await testStore.seed();
45
- *
46
- * // Use for specific test scenarios
47
- * await testStore.commit("test-stream", events, meta);
48
- * ```
49
- *
50
- * @example Querying events
51
- * ```typescript
52
- * const events: any[] = [];
53
- * await store().query(
54
- * (event) => events.push(event),
55
- * { stream: "test-stream" }
56
- * );
57
- * console.log(`Found ${events.length} events`);
58
- * ```
59
- *
60
- * @see {@link Store} for the interface definition
61
- * @see {@link PostgresStore} for production use
62
- * @see {@link store} for injecting stores
63
- *
64
- * @category Adapters
65
- */
66
- export declare class InMemoryStore implements Store {
67
- private _events;
68
- private _streams;
69
- private _streamVersions;
70
- private _maxEventIdByStream;
71
- private _maxNonSnapEventId;
72
- private _resetIndexes;
73
- /**
74
- * Dispose of the store and clear all events.
75
- * @returns Promise that resolves when disposal is complete.
76
- */
77
- dispose(): Promise<void>;
78
- /**
79
- * Seed the store with initial data (no-op for in-memory).
80
- * @returns Promise that resolves when seeding is complete.
81
- */
82
- seed(): Promise<void>;
83
- /**
84
- * Drop all data from the store.
85
- * @returns Promise that resolves when the store is cleared.
86
- */
87
- drop(): Promise<void>;
88
- private in_query;
89
- /**
90
- * Query events in the store, optionally filtered by query options.
91
- * @param callback - Function to call for each event.
92
- * @param query - Optional query options.
93
- * @returns The number of events processed.
94
- */
95
- query<E extends Schemas>(callback: (event: Committed<E, keyof E>) => void, query?: Query): Promise<number>;
96
- /**
97
- * Commit one or more events to a stream.
98
- * @param stream - The stream name.
99
- * @param msgs - The events/messages to commit.
100
- * @param meta - Event metadata.
101
- * @param expectedVersion - Optional optimistic concurrency check.
102
- * @returns The committed events with metadata.
103
- * @throws ConcurrencyError if expectedVersion does not match.
104
- */
105
- commit<E extends Schemas>(stream: string, msgs: Message<E, keyof E>[], meta: EventMeta, expectedVersion?: number): Promise<Committed<E, keyof E>[]>;
106
- /**
107
- * Atomically discovers and leases streams for processing.
108
- * Fuses poll + lease into a single operation.
109
- * @param lagging - Max streams from lagging frontier.
110
- * @param leading - Max streams from leading frontier.
111
- * @param by - Lease holder identifier.
112
- * @param millis - Lease duration in milliseconds.
113
- * @returns Granted leases.
114
- */
115
- claim(lagging: number, leading: number, by: string, millis: number): Promise<Lease[]>;
116
- /**
117
- * Registers streams for event processing.
118
- * @param streams - Streams to register with optional source.
119
- * @returns subscribed count and current max watermark.
120
- */
121
- subscribe(streams: Array<{
122
- stream: string;
123
- source?: string;
124
- }>): Promise<{
125
- subscribed: number;
126
- watermark: number;
127
- }>;
128
- /**
129
- * Acknowledge completion of processing for leased streams.
130
- * @param leases - Leases to acknowledge, including last processed watermark and lease holder.
131
- */
132
- ack(leases: Lease[]): Promise<{
133
- stream: string;
134
- source: string | undefined;
135
- at: number;
136
- by: string;
137
- retry: number;
138
- lagging: boolean;
139
- }[]>;
140
- /**
141
- * Block a stream for processing after failing to process and reaching max retries with blocking enabled.
142
- * @param leases - Leases to block, including lease holder and last error message.
143
- * @returns Blocked leases.
144
- */
145
- block(leases: BlockedLease[]): Promise<{
146
- stream: string;
147
- source: string | undefined;
148
- at: number;
149
- by: string;
150
- retry: number;
151
- error: string;
152
- lagging: boolean;
153
- }[]>;
154
- /**
155
- * Reset watermarks for the given streams to -1, clearing retry, blocked,
156
- * error, and lease state so they can be replayed from the beginning.
157
- * @param streams - Stream names to reset.
158
- * @returns Count of streams that were actually reset.
159
- */
160
- reset(streams: string[]): Promise<number>;
161
- /**
162
- * Streams registered subscription positions to the callback, ordered by
163
- * stream name. Returns the highest event id in the store and the count
164
- * of positions emitted.
165
- */
166
- query_streams(callback: (position: StreamPosition) => void, query?: QueryStreams): Promise<QueryStreamsResult>;
167
- /**
168
- * Atomically truncates streams and seeds each with a snapshot or tombstone.
169
- * @param targets - Streams to truncate with optional snapshot state and meta.
170
- * @returns Map keyed by stream name, each entry with `deleted` count and `committed` event.
171
- */
172
- truncate(targets: Array<{
173
- stream: string;
174
- snapshot?: Schema;
175
- meta?: EventMeta;
176
- }>): Promise<Map<string, {
177
- deleted: number;
178
- committed: Committed<Schemas, keyof Schemas>;
179
- }>>;
180
- }
181
- //# sourceMappingURL=in-memory-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"in-memory-store.d.ts","sourceRoot":"","sources":["../../../src/adapters/in-memory-store.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,KAAK,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,EACL,cAAc,EACf,MAAM,mBAAmB,CAAC;AAkI3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,qBAAa,aAAc,YAAW,KAAK;IAEzC,OAAO,CAAC,OAAO,CAA2C;IAE1D,OAAO,CAAC,QAAQ,CAA0C;IAE1D,OAAO,CAAC,eAAe,CAAkC;IAGzD,OAAO,CAAC,mBAAmB,CAAkC;IAE7D,OAAO,CAAC,kBAAkB,CAAM;IAEhC,OAAO,CAAC,aAAa;IAOrB;;;OAGG;IACG,OAAO;IAKb;;;OAGG;IACG,IAAI;IAIV;;;OAGG;IACG,IAAI;IAMV,OAAO,CAAC,QAAQ;IAahB;;;;;OAKG;IACG,KAAK,CAAC,CAAC,SAAS,OAAO,EAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,IAAI,EAChD,KAAK,CAAC,EAAE,KAAK;IAiCf;;;;;;;;OAQG;IACG,MAAM,CAAC,CAAC,SAAS,OAAO,EAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,EAC3B,IAAI,EAAE,SAAS,EACf,eAAe,CAAC,EAAE,MAAM;IA2C1B;;;;;;;;OAQG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IA0DxE;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;;;;IAgBnE;;;OAGG;IACG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE;;;;;;;;IAOzB;;;;OAIG;IACG,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE;;;;;;;;;IAOlC;;;;;OAKG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE;IAa7B;;;;OAIG;IACG,aAAa,CACjB,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC5C,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,kBAAkB,CAAC;IAuD9B;;;;OAIG;IACG,QAAQ,CACZ,OAAO,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,SAAS,CAAC;KAClB,CAAC;iBAmBW,MAAM;mBAAa,SAAS,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC;;CA6BpE"}
@@ -1,4 +0,0 @@
1
- export { ConsoleLogger } from "./console-logger.js";
2
- export { InMemoryCache } from "./in-memory-cache.js";
3
- export { InMemoryStore } from "./in-memory-store.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,160 +0,0 @@
1
- /**
2
- * @module act-builder
3
- * @category Builders
4
- *
5
- * Fluent builder for composing event-sourced applications.
6
- */
7
- import { Act, type ActOptions } from "../act.js";
8
- import type { Actor, Committed, EventRegister, IAct, ReactionOptions, ReactionResolver, Schema, SchemaRegister, Schemas, Snapshot, State } from "../types/index.js";
9
- import type { Projection } from "./projection-builder.js";
10
- import type { Slice } from "./slice-builder.js";
11
- /**
12
- * Fluent builder interface for composing event-sourced applications.
13
- *
14
- * Provides a chainable API for:
15
- * - Registering states via `.withState()`
16
- * - Registering slices via `.withSlice()`
17
- * - Registering projections via `.withProjection()`
18
- * - Locking a custom actor type via `.withActor<TActor>()`
19
- * - Defining event reactions via `.on()` → `.do()` → `.to()`
20
- * - Building the orchestrator via `.build()`
21
- *
22
- * @template TSchemaReg - Schema register for states (maps action names to state schemas)
23
- * @template TEvents - Event schemas (maps event names to event data schemas)
24
- * @template TActions - Action schemas (maps action names to action payload schemas)
25
- * @template TStateMap - Map of state names to state schemas
26
- * @template TActor - Actor type extending base Actor
27
- *
28
- * @see {@link act} for usage examples
29
- * @see {@link Act} for the built orchestrator API
30
- */
31
- export type ActBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor> = {
32
- /**
33
- * Registers a state definition with the builder.
34
- *
35
- * State names, action names, and event names must be unique across the
36
- * application (partial states with the same name are merged automatically).
37
- *
38
- * @throws {Error} If duplicate action or event names are detected
39
- */
40
- withState: <TNewState extends Schema, TNewEvents extends Schemas, TNewActions extends Schemas, TNewName extends string = string>(state: State<TNewState, TNewEvents, TNewActions, TNewName>) => ActBuilder<TSchemaReg & {
41
- [K in keyof TNewActions]: TNewState;
42
- }, TEvents & TNewEvents, TActions & TNewActions, TStateMap & {
43
- [K in TNewName]: TNewState;
44
- }, TActor>;
45
- /**
46
- * Registers a slice with the builder.
47
- *
48
- * Merges all the slice's states and reactions into the application.
49
- * State names, action names, and event names must be unique across the
50
- * application (partial states with the same name are merged automatically).
51
- *
52
- * @throws {Error} If duplicate action or event names are detected
53
- */
54
- withSlice: <TNewSchemaReg extends SchemaRegister<TNewActions>, TNewEvents extends Schemas, TNewActions extends Schemas, TNewMap extends Record<string, Schema>>(slice: Slice<TNewSchemaReg, TNewEvents, TNewActions, TNewMap>) => ActBuilder<TSchemaReg & TNewSchemaReg, TEvents & TNewEvents, TActions & TNewActions, TStateMap & TNewMap, TActor>;
55
- /**
56
- * Registers a standalone projection with the builder.
57
- *
58
- * The projection's events must be a subset of events already registered
59
- * via `.withState()` or `.withSlice()`.
60
- */
61
- withProjection: <TNewEvents extends Schemas>(projection: [Exclude<keyof TNewEvents, keyof TEvents>] extends [never] ? Projection<TNewEvents> : never) => ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
62
- /**
63
- * Locks a custom actor type for this application.
64
- *
65
- * This is a pure type-level method — it returns the same builder at
66
- * runtime but narrows the `TActor` generic so that `app.do()` and
67
- * reaction dispatchers require the richer actor shape.
68
- *
69
- * @template TNewActor - Custom actor type extending base Actor
70
- * @returns The same builder with `TActor` locked to `TNewActor`
71
- *
72
- * @example
73
- * ```typescript
74
- * type MyActor = { id: string; name: string; role: string; tenantId: string };
75
- *
76
- * const app = act()
77
- * .withActor<MyActor>()
78
- * .withState(Counter)
79
- * .build();
80
- *
81
- * // Now app.do() requires MyActor in the target
82
- * await app.do("increment", {
83
- * stream: "counter-1",
84
- * actor: { id: "1", name: "Alice", role: "admin", tenantId: "t1" }
85
- * }, { by: 5 });
86
- * ```
87
- */
88
- withActor: <TNewActor extends Actor>() => ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TNewActor>;
89
- /**
90
- * Begins defining a reaction to a specific event.
91
- *
92
- * Reactions are event handlers that respond to state changes. They can trigger
93
- * additional actions, update external systems, or perform side effects. Reactions
94
- * are processed asynchronously during drain cycles.
95
- *
96
- * @template TKey - Event name (must be a registered event)
97
- * @param event - The event name to react to
98
- * @returns An object with `.do()` method to define the reaction handler
99
- */
100
- on: <TKey extends keyof TEvents>(event: TKey) => {
101
- do: (handler: (event: Committed<TEvents, TKey>, stream: string, app: IAct<TEvents, TActions, TActor>) => Promise<Snapshot<Schema, TEvents> | void>, options?: Partial<ReactionOptions>) => ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor> & {
102
- to: (resolver: ReactionResolver<TEvents, TKey> | string) => ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
103
- };
104
- };
105
- /**
106
- * Builds and returns the Act orchestrator instance.
107
- *
108
- * @param options - Optional runtime overrides (see {@link ActOptions}).
109
- * @returns The Act orchestrator instance
110
- *
111
- * @see {@link Act} for available orchestrator methods
112
- */
113
- build: (options?: ActOptions) => Act<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
114
- /**
115
- * The registered event schemas and their reaction maps.
116
- */
117
- readonly events: EventRegister<TEvents>;
118
- };
119
- /**
120
- * Creates a new Act orchestrator builder for composing event-sourced applications.
121
- *
122
- * @example Basic application with single state
123
- * ```typescript
124
- * const app = act()
125
- * .withState(Counter)
126
- * .build();
127
- * ```
128
- *
129
- * @example Application with custom actor type
130
- * ```typescript
131
- * type MyActor = { id: string; name: string; role: string };
132
- *
133
- * const app = act()
134
- * .withActor<MyActor>()
135
- * .withState(Counter)
136
- * .build();
137
- * ```
138
- *
139
- * @example Application with slices (vertical slice architecture)
140
- * ```typescript
141
- * const CounterSlice = slice()
142
- * .withState(Counter)
143
- * .on("Incremented")
144
- * .do(async (event) => { console.log("incremented!"); })
145
- * .to("counter-target")
146
- * .build();
147
- *
148
- * const app = act()
149
- * .withSlice(CounterSlice)
150
- * .build();
151
- * ```
152
- *
153
- *
154
- * @see {@link ActBuilder} for available builder methods
155
- * @see {@link Act} for orchestrator API methods
156
- * @see {@link state} for defining states
157
- * @see {@link slice} for defining slices
158
- */
159
- export declare function act<TSchemaReg extends SchemaRegister<TActions> = {}, TEvents extends Schemas = {}, TActions extends Schemas = {}, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor>(): ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
160
- //# sourceMappingURL=act-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"act-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/act-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAOjD,OAAO,KAAK,EACV,KAAK,EAEL,SAAS,EACT,aAAa,EACb,IAAI,EAEJ,eAAe,EACf,gBAAgB,EAEhB,MAAM,EACN,cAAc,EACd,OAAO,EACP,QAAQ,EACR,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAoBhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,UAAU,CACpB,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EAExB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,IAC1B;IACF;;;;;;;OAOG;IACH,SAAS,EAAE,CACT,SAAS,SAAS,MAAM,EACxB,UAAU,SAAS,OAAO,EAC1B,WAAW,SAAS,OAAO,EAC3B,QAAQ,SAAS,MAAM,GAAG,MAAM,EAEhC,KAAK,EAA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**
2
- * @module builders
3
- * @category Builders
4
- *
5
- * Public-facing fluent builders for composing event-sourced applications:
6
- * `state` (aggregates), `slice` (vertical-slice modules), `projection`
7
- * (read-model updaters), and `act` (the orchestrator builder).
8
- */
9
- export * from "./act-builder.js";
10
- export * from "./projection-builder.js";
11
- export * from "./slice-builder.js";
12
- export * from "./state-builder.js";
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -1,101 +0,0 @@
1
- /**
2
- * @module projection-builder
3
- * @category Builders
4
- *
5
- * Fluent builder for composing projection handlers — read-model updaters
6
- * that react to events and update external state (databases, caches, etc.).
7
- *
8
- * Projections differ from slices: they don't contain states, don't dispatch
9
- * actions, and are pure side-effect handlers routed to a named stream.
10
- */
11
- import type { ZodType } from "zod";
12
- import type { BatchHandler, Committed, EventRegister, ReactionResolver, Schema, Schemas } from "../types/index.js";
13
- /**
14
- * A self-contained projection grouping read-model update handlers.
15
- * Projections are composed into an Act orchestrator via `act().withProjection(projection)`.
16
- *
17
- * @template TEvents - Event schemas handled by this projection
18
- */
19
- export type Projection<TEvents extends Schemas> = {
20
- readonly _tag: "Projection";
21
- readonly events: EventRegister<TEvents>;
22
- readonly target?: string;
23
- readonly batchHandler?: BatchHandler<TEvents>;
24
- };
25
- /** Helper: a single-key record mapping an event name to its Zod schema. */
26
- type EventEntry<TKey extends string = string, TData extends Schema = Schema> = {
27
- [P in TKey]: ZodType<TData>;
28
- };
29
- /** Infer the handler-result type after registering one event. */
30
- type DoResult<TEvents extends Schemas, TKey extends string, TData extends Schema, TTarget extends string | undefined = undefined> = ProjectionBuilder<TEvents & {
31
- [P in TKey]: TData;
32
- }, TTarget> & {
33
- to: (resolver: ReactionResolver<TEvents & {
34
- [P in TKey]: TData;
35
- }, TKey> | string) => ProjectionBuilder<TEvents & {
36
- [P in TKey]: TData;
37
- }, TTarget>;
38
- };
39
- /**
40
- * Fluent builder interface for composing projections.
41
- *
42
- * When a static target is provided via `projection("target")`, the builder
43
- * exposes a `.batch()` method for registering a batch handler that processes
44
- * all events in a single call.
45
- *
46
- * @template TEvents - Event schemas
47
- * @template TTarget - Static target string or undefined
48
- */
49
- export type ProjectionBuilder<TEvents extends Schemas, TTarget extends string | undefined = undefined> = {
50
- /**
51
- * Begins defining a projection handler for a specific event.
52
- *
53
- * Pass a `{ EventName: schema }` record — use shorthand `{ EventName }`
54
- * when the variable name matches the event name. The key becomes the
55
- * event name, the value the Zod schema.
56
- */
57
- on: <TKey extends string, TData extends Schema>(entry: EventEntry<TKey, TData>) => {
58
- do: (handler: (event: Committed<TEvents & {
59
- [P in TKey]: TData;
60
- }, TKey>, stream: string) => Promise<void>) => DoResult<TEvents, TKey, TData, TTarget>;
61
- };
62
- /**
63
- * Builds and returns the Projection data structure.
64
- */
65
- build: () => Projection<TEvents>;
66
- /**
67
- * The registered event schemas and their reaction maps.
68
- */
69
- readonly events: EventRegister<TEvents>;
70
- } & (TTarget extends string ? {
71
- /**
72
- * Registers a batch handler that processes all events in a single call.
73
- *
74
- * Only available on projections with a static target (`projection("target")`).
75
- * The handler receives a discriminated union of all declared events,
76
- * enabling bulk DB operations in a single transaction.
77
- *
78
- * When defined, the batch handler is always called — even for a single event.
79
- * Individual `.do()` handlers serve as fallback for projections without `.batch()`.
80
- */
81
- batch: (handler: BatchHandler<TEvents>) => {
82
- build: () => Projection<TEvents>;
83
- };
84
- } : {});
85
- /**
86
- * Creates a new projection builder with a static target stream.
87
- *
88
- * All handlers inherit the target resolver automatically. Enables `.batch()`
89
- * for bulk event processing in a single transaction.
90
- *
91
- * @param target - Static target stream for all handlers
92
- */
93
- export declare function projection<TEvents extends Schemas = {}>(target: string): ProjectionBuilder<TEvents, string>;
94
- /**
95
- * Creates a new projection builder without a default target.
96
- *
97
- * Use per-handler `.to()` to route events to different streams.
98
- */
99
- export declare function projection<TEvents extends Schemas = {}>(target?: undefined): ProjectionBuilder<TEvents, undefined>;
100
- export {};
101
- //# sourceMappingURL=projection-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"projection-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/projection-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,aAAa,EAEb,gBAAgB,EAChB,MAAM,EACN,OAAO,EACR,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,OAAO,IAAI;IAChD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C,CAAC;AAEF,2EAA2E;AAC3E,KAAK,UAAU,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;KAC5E,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;CAC5B,CAAC;AAEF,iEAAiE;AACjE,KAAK,QAAQ,CACX,OAAO,SAAS,OAAO,EACvB,IAAI,SAAS,MAAM,EACnB,KAAK,SAAS,MAAM,EACpB,OAAO,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,IAC5C,iBAAiB,CAAC,OAAO,GAAG;KAAG,CAAC,IAAI,IAAI,GAAG,KAAK;CAAE,EAAE,OAAO,CAAC,GAAG;IACjE,EAAE,EAAE,CACF,QA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iB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,GAAG,EAAE,EACrD,MAAM,CAAC,EAAE,SAAS,GACjB,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC"}
@@ -1,109 +0,0 @@
1
- import type { Actor, Committed, EventRegister, IAct, ReactionOptions, ReactionResolver, Schema, SchemaRegister, Schemas, Snapshot, State } from "../types/index.js";
2
- import type { Projection } from "./projection-builder.js";
3
- /**
4
- * A self-contained functional slice grouping partial states with their
5
- * scoped reactions. Slices are composed into an Act orchestrator via
6
- * `act().withSlice(slice)`.
7
- *
8
- * @template TSchemaReg - Schema register for states
9
- * @template TEvents - Event schemas from this slice's states
10
- * @template TActions - Action schemas from this slice's states
11
- * @template TStateMap - Map of state names to state schemas
12
- * @template TActor - Actor type extending base Actor
13
- */
14
- export type Slice<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor> = {
15
- readonly _tag: "Slice";
16
- readonly states: Map<string, State<any, any, any>>;
17
- readonly events: EventRegister<TEvents>;
18
- readonly projections: ReadonlyArray<Projection<any>>;
19
- /** @internal phantom field for type-level state schema tracking */
20
- readonly _S?: TSchemaReg;
21
- /** @internal phantom field for type-level state name tracking */
22
- readonly _M?: TStateMap;
23
- /** @internal phantom field for type-level actor tracking */
24
- readonly _TActor?: TActor;
25
- };
26
- /**
27
- * Fluent builder interface for composing functional slices.
28
- *
29
- * Provides a chainable API for registering states and projections,
30
- * and defining reactions scoped to the slice's own events.
31
- *
32
- * @template TSchemaReg - Schema register for states
33
- * @template TEvents - Event schemas
34
- * @template TActions - Action schemas
35
- * @template TStateMap - Map of state names to state schemas
36
- * @template TActor - Actor type extending base Actor
37
- */
38
- export type SliceBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor> = {
39
- /**
40
- * Registers a state definition with the slice.
41
- *
42
- * Include every state whose actions your reaction handlers need to
43
- * dispatch. Duplicate registrations (same state in multiple slices)
44
- * are handled automatically at composition time.
45
- */
46
- withState: <TNewState extends Schema, TNewEvents extends Schemas, TNewActions extends Schemas, TNewName extends string = string>(state: State<TNewState, TNewEvents, TNewActions, TNewName>) => SliceBuilder<TSchemaReg & {
47
- [K in keyof TNewActions]: TNewState;
48
- }, TEvents & TNewEvents, TActions & TNewActions, TStateMap & {
49
- [K in TNewName]: TNewState;
50
- }, TActor>;
51
- /**
52
- * Embeds a built Projection within this slice. The projection's events
53
- * must be a subset of events from states already registered via
54
- * `.withState()`. Projection handlers preserve their `(event, stream)`
55
- * signature and do not receive the app interface.
56
- */
57
- withProjection: <TNewEvents extends Schemas>(projection: [Exclude<keyof TNewEvents, keyof TEvents>] extends [never] ? Projection<TNewEvents> : never) => SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
58
- /**
59
- * Begins defining a reaction scoped to this slice's events.
60
- */
61
- on: <TKey extends keyof TEvents>(event: TKey) => {
62
- do: (handler: (event: Committed<TEvents, TKey>, stream: string, app: IAct<TEvents, TActions, TActor>) => Promise<Snapshot<Schema, TEvents> | void>, options?: Partial<ReactionOptions>) => SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor> & {
63
- to: (resolver: ReactionResolver<TEvents, TKey> | string) => SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
64
- };
65
- };
66
- /**
67
- * Builds and returns the Slice data structure.
68
- */
69
- build: () => Slice<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
70
- /**
71
- * The registered event schemas and their reaction maps.
72
- */
73
- readonly events: EventRegister<TEvents>;
74
- };
75
- /**
76
- * Creates a new slice builder for composing partial states with scoped reactions.
77
- *
78
- * Slices enable vertical slice architecture by grouping related states and
79
- * reactions into self-contained feature modules. Reactions defined in a slice
80
- * are type-scoped to events from that slice's states only.
81
- *
82
- * @example Single-state slice with typed dispatch
83
- * ```typescript
84
- * const CounterSlice = slice()
85
- * .withState(Counter)
86
- * .on("Incremented")
87
- * .do(async (event, _stream, app) => {
88
- * await app.do("reset", target, {});
89
- * })
90
- * .to("counter-target")
91
- * .build();
92
- * ```
93
- *
94
- * @example Cross-state dispatch (include both states)
95
- * ```typescript
96
- * const CreationSlice = slice()
97
- * .withState(TicketCreation)
98
- * .withState(TicketOperations) // handler can dispatch AssignTicket
99
- * .on("TicketOpened").do(async (event, _stream, app) => {
100
- * await app.do("AssignTicket", target, payload, event);
101
- * })
102
- * .build();
103
- * ```
104
- *
105
- * @see {@link SliceBuilder} for builder methods
106
- * @see {@link Slice} for the output type
107
- */
108
- export declare function slice<TSchemaReg extends SchemaRegister<TActions> = {}, TEvents extends Schemas = {}, TActions extends Schemas = {}, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor>(): SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
109
- //# sourceMappingURL=slice-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/slice-builder.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,aAAa,EACb,IAAI,EAEJ,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,cAAc,EACd,OAAO,EACP,QAAQ,EACR,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,CACf,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EAExB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,IAC1B;IACF,QAAQ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