@rotorsoft/act 1.32.29 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +41 -233
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts +2 -115
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/builder-utils.d.ts +1 -1
- package/dist/@types/builders/builder-utils.d.ts.map +1 -1
- package/dist/@types/builders/event-builder.d.ts +5 -5
- package/dist/@types/builders/event-builder.d.ts.map +1 -1
- package/dist/@types/builders/merge.d.ts +1 -1
- package/dist/@types/builders/merge.d.ts.map +1 -1
- package/dist/@types/builders/projection-builder.d.ts +2 -144
- package/dist/@types/builders/projection-builder.d.ts.map +1 -1
- package/dist/@types/builders/slice-builder.d.ts +2 -71
- package/dist/@types/builders/slice-builder.d.ts.map +1 -1
- package/dist/@types/builders/state-builder.d.ts +2 -376
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/config.d.ts +6 -43
- package/dist/@types/config.d.ts.map +1 -1
- package/dist/@types/csv.d.ts +1 -15
- package/dist/@types/csv.d.ts.map +1 -1
- package/dist/@types/index.d.ts +0 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-policy.d.ts +9 -108
- package/dist/@types/internal/autoclose-policy.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-reaction.d.ts +1 -9
- package/dist/@types/internal/autoclose-reaction.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-window.d.ts +2 -15
- package/dist/@types/internal/autoclose-window.d.ts.map +1 -1
- package/dist/@types/internal/backoff.d.ts +1 -6
- package/dist/@types/internal/backoff.d.ts.map +1 -1
- package/dist/@types/internal/circuit-breaker.d.ts +1 -4
- package/dist/@types/internal/circuit-breaker.d.ts.map +1 -1
- package/dist/@types/{builders/build-classify.d.ts → internal/classify.d.ts} +2 -15
- package/dist/@types/internal/classify.d.ts.map +1 -0
- package/dist/@types/internal/close-cycle.d.ts +0 -13
- package/dist/@types/internal/close-cycle.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +9 -81
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/{correlator.d.ts → correlation-id.d.ts} +1 -8
- package/dist/@types/internal/correlation-id.d.ts.map +1 -0
- package/dist/@types/internal/date-reviver.d.ts +0 -5
- package/dist/@types/internal/date-reviver.d.ts.map +1 -1
- package/dist/@types/internal/defer-config.d.ts +0 -13
- package/dist/@types/internal/defer-config.d.ts.map +1 -1
- package/dist/@types/internal/defer-timer.d.ts +1 -5
- package/dist/@types/internal/defer-timer.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/{drain.d.ts → drain-ops.d.ts} +1 -7
- package/dist/@types/internal/drain-ops.d.ts.map +1 -0
- package/dist/@types/internal/drain-ratio.d.ts +0 -5
- package/dist/@types/internal/drain-ratio.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts +1 -8
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/event-versions.d.ts +0 -9
- package/dist/@types/internal/event-versions.d.ts.map +1 -1
- package/dist/@types/internal/lru-map.d.ts +0 -9
- package/dist/@types/internal/lru-map.d.ts.map +1 -1
- package/dist/@types/internal/pii.d.ts +78 -0
- package/dist/@types/internal/pii.d.ts.map +1 -0
- package/dist/@types/internal/projection-fold.d.ts +1 -5
- package/dist/@types/internal/projection-fold.d.ts.map +1 -1
- package/dist/@types/internal/{close-signal.d.ts → reaction-dispatch.d.ts} +46 -6
- package/dist/@types/internal/reaction-dispatch.d.ts.map +1 -0
- package/dist/@types/internal/report-once.d.ts +1 -8
- package/dist/@types/internal/report-once.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +21 -21
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/@types/internal/tracing.d.ts +3 -14
- package/dist/@types/internal/tracing.d.ts.map +1 -1
- package/dist/@types/internal/walk-streams.d.ts +0 -2
- package/dist/@types/internal/walk-streams.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +3 -43
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/scoped.d.ts +1 -6
- package/dist/@types/scoped.d.ts.map +1 -1
- package/dist/@types/sensitive.d.ts +56 -0
- package/dist/@types/sensitive.d.ts.map +1 -0
- package/dist/@types/test/index.d.ts +1 -0
- package/dist/@types/test/index.d.ts.map +1 -1
- package/dist/@types/test/sandbox.d.ts +2 -26
- package/dist/@types/test/sandbox.d.ts.map +1 -1
- package/dist/@types/types/act.d.ts +216 -0
- package/dist/@types/types/act.d.ts.map +1 -0
- package/dist/@types/types/action.d.ts +67 -0
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/builders.d.ts +722 -0
- package/dist/@types/types/builders.d.ts.map +1 -0
- package/dist/@types/types/errors.d.ts +31 -1
- package/dist/@types/types/errors.d.ts.map +1 -1
- package/dist/@types/types/index.d.ts +38 -0
- package/dist/@types/types/index.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +16 -10
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +11 -1
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/@types/types/sandbox.d.ts +31 -0
- package/dist/@types/types/sandbox.d.ts.map +1 -0
- package/dist/@types/types/schemas.d.ts +12 -17
- package/dist/@types/types/schemas.d.ts.map +1 -1
- package/dist/{chunk-F7K7SIG6.js → chunk-2PMUONGF.js} +38 -57
- package/dist/chunk-2PMUONGF.js.map +1 -0
- package/dist/chunk-HF433MAF.cjs +264 -0
- package/dist/chunk-HF433MAF.cjs.map +1 -0
- package/dist/{chunk-5FXT63KF.js → chunk-JABYJGT7.js} +184 -24
- package/dist/chunk-JABYJGT7.js.map +1 -0
- package/dist/chunk-VE3MTY4A.cjs +1233 -0
- package/dist/chunk-VE3MTY4A.cjs.map +1 -0
- package/dist/index.cjs +1615 -3003
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +751 -813
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +16 -1105
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +2 -2
- package/dist/test/index.js.map +1 -1
- package/dist/types/index.cjs +58 -276
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +15 -1
- package/package.json +1 -1
- package/dist/@types/builders/build-classify.d.ts.map +0 -1
- package/dist/@types/builders/builder-base.d.ts +0 -70
- package/dist/@types/builders/builder-base.d.ts.map +0 -1
- package/dist/@types/builders/reaction-builder.d.ts +0 -55
- package/dist/@types/builders/reaction-builder.d.ts.map +0 -1
- package/dist/@types/internal/close-signal.d.ts.map +0 -1
- package/dist/@types/internal/correlator.d.ts.map +0 -1
- package/dist/@types/internal/defer-signal.d.ts +0 -35
- package/dist/@types/internal/defer-signal.d.ts.map +0 -1
- package/dist/@types/internal/drain.d.ts.map +0 -1
- package/dist/@types/internal/index.d.ts +0 -43
- package/dist/@types/internal/index.d.ts.map +0 -1
- package/dist/@types/internal/sensitive.d.ts +0 -177
- package/dist/@types/internal/sensitive.d.ts.map +0 -1
- package/dist/chunk-5FXT63KF.js.map +0 -1
- package/dist/chunk-F7K7SIG6.js.map +0 -1
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module settle
|
|
3
|
-
* @category Internal
|
|
4
|
-
*
|
|
5
2
|
* Debounced correlate→drain loop. Sits one level above both correlation
|
|
6
3
|
* and drain: schedule() coalesces rapid callers into a single cycle, then
|
|
7
4
|
* runs correlate+drain in a loop until a pass produces no progress.
|
|
@@ -9,8 +6,6 @@
|
|
|
9
6
|
* Owns the debounce timer and the reentrancy flag. Everything else is
|
|
10
7
|
* supplied via the `SettleDeps` callbacks so this module stays free of
|
|
11
8
|
* orchestrator state.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
9
|
*/
|
|
15
10
|
import type { Drain, DrainOptions, Query, Schemas, SettleOptions } from "../types/index.js";
|
|
16
11
|
import type { CircuitBreaker } from "./circuit-breaker.js";
|
|
@@ -18,8 +13,6 @@ import type { CircuitBreaker } from "./circuit-breaker.js";
|
|
|
18
13
|
* Callbacks the settle loop needs from the orchestrator. Modeled as an
|
|
19
14
|
* input bag so this file doesn't import `Act` (avoids a cycle) and stays
|
|
20
15
|
* independently testable.
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
16
|
*/
|
|
24
17
|
export type SettleDeps<TEvents extends Schemas> = {
|
|
25
18
|
readonly init: () => Promise<void>;
|
|
@@ -43,8 +36,6 @@ export type SettleDeps<TEvents extends Schemas> = {
|
|
|
43
36
|
/**
|
|
44
37
|
* Drives the debounced correlate→drain catch-up cycle. One instance per
|
|
45
38
|
* Act orchestrator.
|
|
46
|
-
*
|
|
47
|
-
* @internal
|
|
48
39
|
*/
|
|
49
40
|
export declare class SettleLoop<TEvents extends Schemas> {
|
|
50
41
|
private _timer;
|
|
@@ -54,22 +45,28 @@ export declare class SettleLoop<TEvents extends Schemas> {
|
|
|
54
45
|
* it (`stop()` cancels scheduling only). Never rejects.
|
|
55
46
|
*/
|
|
56
47
|
private _inflight;
|
|
57
|
-
/**
|
|
58
|
-
* A wake-up that fired while a cycle was running. The running cycle's
|
|
59
|
-
* `finally` schedules one more pass with these options, so it isn't lost.
|
|
60
|
-
*/
|
|
48
|
+
/** A wake-up arrived while a cycle ran: run one more pass after it. */
|
|
61
49
|
private _pending;
|
|
50
|
+
/** The last caller's options, used by the next pass. */
|
|
51
|
+
private _next;
|
|
52
|
+
/** When the scheduled pass fires (epoch ms). */
|
|
53
|
+
private _due;
|
|
54
|
+
/** Set at shutdown: nothing schedules again. */
|
|
55
|
+
private _stopped;
|
|
62
56
|
private readonly _deps;
|
|
63
57
|
/** Debounce window applied when the caller doesn't override via `SettleOptions.debounceMs`. */
|
|
64
58
|
private readonly _default_debounce_ms;
|
|
65
59
|
constructor(deps: SettleDeps<TEvents>, default_debounce_ms: number);
|
|
66
60
|
/**
|
|
67
|
-
* Schedule a settle pass.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
61
|
+
* Schedule a settle pass. A pass already scheduled is never put off or
|
|
62
|
+
* replaced: calls that arrive before it runs join it (a shorter
|
|
63
|
+
* `debounceMs` brings it forward), and a call during a running cycle
|
|
64
|
+
* queues one more pass after it. Callers pass options, which the next
|
|
65
|
+
* pass uses; internal wake-ups pass none, so they never discard a
|
|
66
|
+
* caller's. The cycle runs correlate→drain in a
|
|
67
|
+
* loop until no progress is made (no new subscriptions, no events read,
|
|
68
|
+
* no streams leased) or `maxPasses` is reached, then emits the
|
|
69
|
+
* `"settled"` lifecycle event via {@link SettleDeps.on_settled}.
|
|
73
70
|
*/
|
|
74
71
|
schedule(options?: SettleOptions): void;
|
|
75
72
|
/**
|
|
@@ -78,7 +75,10 @@ export declare class SettleLoop<TEvents extends Schemas> {
|
|
|
78
75
|
* settle parked in `correlate` does not resume after teardown.
|
|
79
76
|
*/
|
|
80
77
|
get inflight(): Promise<void> | undefined;
|
|
81
|
-
/**
|
|
82
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Cancel any pending settle pass. Idempotent. `final` (shutdown) also
|
|
80
|
+
* stops all later scheduling.
|
|
81
|
+
*/
|
|
82
|
+
stop(final?: boolean): void;
|
|
83
83
|
}
|
|
84
84
|
//# sourceMappingURL=settle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settle.d.ts","sourceRoot":"","sources":["../../../src/internal/settle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settle.d.ts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AAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,+FAA+F;IAC/F,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAE9C,YAAY,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,MAAM,EAGjE;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CA0FtC;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAExC;IAED;;;OAGG;IACH,IAAI,CAAC,KAAK,UAAQ,GAAG,IAAI,CAUxB;CACF"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module tracing
|
|
3
|
-
* @category Internal
|
|
4
|
-
*
|
|
5
2
|
* Centralized observability for the framework's internal pipelines.
|
|
6
3
|
*
|
|
7
4
|
* Trace decorators wrap a bare implementation with `logger.trace(...)` calls
|
|
@@ -22,24 +19,18 @@
|
|
|
22
19
|
* orchestrator choose bare or traced variants once at `.build()` time based
|
|
23
20
|
* on the configured log level. Outside this module, no other source file
|
|
24
21
|
* imports tracing primitives.
|
|
25
|
-
*
|
|
26
|
-
* @internal
|
|
27
22
|
*/
|
|
28
|
-
import type { Correlator, Logger, Schemas } from "../types/index.js";
|
|
29
|
-
import type { DrainOps } from "./drain.js";
|
|
30
|
-
import type { EsOps
|
|
23
|
+
import type { Correlator, Logger, PatchFn, Schemas } from "../types/index.js";
|
|
24
|
+
import type { DrainOps } from "./drain-ops.js";
|
|
25
|
+
import type { EsOps } from "./event-sourcing.js";
|
|
31
26
|
/**
|
|
32
27
|
* Selects bare or traced event-sourcing handlers. Called once by the
|
|
33
28
|
* orchestrator constructor.
|
|
34
|
-
*
|
|
35
|
-
* @internal
|
|
36
29
|
*/
|
|
37
30
|
export declare function build_es(logger: Logger, correlator?: Correlator, patch_fn?: PatchFn): EsOps;
|
|
38
31
|
/**
|
|
39
32
|
* Selects bare or traced drain-pipeline ops. Called once by the orchestrator
|
|
40
33
|
* constructor.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
34
|
*/
|
|
44
35
|
export declare function build_drain<TEvents extends Schemas>(logger: Logger): DrainOps<TEvents>;
|
|
45
36
|
/**
|
|
@@ -64,8 +55,6 @@ export declare function build_drain<TEvents extends Schemas>(logger: Logger): Dr
|
|
|
64
55
|
* marker and its adjacent post-state share the marker's color so the
|
|
65
56
|
* eye reads "outcome + where it landed" as one unit. Per-stream
|
|
66
57
|
* `[events]` and `(error)` stay dim — secondary context.
|
|
67
|
-
*
|
|
68
|
-
* @internal
|
|
69
58
|
*/
|
|
70
59
|
export declare function trace_cycle<TEvents extends Schemas>(logger: Logger, leased: ReadonlyArray<{
|
|
71
60
|
readonly stream: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../src/internal/tracing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../src/internal/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAEV,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AA+HjD;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,UAA+B,EAC3C,QAAQ,GAAE,OAAuB,GAChC,KAAK,CA4FP;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,SAAS,OAAO,EACjD,MAAM,EAAE,MAAM,GACb,QAAQ,CAAC,OAAO,CAAC,CAoCnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH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sets the page
|
|
16
16
|
* size (the walk still visits every match); `after` seeds the cursor.
|
|
17
17
|
* @returns The total number of positions emitted.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
18
|
*/
|
|
21
19
|
export declare function walk_streams(store: Store, callback: (position: StreamPosition) => void, query?: Omit<QueryStreams, "after" | "limit"> & {
|
|
22
20
|
after?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk-streams.d.ts","sourceRoot":"","sources":["../../../src/internal/walk-streams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAK7E
|
|
1
|
+
{"version":3,"file":"walk-streams.d.ts","sourceRoot":"","sources":["../../../src/internal/walk-streams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAK7E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC5C,KAAK,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
|
package/dist/@types/ports.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ConsoleLogger } from "./adapters/console-logger.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
export type { Scoped } from "./scoped.js";
|
|
2
|
+
import type { Cache, Disposable, Disposer, Logger, Scoped, Store } from "./types/index.js";
|
|
3
|
+
import { type ExitCode } from "./types/index.js";
|
|
5
4
|
/**
|
|
6
5
|
* Port/adapter infrastructure for the Act framework.
|
|
7
6
|
*
|
|
@@ -16,22 +15,6 @@ export type { Scoped } from "./scoped.js";
|
|
|
16
15
|
*
|
|
17
16
|
* @module ports
|
|
18
17
|
*/
|
|
19
|
-
/**
|
|
20
|
-
* List of exit codes for process termination. Consumed by signal handlers
|
|
21
|
-
* and {@link disposeAndExit}; not part of the user-facing surface.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export declare const ExitCodes: readonly ["ERROR", "EXIT"];
|
|
26
|
-
/**
|
|
27
|
-
* Type for allowed exit codes.
|
|
28
|
-
*
|
|
29
|
-
* - `"ERROR"` — abnormal termination (uncaught exception, unhandled rejection)
|
|
30
|
-
* - `"EXIT"` — clean shutdown (SIGINT, SIGTERM, or manual trigger)
|
|
31
|
-
*
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
export type ExitCode = (typeof ExitCodes)[number];
|
|
35
18
|
/**
|
|
36
19
|
* Factory function that creates or returns the injected adapter.
|
|
37
20
|
* @internal
|
|
@@ -147,28 +130,5 @@ export declare function disposeAndExit(code?: ExitCode): Promise<void>;
|
|
|
147
130
|
* @see {@link disposeAndExit} for the full shutdown sequence
|
|
148
131
|
*/
|
|
149
132
|
export declare function dispose(disposer?: Disposer): (code?: ExitCode) => Promise<void>;
|
|
150
|
-
|
|
151
|
-
* Event name used internally for snapshot events in the event store.
|
|
152
|
-
* Snapshot events store a full state checkpoint, enabling efficient cold-start
|
|
153
|
-
* recovery without replaying the entire event stream.
|
|
154
|
-
*/
|
|
155
|
-
export declare const SNAP_EVENT = "__snapshot__";
|
|
156
|
-
/**
|
|
157
|
-
* Event name used internally for tombstone events in the event store.
|
|
158
|
-
* A tombstone marks a stream as permanently closed — no further writes
|
|
159
|
-
* are permitted until the stream is explicitly restarted via `close()`.
|
|
160
|
-
*
|
|
161
|
-
* @see {@link Act.close} for the close-the-books API
|
|
162
|
-
*/
|
|
163
|
-
export declare const TOMBSTONE_EVENT = "__tombstone__";
|
|
164
|
-
/**
|
|
165
|
-
* Name of the implicit lane every reaction lands in unless its `.to({lane})`
|
|
166
|
-
* declaration says otherwise. Acts that don't call
|
|
167
|
-
* `.withLane(...)` see only this lane, and behavior is identical to
|
|
168
|
-
* pre-1103 single-controller drain.
|
|
169
|
-
*
|
|
170
|
-
* Persisted on `streams.lane` and threaded as the strict-typed default in
|
|
171
|
-
* builder generics — `lane?: TLanes` always includes `"default"`.
|
|
172
|
-
*/
|
|
173
|
-
export declare const DEFAULT_LANE = "default";
|
|
133
|
+
export {};
|
|
174
134
|
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AAMH;;;GAGG;AACH,KAAK,QAAQ,CAAC,IAAI,SAAS,UAAU,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;AAKlE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,IAAI,SAAS,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,cAClD,IAAI,KAAG,IAAI,CAW9B;AAMD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,GAAG,0EASd,CAAC;AA8BH,eAAO,MAAM,KAAK,EAEZ,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC;AAmBjC,eAAO,MAAM,KAAK,EAEZ,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC;AAEjC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,QAAO,MAAuB,CAAC;AAezD;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,QAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB3E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CACrB,QAAQ,CAAC,EAAE,QAAQ,GAClB,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAGpC"}
|
package/dist/@types/scoped.d.ts
CHANGED
|
@@ -24,12 +24,7 @@
|
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
26
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
27
|
-
import type { Actor,
|
|
28
|
-
/** Per-Act ports bag. Both required together — a shared cache across stores would collide on stream keys. */
|
|
29
|
-
export type Scoped = {
|
|
30
|
-
readonly store: Store;
|
|
31
|
-
readonly cache: Cache;
|
|
32
|
-
};
|
|
27
|
+
import type { Actor, Committed, IAct, Schemas, Scoped } from "./types/index.js";
|
|
33
28
|
/**
|
|
34
29
|
* What an Act actually installs in its frame: the ports a caller passed,
|
|
35
30
|
* plus per-Act settings that runtime code has to read from the *running*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped.d.ts","sourceRoot":"","sources":["../../src/scoped.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"scoped.d.ts","sourceRoot":"","sources":["../../src/scoped.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AAE,MAAM,CAAC,EACjC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KACjB,OAAO,CAAC,CAAC,CAAC,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EACxB,MAAM,SAAS,KAAK,GAAG,KAAK,EAE5B,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GACnC,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAE1C"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sensitive-data marker: the registry `sensitive(zodType)` writes to,
|
|
3
|
+
* and the lookups that read it. The public `sensitive()` and the two
|
|
4
|
+
* sentinels live in `types/schemas.ts`, which re-exports `pii_fields` from
|
|
5
|
+
* here. The transforms that apply the marker at commit, load and dispatch
|
|
6
|
+
* live in `internal/pii.ts`.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
/**
|
|
10
|
+
* Process-global registry holding every Zod schema marked sensitive. Backed
|
|
11
|
+
* by a `WeakMap`, so wrapper-created instances (`.optional()`, `.nullable()`,
|
|
12
|
+
* `.default()`) that chain off a marked schema produce *new* schema instances
|
|
13
|
+
* the registry doesn't track; the field walker handles those via unwrap.
|
|
14
|
+
*
|
|
15
|
+
* Exported so the public `sensitive(zodType)` wrapper can call `_registry.add`.
|
|
16
|
+
* Underscore prefix marks "framework-private, don't touch from user code."
|
|
17
|
+
*/
|
|
18
|
+
export declare const _registry: z.core.$ZodRegistry<{
|
|
19
|
+
sensitive: true;
|
|
20
|
+
}, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
21
|
+
/**
|
|
22
|
+
* Stamp the def-level marker. Called by the public `sensitive()` alongside
|
|
23
|
+
* `_registry.add`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function _mark_sensitive(schema: z.ZodType): void;
|
|
26
|
+
/**
|
|
27
|
+
* Derive an event's sensitive fields, as the declared schema of each.
|
|
28
|
+
*
|
|
29
|
+
* Walks the top-level shape of a `z.object({...})` and keeps the keys whose
|
|
30
|
+
* schema (after unwrapping optional/nullable/default wrappers) was marked via
|
|
31
|
+
* `sensitive(...)`. Returns an empty object for non-object schemas or events
|
|
32
|
+
* with no sensitive fields — the common-case zero-cost path.
|
|
33
|
+
*
|
|
34
|
+
* Only the top-level shape is walked. Sensitive fields nested inside a
|
|
35
|
+
* `z.object` declared inside the event payload would require recursive
|
|
36
|
+
* descent; that's deferred until a real callsite needs it.
|
|
37
|
+
*
|
|
38
|
+
* A union event has no top-level shape, so the options are walked and merged:
|
|
39
|
+
* a key sensitive in any variant must be split, because the stored payload
|
|
40
|
+
* could be that variant.
|
|
41
|
+
* The first variant to declare a key wins, which only matters to a caller that
|
|
42
|
+
* wants the schema rather than the name.
|
|
43
|
+
*
|
|
44
|
+
* Returning the schemas rather than just the names is what lets a caller do
|
|
45
|
+
* something per field — the event builder asks each one whether it holds a
|
|
46
|
+
* date, so the `pii` sidecar's dates can be revived like any other.
|
|
47
|
+
*/
|
|
48
|
+
export declare function pii_schemas(schema: z.ZodType): Record<string, z.ZodType>;
|
|
49
|
+
/**
|
|
50
|
+
* The top-level field names of a schema marked with `sensitive()`. Adapters
|
|
51
|
+
* and tooling use it to reflect sensitivity on their own wire surface (the
|
|
52
|
+
* act-http OpenAPI emitter marks these fields `writeOnly`). Returns `[]`
|
|
53
|
+
* for a schema with no sensitive fields.
|
|
54
|
+
*/
|
|
55
|
+
export declare function pii_fields(schema: z.ZodType): readonly string[];
|
|
56
|
+
//# sourceMappingURL=sensitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive.d.ts","sourceRoot":"","sources":["../../src/sensitive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS;eAA2B,IAAI;iFAAK,CAAC;AAe3D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,CAOvD;AA6BD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAmBxE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,MAAM,EAAE,CAE/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,cAAc,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ActOptions } from "../
|
|
2
|
-
import type {
|
|
1
|
+
import type { ActOptions } from "../types/index.js";
|
|
2
|
+
import type { Sandbox, SandboxOptions } from "../types/sandbox.js";
|
|
3
3
|
/**
|
|
4
4
|
* Minimal structural shape — anything with a `.build()` that returns an
|
|
5
5
|
* Act. Avoids the variance pitfalls of constraining on the full
|
|
@@ -9,30 +9,6 @@ import type { Cache, Store } from "../types/index.js";
|
|
|
9
9
|
type AnyActBuilder<TApp> = {
|
|
10
10
|
build: (options?: ActOptions<any>) => TApp;
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Options for {@link sandbox} / {@link fixture}.
|
|
14
|
-
*
|
|
15
|
-
* Defaults to `new InMemoryStore() + new InMemoryCache()` per call.
|
|
16
|
-
* Override `store` / `cache` to point at PG, SQLite, or any other
|
|
17
|
-
* adapter — factories run once per call so each test gets a fresh
|
|
18
|
-
* instance.
|
|
19
|
-
*/
|
|
20
|
-
export type SandboxOptions = {
|
|
21
|
-
/** Factory for the per-test store. Defaults to `new InMemoryStore()`. */
|
|
22
|
-
readonly store?: () => Store | Promise<Store>;
|
|
23
|
-
/** Factory for the per-test cache. Defaults to `new InMemoryCache()`. */
|
|
24
|
-
readonly cache?: () => Cache | Promise<Cache>;
|
|
25
|
-
/** Pass-through ActOptions. `scoped` is filled in by the helper. */
|
|
26
|
-
readonly actOptions?: Omit<ActOptions, "scoped">;
|
|
27
|
-
};
|
|
28
|
-
/** Return shape of {@link sandbox}. */
|
|
29
|
-
export type Sandbox<TApp> = {
|
|
30
|
-
readonly app: TApp;
|
|
31
|
-
readonly store: Store;
|
|
32
|
-
readonly cache: Cache;
|
|
33
|
-
/** Tears down the Act, store, and cache. Idempotent. */
|
|
34
|
-
readonly dispose: () => Promise<void>;
|
|
35
|
-
};
|
|
36
12
|
/**
|
|
37
13
|
* Build a scoped Act bound to a fresh `{ store, cache }` bag.
|
|
38
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/test/sandbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/test/sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnE;;;;;GAKG;AACH,KAAK,aAAa,CAAC,IAAI,IAAI;IAOzB,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAChC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAC5B,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAuBxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAC1B,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAC5B,QAAQ,GAAE,cAAmB;;GAgB9B"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public contracts of the orchestrator: the options `act().build()` takes,
|
|
3
|
+
* the lifecycle events an `Act` emits, and the public defaults behind them.
|
|
4
|
+
* The `Act` class implements them in `../act.ts`; their Zod schemas and
|
|
5
|
+
* resolvers live in `../internal/config.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import type { CloseResult, Correlator, Schema, Schemas, Snapshot } from "./action.js";
|
|
8
|
+
import type { Cache, Store, StoreNotification } from "./ports.js";
|
|
9
|
+
import type { BlockedLease, Drain, Lease } from "./reaction.js";
|
|
10
|
+
import type { SchemaRegister } from "./registry.js";
|
|
11
|
+
/**
|
|
12
|
+
* Default debounce window (ms) for `settle()` when neither the per-call
|
|
13
|
+
* `SettleOptions.debounceMs` nor `ActOptions.settleDebounceMs` is set.
|
|
14
|
+
* Coalesces commits in the same tick and small bursts.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_SETTLE_DEBOUNCE_MS = 10;
|
|
17
|
+
/**
|
|
18
|
+
* Default LRU cap for the subscribed-streams cache. Apps that mint many
|
|
19
|
+
* dynamic targets (one per aggregate) should override it with
|
|
20
|
+
* `ActOptions.maxSubscribedStreams`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_MAX_SUBSCRIBED_STREAMS = 1000;
|
|
23
|
+
/** Per-Act ports bag. Both required together — a shared cache across stores would collide on stream keys. */
|
|
24
|
+
export type Scoped = {
|
|
25
|
+
readonly store: Store;
|
|
26
|
+
readonly cache: Cache;
|
|
27
|
+
};
|
|
28
|
+
/** Circuit breaker state, reported with every `error` lifecycle event. */
|
|
29
|
+
export type CircuitState = "closed" | "open" | "half-open";
|
|
30
|
+
/** Public, all-optional circuit-breaker options bag for `act().build()`. */
|
|
31
|
+
export type CircuitBreakerOptions = {
|
|
32
|
+
failureThreshold?: number;
|
|
33
|
+
cooldownMs?: number;
|
|
34
|
+
};
|
|
35
|
+
/** Resolved autoclose configuration after validation + default expansion. */
|
|
36
|
+
export type AutocloseConfig = {
|
|
37
|
+
autocloseWindow?: {
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
timeZone: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Lifecycle events emitted by {@link Act}, mapped to their payload type.
|
|
45
|
+
* Drives the typing of `emit` / `on` / `off` — the event-name argument
|
|
46
|
+
* narrows its payload at the call site.
|
|
47
|
+
*
|
|
48
|
+
* The first parameter is kept (unused) for arity compatibility: `committed`
|
|
49
|
+
* carries snapshots of whichever state each action targeted, so its honest
|
|
50
|
+
* element type is `Snapshot<Schema, TEvents>` — the register map itself was
|
|
51
|
+
* never the shape of any snapshot's state.
|
|
52
|
+
*/
|
|
53
|
+
export type ActLifecycleEvents<_TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas> = {
|
|
54
|
+
committed: Snapshot<Schema, TEvents>[];
|
|
55
|
+
acked: Lease[];
|
|
56
|
+
blocked: BlockedLease[];
|
|
57
|
+
settled: Drain<TEvents>;
|
|
58
|
+
closed: CloseResult;
|
|
59
|
+
/**
|
|
60
|
+
* A **different process** committed an event to the same backing store.
|
|
61
|
+
*
|
|
62
|
+
* Fires only when the configured store implements
|
|
63
|
+
* {@link Store.notify} and there is at least one registered reaction.
|
|
64
|
+
* The orchestrator uses the same signal internally to wake `settle()`
|
|
65
|
+
* — listeners get the raw payload for SSE fan-out, dashboards, and
|
|
66
|
+
* audit logs.
|
|
67
|
+
*
|
|
68
|
+
* Local commits do *not* fire `notified` (use `committed` for those):
|
|
69
|
+
* stores self-filter their own writes so this channel has a clean
|
|
70
|
+
* cross-process semantic.
|
|
71
|
+
*/
|
|
72
|
+
notified: StoreNotification;
|
|
73
|
+
/**
|
|
74
|
+
* A stream's sensitive-data payload was wiped via {@link Act.forget}.
|
|
75
|
+
* Fires exactly once per successful `forget(stream)` call — idempotent
|
|
76
|
+
* second calls (no PII left on the stream) return `eventCount: 0` and
|
|
77
|
+
* do NOT re-emit. Apps that never call `forget()` never see this event.
|
|
78
|
+
*
|
|
79
|
+
* Listeners use it for the compliance side of GDPR / CCPA: audit log,
|
|
80
|
+
* downstream cache busts, projection-side wipes that the framework
|
|
81
|
+
* doesn't reach (e.g., search indexes, ETL caches). The framework's own
|
|
82
|
+
* cache is invalidated by `forget()` itself before the event fires.
|
|
83
|
+
*/
|
|
84
|
+
forgotten: {
|
|
85
|
+
stream: string;
|
|
86
|
+
at: Date;
|
|
87
|
+
eventCount: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* A store operation failed during the drain loop. Fires on
|
|
91
|
+
* every failed drain cycle — typically a {@link StoreError} from a
|
|
92
|
+
* degraded backend — carrying the orchestrator circuit breaker's state
|
|
93
|
+
* after the failure (`open` means the drain loop has backed off and will
|
|
94
|
+
* retry after the cooldown). Listen to alert on a degraded store; the
|
|
95
|
+
* framework logs the same error regardless. Emitted only when a listener
|
|
96
|
+
* is registered (Node's `EventEmitter` throws on an unhandled `"error"`).
|
|
97
|
+
*/
|
|
98
|
+
error: {
|
|
99
|
+
error: unknown;
|
|
100
|
+
circuit: CircuitState;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Options for {@link Act} construction (passed via {@link ActBuilder.build}).
|
|
105
|
+
*
|
|
106
|
+
* @property maxSubscribedStreams - Cap for the LRU tracking what each
|
|
107
|
+
* dynamically resolved reaction target was last subscribed at. Statically
|
|
108
|
+
* declared targets are held outside it and never evicted, so their lane
|
|
109
|
+
* and priority stay owned by the build-time subscribe.
|
|
110
|
+
* Default: {@link DEFAULT_MAX_SUBSCRIBED_STREAMS}.
|
|
111
|
+
* @property settleDebounceMs - Debounce window (ms) used by `settle()` when
|
|
112
|
+
* the caller doesn't pass `SettleOptions.debounceMs`. Tune this once per
|
|
113
|
+
* Act instance instead of threading the value through every call site.
|
|
114
|
+
* Default: {@link DEFAULT_SETTLE_DEBOUNCE_MS}.
|
|
115
|
+
* @property autoSettle - Settle on its own after a change that frees
|
|
116
|
+
* reaction work: a commit, `reset()`, `unblock()`, `restore()` or a
|
|
117
|
+
* notification from another process. Set `false` when you walk the
|
|
118
|
+
* pipeline yourself with `correlate()` / `drain()` (tests that check its
|
|
119
|
+
* steps, tools). Timers still run: lanes with `cycleMs`,
|
|
120
|
+
* `start_correlations()`, the circuit breaker's recovery pass after a
|
|
121
|
+
* store failure, and each stream's backoff or defer wake-up.
|
|
122
|
+
* Default: `true`.
|
|
123
|
+
*/
|
|
124
|
+
export type ActOptions<TLanes extends string = string> = {
|
|
125
|
+
readonly maxSubscribedStreams?: number;
|
|
126
|
+
readonly settleDebounceMs?: number;
|
|
127
|
+
readonly autoSettle?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Per-Act ports. When set, this Act runs against the
|
|
130
|
+
* provided store + cache instead of the singletons — threaded via
|
|
131
|
+
* AsyncLocalStorage so internals are unchanged. Both are required
|
|
132
|
+
* together (a shared cache across distinct stores would collide on
|
|
133
|
+
* stream keys). Omit for the singleton path.
|
|
134
|
+
*/
|
|
135
|
+
readonly scoped?: Scoped;
|
|
136
|
+
/**
|
|
137
|
+
* Correlation-id generator for originating actions. When
|
|
138
|
+
* omitted, Act uses {@link default_correlator}, which produces a
|
|
139
|
+
* readable, time-monotonic-within-window, lowercase id of the form
|
|
140
|
+
* `{state[:4]}-{action[:4]}-{ts}{rnd}` (18 chars).
|
|
141
|
+
*
|
|
142
|
+
* Reactions inherit `reactingTo.meta.correlation` so the chain stays
|
|
143
|
+
* intact — the delegate is only consulted on originating commits and
|
|
144
|
+
* for the close-the-books transaction.
|
|
145
|
+
*/
|
|
146
|
+
readonly correlator?: Correlator;
|
|
147
|
+
/** Restrict this process to a subset of declared lanes. */
|
|
148
|
+
readonly onlyLanes?: ReadonlyArray<TLanes>;
|
|
149
|
+
/**
|
|
150
|
+
* Subscribe to {@link Store.notify} on this instance. Defaults
|
|
151
|
+
* to `true`. Set `false` on instances that only commit and never
|
|
152
|
+
* react — the subscriber-connection budget is the practical scaling
|
|
153
|
+
* ceiling for the notify/listen pattern, and writer-only fleets
|
|
154
|
+
* spend it for nothing when they subscribe to a channel they never
|
|
155
|
+
* read. Commits still emit notifications (that's part of the
|
|
156
|
+
* store's commit protocol); only the subscriber side is gated.
|
|
157
|
+
*/
|
|
158
|
+
readonly listen?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Run the local reaction pipeline on this instance. Defaults
|
|
161
|
+
* to `true`. Set `false` on writer-only or sidecar instances: drain
|
|
162
|
+
* controllers' auto-cycle workers don't start, `correlate()` /
|
|
163
|
+
* `drain()` / `settle()` become no-ops, and the notify handler
|
|
164
|
+
* skips its drain-wakeup arm (but still emits the `notified`
|
|
165
|
+
* lifecycle event so observability sidecars work).
|
|
166
|
+
*/
|
|
167
|
+
readonly drain?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Orchestrator circuit breaker for the drain loop. After
|
|
170
|
+
* `failureThreshold` consecutive store failures the breaker opens and
|
|
171
|
+
* the drain loop skips `claim()` for `cooldownMs` instead of hammering a
|
|
172
|
+
* down backend, then allows a half-open trial. Out-of-range values throw
|
|
173
|
+
* a `ZodError` at `act().build()`. Defaults: threshold 5, cooldown 30s.
|
|
174
|
+
*/
|
|
175
|
+
readonly circuitBreaker?: CircuitBreakerOptions;
|
|
176
|
+
/**
|
|
177
|
+
* Optional off-hours window restricting when autoclose evaluates. A
|
|
178
|
+
* synthesized autoclose reaction that triggers outside the window
|
|
179
|
+
* defers to the next instant the window opens — derived from the
|
|
180
|
+
* window itself, no polling cadence. Hours are `[0, 23]` integers in
|
|
181
|
+
* `timeZone` (IANA, default `"UTC"`, DST-correct); `start > end` is
|
|
182
|
+
* an overnight window (e.g. `{ start: 22, end: 6 }`). Omit to
|
|
183
|
+
* evaluate regardless of clock time.
|
|
184
|
+
*/
|
|
185
|
+
readonly autocloseWindow?: {
|
|
186
|
+
readonly start: number;
|
|
187
|
+
readonly end: number;
|
|
188
|
+
readonly timeZone?: string;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Validate folded state against its declared Zod schema after every
|
|
192
|
+
* reduction. Off by default.
|
|
193
|
+
*
|
|
194
|
+
* When `true`, each time an event is folded into state — on the
|
|
195
|
+
* command path (`do`), on `load`/replay, and inside projection-fold
|
|
196
|
+
* projections — the merged full state is parsed against the owning
|
|
197
|
+
* state's `state({ Name: schema })` schema. A reducer that produces
|
|
198
|
+
* schema-violating state (the calculator divide-by-zero NaN
|
|
199
|
+
* class) throws a {@link ValidationError} at the triggering event,
|
|
200
|
+
* whose `target` names the state and the event (`<state>.<event>#<id>`)
|
|
201
|
+
* — instead of the bad value propagating and surfacing hops later as a
|
|
202
|
+
* confusing downstream error.
|
|
203
|
+
*
|
|
204
|
+
* This is a **debugging / CI aid, not a production guard**. Turn it on
|
|
205
|
+
* in development and CI to catch total-reducer bugs at the source; the
|
|
206
|
+
* framework already validates action inputs and emitted events, so the
|
|
207
|
+
* reduced state is the one shape it otherwise trusts. The per-event
|
|
208
|
+
* patch step is selected **once at `build()`** (the same way the
|
|
209
|
+
* orchestrator picks bare vs trace-decorated store ops from the log
|
|
210
|
+
* level): when `false` (the default) the fold loop is byte-identical to
|
|
211
|
+
* a bare reduction — the validating patch step is never selected, so
|
|
212
|
+
* there is no per-event cost, not even a branch.
|
|
213
|
+
*/
|
|
214
|
+
readonly validateFoldedState?: boolean;
|
|
215
|
+
};
|
|
216
|
+
//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