@rotorsoft/act 0.32.5 → 0.32.7
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/dist/.tsbuildinfo +1 -1
- package/dist/@types/adapters/{ConsoleLogger.d.ts → console-logger.d.ts} +2 -2
- package/dist/@types/adapters/console-logger.d.ts.map +1 -0
- package/dist/@types/adapters/{InMemoryCache.d.ts → in-memory-cache.d.ts} +1 -1
- package/dist/@types/adapters/in-memory-cache.d.ts.map +1 -0
- package/dist/@types/adapters/{InMemoryStore.d.ts → in-memory-store.d.ts} +5 -1
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -0
- package/dist/@types/adapters/index.d.ts +3 -3
- package/dist/@types/adapters/index.d.ts.map +1 -1
- package/dist/@types/config.d.ts.map +1 -1
- package/dist/@types/internal/close-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/lru-map.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +1 -1
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/types/errors.d.ts.map +1 -1
- package/dist/@types/utils.d.ts +27 -296
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/{chunk-JBKZJXQZ.js → chunk-IDEYGKT4.js} +2 -2
- package/dist/{chunk-JBKZJXQZ.js.map → chunk-IDEYGKT4.js.map} +1 -1
- package/dist/index.cjs +127 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +127 -48
- package/dist/index.js.map +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +2 -2
- package/dist/@types/adapters/ConsoleLogger.d.ts.map +0 -1
- package/dist/@types/adapters/InMemoryCache.d.ts.map +0 -1
- package/dist/@types/adapters/InMemoryStore.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;iBAWxB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AA0CpD;;;;GAIG;AACH,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKd,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAsBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,MAAM,QAAO,MAwBzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/close-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,MAAM,EAEN,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"close-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/close-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,MAAM,EAEN,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAcF;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EAAE,EACtB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,WAAW,CAAC,CAmDtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drain-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/drain-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,eAAe,EACf,QAAQ,EACR,cAAc,EACd,OAAO,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;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":"","sources":["../../../src/internal/lru-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,qBAAa,MAAM,CAAC,CAAC,EAAE,CAAC;IAGV,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;gBAEf,QAAQ,EAAE,MAAM;IAE7C,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAS1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAW3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIvB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAED;;;;;;GAMG;AACH,qBAAa,MAAM,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;gBAE3B,OAAO,EAAE,MAAM;IAI3B,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAItB,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAInB,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAIzB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
package/dist/@types/ports.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAI7D,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,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ACH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAExC,gCAAgC;aAChB,MAAM,EAAE,MAAM;;IAD9B,gCAAgC;IAChB,MAAM,EAAE,MAAM;CAKjC;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IAEvC,sDAAsD;aACtC,MAAM,EAAE,MAAM;IAC9B,8CAA8C;aAC9B,WAAW,EAAE,MAAM;IACnC,2CAA2C;aAC3B,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE;IACzD,2CAA2C;aAC3B,eAAe,EAAE,MAAM;;IAPvC,sDAAsD;IACtC,MAAM,EAAE,MAAM;IAC9B,8CAA8C;IAC9B,WAAW,EAAE,MAAM;IACnC,2CAA2C;IAC3B,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE;IACzD,2CAA2C;IAC3B,eAAe,EAAE,MAAM;CAe1C"}
|
package/dist/@types/utils.d.ts
CHANGED
|
@@ -2,322 +2,53 @@ import { type ZodType } from "zod";
|
|
|
2
2
|
/**
|
|
3
3
|
* @module utils
|
|
4
4
|
* @category Utilities
|
|
5
|
-
* Utility functions for validation, extending objects, and async helpers.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
6
|
+
* Small utilities used across the framework:
|
|
7
|
+
* - {@link validate} — parse a payload against a Zod schema, throwing
|
|
8
|
+
* {@link ValidationError} on failure.
|
|
9
|
+
* - {@link extend} — validate a source object and merge into defaults.
|
|
10
|
+
* - {@link sleep} — async delay (default duration from `config().sleepMs`).
|
|
10
11
|
*/
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Parse `payload` against `schema`, returning the validated value or throwing
|
|
14
|
+
* a {@link ValidationError} with prettified Zod details. When `schema` is
|
|
15
|
+
* omitted, returns `payload` unchanged. The framework calls this for every
|
|
16
|
+
* `app.do()` action, every emitted event, and every state init.
|
|
13
17
|
*
|
|
14
|
-
*
|
|
15
|
-
* It parses the payload using the provided Zod schema and throws a
|
|
16
|
-
* {@link ValidationError} with detailed error information if validation fails.
|
|
17
|
-
*
|
|
18
|
-
* When no schema is provided, the payload is returned as-is without validation.
|
|
19
|
-
* This allows for optional validation in the framework.
|
|
20
|
-
*
|
|
21
|
-
* The framework automatically calls this function when:
|
|
22
|
-
* - Actions are invoked via `app.do()`
|
|
23
|
-
* - Events are emitted from action handlers
|
|
24
|
-
* - States are initialized
|
|
25
|
-
*
|
|
26
|
-
* @param target - Name of the target being validated (used in error messages)
|
|
27
|
-
* @param payload - The data to validate
|
|
28
|
-
* @param schema - Optional Zod schema to validate against
|
|
29
|
-
* @returns The validated and type-safe payload
|
|
30
|
-
* @throws {@link ValidationError} if validation fails with detailed error info
|
|
31
|
-
*
|
|
32
|
-
* @example Basic validation
|
|
33
|
-
* ```typescript
|
|
34
|
-
* import { validate } from "@rotorsoft/act";
|
|
35
|
-
* import { z } from "zod";
|
|
36
|
-
*
|
|
37
|
-
* const UserSchema = z.object({
|
|
38
|
-
* email: z.string().email(),
|
|
39
|
-
* age: z.number().min(0)
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* const user = validate("User", { email: "alice@example.com", age: 30 }, UserSchema);
|
|
43
|
-
* // Returns: { email: "alice@example.com", age: 30 }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @example Handling validation errors
|
|
18
|
+
* @example
|
|
47
19
|
* ```typescript
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* const schema = z.object({
|
|
52
|
-
* email: z.string().email(),
|
|
53
|
-
* age: z.number().min(18)
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* try {
|
|
57
|
-
* validate("User", { email: "invalid", age: 15 }, schema);
|
|
58
|
-
* } catch (error) {
|
|
59
|
-
* if (error instanceof ValidationError) {
|
|
60
|
-
* console.error("Target:", error.target); // "User"
|
|
61
|
-
* console.error("Payload:", error.payload); // { email: "invalid", age: 15 }
|
|
62
|
-
* console.error("Details:", error.details); // Prettified Zod errors
|
|
63
|
-
* // Details shows: email must be valid, age must be >= 18
|
|
64
|
-
* }
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @example Optional validation
|
|
69
|
-
* ```typescript
|
|
70
|
-
* // When schema is undefined, payload is returned as-is
|
|
71
|
-
* const data = validate("Data", { any: "value" });
|
|
72
|
-
* // Returns: { any: "value" } without validation
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @example In action definitions
|
|
76
|
-
* ```typescript
|
|
77
|
-
* import { state } from "@rotorsoft/act";
|
|
78
|
-
* import { z } from "zod";
|
|
79
|
-
*
|
|
80
|
-
* const Counter = state({ Counter: z.object({ count: z.number() }) })
|
|
81
|
-
* .init(() => ({ count: 0 }))
|
|
82
|
-
* .emits({ Incremented: z.object({ by: z.number().positive() }) })
|
|
83
|
-
* .on({ increment: z.object({ by: z.number() }) })
|
|
84
|
-
* .emit((action) => {
|
|
85
|
-
* // validate() is called automatically before this runs
|
|
86
|
-
* // action.by is guaranteed to be a number
|
|
87
|
-
* return ["Incremented", { by: action.by }];
|
|
88
|
-
* })
|
|
89
|
-
* .build();
|
|
20
|
+
* const UserSchema = z.object({ email: z.string().email() });
|
|
21
|
+
* const user = validate("User", { email: "alice@example.com" }, UserSchema);
|
|
90
22
|
* ```
|
|
91
23
|
*
|
|
92
|
-
* @
|
|
93
|
-
* ```typescript
|
|
94
|
-
* import { validate } from "@rotorsoft/act";
|
|
95
|
-
* import { z } from "zod";
|
|
96
|
-
*
|
|
97
|
-
* const ConfigSchema = z.object({
|
|
98
|
-
* apiKey: z.string().min(32),
|
|
99
|
-
* timeout: z.number().positive(),
|
|
100
|
-
* retries: z.number().int().min(0).max(10)
|
|
101
|
-
* });
|
|
102
|
-
*
|
|
103
|
-
* function loadConfig(raw: unknown) {
|
|
104
|
-
* return validate("AppConfig", raw, ConfigSchema);
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* @see {@link ValidationError} for error handling
|
|
109
|
-
* @see {@link https://zod.dev | Zod documentation} for schema definition
|
|
24
|
+
* @see {@link ValidationError}
|
|
110
25
|
*/
|
|
111
26
|
export declare const validate: <S>(target: string, payload: Readonly<S>, schema?: ZodType<S>) => Readonly<S>;
|
|
112
27
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* properties override target properties in the result.
|
|
118
|
-
*
|
|
119
|
-
* Primarily used for configuration management where you want to:
|
|
120
|
-
* 1. Define default configuration values
|
|
121
|
-
* 2. Load environment-specific overrides
|
|
122
|
-
* 3. Validate the final configuration
|
|
123
|
-
*
|
|
124
|
-
* The framework uses this internally for the {@link config} function.
|
|
125
|
-
*
|
|
126
|
-
* @template S - Source object type (must be a record)
|
|
127
|
-
* @template T - Target object type (must be a record)
|
|
128
|
-
* @param source - The source object to validate and use as overrides
|
|
129
|
-
* @param schema - Zod schema to validate the source against
|
|
130
|
-
* @param target - Optional target object with default values
|
|
131
|
-
* @returns Merged object with validated source overriding target
|
|
132
|
-
* @throws {@link ValidationError} if source fails schema validation
|
|
28
|
+
* Validate `source` against `schema` and return a new object that merges
|
|
29
|
+
* `source` over the optional `target` defaults. Used by {@link config} for
|
|
30
|
+
* env-var-overrides-defaults patterns; safe to call elsewhere — it never
|
|
31
|
+
* mutates `target`.
|
|
133
32
|
*
|
|
134
|
-
* @example
|
|
33
|
+
* @example
|
|
135
34
|
* ```typescript
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* const ConfigSchema = z.object({
|
|
140
|
-
* host: z.string(),
|
|
141
|
-
* port: z.number(),
|
|
142
|
-
* debug: z.boolean()
|
|
143
|
-
* });
|
|
144
|
-
*
|
|
145
|
-
* const defaults = { host: "localhost", port: 3000, debug: false };
|
|
146
|
-
* const overrides = { port: 8080, debug: true };
|
|
147
|
-
*
|
|
148
|
-
* const config = extend(overrides, ConfigSchema, defaults);
|
|
149
|
-
* // Result: { host: "localhost", port: 8080, debug: true }
|
|
35
|
+
* const schema = z.object({ host: z.string(), port: z.number() });
|
|
36
|
+
* const cfg = extend({ port: 8080 }, schema, { host: "localhost", port: 80 });
|
|
37
|
+
* // → { host: "localhost", port: 8080 }
|
|
150
38
|
* ```
|
|
151
39
|
*
|
|
152
|
-
* @
|
|
153
|
-
* ```typescript
|
|
154
|
-
* import { extend } from "@rotorsoft/act";
|
|
155
|
-
* import { z } from "zod";
|
|
156
|
-
*
|
|
157
|
-
* const DbConfigSchema = z.object({
|
|
158
|
-
* host: z.string(),
|
|
159
|
-
* port: z.number(),
|
|
160
|
-
* database: z.string(),
|
|
161
|
-
* user: z.string(),
|
|
162
|
-
* password: z.string()
|
|
163
|
-
* });
|
|
164
|
-
*
|
|
165
|
-
* const defaults = {
|
|
166
|
-
* host: "localhost",
|
|
167
|
-
* port: 5432,
|
|
168
|
-
* database: "myapp_dev",
|
|
169
|
-
* user: "postgres",
|
|
170
|
-
* password: "dev"
|
|
171
|
-
* };
|
|
172
|
-
*
|
|
173
|
-
* const envConfig = {
|
|
174
|
-
* host: process.env.DB_HOST || "localhost",
|
|
175
|
-
* port: parseInt(process.env.DB_PORT || "5432"),
|
|
176
|
-
* database: process.env.DB_NAME || "myapp_dev",
|
|
177
|
-
* user: process.env.DB_USER || "postgres",
|
|
178
|
-
* password: process.env.DB_PASSWORD || "dev"
|
|
179
|
-
* };
|
|
180
|
-
*
|
|
181
|
-
* // Validates environment config and merges with defaults
|
|
182
|
-
* const dbConfig = extend(envConfig, DbConfigSchema, defaults);
|
|
183
|
-
* ```
|
|
184
|
-
*
|
|
185
|
-
* @example Framework usage
|
|
186
|
-
* ```typescript
|
|
187
|
-
* // This is how Act's config() function uses extend internally:
|
|
188
|
-
* import { extend } from "@rotorsoft/act";
|
|
189
|
-
* import { z } from "zod";
|
|
190
|
-
*
|
|
191
|
-
* const BaseSchema = z.object({
|
|
192
|
-
* env: z.enum(["development", "test", "staging", "production"]),
|
|
193
|
-
* logLevel: z.enum(["fatal", "error", "warn", "info", "debug", "trace"]),
|
|
194
|
-
* sleepMs: z.number().int().min(0).max(5000)
|
|
195
|
-
* });
|
|
196
|
-
*
|
|
197
|
-
* const packageData = { name: "my-app", version: "1.0.0" };
|
|
198
|
-
* const runtimeConfig = { env: "production", logLevel: "info", sleepMs: 100 };
|
|
199
|
-
*
|
|
200
|
-
* const config = extend(
|
|
201
|
-
* { ...packageData, ...runtimeConfig },
|
|
202
|
-
* BaseSchema,
|
|
203
|
-
* packageData
|
|
204
|
-
* );
|
|
205
|
-
* ```
|
|
206
|
-
*
|
|
207
|
-
* @example With validation error handling
|
|
208
|
-
* ```typescript
|
|
209
|
-
* import { extend, ValidationError } from "@rotorsoft/act";
|
|
210
|
-
* import { z } from "zod";
|
|
211
|
-
*
|
|
212
|
-
* const schema = z.object({
|
|
213
|
-
* apiKey: z.string().min(32),
|
|
214
|
-
* timeout: z.number().positive()
|
|
215
|
-
* });
|
|
216
|
-
*
|
|
217
|
-
* try {
|
|
218
|
-
* const config = extend(
|
|
219
|
-
* { apiKey: "short", timeout: -1 },
|
|
220
|
-
* schema
|
|
221
|
-
* );
|
|
222
|
-
* } catch (error) {
|
|
223
|
-
* if (error instanceof ValidationError) {
|
|
224
|
-
* console.error("Invalid configuration:", error.details);
|
|
225
|
-
* }
|
|
226
|
-
* }
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* @see {@link validate} for validation details
|
|
230
|
-
* @see {@link config} for framework configuration
|
|
231
|
-
* @see {@link ValidationError} for error handling
|
|
40
|
+
* @throws {@link ValidationError} if `source` fails the schema.
|
|
232
41
|
*/
|
|
233
42
|
export declare const extend: <S extends Record<string, unknown>, T extends Record<string, unknown>>(source: Readonly<S>, schema: ZodType<S>, target?: Readonly<T>) => Readonly<S & T>;
|
|
234
43
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* This is a simple async utility for adding delays in your code. When called
|
|
238
|
-
* without arguments, it uses the configured sleep duration from `config().sleepMs`,
|
|
239
|
-
* which defaults to 100ms in development and 0ms in test environments.
|
|
240
|
-
*
|
|
241
|
-
* The framework uses this internally in store adapters to simulate I/O delays
|
|
242
|
-
* in the {@link InMemoryStore}.
|
|
243
|
-
*
|
|
244
|
-
* **Note:** In test environments (NODE_ENV=test), the default sleep duration is
|
|
245
|
-
* 0ms to keep tests fast.
|
|
246
|
-
*
|
|
247
|
-
* @param ms - Optional duration in milliseconds (defaults to config().sleepMs)
|
|
248
|
-
* @returns Promise that resolves after the specified delay
|
|
44
|
+
* Pause for `ms` milliseconds (or `config().sleepMs` when omitted — `100ms`
|
|
45
|
+
* in dev, `0ms` in tests). Used by adapters to simulate async I/O.
|
|
249
46
|
*
|
|
250
|
-
* @example
|
|
47
|
+
* @example
|
|
251
48
|
* ```typescript
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* async function processWithDelay() {
|
|
255
|
-
* console.log("Starting...");
|
|
256
|
-
* await sleep(); // Uses config().sleepMs (100ms in dev, 0ms in test)
|
|
257
|
-
* console.log("Continued after delay");
|
|
258
|
-
* }
|
|
259
|
-
* ```
|
|
260
|
-
*
|
|
261
|
-
* @example Custom sleep duration
|
|
262
|
-
* ```typescript
|
|
263
|
-
* import { sleep } from "@rotorsoft/act";
|
|
264
|
-
*
|
|
265
|
-
* async function retryWithBackoff(fn: () => Promise<void>, retries = 3) {
|
|
266
|
-
* for (let i = 0; i < retries; i++) {
|
|
267
|
-
* try {
|
|
268
|
-
* await fn();
|
|
269
|
-
* return;
|
|
270
|
-
* } catch (error) {
|
|
271
|
-
* if (i < retries - 1) {
|
|
272
|
-
* const delay = Math.pow(2, i) * 1000; // Exponential backoff
|
|
273
|
-
* console.log(`Retrying in ${delay}ms...`);
|
|
274
|
-
* await sleep(delay);
|
|
275
|
-
* } else {
|
|
276
|
-
* throw error;
|
|
277
|
-
* }
|
|
278
|
-
* }
|
|
279
|
-
* }
|
|
280
|
-
* }
|
|
281
|
-
* ```
|
|
282
|
-
*
|
|
283
|
-
* @example Rate limiting
|
|
284
|
-
* ```typescript
|
|
285
|
-
* import { sleep } from "@rotorsoft/act";
|
|
286
|
-
*
|
|
287
|
-
* async function processItems(items: string[]) {
|
|
288
|
-
* for (const item of items) {
|
|
289
|
-
* await processItem(item);
|
|
290
|
-
* await sleep(500); // 500ms between items
|
|
291
|
-
* }
|
|
292
|
-
* }
|
|
49
|
+
* await sleep(); // default delay from config
|
|
50
|
+
* await sleep(500); // explicit 500ms
|
|
293
51
|
* ```
|
|
294
|
-
*
|
|
295
|
-
* @example Framework internal usage
|
|
296
|
-
* ```typescript
|
|
297
|
-
* // InMemoryStore uses sleep to simulate async I/O
|
|
298
|
-
* class InMemoryStore implements Store {
|
|
299
|
-
* async query(...) {
|
|
300
|
-
* await sleep(); // Simulate database latency
|
|
301
|
-
* // ... query logic
|
|
302
|
-
* }
|
|
303
|
-
*
|
|
304
|
-
* async commit(...) {
|
|
305
|
-
* await sleep(); // Simulate write latency
|
|
306
|
-
* // ... commit logic
|
|
307
|
-
* }
|
|
308
|
-
* }
|
|
309
|
-
* ```
|
|
310
|
-
*
|
|
311
|
-
* @example Configuring default sleep duration
|
|
312
|
-
* ```bash
|
|
313
|
-
* # Set custom default sleep duration via environment variable
|
|
314
|
-
* SLEEP_MS=50 npm start
|
|
315
|
-
*
|
|
316
|
-
* # In tests, it's automatically 0
|
|
317
|
-
* NODE_ENV=test npm test
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @see {@link config} for sleep duration configuration
|
|
321
52
|
*/
|
|
322
53
|
export declare function sleep(ms?: number): Promise<unknown>;
|
|
323
54
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,OAAO,EAAiB,MAAM,KAAK,CAAC;AAI5D
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,OAAO,EAAiB,MAAM,KAAK,CAAC;AAI5D;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EACxB,QAAQ,MAAM,EACd,SAAS,QAAQ,CAAC,CAAC,CAAC,EACpB,SAAS,OAAO,CAAC,CAAC,CAAC,KAClB,QAAQ,CAAC,CAAC,CASZ,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM,GACjB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEjC,QAAQ,QAAQ,CAAC,CAAC,CAAC,EACnB,QAAQ,OAAO,CAAC,CAAC,CAAC,EAClB,SAAS,QAAQ,CAAC,CAAC,CAAC,KACnB,QAAQ,CAAC,CAAC,GAAG,CAAC,CAGhB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,oBAEtC"}
|
|
@@ -35,7 +35,7 @@ var StreamClosedError = class extends Error {
|
|
|
35
35
|
var ConcurrencyError = class extends Error {
|
|
36
36
|
constructor(stream, lastVersion, events, expectedVersion) {
|
|
37
37
|
super(
|
|
38
|
-
`Concurrency error committing "${events.map((e) => `${stream}.${e.name}
|
|
38
|
+
`Concurrency error committing "${events.map((e) => `${stream}.${e.name}`).join(
|
|
39
39
|
", "
|
|
40
40
|
)}". Expected version ${expectedVersion} but found version ${lastVersion}.`
|
|
41
41
|
);
|
|
@@ -124,4 +124,4 @@ export {
|
|
|
124
124
|
Environments,
|
|
125
125
|
LogLevels
|
|
126
126
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-IDEYGKT4.js.map
|
|
@@ -1 +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,sBAAsB,WAAW,EAAE;AAVnD;AAEA;AAEA;AAEA;AAEA;AAGT,SAAK,OAAO,OAAO;AAAA,EACrB;AACF;AA8FO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YAEkB,QAChB;AACA,UAAM,WAAW,MAAM,0BAA0B;AAFjC;AAGhB,SAAK,OAAO,OAAO;AAAA,EACrB;AACF;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1C,YAEkB,QAEA,aAEA,QAEA,iBAChB;AACA;AAAA,MACE,iCAAiC,OAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,IAAI,IAAI,KAAK,UAAU,EAAE,IAAI,CAAC,EAAE,EAC1D;AAAA,QACC;AAAA,MACF,CAAC,uBAAuB,eAAe,sBAAsB,WAAW;AAAA,IAC5E;AAdgB;AAEA;AAEA;AAEA;AAShB,SAAK,OAAO,OAAO;AAAA,EAC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C3B,gBAAgB,EAAE,KAAK,EAAE,SAAS;AAAA,EAClC,eAAe,EAAE,KAAK,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,YAAY,EAAE,QAAQ,EAAE,SAAS;AAAA,EACjC,cAAc,EAAE,QAAQ,EAAE,SAAS;AACrC,CAAC,EACA,SAAS;;;AC5EL,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAWO,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
|
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 // Message lists stream + event names only. Payloads remain accessible\n // via `error.events` for callers who need them — keeping them out of\n // the message avoids MB-scale strings on contended writes and keeps\n // potentially-sensitive data out of log streams.\n super(\n `Concurrency error committing \"${events\n .map((e) => `${stream}.${e.name}`)\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,sBAAsB,WAAW,EAAE;AAVnD;AAEA;AAEA;AAEA;AAEA;AAGT,SAAK,OAAO,OAAO;AAAA,EACrB;AACF;AA8FO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