@rotorsoft/act 1.32.12 → 1.32.13
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/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +1 -40
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +8 -0
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/builders/builder-utils.d.ts.map +1 -1
- package/dist/@types/builders/projection-builder.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-reaction.d.ts +1 -1
- package/dist/@types/internal/autoclose-reaction.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +25 -4
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/index.d.ts +1 -1
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/{chunk-UVFP2BQ3.js → chunk-FLAGQMWE.js} +35 -58
- package/dist/chunk-FLAGQMWE.js.map +1 -0
- package/dist/index.cjs +191 -206
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +158 -150
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +34 -57
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-UVFP2BQ3.js.map +0 -1
package/dist/test/index.cjs
CHANGED
|
@@ -749,17 +749,34 @@ var InMemoryStore = class {
|
|
|
749
749
|
this._streams = /* @__PURE__ */ new Map();
|
|
750
750
|
}
|
|
751
751
|
in_query(query, e) {
|
|
752
|
-
if (query.stream)
|
|
753
|
-
|
|
754
|
-
if (e.stream !== query.stream) return false;
|
|
755
|
-
} else if (!RegExp(query.stream).test(e.stream)) return false;
|
|
756
|
-
}
|
|
752
|
+
if (query.stream && !this._stream_matches(query.stream, query, e.stream))
|
|
753
|
+
return false;
|
|
757
754
|
if (query.names && !query.names.includes(e.name)) return false;
|
|
758
755
|
if (query.correlation && e.meta?.correlation !== query.correlation)
|
|
759
756
|
return false;
|
|
760
757
|
if (e.name === SNAP_EVENT && !query.with_snaps) return false;
|
|
758
|
+
if (query.created_after && e.created <= query.created_after) return false;
|
|
759
|
+
if (query.created_before && e.created >= query.created_before) return false;
|
|
761
760
|
return true;
|
|
762
761
|
}
|
|
762
|
+
_stream_matches(pattern, query, stream) {
|
|
763
|
+
return query.stream_exact ? stream === pattern : RegExp(pattern).test(stream);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Index of the latest snapshot of the queried stream, or -1. `with_snaps`
|
|
767
|
+
* on an exact single stream resumes there, so earlier events aren't read.
|
|
768
|
+
* The orchestrator asks only for unbounded current-state loads, so the
|
|
769
|
+
* floor applies whenever asked; an explicit `after` wins over it.
|
|
770
|
+
*/
|
|
771
|
+
_snap_floor(query) {
|
|
772
|
+
if (!query?.with_snaps || !query.stream_exact || query.stream === void 0 || query.after !== void 0)
|
|
773
|
+
return -1;
|
|
774
|
+
for (let j = this._events.length - 1; j >= 0; j--) {
|
|
775
|
+
const e = this._events[j];
|
|
776
|
+
if (e.stream === query.stream && e.name === SNAP_EVENT) return j;
|
|
777
|
+
}
|
|
778
|
+
return -1;
|
|
779
|
+
}
|
|
763
780
|
/**
|
|
764
781
|
* Query events in the store, optionally filtered by query options.
|
|
765
782
|
* @param callback - Function to call for each event.
|
|
@@ -768,59 +785,19 @@ var InMemoryStore = class {
|
|
|
768
785
|
*/
|
|
769
786
|
async query(callback, query) {
|
|
770
787
|
await sleep();
|
|
788
|
+
const floor = this._snap_floor(query);
|
|
789
|
+
const lo = floor >= 0 ? floor : this._first_index_after(query?.after ?? -1);
|
|
790
|
+
const hi = query?.before !== void 0 ? this._first_index_after(query.before - 1) : this._events.length;
|
|
791
|
+
const with_pii = query?.with_pii !== false;
|
|
771
792
|
let count = 0;
|
|
772
|
-
let
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
if (query?.backward) {
|
|
783
|
-
const floor_id = floor_index >= 0 ? this._events[floor_index].id : -1;
|
|
784
|
-
let i = (query?.before !== void 0 ? this._first_index_after(query.before - 1) : this._events.length) - 1;
|
|
785
|
-
while (i >= 0) {
|
|
786
|
-
const e = this._events[i--];
|
|
787
|
-
if (query && !this.in_query(query, e)) continue;
|
|
788
|
-
if (query?.created_before && e.created >= query.created_before)
|
|
789
|
-
continue;
|
|
790
|
-
if (query.after !== void 0 && e.id <= query.after) break;
|
|
791
|
-
if (floor_id >= 0 && e.id < floor_id) break;
|
|
792
|
-
if (query.created_after && e.created <= query.created_after) continue;
|
|
793
|
-
await Promise.resolve(
|
|
794
|
-
callback(
|
|
795
|
-
this._with_pii(
|
|
796
|
-
e,
|
|
797
|
-
query?.with_pii !== false
|
|
798
|
-
)
|
|
799
|
-
)
|
|
800
|
-
);
|
|
801
|
-
count++;
|
|
802
|
-
if (query?.limit && count >= query.limit) break;
|
|
803
|
-
}
|
|
804
|
-
} else {
|
|
805
|
-
let i = floor_index >= 0 ? floor_index : this._first_index_after(query?.after ?? -1);
|
|
806
|
-
while (i < this._events.length) {
|
|
807
|
-
const e = this._events[i++];
|
|
808
|
-
if (query && !this.in_query(query, e)) continue;
|
|
809
|
-
if (query?.created_after && e.created <= query.created_after) continue;
|
|
810
|
-
if (query?.before !== void 0 && e.id >= query.before) break;
|
|
811
|
-
if (query?.created_before && e.created >= query.created_before)
|
|
812
|
-
continue;
|
|
813
|
-
await Promise.resolve(
|
|
814
|
-
callback(
|
|
815
|
-
this._with_pii(
|
|
816
|
-
e,
|
|
817
|
-
query?.with_pii !== false
|
|
818
|
-
)
|
|
819
|
-
)
|
|
820
|
-
);
|
|
821
|
-
count++;
|
|
822
|
-
if (query?.limit && count >= query.limit) break;
|
|
823
|
-
}
|
|
793
|
+
for (let k = 0; k < hi - lo; k++) {
|
|
794
|
+
const e = this._events[query?.backward ? hi - 1 - k : lo + k];
|
|
795
|
+
if (query && !this.in_query(query, e)) continue;
|
|
796
|
+
await Promise.resolve(
|
|
797
|
+
callback(this._with_pii(e, with_pii))
|
|
798
|
+
);
|
|
799
|
+
count++;
|
|
800
|
+
if (query?.limit && count >= query.limit) break;
|
|
824
801
|
}
|
|
825
802
|
return count;
|
|
826
803
|
}
|