@rotorsoft/act 0.31.1 → 0.32.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.
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @module drain
3
+ * @category Internal
4
+ *
5
+ * Pipeline operations consumed by the drain/correlate loop. Each op is a
6
+ * single async step the orchestrator invokes per drain cycle:
7
+ *
8
+ * - `claim` — atomically discover and lock streams for processing
9
+ * - `fetch` — read events for each leased stream
10
+ * - `ack` — release leases for successfully handled streams
11
+ * - `block` — flag leases that exceeded the retry budget
12
+ * - `subscribe` — register newly correlated streams with the store
13
+ *
14
+ * This module exposes only the bare implementations as plain async functions,
15
+ * mirroring the shape of {@link "event-sourcing"}. Trace decoration is
16
+ * layered on top in {@link "tracing"} and selected by the orchestrator at
17
+ * construction time. No tracing imports here.
18
+ */
19
+ import type { Fetch, Lease, Schemas } from "../types/index.js";
20
+ /** @internal */
21
+ export interface DrainOps<TEvents extends Schemas> {
22
+ claim: typeof claim;
23
+ fetch: typeof fetch<TEvents>;
24
+ ack: typeof ack;
25
+ block: typeof block;
26
+ subscribe: typeof subscribe;
27
+ }
28
+ export declare const claim: (lagging: number, leading: number, by: string, millis: number) => Promise<Lease[]>;
29
+ export declare function fetch<TEvents extends Schemas>(leased: Lease[], eventLimit: number): Promise<Fetch<TEvents>>;
30
+ export declare const ack: (leases: Lease[]) => Promise<Lease[]>;
31
+ export declare const block: (leases: Array<Lease & {
32
+ error: string;
33
+ }>) => Promise<Array<Lease & {
34
+ error: string;
35
+ }>>;
36
+ export declare const subscribe: (streams: Array<{
37
+ stream: string;
38
+ source?: string;
39
+ }>) => Promise<{
40
+ subscribed: number;
41
+ watermark: number;
42
+ }>;
43
+ //# sourceMappingURL=drain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drain.d.ts","sourceRoot":"","sources":["../../../src/internal/drain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH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for event sourcing, snapshotting, and event store interaction.
5
+ * Pure event-sourcing primitives: `snap` persists state checkpoints, `load`
6
+ * reconstructs state by replaying events through reducers, and `action`
7
+ * validates an action, runs invariants, emits events, and commits them
8
+ * atomically.
9
+ *
10
+ * These are the bare implementations — observability is layered on top in
11
+ * {@link "tracing"} and wired by the orchestrator at construction time.
12
+ * No tracing imports here, no module-level mutable state.
6
13
  */
7
- import type { AsOf, Committed, Schema, Schemas, Snapshot, State, Target } from "./types/index.js";
14
+ import type { AsOf, Committed, Schema, Schemas, Snapshot, State, Target } from "../types/index.js";
15
+ /** @internal */
16
+ export interface EsOps {
17
+ snap: typeof snap;
18
+ load: typeof load;
19
+ action: typeof action;
20
+ }
8
21
  /**
9
22
  * Event sourcing utilities for snapshotting, loading, and committing actions/events.
10
23
  * Used internally by Act and state machines.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-sourcing.d.ts","sourceRoot":"","sources":["../../../src/internal/event-sourcing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EAGT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,MAAM,EACP,MAAM,mBAAmB,CAAC;AAK3B,gBAAgB;AAChB,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,MAAM,CAAC;CACvB;AAED;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,SAAS,OAAO,EACvE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC,CAef;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,IAAI,CACxB,MAAM,SAAS,MAAM,EACrB,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EAExB,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EACpC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,EACxD,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkCpC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,MAAM,CAC1B,MAAM,SAAS,MAAM,EACrB,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EACxB,IAAI,SAAS,MAAM,QAAQ,EAE3B,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EACpC,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EACjC,UAAU,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,EAC9C,cAAc,UAAQ,GACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA2GtC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module internal
3
+ * @category Internal
4
+ *
5
+ * Barrel for framework-internal modules. These exports are not part of the
6
+ * public package API and may change between minors. Anything reachable from
7
+ * `@rotorsoft/act`'s top-level barrel (`src/index.ts`) is the public surface;
8
+ * what lives here is implementation detail used by `Act`, the builders, and
9
+ * the orchestrator's pipelines.
10
+ *
11
+ * @internal
12
+ */
13
+ export * from "./drain.js";
14
+ export * from "./event-sourcing.js";
15
+ export * from "./merge.js";
16
+ export * from "./tracing.js";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -5,8 +5,8 @@
5
5
  * Shared utilities for merging partial states and projections across builders.
