@rotorsoft/act 0.30.1 → 0.31.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.
@@ -54,6 +54,82 @@ export type TruncateResult = Map<string, {
54
54
  deleted: number;
55
55
  committed: Committed<Schemas, keyof Schemas>;
56
56
  }>;
57
+ /**
58
+ * Subscription position for a registered stream.
59
+ *
60
+ * Streamed by {@link Store.query_streams} to power operational dashboards
61
+ * (projection lag, blocked subscriptions, in-flight leases). The shape
62
+ * mirrors what every adapter already tracks on its `streams` table.
63
+ *
64
+ * @property stream - The subscription target (projection or reaction stream)
65
+ * @property source - Optional source stream filter (for reactions)
66
+ * @property at - Last processed event id watermark (-1 for fresh streams)
67
+ * @property retry - Current retry counter
68
+ * @property blocked - True when the stream is blocked by a poison message
69
+ * @property error - Last error message (empty string when none)
70
+ * @property leased_by - Current lease holder UUID (when leased)
71
+ * @property leased_until - Lease expiration timestamp (when leased)
72
+ */
73
+ export type StreamPosition = {
74
+ readonly stream: string;
75
+ readonly source?: string;
76
+ readonly at: number;
77
+ readonly retry: number;
78
+ readonly blocked: boolean;
79
+ readonly error: string;
80
+ readonly leased_by?: string;
81
+ readonly leased_until?: Date;
82
+ };
83
+ /**
84
+ * Filter options for {@link Store.query_streams}.
85
+ *
86
+ * Mirrors the {@link Query} pattern used by {@link Store.query} — pass
87
+ * filters server-side to keep the cost low on large tables (e.g., dynamic
88
+ * reactions producing one subscription per aggregate).
89
+ *
90
+ * **What the store can filter:** the columns it actually persists —
91
+ * `stream`, `source`, `blocked`. Higher-level classification ("is this a
92
+ * projection vs a reaction?", "is this a static or dynamic resolver?")
93
+ * is an orchestrator concern; the streams table doesn't store kinds.
94
+ * Layer that on top by joining results with `Act`'s built-in registry.
95
+ *
96
+ * @property stream - Stream-name filter. By default treated as a regex
97
+ * (PG `~`, SQLite/InMemory `LIKE`-translated). Pass `stream_exact: true`
98
+ * for exact string equality.
99
+ * @property stream_exact - Use exact match instead of pattern match for
100
+ * `stream`.
101
+ * @property source - Source-stream filter (regex by default). Useful to
102
+ * isolate dynamic-reaction subscriptions tied to a particular aggregate
103
+ * stream. Pass `source_exact: true` for exact equality.
104
+ * @property source_exact - Use exact match instead of pattern match for
105
+ * `source`.
106
+ * @property blocked - Restrict to blocked (`true`) or unblocked (`false`)
107
+ * streams. Omit for all.
108
+ * @property after - Keyset pagination cursor: returns only streams with
109
+ * `stream > after` (lexicographic). Pass the last seen `stream` to fetch
110
+ * the next page.
111
+ * @property limit - Max rows to return (default: 100).
112
+ */
113
+ export type QueryStreams = {
114
+ readonly stream?: string;
115
+ readonly stream_exact?: boolean;
116
+ readonly source?: string;
117
+ readonly source_exact?: boolean;
118
+ readonly blocked?: boolean;
119
+ readonly after?: string;
120
+ readonly limit?: number;
121
+ };
122
+ /**
123
+ * Result of a {@link Store.query_streams} call.
124
+ *
125
+ * @property maxEventId - Highest event id in the store (-1 when empty).
126
+ * UI uses this to compute lag as `maxEventId - position.at`.
127
+ * @property count - Number of stream positions delivered to the callback.
128
+ */
129
+ export type QueryStreamsResult = {
130
+ readonly maxEventId: number;
131
+ readonly count: number;
132
+ };
57
133
  /**
58
134
  * Interface for event store implementations.
59
135
  *
@@ -339,6 +415,49 @@ export interface Store extends Disposable {
339
415
  snapshot?: Schema;
340
416
  meta?: EventMeta;
341
417
  }>) => Promise<TruncateResult>;
418
+ /**
419
+ * Streams registered subscription positions to a callback, plus the
420
+ * highest event id in the store.
421
+ *
422
+ * Read-only introspection for operational dashboards (Store /
423
+ * Subscriptions tab, projection lag, blocked subscriptions). Avoids
424
+ * forcing apps to open a second connection and run raw SQL against
425
+ * adapter-specific schemas.
426
+ *
427
+ * Mirrors the {@link Store.query} callback pattern: the callback is
428
+ * invoked once per matching position, allowing large result sets to be
429
+ * processed without buffering. Results are ordered by `stream` name; use
430
+ * `query.after` (last seen stream name) for keyset pagination on big
431
+ * tables (dynamic reactions can produce one subscription per aggregate).
432
+ *
433
+ * @param callback - Invoked once per matching {@link StreamPosition}.
434
+ * @param query - Optional {@link QueryStreams} filter (default `limit: 100`).
435
+ * @returns `maxEventId` and the `count` of positions emitted.
436
+ *
437
+ * @example List blocked streams with their lag
438
+ * ```typescript
439
+ * const { maxEventId } = await store().query_streams(
440
+ * (s) => console.log(`${s.stream}: lag=${maxEventId - s.at} ${s.error}`),
441
+ * { blocked: true, limit: 50 }
442
+ * );
443
+ * ```
444
+ *
445
+ * @example Page through all positions
446
+ * ```typescript
447
+ * let after: string | undefined;
448
+ * for (;;) {
449
+ * const page: StreamPosition[] = [];
450
+ * const { count } = await store().query_streams(
451
+ * (s) => page.push(s),
452
+ * { after, limit: 100 }
453
+ * );
454
+ * if (!count) break;
455
+ * // ... use page ...
456
+ * after = page.at(-1)?.stream;
457
+ * }
458
+ * ```
459
+ */
460
+ query_streams: (callback: (position: StreamPosition) => void, query?: QueryStreams) => Promise<QueryStreamsResult>;
342
461
  }
