@rotorsoft/act 0.30.1 → 0.31.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/index.js CHANGED
@@ -323,6 +323,21 @@ var InMemoryStream = class {
323
323
  get at() {
324
324
  return this._at;
325
325
  }
326
+ get retry() {
327
+ return this._retry;
328
+ }
329
+ get blocked() {
330
+ return this._blocked;
331
+ }
332
+ get error() {
333
+ return this._error;
334
+ }
335
+ get leased_by() {
336
+ return this._leased_by;
337
+ }
338
+ get leased_until() {
339
+ return this._leased_until;
340
+ }
326
341
  /**
327
342
  * Attempt to lease this stream for processing.
328
343
  * @param lease - The lease request.
@@ -603,6 +618,49 @@ var InMemoryStore = class {
603
618
  }
604
619
  return count;
605
620
  }
621
+ /**
622
+ * Streams registered subscription positions to the callback, ordered by
623
+ * stream name. Returns the highest event id in the store and the count
624
+ * of positions emitted.
625
+ */
626
+ async query_streams(callback, query) {
627
+ await sleep();
628
+ const limit = query?.limit ?? 100;
629
+ const after = query?.after;
630
+ const blocked = query?.blocked;
631
+ const streamRe = query?.stream && !query.stream_exact ? new RegExp(`^${query.stream}$`) : void 0;
632
+ const sourceRe = query?.source && !query.source_exact ? new RegExp(`^${query.source}$`) : void 0;
633
+ const sorted = [...this._streams.values()].sort(
634
+ (a, b) => a.stream.localeCompare(b.stream)
635
+ );
636
+ let count = 0;
637
+ for (const s of sorted) {
638
+ if (after !== void 0 && s.stream <= after) continue;
639
+ if (query?.stream !== void 0) {
640
+ if (query.stream_exact ? s.stream !== query.stream : !streamRe.test(s.stream))
641
+ continue;
642
+ }
643
+ if (query?.source !== void 0) {
644
+ if (s.source === void 0) continue;
645
+ if (query.source_exact ? s.source !== query.source : !sourceRe.test(s.source))
646
+ continue;
647
+ }
648
+ if (blocked !== void 0 && s.blocked !== blocked) continue;
649
+ callback({
650
+ stream: s.stream,
651
+ source: s.source,
652
+ at: s.at,
653
+ retry: s.retry,
654
+ blocked: s.blocked,
655
+ error: s.error,
656
+ leased_by: s.leased_by,
657
+ leased_until: s.leased_until
658
+ });
659
+ count++;
660
+ if (count >= limit) break;
661
+ }
662
+ return { maxEventId: this._events.length - 1, count };
663
+ }
606
664
  /**
607
665
  * Atomically truncates streams and seeds each with a snapshot or tombstone.
608
666
  * @param targets - Streams to truncate with optional snapshot state and meta.