6
6
  */
7
7
  import { type ZodType } from "zod";
8
- import type { Projection } from "./projection-builder.js";
9
- import type { Schema, State } from "./types/index.js";
8
+ import type { Projection } from "../projection-builder.js";
9
+ import type { Schema, State } from "../types/index.js";
10
10
  /**
11
11
  * Unwraps wrapper types (ZodOptional, ZodNullable, ZodDefault, ZodReadonly)
12
12
  * to find the base type name, e.g. `z.string().optional()` -> `"ZodString"`.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/internal/merge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAMrD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAkBT;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAS,MAAM,EAC9C,QAAQ,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,EAChC,QAAQ,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,GAC/B,MAAM,QAAQ,CAAC,MAAM,CAAC,CAExB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,IAAI,CAwFN;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,IAAI,CAiBN;AAGD,eAAO,MAAM,MAAM,GAAI,YAAY;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;;;CAGnD,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @module tracing
3
+ * @category Internal
4
+ *
5
+ * Centralized observability for the framework's internal pipelines.
6
+ *
7
+ * Trace decorators are higher-order functions that wrap a bare implementation
8
+ * with `logger.trace(...)` calls at well-defined moments — entry points for
9
+ * {@link "event-sourcing"} (`load`, `snap`, `action`) and exit points for the
10
+ * {@link "drain"} pipeline (`claim`, `fetch`, `ack`, `block`,
11
+ * `subscribe`). `action` carries both an entry log (🔵) and a post-commit
12
+ * log (🔴) to preserve the diagnostic value of the historical mid-function
13
+ * trace points.
14
+ *
15
+ * The two factories — {@link buildEs} and {@link buildDrain} — let the
16
+ * orchestrator choose bare or traced variants once at `.build()` time based
17
+ * on the configured log level. Outside this module, no other source file
18
+ * imports tracing primitives.
19
+ */
20
+ import type { Schemas } from "../types/index.js";
21
+ import { type DrainOps } from "./drain.js";
22
+ import { type EsOps } from "./event-sourcing.js";
23
+ /**
24
+ * Selects bare or traced event-sourcing handlers. Called once by the
25
+ * orchestrator constructor.
26
+ *
27
+ * @internal
28
+ */
29
+ export declare function buildEs(level: string): EsOps;
30
+ /**
31
+ * Selects bare or traced drain-pipeline ops. Called once by the orchestrator
32
+ * constructor.
33
+ *
34
+ * @internal
35
+ */
36
+ export declare function buildDrain<TEvents extends Schemas>(level: string): DrainOps<TEvents>;
37
+ //# sourceMappingURL=tracing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../src/internal/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAS,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAgDjD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAS5C;AA8ED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,OAAO,EAChD,KAAK,EAAE,MAAM,GACZ,QAAQ,CAAC,OAAO,CAAC,CAiBnB"}
@@ -1,5 +1,5 @@
1
1
  import { ConsoleLogger } from "./adapters/ConsoleLogger.js";
2
- import type { Cache, Disposable, Disposer, Fetch, Lease, Logger, LogLevel, Schemas, Store } from "./types/index.js";
2
+ import type { Cache, Disposable, Disposer, Logger, Store } from "./types/index.js";
3
3
  /**
4
4
  * Port/adapter infrastructure for the Act framework.
5
5
  *
@@ -187,29 +187,5 @@ export declare const SNAP_EVENT = "__snapshot__";
187
187
  * @see {@link Act.close} for the close-the-books API
188
188
  */
