@rotorsoft/act 2.1.12 → 2.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/ports.d.ts +0 -5
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +1 -1
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.js +2 -2
- package/dist/{chunk-BQUOIHOR.js → chunk-FYI7O7W6.js} +38 -6
- package/dist/{chunk-BQUOIHOR.js.map → chunk-FYI7O7W6.js.map} +1 -1
- package/dist/{chunk-RV34EYSN.js → chunk-MWLATJDX.js} +11 -3
- package/dist/{chunk-RV34EYSN.js.map → chunk-MWLATJDX.js.map} +1 -1
- package/dist/{chunk-N74AN6L5.cjs → chunk-OW67FBYO.cjs} +83 -55
- package/dist/chunk-OW67FBYO.cjs.map +1 -0
- package/dist/{chunk-SC6TY4P2.cjs → chunk-PDMLWC77.cjs} +12 -4
- package/dist/chunk-PDMLWC77.cjs.map +1 -0
- package/dist/{chunk-ZTHGF62O.cjs → chunk-QSXWCJ2U.cjs} +40 -8
- package/dist/chunk-QSXWCJ2U.cjs.map +1 -0
- package/dist/{chunk-Y2ISPWQL.js → chunk-R5PT4AYJ.js} +70 -42
- package/dist/{chunk-Y2ISPWQL.js.map → chunk-R5PT4AYJ.js.map} +1 -1
- package/dist/index.cjs +505 -365
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +324 -184
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +13 -9
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +11 -7
- package/dist/test/index.js.map +1 -1
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-N74AN6L5.cjs.map +0 -1
- package/dist/chunk-SC6TY4P2.cjs.map +0 -1
- package/dist/chunk-ZTHGF62O.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkOW67FBYOcjs = require('./chunk-OW67FBYO.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ var _chunkN74AN6L5cjs = require('./chunk-N74AN6L5.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunkPDMLWC77cjs = require('./chunk-PDMLWC77.cjs');
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -71,24 +71,27 @@ var _chunkSC6TY4P2cjs = require('./chunk-SC6TY4P2.cjs');
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
var _chunkQSXWCJ2Ucjs = require('./chunk-QSXWCJ2U.cjs');
|
|
75
76
|
|
|
76
77
|
// src/signals.ts
|
|
77
78
|
process.once("SIGINT", async (arg) => {
|
|
78
|
-
|
|
79
|
-
await
|
|
79
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).info(arg, "SIGINT");
|
|
80
|
+
await _chunkOW67FBYOcjs.disposeAndExit.call(void 0, "EXIT");
|
|
80
81
|
});
|
|
81
82
|
process.once("SIGTERM", async (arg) => {
|
|
82
|
-
|
|
83
|
-
await
|
|
83
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).info(arg, "SIGTERM");
|
|
84
|
+
await _chunkOW67FBYOcjs.disposeAndExit.call(void 0, "EXIT");
|
|
84
85
|
});
|
|
85
86
|
process.once("uncaughtException", async (arg) => {
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
|
|
89
|
+
await _chunkOW67FBYOcjs.disposeAndExit.call(void 0, "ERROR");
|
|
88
90
|
});
|
|
89
91
|
process.once("unhandledRejection", async (arg) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
process.exitCode = 1;
|
|
93
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
|
|
94
|
+
await _chunkOW67FBYOcjs.disposeAndExit.call(void 0, "ERROR");
|
|
92
95
|
});
|
|
93
96
|
|
|
94
97
|
// src/act.ts
|
|
@@ -104,6 +107,7 @@ function parse(name) {
|
|
|
104
107
|
}
|
|
105
108
|
return { base: name, version: 1 };
|
|
106
109
|
}
|
|
110
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, parse, "parse");
|
|
107
111
|
function deprecated_event_names(names) {
|
|
108
112
|
const groups = /* @__PURE__ */ new Map();
|
|
109
113
|
for (const name of names) {
|
|
@@ -129,6 +133,7 @@ function deprecated_event_names(names) {
|
|
|
129
133
|
}
|
|
130
134
|
return deprecated;
|
|
131
135
|
}
|
|
136
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, deprecated_event_names, "deprecated_event_names");
|
|
132
137
|
function current_version_of(deprecated_name, all_names) {
|
|
133
138
|
const target = parse(deprecated_name);
|
|
134
139
|
let highest;
|
|
@@ -139,6 +144,7 @@ function current_version_of(deprecated_name, all_names) {
|
|
|
139
144
|
}
|
|
140
145
|
return highest && highest.version > target.version ? highest.name : void 0;
|
|
141
146
|
}
|
|
147
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, current_version_of, "current_version_of");
|
|
142
148
|
|
|
143
149
|
// src/internal/walk-streams.ts
|
|
144
150
|
var DEFAULT_STREAM_PAGE = 500;
|
|
@@ -160,6 +166,7 @@ async function walk_streams(store2, callback, query) {
|
|
|
160
166
|
after = last;
|
|
161
167
|
}
|
|
162
168
|
}
|
|
169
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, walk_streams, "walk_streams");
|
|
163
170
|
|
|
164
171
|
// src/internal/audit.ts
|
|
165
172
|
var DEFAULTS = {
|
|
@@ -196,7 +203,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
196
203
|
if (need_stats) {
|
|
197
204
|
const stats = await deps.store().query_stats(
|
|
198
205
|
{},
|
|
199
|
-
{ count: true, names: true, exclude: [
|
|
206
|
+
{ count: true, names: true, exclude: [_chunkQSXWCJ2Ucjs.SNAP_EVENT] }
|
|
200
207
|
);
|
|
201
208
|
for (const [stream, s] of stats) {
|
|
202
209
|
for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
|
|
@@ -224,6 +231,7 @@ async function* audit(deps, categories, options = {}) {
|
|
|
224
231
|
for (const f of p.drain()) yield f;
|
|
225
232
|
}
|
|
226
233
|
}
|
|
234
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, audit, "audit");
|
|
227
235
|
async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
|
|
228
236
|
let cursor = _optionalChain([query, 'optionalAccess', _14 => _14.after]);
|
|
229
237
|
let remaining = _optionalChain([query, 'optionalAccess', _15 => _15.limit]);
|
|
@@ -259,7 +267,8 @@ async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
|
|
|
259
267
|
}
|
|
260
268
|
}
|
|
261
269
|
}
|
|
262
|
-
|
|
270
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, scan_events_resiliently, "scan_events_resiliently");
|
|
271
|
+
var make_schema_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps) => {
|
|
263
272
|
const findings = [];
|
|
264
273
|
return {
|
|
265
274
|
category: "schema",
|
|
@@ -278,7 +287,7 @@ var make_schema_pass = (deps) => {
|
|
|
278
287
|
return;
|
|
279
288
|
}
|
|
280
289
|
const schema = state2.events[name];
|
|
281
|
-
const sensitive2 =
|
|
290
|
+
const sensitive2 = _chunkQSXWCJ2Ucjs.sensitiveFields.call(void 0, schema);
|
|
282
291
|
let parse_schema = schema;
|
|
283
292
|
if (sensitive2.length > 0) {
|
|
284
293
|
const omitter = schema.omit;
|
|
@@ -302,10 +311,10 @@ var make_schema_pass = (deps) => {
|
|
|
302
311
|
});
|
|
303
312
|
}
|
|
304
313
|
},
|
|
305
|
-
drain: () => findings
|
|
314
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
306
315
|
};
|
|
307
|
-
};
|
|
308
|
-
var classify_deprecated_by_state = (deps) => {
|
|
316
|
+
}, "make_schema_pass");
|
|
317
|
+
var classify_deprecated_by_state = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps) => {
|
|
309
318
|
const names_by_state = /* @__PURE__ */ new Map();
|
|
310
319
|
for (const [name, state2] of deps.event_to_state) {
|
|
311
320
|
let set = names_by_state.get(state2);
|
|
@@ -322,8 +331,8 @@ var classify_deprecated_by_state = (deps) => {
|
|
|
322
331
|
}
|
|
323
332
|
}
|
|
324
333
|
return deprecated_to_current;
|
|
325
|
-
};
|
|
326
|
-
var make_deprecated_load_pass = (deps, options) => {
|
|
334
|
+
}, "classify_deprecated_by_state");
|
|
335
|
+
var make_deprecated_load_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps, options) => {
|
|
327
336
|
const share_min = _nullishCoalesce(_optionalChain([options, 'access', _17 => _17.thresholds, 'optionalAccess', _18 => _18.deprecated_min]), () => ( DEFAULTS.deprecated_min));
|
|
328
337
|
const totals = /* @__PURE__ */ new Map();
|
|
329
338
|
const per_stream = /* @__PURE__ */ new Map();
|
|
@@ -362,8 +371,8 @@ var make_deprecated_load_pass = (deps, options) => {
|
|
|
362
371
|
return findings;
|
|
363
372
|
}
|
|
364
373
|
};
|
|
365
|
-
};
|
|
366
|
-
var make_close_candidate_pass = (deps, options) => {
|
|
374
|
+
}, "make_deprecated_load_pass");
|
|
375
|
+
var make_close_candidate_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps, options) => {
|
|
367
376
|
const idle_days = _nullishCoalesce(_optionalChain([options, 'access', _19 => _19.thresholds, 'optionalAccess', _20 => _20.idle_days]), () => ( DEFAULTS.idle_days));
|
|
368
377
|
const terminal_events = new Set(_nullishCoalesce(_optionalChain([options, 'access', _21 => _21.thresholds, 'optionalAccess', _22 => _22.terminal_events]), () => ( [])));
|
|
369
378
|
const idle_cutoff = Date.now() - idle_days * 24 * 60 * 60 * 1e3;
|
|
@@ -386,10 +395,10 @@ var make_close_candidate_pass = (deps, options) => {
|
|
|
386
395
|
restart_supported: restart_is_supported(deps, head_name)
|
|
387
396
|
});
|
|
388
397
|
},
|
|
389
|
-
drain: () => findings
|
|
398
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
390
399
|
};
|
|
391
|
-
};
|
|
392
|
-
var make_restart_candidate_pass = (deps, options) => {
|
|
400
|
+
}, "make_close_candidate_pass");
|
|
401
|
+
var make_restart_candidate_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps, options) => {
|
|
393
402
|
const threshold = _nullishCoalesce(_optionalChain([options, 'access', _23 => _23.thresholds, 'optionalAccess', _24 => _24.restart_min]), () => ( DEFAULTS.restart_min));
|
|
394
403
|
const candidates = [];
|
|
395
404
|
const findings = [];
|
|
@@ -412,7 +421,7 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
412
421
|
{
|
|
413
422
|
stream,
|
|
414
423
|
stream_exact: true,
|
|
415
|
-
names: [
|
|
424
|
+
names: [_chunkQSXWCJ2Ucjs.SNAP_EVENT],
|
|
416
425
|
with_snaps: true,
|
|
417
426
|
// From the start: on its own, `with_snaps` resumes at the latest.
|
|
418
427
|
after: -1
|
|
@@ -426,10 +435,10 @@ var make_restart_candidate_pass = (deps, options) => {
|
|
|
426
435
|
});
|
|
427
436
|
}
|
|
428
437
|
},
|
|
429
|
-
drain: () => findings
|
|
438
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
430
439
|
};
|
|
431
|
-
};
|
|
432
|
-
var make_reaction_health_pass = (_deps, options) => {
|
|
440
|
+
}, "make_restart_candidate_pass");
|
|
441
|
+
var make_reaction_health_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (_deps, options) => {
|
|
433
442
|
const near_block = _nullishCoalesce(_optionalChain([options, 'access', _25 => _25.thresholds, 'optionalAccess', _26 => _26.near_block]), () => ( DEFAULTS.near_block));
|
|
434
443
|
const stuck_minutes = _nullishCoalesce(_optionalChain([options, 'access', _27 => _27.thresholds, 'optionalAccess', _28 => _28.stuck_minutes]), () => ( DEFAULTS.stuck_minutes));
|
|
435
444
|
const stuck_cutoff = Date.now() - stuck_minutes * 60 * 1e3;
|
|
@@ -470,10 +479,10 @@ var make_reaction_health_pass = (_deps, options) => {
|
|
|
470
479
|
});
|
|
471
480
|
}
|
|
472
481
|
},
|
|
473
|
-
drain: () => findings
|
|
482
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
474
483
|
};
|
|
475
|
-
};
|
|
476
|
-
var make_snapshot_drift_pass = (deps, options) => {
|
|
484
|
+
}, "make_reaction_health_pass");
|
|
485
|
+
var make_snapshot_drift_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps, options) => {
|
|
477
486
|
const drift_min = _nullishCoalesce(_optionalChain([options, 'access', _29 => _29.thresholds, 'optionalAccess', _30 => _30.drift_min]), () => ( DEFAULTS.drift_min));
|
|
478
487
|
const candidates = [];
|
|
479
488
|
const findings = [];
|
|
@@ -525,10 +534,10 @@ var make_snapshot_drift_pass = (deps, options) => {
|
|
|
525
534
|
});
|
|
526
535
|
}
|
|
527
536
|
},
|
|
528
|
-
drain: () => findings
|
|
537
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
529
538
|
};
|
|
530
|
-
};
|
|
531
|
-
var make_routing_health_pass = (deps) => {
|
|
539
|
+
}, "make_snapshot_drift_pass");
|
|
540
|
+
var make_routing_health_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (deps) => {
|
|
532
541
|
const findings = [];
|
|
533
542
|
const seen_event_names = /* @__PURE__ */ new Set();
|
|
534
543
|
return {
|
|
@@ -560,10 +569,10 @@ var make_routing_health_pass = (deps) => {
|
|
|
560
569
|
}
|
|
561
570
|
return Promise.resolve();
|
|
562
571
|
},
|
|
563
|
-
drain: () => findings
|
|
572
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
564
573
|
};
|
|
565
|
-
};
|
|
566
|
-
var make_correlation_gaps_pass = () => {
|
|
574
|
+
}, "make_routing_health_pass");
|
|
575
|
+
var make_correlation_gaps_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => {
|
|
567
576
|
const seen_ids = /* @__PURE__ */ new Set();
|
|
568
577
|
const checks = [];
|
|
569
578
|
return {
|
|
@@ -572,7 +581,7 @@ var make_correlation_gaps_pass = () => {
|
|
|
572
581
|
seen_ids.add(e.id);
|
|
573
582
|
const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
|
|
574
583
|
const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
|
|
575
|
-
if (parent_id !== void 0 && e.name !==
|
|
584
|
+
if (parent_id !== void 0 && e.name !== _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT) {
|
|
576
585
|
checks.push({ stream: e.stream, id: e.id, parent_id });
|
|
577
586
|
}
|
|
578
587
|
},
|
|
@@ -591,8 +600,8 @@ var make_correlation_gaps_pass = () => {
|
|
|
591
600
|
return findings;
|
|
592
601
|
}
|
|
593
602
|
};
|
|
594
|
-
};
|
|
595
|
-
var make_clock_anomalies_pass = () => {
|
|
603
|
+
}, "make_correlation_gaps_pass");
|
|
604
|
+
var make_clock_anomalies_pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => {
|
|
596
605
|
const findings = [];
|
|
597
606
|
const last_per_stream = /* @__PURE__ */ new Map();
|
|
598
607
|
return {
|
|
@@ -618,13 +627,14 @@ var make_clock_anomalies_pass = () => {
|
|
|
618
627
|
}
|
|
619
628
|
last_per_stream.set(e.stream, created);
|
|
620
629
|
},
|
|
621
|
-
drain: () => findings
|
|
630
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
622
631
|
};
|
|
623
|
-
};
|
|
632
|
+
}, "make_clock_anomalies_pass");
|
|
624
633
|
function restart_is_supported(deps, head_event_name) {
|
|
625
634
|
const state2 = deps.event_to_state.get(head_event_name);
|
|
626
635
|
return _optionalChain([state2, 'optionalAccess', _35 => _35.snap]) !== void 0;
|
|
627
636
|
}
|
|
637
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, restart_is_supported, "restart_is_supported");
|
|
628
638
|
function make_unreadable_events_pass() {
|
|
629
639
|
const findings = [];
|
|
630
640
|
return {
|
|
@@ -638,9 +648,10 @@ function make_unreadable_events_pass() {
|
|
|
638
648
|
error
|
|
639
649
|
});
|
|
640
650
|
},
|
|
641
|
-
drain: () => findings
|
|
651
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => findings, "drain")
|
|
642
652
|
};
|
|
643
653
|
}
|
|
654
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, make_unreadable_events_pass, "make_unreadable_events_pass");
|
|
644
655
|
var PASS_FACTORIES = {
|
|
645
656
|
schema: make_schema_pass,
|
|
646
657
|
"deprecated-load": make_deprecated_load_pass,
|
|
@@ -656,6 +667,9 @@ var PASS_FACTORIES = {
|
|
|
656
667
|
|
|
657
668
|
// src/internal/circuit-breaker.ts
|
|
658
669
|
var CircuitBreaker = (_class = class {
|
|
670
|
+
static {
|
|
671
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "CircuitBreaker");
|
|
672
|
+
}
|
|
659
673
|
__init() {this._failures = 0}
|
|
660
674
|
|
|
661
675
|
|
|
@@ -747,7 +761,7 @@ var CircuitBreaker = (_class = class {
|
|
|
747
761
|
|
|
748
762
|
// src/internal/classify.ts
|
|
749
763
|
var ALL_LANES = /* @__PURE__ */ Symbol("act/all-lanes");
|
|
750
|
-
var describe_source = (source) => source === void 0 ? "no source (every stream)" : `"${source}"
|
|
764
|
+
var describe_source = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (source) => source === void 0 ? "no source (every stream)" : `"${source}"`, "describe_source");
|
|
751
765
|
function classify_registry(registry, states) {
|
|
752
766
|
const statics = /* @__PURE__ */ new Map();
|
|
753
767
|
const target_lanes = /* @__PURE__ */ new Map();
|
|
@@ -798,35 +812,43 @@ function classify_registry(registry, states) {
|
|
|
798
812
|
event_to_lanes
|
|
799
813
|
};
|
|
800
814
|
}
|
|
815
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, classify_registry, "classify_registry");
|
|
801
816
|
|
|
802
817
|
// src/internal/autoclose-policy.ts
|
|
803
818
|
var DAY_MS = 864e5;
|
|
804
819
|
function days_after(date, days) {
|
|
805
820
|
return new Date(date.getTime() + days * DAY_MS);
|
|
806
821
|
}
|
|
822
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, days_after, "days_after");
|
|
807
823
|
function days_before_now(days) {
|
|
808
824
|
return new Date(Date.now() - days * DAY_MS);
|
|
809
825
|
}
|
|
826
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, days_before_now, "days_before_now");
|
|
810
827
|
function compile_after(after) {
|
|
811
828
|
return (_stream, head) => days_after(head.created, after.days) <= /* @__PURE__ */ new Date();
|
|
812
829
|
}
|
|
830
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, compile_after, "compile_after");
|
|
813
831
|
function compile_is(is) {
|
|
814
832
|
const set = new Set(typeof is === "string" ? [is] : is);
|
|
815
833
|
return (_stream, head) => set.has(head.name);
|
|
816
834
|
}
|
|
835
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, compile_is, "compile_is");
|
|
817
836
|
function compile_reaches(reaches) {
|
|
818
837
|
return (_stream, _head, count) => count >= reaches;
|
|
819
838
|
}
|
|
839
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, compile_reaches, "compile_reaches");
|
|
820
840
|
function policy_after_windows(options) {
|
|
821
|
-
const parsed =
|
|
841
|
+
const parsed = _chunkOW67FBYOcjs.check.call(void 0, "autoclose_policy", options);
|
|
822
842
|
return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
|
|
823
843
|
}
|
|
844
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, policy_after_windows, "policy_after_windows");
|
|
824
845
|
function policy_keep_days(options) {
|
|
825
|
-
const parsed =
|
|
846
|
+
const parsed = _chunkOW67FBYOcjs.check.call(void 0, "autoclose_policy", options);
|
|
826
847
|
return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
|
|
827
848
|
}
|
|
849
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, policy_keep_days, "policy_keep_days");
|
|
828
850
|
function compile_autoclose_policy(options) {
|
|
829
|
-
const parsed =
|
|
851
|
+
const parsed = _chunkOW67FBYOcjs.check.call(void 0, "autoclose_policy", options);
|
|
830
852
|
const and_preds = [];
|
|
831
853
|
if (parsed.after) and_preds.push(compile_after(parsed.after));
|
|
832
854
|
if (parsed.is) and_preds.push(compile_is(parsed.is));
|
|
@@ -847,6 +869,7 @@ function compile_autoclose_policy(options) {
|
|
|
847
869
|
return false;
|
|
848
870
|
};
|
|
849
871
|
}
|
|
872
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, compile_autoclose_policy, "compile_autoclose_policy");
|
|
850
873
|
|
|
851
874
|
// src/internal/autoclose-window.ts
|
|
852
875
|
function hour_in_zone(now, timeZone) {
|
|
@@ -857,20 +880,24 @@ function hour_in_zone(now, timeZone) {
|
|
|
857
880
|
}).formatToParts(now);
|
|
858
881
|
return Number(_optionalChain([parts, 'access', _46 => _46.find, 'call', _47 => _47((p) => p.type === "hour"), 'optionalAccess', _48 => _48.value]));
|
|
859
882
|
}
|
|
883
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, hour_in_zone, "hour_in_zone");
|
|
860
884
|
function hour_in_range(hour, start, end) {
|
|
861
885
|
return start < end ? hour >= start && hour < end : hour >= start || hour < end;
|
|
862
886
|
}
|
|
887
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, hour_in_range, "hour_in_range");
|
|
863
888
|
function is_dst_gap_open(now, timeZone, start) {
|
|
864
889
|
const hour = hour_in_zone(now, timeZone);
|
|
865
890
|
if (hour <= start) return false;
|
|
866
891
|
const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
|
|
867
892
|
return prev === start - 1 && hour === start + 1;
|
|
868
893
|
}
|
|
894
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, is_dst_gap_open, "is_dst_gap_open");
|
|
869
895
|
function in_autoclose_window(window, now) {
|
|
870
896
|
if (!window) return true;
|
|
871
897
|
const hour = hour_in_zone(now, window.timeZone);
|
|
872
898
|
return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
|
|
873
899
|
}
|
|
900
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, in_autoclose_window, "in_autoclose_window");
|
|
874
901
|
function next_window_open(window, now) {
|
|
875
902
|
const start_ms = now.getTime();
|
|
876
903
|
for (let h = 0; h <= 48; h++) {
|
|
@@ -885,26 +912,30 @@ function next_window_open(window, now) {
|
|
|
885
912
|
}
|
|
886
913
|
return new Date(start_ms + 864e5);
|
|
887
914
|
}
|
|
915
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, next_window_open, "next_window_open");
|
|
888
916
|
|
|
889
917
|
// src/internal/defer-config.ts
|
|
890
918
|
function duration_ms(d) {
|
|
891
919
|
return (_nullishCoalesce(d.days, () => ( 0))) * 864e5 + (_nullishCoalesce(d.hours, () => ( 0))) * 36e5 + (_nullishCoalesce(d.minutes, () => ( 0))) * 6e4;
|
|
892
920
|
}
|
|
921
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, duration_ms, "duration_ms");
|
|
893
922
|
function resolve_defer_at(when, event) {
|
|
894
|
-
const parsed =
|
|
923
|
+
const parsed = _chunkOW67FBYOcjs.check.call(void 0, "defer", when);
|
|
895
924
|
if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
|
|
896
925
|
return parsed.at.getTime();
|
|
897
926
|
}
|
|
927
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, resolve_defer_at, "resolve_defer_at");
|
|
898
928
|
function make_deferred(handler, schedule) {
|
|
899
929
|
const call = handler;
|
|
900
|
-
const deferred = async (event, stream, app) => {
|
|
930
|
+
const deferred = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async (event, stream, app) => {
|
|
901
931
|
const when = typeof schedule === "function" ? schedule(event) : schedule;
|
|
902
|
-
if (Date.now() < resolve_defer_at(when, event)) throw new (0,
|
|
932
|
+
if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkQSXWCJ2Ucjs.DeferSignal)(when);
|
|
903
933
|
return call(event, stream, app);
|
|
904
|
-
};
|
|
934
|
+
}, "deferred");
|
|
905
935
|
Object.defineProperty(deferred, "name", { value: handler.name });
|
|
906
936
|
return deferred;
|
|
907
937
|
}
|
|
938
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, make_deferred, "make_deferred");
|
|
908
939
|
|
|
909
940
|
// src/internal/drain-cycle.ts
|
|
910
941
|
var _crypto = require('crypto');
|
|
@@ -933,10 +964,14 @@ function compute_backoff_delay(retry, opts) {
|
|
|
933
964
|
if (opts.jitter) delay = delay * (0.5 + Math.random());
|
|
934
965
|
return Math.max(0, Math.floor(delay));
|
|
935
966
|
}
|
|
967
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, compute_backoff_delay, "compute_backoff_delay");
|
|
936
968
|
|
|
937
969
|
// src/internal/defer-timer.ts
|
|
938
970
|
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
939
971
|
var DeferTimer = (_class2 = class {
|
|
972
|
+
static {
|
|
973
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "DeferTimer");
|
|
974
|
+
}
|
|
940
975
|
__init2() {this._due = /* @__PURE__ */ new Map()}
|
|
941
976
|
|
|
942
977
|
|
|
@@ -1026,13 +1061,15 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
|
|
|
1026
1061
|
if (total === 0) return RATIO_DEFAULT;
|
|
1027
1062
|
return Math.max(RATIO_MIN, Math.min(RATIO_MAX, lagging_avg / total));
|
|
1028
1063
|
}
|
|
1064
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, compute_lag_lead_ratio, "compute_lag_lead_ratio");
|
|
1029
1065
|
|
|
1030
1066
|
// src/internal/report-once.ts
|
|
1031
1067
|
function report_once(seen, key, message) {
|
|
1032
1068
|
if (seen.has(key)) return;
|
|
1033
1069
|
seen.add(key);
|
|
1034
|
-
|
|
1070
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).error(new Error(message));
|
|
1035
1071
|
}
|
|
1072
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, report_once, "report_once");
|
|
1036
1073
|
|
|
1037
1074
|
// src/internal/correlation-id.ts
|
|
1038
1075
|
|
|
@@ -1042,13 +1079,14 @@ var SEG_SPACE = BASE ** SEG_WIDTH;
|
|
|
1042
1079
|
function seg(n) {
|
|
1043
1080
|
return n.toString(BASE).padStart(SEG_WIDTH, "0");
|
|
1044
1081
|
}
|
|
1045
|
-
|
|
1082
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, seg, "seg");
|
|
1083
|
+
var default_correlator = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, ({ state: state2, action: action2 }) => {
|
|
1046
1084
|
const s = state2.slice(0, SEG_WIDTH).toLowerCase();
|
|
1047
1085
|
const a = action2.slice(0, SEG_WIDTH).toLowerCase();
|
|
1048
1086
|
const ts = seg(Date.now() % SEG_SPACE);
|
|
1049
1087
|
const rnd = seg(_crypto.randomInt.call(void 0, SEG_SPACE));
|
|
1050
1088
|
return `${s}-${a}-${ts}${rnd}`;
|
|
1051
|
-
};
|
|
1089
|
+
}, "default_correlator");
|
|
1052
1090
|
function close_correlation(correlator, actor) {
|
|
1053
1091
|
return correlator({
|
|
1054
1092
|
state: "$close",
|
|
@@ -1057,16 +1095,17 @@ function close_correlation(correlator, actor) {
|
|
|
1057
1095
|
actor
|
|
1058
1096
|
});
|
|
1059
1097
|
}
|
|
1098
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, close_correlation, "close_correlation");
|
|
1060
1099
|
|
|
1061
1100
|
// src/internal/drain-ops.ts
|
|
1062
|
-
var claim = (lagging, leading, by, millis, lane) =>
|
|
1101
|
+
var claim = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (lagging, leading, by, millis, lane) => _chunkOW67FBYOcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane), "claim");
|
|
1063
1102
|
async function fetch(leased, eventLimit) {
|
|
1064
1103
|
return Promise.all(
|
|
1065
1104
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1066
1105
|
const events = [];
|
|
1067
|
-
const stream_exact = source !== void 0 &&
|
|
1106
|
+
const stream_exact = source !== void 0 && _chunkPDMLWC77cjs.isStreamName.call(void 0, source, stream) ? true : void 0;
|
|
1068
1107
|
try {
|
|
1069
|
-
await
|
|
1108
|
+
await _chunkOW67FBYOcjs.store.call(void 0, ).query((e) => events.push(e), {
|
|
1070
1109
|
stream: source,
|
|
1071
1110
|
stream_exact,
|
|
1072
1111
|
after: at,
|
|
@@ -1086,9 +1125,10 @@ async function fetch(leased, eventLimit) {
|
|
|
1086
1125
|
})
|
|
1087
1126
|
);
|
|
1088
1127
|
}
|
|
1089
|
-
|
|
1090
|
-
var
|
|
1091
|
-
var
|
|
1128
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, fetch, "fetch");
|
|
1129
|
+
var ack = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (leases) => _chunkOW67FBYOcjs.store.call(void 0, ).ack(leases), "ack");
|
|
1130
|
+
var block = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (leases) => _chunkOW67FBYOcjs.store.call(void 0, ).block(leases), "block");
|
|
1131
|
+
var subscribe = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (streams, correlated_at, correlator) => _chunkOW67FBYOcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator), "subscribe");
|
|
1092
1132
|
|
|
1093
1133
|
// src/internal/event-sourcing.ts
|
|
1094
1134
|
var _actpatch = require('@rotorsoft/act-patch');
|
|
@@ -1097,7 +1137,7 @@ var _zod = require('zod');
|
|
|
1097
1137
|
// src/internal/date-reviver.ts
|
|
1098
1138
|
|
|
1099
1139
|
function variant_schema(schema, walk) {
|
|
1100
|
-
const shape = _optionalChain([
|
|
1140
|
+
const shape = _optionalChain([_chunkQSXWCJ2Ucjs.def_of.call(void 0, schema), 'optionalAccess', _50 => _50.shape]);
|
|
1101
1141
|
if (!shape) {
|
|
1102
1142
|
const dates = walk(schema);
|
|
1103
1143
|
return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
|
|
@@ -1111,12 +1151,13 @@ function variant_schema(schema, walk) {
|
|
|
1111
1151
|
}
|
|
1112
1152
|
return { schema: _zod.z.looseObject(next), dated };
|
|
1113
1153
|
}
|
|
1154
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, variant_schema, "variant_schema");
|
|
1114
1155
|
function date_reviver_schema(schema) {
|
|
1115
1156
|
let recursive = false;
|
|
1116
|
-
const pass = (tie) => {
|
|
1157
|
+
const pass = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (tie) => {
|
|
1117
1158
|
const done = /* @__PURE__ */ new Map();
|
|
1118
1159
|
const active = /* @__PURE__ */ new Set();
|
|
1119
|
-
const walk = (node) => {
|
|
1160
|
+
const walk = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (node) => {
|
|
1120
1161
|
if (done.has(node)) return done.get(node);
|
|
1121
1162
|
if (active.has(node)) {
|
|
1122
1163
|
recursive = true;
|
|
@@ -1127,16 +1168,17 @@ function date_reviver_schema(schema) {
|
|
|
1127
1168
|
active.delete(node);
|
|
1128
1169
|
done.set(node, result);
|
|
1129
1170
|
return result;
|
|
1130
|
-
};
|
|
1171
|
+
}, "walk");
|
|
1131
1172
|
return walk(schema);
|
|
1132
|
-
};
|
|
1173
|
+
}, "pass");
|
|
1133
1174
|
const first = pass(false);
|
|
1134
1175
|
return first && recursive ? pass(true) : first;
|
|
1135
1176
|
}
|
|
1177
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, date_reviver_schema, "date_reviver_schema");
|
|
1136
1178
|
function build(schema, walk) {
|
|
1137
|
-
const def =
|
|
1179
|
+
const def = _chunkQSXWCJ2Ucjs.def_of.call(void 0, schema);
|
|
1138
1180
|
if (!def) return void 0;
|
|
1139
|
-
const inner = () => walk(def.innerType);
|
|
1181
|
+
const inner = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => walk(def.innerType), "inner");
|
|
1140
1182
|
switch (def.type) {
|
|
1141
1183
|
case "date":
|
|
1142
1184
|
return _zod.z.coerce.date();
|
|
@@ -1180,56 +1222,57 @@ function build(schema, walk) {
|
|
|
1180
1222
|
return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
|
|
1181
1223
|
}
|
|
1182
1224
|
default:
|
|
1183
|
-
return
|
|
1225
|
+
return _chunkQSXWCJ2Ucjs.inner_of.call(void 0, def) ? inner() : void 0;
|
|
1184
1226
|
}
|
|
1185
1227
|
}
|
|
1228
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, build, "build");
|
|
1186
1229
|
|
|
1187
1230
|
// src/internal/event-sourcing.ts
|
|
1188
|
-
var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
|
|
1189
|
-
var value_at = (value, path) => path.reduce(
|
|
1231
|
+
var bare_patch = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial), "bare_patch");
|
|
1232
|
+
var value_at = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (value, path) => path.reduce(
|
|
1190
1233
|
(at, key) => _optionalChain([at, 'optionalAccess', _54 => _54[key]]),
|
|
1191
1234
|
value
|
|
1192
|
-
);
|
|
1193
|
-
var check_invariants = (target, state2, schema, pii_aware) => {
|
|
1235
|
+
), "value_at");
|
|
1236
|
+
var check_invariants = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (target, state2, schema, pii_aware) => {
|
|
1194
1237
|
let result;
|
|
1195
1238
|
try {
|
|
1196
1239
|
result = schema.safeParse(state2);
|
|
1197
1240
|
} catch (error) {
|
|
1198
|
-
throw new (0,
|
|
1241
|
+
throw new (0, _chunkQSXWCJ2Ucjs.ValidationError)(target, state2, error);
|
|
1199
1242
|
}
|
|
1200
1243
|
if (result.success) return;
|
|
1201
1244
|
const issues = pii_aware ? result.error.issues.filter((issue) => {
|
|
1202
1245
|
const value = value_at(state2, issue.path);
|
|
1203
|
-
return value !==
|
|
1246
|
+
return value !== _chunkQSXWCJ2Ucjs.REDACTED && value !== _chunkQSXWCJ2Ucjs.SHREDDED;
|
|
1204
1247
|
}) : result.error.issues;
|
|
1205
1248
|
if (issues.length)
|
|
1206
|
-
throw new (0,
|
|
1249
|
+
throw new (0, _chunkQSXWCJ2Ucjs.ValidationError)(
|
|
1207
1250
|
target,
|
|
1208
1251
|
state2,
|
|
1209
1252
|
_zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
|
|
1210
1253
|
);
|
|
1211
|
-
};
|
|
1254
|
+
}, "check_invariants");
|
|
1212
1255
|
var DEFAULT_BATCH = 500;
|
|
1213
|
-
var cache_put = (stream, entry) =>
|
|
1214
|
-
(err) =>
|
|
1256
|
+
var cache_put = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (stream, entry) => _chunkOW67FBYOcjs.cache.call(void 0, ).set(stream, entry).catch(
|
|
1257
|
+
(err) => _chunkOW67FBYOcjs.log.call(void 0, ).warn(
|
|
1215
1258
|
err,
|
|
1216
1259
|
"cache set skipped; the next load re-folds from the store"
|
|
1217
1260
|
)
|
|
1218
|
-
);
|
|
1219
|
-
var cache_drop = (stream) =>
|
|
1220
|
-
(err) =>
|
|
1261
|
+
), "cache_put");
|
|
1262
|
+
var cache_drop = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (stream) => _chunkOW67FBYOcjs.cache.call(void 0, ).invalidate(stream).catch(
|
|
1263
|
+
(err) => _chunkOW67FBYOcjs.log.call(void 0, ).warn(
|
|
1221
1264
|
err,
|
|
1222
1265
|
"cache invalidate skipped; a stale checkpoint re-folds from its event_id"
|
|
1223
1266
|
)
|
|
1224
|
-
);
|
|
1267
|
+
), "cache_drop");
|
|
1225
1268
|
async function snap(snapshot) {
|
|
1226
1269
|
const { id, stream, name, meta, version } = snapshot.event;
|
|
1227
1270
|
try {
|
|
1228
|
-
const [committed] = await
|
|
1271
|
+
const [committed] = await _chunkOW67FBYOcjs.store.call(void 0, ).commit(
|
|
1229
1272
|
[
|
|
1230
1273
|
{
|
|
1231
1274
|
stream,
|
|
1232
|
-
msgs: [{ name:
|
|
1275
|
+
msgs: [{ name: _chunkQSXWCJ2Ucjs.SNAP_EVENT, data: snapshot.state }],
|
|
1233
1276
|
// IMPORTANT! - state events are committed right after the snapshot event
|
|
1234
1277
|
expectedVersion: version
|
|
1235
1278
|
}
|
|
@@ -1242,18 +1285,19 @@ async function snap(snapshot) {
|
|
|
1242
1285
|
return committed;
|
|
1243
1286
|
} catch (error) {
|
|
1244
1287
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1245
|
-
|
|
1288
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).warn(
|
|
1246
1289
|
`Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
|
|
1247
1290
|
);
|
|
1248
1291
|
}
|
|
1249
1292
|
}
|
|
1293
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, snap, "snap");
|
|
1250
1294
|
async function tombstone(stream, expectedVersion, correlation) {
|
|
1251
1295
|
try {
|
|
1252
|
-
const [committed] = await
|
|
1296
|
+
const [committed] = await _chunkOW67FBYOcjs.store.call(void 0, ).commit(
|
|
1253
1297
|
[
|
|
1254
1298
|
{
|
|
1255
1299
|
stream,
|
|
1256
|
-
msgs: [{ name:
|
|
1300
|
+
msgs: [{ name: _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT, data: {} }],
|
|
1257
1301
|
expectedVersion
|
|
1258
1302
|
}
|
|
1259
1303
|
],
|
|
@@ -1261,16 +1305,18 @@ async function tombstone(stream, expectedVersion, correlation) {
|
|
|
1261
1305
|
);
|
|
1262
1306
|
return committed;
|
|
1263
1307
|
} catch (error) {
|
|
1264
|
-
if (error instanceof
|
|
1308
|
+
if (error instanceof _chunkQSXWCJ2Ucjs.ConcurrencyError) return void 0;
|
|
1265
1309
|
throw error;
|
|
1266
1310
|
}
|
|
1267
1311
|
}
|
|
1312
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, tombstone, "tombstone");
|
|
1268
1313
|
function is_valid(event) {
|
|
1269
1314
|
if (event.version < 0) return false;
|
|
1270
1315
|
if (!(event.created instanceof Date) || Number.isNaN(event.created.getTime()))
|
|
1271
1316
|
return false;
|
|
1272
1317
|
return true;
|
|
1273
1318
|
}
|
|
1319
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, is_valid, "is_valid");
|
|
1274
1320
|
async function scan(source, opts = {}, callback) {
|
|
1275
1321
|
const {
|
|
1276
1322
|
drop_snapshots = false,
|
|
@@ -1298,9 +1344,9 @@ async function scan(source, opts = {}, callback) {
|
|
|
1298
1344
|
if (drop_closed_streams) {
|
|
1299
1345
|
await source.query(
|
|
1300
1346
|
(e) => {
|
|
1301
|
-
if (e.name ===
|
|
1347
|
+
if (e.name === _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
|
|
1302
1348
|
},
|
|
1303
|
-
{ names: [
|
|
1349
|
+
{ names: [_chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT] }
|
|
1304
1350
|
);
|
|
1305
1351
|
}
|
|
1306
1352
|
let max_id;
|
|
@@ -1325,11 +1371,11 @@ async function scan(source, opts = {}, callback) {
|
|
|
1325
1371
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1326
1372
|
const has_history = started.has(event.stream);
|
|
1327
1373
|
started.add(event.stream);
|
|
1328
|
-
if (drop_snapshots && event.name ===
|
|
1374
|
+
if (drop_snapshots && event.name === _chunkQSXWCJ2Ucjs.SNAP_EVENT && has_history) {
|
|
1329
1375
|
dropped_snaps++;
|
|
1330
1376
|
return;
|
|
1331
1377
|
}
|
|
1332
|
-
if (closed_streams.has(event.stream) && event.name !==
|
|
1378
|
+
if (closed_streams.has(event.stream) && event.name !== _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT) {
|
|
1333
1379
|
dropped_closed++;
|
|
1334
1380
|
return;
|
|
1335
1381
|
}
|
|
@@ -1402,22 +1448,23 @@ async function scan(source, opts = {}, callback) {
|
|
|
1402
1448
|
}
|
|
1403
1449
|
};
|
|
1404
1450
|
}
|
|
1451
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, scan, "scan");
|
|
1405
1452
|
async function load(me, target, callback, patch_fn = bare_patch) {
|
|
1406
1453
|
const { stream, actor, asOf } = target;
|
|
1407
1454
|
const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
|
|
1408
1455
|
const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
|
|
1409
|
-
const cached = time_travel ? void 0 : await
|
|
1456
|
+
const cached = time_travel ? void 0 : await _chunkOW67FBYOcjs.cache.call(void 0, ).get(stream);
|
|
1410
1457
|
const cache_hit = !!cached;
|
|
1411
1458
|
let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _63 => _63.state]), () => ( (me.init ? me.init() : {})));
|
|
1412
1459
|
let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _64 => _64.patches]), () => ( 0));
|
|
1413
1460
|
let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _65 => _65.snaps]), () => ( 0));
|
|
1414
1461
|
let replayed = 0;
|
|
1415
1462
|
let event;
|
|
1416
|
-
await
|
|
1463
|
+
await _chunkOW67FBYOcjs.store.call(void 0, ).query(
|
|
1417
1464
|
(raw) => {
|
|
1418
|
-
if (seeded && raw.name ===
|
|
1465
|
+
if (seeded && raw.name === _chunkQSXWCJ2Ucjs.SNAP_EVENT && replayed > 0) return;
|
|
1419
1466
|
event = me.view(raw, actor);
|
|
1420
|
-
if (event.name ===
|
|
1467
|
+
if (event.name === _chunkQSXWCJ2Ucjs.SNAP_EVENT) {
|
|
1421
1468
|
state2 = event.data;
|
|
1422
1469
|
snaps++;
|
|
1423
1470
|
patches = 0;
|
|
@@ -1426,8 +1473,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1426
1473
|
state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
|
|
1427
1474
|
patches++;
|
|
1428
1475
|
replayed++;
|
|
1429
|
-
} else if (event.name !==
|
|
1430
|
-
|
|
1476
|
+
} else if (event.name !== _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT) {
|
|
1477
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).warn(
|
|
1431
1478
|
`Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
|
|
1432
1479
|
);
|
|
1433
1480
|
}
|
|
@@ -1455,7 +1502,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1455
1502
|
) : time_travel ? asOf : { with_snaps: true }
|
|
1456
1503
|
}
|
|
1457
1504
|
);
|
|
1458
|
-
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _67 => _67.name]) ===
|
|
1505
|
+
const head_is_tombstone = _optionalChain([event, 'optionalAccess', _67 => _67.name]) === _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT;
|
|
1459
1506
|
if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
|
|
1460
1507
|
await cache_put(stream, {
|
|
1461
1508
|
stream,
|
|
@@ -1478,6 +1525,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
|
|
|
1478
1525
|
replayed
|
|
1479
1526
|
};
|
|
1480
1527
|
}
|
|
1528
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, load, "load");
|
|
1481
1529
|
async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
1482
1530
|
const streams = loads.map((l) => l.target(payload, own.state));
|
|
1483
1531
|
streams.forEach((stream, i) => {
|
|
@@ -1498,8 +1546,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1498
1546
|
void 0,
|
|
1499
1547
|
patch_fn
|
|
1500
1548
|
);
|
|
1501
|
-
if (_optionalChain([snapshot, 'access', _72 => _72.event, 'optionalAccess', _73 => _73.name]) ===
|
|
1502
|
-
throw new (0,
|
|
1549
|
+
if (_optionalChain([snapshot, 'access', _72 => _72.event, 'optionalAccess', _73 => _73.name]) === _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT)
|
|
1550
|
+
throw new (0, _chunkQSXWCJ2Ucjs.StreamClosedError)(stream);
|
|
1503
1551
|
return {
|
|
1504
1552
|
state: l.state,
|
|
1505
1553
|
stream,
|
|
@@ -1510,12 +1558,13 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
|
|
|
1510
1558
|
})
|
|
1511
1559
|
);
|
|
1512
1560
|
}
|
|
1561
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, load_others, "load_others");
|
|
1513
1562
|
async function action(me, action2, target, payload, options, patch_fn = bare_patch) {
|
|
1514
1563
|
const { stream, expectedVersion, actor } = target;
|
|
1515
1564
|
if (!stream) throw new Error("Missing target stream");
|
|
1516
1565
|
const reactingTo = _optionalChain([options, 'optionalAccess', _74 => _74.reactingTo]);
|
|
1517
1566
|
const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _75 => _75.correlator]), () => ( default_correlator));
|
|
1518
|
-
const validated =
|
|
1567
|
+
const validated = _chunkOW67FBYOcjs.validate.call(void 0, action2, payload, me.actions[action2]);
|
|
1519
1568
|
const opts = _optionalChain([me, 'access', _76 => _76.options, 'optionalAccess', _77 => _77[action2]]);
|
|
1520
1569
|
const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _78 => _78.maxRetries]), () => ( 0));
|
|
1521
1570
|
const loads = _nullishCoalesce(_optionalChain([me, 'access', _79 => _79.loads, 'optionalAccess', _80 => _80[action2]]), () => ( []));
|
|
@@ -1527,8 +1576,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1527
1576
|
void 0,
|
|
1528
1577
|
patch_fn
|
|
1529
1578
|
);
|
|
1530
|
-
if (_optionalChain([snapshot, 'access', _81 => _81.event, 'optionalAccess', _82 => _82.name]) ===
|
|
1531
|
-
throw new (0,
|
|
1579
|
+
if (_optionalChain([snapshot, 'access', _81 => _81.event, 'optionalAccess', _82 => _82.name]) === _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT)
|
|
1580
|
+
throw new (0, _chunkQSXWCJ2Ucjs.StreamClosedError)(stream);
|
|
1532
1581
|
const own = {
|
|
1533
1582
|
state: me,
|
|
1534
1583
|
stream,
|
|
@@ -1542,7 +1591,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1542
1591
|
{ stream, state: snapshot.state },
|
|
1543
1592
|
target.actor,
|
|
1544
1593
|
patch_fn,
|
|
1545
|
-
(description) => new (0,
|
|
1594
|
+
(description) => new (0, _chunkQSXWCJ2Ucjs.PreconditionError)(
|
|
1546
1595
|
action2,
|
|
1547
1596
|
validated,
|
|
1548
1597
|
target,
|
|
@@ -1555,7 +1604,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1555
1604
|
);
|
|
1556
1605
|
for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _85 => _85.requires, 'optionalAccess', _86 => _86[action2]]), () => ( [])))
|
|
1557
1606
|
if (!holds(validated, snapshot.state, actor, loaded))
|
|
1558
|
-
throw new (0,
|
|
1607
|
+
throw new (0, _chunkQSXWCJ2Ucjs.PreconditionError)(
|
|
1559
1608
|
action2,
|
|
1560
1609
|
validated,
|
|
1561
1610
|
target,
|
|
@@ -1577,7 +1626,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1577
1626
|
);
|
|
1578
1627
|
to.events.push({
|
|
1579
1628
|
name: event,
|
|
1580
|
-
data:
|
|
1629
|
+
data: _chunkOW67FBYOcjs.validate.call(void 0, event, data, to.state.events[event])
|
|
1581
1630
|
});
|
|
1582
1631
|
}
|
|
1583
1632
|
if (!own.events.length)
|
|
@@ -1634,7 +1683,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1634
1683
|
});
|
|
1635
1684
|
let committed;
|
|
1636
1685
|
try {
|
|
1637
|
-
committed = await
|
|
1686
|
+
committed = await _chunkOW67FBYOcjs.store.call(void 0, ).commit(
|
|
1638
1687
|
appends.map((p) => ({
|
|
1639
1688
|
stream: p.stream,
|
|
1640
1689
|
msgs: p.events.map((e) => p.state.message(e)),
|
|
@@ -1643,7 +1692,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1643
1692
|
meta
|
|
1644
1693
|
);
|
|
1645
1694
|
} catch (error) {
|
|
1646
|
-
if (error instanceof
|
|
1695
|
+
if (error instanceof _chunkQSXWCJ2Ucjs.ConcurrencyError) void cache_drop(error.stream);
|
|
1647
1696
|
throw error;
|
|
1648
1697
|
}
|
|
1649
1698
|
let row = 0;
|
|
@@ -1685,19 +1734,20 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
|
|
|
1685
1734
|
}
|
|
1686
1735
|
return snapshots;
|
|
1687
1736
|
} catch (error) {
|
|
1688
|
-
if (!(error instanceof
|
|
1737
|
+
if (!(error instanceof _chunkQSXWCJ2Ucjs.ConcurrencyError)) throw error;
|
|
1689
1738
|
if (expectedVersion !== void 0 && error.stream === stream) throw error;
|
|
1690
1739
|
if (attempt >= max_retries) throw error;
|
|
1691
1740
|
if (_optionalChain([opts, 'optionalAccess', _95 => _95.backoff])) {
|
|
1692
1741
|
const delay_ms = compute_backoff_delay(attempt, opts.backoff);
|
|
1693
|
-
if (delay_ms > 0) await
|
|
1742
|
+
if (delay_ms > 0) await _chunkOW67FBYOcjs.sleep.call(void 0, delay_ms);
|
|
1694
1743
|
}
|
|
1695
1744
|
}
|
|
1696
1745
|
}
|
|
1697
1746
|
}
|
|
1747
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, action, "action");
|
|
1698
1748
|
|
|
1699
1749
|
// src/internal/tracing.ts
|
|
1700
|
-
var PRETTY =
|
|
1750
|
+
var PRETTY = _chunkOW67FBYOcjs.config.call(void 0, ).env !== "production";
|
|
1701
1751
|
var C_BLUE = "\x1B[38;5;39m";
|
|
1702
1752
|
var C_ORANGE = "\x1B[38;5;208m";
|
|
1703
1753
|
var C_GREEN = "\x1B[38;5;42m";
|
|
@@ -1706,32 +1756,32 @@ var C_DRAIN = "\x1B[38;5;244m";
|
|
|
1706
1756
|
var C_HIT = "\x1B[38;5;82m";
|
|
1707
1757
|
var C_MISS = "\x1B[38;5;220m";
|
|
1708
1758
|
var C_RESET = "\x1B[0m";
|
|
1709
|
-
var es_caption = (caption, color, body) => PRETTY ? `${color}${body}${C_RESET}` : `${caption}: ${body}
|
|
1759
|
+
var es_caption = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (caption, color, body) => PRETTY ? `${color}${body}${C_RESET}` : `${caption}: ${body}`, "es_caption");
|
|
1710
1760
|
var C_LANE = "\x1B[38;5;183m";
|
|
1711
1761
|
var C_DIM = "\x1B[38;5;240m";
|
|
1712
1762
|
var C_ERR = "\x1B[38;5;196m";
|
|
1713
1763
|
var C_STREAM = "\x1B[38;5;226m";
|
|
1714
|
-
var dim = (text) => PRETTY ? `${C_DIM}${text}${C_RESET}` : text;
|
|
1715
|
-
var hue = (color, text) => PRETTY ? `${color}${text}${C_RESET}` : text;
|
|
1716
|
-
var drain_caption = (caption, lane) => {
|
|
1764
|
+
var dim = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (text) => PRETTY ? `${C_DIM}${text}${C_RESET}` : text, "dim");
|
|
1765
|
+
var hue = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (color, text) => PRETTY ? `${color}${text}${C_RESET}` : text, "hue");
|
|
1766
|
+
var drain_caption = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (caption, lane) => {
|
|
1717
1767
|
const show_lane = lane && lane !== "default";
|
|
1718
1768
|
if (PRETTY) {
|
|
1719
1769
|
const tag = `${C_DRAIN}>> ${caption}${C_RESET}`;
|
|
1720
1770
|
return show_lane ? `${tag} ${C_LANE}${lane}${C_RESET}` : tag;
|
|
1721
1771
|
}
|
|
1722
1772
|
return show_lane ? `>> ${caption} ${lane}` : `>> ${caption}`;
|
|
1723
|
-
};
|
|
1724
|
-
var cache_marker = (hit) => {
|
|
1773
|
+
}, "drain_caption");
|
|
1774
|
+
var cache_marker = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (hit) => {
|
|
1725
1775
|
const word = hit ? "hit" : "miss";
|
|
1726
1776
|
if (!PRETTY) return word;
|
|
1727
1777
|
return `${hit ? C_HIT : C_MISS}${word}${C_RESET}${C_GREEN}`;
|
|
1728
|
-
};
|
|
1729
|
-
var stats_marker = (version, replayed, snaps, patches) => {
|
|
1778
|
+
}, "cache_marker");
|
|
1779
|
+
var stats_marker = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (version, replayed, snaps, patches) => {
|
|
1730
1780
|
const text = `v=${version} replayed=${replayed} snaps=${snaps} patches=${patches}`;
|
|
1731
1781
|
if (!PRETTY) return text;
|
|
1732
1782
|
return `${C_DRAIN}${text}${C_RESET}${C_GREEN}`;
|
|
1733
|
-
};
|
|
1734
|
-
var as_of_marker = (asOf) => {
|
|
1783
|
+
}, "stats_marker");
|
|
1784
|
+
var as_of_marker = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (asOf) => {
|
|
1735
1785
|
if (!asOf) return "";
|
|
1736
1786
|
const parts = [];
|
|
1737
1787
|
if (asOf.before !== void 0) parts.push(`before=${asOf.before}`);
|
|
@@ -1741,23 +1791,23 @@ var as_of_marker = (asOf) => {
|
|
|
1741
1791
|
parts.push(`created_after=${asOf.created_after.toISOString()}`);
|
|
1742
1792
|
if (asOf.limit !== void 0) parts.push(`limit=${asOf.limit}`);
|
|
1743
1793
|
return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
|
|
1744
|
-
};
|
|
1745
|
-
var traced = (inner, exit, entry) => (async (...args) => {
|
|
1794
|
+
}, "as_of_marker");
|
|
1795
|
+
var traced = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (inner, exit, entry) => (async (...args) => {
|
|
1746
1796
|
_optionalChain([entry, 'optionalCall', _96 => _96(...args)]);
|
|
1747
1797
|
const result = await inner(...args);
|
|
1748
1798
|
_optionalChain([exit, 'optionalCall', _97 => _97(result, ...args)]);
|
|
1749
1799
|
return result;
|
|
1750
|
-
});
|
|
1800
|
+
}), "traced");
|
|
1751
1801
|
function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
|
|
1752
|
-
const bound_action = (me, action_name, target, payload, options) => action(
|
|
1802
|
+
const bound_action = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (me, action_name, target, payload, options) => action(
|
|
1753
1803
|
me,
|
|
1754
1804
|
action_name,
|
|
1755
1805
|
target,
|
|
1756
1806
|
payload,
|
|
1757
1807
|
{ ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _98 => _98.correlator]), () => ( correlator)) },
|
|
1758
1808
|
patch_fn
|
|
1759
|
-
);
|
|
1760
|
-
const bound_load = (me, target, callback) => load(me, target, callback, patch_fn);
|
|
1809
|
+
), "bound_action");
|
|
1810
|
+
const bound_load = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (me, target, callback) => load(me, target, callback, patch_fn), "bound_load");
|
|
1761
1811
|
if (logger.level !== "trace") {
|
|
1762
1812
|
return {
|
|
1763
1813
|
snap,
|
|
@@ -1819,6 +1869,7 @@ function build_es(logger, correlator = default_correlator, patch_fn = bare_patch
|
|
|
1819
1869
|
})
|
|
1820
1870
|
};
|
|
1821
1871
|
}
|
|
1872
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, build_es, "build_es");
|
|
1822
1873
|
function build_drain(logger) {
|
|
1823
1874
|
return {
|
|
1824
1875
|
claim,
|
|
@@ -1838,6 +1889,7 @@ function build_drain(logger) {
|
|
|
1838
1889
|
})
|
|
1839
1890
|
};
|
|
1840
1891
|
}
|
|
1892
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, build_drain, "build_drain");
|
|
1841
1893
|
function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
1842
1894
|
if (logger.level !== "trace" || !leased.length) return;
|
|
1843
1895
|
const lane = _optionalChain([leased, 'access', _101 => _101[0], 'optionalAccess', _102 => _102.lane]);
|
|
@@ -1875,15 +1927,17 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
|
|
|
1875
1927
|
}).join(", ");
|
|
1876
1928
|
logger.trace(`${drain_caption("drained", lane)} ${detail}`);
|
|
1877
1929
|
}
|
|
1930
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, trace_cycle, "trace_cycle");
|
|
1878
1931
|
|
|
1879
1932
|
// src/internal/drain-cycle.ts
|
|
1880
1933
|
function budget_exhausted(lease, options, store_failing) {
|
|
1881
1934
|
if (store_failing || !_optionalChain([options, 'optionalAccess', _106 => _106.blockOnError]) || lease.retry <= options.maxRetries)
|
|
1882
1935
|
return void 0;
|
|
1883
1936
|
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.`;
|
|
1884
|
-
|
|
1937
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).error(error);
|
|
1885
1938
|
return { lease, handled: 0, acked_at: lease.at, error, block: true };
|
|
1886
1939
|
}
|
|
1940
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, budget_exhausted, "budget_exhausted");
|
|
1887
1941
|
function fetch_failure_policy(registry) {
|
|
1888
1942
|
let blockOnError = true;
|
|
1889
1943
|
let maxRetries = 0;
|
|
@@ -1894,16 +1948,17 @@ function fetch_failure_policy(registry) {
|
|
|
1894
1948
|
}
|
|
1895
1949
|
return { blockOnError, maxRetries };
|
|
1896
1950
|
}
|
|
1951
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, fetch_failure_policy, "fetch_failure_policy");
|
|
1897
1952
|
function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
1898
1953
|
if (!error) return { lease, handled, acked_at: at };
|
|
1899
1954
|
logger.error(error);
|
|
1900
|
-
const non_retryable = error instanceof
|
|
1955
|
+
const non_retryable = error instanceof _chunkQSXWCJ2Ucjs.NonRetryableError;
|
|
1901
1956
|
const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
|
|
1902
1957
|
if (block2)
|
|
1903
1958
|
logger.error(
|
|
1904
1959
|
non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
|
|
1905
1960
|
);
|
|
1906
|
-
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => (
|
|
1961
|
+
const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkOW67FBYOcjs.DEFAULT_BACKOFF)));
|
|
1907
1962
|
return {
|
|
1908
1963
|
lease,
|
|
1909
1964
|
handled,
|
|
@@ -1914,6 +1969,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
|
|
|
1914
1969
|
failed_at
|
|
1915
1970
|
};
|
|
1916
1971
|
}
|
|
1972
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, finalize, "finalize");
|
|
1917
1973
|
function warn_misrouted(seen, stream, handler, event) {
|
|
1918
1974
|
report_once(
|
|
1919
1975
|
seen,
|
|
@@ -1921,6 +1977,7 @@ function warn_misrouted(seen, stream, handler, event) {
|
|
|
1921
1977
|
`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.`
|
|
1922
1978
|
);
|
|
1923
1979
|
}
|
|
1980
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, warn_misrouted, "warn_misrouted");
|
|
1924
1981
|
async function run_drain_cycle(deps, cycle) {
|
|
1925
1982
|
const { ops, registry, batch_handlers, handle, handle_batch, lane } = deps;
|
|
1926
1983
|
const {
|
|
@@ -2031,12 +2088,13 @@ async function run_drain_cycle(deps, cycle) {
|
|
|
2031
2088
|
const acked = submitted.length ? await ops.ack(submitted) : [];
|
|
2032
2089
|
const expected = submitted.filter((l) => l.due === void 0).length;
|
|
2033
2090
|
if (acked.length < expected)
|
|
2034
|
-
|
|
2091
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).warn(
|
|
2035
2092
|
`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.`
|
|
2036
2093
|
);
|
|
2037
2094
|
const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
|
|
2038
2095
|
return { leased, fetched, handled, acked, blocked, closeable };
|
|
2039
2096
|
}
|
|
2097
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, run_drain_cycle, "run_drain_cycle");
|
|
2040
2098
|
var EMPTY_DRAIN = {
|
|
2041
2099
|
fetched: [],
|
|
2042
2100
|
leased: [],
|
|
@@ -2051,8 +2109,12 @@ function merge_drains(drains) {
|
|
|
2051
2109
|
blocked: drains.flatMap((d) => d.blocked)
|
|
2052
2110
|
};
|
|
2053
2111
|
}
|
|
2112
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_drains, "merge_drains");
|
|
2054
2113
|
var RETRY = "";
|
|
2055
2114
|
var DrainController = (_class3 = class {
|
|
2115
|
+
static {
|
|
2116
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "DrainController");
|
|
2117
|
+
}
|
|
2056
2118
|
// Armed while `_raised` is ahead of `_lowered` (the raise count the last
|
|
2057
2119
|
// empty claim saw), so a claim never lowers over a raise that landed
|
|
2058
2120
|
// during it.
|
|
@@ -2106,12 +2168,12 @@ var DrainController = (_class3 = class {
|
|
|
2106
2168
|
*/
|
|
2107
2169
|
start(cycleMs) {
|
|
2108
2170
|
const run = this._deps.run_scoped;
|
|
2109
|
-
const tick = async () => {
|
|
2171
|
+
const tick = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async () => {
|
|
2110
2172
|
if (this.armed) await run(() => this.drain());
|
|
2111
2173
|
if (this._stopped) return;
|
|
2112
2174
|
this._worker = setTimeout(tick, cycleMs);
|
|
2113
2175
|
this._worker.unref();
|
|
2114
|
-
};
|
|
2176
|
+
}, "tick");
|
|
2115
2177
|
this._worker = setTimeout(tick, cycleMs);
|
|
2116
2178
|
this._worker.unref();
|
|
2117
2179
|
}
|
|
@@ -2127,9 +2189,9 @@ var DrainController = (_class3 = class {
|
|
|
2127
2189
|
if (!this.armed || this._stopped || this._inflight)
|
|
2128
2190
|
return EMPTY_DRAIN;
|
|
2129
2191
|
const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
|
|
2130
|
-
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => (
|
|
2131
|
-
const eventLimit = _nullishCoalesce(options.eventLimit, () => (
|
|
2132
|
-
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => (
|
|
2192
|
+
const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkOW67FBYOcjs.DEFAULT_STREAM_LIMIT));
|
|
2193
|
+
const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkOW67FBYOcjs.DEFAULT_EVENT_LIMIT));
|
|
2194
|
+
const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkOW67FBYOcjs.DEFAULT_LEASE_MILLIS));
|
|
2133
2195
|
if (this._deps.breaker.state(Date.now()) === "open")
|
|
2134
2196
|
return EMPTY_DRAIN;
|
|
2135
2197
|
const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
|
|
@@ -2189,6 +2251,9 @@ var DrainController = (_class3 = class {
|
|
|
2189
2251
|
|
|
2190
2252
|
// src/internal/reaction-dispatch.ts
|
|
2191
2253
|
var CloseSignal = class extends Error {
|
|
2254
|
+
static {
|
|
2255
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "CloseSignal");
|
|
2256
|
+
}
|
|
2192
2257
|
/**
|
|
2193
2258
|
* Stream to close. Omitted → the reaction's own lease stream (a self-close).
|
|
2194
2259
|
* The synthesized autoclose reaction sets it to the aggregate stream, since
|
|
@@ -2255,7 +2320,7 @@ function build_handle(deps) {
|
|
|
2255
2320
|
handled++;
|
|
2256
2321
|
}
|
|
2257
2322
|
} catch (error) {
|
|
2258
|
-
if (error instanceof
|
|
2323
|
+
if (error instanceof _chunkQSXWCJ2Ucjs.DeferSignal) {
|
|
2259
2324
|
let defer;
|
|
2260
2325
|
try {
|
|
2261
2326
|
defer = resolve_defer_at(error.when, event);
|
|
@@ -2304,6 +2369,7 @@ function build_handle(deps) {
|
|
|
2304
2369
|
return finalize(lease, handled, at, void 0, payloads[0].options, logger);
|
|
2305
2370
|
};
|
|
2306
2371
|
}
|
|
2372
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, build_handle, "build_handle");
|
|
2307
2373
|
function build_handle_batch(logger) {
|
|
2308
2374
|
return async (lease, payloads, batchHandler) => {
|
|
2309
2375
|
const stream = lease.stream;
|
|
@@ -2332,6 +2398,7 @@ function build_handle_batch(logger) {
|
|
|
2332
2398
|
}
|
|
2333
2399
|
};
|
|
2334
2400
|
}
|
|
2401
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, build_handle_batch, "build_handle_batch");
|
|
2335
2402
|
|
|
2336
2403
|
// src/internal/autoclose-reaction.ts
|
|
2337
2404
|
var AUTOCLOSE_TARGET_PREFIX = "__autoclose__:";
|
|
@@ -2352,22 +2419,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2352
2419
|
// An anchored stream name would read as a pattern, and a store may refuse
|
|
2353
2420
|
// it at subscribe, stopping every reaction. Such a stream has no
|
|
2354
2421
|
// autoclose: `app.close` still closes it.
|
|
2355
|
-
resolver: (e) =>
|
|
2422
|
+
resolver: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (e) => _chunkPDMLWC77cjs.isStreamName.call(void 0, e.stream) ? {
|
|
2356
2423
|
target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
|
|
2357
2424
|
source: e.stream
|
|
2358
|
-
} : void 0,
|
|
2425
|
+
} : void 0, "resolver"),
|
|
2359
2426
|
// Never block on autoclose: a transient query/store error should retry,
|
|
2360
2427
|
// not quarantine the synthetic stream.
|
|
2361
|
-
options: { blockOnError: false, maxRetries:
|
|
2362
|
-
handler: async (event) => {
|
|
2428
|
+
options: { blockOnError: false, maxRetries: _chunkOW67FBYOcjs.DEFAULT_MAX_RETRIES },
|
|
2429
|
+
handler: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async (event) => {
|
|
2363
2430
|
const aggregate = event.stream;
|
|
2364
2431
|
const window = read_window();
|
|
2365
2432
|
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
2366
|
-
throw new (0,
|
|
2367
|
-
const stats = await
|
|
2433
|
+
throw new (0, _chunkQSXWCJ2Ucjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
2434
|
+
const stats = await _chunkOW67FBYOcjs.store.call(void 0, ).query_stats([aggregate], {
|
|
2368
2435
|
count: true,
|
|
2369
2436
|
tail: keep_days !== void 0 ? true : void 0,
|
|
2370
|
-
exclude: [
|
|
2437
|
+
exclude: [_chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT, _chunkQSXWCJ2Ucjs.SNAP_EVENT]
|
|
2371
2438
|
});
|
|
2372
2439
|
const entry = stats.get(aggregate);
|
|
2373
2440
|
if (!entry) return;
|
|
@@ -2405,8 +2472,8 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2405
2472
|
dues.push(days_after(entry.tail.created, keep_days));
|
|
2406
2473
|
const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
|
|
2407
2474
|
if (future.length)
|
|
2408
|
-
throw new (0,
|
|
2409
|
-
}
|
|
2475
|
+
throw new (0, _chunkQSXWCJ2Ucjs.DeferSignal)({ at: new Date(Math.min(...future)) });
|
|
2476
|
+
}, "handler")
|
|
2410
2477
|
};
|
|
2411
2478
|
const key = `__autoclose_${st.name}`;
|
|
2412
2479
|
for (const event_name of Object.keys(st.events)) {
|
|
@@ -2417,6 +2484,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2417
2484
|
}
|
|
2418
2485
|
}
|
|
2419
2486
|
}
|
|
2487
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, synthesize_autoclose_reactions, "synthesize_autoclose_reactions");
|
|
2420
2488
|
|
|
2421
2489
|
// src/internal/close-cycle.ts
|
|
2422
2490
|
var CLOSE_CATCH_UP_LIMIT = 1e3;
|
|
@@ -2430,16 +2498,20 @@ async function catch_up_correlation(cursor, correlate, until) {
|
|
|
2430
2498
|
}
|
|
2431
2499
|
return cursor.checkpoint;
|
|
2432
2500
|
}
|
|
2501
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, catch_up_correlation, "catch_up_correlation");
|
|
2433
2502
|
var CloseLock = (_class4 = class {constructor() { _class4.prototype.__init9.call(this); }
|
|
2503
|
+
static {
|
|
2504
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "CloseLock");
|
|
2505
|
+
}
|
|
2434
2506
|
__init9() {this._tails = /* @__PURE__ */ new Map()}
|
|
2435
2507
|
/** Run `work` after every earlier close of `stream` has settled. */
|
|
2436
2508
|
run(stream, work) {
|
|
2437
2509
|
const prev = _nullishCoalesce(this._tails.get(stream), () => ( Promise.resolve()));
|
|
2438
2510
|
const next = prev.then(work, work);
|
|
2439
2511
|
this._tails.set(stream, next);
|
|
2440
|
-
const cleanup = () => {
|
|
2512
|
+
const cleanup = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => {
|
|
2441
2513
|
if (this._tails.get(stream) === next) this._tails.delete(stream);
|
|
2442
|
-
};
|
|
2514
|
+
}, "cleanup");
|
|
2443
2515
|
next.then(cleanup, cleanup);
|
|
2444
2516
|
return next;
|
|
2445
2517
|
}
|
|
@@ -2465,11 +2537,12 @@ async function run_close_cycle(targets, deps) {
|
|
|
2465
2537
|
deps,
|
|
2466
2538
|
() => run_full_closes(full, target_map, deps, skipped)
|
|
2467
2539
|
);
|
|
2468
|
-
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name ===
|
|
2540
|
+
const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT).map(([stream]) => stream);
|
|
2469
2541
|
if (retired.length) _optionalChain([deps, 'access', _133 => _133.forget_subscribed, 'optionalCall', _134 => _134(retired)]);
|
|
2470
2542
|
for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
|
|
2471
2543
|
return { truncated, skipped };
|
|
2472
2544
|
}
|
|
2545
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, run_close_cycle, "run_close_cycle");
|
|
2473
2546
|
function with_stream_locks(streams, deps, work) {
|
|
2474
2547
|
const with_lock = _nullishCoalesce(deps.with_stream_lock, () => ( ((_stream, w) => w())));
|
|
2475
2548
|
return [...streams].sort().reduceRight(
|
|
@@ -2477,6 +2550,7 @@ function with_stream_locks(streams, deps, work) {
|
|
|
2477
2550
|
work
|
|
2478
2551
|
)();
|
|
2479
2552
|
}
|
|
2553
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, with_stream_locks, "with_stream_locks");
|
|
2480
2554
|
async function run_full_closes(full, target_map, deps, skipped) {
|
|
2481
2555
|
const none = /* @__PURE__ */ new Map();
|
|
2482
2556
|
const streams = full.map((t) => t.stream);
|
|
@@ -2532,6 +2606,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
|
|
|
2532
2606
|
deps.correlation
|
|
2533
2607
|
);
|
|
2534
2608
|
}
|
|
2609
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, run_full_closes, "run_full_closes");
|
|
2535
2610
|
async function run_windowed_closes(windowed, deps, skipped) {
|
|
2536
2611
|
const checkpoint = deps.reactive ? await deps.catch_up_correlation(Number.MAX_SAFE_INTEGER) : -1;
|
|
2537
2612
|
const min_at = deps.reactive ? await probe_min_watermarks(
|
|
@@ -2547,7 +2622,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2547
2622
|
if (!await windowed_prune_pending(t.stream, t.before, max_id))
|
|
2548
2623
|
return void 0;
|
|
2549
2624
|
if (t.archive) await t.archive();
|
|
2550
|
-
const result = await
|
|
2625
|
+
const result = await _chunkOW67FBYOcjs.store.call(void 0, ).truncate([
|
|
2551
2626
|
{ stream: t.stream, before: t.before, max_id }
|
|
2552
2627
|
]);
|
|
2553
2628
|
return result.get(t.stream);
|
|
@@ -2557,24 +2632,26 @@ async function run_windowed_closes(windowed, deps, skipped) {
|
|
|
2557
2632
|
}
|
|
2558
2633
|
return truncated;
|
|
2559
2634
|
}
|
|
2635
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, run_windowed_closes, "run_windowed_closes");
|
|
2560
2636
|
async function windowed_prune_pending(stream, before, max_id) {
|
|
2561
2637
|
let boundary_id;
|
|
2562
2638
|
let min_id;
|
|
2563
|
-
await
|
|
2639
|
+
await _chunkOW67FBYOcjs.store.call(void 0, ).query(
|
|
2564
2640
|
(event) => {
|
|
2565
2641
|
if (min_id === void 0 || event.id < min_id) min_id = event.id;
|
|
2566
|
-
if (event.name ===
|
|
2642
|
+
if (event.name === _chunkQSXWCJ2Ucjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
|
|
2567
2643
|
boundary_id = event.id;
|
|
2568
2644
|
},
|
|
2569
2645
|
{ stream, stream_exact: true, with_snaps: true, after: -1 }
|
|
2570
2646
|
);
|
|
2571
2647
|
return boundary_id !== void 0 && min_id < boundary_id;
|
|
2572
2648
|
}
|
|
2649
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, windowed_prune_pending, "windowed_prune_pending");
|
|
2573
2650
|
async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
2574
2651
|
const min_at = /* @__PURE__ */ new Map();
|
|
2575
2652
|
const matches = source_matcher();
|
|
2576
2653
|
await walk_streams(
|
|
2577
|
-
|
|
2654
|
+
_chunkOW67FBYOcjs.store.call(void 0, ),
|
|
2578
2655
|
(position) => {
|
|
2579
2656
|
const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
|
|
2580
2657
|
const cap = pending ? position.at : Math.max(position.at, checkpoint);
|
|
@@ -2589,11 +2666,12 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
|
|
|
2589
2666
|
);
|
|
2590
2667
|
return min_at;
|
|
2591
2668
|
}
|
|
2669
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, probe_min_watermarks, "probe_min_watermarks");
|
|
2592
2670
|
function source_matcher() {
|
|
2593
2671
|
const compiled = /* @__PURE__ */ new Map();
|
|
2594
2672
|
return (source, target, stream) => {
|
|
2595
2673
|
if (!source) return true;
|
|
2596
|
-
if (
|
|
2674
|
+
if (_chunkPDMLWC77cjs.isStreamName.call(void 0, source, target)) return source === stream;
|
|
2597
2675
|
let re = compiled.get(source);
|
|
2598
2676
|
if (!re) {
|
|
2599
2677
|
re = new RegExp(source);
|
|
@@ -2602,18 +2680,19 @@ function source_matcher() {
|
|
|
2602
2680
|
return re.test(stream);
|
|
2603
2681
|
};
|
|
2604
2682
|
}
|
|
2683
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, source_matcher, "source_matcher");
|
|
2605
2684
|
async function scan_stream_heads(streams) {
|
|
2606
|
-
const stats = await
|
|
2607
|
-
exclude: [
|
|
2685
|
+
const stats = await _chunkOW67FBYOcjs.store.call(void 0, ).query_stats(streams, {
|
|
2686
|
+
exclude: [_chunkQSXWCJ2Ucjs.SNAP_EVENT]
|
|
2608
2687
|
});
|
|
2609
|
-
const domain_heads = await
|
|
2610
|
-
exclude: [
|
|
2688
|
+
const domain_heads = await _chunkOW67FBYOcjs.store.call(void 0, ).query_stats(streams, {
|
|
2689
|
+
exclude: [_chunkQSXWCJ2Ucjs.SNAP_EVENT, _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT]
|
|
2611
2690
|
});
|
|
2612
|
-
const true_heads = await
|
|
2691
|
+
const true_heads = await _chunkOW67FBYOcjs.store.call(void 0, ).query_stats(streams, {});
|
|
2613
2692
|
const out = /* @__PURE__ */ new Map();
|
|
2614
2693
|
for (const [stream, { head }] of domain_heads) {
|
|
2615
2694
|
const marker_head = _optionalChain([stats, 'access', _136 => _136.get, 'call', _137 => _137(stream), 'optionalAccess', _138 => _138.head]);
|
|
2616
|
-
const interrupted = _optionalChain([marker_head, 'optionalAccess', _139 => _139.name]) ===
|
|
2695
|
+
const interrupted = _optionalChain([marker_head, 'optionalAccess', _139 => _139.name]) === _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT;
|
|
2617
2696
|
out.set(stream, {
|
|
2618
2697
|
max_id: head.id,
|
|
2619
2698
|
version: true_heads.get(stream).head.version,
|
|
@@ -2623,6 +2702,7 @@ async function scan_stream_heads(streams) {
|
|
|
2623
2702
|
}
|
|
2624
2703
|
return out;
|
|
2625
2704
|
}
|
|
2705
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, scan_stream_heads, "scan_stream_heads");
|
|
2626
2706
|
async function partition_by_safety(stream_info, reactive, skipped, page_size, catch_up_correlation2) {
|
|
2627
2707
|
if (!reactive) return [...stream_info.keys()];
|
|
2628
2708
|
let needed = -1;
|
|
@@ -2636,7 +2716,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2636
2716
|
const pending_set = /* @__PURE__ */ new Set();
|
|
2637
2717
|
const matches = source_matcher();
|
|
2638
2718
|
await walk_streams(
|
|
2639
|
-
|
|
2719
|
+
_chunkOW67FBYOcjs.store.call(void 0, ),
|
|
2640
2720
|
(position) => {
|
|
2641
2721
|
const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
|
|
2642
2722
|
if (!has_work) return;
|
|
@@ -2656,6 +2736,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
|
|
|
2656
2736
|
}
|
|
2657
2737
|
return safe;
|
|
2658
2738
|
}
|
|
2739
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, partition_by_safety, "partition_by_safety");
|
|
2659
2740
|
async function guard_with_tombstones(safe, stream_info, correlation, tombstone2, skipped) {
|
|
2660
2741
|
const guarded = [];
|
|
2661
2742
|
const guard_events = /* @__PURE__ */ new Map();
|
|
@@ -2678,6 +2759,7 @@ async function guard_with_tombstones(safe, stream_info, correlation, tombstone2,
|
|
|
2678
2759
|
);
|
|
2679
2760
|
return { guarded, guard_events };
|
|
2680
2761
|
}
|
|
2762
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, guard_with_tombstones, "guard_with_tombstones");
|
|
2681
2763
|
async function load_restart_seeds(guarded, target_map, stream_info, event_to_state, load2, logger) {
|
|
2682
2764
|
const seed_states = /* @__PURE__ */ new Map();
|
|
2683
2765
|
await Promise.all(
|
|
@@ -2696,14 +2778,16 @@ async function load_restart_seeds(guarded, target_map, stream_info, event_to_sta
|
|
|
2696
2778
|
);
|
|
2697
2779
|
return seed_states;
|
|
2698
2780
|
}
|
|
2781
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, load_restart_seeds, "load_restart_seeds");
|
|
2699
2782
|
async function run_archive_callbacks(guarded, target_map) {
|
|
2700
2783
|
for (const stream of guarded) {
|
|
2701
2784
|
const archive_fn = _optionalChain([target_map, 'access', _143 => _143.get, 'call', _144 => _144(stream), 'optionalAccess', _145 => _145.archive]);
|
|
2702
2785
|
if (archive_fn) await archive_fn();
|
|
2703
2786
|
}
|
|
2704
2787
|
}
|
|
2788
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, run_archive_callbacks, "run_archive_callbacks");
|
|
2705
2789
|
async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
2706
|
-
const heads = await
|
|
2790
|
+
const heads = await _chunkOW67FBYOcjs.store.call(void 0, ).query_stats(guarded, {});
|
|
2707
2791
|
return guarded.filter((stream) => {
|
|
2708
2792
|
if (_optionalChain([heads, 'access', _146 => _146.get, 'call', _147 => _147(stream), 'optionalAccess', _148 => _148.head, 'access', _149 => _149.id]) === guard_events.get(stream).id)
|
|
2709
2793
|
return true;
|
|
@@ -2711,6 +2795,7 @@ async function heads_still_guarded(guarded, guard_events, skipped) {
|
|
|
2711
2795
|
return false;
|
|
2712
2796
|
});
|
|
2713
2797
|
}
|
|
2798
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, heads_still_guarded, "heads_still_guarded");
|
|
2714
2799
|
async function truncate_and_warm_cache(guarded, seed_states, guard_events, correlation) {
|
|
2715
2800
|
const trunc_targets = guarded.map((stream) => {
|
|
2716
2801
|
const snapshot = seed_states.get(stream);
|
|
@@ -2721,18 +2806,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2721
2806
|
meta: {
|
|
2722
2807
|
correlation,
|
|
2723
2808
|
causation: {
|
|
2724
|
-
event: { id: guard.id, name:
|
|
2809
|
+
event: { id: guard.id, name: _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT, stream: guard.stream }
|
|
2725
2810
|
}
|
|
2726
2811
|
}
|
|
2727
2812
|
};
|
|
2728
2813
|
});
|
|
2729
|
-
const truncated = await
|
|
2814
|
+
const truncated = await _chunkOW67FBYOcjs.store.call(void 0, ).truncate(trunc_targets);
|
|
2730
2815
|
await Promise.all(
|
|
2731
2816
|
guarded.map(async (stream) => {
|
|
2732
2817
|
const entry = truncated.get(stream);
|
|
2733
2818
|
const state2 = seed_states.get(stream);
|
|
2734
2819
|
if (state2 && entry) {
|
|
2735
|
-
await
|
|
2820
|
+
await _chunkOW67FBYOcjs.cache.call(void 0, ).set(stream, {
|
|
2736
2821
|
stream,
|
|
2737
2822
|
state: state2,
|
|
2738
2823
|
version: entry.committed.version,
|
|
@@ -2741,21 +2826,22 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
|
|
|
2741
2826
|
snaps: 1
|
|
2742
2827
|
});
|
|
2743
2828
|
} else {
|
|
2744
|
-
await
|
|
2829
|
+
await _chunkOW67FBYOcjs.cache.call(void 0, ).invalidate(stream);
|
|
2745
2830
|
}
|
|
2746
2831
|
})
|
|
2747
2832
|
);
|
|
2748
2833
|
return truncated;
|
|
2749
2834
|
}
|
|
2835
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, truncate_and_warm_cache, "truncate_and_warm_cache");
|
|
2750
2836
|
|
|
2751
2837
|
// src/internal/correlate-cycle.ts
|
|
2752
2838
|
|
|
2753
2839
|
var COLD_START_BACK_SCAN = 1e4;
|
|
2754
2840
|
var CORRELATION_LEASE_MS = 5e3;
|
|
2755
|
-
var registry_key = (events) => {
|
|
2841
|
+
var registry_key = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (events) => {
|
|
2756
2842
|
const shape = Object.keys(events).filter((name) => events[name].reactions.size > 0).sort().map((name) => [name, [...events[name].reactions.keys()].sort()]);
|
|
2757
2843
|
return _crypto.createHash.call(void 0, "sha256").update(JSON.stringify(shape)).digest("hex").slice(0, 32);
|
|
2758
|
-
};
|
|
2844
|
+
}, "registry_key");
|
|
2759
2845
|
var PATTERN_CACHE_SIZE = 32;
|
|
2760
2846
|
function report_undeclared_lane(seen, handler, target, lane, declared) {
|
|
2761
2847
|
report_once(
|
|
@@ -2764,6 +2850,7 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
|
|
|
2764
2850
|
`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.`
|
|
2765
2851
|
);
|
|
2766
2852
|
}
|
|
2853
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, report_undeclared_lane, "report_undeclared_lane");
|
|
2767
2854
|
function report_bad_priority(seen, handler, target, priority) {
|
|
2768
2855
|
report_once(
|
|
2769
2856
|
seen,
|
|
@@ -2771,6 +2858,7 @@ function report_bad_priority(seen, handler, target, priority) {
|
|
|
2771
2858
|
`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.`
|
|
2772
2859
|
);
|
|
2773
2860
|
}
|
|
2861
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, report_bad_priority, "report_bad_priority");
|
|
2774
2862
|
function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
2775
2863
|
report_once(
|
|
2776
2864
|
seen,
|
|
@@ -2778,7 +2866,11 @@ function report_lane_conflict(seen, handler, target, kept, dropped) {
|
|
|
2778
2866
|
`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.`
|
|
2779
2867
|
);
|
|
2780
2868
|
}
|
|
2869
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, report_lane_conflict, "report_lane_conflict");
|
|
2781
2870
|
var CorrelateCycle = (_class5 = class {
|
|
2871
|
+
static {
|
|
2872
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "CorrelateCycle");
|
|
2873
|
+
}
|
|
2782
2874
|
__init10() {this._checkpoint = -1}
|
|
2783
2875
|
// Lease holder id; per instance, so a restart never inherits a stale claim.
|
|
2784
2876
|
__init11() {this._by = _crypto.randomUUID.call(void 0, )}
|
|
@@ -2800,7 +2892,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2800
2892
|
// never lets a resolution re-lane them.
|
|
2801
2893
|
|
|
2802
2894
|
__init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
|
|
2803
|
-
__init19() {this._patterns = new (0,
|
|
2895
|
+
__init19() {this._patterns = new (0, _chunkOW67FBYOcjs.LruMap)(PATTERN_CACHE_SIZE)}
|
|
2804
2896
|
|
|
2805
2897
|
|
|
2806
2898
|
|
|
@@ -2818,7 +2910,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2818
2910
|
on_init
|
|
2819
2911
|
}) {;_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);
|
|
2820
2912
|
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
2821
|
-
this._dynamic_subscriptions = new (0,
|
|
2913
|
+
this._dynamic_subscriptions = new (0, _chunkOW67FBYOcjs.LruMap)(max_subscribed_streams);
|
|
2822
2914
|
this._registry = registry;
|
|
2823
2915
|
this._declared_lanes = declared_lanes;
|
|
2824
2916
|
this._static_targets = static_targets;
|
|
@@ -2876,7 +2968,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2876
2968
|
// Would the target's own `fetch` (filtered by `source`) return this event?
|
|
2877
2969
|
_in_fetch_window(source, stream) {
|
|
2878
2970
|
if (source === void 0 || source === stream) return true;
|
|
2879
|
-
if (
|
|
2971
|
+
if (_chunkPDMLWC77cjs.isStreamName.call(void 0, source)) return false;
|
|
2880
2972
|
let pattern = this._patterns.get(source);
|
|
2881
2973
|
if (!pattern) {
|
|
2882
2974
|
pattern = new RegExp(source);
|
|
@@ -2898,10 +2990,10 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2898
2990
|
async _scan(limit, lease) {
|
|
2899
2991
|
await this._init();
|
|
2900
2992
|
const epoch = this._epoch;
|
|
2901
|
-
const idle = () => ({
|
|
2993
|
+
const idle = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => ({
|
|
2902
2994
|
kind: "idle",
|
|
2903
2995
|
last_id: this._checkpoint
|
|
2904
|
-
});
|
|
2996
|
+
}), "idle");
|
|
2905
2997
|
if (this._raised === this._lowered) return idle();
|
|
2906
2998
|
const raised = this._raised;
|
|
2907
2999
|
const now = Date.now();
|
|
@@ -2919,7 +3011,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2919
3011
|
const correlated = /* @__PURE__ */ new Map();
|
|
2920
3012
|
let last_id = after;
|
|
2921
3013
|
let stopped = false;
|
|
2922
|
-
const found = await
|
|
3014
|
+
const found = await _chunkOW67FBYOcjs.store.call(void 0, ).query(
|
|
2923
3015
|
(event) => {
|
|
2924
3016
|
if (stopped) return;
|
|
2925
3017
|
const register = this._registry.events[event.name];
|
|
@@ -2939,7 +3031,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2939
3031
|
}
|
|
2940
3032
|
if (!resolved) continue;
|
|
2941
3033
|
try {
|
|
2942
|
-
|
|
3034
|
+
_chunkOW67FBYOcjs.check.call(void 0, "target", resolved);
|
|
2943
3035
|
} catch (e2) {
|
|
2944
3036
|
report_bad_priority(
|
|
2945
3037
|
this._reported,
|
|
@@ -2975,9 +3067,9 @@ var CorrelateCycle = (_class5 = class {
|
|
|
2975
3067
|
correlated_at: void 0
|
|
2976
3068
|
};
|
|
2977
3069
|
const seen_in_scan = correlated.has(resolved.target);
|
|
2978
|
-
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _152 => _152.lane])), () => (
|
|
3070
|
+
const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _152 => _152.lane])), () => ( _chunkQSXWCJ2Ucjs.DEFAULT_LANE));
|
|
2979
3071
|
const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _153 => _153.priority]);
|
|
2980
|
-
const resolved_lane = _nullishCoalesce(lane, () => (
|
|
3072
|
+
const resolved_lane = _nullishCoalesce(lane, () => ( _chunkQSXWCJ2Ucjs.DEFAULT_LANE));
|
|
2981
3073
|
if (held_priority === priority && held_lane !== resolved_lane)
|
|
2982
3074
|
report_lane_conflict(
|
|
2983
3075
|
this._reported,
|
|
@@ -3051,7 +3143,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3051
3143
|
await Promise.all(
|
|
3052
3144
|
missed.map(async ([stream, entry]) => {
|
|
3053
3145
|
let row;
|
|
3054
|
-
await
|
|
3146
|
+
await _chunkOW67FBYOcjs.store.call(void 0, ).query_streams(
|
|
3055
3147
|
(position) => {
|
|
3056
3148
|
row = position;
|
|
3057
3149
|
},
|
|
@@ -3063,8 +3155,8 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3063
3155
|
lane: row.lane
|
|
3064
3156
|
});
|
|
3065
3157
|
if (entry.priority > row.priority) return;
|
|
3066
|
-
const held_lane = _nullishCoalesce(row.lane, () => (
|
|
3067
|
-
const resolved_lane = _nullishCoalesce(entry.lane, () => (
|
|
3158
|
+
const held_lane = _nullishCoalesce(row.lane, () => ( _chunkQSXWCJ2Ucjs.DEFAULT_LANE));
|
|
3159
|
+
const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkQSXWCJ2Ucjs.DEFAULT_LANE));
|
|
3068
3160
|
if (entry.priority === row.priority && held_lane !== resolved_lane)
|
|
3069
3161
|
report_lane_conflict(
|
|
3070
3162
|
this._reported,
|
|
@@ -3090,7 +3182,7 @@ var CorrelateCycle = (_class5 = class {
|
|
|
3090
3182
|
millis: 0
|
|
3091
3183
|
});
|
|
3092
3184
|
} catch (error) {
|
|
3093
|
-
|
|
3185
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).warn(
|
|
3094
3186
|
`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)))}`
|
|
3095
3187
|
);
|
|
3096
3188
|
}
|
|
@@ -3109,12 +3201,13 @@ function pii_split(emitted, fields) {
|
|
|
3109
3201
|
}
|
|
3110
3202
|
return { name: emitted.name, data, pii };
|
|
3111
3203
|
}
|
|
3204
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, pii_split, "pii_split");
|
|
3112
3205
|
function pii_gate(event, fields, predicate, actor) {
|
|
3113
3206
|
const data = event.data;
|
|
3114
3207
|
const { pii, ...rest } = event;
|
|
3115
3208
|
if (pii == null) {
|
|
3116
3209
|
const shredded = { ...data };
|
|
3117
|
-
for (const f of fields) shredded[f] =
|
|
3210
|
+
for (const f of fields) shredded[f] = _chunkQSXWCJ2Ucjs.SHREDDED;
|
|
3118
3211
|
return { ...rest, data: shredded };
|
|
3119
3212
|
}
|
|
3120
3213
|
const allowed = !!actor && !!predicate && predicate(event, actor);
|
|
@@ -3125,13 +3218,15 @@ function pii_gate(event, fields, predicate, actor) {
|
|
|
3125
3218
|
};
|
|
3126
3219
|
}
|
|
3127
3220
|
const redacted = { ...data };
|
|
3128
|
-
for (const f of fields) redacted[f] =
|
|
3221
|
+
for (const f of fields) redacted[f] = _chunkQSXWCJ2Ucjs.REDACTED;
|
|
3129
3222
|
return { ...rest, data: redacted };
|
|
3130
3223
|
}
|
|
3131
|
-
|
|
3224
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, pii_gate, "pii_gate");
|
|
3225
|
+
var IDENTITY_GATE = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (event) => event, "IDENTITY_GATE");
|
|
3132
3226
|
function make_gate(fields, predicate) {
|
|
3133
3227
|
return (event, actor) => pii_gate(event, fields, predicate, actor);
|
|
3134
3228
|
}
|
|
3229
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, make_gate, "make_gate");
|
|
3135
3230
|
function pii_strip(event, fields) {
|
|
3136
3231
|
const data = event.data;
|
|
3137
3232
|
const stripped = {};
|
|
@@ -3144,21 +3239,22 @@ function pii_strip(event, fields) {
|
|
|
3144
3239
|
data: stripped
|
|
3145
3240
|
};
|
|
3146
3241
|
}
|
|
3242
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, pii_strip, "pii_strip");
|
|
3147
3243
|
|
|
3148
3244
|
// src/internal/projection-fold.ts
|
|
3149
3245
|
var FOLD_RESET = /* @__PURE__ */ Symbol("act.fold.reset");
|
|
3150
3246
|
function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
3151
3247
|
const load_me = {
|
|
3152
3248
|
...me,
|
|
3153
|
-
view: (raw, actor) => {
|
|
3249
|
+
view: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (raw, actor) => {
|
|
3154
3250
|
const viewed = me.view(raw, actor);
|
|
3155
3251
|
const fields = sensitive_fields(viewed.name);
|
|
3156
3252
|
return fields.length ? pii_strip(viewed, fields) : viewed;
|
|
3157
|
-
}
|
|
3253
|
+
}, "view")
|
|
3158
3254
|
};
|
|
3159
3255
|
const cache2 = /* @__PURE__ */ new Map();
|
|
3160
|
-
const row = ({ dirty: _, ...row2 }) => row2;
|
|
3161
|
-
const flush_dirty = async () => {
|
|
3256
|
+
const row = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, ({ dirty: _, ...row2 }) => row2, "row");
|
|
3257
|
+
const flush_dirty = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async () => {
|
|
3162
3258
|
const rows = [];
|
|
3163
3259
|
const flushed = [];
|
|
3164
3260
|
for (const f of cache2.values())
|
|
@@ -3169,8 +3265,8 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3169
3265
|
if (rows.length === 0) return;
|
|
3170
3266
|
await flush(rows);
|
|
3171
3267
|
for (const f of flushed) f.dirty = false;
|
|
3172
|
-
};
|
|
3173
|
-
const first_sight = async (stream) => {
|
|
3268
|
+
}, "flush_dirty");
|
|
3269
|
+
const first_sight = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async (stream) => {
|
|
3174
3270
|
if (cache2.size >= config2.maxCachedStates) {
|
|
3175
3271
|
const oldest = cache2.keys().next().value;
|
|
3176
3272
|
const evictee = cache2.get(oldest);
|
|
@@ -3189,8 +3285,8 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3189
3285
|
};
|
|
3190
3286
|
cache2.set(stream, seated);
|
|
3191
3287
|
return seated;
|
|
3192
|
-
};
|
|
3193
|
-
const handler = async (events) => {
|
|
3288
|
+
}, "first_sight");
|
|
3289
|
+
const handler = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async (events) => {
|
|
3194
3290
|
let folded_since_flush = 0;
|
|
3195
3291
|
for (const event of events) {
|
|
3196
3292
|
const stream = event.stream;
|
|
@@ -3227,13 +3323,17 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
|
|
|
3227
3323
|
}
|
|
3228
3324
|
}
|
|
3229
3325
|
await flush_dirty();
|
|
3230
|
-
};
|
|
3231
|
-
Object.defineProperty(handler, FOLD_RESET, { value: () => cache2.clear() });
|
|
3326
|
+
}, "handler");
|
|
3327
|
+
Object.defineProperty(handler, FOLD_RESET, { value: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => cache2.clear(), "value") });
|
|
3232
3328
|
return handler;
|
|
3233
3329
|
}
|
|
3330
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, make_fold_handler, "make_fold_handler");
|
|
3234
3331
|
|
|
3235
3332
|
// src/internal/settle.ts
|
|
3236
3333
|
var SettleLoop = (_class6 = class {
|
|
3334
|
+
static {
|
|
3335
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "SettleLoop");
|
|
3336
|
+
}
|
|
3237
3337
|
__init21() {this._timer = void 0}
|
|
3238
3338
|
// The cycle in flight, set while one runs. Shutdown waits for it
|
|
3239
3339
|
// (`stop()` cancels scheduling only). Never rejects.
|
|
@@ -3334,6 +3434,9 @@ var SettleLoop = (_class6 = class {
|
|
|
3334
3434
|
|
|
3335
3435
|
// src/act.ts
|
|
3336
3436
|
var Act = (_class7 = class {
|
|
3437
|
+
static {
|
|
3438
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "Act");
|
|
3439
|
+
}
|
|
3337
3440
|
__init26() {this._emitter = new (0, _events2.default)()}
|
|
3338
3441
|
|
|
3339
3442
|
|
|
@@ -3420,7 +3523,7 @@ var Act = (_class7 = class {
|
|
|
3420
3523
|
// Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
|
|
3421
3524
|
|
|
3422
3525
|
|
|
3423
|
-
__init27() {this._logger =
|
|
3526
|
+
__init27() {this._logger = _chunkOW67FBYOcjs.log.call(void 0, )}
|
|
3424
3527
|
// This Act's ports: its own bag, or the singleton adapters.
|
|
3425
3528
|
|
|
3426
3529
|
// Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
|
|
@@ -3449,10 +3552,10 @@ var Act = (_class7 = class {
|
|
|
3449
3552
|
throw new Error(
|
|
3450
3553
|
`ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
|
|
3451
3554
|
);
|
|
3452
|
-
if (options.scoped)
|
|
3453
|
-
this._ports = _nullishCoalesce(options.scoped, () => (
|
|
3555
|
+
if (options.scoped) _chunkOW67FBYOcjs.check.call(void 0, "store", options.scoped.store);
|
|
3556
|
+
this._ports = _nullishCoalesce(options.scoped, () => ( _chunkOW67FBYOcjs.unscoped_ports.call(void 0, )));
|
|
3454
3557
|
const ports = this._ports;
|
|
3455
|
-
this._scoped =
|
|
3558
|
+
this._scoped = _chunkOW67FBYOcjs.make_run_scoped.call(void 0, {
|
|
3456
3559
|
// Getters, not a spread: the singletons resolve lazily, so a later
|
|
3457
3560
|
// `store(...)` / `cache(...)` still takes effect.
|
|
3458
3561
|
get store() {
|
|
@@ -3462,14 +3565,14 @@ var Act = (_class7 = class {
|
|
|
3462
3565
|
return ports.cache;
|
|
3463
3566
|
},
|
|
3464
3567
|
// Parsed per build, so a bad window throws on every build.
|
|
3465
|
-
autoclose_window:
|
|
3568
|
+
autoclose_window: _chunkOW67FBYOcjs.check.call(void 0, "autoclose", options).autocloseWindow
|
|
3466
3569
|
});
|
|
3467
3570
|
this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
|
|
3468
3571
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3469
3572
|
this._cd = build_drain(this._logger);
|
|
3470
3573
|
const handle = build_handle({
|
|
3471
3574
|
logger: this._logger,
|
|
3472
|
-
reaction_scope:
|
|
3575
|
+
reaction_scope: _chunkOW67FBYOcjs.make_reaction_scope.call(void 0, {
|
|
3473
3576
|
do: this.do.bind(this),
|
|
3474
3577
|
load: this.load.bind(this),
|
|
3475
3578
|
query: this.query.bind(this),
|
|
@@ -3499,17 +3602,17 @@ var Act = (_class7 = class {
|
|
|
3499
3602
|
this._ports.store,
|
|
3500
3603
|
options.listen !== false
|
|
3501
3604
|
);
|
|
3502
|
-
|
|
3605
|
+
_chunkOW67FBYOcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
|
|
3503
3606
|
}
|
|
3504
3607
|
// Shared by drain, settle and autoclose; bad knobs throw at build.
|
|
3505
3608
|
_build_breaker(options) {
|
|
3506
3609
|
return new CircuitBreaker(
|
|
3507
|
-
|
|
3610
|
+
_chunkOW67FBYOcjs.check.call(void 0, "circuit_breaker", _nullishCoalesce(options.circuitBreaker, () => ( {}))),
|
|
3508
3611
|
{
|
|
3509
|
-
on_error: (error, circuit) => this._emit_error(error, circuit),
|
|
3612
|
+
on_error: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (error, circuit) => this._emit_error(error, circuit), "on_error"),
|
|
3510
3613
|
// When the cooldown elapses, settle once: its scan or claim is the
|
|
3511
3614
|
// half-open probe that closes or re-opens the breaker.
|
|
3512
|
-
on_retry: () => this._schedule()
|
|
3615
|
+
on_retry: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => this._schedule(), "on_retry")
|
|
3513
3616
|
}
|
|
3514
3617
|
);
|
|
3515
3618
|
}
|
|
@@ -3529,22 +3632,22 @@ var Act = (_class7 = class {
|
|
|
3529
3632
|
batch_handlers: this._batch_handlers,
|
|
3530
3633
|
handle,
|
|
3531
3634
|
handle_batch,
|
|
3532
|
-
on_acked: (acked) => this.emit("acked", acked),
|
|
3533
|
-
on_blocked: (blocked) => this.emit("blocked", blocked),
|
|
3635
|
+
on_acked: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (acked) => this.emit("acked", acked), "on_acked"),
|
|
3636
|
+
on_blocked: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (blocked) => this.emit("blocked", blocked), "on_blocked"),
|
|
3534
3637
|
// Reaction-requested close: the same machinery as `app.close`.
|
|
3535
3638
|
// A store failure reaches the breaker; anything else (the archive
|
|
3536
3639
|
// callback is app code) is logged here, never counted.
|
|
3537
|
-
on_close: async (targets) => {
|
|
3640
|
+
on_close: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async (targets) => {
|
|
3538
3641
|
try {
|
|
3539
3642
|
await this._run_close(targets);
|
|
3540
3643
|
} catch (error) {
|
|
3541
|
-
if (error instanceof
|
|
3644
|
+
if (error instanceof _chunkQSXWCJ2Ucjs.StoreError) throw error;
|
|
3542
3645
|
this._logger.error(
|
|
3543
3646
|
error,
|
|
3544
3647
|
`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.`
|
|
3545
3648
|
);
|
|
3546
3649
|
}
|
|
3547
|
-
},
|
|
3650
|
+
}, "on_close"),
|
|
3548
3651
|
breaker: this._breaker,
|
|
3549
3652
|
run_scoped: this._scoped,
|
|
3550
3653
|
lane: single_default_lane ? void 0 : name,
|
|
@@ -3572,7 +3675,7 @@ var Act = (_class7 = class {
|
|
|
3572
3675
|
// Audit deps, built after the controllers so the lane set is final.
|
|
3573
3676
|
_build_audit_deps() {
|
|
3574
3677
|
return {
|
|
3575
|
-
store:
|
|
3678
|
+
store: _chunkOW67FBYOcjs.store,
|
|
3576
3679
|
event_to_state: this._event_to_state,
|
|
3577
3680
|
// Declared lanes, not this process's controllers: a lane another
|
|
3578
3681
|
// worker drains is not `unknown-lane`.
|
|
@@ -3585,23 +3688,23 @@ var Act = (_class7 = class {
|
|
|
3585
3688
|
registry: this.registry,
|
|
3586
3689
|
static_targets: classification.static_targets,
|
|
3587
3690
|
cd: this._cd,
|
|
3588
|
-
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => (
|
|
3691
|
+
max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkQSXWCJ2Ucjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
|
|
3589
3692
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3590
3693
|
// still a valid destination.
|
|
3591
3694
|
declared_lanes: new Set(this._declared_lanes),
|
|
3592
3695
|
// Built after the controllers, so their keys are the active lanes.
|
|
3593
3696
|
shard: this._drain_controllers.size < this._declared_lanes.length ? [...this._drain_controllers.keys()] : void 0,
|
|
3594
3697
|
// Only reached on a draining app: writer-only ones never correlate.
|
|
3595
|
-
on_init: async () => {
|
|
3698
|
+
on_init: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async () => {
|
|
3596
3699
|
this._arm_all();
|
|
3597
3700
|
await this._seed_persisted_defers();
|
|
3598
|
-
}
|
|
3701
|
+
}, "on_init")
|
|
3599
3702
|
});
|
|
3600
3703
|
}
|
|
3601
3704
|
// Cold start: an idle deferred stream still fires on time after a restart.
|
|
3602
3705
|
async _seed_persisted_defers() {
|
|
3603
3706
|
const now = Date.now();
|
|
3604
|
-
await walk_streams(
|
|
3707
|
+
await walk_streams(_chunkOW67FBYOcjs.store.call(void 0, ), (pos) => {
|
|
3605
3708
|
if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
|
|
3606
3709
|
const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
|
|
3607
3710
|
_optionalChain([controller, 'optionalAccess', _161 => _161.seed_defer, 'call', _162 => _162(pos.stream, pos.deferred_at)]);
|
|
@@ -3610,14 +3713,14 @@ var Act = (_class7 = class {
|
|
|
3610
3713
|
_build_settle(options) {
|
|
3611
3714
|
return new SettleLoop(
|
|
3612
3715
|
{
|
|
3613
|
-
correlate: (q) => this._correlate_pass(_nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)), true),
|
|
3716
|
+
correlate: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (q) => this._correlate_pass(_nullishCoalesce(_nullishCoalesce(q.limit, () => ( this._poll_limit)), () => ( 100)), true), "correlate"),
|
|
3614
3717
|
// `settle()` validated the options, and `_schedule` skips writer-only
|
|
3615
3718
|
// instances, so the loop drains through the internal path.
|
|
3616
|
-
drain: (o) => this._scoped(() => this._drain_all(o)),
|
|
3617
|
-
on_settled: (drain) => this.emit("settled", drain),
|
|
3719
|
+
drain: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (o) => this._scoped(() => this._drain_all(o)), "drain"),
|
|
3720
|
+
on_settled: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (drain) => this.emit("settled", drain), "on_settled"),
|
|
3618
3721
|
breaker: this._breaker
|
|
3619
3722
|
},
|
|
3620
|
-
_nullishCoalesce(options.settleDebounceMs, () => (
|
|
3723
|
+
_nullishCoalesce(options.settleDebounceMs, () => ( _chunkQSXWCJ2Ucjs.DEFAULT_SETTLE_DEBOUNCE_MS))
|
|
3621
3724
|
);
|
|
3622
3725
|
}
|
|
3623
3726
|
|
|
@@ -3637,7 +3740,7 @@ var Act = (_class7 = class {
|
|
|
3637
3740
|
*/
|
|
3638
3741
|
shutdown(options) {
|
|
3639
3742
|
if (!this._shutdown_promise) {
|
|
3640
|
-
|
|
3743
|
+
_chunkOW67FBYOcjs.check.call(void 0, "shutdown", _nullishCoalesce(options, () => ( {})));
|
|
3641
3744
|
this._shutdown_promise = (async () => {
|
|
3642
3745
|
this.stop_correlations();
|
|
3643
3746
|
this._settle.stop(true);
|
|
@@ -3655,10 +3758,10 @@ var Act = (_class7 = class {
|
|
|
3655
3758
|
// The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
3656
3759
|
// default for none or 0, and for a running settle), capped.
|
|
3657
3760
|
_derive_grace_ms(running, settling) {
|
|
3658
|
-
let max = settling ?
|
|
3761
|
+
let max = settling ? _chunkOW67FBYOcjs.DEFAULT_LEASE_MILLIS : 0;
|
|
3659
3762
|
for (const c of running)
|
|
3660
|
-
max = Math.max(max, c.lease_millis ||
|
|
3661
|
-
return Math.min(max,
|
|
3763
|
+
max = Math.max(max, c.lease_millis || _chunkOW67FBYOcjs.DEFAULT_LEASE_MILLIS);
|
|
3764
|
+
return Math.min(max, _chunkOW67FBYOcjs.MAX_SHUTDOWN_GRACE_MS);
|
|
3662
3765
|
}
|
|
3663
3766
|
async _await_inflight(grace_ms) {
|
|
3664
3767
|
const running = [...this._drain_controllers.values()].filter(
|
|
@@ -3742,7 +3845,7 @@ var Act = (_class7 = class {
|
|
|
3742
3845
|
* @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
|
|
3743
3846
|
*/
|
|
3744
3847
|
async do(action2, target, payload, options) {
|
|
3745
|
-
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _164 => _164.reactingTo]), () => (
|
|
3848
|
+
const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _164 => _164.reactingTo]), () => ( _chunkOW67FBYOcjs.current_reacting.call(void 0, )));
|
|
3746
3849
|
const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _165 => _165.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
|
|
3747
3850
|
return this._scoped(async () => {
|
|
3748
3851
|
const snapshots = await this._es.action(
|
|
@@ -3816,7 +3919,7 @@ var Act = (_class7 = class {
|
|
|
3816
3919
|
return this._scoped(async () => {
|
|
3817
3920
|
let first;
|
|
3818
3921
|
let last;
|
|
3819
|
-
const count = await
|
|
3922
|
+
const count = await _chunkOW67FBYOcjs.store.call(void 0, ).query((e) => {
|
|
3820
3923
|
const gated = this.registry.query_gate(e.name)(e);
|
|
3821
3924
|
if (!first) first = gated;
|
|
3822
3925
|
last = gated;
|
|
@@ -3862,14 +3965,14 @@ var Act = (_class7 = class {
|
|
|
3862
3965
|
*/
|
|
3863
3966
|
async forget(stream) {
|
|
3864
3967
|
return this._scoped(async () => {
|
|
3865
|
-
const s =
|
|
3968
|
+
const s = _chunkOW67FBYOcjs.store.call(void 0, );
|
|
3866
3969
|
if (!s.forget_pii) {
|
|
3867
3970
|
throw new Error(
|
|
3868
3971
|
`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).`
|
|
3869
3972
|
);
|
|
3870
3973
|
}
|
|
3871
3974
|
const eventCount = await s.forget_pii(stream);
|
|
3872
|
-
await
|
|
3975
|
+
await _chunkOW67FBYOcjs.cache.call(void 0, ).invalidate(stream);
|
|
3873
3976
|
if (eventCount > 0) {
|
|
3874
3977
|
this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
|
|
3875
3978
|
}
|
|
@@ -3903,7 +4006,7 @@ var Act = (_class7 = class {
|
|
|
3903
4006
|
* @see {@link correlate} for dynamic stream discovery
|
|
3904
4007
|
*/
|
|
3905
4008
|
async drain(options = {}) {
|
|
3906
|
-
|
|
4009
|
+
_chunkOW67FBYOcjs.check.call(void 0, "drain", options);
|
|
3907
4010
|
if (!this._drain)
|
|
3908
4011
|
return { fetched: [], leased: [], acked: [], blocked: [] };
|
|
3909
4012
|
return this._scoped(() => this._drain_all(options));
|
|
@@ -4090,7 +4193,7 @@ var Act = (_class7 = class {
|
|
|
4090
4193
|
*/
|
|
4091
4194
|
async reset(input) {
|
|
4092
4195
|
return this._scoped(async () => {
|
|
4093
|
-
const count = await
|
|
4196
|
+
const count = await _chunkOW67FBYOcjs.store.call(void 0, ).reset(input);
|
|
4094
4197
|
this._reset_folds();
|
|
4095
4198
|
if (count > 0) {
|
|
4096
4199
|
this._wake();
|
|
@@ -4125,7 +4228,7 @@ var Act = (_class7 = class {
|
|
|
4125
4228
|
*/
|
|
4126
4229
|
async unblock(input) {
|
|
4127
4230
|
return this._scoped(async () => {
|
|
4128
|
-
const count = await
|
|
4231
|
+
const count = await _chunkOW67FBYOcjs.store.call(void 0, ).unblock(input);
|
|
4129
4232
|
if (count > 0) {
|
|
4130
4233
|
this._wake();
|
|
4131
4234
|
}
|
|
@@ -4173,7 +4276,7 @@ var Act = (_class7 = class {
|
|
|
4173
4276
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4174
4277
|
*/
|
|
4175
4278
|
async restore(source, opts = {}, sink) {
|
|
4176
|
-
|
|
4279
|
+
_chunkOW67FBYOcjs.check.call(void 0, "scan", opts);
|
|
4177
4280
|
return this._scoped(async () => {
|
|
4178
4281
|
const started = Date.now();
|
|
4179
4282
|
if (opts.dry_run) {
|
|
@@ -4181,19 +4284,19 @@ var Act = (_class7 = class {
|
|
|
4181
4284
|
return { ...partial, duration_ms: Date.now() - started };
|
|
4182
4285
|
}
|
|
4183
4286
|
const target = _nullishCoalesce(sink, () => ( (() => {
|
|
4184
|
-
const s =
|
|
4287
|
+
const s = _chunkOW67FBYOcjs.store.call(void 0, );
|
|
4185
4288
|
if (!s.restore) throw new Error("adapter has no restore capability");
|
|
4186
4289
|
return s;
|
|
4187
4290
|
})()));
|
|
4188
4291
|
let kept = 0;
|
|
4189
4292
|
let migrated = 0;
|
|
4190
4293
|
let dropped = { closed_streams: 0, snapshots: 0 };
|
|
4191
|
-
const run = () => target.restore(async (callback) => {
|
|
4294
|
+
const run = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => target.restore(async (callback) => {
|
|
4192
4295
|
const partial = await scan(source, opts, callback);
|
|
4193
4296
|
kept = partial.kept;
|
|
4194
4297
|
migrated = partial.migrated;
|
|
4195
4298
|
dropped = partial.dropped;
|
|
4196
|
-
});
|
|
4299
|
+
}), "run");
|
|
4197
4300
|
if (sink) await run();
|
|
4198
4301
|
else {
|
|
4199
4302
|
await this._correlate.restart(run);
|
|
@@ -4228,7 +4331,7 @@ var Act = (_class7 = class {
|
|
|
4228
4331
|
async blocked_streams(options) {
|
|
4229
4332
|
return this._scoped(async () => {
|
|
4230
4333
|
const positions = [];
|
|
4231
|
-
await
|
|
4334
|
+
await _chunkOW67FBYOcjs.store.call(void 0, ).query_streams(
|
|
4232
4335
|
(p) => {
|
|
4233
4336
|
positions.push(p);
|
|
4234
4337
|
},
|
|
@@ -4254,7 +4357,7 @@ var Act = (_class7 = class {
|
|
|
4254
4357
|
* ```
|
|
4255
4358
|
*/
|
|
4256
4359
|
async *audit(categories, options) {
|
|
4257
|
-
|
|
4360
|
+
_chunkOW67FBYOcjs.check.call(void 0, "audit", _nullishCoalesce(options, () => ( {})));
|
|
4258
4361
|
const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
|
|
4259
4362
|
while (true) {
|
|
4260
4363
|
const { value, done } = await this._scoped(() => it.next());
|
|
@@ -4282,26 +4385,26 @@ var Act = (_class7 = class {
|
|
|
4282
4385
|
* @see {@link Store.prioritize} for the underlying primitive
|
|
4283
4386
|
*/
|
|
4284
4387
|
async prioritize(filter, priority) {
|
|
4285
|
-
|
|
4286
|
-
return this._scoped(() =>
|
|
4388
|
+
_chunkOW67FBYOcjs.check.call(void 0, "target", { priority });
|
|
4389
|
+
return this._scoped(() => _chunkOW67FBYOcjs.store.call(void 0, ).prioritize(filter, priority));
|
|
4287
4390
|
}
|
|
4288
4391
|
// Shared by `close()` and reaction-requested closes.
|
|
4289
4392
|
async _run_close(targets) {
|
|
4290
4393
|
const close_actor = { id: "$close", name: "close" };
|
|
4291
4394
|
const result = await run_close_cycle(targets, {
|
|
4292
4395
|
reactive: this._reactive,
|
|
4293
|
-
catch_up_correlation: (until) => catch_up_correlation(
|
|
4396
|
+
catch_up_correlation: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (until) => catch_up_correlation(
|
|
4294
4397
|
this._correlate,
|
|
4295
4398
|
(limit) => this.correlate({ limit }),
|
|
4296
4399
|
until
|
|
4297
|
-
),
|
|
4400
|
+
), "catch_up_correlation"),
|
|
4298
4401
|
event_to_state: this._event_to_state,
|
|
4299
4402
|
load: this._es.load,
|
|
4300
4403
|
tombstone: this._es.tombstone,
|
|
4301
4404
|
logger: this._logger,
|
|
4302
4405
|
correlation: close_correlation(this._correlator, close_actor),
|
|
4303
|
-
with_stream_lock: (stream, work) => this._close_lock.run(stream, work),
|
|
4304
|
-
forget_subscribed: (streams) => this._correlate.forget_subscribed(streams)
|
|
4406
|
+
with_stream_lock: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (stream, work) => this._close_lock.run(stream, work), "with_stream_lock"),
|
|
4407
|
+
forget_subscribed: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (streams) => this._correlate.forget_subscribed(streams), "forget_subscribed")
|
|
4305
4408
|
});
|
|
4306
4409
|
this.emit("closed", result);
|
|
4307
4410
|
return result;
|
|
@@ -4363,7 +4466,7 @@ var Act = (_class7 = class {
|
|
|
4363
4466
|
* @see {@link correlate} for manual correlation
|
|
4364
4467
|
*/
|
|
4365
4468
|
settle(options) {
|
|
4366
|
-
|
|
4469
|
+
_chunkOW67FBYOcjs.check.call(void 0, "settle", _nullishCoalesce(options, () => ( {})));
|
|
4367
4470
|
this._schedule(options);
|
|
4368
4471
|
}
|
|
4369
4472
|
}, _class7);
|
|
@@ -4371,11 +4474,12 @@ var Act = (_class7 = class {
|
|
|
4371
4474
|
// src/builders/merge.ts
|
|
4372
4475
|
|
|
4373
4476
|
function base_type_name(schema) {
|
|
4374
|
-
let def =
|
|
4375
|
-
for (let inner =
|
|
4376
|
-
def =
|
|
4477
|
+
let def = _chunkQSXWCJ2Ucjs.def_of.call(void 0, schema);
|
|
4478
|
+
for (let inner = _chunkQSXWCJ2Ucjs.inner_of.call(void 0, def); inner; inner = _chunkQSXWCJ2Ucjs.inner_of.call(void 0, def))
|
|
4479
|
+
def = _chunkQSXWCJ2Ucjs.def_of.call(void 0, inner);
|
|
4377
4480
|
return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
|
|
4378
4481
|
}
|
|
4482
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, base_type_name, "base_type_name");
|
|
4379
4483
|
function merge_schemas(existing, incoming, state_name) {
|
|
4380
4484
|
if (existing === incoming) return existing;
|
|
4381
4485
|
const existing_object = as_object(existing, "existing", state_name);
|
|
@@ -4395,15 +4499,18 @@ function merge_schemas(existing, incoming, state_name) {
|
|
|
4395
4499
|
}
|
|
4396
4500
|
return existing_object.extend(incoming_shape);
|
|
4397
4501
|
}
|
|
4502
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_schemas, "merge_schemas");
|
|
4398
4503
|
function as_object(schema, side, state_name) {
|
|
4399
4504
|
if (schema instanceof _zod.ZodObject) return schema;
|
|
4400
4505
|
throw new Error(
|
|
4401
4506
|
`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({ ... }).`
|
|
4402
4507
|
);
|
|
4403
4508
|
}
|
|
4509
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, as_object, "as_object");
|
|
4404
4510
|
function merge_inits(existing, incoming) {
|
|
4405
4511
|
return () => ({ ...existing(), ...incoming() });
|
|
4406
4512
|
}
|
|
4513
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_inits, "merge_inits");
|
|
4407
4514
|
function register_state(state2, states, actions, events) {
|
|
4408
4515
|
const existing = states.get(state2.name);
|
|
4409
4516
|
if (existing) {
|
|
@@ -4412,6 +4519,7 @@ function register_state(state2, states, actions, events) {
|
|
|
4412
4519
|
register_new_state(state2, states, actions, events);
|
|
4413
4520
|
}
|
|
4414
4521
|
}
|
|
4522
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, register_state, "register_state");
|
|
4415
4523
|
function register_new_state(state2, states, actions, events) {
|
|
4416
4524
|
states.set(state2.name, state2);
|
|
4417
4525
|
for (const name of Object.keys(state2.actions)) {
|
|
@@ -4423,11 +4531,13 @@ function register_new_state(state2, states, actions, events) {
|
|
|
4423
4531
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4424
4532
|
}
|
|
4425
4533
|
}
|
|
4534
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, register_new_state, "register_new_state");
|
|
4426
4535
|
function pick_declared(existing, incoming, what, state_name) {
|
|
4427
4536
|
if (existing && incoming && existing !== incoming)
|
|
4428
4537
|
throw new Error(`Duplicate ${what} for state "${state_name}"`);
|
|
4429
4538
|
return _nullishCoalesce(incoming, () => ( existing));
|
|
4430
4539
|
}
|
|
4540
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, pick_declared, "pick_declared");
|
|
4431
4541
|
function autoclose_of(existing, state2) {
|
|
4432
4542
|
pick_declared(
|
|
4433
4543
|
existing.autoclose,
|
|
@@ -4443,6 +4553,7 @@ function autoclose_of(existing, state2) {
|
|
|
4443
4553
|
autoclose_keep_days: owner.autoclose_keep_days
|
|
4444
4554
|
};
|
|
4445
4555
|
}
|
|
4556
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, autoclose_of, "autoclose_of");
|
|
4446
4557
|
function merge_into_existing(state2, existing, states, actions, events) {
|
|
4447
4558
|
for (const name of Object.keys(state2.actions)) {
|
|
4448
4559
|
if (existing.on[name] === state2.on[name]) continue;
|
|
@@ -4498,6 +4609,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
|
|
|
4498
4609
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4499
4610
|
}
|
|
4500
4611
|
}
|
|
4612
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_into_existing, "merge_into_existing");
|
|
4501
4613
|
function merge_patches(existing, incoming, state_name) {
|
|
4502
4614
|
const merged = { ...existing };
|
|
4503
4615
|
for (const name of Object.keys(incoming)) {
|
|
@@ -4520,6 +4632,7 @@ function merge_patches(existing, incoming, state_name) {
|
|
|
4520
4632
|
}
|
|
4521
4633
|
return merged;
|
|
4522
4634
|
}
|
|
4635
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_patches, "merge_patches");
|
|
4523
4636
|
function merge_event_register(target, source) {
|
|
4524
4637
|
for (const [event_name, source_reg] of Object.entries(source)) {
|
|
4525
4638
|
const target_reg = target[event_name];
|
|
@@ -4534,6 +4647,7 @@ function merge_event_register(target, source) {
|
|
|
4534
4647
|
}
|
|
4535
4648
|
}
|
|
4536
4649
|
}
|
|
4650
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_event_register, "merge_event_register");
|
|
4537
4651
|
function merge_projection(proj, events) {
|
|
4538
4652
|
for (const event_name of Object.keys(proj.events)) {
|
|
4539
4653
|
const proj_register = proj.events[event_name];
|
|
@@ -4553,16 +4667,17 @@ function merge_projection(proj, events) {
|
|
|
4553
4667
|
}
|
|
4554
4668
|
}
|
|
4555
4669
|
}
|
|
4556
|
-
|
|
4670
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, merge_projection, "merge_projection");
|
|
4671
|
+
var _this_ = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, ({ stream }) => ({
|
|
4557
4672
|
source: stream,
|
|
4558
4673
|
target: stream
|
|
4559
|
-
});
|
|
4674
|
+
}), "_this_");
|
|
4560
4675
|
|
|
4561
4676
|
// src/builders/builder-utils.ts
|
|
4562
4677
|
function register_lane(config2, lanes) {
|
|
4563
|
-
|
|
4564
|
-
if (config2.name ===
|
|
4565
|
-
throw new Error(`Lane "${
|
|
4678
|
+
_chunkOW67FBYOcjs.check.call(void 0, "lane", config2);
|
|
4679
|
+
if (config2.name === _chunkQSXWCJ2Ucjs.DEFAULT_LANE)
|
|
4680
|
+
throw new Error(`Lane "${_chunkQSXWCJ2Ucjs.DEFAULT_LANE}" is reserved`);
|
|
4566
4681
|
const existing = lanes.find((l) => l.name === config2.name);
|
|
4567
4682
|
if (!existing) return void lanes.push(config2);
|
|
4568
4683
|
if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
|
|
@@ -4570,6 +4685,7 @@ function register_lane(config2, lanes) {
|
|
|
4570
4685
|
`Lane "${config2.name}" was already declared with a different config`
|
|
4571
4686
|
);
|
|
4572
4687
|
}
|
|
4688
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, register_lane, "register_lane");
|
|
4573
4689
|
function add_reaction(events, event, name, kind, make, builder) {
|
|
4574
4690
|
if (!name)
|
|
4575
4691
|
throw new Error(
|
|
@@ -4584,58 +4700,60 @@ function add_reaction(events, event, name, kind, make, builder) {
|
|
|
4584
4700
|
events[event].reactions.set(name, reaction);
|
|
4585
4701
|
return Object.assign(builder, {
|
|
4586
4702
|
to(resolver) {
|
|
4587
|
-
if (typeof resolver === "object")
|
|
4703
|
+
if (typeof resolver === "object") _chunkOW67FBYOcjs.check.call(void 0, "target", resolver);
|
|
4588
4704
|
reaction.resolver = typeof resolver === "string" ? { target: resolver } : resolver;
|
|
4589
4705
|
return builder;
|
|
4590
4706
|
}
|
|
4591
4707
|
});
|
|
4592
4708
|
}
|
|
4709
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, add_reaction, "add_reaction");
|
|
4593
4710
|
function reaction_on(event, events, builder) {
|
|
4594
|
-
const register = (handler, options, schedule) => add_reaction(
|
|
4711
|
+
const register = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (handler, options, schedule) => add_reaction(
|
|
4595
4712
|
events,
|
|
4596
4713
|
event,
|
|
4597
4714
|
handler.name,
|
|
4598
4715
|
"Reaction",
|
|
4599
4716
|
() => {
|
|
4600
4717
|
if (schedule && typeof schedule !== "function")
|
|
4601
|
-
|
|
4718
|
+
_chunkOW67FBYOcjs.check.call(void 0, "defer", schedule);
|
|
4602
4719
|
return {
|
|
4603
4720
|
handler: schedule ? make_deferred(handler, schedule) : handler,
|
|
4604
4721
|
resolver: _this_,
|
|
4605
4722
|
// Validate the whole bag at the declaration site so a bad
|
|
4606
4723
|
// `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
|
|
4607
4724
|
// not a NaN gate on the first retry.
|
|
4608
|
-
options:
|
|
4609
|
-
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _176 => _176.blockOnError]), () => (
|
|
4610
|
-
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _177 => _177.maxRetries]), () => (
|
|
4725
|
+
options: _chunkOW67FBYOcjs.check.call(void 0, "reaction", {
|
|
4726
|
+
blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _176 => _176.blockOnError]), () => ( _chunkOW67FBYOcjs.DEFAULT_BLOCK_ON_ERROR)),
|
|
4727
|
+
maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _177 => _177.maxRetries]), () => ( _chunkOW67FBYOcjs.DEFAULT_MAX_RETRIES)),
|
|
4611
4728
|
backoff: _optionalChain([options, 'optionalAccess', _178 => _178.backoff])
|
|
4612
4729
|
})
|
|
4613
4730
|
};
|
|
4614
4731
|
},
|
|
4615
4732
|
builder
|
|
4616
|
-
);
|
|
4733
|
+
), "register");
|
|
4617
4734
|
return {
|
|
4618
|
-
do: (handler, options) => register(handler, options),
|
|
4619
|
-
defer: (schedule) => ({
|
|
4620
|
-
do: (handler, options) => register(handler, options, schedule)
|
|
4621
|
-
})
|
|
4735
|
+
do: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (handler, options) => register(handler, options), "do"),
|
|
4736
|
+
defer: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (schedule) => ({
|
|
4737
|
+
do: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (handler, options) => register(handler, options, schedule), "do")
|
|
4738
|
+
}), "defer")
|
|
4622
4739
|
};
|
|
4623
4740
|
}
|
|
4741
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, reaction_on, "reaction_on");
|
|
4624
4742
|
|
|
4625
4743
|
// src/builders/event-builder.ts
|
|
4626
4744
|
|
|
4627
4745
|
function event_tags(schema) {
|
|
4628
|
-
const pii =
|
|
4746
|
+
const pii = _chunkQSXWCJ2Ucjs.pii_schemas.call(void 0, schema);
|
|
4629
4747
|
const pii_dates = {};
|
|
4630
4748
|
for (const [key, field] of Object.entries(pii)) {
|
|
4631
4749
|
const dates = date_reviver_schema(field);
|
|
4632
4750
|
if (dates) pii_dates[key] = dates.optional();
|
|
4633
4751
|
}
|
|
4634
4752
|
const data_reviver_schema = date_reviver_schema(schema);
|
|
4635
|
-
const revive = (schema2) => (data) => {
|
|
4753
|
+
const revive = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (schema2) => (data) => {
|
|
4636
4754
|
const revived = schema2.safeParse(data);
|
|
4637
4755
|
return revived.success ? revived.data : data;
|
|
4638
|
-
};
|
|
4756
|
+
}, "revive");
|
|
4639
4757
|
const dated_pii = Object.keys(pii_dates).length > 0;
|
|
4640
4758
|
return {
|
|
4641
4759
|
sensitive: pii,
|
|
@@ -4643,6 +4761,7 @@ function event_tags(schema) {
|
|
|
4643
4761
|
pii_date_reviver: dated_pii ? revive(_zod.z.looseObject(pii_dates)) : void 0
|
|
4644
4762
|
};
|
|
4645
4763
|
}
|
|
4764
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, event_tags, "event_tags");
|
|
4646
4765
|
function make_event_reader(tags, disclosure, predicate = null) {
|
|
4647
4766
|
const { date_reviver, pii_date_reviver } = tags;
|
|
4648
4767
|
const sensitive2 = Object.keys(tags.sensitive);
|
|
@@ -4662,8 +4781,9 @@ function make_event_reader(tags, disclosure, predicate = null) {
|
|
|
4662
4781
|
);
|
|
4663
4782
|
});
|
|
4664
4783
|
}
|
|
4784
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, make_event_reader, "make_event_reader");
|
|
4665
4785
|
function build_events(registry, states, lanes, owners) {
|
|
4666
|
-
const declared = /* @__PURE__ */ new Set([
|
|
4786
|
+
const declared = /* @__PURE__ */ new Set([_chunkQSXWCJ2Ucjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
4667
4787
|
const lane_errors = [];
|
|
4668
4788
|
const tags = /* @__PURE__ */ new Map();
|
|
4669
4789
|
const sensitive2 = /* @__PURE__ */ new Map();
|
|
@@ -4696,7 +4816,7 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4696
4816
|
handler_readers.set(event_name, handler_reader);
|
|
4697
4817
|
for (const [name, reaction] of def.reactions) {
|
|
4698
4818
|
const inner = reaction.handler;
|
|
4699
|
-
const wrapped = (evt, stream, app) => inner(handler_reader(evt), stream, app);
|
|
4819
|
+
const wrapped = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (evt, stream, app) => inner(handler_reader(evt), stream, app), "wrapped");
|
|
4700
4820
|
Object.defineProperty(wrapped, "name", { value: inner.name });
|
|
4701
4821
|
reaction.handler = wrapped;
|
|
4702
4822
|
def.reactions.set(name, reaction);
|
|
@@ -4738,17 +4858,19 @@ function build_events(registry, states, lanes, owners) {
|
|
|
4738
4858
|
if (reader) readers.set(event_name, reader);
|
|
4739
4859
|
}
|
|
4740
4860
|
const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
|
|
4741
|
-
if (snap2) readers.set(
|
|
4861
|
+
if (snap2) readers.set(_chunkQSXWCJ2Ucjs.SNAP_EVENT, snap2);
|
|
4742
4862
|
if (readers.size === 0) continue;
|
|
4743
4863
|
state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
|
|
4744
4864
|
}
|
|
4745
4865
|
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;
|
|
4746
4866
|
return { sensitive: sensitive2, advisory, query_readers, handler_readers };
|
|
4747
4867
|
}
|
|
4868
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, build_events, "build_events");
|
|
4748
4869
|
function reads_as_string(schema) {
|
|
4749
|
-
const type = _optionalChain([
|
|
4870
|
+
const type = _optionalChain([_chunkQSXWCJ2Ucjs.def_of.call(void 0, _chunkQSXWCJ2Ucjs.output_of.call(void 0, schema)), 'optionalAccess', _179 => _179.type]);
|
|
4750
4871
|
return type === "string" || type === "transform";
|
|
4751
4872
|
}
|
|
4873
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, reads_as_string, "reads_as_string");
|
|
4752
4874
|
|
|
4753
4875
|
// src/builders/act-builder.ts
|
|
4754
4876
|
function register_batch_handler(proj, batch_handlers) {
|
|
@@ -4761,6 +4883,7 @@ function register_batch_handler(proj, batch_handlers) {
|
|
|
4761
4883
|
}
|
|
4762
4884
|
batch_handlers.set(proj.target, proj.batchHandler);
|
|
4763
4885
|
}
|
|
4886
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, register_batch_handler, "register_batch_handler");
|
|
4764
4887
|
function act() {
|
|
4765
4888
|
const states = /* @__PURE__ */ new Map();
|
|
4766
4889
|
const _sf = /* @__PURE__ */ new Map();
|
|
@@ -4774,44 +4897,44 @@ function act() {
|
|
|
4774
4897
|
const registry = {
|
|
4775
4898
|
actions: {},
|
|
4776
4899
|
events: {},
|
|
4777
|
-
sensitive_fields: (event_name) => _nullishCoalesce(_sf.get(event_name), () => ( [])),
|
|
4778
|
-
query_gate: (event_name) => _nullishCoalesce(_qg.get(event_name), () => ( IDENTITY_GATE)),
|
|
4779
|
-
disclosure_predicate: (state_name) => _nullishCoalesce(_dp.get(state_name), () => ( null)),
|
|
4780
|
-
deprecated_events: (state_name) => _nullishCoalesce(_de.get(state_name), () => ( EMPTY_DEPRECATED)),
|
|
4781
|
-
autoclose_policy: (state_name) => _nullishCoalesce(_ac.get(state_name), () => ( null)),
|
|
4782
|
-
autoclose_archiver: (state_name) => _nullishCoalesce(_aa.get(state_name), () => ( null))
|
|
4900
|
+
sensitive_fields: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (event_name) => _nullishCoalesce(_sf.get(event_name), () => ( [])), "sensitive_fields"),
|
|
4901
|
+
query_gate: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (event_name) => _nullishCoalesce(_qg.get(event_name), () => ( IDENTITY_GATE)), "query_gate"),
|
|
4902
|
+
disclosure_predicate: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (state_name) => _nullishCoalesce(_dp.get(state_name), () => ( null)), "disclosure_predicate"),
|
|
4903
|
+
deprecated_events: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (state_name) => _nullishCoalesce(_de.get(state_name), () => ( EMPTY_DEPRECATED)), "deprecated_events"),
|
|
4904
|
+
autoclose_policy: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (state_name) => _nullishCoalesce(_ac.get(state_name), () => ( null)), "autoclose_policy"),
|
|
4905
|
+
autoclose_archiver: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (state_name) => _nullishCoalesce(_aa.get(state_name), () => ( null)), "autoclose_archiver")
|
|
4783
4906
|
};
|
|
4784
4907
|
const pending_projections = [];
|
|
4785
4908
|
const projection_reactions = /* @__PURE__ */ new Set();
|
|
4786
|
-
const record_projection_reactions = (proj) => {
|
|
4909
|
+
const record_projection_reactions = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (proj) => {
|
|
4787
4910
|
if (!proj.batchHandler && !proj.fold) return;
|
|
4788
4911
|
for (const register of Object.values(
|
|
4789
4912
|
proj.events
|
|
4790
4913
|
))
|
|
4791
4914
|
for (const reaction of register.reactions.values())
|
|
4792
4915
|
projection_reactions.add(reaction);
|
|
4793
|
-
};
|
|
4916
|
+
}, "record_projection_reactions");
|
|
4794
4917
|
const fold_projections = [];
|
|
4795
4918
|
const batch_handlers = /* @__PURE__ */ new Map();
|
|
4796
|
-
const add_projection = (proj) => {
|
|
4919
|
+
const add_projection = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (proj) => {
|
|
4797
4920
|
record_projection_reactions(proj);
|
|
4798
4921
|
merge_projection(proj, registry.events);
|
|
4799
4922
|
register_batch_handler(proj, batch_handlers);
|
|
4800
4923
|
if (proj.fold) fold_projections.push(proj);
|
|
4801
|
-
};
|
|
4924
|
+
}, "add_projection");
|
|
4802
4925
|
const fold_specs = [];
|
|
4803
4926
|
const lanes = [];
|
|
4804
4927
|
let _built = false;
|
|
4805
|
-
const read_wrap = (original) => {
|
|
4806
|
-
const wrapped = async (events, stream) => {
|
|
4928
|
+
const read_wrap = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (original) => {
|
|
4929
|
+
const wrapped = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, async (events, stream) => {
|
|
4807
4930
|
const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _180 => _180.get, 'call', _181 => _181(e.name), 'optionalCall', _182 => _182(e)]), () => ( e)));
|
|
4808
4931
|
return original(read, stream);
|
|
4809
|
-
};
|
|
4932
|
+
}, "wrapped");
|
|
4810
4933
|
const reset = original[FOLD_RESET];
|
|
4811
4934
|
if (reset) Object.defineProperty(wrapped, FOLD_RESET, { value: reset });
|
|
4812
4935
|
return wrapped;
|
|
4813
|
-
};
|
|
4814
|
-
const make_batch_handlers = () => {
|
|
4936
|
+
}, "read_wrap");
|
|
4937
|
+
const make_batch_handlers = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => {
|
|
4815
4938
|
const handlers = new Map(batch_handlers);
|
|
4816
4939
|
for (const spec of fold_specs) {
|
|
4817
4940
|
handlers.set(
|
|
@@ -4828,8 +4951,8 @@ function act() {
|
|
|
4828
4951
|
);
|
|
4829
4952
|
}
|
|
4830
4953
|
return handlers;
|
|
4831
|
-
};
|
|
4832
|
-
const finalize_deprecations = () => {
|
|
4954
|
+
}, "make_batch_handlers");
|
|
4955
|
+
const finalize_deprecations = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => {
|
|
4833
4956
|
const deprecation_summary = [];
|
|
4834
4957
|
for (const state2 of states.values()) {
|
|
4835
4958
|
const event_names = Object.keys(state2.events);
|
|
@@ -4858,23 +4981,23 @@ function act() {
|
|
|
4858
4981
|
const list = deprecation_summary.map(
|
|
4859
4982
|
(d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
|
|
4860
4983
|
).join(", ");
|
|
4861
|
-
|
|
4984
|
+
_chunkOW67FBYOcjs.log.call(void 0, ).info(
|
|
4862
4985
|
`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.`
|
|
4863
4986
|
);
|
|
4864
4987
|
}
|
|
4865
|
-
};
|
|
4866
|
-
const closed = (method) => {
|
|
4988
|
+
}, "finalize_deprecations");
|
|
4989
|
+
const closed = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (method) => {
|
|
4867
4990
|
throw new Error(
|
|
4868
4991
|
`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).`
|
|
4869
4992
|
);
|
|
4870
|
-
};
|
|
4993
|
+
}, "closed");
|
|
4871
4994
|
const builder = {
|
|
4872
|
-
withState: (state2) => {
|
|
4995
|
+
withState: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (state2) => {
|
|
4873
4996
|
if (_built) closed("withState");
|
|
4874
4997
|
register_state(state2, states, registry.actions, registry.events);
|
|
4875
4998
|
return builder;
|
|
4876
|
-
},
|
|
4877
|
-
withSlice: (input) => {
|
|
4999
|
+
}, "withState"),
|
|
5000
|
+
withSlice: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (input) => {
|
|
4878
5001
|
if (_built) closed("withSlice");
|
|
4879
5002
|
for (const s of input.states.values()) {
|
|
4880
5003
|
register_state(s, states, registry.actions, registry.events);
|
|
@@ -4883,24 +5006,24 @@ function act() {
|
|
|
4883
5006
|
pending_projections.push(...input.projections);
|
|
4884
5007
|
for (const lane of input.lanes) register_lane(lane, lanes);
|
|
4885
5008
|
return builder;
|
|
4886
|
-
},
|
|
4887
|
-
withProjection: (proj) => {
|
|
5009
|
+
}, "withSlice"),
|
|
5010
|
+
withProjection: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (proj) => {
|
|
4888
5011
|
if (_built) closed("withProjection");
|
|
4889
5012
|
add_projection(proj);
|
|
4890
5013
|
return builder;
|
|
4891
|
-
},
|
|
4892
|
-
withActor: () => builder,
|
|
4893
|
-
withLane: (config2) => {
|
|
5014
|
+
}, "withProjection"),
|
|
5015
|
+
withActor: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => builder, "withActor"),
|
|
5016
|
+
withLane: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (config2) => {
|
|
4894
5017
|
if (_built) closed("withLane");
|
|
4895
5018
|
register_lane(config2, lanes);
|
|
4896
5019
|
return builder;
|
|
4897
|
-
},
|
|
4898
|
-
on: (event) => {
|
|
5020
|
+
}, "withLane"),
|
|
5021
|
+
on: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (event) => {
|
|
4899
5022
|
if (_built) closed("on");
|
|
4900
5023
|
return reaction_on(event, registry.events, builder);
|
|
4901
|
-
},
|
|
4902
|
-
build: (options) => {
|
|
4903
|
-
|
|
5024
|
+
}, "on"),
|
|
5025
|
+
build: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (options) => {
|
|
5026
|
+
_chunkOW67FBYOcjs.check.call(void 0, "act", _nullishCoalesce(options, () => ( {})));
|
|
4904
5027
|
if (!_built) {
|
|
4905
5028
|
for (const proj of pending_projections) add_projection(proj);
|
|
4906
5029
|
for (const proj of fold_projections) {
|
|
@@ -4940,7 +5063,7 @@ function act() {
|
|
|
4940
5063
|
for (const [name, gate] of built.query_readers) _qg.set(name, gate);
|
|
4941
5064
|
for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
|
|
4942
5065
|
finalize_deprecations();
|
|
4943
|
-
if (built.advisory)
|
|
5066
|
+
if (built.advisory) _chunkOW67FBYOcjs.log.call(void 0, ).warn(built.advisory);
|
|
4944
5067
|
for (const [name, state2] of states) {
|
|
4945
5068
|
if (!state2.loads) continue;
|
|
4946
5069
|
const resolved = {};
|
|
@@ -4984,7 +5107,7 @@ function act() {
|
|
|
4984
5107
|
synthesize_autoclose_reactions(
|
|
4985
5108
|
registry,
|
|
4986
5109
|
states,
|
|
4987
|
-
|
|
5110
|
+
_chunkOW67FBYOcjs.current_autoclose_window
|
|
4988
5111
|
);
|
|
4989
5112
|
Object.freeze(registry.actions);
|
|
4990
5113
|
Object.freeze(registry.events);
|
|
@@ -4998,18 +5121,19 @@ function act() {
|
|
|
4998
5121
|
options,
|
|
4999
5122
|
lanes
|
|
5000
5123
|
);
|
|
5001
|
-
},
|
|
5124
|
+
}, "build"),
|
|
5002
5125
|
events: registry.events
|
|
5003
5126
|
};
|
|
5004
5127
|
return builder;
|
|
5005
5128
|
}
|
|
5129
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, act, "act");
|
|
5006
5130
|
|
|
5007
5131
|
// src/builders/projection-builder.ts
|
|
5008
5132
|
function _projection(target) {
|
|
5009
5133
|
const events = {};
|
|
5010
5134
|
const default_resolver = typeof target === "string" ? { target } : void 0;
|
|
5011
5135
|
const base = {
|
|
5012
|
-
on: (entry) => {
|
|
5136
|
+
on: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (entry) => {
|
|
5013
5137
|
const keys = Object.keys(entry);
|
|
5014
5138
|
if (keys.length !== 1) throw new Error(".on() requires exactly one key");
|
|
5015
5139
|
const event = keys[0];
|
|
@@ -5021,7 +5145,7 @@ function _projection(target) {
|
|
|
5021
5145
|
};
|
|
5022
5146
|
}
|
|
5023
5147
|
return {
|
|
5024
|
-
do: (handler) => {
|
|
5148
|
+
do: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (handler) => {
|
|
5025
5149
|
const widened = base;
|
|
5026
5150
|
return add_reaction(
|
|
5027
5151
|
events,
|
|
@@ -5032,38 +5156,38 @@ function _projection(target) {
|
|
|
5032
5156
|
handler,
|
|
5033
5157
|
resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
|
|
5034
5158
|
options: {
|
|
5035
|
-
blockOnError:
|
|
5036
|
-
maxRetries:
|
|
5159
|
+
blockOnError: _chunkOW67FBYOcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5160
|
+
maxRetries: _chunkOW67FBYOcjs.DEFAULT_MAX_RETRIES
|
|
5037
5161
|
}
|
|
5038
5162
|
}),
|
|
5039
5163
|
widened
|
|
5040
5164
|
);
|
|
5041
|
-
}
|
|
5165
|
+
}, "do")
|
|
5042
5166
|
};
|
|
5043
|
-
},
|
|
5044
|
-
build: () => ({
|
|
5167
|
+
}, "on"),
|
|
5168
|
+
build: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => ({
|
|
5045
5169
|
_tag: "Projection",
|
|
5046
5170
|
events,
|
|
5047
5171
|
...target !== void 0 && { target }
|
|
5048
|
-
}),
|
|
5172
|
+
}), "build"),
|
|
5049
5173
|
events
|
|
5050
5174
|
};
|
|
5051
5175
|
if (typeof target === "string") {
|
|
5052
5176
|
return Object.assign(base, {
|
|
5053
|
-
batch: (handler) => ({
|
|
5054
|
-
build: () => ({
|
|
5177
|
+
batch: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (handler) => ({
|
|
5178
|
+
build: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => ({
|
|
5055
5179
|
_tag: "Projection",
|
|
5056
5180
|
events,
|
|
5057
5181
|
target,
|
|
5058
5182
|
batchHandler: handler
|
|
5059
|
-
})
|
|
5060
|
-
}),
|
|
5061
|
-
of: (...args) => {
|
|
5183
|
+
}), "build")
|
|
5184
|
+
}), "batch"),
|
|
5185
|
+
of: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (...args) => {
|
|
5062
5186
|
if (Object.keys(events).length > 0)
|
|
5063
5187
|
throw new Error(
|
|
5064
5188
|
`Projection "${target}" mixes .of() with .on() handlers \u2014 a projection either folds a state or declares handlers, never both`
|
|
5065
5189
|
);
|
|
5066
|
-
const is_state = (a) => !!a && typeof a.init === "function";
|
|
5190
|
+
const is_state = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (a) => !!a && typeof a.init === "function", "is_state");
|
|
5067
5191
|
const partials = args.filter(is_state);
|
|
5068
5192
|
const options = _nullishCoalesce(args.find((a) => !is_state(a)), () => ( {}));
|
|
5069
5193
|
if (partials.length === 0)
|
|
@@ -5074,7 +5198,7 @@ function _projection(target) {
|
|
|
5074
5198
|
throw new Error(
|
|
5075
5199
|
`Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
|
|
5076
5200
|
);
|
|
5077
|
-
const config2 =
|
|
5201
|
+
const config2 = _chunkOW67FBYOcjs.check.call(void 0, "fold", options);
|
|
5078
5202
|
const fold_events = {};
|
|
5079
5203
|
for (const partial of partials)
|
|
5080
5204
|
for (const [event_name, schema] of Object.entries(partial.events)) {
|
|
@@ -5092,8 +5216,8 @@ function _projection(target) {
|
|
|
5092
5216
|
handler: noop,
|
|
5093
5217
|
resolver: { target },
|
|
5094
5218
|
options: {
|
|
5095
|
-
blockOnError:
|
|
5096
|
-
maxRetries:
|
|
5219
|
+
blockOnError: _chunkOW67FBYOcjs.DEFAULT_BLOCK_ON_ERROR,
|
|
5220
|
+
maxRetries: _chunkOW67FBYOcjs.DEFAULT_MAX_RETRIES
|
|
5097
5221
|
}
|
|
5098
5222
|
}
|
|
5099
5223
|
]
|
|
@@ -5101,23 +5225,25 @@ function _projection(target) {
|
|
|
5101
5225
|
};
|
|
5102
5226
|
}
|
|
5103
5227
|
return {
|
|
5104
|
-
flush: (handler) => ({
|
|
5105
|
-
build: () => ({
|
|
5228
|
+
flush: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (handler) => ({
|
|
5229
|
+
build: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => ({
|
|
5106
5230
|
_tag: "Projection",
|
|
5107
5231
|
events: fold_events,
|
|
5108
5232
|
target,
|
|
5109
5233
|
fold: { name, flush: handler, config: config2 }
|
|
5110
|
-
})
|
|
5111
|
-
})
|
|
5234
|
+
}), "build")
|
|
5235
|
+
}), "flush")
|
|
5112
5236
|
};
|
|
5113
|
-
}
|
|
5237
|
+
}, "of")
|
|
5114
5238
|
});
|
|
5115
5239
|
}
|
|
5116
5240
|
return base;
|
|
5117
5241
|
}
|
|
5242
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, _projection, "_projection");
|
|
5118
5243
|
function projection(target) {
|
|
5119
5244
|
return _projection(target);
|
|
5120
5245
|
}
|
|
5246
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, projection, "projection");
|
|
5121
5247
|
|
|
5122
5248
|
// src/builders/slice-builder.ts
|
|
5123
5249
|
function slice() {
|
|
@@ -5127,30 +5253,31 @@ function slice() {
|
|
|
5127
5253
|
const projections = [];
|
|
5128
5254
|
const lanes = [];
|
|
5129
5255
|
const builder = {
|
|
5130
|
-
withState: (state2) => {
|
|
5256
|
+
withState: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (state2) => {
|
|
5131
5257
|
register_state(state2, states, actions, events);
|
|
5132
5258
|
return builder;
|
|
5133
|
-
},
|
|
5134
|
-
withProjection: (proj) => {
|
|
5259
|
+
}, "withState"),
|
|
5260
|
+
withProjection: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (proj) => {
|
|
5135
5261
|
projections.push(proj);
|
|
5136
5262
|
return builder;
|
|
5137
|
-
},
|
|
5138
|
-
withLane: (config2) => {
|
|
5263
|
+
}, "withProjection"),
|
|
5264
|
+
withLane: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (config2) => {
|
|
5139
5265
|
register_lane(config2, lanes);
|
|
5140
5266
|
return builder;
|
|
5141
|
-
},
|
|
5142
|
-
on: (event) => reaction_on(event, events, builder),
|
|
5143
|
-
build: () => ({
|
|
5267
|
+
}, "withLane"),
|
|
5268
|
+
on: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (event) => reaction_on(event, events, builder), "on"),
|
|
5269
|
+
build: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, () => ({
|
|
5144
5270
|
_tag: "Slice",
|
|
5145
5271
|
states,
|
|
5146
5272
|
events,
|
|
5147
5273
|
projections,
|
|
5148
5274
|
lanes
|
|
5149
|
-
}),
|
|
5275
|
+
}), "build"),
|
|
5150
5276
|
events
|
|
5151
5277
|
};
|
|
5152
5278
|
return builder;
|
|
5153
5279
|
}
|
|
5280
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, slice, "slice");
|
|
5154
5281
|
|
|
5155
5282
|
// src/builders/state-builder.ts
|
|
5156
5283
|
function state(entry) {
|
|
@@ -5182,8 +5309,8 @@ function state(entry) {
|
|
|
5182
5309
|
// `act().build()` flips both on states with `sensitive(...)`
|
|
5183
5310
|
// events to bake in the gate / split and gate the cache write.
|
|
5184
5311
|
pii_aware: false,
|
|
5185
|
-
view: (event) => event,
|
|
5186
|
-
message: (validated) => validated
|
|
5312
|
+
view: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (event) => event, "view"),
|
|
5313
|
+
message: /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (validated) => validated, "message")
|
|
5187
5314
|
};
|
|
5188
5315
|
const builder = action_builder(internal);
|
|
5189
5316
|
return Object.assign(builder, {
|
|
@@ -5197,6 +5324,7 @@ function state(entry) {
|
|
|
5197
5324
|
}
|
|
5198
5325
|
};
|
|
5199
5326
|
}
|
|
5327
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, state, "state");
|
|
5200
5328
|
function action_builder(state2) {
|
|
5201
5329
|
const internal = state2;
|
|
5202
5330
|
const builder = {
|
|
@@ -5209,7 +5337,7 @@ function action_builder(state2) {
|
|
|
5209
5337
|
throw new Error(`Duplicate action "${action2}"`);
|
|
5210
5338
|
internal.actions[action2] = schema;
|
|
5211
5339
|
if (options) {
|
|
5212
|
-
|
|
5340
|
+
_chunkOW67FBYOcjs.check.call(void 0, "action", options);
|
|
5213
5341
|
internal.options ??= {};
|
|
5214
5342
|
internal.options[action2] = options;
|
|
5215
5343
|
}
|
|
@@ -5233,10 +5361,12 @@ function action_builder(state2) {
|
|
|
5233
5361
|
(internal.loads ??= {})[action2] = loads;
|
|
5234
5362
|
return { loads: load2, requires, emit };
|
|
5235
5363
|
}
|
|
5364
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, load2, "load");
|
|
5236
5365
|
function requires(rules) {
|
|
5237
5366
|
(internal.requires ??= {})[action2] = rules;
|
|
5238
5367
|
return { emit };
|
|
5239
5368
|
}
|
|
5369
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, requires, "requires");
|
|
5240
5370
|
function emit(handler) {
|
|
5241
5371
|
if (typeof handler === "string") {
|
|
5242
5372
|
const event_name = handler;
|
|
@@ -5252,6 +5382,7 @@ function action_builder(state2) {
|
|
|
5252
5382
|
}
|
|
5253
5383
|
return builder;
|
|
5254
5384
|
}
|
|
5385
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, emit, "emit");
|
|
5255
5386
|
return { loads: load2, requires, emit };
|
|
5256
5387
|
},
|
|
5257
5388
|
snap(snap2) {
|
|
@@ -5302,6 +5433,7 @@ function action_builder(state2) {
|
|
|
5302
5433
|
};
|
|
5303
5434
|
return builder;
|
|
5304
5435
|
}
|
|
5436
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, action_builder, "action_builder");
|
|
5305
5437
|
|
|
5306
5438
|
// src/csv.ts
|
|
5307
5439
|
var _fs = require('fs');
|
|
@@ -5316,6 +5448,9 @@ var CSV_COLUMNS = [
|
|
|
5316
5448
|
"meta"
|
|
5317
5449
|
];
|
|
5318
5450
|
var CsvFile = class {
|
|
5451
|
+
static {
|
|
5452
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, this, "CsvFile");
|
|
5453
|
+
}
|
|
5319
5454
|
|
|
5320
5455
|
|
|
5321
5456
|
constructor(options) {
|
|
@@ -5409,6 +5544,7 @@ async function* linesFromFile(path) {
|
|
|
5409
5544
|
stream.close();
|
|
5410
5545
|
}
|
|
5411
5546
|
}
|
|
5547
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, linesFromFile, "linesFromFile");
|
|
5412
5548
|
async function* linesFromBlob(blob) {
|
|
5413
5549
|
let start = 0;
|
|
5414
5550
|
while (start < blob.length) {
|
|
@@ -5419,6 +5555,7 @@ async function* linesFromBlob(blob) {
|
|
|
5419
5555
|
await Promise.resolve();
|
|
5420
5556
|
}
|
|
5421
5557
|
}
|
|
5558
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, linesFromBlob, "linesFromBlob");
|
|
5422
5559
|
function parse_csv_line(line) {
|
|
5423
5560
|
const fields = [];
|
|
5424
5561
|
let i = 0;
|
|
@@ -5452,10 +5589,12 @@ function parse_csv_line(line) {
|
|
|
5452
5589
|
}
|
|
5453
5590
|
return fields;
|
|
5454
5591
|
}
|
|
5592
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, parse_csv_line, "parse_csv_line");
|
|
5455
5593
|
function csv_escape(value) {
|
|
5456
5594
|
if (/[",\n\r]/.test(value)) return `"${value.replace(/"/g, '""')}"`;
|
|
5457
5595
|
return value;
|
|
5458
5596
|
}
|
|
5597
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, csv_escape, "csv_escape");
|
|
5459
5598
|
function write_line(writer, line) {
|
|
5460
5599
|
return new Promise((resolve, reject) => {
|
|
5461
5600
|
writer.write(`${line}
|
|
@@ -5465,33 +5604,34 @@ function write_line(writer, line) {
|
|
|
5465
5604
|
});
|
|
5466
5605
|
});
|
|
5467
5606
|
}
|
|
5607
|
+
_chunkQSXWCJ2Ucjs.__name.call(void 0, write_line, "write_line");
|
|
5468
5608
|
|
|
5469
5609
|
// src/deprecated.ts
|
|
5470
|
-
var check_appends =
|
|
5471
|
-
var throw_if_stale =
|
|
5472
|
-
var concurrency_error =
|
|
5473
|
-
var seed_event =
|
|
5474
|
-
var fair_slots =
|
|
5475
|
-
var is_literal_source =
|
|
5476
|
-
var notification_of =
|
|
5477
|
-
var DEFAULT_QUERY_STREAMS_LIMIT2 =
|
|
5478
|
-
var ActorSchema2 =
|
|
5479
|
-
var TargetSchema2 =
|
|
5480
|
-
var EventMetaSchema2 =
|
|
5481
|
-
var CausationEventSchema2 =
|
|
5482
|
-
var CommittedMetaSchema2 =
|
|
5483
|
-
var QuerySchema2 =
|
|
5484
|
-
var Environments2 =
|
|
5485
|
-
var LogLevels2 =
|
|
5486
|
-
var ExitCodes2 =
|
|
5487
|
-
var DEFAULT_LANE2 =
|
|
5488
|
-
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 =
|
|
5489
|
-
var DEFAULT_SETTLE_DEBOUNCE_MS2 =
|
|
5490
|
-
var PackageSchema =
|
|
5491
|
-
var default_scope =
|
|
5492
|
-
var extend = (source, schema, target) => ({ ...target, ...
|
|
5610
|
+
var check_appends = _chunkPDMLWC77cjs.checkAppends;
|
|
5611
|
+
var throw_if_stale = _chunkPDMLWC77cjs.checkVersion;
|
|
5612
|
+
var concurrency_error = _chunkPDMLWC77cjs.concurrencyError;
|
|
5613
|
+
var seed_event = _chunkPDMLWC77cjs.seedEvent;
|
|
5614
|
+
var fair_slots = _chunkPDMLWC77cjs.fairSlots;
|
|
5615
|
+
var is_literal_source = _chunkPDMLWC77cjs.isStreamName;
|
|
5616
|
+
var notification_of = _chunkPDMLWC77cjs.parseNotification;
|
|
5617
|
+
var DEFAULT_QUERY_STREAMS_LIMIT2 = _chunkQSXWCJ2Ucjs.DEFAULT_QUERY_STREAMS_LIMIT;
|
|
5618
|
+
var ActorSchema2 = _chunkQSXWCJ2Ucjs.ActorSchema;
|
|
5619
|
+
var TargetSchema2 = _chunkQSXWCJ2Ucjs.TargetSchema;
|
|
5620
|
+
var EventMetaSchema2 = _chunkQSXWCJ2Ucjs.EventMetaSchema;
|
|
5621
|
+
var CausationEventSchema2 = _chunkQSXWCJ2Ucjs.CausationEventSchema;
|
|
5622
|
+
var CommittedMetaSchema2 = _chunkQSXWCJ2Ucjs.CommittedMetaSchema;
|
|
5623
|
+
var QuerySchema2 = _chunkQSXWCJ2Ucjs.QuerySchema;
|
|
5624
|
+
var Environments2 = _chunkQSXWCJ2Ucjs.Environments;
|
|
5625
|
+
var LogLevels2 = _chunkQSXWCJ2Ucjs.LogLevels;
|
|
5626
|
+
var ExitCodes2 = _chunkQSXWCJ2Ucjs.ExitCodes;
|
|
5627
|
+
var DEFAULT_LANE2 = _chunkQSXWCJ2Ucjs.DEFAULT_LANE;
|
|
5628
|
+
var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = _chunkQSXWCJ2Ucjs.DEFAULT_MAX_SUBSCRIBED_STREAMS;
|
|
5629
|
+
var DEFAULT_SETTLE_DEBOUNCE_MS2 = _chunkQSXWCJ2Ucjs.DEFAULT_SETTLE_DEBOUNCE_MS;
|
|
5630
|
+
var PackageSchema = _chunkOW67FBYOcjs.package_schema;
|
|
5631
|
+
var default_scope = _chunkOW67FBYOcjs.unscoped_ports;
|
|
5632
|
+
var extend = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (source, schema, target) => ({ ...target, ..._chunkOW67FBYOcjs.validate.call(void 0, "config", source, schema) }), "extend");
|
|
5493
5633
|
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])?$/;
|
|
5494
|
-
var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value;
|
|
5634
|
+
var dateReviver = /* @__PURE__ */ _chunkQSXWCJ2Ucjs.__name.call(void 0, (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
|
|
5495
5635
|
|
|
5496
5636
|
|
|
5497
5637
|
|
|
@@ -5551,5 +5691,5 @@ var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(va
|
|
|
5551
5691
|
|
|
5552
5692
|
|
|
5553
5693
|
|
|
5554
|
-
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError =
|
|
5694
|
+
exports.Act = Act; exports.ActorSchema = ActorSchema2; exports.CausationEventSchema = CausationEventSchema2; exports.CommittedMetaSchema = CommittedMetaSchema2; exports.ConcurrencyError = _chunkQSXWCJ2Ucjs.ConcurrencyError; exports.ConsoleLogger = _chunkOW67FBYOcjs.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 = _chunkQSXWCJ2Ucjs.DeferSignal; exports.Environments = Environments2; exports.Errors = _chunkQSXWCJ2Ucjs.Errors; exports.EventMetaSchema = EventMetaSchema2; exports.ExitCodes = ExitCodes2; exports.InMemoryCache = _chunkOW67FBYOcjs.InMemoryCache; exports.InMemoryStore = _chunkOW67FBYOcjs.InMemoryStore; exports.LogLevels = LogLevels2; exports.NonRetryableError = _chunkQSXWCJ2Ucjs.NonRetryableError; exports.PackageSchema = PackageSchema; exports.PreconditionError = _chunkQSXWCJ2Ucjs.PreconditionError; exports.QuerySchema = QuerySchema2; exports.REDACTED = _chunkQSXWCJ2Ucjs.REDACTED; exports.SHREDDED = _chunkQSXWCJ2Ucjs.SHREDDED; exports.SNAP_EVENT = _chunkQSXWCJ2Ucjs.SNAP_EVENT; exports.StoreError = _chunkQSXWCJ2Ucjs.StoreError; exports.StreamClosedError = _chunkQSXWCJ2Ucjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkQSXWCJ2Ucjs.TOMBSTONE_EVENT; exports.TargetSchema = TargetSchema2; exports.ValidationError = _chunkQSXWCJ2Ucjs.ValidationError; exports.ZodEmpty = _chunkQSXWCJ2Ucjs.ZodEmpty; exports.act = act; exports.cache = _chunkOW67FBYOcjs.cache; exports.check_appends = check_appends; exports.concurrency_error = concurrency_error; exports.config = _chunkOW67FBYOcjs.config; exports.dateReviver = dateReviver; exports.default_scope = default_scope; exports.dispose = _chunkOW67FBYOcjs.dispose; exports.disposeAndExit = _chunkOW67FBYOcjs.disposeAndExit; exports.extend = extend; exports.fair_slots = fair_slots; exports.is_literal_source = is_literal_source; exports.log = _chunkOW67FBYOcjs.log; exports.notification_of = notification_of; exports.pii_fields = _chunkQSXWCJ2Ucjs.pii_fields; exports.port = _chunkOW67FBYOcjs.port; exports.projection = projection; exports.seed_event = seed_event; exports.sensitive = _chunkQSXWCJ2Ucjs.sensitive; exports.sensitiveFields = _chunkQSXWCJ2Ucjs.sensitiveFields; exports.sleep = _chunkOW67FBYOcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkOW67FBYOcjs.store; exports.throw_if_stale = throw_if_stale; exports.validate = _chunkOW67FBYOcjs.validate;
|
|
5555
5695
|
//# sourceMappingURL=index.cjs.map
|