@rotorsoft/act 2.1.14 → 2.1.16
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.map +1 -1
- package/dist/@types/builders/event-builder.d.ts +3 -11
- package/dist/@types/builders/event-builder.d.ts.map +1 -1
- package/dist/@types/internal/sensitive.d.ts +4 -2
- package/dist/@types/internal/sensitive.d.ts.map +1 -1
- package/dist/@types/internal/zod.d.ts +6 -0
- package/dist/@types/internal/zod.d.ts.map +1 -1
- package/dist/@types/types/act.d.ts +4 -3
- package/dist/@types/types/act.d.ts.map +1 -1
- package/dist/@types/types/registry.d.ts +2 -2
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.js +2 -2
- package/dist/{chunk-WDIBO6AW.cjs → chunk-3WHD4VPP.cjs} +54 -54
- package/dist/{chunk-WDIBO6AW.cjs.map → chunk-3WHD4VPP.cjs.map} +1 -1
- package/dist/{chunk-SCH4GLWM.js → chunk-CWWTVYIN.js} +3 -3
- package/dist/{chunk-EIGZVFT7.js → chunk-GHMCESJA.js} +2 -2
- package/dist/{chunk-GDPBPAML.js → chunk-KAUON2M3.js} +1 -1
- package/dist/chunk-KAUON2M3.js.map +1 -0
- package/dist/{chunk-UEGKXCSQ.cjs → chunk-LA2BPKNS.cjs} +1 -1
- package/dist/chunk-LA2BPKNS.cjs.map +1 -0
- package/dist/{chunk-DCWPJFXR.cjs → chunk-QITJ63HG.cjs} +11 -11
- package/dist/{chunk-DCWPJFXR.cjs.map → chunk-QITJ63HG.cjs.map} +1 -1
- package/dist/index.cjs +504 -503
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +9 -9
- package/dist/test/index.js +3 -3
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-GDPBPAML.js.map +0 -1
- package/dist/chunk-UEGKXCSQ.cjs.map +0 -1
- /package/dist/{chunk-SCH4GLWM.js.map → chunk-CWWTVYIN.js.map} +0 -0
- /package/dist/{chunk-EIGZVFT7.js.map → chunk-GHMCESJA.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunk3WHD4VPPcjs = require('./chunk-3WHD4VPP.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ var _chunkWDIBO6AWcjs = require('./chunk-WDIBO6AW.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunkQITJ63HGcjs = require('./chunk-QITJ63HG.cjs');
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -66,26 +66,26 @@ var _chunkDCWPJFXRcjs = require('./chunk-DCWPJFXR.cjs');
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
var
|
|
69
|
+
var _chunkLA2BPKNScjs = require('./chunk-LA2BPKNS.cjs');
|
|
70
70
|
|
|
71
71
|
// src/signals.ts
|
|
72
72
|
process.once("SIGINT", async (arg) => {
|
|
73
|
-
|
|
74
|
-
await
|
|
73
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
74
|
+
await _chunk3WHD4VPPcjs.disposeAndExit.call(void 0, "EXIT");
|
|
75
75
|
});
|
|
76
76
|
process.once("SIGTERM", async (arg) => {
|
|
77
|
-
|
|
78
|
-
await
|
|
77
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
78
|
+
await _chunk3WHD4VPPcjs.disposeAndExit.call(void 0, "EXIT");
|
|
79
79
|
});
|
|
80
80
|
process.once("uncaughtException", async (arg) => {
|
|
81
81
|
process.exitCode = 1;
|
|
82
|
-
|
|
83
|
-
await
|
|
82
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
83
|
+
await _chunk3WHD4VPPcjs.disposeAndExit.call(void 0, "ERROR");
|
|
84
84
|
});
|
|
85
85
|
process.once("unhandledRejection", async (arg) => {
|
|
86
86
|
process.exitCode = 1;
|
|
87
|
-
|
|
88
|
-
await
|
|
87
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
88
|
+
await _chunk3WHD4VPPcjs.disposeAndExit.call(void 0, "ERROR");
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
// src/act.ts
|
|
@@ -101,7 +101,7 @@ function parse(name) {
|
|
|
101
101
|
}
|
|
102
102
|
return { base: name, version: 1 };
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
_chunkLA2BPKNScjs.__name.call(void 0, parse, "parse");
|
|
105
105
|
function deprecated_event_names(names) {
|
|
106
106
|
const groups = /* @__PURE__ */ new Map();
|
|
107
107
|
for (const name of names) {
|
|
@@ -127,7 +127,7 @@ function deprecated_event_names(names) {
|
|
|
127
127
|
}
|
|
128
128
|
return deprecated;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
_chunkLA2BPKNScjs.__name.call(void 0, deprecated_event_names, "deprecated_event_names");
|
|
131
131
|
function current_version_of(deprecated_name, all_names) {
|
|
132
132
|
const target = parse(deprecated_name);
|
|
133
133
|
let highest;
|
|
@@ -138,7 +138,7 @@ function current_version_of(deprecated_name, all_names) {
|
|
|
138
138
|
}
|
|
139
139
|
return highest && highest.version > target.version ? highest.name : void 0;
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
_chunkLA2BPKNScjs.__name.call(void 0, current_version_of, "current_version_of");
|
|
142
142
|
|
|
143
143
|
// src/internal/walk-streams.ts
|
|
144
144
|
var DEFAULT_STREAM_PAGE = 500;
|
|
@@ -160,7 +160,7 @@ async function walk_streams(store2, callback, query) {
|
|
|
160
160
|
after = last;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
_chunkLA2BPKNScjs.__name.call(void 0, walk_streams, "walk_streams");
|
|
164
164
|
|
|
165
165
|
// src/internal/audit.ts
|
|
166
166
|
var DEFAULTS = {
|
|
@@ -197,7 +197,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
197
197
|
if (need_stats) {
|
|
198
198
|
const stats = await deps.store().query_stats(
|
|
199
199
|
{},
|
|
200
|
-
{ count: true, names: true, exclude: [
|
|
200
|
+
{ count: true, names: true, exclude: [_chunkLA2BPKNScjs.SNAP_EVENT] }
|
|
201
201
|
);
|
|
202
202
|
for (const [stream, s] of stats) {
|
|
203
203
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -225,7 +225,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
225
225
|
for (const f of p.drain()) yield f;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
_chunkLA2BPKNScjs.__name.call(void 0, audit, "audit");
|
|
229
229
|
async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
|
|
230
230
|
let cursor = _optionalChain([query, 'optionalAccess', _14 => _14.after]);
|
|
231
231
|
let remaining = _optionalChain([query, 'optionalAccess', _15 => _15.limit]);
|
|
@@ -261,8 +261,8 @@ async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
|
|
265
|
-
var make_schema_pass = /* @__PURE__ */
|
|
264
|
+
_chunkLA2BPKNScjs.__name.call(void 0, scan_events_resiliently, "scan_events_resiliently");
|
|
265
|
+
var make_schema_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps) => {
|
|
266
266
|
const findings = [];
|
|
267
267
|
return {
|
|
268
268
|
category: "schema",
|
|
@@ -305,10 +305,10 @@ var make_schema_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (de
|
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
},
|
|
308
|
-
drain: /* @__PURE__ */
|
|
308
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
309
309
|
};
|
|
310
310
|
}, "make_schema_pass");
|
|
311
|
-
var classify_deprecated_by_state = /* @__PURE__ */
|
|
311
|
+
var classify_deprecated_by_state = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps) => {
|
|
312
312
|
const names_by_state = /* @__PURE__ */ new Map();
|
|
313
313
|
for (const [name, state2] of deps.event_to_state) {
|
|
314
314
|
let set = names_by_state.get(state2);
|
|
@@ -326,7 +326,7 @@ var classify_deprecated_by_state = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call
|
|
|
326
326
|
}
|
|
327
327
|
return deprecated_to_current;
|
|
328
328
|
}, "classify_deprecated_by_state");
|
|
329
|
-
var make_deprecated_load_pass = /* @__PURE__ */
|
|
329
|
+
var make_deprecated_load_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps, options) => {
|
|
330
330
|
const share_min = _nullishCoalesce(_optionalChain([options, 'access', _17 => _17.thresholds, 'optionalAccess', _18 => _18.deprecated_min]), () => ( DEFAULTS.deprecated_min));
|
|
331
331
|
const totals = /* @__PURE__ */ new Map();
|
|
332
332
|
const per_stream = /* @__PURE__ */ new Map();
|
|
@@ -366,7 +366,7 @@ var make_deprecated_load_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(vo
|
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
}, "make_deprecated_load_pass");
|
|
369
|
-
var make_close_candidate_pass = /* @__PURE__ */
|
|
369
|
+
var make_close_candidate_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps, options) => {
|
|
370
370
|
const idle_days = _nullishCoalesce(_optionalChain([options, 'access', _19 => _19.thresholds, 'optionalAccess', _20 => _20.idle_days]), () => ( DEFAULTS.idle_days));
|
|
371
371
|
const terminal_events = new Set(_nullishCoalesce(_optionalChain([options, 'access', _21 => _21.thresholds, 'optionalAccess', _22 => _22.terminal_events]), () => ( [])));
|
|
372
372
|
const idle_cutoff = Date.now() - idle_days * 24 * 60 * 60 * 1e3;
|
|
@@ -389,10 +389,10 @@ var make_close_candidate_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(vo
|
|
|
389
389
|
restart_supported: restart_is_supported(deps, head_name)
|
|
390
390
|
});
|
|
391
391
|
},
|
|
392
|
-
drain: /* @__PURE__ */
|
|
392
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
393
393
|
};
|
|
394
394
|
}, "make_close_candidate_pass");
|
|
395
|
-
var make_restart_candidate_pass = /* @__PURE__ */
|
|
395
|
+
var make_restart_candidate_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps, options) => {
|
|
396
396
|
const threshold = _nullishCoalesce(_optionalChain([options, 'access', _23 => _23.thresholds, 'optionalAccess', _24 => _24.restart_min]), () => ( DEFAULTS.restart_min));
|
|
397
397
|
const candidates = [];
|
|
398
398
|
const findings = [];
|
|
@@ -415,7 +415,7 @@ var make_restart_candidate_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(
|
|
|
415
415
|
{
|
|
416
416
|
stream,
|
|
417
417
|
stream_exact: true,
|
|
418
|
-
names: [
|
|
418
|
+
names: [_chunkLA2BPKNScjs.SNAP_EVENT],
|
|
419
419
|
with_snaps: true,
|
|
420
420
|
// From the start: on its own, `with_snaps` resumes at the latest.
|
|
421
421
|
after: -1
|
|
@@ -429,10 +429,10 @@ var make_restart_candidate_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(
|
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
},
|
|
432
|
-
drain: /* @__PURE__ */
|
|
432
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
433
433
|
};
|
|
434
434
|
}, "make_restart_candidate_pass");
|
|
435
|
-
var make_reaction_health_pass = /* @__PURE__ */
|
|
435
|
+
var make_reaction_health_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (_deps, options) => {
|
|
436
436
|
const near_block = _nullishCoalesce(_optionalChain([options, 'access', _25 => _25.thresholds, 'optionalAccess', _26 => _26.near_block]), () => ( DEFAULTS.near_block));
|
|
437
437
|
const stuck_minutes = _nullishCoalesce(_optionalChain([options, 'access', _27 => _27.thresholds, 'optionalAccess', _28 => _28.stuck_minutes]), () => ( DEFAULTS.stuck_minutes));
|
|
438
438
|
const stuck_cutoff = Date.now() - stuck_minutes * 60 * 1e3;
|
|
@@ -473,10 +473,10 @@ var make_reaction_health_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(vo
|
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
},
|
|
476
|
-
drain: /* @__PURE__ */
|
|
476
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
477
477
|
};
|
|
478
478
|
}, "make_reaction_health_pass");
|
|
479
|
-
var make_snapshot_drift_pass = /* @__PURE__ */
|
|
479
|
+
var make_snapshot_drift_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps, options) => {
|
|
480
480
|
const drift_min = _nullishCoalesce(_optionalChain([options, 'access', _29 => _29.thresholds, 'optionalAccess', _30 => _30.drift_min]), () => ( DEFAULTS.drift_min));
|
|
481
481
|
const candidates = [];
|
|
482
482
|
const findings = [];
|
|
@@ -528,10 +528,10 @@ var make_snapshot_drift_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(voi
|
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
},
|
|
531
|
-
drain: /* @__PURE__ */
|
|
531
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
532
532
|
};
|
|
533
533
|
}, "make_snapshot_drift_pass");
|
|
534
|
-
var make_routing_health_pass = /* @__PURE__ */
|
|
534
|
+
var make_routing_health_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (deps) => {
|
|
535
535
|
const findings = [];
|
|
536
536
|
const seen_event_names = /* @__PURE__ */ new Set();
|
|
537
537
|
return {
|
|
@@ -563,10 +563,10 @@ var make_routing_health_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(voi
|
|
|
563
563
|
}
|
|
564
564
|
return Promise.resolve();
|
|
565
565
|
},
|
|
566
|
-
drain: /* @__PURE__ */
|
|
566
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
567
567
|
};
|
|
568
568
|
}, "make_routing_health_pass");
|
|
569
|
-
var make_correlation_gaps_pass = /* @__PURE__ */
|
|
569
|
+
var make_correlation_gaps_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => {
|
|
570
570
|
const seen_ids = /* @__PURE__ */ new Set();
|
|
571
571
|
const checks = [];
|
|
572
572
|
return {
|
|
@@ -575,7 +575,7 @@ var make_correlation_gaps_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(v
|
|
|
575
575
|
seen_ids.add(e.id);
|
|
576
576
|
const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
|
|
577
577
|
const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
|
|
578
|
-
if (parent_id !== void 0 && e.name !==
|
|
578
|
+
if (parent_id !== void 0 && e.name !== _chunkLA2BPKNScjs.TOMBSTONE_EVENT) {
|
|
579
579
|
checks.push({ stream: e.stream, id: e.id, parent_id });
|
|
580
580
|
}
|
|
581
581
|
},
|
|
@@ -595,7 +595,7 @@ var make_correlation_gaps_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(v
|
|
|
595
595
|
}
|
|
596
596
|
};
|
|
597
597
|
}, "make_correlation_gaps_pass");
|
|
598
|
-
var make_clock_anomalies_pass = /* @__PURE__ */
|
|
598
|
+
var make_clock_anomalies_pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => {
|
|
599
599
|
const findings = [];
|
|
600
600
|
const last_per_stream = /* @__PURE__ */ new Map();
|
|
601
601
|
return {
|
|
@@ -621,14 +621,14 @@ var make_clock_anomalies_pass = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(vo
|
|
|
621
621
|
}
|
|
622
622
|
last_per_stream.set(e.stream, created);
|
|
623
623
|
},
|
|
624
|
-
drain: /* @__PURE__ */
|
|
624
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
625
625
|
};
|
|
626
626
|
}, "make_clock_anomalies_pass");
|
|
627
627
|
function restart_is_supported(deps, head_event_name) {
|
|
628
628
|
const state2 = deps.event_to_state.get(head_event_name);
|
|
629
629
|
return _optionalChain([state2, 'optionalAccess', _35 => _35.snap]) !== void 0;
|
|
630
630
|
}
|
|
631
|
-
|
|
631
|
+
_chunkLA2BPKNScjs.__name.call(void 0, restart_is_supported, "restart_is_supported");
|
|
632
632
|
function make_unreadable_events_pass() {
|
|
633
633
|
const findings = [];
|
|
634
634
|
return {
|
|
@@ -642,10 +642,10 @@ function make_unreadable_events_pass() {
|
|
|
642
642
|
error
|
|
643
643
|
});
|
|
644
644
|
},
|
|
645
|
-
drain: /* @__PURE__ */
|
|
645
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => findings, "drain")
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
|
-
|
|
648
|
+
_chunkLA2BPKNScjs.__name.call(void 0, make_unreadable_events_pass, "make_unreadable_events_pass");
|
|
649
649
|
var PASS_FACTORIES = {
|
|
650
650
|
schema: make_schema_pass,
|
|
651
651
|
"deprecated-load": make_deprecated_load_pass,
|
|
@@ -662,7 +662,7 @@ var PASS_FACTORIES = {
|
|
|
662
662
|
// src/internal/circuit-breaker.ts
|
|
663
663
|
var CircuitBreaker = (_class = class {
|
|
664
664
|
static {
|
|
665
|
-
|
|
665
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "CircuitBreaker");
|
|
666
666
|
}
|
|
667
667
|
__init() {this._failures = 0}
|
|
668
668
|
|
|
@@ -755,7 +755,7 @@ var CircuitBreaker = (_class = class {
|
|
|
755
755
|
|
|
756
756
|
// src/internal/classify.ts
|
|
757
757
|
var ALL_LANES = /* @__PURE__ */ Symbol("act/all-lanes");
|
|
758
|
-
var describe_source = /* @__PURE__ */
|
|
758
|
+
var describe_source = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (source) => source === void 0 ? "no source (every stream)" : `"${source}"`, "describe_source");
|
|
759
759
|
function classify_registry(registry, states) {
|
|
760
760
|
const statics = /* @__PURE__ */ new Map();
|
|
761
761
|
const target_lanes = /* @__PURE__ */ new Map();
|
|
@@ -806,43 +806,43 @@ function classify_registry(registry, states) {
|
|
|
806
806
|
event_to_lanes
|
|
807
807
|
};
|
|
808
808
|
}
|
|
809
|
-
|
|
809
|
+
_chunkLA2BPKNScjs.__name.call(void 0, classify_registry, "classify_registry");
|
|
810
810
|
|
|
811
811
|
// src/internal/autoclose-policy.ts
|
|
812
812
|
var DAY_MS = 864e5;
|
|
813
813
|
function days_after(date, days) {
|
|
814
814
|
return new Date(date.getTime() + days * DAY_MS);
|
|
815
815
|
}
|
|
816
|
-
|
|
816
|
+
_chunkLA2BPKNScjs.__name.call(void 0, days_after, "days_after");
|
|
817
817
|
function days_before_now(days) {
|
|
818
818
|
return new Date(Date.now() - days * DAY_MS);
|
|
819
819
|
}
|
|
820
|
-
|
|
820
|
+
_chunkLA2BPKNScjs.__name.call(void 0, days_before_now, "days_before_now");
|
|
821
821
|
function compile_after(after) {
|
|
822
822
|
return (_stream, head) => days_after(head.created, after.days) <= /* @__PURE__ */ new Date();
|
|
823
823
|
}
|
|
824
|
-
|
|
824
|
+
_chunkLA2BPKNScjs.__name.call(void 0, compile_after, "compile_after");
|
|
825
825
|
function compile_is(is) {
|
|
826
826
|
const set = new Set(typeof is === "string" ? [is] : is);
|
|
827
827
|
return (_stream, head) => set.has(head.name);
|
|
828
828
|
}
|
|
829
|
-
|
|
829
|
+
_chunkLA2BPKNScjs.__name.call(void 0, compile_is, "compile_is");
|
|
830
830
|
function compile_reaches(reaches) {
|
|
831
831
|
return (_stream, _head, count) => count >= reaches;
|
|
832
832
|
}
|
|
833
|
-
|
|
833
|
+
_chunkLA2BPKNScjs.__name.call(void 0, compile_reaches, "compile_reaches");
|
|
834
834
|
function policy_after_windows(options) {
|
|
835
|
-
const parsed =
|
|
835
|
+
const parsed = _chunk3WHD4VPPcjs.check.call(void 0, "autoclose_policy", options);
|
|
836
836
|
return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
|
|
837
837
|
}
|
|
838
|
-
|
|
838
|
+
_chunkLA2BPKNScjs.__name.call(void 0, policy_after_windows, "policy_after_windows");
|
|
839
839
|
function policy_keep_days(options) {
|
|
840
|
-
const parsed =
|
|
840
|
+
const parsed = _chunk3WHD4VPPcjs.check.call(void 0, "autoclose_policy", options);
|
|
841
841
|
return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
|
|
842
842
|
}
|
|
843
|
-
|
|
843
|
+
_chunkLA2BPKNScjs.__name.call(void 0, policy_keep_days, "policy_keep_days");
|
|
844
844
|
function compile_autoclose_policy(options) {
|
|
845
|
-
const parsed =
|
|
845
|
+
const parsed = _chunk3WHD4VPPcjs.check.call(void 0, "autoclose_policy", options);
|
|
846
846
|
const and_preds = [];
|
|
847
847
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
848
848
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -863,7 +863,7 @@ function compile_autoclose_policy(options) {
|
|
|
863
863
|
return false;
|
|
864
864
|
};
|
|
865
865
|
}
|
|
866
|
-
|
|
866
|
+
_chunkLA2BPKNScjs.__name.call(void 0, compile_autoclose_policy, "compile_autoclose_policy");
|
|
867
867
|
|
|
868
868
|
// src/internal/autoclose-window.ts
|
|
869
869
|
function hour_in_zone(now, timeZone) {
|
|
@@ -874,24 +874,24 @@ function hour_in_zone(now, timeZone) {
|
|
|
874
874
|
}).formatToParts(now);
|
|
875
875
|
return Number(_optionalChain([parts, 'access', _46 => _46.find, 'call', _47 => _47((p) => p.type === "hour"), 'optionalAccess', _48 => _48.value]));
|
|
876
876
|
}
|
|
877
|
-
|
|
877
|
+
_chunkLA2BPKNScjs.__name.call(void 0, hour_in_zone, "hour_in_zone");
|
|
878
878
|
function hour_in_range(hour, start, end) {
|
|
879
879
|
return start < end ? hour >= start && hour < end : hour >= start || hour < end;
|
|
880
880
|
}
|
|
881
|
-
|
|
881
|
+
_chunkLA2BPKNScjs.__name.call(void 0, hour_in_range, "hour_in_range");
|
|
882
882
|
function is_dst_gap_open(now, timeZone, start) {
|
|
883
883
|
const hour = hour_in_zone(now, timeZone);
|
|
884
884
|
if (hour <= start) return false;
|
|
885
885
|
const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
|
|
886
886
|
return prev === start - 1 && hour === start + 1;
|
|
887
887
|
}
|
|
888
|
-
|
|
888
|
+
_chunkLA2BPKNScjs.__name.call(void 0, is_dst_gap_open, "is_dst_gap_open");
|
|
889
889
|
function in_autoclose_window(window, now) {
|
|
890
890
|
if (!window) return true;
|
|
891
891
|
const hour = hour_in_zone(now, window.timeZone);
|
|
892
892
|
return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
|
|
893
893
|
}
|
|
894
|
-
|
|
894
|
+
_chunkLA2BPKNScjs.__name.call(void 0, in_autoclose_window, "in_autoclose_window");
|
|
895
895
|
function next_window_open(window, now) {
|
|
896
896
|
const start_ms = now.getTime();
|
|
897
897
|
for (let h = 0; h <= 48; h++) {
|
|
@@ -906,30 +906,30 @@ function next_window_open(window, now) {
|
|
|
906
906
|
}
|
|
907
907
|
return new Date(start_ms + 864e5);
|
|
908
908
|
}
|
|
909
|
-
|
|
909
|
+
_chunkLA2BPKNScjs.__name.call(void 0, next_window_open, "next_window_open");
|
|
910
910
|
|
|
911
911
|
// src/internal/defer-config.ts
|
|
912
912
|
function duration_ms(d) {
|
|
913
913
|
return (_nullishCoalesce(d.days, () => ( 0))) * 864e5 + (_nullishCoalesce(d.hours, () => ( 0))) * 36e5 + (_nullishCoalesce(d.minutes, () => ( 0))) * 6e4;
|
|
914
914
|
}
|
|
915
|
-
|
|
915
|
+
_chunkLA2BPKNScjs.__name.call(void 0, duration_ms, "duration_ms");
|
|
916
916
|
function resolve_defer_at(when, event) {
|
|
917
|
-
const parsed =
|
|
917
|
+
const parsed = _chunk3WHD4VPPcjs.check.call(void 0, "defer", when);
|
|
918
918
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
919
919
|
return parsed.at.getTime();
|
|
920
920
|
}
|
|
921
|
-
|
|
921
|
+
_chunkLA2BPKNScjs.__name.call(void 0, resolve_defer_at, "resolve_defer_at");
|
|
922
922
|
function make_deferred(handler, schedule) {
|
|
923
923
|
const call = handler;
|
|
924
|
-
const deferred = /* @__PURE__ */
|
|
924
|
+
const deferred = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (event, stream, app) => {
|
|
925
925
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
926
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
926
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkLA2BPKNScjs.DeferSignal)(when);
|
|
927
927
|
return call(event, stream, app);
|
|
928
928
|
}, "deferred");
|
|
929
929
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
930
930
|
return deferred;
|
|
931
931
|
}
|
|
932
|
-
|
|
932
|
+
_chunkLA2BPKNScjs.__name.call(void 0, make_deferred, "make_deferred");
|
|
933
933
|
|
|
934
934
|
// src/internal/drain-cycle.ts
|
|
935
935
|
var _crypto = require('crypto');
|
|
@@ -958,13 +958,13 @@ function compute_backoff_delay(retry, opts) {
|
|
|
958
958
|
if (opts.jitter) delay = delay * (0.5 + Math.random());
|
|
959
959
|
return Math.max(0, Math.floor(delay));
|
|
960
960
|
}
|
|
961
|
-
|
|
961
|
+
_chunkLA2BPKNScjs.__name.call(void 0, compute_backoff_delay, "compute_backoff_delay");
|
|
962
962
|
|
|
963
963
|
// src/internal/defer-timer.ts
|
|
964
964
|
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
965
965
|
var DeferTimer = (_class2 = class {
|
|
966
966
|
static {
|
|
967
|
-
|
|
967
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "DeferTimer");
|
|
968
968
|
}
|
|
969
969
|
__init2() {this._due = /* @__PURE__ */ new Map()}
|
|
970
970
|
|
|
@@ -1055,15 +1055,15 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1055
1055
|
if (total === 0) return RATIO_DEFAULT;
|
|
1056
1056
|
return Math.max(RATIO_MIN, Math.min(RATIO_MAX, lagging_avg / total));
|
|
1057
1057
|
}
|
|
1058
|
-
|
|
1058
|
+
_chunkLA2BPKNScjs.__name.call(void 0, compute_lag_lead_ratio, "compute_lag_lead_ratio");
|
|
1059
1059
|
|
|
1060
1060
|
// src/internal/report-once.ts
|
|
1061
1061
|
function report_once(seen, key, message) {
|
|
1062
1062
|
if (seen.has(key)) return;
|
|
1063
1063
|
seen.add(key);
|
|
1064
|
-
|
|
1064
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).error(new Error(message));
|
|
1065
1065
|
}
|
|
1066
|
-
|
|
1066
|
+
_chunkLA2BPKNScjs.__name.call(void 0, report_once, "report_once");
|
|
1067
1067
|
|
|
1068
1068
|
// src/internal/correlation-id.ts
|
|
1069
1069
|
|
|
@@ -1073,8 +1073,8 @@ var SEG_SPACE = BASE ** SEG_WIDTH;
|
|
|
1073
1073
|
function seg(n) {
|
|
1074
1074
|
return n.toString(BASE).padStart(SEG_WIDTH, "0");
|
|
1075
1075
|
}
|
|
1076
|
-
|
|
1077
|
-
var default_correlator = /* @__PURE__ */
|
|
1076
|
+
_chunkLA2BPKNScjs.__name.call(void 0, seg, "seg");
|
|
1077
|
+
var default_correlator = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, ({ state: state2, action: action2 }) => {
|
|
1078
1078
|
const s = state2.slice(0, SEG_WIDTH).toLowerCase();
|
|
1079
1079
|
const a = action2.slice(0, SEG_WIDTH).toLowerCase();
|
|
1080
1080
|
const ts = seg(Date.now() % SEG_SPACE);
|
|
@@ -1089,17 +1089,17 @@ function close_correlation(correlator, actor) {
|
|
|
1089
1089
|
actor
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
|
-
|
|
1092
|
+
_chunkLA2BPKNScjs.__name.call(void 0, close_correlation, "close_correlation");
|
|
1093
1093
|
|
|
1094
1094
|
// src/internal/drain-ops.ts
|
|
1095
|
-
var claim = /* @__PURE__ */
|
|
1095
|
+
var claim = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (lagging, leading, by, millis, lane) => _chunk3WHD4VPPcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane), "claim");
|
|
1096
1096
|
async function fetch(leased, eventLimit) {
|
|
1097
1097
|
return Promise.all(
|
|
1098
1098
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1099
1099
|
const events = [];
|
|
1100
|
-
const stream_exact = source !== void 0 &&
|
|
1100
|
+
const stream_exact = source !== void 0 && _chunkQITJ63HGcjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1101
1101
|
try {
|
|
1102
|
-
await
|
|
1102
|
+
await _chunk3WHD4VPPcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1103
1103
|
stream: source,
|
|
1104
1104
|
stream_exact,
|
|
1105
1105
|
after: at,
|
|
@@ -1119,10 +1119,10 @@ async function fetch(leased, eventLimit) {
|
|
|
1119
1119
|
})
|
|
1120
1120
|
);
|
|
1121
1121
|
}
|
|
1122
|
-
|
|
1123
|
-
var ack = /* @__PURE__ */
|
|
1124
|
-
var block = /* @__PURE__ */
|
|
1125
|
-
var subscribe = /* @__PURE__ */
|
|
1122
|
+
_chunkLA2BPKNScjs.__name.call(void 0, fetch, "fetch");
|
|
1123
|
+
var ack = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) => _chunk3WHD4VPPcjs.store.call(void 0, ).ack(leases), "ack");
|
|
1124
|
+
var block = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (leases) => _chunk3WHD4VPPcjs.store.call(void 0, ).block(leases), "block");
|
|
1125
|
+
var subscribe = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (streams, correlated_at, correlator) => _chunk3WHD4VPPcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator), "subscribe");
|
|
1126
1126
|
|
|
1127
1127
|
// src/internal/event-sourcing.ts
|
|
1128
1128
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1132,7 +1132,7 @@ var _zod2 = require('zod');
|
|
|
1132
1132
|
|
|
1133
1133
|
|
|
1134
1134
|
// src/internal/zod.ts
|
|
1135
|
-
var def_of = /* @__PURE__ */
|
|
1135
|
+
var def_of = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (schema) => _optionalChain([schema, 'optionalAccess', _50 => _50._zod, 'optionalAccess', _51 => _51.def]), "def_of");
|
|
1136
1136
|
var SINGLE_INNER = [
|
|
1137
1137
|
"optional",
|
|
1138
1138
|
"nullable",
|
|
@@ -1142,7 +1142,7 @@ var SINGLE_INNER = [
|
|
|
1142
1142
|
"readonly",
|
|
1143
1143
|
"catch"
|
|
1144
1144
|
];
|
|
1145
|
-
var inner_of = /* @__PURE__ */
|
|
1145
|
+
var inner_of = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (def) => SINGLE_INNER.includes(def.type) ? def.innerType : void 0, "inner_of");
|
|
1146
1146
|
function wrapped(schema) {
|
|
1147
1147
|
const def = def_of(schema);
|
|
1148
1148
|
if (!def) return [];
|
|
@@ -1151,10 +1151,15 @@ function wrapped(schema) {
|
|
|
1151
1151
|
const inner = inner_of(def);
|
|
1152
1152
|
return inner ? [inner] : [];
|
|
1153
1153
|
}
|
|
1154
|
-
|
|
1154
|
+
_chunkLA2BPKNScjs.__name.call(void 0, wrapped, "wrapped");
|
|
1155
|
+
function parts_of(schema) {
|
|
1156
|
+
const def = def_of(schema);
|
|
1157
|
+
return _optionalChain([def, 'optionalAccess', _52 => _52.type]) === "intersection" ? [def.left, def.right] : wrapped(schema);
|
|
1158
|
+
}
|
|
1159
|
+
_chunkLA2BPKNScjs.__name.call(void 0, parts_of, "parts_of");
|
|
1155
1160
|
function some_layer(schema, test) {
|
|
1156
1161
|
const seen = /* @__PURE__ */ new Set();
|
|
1157
|
-
const visit = /* @__PURE__ */
|
|
1162
|
+
const visit = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (s) => {
|
|
1158
1163
|
if (seen.has(s)) return false;
|
|
1159
1164
|
seen.add(s);
|
|
1160
1165
|
const def = def_of(s);
|
|
@@ -1162,7 +1167,7 @@ function some_layer(schema, test) {
|
|
|
1162
1167
|
}, "visit");
|
|
1163
1168
|
return visit(schema);
|
|
1164
1169
|
}
|
|
1165
|
-
|
|
1170
|
+
_chunkLA2BPKNScjs.__name.call(void 0, some_layer, "some_layer");
|
|
1166
1171
|
function output_of(schema) {
|
|
1167
1172
|
const seen = /* @__PURE__ */ new Set();
|
|
1168
1173
|
let cur = schema;
|
|
@@ -1176,11 +1181,11 @@ function output_of(schema) {
|
|
|
1176
1181
|
}
|
|
1177
1182
|
return cur;
|
|
1178
1183
|
}
|
|
1179
|
-
|
|
1184
|
+
_chunkLA2BPKNScjs.__name.call(void 0, output_of, "output_of");
|
|
1180
1185
|
|
|
1181
1186
|
// src/internal/date-reviver.ts
|
|
1182
1187
|
function variant_schema(schema, walk) {
|
|
1183
|
-
const shape = _optionalChain([def_of, 'call',
|
|
1188
|
+
const shape = _optionalChain([def_of, 'call', _53 => _53(schema), 'optionalAccess', _54 => _54.shape]);
|
|
1184
1189
|
if (!shape) {
|
|
1185
1190
|
const dates = walk(schema);
|
|
1186
1191
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -1194,13 +1199,13 @@ function variant_schema(schema, walk) {
|
|
|
1194
1199
|
}
|
|
1195
1200
|
return { schema: _zod2.z.looseObject(next), dated };
|
|
1196
1201
|
}
|
|
1197
|
-
|
|
1202
|
+
_chunkLA2BPKNScjs.__name.call(void 0, variant_schema, "variant_schema");
|
|
1198
1203
|
function date_reviver_schema(schema) {
|
|
1199
1204
|
let recursive = false;
|
|
1200
|
-
const pass = /* @__PURE__ */
|
|
1205
|
+
const pass = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (tie) => {
|
|
1201
1206
|
const done = /* @__PURE__ */ new Map();
|
|
1202
1207
|
const active = /* @__PURE__ */ new Set();
|
|
1203
|
-
const walk = /* @__PURE__ */
|
|
1208
|
+
const walk = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (node) => {
|
|
1204
1209
|
if (done.has(node)) return done.get(node);
|
|
1205
1210
|
if (active.has(node)) {
|
|
1206
1211
|
recursive = true;
|
|
@@ -1217,11 +1222,11 @@ function date_reviver_schema(schema) {
|
|
|
1217
1222
|
const first = pass(false);
|
|
1218
1223
|
return first && recursive ? pass(true) : first;
|
|
1219
1224
|
}
|
|
1220
|
-
|
|
1225
|
+
_chunkLA2BPKNScjs.__name.call(void 0, date_reviver_schema, "date_reviver_schema");
|
|
1221
1226
|
function build(schema, walk) {
|
|
1222
1227
|
const def = def_of(schema);
|
|
1223
1228
|
if (!def) return void 0;
|
|
1224
|
-
const inner = /* @__PURE__ */
|
|
1229
|
+
const inner = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => walk(def.innerType), "inner");
|
|
1225
1230
|
switch (def.type) {
|
|
1226
1231
|
case "date":
|
|
1227
1232
|
return _zod2.z.coerce.date();
|
|
@@ -1254,7 +1259,7 @@ function build(schema, walk) {
|
|
|
1254
1259
|
return variants.some((v) => v.dated) ? _zod2.z.union(variants.map((v) => v.schema)) : void 0;
|
|
1255
1260
|
}
|
|
1256
1261
|
case "nullable":
|
|
1257
|
-
return _optionalChain([inner, 'call',
|
|
1262
|
+
return _optionalChain([inner, 'call', _55 => _55(), 'optionalAccess', _56 => _56.nullable, 'call', _57 => _57()]);
|
|
1258
1263
|
case "pipe":
|
|
1259
1264
|
return walk(def.out);
|
|
1260
1265
|
case "lazy":
|
|
@@ -1268,42 +1273,42 @@ function build(schema, walk) {
|
|
|
1268
1273
|
return inner_of(def) ? inner() : void 0;
|
|
1269
1274
|
}
|
|
1270
1275
|
}
|
|
1271
|
-
|
|
1276
|
+
_chunkLA2BPKNScjs.__name.call(void 0, build, "build");
|
|
1272
1277
|
|
|
1273
1278
|
// src/internal/event-sourcing.ts
|
|
1274
|
-
var bare_patch = /* @__PURE__ */
|
|
1275
|
-
var value_at = /* @__PURE__ */
|
|
1276
|
-
(at, key) => _optionalChain([at, 'optionalAccess',
|
|
1279
|
+
var bare_patch = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial), "bare_patch");
|
|
1280
|
+
var value_at = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (value, path) => path.reduce(
|
|
1281
|
+
(at, key) => _optionalChain([at, 'optionalAccess', _58 => _58[key]]),
|
|
1277
1282
|
value
|
|
1278
1283
|
), "value_at");
|
|
1279
|
-
var check_invariants = /* @__PURE__ */
|
|
1284
|
+
var check_invariants = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (target, state2, schema, pii_aware) => {
|
|
1280
1285
|
let result;
|
|
1281
1286
|
try {
|
|
1282
1287
|
result = schema.safeParse(state2);
|
|
1283
1288
|
} catch (error) {
|
|
1284
|
-
throw new (0,
|
|
1289
|
+
throw new (0, _chunkLA2BPKNScjs.ValidationError)(target, state2, error);
|
|
1285
1290
|
}
|
|
1286
1291
|
if (result.success) return;
|
|
1287
1292
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1288
1293
|
const value = value_at(state2, issue.path);
|
|
1289
|
-
return value !==
|
|
1294
|
+
return value !== _chunkLA2BPKNScjs.REDACTED && value !== _chunkLA2BPKNScjs.SHREDDED;
|
|
1290
1295
|
}) : result.error.issues;
|
|
1291
1296
|
if (issues.length)
|
|
1292
|
-
throw new (0,
|
|
1297
|
+
throw new (0, _chunkLA2BPKNScjs.ValidationError)(
|
|
1293
1298
|
target,
|
|
1294
1299
|
state2,
|
|
1295
1300
|
_zod2.prettifyError.call(void 0, new (0, _zod2.ZodError)(issues))
|
|
1296
1301
|
);
|
|
1297
1302
|
}, "check_invariants");
|
|
1298
1303
|
var DEFAULT_BATCH = 500;
|
|
1299
|
-
var cache_put = /* @__PURE__ */
|
|
1300
|
-
(err) =>
|
|
1304
|
+
var cache_put = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream, entry) => _chunk3WHD4VPPcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1305
|
+
(err) => _chunk3WHD4VPPcjs.log.call(void 0, ).warn(
|
|
1301
1306
|
err,
|
|
1302
1307
|
"cache set skipped; the next load re-folds from the store"
|
|
1303
1308
|
)
|
|
1304
1309
|
), "cache_put");
|
|
1305
|
-
var cache_drop = /* @__PURE__ */
|
|
1306
|
-
(err) =>
|
|
1310
|
+
var cache_drop = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream) => _chunk3WHD4VPPcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1311
|
+
(err) => _chunk3WHD4VPPcjs.log.call(void 0, ).warn(
|
|
1307
1312
|
err,
|
|
1308
1313
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1309
1314
|
)
|
|
@@ -1311,11 +1316,11 @@ var cache_drop = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (stream)
|
|
|
1311
1316
|
async function snap(snapshot) {
|
|
1312
1317
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1313
1318
|
try {
|
|
1314
|
-
const [committed] = await
|
|
1319
|
+
const [committed] = await _chunk3WHD4VPPcjs.store.call(void 0, ).commit(
|
|
1315
1320
|
[
|
|
1316
1321
|
{
|
|
1317
1322
|
stream,
|
|
1318
|
-
msgs: [{ name:
|
|
1323
|
+
msgs: [{ name: _chunkLA2BPKNScjs.SNAP_EVENT, data: snapshot.state }],
|
|
1319
1324
|
// IMPORTANT! - state events are committed right after the snapshot event
|
|
1320
1325
|
expectedVersion: version
|
|
1321
1326
|
}
|
|
@@ -1328,19 +1333,19 @@ async function snap(snapshot) {
|
|
|
1328
1333
|
return committed;
|
|
1329
1334
|
} catch (error) {
|
|
1330
1335
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1331
|
-
|
|
1336
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).warn(
|
|
1332
1337
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1333
1338
|
);
|
|
1334
1339
|
}
|
|
1335
1340
|
}
|
|
1336
|
-
|
|
1341
|
+
_chunkLA2BPKNScjs.__name.call(void 0, snap, "snap");
|
|
1337
1342
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1338
1343
|
try {
|
|
1339
|
-
const [committed] = await
|
|
1344
|
+
const [committed] = await _chunk3WHD4VPPcjs.store.call(void 0, ).commit(
|
|
1340
1345
|
[
|
|
1341
1346
|
{
|
|
1342
1347
|
stream,
|
|
1343
|
-
msgs: [{ name:
|
|
1348
|
+
msgs: [{ name: _chunkLA2BPKNScjs.TOMBSTONE_EVENT, data: {} }],
|
|
1344
1349
|
expectedVersion
|
|
1345
1350
|
}
|
|
1346
1351
|
],
|
|
@@ -1348,18 +1353,18 @@ async function tombstone(stream, expectedVersion, correlation) {
|
|
|
1348
1353
|
);
|
|
1349
1354
|
return committed;
|
|
1350
1355
|
} catch (error) {
|
|
1351
|
-
if (error instanceof
|
|
1356
|
+
if (error instanceof _chunkLA2BPKNScjs.ConcurrencyError) return void 0;
|
|
1352
1357
|
throw error;
|
|
1353
1358
|
}
|
|
1354
1359
|
}
|
|
1355
|
-
|
|
1360
|
+
_chunkLA2BPKNScjs.__name.call(void 0, tombstone, "tombstone");
|
|
1356
1361
|
function is_valid(event) {
|
|
1357
1362
|
if (event.version < 0) return false;
|
|
1358
1363
|
if (!(event.created instanceof Date) || Number.isNaN(event.created.getTime()))
|
|
1359
1364
|
return false;
|
|
1360
1365
|
return true;
|
|
1361
1366
|
}
|
|
1362
|
-
|
|
1367
|
+
_chunkLA2BPKNScjs.__name.call(void 0, is_valid, "is_valid");
|
|
1363
1368
|
async function scan(source, opts = {}, callback) {
|
|
1364
1369
|
const {
|
|
1365
1370
|
drop_snapshots = false,
|
|
@@ -1387,9 +1392,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1387
1392
|
if (drop_closed_streams) {
|
|
1388
1393
|
await source.query(
|
|
1389
1394
|
(e) => {
|
|
1390
|
-
if (e.name ===
|
|
1395
|
+
if (e.name === _chunkLA2BPKNScjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1391
1396
|
},
|
|
1392
|
-
{ names: [
|
|
1397
|
+
{ names: [_chunkLA2BPKNScjs.TOMBSTONE_EVENT] }
|
|
1393
1398
|
);
|
|
1394
1399
|
}
|
|
1395
1400
|
let max_id;
|
|
@@ -1414,20 +1419,20 @@ async function scan(source, opts = {}, callback) {
|
|
|
1414
1419
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1415
1420
|
const has_history = started.has(event.stream);
|
|
1416
1421
|
started.add(event.stream);
|
|
1417
|
-
if (drop_snapshots && event.name ===
|
|
1422
|
+
if (drop_snapshots && event.name === _chunkLA2BPKNScjs.SNAP_EVENT && has_history) {
|
|
1418
1423
|
dropped_snaps++;
|
|
1419
1424
|
return;
|
|
1420
1425
|
}
|
|
1421
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1426
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkLA2BPKNScjs.TOMBSTONE_EVENT) {
|
|
1422
1427
|
dropped_closed++;
|
|
1423
1428
|
return;
|
|
1424
1429
|
}
|
|
1425
1430
|
let migrated = event;
|
|
1426
|
-
const migration = _optionalChain([event_migrations, 'optionalAccess',
|
|
1431
|
+
const migration = _optionalChain([event_migrations, 'optionalAccess', _59 => _59[event.name]]);
|
|
1427
1432
|
if (migration) {
|
|
1428
|
-
const revived = _optionalChain([migration_dates, 'access',
|
|
1433
|
+
const revived = _optionalChain([migration_dates, 'access', _60 => _60.get, 'call', _61 => _61(event.name), 'optionalAccess', _62 => _62.safeParse, 'call', _63 => _63(event.data)]);
|
|
1429
1434
|
const old_data = migration.from_schema.parse(
|
|
1430
|
-
_optionalChain([revived, 'optionalAccess',
|
|
1435
|
+
_optionalChain([revived, 'optionalAccess', _64 => _64.success]) ? revived.data : event.data
|
|
1431
1436
|
);
|
|
1432
1437
|
const new_data = migration.migrate(old_data);
|
|
1433
1438
|
migration.to_schema.parse(new_data);
|
|
@@ -1465,7 +1470,7 @@ async function scan(source, opts = {}, callback) {
|
|
|
1465
1470
|
// A cause missing from the source has no id in the new
|
|
1466
1471
|
// log; its old id would name another event there.
|
|
1467
1472
|
id: _nullishCoalesce(id_map.get(cause.id), () => ( -1)),
|
|
1468
|
-
name: _nullishCoalesce(_optionalChain([event_migrations, 'optionalAccess',
|
|
1473
|
+
name: _nullishCoalesce(_optionalChain([event_migrations, 'optionalAccess', _65 => _65[cause.name], 'optionalAccess', _66 => _66.to]), () => ( cause.name)),
|
|
1469
1474
|
stream: stream_rename ? stream_rename(cause.stream) : cause.stream
|
|
1470
1475
|
}
|
|
1471
1476
|
}
|
|
@@ -1491,23 +1496,23 @@ async function scan(source, opts = {}, callback) {
|
|
|
1491
1496
|
}
|
|
1492
1497
|
};
|
|
1493
1498
|
}
|
|
1494
|
-
|
|
1499
|
+
_chunkLA2BPKNScjs.__name.call(void 0, scan, "scan");
|
|
1495
1500
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1496
1501
|
const { stream, actor, asOf } = target;
|
|
1497
1502
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1498
1503
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1499
|
-
const cached = time_travel ? void 0 : await
|
|
1504
|
+
const cached = time_travel ? void 0 : await _chunk3WHD4VPPcjs.cache.call(void 0, ).get(stream);
|
|
1500
1505
|
const cache_hit = !!cached;
|
|
1501
|
-
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1502
|
-
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1503
|
-
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess',
|
|
1506
|
+
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _67 => _67.state]), () => ( (me.init ? me.init() : {})));
|
|
1507
|
+
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _68 => _68.patches]), () => ( 0));
|
|
1508
|
+
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _69 => _69.snaps]), () => ( 0));
|
|
1504
1509
|
let replayed = 0;
|
|
1505
1510
|
let event;
|
|
1506
|
-
await
|
|
1511
|
+
await _chunk3WHD4VPPcjs.store.call(void 0, ).query(
|
|
1507
1512
|
(raw) => {
|
|
1508
|
-
if (seeded && raw.name ===
|
|
1513
|
+
if (seeded && raw.name === _chunkLA2BPKNScjs.SNAP_EVENT && replayed > 0) return;
|
|
1509
1514
|
event = me.view(raw, actor);
|
|
1510
|
-
if (event.name ===
|
|
1515
|
+
if (event.name === _chunkLA2BPKNScjs.SNAP_EVENT) {
|
|
1511
1516
|
state2 = event.data;
|
|
1512
1517
|
snaps++;
|
|
1513
1518
|
patches = 0;
|
|
@@ -1516,12 +1521,12 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1516
1521
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1517
1522
|
patches++;
|
|
1518
1523
|
replayed++;
|
|
1519
|
-
} else if (event.name !==
|
|
1520
|
-
|
|
1524
|
+
} else if (event.name !== _chunkLA2BPKNScjs.TOMBSTONE_EVENT) {
|
|
1525
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).warn(
|
|
1521
1526
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1522
1527
|
);
|
|
1523
1528
|
}
|
|
1524
|
-
_optionalChain([callback, 'optionalCall',
|
|
1529
|
+
_optionalChain([callback, 'optionalCall', _70 => _70({
|
|
1525
1530
|
event,
|
|
1526
1531
|
state: state2,
|
|
1527
1532
|
version: event.version,
|
|
@@ -1545,7 +1550,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1545
1550
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1546
1551
|
}
|
|
1547
1552
|
);
|
|
1548
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess',
|
|
1553
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _71 => _71.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT;
|
|
1549
1554
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1550
1555
|
await cache_put(stream, {
|
|
1551
1556
|
stream,
|
|
@@ -1559,16 +1564,16 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1559
1564
|
return {
|
|
1560
1565
|
event,
|
|
1561
1566
|
state: state2,
|
|
1562
|
-
version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1567
|
+
version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _72 => _72.version]), () => ( _optionalChain([cached, 'optionalAccess', _73 => _73.version]))), () => ( -1)),
|
|
1563
1568
|
// Captured with `state`, so consumers never race a separate cache lookup.
|
|
1564
|
-
id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1569
|
+
id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _74 => _74.id]), () => ( _optionalChain([cached, 'optionalAccess', _75 => _75.event_id]))), () => ( -1)),
|
|
1565
1570
|
patches,
|
|
1566
1571
|
snaps,
|
|
1567
1572
|
cache_hit,
|
|
1568
1573
|
replayed
|
|
1569
1574
|
};
|
|
1570
1575
|
}
|
|
1571
|
-
|
|
1576
|
+
_chunkLA2BPKNScjs.__name.call(void 0, load, "load");
|
|
1572
1577
|
async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
1573
1578
|
const streams = loads.map((l) => l.target(payload, own.state));
|
|
1574
1579
|
streams.forEach((stream, i) => {
|
|
@@ -1589,8 +1594,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1589
1594
|
void 0,
|
|
1590
1595
|
patch_fn
|
|
1591
1596
|
);
|
|
1592
|
-
if (_optionalChain([snapshot, 'access',
|
|
1593
|
-
throw new (0,
|
|
1597
|
+
if (_optionalChain([snapshot, 'access', _76 => _76.event, 'optionalAccess', _77 => _77.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT)
|
|
1598
|
+
throw new (0, _chunkLA2BPKNScjs.StreamClosedError)(stream);
|
|
1594
1599
|
return {
|
|
1595
1600
|
state: l.state,
|
|
1596
1601
|
stream,
|
|
@@ -1601,16 +1606,16 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1601
1606
|
})
|
|
1602
1607
|
);
|
|
1603
1608
|
}
|
|
1604
|
-
|
|
1609
|
+
_chunkLA2BPKNScjs.__name.call(void 0, load_others, "load_others");
|
|
1605
1610
|
async function action(me, action2, target, payload, options, patch_fn = bare_patch) {
|
|
1606
1611
|
const { stream, expectedVersion, actor } = target;
|
|
1607
1612
|
if (!stream) throw new Error("Missing target stream");
|
|
1608
|
-
const reactingTo = _optionalChain([options, 'optionalAccess',
|
|
1609
|
-
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1610
|
-
const validated =
|
|
1611
|
-
const opts = _optionalChain([me, 'access',
|
|
1612
|
-
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1613
|
-
const loads = _nullishCoalesce(_optionalChain([me, 'access',
|
|
1613
|
+
const reactingTo = _optionalChain([options, 'optionalAccess', _78 => _78.reactingTo]);
|
|
1614
|
+
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _79 => _79.correlator]), () => ( default_correlator));
|
|
1615
|
+
const validated = _chunk3WHD4VPPcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1616
|
+
const opts = _optionalChain([me, 'access', _80 => _80.options, 'optionalAccess', _81 => _81[action2]]);
|
|
1617
|
+
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _82 => _82.maxRetries]), () => ( 0));
|
|
1618
|
+
const loads = _nullishCoalesce(_optionalChain([me, 'access', _83 => _83.loads, 'optionalAccess', _84 => _84[action2]]), () => ( []));
|
|
1614
1619
|
for (let attempt = 0; ; attempt++) {
|
|
1615
1620
|
try {
|
|
1616
1621
|
const snapshot = await load(
|
|
@@ -1619,8 +1624,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1619
1624
|
void 0,
|
|
1620
1625
|
patch_fn
|
|
1621
1626
|
);
|
|
1622
|
-
if (_optionalChain([snapshot, 'access',
|
|
1623
|
-
throw new (0,
|
|
1627
|
+
if (_optionalChain([snapshot, 'access', _85 => _85.event, 'optionalAccess', _86 => _86.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT)
|
|
1628
|
+
throw new (0, _chunkLA2BPKNScjs.StreamClosedError)(stream);
|
|
1624
1629
|
const own = {
|
|
1625
1630
|
state: me,
|
|
1626
1631
|
stream,
|
|
@@ -1634,7 +1639,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1634
1639
|
{ stream, state: snapshot.state },
|
|
1635
1640
|
target.actor,
|
|
1636
1641
|
patch_fn,
|
|
1637
|
-
(description) => new (0,
|
|
1642
|
+
(description) => new (0, _chunkLA2BPKNScjs.PreconditionError)(
|
|
1638
1643
|
action2,
|
|
1639
1644
|
validated,
|
|
1640
1645
|
target,
|
|
@@ -1643,11 +1648,11 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1643
1648
|
)
|
|
1644
1649
|
) : [];
|
|
1645
1650
|
const loaded = Object.fromEntries(
|
|
1646
|
-
others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess',
|
|
1651
|
+
others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess', _87 => _87.snapshot, 'access', _88 => _88.state])])
|
|
1647
1652
|
);
|
|
1648
|
-
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access',
|
|
1653
|
+
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _89 => _89.requires, 'optionalAccess', _90 => _90[action2]]), () => ( [])))
|
|
1649
1654
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1650
|
-
throw new (0,
|
|
1655
|
+
throw new (0, _chunkLA2BPKNScjs.PreconditionError)(
|
|
1651
1656
|
action2,
|
|
1652
1657
|
validated,
|
|
1653
1658
|
target,
|
|
@@ -1669,7 +1674,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1669
1674
|
);
|
|
1670
1675
|
to.events.push({
|
|
1671
1676
|
name: event,
|
|
1672
|
-
data:
|
|
1677
|
+
data: _chunk3WHD4VPPcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1673
1678
|
});
|
|
1674
1679
|
}
|
|
1675
1680
|
if (!own.events.length)
|
|
@@ -1677,10 +1682,10 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1677
1682
|
`Action "${action2}" appends only to the streams it loads; it must append an event to its own stream too`
|
|
1678
1683
|
);
|
|
1679
1684
|
const appends = [own, ...others].filter(
|
|
1680
|
-
(p) => !!_optionalChain([p, 'optionalAccess',
|
|
1685
|
+
(p) => !!_optionalChain([p, 'optionalAccess', _91 => _91.events, 'access', _92 => _92.length])
|
|
1681
1686
|
);
|
|
1682
1687
|
const meta = {
|
|
1683
|
-
correlation: _optionalChain([reactingTo, 'optionalAccess',
|
|
1688
|
+
correlation: _optionalChain([reactingTo, 'optionalAccess', _93 => _93.meta, 'access', _94 => _94.correlation]) || correlator({
|
|
1684
1689
|
action: action2,
|
|
1685
1690
|
state: me.name,
|
|
1686
1691
|
stream,
|
|
@@ -1726,7 +1731,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1726
1731
|
});
|
|
1727
1732
|
let committed;
|
|
1728
1733
|
try {
|
|
1729
|
-
committed = await
|
|
1734
|
+
committed = await _chunk3WHD4VPPcjs.store.call(void 0, ).commit(
|
|
1730
1735
|
appends.map((p) => ({
|
|
1731
1736
|
stream: p.stream,
|
|
1732
1737
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1735,7 +1740,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1735
1740
|
meta
|
|
1736
1741
|
);
|
|
1737
1742
|
} catch (error) {
|
|
1738
|
-
if (error instanceof
|
|
1743
|
+
if (error instanceof _chunkLA2BPKNScjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1739
1744
|
throw error;
|
|
1740
1745
|
}
|
|
1741
1746
|
let row = 0;
|
|
@@ -1758,13 +1763,13 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1758
1763
|
};
|
|
1759
1764
|
});
|
|
1760
1765
|
const last = appended.at(-1);
|
|
1761
|
-
const snap_event = _optionalChain([owner, 'access',
|
|
1766
|
+
const snap_event = _optionalChain([owner, 'access', _95 => _95.snap, 'optionalCall', _96 => _96(last)]) ? await snap(last) : void 0;
|
|
1762
1767
|
if (!owner.pii_aware)
|
|
1763
1768
|
void cache_put(append.stream, {
|
|
1764
1769
|
stream: append.stream,
|
|
1765
1770
|
state: last.state,
|
|
1766
|
-
version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess',
|
|
1767
|
-
event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess',
|
|
1771
|
+
version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _97 => _97.version]), () => ( last.event.version)),
|
|
1772
|
+
event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _98 => _98.id]), () => ( last.event.id)),
|
|
1768
1773
|
patches: snap_event ? 0 : last.patches,
|
|
1769
1774
|
snaps: snap_event ? last.snaps + 1 : last.snaps
|
|
1770
1775
|
});
|
|
@@ -1777,20 +1782,20 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1777
1782
|
}
|
|
1778
1783
|
return snapshots;
|
|
1779
1784
|
} catch (error) {
|
|
1780
|
-
if (!(error instanceof
|
|
1785
|
+
if (!(error instanceof _chunkLA2BPKNScjs.ConcurrencyError)) throw error;
|
|
1781
1786
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1782
1787
|
if (attempt >= max_retries) throw error;
|
|
1783
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
1788
|
+
if (_optionalChain([opts, 'optionalAccess', _99 => _99.backoff])) {
|
|
1784
1789
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1785
|
-
if (delay_ms > 0) await
|
|
1790
|
+
if (delay_ms > 0) await _chunk3WHD4VPPcjs.sleep.call(void 0, delay_ms);
|
|
1786
1791
|
}
|
|
1787
1792
|
}
|
|
1788
1793
|
}
|
|
1789
1794
|
}
|
|
1790
|
-
|
|
1795
|
+
_chunkLA2BPKNScjs.__name.call(void 0, action, "action");
|
|
1791
1796
|
|
|
1792
1797
|
// src/internal/tracing.ts
|
|
1793
|
-
var PRETTY =
|
|
1798
|
+
var PRETTY = _chunk3WHD4VPPcjs.config.call(void 0, ).env !== "production";
|
|
1794
1799
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1795
1800
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1796
1801
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1799,14 +1804,14 @@ var C_DRAIN = "\x1B[38;5;244m";
|
|
|
1799
1804
|
var C_HIT = "\x1B[38;5;82m";
|
|
1800
1805
|
var C_MISS = "\x1B[38;5;220m";
|
|
1801
1806
|
var C_RESET = "\x1B[0m";
|
|
1802
|
-
var es_caption = /* @__PURE__ */
|
|
1807
|
+
var es_caption = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (caption, color, body) => PRETTY ? `${color}${body}${C_RESET}` : `${caption}: ${body}`, "es_caption");
|
|
1803
1808
|
var C_LANE = "\x1B[38;5;183m";
|
|
1804
1809
|
var C_DIM = "\x1B[38;5;240m";
|
|
1805
1810
|
var C_ERR = "\x1B[38;5;196m";
|
|
1806
1811
|
var C_STREAM = "\x1B[38;5;226m";
|
|
1807
|
-
var dim = /* @__PURE__ */
|
|
1808
|
-
var hue = /* @__PURE__ */
|
|
1809
|
-
var drain_caption = /* @__PURE__ */
|
|
1812
|
+
var dim = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (text) => PRETTY ? `${C_DIM}${text}${C_RESET}` : text, "dim");
|
|
1813
|
+
var hue = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (color, text) => PRETTY ? `${color}${text}${C_RESET}` : text, "hue");
|
|
1814
|
+
var drain_caption = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (caption, lane) => {
|
|
1810
1815
|
const show_lane = lane && lane !== "default";
|
|
1811
1816
|
if (PRETTY) {
|
|
1812
1817
|
const tag = `${C_DRAIN}>> ${caption}${C_RESET}`;
|
|
@@ -1814,17 +1819,17 @@ var drain_caption = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (capti
|
|
|
1814
1819
|
}
|
|
1815
1820
|
return show_lane ? `>> ${caption} ${lane}` : `>> ${caption}`;
|
|
1816
1821
|
}, "drain_caption");
|
|
1817
|
-
var cache_marker = /* @__PURE__ */
|
|
1822
|
+
var cache_marker = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (hit) => {
|
|
1818
1823
|
const word = hit ? "hit" : "miss";
|
|
1819
1824
|
if (!PRETTY) return word;
|
|
1820
1825
|
return `${hit ? C_HIT : C_MISS}${word}${C_RESET}${C_GREEN}`;
|
|
1821
1826
|
}, "cache_marker");
|
|
1822
|
-
var stats_marker = /* @__PURE__ */
|
|
1827
|
+
var stats_marker = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (version, replayed, snaps, patches) => {
|
|
1823
1828
|
const text = `v=${version} replayed=${replayed} snaps=${snaps} patches=${patches}`;
|
|
1824
1829
|
if (!PRETTY) return text;
|
|
1825
1830
|
return `${C_DRAIN}${text}${C_RESET}${C_GREEN}`;
|
|
1826
1831
|
}, "stats_marker");
|
|
1827
|
-
var as_of_marker = /* @__PURE__ */
|
|
1832
|
+
var as_of_marker = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (asOf) => {
|
|
1828
1833
|
if (!asOf) return "";
|
|
1829
1834
|
const parts = [];
|
|
1830
1835
|
if (asOf.before !== void 0) parts.push(`before=${asOf.before}`);
|
|
@@ -1835,22 +1840,22 @@ var as_of_marker = /* @__PURE__ */ _chunkUEGKXCSQcjs.__name.call(void 0, (asOf)
|
|
|
1835
1840
|
if (asOf.limit !== void 0) parts.push(`limit=${asOf.limit}`);
|
|
1836
1841
|
return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
|
|
1837
1842
|
}, "as_of_marker");
|
|
1838
|
-
var traced = /* @__PURE__ */
|
|
1839
|
-
_optionalChain([entry, 'optionalCall',
|
|
1843
|
+
var traced = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (inner, exit, entry) => (async (...args) => {
|
|
1844
|
+
_optionalChain([entry, 'optionalCall', _100 => _100(...args)]);
|
|
1840
1845
|
const result = await inner(...args);
|
|
1841
|
-
_optionalChain([exit, 'optionalCall',
|
|
1846
|
+
_optionalChain([exit, 'optionalCall', _101 => _101(result, ...args)]);
|
|
1842
1847
|
return result;
|
|
1843
1848
|
}), "traced");
|
|
1844
1849
|
function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
|
|
1845
|
-
const bound_action = /* @__PURE__ */
|
|
1850
|
+
const bound_action = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (me, action_name, target, payload, options) => action(
|
|
1846
1851
|
me,
|
|
1847
1852
|
action_name,
|
|
1848
1853
|
target,
|
|
1849
1854
|
payload,
|
|
1850
|
-
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1855
|
+
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _102 => _102.correlator]), () => ( correlator)) },
|
|
1851
1856
|
patch_fn
|
|
1852
1857
|
), "bound_action");
|
|
1853
|
-
const bound_load = /* @__PURE__ */
|
|
1858
|
+
const bound_load = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (me, target, callback) => load(me, target, callback, patch_fn), "bound_load");
|
|
1854
1859
|
if (logger.level !== "trace") {
|
|
1855
1860
|
return {
|
|
1856
1861
|
snap,
|
|
@@ -1912,7 +1917,7 @@ function build_es(logger, correlator = default_correlator, patch_fn = bare_patch
|
|
|
1912
1917
|
})
|
|
1913
1918
|
};
|
|
1914
1919
|
}
|
|
1915
|
-
|
|
1920
|
+
_chunkLA2BPKNScjs.__name.call(void 0, build_es, "build_es");
|
|
1916
1921
|
function build_drain(logger) {
|
|
1917
1922
|
return {
|
|
1918
1923
|
claim,
|
|
@@ -1922,7 +1927,7 @@ function build_drain(logger) {
|
|
|
1922
1927
|
subscribe: logger.level !== "trace" ? subscribe : traced(subscribe, (result, streams) => {
|
|
1923
1928
|
if (!result.subscribed) return;
|
|
1924
1929
|
const lanes = new Set(streams.map((s) => _nullishCoalesce(s.lane, () => ( "default"))));
|
|
1925
|
-
const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access',
|
|
1930
|
+
const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _103 => _103[0], 'optionalAccess', _104 => _104.lane]) : void 0;
|
|
1926
1931
|
const data = streams.map(
|
|
1927
1932
|
({ stream, lane }) => uniform_lane || !lane || lane === "default" ? hue(C_STREAM, stream) : `${hue(C_STREAM, stream)}${dim(`[${lane}]`)}`
|
|
1928
1933
|
).join(" ");
|
|
@@ -1932,10 +1937,10 @@ function build_drain(logger) {
|
|
|
1932
1937
|
})
|
|
1933
1938
|
};
|
|
1934
1939
|
}
|
|
1935
|
-
|
|
1940
|
+
_chunkLA2BPKNScjs.__name.call(void 0, build_drain, "build_drain");
|
|
1936
1941
|
function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
1937
1942
|
if (logger.level !== "trace" || !leased.length) return;
|
|
1938
|
-
const lane = _optionalChain([leased, 'access',
|
|
1943
|
+
const lane = _optionalChain([leased, 'access', _105 => _105[0], 'optionalAccess', _106 => _106.lane]);
|
|
1939
1944
|
const fetch_by_stream = new Map(fetched.map((f) => [f.stream, f]));
|
|
1940
1945
|
const acked_by_stream = new Map(acked.map((a) => [a.stream, a.at]));
|
|
1941
1946
|
const blocked_by_stream = new Map(blocked.map((b) => [b.stream, b.error]));
|
|
@@ -1944,8 +1949,8 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
|
1944
1949
|
);
|
|
1945
1950
|
const detail = leased.map(({ stream, at, retry }) => {
|
|
1946
1951
|
const f = fetch_by_stream.get(stream);
|
|
1947
|
-
const key = _optionalChain([f, 'optionalAccess',
|
|
1948
|
-
const events = _optionalChain([f, 'optionalAccess',
|
|
1952
|
+
const key = _optionalChain([f, 'optionalAccess', _107 => _107.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
|
|
1953
|
+
const events = _optionalChain([f, 'optionalAccess', _108 => _108.events, 'access', _109 => _109.length]) ? ` ${dim(
|
|
1949
1954
|
`[${f.events.map(({ id, name }) => `#${id} ${String(name)}`).join(", ")}]`
|
|
1950
1955
|
)}` : "";
|
|
1951
1956
|
const acked_at = acked_by_stream.get(stream);
|
|
@@ -1970,17 +1975,17 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
|
1970
1975
|
}).join(", ");
|
|
1971
1976
|
logger.trace(`${drain_caption("drained", lane)} ${detail}`);
|
|
1972
1977
|
}
|
|
1973
|
-
|
|
1978
|
+
_chunkLA2BPKNScjs.__name.call(void 0, trace_cycle, "trace_cycle");
|
|
1974
1979
|
|
|
1975
1980
|
// src/internal/drain-cycle.ts
|
|
1976
1981
|
function budget_exhausted(lease, options, store_failing) {
|
|
1977
|
-
if (store_failing || !_optionalChain([options, 'optionalAccess',
|
|
1982
|
+
if (store_failing || !_optionalChain([options, 'optionalAccess', _110 => _110.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1978
1983
|
return void 0;
|
|
1979
1984
|
const error = `Blocking ${lease.stream} after ${lease.retry} claims with no acknowledged progress \u2014 the retry budget (${options.maxRetries}) was spent without the handler ever reporting an error. That means every attempt lost its lease before it could ack: move the reaction to a lane whose leaseMillis covers the handler, then unblock the stream.`;
|
|
1980
|
-
|
|
1985
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).error(error);
|
|
1981
1986
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1982
1987
|
}
|
|
1983
|
-
|
|
1988
|
+
_chunkLA2BPKNScjs.__name.call(void 0, budget_exhausted, "budget_exhausted");
|
|
1984
1989
|
function fetch_failure_policy(registry) {
|
|
1985
1990
|
let blockOnError = true;
|
|
1986
1991
|
let maxRetries = 0;
|
|
@@ -1991,17 +1996,17 @@ function fetch_failure_policy(registry) {
|
|
|
1991
1996
|
}
|
|
1992
1997
|
return { blockOnError, maxRetries };
|
|
1993
1998
|
}
|
|
1994
|
-
|
|
1999
|
+
_chunkLA2BPKNScjs.__name.call(void 0, fetch_failure_policy, "fetch_failure_policy");
|
|
1995
2000
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1996
2001
|
if (!error) return { lease, handled, acked_at: at };
|
|
1997
2002
|
logger.error(error);
|
|
1998
|
-
const non_retryable = error instanceof
|
|
2003
|
+
const non_retryable = error instanceof _chunkLA2BPKNScjs.NonRetryableError;
|
|
1999
2004
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
2000
2005
|
if (block2)
|
|
2001
2006
|
logger.error(
|
|
2002
2007
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
2003
2008
|
);
|
|
2004
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
2009
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunk3WHD4VPPcjs.DEFAULT_BACKOFF)));
|
|
2005
2010
|
return {
|
|
2006
2011
|
lease,
|
|
2007
2012
|
handled,
|
|
@@ -2012,7 +2017,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
2012
2017
|
failed_at
|
|
2013
2018
|
};
|
|
2014
2019
|
}
|
|
2015
|
-
|
|
2020
|
+
_chunkLA2BPKNScjs.__name.call(void 0, finalize, "finalize");
|
|
2016
2021
|
function warn_misrouted(seen, stream, handler, event) {
|
|
2017
2022
|
report_once(
|
|
2018
2023
|
seen,
|
|
@@ -2020,7 +2025,7 @@ function warn_misrouted(seen, stream, handler, event) {
|
|
|
2020
2025
|
`Reaction "${handler}" on "${event}" resolved to target "${stream}", which a projection already serves. A target is served by one batch handler or one state projection, so this reaction can never run \u2014 and delivering to it would hand the projection an aggregate from another stream. Skipping it. The equivalent static \`.to({ target })\` is rejected at build; a dynamic resolver's target is only knowable here.`
|
|
2021
2026
|
);
|
|
2022
2027
|
}
|
|
2023
|
-
|
|
2028
|
+
_chunkLA2BPKNScjs.__name.call(void 0, warn_misrouted, "warn_misrouted");
|
|
2024
2029
|
async function run_drain_cycle(deps, cycle) {
|
|
2025
2030
|
const { ops, registry, batch_handlers, handle, handle_batch, lane } = deps;
|
|
2026
2031
|
const {
|
|
@@ -2042,7 +2047,7 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2042
2047
|
const fetched = await ops.fetch(leased, eventLimit);
|
|
2043
2048
|
const fetch_map = /* @__PURE__ */ new Map();
|
|
2044
2049
|
const fetch_window_at = fetched.reduce(
|
|
2045
|
-
(max, { at, events }) => Math.max(max, _optionalChain([events, 'access',
|
|
2050
|
+
(max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _111 => _111.at, 'call', _112 => _112(-1), 'optionalAccess', _113 => _113.id]) || at),
|
|
2046
2051
|
0
|
|
2047
2052
|
);
|
|
2048
2053
|
for (const f of fetched) {
|
|
@@ -2106,11 +2111,11 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2106
2111
|
deps.logger
|
|
2107
2112
|
)
|
|
2108
2113
|
);
|
|
2109
|
-
const at = _optionalChain([entry, 'access',
|
|
2114
|
+
const at = _optionalChain([entry, 'access', _114 => _114.fetch, 'access', _115 => _115.events, 'access', _116 => _116.at, 'call', _117 => _117(-1), 'optionalAccess', _118 => _118.id]) || fetch_window_at;
|
|
2110
2115
|
const { payloads } = entry;
|
|
2111
2116
|
const exhausted = budget_exhausted(
|
|
2112
2117
|
lease,
|
|
2113
|
-
_optionalChain([payloads, 'access',
|
|
2118
|
+
_optionalChain([payloads, 'access', _119 => _119[0], 'optionalAccess', _120 => _120.options]),
|
|
2114
2119
|
store_failing
|
|
2115
2120
|
);
|
|
2116
2121
|
if (exhausted) return Promise.resolve(exhausted);
|
|
@@ -2131,13 +2136,13 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2131
2136
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2132
2137
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2133
2138
|
if (acked.length < expected)
|
|
2134
|
-
|
|
2139
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).warn(
|
|
2135
2140
|
`drain: ${expected - acked.length} of ${expected} acks were dropped \u2014 the lease was taken by another worker mid-handler. That work will be redelivered (at-least-once), but persistent drops mean leaseMillis is too short for this handler.`
|
|
2136
2141
|
);
|
|
2137
2142
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
2138
2143
|
return { leased, fetched, handled, acked, blocked, closeable };
|
|
2139
2144
|
}
|
|
2140
|
-
|
|
2145
|
+
_chunkLA2BPKNScjs.__name.call(void 0, run_drain_cycle, "run_drain_cycle");
|
|
2141
2146
|
var EMPTY_DRAIN = {
|
|
2142
2147
|
fetched: [],
|
|
2143
2148
|
leased: [],
|
|
@@ -2152,11 +2157,11 @@ function merge_drains(drains) {
|
|
|
2152
2157
|
blocked: drains.flatMap((d) => d.blocked)
|
|
2153
2158
|
};
|
|
2154
2159
|
}
|
|
2155
|
-
|
|
2160
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_drains, "merge_drains");
|
|
2156
2161
|
var RETRY = "";
|
|
2157
2162
|
var DrainController = (_class3 = class {
|
|
2158
2163
|
static {
|
|
2159
|
-
|
|
2164
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "DrainController");
|
|
2160
2165
|
}
|
|
2161
2166
|
// Armed while `_raised` is ahead of `_lowered` (the raise count the last
|
|
2162
2167
|
// empty claim saw), so a claim never lowers over a raise that landed
|
|
@@ -2200,7 +2205,7 @@ var DrainController = (_class3 = class {
|
|
|
2200
2205
|
}
|
|
2201
2206
|
/** This lane's configured lease, or `undefined`; the shutdown grace basis. */
|
|
2202
2207
|
get lease_millis() {
|
|
2203
|
-
return _optionalChain([this, 'access',
|
|
2208
|
+
return _optionalChain([this, 'access', _121 => _121._deps, 'access', _122 => _122.defaults, 'optionalAccess', _123 => _123.leaseMillis]);
|
|
2204
2209
|
}
|
|
2205
2210
|
get lane() {
|
|
2206
2211
|
return this._deps.lane;
|
|
@@ -2211,7 +2216,7 @@ var DrainController = (_class3 = class {
|
|
|
2211
2216
|
*/
|
|
2212
2217
|
start(cycleMs) {
|
|
2213
2218
|
const run = this._deps.run_scoped;
|
|
2214
|
-
const tick = /* @__PURE__ */
|
|
2219
|
+
const tick = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async () => {
|
|
2215
2220
|
if (this.armed) await run(() => this.drain());
|
|
2216
2221
|
if (this._stopped) return;
|
|
2217
2222
|
this._worker = setTimeout(tick, cycleMs);
|
|
@@ -2232,9 +2237,9 @@ var DrainController = (_class3 = class {
|
|
|
2232
2237
|
if (!this.armed || this._stopped || this._inflight)
|
|
2233
2238
|
return EMPTY_DRAIN;
|
|
2234
2239
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2235
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2236
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2237
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2240
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunk3WHD4VPPcjs.DEFAULT_STREAM_LIMIT));
|
|
2241
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunk3WHD4VPPcjs.DEFAULT_EVENT_LIMIT));
|
|
2242
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunk3WHD4VPPcjs.DEFAULT_LEASE_MILLIS));
|
|
2238
2243
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2239
2244
|
return EMPTY_DRAIN;
|
|
2240
2245
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2295,7 +2300,7 @@ var DrainController = (_class3 = class {
|
|
|
2295
2300
|
// src/internal/reaction-dispatch.ts
|
|
2296
2301
|
var CloseSignal = class extends Error {
|
|
2297
2302
|
static {
|
|
2298
|
-
|
|
2303
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "CloseSignal");
|
|
2299
2304
|
}
|
|
2300
2305
|
/**
|
|
2301
2306
|
* Stream to close. Omitted → the reaction's own lease stream (a self-close).
|
|
@@ -2329,11 +2334,11 @@ var CloseSignal = class extends Error {
|
|
|
2329
2334
|
constructor(opts) {
|
|
2330
2335
|
super("reaction requested close");
|
|
2331
2336
|
this.name = "CloseSignal";
|
|
2332
|
-
this.stream = _optionalChain([opts, 'optionalAccess',
|
|
2333
|
-
this.archive = _optionalChain([opts, 'optionalAccess',
|
|
2334
|
-
this.at = _optionalChain([opts, 'optionalAccess',
|
|
2335
|
-
this.before = _optionalChain([opts, 'optionalAccess',
|
|
2336
|
-
this.defer = _optionalChain([opts, 'optionalAccess',
|
|
2337
|
+
this.stream = _optionalChain([opts, 'optionalAccess', _124 => _124.stream]);
|
|
2338
|
+
this.archive = _optionalChain([opts, 'optionalAccess', _125 => _125.archive]);
|
|
2339
|
+
this.at = _optionalChain([opts, 'optionalAccess', _126 => _126.at]);
|
|
2340
|
+
this.before = _optionalChain([opts, 'optionalAccess', _127 => _127.before]);
|
|
2341
|
+
this.defer = _optionalChain([opts, 'optionalAccess', _128 => _128.defer]);
|
|
2337
2342
|
}
|
|
2338
2343
|
};
|
|
2339
2344
|
function build_handle(deps) {
|
|
@@ -2363,7 +2368,7 @@ function build_handle(deps) {
|
|
|
2363
2368
|
handled++;
|
|
2364
2369
|
}
|
|
2365
2370
|
} catch (error) {
|
|
2366
|
-
if (error instanceof
|
|
2371
|
+
if (error instanceof _chunkLA2BPKNScjs.DeferSignal) {
|
|
2367
2372
|
let defer;
|
|
2368
2373
|
try {
|
|
2369
2374
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2387,7 +2392,7 @@ function build_handle(deps) {
|
|
|
2387
2392
|
// Advance to the live head the handler evaluated against (when
|
|
2388
2393
|
// provided) so the close-cycle guard sees this reaction caught up.
|
|
2389
2394
|
acked_at: _nullishCoalesce(error.at, () => ( event.id)),
|
|
2390
|
-
defer: _optionalChain([error, 'access',
|
|
2395
|
+
defer: _optionalChain([error, 'access', _129 => _129.defer, 'optionalAccess', _130 => _130.getTime, 'call', _131 => _131()]),
|
|
2391
2396
|
// Close the signalled stream (the autoclose reaction's aggregate,
|
|
2392
2397
|
// which differs from its synthetic lease stream); a self-closing
|
|
2393
2398
|
// user reaction omits it and closes its own lease stream. A
|
|
@@ -2412,7 +2417,7 @@ function build_handle(deps) {
|
|
|
2412
2417
|
return finalize(lease, handled, at, void 0, payloads[0].options, logger);
|
|
2413
2418
|
};
|
|
2414
2419
|
}
|
|
2415
|
-
|
|
2420
|
+
_chunkLA2BPKNScjs.__name.call(void 0, build_handle, "build_handle");
|
|
2416
2421
|
function build_handle_batch(logger) {
|
|
2417
2422
|
return async (lease, payloads, batchHandler) => {
|
|
2418
2423
|
const stream = lease.stream;
|
|
@@ -2441,7 +2446,7 @@ function build_handle_batch(logger) {
|
|
|
2441
2446
|
}
|
|
2442
2447
|
};
|
|
2443
2448
|
}
|
|
2444
|
-
|
|
2449
|
+
_chunkLA2BPKNScjs.__name.call(void 0, build_handle_batch, "build_handle_batch");
|
|
2445
2450
|
|
|
2446
2451
|
// src/internal/autoclose-reaction.ts
|
|
2447
2452
|
var AUTOCLOSE_TARGET_PREFIX = "__autoclose__:";
|
|
@@ -2462,22 +2467,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2462
2467
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2463
2468
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2464
2469
|
// autoclose: `app.close` still closes it.
|
|
2465
|
-
resolver: /* @__PURE__ */
|
|
2470
|
+
resolver: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (e) => _chunkQITJ63HGcjs.isStreamName.call(void 0, e.stream) ? {
|
|
2466
2471
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2467
2472
|
source: e.stream
|
|
2468
2473
|
} : void 0, "resolver"),
|
|
2469
2474
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2470
2475
|
// not quarantine the synthetic stream.
|
|
2471
|
-
options: { blockOnError: false, maxRetries:
|
|
2472
|
-
handler: /* @__PURE__ */
|
|
2476
|
+
options: { blockOnError: false, maxRetries: _chunk3WHD4VPPcjs.DEFAULT_MAX_RETRIES },
|
|
2477
|
+
handler: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (event) => {
|
|
2473
2478
|
const aggregate = event.stream;
|
|
2474
2479
|
const window = read_window();
|
|
2475
2480
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2476
|
-
throw new (0,
|
|
2477
|
-
const stats = await
|
|
2481
|
+
throw new (0, _chunkLA2BPKNScjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2482
|
+
const stats = await _chunk3WHD4VPPcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2478
2483
|
count: true,
|
|
2479
2484
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2480
|
-
exclude: [
|
|
2485
|
+
exclude: [_chunkLA2BPKNScjs.TOMBSTONE_EVENT, _chunkLA2BPKNScjs.SNAP_EVENT]
|
|
2481
2486
|
});
|
|
2482
2487
|
const entry = stats.get(aggregate);
|
|
2483
2488
|
if (!entry) return;
|
|
@@ -2515,19 +2520,19 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2515
2520
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2516
2521
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2517
2522
|
if (future.length)
|
|
2518
|
-
throw new (0,
|
|
2523
|
+
throw new (0, _chunkLA2BPKNScjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2519
2524
|
}, "handler")
|
|
2520
2525
|
};
|
|
2521
2526
|
const key = `__autoclose_${st.name}`;
|
|
2522
2527
|
for (const event_name of Object.keys(st.events)) {
|
|
2523
|
-
_optionalChain([registry, 'access',
|
|
2528
|
+
_optionalChain([registry, 'access', _132 => _132.events, 'access', _133 => _133[event_name], 'optionalAccess', _134 => _134.reactions, 'access', _135 => _135.set, 'call', _136 => _136(
|
|
2524
2529
|
key,
|
|
2525
2530
|
reaction
|
|
2526
2531
|
)]);
|
|
2527
2532
|
}
|
|
2528
2533
|
}
|
|
2529
2534
|
}
|
|
2530
|
-
|
|
2535
|
+
_chunkLA2BPKNScjs.__name.call(void 0, synthesize_autoclose_reactions, "synthesize_autoclose_reactions");
|
|
2531
2536
|
|
|
2532
2537
|
// src/internal/close-cycle.ts
|
|
2533
2538
|
var CLOSE_CATCH_UP_LIMIT = 1e3;
|
|
@@ -2541,10 +2546,10 @@ async function catch_up_correlation(cursor, correlate, until) {
|
|
|
2541
2546
|
}
|
|
2542
2547
|
return cursor.checkpoint;
|
|
2543
2548
|
}
|
|
2544
|
-
|
|
2549
|
+
_chunkLA2BPKNScjs.__name.call(void 0, catch_up_correlation, "catch_up_correlation");
|
|
2545
2550
|
var CloseLock = (_class4 = class {constructor() { _class4.prototype.__init9.call(this); }
|
|
2546
2551
|
static {
|
|
2547
|
-
|
|
2552
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "CloseLock");
|
|
2548
2553
|
}
|
|
2549
2554
|
__init9() {this._tails = /* @__PURE__ */ new Map()}
|
|
2550
2555
|
/** Run `work` after every earlier close of `stream` has settled. */
|
|
@@ -2552,7 +2557,7 @@ var CloseLock = (_class4 = class {constructor() { _class4.prototype.__init9.call
|
|
|
2552
2557
|
const prev = _nullishCoalesce(this._tails.get(stream), () => ( Promise.resolve()));
|
|
2553
2558
|
const next = prev.then(work, work);
|
|
2554
2559
|
this._tails.set(stream, next);
|
|
2555
|
-
const cleanup = /* @__PURE__ */
|
|
2560
|
+
const cleanup = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => {
|
|
2556
2561
|
if (this._tails.get(stream) === next) this._tails.delete(stream);
|
|
2557
2562
|
}, "cleanup");
|
|
2558
2563
|
next.then(cleanup, cleanup);
|
|
@@ -2580,12 +2585,12 @@ async function run_close_cycle(targets, deps) {
|
|
|
2580
2585
|
deps,
|
|
2581
2586
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2582
2587
|
);
|
|
2583
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2584
|
-
if (retired.length) _optionalChain([deps, 'access',
|
|
2588
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkLA2BPKNScjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2589
|
+
if (retired.length) _optionalChain([deps, 'access', _137 => _137.forget_subscribed, 'optionalCall', _138 => _138(retired)]);
|
|
2585
2590
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2586
2591
|
return { truncated, skipped };
|
|
2587
2592
|
}
|
|
2588
|
-
|
|
2593
|
+
_chunkLA2BPKNScjs.__name.call(void 0, run_close_cycle, "run_close_cycle");
|
|
2589
2594
|
function with_stream_locks(streams, deps, work) {
|
|
2590
2595
|
const with_lock = _nullishCoalesce(deps.with_stream_lock, () => ( ((_stream, w) => w())));
|
|
2591
2596
|
return [...streams].sort().reduceRight(
|
|
@@ -2593,7 +2598,7 @@ function with_stream_locks(streams, deps, work) {
|
|
|
2593
2598
|
work
|
|
2594
2599
|
)();
|
|
2595
2600
|
}
|
|
2596
|
-
|
|
2601
|
+
_chunkLA2BPKNScjs.__name.call(void 0, with_stream_locks, "with_stream_locks");
|
|
2597
2602
|
async function run_full_closes(full, target_map, deps, skipped) {
|
|
2598
2603
|
const none = /* @__PURE__ */ new Map();
|
|
2599
2604
|
const streams = full.map((t) => t.stream);
|
|
@@ -2603,7 +2608,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
|
|
|
2603
2608
|
const info = stream_info.get(target.stream);
|
|
2604
2609
|
if (!info) continue;
|
|
2605
2610
|
const owner = deps.event_to_state.get(info.last_event_name);
|
|
2606
|
-
if (_optionalChain([owner, 'optionalAccess',
|
|
2611
|
+
if (_optionalChain([owner, 'optionalAccess', _139 => _139.pii_aware])) {
|
|
2607
2612
|
deps.logger.error(
|
|
2608
2613
|
`Refusing to close "${target.stream}" with restart: state "${owner.name}" carries sensitive fields, so a restart seed would persist redacted values while deleting the originals. Close it without restart to retire the stream, or leave it open.`
|
|
2609
2614
|
);
|
|
@@ -2649,7 +2654,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
|
|
|
2649
2654
|
deps.correlation
|
|
2650
2655
|
);
|
|
2651
2656
|
}
|
|
2652
|
-
|
|
2657
|
+
_chunkLA2BPKNScjs.__name.call(void 0, run_full_closes, "run_full_closes");
|
|
2653
2658
|
async function run_windowed_closes(windowed, deps, skipped) {
|
|
2654
2659
|
const checkpoint = deps.reactive ? await deps.catch_up_correlation(Number.MAX_SAFE_INTEGER) : -1;
|
|
2655
2660
|
const min_at = deps.reactive ? await probe_min_watermarks(
|
|
@@ -2665,7 +2670,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2665
2670
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2666
2671
|
return void 0;
|
|
2667
2672
|
if (t.archive) await t.archive();
|
|
2668
|
-
const result = await
|
|
2673
|
+
const result = await _chunk3WHD4VPPcjs.store.call(void 0, ).truncate([
|
|
2669
2674
|
{ stream: t.stream, before: t.before, max_id }
|
|
2670
2675
|
]);
|
|
2671
2676
|
return result.get(t.stream);
|
|
@@ -2675,26 +2680,26 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2675
2680
|
}
|
|
2676
2681
|
return truncated;
|
|
2677
2682
|
}
|
|
2678
|
-
|
|
2683
|
+
_chunkLA2BPKNScjs.__name.call(void 0, run_windowed_closes, "run_windowed_closes");
|
|
2679
2684
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2680
2685
|
let boundary_id;
|
|
2681
2686
|
let min_id;
|
|
2682
|
-
await
|
|
2687
|
+
await _chunk3WHD4VPPcjs.store.call(void 0, ).query(
|
|
2683
2688
|
(event) => {
|
|
2684
2689
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2685
|
-
if (event.name ===
|
|
2690
|
+
if (event.name === _chunkLA2BPKNScjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
2686
2691
|
boundary_id = event.id;
|
|
2687
2692
|
},
|
|
2688
2693
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
2689
2694
|
);
|
|
2690
2695
|
return boundary_id !== void 0 && min_id < boundary_id;
|
|
2691
2696
|
}
|
|
2692
|
-
|
|
2697
|
+
_chunkLA2BPKNScjs.__name.call(void 0, windowed_prune_pending, "windowed_prune_pending");
|
|
2693
2698
|
async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
2694
2699
|
const min_at = /* @__PURE__ */ new Map();
|
|
2695
2700
|
const matches = source_matcher();
|
|
2696
2701
|
await walk_streams(
|
|
2697
|
-
|
|
2702
|
+
_chunk3WHD4VPPcjs.store.call(void 0, ),
|
|
2698
2703
|
(position) => {
|
|
2699
2704
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2700
2705
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2709,12 +2714,12 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2709
2714
|
);
|
|
2710
2715
|
return min_at;
|
|
2711
2716
|
}
|
|
2712
|
-
|
|
2717
|
+
_chunkLA2BPKNScjs.__name.call(void 0, probe_min_watermarks, "probe_min_watermarks");
|
|
2713
2718
|
function source_matcher() {
|
|
2714
2719
|
const compiled = /* @__PURE__ */ new Map();
|
|
2715
2720
|
return (source, target, stream) => {
|
|
2716
2721
|
if (!source) return true;
|
|
2717
|
-
if (
|
|
2722
|
+
if (_chunkQITJ63HGcjs.isStreamName.call(void 0, source, target)) return source === stream;
|
|
2718
2723
|
let re = compiled.get(source);
|
|
2719
2724
|
if (!re) {
|
|
2720
2725
|
re = new RegExp(source);
|
|
@@ -2723,19 +2728,19 @@ function source_matcher() {
|
|
|
2723
2728
|
return re.test(stream);
|
|
2724
2729
|
};
|
|
2725
2730
|
}
|
|
2726
|
-
|
|
2731
|
+
_chunkLA2BPKNScjs.__name.call(void 0, source_matcher, "source_matcher");
|
|
2727
2732
|
async function scan_stream_heads(streams) {
|
|
2728
|
-
const stats = await
|
|
2729
|
-
exclude: [
|
|
2733
|
+
const stats = await _chunk3WHD4VPPcjs.store.call(void 0, ).query_stats(streams, {
|
|
2734
|
+
exclude: [_chunkLA2BPKNScjs.SNAP_EVENT]
|
|
2730
2735
|
});
|
|
2731
|
-
const domain_heads = await
|
|
2732
|
-
exclude: [
|
|
2736
|
+
const domain_heads = await _chunk3WHD4VPPcjs.store.call(void 0, ).query_stats(streams, {
|
|
2737
|
+
exclude: [_chunkLA2BPKNScjs.SNAP_EVENT, _chunkLA2BPKNScjs.TOMBSTONE_EVENT]
|
|
2733
2738
|
});
|
|
2734
|
-
const true_heads = await
|
|
2739
|
+
const true_heads = await _chunk3WHD4VPPcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2735
2740
|
const out = /* @__PURE__ */ new Map();
|
|
2736
2741
|
for (const [stream, { head }] of domain_heads) {
|
|
2737
|
-
const marker_head = _optionalChain([stats, 'access',
|
|
2738
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess',
|
|
2742
|
+
const marker_head = _optionalChain([stats, 'access', _140 => _140.get, 'call', _141 => _141(stream), 'optionalAccess', _142 => _142.head]);
|
|
2743
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _143 => _143.name]) === _chunkLA2BPKNScjs.TOMBSTONE_EVENT;
|
|
2739
2744
|
out.set(stream, {
|
|
2740
2745
|
max_id: head.id,
|
|
2741
2746
|
version: true_heads.get(stream).head.version,
|
|
@@ -2745,7 +2750,7 @@ async function scan_stream_heads(streams) {
|
|
|
2745
2750
|
}
|
|
2746
2751
|
return out;
|
|
2747
2752
|
}
|
|
2748
|
-
|
|
2753
|
+
_chunkLA2BPKNScjs.__name.call(void 0, scan_stream_heads, "scan_stream_heads");
|
|
2749
2754
|
async function partition_by_safety(stream_info, reactive, skipped, page_size, catch_up_correlation2) {
|
|
2750
2755
|
if (!reactive) return [...stream_info.keys()];
|
|
2751
2756
|
let needed = -1;
|
|
@@ -2759,7 +2764,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2759
2764
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2760
2765
|
const matches = source_matcher();
|
|
2761
2766
|
await walk_streams(
|
|
2762
|
-
|
|
2767
|
+
_chunk3WHD4VPPcjs.store.call(void 0, ),
|
|
2763
2768
|
(position) => {
|
|
2764
2769
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2765
2770
|
if (!has_work) return;
|
|
@@ -2779,7 +2784,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2779
2784
|
}
|
|
2780
2785
|
return safe;
|
|
2781
2786
|
}
|
|
2782
|
-
|
|
2787
|
+
_chunkLA2BPKNScjs.__name.call(void 0, partition_by_safety, "partition_by_safety");
|
|
2783
2788
|
async function guard_with_tombstones(safe, stream_info, correlation, tombstone2, skipped) {
|
|
2784
2789
|
const guarded = [];
|
|
2785
2790
|
const guard_events = /* @__PURE__ */ new Map();
|
|
@@ -2802,11 +2807,11 @@ async function guard_with_tombstones(safe, stream_info, correlation, tombstone2,
|
|
|
2802
2807
|
);
|
|
2803
2808
|
return { guarded, guard_events };
|
|
2804
2809
|
}
|
|
2805
|
-
|
|
2810
|
+
_chunkLA2BPKNScjs.__name.call(void 0, guard_with_tombstones, "guard_with_tombstones");
|
|
2806
2811
|
async function load_restart_seeds(guarded, target_map, stream_info, event_to_state, load2, logger) {
|
|
2807
2812
|
const seed_states = /* @__PURE__ */ new Map();
|
|
2808
2813
|
await Promise.all(
|
|
2809
|
-
guarded.filter((s) => _optionalChain([target_map, 'access',
|
|
2814
|
+
guarded.filter((s) => _optionalChain([target_map, 'access', _144 => _144.get, 'call', _145 => _145(s), 'optionalAccess', _146 => _146.restart])).map(async (stream) => {
|
|
2810
2815
|
const last_event_name = stream_info.get(stream).last_event_name;
|
|
2811
2816
|
const owner_state = event_to_state.get(last_event_name);
|
|
2812
2817
|
if (!owner_state) {
|
|
@@ -2821,24 +2826,24 @@ async function load_restart_seeds(guarded, target_map, stream_info, event_to_sta
|
|
|
2821
2826
|
);
|
|
2822
2827
|
return seed_states;
|
|
2823
2828
|
}
|
|
2824
|
-
|
|
2829
|
+
_chunkLA2BPKNScjs.__name.call(void 0, load_restart_seeds, "load_restart_seeds");
|
|
2825
2830
|
async function run_archive_callbacks(guarded, target_map) {
|
|
2826
2831
|
for (const stream of guarded) {
|
|
2827
|
-
const archive_fn = _optionalChain([target_map, 'access',
|
|
2832
|
+
const archive_fn = _optionalChain([target_map, 'access', _147 => _147.get, 'call', _148 => _148(stream), 'optionalAccess', _149 => _149.archive]);
|
|
2828
2833
|
if (archive_fn) await archive_fn();
|
|
2829
2834
|
}
|
|
2830
2835
|
}
|
|
2831
|
-
|
|
2836
|
+
_chunkLA2BPKNScjs.__name.call(void 0, run_archive_callbacks, "run_archive_callbacks");
|
|
2832
2837
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2833
|
-
const heads = await
|
|
2838
|
+
const heads = await _chunk3WHD4VPPcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2834
2839
|
return guarded.filter((stream) => {
|
|
2835
|
-
if (_optionalChain([heads, 'access',
|
|
2840
|
+
if (_optionalChain([heads, 'access', _150 => _150.get, 'call', _151 => _151(stream), 'optionalAccess', _152 => _152.head, 'access', _153 => _153.id]) === guard_events.get(stream).id)
|
|
2836
2841
|
return true;
|
|
2837
2842
|
skipped.push(stream);
|
|
2838
2843
|
return false;
|
|
2839
2844
|
});
|
|
2840
2845
|
}
|
|
2841
|
-
|
|
2846
|
+
_chunkLA2BPKNScjs.__name.call(void 0, heads_still_guarded, "heads_still_guarded");
|
|
2842
2847
|
async function truncate_and_warm_cache(guarded, seed_states, guard_events, correlation) {
|
|
2843
2848
|
const trunc_targets = guarded.map((stream) => {
|
|
2844
2849
|
const snapshot = seed_states.get(stream);
|
|
@@ -2849,18 +2854,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2849
2854
|
meta: {
|
|
2850
2855
|
correlation,
|
|
2851
2856
|
causation: {
|
|
2852
|
-
event: { id: guard.id, name:
|
|
2857
|
+
event: { id: guard.id, name: _chunkLA2BPKNScjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2853
2858
|
}
|
|
2854
2859
|
}
|
|
2855
2860
|
};
|
|
2856
2861
|
});
|
|
2857
|
-
const truncated = await
|
|
2862
|
+
const truncated = await _chunk3WHD4VPPcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2858
2863
|
await Promise.all(
|
|
2859
2864
|
guarded.map(async (stream) => {
|
|
2860
2865
|
const entry = truncated.get(stream);
|
|
2861
2866
|
const state2 = seed_states.get(stream);
|
|
2862
2867
|
if (state2 && entry) {
|
|
2863
|
-
await
|
|
2868
|
+
await _chunk3WHD4VPPcjs.cache.call(void 0, ).set(stream, {
|
|
2864
2869
|
stream,
|
|
2865
2870
|
state: state2,
|
|
2866
2871
|
version: entry.committed.version,
|
|
@@ -2869,19 +2874,19 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2869
2874
|
snaps: 1
|
|
2870
2875
|
});
|
|
2871
2876
|
} else {
|
|
2872
|
-
await
|
|
2877
|
+
await _chunk3WHD4VPPcjs.cache.call(void 0, ).invalidate(stream);
|
|
2873
2878
|
}
|
|
2874
2879
|
})
|
|
2875
2880
|
);
|
|
2876
2881
|
return truncated;
|
|
2877
2882
|
}
|
|
2878
|
-
|
|
2883
|
+
_chunkLA2BPKNScjs.__name.call(void 0, truncate_and_warm_cache, "truncate_and_warm_cache");
|
|
2879
2884
|
|
|
2880
2885
|
// src/internal/correlate-cycle.ts
|
|
2881
2886
|
|
|
2882
2887
|
var COLD_START_BACK_SCAN = 1e4;
|
|
2883
2888
|
var CORRELATION_LEASE_MS = 5e3;
|
|
2884
|
-
var registry_key = /* @__PURE__ */
|
|
2889
|
+
var registry_key = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (events) => {
|
|
2885
2890
|
const shape = Object.keys(events).filter((name) => events[name].reactions.size > 0).sort().map((name) => [name, [...events[name].reactions.keys()].sort()]);
|
|
2886
2891
|
return _crypto.createHash.call(void 0, "sha256").update(JSON.stringify(shape)).digest("hex").slice(0, 32);
|
|
2887
2892
|
}, "registry_key");
|
|
@@ -2893,7 +2898,7 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
|
|
|
2893
2898
|
`Reaction "${handler}" resolved onto undeclared lane "${lane}" \u2014 for example target "${target}". Declared lanes: ${[...declared].map((l) => `"${l}"`).join(", ")}. No controller claims it, so the stream would never drain \u2014 running it on "default" instead. The equivalent static \`.to({ lane })\` is rejected at build; a dynamic resolver's lane is only knowable here.`
|
|
2894
2899
|
);
|
|
2895
2900
|
}
|
|
2896
|
-
|
|
2901
|
+
_chunkLA2BPKNScjs.__name.call(void 0, report_undeclared_lane, "report_undeclared_lane");
|
|
2897
2902
|
function report_bad_priority(seen, handler, target, priority) {
|
|
2898
2903
|
report_once(
|
|
2899
2904
|
seen,
|
|
@@ -2901,7 +2906,7 @@ function report_bad_priority(seen, handler, target, priority) {
|
|
|
2901
2906
|
`Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer. Running it at priority 0 instead. The equivalent static \`.to({ priority })\` is rejected at build; a dynamic resolver's priority is only knowable here.`
|
|
2902
2907
|
);
|
|
2903
2908
|
}
|
|
2904
|
-
|
|
2909
|
+
_chunkLA2BPKNScjs.__name.call(void 0, report_bad_priority, "report_bad_priority");
|
|
2905
2910
|
function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
2906
2911
|
report_once(
|
|
2907
2912
|
seen,
|
|
@@ -2909,10 +2914,10 @@ function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
|
2909
2914
|
`Reaction "${handler}" resolved lane "${dropped}" for a stream already on "${kept}" \u2014 for example "${target}". These are conflicting lane assignments from two dynamic resolutions at equal priority. Keeping "${kept}", the lane it was first discovered on \u2014 re-laning a live stream would move it out from under a worker holding its lease. The reaction resolving "${dropped}" runs inside the "${kept}" lane's budget, and a process restricted to "${dropped}" via onlyLanes never runs it. The equivalent static declaration is rejected at build; align the resolvers, or split the target.`
|
|
2910
2915
|
);
|
|
2911
2916
|
}
|
|
2912
|
-
|
|
2917
|
+
_chunkLA2BPKNScjs.__name.call(void 0, report_lane_conflict, "report_lane_conflict");
|
|
2913
2918
|
var CorrelateCycle = (_class5 = class {
|
|
2914
2919
|
static {
|
|
2915
|
-
|
|
2920
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "CorrelateCycle");
|
|
2916
2921
|
}
|
|
2917
2922
|
__init10() {this._checkpoint = -1}
|
|
2918
2923
|
// Lease holder id; per instance, so a restart never inherits a stale claim.
|
|
@@ -2935,7 +2940,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2935
2940
|
// never lets a resolution re-lane them.
|
|
2936
2941
|
|
|
2937
2942
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2938
|
-
__init19() {this._patterns = new (0,
|
|
2943
|
+
__init19() {this._patterns = new (0, _chunk3WHD4VPPcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2939
2944
|
|
|
2940
2945
|
|
|
2941
2946
|
|
|
@@ -2953,7 +2958,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2953
2958
|
on_init
|
|
2954
2959
|
}) {;_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);
|
|
2955
2960
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2956
|
-
this._dynamic_subscriptions = new (0,
|
|
2961
|
+
this._dynamic_subscriptions = new (0, _chunk3WHD4VPPcjs.LruMap)(max_subscribed_streams);
|
|
2957
2962
|
this._registry = registry;
|
|
2958
2963
|
this._declared_lanes = declared_lanes;
|
|
2959
2964
|
this._static_targets = static_targets;
|
|
@@ -2985,7 +2990,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2985
2990
|
lane
|
|
2986
2991
|
});
|
|
2987
2992
|
}
|
|
2988
|
-
await _optionalChain([this, 'access',
|
|
2993
|
+
await _optionalChain([this, 'access', _154 => _154._on_init, 'optionalCall', _155 => _155()]);
|
|
2989
2994
|
}
|
|
2990
2995
|
/**
|
|
2991
2996
|
* Replace the log with no pass in flight, then cold-start: a pass that
|
|
@@ -3011,7 +3016,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3011
3016
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
3012
3017
|
_in_fetch_window(source, stream) {
|
|
3013
3018
|
if (source === void 0 || source === stream) return true;
|
|
3014
|
-
if (
|
|
3019
|
+
if (_chunkQITJ63HGcjs.isStreamName.call(void 0, source)) return false;
|
|
3015
3020
|
let pattern = this._patterns.get(source);
|
|
3016
3021
|
if (!pattern) {
|
|
3017
3022
|
pattern = new RegExp(source);
|
|
@@ -3033,7 +3038,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3033
3038
|
async _scan(limit, lease) {
|
|
3034
3039
|
await this._init();
|
|
3035
3040
|
const epoch = this._epoch;
|
|
3036
|
-
const idle = /* @__PURE__ */
|
|
3041
|
+
const idle = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => ({
|
|
3037
3042
|
kind: "idle",
|
|
3038
3043
|
last_id: this._checkpoint
|
|
3039
3044
|
}), "idle");
|
|
@@ -3054,7 +3059,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3054
3059
|
const correlated = /* @__PURE__ */ new Map();
|
|
3055
3060
|
let last_id = after;
|
|
3056
3061
|
let stopped = false;
|
|
3057
|
-
const found = await
|
|
3062
|
+
const found = await _chunk3WHD4VPPcjs.store.call(void 0, ).query(
|
|
3058
3063
|
(event) => {
|
|
3059
3064
|
if (stopped) return;
|
|
3060
3065
|
const register = this._registry.events[event.name];
|
|
@@ -3074,7 +3079,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3074
3079
|
}
|
|
3075
3080
|
if (!resolved) continue;
|
|
3076
3081
|
try {
|
|
3077
|
-
|
|
3082
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "target", resolved);
|
|
3078
3083
|
} catch (e2) {
|
|
3079
3084
|
report_bad_priority(
|
|
3080
3085
|
this._reported,
|
|
@@ -3110,9 +3115,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3110
3115
|
correlated_at: void 0
|
|
3111
3116
|
};
|
|
3112
3117
|
const seen_in_scan = correlated.has(resolved.target);
|
|
3113
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess',
|
|
3114
|
-
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess',
|
|
3115
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
3118
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _156 => _156.lane])), () => ( _chunkLA2BPKNScjs.DEFAULT_LANE));
|
|
3119
|
+
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _157 => _157.priority]);
|
|
3120
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkLA2BPKNScjs.DEFAULT_LANE));
|
|
3116
3121
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
3117
3122
|
report_lane_conflict(
|
|
3118
3123
|
this._reported,
|
|
@@ -3166,7 +3171,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3166
3171
|
).length;
|
|
3167
3172
|
this._checkpoint = last_id;
|
|
3168
3173
|
for (const { stream, priority, lane } of streams) {
|
|
3169
|
-
if (_optionalChain([correlated, 'access',
|
|
3174
|
+
if (_optionalChain([correlated, 'access', _158 => _158.get, 'call', _159 => _159(stream), 'optionalAccess', _160 => _160.upgraded]))
|
|
3170
3175
|
this._dynamic_subscriptions.set(stream, {
|
|
3171
3176
|
priority,
|
|
3172
3177
|
lane
|
|
@@ -3186,7 +3191,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3186
3191
|
await Promise.all(
|
|
3187
3192
|
missed.map(async ([stream, entry]) => {
|
|
3188
3193
|
let row;
|
|
3189
|
-
await
|
|
3194
|
+
await _chunk3WHD4VPPcjs.store.call(void 0, ).query_streams(
|
|
3190
3195
|
(position) => {
|
|
3191
3196
|
row = position;
|
|
3192
3197
|
},
|
|
@@ -3198,8 +3203,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3198
3203
|
lane: row.lane
|
|
3199
3204
|
});
|
|
3200
3205
|
if (entry.priority > row.priority) return;
|
|
3201
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3202
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3206
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkLA2BPKNScjs.DEFAULT_LANE));
|
|
3207
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkLA2BPKNScjs.DEFAULT_LANE));
|
|
3203
3208
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3204
3209
|
report_lane_conflict(
|
|
3205
3210
|
this._reported,
|
|
@@ -3225,7 +3230,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3225
3230
|
millis: 0
|
|
3226
3231
|
});
|
|
3227
3232
|
} catch (error) {
|
|
3228
|
-
|
|
3233
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).warn(
|
|
3229
3234
|
`Could not hand back the correlation lease during shutdown; it expires on its own within ${CORRELATION_LEASE_MS}ms and correlation resumes normally after that. On a single-writer store this usually means another connection holds the database. Cause: ${String(_nullishCoalesce(error.cause, () => ( error)))}`
|
|
3230
3235
|
);
|
|
3231
3236
|
}
|
|
@@ -3244,13 +3249,13 @@ function pii_split(emitted, fields) {
|
|
|
3244
3249
|
}
|
|
3245
3250
|
return { name: emitted.name, data, pii };
|
|
3246
3251
|
}
|
|
3247
|
-
|
|
3252
|
+
_chunkLA2BPKNScjs.__name.call(void 0, pii_split, "pii_split");
|
|
3248
3253
|
function pii_gate(event, fields, predicate, actor) {
|
|
3249
3254
|
const data = event.data;
|
|
3250
3255
|
const { pii, ...rest } = event;
|
|
3251
3256
|
if (pii == null) {
|
|
3252
3257
|
const shredded = { ...data };
|
|
3253
|
-
for (const f of fields) shredded[f] =
|
|
3258
|
+
for (const f of fields) shredded[f] = _chunkLA2BPKNScjs.SHREDDED;
|
|
3254
3259
|
return { ...rest, data: shredded };
|
|
3255
3260
|
}
|
|
3256
3261
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3261,15 +3266,15 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3261
3266
|
};
|
|
3262
3267
|
}
|
|
3263
3268
|
const redacted = { ...data };
|
|
3264
|
-
for (const f of fields) redacted[f] =
|
|
3269
|
+
for (const f of fields) redacted[f] = _chunkLA2BPKNScjs.REDACTED;
|
|
3265
3270
|
return { ...rest, data: redacted };
|
|
3266
3271
|
}
|
|
3267
|
-
|
|
3268
|
-
var IDENTITY_GATE = /* @__PURE__ */
|
|
3272
|
+
_chunkLA2BPKNScjs.__name.call(void 0, pii_gate, "pii_gate");
|
|
3273
|
+
var IDENTITY_GATE = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (event) => event, "IDENTITY_GATE");
|
|
3269
3274
|
function make_gate(fields, predicate) {
|
|
3270
3275
|
return (event, actor) => pii_gate(event, fields, predicate, actor);
|
|
3271
3276
|
}
|
|
3272
|
-
|
|
3277
|
+
_chunkLA2BPKNScjs.__name.call(void 0, make_gate, "make_gate");
|
|
3273
3278
|
function pii_strip(event, fields) {
|
|
3274
3279
|
const data = event.data;
|
|
3275
3280
|
const stripped = {};
|
|
@@ -3282,22 +3287,22 @@ function pii_strip(event, fields) {
|
|
|
3282
3287
|
data: stripped
|
|
3283
3288
|
};
|
|
3284
3289
|
}
|
|
3285
|
-
|
|
3290
|
+
_chunkLA2BPKNScjs.__name.call(void 0, pii_strip, "pii_strip");
|
|
3286
3291
|
|
|
3287
3292
|
// src/internal/projection-fold.ts
|
|
3288
3293
|
var FOLD_RESET = /* @__PURE__ */ Symbol("act.fold.reset");
|
|
3289
3294
|
function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
3290
3295
|
const load_me = {
|
|
3291
3296
|
...me,
|
|
3292
|
-
view: /* @__PURE__ */
|
|
3297
|
+
view: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (raw, actor) => {
|
|
3293
3298
|
const viewed = me.view(raw, actor);
|
|
3294
3299
|
const fields = sensitive_fields(viewed.name);
|
|
3295
3300
|
return fields.length ? pii_strip(viewed, fields) : viewed;
|
|
3296
3301
|
}, "view")
|
|
3297
3302
|
};
|
|
3298
3303
|
const cache2 = /* @__PURE__ */ new Map();
|
|
3299
|
-
const row = /* @__PURE__ */
|
|
3300
|
-
const flush_dirty = /* @__PURE__ */
|
|
3304
|
+
const row = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, ({ dirty: _, ...row2 }) => row2, "row");
|
|
3305
|
+
const flush_dirty = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async () => {
|
|
3301
3306
|
const rows = [];
|
|
3302
3307
|
const flushed = [];
|
|
3303
3308
|
for (const f of cache2.values())
|
|
@@ -3309,7 +3314,7 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3309
3314
|
await flush(rows);
|
|
3310
3315
|
for (const f of flushed) f.dirty = false;
|
|
3311
3316
|
}, "flush_dirty");
|
|
3312
|
-
const first_sight = /* @__PURE__ */
|
|
3317
|
+
const first_sight = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (stream) => {
|
|
3313
3318
|
if (cache2.size >= config2.maxCachedStates) {
|
|
3314
3319
|
const oldest = cache2.keys().next().value;
|
|
3315
3320
|
const evictee = cache2.get(oldest);
|
|
@@ -3329,7 +3334,7 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3329
3334
|
cache2.set(stream, seated);
|
|
3330
3335
|
return seated;
|
|
3331
3336
|
}, "first_sight");
|
|
3332
|
-
const handler = /* @__PURE__ */
|
|
3337
|
+
const handler = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (events) => {
|
|
3333
3338
|
let folded_since_flush = 0;
|
|
3334
3339
|
for (const event of events) {
|
|
3335
3340
|
const stream = event.stream;
|
|
@@ -3367,15 +3372,15 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3367
3372
|
}
|
|
3368
3373
|
await flush_dirty();
|
|
3369
3374
|
}, "handler");
|
|
3370
|
-
Object.defineProperty(handler, FOLD_RESET, { value: /* @__PURE__ */
|
|
3375
|
+
Object.defineProperty(handler, FOLD_RESET, { value: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => cache2.clear(), "value") });
|
|
3371
3376
|
return handler;
|
|
3372
3377
|
}
|
|
3373
|
-
|
|
3378
|
+
_chunkLA2BPKNScjs.__name.call(void 0, make_fold_handler, "make_fold_handler");
|
|
3374
3379
|
|
|
3375
3380
|
// src/internal/settle.ts
|
|
3376
3381
|
var SettleLoop = (_class6 = class {
|
|
3377
3382
|
static {
|
|
3378
|
-
|
|
3383
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "SettleLoop");
|
|
3379
3384
|
}
|
|
3380
3385
|
__init21() {this._timer = void 0}
|
|
3381
3386
|
// The cycle in flight, set while one runs. Shutdown waits for it
|
|
@@ -3413,7 +3418,7 @@ var SettleLoop = (_class6 = class {
|
|
|
3413
3418
|
this._pending = true;
|
|
3414
3419
|
return;
|
|
3415
3420
|
}
|
|
3416
|
-
const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3421
|
+
const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _161 => _161.debounceMs]), () => ( this._default_debounce_ms));
|
|
3417
3422
|
const due = Date.now() + delay;
|
|
3418
3423
|
if (this._timer) {
|
|
3419
3424
|
if (due >= this._due) return;
|
|
@@ -3478,7 +3483,7 @@ var SettleLoop = (_class6 = class {
|
|
|
3478
3483
|
// src/act.ts
|
|
3479
3484
|
var Act = (_class7 = class {
|
|
3480
3485
|
static {
|
|
3481
|
-
|
|
3486
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "Act");
|
|
3482
3487
|
}
|
|
3483
3488
|
__init26() {this._emitter = new (0, _events2.default)()}
|
|
3484
3489
|
|
|
@@ -3566,7 +3571,7 @@ var Act = (_class7 = class {
|
|
|
3566
3571
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3567
3572
|
|
|
3568
3573
|
|
|
3569
|
-
__init27() {this._logger =
|
|
3574
|
+
__init27() {this._logger = _chunk3WHD4VPPcjs.log.call(void 0, )}
|
|
3570
3575
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3571
3576
|
|
|
3572
3577
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3595,11 +3600,11 @@ var Act = (_class7 = class {
|
|
|
3595
3600
|
throw new Error(
|
|
3596
3601
|
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3597
3602
|
);
|
|
3598
|
-
|
|
3599
|
-
if (options.scoped)
|
|
3600
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3603
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "act", options);
|
|
3604
|
+
if (options.scoped) _chunk3WHD4VPPcjs.check.call(void 0, "store", options.scoped.store);
|
|
3605
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunk3WHD4VPPcjs.unscoped_ports.call(void 0, )));
|
|
3601
3606
|
const ports = this._ports;
|
|
3602
|
-
this._scoped =
|
|
3607
|
+
this._scoped = _chunk3WHD4VPPcjs.make_run_scoped.call(void 0, {
|
|
3603
3608
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3604
3609
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3605
3610
|
get store() {
|
|
@@ -3609,14 +3614,14 @@ var Act = (_class7 = class {
|
|
|
3609
3614
|
return ports.cache;
|
|
3610
3615
|
},
|
|
3611
3616
|
// Parsed per build, so a bad window throws on every build.
|
|
3612
|
-
autoclose_window:
|
|
3617
|
+
autoclose_window: _chunk3WHD4VPPcjs.check.call(void 0, "autoclose", options).autocloseWindow
|
|
3613
3618
|
});
|
|
3614
3619
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3615
3620
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3616
3621
|
this._cd = build_drain(this._logger);
|
|
3617
3622
|
const handle = build_handle({
|
|
3618
3623
|
logger: this._logger,
|
|
3619
|
-
reaction_scope:
|
|
3624
|
+
reaction_scope: _chunk3WHD4VPPcjs.make_reaction_scope.call(void 0, {
|
|
3620
3625
|
do: this.do.bind(this),
|
|
3621
3626
|
load: this.load.bind(this),
|
|
3622
3627
|
query: this.query.bind(this),
|
|
@@ -3646,24 +3651,24 @@ var Act = (_class7 = class {
|
|
|
3646
3651
|
this._ports.store,
|
|
3647
3652
|
options.listen !== false
|
|
3648
3653
|
);
|
|
3649
|
-
|
|
3654
|
+
_chunk3WHD4VPPcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3650
3655
|
}
|
|
3651
3656
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3652
3657
|
_build_breaker(options) {
|
|
3653
3658
|
return new CircuitBreaker(
|
|
3654
|
-
|
|
3659
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "circuit_breaker", _nullishCoalesce(options.circuitBreaker, () => ( {}))),
|
|
3655
3660
|
{
|
|
3656
|
-
on_error: /* @__PURE__ */
|
|
3661
|
+
on_error: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (error, circuit) => this._emit_error(error, circuit), "on_error"),
|
|
3657
3662
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
3658
3663
|
// half-open probe that closes or re-opens the breaker.
|
|
3659
|
-
on_retry: /* @__PURE__ */
|
|
3664
|
+
on_retry: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => this._schedule(), "on_retry")
|
|
3660
3665
|
}
|
|
3661
3666
|
);
|
|
3662
3667
|
}
|
|
3663
3668
|
// Apps that declare no lanes pass no lane filter to `claim`.
|
|
3664
3669
|
_build_drain_controllers(options, lanes, handle, handle_batch) {
|
|
3665
3670
|
const all_lanes = this._declared_lanes;
|
|
3666
|
-
const only_set = _optionalChain([options, 'access',
|
|
3671
|
+
const only_set = _optionalChain([options, 'access', _162 => _162.onlyLanes, 'optionalAccess', _163 => _163.length]) ? new Set(options.onlyLanes) : void 0;
|
|
3667
3672
|
const active_lanes = only_set ? all_lanes.filter((n) => only_set.has(n)) : all_lanes;
|
|
3668
3673
|
const single_default_lane = lanes.length === 0;
|
|
3669
3674
|
const controllers = /* @__PURE__ */ new Map();
|
|
@@ -3676,16 +3681,16 @@ var Act = (_class7 = class {
|
|
|
3676
3681
|
batch_handlers: this._batch_handlers,
|
|
3677
3682
|
handle,
|
|
3678
3683
|
handle_batch,
|
|
3679
|
-
on_acked: /* @__PURE__ */
|
|
3680
|
-
on_blocked: /* @__PURE__ */
|
|
3684
|
+
on_acked: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (acked) => this.emit("acked", acked), "on_acked"),
|
|
3685
|
+
on_blocked: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (blocked) => this.emit("blocked", blocked), "on_blocked"),
|
|
3681
3686
|
// Reaction-requested close: the same machinery as `app.close`.
|
|
3682
3687
|
// A store failure reaches the breaker; anything else (the archive
|
|
3683
3688
|
// callback is app code) is logged here, never counted.
|
|
3684
|
-
on_close: /* @__PURE__ */
|
|
3689
|
+
on_close: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (targets) => {
|
|
3685
3690
|
try {
|
|
3686
3691
|
await this._run_close(targets);
|
|
3687
3692
|
} catch (error) {
|
|
3688
|
-
if (error instanceof
|
|
3693
|
+
if (error instanceof _chunkLA2BPKNScjs.StoreError) throw error;
|
|
3689
3694
|
this._logger.error(
|
|
3690
3695
|
error,
|
|
3691
3696
|
`Reaction-requested close of ${targets.map((t) => `"${t.stream}"`).join(", ")} failed; the policy retries it (a full close the next day, a prune on the stream's next commit), or close it now with app.close(...) once the cause is fixed.`
|
|
@@ -3700,7 +3705,7 @@ var Act = (_class7 = class {
|
|
|
3700
3705
|
leaseMillis: cfg.leaseMillis
|
|
3701
3706
|
}
|
|
3702
3707
|
});
|
|
3703
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
3708
|
+
if (_optionalChain([cfg, 'optionalAccess', _164 => _164.cycleMs]) !== void 0 && this._drain)
|
|
3704
3709
|
controller.start(cfg.cycleMs);
|
|
3705
3710
|
controllers.set(name, controller);
|
|
3706
3711
|
}
|
|
@@ -3719,7 +3724,7 @@ var Act = (_class7 = class {
|
|
|
3719
3724
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3720
3725
|
_build_audit_deps() {
|
|
3721
3726
|
return {
|
|
3722
|
-
store:
|
|
3727
|
+
store: _chunk3WHD4VPPcjs.store,
|
|
3723
3728
|
event_to_state: this._event_to_state,
|
|
3724
3729
|
sensitive_fields: this.registry.sensitive_fields,
|
|
3725
3730
|
// Declared lanes, not this process's controllers: a lane another
|
|
@@ -3733,14 +3738,14 @@ var Act = (_class7 = class {
|
|
|
3733
3738
|
registry: this.registry,
|
|
3734
3739
|
static_targets: classification.static_targets,
|
|
3735
3740
|
cd: this._cd,
|
|
3736
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3741
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkLA2BPKNScjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3737
3742
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3738
3743
|
// still a valid destination.
|
|
3739
3744
|
declared_lanes: new Set(this._declared_lanes),
|
|
3740
3745
|
// Built after the controllers, so their keys are the active lanes.
|
|
3741
3746
|
shard: this._drain_controllers.size < this._declared_lanes.length ? [...this._drain_controllers.keys()] : void 0,
|
|
3742
3747
|
// Only reached on a draining app: writer-only ones never correlate.
|
|
3743
|
-
on_init: /* @__PURE__ */
|
|
3748
|
+
on_init: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async () => {
|
|
3744
3749
|
this._arm_all();
|
|
3745
3750
|
await this._seed_persisted_defers();
|
|
3746
3751
|
}, "on_init")
|
|
@@ -3749,23 +3754,23 @@ var Act = (_class7 = class {
|
|
|
3749
3754
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3750
3755
|
async _seed_persisted_defers() {
|
|
3751
3756
|
const now = Date.now();
|
|
3752
|
-
await walk_streams(
|
|
3757
|
+
await walk_streams(_chunk3WHD4VPPcjs.store.call(void 0, ), (pos) => {
|
|
3753
3758
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3754
3759
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3755
|
-
_optionalChain([controller, 'optionalAccess',
|
|
3760
|
+
_optionalChain([controller, 'optionalAccess', _165 => _165.seed_defer, 'call', _166 => _166(pos.stream, pos.deferred_at)]);
|
|
3756
3761
|
});
|
|
3757
3762
|
}
|
|
3758
3763
|
_build_settle(options) {
|
|
3759
3764
|
return new SettleLoop(
|
|
3760
3765
|
{
|
|
3761
|
-
correlate: /* @__PURE__ */
|
|
3766
|
+
correlate: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (q) => this._correlate_pass(_nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)), true), "correlate"),
|
|
3762
3767
|
// `settle()` validated the options, and `_schedule` skips writer-only
|
|
3763
3768
|
// instances, so the loop drains through the internal path.
|
|
3764
|
-
drain: /* @__PURE__ */
|
|
3765
|
-
on_settled: /* @__PURE__ */
|
|
3769
|
+
drain: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (o) => this._scoped(() => this._drain_all(o)), "drain"),
|
|
3770
|
+
on_settled: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (drain) => this.emit("settled", drain), "on_settled"),
|
|
3766
3771
|
breaker: this._breaker
|
|
3767
3772
|
},
|
|
3768
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3773
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkLA2BPKNScjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3769
3774
|
);
|
|
3770
3775
|
}
|
|
3771
3776
|
|
|
@@ -3785,7 +3790,7 @@ var Act = (_class7 = class {
|
|
|
3785
3790
|
*/
|
|
3786
3791
|
shutdown(options) {
|
|
3787
3792
|
if (!this._shutdown_promise) {
|
|
3788
|
-
|
|
3793
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "shutdown", _nullishCoalesce(options, () => ( {})));
|
|
3789
3794
|
this._shutdown_promise = (async () => {
|
|
3790
3795
|
this.stop_correlations();
|
|
3791
3796
|
this._settle.stop(true);
|
|
@@ -3793,7 +3798,7 @@ var Act = (_class7 = class {
|
|
|
3793
3798
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3794
3799
|
const disposer = await this._notify_disposer;
|
|
3795
3800
|
if (disposer) await disposer();
|
|
3796
|
-
await this._await_inflight(_optionalChain([options, 'optionalAccess',
|
|
3801
|
+
await this._await_inflight(_optionalChain([options, 'optionalAccess', _167 => _167.graceMs]));
|
|
3797
3802
|
await this._scoped(() => this._correlate.release_correlation());
|
|
3798
3803
|
this._emitter.removeAllListeners();
|
|
3799
3804
|
})();
|
|
@@ -3803,10 +3808,10 @@ var Act = (_class7 = class {
|
|
|
3803
3808
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3804
3809
|
// default for none or 0, and for a running settle), capped.
|
|
3805
3810
|
_derive_grace_ms(running, settling) {
|
|
3806
|
-
let max = settling ?
|
|
3811
|
+
let max = settling ? _chunk3WHD4VPPcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3807
3812
|
for (const c of running)
|
|
3808
|
-
max = Math.max(max, c.lease_millis ||
|
|
3809
|
-
return Math.min(max,
|
|
3813
|
+
max = Math.max(max, c.lease_millis || _chunk3WHD4VPPcjs.DEFAULT_LEASE_MILLIS);
|
|
3814
|
+
return Math.min(max, _chunk3WHD4VPPcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3810
3815
|
}
|
|
3811
3816
|
async _await_inflight(grace_ms) {
|
|
3812
3817
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3890,8 +3895,8 @@ var Act = (_class7 = class {
|
|
|
3890
3895
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3891
3896
|
*/
|
|
3892
3897
|
async do(action2, target, payload, options) {
|
|
3893
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3894
|
-
const do_options = reacting_to === _optionalChain([options, 'optionalAccess',
|
|
3898
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _168 => _168.reactingTo]), () => ( _chunk3WHD4VPPcjs.current_reacting.call(void 0, )));
|
|
3899
|
+
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _169 => _169.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3895
3900
|
return this._scoped(async () => {
|
|
3896
3901
|
const snapshots = await this._es.action(
|
|
3897
3902
|
this.registry.actions[action2],
|
|
@@ -3961,14 +3966,15 @@ var Act = (_class7 = class {
|
|
|
3961
3966
|
* @see {@link query_array} for loading events into memory
|
|
3962
3967
|
*/
|
|
3963
3968
|
async query(query, callback) {
|
|
3969
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "page", query);
|
|
3964
3970
|
return this._scoped(async () => {
|
|
3965
3971
|
let first;
|
|
3966
3972
|
let last;
|
|
3967
|
-
const count = await
|
|
3973
|
+
const count = await _chunk3WHD4VPPcjs.store.call(void 0, ).query((e) => {
|
|
3968
3974
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3969
3975
|
if (!first) first = gated;
|
|
3970
3976
|
last = gated;
|
|
3971
|
-
_optionalChain([callback, 'optionalCall',
|
|
3977
|
+
_optionalChain([callback, 'optionalCall', _170 => _170(gated)]);
|
|
3972
3978
|
}, query);
|
|
3973
3979
|
return { first, last, count };
|
|
3974
3980
|
});
|
|
@@ -4010,14 +4016,14 @@ var Act = (_class7 = class {
|
|
|
4010
4016
|
*/
|
|
4011
4017
|
async forget(stream) {
|
|
4012
4018
|
return this._scoped(async () => {
|
|
4013
|
-
const s =
|
|
4019
|
+
const s = _chunk3WHD4VPPcjs.store.call(void 0, );
|
|
4014
4020
|
if (!s.forget_pii) {
|
|
4015
4021
|
throw new Error(
|
|
4016
4022
|
`Store does not implement forget_pii \u2014 adapter cannot comply with sensitive-data erasure. Use an adapter that declares pii_isolation: true (e.g. @rotorsoft/act on the in-memory store).`
|
|
4017
4023
|
);
|
|
4018
4024
|
}
|
|
4019
4025
|
const eventCount = await s.forget_pii(stream);
|
|
4020
|
-
await
|
|
4026
|
+
await _chunk3WHD4VPPcjs.cache.call(void 0, ).invalidate(stream);
|
|
4021
4027
|
if (eventCount > 0) {
|
|
4022
4028
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
4023
4029
|
}
|
|
@@ -4051,7 +4057,7 @@ var Act = (_class7 = class {
|
|
|
4051
4057
|
* @see {@link correlate} for dynamic stream discovery
|
|
4052
4058
|
*/
|
|
4053
4059
|
async drain(options = {}) {
|
|
4054
|
-
|
|
4060
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "drain", options);
|
|
4055
4061
|
if (!this._drain)
|
|
4056
4062
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
4057
4063
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4089,7 +4095,7 @@ var Act = (_class7 = class {
|
|
|
4089
4095
|
}
|
|
4090
4096
|
if (to_arm.size === 0) return false;
|
|
4091
4097
|
this._correlate.arm();
|
|
4092
|
-
for (const lane of to_arm) _optionalChain([this, 'access',
|
|
4098
|
+
for (const lane of to_arm) _optionalChain([this, 'access', _171 => _171._drain_controllers, 'access', _172 => _172.get, 'call', _173 => _173(lane), 'optionalAccess', _174 => _174.arm, 'call', _175 => _175()]);
|
|
4093
4099
|
return true;
|
|
4094
4100
|
}
|
|
4095
4101
|
// In parallel, so a slow lane never holds up a fast one.
|
|
@@ -4128,7 +4134,7 @@ var Act = (_class7 = class {
|
|
|
4128
4134
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
4129
4135
|
*/
|
|
4130
4136
|
async correlate(query = {}) {
|
|
4131
|
-
|
|
4137
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "page", query);
|
|
4132
4138
|
const pass = await this._correlate_pass(_nullishCoalesce(query.limit, () => ( 10)));
|
|
4133
4139
|
return {
|
|
4134
4140
|
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
@@ -4174,8 +4180,8 @@ var Act = (_class7 = class {
|
|
|
4174
4180
|
* @see {@link stop_correlations} to stop the poll
|
|
4175
4181
|
*/
|
|
4176
4182
|
start_correlations(query = {}, frequency = 1e4) {
|
|
4177
|
-
|
|
4178
|
-
|
|
4183
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "page", query);
|
|
4184
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "poll", { frequency });
|
|
4179
4185
|
if (this._poll) return false;
|
|
4180
4186
|
this._poll_limit = query.limit || void 0;
|
|
4181
4187
|
this._poll = setInterval(() => {
|
|
@@ -4212,7 +4218,7 @@ var Act = (_class7 = class {
|
|
|
4212
4218
|
// and an extra clear costs one head load per stream.
|
|
4213
4219
|
_reset_folds() {
|
|
4214
4220
|
for (const handler of this._batch_handlers.values())
|
|
4215
|
-
_optionalChain([handler, 'access',
|
|
4221
|
+
_optionalChain([handler, 'access', _176 => _176[FOLD_RESET], 'optionalCall', _177 => _177()]);
|
|
4216
4222
|
}
|
|
4217
4223
|
/**
|
|
4218
4224
|
* Reset reaction stream watermarks and settle them, replaying their
|
|
@@ -4241,7 +4247,7 @@ var Act = (_class7 = class {
|
|
|
4241
4247
|
*/
|
|
4242
4248
|
async reset(input) {
|
|
4243
4249
|
return this._scoped(async () => {
|
|
4244
|
-
const count = await
|
|
4250
|
+
const count = await _chunk3WHD4VPPcjs.store.call(void 0, ).reset(input);
|
|
4245
4251
|
this._reset_folds();
|
|
4246
4252
|
if (count > 0) {
|
|
4247
4253
|
this._wake();
|
|
@@ -4276,7 +4282,7 @@ var Act = (_class7 = class {
|
|
|
4276
4282
|
*/
|
|
4277
4283
|
async unblock(input) {
|
|
4278
4284
|
return this._scoped(async () => {
|
|
4279
|
-
const count = await
|
|
4285
|
+
const count = await _chunk3WHD4VPPcjs.store.call(void 0, ).unblock(input);
|
|
4280
4286
|
if (count > 0) {
|
|
4281
4287
|
this._wake();
|
|
4282
4288
|
}
|
|
@@ -4324,7 +4330,7 @@ var Act = (_class7 = class {
|
|
|
4324
4330
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4325
4331
|
*/
|
|
4326
4332
|
async restore(source, opts = {}, sink) {
|
|
4327
|
-
|
|
4333
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "scan", opts);
|
|
4328
4334
|
return this._scoped(async () => {
|
|
4329
4335
|
const started = Date.now();
|
|
4330
4336
|
if (opts.dry_run) {
|
|
@@ -4332,14 +4338,14 @@ var Act = (_class7 = class {
|
|
|
4332
4338
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4333
4339
|
}
|
|
4334
4340
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4335
|
-
const s =
|
|
4341
|
+
const s = _chunk3WHD4VPPcjs.store.call(void 0, );
|
|
4336
4342
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4337
4343
|
return s;
|
|
4338
4344
|
})()));
|
|
4339
4345
|
let kept = 0;
|
|
4340
4346
|
let migrated = 0;
|
|
4341
4347
|
let dropped = { closed_streams: 0, snapshots: 0 };
|
|
4342
|
-
const run = /* @__PURE__ */
|
|
4348
|
+
const run = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => target.restore(async (callback) => {
|
|
4343
4349
|
const partial = await scan(source, opts, callback);
|
|
4344
4350
|
kept = partial.kept;
|
|
4345
4351
|
migrated = partial.migrated;
|
|
@@ -4377,14 +4383,14 @@ var Act = (_class7 = class {
|
|
|
4377
4383
|
* ```
|
|
4378
4384
|
*/
|
|
4379
4385
|
async blocked_streams(options) {
|
|
4380
|
-
|
|
4386
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "page", _nullishCoalesce(options, () => ( {})));
|
|
4381
4387
|
return this._scoped(async () => {
|
|
4382
4388
|
const positions = [];
|
|
4383
|
-
await
|
|
4389
|
+
await _chunk3WHD4VPPcjs.store.call(void 0, ).query_streams(
|
|
4384
4390
|
(p) => {
|
|
4385
4391
|
positions.push(p);
|
|
4386
4392
|
},
|
|
4387
|
-
{ blocked: true, after: _optionalChain([options, 'optionalAccess',
|
|
4393
|
+
{ blocked: true, after: _optionalChain([options, 'optionalAccess', _178 => _178.after]), limit: _optionalChain([options, 'optionalAccess', _179 => _179.limit]) }
|
|
4388
4394
|
);
|
|
4389
4395
|
return positions;
|
|
4390
4396
|
});
|
|
@@ -4406,7 +4412,7 @@ var Act = (_class7 = class {
|
|
|
4406
4412
|
* ```
|
|
4407
4413
|
*/
|
|
4408
4414
|
async *audit(categories, options) {
|
|
4409
|
-
|
|
4415
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "audit", _nullishCoalesce(options, () => ( {})));
|
|
4410
4416
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4411
4417
|
while (true) {
|
|
4412
4418
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4434,15 +4440,15 @@ var Act = (_class7 = class {
|
|
|
4434
4440
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4435
4441
|
*/
|
|
4436
4442
|
async prioritize(filter, priority) {
|
|
4437
|
-
|
|
4438
|
-
return this._scoped(() =>
|
|
4443
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "target", { priority });
|
|
4444
|
+
return this._scoped(() => _chunk3WHD4VPPcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4439
4445
|
}
|
|
4440
4446
|
// Shared by `close()` and reaction-requested closes.
|
|
4441
4447
|
async _run_close(targets) {
|
|
4442
4448
|
const close_actor = { id: "$close", name: "close" };
|
|
4443
4449
|
const result = await run_close_cycle(targets, {
|
|
4444
4450
|
reactive: this._reactive,
|
|
4445
|
-
catch_up_correlation: /* @__PURE__ */
|
|
4451
|
+
catch_up_correlation: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (until) => catch_up_correlation(
|
|
4446
4452
|
this._correlate,
|
|
4447
4453
|
(limit) => this.correlate({ limit }),
|
|
4448
4454
|
until
|
|
@@ -4452,8 +4458,8 @@ var Act = (_class7 = class {
|
|
|
4452
4458
|
tombstone: this._es.tombstone,
|
|
4453
4459
|
logger: this._logger,
|
|
4454
4460
|
correlation: close_correlation(this._correlator, close_actor),
|
|
4455
|
-
with_stream_lock: /* @__PURE__ */
|
|
4456
|
-
forget_subscribed: /* @__PURE__ */
|
|
4461
|
+
with_stream_lock: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (stream, work) => this._close_lock.run(stream, work), "with_stream_lock"),
|
|
4462
|
+
forget_subscribed: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (streams) => this._correlate.forget_subscribed(streams), "forget_subscribed")
|
|
4457
4463
|
});
|
|
4458
4464
|
this.emit("closed", result);
|
|
4459
4465
|
return result;
|
|
@@ -4515,7 +4521,7 @@ var Act = (_class7 = class {
|
|
|
4515
4521
|
* @see {@link correlate} for manual correlation
|
|
4516
4522
|
*/
|
|
4517
4523
|
settle(options) {
|
|
4518
|
-
|
|
4524
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "settle", _nullishCoalesce(options, () => ( {})));
|
|
4519
4525
|
this._schedule(options);
|
|
4520
4526
|
}
|
|
4521
4527
|
}, _class7);
|
|
@@ -4528,7 +4534,7 @@ function base_type_name(schema) {
|
|
|
4528
4534
|
def = def_of(inner);
|
|
4529
4535
|
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4530
4536
|
}
|
|
4531
|
-
|
|
4537
|
+
_chunkLA2BPKNScjs.__name.call(void 0, base_type_name, "base_type_name");
|
|
4532
4538
|
function merge_schemas(existing, incoming, state_name) {
|
|
4533
4539
|
if (existing === incoming) return existing;
|
|
4534
4540
|
const existing_object = as_object(existing, "existing", state_name);
|
|
@@ -4548,18 +4554,18 @@ function merge_schemas(existing, incoming, state_name) {
|
|
|
4548
4554
|
}
|
|
4549
4555
|
return existing_object.extend(incoming_shape);
|
|
4550
4556
|
}
|
|
4551
|
-
|
|
4557
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_schemas, "merge_schemas");
|
|
4552
4558
|
function as_object(schema, side, state_name) {
|
|
4553
4559
|
if (schema instanceof _zod2.ZodObject) return schema;
|
|
4554
4560
|
throw new Error(
|
|
4555
4561
|
`Cannot merge state schemas for "${state_name}": the ${side} partial's schema is a ${schema.constructor.name}, not a z.object. Partials of the same state are merged by extending their shapes, so declare every partial's state as a plain z.object({ ... }).`
|
|
4556
4562
|
);
|
|
4557
4563
|
}
|
|
4558
|
-
|
|
4564
|
+
_chunkLA2BPKNScjs.__name.call(void 0, as_object, "as_object");
|
|
4559
4565
|
function merge_inits(existing, incoming) {
|
|
4560
4566
|
return () => ({ ...existing(), ...incoming() });
|
|
4561
4567
|
}
|
|
4562
|
-
|
|
4568
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_inits, "merge_inits");
|
|
4563
4569
|
function register_state(state2, states, actions, events) {
|
|
4564
4570
|
const existing = states.get(state2.name);
|
|
4565
4571
|
if (existing) {
|
|
@@ -4568,8 +4574,8 @@ function register_state(state2, states, actions, events) {
|
|
|
4568
4574
|
register_new_state(state2, states, actions, events);
|
|
4569
4575
|
}
|
|
4570
4576
|
}
|
|
4571
|
-
|
|
4572
|
-
var shared_name = /* @__PURE__ */
|
|
4577
|
+
_chunkLA2BPKNScjs.__name.call(void 0, register_state, "register_state");
|
|
4578
|
+
var shared_name = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (name) => new Error(
|
|
4573
4579
|
`Action and event share the name "${name}" \u2014 action and event names must be unique across the application. Rename one of them.`
|
|
4574
4580
|
), "shared_name");
|
|
4575
4581
|
function register_new_state(state2, states, actions, events) {
|
|
@@ -4585,13 +4591,13 @@ function register_new_state(state2, states, actions, events) {
|
|
|
4585
4591
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4586
4592
|
}
|
|
4587
4593
|
}
|
|
4588
|
-
|
|
4594
|
+
_chunkLA2BPKNScjs.__name.call(void 0, register_new_state, "register_new_state");
|
|
4589
4595
|
function pick_declared(existing, incoming, what, state_name) {
|
|
4590
4596
|
if (existing && incoming && existing !== incoming)
|
|
4591
4597
|
throw new Error(`Duplicate ${what} for state "${state_name}"`);
|
|
4592
4598
|
return _nullishCoalesce(incoming, () => ( existing));
|
|
4593
4599
|
}
|
|
4594
|
-
|
|
4600
|
+
_chunkLA2BPKNScjs.__name.call(void 0, pick_declared, "pick_declared");
|
|
4595
4601
|
function autoclose_of(existing, state2) {
|
|
4596
4602
|
pick_declared(
|
|
4597
4603
|
existing.autoclose,
|
|
@@ -4607,7 +4613,7 @@ function autoclose_of(existing, state2) {
|
|
|
4607
4613
|
autoclose_keep_days: owner.autoclose_keep_days
|
|
4608
4614
|
};
|
|
4609
4615
|
}
|
|
4610
|
-
|
|
4616
|
+
_chunkLA2BPKNScjs.__name.call(void 0, autoclose_of, "autoclose_of");
|
|
4611
4617
|
function merge_into_existing(state2, existing, states, actions, events) {
|
|
4612
4618
|
for (const name of Object.keys(state2.actions)) {
|
|
4613
4619
|
if (existing.on[name] === state2.on[name]) continue;
|
|
@@ -4665,7 +4671,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
|
|
|
4665
4671
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4666
4672
|
}
|
|
4667
4673
|
}
|
|
4668
|
-
|
|
4674
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_into_existing, "merge_into_existing");
|
|
4669
4675
|
function merge_patches(existing, incoming, state_name) {
|
|
4670
4676
|
const merged = { ...existing };
|
|
4671
4677
|
for (const name of Object.keys(incoming)) {
|
|
@@ -4688,7 +4694,7 @@ function merge_patches(existing, incoming, state_name) {
|
|
|
4688
4694
|
}
|
|
4689
4695
|
return merged;
|
|
4690
4696
|
}
|
|
4691
|
-
|
|
4697
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_patches, "merge_patches");
|
|
4692
4698
|
function merge_event_register(target, source) {
|
|
4693
4699
|
for (const [event_name, source_reg] of Object.entries(source)) {
|
|
4694
4700
|
const target_reg = target[event_name];
|
|
@@ -4703,7 +4709,7 @@ function merge_event_register(target, source) {
|
|
|
4703
4709
|
}
|
|
4704
4710
|
}
|
|
4705
4711
|
}
|
|
4706
|
-
|
|
4712
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_event_register, "merge_event_register");
|
|
4707
4713
|
function merge_projection(proj, events) {
|
|
4708
4714
|
for (const event_name of Object.keys(proj.events)) {
|
|
4709
4715
|
const proj_register = proj.events[event_name];
|
|
@@ -4723,17 +4729,17 @@ function merge_projection(proj, events) {
|
|
|
4723
4729
|
}
|
|
4724
4730
|
}
|
|
4725
4731
|
}
|
|
4726
|
-
|
|
4727
|
-
var _this_ = /* @__PURE__ */
|
|
4732
|
+
_chunkLA2BPKNScjs.__name.call(void 0, merge_projection, "merge_projection");
|
|
4733
|
+
var _this_ = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, ({ stream }) => ({
|
|
4728
4734
|
source: stream,
|
|
4729
4735
|
target: stream
|
|
4730
4736
|
}), "_this_");
|
|
4731
4737
|
|
|
4732
4738
|
// src/builders/builder-utils.ts
|
|
4733
4739
|
function register_lane(config2, lanes) {
|
|
4734
|
-
|
|
4735
|
-
if (config2.name ===
|
|
4736
|
-
throw new Error(`Lane "${
|
|
4740
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "lane", config2);
|
|
4741
|
+
if (config2.name === _chunkLA2BPKNScjs.DEFAULT_LANE)
|
|
4742
|
+
throw new Error(`Lane "${_chunkLA2BPKNScjs.DEFAULT_LANE}" is reserved`);
|
|
4737
4743
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4738
4744
|
if (!existing) return void lanes.push(config2);
|
|
4739
4745
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4741,7 +4747,7 @@ function register_lane(config2, lanes) {
|
|
|
4741
4747
|
`Lane "${config2.name}" was already declared with a different config`
|
|
4742
4748
|
);
|
|
4743
4749
|
}
|
|
4744
|
-
|
|
4750
|
+
_chunkLA2BPKNScjs.__name.call(void 0, register_lane, "register_lane");
|
|
4745
4751
|
function add_reaction(events, event, name, kind, make, builder) {
|
|
4746
4752
|
if (!name)
|
|
4747
4753
|
throw new Error(
|
|
@@ -4756,73 +4762,68 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4756
4762
|
events[event].reactions.set(name, reaction);
|
|
4757
4763
|
return Object.assign(builder, {
|
|
4758
4764
|
to(resolver) {
|
|
4759
|
-
if (typeof resolver === "object")
|
|
4765
|
+
if (typeof resolver === "object") _chunk3WHD4VPPcjs.check.call(void 0, "target", resolver);
|
|
4760
4766
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4761
4767
|
return builder;
|
|
4762
4768
|
}
|
|
4763
4769
|
});
|
|
4764
4770
|
}
|
|
4765
|
-
|
|
4771
|
+
_chunkLA2BPKNScjs.__name.call(void 0, add_reaction, "add_reaction");
|
|
4766
4772
|
function reaction_on(event, events, builder) {
|
|
4767
|
-
const register = /* @__PURE__ */
|
|
4773
|
+
const register = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (handler, options, schedule) => add_reaction(
|
|
4768
4774
|
events,
|
|
4769
4775
|
event,
|
|
4770
4776
|
handler.name,
|
|
4771
4777
|
"Reaction",
|
|
4772
4778
|
() => {
|
|
4773
4779
|
if (schedule && typeof schedule !== "function")
|
|
4774
|
-
|
|
4780
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "defer", schedule);
|
|
4775
4781
|
return {
|
|
4776
4782
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4777
4783
|
resolver: _this_,
|
|
4778
4784
|
// Validate the whole bag at the declaration site so a bad
|
|
4779
4785
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4780
4786
|
// not a NaN gate on the first retry.
|
|
4781
|
-
options:
|
|
4782
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4783
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4784
|
-
backoff: _optionalChain([options, 'optionalAccess',
|
|
4787
|
+
options: _chunk3WHD4VPPcjs.check.call(void 0, "reaction", {
|
|
4788
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _180 => _180.blockOnError]), () => ( _chunk3WHD4VPPcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4789
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _181 => _181.maxRetries]), () => ( _chunk3WHD4VPPcjs.DEFAULT_MAX_RETRIES)),
|
|
4790
|
+
backoff: _optionalChain([options, 'optionalAccess', _182 => _182.backoff])
|
|
4785
4791
|
})
|
|
4786
4792
|
};
|
|
4787
4793
|
},
|
|
4788
4794
|
builder
|
|
4789
4795
|
), "register");
|
|
4790
4796
|
return {
|
|
4791
|
-
do: /* @__PURE__ */
|
|
4792
|
-
defer: /* @__PURE__ */
|
|
4793
|
-
do: /* @__PURE__ */
|
|
4797
|
+
do: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (handler, options) => register(handler, options), "do"),
|
|
4798
|
+
defer: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (schedule) => ({
|
|
4799
|
+
do: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (handler, options) => register(handler, options, schedule), "do")
|
|
4794
4800
|
}), "defer")
|
|
4795
4801
|
};
|
|
4796
4802
|
}
|
|
4797
|
-
|
|
4803
|
+
_chunkLA2BPKNScjs.__name.call(void 0, reaction_on, "reaction_on");
|
|
4798
4804
|
|
|
4799
4805
|
// src/builders/event-builder.ts
|
|
4800
4806
|
|
|
4801
4807
|
|
|
4802
4808
|
// src/internal/sensitive.ts
|
|
4803
4809
|
var SENSITIVE = /* @__PURE__ */ Symbol.for("act.sensitive");
|
|
4804
|
-
var is_pii = /* @__PURE__ */
|
|
4810
|
+
var is_pii = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (schema) => some_layer(schema, (def) => def[SENSITIVE] === true), "is_pii");
|
|
4805
4811
|
function pii_schemas(schema) {
|
|
4812
|
+
const fields = {};
|
|
4806
4813
|
const shape = schema.shape;
|
|
4807
4814
|
if (shape && typeof shape === "object") {
|
|
4808
|
-
const fields = {};
|
|
4809
4815
|
for (const key of Object.keys(shape))
|
|
4810
4816
|
if (is_pii(shape[key])) fields[key] = shape[key];
|
|
4811
4817
|
return fields;
|
|
4812
4818
|
}
|
|
4813
4819
|
const options = schema.options;
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
for (const
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
))
|
|
4820
|
-
fields[key] ??= field;
|
|
4821
|
-
return fields;
|
|
4822
|
-
}
|
|
4823
|
-
return {};
|
|
4820
|
+
const parts = Array.isArray(options) ? options : parts_of(schema);
|
|
4821
|
+
for (const part of parts)
|
|
4822
|
+
for (const [key, field] of Object.entries(pii_schemas(part)))
|
|
4823
|
+
fields[key] ??= field;
|
|
4824
|
+
return fields;
|
|
4824
4825
|
}
|
|
4825
|
-
|
|
4826
|
+
_chunkLA2BPKNScjs.__name.call(void 0, pii_schemas, "pii_schemas");
|
|
4826
4827
|
|
|
4827
4828
|
// src/builders/event-builder.ts
|
|
4828
4829
|
function event_tags(schema) {
|
|
@@ -4833,7 +4834,7 @@ function event_tags(schema) {
|
|
|
4833
4834
|
if (dates) pii_dates[key] = dates.optional();
|
|
4834
4835
|
}
|
|
4835
4836
|
const data_reviver_schema = date_reviver_schema(schema);
|
|
4836
|
-
const revive = /* @__PURE__ */
|
|
4837
|
+
const revive = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (schema2) => (data) => {
|
|
4837
4838
|
const revived = schema2.safeParse(data);
|
|
4838
4839
|
return revived.success ? revived.data : data;
|
|
4839
4840
|
}, "revive");
|
|
@@ -4844,7 +4845,7 @@ function event_tags(schema) {
|
|
|
4844
4845
|
pii_date_reviver: dated_pii ? revive(_zod2.z.looseObject(pii_dates)) : void 0
|
|
4845
4846
|
};
|
|
4846
4847
|
}
|
|
4847
|
-
|
|
4848
|
+
_chunkLA2BPKNScjs.__name.call(void 0, event_tags, "event_tags");
|
|
4848
4849
|
function make_event_reader(tags, disclosure, predicate = null) {
|
|
4849
4850
|
const { date_reviver, pii_date_reviver } = tags;
|
|
4850
4851
|
const sensitive2 = Object.keys(tags.sensitive);
|
|
@@ -4864,9 +4865,9 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4864
4865
|
);
|
|
4865
4866
|
});
|
|
4866
4867
|
}
|
|
4867
|
-
|
|
4868
|
+
_chunkLA2BPKNScjs.__name.call(void 0, make_event_reader, "make_event_reader");
|
|
4868
4869
|
function build_events(registry, states, lanes, owners) {
|
|
4869
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4870
|
+
const declared = /* @__PURE__ */ new Set([_chunkLA2BPKNScjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4870
4871
|
const lane_errors = [];
|
|
4871
4872
|
const tags = /* @__PURE__ */ new Map();
|
|
4872
4873
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4899,7 +4900,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4899
4900
|
handler_readers.set(event_name, handler_reader);
|
|
4900
4901
|
for (const [name, reaction] of def.reactions) {
|
|
4901
4902
|
const inner = reaction.handler;
|
|
4902
|
-
const wrapped2 = /* @__PURE__ */
|
|
4903
|
+
const wrapped2 = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (evt, stream, app) => inner(handler_reader(evt), stream, app), "wrapped");
|
|
4903
4904
|
Object.defineProperty(wrapped2, "name", { value: inner.name });
|
|
4904
4905
|
reaction.handler = wrapped2;
|
|
4905
4906
|
def.reactions.set(name, reaction);
|
|
@@ -4941,7 +4942,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4941
4942
|
if (reader) readers.set(event_name, reader);
|
|
4942
4943
|
}
|
|
4943
4944
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4944
|
-
if (snap2) readers.set(
|
|
4945
|
+
if (snap2) readers.set(_chunkLA2BPKNScjs.SNAP_EVENT, snap2);
|
|
4945
4946
|
if (readers.size === 0) continue;
|
|
4946
4947
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4947
4948
|
}
|
|
@@ -4952,12 +4953,12 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4952
4953
|
const advisory = advised.size > 0 ? `Act has ${advised.size} sensitive field(s) whose type isn't a string: ${[...advised].join(", ")}. A caller who may not see one reads "[REDACTED]" or "[SHREDDED]" there instead, which its type doesn't allow. Declare sensitive fields as strings. See docs/docs/guides/sensitive-data.md.` : void 0;
|
|
4953
4954
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4954
4955
|
}
|
|
4955
|
-
|
|
4956
|
+
_chunkLA2BPKNScjs.__name.call(void 0, build_events, "build_events");
|
|
4956
4957
|
function reads_as_string(schema) {
|
|
4957
|
-
const type = _optionalChain([def_of, 'call',
|
|
4958
|
+
const type = _optionalChain([def_of, 'call', _183 => _183(output_of(schema)), 'optionalAccess', _184 => _184.type]);
|
|
4958
4959
|
return type === "string" || type === "transform";
|
|
4959
4960
|
}
|
|
4960
|
-
|
|
4961
|
+
_chunkLA2BPKNScjs.__name.call(void 0, reads_as_string, "reads_as_string");
|
|
4961
4962
|
|
|
4962
4963
|
// src/builders/act-builder.ts
|
|
4963
4964
|
function register_batch_handler(proj, batch_handlers) {
|
|
@@ -4970,7 +4971,7 @@ function register_batch_handler(proj, batch_handlers) {
|
|
|
4970
4971
|
}
|
|
4971
4972
|
batch_handlers.set(proj.target, proj.batchHandler);
|
|
4972
4973
|
}
|
|
4973
|
-
|
|
4974
|
+
_chunkLA2BPKNScjs.__name.call(void 0, register_batch_handler, "register_batch_handler");
|
|
4974
4975
|
function act() {
|
|
4975
4976
|
const states = /* @__PURE__ */ new Map();
|
|
4976
4977
|
const _sf = /* @__PURE__ */ new Map();
|
|
@@ -4984,16 +4985,16 @@ function act() {
|
|
|
4984
4985
|
const registry = {
|
|
4985
4986
|
actions: {},
|
|
4986
4987
|
events: {},
|
|
4987
|
-
sensitive_fields: /* @__PURE__ */
|
|
4988
|
-
query_gate: /* @__PURE__ */
|
|
4989
|
-
disclosure_predicate: /* @__PURE__ */
|
|
4990
|
-
deprecated_events: /* @__PURE__ */
|
|
4991
|
-
autoclose_policy: /* @__PURE__ */
|
|
4992
|
-
autoclose_archiver: /* @__PURE__ */
|
|
4988
|
+
sensitive_fields: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (name) => _nullishCoalesce(_sf.get(name), () => ( [])), "sensitive_fields"),
|
|
4989
|
+
query_gate: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (event_name) => _nullishCoalesce(_qg.get(event_name), () => ( IDENTITY_GATE)), "query_gate"),
|
|
4990
|
+
disclosure_predicate: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (state_name) => _nullishCoalesce(_dp.get(state_name), () => ( null)), "disclosure_predicate"),
|
|
4991
|
+
deprecated_events: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (state_name) => _nullishCoalesce(_de.get(state_name), () => ( EMPTY_DEPRECATED)), "deprecated_events"),
|
|
4992
|
+
autoclose_policy: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (state_name) => _nullishCoalesce(_ac.get(state_name), () => ( null)), "autoclose_policy"),
|
|
4993
|
+
autoclose_archiver: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (state_name) => _nullishCoalesce(_aa.get(state_name), () => ( null)), "autoclose_archiver")
|
|
4993
4994
|
};
|
|
4994
4995
|
const pending_projections = [];
|
|
4995
4996
|
const projection_reactions = /* @__PURE__ */ new Set();
|
|
4996
|
-
const record_projection_reactions = /* @__PURE__ */
|
|
4997
|
+
const record_projection_reactions = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (proj) => {
|
|
4997
4998
|
if (!proj.batchHandler && !proj.fold) return;
|
|
4998
4999
|
for (const register of Object.values(
|
|
4999
5000
|
proj.events
|
|
@@ -5003,7 +5004,7 @@ function act() {
|
|
|
5003
5004
|
}, "record_projection_reactions");
|
|
5004
5005
|
const fold_projections = [];
|
|
5005
5006
|
const batch_handlers = /* @__PURE__ */ new Map();
|
|
5006
|
-
const add_projection = /* @__PURE__ */
|
|
5007
|
+
const add_projection = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (proj) => {
|
|
5007
5008
|
record_projection_reactions(proj);
|
|
5008
5009
|
merge_projection(proj, registry.events);
|
|
5009
5010
|
register_batch_handler(proj, batch_handlers);
|
|
@@ -5012,16 +5013,16 @@ function act() {
|
|
|
5012
5013
|
const fold_specs = [];
|
|
5013
5014
|
const lanes = [];
|
|
5014
5015
|
let _built = false;
|
|
5015
|
-
const read_wrap = /* @__PURE__ */
|
|
5016
|
-
const wrapped2 = /* @__PURE__ */
|
|
5017
|
-
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access',
|
|
5016
|
+
const read_wrap = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (original) => {
|
|
5017
|
+
const wrapped2 = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, async (events, stream) => {
|
|
5018
|
+
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _185 => _185.get, 'call', _186 => _186(e.name), 'optionalCall', _187 => _187(e)]), () => ( e)));
|
|
5018
5019
|
return original(read, stream);
|
|
5019
5020
|
}, "wrapped");
|
|
5020
5021
|
const reset = original[FOLD_RESET];
|
|
5021
5022
|
if (reset) Object.defineProperty(wrapped2, FOLD_RESET, { value: reset });
|
|
5022
5023
|
return wrapped2;
|
|
5023
5024
|
}, "read_wrap");
|
|
5024
|
-
const make_batch_handlers = /* @__PURE__ */
|
|
5025
|
+
const make_batch_handlers = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => {
|
|
5025
5026
|
const handlers = new Map(batch_handlers);
|
|
5026
5027
|
for (const spec of fold_specs) {
|
|
5027
5028
|
handlers.set(
|
|
@@ -5039,7 +5040,7 @@ function act() {
|
|
|
5039
5040
|
}
|
|
5040
5041
|
return handlers;
|
|
5041
5042
|
}, "make_batch_handlers");
|
|
5042
|
-
const finalize_deprecations = /* @__PURE__ */
|
|
5043
|
+
const finalize_deprecations = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => {
|
|
5043
5044
|
const deprecation_summary = [];
|
|
5044
5045
|
for (const state2 of states.values()) {
|
|
5045
5046
|
const event_names = Object.keys(state2.events);
|
|
@@ -5055,7 +5056,7 @@ function act() {
|
|
|
5055
5056
|
});
|
|
5056
5057
|
}
|
|
5057
5058
|
for (const [action_name, handler] of Object.entries(state2.on)) {
|
|
5058
|
-
const static_target = _optionalChain([handler, 'optionalAccess',
|
|
5059
|
+
const static_target = _optionalChain([handler, 'optionalAccess', _188 => _188._static_emit]);
|
|
5059
5060
|
if (static_target && deprecated.has(static_target)) {
|
|
5060
5061
|
const current = current_version_of(static_target, event_names);
|
|
5061
5062
|
throw new Error(
|
|
@@ -5068,23 +5069,23 @@ function act() {
|
|
|
5068
5069
|
const list = deprecation_summary.map(
|
|
5069
5070
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
5070
5071
|
).join(", ");
|
|
5071
|
-
|
|
5072
|
+
_chunk3WHD4VPPcjs.log.call(void 0, ).info(
|
|
5072
5073
|
`Act registered ${deprecation_summary.length} deprecated event(s): ${list}. These are legacy versions kept for the read path. Consider truncating closed streams via app.close() when feasible to reduce historical event load. See docs/docs/architecture/event-schema-evolution.md.`
|
|
5073
5074
|
);
|
|
5074
5075
|
}
|
|
5075
5076
|
}, "finalize_deprecations");
|
|
5076
|
-
const closed = /* @__PURE__ */
|
|
5077
|
+
const closed = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (method) => {
|
|
5077
5078
|
throw new Error(
|
|
5078
5079
|
`act().${method}() was called after build(); the registry is already classified. Register everything before build() \u2014 build() itself may be called repeatedly (e.g. once per tenant with ActOptions.scoped).`
|
|
5079
5080
|
);
|
|
5080
5081
|
}, "closed");
|
|
5081
5082
|
const builder = {
|
|
5082
|
-
withState: /* @__PURE__ */
|
|
5083
|
+
withState: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (state2) => {
|
|
5083
5084
|
if (_built) closed("withState");
|
|
5084
5085
|
register_state(state2, states, registry.actions, registry.events);
|
|
5085
5086
|
return builder;
|
|
5086
5087
|
}, "withState"),
|
|
5087
|
-
withSlice: /* @__PURE__ */
|
|
5088
|
+
withSlice: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (input) => {
|
|
5088
5089
|
if (_built) closed("withSlice");
|
|
5089
5090
|
for (const s of input.states.values()) {
|
|
5090
5091
|
register_state(s, states, registry.actions, registry.events);
|
|
@@ -5094,22 +5095,22 @@ function act() {
|
|
|
5094
5095
|
for (const lane of input.lanes) register_lane(lane, lanes);
|
|
5095
5096
|
return builder;
|
|
5096
5097
|
}, "withSlice"),
|
|
5097
|
-
withProjection: /* @__PURE__ */
|
|
5098
|
+
withProjection: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (proj) => {
|
|
5098
5099
|
if (_built) closed("withProjection");
|
|
5099
5100
|
add_projection(proj);
|
|
5100
5101
|
return builder;
|
|
5101
5102
|
}, "withProjection"),
|
|
5102
|
-
withActor: /* @__PURE__ */
|
|
5103
|
-
withLane: /* @__PURE__ */
|
|
5103
|
+
withActor: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => builder, "withActor"),
|
|
5104
|
+
withLane: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (config2) => {
|
|
5104
5105
|
if (_built) closed("withLane");
|
|
5105
5106
|
register_lane(config2, lanes);
|
|
5106
5107
|
return builder;
|
|
5107
5108
|
}, "withLane"),
|
|
5108
|
-
on: /* @__PURE__ */
|
|
5109
|
+
on: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (event) => {
|
|
5109
5110
|
if (_built) closed("on");
|
|
5110
5111
|
return reaction_on(event, registry.events, builder);
|
|
5111
5112
|
}, "on"),
|
|
5112
|
-
build: /* @__PURE__ */
|
|
5113
|
+
build: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (options) => {
|
|
5113
5114
|
if (!_built) {
|
|
5114
5115
|
for (const proj of pending_projections) add_projection(proj);
|
|
5115
5116
|
for (const proj of fold_projections) {
|
|
@@ -5127,7 +5128,7 @@ function act() {
|
|
|
5127
5128
|
`State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
|
|
5128
5129
|
);
|
|
5129
5130
|
const claimed = fold_specs.find((s) => s.target === proj.target);
|
|
5130
|
-
if (_optionalChain([claimed, 'optionalAccess',
|
|
5131
|
+
if (_optionalChain([claimed, 'optionalAccess', _189 => _189.projection]) === proj) continue;
|
|
5131
5132
|
if (batch_handlers.has(proj.target) || claimed)
|
|
5132
5133
|
throw new Error(
|
|
5133
5134
|
`Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
|
|
@@ -5149,7 +5150,7 @@ function act() {
|
|
|
5149
5150
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
5150
5151
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
5151
5152
|
finalize_deprecations();
|
|
5152
|
-
if (built.advisory)
|
|
5153
|
+
if (built.advisory) _chunk3WHD4VPPcjs.log.call(void 0, ).warn(built.advisory);
|
|
5153
5154
|
for (const [name, state2] of states) {
|
|
5154
5155
|
if (!state2.loads) continue;
|
|
5155
5156
|
const resolved = {};
|
|
@@ -5161,7 +5162,7 @@ function act() {
|
|
|
5161
5162
|
`Action "${action2}" loads "${l.state.name}", which is not registered \u2014 add it via withState/withSlice before build()`
|
|
5162
5163
|
);
|
|
5163
5164
|
const deprecated = l.events.find(
|
|
5164
|
-
(e) => _optionalChain([_de, 'access',
|
|
5165
|
+
(e) => _optionalChain([_de, 'access', _190 => _190.get, 'call', _191 => _191(registered.name), 'optionalAccess', _192 => _192.has, 'call', _193 => _193(e)])
|
|
5165
5166
|
);
|
|
5166
5167
|
if (deprecated)
|
|
5167
5168
|
throw new Error(
|
|
@@ -5193,7 +5194,7 @@ function act() {
|
|
|
5193
5194
|
synthesize_autoclose_reactions(
|
|
5194
5195
|
registry,
|
|
5195
5196
|
states,
|
|
5196
|
-
|
|
5197
|
+
_chunk3WHD4VPPcjs.current_autoclose_window
|
|
5197
5198
|
);
|
|
5198
5199
|
Object.freeze(registry.actions);
|
|
5199
5200
|
Object.freeze(registry.events);
|
|
@@ -5212,14 +5213,14 @@ function act() {
|
|
|
5212
5213
|
};
|
|
5213
5214
|
return builder;
|
|
5214
5215
|
}
|
|
5215
|
-
|
|
5216
|
+
_chunkLA2BPKNScjs.__name.call(void 0, act, "act");
|
|
5216
5217
|
|
|
5217
5218
|
// src/builders/projection-builder.ts
|
|
5218
5219
|
function _projection(target) {
|
|
5219
5220
|
const events = {};
|
|
5220
5221
|
const default_resolver = typeof target === "string" ? { target } : void 0;
|
|
5221
5222
|
const base = {
|
|
5222
|
-
on: /* @__PURE__ */
|
|
5223
|
+
on: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (entry) => {
|
|
5223
5224
|
const keys = Object.keys(entry);
|
|
5224
5225
|
if (keys.length !== 1) throw new Error(".on() requires exactly one key");
|
|
5225
5226
|
const event = keys[0];
|
|
@@ -5231,7 +5232,7 @@ function _projection(target) {
|
|
|
5231
5232
|
};
|
|
5232
5233
|
}
|
|
5233
5234
|
return {
|
|
5234
|
-
do: /* @__PURE__ */
|
|
5235
|
+
do: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (handler) => {
|
|
5235
5236
|
const widened = base;
|
|
5236
5237
|
return add_reaction(
|
|
5237
5238
|
events,
|
|
@@ -5242,8 +5243,8 @@ function _projection(target) {
|
|
|
5242
5243
|
handler,
|
|
5243
5244
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5244
5245
|
options: {
|
|
5245
|
-
blockOnError:
|
|
5246
|
-
maxRetries:
|
|
5246
|
+
blockOnError: _chunk3WHD4VPPcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5247
|
+
maxRetries: _chunk3WHD4VPPcjs.DEFAULT_MAX_RETRIES
|
|
5247
5248
|
}
|
|
5248
5249
|
}),
|
|
5249
5250
|
widened
|
|
@@ -5251,7 +5252,7 @@ function _projection(target) {
|
|
|
5251
5252
|
}, "do")
|
|
5252
5253
|
};
|
|
5253
5254
|
}, "on"),
|
|
5254
|
-
build: /* @__PURE__ */
|
|
5255
|
+
build: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => ({
|
|
5255
5256
|
_tag: "Projection",
|
|
5256
5257
|
events,
|
|
5257
5258
|
...target !== void 0 && { target }
|
|
@@ -5260,20 +5261,20 @@ function _projection(target) {
|
|
|
5260
5261
|
};
|
|
5261
5262
|
if (typeof target === "string") {
|
|
5262
5263
|
return Object.assign(base, {
|
|
5263
|
-
batch: /* @__PURE__ */
|
|
5264
|
-
build: /* @__PURE__ */
|
|
5264
|
+
batch: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (handler) => ({
|
|
5265
|
+
build: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => ({
|
|
5265
5266
|
_tag: "Projection",
|
|
5266
5267
|
events,
|
|
5267
5268
|
target,
|
|
5268
5269
|
batchHandler: handler
|
|
5269
5270
|
}), "build")
|
|
5270
5271
|
}), "batch"),
|
|
5271
|
-
of: /* @__PURE__ */
|
|
5272
|
+
of: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (...args) => {
|
|
5272
5273
|
if (Object.keys(events).length > 0)
|
|
5273
5274
|
throw new Error(
|
|
5274
5275
|
`Projection "${target}" mixes .of() with .on() handlers \u2014 a projection either folds a state or declares handlers, never both`
|
|
5275
5276
|
);
|
|
5276
|
-
const is_state = /* @__PURE__ */
|
|
5277
|
+
const is_state = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (a) => !!a && typeof a.init === "function", "is_state");
|
|
5277
5278
|
const partials = args.filter(is_state);
|
|
5278
5279
|
const options = _nullishCoalesce(args.find((a) => !is_state(a)), () => ( {}));
|
|
5279
5280
|
if (partials.length === 0)
|
|
@@ -5284,7 +5285,7 @@ function _projection(target) {
|
|
|
5284
5285
|
throw new Error(
|
|
5285
5286
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5286
5287
|
);
|
|
5287
|
-
const config2 =
|
|
5288
|
+
const config2 = _chunk3WHD4VPPcjs.check.call(void 0, "fold", options);
|
|
5288
5289
|
const fold_events = {};
|
|
5289
5290
|
for (const partial of partials)
|
|
5290
5291
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5302,8 +5303,8 @@ function _projection(target) {
|
|
|
5302
5303
|
handler: noop,
|
|
5303
5304
|
resolver: { target },
|
|
5304
5305
|
options: {
|
|
5305
|
-
blockOnError:
|
|
5306
|
-
maxRetries:
|
|
5306
|
+
blockOnError: _chunk3WHD4VPPcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5307
|
+
maxRetries: _chunk3WHD4VPPcjs.DEFAULT_MAX_RETRIES
|
|
5307
5308
|
}
|
|
5308
5309
|
}
|
|
5309
5310
|
]
|
|
@@ -5311,8 +5312,8 @@ function _projection(target) {
|
|
|
5311
5312
|
};
|
|
5312
5313
|
}
|
|
5313
5314
|
return {
|
|
5314
|
-
flush: /* @__PURE__ */
|
|
5315
|
-
build: /* @__PURE__ */
|
|
5315
|
+
flush: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (handler) => ({
|
|
5316
|
+
build: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => ({
|
|
5316
5317
|
_tag: "Projection",
|
|
5317
5318
|
events: fold_events,
|
|
5318
5319
|
target,
|
|
@@ -5325,11 +5326,11 @@ function _projection(target) {
|
|
|
5325
5326
|
}
|
|
5326
5327
|
return base;
|
|
5327
5328
|
}
|
|
5328
|
-
|
|
5329
|
+
_chunkLA2BPKNScjs.__name.call(void 0, _projection, "_projection");
|
|
5329
5330
|
function projection(target) {
|
|
5330
5331
|
return _projection(target);
|
|
5331
5332
|
}
|
|
5332
|
-
|
|
5333
|
+
_chunkLA2BPKNScjs.__name.call(void 0, projection, "projection");
|
|
5333
5334
|
|
|
5334
5335
|
// src/builders/slice-builder.ts
|
|
5335
5336
|
function slice() {
|
|
@@ -5339,20 +5340,20 @@ function slice() {
|
|
|
5339
5340
|
const projections = [];
|
|
5340
5341
|
const lanes = [];
|
|
5341
5342
|
const builder = {
|
|
5342
|
-
withState: /* @__PURE__ */
|
|
5343
|
+
withState: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (state2) => {
|
|
5343
5344
|
register_state(state2, states, actions, events);
|
|
5344
5345
|
return builder;
|
|
5345
5346
|
}, "withState"),
|
|
5346
|
-
withProjection: /* @__PURE__ */
|
|
5347
|
+
withProjection: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (proj) => {
|
|
5347
5348
|
projections.push(proj);
|
|
5348
5349
|
return builder;
|
|
5349
5350
|
}, "withProjection"),
|
|
5350
|
-
withLane: /* @__PURE__ */
|
|
5351
|
+
withLane: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (config2) => {
|
|
5351
5352
|
register_lane(config2, lanes);
|
|
5352
5353
|
return builder;
|
|
5353
5354
|
}, "withLane"),
|
|
5354
|
-
on: /* @__PURE__ */
|
|
5355
|
-
build: /* @__PURE__ */
|
|
5355
|
+
on: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (event) => reaction_on(event, events, builder), "on"),
|
|
5356
|
+
build: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, () => ({
|
|
5356
5357
|
_tag: "Slice",
|
|
5357
5358
|
states,
|
|
5358
5359
|
events,
|
|
@@ -5363,7 +5364,7 @@ function slice() {
|
|
|
5363
5364
|
};
|
|
5364
5365
|
return builder;
|
|
5365
5366
|
}
|
|
5366
|
-
|
|
5367
|
+
_chunkLA2BPKNScjs.__name.call(void 0, slice, "slice");
|
|
5367
5368
|
|
|
5368
5369
|
// src/builders/state-builder.ts
|
|
5369
5370
|
function state(entry) {
|
|
@@ -5395,8 +5396,8 @@ function state(entry) {
|
|
|
5395
5396
|
// `act().build()` flips both on states with `sensitive(...)`
|
|
5396
5397
|
// events to bake in the gate / split and gate the cache write.
|
|
5397
5398
|
pii_aware: false,
|
|
5398
|
-
view: /* @__PURE__ */
|
|
5399
|
-
message: /* @__PURE__ */
|
|
5399
|
+
view: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (event) => event, "view"),
|
|
5400
|
+
message: /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (validated) => validated, "message")
|
|
5400
5401
|
};
|
|
5401
5402
|
const builder = action_builder(internal);
|
|
5402
5403
|
return Object.assign(builder, {
|
|
@@ -5410,7 +5411,7 @@ function state(entry) {
|
|
|
5410
5411
|
}
|
|
5411
5412
|
};
|
|
5412
5413
|
}
|
|
5413
|
-
|
|
5414
|
+
_chunkLA2BPKNScjs.__name.call(void 0, state, "state");
|
|
5414
5415
|
function action_builder(state2) {
|
|
5415
5416
|
const internal = state2;
|
|
5416
5417
|
const builder = {
|
|
@@ -5423,7 +5424,7 @@ function action_builder(state2) {
|
|
|
5423
5424
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5424
5425
|
internal.actions[action2] = schema;
|
|
5425
5426
|
if (options) {
|
|
5426
|
-
|
|
5427
|
+
_chunk3WHD4VPPcjs.check.call(void 0, "action", options);
|
|
5427
5428
|
internal.options ??= {};
|
|
5428
5429
|
internal.options[action2] = options;
|
|
5429
5430
|
}
|
|
@@ -5447,12 +5448,12 @@ function action_builder(state2) {
|
|
|
5447
5448
|
(internal.loads ??= {})[action2] = loads;
|
|
5448
5449
|
return { loads: load2, requires, emit };
|
|
5449
5450
|
}
|
|
5450
|
-
|
|
5451
|
+
_chunkLA2BPKNScjs.__name.call(void 0, load2, "load");
|
|
5451
5452
|
function requires(rules) {
|
|
5452
5453
|
(internal.requires ??= {})[action2] = rules;
|
|
5453
5454
|
return { emit };
|
|
5454
5455
|
}
|
|
5455
|
-
|
|
5456
|
+
_chunkLA2BPKNScjs.__name.call(void 0, requires, "requires");
|
|
5456
5457
|
function emit(handler) {
|
|
5457
5458
|
if (typeof handler === "string") {
|
|
5458
5459
|
const event_name = handler;
|
|
@@ -5468,7 +5469,7 @@ function action_builder(state2) {
|
|
|
5468
5469
|
}
|
|
5469
5470
|
return builder;
|
|
5470
5471
|
}
|
|
5471
|
-
|
|
5472
|
+
_chunkLA2BPKNScjs.__name.call(void 0, emit, "emit");
|
|
5472
5473
|
return { loads: load2, requires, emit };
|
|
5473
5474
|
},
|
|
5474
5475
|
snap(snap2) {
|
|
@@ -5519,7 +5520,7 @@ function action_builder(state2) {
|
|
|
5519
5520
|
};
|
|
5520
5521
|
return builder;
|
|
5521
5522
|
}
|
|
5522
|
-
|
|
5523
|
+
_chunkLA2BPKNScjs.__name.call(void 0, action_builder, "action_builder");
|
|
5523
5524
|
|
|
5524
5525
|
// src/csv.ts
|
|
5525
5526
|
var _fs = require('fs');
|
|
@@ -5535,7 +5536,7 @@ var CSV_COLUMNS = [
|
|
|
5535
5536
|
];
|
|
5536
5537
|
var CsvFile = class {
|
|
5537
5538
|
static {
|
|
5538
|
-
|
|
5539
|
+
_chunkLA2BPKNScjs.__name.call(void 0, this, "CsvFile");
|
|
5539
5540
|
}
|
|
5540
5541
|
|
|
5541
5542
|
|
|
@@ -5630,7 +5631,7 @@ async function* linesFromFile(path) {
|
|
|
5630
5631
|
stream.close();
|
|
5631
5632
|
}
|
|
5632
5633
|
}
|
|
5633
|
-
|
|
5634
|
+
_chunkLA2BPKNScjs.__name.call(void 0, linesFromFile, "linesFromFile");
|
|
5634
5635
|
async function* linesFromBlob(blob) {
|
|
5635
5636
|
let start = 0;
|
|
5636
5637
|
while (start < blob.length) {
|
|
@@ -5641,7 +5642,7 @@ async function* linesFromBlob(blob) {
|
|
|
5641
5642
|
await Promise.resolve();
|
|
5642
5643
|
}
|
|
5643
5644
|
}
|
|
5644
|
-
|
|
5645
|
+
_chunkLA2BPKNScjs.__name.call(void 0, linesFromBlob, "linesFromBlob");
|
|
5645
5646
|
function parse_csv_line(line) {
|
|
5646
5647
|
const fields = [];
|
|
5647
5648
|
let i = 0;
|
|
@@ -5675,12 +5676,12 @@ function parse_csv_line(line) {
|
|
|
5675
5676
|
}
|
|
5676
5677
|
return fields;
|
|
5677
5678
|
}
|
|
5678
|
-
|
|
5679
|
+
_chunkLA2BPKNScjs.__name.call(void 0, parse_csv_line, "parse_csv_line");
|
|
5679
5680
|
function csv_escape(value) {
|
|
5680
5681
|
if (/[",\n\r]/.test(value)) return `"${value.replace(/"/g, '""')}"`;
|
|
5681
5682
|
return value;
|
|
5682
5683
|
}
|
|
5683
|
-
|
|
5684
|
+
_chunkLA2BPKNScjs.__name.call(void 0, csv_escape, "csv_escape");
|
|
5684
5685
|
function write_line(writer, line) {
|
|
5685
5686
|
return new Promise((resolve, reject) => {
|
|
5686
5687
|
writer.write(`${line}
|
|
@@ -5690,38 +5691,38 @@ function write_line(writer, line) {
|
|
|
5690
5691
|
});
|
|
5691
5692
|
});
|
|
5692
5693
|
}
|
|
5693
|
-
|
|
5694
|
+
_chunkLA2BPKNScjs.__name.call(void 0, write_line, "write_line");
|
|
5694
5695
|
|
|
5695
5696
|
// src/deprecated.ts
|
|
5696
|
-
var check_appends =
|
|
5697
|
-
var throw_if_stale =
|
|
5698
|
-
var concurrency_error =
|
|
5699
|
-
var seed_event =
|
|
5700
|
-
var fair_slots =
|
|
5701
|
-
var is_literal_source =
|
|
5702
|
-
var notification_of =
|
|
5703
|
-
var DEFAULT_QUERY_STREAMS_LIMIT2 =
|
|
5704
|
-
var ActorSchema2 =
|
|
5705
|
-
var TargetSchema2 =
|
|
5706
|
-
var EventMetaSchema2 =
|
|
5707
|
-
var CausationEventSchema2 =
|
|
5708
|
-
var CommittedMetaSchema2 =
|
|
5709
|
-
var QuerySchema2 =
|
|
5710
|
-
var Environments2 =
|
|
5711
|
-
var LogLevels2 =
|
|
5712
|
-
var ExitCodes2 =
|
|
5713
|
-
var DEFAULT_LANE2 =
|
|
5714
|
-
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 =
|
|
5715
|
-
var DEFAULT_SETTLE_DEBOUNCE_MS2 =
|
|
5716
|
-
var PackageSchema =
|
|
5717
|
-
var default_scope =
|
|
5718
|
-
var extend = /* @__PURE__ */
|
|
5697
|
+
var check_appends = _chunkQITJ63HGcjs.checkAppends;
|
|
5698
|
+
var throw_if_stale = _chunkQITJ63HGcjs.checkVersion;
|
|
5699
|
+
var concurrency_error = _chunkQITJ63HGcjs.concurrencyError;
|
|
5700
|
+
var seed_event = _chunkQITJ63HGcjs.seedEvent;
|
|
5701
|
+
var fair_slots = _chunkQITJ63HGcjs.fairSlots;
|
|
5702
|
+
var is_literal_source = _chunkQITJ63HGcjs.isStreamName;
|
|
5703
|
+
var notification_of = _chunkQITJ63HGcjs.parseNotification;
|
|
5704
|
+
var DEFAULT_QUERY_STREAMS_LIMIT2 = _chunkLA2BPKNScjs.DEFAULT_QUERY_STREAMS_LIMIT;
|
|
5705
|
+
var ActorSchema2 = _chunkLA2BPKNScjs.ActorSchema;
|
|
5706
|
+
var TargetSchema2 = _chunkLA2BPKNScjs.TargetSchema;
|
|
5707
|
+
var EventMetaSchema2 = _chunkLA2BPKNScjs.EventMetaSchema;
|
|
5708
|
+
var CausationEventSchema2 = _chunkLA2BPKNScjs.CausationEventSchema;
|
|
5709
|
+
var CommittedMetaSchema2 = _chunkLA2BPKNScjs.CommittedMetaSchema;
|
|
5710
|
+
var QuerySchema2 = _chunkLA2BPKNScjs.QuerySchema;
|
|
5711
|
+
var Environments2 = _chunkLA2BPKNScjs.Environments;
|
|
5712
|
+
var LogLevels2 = _chunkLA2BPKNScjs.LogLevels;
|
|
5713
|
+
var ExitCodes2 = _chunkLA2BPKNScjs.ExitCodes;
|
|
5714
|
+
var DEFAULT_LANE2 = _chunkLA2BPKNScjs.DEFAULT_LANE;
|
|
5715
|
+
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkLA2BPKNScjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5716
|
+
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkLA2BPKNScjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5717
|
+
var PackageSchema = _chunk3WHD4VPPcjs.package_schema;
|
|
5718
|
+
var default_scope = _chunk3WHD4VPPcjs.unscoped_ports;
|
|
5719
|
+
var extend = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (source, schema, target) => ({ ...target, ..._chunk3WHD4VPPcjs.validate.call(void 0, "config", source, schema) }), "extend");
|
|
5719
5720
|
var ISO_8601 = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d+)?(Z|[+-][0-2][0-9]:[0-5][0-9])?$/;
|
|
5720
|
-
var dateReviver = /* @__PURE__ */
|
|
5721
|
+
var dateReviver = /* @__PURE__ */ _chunkLA2BPKNScjs.__name.call(void 0, (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
|
|
5721
5722
|
function sensitiveFields(schema) {
|
|
5722
5723
|
return Object.keys(pii_schemas(schema));
|
|
5723
5724
|
}
|
|
5724
|
-
|
|
5725
|
+
_chunkLA2BPKNScjs.__name.call(void 0, sensitiveFields, "sensitiveFields");
|
|
5725
5726
|
var pii_fields = sensitiveFields;
|
|
5726
5727
|
|
|
5727
5728
|
|
|
@@ -5782,5 +5783,5 @@ var pii_fields = sensitiveFields;
|
|
|
5782
5783
|
|
|
5783
5784
|
|
|
5784
5785
|
|
|
5785
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError =
|
|
5786
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkLA2BPKNScjs.ConcurrencyError; exports.ConsoleLogger = _chunk3WHD4VPPcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = DEFAULT_LANE2; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = DEFAULT_MAX_SUBSCRIBED_STREAMS2; exports.DEFAULT_QUERY_STREAMS_LIMIT = DEFAULT_QUERY_STREAMS_LIMIT2; exports.DEFAULT_SETTLE_DEBOUNCE_MS = DEFAULT_SETTLE_DEBOUNCE_MS2; exports.DeferSignal = _chunkLA2BPKNScjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunkLA2BPKNScjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunk3WHD4VPPcjs.InMemoryCache; exports.InMemoryStore = _chunk3WHD4VPPcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunkLA2BPKNScjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunkLA2BPKNScjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunkLA2BPKNScjs.REDACTED; exports.SHREDDED = _chunkLA2BPKNScjs.SHREDDED; exports.SNAP_EVENT = _chunkLA2BPKNScjs.SNAP_EVENT; exports.StoreError = _chunkLA2BPKNScjs.StoreError; exports.StreamClosedError = _chunkLA2BPKNScjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkLA2BPKNScjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunkLA2BPKNScjs.ValidationError; exports.ZodEmpty = _chunkLA2BPKNScjs.ZodEmpty; exports.act = act; exports.cache = _chunk3WHD4VPPcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunk3WHD4VPPcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunk3WHD4VPPcjs.dispose; exports.disposeAndExit = _chunk3WHD4VPPcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunk3WHD4VPPcjs.log; exports.notification_of = notification_of; exports.pii_fields = pii_fields; exports.port = _chunk3WHD4VPPcjs.port; exports.projection = projection; exports.seed_event = seed_event; exports.sensitive = _chunkLA2BPKNScjs.sensitive; exports.sensitiveFields = sensitiveFields; exports.sleep = _chunk3WHD4VPPcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunk3WHD4VPPcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunk3WHD4VPPcjs.validate;
|
|
5786
5787
|
//# sourceMappingURL=index.cjs.map
|