189
189
  export declare const TOMBSTONE_EVENT = "__tombstone__";
190
- /**
191
- * Creates a tracer for detailed drain-cycle logging.
192
- *
193
- * When `logLevel` is `"trace"`, returns functions that log fetch, correlate,
194
- * lease, ack, and block operations. At any other level, returns no-op
195
- * functions to avoid overhead.
196
- *
197
- * @param logLevel - Current log level from configuration
198
- * @returns Object with tracer methods (active or no-op)
199
- *
200
- * @internal Used by {@link Act} to instrument drain cycles.
201
- */
202
- export declare function build_tracer(logLevel: LogLevel): {
203
- fetched: <E extends Schemas>(fetched: Fetch<E>) => void;
204
- correlated: (streams: Array<{
205
- stream: string;
206
- source?: string;
207
- }>) => void;
208
- leased: (leases: Lease[]) => void;
209
- acked: (leases: Lease[]) => void;
210
- blocked: (leases: Array<Lease & {
211
- error: string;
212
- }>) => void;
213
- };
214
190
  export {};
215
191
  //# sourceMappingURL=ports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5D,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,KAAK,EACN,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,4BAA6B,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAMlD;;;GAGG;AACH,KAAK,QAAQ,CAAC,IAAI,SAAS,UAAU,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;AAKlE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,IAAI,SAAS,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,IACnD,UAAU,IAAI,KAAG,IAAI,CAQvC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,GAAG,0EASd,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,KAAK,wCAEhB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,wCAEhB,CAAC;AASH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,Q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,CAAC;SACrE,CAAC;KACH,CAAC;IACF;;OAEG;IACH,KAAK,EAAE,MAAM,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACrE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,KAAK,CAEnB,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,EAChD,OAAO,SAAS,OAAO,GAAG,EAAE,EAC5B,QAAQ,SAAS,OAAO,GAAG,EAAE,EAC7B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,EAE5B,MAAM,GAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAa,EACrD,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACjC,MAAM,GAAE,aAAa,CAAC,OAAO,CAAgC,EAC7D,WAAW,GAAE,UAAU,CAAC,GAAG,CAAC,EAAO,GAClC,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAqFhE"}
