@rotorsoft/act 0.33.3 → 0.35.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 +53 -2
- package/package.json +5 -2
- package/dist/.tsbuildinfo +0 -1
- package/dist/@types/act.d.ts +0 -598
- package/dist/@types/act.d.ts.map +0 -1
- package/dist/@types/adapters/console-logger.d.ts +0 -41
- package/dist/@types/adapters/console-logger.d.ts.map +0 -1
- package/dist/@types/adapters/in-memory-cache.d.ts +0 -34
- package/dist/@types/adapters/in-memory-cache.d.ts.map +0 -1
- package/dist/@types/adapters/in-memory-store.d.ts +0 -181
- package/dist/@types/adapters/in-memory-store.d.ts.map +0 -1
- package/dist/@types/adapters/index.d.ts +0 -4
- package/dist/@types/adapters/index.d.ts.map +0 -1
- package/dist/@types/builders/act-builder.d.ts +0 -160
- package/dist/@types/builders/act-builder.d.ts.map +0 -1
- package/dist/@types/builders/index.d.ts +0 -13
- package/dist/@types/builders/index.d.ts.map +0 -1
- package/dist/@types/builders/projection-builder.d.ts +0 -101
- package/dist/@types/builders/projection-builder.d.ts.map +0 -1
- package/dist/@types/builders/slice-builder.d.ts +0 -109
- package/dist/@types/builders/slice-builder.d.ts.map +0 -1
- package/dist/@types/builders/state-builder.d.ts +0 -424
- package/dist/@types/builders/state-builder.d.ts.map +0 -1
- package/dist/@types/config.d.ts +0 -119
- package/dist/@types/config.d.ts.map +0 -1
- package/dist/@types/index.d.ts +0 -14
- package/dist/@types/index.d.ts.map +0 -1
- package/dist/@types/internal/build-classify.d.ts +0 -44
- package/dist/@types/internal/build-classify.d.ts.map +0 -1
- package/dist/@types/internal/close-cycle.d.ts +0 -38
- package/dist/@types/internal/close-cycle.d.ts.map +0 -1
- package/dist/@types/internal/correlate-cycle.d.ts +0 -73
- package/dist/@types/internal/correlate-cycle.d.ts.map +0 -1
- package/dist/@types/internal/drain-cycle.d.ts +0 -113
- package/dist/@types/internal/drain-cycle.d.ts.map +0 -1
- package/dist/@types/internal/drain-ratio.d.ts +0 -26
- package/dist/@types/internal/drain-ratio.d.ts.map +0 -1
- package/dist/@types/internal/drain.d.ts +0 -41
- package/dist/@types/internal/drain.d.ts.map +0 -1
- package/dist/@types/internal/event-sourcing.d.ts +0 -96
- package/dist/@types/internal/event-sourcing.d.ts.map +0 -1
- package/dist/@types/internal/index.d.ts +0 -29
- package/dist/@types/internal/index.d.ts.map +0 -1
- package/dist/@types/internal/merge.d.ts +0 -31
- package/dist/@types/internal/merge.d.ts.map +0 -1
- package/dist/@types/internal/reactions.d.ts +0 -54
- package/dist/@types/internal/reactions.d.ts.map +0 -1
- package/dist/@types/internal/settle.d.ts +0 -60
- package/dist/@types/internal/settle.d.ts.map +0 -1
- package/dist/@types/internal/tracing.d.ts +0 -45
- package/dist/@types/internal/tracing.d.ts.map +0 -1
- package/dist/@types/lru-map.d.ts +0 -50
- package/dist/@types/lru-map.d.ts.map +0 -1
- package/dist/@types/ports.d.ts +0 -196
- package/dist/@types/ports.d.ts.map +0 -1
- package/dist/@types/signals.d.ts +0 -2
- package/dist/@types/signals.d.ts.map +0 -1
- package/dist/@types/types/action.d.ts +0 -444
- package/dist/@types/types/action.d.ts.map +0 -1
- package/dist/@types/types/errors.d.ts +0 -284
- package/dist/@types/types/errors.d.ts.map +0 -1
- package/dist/@types/types/index.d.ts +0 -39
- package/dist/@types/types/index.d.ts.map +0 -1
- package/dist/@types/types/ports.d.ts +0 -485
- package/dist/@types/types/ports.d.ts.map +0 -1
- package/dist/@types/types/reaction.d.ts +0 -291
- package/dist/@types/types/reaction.d.ts.map +0 -1
- package/dist/@types/types/registry.d.ts +0 -74
- package/dist/@types/types/registry.d.ts.map +0 -1
- package/dist/@types/types/schemas.d.ts +0 -117
- package/dist/@types/types/schemas.d.ts.map +0 -1
- package/dist/@types/utils.d.ts +0 -54
- package/dist/@types/utils.d.ts.map +0 -1
- package/dist/chunk-AGWZY6YT.js +0 -127
- package/dist/chunk-AGWZY6YT.js.map +0 -1
- package/dist/index.cjs +0 -2985
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -2816
- package/dist/index.js.map +0 -1
- package/dist/types/index.cjs +0 -166
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.js +0 -33
- package/dist/types/index.js.map +0 -1
package/dist/@types/lru-map.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module lru-map
|
|
3
|
-
* @category Internal
|
|
4
|
-
*
|
|
5
|
-
* Tiny bounded LRU map / set built on insertion-ordered `Map`. Used to cap
|
|
6
|
-
* memory in long-running orchestrators that mint large numbers of keys —
|
|
7
|
-
* notably:
|
|
8
|
-
*
|
|
9
|
-
* - {@link InMemoryCache}: stream → state checkpoint
|
|
10
|
-
* - `Act._subscribed_streams`: stream → presence (LruSet)
|
|
11
|
-
*
|
|
12
|
-
* Apps with millions of dynamic streams (one target per aggregate) can't
|
|
13
|
-
* afford an unbounded `Set<string>` — eviction is required.
|
|
14
|
-
*
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Bounded LRU map. `get()` promotes; `has()` does not. `set()` always
|
|
19
|
-
* promotes and evicts the oldest entry when at capacity.
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare class LruMap<K, V> {
|
|
24
|
-
private readonly _maxSize;
|
|
25
|
-
private readonly _entries;
|
|
26
|
-
constructor(_maxSize: number);
|
|
27
|
-
get(key: K): V | undefined;
|
|
28
|
-
has(key: K): boolean;
|
|
29
|
-
set(key: K, value: V): void;
|
|
30
|
-
delete(key: K): boolean;
|
|
31
|
-
clear(): void;
|
|
32
|
-
get size(): number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Bounded LRU set built on top of {@link LruMap}. `has()` does not promote;
|
|
36
|
-
* `add()` does (re-inserting if already present, evicting the oldest at
|
|
37
|
-
* capacity).
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export declare class LruSet<T> {
|
|
42
|
-
private readonly _map;
|
|
43
|
-
constructor(maxSize: number);
|
|
44
|
-
has(value: T): boolean;
|
|
45
|
-
add(value: T): void;
|
|
46
|
-
delete(value: T): boolean;
|
|
47
|
-
clear(): void;
|
|
48
|
-
get size(): number;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=lru-map.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lru-map.d.ts","sourceRoot":"","sources":["../../src/lru-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,qBAAa,MAAM,CAAC,CAAC,EAAE,CAAC;IAGV,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;gBAEf,QAAQ,EAAE,MAAM;IAE7C,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAS1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAW3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIvB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAED;;;;;;GAMG;AACH,qBAAa,MAAM,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;gBAE3B,OAAO,EAAE,MAAM;IAI3B,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAItB,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAInB,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAIzB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
package/dist/@types/ports.d.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger } from "./adapters/console-logger.js";
|
|
2
|
-
import type { Cache, Disposable, Disposer, Logger, Store } from "./types/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Port/adapter infrastructure for the Act framework.
|
|
5
|
-
*
|
|
6
|
-
* All infrastructure concerns (logging, storage, caching) are managed as
|
|
7
|
-
* singleton adapters injected via port functions. Each port follows the same
|
|
8
|
-
* pattern: first call wins with a sensible default, optional adapter injection.
|
|
9
|
-
*
|
|
10
|
-
* - `log()` — structured logging (default: ConsoleLogger)
|
|
11
|
-
* - `store()` — event persistence (default: InMemoryStore)
|
|
12
|
-
* - `cache()` — state checkpoints (default: InMemoryCache)
|
|
13
|
-
* - `dispose()` — register cleanup functions for graceful shutdown
|
|
14
|
-
*
|
|
15
|
-
* @module ports
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* List of exit codes for process termination. Consumed by signal handlers
|
|
19
|
-
* and {@link disposeAndExit}; not part of the user-facing surface.
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare const ExitCodes: readonly ["ERROR", "EXIT"];
|
|
24
|
-
/**
|
|
25
|
-
* Type for allowed exit codes.
|
|
26
|
-
*
|
|
27
|
-
* - `"ERROR"` — abnormal termination (uncaught exception, unhandled rejection)
|
|
28
|
-
* - `"EXIT"` — clean shutdown (SIGINT, SIGTERM, or manual trigger)
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
export type ExitCode = (typeof ExitCodes)[number];
|
|
33
|
-
/**
|
|
34
|
-
* Factory function that creates or returns the injected adapter.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
type Injector<Port extends Disposable> = (adapter?: Port) => Port;
|
|
38
|
-
/**
|
|
39
|
-
* Creates a singleton port with optional adapter injection.
|
|
40
|
-
*
|
|
41
|
-
* The first call initializes the adapter (using the provided adapter or the
|
|
42
|
-
* injector's default). Subsequent calls return the cached singleton. Adapters
|
|
43
|
-
* are disposed in reverse registration order during {@link disposeAndExit}.
|
|
44
|
-
*
|
|
45
|
-
* @param injector - Named function that creates the default adapter
|
|
46
|
-
* @returns Port function: call with no args to get the singleton, or pass an
|
|
47
|
-
* adapter on the first call to override the default
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* const store = port(function store(adapter?: Store) {
|
|
52
|
-
* return adapter || new InMemoryStore();
|
|
53
|
-
* });
|
|
54
|
-
* const s = store(); // InMemoryStore
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare function port<Port extends Disposable>(injector: Injector<Port>): (adapter?: Port) => Port;
|
|
58
|
-
/**
|
|
59
|
-
* Gets or injects the singleton logger.
|
|
60
|
-
*
|
|
61
|
-
* By default, Act uses a built-in {@link ConsoleLogger} that emits JSON lines
|
|
62
|
-
* in production (compatible with GCP, AWS CloudWatch, Datadog) and colorized
|
|
63
|
-
* output in development — zero external dependencies.
|
|
64
|
-
*
|
|
65
|
-
* For pino, inject a `PinoLogger` from `@rotorsoft/act-pino` before building
|
|
66
|
-
* your application.
|
|
67
|
-
*
|
|
68
|
-
* @param adapter - Optional logger implementation to inject
|
|
69
|
-
* @returns The singleton logger instance
|
|
70
|
-
*
|
|
71
|
-
* @example Default console logger
|
|
72
|
-
* ```typescript
|
|
73
|
-
* import { log } from "@rotorsoft/act";
|
|
74
|
-
* const logger = log();
|
|
75
|
-
* logger.info("Application started");
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* @example Injecting pino
|
|
79
|
-
* ```typescript
|
|
80
|
-
* import { log } from "@rotorsoft/act";
|
|
81
|
-
* import { PinoLogger } from "@rotorsoft/act-pino";
|
|
82
|
-
* log(new PinoLogger({ level: "debug", pretty: true }));
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* @see {@link Logger} for the interface contract
|
|
86
|
-
* @see {@link ConsoleLogger} for the default implementation
|
|
87
|
-
*/
|
|
88
|
-
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;
|
|
140
|
-
/**
|
|
141
|
-
* Disposes all registered adapters and disposers, then exits the process.
|
|
142
|
-
*
|
|
143
|
-
* Execution order:
|
|
144
|
-
* 1. Custom disposers (registered via {@link dispose}) — in reverse order
|
|
145
|
-
* 2. Port adapters (log, store, cache) — in reverse registration order
|
|
146
|
-
* 3. Adapter registry is cleared
|
|
147
|
-
* 4. Process exits (skipped in test environment)
|
|
148
|
-
*
|
|
149
|
-
* In production, `"ERROR"` exits are silently ignored to avoid crashing on
|
|
150
|
-
* transient failures (e.g. an uncaught promise in a non-critical path).
|
|
151
|
-
*
|
|
152
|
-
* @param code - Exit code: `"EXIT"` for clean shutdown (exit 0),
|
|
153
|
-
* `"ERROR"` for abnormal termination (exit 1)
|
|
154
|
-
*/
|
|
155
|
-
export declare function disposeAndExit(code?: ExitCode): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Registers a cleanup function for graceful shutdown.
|
|
158
|
-
*
|
|
159
|
-
* Disposers are called automatically on SIGINT, SIGTERM, uncaught exceptions,
|
|
160
|
-
* and unhandled rejections. They execute in reverse registration order before
|
|
161
|
-
* port adapters are disposed.
|
|
162
|
-
*
|
|
163
|
-
* @param disposer - Async function to call during cleanup. Omit to get a
|
|
164
|
-
* reference to {@link disposeAndExit} without registering.
|
|
165
|
-
* @returns Function to manually trigger disposal and exit
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```typescript
|
|
169
|
-
* import { dispose } from "@rotorsoft/act";
|
|
170
|
-
*
|
|
171
|
-
* const db = connectDatabase();
|
|
172
|
-
* dispose(async () => await db.close());
|
|
173
|
-
*
|
|
174
|
-
* // In tests
|
|
175
|
-
* afterAll(async () => await dispose()());
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* @see {@link disposeAndExit} for the full shutdown sequence
|
|
179
|
-
*/
|
|
180
|
-
export declare function dispose(disposer?: Disposer): (code?: ExitCode) => Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Event name used internally for snapshot events in the event store.
|
|
183
|
-
* Snapshot events store a full state checkpoint, enabling efficient cold-start
|
|
184
|
-
* recovery without replaying the entire event stream.
|
|
185
|
-
*/
|
|
186
|
-
export declare const SNAP_EVENT = "__snapshot__";
|
|
187
|
-
/**
|
|
188
|
-
* Event name used internally for tombstone events in the event store.
|
|
189
|
-
* A tombstone marks a stream as permanently closed — no further writes
|
|
190
|
-
* are permitted until the stream is explicitly restarted via `close()`.
|
|
191
|
-
*
|
|
192
|
-
* @see {@link Act.close} for the close-the-books API
|
|
193
|
-
*/
|
|
194
|
-
export declare const TOMBSTONE_EVENT = "__tombstone__";
|
|
195
|
-
export {};
|
|
196
|
-
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAMlD;;;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,IAC5D,UAAU,IAAI,KAAG,IAAI,CAW9B;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,GAAG,0EASd,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,KAAK,wCAEhB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,wCAEhB,CAAC;AASH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,QAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CACrB,QAAQ,CAAC,EAAE,QAAQ,GAClB,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAGpC;AAMD;;;;GAIG;AACH,eAAO,MAAM,UAAU,iBAAiB,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,kBAAkB,CAAC"}
|
package/dist/@types/signals.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":""}
|