@rotorsoft/act 1.18.0 → 1.18.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/builders/act-builder.d.ts +4 -28
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/builder-base.d.ts +70 -0
- package/dist/@types/builders/builder-base.d.ts.map +1 -0
- package/dist/@types/builders/slice-builder.d.ts +3 -29
- package/dist/@types/builders/slice-builder.d.ts.map +1 -1
- package/dist/@types/internal/builder-utils.d.ts +1 -20
- package/dist/@types/internal/builder-utils.d.ts.map +1 -1
- package/dist/@types/internal/index.d.ts +1 -1
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* Fluent builder for composing event-sourced applications.
|
|
6
6
|
*/
|
|
7
7
|
import { Act, type ActOptions } from "../act.js";
|
|
8
|
-
import { type ReactionOn } from "../internal/index.js";
|
|
9
8
|
import { DEFAULT_LANE } from "../ports.js";
|
|
10
|
-
import type { Actor,
|
|
11
|
-
import type {
|
|
9
|
+
import type { Actor, LaneConfig, Schema, SchemaRegister, Schemas, State } from "../types/index.js";
|
|
10
|
+
import type { BuilderBase } from "./builder-base.js";
|
|
12
11
|
import type { Slice } from "./slice-builder.js";
|
|
13
12
|
/**
|
|
14
13
|
* Fluent builder interface for composing event-sourced applications.
|
|
@@ -34,7 +33,7 @@ import type { Slice } from "./slice-builder.js";
|
|
|
34
33
|
* @see {@link act} for usage examples
|
|
35
34
|
* @see {@link Act} for the built orchestrator API
|
|
36
35
|
*/
|
|
37
|
-
export
|
|
36
|
+
export interface ActBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor, TLanes extends string = typeof DEFAULT_LANE> extends BuilderBase<ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>, TEvents, TActions, TActor, TLanes> {
|
|
38
37
|
/**
|
|
39
38
|
* Registers a state definition with the builder.
|
|
40
39
|
*
|
|
@@ -58,13 +57,6 @@ export type ActBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents exte
|
|
|
58
57
|
* @throws {Error} If duplicate action or event names are detected
|
|
59
58
|
*/
|
|
60
59
|
withSlice: <TNewSchemaReg extends SchemaRegister<TNewActions>, TNewEvents extends Schemas, TNewActions extends Schemas, TNewMap extends Record<string, Schema>, TNewLanes extends string>(slice: Slice<TNewSchemaReg, TNewEvents, TNewActions, TNewMap, Actor, TNewLanes>) => ActBuilder<TSchemaReg & TNewSchemaReg, TEvents & TNewEvents, TActions & TNewActions, TStateMap & TNewMap, TActor, TLanes | TNewLanes>;
|
|
61
|
-
/**
|
|
62
|
-
* Registers a standalone projection with the builder.
|
|
63
|
-
*
|
|
64
|
-
* The projection's events must be a subset of events already registered
|
|
65
|
-
* via `.withState()` or `.withSlice()`.
|
|
66
|
-
*/
|
|
67
|
-
withProjection: <TNewEvents extends Schemas>(projection: [Exclude<keyof TNewEvents, keyof TEvents>] extends [never] ? Projection<TNewEvents> : never) => ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>;
|
|
68
60
|
/**
|
|
69
61
|
* Locks a custom actor type for this application.
|
|
70
62
|
*
|
|
@@ -108,18 +100,6 @@ export type ActBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents exte
|
|
|
108
100
|
* ```
|
|
109
101
|
*/
|
|
110
102
|
withLane: <const TConfig extends LaneConfig>(config: TConfig) => ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes | TConfig["name"]>;
|
|
111
|
-
/**
|
|
112
|
-
* Begins defining a reaction to a specific event.
|
|
113
|
-
*
|
|
114
|
-
* Reactions are event handlers that respond to state changes. They can trigger
|
|
115
|
-
* additional actions, update external systems, or perform side effects. Reactions
|
|
116
|
-
* are processed asynchronously during drain cycles.
|
|
117
|
-
*
|
|
118
|
-
* @template TKey - Event name (must be a registered event)
|
|
119
|
-
* @param event - The event name to react to
|
|
120
|
-
* @returns An object with `.do()` method to define the reaction handler
|
|
121
|
-
*/
|
|
122
|
-
on: <TKey extends keyof TEvents>(event: TKey) => ReactionOn<ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>, TEvents, TActions, TActor, TLanes, TKey>;
|
|
123
103
|
/**
|
|
124
104
|
* Builds and returns the Act orchestrator instance.
|
|
125
105
|
*
|
|
@@ -132,11 +112,7 @@ export type ActBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents exte
|
|
|
132
112
|
* @see {@link Act} for available orchestrator methods
|
|
133
113
|
*/
|
|
134
114
|
build: (options?: ActOptions<TLanes>) => Act<TSchemaReg, TEvents, TActions, TStateMap, TActor>;
|
|
135
|
-
|
|
136
|
-
* The registered event schemas and their reaction maps.
|
|
137
|
-
*/
|
|
138
|
-
readonly events: EventRegister<TEvents>;
|
|
139
|
-
};
|
|
115
|
+
}
|
|
140
116
|
/**
|
|
141
117
|
* Creates a new Act orchestrator builder for composing event-sourced applications.
|
|
142
118
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/act-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"act-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/act-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAcjD,OAAO,EAAE,YAAY,EAAO,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EACV,KAAK,EAEL,UAAU,EAGV,MAAM,EACN,cAAc,EACd,OAAO,EAC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AAS,EAAE,MAAM,CAAC,CA2RhE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module builder-base
|
|
3
|
+
* @category Builders
|
|
4
|
+
*
|
|
5
|
+
* The builder types shared by `SliceBuilder` and `ActBuilder`: the `.on(...)`
|
|
6
|
+
* reaction step ({@link ReactionOn}) and the base of members whose return type
|
|
7
|
+
* is the builder itself with the **same** generics ({@link BuilderBase}). Both
|
|
8
|
+
* are parameterized on the concrete builder (`TReturn` / `Self`) via plain
|
|
9
|
+
* F-bounded polymorphism, so error messages resolve to `SliceBuilder<…>` /
|
|
10
|
+
* `ActBuilder<…>` rather than an abstract base.
|
|
11
|
+
*
|
|
12
|
+
* These live in the builders layer (not `internal/`) because they reference
|
|
13
|
+
* `Projection`, a builders-layer type; the runtime that fills them
|
|
14
|
+
* (`reaction_on`, `register_lane`) stays in `internal/builder-utils.ts`.
|
|
15
|
+
*
|
|
16
|
+
* `withState` and `withLane` are intentionally **not** in `BuilderBase`: they
|
|
17
|
+
* *widen* the generics (return a different instantiation), which a shared
|
|
18
|
+
* signature could only express with HKT emulation, and that degrades the public
|
|
19
|
+
* builder's hover and error output. That trade isn't worth deduping two
|
|
20
|
+
* declarative signatures, so they stay declared per-builder (#1110).
|
|
21
|
+
*/
|
|
22
|
+
import type { Actor, Committed, DeferWhen, EventRegister, IAct, ReactionOptions, ReactionResolver, Schema, Schemas, Snapshot } from "../types/index.js";
|
|
23
|
+
import type { Projection } from "./projection-builder.js";
|
|
24
|
+
/**
|
|
25
|
+
* The `.do(handler)` step, parameterized by the builder it returns (`TReturn`).
|
|
26
|
+
* Identical for both builders modulo that return type.
|
|
27
|
+
*/
|
|
28
|
+
type ReactionDo<TReturn, TEvents extends Schemas, TActions extends Schemas, TActor extends Actor, TLanes extends string, TKey extends keyof TEvents> = (handler: (event: Committed<TEvents, TKey>, stream: string, app: IAct<TEvents, TActions, TActor>) => Promise<Snapshot<Schema, TEvents> | void>, options?: Partial<ReactionOptions>) => TReturn & {
|
|
29
|
+
to: (resolver: ReactionResolver<TEvents, TKey, TLanes> | string) => TReturn;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The object `.on(event)` returns: run immediately with `.do(...)`, or hold
|
|
33
|
+
* with `.defer(when).do(...)`. Parameterized by the return builder so
|
|
34
|
+
* `act()` and `slice()` share one shape.
|
|
35
|
+
*/
|
|
36
|
+
export type ReactionOn<TReturn, TEvents extends Schemas, TActions extends Schemas, TActor extends Actor, TLanes extends string, TKey extends keyof TEvents> = {
|
|
37
|
+
do: ReactionDo<TReturn, TEvents, TActions, TActor, TLanes, TKey>;
|
|
38
|
+
defer: (schedule: DeferWhen | ((event: Committed<TEvents, TKey>) => DeferWhen)) => {
|
|
39
|
+
do: ReactionDo<TReturn, TEvents, TActions, TActor, TLanes, TKey>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Builder members that return `Self` unchanged — shared by both builders.
|
|
44
|
+
*
|
|
45
|
+
* @template Self - the concrete builder type returned for chaining
|
|
46
|
+
* @template TEvents - event schemas
|
|
47
|
+
* @template TActions - action schemas
|
|
48
|
+
* @template TActor - actor type
|
|
49
|
+
* @template TLanes - declared lane-name union
|
|
50
|
+
*/
|
|
51
|
+
export interface BuilderBase<Self, TEvents extends Schemas, TActions extends Schemas, TActor extends Actor, TLanes extends string> {
|
|
52
|
+
/**
|
|
53
|
+
* Registers a standalone projection. Its events must be a subset of events
|
|
54
|
+
* already registered via `.withState()` (or `.withSlice()` on the Act
|
|
55
|
+
* builder); handlers keep their `(event, stream)` signature.
|
|
56
|
+
*/
|
|
57
|
+
withProjection: <TNewEvents extends Schemas>(projection: [Exclude<keyof TNewEvents, keyof TEvents>] extends [never] ? Projection<TNewEvents> : never) => Self;
|
|
58
|
+
/**
|
|
59
|
+
* Begins defining a reaction. Chain `.do(...)` to run immediately, or
|
|
60
|
+
* `.defer(when).do(...)` to hold the reaction until a schedule is due
|
|
61
|
+
* (#1091). `.to(...)` follows `.do(...)` in both cases and, for a deferred
|
|
62
|
+
* reaction, routes it onto its own target so the hold doesn't stall the
|
|
63
|
+
* stream's other reactions.
|
|
64
|
+
*/
|
|
65
|
+
on: <TKey extends keyof TEvents>(event: TKey) => ReactionOn<Self, TEvents, TActions, TActor, TLanes, TKey>;
|
|
66
|
+
/** The registered event schemas and their reaction maps. */
|
|
67
|
+
readonly events: EventRegister<TEvents>;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=builder-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-base.d.ts","sourceRoot":"","sources":["../../../src/builders/builder-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,SAAS,EACT,aAAa,EACb,IAAI,EACJ,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;GAGG;AACH,KAAK,UAAU,CACb,OAAO,EACP,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EACxB,MAAM,SAAS,KAAK,EACpB,MAAM,SAAS,MAAM,EACrB,IAAI,SAAS,MAAM,OAAO,IACxB,CACF,OAAO,EAAE,CACP,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAC/B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,KACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,EAC9C,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,KAC/B,OAAO,GAAG;IACb,EAAE,EAAE,CAAC,QAAQ,EAAE,gBAAgB,C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MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACzC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module slice-builder
|
|
3
|
-
* @category Builders
|
|
4
|
-
*
|
|
5
|
-
* Fluent builder for composing partial states with scoped reactions into
|
|
6
|
-
* self-contained functional slices (vertical slice architecture).
|
|
7
|
-
*/
|
|
8
|
-
import { type ReactionOn } from "../internal/index.js";
|
|
9
1
|
import type { DEFAULT_LANE } from "../ports.js";
|
|
10
2
|
import type { Actor, EventRegister, LaneConfig, Schema, SchemaRegister, Schemas, State } from "../types/index.js";
|
|
3
|
+
import type { BuilderBase } from "./builder-base.js";
|
|
11
4
|
import type { Projection } from "./projection-builder.js";
|
|
12
5
|
/**
|
|
13
6
|
* A self-contained functional slice grouping partial states with their
|
|
@@ -53,7 +46,7 @@ export type Slice<TSchemaReg extends SchemaRegister<TActions>, TEvents extends S
|
|
|
53
46
|
* @template TStateMap - Map of state names to state schemas
|
|
54
47
|
* @template TActor - Actor type extending base Actor
|
|
55
48
|
*/
|
|
56
|
-
export
|
|
49
|
+
export interface SliceBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = {}, TActor extends Actor = Actor, TLanes extends string = typeof DEFAULT_LANE> extends BuilderBase<SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>, TEvents, TActions, TActor, TLanes> {
|
|
57
50
|
/**
|
|
58
51
|
* Registers a state definition with the slice.
|
|
59
52
|
*
|
|
@@ -66,35 +59,16 @@ export type SliceBuilder<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
66
59
|
}, TEvents & TNewEvents, TActions & TNewActions, TStateMap & {
|
|
67
60
|
[K in TNewName]: TNewState;
|
|
68
61
|
}, TActor, TLanes>;
|
|
69
|
-
/**
|
|
70
|
-
* Embeds a built Projection within this slice. The projection's events
|
|
71
|
-
* must be a subset of events from states already registered via
|
|
72
|
-
* `.withState()`. Projection handlers preserve their `(event, stream)`
|
|
73
|
-
* signature and do not receive the app interface.
|
|
74
|
-
*/
|
|
75
|
-
withProjection: <TNewEvents extends Schemas>(projection: [Exclude<keyof TNewEvents, keyof TEvents>] extends [never] ? Projection<TNewEvents> : never) => SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>;
|
|
76
62
|
/**
|
|
77
63
|
* Declares a drain lane on this slice (ACT-1103). Merged into the
|
|
78
64
|
* parent Act's lane set by `act().withSlice(slice)`.
|
|
79
65
|
*/
|
|
80
66
|
withLane: <const TConfig extends LaneConfig>(config: TConfig) => SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes | TConfig["name"]>;
|
|
81
|
-
/**
|
|
82
|
-
* Begins defining a reaction scoped to this slice's events. Chain `.do(...)`
|
|
83
|
-
* to run immediately, or `.defer(when).do(...)` to hold the reaction until a
|
|
84
|
-
* schedule is due (#1091). `.to(...)` follows `.do(...)` in both cases and,
|
|
85
|
-
* for a deferred reaction, is how you route it onto its own target when you
|
|
86
|
-
* don't want the hold to stall the aggregate's other reactions.
|
|
87
|
-
*/
|
|
88
|
-
on: <TKey extends keyof TEvents>(event: TKey) => ReactionOn<SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>, TEvents, TActions, TActor, TLanes, TKey>;
|
|
89
67
|
/**
|
|
90
68
|
* Builds and returns the Slice data structure.
|
|
91
69
|
*/
|
|
92
70
|
build: () => Slice<TSchemaReg, TEvents, TActions, TStateMap, TActor, TLanes>;
|
|
93
|
-
|
|
94
|
-
* The registered event schemas and their reaction maps.
|
|
95
|
-
*/
|
|
96
|
-
readonly events: EventRegister<TEvents>;
|
|
97
|
-
};
|
|
71
|
+
}
|
|
98
72
|
/**
|
|
99
73
|
* Creates a new slice builder for composing partial states with scoped reactions.
|
|
100
74
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/slice-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slice-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/slice-builder.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,UAAU,EACV,MAAM,EACN,cAAc,EACd,OAAO,EACP,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,CACf,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EAExB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,EAC5B,MAAM,SAAS,MAAM,GAAG,OAAO,YAAY,IACzC;IACF,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1C,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC;IACxB,4DAA4D;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,CAAC;IACF;;OAEG;IACH,KAAK,EAAE,MAAM,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9E;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,KACzB,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CA0ClE"}
|
|
@@ -11,26 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
|
-
import type {
|
|
14
|
+
import type { Committed, EventRegister, LaneConfig, ReactionHandler, ReactionOptions, ReactionResolver, Schemas } from "../types/index.js";
|
|
15
15
|
import { type DeferSchedule } from "./defer-config.js";
|
|
16
|
-
/**
|
|
17
|
-
* The `.do(handler)` step, parameterized by the builder it returns (`TReturn`).
|
|
18
|
-
* Identical for both builders modulo that return type.
|
|
19
|
-
*/
|
|
20
|
-
type ReactionDo<TReturn, TEvents extends Schemas, TActions extends Schemas, TActor extends Actor, TLanes extends string, TKey extends keyof TEvents> = (handler: (event: Committed<TEvents, TKey>, stream: string, app: IAct<TEvents, TActions, TActor>) => Promise<Snapshot<Schema, TEvents> | void>, options?: Partial<ReactionOptions>) => TReturn & {
|
|
21
|
-
to: (resolver: ReactionResolver<TEvents, TKey, TLanes> | string) => TReturn;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* The object `.on(event)` returns: run immediately with `.do(...)`, or hold
|
|
25
|
-
* with `.defer(when).do(...)`. Parameterized by the return builder so
|
|
26
|
-
* `act()` and `slice()` share one shape.
|
|
27
|
-
*/
|
|
28
|
-
export type ReactionOn<TReturn, TEvents extends Schemas, TActions extends Schemas, TActor extends Actor, TLanes extends string, TKey extends keyof TEvents> = {
|
|
29
|
-
do: ReactionDo<TReturn, TEvents, TActions, TActor, TLanes, TKey>;
|
|
30
|
-
defer: (schedule: DeferSchedule<Committed<TEvents, TKey>>) => {
|
|
31
|
-
do: ReactionDo<TReturn, TEvents, TActions, TActor, TLanes, TKey>;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
16
|
/**
|
|
35
17
|
* Validate and register a drain lane (ACT-1103): the `"default"` name is
|
|
36
18
|
* reserved and each lane name must be unique. Mutates `lanes` in place; the
|
|
@@ -61,5 +43,4 @@ export declare function reaction_on<TEvents extends Schemas, TKey extends keyof
|
|
|
61
43
|
};
|
|
62
44
|
};
|
|
63
45
|
};
|
|
64
|
-
export {};
|
|
65
46
|
//# sourceMappingURL=builder-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder-utils.d.ts","sourceRoot":"","sources":["../../../src/internal/builder-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"builder-utils.d.ts","sourceRoot":"","sources":["../../../src/internal/builder-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,UAAU,EAEV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,OAAO,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAG3B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAM3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,OAAO,SAAS,OAAO,EACvB,IAAI,SAAS,MAAM,OAAO,EAC1B,QAAQ,EACR,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ;kBAyCjD,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,YAC7B,OAAO,CAAC,eAAe,CAAC;qBAVrB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,MAAM;;sBAYrC,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;sBAE5C,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,YAC7B,OAAO,CAAC,eAAe,CAAC;yBAfvB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,MAAM;;;EAmB1D"}
|
|
@@ -21,7 +21,7 @@ export { type AutocloseConfig, DEFAULT_AUTOCLOSE_CYCLE_MINUTES, DEFAULT_CLOSE_BA
|
|
|
21
21
|
export { type AutoclosePolicy, compile_autoclose_policy, policy_min_after_ms, } from "./autoclose-policy.js";
|
|
22
22
|
export type { EventLaneSet } from "./build-classify.js";
|
|
23
23
|
export { ALL_LANES, classify_registry } from "./build-classify.js";
|
|
24
|
-
export {
|
|
24
|
+
export { reaction_on, register_lane } from "./builder-utils.js";
|
|
25
25
|
export { CircuitBreaker, type CircuitBreakerOptions, type CircuitState, resolveCircuitBreakerConfig, } from "./circuit-breaker.js";
|
|
26
26
|
export { run_close_cycle } from "./close-cycle.js";
|
|
27
27
|
export { CloseSignal } from "./close-signal.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,KAAK,eAAe,EACpB,+BAA+B,EAC/B,wBAAwB,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