@rotorsoft/act 0.37.0 → 0.39.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.
@@ -1,3 +1,4 @@
1
+ import { type Scoped } from "./ports.js";
1
2
  import type { Actor, AsOf, BatchHandler, BlockedLease, CloseResult, CloseTarget, Committed, Drain, DrainOptions, IAct, Lease, PrioritizeFilter, Query, Registry, Schema, SchemaRegister, Schemas, SettleOptions, Snapshot, State, StoreNotification, Target } from "./types/index.js";
2
3
  /**
3
4
  * @category Orchestrator
@@ -77,6 +78,14 @@ export type ActLifecycleEvents<TSchemaReg extends SchemaRegister<TActions>, TEve
77
78
  export type ActOptions = {
78
79
  readonly maxSubscribedStreams?: number;
79
80
  readonly settleDebounceMs?: number;
81
+ /**
82
+ * Per-Act ports (ACT-501). When set, this Act runs against the
83
+ * provided store + cache instead of the singletons — threaded via
84
+ * AsyncLocalStorage so internals are unchanged. Both are required
85
+ * together (a shared cache across distinct stores would collide on
86
+ * stream keys). Omit for the singleton path.
87
+ */
88
+ readonly scoped?: Scoped;
80
89
  };
81
90
  export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = Record<string, never>, TActor extends Actor = Actor> implements IAct<TEvents, TActions, TActor> {
82
91
  readonly registry: Registry<TSchemaReg, TEvents, TActions>;
@@ -133,6 +142,11 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
133
142
  private readonly _event_to_state;
134
143
  /** Logger resolved at construction time (after user port configuration) */
135
144
  private readonly _logger;
145
+ /** Wraps a public-method body so internal `store()`/`cache()` resolve to the
146
+ * per-Act ports (ACT-501). No-op when the Act is unscoped — so the singleton
147
+ * path keeps reading fresh `store()`/`cache()` per call, which matters for
148
+ * tests that dispose and re-seed mid-suite. */
149
+ private readonly _scoped;
136
150
  /** Pre-bound IAct methods reused across drain cycles. Only `do` varies per
137
151
  * payload (it captures the triggering event for reactingTo auto-inject). */
138
152
  private readonly _bound_do;
@@ -154,6 +168,19 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
154
168
  * @param options Tuning knobs — see {@link ActOptions}
155
169
  */
156
170
  constructor(registry: Registry<TSchemaReg, TEvents, TActions>, _states?: Map<string, State<any, any, any>>, batchHandlers?: Map<string, BatchHandler<any>>, options?: ActOptions);
171
+ /** True after the first `shutdown()` call. Guards idempotency. */
172
+ private _shutdown_promise;
173
+ /**
174
+ * Per-instance teardown: remove lifecycle listeners, stop the
175
+ * correlation worker, cancel any pending settle cycle, and tear
176
+ * down the cross-process notify subscription.
177
+ *
178
+ * Idempotent — repeated calls return the same promise. Registered
179
+ * automatically with the global `dispose()` registry at construction,
180
+ * so process-wide `dispose()()` covers it; test helpers (or operators
181
+ * that mint short-lived Acts) call it explicitly for prompt cleanup.
182
+ */
183
+ shutdown(): Promise<void>;
157
184
  /**
158
185
  * Subscribe to {@link Store.notify} when both the store and the
159
186
  * registry support it. Returns the disposer (or `undefined` when no
@@ -1 +1 @@
1
- {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/act.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,KAAK,EAEL,gBAAgB,EAChB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,cAAc,EACd,OAAO,EACP,aAAa,EACb,QAAQ,EACR,KAAK,EACL,iBAAiB,EACjB,MAAM,EACP,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAC5B,UAAU,SAAS,cA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AC;IAC3D;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,GAAG,CAEjB,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,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CA2KhE"}
@@ -1,5 +1,13 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
1
2
  import { ConsoleLogger } from "./adapters/console-logger.js";
2
3
  import type { Cache, Disposable, Disposer, Logger, Store } from "./types/index.js";
4
+ /** Per-Act ports bag (ACT-501). Both required together — a shared cache across stores would collide on stream keys. */
5
+ export type Scoped = {
6
+ readonly store: Store;
7
+ readonly cache: Cache;
8
+ };
9
+ /** AsyncLocalStorage carrying the active Act's ports. Internal — not re-exported. */
10
+ export declare const scoped: AsyncLocalStorage<Scoped>;
3
11
  /**
4
12
  * Port/adapter infrastructure for the Act framework.
5
13
  *
@@ -86,57 +94,8 @@ export declare function port<Port extends Disposable>(injector: Injector<Port>):
86
94
  * @see {@link ConsoleLogger} for the default implementation
87
95
  */
88
96
  export declare const log: (adapter?: Logger | ConsoleLogger | undefined) => Logger | ConsoleLogger;
89
- /**
90
- * Gets or injects the singleton event store.
91
- *
92
- * By default, Act uses an {@link InMemoryStore} suitable for development and
93
- * testing. For production, inject a persistent store like `PostgresStore` from
94
- * `@rotorsoft/act-pg` before building your application.
95
- *
96
- * **Important:** Store injection must happen before creating any Act instances.
97
- * Once set, the store cannot be changed without restarting the application.
98
- *
99
- * @param adapter - Optional store implementation to inject
100
- * @returns The singleton store instance
101
- *
102
- * @example Default in-memory store
103
- * ```typescript
104
- * import { store } from "@rotorsoft/act";
105
- * const s = store();
106
- * ```
107
- *
108
- * @example Injecting PostgreSQL
109
- * ```typescript
110
- * import { store } from "@rotorsoft/act";
111
- * import { PostgresStore } from "@rotorsoft/act-pg";
112
- *
113
- * store(new PostgresStore({
114
- * host: "localhost",
115
- * port: 5432,
116
- * database: "myapp",
117
- * user: "postgres",
118
- * password: "secret",
119
- * }));
120
- * ```
121
- *
122
- * @see {@link Store} for the interface contract
123
- * @see {@link InMemoryStore} for the default implementation
124
- */
125
- export declare const store: (adapter?: Store | undefined) => Store;
126
- /**
127
- * Gets or injects the singleton cache.
128
- *
129
- * By default, Act uses an {@link InMemoryCache} (LRU, maxSize 1000). For
130
- * distributed deployments, inject a Redis-backed cache before building your
131
- * application.
132
- *
133
- * @param adapter - Optional cache implementation to inject
134
- * @returns The singleton cache instance
135
- *
136
- * @see {@link Cache} for the interface contract
137
- * @see {@link InMemoryCache} for the default implementation
138
- */
139
- export declare const cache: (adapter?: Cache | undefined) => Cache;
97
+ export declare const store: (adapter?: Store) => Store;
98
+ export declare const cache: (adapter?: Cache) => Cache;
140
99
  /**
141
100
  * Disposes all registered adapters and disposers, then exits the process.
142
101
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAI7D,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACN,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,4BAA6B,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;A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@@
1
+ export * from "./sandbox.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,113 @@
1
+ import type { ActOptions } from "../act.js";
2
+ import type { Cache, Store } from "../types/index.js";
3
+ /**
4
+ * Minimal structural shape — anything with a `.build()` that returns an
5
+ * Act. Avoids the variance pitfalls of constraining on the full
6
+ * `ActBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>`
7
+ * generic when called across package boundaries.
8
+ */
9
+ type AnyActBuilder<TApp> = {
10
+ build: (options?: ActOptions) => TApp;
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
+ /**
37
+ * Build a scoped Act bound to a fresh `{ store, cache }` bag.
38
+ *
39
+ * Intended for parallel-safe test isolation. Each call constructs new
40
+ * ports (defaults to InMemoryStore + InMemoryCache), seeds the store,
41
+ * builds the Act with `ActOptions.scoped`, and returns `{ app, store,
42
+ * cache, dispose }`. The caller owns the lifecycle: `dispose()` performs
43
+ * `app.shutdown()` followed by `store.dispose()` + `cache.dispose()`.
44
+ *
45
+ * Prefer {@link fixture} when fixture-style ergonomics fit; reach for
46
+ * `sandbox` when you need explicit control (e.g., wiring inside
47
+ * `beforeAll` rather than per-test, or two scoped Acts in one test, or
48
+ * direct access to the store/cache handles).
49
+ *
50
+ * @example Per-test isolated Act with explicit dispose
51
+ * ```ts
52
+ * import { sandbox } from "@rotorsoft/act/test";
53
+ *
54
+ * const counterBuilder = act().withState(Counter);
55
+ *
56
+ * it("increments", async () => {
57
+ * const { app, dispose } = await sandbox(counterBuilder);
58
+ * await app.do("increment", { stream: "c-1", actor }, { by: 1 });
59
+ * expect((await app.load("Counter", "c-1")).state.count).toBe(1);
60
+ * await dispose();
61
+ * });
62
+ * ```
63
+ *
64
+ * @example Custom store factory (PG per-test schema)
65
+ * ```ts
66
+ * const { app, dispose } = await sandbox(builder, {
67
+ * store: () => new PostgresStore({ schema: `t_${nanoid()}` }),
68
+ * });
69
+ * ```
70
+ */
71
+ export declare function sandbox<TApp>(builder: AnyActBuilder<TApp>, options?: SandboxOptions): Promise<Sandbox<TApp>>;
72
+ /**
73
+ * Vitest fixture wrapper around {@link sandbox}.
74
+ *
75
+ * Returns a `test` instance with an `app` fixture — each test gets a
76
+ * fresh, isolated Act and vitest's fixture lifecycle runs the cleanup
77
+ * automatically when the test completes.
78
+ *
79
+ * Works with `test.concurrent(...)` — every concurrent invocation
80
+ * receives its own bag, so tests don't race on the singleton.
81
+ *
82
+ * For tests that also need direct access to the underlying `store` /
83
+ * `cache` handles, use {@link sandbox} explicitly.
84
+ *
85
+ * @example Fixture-style — auto cleanup, parallel-safe
86
+ * ```ts
87
+ * import { fixture } from "@rotorsoft/act/test";
88
+ *
89
+ * const test = fixture(act().withState(Counter));
90
+ *
91
+ * test("increments", async ({ app }) => {
92
+ * await app.do("increment", { stream: "c-1", actor }, { by: 1 });
93
+ * expect((await app.load("Counter", "c-1")).state.count).toBe(1);
94
+ * });
95
+ *
96
+ * test.concurrent("isolated from concurrent peers", async ({ app }) => {
97
+ * // Each concurrent invocation gets its own store + cache — no
98
+ * // singleton contention, no flake.
99
+ * });
100
+ * ```
101
+ *
102
+ * @example Custom store factory
103
+ * ```ts
104
+ * const test = fixture(builder, {
105
+ * store: () => new PostgresStore({ schema: `t_${nanoid()}` }),
106
+ * });
107
+ * ```
108
+ */
109
+ export declare function fixture<TApp>(builder: AnyActBuilder<TApp>, defaults?: SandboxOptions): import("vitest").TestAPI<{
110
+ app: TApp;
111
+ }>;
112
+ export {};
113
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/test/sandbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,UAAU,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;GAKG;AACH,KAAK,aAAa,CAAC,IAAI,IAAI;IACzB,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,oEAAoE;IACpE,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;CAClD,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,OAAO,CAAC,IAAI,IAAI;IAC1B,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAC1B,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAC5B,QAAQ,GAAE,cAAmB;;GAgB9B"}
@@ -0,0 +1,31 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ export {
28
+ __commonJS,
29
+ __toESM
30
+ };
31
+ //# sourceMappingURL=chunk-5WRI5ZAA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}