@graphrefly/ts 0.0.0
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/LICENSE +21 -0
- package/dist/adapters/index.cjs +9015 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +678 -0
- package/dist/adapters/index.d.ts +678 -0
- package/dist/adapters/index.js +2894 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/observe-storage.cjs +260 -0
- package/dist/adapters/observe-storage.cjs.map +1 -0
- package/dist/adapters/observe-storage.d.cts +77 -0
- package/dist/adapters/observe-storage.d.ts +77 -0
- package/dist/adapters/observe-storage.js +161 -0
- package/dist/adapters/observe-storage.js.map +1 -0
- package/dist/append-log-DisvEReb.d.cts +189 -0
- package/dist/append-log-DzKMmjxx.d.ts +189 -0
- package/dist/chunk-2ILL7HQI.js +1189 -0
- package/dist/chunk-2ILL7HQI.js.map +1 -0
- package/dist/chunk-4VLAQHZI.js +330 -0
- package/dist/chunk-4VLAQHZI.js.map +1 -0
- package/dist/chunk-6PHB5CJS.js +229 -0
- package/dist/chunk-6PHB5CJS.js.map +1 -0
- package/dist/chunk-COHO25CZ.js +2449 -0
- package/dist/chunk-COHO25CZ.js.map +1 -0
- package/dist/chunk-D6BG7U6A.js +161 -0
- package/dist/chunk-D6BG7U6A.js.map +1 -0
- package/dist/chunk-DJC4CHLQ.js +818 -0
- package/dist/chunk-DJC4CHLQ.js.map +1 -0
- package/dist/chunk-DK554R7P.js +67 -0
- package/dist/chunk-DK554R7P.js.map +1 -0
- package/dist/chunk-DKP56CSW.js +322 -0
- package/dist/chunk-DKP56CSW.js.map +1 -0
- package/dist/chunk-G4M3NHRJ.js +688 -0
- package/dist/chunk-G4M3NHRJ.js.map +1 -0
- package/dist/chunk-GAJW5I5P.js +1 -0
- package/dist/chunk-GAJW5I5P.js.map +1 -0
- package/dist/chunk-GDL26N2T.js +282 -0
- package/dist/chunk-GDL26N2T.js.map +1 -0
- package/dist/chunk-GTPCOEOZ.js +741 -0
- package/dist/chunk-GTPCOEOZ.js.map +1 -0
- package/dist/chunk-H2HTHFVN.js +1 -0
- package/dist/chunk-H2HTHFVN.js.map +1 -0
- package/dist/chunk-HDRL4VQQ.js +218 -0
- package/dist/chunk-HDRL4VQQ.js.map +1 -0
- package/dist/chunk-I3IHOHCJ.js +2267 -0
- package/dist/chunk-I3IHOHCJ.js.map +1 -0
- package/dist/chunk-JIMUDQN3.js +965 -0
- package/dist/chunk-JIMUDQN3.js.map +1 -0
- package/dist/chunk-JR4IKCR2.js +462 -0
- package/dist/chunk-JR4IKCR2.js.map +1 -0
- package/dist/chunk-K3FXTC3I.js +165 -0
- package/dist/chunk-K3FXTC3I.js.map +1 -0
- package/dist/chunk-OOEN33FB.js +65 -0
- package/dist/chunk-OOEN33FB.js.map +1 -0
- package/dist/chunk-PKVBHGBM.js +554 -0
- package/dist/chunk-PKVBHGBM.js.map +1 -0
- package/dist/chunk-RIIOUTGM.js +1857 -0
- package/dist/chunk-RIIOUTGM.js.map +1 -0
- package/dist/chunk-SCRFRCGR.js +33 -0
- package/dist/chunk-SCRFRCGR.js.map +1 -0
- package/dist/chunk-SWTLEQL6.js +53 -0
- package/dist/chunk-SWTLEQL6.js.map +1 -0
- package/dist/chunk-SZAETNNA.js +1 -0
- package/dist/chunk-SZAETNNA.js.map +1 -0
- package/dist/chunk-TEW47IVR.js +49 -0
- package/dist/chunk-TEW47IVR.js.map +1 -0
- package/dist/chunk-Y3ZLRGHC.js +1482 -0
- package/dist/chunk-Y3ZLRGHC.js.map +1 -0
- package/dist/chunk-Z2ANQ6JW.js +149 -0
- package/dist/chunk-Z2ANQ6JW.js.map +1 -0
- package/dist/codec-BB7p8fJc.d.cts +38 -0
- package/dist/codec-BB7p8fJc.d.ts +38 -0
- package/dist/composition/index.cjs +2505 -0
- package/dist/composition/index.cjs.map +1 -0
- package/dist/composition/index.d.cts +95 -0
- package/dist/composition/index.d.ts +95 -0
- package/dist/composition/index.js +19 -0
- package/dist/composition/index.js.map +1 -0
- package/dist/core/index.cjs +2475 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +25 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/index.js +74 -0
- package/dist/core/index.js.map +1 -0
- package/dist/cqrs/index.cjs +595 -0
- package/dist/cqrs/index.cjs.map +1 -0
- package/dist/cqrs/index.d.cts +200 -0
- package/dist/cqrs/index.d.ts +200 -0
- package/dist/cqrs/index.js +557 -0
- package/dist/cqrs/index.js.map +1 -0
- package/dist/data-structures/index.cjs +4277 -0
- package/dist/data-structures/index.cjs.map +1 -0
- package/dist/data-structures/index.d.cts +22 -0
- package/dist/data-structures/index.d.ts +22 -0
- package/dist/data-structures/index.js +31 -0
- package/dist/data-structures/index.js.map +1 -0
- package/dist/describe-BZb7AS2y.d.ts +57 -0
- package/dist/describe-Ciu8SUnN.d.cts +57 -0
- package/dist/graph/index.cjs +7832 -0
- package/dist/graph/index.cjs.map +1 -0
- package/dist/graph/index.d.cts +251 -0
- package/dist/graph/index.d.ts +251 -0
- package/dist/graph/index.js +131 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph-DfdF9zy4.d.ts +666 -0
- package/dist/graph-s23RbbFO.d.cts +666 -0
- package/dist/index-CAEmLCYF.d.cts +166 -0
- package/dist/index-SnzZu3x7.d.ts +166 -0
- package/dist/index.cjs +15409 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/messages-BZqrGGm1.d.cts +55 -0
- package/dist/messages-BZqrGGm1.d.ts +55 -0
- package/dist/messaging/index.cjs +818 -0
- package/dist/messaging/index.cjs.map +1 -0
- package/dist/messaging/index.d.cts +235 -0
- package/dist/messaging/index.d.ts +235 -0
- package/dist/messaging/index.js +767 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/observe-event-log-0SVsx7JG.d.cts +88 -0
- package/dist/observe-event-log-Dnm76owp.d.ts +88 -0
- package/dist/operators/index.cjs +3774 -0
- package/dist/operators/index.cjs.map +1 -0
- package/dist/operators/index.d.cts +308 -0
- package/dist/operators/index.d.ts +308 -0
- package/dist/operators/index.js +112 -0
- package/dist/operators/index.js.map +1 -0
- package/dist/orchestration/index.cjs +3541 -0
- package/dist/orchestration/index.cjs.map +1 -0
- package/dist/orchestration/index.d.cts +302 -0
- package/dist/orchestration/index.d.ts +302 -0
- package/dist/orchestration/index.js +1004 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/patterns/index.cjs +1045 -0
- package/dist/patterns/index.cjs.map +1 -0
- package/dist/patterns/index.d.cts +39 -0
- package/dist/patterns/index.d.ts +39 -0
- package/dist/patterns/index.js +33 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/reactive-collection-BxBqtIOE.d.cts +344 -0
- package/dist/reactive-collection-Cb1II1Fi.d.ts +344 -0
- package/dist/reactive-collection-storage-BNiEc-Gd.d.ts +217 -0
- package/dist/reactive-collection-storage-D-KmjE0J.d.cts +217 -0
- package/dist/reactive-map-BcB4KsQR.d.ts +256 -0
- package/dist/reactive-map-D-g3dv8I.d.cts +256 -0
- package/dist/read-through-B1CYPfq_.d.cts +82 -0
- package/dist/read-through-DwyJhGs1.d.ts +82 -0
- package/dist/render/index.cjs +250 -0
- package/dist/render/index.cjs.map +1 -0
- package/dist/render/index.d.cts +58 -0
- package/dist/render/index.d.ts +58 -0
- package/dist/render/index.js +20 -0
- package/dist/render/index.js.map +1 -0
- package/dist/resilience-Dig3Q7n0.d.cts +45 -0
- package/dist/resilience-Dig3Q7n0.d.ts +45 -0
- package/dist/semantic-memory-graph-BYoIlP35.d.cts +356 -0
- package/dist/semantic-memory-graph-CxyXLms3.d.ts +356 -0
- package/dist/solutions/index.cjs +3249 -0
- package/dist/solutions/index.cjs.map +1 -0
- package/dist/solutions/index.d.cts +520 -0
- package/dist/solutions/index.d.ts +520 -0
- package/dist/solutions/index.js +31 -0
- package/dist/solutions/index.js.map +1 -0
- package/dist/sources/browser.cjs +3095 -0
- package/dist/sources/browser.cjs.map +1 -0
- package/dist/sources/browser.d.cts +39 -0
- package/dist/sources/browser.d.ts +39 -0
- package/dist/sources/browser.js +137 -0
- package/dist/sources/browser.js.map +1 -0
- package/dist/sources/index.cjs +3021 -0
- package/dist/sources/index.cjs.map +1 -0
- package/dist/sources/index.d.cts +7 -0
- package/dist/sources/index.d.ts +7 -0
- package/dist/sources/index.js +63 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/node.cjs +675 -0
- package/dist/sources/node.cjs.map +1 -0
- package/dist/sources/node.d.cts +109 -0
- package/dist/sources/node.d.ts +109 -0
- package/dist/sources/node.js +639 -0
- package/dist/sources/node.js.map +1 -0
- package/dist/storage/browser.cjs +777 -0
- package/dist/storage/browser.cjs.map +1 -0
- package/dist/storage/browser.d.cts +40 -0
- package/dist/storage/browser.d.ts +40 -0
- package/dist/storage/browser.js +275 -0
- package/dist/storage/browser.js.map +1 -0
- package/dist/storage/index.cjs +1989 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +92 -0
- package/dist/storage/index.d.ts +92 -0
- package/dist/storage/index.js +161 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/node.cjs +898 -0
- package/dist/storage/node.cjs.map +1 -0
- package/dist/storage/node.d.cts +66 -0
- package/dist/storage/node.d.ts +66 -0
- package/dist/storage/node.js +402 -0
- package/dist/storage/node.js.map +1 -0
- package/dist/testing/index.cjs +95 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +20 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types-bNMSWKqF.d.cts +732 -0
- package/dist/types-h12mNYbq.d.ts +732 -0
- package/package.json +250 -0
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initNode,
|
|
3
|
+
toCheckpointJson
|
|
4
|
+
} from "./chunk-PKVBHGBM.js";
|
|
5
|
+
import {
|
|
6
|
+
errorPayload
|
|
7
|
+
} from "./chunk-DK554R7P.js";
|
|
8
|
+
|
|
9
|
+
// src/graph/sources.ts
|
|
10
|
+
function source(factory, setup, opts) {
|
|
11
|
+
return {
|
|
12
|
+
factory,
|
|
13
|
+
opts,
|
|
14
|
+
body: (ctx) => {
|
|
15
|
+
let cleanup;
|
|
16
|
+
let deactivated = false;
|
|
17
|
+
ctx.onDeactivation(() => {
|
|
18
|
+
deactivated = true;
|
|
19
|
+
if (typeof cleanup === "function") cleanup();
|
|
20
|
+
});
|
|
21
|
+
const maybeCleanup = setup(ctx);
|
|
22
|
+
cleanup = typeof maybeCleanup === "function" ? maybeCleanup : void 0;
|
|
23
|
+
if (deactivated && typeof cleanup === "function") cleanup();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function assertNonEmptyString(value, label) {
|
|
28
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
29
|
+
throw new TypeError(`${label} must be a non-empty string`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function cleanupDriverWork(active, cancelSlot) {
|
|
33
|
+
active.value = false;
|
|
34
|
+
const cancel = cancelSlot.value;
|
|
35
|
+
cancelSlot.value = void 0;
|
|
36
|
+
if (cancel !== void 0) runDriverCancel(cancel);
|
|
37
|
+
}
|
|
38
|
+
function installDriverCancel(active, cancelSlot, cancel) {
|
|
39
|
+
if (active.value) cancelSlot.value = cancel;
|
|
40
|
+
else runDriverCancel(cancel);
|
|
41
|
+
}
|
|
42
|
+
function runDriverCancel(cancel) {
|
|
43
|
+
try {
|
|
44
|
+
cancel();
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function driverOneShotSource(factory, missing, start) {
|
|
49
|
+
return source(
|
|
50
|
+
factory,
|
|
51
|
+
(ctx) => {
|
|
52
|
+
const active = { value: true };
|
|
53
|
+
const cancelSlot = { value: void 0 };
|
|
54
|
+
const callback = (result) => {
|
|
55
|
+
if (!active.value) return;
|
|
56
|
+
cleanupDriverWork(active, cancelSlot);
|
|
57
|
+
if (result.ok) ctx.down([["DATA", result.value], ["COMPLETE"]]);
|
|
58
|
+
else ctx.down([["ERROR", errorPayload(result.error)]]);
|
|
59
|
+
};
|
|
60
|
+
let cancel;
|
|
61
|
+
try {
|
|
62
|
+
cancel = start(ctx, callback);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
active.value = false;
|
|
65
|
+
ctx.down([["ERROR", errorPayload(e)]]);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (cancel === void 0) {
|
|
69
|
+
active.value = false;
|
|
70
|
+
ctx.down([["ERROR", missing]]);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
installDriverCancel(active, cancelSlot, cancel);
|
|
74
|
+
return () => cleanupDriverWork(active, cancelSlot);
|
|
75
|
+
},
|
|
76
|
+
{ pool: "async", pausable: false }
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function driverStreamSource(factory, missing, start, dataOf, errorOf) {
|
|
80
|
+
return source(
|
|
81
|
+
factory,
|
|
82
|
+
(ctx) => {
|
|
83
|
+
const active = { value: true };
|
|
84
|
+
const cancelSlot = { value: void 0 };
|
|
85
|
+
const callback = (event) => {
|
|
86
|
+
if (!active.value) return;
|
|
87
|
+
if (event.kind === "event") {
|
|
88
|
+
const value = dataOf(event);
|
|
89
|
+
if (value !== void 0) ctx.down([["DATA", value]]);
|
|
90
|
+
} else if (event.kind === "error") {
|
|
91
|
+
cleanupDriverWork(active, cancelSlot);
|
|
92
|
+
ctx.down([["ERROR", errorPayload(errorOf(event))]]);
|
|
93
|
+
} else if (event.kind === "complete") {
|
|
94
|
+
cleanupDriverWork(active, cancelSlot);
|
|
95
|
+
ctx.down([["COMPLETE"]]);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
let cancel;
|
|
99
|
+
try {
|
|
100
|
+
cancel = start(ctx, callback);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
active.value = false;
|
|
103
|
+
ctx.down([["ERROR", errorPayload(e)]]);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (cancel === void 0) {
|
|
107
|
+
active.value = false;
|
|
108
|
+
ctx.down([["ERROR", missing]]);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
installDriverCancel(active, cancelSlot, cancel);
|
|
112
|
+
return () => cleanupDriverWork(active, cancelSlot);
|
|
113
|
+
},
|
|
114
|
+
{ pool: "async", pausable: false }
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function isNode(x) {
|
|
118
|
+
return x != null && typeof x === "object" && "cache" in x && typeof x.subscribe === "function";
|
|
119
|
+
}
|
|
120
|
+
function isThenable(x) {
|
|
121
|
+
return x != null && typeof x.then === "function";
|
|
122
|
+
}
|
|
123
|
+
function isAsyncIterable(x) {
|
|
124
|
+
return x !== null && x !== void 0 && typeof x[Symbol.asyncIterator] === "function";
|
|
125
|
+
}
|
|
126
|
+
function isIterable(x) {
|
|
127
|
+
return x !== null && x !== void 0 && typeof x[Symbol.iterator] === "function";
|
|
128
|
+
}
|
|
129
|
+
function parseCronField(field, min, max) {
|
|
130
|
+
if (field.length === 0) throw new Error("Invalid cron field: empty");
|
|
131
|
+
const out = /* @__PURE__ */ new Set();
|
|
132
|
+
for (const part of field.split(",")) {
|
|
133
|
+
if (part.length === 0) throw new Error(`Invalid cron field: ${field}`);
|
|
134
|
+
const stepParts = part.split("/");
|
|
135
|
+
if (stepParts.length > 2) throw new Error(`Invalid cron step: ${part}`);
|
|
136
|
+
const [range, stepText] = stepParts;
|
|
137
|
+
if (range == null || range.length === 0) throw new Error(`Invalid cron field: ${field}`);
|
|
138
|
+
if (stepText === "") throw new Error(`Invalid cron step: ${part}`);
|
|
139
|
+
const step = stepText == null ? 1 : parseCronInt(stepText, `Invalid cron step: ${part}`);
|
|
140
|
+
if (step < 1) throw new Error(`Invalid cron step: ${part}`);
|
|
141
|
+
let start;
|
|
142
|
+
let end;
|
|
143
|
+
if (range === "*") {
|
|
144
|
+
start = min;
|
|
145
|
+
end = max;
|
|
146
|
+
} else if (range.includes("-")) {
|
|
147
|
+
const [a, b, extra] = range.split("-");
|
|
148
|
+
if (extra !== void 0 || a === "" || b === "")
|
|
149
|
+
throw new Error(`Invalid cron field: ${field}`);
|
|
150
|
+
start = parseCronInt(a, `Invalid cron field: ${field}`);
|
|
151
|
+
end = parseCronInt(b, `Invalid cron field: ${field}`);
|
|
152
|
+
} else {
|
|
153
|
+
start = parseCronInt(range, `Invalid cron field: ${field}`);
|
|
154
|
+
end = start;
|
|
155
|
+
}
|
|
156
|
+
if (!Number.isInteger(start) || !Number.isInteger(end)) {
|
|
157
|
+
throw new Error(`Invalid cron field: ${field}`);
|
|
158
|
+
}
|
|
159
|
+
if (start < min || end > max) {
|
|
160
|
+
throw new RangeError(`Cron field out of range: ${field} (${min}-${max})`);
|
|
161
|
+
}
|
|
162
|
+
if (start > end) throw new Error(`Invalid cron range: ${start}-${end} in ${field}`);
|
|
163
|
+
for (let i = start; i <= end; i += step) out.add(i);
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
function parseCronInt(text, message) {
|
|
168
|
+
if (!/^\d+$/.test(text)) throw new Error(message);
|
|
169
|
+
const value = Number.parseInt(text, 10);
|
|
170
|
+
if (!Number.isSafeInteger(value)) throw new Error(message);
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
function parseCron(expr) {
|
|
174
|
+
const parts = expr.trim().split(/\s+/);
|
|
175
|
+
if (parts.length !== 5 || parts.some((part) => part.length === 0)) {
|
|
176
|
+
throw new Error(`Invalid cron: expected 5 fields, got ${parts.length}`);
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
minutes: parseCronField(parts[0], 0, 59),
|
|
180
|
+
hours: parseCronField(parts[1], 0, 23),
|
|
181
|
+
daysOfMonth: parseCronField(parts[2], 1, 31),
|
|
182
|
+
months: parseCronField(parts[3], 1, 12),
|
|
183
|
+
daysOfWeek: parseCronField(parts[4], 0, 6)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function matchesCron(schedule, date) {
|
|
187
|
+
return schedule.minutes.has(date.getMinutes()) && schedule.hours.has(date.getHours()) && schedule.daysOfMonth.has(date.getDate()) && schedule.months.has(date.getMonth() + 1) && schedule.daysOfWeek.has(date.getDay());
|
|
188
|
+
}
|
|
189
|
+
function cronMinuteKey(date) {
|
|
190
|
+
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}-${date.getHours()}-${date.getMinutes()}`;
|
|
191
|
+
}
|
|
192
|
+
function dateToTimestampNs(date) {
|
|
193
|
+
return (BigInt(date.getTime()) * 1000000n).toString();
|
|
194
|
+
}
|
|
195
|
+
function fromCron(expr, opts = {}) {
|
|
196
|
+
const schedule = parseCron(expr);
|
|
197
|
+
const { tickMs = 6e4, output = "timestamp_ns", signal } = opts;
|
|
198
|
+
if (!Number.isFinite(tickMs) || tickMs <= 0) {
|
|
199
|
+
throw new RangeError("fromCron: tickMs must be a positive finite number");
|
|
200
|
+
}
|
|
201
|
+
return source(
|
|
202
|
+
"fromCron",
|
|
203
|
+
(ctx) => {
|
|
204
|
+
let done = false;
|
|
205
|
+
let lastFiredKey;
|
|
206
|
+
let intervalId;
|
|
207
|
+
const cleanup = () => {
|
|
208
|
+
done = true;
|
|
209
|
+
if (intervalId !== void 0) clearInterval(intervalId);
|
|
210
|
+
intervalId = void 0;
|
|
211
|
+
signal?.removeEventListener("abort", onAbort);
|
|
212
|
+
};
|
|
213
|
+
const onAbort = () => {
|
|
214
|
+
if (done) return;
|
|
215
|
+
cleanup();
|
|
216
|
+
ctx.down([["ERROR", errorPayload(signal?.reason)]]);
|
|
217
|
+
};
|
|
218
|
+
const emitNow = (now) => {
|
|
219
|
+
if (output === "date") ctx.down([["DATA", now]]);
|
|
220
|
+
else if (output === "timestamp_ms") ctx.down([["DATA", now.getTime()]]);
|
|
221
|
+
else ctx.down([["DATA", dateToTimestampNs(now)]]);
|
|
222
|
+
};
|
|
223
|
+
const check = () => {
|
|
224
|
+
if (done) return;
|
|
225
|
+
const now = /* @__PURE__ */ new Date();
|
|
226
|
+
const key = cronMinuteKey(now);
|
|
227
|
+
if (key !== lastFiredKey && matchesCron(schedule, now)) {
|
|
228
|
+
lastFiredKey = key;
|
|
229
|
+
emitNow(now);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
if (signal?.aborted) {
|
|
233
|
+
onAbort();
|
|
234
|
+
return cleanup;
|
|
235
|
+
}
|
|
236
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
237
|
+
check();
|
|
238
|
+
intervalId = setInterval(check, tickMs);
|
|
239
|
+
return cleanup;
|
|
240
|
+
},
|
|
241
|
+
{ pool: "sync", pausable: false }
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
function runProcess(program, args = []) {
|
|
245
|
+
return runProcessWithOptions({ program, args });
|
|
246
|
+
}
|
|
247
|
+
function fromProcess(program, args = []) {
|
|
248
|
+
return processSource("fromProcess", { program, args });
|
|
249
|
+
}
|
|
250
|
+
function runProcessWithOptions(command) {
|
|
251
|
+
return processSource("runProcess", command);
|
|
252
|
+
}
|
|
253
|
+
function processSource(factory, command) {
|
|
254
|
+
assertNonEmptyString(command.program, `${factory}: program`);
|
|
255
|
+
return driverOneShotSource(
|
|
256
|
+
factory,
|
|
257
|
+
`${factory}: missing process driver`,
|
|
258
|
+
(ctx, callback) => ctx.environment().processDriver()?.run(command, callback)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
function fromHttp(url) {
|
|
262
|
+
return fromHttpWithOptions({ method: "GET", url });
|
|
263
|
+
}
|
|
264
|
+
function fromHttpWithOptions(request) {
|
|
265
|
+
assertNonEmptyString(request.url, "fromHttp: url");
|
|
266
|
+
assertNonEmptyString(request.method, "fromHttp: method");
|
|
267
|
+
return driverOneShotSource(
|
|
268
|
+
"fromHttp",
|
|
269
|
+
"fromHttp: missing http driver",
|
|
270
|
+
(ctx, callback) => ctx.environment().httpDriver()?.request(request, callback)
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
function fromSSE(url) {
|
|
274
|
+
return fromSSEWithOptions({ url });
|
|
275
|
+
}
|
|
276
|
+
function fromSSEWithOptions(request) {
|
|
277
|
+
assertNonEmptyString(request.url, "fromSSE: url");
|
|
278
|
+
return driverStreamSource(
|
|
279
|
+
"fromSSE",
|
|
280
|
+
"fromSSE: missing sse driver",
|
|
281
|
+
(ctx, callback) => ctx.environment().sseDriver()?.connect(request, callback),
|
|
282
|
+
(event) => event.kind === "event" ? event.event : void 0,
|
|
283
|
+
(event) => event.kind === "error" ? event.error : void 0
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function fromWebSocket(url) {
|
|
287
|
+
return fromWebSocketWithOptions({ url });
|
|
288
|
+
}
|
|
289
|
+
function fromWebSocketWithOptions(request) {
|
|
290
|
+
assertNonEmptyString(request.url, "fromWebSocket: url");
|
|
291
|
+
return driverStreamSource(
|
|
292
|
+
"fromWebSocket",
|
|
293
|
+
"fromWebSocket: missing websocket driver",
|
|
294
|
+
(ctx, callback) => ctx.environment().webSocketDriver()?.connect(request, callback),
|
|
295
|
+
(event) => event.kind === "event" ? event.event : void 0,
|
|
296
|
+
(event) => event.kind === "error" ? event.error : void 0
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
function fromWebhook(id) {
|
|
300
|
+
return fromWebhookWithOptions({ id });
|
|
301
|
+
}
|
|
302
|
+
function fromWebhookWithOptions(registration) {
|
|
303
|
+
assertNonEmptyString(registration.id, "fromWebhook: id");
|
|
304
|
+
return driverStreamSource(
|
|
305
|
+
"fromWebhook",
|
|
306
|
+
"fromWebhook: missing webhook driver",
|
|
307
|
+
(ctx, callback) => ctx.environment().webhookDriver()?.register(registration, callback),
|
|
308
|
+
(event) => event.kind === "event" ? event.event : void 0,
|
|
309
|
+
(event) => event.kind === "error" ? event.error : void 0
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
function timerSource(factory, ms, opts) {
|
|
313
|
+
const { period, signal } = opts ?? {};
|
|
314
|
+
const op = source(
|
|
315
|
+
factory,
|
|
316
|
+
(ctx) => {
|
|
317
|
+
let done = false;
|
|
318
|
+
let count = 0;
|
|
319
|
+
let t;
|
|
320
|
+
let iv;
|
|
321
|
+
const cleanup = () => {
|
|
322
|
+
done = true;
|
|
323
|
+
if (t !== void 0) clearTimeout(t);
|
|
324
|
+
if (iv !== void 0) clearInterval(iv);
|
|
325
|
+
signal?.removeEventListener("abort", onAbort);
|
|
326
|
+
};
|
|
327
|
+
const onAbort = () => {
|
|
328
|
+
if (done) return;
|
|
329
|
+
cleanup();
|
|
330
|
+
ctx.down([["ERROR", errorPayload(signal?.reason)]]);
|
|
331
|
+
};
|
|
332
|
+
const finish = () => {
|
|
333
|
+
if (done) return;
|
|
334
|
+
if (period != null) {
|
|
335
|
+
ctx.down([["DATA", count++]]);
|
|
336
|
+
iv = setInterval(() => {
|
|
337
|
+
if (done) return;
|
|
338
|
+
ctx.down([["DATA", count++]]);
|
|
339
|
+
}, period);
|
|
340
|
+
} else {
|
|
341
|
+
done = true;
|
|
342
|
+
signal?.removeEventListener("abort", onAbort);
|
|
343
|
+
ctx.down([["DATA", count++], ["COMPLETE"]]);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
if (signal?.aborted) {
|
|
347
|
+
onAbort();
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
351
|
+
t = setTimeout(finish, ms);
|
|
352
|
+
return cleanup;
|
|
353
|
+
},
|
|
354
|
+
{ pool: "sync", pausable: false }
|
|
355
|
+
);
|
|
356
|
+
if (factory === "timer" && period === void 0 && signal === void 0) {
|
|
357
|
+
return { ...op, restore: { ref: "timer", config: { ms: toCheckpointJson(ms, "timer.ms") } } };
|
|
358
|
+
}
|
|
359
|
+
return op;
|
|
360
|
+
}
|
|
361
|
+
function timer(ms, opts) {
|
|
362
|
+
return timerSource("timer", ms, opts);
|
|
363
|
+
}
|
|
364
|
+
function fromTimer(ms, opts) {
|
|
365
|
+
return timerSource("fromTimer", ms, opts);
|
|
366
|
+
}
|
|
367
|
+
function interval(ms) {
|
|
368
|
+
return timerSource("interval", ms, { period: ms });
|
|
369
|
+
}
|
|
370
|
+
function fromPromise(p, opts) {
|
|
371
|
+
const signal = opts?.signal;
|
|
372
|
+
return source(
|
|
373
|
+
"fromPromise",
|
|
374
|
+
(ctx) => {
|
|
375
|
+
let settled = false;
|
|
376
|
+
const onAbort = () => {
|
|
377
|
+
if (settled) return;
|
|
378
|
+
settled = true;
|
|
379
|
+
ctx.down([["ERROR", errorPayload(signal.reason)]]);
|
|
380
|
+
};
|
|
381
|
+
if (signal?.aborted) {
|
|
382
|
+
onAbort();
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
386
|
+
void Promise.resolve(p).then(
|
|
387
|
+
(v) => {
|
|
388
|
+
if (settled) return;
|
|
389
|
+
settled = true;
|
|
390
|
+
signal?.removeEventListener("abort", onAbort);
|
|
391
|
+
ctx.down([["DATA", v], ["COMPLETE"]]);
|
|
392
|
+
},
|
|
393
|
+
(e) => {
|
|
394
|
+
if (settled) return;
|
|
395
|
+
settled = true;
|
|
396
|
+
signal?.removeEventListener("abort", onAbort);
|
|
397
|
+
ctx.down([["ERROR", errorPayload(e)]]);
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
return () => {
|
|
401
|
+
settled = true;
|
|
402
|
+
signal?.removeEventListener("abort", onAbort);
|
|
403
|
+
};
|
|
404
|
+
},
|
|
405
|
+
{ pool: "async" }
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
function fromAsyncIter(iterable, opts) {
|
|
409
|
+
const outerSignal = opts?.signal;
|
|
410
|
+
return source(
|
|
411
|
+
"fromAsyncIter",
|
|
412
|
+
(ctx) => {
|
|
413
|
+
const ac = new AbortController();
|
|
414
|
+
const onOuterAbort = () => ac.abort(outerSignal?.reason);
|
|
415
|
+
outerSignal?.addEventListener("abort", onOuterAbort, { once: true });
|
|
416
|
+
let done = false;
|
|
417
|
+
const pump = async () => {
|
|
418
|
+
try {
|
|
419
|
+
for await (const v of iterable) {
|
|
420
|
+
if (ac.signal.aborted) break;
|
|
421
|
+
ctx.down([["DATA", v]]);
|
|
422
|
+
}
|
|
423
|
+
if (!ac.signal.aborted) ctx.down([["COMPLETE"]]);
|
|
424
|
+
} catch (e) {
|
|
425
|
+
if (!ac.signal.aborted) ctx.down([["ERROR", errorPayload(e)]]);
|
|
426
|
+
} finally {
|
|
427
|
+
done = true;
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
void pump();
|
|
431
|
+
return () => {
|
|
432
|
+
if (!done) ac.abort();
|
|
433
|
+
outerSignal?.removeEventListener("abort", onOuterAbort);
|
|
434
|
+
};
|
|
435
|
+
},
|
|
436
|
+
{ pool: "async" }
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
function of(...values) {
|
|
440
|
+
return source(
|
|
441
|
+
"of",
|
|
442
|
+
(ctx) => {
|
|
443
|
+
for (const value of values) ctx.down([["DATA", value]]);
|
|
444
|
+
ctx.down([["COMPLETE"]]);
|
|
445
|
+
},
|
|
446
|
+
{ pool: "sync" }
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
function fromIter(iterable) {
|
|
450
|
+
return source(
|
|
451
|
+
"fromIter",
|
|
452
|
+
(ctx) => {
|
|
453
|
+
for (const v of iterable) ctx.down([["DATA", v]]);
|
|
454
|
+
ctx.down([["COMPLETE"]]);
|
|
455
|
+
},
|
|
456
|
+
{ pool: "sync" }
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
function empty() {
|
|
460
|
+
return source(
|
|
461
|
+
"empty",
|
|
462
|
+
(ctx) => {
|
|
463
|
+
ctx.down([["COMPLETE"]]);
|
|
464
|
+
},
|
|
465
|
+
{ pool: "sync" }
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
function never() {
|
|
469
|
+
return source("never", () => void 0, { pool: "sync" });
|
|
470
|
+
}
|
|
471
|
+
function throwError(err) {
|
|
472
|
+
return source(
|
|
473
|
+
"throwError",
|
|
474
|
+
(ctx) => {
|
|
475
|
+
ctx.down([["ERROR", errorPayload(err)]]);
|
|
476
|
+
},
|
|
477
|
+
{ pool: "sync" }
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
function fromEvent(target, type, opts = {}) {
|
|
481
|
+
if (target == null || typeof target.addEventListener !== "function") {
|
|
482
|
+
throw new TypeError("fromEvent: target must implement addEventListener");
|
|
483
|
+
}
|
|
484
|
+
if (typeof target.removeEventListener !== "function") {
|
|
485
|
+
throw new TypeError("fromEvent: target must implement removeEventListener");
|
|
486
|
+
}
|
|
487
|
+
if (typeof type !== "string" || type.length === 0) {
|
|
488
|
+
throw new TypeError("fromEvent: event type must be a non-empty string");
|
|
489
|
+
}
|
|
490
|
+
return source(
|
|
491
|
+
"fromEvent",
|
|
492
|
+
(ctx) => {
|
|
493
|
+
let done = false;
|
|
494
|
+
const handler = (event) => {
|
|
495
|
+
if (!done) ctx.down([["DATA", event]]);
|
|
496
|
+
};
|
|
497
|
+
target.addEventListener(type, handler, opts);
|
|
498
|
+
return () => {
|
|
499
|
+
done = true;
|
|
500
|
+
target.removeEventListener(type, handler, opts);
|
|
501
|
+
};
|
|
502
|
+
},
|
|
503
|
+
{ pool: "sync" }
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
function fromPushNotification(register) {
|
|
507
|
+
if (typeof register !== "function") {
|
|
508
|
+
throw new TypeError("fromPushNotification: register must be a function");
|
|
509
|
+
}
|
|
510
|
+
return source(
|
|
511
|
+
"fromPushNotification",
|
|
512
|
+
(ctx) => {
|
|
513
|
+
let done = false;
|
|
514
|
+
const deliver = (payload) => {
|
|
515
|
+
if (!done) ctx.down([["DATA", payload]]);
|
|
516
|
+
};
|
|
517
|
+
const unsubscribe = register(deliver);
|
|
518
|
+
return () => {
|
|
519
|
+
done = true;
|
|
520
|
+
if (typeof unsubscribe === "function") unsubscribe();
|
|
521
|
+
};
|
|
522
|
+
},
|
|
523
|
+
{ pool: "sync" }
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
function fromAny(input, opts = {}) {
|
|
527
|
+
if (isNode(input)) return input;
|
|
528
|
+
const { iter, ...nodeOpts } = opts;
|
|
529
|
+
if (isThenable(input)) {
|
|
530
|
+
return initNode(fromPromise(input), [], nodeOpts);
|
|
531
|
+
}
|
|
532
|
+
if (input !== null && input !== void 0) {
|
|
533
|
+
const candidate = input;
|
|
534
|
+
if (typeof candidate[Symbol.asyncIterator] === "function") {
|
|
535
|
+
return initNode(fromAsyncIter(input), [], nodeOpts);
|
|
536
|
+
}
|
|
537
|
+
if (iter === true && typeof candidate[Symbol.iterator] === "function") {
|
|
538
|
+
return initNode(fromIter(input), [], nodeOpts);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return initNode(of(input), [], nodeOpts);
|
|
542
|
+
}
|
|
543
|
+
function firstValueFrom(source2) {
|
|
544
|
+
return new Promise((resolve, reject) => {
|
|
545
|
+
let settled = false;
|
|
546
|
+
let shouldUnsub = false;
|
|
547
|
+
let unsub;
|
|
548
|
+
const finish = (f) => {
|
|
549
|
+
if (settled) return;
|
|
550
|
+
settled = true;
|
|
551
|
+
f();
|
|
552
|
+
if (unsub) {
|
|
553
|
+
unsub();
|
|
554
|
+
unsub = void 0;
|
|
555
|
+
} else {
|
|
556
|
+
shouldUnsub = true;
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
unsub = source2.subscribe((msg) => {
|
|
560
|
+
if (msg[0] === "DATA") {
|
|
561
|
+
finish(() => resolve(msg[1]));
|
|
562
|
+
} else if (msg[0] === "ERROR") {
|
|
563
|
+
finish(() => reject(msg[1]));
|
|
564
|
+
} else if (msg[0] === "COMPLETE") {
|
|
565
|
+
finish(() => reject(new Error("firstValueFrom: completed without DATA")));
|
|
566
|
+
} else if (msg[0] === "TEARDOWN") {
|
|
567
|
+
finish(() => reject(new Error("firstValueFrom: torn down without DATA")));
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
if (shouldUnsub) {
|
|
571
|
+
unsub?.();
|
|
572
|
+
unsub = void 0;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function singleFromAnyValue(value) {
|
|
577
|
+
if (value === void 0) {
|
|
578
|
+
throw new TypeError("singleFromAny: undefined is the substrate SENTINEL");
|
|
579
|
+
}
|
|
580
|
+
return value;
|
|
581
|
+
}
|
|
582
|
+
async function firstFromAsyncIterable(input) {
|
|
583
|
+
const iter = input[Symbol.asyncIterator]();
|
|
584
|
+
const { value, done } = await iter.next();
|
|
585
|
+
if (done) {
|
|
586
|
+
await iter.return?.();
|
|
587
|
+
throw new Error("singleFromAny: factory returned empty async iterable");
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
await iter.return?.();
|
|
591
|
+
} catch {
|
|
592
|
+
}
|
|
593
|
+
return value;
|
|
594
|
+
}
|
|
595
|
+
function firstFromIterable(input) {
|
|
596
|
+
const iter = input[Symbol.iterator]();
|
|
597
|
+
const { value, done } = iter.next();
|
|
598
|
+
if (done) {
|
|
599
|
+
iter.return?.();
|
|
600
|
+
return Promise.reject(new Error("singleFromAny: factory returned empty iterable"));
|
|
601
|
+
}
|
|
602
|
+
try {
|
|
603
|
+
iter.return?.();
|
|
604
|
+
} catch {
|
|
605
|
+
}
|
|
606
|
+
return Promise.resolve(value);
|
|
607
|
+
}
|
|
608
|
+
function nodeInputToPromise(input, opts) {
|
|
609
|
+
if (isThenable(input)) return Promise.resolve(input).then(singleFromAnyValue);
|
|
610
|
+
if (isNode(input)) return firstValueFrom(input).then(singleFromAnyValue);
|
|
611
|
+
if (isAsyncIterable(input)) return firstFromAsyncIterable(input).then(singleFromAnyValue);
|
|
612
|
+
if (opts.iter === true && isIterable(input)) {
|
|
613
|
+
return firstFromIterable(input).then(singleFromAnyValue);
|
|
614
|
+
}
|
|
615
|
+
if (input === void 0) {
|
|
616
|
+
return Promise.reject(new TypeError("singleFromAny: undefined is the substrate SENTINEL"));
|
|
617
|
+
}
|
|
618
|
+
return Promise.resolve(singleFromAnyValue(input));
|
|
619
|
+
}
|
|
620
|
+
function singleFromAny(factory, opts = {}) {
|
|
621
|
+
const keyOf = opts.keyOf ?? ((key) => key);
|
|
622
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
623
|
+
return (key) => {
|
|
624
|
+
const dedupeKey = keyOf(key);
|
|
625
|
+
const existing = inFlight.get(dedupeKey);
|
|
626
|
+
if (existing) return existing;
|
|
627
|
+
let resolvePending;
|
|
628
|
+
let rejectPending;
|
|
629
|
+
let tracked;
|
|
630
|
+
const cleanup = () => {
|
|
631
|
+
if (inFlight.get(dedupeKey) === tracked) inFlight.delete(dedupeKey);
|
|
632
|
+
};
|
|
633
|
+
const pending = new Promise((resolve, reject) => {
|
|
634
|
+
resolvePending = resolve;
|
|
635
|
+
rejectPending = reject;
|
|
636
|
+
});
|
|
637
|
+
tracked = pending.then(
|
|
638
|
+
(value) => {
|
|
639
|
+
cleanup();
|
|
640
|
+
return value;
|
|
641
|
+
},
|
|
642
|
+
(error) => {
|
|
643
|
+
cleanup();
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
);
|
|
647
|
+
inFlight.set(dedupeKey, tracked);
|
|
648
|
+
try {
|
|
649
|
+
nodeInputToPromise(factory(key), opts).then(resolvePending, rejectPending);
|
|
650
|
+
} catch (e) {
|
|
651
|
+
rejectPending(e);
|
|
652
|
+
}
|
|
653
|
+
return tracked;
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export {
|
|
658
|
+
parseCron,
|
|
659
|
+
matchesCron,
|
|
660
|
+
fromCron,
|
|
661
|
+
runProcess,
|
|
662
|
+
fromProcess,
|
|
663
|
+
runProcessWithOptions,
|
|
664
|
+
fromHttp,
|
|
665
|
+
fromHttpWithOptions,
|
|
666
|
+
fromSSE,
|
|
667
|
+
fromSSEWithOptions,
|
|
668
|
+
fromWebSocket,
|
|
669
|
+
fromWebSocketWithOptions,
|
|
670
|
+
fromWebhook,
|
|
671
|
+
fromWebhookWithOptions,
|
|
672
|
+
timer,
|
|
673
|
+
fromTimer,
|
|
674
|
+
interval,
|
|
675
|
+
fromPromise,
|
|
676
|
+
fromAsyncIter,
|
|
677
|
+
of,
|
|
678
|
+
fromIter,
|
|
679
|
+
empty,
|
|
680
|
+
never,
|
|
681
|
+
throwError,
|
|
682
|
+
fromEvent,
|
|
683
|
+
fromPushNotification,
|
|
684
|
+
fromAny,
|
|
685
|
+
firstValueFrom,
|
|
686
|
+
singleFromAny
|
|
687
|
+
};
|
|
688
|
+
//# sourceMappingURL=chunk-G4M3NHRJ.js.map
|