@@ -0,0 +1,127 @@
1
+ // src/types/errors.ts
2
+ var Errors = {
3
+ ValidationError: "ERR_VALIDATION",
4
+ InvariantError: "ERR_INVARIANT",
5
+ ConcurrencyError: "ERR_CONCURRENCY",
6
+ StreamClosedError: "ERR_STREAM_CLOSED"
7
+ };
8
+ var ValidationError = class extends Error {
9
+ constructor(target, payload, details) {
10
+ super(`Invalid ${target} payload`);
11
+ this.target = target;
12
+ this.payload = payload;
13
+ this.details = details;
14
+ this.name = Errors.ValidationError;
15
+ }
16
+ };
17
+ var InvariantError = class extends Error {
18
+ constructor(action, payload, target, snapshot, description) {
19
+ super(`${action} failed invariant: ${description}`);
20
+ this.action = action;
21
+ this.payload = payload;
22
+ this.target = target;
23
+ this.snapshot = snapshot;
24
+ this.description = description;
25
+ this.name = Errors.InvariantError;
26
+ }
27
+ };
28
+ var StreamClosedError = class extends Error {
29
+ constructor(stream) {
30
+ super(`Stream "${stream}" is closed (tombstoned)`);
31
+ this.stream = stream;
32
+ this.name = Errors.StreamClosedError;
33
+ }
34
+ };
35
+ var ConcurrencyError = class extends Error {
36
+ constructor(stream, lastVersion, events, expectedVersion) {
37
+ super(
38
+ `Concurrency error committing "${events.map((e) => `${stream}.${e.name}.${JSON.stringify(e.data)}`).join(
39
+ ", "
40
+ )}". Expected version ${expectedVersion} but found version ${lastVersion}.`
41
+ );
42
+ this.stream = stream;
43
+ this.lastVersion = lastVersion;
44
+ this.events = events;
45
+ this.expectedVersion = expectedVersion;
46
+ this.name = Errors.ConcurrencyError;
47
+ }
48
+ };
49
+
50
+ // src/types/schemas.ts
51
+ import { z } from "zod";
52
+ var ZodEmpty = z.record(z.string(), z.never());
53
+ var ActorSchema = z.object({
54
+ id: z.string(),
55
+ name: z.string()
56
+ }).loose().readonly();
57
+ var TargetSchema = z.object({
58
+ stream: z.string(),
59
+ actor: ActorSchema,
60
+ expectedVersion: z.number().optional()
61
+ }).loose().readonly();
62
+ var CausationEventSchema = z.object({
63
+ id: z.number(),
64
+ name: z.string(),
65
+ stream: z.string()
66
+ });
67
+ var EventMetaSchema = z.object({
68
+ correlation: z.string(),
69
+ causation: z.object({
70
+ action: TargetSchema.and(z.object({ name: z.string() })).optional(),
71
+ event: CausationEventSchema.optional()
72
+ })
73
+ }).readonly();
74
+ var CommittedMetaSchema = z.object({
75
+ id: z.number(),
76
+ stream: z.string(),
77
+ version: z.number(),
78
+ created: z.date(),
79
+ meta: EventMetaSchema
80
+ }).readonly();
81
+ var QuerySchema = z.object({
82
+ stream: z.string().optional(),
83
+ names: z.string().array().optional(),
84
+ before: z.number().optional(),
85
+ after: z.number().optional(),
86
+ limit: z.number().optional(),
87
+ created_before: z.date().optional(),
88
+ created_after: z.date().optional(),
89
+ backward: z.boolean().optional(),
90
+ correlation: z.string().optional(),
91
+ with_snaps: z.boolean().optional(),
92
+ stream_exact: z.boolean().optional()
93
+ }).readonly();
94
+
95
+ // src/types/index.ts
96
+ var Environments = [
97
+ "development",
98
+ "test",
99
+ "staging",
100
+ "production"
101
+ ];
102
+ var LogLevels = [
103
+ "fatal",
104
+ "error",
105
+ "warn",
106
+ "info",
107
+ "debug",
108
+ "trace"
109
+ ];
110
+
111
+ export {
112
+ Errors,
113
+ ValidationError,
114
+ InvariantError,
115
+ StreamClosedError,
116
+ ConcurrencyError,
117
+ ZodEmpty,
118
+ ActorSchema,
119
+ TargetSchema,
120
+ CausationEventSchema,
121
+ EventMetaSchema,
122
+ CommittedMetaSchema,
123
+ QuerySchema,
124
+ Environments,
125
+ LogLevels
126
+ };
127
+ //# sourceMappingURL=chunk-JBKZJXQZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/errors.ts","../src/types/schemas.ts","../src/types/index.ts"],"sourcesContent":["import type {\n Actor,\n Message,\n Schema,\n Schemas,\n Snapshot,\n Target,\n} from \"./action.js\";\n\n/**\n * @packageDocumentation\n * @module act/types\n * @category Types\n * Application error type constants and error classes for the Act Framework.\n *\n * - `ERR_VALIDATION`: Schema validation error\n * - `ERR_INVARIANT`: Invariant validation error\n * - `ERR_CONCURRENCY`: Optimistic concurrency validation error on commits\n */\nexport const Errors = {\n ValidationError: \"ERR_VALIDATION\",\n InvariantError: \"ERR_INVARIANT\",\n ConcurrencyError: \"ERR_CONCURRENCY\",\n StreamClosedError: \"ERR_STREAM_CLOSED\",\n} as const;\n\n/**\n * Thrown when an action or event payload fails Zod schema validation.\n *\n * This error indicates that data doesn't match the expected schema defined\n * for an action or event. The `details` property contains the Zod validation\n * error with specific information about what failed.\n *\n * @example Catching validation errors\n * ```typescript\n * import { ValidationError } from \"@rotorsoft/act\";\n *\n * try {\n * await app.do(\"createUser\", target, {\n * email: \"invalid-email\", // Missing @ symbol\n * age: -5 // Negative age\n * });\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.error(\"Validation failed for:\", error.target);\n * console.error(\"Invalid payload:\", error.payload);\n * console.error(\"Validation details:\", error.details);\n * // details contains Zod error with field-level info\n * }\n * }\n * ```\n *\n * @example Logging validation details\n * ```typescript\n * try {\n * await app.do(\"updateProfile\", target, payload);\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * error.details.errors.forEach((err) => {\n * console.error(`Field ${err.path.join(\".\")}: ${err.message}`);\n * });\n * }\n * }\n * ```\n *\n * @see {@link https://zod.dev | Zod documentation} for validation details\n */\nexport class ValidationError extends Error {\n constructor(\n /** The type of target being validated (e.g., \"action\", \"event\") */\n public readonly target: string,\n /** The invalid payload that failed validation */\n public readonly payload: any,\n /** Zod validation error details */\n public readonly details: any\n ) {\n super(`Invalid ${target} payload`);\n this.name = Errors.ValidationError;\n }\n}\n\n/**\n * Thrown when a business rule (invariant) is violated during action execution.\n *\n * Invariants are conditions that must hold true for an action to succeed.\n * They're checked after loading the current state but before emitting events.\n * This error provides complete context about what action was attempted and\n * why it was rejected.\n *\n * @template TState - State schema type\n * @template TEvents - Event schemas type\n * @template TActions - Action schemas type\n * @template TKey - Action name\n * @template TActor - Actor type extending base Actor\n *\n * @example Catching invariant violations\n * ```typescript\n * import { InvariantError } from \"@rotorsoft/act\";\n *\n * try {\n * await app.do(\"withdraw\",\n * { stream: \"account-123\", actor: { id: \"user1\", name: \"Alice\" } },\n * { amount: 1000 }\n * );\n * } catch (error) {\n * if (error instanceof InvariantError) {\n * console.error(\"Action:\", error.action);\n * console.error(\"Reason:\", error.description);\n * console.error(\"Current state:\", error.snapshot.state);\n * console.error(\"Attempted payload:\", error.payload);\n * }\n * }\n * ```\n *\n * @example User-friendly error messages\n * ```typescript\n * try {\n * await app.do(\"closeTicket\", target, payload);\n * } catch (error) {\n * if (error instanceof InvariantError) {\n * // Present friendly message to user\n * if (error.description === \"Ticket must be open\") {\n * return { error: \"This ticket is already closed\" };\n * } else if (error.description === \"Not authorized\") {\n * return { error: \"You don't have permission to close this ticket\" };\n * }\n * }\n * }\n * ```\n *\n * @example Logging with context\n * ```typescript\n * try {\n * await app.do(\"transfer\", target, { to: \"account2\", amount: 500 });\n * } catch (error) {\n * if (error instanceof InvariantError) {\n * logger.error({\n * action: error.action,\n * stream: error.target.stream,\n * actor: error.target.actor,\n * reason: error.description,\n * balance: error.snapshot.state.balance,\n * attempted: error.payload.amount\n * }, \"Invariant violation\");\n * }\n * }\n * ```\n *\n * @see {@link Invariant} for defining business rules\n */\nexport class InvariantError<\n TState extends Schema,\n TEvents extends Schemas,\n TActions extends Schemas,\n TKey extends keyof TActions,\n TActor extends Actor = Actor,\n> extends Error {\n constructor(\n /** The action that was attempted */\n readonly action: TKey,\n /** The action payload that was provided */\n readonly payload: Readonly<TActions[TKey]>,\n /** The target stream and actor context */\n readonly target: Target<TActor>,\n /** The current state snapshot when invariant was checked */\n readonly snapshot: Snapshot<TState, TEvents>,\n /** Human-readable description of why the invariant failed */\n readonly description: string\n ) {\n super(`${action as string} failed invariant: ${description}`);\n this.name = Errors.InvariantError;\n }\n}\n\n/**\n * Thrown when optimistic concurrency control detects a conflict.\n *\n * This error occurs when trying to commit events to a stream that has been\n * modified by another process since it was last loaded. The version number\n * doesn't match expectations, indicating a concurrent modification.\n *\n * This is a normal occurrence in distributed systems and should be handled\n * by reloading the current state and retrying the action.\n *\n * @example Handling concurrency conflicts with retry\n * ```typescript\n * import { ConcurrencyError } from \"@rotorsoft/act\";\n *\n * async function transferWithRetry(from, to, amount, maxRetries = 3) {\n * for (let attempt = 0; attempt < maxRetries; attempt++) {\n * try {\n * await app.do(\"transfer\",\n * { stream: from, actor: currentUser },\n * { to, amount }\n * );\n * return { success: true };\n * } catch (error) {\n * if (error instanceof ConcurrencyError) {\n * if (attempt < maxRetries - 1) {\n * console.log(`Concurrent modification detected, retrying... (${attempt + 1}/${maxRetries})`);\n * await sleep(100 * Math.pow(2, attempt)); // Exponential backoff\n * continue;\n * }\n * }\n * throw error;\n * }\n * }\n * return { success: false, reason: \"Too many concurrent modifications\" };\n * }\n * ```\n *\n * @example Logging concurrency conflicts\n * ```typescript\n * try {\n * await app.do(\"updateInventory\", target, payload);\n * } catch (error) {\n * if (error instanceof ConcurrencyError) {\n * logger.warn({\n * stream: error.stream,\n * expectedVersion: error.expectedVersion,\n * actualVersion: error.lastVersion,\n * events: error.events.map(e => e.name)\n * }, \"Concurrent modification detected\");\n * }\n * }\n * ```\n *\n * @example User feedback for conflicts\n * ```typescript\n * try {\n * await app.do(\"editDocument\", target, { content: newContent });\n * } catch (error) {\n * if (error instanceof ConcurrencyError) {\n * return {\n * error: \"This document was modified by another user. Please refresh and try again.\",\n * code: \"CONCURRENT_MODIFICATION\"\n * };\n * }\n * }\n * ```\n *\n * @see {@link Store.commit} for version checking details\n */\n/**\n * Thrown when attempting to write to a stream that has been closed\n * with a tombstone event.\n *\n * A tombstoned stream is permanently closed — no further actions can\n * be executed against it. The only way to reopen a tombstoned stream\n * is through `Act.close()` with a `restart` callback.\n *\n * @example\n * ```typescript\n * import { StreamClosedError } from \"@rotorsoft/act\";\n *\n * try {\n * await app.do(\"updateTicket\", target, payload);\n * } catch (error) {\n * if (error instanceof StreamClosedError) {\n * console.error(`Stream ${error.stream} is closed`);\n * }\n * }\n * ```\n *\n * @see {@link Act.close} for closing streams\n */\nexport class StreamClosedError extends Error {\n constructor(\n /** The stream that is closed */\n public readonly stream: string\n ) {\n super(`Stream \"${stream}\" is closed (tombstoned)`);\n this.name = Errors.StreamClosedError;\n }\n}\n\nexport class ConcurrencyError extends Error {\n constructor(\n /** The stream that had the concurrent modification */\n public readonly stream: string,\n /** The actual current version in the store */\n public readonly lastVersion: number,\n /** The events that were being committed */\n public readonly events: Message<Schemas, keyof Schemas>[],\n /** The version number that was expected */\n public readonly expectedVersion: number\n ) {\n super(\n `Concurrency error committing \"${events\n .map((e) => `${stream}.${e.name}.${JSON.stringify(e.data)}`)\n .join(\n \", \"\n )}\". Expected version ${expectedVersion} but found version ${lastVersion}.`\n );\n this.name = Errors.ConcurrencyError;\n }\n}\n","import { z, ZodObject, ZodRawShape } from \"zod\";\n\n/**\n * @packageDocumentation\n * @module act/types\n * @category Types\n * Zod schemas and helpers for the Act Framework.\n */\n\n/**\n * An empty Zod schema (no properties).\n */\nexport const ZodEmpty = z.record(z.string(), z.never());\n\n/**\n * Zod schema for an actor (user, system, etc.).\n */\nexport const ActorSchema = z\n .object({\n id: z.string(),\n name: z.string(),\n })\n .loose()\n .readonly();\n\n/**\n * Zod schema for a target (stream and actor info).\n */\nexport const TargetSchema = z\n .object({\n stream: z.string(),\n actor: ActorSchema,\n expectedVersion: z.number().optional(),\n })\n .loose()\n .readonly();\n\n/**\n * Zod schema for causation event metadata.\n */\nexport const CausationEventSchema = z.object({\n id: z.number(),\n name: z.string(),\n stream: z.string(),\n});\n\n/**\n * Zod schema for event metadata (correlation and causation).\n */\nexport const EventMetaSchema = z\n .object({\n correlation: z.string(),\n causation: z.object({\n action: TargetSchema.and(z.object({ name: z.string() })).optional(),\n event: CausationEventSchema.optional(),\n }),\n })\n .readonly();\n\n/**\n * Zod schema for committed event metadata (id, stream, version, created, meta).\n */\nexport const CommittedMetaSchema = z\n .object({\n id: z.number(),\n stream: z.string(),\n version: z.number(),\n created: z.date(),\n meta: EventMetaSchema,\n })\n .readonly();\n\n/**\n * Type representing the full state schema for a domain.\n * @property events - Map of event names to Zod schemas.\n * @property actions - Map of action names to Zod schemas.\n * @property state - Zod schema for the state object.\n */\nexport type StateSchema = Readonly<{\n events: Record<string, ZodObject<ZodRawShape> | typeof ZodEmpty>;\n actions: Record<string, ZodObject<ZodRawShape> | typeof ZodEmpty>;\n state: ZodObject<ZodRawShape>;\n}>;\n\n/**\n * Query options for event store queries.\n */\nexport const QuerySchema = z\n .object({\n stream: z.string().optional(),\n names: z.string().array().optional(),\n before: z.number().optional(),\n after: z.number().optional(),\n limit: z.number().optional(),\n created_before: z.date().optional(),\n created_after: z.date().optional(),\n backward: z.boolean().optional(),\n correlation: z.string().optional(),\n with_snaps: z.boolean().optional(),\n stream_exact: z.boolean().optional(),\n })\n .readonly();\n","/**\n * @packageDocumentation\n * @module act/types\n * Barrel file for Act Framework core types.\n *\n * Re-exports all major type definitions for actions, errors, ports, reactions, registries, and schemas.\n * Also defines common environment and log level types/constants for configuration and logging.\n *\n * @remarks\n * Import from this module to access all core framework types in one place.\n */\nexport type * from \"./action.js\";\nexport * from \"./errors.js\";\nexport type * from \"./ports.js\";\nexport type * from \"./reaction.js\";\nexport type * from \"./registry.js\";\nexport * from \"./schemas.js\";\n\n/**\n * Supported runtime environments for the framework.\n * - `development`: Local development\n * - `test`: Automated testing\n * - `staging`: Pre-production\n * - `production`: Live/production\n */\nexport const Environments = [\n \"development\",\n \"test\",\n \"staging\",\n \"production\",\n] as const;\n\n/**\n * Type representing a valid environment string.\n */\nexport type Environment = (typeof Environments)[number];\n\n/**\n * Supported log levels for framework logging.\n * - `fatal`, `error`, `warn`, `info`, `debug`, `trace`\n */\nexport const LogLevels = [\n \"fatal\",\n \"error\",\n \"warn\",\n \"info\",\n \"debug\",\n \"trace\",\n] as const;\n\n/**\n * Type representing a valid log level string.\n */\nexport type LogLevel = (typeof LogLevels)[number];\n"],"mappings":";AAmBO,IAAM,SAAS;AAAA,EACpB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,mBAAmB;AACrB;AA2CO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YAEkB,QAEA,SAEA,SAChB;AACA,UAAM,WAAW,MAAM,UAAU;AANjB;AAEA;AAEA;AAGhB,SAAK,OAAO,OAAO;AAAA,EACrB;AACF;AAuEO,IAAM,iBAAN,cAMG,MAAM;AAAA,EACd,YAEW,QAEA,SAEA,QAEA,UAEA,aACT;AACA,UAAM,GAAG,MAAgB,sBA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