@rotorsoft/act 0.5.1 → 0.5.3
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/act-builder.d.ts +66 -2
- package/dist/@types/act-builder.d.ts.map +1 -1
- package/dist/@types/act.d.ts +77 -21
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/InMemoryStore.d.ts +49 -2
- package/dist/@types/adapters/InMemoryStore.d.ts.map +1 -1
- package/dist/@types/config.d.ts +34 -11
- package/dist/@types/config.d.ts.map +1 -1
- package/dist/@types/event-sourcing.d.ts +30 -9
- package/dist/@types/event-sourcing.d.ts.map +1 -1
- package/dist/@types/index.d.ts +3 -2
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +51 -4
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/signals.d.ts +2 -0
- package/dist/@types/signals.d.ts.map +1 -0
- package/dist/@types/state-builder.d.ts +54 -3
- package/dist/@types/state-builder.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +105 -0
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/errors.d.ts +33 -4
- package/dist/@types/types/errors.d.ts.map +1 -1
- package/dist/@types/types/index.d.ts +28 -0
- package/dist/@types/types/index.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +53 -0
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +51 -0
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/@types/types/registry.d.ts +27 -0
- package/dist/@types/types/registry.d.ts.map +1 -1
- package/dist/@types/types/schemas.d.ts +43 -107
- package/dist/@types/types/schemas.d.ts.map +1 -1
- package/dist/@types/utils.d.ts +46 -5
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/index.cjs +146 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +144 -95
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import type { Message, Schema, Schemas, Target } from "./action.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
* @module act/types
|
|
5
|
+
* @category Types
|
|
6
|
+
* Application error type constants and error classes for the Act Framework.
|
|
7
|
+
*
|
|
8
|
+
* - `ERR_VALIDATION`: Schema validation error
|
|
9
|
+
* - `ERR_INVARIANT`: Invariant validation error
|
|
10
|
+
* - `ERR_CONCURRENCY`: Optimistic concurrency validation error on commits
|
|
7
11
|
*/
|
|
8
12
|
export declare const Errors: {
|
|
9
13
|
readonly ValidationError: "ERR_VALIDATION";
|
|
10
14
|
readonly InvariantError: "ERR_INVARIANT";
|
|
11
15
|
readonly ConcurrencyError: "ERR_CONCURRENCY";
|
|
12
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when a payload fails schema validation.
|
|
19
|
+
* @param target - The name of the target being validated (e.g., event, action).
|
|
20
|
+
* @param payload - The invalid payload.
|
|
21
|
+
* @param details - Additional validation error details.
|
|
22
|
+
* @example
|
|
23
|
+
* throw new ValidationError('event', payload, zodError);
|
|
24
|
+
*/
|
|
13
25
|
export declare class ValidationError extends Error {
|
|
14
26
|
readonly target: string;
|
|
15
27
|
readonly payload: any;
|
|
16
28
|
readonly details: any;
|
|
17
29
|
constructor(target: string, payload: any, details: any);
|
|
18
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when a state invariant is violated after an action or event.
|
|
33
|
+
* @param name - The name of the invariant or action.
|
|
34
|
+
* @param payload - The state or payload that failed the invariant.
|
|
35
|
+
* @param target - The target context (e.g., stream, actor).
|
|
36
|
+
* @param description - Description of the invariant.
|
|
37
|
+
* @example
|
|
38
|
+
* throw new InvariantError('balanceNonNegative', state, target, 'Balance must be >= 0');
|
|
39
|
+
*/
|
|
19
40
|
export declare class InvariantError extends Error {
|
|
20
41
|
readonly details: {
|
|
21
42
|
name: string;
|
|
@@ -32,6 +53,14 @@ export declare class InvariantError extends Error {
|
|
|
32
53
|
};
|
|
33
54
|
constructor(name: string, payload: Schema, target: Target, description: string);
|
|
34
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when an optimistic concurrency check fails during event commit.
|
|
58
|
+
* @param lastVersion - The last known version in the stream.
|
|
59
|
+
* @param events - The events being committed.
|
|
60
|
+
* @param expectedVersion - The expected version for the commit.
|
|
61
|
+
* @example
|
|
62
|
+
* throw new ConcurrencyError(2, events, 1);
|
|
63
|
+
*/
|
|
35
64
|
export declare class ConcurrencyError extends Error {
|
|
36
65
|
readonly lastVersion: number;
|
|
37
66
|
readonly events: Message<Schemas, keyof Schemas>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM;;;;CAIT,CAAC;AAEX;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAEtB,MAAM,EAAE,MAAM;aACd,OAAO,EAAE,GAAG;aACZ,OAAO,EAAE,GAAG;gBAFZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG;CAK/B;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,OAAO;;;;;;;;;;;;MAAC;gBAEtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM;CAMtB;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,WAAW,EAAE,MAAM;aACnB,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE;aACzC,eAAe,EAAE,MAAM;gBAFvB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,EAAE,EACzC,eAAe,EAAE,MAAM;CAS1C"}
|
|
@@ -1,11 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module act/types
|
|
4
|
+
* Barrel file for Act Framework core types.
|
|
5
|
+
*
|
|
6
|
+
* Re-exports all major type definitions for actions, errors, ports, reactions, registries, and schemas.
|
|
7
|
+
* Also defines common environment and log level types/constants for configuration and logging.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Import from this module to access all core framework types in one place.
|
|
11
|
+
*/
|
|
1
12
|
export type * from "./action.js";
|
|
2
13
|
export * from "./errors.js";
|
|
3
14
|
export type * from "./ports.js";
|
|
4
15
|
export type * from "./reaction.js";
|
|
5
16
|
export type * from "./registry.js";
|
|
6
17
|
export * from "./schemas.js";
|
|
18
|
+
/**
|
|
19
|
+
* Supported runtime environments for the framework.
|
|
20
|
+
* - `development`: Local development
|
|
21
|
+
* - `test`: Automated testing
|
|
22
|
+
* - `staging`: Pre-production
|
|
23
|
+
* - `production`: Live/production
|
|
24
|
+
*/
|
|
7
25
|
export declare const Environments: readonly ["development", "test", "staging", "production"];
|
|
26
|
+
/**
|
|
27
|
+
* Type representing a valid environment string.
|
|
28
|
+
*/
|
|
8
29
|
export type Environment = (typeof Environments)[number];
|
|
30
|
+
/**
|
|
31
|
+
* Supported log levels for framework logging.
|
|
32
|
+
* - `fatal`, `error`, `warn`, `info`, `debug`, `trace`
|
|
33
|
+
*/
|
|
9
34
|
export declare const LogLevels: readonly ["fatal", "error", "warn", "info", "debug", "trace"];
|
|
35
|
+
/**
|
|
36
|
+
* Type representing a valid log level string.
|
|
37
|
+
*/
|
|
10
38
|
export type LogLevel = (typeof LogLevels)[number];
|
|
11
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,aAAa,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,eAAe,CAAC;AACnC,cAAc,cAAc,CAAC;AAE7B,eAAO,MAAM,YAAY,2DAKf,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,mBAAmB,aAAa,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,eAAe,CAAC;AACnC,cAAc,cAAc,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,2DAKf,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,SAAS,+DAOZ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,16 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module act/types
|
|
4
|
+
* @category Types
|
|
5
|
+
* Types and interfaces for event store ports and disposables in the Act Framework.
|
|
6
|
+
*/
|
|
1
7
|
import type { Committed, EventMeta, Message, Query, Schemas } from "./action.js";
|
|
2
8
|
import type { Fetch, Lease } from "./reaction.js";
|
|
9
|
+
/**
|
|
10
|
+
* A function that disposes of a resource asynchronously.
|
|
11
|
+
* @returns Promise that resolves when disposal is complete.
|
|
12
|
+
*/
|
|
3
13
|
export type Disposer = () => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* An object that can be disposed of asynchronously.
|
|
16
|
+
*/
|
|
4
17
|
export type Disposable = {
|
|
5
18
|
dispose: Disposer;
|
|
6
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Interface for an event store implementation.
|
|
22
|
+
* Provides methods for seeding, dropping, committing, querying, and managing event streams.
|
|
23
|
+
*/
|
|
7
24
|
export interface Store extends Disposable {
|
|
25
|
+
/**
|
|
26
|
+
* Seed the store with initial data (optional, for testing/dev).
|
|
27
|
+
*/
|
|
8
28
|
seed: () => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Drop all data from the store (optional, for testing/dev).
|
|
31
|
+
*/
|
|
9
32
|
drop: () => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Commit one or more events to a stream.
|
|
35
|
+
* @param stream - The stream name.
|
|
36
|
+
* @param msgs - The events/messages to commit.
|
|
37
|
+
* @param meta - Event metadata.
|
|
38
|
+
* @param expectedVersion - Optional optimistic concurrency check.
|
|
39
|
+
* @returns The committed events with metadata.
|
|
40
|
+
* @throws ConcurrencyError if expectedVersion does not match.
|
|
41
|
+
*/
|
|
10
42
|
commit: <E extends Schemas>(stream: string, msgs: Message<E, keyof E>[], meta: EventMeta, expectedVersion?: number) => Promise<Committed<E, keyof E>[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Query events in the store, optionally filtered by query options.
|
|
45
|
+
* @param callback - Function to call for each event.
|
|
46
|
+
* @param query - Optional query options.
|
|
47
|
+
* @param withSnaps - Whether to include snapshot events.
|
|
48
|
+
* @returns The number of events processed.
|
|
49
|
+
*/
|
|
11
50
|
query: <E extends Schemas>(callback: (event: Committed<E, keyof E>) => void, query?: Query, withSnaps?: boolean) => Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch new events from stream watermarks for processing.
|
|
53
|
+
* @param limit - Maximum number of streams to fetch.
|
|
54
|
+
* @returns Fetched streams and events.
|
|
55
|
+
*/
|
|
12
56
|
fetch: <E extends Schemas>(limit: number) => Promise<Fetch<E>>;
|
|
57
|
+
/**
|
|
58
|
+
* Lease streams for processing (e.g., for distributed consumers).
|
|
59
|
+
* @param leases - Lease requests.
|
|
60
|
+
* @returns Granted leases.
|
|
61
|
+
*/
|
|
13
62
|
lease: (leases: Lease[]) => Promise<Lease[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Acknowledge completion of processing for leased streams.
|
|
65
|
+
* @param leases - Leases to acknowledge.
|
|
66
|
+
*/
|
|
14
67
|
ack: (leases: Lease[]) => Promise<void>;
|
|
15
68
|
}
|
|
16
69
|
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/types/ports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,OAAO,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/types/ports.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,OAAO,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,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ageDocumentation
|
|
3
|
+
* @module act/types
|
|
4
|
+
* @category Types
|
|
5
|
+
* Types for reactions, leases, and fetch results in the Act Framework.
|
|
6
|
+
*/
|
|
1
7
|
import type { Committed, Schema, Schemas, Snapshot } from "./action.js";
|
|
8
|
+
/**
|
|
9
|
+
* Handles a committed event and optionally returns a new snapshot of state.
|
|
10
|
+
* @template E - Event schemas.
|
|
11
|
+
* @template K - Event name.
|
|
12
|
+
* @param event - The committed event.
|
|
13
|
+
* @param stream - The stream name.
|
|
14
|
+
* @returns A promise resolving to a snapshot or void.
|
|
15
|
+
*/
|
|
2
16
|
export type ReactionHandler<E extends Schemas, K extends keyof E> = (event: Committed<E, K>, stream: string) => Promise<Snapshot<E, Schema> | void>;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the stream for a reaction, either by function or static string.
|
|
19
|
+
* @template E - Event schemas.
|
|
20
|
+
* @template K - Event name.
|
|
21
|
+
* @param event - The committed event.
|
|
22
|
+
* @returns The stream name or undefined.
|
|
23
|
+
*/
|
|
3
24
|
export type ReactionResolver<E extends Schemas, K extends keyof E> = ((event: Committed<E, K>) => string | undefined) | string;
|
|
25
|
+
/**
|
|
26
|
+
* Options for reaction processing.
|
|
27
|
+
* @property blockOnError - Whether to block on error.
|
|
28
|
+
* @property maxRetries - Maximum number of retries.
|
|
29
|
+
* @property retryDelayMs - Delay between retries in ms.
|
|
30
|
+
*/
|
|
4
31
|
export type ReactionOptions = {
|
|
5
32
|
readonly blockOnError: boolean;
|
|
6
33
|
readonly maxRetries: number;
|
|
7
34
|
readonly retryDelayMs: number;
|
|
8
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Defines a reaction to an event, including handler, resolver, and options.
|
|
38
|
+
* @template E - Event schemas.
|
|
39
|
+
* @template K - Event name.
|
|
40
|
+
*/
|
|
9
41
|
export type Reaction<E extends Schemas, K extends keyof E = keyof E> = {
|
|
10
42
|
readonly handler: ReactionHandler<E, K>;
|
|
11
43
|
readonly resolver: ReactionResolver<E, K>;
|
|
12
44
|
readonly options: ReactionOptions;
|
|
13
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Payload for a reaction, including the event and reaction definition.
|
|
48
|
+
* @template E - Event schemas.
|
|
49
|
+
*/
|
|
14
50
|
export type ReactionPayload<E extends Schemas> = Reaction<E> & {
|
|
15
51
|
readonly event: Committed<E, keyof E>;
|
|
16
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Result of fetching events from the store for processing.
|
|
55
|
+
* @template E - Event schemas.
|
|
56
|
+
* @property streams - The list of stream names.
|
|
57
|
+
* @property events - The list of committed events.
|
|
58
|
+
*/
|
|
17
59
|
export type Fetch<E extends Schemas> = {
|
|
18
60
|
streams: string[];
|
|
19
61
|
events: Committed<E, keyof E>[];
|
|
20
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Lease information for stream processing.
|
|
65
|
+
* @property stream - The stream name.
|
|
66
|
+
* @property by - The lease holder.
|
|
67
|
+
* @property at - The lease timestamp.
|
|
68
|
+
* @property retry - Retry count.
|
|
69
|
+
* @property block - Whether the stream is blocked.
|
|
70
|
+
* @property error - Optional error info.
|
|
71
|
+
*/
|
|
21
72
|
export type Lease = {
|
|
22
73
|
stream: string;
|
|
23
74
|
by: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../src/types/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAClE,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,gBAAgB,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AAS,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG;IAC7D,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,IAAI;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;CACjC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
|
|
@@ -1,21 +1,48 @@
|
|
|
1
1
|
import { z, ZodType } from "zod/v4";
|
|
2
2
|
import type { CommittedMeta, Schema, Schemas, State } from "./action.js";
|
|
3
3
|
import type { Reaction } from "./reaction.js";
|
|
4
|
+
/**
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
* @module act/types
|
|
7
|
+
* @category Types
|
|
8
|
+
* Types for event and action registries in the Act Framework.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Maps event names to their schema and registered reactions.
|
|
12
|
+
* @template E - Event schemas.
|
|
13
|
+
*/
|
|
4
14
|
export type EventRegister<E extends Schemas> = {
|
|
5
15
|
[K in keyof E]: {
|
|
6
16
|
schema: ZodType<E[K]>;
|
|
7
17
|
reactions: Map<string, Reaction<E, K>>;
|
|
8
18
|
};
|
|
9
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Maps action names to their schema definitions.
|
|
22
|
+
* @template A - Action schemas.
|
|
23
|
+
*/
|
|
10
24
|
export type SchemaRegister<A> = {
|
|
11
25
|
[K in keyof A]: Schema;
|
|
12
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Registry of all actions and events for a domain.
|
|
29
|
+
* @template S - State schemas.
|
|
30
|
+
* @template E - Event schemas.
|
|
31
|
+
* @template A - Action schemas.
|
|
32
|
+
* @property actions - Map of action names to state definitions.
|
|
33
|
+
* @property events - Map of event names to event registration info.
|
|
34
|
+
*/
|
|
13
35
|
export type Registry<S extends SchemaRegister<A>, E extends Schemas, A extends Schemas> = {
|
|
14
36
|
readonly actions: {
|
|
15
37
|
[K in keyof A]: State<S[K], E, A>;
|
|
16
38
|
};
|
|
17
39
|
readonly events: EventRegister<E>;
|
|
18
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Utility type to convert a registry entry to a committed event type.
|
|
43
|
+
* @template R - Registry map.
|
|
44
|
+
* @template K - Event name.
|
|
45
|
+
*/
|
|
19
46
|
export type AsCommitted<R, K extends keyof R> = R[K] extends {
|
|
20
47
|
schema: infer S;
|
|
21
48
|
} ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/types/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,OAAO,IAAI;KAC5C,CAAC,IAAI,MAAM,CAAC,GAAG;QACd,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KACxC;CACF,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;KAAG,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AAE,CAAC,CAAC,CAAC,CAAC;KACxC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;CAAE,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,CAClB,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,EAC3B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf;IACF,QAAQ,CAAC,OAAO,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KAAE,CAAC;IACxD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;CACnC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC5E;IACE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC3B,GAAG,aAAa,GACjB,KAAK,CAAC"}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { z, ZodObject, ZodRawShape } from "zod/v4";
|
|
2
|
+
/**
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
* @module act/types
|
|
5
|
+
* @category Types
|
|
6
|
+
* Zod schemas and helpers for the Act Framework.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* An empty Zod schema (no properties).
|
|
10
|
+
*/
|
|
2
11
|
export declare const ZodEmpty: z.ZodRecord<z.ZodString, z.ZodNever>;
|
|
12
|
+
/**
|
|
13
|
+
* Zod schema for an actor (user, system, etc.).
|
|
14
|
+
*/
|
|
3
15
|
export declare const ActorSchema: z.ZodReadonly<z.ZodObject<{
|
|
4
16
|
id: z.ZodString;
|
|
5
17
|
name: z.ZodString;
|
|
6
18
|
}, z.core.$strip>>;
|
|
19
|
+
/**
|
|
20
|
+
* Zod schema for a target (stream and actor info).
|
|
21
|
+
*/
|
|
7
22
|
export declare const TargetSchema: z.ZodReadonly<z.ZodObject<{
|
|
8
23
|
stream: z.ZodString;
|
|
9
24
|
actor: z.ZodReadonly<z.ZodObject<{
|
|
@@ -12,11 +27,17 @@ export declare const TargetSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
12
27
|
}, z.core.$strip>>;
|
|
13
28
|
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
14
29
|
}, z.core.$strip>>;
|
|
30
|
+
/**
|
|
31
|
+
* Zod schema for causation event metadata.
|
|
32
|
+
*/
|
|
15
33
|
export declare const CausationEventSchema: z.ZodObject<{
|
|
16
34
|
id: z.ZodNumber;
|
|
17
35
|
name: z.ZodString;
|
|
18
36
|
stream: z.ZodString;
|
|
19
37
|
}, z.core.$strip>;
|
|
38
|
+
/**
|
|
39
|
+
* Zod schema for event metadata (correlation and causation).
|
|
40
|
+
*/
|
|
20
41
|
export declare const EventMetaSchema: z.ZodReadonly<z.ZodObject<{
|
|
21
42
|
correlation: z.ZodString;
|
|
22
43
|
causation: z.ZodObject<{
|
|
@@ -37,6 +58,9 @@ export declare const EventMetaSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
37
58
|
}, z.core.$strip>>;
|
|
38
59
|
}, z.core.$strip>;
|
|
39
60
|
}, z.core.$strip>>;
|
|
61
|
+
/**
|
|
62
|
+
* Zod schema for committed event metadata (id, stream, version, created, meta).
|
|
63
|
+
*/
|
|
40
64
|
export declare const CommittedMetaSchema: z.ZodReadonly<z.ZodObject<{
|
|
41
65
|
id: z.ZodNumber;
|
|
42
66
|
stream: z.ZodString;
|
|
@@ -63,119 +87,31 @@ export declare const CommittedMetaSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
63
87
|
}, z.core.$strip>;
|
|
64
88
|
}, z.core.$strip>>;
|
|
65
89
|
}, z.core.$strip>>;
|
|
90
|
+
/**
|
|
91
|
+
* Type representing the full state schema for a domain.
|
|
92
|
+
* @property events - Map of event names to Zod schemas.
|
|
93
|
+
* @property actions - Map of action names to Zod schemas.
|
|
94
|
+
* @property state - Zod schema for the state object.
|
|
95
|
+
*/
|
|
66
96
|
export type StateSchema = Readonly<{
|
|
67
97
|
events: Record<string, ZodObject<ZodRawShape> | typeof ZodEmpty>;
|
|
68
98
|
actions: Record<string, ZodObject<ZodRawShape> | typeof ZodEmpty>;
|
|
69
99
|
state: ZodObject<ZodRawShape>;
|
|
70
100
|
}>;
|
|
71
|
-
export declare function buildSnapshotSchema<S extends StateSchema>(s: S): z.ZodObject<{
|
|
72
|
-
state: z.ZodReadonly<z.ZodObject<Readonly<{
|
|
73
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
74
|
-
}>, z.core.$strip>>;
|
|
75
|
-
event: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
76
|
-
name: z.ZodLiteral<string>;
|
|
77
|
-
data: z.ZodRecord<z.ZodString, z.ZodNever> | z.ZodObject<Readonly<{
|
|
78
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
79
|
-
}>, z.core.$strip>;
|
|
80
|
-
id: z.ZodNumber;
|
|
81
|
-
stream: z.ZodString;
|
|
82
|
-
version: z.ZodNumber;
|
|
83
|
-
created: z.ZodDate;
|
|
84
|
-
meta: z.ZodReadonly<z.ZodObject<{
|
|
85
|
-
correlation: z.ZodString;
|
|
86
|
-
causation: z.ZodObject<{
|
|
87
|
-
action: z.ZodOptional<z.ZodIntersection<z.ZodReadonly<z.ZodObject<{
|
|
88
|
-
stream: z.ZodString;
|
|
89
|
-
actor: z.ZodReadonly<z.ZodObject<{
|
|
90
|
-
id: z.ZodString;
|
|
91
|
-
name: z.ZodString;
|
|
92
|
-
}, z.core.$strip>>;
|
|
93
|
-
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
94
|
-
}, z.core.$strip>>, z.ZodObject<{
|
|
95
|
-
name: z.ZodString;
|
|
96
|
-
}, z.core.$strip>>>;
|
|
97
|
-
event: z.ZodOptional<z.ZodObject<{
|
|
98
|
-
id: z.ZodNumber;
|
|
99
|
-
name: z.ZodString;
|
|
100
|
-
stream: z.ZodString;
|
|
101
|
-
}, z.core.$strip>>;
|
|
102
|
-
}, z.core.$strip>;
|
|
103
|
-
}, z.core.$strip>>;
|
|
104
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
105
|
-
name: z.ZodLiteral<string>;
|
|
106
|
-
data: z.ZodRecord<z.ZodString, z.ZodNever> | z.ZodObject<Readonly<{
|
|
107
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
108
|
-
}>, z.core.$strip>;
|
|
109
|
-
id: z.ZodNumber;
|
|
110
|
-
stream: z.ZodString;
|
|
111
|
-
version: z.ZodNumber;
|
|
112
|
-
created: z.ZodDate;
|
|
113
|
-
meta: z.ZodReadonly<z.ZodObject<{
|
|
114
|
-
correlation: z.ZodString;
|
|
115
|
-
causation: z.ZodObject<{
|
|
116
|
-
action: z.ZodOptional<z.ZodIntersection<z.ZodReadonly<z.ZodObject<{
|
|
117
|
-
stream: z.ZodString;
|
|
118
|
-
actor: z.ZodReadonly<z.ZodObject<{
|
|
119
|
-
id: z.ZodString;
|
|
120
|
-
name: z.ZodString;
|
|
121
|
-
}, z.core.$strip>>;
|
|
122
|
-
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
123
|
-
}, z.core.$strip>>, z.ZodObject<{
|
|
124
|
-
name: z.ZodString;
|
|
125
|
-
}, z.core.$strip>>>;
|
|
126
|
-
event: z.ZodOptional<z.ZodObject<{
|
|
127
|
-
id: z.ZodNumber;
|
|
128
|
-
name: z.ZodString;
|
|
129
|
-
stream: z.ZodString;
|
|
130
|
-
}, z.core.$strip>>;
|
|
131
|
-
}, z.core.$strip>;
|
|
132
|
-
}, z.core.$strip>>;
|
|
133
|
-
}, z.core.$strip>, ...z.ZodObject<{
|
|
134
|
-
name: z.ZodLiteral<string>;
|
|
135
|
-
data: z.ZodRecord<z.ZodString, z.ZodNever> | z.ZodObject<Readonly<{
|
|
136
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
137
|
-
}>, z.core.$strip>;
|
|
138
|
-
id: z.ZodNumber;
|
|
139
|
-
stream: z.ZodString;
|
|
140
|
-
version: z.ZodNumber;
|
|
141
|
-
created: z.ZodDate;
|
|
142
|
-
meta: z.ZodReadonly<z.ZodObject<{
|
|
143
|
-
correlation: z.ZodString;
|
|
144
|
-
causation: z.ZodObject<{
|
|
145
|
-
action: z.ZodOptional<z.ZodIntersection<z.ZodReadonly<z.ZodObject<{
|
|
146
|
-
stream: z.ZodString;
|
|
147
|
-
actor: z.ZodReadonly<z.ZodObject<{
|
|
148
|
-
id: z.ZodString;
|
|
149
|
-
name: z.ZodString;
|
|
150
|
-
}, z.core.$strip>>;
|
|
151
|
-
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
152
|
-
}, z.core.$strip>>, z.ZodObject<{
|
|
153
|
-
name: z.ZodString;
|
|
154
|
-
}, z.core.$strip>>>;
|
|
155
|
-
event: z.ZodOptional<z.ZodObject<{
|
|
156
|
-
id: z.ZodNumber;
|
|
157
|
-
name: z.ZodString;
|
|
158
|
-
stream: z.ZodString;
|
|
159
|
-
}, z.core.$strip>>;
|
|
160
|
-
}, z.core.$strip>;
|
|
161
|
-
}, z.core.$strip>>;
|
|
162
|
-
}, z.core.$strip>[]]>>;
|
|
163
|
-
patches: z.ZodNumber;
|
|
164
|
-
snaps: z.ZodNumber;
|
|
165
|
-
}, z.core.$strip>;
|
|
166
101
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* - `
|
|
170
|
-
* - `
|
|
171
|
-
* - `
|
|
172
|
-
* - `
|
|
173
|
-
* - `
|
|
174
|
-
* - `
|
|
175
|
-
* - `
|
|
176
|
-
* - `
|
|
177
|
-
* - `
|
|
178
|
-
* - `
|
|
102
|
+
* Query options for event store queries.
|
|
103
|
+
*
|
|
104
|
+
* - `stream?`: Filter by stream name
|
|
105
|
+
* - `names?`: Filter by event names
|
|
106
|
+
* - `before?`: Filter events before this id
|
|
107
|
+
* - `after?`: Filter events after this id
|
|
108
|
+
* - `limit?`: Limit the number of events to return
|
|
109
|
+
* - `created_before?`: Filter events created before this date/time
|
|
110
|
+
* - `created_after?`: Filter events created after this date/time
|
|
111
|
+
* - `backward?`: Order descending when true
|
|
112
|
+
* - `correlation?`: Filter by correlation
|
|
113
|
+
* - `actor?`: Filter by actor id (mainly used to reduce process managers)
|
|
114
|
+
* - `loading?`: Flag when loading to optimize queries
|
|
179
115
|
*/
|
|
180
116
|
export declare const QuerySchema: z.ZodObject<{
|
|
181
117
|
stream: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/types/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEnD,eAAO,MAAM,QAAQ,sCAAkC,CAAC;AAExD,eAAO,MAAM,WAAW;;;kBAKX,CAAC;AAEd,eAAO,MAAM,YAAY;;;;;;;kBAMZ,CAAC;AAEd,eAAO,MAAM,oBAAoB;;;;iBAI/B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;kBAQf,CAAC;AAEd,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;kBAQnB,CAAC;AAEd,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,M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
|
|
1
1
|
import { type ZodType } from "zod/v4";
|
|
2
2
|
import type { Patch, Schema } from "./types/index.js";
|
|
3
3
|
/**
|
|
4
|
+
* @module utils
|
|
5
|
+
* @category Utilities
|
|
4
6
|
* Utility functions for patching state, validation, extending objects, and async helpers.
|
|
7
|
+
*
|
|
8
|
+
* - Use `patch()` to immutably update state with patches.
|
|
9
|
+
* - Use `validate()` to validate payloads against Zod schemas.
|
|
10
|
+
* - Use `extend()` to merge and validate configuration objects.
|
|
11
|
+
* - Use `sleep()` for async delays.
|
|
5
12
|
*/
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
14
|
+
* Immutably copies state with patches recursively.
|
|
15
|
+
*
|
|
8
16
|
* Keys with `undefined` or `null` values in patch are deleted.
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
11
|
-
* @
|
|
17
|
+
*
|
|
18
|
+
* @param original The original state object
|
|
19
|
+
* @param patches The patches to merge
|
|
20
|
+
* @returns A new patched state
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const newState = patch(oldState, { count: 5 });
|
|
12
24
|
*/
|
|
13
25
|
export declare const patch: <S extends Schema>(original: Readonly<S>, patches: Readonly<Patch<S>>) => Readonly<S>;
|
|
26
|
+
/**
|
|
27
|
+
* Validates a payload against a Zod schema, throwing a ValidationError on failure.
|
|
28
|
+
*
|
|
29
|
+
* @param target The name of the target (for error reporting)
|
|
30
|
+
* @param payload The payload to validate
|
|
31
|
+
* @param schema (Optional) The Zod schema to validate against
|
|
32
|
+
* @returns The validated payload
|
|
33
|
+
* @throws ValidationError if validation fails
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const valid = validate("User", userPayload, userSchema);
|
|
37
|
+
*/
|
|
14
38
|
export declare const validate: <S>(target: string, payload: Readonly<S>, schema?: ZodType<S>) => Readonly<S>;
|
|
15
39
|
/**
|
|
16
|
-
* Extends target payload with source payload after validating source
|
|
40
|
+
* Extends the target payload with the source payload after validating the source.
|
|
41
|
+
*
|
|
42
|
+
* @param source The source object to validate and merge
|
|
43
|
+
* @param schema The Zod schema for the source
|
|
44
|
+
* @param target (Optional) The target object to extend
|
|
45
|
+
* @returns The merged and validated object
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const config = extend(envConfig, configSchema, defaultConfig);
|
|
17
49
|
*/
|
|
18
50
|
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>;
|
|
51
|
+
/**
|
|
52
|
+
* Async helper to pause execution for a given number of milliseconds.
|
|
53
|
+
*
|
|
54
|
+
* @param ms (Optional) Milliseconds to sleep (defaults to config().sleepMs)
|
|
55
|
+
* @returns Promise that resolves after the delay
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* await sleep(1000); // sleep for 1 second
|
|
59
|
+
*/
|
|
19
60
|
export declare function sleep(ms?: number): Promise<unknown>;
|
|
20
61
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAEpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA+BtD;;;;;;;;;GASG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,EACpC,UAAU,QAAQ,CAAC,CAAC,CAAC,EACrB,SAAS,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAC1B,QAAQ,CAAC,CAAC,CAgBZ,CAAC;AAEF;;;;;;;;;;;GAWG;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,CAaZ,CAAC;AAEF;;;;;;;;;;GAUG;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;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,oBAEtC"}
|