@rotorsoft/act 2.1.2 → 2.1.4
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/internal/autoclose-reaction.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +2 -2
- package/dist/@types/types/builders.d.ts +2 -2
- package/dist/@types/types/restore.d.ts +6 -4
- package/dist/@types/types/restore.d.ts.map +1 -1
- package/dist/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1263,6 +1263,7 @@ async function scan(source, opts = {}, callback) {
|
|
|
1263
1263
|
let migrated_count = 0;
|
|
1264
1264
|
let processed = 0;
|
|
1265
1265
|
let at;
|
|
1266
|
+
const started = /* @__PURE__ */ new Set();
|
|
1266
1267
|
const closed_streams = /* @__PURE__ */ new Set();
|
|
1267
1268
|
if (drop_closed_streams) {
|
|
1268
1269
|
await source.query(
|
|
@@ -1285,13 +1286,16 @@ async function scan(source, opts = {}, callback) {
|
|
|
1285
1286
|
let id;
|
|
1286
1287
|
await source.query(
|
|
1287
1288
|
async (event) => {
|
|
1289
|
+
if (at !== void 0 && event.id <= at) return;
|
|
1288
1290
|
got++;
|
|
1289
1291
|
id = event.id;
|
|
1290
1292
|
processed++;
|
|
1291
1293
|
if (!is_valid(event))
|
|
1292
1294
|
throw new Error(`Invalid event at index ${processed}`);
|
|
1293
1295
|
if (on_progress) on_progress({ processed, id: event.id, max_id });
|
|
1294
|
-
|
|
1296
|
+
const has_history = started.has(event.stream);
|
|
1297
|
+
started.add(event.stream);
|
|
1298
|
+
if (drop_snapshots && event.name === SNAP_EVENT && has_history) {
|
|
1295
1299
|
dropped_snaps++;
|
|
1296
1300
|
return;
|
|
1297
1301
|
}
|
|
@@ -2338,10 +2342,12 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
|
2338
2342
|
throw new CloseSignal({
|
|
2339
2343
|
stream: aggregate,
|
|
2340
2344
|
archive: archiver ? () => archiver(aggregate, head) : void 0,
|
|
2341
|
-
//
|
|
2342
|
-
//
|
|
2343
|
-
//
|
|
2344
|
-
|
|
2345
|
+
// Hold the head and look again tomorrow: a close skipped for a
|
|
2346
|
+
// lagging reaction, or a failed archive, retries then, and a
|
|
2347
|
+
// closed stream has no head left to act on. The close guard
|
|
2348
|
+
// ignores this parked row, so it doesn't block its own close.
|
|
2349
|
+
at: head.id - 1,
|
|
2350
|
+
defer: days_after(/* @__PURE__ */ new Date(), 1)
|
|
2345
2351
|
});
|
|
2346
2352
|
if (keep_days !== void 0) {
|
|
2347
2353
|
const cutoff = days_before_now(keep_days);
|