@oomol-lab/open-flow 0.1.0-alpha.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 +201 -0
- package/NOTICE +47 -0
- package/README.md +18 -0
- package/dist/browser/_virtual_open-flow-twemoji-DJwKsM_w.js +5067 -0
- package/dist/browser/addNodeOptions-DqoIueCR.js +33746 -0
- package/dist/browser/assets/font-00b26ac825e20950.woff2 +0 -0
- package/dist/browser/assets/font-036d4e95149b69ff.woff2 +0 -0
- package/dist/browser/assets/font-07d8e303ce4fc12b.ttf +0 -0
- package/dist/browser/assets/font-08ce98e51b04d589.ttf +0 -0
- package/dist/browser/assets/font-0cdd387c9590a1a9.woff2 +0 -0
- package/dist/browser/assets/font-0d85ae7cc30f2379.ttf +0 -0
- package/dist/browser/assets/font-0f60d1b897938ec9.woff2 +0 -0
- package/dist/browser/assets/font-11e4dc8a6471ff6d.woff +0 -0
- package/dist/browser/assets/font-138ac28d1663b303.ttf +0 -0
- package/dist/browser/assets/font-1ae6bd7475590e97.woff +0 -0
- package/dist/browser/assets/font-1c67f068fea8bb09.ttf +0 -0
- package/dist/browser/assets/font-1e6f9579e90e2cac.ttf +0 -0
- package/dist/browser/assets/font-1ece03f79f95277d.ttf +0 -0
- package/dist/browser/assets/font-2014c523c3210bcc.woff +0 -0
- package/dist/browser/assets/font-30da91e84c893f87.woff +0 -0
- package/dist/browser/assets/font-3398dd02302557a7.woff +0 -0
- package/dist/browser/assets/font-3931dd81faed86ba.ttf +0 -0
- package/dist/browser/assets/font-500e04d54f0d5166.ttf +0 -0
- package/dist/browser/assets/font-51814d270d06ff02.woff2 +0 -0
- package/dist/browser/assets/font-5d53e70ad607c235.woff2 +0 -0
- package/dist/browser/assets/font-5e28753be717dac9.woff +0 -0
- package/dist/browser/assets/font-68534840bcfdd2bf.ttf +0 -0
- package/dist/browser/assets/font-68e8c73ef42afd3c.woff2 +0 -0
- package/dist/browser/assets/font-6ab6b62e9b62dae2.woff +0 -0
- package/dist/browser/assets/font-6b47c40166b6dbe2.woff2 +0 -0
- package/dist/browser/assets/font-70ee1f64a20f2048.ttf +0 -0
- package/dist/browser/assets/font-71d517d67827787c.woff2 +0 -0
- package/dist/browser/assets/font-73d591271b160496.woff2 +0 -0
- package/dist/browser/assets/font-74444efd593c005e.woff2 +0 -0
- package/dist/browser/assets/font-7af58c5ec8f132a2.woff2 +0 -0
- package/dist/browser/assets/font-850c0af5c2238497.woff +0 -0
- package/dist/browser/assets/font-8a8d244581371912.woff +0 -0
- package/dist/browser/assets/font-9163df9c7122432e.ttf +0 -0
- package/dist/browser/assets/font-91ee67500cc0129a.woff +0 -0
- package/dist/browser/assets/font-95b6d2f1a50173bf.ttf +0 -0
- package/dist/browser/assets/font-97479ca6cce906ab.woff2 +0 -0
- package/dist/browser/assets/font-99cd42a3c072d918.woff2 +0 -0
- package/dist/browser/assets/font-99f9c6750b489c94.woff +0 -0
- package/dist/browser/assets/font-9be7ceb88004ab8a.woff +0 -0
- package/dist/browser/assets/font-a4af7d414440a1c1.woff2 +0 -0
- package/dist/browser/assets/font-a6b2099fb555c60e.ttf +0 -0
- package/dist/browser/assets/font-a6f7ec0d846ac7ad.woff +0 -0
- package/dist/browser/assets/font-c2342cd8b869e017.woff2 +0 -0
- package/dist/browser/assets/font-c6368d87e8a1a3a5.woff +0 -0
- package/dist/browser/assets/font-c647367d1dd4e162.ttf +0 -0
- package/dist/browser/assets/font-c76c5d696297d51b.woff +0 -0
- package/dist/browser/assets/font-c943cc986384f59e.woff +0 -0
- package/dist/browser/assets/font-d0332f52868370fd.ttf +0 -0
- package/dist/browser/assets/font-d04c54219f9eaec6.woff2 +0 -0
- package/dist/browser/assets/font-d96cdf2b3bdd4d64.woff +0 -0
- package/dist/browser/assets/font-dc47344dbb6cb5b6.woff2 +0 -0
- package/dist/browser/assets/font-de7701e42cf1f4cf.woff2 +0 -0
- package/dist/browser/assets/font-e14fed02b1aba7ce.woff +0 -0
- package/dist/browser/assets/font-e99ae51144bf1232.woff2 +0 -0
- package/dist/browser/assets/font-ece03cfd83e22c21.woff +0 -0
- package/dist/browser/assets/font-ed0b74372feefcbb.ttf +0 -0
- package/dist/browser/assets/font-f01f3e87d9c6a61c.ttf +0 -0
- package/dist/browser/assets/font-f1d6ef86f3b11a52.woff +0 -0
- package/dist/browser/assets/font-f36ea897e19f4a2e.ttf +0 -0
- package/dist/browser/assets/font-f9377ab0271cda59.ttf +0 -0
- package/dist/browser/carbon-nMY84Amv.js +53 -0
- package/dist/browser/composite-7VwgfnXx.js +6088 -0
- package/dist/browser/createResourceDialog-ByuJWdSL.js +439 -0
- package/dist/browser/dist-7oZK9QXZ.js +50088 -0
- package/dist/browser/dist-B9OV3YTx.js +881 -0
- package/dist/browser/dist-BLk5M0uK.js +1816 -0
- package/dist/browser/dist-BbyiRq3c.js +3285 -0
- package/dist/browser/dist-CIq6ue3I.js +6646 -0
- package/dist/browser/dist-CLZJNoWB.js +89 -0
- package/dist/browser/dist-CvcmLAMW.js +1620 -0
- package/dist/browser/dist-DL0SDskM.js +2327 -0
- package/dist/browser/dist-Djd02JSy.js +1247 -0
- package/dist/browser/dist-aWSZx4q1.js +850 -0
- package/dist/browser/dist-n-z5HtaO.js +4 -0
- package/dist/browser/dist-o4dBuwiG.js +320 -0
- package/dist/browser/dist-zyY--HOV.js +1543 -0
- package/dist/browser/esm-DXw7EADW.js +218 -0
- package/dist/browser/favicon.svg +7 -0
- package/dist/browser/flowWorkspace-DwVMpcar.js +22092 -0
- package/dist/browser/lib-S4ccuMeT.js +7857 -0
- package/dist/browser/licenses.md +4973 -0
- package/dist/browser/markdownContent-ZZFfSRqO.js +44545 -0
- package/dist/browser/project-change.d.ts +311 -0
- package/dist/browser/project-change.js +259 -0
- package/dist/browser/project-notifications.d.ts +12 -0
- package/dist/browser/rolldown-runtime-CEFd7nDs.js +30 -0
- package/dist/browser/workbench-contract.d.ts +28 -0
- package/dist/browser/workbench.css +2 -0
- package/dist/browser/workbench.css.d.ts +1 -0
- package/dist/browser/workbench.d.ts +14 -0
- package/dist/browser/workbench.js +3364 -0
- package/dist/common/connector-action.d.ts +20 -0
- package/dist/common/connector-action.js +106 -0
- package/dist/common/connector-proxy.d.ts +14 -0
- package/dist/common/connector-proxy.js +0 -0
- package/dist/common/control-api-conformance.d.ts +13 -0
- package/dist/common/control-api-conformance.js +518 -0
- package/dist/common/control-api-errors.d.ts +121 -0
- package/dist/common/control-api.d.ts +349 -0
- package/dist/common/control-api.js +884 -0
- package/dist/common/cron-trigger.d.ts +21 -0
- package/dist/common/cron-trigger.js +834 -0
- package/dist/common/engine-contract.d.ts +7 -0
- package/dist/common/favicon.svg +7 -0
- package/dist/common/integration-trigger.d.ts +111 -0
- package/dist/common/integration-trigger.js +290 -0
- package/dist/common/licenses.md +27 -0
- package/dist/common/poll-trigger.d.ts +69 -0
- package/dist/common/poll-trigger.js +155 -0
- package/dist/common/project-encoding.d.ts +11 -0
- package/dist/common/project-encoding.js +242 -0
- package/dist/common/project-notifications.d.ts +12 -0
- package/dist/common/project-semantics.d.ts +55 -0
- package/dist/common/project-semantics.js +8687 -0
- package/dist/common/provider-triggers.d.ts +6 -0
- package/dist/common/provider-triggers.js +4614 -0
- package/dist/common/run-events.d.ts +9 -0
- package/dist/common/run-events.js +192 -0
- package/dist/common/run-lifecycle.d.ts +69 -0
- package/dist/common/run-lifecycle.js +169 -0
- package/dist/common/runtime-contract.d.ts +53 -0
- package/dist/common/runtime-contract.js +151 -0
- package/dist/common/scheduler.d.ts +99 -0
- package/dist/common/scheduler.js +379 -0
- package/dist/common/webhook-trigger.d.ts +22 -0
- package/dist/common/webhook-trigger.js +270 -0
- package/dist/index.d.ts +66 -0
- package/package.json +102 -0
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
//#region ../../node_modules/croner/dist/croner.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
return Date.UTC(e.y, e.m - 1, e.d, e.h, e.i, e.s);
|
|
4
|
+
}
|
|
5
|
+
function t(e, t) {
|
|
6
|
+
return e.y === t.y && e.m === t.m && e.d === t.d && e.h === t.h && e.i === t.i && e.s === t.s;
|
|
7
|
+
}
|
|
8
|
+
function n(e, t) {
|
|
9
|
+
let n = new Date(Date.parse(e));
|
|
10
|
+
if (isNaN(n)) throw Error("Invalid ISO8601 passed to timezone parser.");
|
|
11
|
+
let r = e.substring(9);
|
|
12
|
+
return r.includes("Z") || r.includes("+") || r.includes("-") ? o(n.getUTCFullYear(), n.getUTCMonth() + 1, n.getUTCDate(), n.getUTCHours(), n.getUTCMinutes(), n.getUTCSeconds(), "Etc/UTC") : o(n.getFullYear(), n.getMonth() + 1, n.getDate(), n.getHours(), n.getMinutes(), n.getSeconds(), t);
|
|
13
|
+
}
|
|
14
|
+
function r(e, t, r) {
|
|
15
|
+
return i(n(e, t), r);
|
|
16
|
+
}
|
|
17
|
+
function i(n, r) {
|
|
18
|
+
let i = new Date(e(n)), o = a(i, n.tz), s = e(n) - e(o), c = new Date(i.getTime() + s), l = a(c, n.tz);
|
|
19
|
+
if (t(l, n)) {
|
|
20
|
+
let e = /* @__PURE__ */ new Date(c.getTime() - 36e5);
|
|
21
|
+
return t(a(e, n.tz), n) ? e : c;
|
|
22
|
+
}
|
|
23
|
+
let u = new Date(c.getTime() + e(n) - e(l));
|
|
24
|
+
if (t(a(u, n.tz), n)) return u;
|
|
25
|
+
if (r) throw Error("Invalid date passed to fromTZ()");
|
|
26
|
+
return c.getTime() > u.getTime() ? c : u;
|
|
27
|
+
}
|
|
28
|
+
function a(e, t) {
|
|
29
|
+
let n, r;
|
|
30
|
+
try {
|
|
31
|
+
n = new Intl.DateTimeFormat("en-US", {
|
|
32
|
+
timeZone: t,
|
|
33
|
+
year: "numeric",
|
|
34
|
+
month: "numeric",
|
|
35
|
+
day: "numeric",
|
|
36
|
+
hour: "numeric",
|
|
37
|
+
minute: "numeric",
|
|
38
|
+
second: "numeric",
|
|
39
|
+
hour12: !1
|
|
40
|
+
}), r = n.formatToParts(e);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
let n = e instanceof Error ? e.message : String(e);
|
|
43
|
+
throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`);
|
|
44
|
+
}
|
|
45
|
+
let i = {
|
|
46
|
+
year: 0,
|
|
47
|
+
month: 0,
|
|
48
|
+
day: 0,
|
|
49
|
+
hour: 0,
|
|
50
|
+
minute: 0,
|
|
51
|
+
second: 0
|
|
52
|
+
};
|
|
53
|
+
for (let e of r) (e.type === "year" || e.type === "month" || e.type === "day" || e.type === "hour" || e.type === "minute" || e.type === "second") && (i[e.type] = parseInt(e.value, 10));
|
|
54
|
+
if (isNaN(i.year) || isNaN(i.month) || isNaN(i.day) || isNaN(i.hour) || isNaN(i.minute) || isNaN(i.second)) throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);
|
|
55
|
+
return i.hour === 24 && (i.hour = 0), {
|
|
56
|
+
y: i.year,
|
|
57
|
+
m: i.month,
|
|
58
|
+
d: i.day,
|
|
59
|
+
h: i.hour,
|
|
60
|
+
i: i.minute,
|
|
61
|
+
s: i.second,
|
|
62
|
+
tz: t
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function o(e, t, n, r, i, a, o) {
|
|
66
|
+
return {
|
|
67
|
+
y: e,
|
|
68
|
+
m: t,
|
|
69
|
+
d: n,
|
|
70
|
+
h: r,
|
|
71
|
+
i,
|
|
72
|
+
s: a,
|
|
73
|
+
tz: o
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var s = [
|
|
77
|
+
1,
|
|
78
|
+
2,
|
|
79
|
+
4,
|
|
80
|
+
8,
|
|
81
|
+
16
|
|
82
|
+
], c = class {
|
|
83
|
+
pattern;
|
|
84
|
+
timezone;
|
|
85
|
+
mode;
|
|
86
|
+
alternativeWeekdays;
|
|
87
|
+
sloppyRanges;
|
|
88
|
+
second;
|
|
89
|
+
minute;
|
|
90
|
+
hour;
|
|
91
|
+
day;
|
|
92
|
+
month;
|
|
93
|
+
dayOfWeek;
|
|
94
|
+
year;
|
|
95
|
+
lastDayOfMonth;
|
|
96
|
+
lastWeekday;
|
|
97
|
+
nearestWeekdays;
|
|
98
|
+
starDOM;
|
|
99
|
+
starDOW;
|
|
100
|
+
starYear;
|
|
101
|
+
useAndLogic;
|
|
102
|
+
constructor(e, t, n) {
|
|
103
|
+
this.pattern = e, this.timezone = t, this.mode = n?.mode ?? "auto", this.alternativeWeekdays = n?.alternativeWeekdays ?? !1, this.sloppyRanges = n?.sloppyRanges ?? !1, this.second = Array(60).fill(0), this.minute = Array(60).fill(0), this.hour = Array(24).fill(0), this.day = Array(31).fill(0), this.month = Array(12).fill(0), this.dayOfWeek = Array(7).fill(0), this.year = Array(1e4).fill(0), this.lastDayOfMonth = !1, this.lastWeekday = !1, this.nearestWeekdays = Array(31).fill(0), this.starDOM = !1, this.starDOW = !1, this.starYear = !1, this.useAndLogic = !1, this.parse();
|
|
104
|
+
}
|
|
105
|
+
parse() {
|
|
106
|
+
if (!(typeof this.pattern == "string" || this.pattern instanceof String)) throw TypeError("CronPattern: Pattern has to be of type string.");
|
|
107
|
+
this.pattern.indexOf("@") >= 0 && (this.pattern = this.handleNicknames(this.pattern).trim());
|
|
108
|
+
let e = this.pattern.match(/\S+/g) || [""], t = e.length;
|
|
109
|
+
if (e.length < 5 || e.length > 7) throw TypeError("CronPattern: invalid configuration format ('" + this.pattern + "'), exactly five, six, or seven space separated parts are required.");
|
|
110
|
+
if (this.mode !== "auto") {
|
|
111
|
+
let e;
|
|
112
|
+
switch (this.mode) {
|
|
113
|
+
case "5-part":
|
|
114
|
+
e = 5;
|
|
115
|
+
break;
|
|
116
|
+
case "6-part":
|
|
117
|
+
e = 6;
|
|
118
|
+
break;
|
|
119
|
+
case "7-part":
|
|
120
|
+
e = 7;
|
|
121
|
+
break;
|
|
122
|
+
case "5-or-6-parts":
|
|
123
|
+
e = [5, 6];
|
|
124
|
+
break;
|
|
125
|
+
case "6-or-7-parts":
|
|
126
|
+
e = [6, 7];
|
|
127
|
+
break;
|
|
128
|
+
default: e = 0;
|
|
129
|
+
}
|
|
130
|
+
if (!(Array.isArray(e) ? e.includes(t) : t === e)) {
|
|
131
|
+
let n = Array.isArray(e) ? e.join(" or ") : e.toString();
|
|
132
|
+
throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (e.length === 5 && e.unshift("0"), e.length === 6 && e.push("*"), e[3].toUpperCase() === "LW" ? (this.lastWeekday = !0, e[3] = "") : e[3].toUpperCase().indexOf("L") >= 0 && (e[3] = e[3].replace(/L/gi, ""), this.lastDayOfMonth = !0), e[3] == "*" && (this.starDOM = !0), e[6] == "*" && (this.starYear = !0), e[4].length >= 3 && (e[4] = this.replaceAlphaMonths(e[4])), e[5].length >= 3 && (e[5] = this.alternativeWeekdays ? this.replaceAlphaDaysQuartz(e[5]) : this.replaceAlphaDays(e[5])), e[5].startsWith("+") && (this.useAndLogic = !0, e[5] = e[5].substring(1), e[5] === "")) throw TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");
|
|
136
|
+
switch (e[5] == "*" && (this.starDOW = !0), this.pattern.indexOf("?") >= 0 && (e[0] = e[0].replace(/\?/g, "*"), e[1] = e[1].replace(/\?/g, "*"), e[2] = e[2].replace(/\?/g, "*"), e[3] = e[3].replace(/\?/g, "*"), e[4] = e[4].replace(/\?/g, "*"), e[5] = e[5].replace(/\?/g, "*"), e[6] &&= e[6].replace(/\?/g, "*")), this.mode) {
|
|
137
|
+
case "5-part":
|
|
138
|
+
e[0] = "0", e[6] = "*";
|
|
139
|
+
break;
|
|
140
|
+
case "6-part":
|
|
141
|
+
e[6] = "*";
|
|
142
|
+
break;
|
|
143
|
+
case "5-or-6-parts": e[6] = "*";
|
|
144
|
+
}
|
|
145
|
+
this.throwAtIllegalCharacters(e), this.partToArray("second", e[0], 0, 1), this.partToArray("minute", e[1], 0, 1), this.partToArray("hour", e[2], 0, 1), this.partToArray("day", e[3], -1, 1), this.partToArray("month", e[4], -1, 1);
|
|
146
|
+
let n = this.alternativeWeekdays ? -1 : 0;
|
|
147
|
+
this.partToArray("dayOfWeek", e[5], n, 63), this.partToArray("year", e[6], 0, 1), !this.alternativeWeekdays && this.dayOfWeek[7] && (this.dayOfWeek[0] = this.dayOfWeek[7]);
|
|
148
|
+
}
|
|
149
|
+
partToArray(e, t, n, r) {
|
|
150
|
+
let i = this[e], a = e === "day" && this.lastDayOfMonth, o = e === "day" && this.lastWeekday;
|
|
151
|
+
if (t === "" && !a && !o) throw TypeError("CronPattern: configuration entry " + e + " (" + t + ") is empty, check for trailing spaces.");
|
|
152
|
+
if (t === "*") return i.fill(r);
|
|
153
|
+
let s = t.split(",");
|
|
154
|
+
if (s.length > 1) for (let t = 0; t < s.length; t++) this.partToArray(e, s[t], n, r);
|
|
155
|
+
else t.indexOf("-") !== -1 && t.indexOf("/") !== -1 ? this.handleRangeWithStepping(t, e, n, r) : t.indexOf("-") === -1 ? t.indexOf("/") === -1 ? t !== "" && this.handleNumber(t, e, n, r) : this.handleStepping(t, e, n, r) : this.handleRange(t, e, n, r);
|
|
156
|
+
}
|
|
157
|
+
throwAtIllegalCharacters(e) {
|
|
158
|
+
for (let t = 0; t < e.length; t++) if ((t === 3 ? /[^/*0-9,\-WwLl]+/ : t === 5 ? /[^/*0-9,\-#Ll]+/ : /[^/*0-9,\-]+/).test(e[t])) throw TypeError("CronPattern: configuration entry " + t + " (" + e[t] + ") contains illegal characters.");
|
|
159
|
+
}
|
|
160
|
+
handleNumber(e, t, n, r) {
|
|
161
|
+
let i = this.extractNth(e, t), a = e.toUpperCase().includes("W");
|
|
162
|
+
if (t !== "day" && a) throw TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");
|
|
163
|
+
a && (t = "nearestWeekdays");
|
|
164
|
+
let o = parseInt(i[0], 10) + n;
|
|
165
|
+
if (isNaN(o)) throw TypeError("CronPattern: " + t + " is not a number: '" + e + "'");
|
|
166
|
+
this.setPart(t, o, i[1] || r);
|
|
167
|
+
}
|
|
168
|
+
setPart(e, t, n) {
|
|
169
|
+
if (!Object.prototype.hasOwnProperty.call(this, e)) throw TypeError("CronPattern: Invalid part specified: " + e);
|
|
170
|
+
if (e === "dayOfWeek") {
|
|
171
|
+
if (t === 7 && (t = 0), t < 0 || t > 6) throw RangeError("CronPattern: Invalid value for dayOfWeek: " + t);
|
|
172
|
+
this.setNthWeekdayOfMonth(t, n);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (e === "second" || e === "minute") {
|
|
176
|
+
if (t < 0 || t >= 60) throw RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
177
|
+
} else if (e === "hour") {
|
|
178
|
+
if (t < 0 || t >= 24) throw RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
179
|
+
} else if (e === "day" || e === "nearestWeekdays") {
|
|
180
|
+
if (t < 0 || t >= 31) throw RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
181
|
+
} else if (e === "month") {
|
|
182
|
+
if (t < 0 || t >= 12) throw RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
183
|
+
} else if (e === "year" && (t < 1 || t >= 1e4)) throw RangeError("CronPattern: Invalid value for " + e + ": " + t + " (supported range: 1-9999)");
|
|
184
|
+
this[e][t] = n;
|
|
185
|
+
}
|
|
186
|
+
validateNotNaN(e, t) {
|
|
187
|
+
if (isNaN(e)) throw TypeError(t);
|
|
188
|
+
}
|
|
189
|
+
validateRange(e, t, n, r, i) {
|
|
190
|
+
if (e > t) throw TypeError("CronPattern: From value is larger than to value: '" + i + "'");
|
|
191
|
+
if (n !== void 0) {
|
|
192
|
+
if (n === 0) throw TypeError("CronPattern: Syntax error, illegal stepping: 0");
|
|
193
|
+
if (n > this[r].length) throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part (" + this[r].length + ")");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
handleRangeWithStepping(e, t, n, r) {
|
|
197
|
+
if (e.toUpperCase().includes("W")) throw TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");
|
|
198
|
+
let i = this.extractNth(e, t), a = i[0].match(/^(\d+)-(\d+)\/(\d+)$/);
|
|
199
|
+
if (a === null) throw TypeError("CronPattern: Syntax error, illegal range with stepping: '" + e + "'");
|
|
200
|
+
let [, o, s, c] = a, l = parseInt(o, 10) + n, u = parseInt(s, 10) + n, d = parseInt(c, 10);
|
|
201
|
+
this.validateNotNaN(l, "CronPattern: Syntax error, illegal lower range (NaN)"), this.validateNotNaN(u, "CronPattern: Syntax error, illegal upper range (NaN)"), this.validateNotNaN(d, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(l, u, d, t, e);
|
|
202
|
+
for (let e = l; e <= u; e += d) this.setPart(t, e, i[1] || r);
|
|
203
|
+
}
|
|
204
|
+
extractNth(e, t) {
|
|
205
|
+
let n = e, r;
|
|
206
|
+
if (n.includes("#")) {
|
|
207
|
+
if (t !== "dayOfWeek") throw Error("CronPattern: nth (#) only allowed in day-of-week field");
|
|
208
|
+
r = n.split("#")[1], n = n.split("#")[0];
|
|
209
|
+
} else if (n.toUpperCase().endsWith("L")) {
|
|
210
|
+
if (t !== "dayOfWeek") throw Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");
|
|
211
|
+
r = "L", n = n.slice(0, -1);
|
|
212
|
+
}
|
|
213
|
+
return [n, r];
|
|
214
|
+
}
|
|
215
|
+
handleRange(e, t, n, r) {
|
|
216
|
+
if (e.toUpperCase().includes("W")) throw TypeError("CronPattern: Syntax error, W is not allowed in a range.");
|
|
217
|
+
let i = this.extractNth(e, t), a = i[0].split("-");
|
|
218
|
+
if (a.length !== 2) throw TypeError("CronPattern: Syntax error, illegal range: '" + e + "'");
|
|
219
|
+
let o = parseInt(a[0], 10) + n, s = parseInt(a[1], 10) + n;
|
|
220
|
+
this.validateNotNaN(o, "CronPattern: Syntax error, illegal lower range (NaN)"), this.validateNotNaN(s, "CronPattern: Syntax error, illegal upper range (NaN)"), this.validateRange(o, s, void 0, t, e);
|
|
221
|
+
for (let e = o; e <= s; e++) this.setPart(t, e, i[1] || r);
|
|
222
|
+
}
|
|
223
|
+
handleStepping(e, t, n, r) {
|
|
224
|
+
if (e.toUpperCase().includes("W")) throw TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");
|
|
225
|
+
let i = this.extractNth(e, t), a = i[0].split("/");
|
|
226
|
+
if (a.length !== 2) throw TypeError("CronPattern: Syntax error, illegal stepping: '" + e + "'");
|
|
227
|
+
if (this.sloppyRanges) a[0] === "" && (a[0] = "*");
|
|
228
|
+
else {
|
|
229
|
+
if (a[0] === "") throw TypeError("CronPattern: Syntax error, stepping with missing prefix ('" + e + "') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");
|
|
230
|
+
if (a[0] !== "*") throw TypeError("CronPattern: Syntax error, stepping with numeric prefix ('" + e + "') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");
|
|
231
|
+
}
|
|
232
|
+
let o = 0;
|
|
233
|
+
a[0] !== "*" && (o = parseInt(a[0], 10) + n);
|
|
234
|
+
let s = parseInt(a[1], 10);
|
|
235
|
+
this.validateNotNaN(s, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(0, this[t].length - 1, s, t, e);
|
|
236
|
+
for (let e = o; e < this[t].length; e += s) this.setPart(t, e, i[1] || r);
|
|
237
|
+
}
|
|
238
|
+
replaceAlphaDays(e) {
|
|
239
|
+
return e.replace(/-sun/gi, "-7").replace(/sun/gi, "0").replace(/mon/gi, "1").replace(/tue/gi, "2").replace(/wed/gi, "3").replace(/thu/gi, "4").replace(/fri/gi, "5").replace(/sat/gi, "6");
|
|
240
|
+
}
|
|
241
|
+
replaceAlphaDaysQuartz(e) {
|
|
242
|
+
return e.replace(/sun/gi, "1").replace(/mon/gi, "2").replace(/tue/gi, "3").replace(/wed/gi, "4").replace(/thu/gi, "5").replace(/fri/gi, "6").replace(/sat/gi, "7");
|
|
243
|
+
}
|
|
244
|
+
replaceAlphaMonths(e) {
|
|
245
|
+
return e.replace(/jan/gi, "1").replace(/feb/gi, "2").replace(/mar/gi, "3").replace(/apr/gi, "4").replace(/may/gi, "5").replace(/jun/gi, "6").replace(/jul/gi, "7").replace(/aug/gi, "8").replace(/sep/gi, "9").replace(/oct/gi, "10").replace(/nov/gi, "11").replace(/dec/gi, "12");
|
|
246
|
+
}
|
|
247
|
+
handleNicknames(e) {
|
|
248
|
+
let t = e.trim().toLowerCase();
|
|
249
|
+
if (t === "@yearly" || t === "@annually") return "0 0 1 1 *";
|
|
250
|
+
if (t === "@monthly") return "0 0 1 * *";
|
|
251
|
+
if (t === "@weekly") return "0 0 * * 0";
|
|
252
|
+
if (t === "@daily" || t === "@midnight") return "0 0 * * *";
|
|
253
|
+
if (t === "@hourly") return "0 * * * *";
|
|
254
|
+
if (t === "@reboot") throw TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");
|
|
255
|
+
return e;
|
|
256
|
+
}
|
|
257
|
+
setNthWeekdayOfMonth(e, t) {
|
|
258
|
+
if (typeof t != "number" && t.toUpperCase() === "L") this.dayOfWeek[e] = this.dayOfWeek[e] | 32;
|
|
259
|
+
else if (t === 63) this.dayOfWeek[e] = 63;
|
|
260
|
+
else if (t < 6 && t > 0) this.dayOfWeek[e] = this.dayOfWeek[e] | s[t - 1];
|
|
261
|
+
else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`);
|
|
262
|
+
}
|
|
263
|
+
}, l = [
|
|
264
|
+
31,
|
|
265
|
+
28,
|
|
266
|
+
31,
|
|
267
|
+
30,
|
|
268
|
+
31,
|
|
269
|
+
30,
|
|
270
|
+
31,
|
|
271
|
+
31,
|
|
272
|
+
30,
|
|
273
|
+
31,
|
|
274
|
+
30,
|
|
275
|
+
31
|
|
276
|
+
], u = [
|
|
277
|
+
[
|
|
278
|
+
"month",
|
|
279
|
+
"year",
|
|
280
|
+
0
|
|
281
|
+
],
|
|
282
|
+
[
|
|
283
|
+
"day",
|
|
284
|
+
"month",
|
|
285
|
+
-1
|
|
286
|
+
],
|
|
287
|
+
[
|
|
288
|
+
"hour",
|
|
289
|
+
"day",
|
|
290
|
+
0
|
|
291
|
+
],
|
|
292
|
+
[
|
|
293
|
+
"minute",
|
|
294
|
+
"hour",
|
|
295
|
+
0
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
"second",
|
|
299
|
+
"minute",
|
|
300
|
+
0
|
|
301
|
+
]
|
|
302
|
+
], d = class e {
|
|
303
|
+
tz;
|
|
304
|
+
ms;
|
|
305
|
+
second;
|
|
306
|
+
minute;
|
|
307
|
+
hour;
|
|
308
|
+
day;
|
|
309
|
+
month;
|
|
310
|
+
year;
|
|
311
|
+
constructor(t, n) {
|
|
312
|
+
if (this.tz = n, t && t instanceof Date) {
|
|
313
|
+
if (!isNaN(t)) this.fromDate(t);
|
|
314
|
+
else throw TypeError("CronDate: Invalid date passed to CronDate constructor");
|
|
315
|
+
} else if (t == null) this.fromDate(/* @__PURE__ */ new Date());
|
|
316
|
+
else if (t && typeof t == "string") this.fromString(t);
|
|
317
|
+
else if (t instanceof e) this.fromCronDate(t);
|
|
318
|
+
else throw TypeError("CronDate: Invalid type (" + typeof t + ") passed to CronDate constructor");
|
|
319
|
+
}
|
|
320
|
+
getLastDayOfMonth(e, t) {
|
|
321
|
+
return t === 1 ? new Date(Date.UTC(e, t + 1, 0)).getUTCDate() : l[t];
|
|
322
|
+
}
|
|
323
|
+
getLastWeekday(e, t) {
|
|
324
|
+
let n = this.getLastDayOfMonth(e, t), r = new Date(Date.UTC(e, t, n)).getUTCDay();
|
|
325
|
+
return r === 0 ? n - 2 : r === 6 ? n - 1 : n;
|
|
326
|
+
}
|
|
327
|
+
getNearestWeekday(e, t, n) {
|
|
328
|
+
let r = this.getLastDayOfMonth(e, t);
|
|
329
|
+
if (n > r) return -1;
|
|
330
|
+
let i = new Date(Date.UTC(e, t, n)).getUTCDay();
|
|
331
|
+
return i === 0 ? n === r ? n - 2 : n + 1 : i === 6 ? n === 1 ? n + 2 : n - 1 : n;
|
|
332
|
+
}
|
|
333
|
+
isNthWeekdayOfMonth(e, t, n, r) {
|
|
334
|
+
let i = new Date(Date.UTC(e, t, n)).getUTCDay(), a = 0;
|
|
335
|
+
for (let r = 1; r <= n; r++) new Date(Date.UTC(e, t, r)).getUTCDay() === i && a++;
|
|
336
|
+
if (r & 63 && s[a - 1] & r) return !0;
|
|
337
|
+
if (r & 32) {
|
|
338
|
+
let r = this.getLastDayOfMonth(e, t);
|
|
339
|
+
for (let a = n + 1; a <= r; a++) if (new Date(Date.UTC(e, t, a)).getUTCDay() === i) return !1;
|
|
340
|
+
return !0;
|
|
341
|
+
}
|
|
342
|
+
return !1;
|
|
343
|
+
}
|
|
344
|
+
fromDate(e) {
|
|
345
|
+
if (this.tz !== void 0) {
|
|
346
|
+
if (typeof this.tz == "number") this.ms = e.getUTCMilliseconds(), this.second = e.getUTCSeconds(), this.minute = e.getUTCMinutes() + this.tz, this.hour = e.getUTCHours(), this.day = e.getUTCDate(), this.month = e.getUTCMonth(), this.year = e.getUTCFullYear(), this.apply();
|
|
347
|
+
else try {
|
|
348
|
+
let t = a(e, this.tz);
|
|
349
|
+
this.ms = e.getMilliseconds(), this.second = t.s, this.minute = t.i, this.hour = t.h, this.day = t.d, this.month = t.m - 1, this.year = t.y;
|
|
350
|
+
} catch (e) {
|
|
351
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
352
|
+
throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`);
|
|
353
|
+
}
|
|
354
|
+
} else this.ms = e.getMilliseconds(), this.second = e.getSeconds(), this.minute = e.getMinutes(), this.hour = e.getHours(), this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear();
|
|
355
|
+
}
|
|
356
|
+
fromCronDate(e) {
|
|
357
|
+
this.tz = e.tz, this.year = e.year, this.month = e.month, this.day = e.day, this.hour = e.hour, this.minute = e.minute, this.second = e.second, this.ms = e.ms;
|
|
358
|
+
}
|
|
359
|
+
apply() {
|
|
360
|
+
if (this.month > 11 || this.month < 0 || this.day > l[this.month] || this.day < 1 || this.hour > 59 || this.minute > 59 || this.second > 59 || this.hour < 0 || this.minute < 0 || this.second < 0) {
|
|
361
|
+
let e = new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms));
|
|
362
|
+
return this.ms = e.getUTCMilliseconds(), this.second = e.getUTCSeconds(), this.minute = e.getUTCMinutes(), this.hour = e.getUTCHours(), this.day = e.getUTCDate(), this.month = e.getUTCMonth(), this.year = e.getUTCFullYear(), !0;
|
|
363
|
+
}
|
|
364
|
+
return !1;
|
|
365
|
+
}
|
|
366
|
+
fromString(e) {
|
|
367
|
+
if (typeof this.tz == "number") {
|
|
368
|
+
let t = r(e);
|
|
369
|
+
this.ms = t.getUTCMilliseconds(), this.second = t.getUTCSeconds(), this.minute = t.getUTCMinutes(), this.hour = t.getUTCHours(), this.day = t.getUTCDate(), this.month = t.getUTCMonth(), this.year = t.getUTCFullYear(), this.apply();
|
|
370
|
+
} else return this.fromDate(r(e, this.tz));
|
|
371
|
+
}
|
|
372
|
+
findNext(e, t, n, r) {
|
|
373
|
+
return this._findMatch(e, t, n, r, 1);
|
|
374
|
+
}
|
|
375
|
+
_findMatch(e, t, n, r, i) {
|
|
376
|
+
let a = this[t], o;
|
|
377
|
+
n.lastDayOfMonth && (o = this.getLastDayOfMonth(this.year, this.month));
|
|
378
|
+
let s = !n.starDOW && t == "day" ? new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay() : void 0, c = this[t] + r, l = i === 1 ? (e) => e < n[t].length : (e) => e >= 0;
|
|
379
|
+
for (let u = c; l(u); u += i) {
|
|
380
|
+
let i = n[t][u];
|
|
381
|
+
if (t === "day" && !i) {
|
|
382
|
+
for (let e = 0; e < n.nearestWeekdays.length; e++) if (n.nearestWeekdays[e]) {
|
|
383
|
+
let t = this.getNearestWeekday(this.year, this.month, e - r);
|
|
384
|
+
if (t === -1) continue;
|
|
385
|
+
if (t === u - r) {
|
|
386
|
+
i = 1;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (t === "day" && n.lastWeekday) {
|
|
392
|
+
let e = this.getLastWeekday(this.year, this.month);
|
|
393
|
+
u - r === e && (i = 1);
|
|
394
|
+
}
|
|
395
|
+
if (t === "day" && n.lastDayOfMonth && u - r == o && (i = 1), t === "day" && !n.starDOW) {
|
|
396
|
+
let t = n.dayOfWeek[(s + (u - r - 1)) % 7];
|
|
397
|
+
if (t && t & 63) t = +!!this.isNthWeekdayOfMonth(this.year, this.month, u - r, t);
|
|
398
|
+
else if (t) throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);
|
|
399
|
+
n.useAndLogic ? i &&= t : !e.domAndDow && !n.starDOM ? i ||= t : i &&= t;
|
|
400
|
+
}
|
|
401
|
+
if (i) return this[t] = u - r, a === this[t] ? 1 : 2;
|
|
402
|
+
}
|
|
403
|
+
return 3;
|
|
404
|
+
}
|
|
405
|
+
recurse(e, t, n) {
|
|
406
|
+
if (n === 0 && !e.starYear) {
|
|
407
|
+
if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
|
|
408
|
+
let t = -1;
|
|
409
|
+
for (let n = this.year + 1; n < e.year.length && n < 1e4; n++) if (e.year[n] === 1) {
|
|
410
|
+
t = n;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
if (t === -1) return null;
|
|
414
|
+
this.year = t, this.month = 0, this.day = 1, this.hour = 0, this.minute = 0, this.second = 0, this.ms = 0;
|
|
415
|
+
}
|
|
416
|
+
if (this.year >= 1e4) return null;
|
|
417
|
+
}
|
|
418
|
+
let r = this.findNext(t, u[n][0], e, u[n][2]);
|
|
419
|
+
if (r > 1) {
|
|
420
|
+
let i = n + 1;
|
|
421
|
+
for (; i < u.length;) this[u[i][0]] = -u[i][2], i++;
|
|
422
|
+
if (r === 3) {
|
|
423
|
+
if (this[u[n][1]]++, this[u[n][0]] = -u[n][2], this.apply(), n === 0 && !e.starYear) {
|
|
424
|
+
for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0 && this.year < 1e4;) this.year++;
|
|
425
|
+
if (this.year >= 1e4 || this.year >= e.year.length) return null;
|
|
426
|
+
}
|
|
427
|
+
return this.recurse(e, t, 0);
|
|
428
|
+
}
|
|
429
|
+
if (this.apply()) return this.recurse(e, t, n - 1);
|
|
430
|
+
}
|
|
431
|
+
return n += 1, n >= u.length ? this : (e.starYear ? this.year >= 3e3 : this.year >= 1e4) ? null : this.recurse(e, t, n);
|
|
432
|
+
}
|
|
433
|
+
increment(e, t, n) {
|
|
434
|
+
return this.second += t.interval !== void 0 && t.interval > 1 && n ? t.interval : 1, this.ms = 0, this.apply(), this.recurse(e, t, 0);
|
|
435
|
+
}
|
|
436
|
+
decrement(e, t) {
|
|
437
|
+
return this.second -= t.interval !== void 0 && t.interval > 1 ? t.interval : 1, this.ms = 0, this.apply(), this.recurseBackward(e, t, 0, 0);
|
|
438
|
+
}
|
|
439
|
+
recurseBackward(e, t, n, r = 0) {
|
|
440
|
+
if (r > 1e4) return null;
|
|
441
|
+
if (n === 0 && !e.starYear) {
|
|
442
|
+
if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
|
|
443
|
+
let t = -1;
|
|
444
|
+
for (let n = this.year - 1; n >= 0; n--) if (e.year[n] === 1) {
|
|
445
|
+
t = n;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
if (t === -1) return null;
|
|
449
|
+
this.year = t, this.month = 11, this.day = 31, this.hour = 23, this.minute = 59, this.second = 59, this.ms = 0;
|
|
450
|
+
}
|
|
451
|
+
if (this.year < 0) return null;
|
|
452
|
+
}
|
|
453
|
+
let i = this.findPrevious(t, u[n][0], e, u[n][2]);
|
|
454
|
+
if (i > 1) {
|
|
455
|
+
let a = n + 1;
|
|
456
|
+
for (; a < u.length;) {
|
|
457
|
+
let t = u[a][0], n = u[a][2], r = this.getMaxPatternValue(t, e, n);
|
|
458
|
+
this[t] = r, a++;
|
|
459
|
+
}
|
|
460
|
+
if (i === 3) {
|
|
461
|
+
if (this[u[n][1]]--, n === 0) {
|
|
462
|
+
let e = this.getLastDayOfMonth(this.year, this.month);
|
|
463
|
+
this.day > e && (this.day = e);
|
|
464
|
+
}
|
|
465
|
+
if (n === 1) {
|
|
466
|
+
if (this.day <= 0) this.day = 1;
|
|
467
|
+
else {
|
|
468
|
+
let e = this.year, t = this.month;
|
|
469
|
+
for (; t < 0;) t += 12, e--;
|
|
470
|
+
for (; t > 11;) t -= 12, e++;
|
|
471
|
+
let n = t === 1 ? new Date(Date.UTC(e, t + 1, 0)).getUTCDate() : l[t];
|
|
472
|
+
this.day > n && (this.day = n);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
this.apply();
|
|
476
|
+
let i = u[n][0], a = u[n][2], o = this.getMaxPatternValue(i, e, a);
|
|
477
|
+
if (i === "day") {
|
|
478
|
+
let e = this.getLastDayOfMonth(this.year, this.month);
|
|
479
|
+
this[i] = Math.min(o, e);
|
|
480
|
+
} else this[i] = o;
|
|
481
|
+
if (this.apply(), n === 0) {
|
|
482
|
+
let t = u[1][2], n = this.getMaxPatternValue("day", e, t), r = this.getLastDayOfMonth(this.year, this.month), i = Math.min(n, r);
|
|
483
|
+
i !== this.day && (this.day = i, this.hour = this.getMaxPatternValue("hour", e, u[2][2]), this.minute = this.getMaxPatternValue("minute", e, u[3][2]), this.second = this.getMaxPatternValue("second", e, u[4][2]));
|
|
484
|
+
}
|
|
485
|
+
if (n === 0 && !e.starYear) {
|
|
486
|
+
for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0;) this.year--;
|
|
487
|
+
if (this.year < 0) return null;
|
|
488
|
+
}
|
|
489
|
+
return this.recurseBackward(e, t, 0, r + 1);
|
|
490
|
+
}
|
|
491
|
+
if (this.apply()) return this.recurseBackward(e, t, n - 1, r + 1);
|
|
492
|
+
}
|
|
493
|
+
return n += 1, n >= u.length ? this : this.year < 0 ? null : this.recurseBackward(e, t, n, r + 1);
|
|
494
|
+
}
|
|
495
|
+
getMaxPatternValue(e, t, n) {
|
|
496
|
+
if (e === "day" && t.lastDayOfMonth || e === "day" && !t.starDOW) return this.getLastDayOfMonth(this.year, this.month);
|
|
497
|
+
for (let r = t[e].length - 1; r >= 0; r--) if (t[e][r]) return r - n;
|
|
498
|
+
return t[e].length - 1 - n;
|
|
499
|
+
}
|
|
500
|
+
findPrevious(e, t, n, r) {
|
|
501
|
+
return this._findMatch(e, t, n, r, -1);
|
|
502
|
+
}
|
|
503
|
+
getDate(e) {
|
|
504
|
+
return e || this.tz === void 0 ? new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms) : typeof this.tz == "number" ? new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute - this.tz, this.second, this.ms)) : i(o(this.year, this.month + 1, this.day, this.hour, this.minute, this.second, this.tz), !1);
|
|
505
|
+
}
|
|
506
|
+
getTime() {
|
|
507
|
+
return this.getDate(!1).getTime();
|
|
508
|
+
}
|
|
509
|
+
match(e, t) {
|
|
510
|
+
if (!e.starYear && (this.year < 0 || this.year >= e.year.length || e.year[this.year] === 0)) return !1;
|
|
511
|
+
for (let n = 0; n < u.length; n++) {
|
|
512
|
+
let r = u[n][0], i = u[n][2], a = this[r];
|
|
513
|
+
if (a + i < 0 || a + i >= e[r].length) return !1;
|
|
514
|
+
let o = e[r][a + i];
|
|
515
|
+
if (r === "day") {
|
|
516
|
+
if (!o) {
|
|
517
|
+
for (let t = 0; t < e.nearestWeekdays.length; t++) if (e.nearestWeekdays[t]) {
|
|
518
|
+
let e = this.getNearestWeekday(this.year, this.month, t - i);
|
|
519
|
+
if (e !== -1 && e === a) {
|
|
520
|
+
o = 1;
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (e.lastWeekday && a === this.getLastWeekday(this.year, this.month) && (o = 1), e.lastDayOfMonth && a === this.getLastDayOfMonth(this.year, this.month) && (o = 1), !e.starDOW) {
|
|
526
|
+
let n = new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay(), r = e.dayOfWeek[(n + (a - 1)) % 7];
|
|
527
|
+
r && r & 63 && (r = +!!this.isNthWeekdayOfMonth(this.year, this.month, a, r)), e.useAndLogic ? o &&= r : !t.domAndDow && !e.starDOM ? o ||= r : o &&= r;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (!o) return !1;
|
|
531
|
+
}
|
|
532
|
+
return !0;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
function f(e) {
|
|
536
|
+
if (e === void 0 && (e = {}), delete e.name, e.legacyMode !== void 0 && e.domAndDow === void 0 ? e.domAndDow = !e.legacyMode : e.domAndDow === void 0 && (e.domAndDow = !1), e.legacyMode = !e.domAndDow, e.paused = e.paused !== void 0 && e.paused, e.maxRuns = e.maxRuns === void 0 ? 1 / 0 : e.maxRuns, e.catch = e.catch !== void 0 && e.catch, e.interval = e.interval === void 0 ? 0 : parseInt(e.interval.toString(), 10), e.utcOffset = e.utcOffset === void 0 ? void 0 : parseInt(e.utcOffset.toString(), 10), e.dayOffset = e.dayOffset === void 0 ? 0 : parseInt(e.dayOffset.toString(), 10), e.unref = e.unref !== void 0 && e.unref, e.mode = e.mode === void 0 ? "auto" : e.mode, e.alternativeWeekdays = e.alternativeWeekdays !== void 0 && e.alternativeWeekdays, e.sloppyRanges = e.sloppyRanges !== void 0 && e.sloppyRanges, ![
|
|
537
|
+
"auto",
|
|
538
|
+
"5-part",
|
|
539
|
+
"6-part",
|
|
540
|
+
"7-part",
|
|
541
|
+
"5-or-6-parts",
|
|
542
|
+
"6-or-7-parts"
|
|
543
|
+
].includes(e.mode)) throw Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");
|
|
544
|
+
if (e.startAt && (e.startAt = new d(e.startAt, e.timezone)), e.stopAt && (e.stopAt = new d(e.stopAt, e.timezone)), e.interval !== null) {
|
|
545
|
+
if (isNaN(e.interval)) throw Error("CronOptions: Supplied value for interval is not a number");
|
|
546
|
+
if (e.interval < 0) throw Error("CronOptions: Supplied value for interval can not be negative");
|
|
547
|
+
}
|
|
548
|
+
if (e.utcOffset !== void 0) {
|
|
549
|
+
if (isNaN(e.utcOffset)) throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");
|
|
550
|
+
if (e.utcOffset < -870 || e.utcOffset > 870) throw Error("CronOptions: utcOffset out of bounds.");
|
|
551
|
+
if (e.utcOffset !== void 0 && e.timezone) throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.");
|
|
552
|
+
}
|
|
553
|
+
if (e.unref !== !0 && e.unref !== !1) throw Error("CronOptions: Unref should be either true, false or undefined(false).");
|
|
554
|
+
if (e.dayOffset !== void 0 && e.dayOffset !== 0 && isNaN(e.dayOffset)) throw Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");
|
|
555
|
+
return e;
|
|
556
|
+
}
|
|
557
|
+
function p(e) {
|
|
558
|
+
return Object.prototype.toString.call(e) === "[object Function]" || typeof e == "function" || e instanceof Function;
|
|
559
|
+
}
|
|
560
|
+
function m(e) {
|
|
561
|
+
return p(e);
|
|
562
|
+
}
|
|
563
|
+
function h(e) {
|
|
564
|
+
typeof Deno < "u" && typeof Deno.unrefTimer < "u" ? Deno.unrefTimer(e) : e && typeof e.unref < "u" && e.unref();
|
|
565
|
+
}
|
|
566
|
+
var g = 3e4, _ = [], v = class {
|
|
567
|
+
name;
|
|
568
|
+
options;
|
|
569
|
+
_states;
|
|
570
|
+
fn;
|
|
571
|
+
getTz() {
|
|
572
|
+
return this.options.timezone || this.options.utcOffset;
|
|
573
|
+
}
|
|
574
|
+
applyDayOffset(e) {
|
|
575
|
+
if (this.options.dayOffset !== void 0 && this.options.dayOffset !== 0) {
|
|
576
|
+
let t = this.options.dayOffset * 24 * 60 * 60 * 1e3;
|
|
577
|
+
return new Date(e.getTime() + t);
|
|
578
|
+
}
|
|
579
|
+
return e;
|
|
580
|
+
}
|
|
581
|
+
constructor(e, t, n) {
|
|
582
|
+
let r, i;
|
|
583
|
+
if (p(t)) i = t;
|
|
584
|
+
else if (typeof t == "object") r = t;
|
|
585
|
+
else if (t !== void 0) throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");
|
|
586
|
+
if (p(n)) i = n;
|
|
587
|
+
else if (typeof n == "object") r = n;
|
|
588
|
+
else if (n !== void 0) throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");
|
|
589
|
+
if (this.name = r?.name, this.options = f(r), this._states = {
|
|
590
|
+
kill: !1,
|
|
591
|
+
blocking: !1,
|
|
592
|
+
previousRun: void 0,
|
|
593
|
+
currentRun: void 0,
|
|
594
|
+
once: void 0,
|
|
595
|
+
currentTimeout: void 0,
|
|
596
|
+
maxRuns: r ? r.maxRuns : void 0,
|
|
597
|
+
paused: r ? r.paused : !1,
|
|
598
|
+
pattern: new c("* * * * *", void 0, { mode: "auto" })
|
|
599
|
+
}, e && (e instanceof Date || typeof e == "string" && e.indexOf(":") > 0) ? this._states.once = new d(e, this.getTz()) : this._states.pattern = new c(e, this.options.timezone, {
|
|
600
|
+
mode: this.options.mode,
|
|
601
|
+
alternativeWeekdays: this.options.alternativeWeekdays,
|
|
602
|
+
sloppyRanges: this.options.sloppyRanges
|
|
603
|
+
}), this.name) {
|
|
604
|
+
if (_.find((e) => e.name === this.name)) throw Error("Cron: Tried to initialize new named job '" + this.name + "', but name already taken.");
|
|
605
|
+
_.push(this);
|
|
606
|
+
}
|
|
607
|
+
return i !== void 0 && m(i) && (this.fn = i, this.schedule()), this;
|
|
608
|
+
}
|
|
609
|
+
nextRun(e) {
|
|
610
|
+
let t = this._next(e);
|
|
611
|
+
return t ? this.applyDayOffset(t.getDate(!1)) : null;
|
|
612
|
+
}
|
|
613
|
+
nextRuns(e, t) {
|
|
614
|
+
this._states.maxRuns !== void 0 && e > this._states.maxRuns && (e = this._states.maxRuns);
|
|
615
|
+
let n = t || this._states.currentRun || void 0;
|
|
616
|
+
return this._enumerateRuns(e, n, "next");
|
|
617
|
+
}
|
|
618
|
+
previousRuns(e, t) {
|
|
619
|
+
return this._enumerateRuns(e, t || void 0, "previous");
|
|
620
|
+
}
|
|
621
|
+
_enumerateRuns(e, t, n) {
|
|
622
|
+
let r = [], i = t ? new d(t, this.getTz()) : null, a = n === "next" ? this._next : this._previous;
|
|
623
|
+
for (; e--;) {
|
|
624
|
+
let e = a.call(this, i);
|
|
625
|
+
if (!e) break;
|
|
626
|
+
let t = e.getDate(!1);
|
|
627
|
+
r.push(this.applyDayOffset(t)), i = e;
|
|
628
|
+
}
|
|
629
|
+
return r;
|
|
630
|
+
}
|
|
631
|
+
match(e) {
|
|
632
|
+
if (this._states.once) {
|
|
633
|
+
let t = new d(e, this.getTz());
|
|
634
|
+
t.ms = 0;
|
|
635
|
+
let n = new d(this._states.once, this.getTz());
|
|
636
|
+
return n.ms = 0, t.getTime() === n.getTime();
|
|
637
|
+
}
|
|
638
|
+
let t = new d(e, this.getTz());
|
|
639
|
+
return t.ms = 0, t.match(this._states.pattern, this.options);
|
|
640
|
+
}
|
|
641
|
+
getPattern() {
|
|
642
|
+
if (!this._states.once) return this._states.pattern ? this._states.pattern.pattern : void 0;
|
|
643
|
+
}
|
|
644
|
+
getOnce() {
|
|
645
|
+
return this._states.once ? this._states.once.getDate() : null;
|
|
646
|
+
}
|
|
647
|
+
isRunning() {
|
|
648
|
+
let e = this.nextRun(this._states.currentRun), t = !this._states.paused, n = this.fn !== void 0, r = !this._states.kill;
|
|
649
|
+
return t && n && r && e !== null;
|
|
650
|
+
}
|
|
651
|
+
isStopped() {
|
|
652
|
+
return this._states.kill;
|
|
653
|
+
}
|
|
654
|
+
isBusy() {
|
|
655
|
+
return this._states.blocking;
|
|
656
|
+
}
|
|
657
|
+
currentRun() {
|
|
658
|
+
return this._states.currentRun ? this._states.currentRun.getDate() : null;
|
|
659
|
+
}
|
|
660
|
+
previousRun() {
|
|
661
|
+
return this._states.previousRun ? this._states.previousRun.getDate() : null;
|
|
662
|
+
}
|
|
663
|
+
msToNext(e) {
|
|
664
|
+
let t = this._next(e);
|
|
665
|
+
return t ? e instanceof d || e instanceof Date ? t.getTime() - e.getTime() : t.getTime() - new d(e).getTime() : null;
|
|
666
|
+
}
|
|
667
|
+
stop() {
|
|
668
|
+
this._states.kill = !0, this._states.currentTimeout && clearTimeout(this._states.currentTimeout);
|
|
669
|
+
let e = _.indexOf(this);
|
|
670
|
+
e >= 0 && _.splice(e, 1);
|
|
671
|
+
}
|
|
672
|
+
pause() {
|
|
673
|
+
return this._states.paused = !0, !this._states.kill;
|
|
674
|
+
}
|
|
675
|
+
resume() {
|
|
676
|
+
return this._states.paused = !1, !this._states.kill;
|
|
677
|
+
}
|
|
678
|
+
schedule(e) {
|
|
679
|
+
if (e && this.fn) throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");
|
|
680
|
+
e && (this.fn = e);
|
|
681
|
+
let t = this.msToNext(), n = this.nextRun(this._states.currentRun);
|
|
682
|
+
return t == null || isNaN(t) || n === null ? this : (t > g && (t = g), this._states.currentTimeout = setTimeout(() => this._checkTrigger(n), t), this._states.currentTimeout && this.options.unref && h(this._states.currentTimeout), this);
|
|
683
|
+
}
|
|
684
|
+
async _trigger(e) {
|
|
685
|
+
this._states.blocking = !0, this._states.currentRun = new d(void 0, this.getTz());
|
|
686
|
+
try {
|
|
687
|
+
if (this.options.catch) try {
|
|
688
|
+
this.fn !== void 0 && await this.fn(this, this.options.context);
|
|
689
|
+
} catch (e) {
|
|
690
|
+
if (p(this.options.catch)) try {
|
|
691
|
+
this.options.catch(e, this);
|
|
692
|
+
} catch {}
|
|
693
|
+
}
|
|
694
|
+
else this.fn !== void 0 && await this.fn(this, this.options.context);
|
|
695
|
+
} finally {
|
|
696
|
+
this._states.previousRun = new d(e, this.getTz()), this._states.blocking = !1;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
async trigger() {
|
|
700
|
+
await this._trigger();
|
|
701
|
+
}
|
|
702
|
+
runsLeft() {
|
|
703
|
+
return this._states.maxRuns;
|
|
704
|
+
}
|
|
705
|
+
_checkTrigger(e) {
|
|
706
|
+
let t = /* @__PURE__ */ new Date(), n = !this._states.paused && t.getTime() >= e.getTime(), r = this._states.blocking && this.options.protect;
|
|
707
|
+
n && !r ? (this._states.maxRuns !== void 0 && this._states.maxRuns--, this._trigger()) : n && r && p(this.options.protect) && setTimeout(() => this.options.protect(this), 0), this.schedule();
|
|
708
|
+
}
|
|
709
|
+
_next(e) {
|
|
710
|
+
let t = !!(e || this._states.currentRun), n = !1;
|
|
711
|
+
!e && this.options.startAt && this.options.interval && ([e, t] = this._calculatePreviousRun(e, t), n = !e), e = new d(e, this.getTz()), this.options.startAt && e && e.getTime() < this.options.startAt.getTime() && (e = this.options.startAt);
|
|
712
|
+
let r = this._states.once || new d(e, this.getTz());
|
|
713
|
+
return !n && r !== this._states.once && (r = r.increment(this._states.pattern, this.options, t)), this._states.once && this._states.once.getTime() <= e.getTime() || r === null || this._states.maxRuns !== void 0 && this._states.maxRuns <= 0 || this._states.kill || this.options.stopAt && r.getTime() >= this.options.stopAt.getTime() ? null : r;
|
|
714
|
+
}
|
|
715
|
+
_previous(e) {
|
|
716
|
+
let t = new d(e, this.getTz());
|
|
717
|
+
this.options.stopAt && t.getTime() > this.options.stopAt.getTime() && (t = this.options.stopAt);
|
|
718
|
+
let n = new d(t, this.getTz());
|
|
719
|
+
return this._states.once ? this._states.once.getTime() < t.getTime() ? this._states.once : null : (n = n.decrement(this._states.pattern, this.options), n === null || this.options.startAt && n.getTime() < this.options.startAt.getTime() ? null : n);
|
|
720
|
+
}
|
|
721
|
+
_calculatePreviousRun(e, t) {
|
|
722
|
+
let n = new d(void 0, this.getTz()), r = e;
|
|
723
|
+
if (this.options.startAt.getTime() <= n.getTime()) {
|
|
724
|
+
r = this.options.startAt;
|
|
725
|
+
let e = r.getTime() + this.options.interval * 1e3;
|
|
726
|
+
for (; e <= n.getTime();) r = new d(r, this.getTz()).increment(this._states.pattern, this.options, !0), e = r.getTime() + this.options.interval * 1e3;
|
|
727
|
+
t = !0;
|
|
728
|
+
}
|
|
729
|
+
return r === null && (r = void 0), [r, t];
|
|
730
|
+
}
|
|
731
|
+
}, y = 6e4, b = 60 * y, x = 24 * b, S = 4 * x, C = 366 * x, w = new TextEncoder(), T = {
|
|
732
|
+
day: x,
|
|
733
|
+
hour: b,
|
|
734
|
+
minute: y,
|
|
735
|
+
week: 7 * x
|
|
736
|
+
};
|
|
737
|
+
function E(e) {
|
|
738
|
+
if (e.length == 0) throw TypeError("At least one schedule rule is required.");
|
|
739
|
+
for (let t of e) {
|
|
740
|
+
if (t.type == "every") {
|
|
741
|
+
if (!Number.isSafeInteger(t.value) || t.value < 1) throw TypeError("Every rule value must be a positive integer.");
|
|
742
|
+
if (t.unit == "month" && t.value > 12 || t.unit != "month" && t.value * T[t.unit] > C) throw TypeError("Every rule interval must not exceed one year.");
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
if (t.expression.trim().split(/\s+/).length != 5) throw TypeError("Cron expression must have exactly five fields.");
|
|
746
|
+
try {
|
|
747
|
+
Intl.DateTimeFormat("en-US", { timeZone: t.timezone });
|
|
748
|
+
} catch {
|
|
749
|
+
throw TypeError(`Invalid IANA timezone: ${t.timezone}`);
|
|
750
|
+
}
|
|
751
|
+
let e;
|
|
752
|
+
try {
|
|
753
|
+
e = new v(t.expression, { timezone: t.timezone });
|
|
754
|
+
} catch (e) {
|
|
755
|
+
throw TypeError(`Invalid cron expression: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
756
|
+
}
|
|
757
|
+
if (e.nextRun() == null) throw TypeError("Cron expression has no future occurrence.");
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function D(e, t) {
|
|
761
|
+
let n = Infinity;
|
|
762
|
+
for (let r of e) n = Math.min(n, M(r, t));
|
|
763
|
+
if (!Number.isFinite(n)) throw Error("Schedule has no future occurrence.");
|
|
764
|
+
return n;
|
|
765
|
+
}
|
|
766
|
+
async function O(e, t, n) {
|
|
767
|
+
let r = w.encode(`${e}\0${t}\0${n}`), i = await crypto.subtle.digest("SHA-256", r);
|
|
768
|
+
return `sha256:${Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
769
|
+
}
|
|
770
|
+
var k = [{
|
|
771
|
+
type: "every",
|
|
772
|
+
unit: "hour",
|
|
773
|
+
value: 1
|
|
774
|
+
}], A = [{
|
|
775
|
+
type: "every",
|
|
776
|
+
unit: "minute",
|
|
777
|
+
value: 1
|
|
778
|
+
}], j = [
|
|
779
|
+
{
|
|
780
|
+
fixture: {
|
|
781
|
+
publishedAt: "2026-08-21T00:30:00.000Z",
|
|
782
|
+
rules: k
|
|
783
|
+
},
|
|
784
|
+
name: "admits an exact schedule grid once",
|
|
785
|
+
async verify(e) {
|
|
786
|
+
await e.tick("2026-08-21T01:00:00.000Z"), await e.tick("2026-08-21T01:00:00.000Z"), N(await e.payloads(), [{ scheduledAt: "2026-08-21T01:00:00.000Z" }], "Exact schedule payloads");
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
fixture: {
|
|
791
|
+
publishedAt: "2026-08-21T00:00:30.000Z",
|
|
792
|
+
rules: A
|
|
793
|
+
},
|
|
794
|
+
name: "coalesces missed grids and preserves the earliest due time",
|
|
795
|
+
async verify(e) {
|
|
796
|
+
await e.tick("2026-08-21T00:03:30.000Z"), N(await e.payloads(), [{ scheduledAt: "2026-08-21T00:01:00.000Z" }], "Delayed schedule payloads"), await e.tick("2026-08-21T00:04:00.000Z"), N(await e.payloads(), [{ scheduledAt: "2026-08-21T00:01:00.000Z" }, { scheduledAt: "2026-08-21T00:04:00.000Z" }], "Advanced schedule payloads");
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
fixture: {
|
|
801
|
+
publishedAt: "2026-08-21T00:00:30.000Z",
|
|
802
|
+
rules: A
|
|
803
|
+
},
|
|
804
|
+
name: "resets the schedule when its publication changes",
|
|
805
|
+
async verify(e) {
|
|
806
|
+
await e.republish("2026-08-21T00:00:45.000Z", k), await e.tick("2026-08-21T00:01:00.000Z"), N(await e.payloads(), [], "Payloads from the previous publication"), await e.tick("2026-08-21T01:00:00.000Z"), N(await e.payloads(), [{ scheduledAt: "2026-08-21T01:00:00.000Z" }], "Republished schedule payloads");
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
fixture: {
|
|
811
|
+
publishedAt: "2026-08-21T00:30:00.000Z",
|
|
812
|
+
rules: k
|
|
813
|
+
},
|
|
814
|
+
name: "stops admitting runs after retirement",
|
|
815
|
+
async verify(e) {
|
|
816
|
+
await e.retire("2026-08-21T00:45:00.000Z"), await e.tick("2026-08-21T01:00:00.000Z"), N(await e.payloads(), [], "Retired schedule payloads");
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
];
|
|
820
|
+
function M(e, t) {
|
|
821
|
+
if (e.type == "cron") return new v(e.expression, { timezone: e.timezone }).nextRun(new Date(t))?.getTime() ?? Infinity;
|
|
822
|
+
if (e.unit == "month") {
|
|
823
|
+
let n = new Date(t), r = (n.getUTCFullYear() - 1970) * 12 + n.getUTCMonth(), i = Math.floor(r / e.value) * e.value, a = Date.UTC(1970, i, 1);
|
|
824
|
+
for (; a <= t;) i += e.value, a = Date.UTC(1970, i, 1);
|
|
825
|
+
return a;
|
|
826
|
+
}
|
|
827
|
+
let n = e.value * T[e.unit], r = e.unit == "week" ? S : 0;
|
|
828
|
+
return r + (Math.floor((t - r) / n) + 1) * n;
|
|
829
|
+
}
|
|
830
|
+
function N(e, t, n) {
|
|
831
|
+
if (JSON.stringify(e) != JSON.stringify(t)) throw Error(`${n}: expected ${JSON.stringify(t)}, received ${JSON.stringify(e)}.`);
|
|
832
|
+
}
|
|
833
|
+
//#endregion
|
|
834
|
+
export { j as cronConformanceCases, D as nextTriggerScheduledAt, O as scheduledTriggerOccurrenceId, E as validateTriggerSchedule };
|