@rotorsoft/act 1.22.4 → 1.22.6
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/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-config.d.ts +13 -0
- package/dist/@types/internal/autoclose-config.d.ts.map +1 -1
- package/dist/@types/internal/drain.d.ts.map +1 -1
- package/dist/@types/internal/event-versions.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +15 -9
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +8 -6
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/@types/utils.d.ts +20 -0
- package/dist/@types/utils.d.ts.map +1 -1
- package/dist/{chunk-2FN4RFBQ.js → chunk-CWBI4NQD.js} +18 -5
- package/dist/chunk-CWBI4NQD.js.map +1 -0
- package/dist/index.cjs +47 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -4
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +16 -4
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-2FN4RFBQ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -13,13 +13,14 @@ import {
|
|
|
13
13
|
dispose,
|
|
14
14
|
disposeAndExit,
|
|
15
15
|
extend,
|
|
16
|
+
is_literal_source,
|
|
16
17
|
log,
|
|
17
18
|
port,
|
|
18
19
|
scoped,
|
|
19
20
|
sleep,
|
|
20
21
|
store,
|
|
21
22
|
validate
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-CWBI4NQD.js";
|
|
23
24
|
import {
|
|
24
25
|
ActorSchema,
|
|
25
26
|
CausationEventSchema,
|
|
@@ -88,6 +89,15 @@ function deprecated_event_names(names) {
|
|
|
88
89
|
const deprecated = /* @__PURE__ */ new Set();
|
|
89
90
|
for (const list of groups.values()) {
|
|
90
91
|
if (list.length < 2) continue;
|
|
92
|
+
const by_version = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const { version, name } of list) {
|
|
94
|
+
const clash = by_version.get(version);
|
|
95
|
+
if (clash)
|
|
96
|
+
throw new Error(
|
|
97
|
+
`duplicate event version: ${clash} and ${name} both map to version ${version} \u2014 leading zeros in a \`_v<n>\` suffix are not allowed; use a single canonical spelling`
|
|
98
|
+
);
|
|
99
|
+
by_version.set(version, name);
|
|
100
|
+
}
|
|
91
101
|
list.sort((a, b) => b.version - a.version);
|
|
92
102
|
for (let i = 1; i < list.length; i++) deprecated.add(list[i].name);
|
|
93
103
|
}
|
|
@@ -533,18 +543,33 @@ function hour_in_zone(now, timeZone) {
|
|
|
533
543
|
}).formatToParts(now);
|
|
534
544
|
return Number(parts.find((p) => p.type === "hour")?.value);
|
|
535
545
|
}
|
|
546
|
+
function hour_in_range(hour, start, end) {
|
|
547
|
+
return start < end ? hour >= start && hour < end : hour >= start || hour < end;
|
|
548
|
+
}
|
|
549
|
+
function is_dst_gap_open(now, timeZone, start) {
|
|
550
|
+
const hour = hour_in_zone(now, timeZone);
|
|
551
|
+
if (hour <= start) return false;
|
|
552
|
+
const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
|
|
553
|
+
return prev === start - 1 && hour === start + 1;
|
|
554
|
+
}
|
|
536
555
|
function in_autoclose_window(window, now) {
|
|
537
556
|
if (!window) return true;
|
|
538
557
|
const hour = hour_in_zone(now, window.timeZone);
|
|
539
|
-
return
|
|
558
|
+
return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
|
|
540
559
|
}
|
|
541
560
|
function next_window_open(window, now) {
|
|
561
|
+
const start_ms = now.getTime();
|
|
542
562
|
for (let h = 0; h <= 48; h++) {
|
|
543
|
-
const candidate = new Date(
|
|
563
|
+
const candidate = new Date(start_ms + h * 36e5);
|
|
544
564
|
if (hour_in_zone(candidate, window.timeZone) === window.start)
|
|
545
565
|
return candidate;
|
|
566
|
+
const boundary = new Date(
|
|
567
|
+
candidate.getTime() - candidate.getTime() % 36e5
|
|
568
|
+
);
|
|
569
|
+
if (is_dst_gap_open(boundary, window.timeZone, window.start))
|
|
570
|
+
return boundary;
|
|
546
571
|
}
|
|
547
|
-
return new Date(
|
|
572
|
+
return new Date(start_ms + 864e5);
|
|
548
573
|
}
|
|
549
574
|
|
|
550
575
|
// src/internal/autoclose-policy.ts
|
|
@@ -1638,8 +1663,10 @@ async function fetch(leased, eventLimit) {
|
|
|
1638
1663
|
return Promise.all(
|
|
1639
1664
|
leased.map(async ({ stream, source, at, lagging }) => {
|
|
1640
1665
|
const events = [];
|
|
1666
|
+
const stream_exact = source !== void 0 && is_literal_source(source) ? true : void 0;
|
|
1641
1667
|
await store().query((e) => events.push(e), {
|
|
1642
1668
|
stream: source,
|
|
1669
|
+
stream_exact,
|
|
1643
1670
|
after: at,
|
|
1644
1671
|
limit: eventLimit
|
|
1645
1672
|
});
|
|
@@ -4586,6 +4613,7 @@ export {
|
|
|
4586
4613
|
dispose,
|
|
4587
4614
|
disposeAndExit,
|
|
4588
4615
|
extend,
|
|
4616
|
+
is_literal_source,
|
|
4589
4617
|
log,
|
|
4590
4618
|
port,
|
|
4591
4619
|
projection,
|