@rotorsoft/act 1.33.17 → 1.33.19
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 +6 -5
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/config.d.ts +2 -2
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +2 -2
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +1 -1
- package/dist/@types/types/reaction.d.ts +8 -6
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/@types/utils.d.ts +5 -9
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/{chunk-5KTVG7IM.js → chunk-5Z53Y7SG.js} +2 -2
- package/dist/chunk-5Z53Y7SG.js.map +1 -0
- package/dist/{chunk-PMS6BMIU.cjs → chunk-DVYTKZD5.cjs} +1 -1
- package/dist/{chunk-PMS6BMIU.cjs.map → chunk-DVYTKZD5.cjs.map} +1 -1
- package/dist/{chunk-J6QMZEQF.cjs → chunk-GEUBNZ3B.cjs} +13 -13
- package/dist/chunk-GEUBNZ3B.cjs.map +1 -0
- package/dist/{chunk-CAL4XEVN.js → chunk-HEHGZHHA.js} +1 -1
- package/dist/{chunk-CAL4XEVN.js.map → chunk-HEHGZHHA.js.map} +1 -1
- package/dist/index.cjs +159 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -23
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +4 -4
- package/dist/test/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5KTVG7IM.js.map +0 -1
- package/dist/chunk-J6QMZEQF.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
sleep,
|
|
41
41
|
store,
|
|
42
42
|
validate
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-5Z53Y7SG.js";
|
|
44
44
|
import {
|
|
45
45
|
ActorSchema,
|
|
46
46
|
CausationEventSchema,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
pii_fields,
|
|
71
71
|
pii_schemas,
|
|
72
72
|
sensitive
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-HEHGZHHA.js";
|
|
74
74
|
|
|
75
75
|
// src/signals.ts
|
|
76
76
|
process.once("SIGINT", async (arg) => {
|
|
@@ -1177,7 +1177,7 @@ var CorrelateCycle = class {
|
|
|
1177
1177
|
_restoring = false;
|
|
1178
1178
|
_init_promise;
|
|
1179
1179
|
// Bounded by `maxSubscribedStreams`; static records live apart so eviction
|
|
1180
|
-
// never
|
|
1180
|
+
// never lets a resolution re-lane them.
|
|
1181
1181
|
_dynamic_subscriptions;
|
|
1182
1182
|
_static_subscriptions = /* @__PURE__ */ new Map();
|
|
1183
1183
|
_patterns = new LruMap(PATTERN_CACHE_SIZE);
|
|
@@ -1226,7 +1226,6 @@ var CorrelateCycle = class {
|
|
|
1226
1226
|
this._checkpoint = correlated_at >= 0 ? correlated_at : Math.max(-1, watermark - COLD_START_BACK_SCAN);
|
|
1227
1227
|
for (const { stream, priority = 0, lane } of this._static_targets) {
|
|
1228
1228
|
this._static_subscriptions.set(stream, {
|
|
1229
|
-
floor: Number.POSITIVE_INFINITY,
|
|
1230
1229
|
priority,
|
|
1231
1230
|
lane
|
|
1232
1231
|
});
|
|
@@ -1296,7 +1295,7 @@ var CorrelateCycle = class {
|
|
|
1296
1295
|
this._lease_until = correlating ? now + CORRELATION_LEASE_MS : 0;
|
|
1297
1296
|
if (correlating === false) return idle();
|
|
1298
1297
|
}
|
|
1299
|
-
const after =
|
|
1298
|
+
const after = this._checkpoint;
|
|
1300
1299
|
const correlated = /* @__PURE__ */ new Map();
|
|
1301
1300
|
let last_id = after;
|
|
1302
1301
|
let stopped = false;
|
|
@@ -1330,9 +1329,10 @@ var CorrelateCycle = class {
|
|
|
1330
1329
|
);
|
|
1331
1330
|
lane = void 0;
|
|
1332
1331
|
}
|
|
1333
|
-
const
|
|
1332
|
+
const fixed = this._static_subscriptions.get(resolved.target);
|
|
1333
|
+
const recorded = fixed ?? this._dynamic_subscriptions.get(resolved.target);
|
|
1334
1334
|
const priority = resolved.priority ?? 0;
|
|
1335
|
-
const upgraded = !recorded || priority > recorded.
|
|
1335
|
+
const upgraded = !recorded || !fixed && priority > recorded.priority;
|
|
1336
1336
|
const carried = upgraded ? { priority, lane } : { priority: recorded.priority, lane: recorded.lane };
|
|
1337
1337
|
const entry = correlated.get(resolved.target) || {
|
|
1338
1338
|
source: resolved.source,
|
|
@@ -1370,7 +1370,7 @@ var CorrelateCycle = class {
|
|
|
1370
1370
|
},
|
|
1371
1371
|
// Resolvers see `pii: null`: correlate runs actor-less, and one
|
|
1372
1372
|
// undecryptable row would otherwise stop every stream's reactions.
|
|
1373
|
-
{
|
|
1373
|
+
{ after, limit: query.limit, with_pii: false }
|
|
1374
1374
|
);
|
|
1375
1375
|
if (this._declared_lanes.size > 1) await this._recall(correlated);
|
|
1376
1376
|
const read = last_id > after;
|
|
@@ -1402,7 +1402,6 @@ var CorrelateCycle = class {
|
|
|
1402
1402
|
for (const { stream, priority, lane } of streams) {
|
|
1403
1403
|
if (correlated.get(stream)?.upgraded)
|
|
1404
1404
|
this._dynamic_subscriptions.set(stream, {
|
|
1405
|
-
floor: priority,
|
|
1406
1405
|
priority,
|
|
1407
1406
|
lane
|
|
1408
1407
|
});
|
|
@@ -1431,7 +1430,6 @@ var CorrelateCycle = class {
|
|
|
1431
1430
|
);
|
|
1432
1431
|
if (!row) return;
|
|
1433
1432
|
this._dynamic_subscriptions.set(stream, {
|
|
1434
|
-
floor: row.priority,
|
|
1435
1433
|
priority: row.priority,
|
|
1436
1434
|
lane: row.lane
|
|
1437
1435
|
});
|
|
@@ -2857,8 +2855,8 @@ var SettleLoop = class {
|
|
|
2857
2855
|
* queues one more pass after it. Callers pass options, which the next
|
|
2858
2856
|
* pass uses; internal wake-ups pass none, so they never discard a
|
|
2859
2857
|
* caller's. The cycle runs correlate→drain in a
|
|
2860
|
-
* loop until no progress
|
|
2861
|
-
*
|
|
2858
|
+
* loop until a pass makes no progress (it read no events and leased no
|
|
2859
|
+
* streams) or `maxPasses` is reached, then emits the
|
|
2862
2860
|
* `"settled"` lifecycle event via {@link SettleDeps.on_settled}.
|
|
2863
2861
|
*/
|
|
2864
2862
|
schedule(options) {
|
|
@@ -2879,8 +2877,7 @@ var SettleLoop = class {
|
|
|
2879
2877
|
this._timer = void 0;
|
|
2880
2878
|
const {
|
|
2881
2879
|
debounceMs: _,
|
|
2882
|
-
|
|
2883
|
-
correlate: { after: _after, ...correlate_query } = {},
|
|
2880
|
+
correlate: correlate_query = {},
|
|
2884
2881
|
maxPasses = Infinity,
|
|
2885
2882
|
...drain_options
|
|
2886
2883
|
} = this._next ?? {};
|
|
@@ -2893,7 +2890,7 @@ var SettleLoop = class {
|
|
|
2893
2890
|
if (scanned) this._deps.breaker.passed();
|
|
2894
2891
|
const drain = await this._deps.drain(drain_options);
|
|
2895
2892
|
passes.push(drain);
|
|
2896
|
-
const made_progress = drain.leased.length > 0 || scanned &&
|
|
2893
|
+
const made_progress = drain.leased.length > 0 || scanned && pass.read;
|
|
2897
2894
|
if (!made_progress) break;
|
|
2898
2895
|
}
|
|
2899
2896
|
if (passes.length) this._deps.on_settled(merge_drains(passes));
|
|
@@ -3552,8 +3549,9 @@ var Act = class {
|
|
|
3552
3549
|
* target streams their reactions resolve to (static or computed from
|
|
3553
3550
|
* the event), and marks their work so the next drain can claim it.
|
|
3554
3551
|
*
|
|
3555
|
-
* @param query -
|
|
3556
|
-
*
|
|
3552
|
+
* @param query - Only `limit` is used: the most events the pass reads
|
|
3553
|
+
* (default 10). The scan always starts at the correlation checkpoint,
|
|
3554
|
+
* which every reaction shares, so filters and `after` are ignored.
|
|
3557
3555
|
* @returns The number of newly subscribed streams and the last scanned event id
|
|
3558
3556
|
*
|
|
3559
3557
|
* @example Manual correlation
|
|
@@ -3563,7 +3561,7 @@ var Act = class {
|
|
|
3563
3561
|
*
|
|
3564
3562
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3565
3563
|
*/
|
|
3566
|
-
async correlate(query = {
|
|
3564
|
+
async correlate(query = { limit: 10 }) {
|
|
3567
3565
|
const pass = await this._correlate_pass(query);
|
|
3568
3566
|
return {
|
|
3569
3567
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -3575,8 +3573,7 @@ var Act = class {
|
|
|
3575
3573
|
if (!this._drain) return { kind: "idle", last_id: -1 };
|
|
3576
3574
|
return this._scoped(async () => {
|
|
3577
3575
|
const pass = await this._correlate.correlate(query, lease);
|
|
3578
|
-
if (pass.kind === "scanned" &&
|
|
3579
|
-
this._arm_all();
|
|
3576
|
+
if (pass.kind === "scanned" && pass.marked > 0) this._arm_all();
|
|
3580
3577
|
return pass;
|
|
3581
3578
|
});
|
|
3582
3579
|
}
|
|
@@ -3738,8 +3735,8 @@ var Act = class {
|
|
|
3738
3735
|
* `__snapshot__` events (counted in the result); `on_progress`
|
|
3739
3736
|
* fires once per event.
|
|
3740
3737
|
* @param sink - Where the events land. Defaults to this Act's store.
|
|
3741
|
-
* @returns {@link ScanResult}
|
|
3742
|
-
*
|
|
3738
|
+
* @returns The {@link ScanResult}: what was kept, migrated and dropped,
|
|
3739
|
+
* and how long it took.
|
|
3743
3740
|
*
|
|
3744
3741
|
* @example Restore a CSV backup into the connected store
|
|
3745
3742
|
* ```typescript
|
|
@@ -3910,7 +3907,7 @@ var Act = class {
|
|
|
3910
3907
|
* sets `autoSettle: false`. Call it at startup, to run what was pending
|
|
3911
3908
|
* before a restart, or with options for the next pass; the scheduling
|
|
3912
3909
|
* rule is in the event-sourcing docs (§ settle). Runs correlate→drain in a loop until a pass makes no
|
|
3913
|
-
* progress —
|
|
3910
|
+
* progress — it read no events and leased no streams —
|
|
3914
3911
|
* then emits the `"settled"` lifecycle event, so one call fully catches
|
|
3915
3912
|
* up paginated streams without forcing callers to loop.
|
|
3916
3913
|
*
|