343
462
  /**
344
463
  * A cached snapshot entry for a stream.
@@ -1 +1 @@
1
- {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/types/ports.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,EACN,OAAO,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAM/C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,GAA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MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,KAAM,SAAQ,UAAU;IACvC,GAAG,CAAC,MAAM,SAAS,MAAM,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3C,GAAG,CAAC,MAAM,SAAS,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GACxB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
package/dist/index.cjs CHANGED
@@ -395,6 +395,21 @@ var InMemoryStream = class {
395
395
  get at() {
396
396
  return this._at;
397
397
  }
398
+ get retry() {
399
+ return this._retry;
400
+ }
401
+ get blocked() {
402
+ return this._blocked;
403
+ }
404
+ get error() {
405
+ return this._error;
406
+ }
407
+ get leased_by() {
408
+ return this._leased_by;
409
+ }
410
+ get leased_until() {
411
+ return this._leased_until;
412
+ }
398
413
  /**
399
414
  * Attempt to lease this stream for processing.
400
415
  * @param lease - The lease request.
@@ -675,6 +690,49 @@ var InMemoryStore = class {
675
690
  }
676
691
  return count;
677
692
  }
693
+ /**
694
+ * Streams registered subscription positions to the callback, ordered by
695
+ * stream name. Returns the highest event id in the store and the count
696
+ * of positions emitted.
697
+ */
698
+ async query_streams(callback, query) {
699
+ await sleep();
700
+ const limit = query?.limit ?? 100;
701
+ const after = query?.after;
702
+ const blocked = query?.blocked;
703
+ const streamRe = query?.stream && !query.stream_exact ? new RegExp(`^${query.stream}$`) : void 0;
704
+ const sourceRe = query?.source && !query.source_exact ? new RegExp(`^${query.source}$`) : void 0;
705
+ const sorted = [...this._streams.values()].sort(
706
+ (a, b) => a.stream.localeCompare(b.stream)
707
+ );
708
+ let count = 0;
709
+ for (const s of sorted) {
710
+ if (after !== void 0 && s.stream <= after) continue;
711
+ if (query?.stream !== void 0) {
712
+ if (query.stream_exact ? s.stream !== query.stream : !streamRe.test(s.stream))
713
+ continue;
714
+ }
715
+ if (query?.source !== void 0) {
716
+ if (s.source === void 0) continue;
717
+ if (query.source_exact ? s.source !== query.source : !sourceRe.test(s.source))
718
+ continue;
719
+ }
720
+ if (blocked !== void 0 && s.blocked !== blocked) continue;
721
+ callback({
722
+ stream: s.stream,
723
+ source: s.source,
724
+ at: s.at,
725
+ retry: s.retry,
726
+ blocked: s.blocked,
727
+ error: s.error,
728
+ leased_by: s.leased_by,
729
+ leased_until: s.leased_until
730
+ });
731
+ count++;
732
+ if (count >= limit) break;
733
+ }
734
+ return { maxEventId: this._events.length - 1, count };
735
+ }
678
736
  /**
679
737
  * Atomically truncates streams and seeds each with a snapshot or tombstone.
680
738
  * @param targets - Streams to truncate with optional snapshot state and meta.