@vite-hub/schedule 0.1.0 → 0.4.1
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/README.md +118 -100
- package/dist/console-wEhr0LWn.d.ts +330 -0
- package/dist/definition.d.ts +6 -2
- package/dist/definition.js +47 -1
- package/dist/due-sOJvF_6Z.js +144 -0
- package/dist/durability.d.ts +14 -0
- package/dist/durability.js +23 -0
- package/dist/error-diagnostics-BBtYYl8j.js +170 -0
- package/dist/error-diagnostics-CQ4BUqRe.js +270 -0
- package/dist/index.d.ts +73 -5
- package/dist/index.js +56 -2
- package/dist/invariant-DolT9EEx.js +22 -0
- package/dist/{kv-storage-DWinmLLy.js → kv-storage-2kZtP2CC.js} +4 -4
- package/dist/{kv-storage-Bv9ocZT-.d.ts → kv-storage-Bm9aYLfZ.d.ts} +7 -3
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/{operations-tNUdj3G4.d.ts → operation-definition-nmRu_O3V.d.ts} +42 -15
- package/dist/operations-DqwmJ8MN.js +207 -0
- package/dist/operations.d.ts +36 -4
- package/dist/operations.js +130 -730
- package/dist/os.d.ts +167 -0
- package/dist/os.js +1659 -0
- package/dist/runtime/console.d.ts +12 -0
- package/dist/runtime/console.js +85 -0
- package/dist/runtime/kv.d.ts +1 -1
- package/dist/runtime/kv.js +1 -1
- package/dist/runtime/process.d.ts +32 -5
- package/dist/runtime/process.js +401 -413
- package/dist/runtime/state.d.ts +2 -9
- package/dist/runtime/state.js +2 -2
- package/dist/runtime/static.d.ts +28 -2
- package/dist/runtime/static.js +2 -2
- package/dist/runtime.d.ts +34 -32
- package/dist/runtime.js +6 -5
- package/dist/started-B0pc3JY0.js +146 -0
- package/dist/started-Bk2Icknk.js +201 -0
- package/dist/{execute-BJrgNgQ0.js → started-errors-DEmYH-vp.js} +94 -38
- package/dist/{inspect-DTfAo5gS.js → started-name-ruCM1EtQ.js} +5 -1
- package/dist/state-CPd10SXq.d.ts +58 -0
- package/dist/{state-DSxmHPn3.js → state-D4SZH6zk.js} +50 -22
- package/dist/{static-6g82xguw.js → static-7JCga3Iu.js} +80 -44
- package/dist/store-DeMojnXM.d.ts +53 -0
- package/dist/time-zone-SBldrUgt.js +59 -0
- package/dist/{types-CHdV9FQU.d.ts → types-Cw5LjPuc.d.ts} +62 -8
- package/dist/vite.d.ts +255 -2
- package/dist/vite.js +6128 -2
- package/dist/{wait-until-BmIqRo4x.js → wait-until-Dy4Bn3ZN.js} +26 -1
- package/package.json +19 -24
- package/dist/definition-CMiOg1lg.js +0 -111
- package/dist/error-diagnostics-A_8Kp-48.js +0 -116
- package/dist/error-diagnostics-in7mif5s.js +0 -45
- package/dist/nuxt.d.ts +0 -17
- package/dist/nuxt.js +0 -27
- package/dist/operations-gk2qzhYV.js +0 -131
- package/dist/store-QAOd8bxm.d.ts +0 -11
- package/dist/vite-BAVyZ8hZ.d.ts +0 -474
- package/dist/vite-BJwZkMrn.js +0 -5193
|
@@ -34,6 +34,10 @@ function createScheduleError(code, options = {}) {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/runtime/date.ts
|
|
37
|
+
/** The idempotency key of one Schedule occurrence. Two runs of the same Schedule for the same time share it. */
|
|
38
|
+
function scheduleIdempotencyKey(name, scheduledAt) {
|
|
39
|
+
return `schedule:${name}:${scheduledAt.toISOString()}`;
|
|
40
|
+
}
|
|
37
41
|
function isScheduleDate(value) {
|
|
38
42
|
try {
|
|
39
43
|
return !Number.isNaN(Date.prototype.getTime.call(value));
|
|
@@ -41,11 +45,32 @@ function isScheduleDate(value) {
|
|
|
41
45
|
return false;
|
|
42
46
|
}
|
|
43
47
|
}
|
|
48
|
+
const scheduledAtText = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/i;
|
|
49
|
+
function parseScheduledAtText(value) {
|
|
50
|
+
const match = scheduledAtText.exec(value);
|
|
51
|
+
if (!match) return;
|
|
52
|
+
const [, year, month, day, hour] = match.map(Number);
|
|
53
|
+
const calendarDay = /* @__PURE__ */ new Date(0);
|
|
54
|
+
calendarDay.setUTCFullYear(year, month - 1, day);
|
|
55
|
+
if (hour > 23 || calendarDay.getUTCMonth() !== month - 1 || calendarDay.getUTCDate() !== day) return;
|
|
56
|
+
const date = new Date(value);
|
|
57
|
+
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
58
|
+
}
|
|
44
59
|
function validateScheduledAt(scheduledAt) {
|
|
45
60
|
const value = scheduledAt ?? /* @__PURE__ */ new Date();
|
|
46
61
|
if (!isScheduleDate(value)) throw createScheduleError("SCHEDULE_INVALID_SCHEDULED_AT", { details: invalidScheduleValueDetails("scheduledAt", value) });
|
|
47
62
|
return new Date(Date.prototype.getTime.call(value));
|
|
48
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the time a manual run treats as its fire time. A string must be an ISO 8601 date-time with a time zone, such
|
|
66
|
+
* as `2026-01-31T23:59:00Z`. Anything else fails with `SCHEDULE_INVALID_SCHEDULED_AT`. Absent means now.
|
|
67
|
+
*/
|
|
68
|
+
function parseScheduledAt(scheduledAt) {
|
|
69
|
+
if (typeof scheduledAt !== "string") return validateScheduledAt(scheduledAt);
|
|
70
|
+
const parsed = parseScheduledAtText(scheduledAt);
|
|
71
|
+
if (parsed) return parsed;
|
|
72
|
+
throw createScheduleError("SCHEDULE_INVALID_SCHEDULED_AT", { details: invalidScheduleValueDetails("scheduledAt", scheduledAt) });
|
|
73
|
+
}
|
|
49
74
|
//#endregion
|
|
50
75
|
//#region src/runtime/wait-until.ts
|
|
51
76
|
function createLocalWaitUntil() {
|
|
@@ -84,4 +109,4 @@ async function runWithScheduleWaitUntil(run, hostWaitUntil) {
|
|
|
84
109
|
}
|
|
85
110
|
}
|
|
86
111
|
//#endregion
|
|
87
|
-
export {
|
|
112
|
+
export { validateScheduledAt as a, scheduleIdempotencyKey as i, isScheduleDate as n, createScheduleError as o, parseScheduledAt as r, invalidScheduleValueDetails as s, runWithScheduleWaitUntil as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/schedule",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Schedule primitives and definition discovery for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"cron-jobs",
|
|
9
9
|
"netlify",
|
|
10
10
|
"nuxt",
|
|
11
|
-
"nuxt-module",
|
|
12
11
|
"schedule",
|
|
13
12
|
"typescript",
|
|
14
13
|
"vercel",
|
|
@@ -37,15 +36,15 @@
|
|
|
37
36
|
"import": "./dist/index.js",
|
|
38
37
|
"default": "./dist/index.js"
|
|
39
38
|
},
|
|
40
|
-
"./
|
|
41
|
-
"types": "./dist/
|
|
42
|
-
"import": "./dist/
|
|
43
|
-
"default": "./dist/
|
|
39
|
+
"./durability": {
|
|
40
|
+
"types": "./dist/durability.d.ts",
|
|
41
|
+
"import": "./dist/durability.js",
|
|
42
|
+
"default": "./dist/durability.js"
|
|
44
43
|
},
|
|
45
|
-
"./
|
|
46
|
-
"types": "./dist/
|
|
47
|
-
"import": "./dist/
|
|
48
|
-
"default": "./dist/
|
|
44
|
+
"./os": {
|
|
45
|
+
"types": "./dist/os.d.ts",
|
|
46
|
+
"import": "./dist/os.js",
|
|
47
|
+
"default": "./dist/os.js"
|
|
49
48
|
},
|
|
50
49
|
"./runtime": {
|
|
51
50
|
"types": "./dist/runtime.d.ts",
|
|
@@ -62,11 +61,6 @@
|
|
|
62
61
|
"import": "./dist/runtime/process.js",
|
|
63
62
|
"default": "./dist/runtime/process.js"
|
|
64
63
|
},
|
|
65
|
-
"./runtime/state": {
|
|
66
|
-
"types": "./dist/runtime/state.d.ts",
|
|
67
|
-
"import": "./dist/runtime/state.js",
|
|
68
|
-
"default": "./dist/runtime/state.js"
|
|
69
|
-
},
|
|
70
64
|
"./runtime/static": {
|
|
71
65
|
"types": "./dist/runtime/static.d.ts",
|
|
72
66
|
"import": "./dist/runtime/static.js",
|
|
@@ -80,25 +74,26 @@
|
|
|
80
74
|
"./package.json": "./package.json"
|
|
81
75
|
},
|
|
82
76
|
"dependencies": {
|
|
83
|
-
"@
|
|
77
|
+
"@valibot/to-json-schema": "^1.8.0",
|
|
78
|
+
"@vite-hub/runtime": "0.4.1",
|
|
84
79
|
"cron-schedule": "^6.0.0",
|
|
85
|
-
"
|
|
86
|
-
"esbuild": "^0.28.2",
|
|
87
|
-
"nostics": "1.3.0",
|
|
80
|
+
"nostics": "1.4.0",
|
|
88
81
|
"valibot": "^1.5.0"
|
|
89
82
|
},
|
|
90
83
|
"devDependencies": {
|
|
91
84
|
"@types/node": "^24.19.1",
|
|
92
|
-
"@vite-hub/
|
|
85
|
+
"@vite-hub/internal": "0.0.1",
|
|
86
|
+
"@vite-hub/kv": "0.4.1",
|
|
87
|
+
"esbuild": "^0.28.2",
|
|
88
|
+
"postgres": "^3.4.9",
|
|
93
89
|
"publint": "^0.3.25",
|
|
94
90
|
"typescript": "^6.0.3",
|
|
95
91
|
"vite": "^8.2.2",
|
|
96
92
|
"vite-plus": "^0.3.3",
|
|
97
|
-
"vitest": "^4.1.11"
|
|
98
|
-
"@vite-hub/internal": "0.0.1"
|
|
93
|
+
"vitest": "^4.1.11"
|
|
99
94
|
},
|
|
100
95
|
"peerDependencies": {
|
|
101
|
-
"@vite-hub/kv": "0.1
|
|
96
|
+
"@vite-hub/kv": "0.4.1",
|
|
102
97
|
"vite": ">=8.0.0"
|
|
103
98
|
},
|
|
104
99
|
"peerDependenciesMeta": {
|
|
@@ -116,6 +111,6 @@
|
|
|
116
111
|
"build": "vp pack",
|
|
117
112
|
"dev": "vp pack --watch",
|
|
118
113
|
"typecheck": "vp run --cache -t @vite-hub/schedule#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
|
|
119
|
-
"test": "vp run -t @vite-hub/schedule#build && vp test"
|
|
114
|
+
"test": "vp run --cache -t @vite-hub/schedule#build && vp test"
|
|
120
115
|
}
|
|
121
116
|
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { t as scheduleErrorDiagnostics } from "./error-diagnostics-in7mif5s.js";
|
|
2
|
-
//#region ../internal/src/runtime/time-zone.ts
|
|
3
|
-
const slashlessIanaTimeZones = /* @__PURE__ */ new Set([
|
|
4
|
-
"CET",
|
|
5
|
-
"CST6CDT",
|
|
6
|
-
"Cuba",
|
|
7
|
-
"EET",
|
|
8
|
-
"EST",
|
|
9
|
-
"EST5EDT",
|
|
10
|
-
"Egypt",
|
|
11
|
-
"Eire",
|
|
12
|
-
"Factory",
|
|
13
|
-
"GB",
|
|
14
|
-
"GB-Eire",
|
|
15
|
-
"GMT",
|
|
16
|
-
"GMT+0",
|
|
17
|
-
"GMT-0",
|
|
18
|
-
"GMT0",
|
|
19
|
-
"Greenwich",
|
|
20
|
-
"HST",
|
|
21
|
-
"Hongkong",
|
|
22
|
-
"Iceland",
|
|
23
|
-
"Iran",
|
|
24
|
-
"Israel",
|
|
25
|
-
"Jamaica",
|
|
26
|
-
"Japan",
|
|
27
|
-
"Kwajalein",
|
|
28
|
-
"Libya",
|
|
29
|
-
"MET",
|
|
30
|
-
"MST",
|
|
31
|
-
"MST7MDT",
|
|
32
|
-
"NZ",
|
|
33
|
-
"NZ-CHAT",
|
|
34
|
-
"Navajo",
|
|
35
|
-
"PRC",
|
|
36
|
-
"PST8PDT",
|
|
37
|
-
"Poland",
|
|
38
|
-
"Portugal",
|
|
39
|
-
"ROC",
|
|
40
|
-
"ROK",
|
|
41
|
-
"Singapore",
|
|
42
|
-
"Turkey",
|
|
43
|
-
"UCT",
|
|
44
|
-
"UTC",
|
|
45
|
-
"Universal",
|
|
46
|
-
"W-SU",
|
|
47
|
-
"WET",
|
|
48
|
-
"Zulu"
|
|
49
|
-
]);
|
|
50
|
-
function isIanaTimeZone(timeZone) {
|
|
51
|
-
if (typeof timeZone !== "string" || !timeZone.includes("/") && !slashlessIanaTimeZones.has(timeZone)) return false;
|
|
52
|
-
try {
|
|
53
|
-
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
54
|
-
return true;
|
|
55
|
-
} catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/definition.ts
|
|
61
|
-
const cronFieldPattern = /^[^\s]+$/;
|
|
62
|
-
const scheduleDefinitionKeys = /* @__PURE__ */ new Set([
|
|
63
|
-
"manual",
|
|
64
|
-
"cron",
|
|
65
|
-
"handler",
|
|
66
|
-
"timeZone"
|
|
67
|
-
]);
|
|
68
|
-
const scheduleOptionsKeys = /* @__PURE__ */ new Set(["manual", "timeZone"]);
|
|
69
|
-
function isPlainObject(value) {
|
|
70
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
71
|
-
}
|
|
72
|
-
function isCronString(value) {
|
|
73
|
-
return value !== null && value !== void 0 && String(value) === value;
|
|
74
|
-
}
|
|
75
|
-
function assertOwnDefinitionFields(input, keys, message, diagnostic) {
|
|
76
|
-
const inheritedKey = [...keys].find((key) => key in input && !Object.hasOwn(input, key));
|
|
77
|
-
if (inheritedKey) throw diagnostic({ message: `${message} The "${inheritedKey}" option must be an own property.` });
|
|
78
|
-
}
|
|
79
|
-
function validateCron(cron) {
|
|
80
|
-
if (typeof cron !== "string" || cron.trim() !== cron || cron.length === 0) throw scheduleErrorDiagnostics.SCHEDULE_C0001({ message: "`defineSchedule()` requires a cron string." });
|
|
81
|
-
const fields = cron.split(/\s+/);
|
|
82
|
-
if (fields.length !== 5 || !fields.every((field) => cronFieldPattern.test(field))) throw scheduleErrorDiagnostics.SCHEDULE_C0002({ message: "`defineSchedule()` cron must be a five-field cron expression." });
|
|
83
|
-
}
|
|
84
|
-
function defineSchedule(cronOrInput, handler, options = {}) {
|
|
85
|
-
if (!isPlainObject(options)) throw scheduleErrorDiagnostics.SCHEDULE_C0003({ message: "`defineSchedule()` options must be an object." });
|
|
86
|
-
assertOwnDefinitionFields(options, scheduleOptionsKeys, "`defineSchedule()` does not accept inherited options.", scheduleErrorDiagnostics.SCHEDULE_C0004);
|
|
87
|
-
if (!isCronString(cronOrInput) && !isPlainObject(cronOrInput)) throw scheduleErrorDiagnostics.SCHEDULE_C0003({ message: "`defineSchedule()` expects an object with `cron` and `handler`." });
|
|
88
|
-
const input = isPlainObject(cronOrInput) ? cronOrInput : {
|
|
89
|
-
...options,
|
|
90
|
-
cron: cronOrInput,
|
|
91
|
-
handler
|
|
92
|
-
};
|
|
93
|
-
if (!isPlainObject(input)) throw scheduleErrorDiagnostics.SCHEDULE_C0003({ message: "`defineSchedule()` expects an object with `cron` and `handler`." });
|
|
94
|
-
if (!Object.hasOwn(input, "cron") || !Object.hasOwn(input, "handler")) throw scheduleErrorDiagnostics.SCHEDULE_C0003({ message: "`defineSchedule()` expects an object with `cron` and `handler`." });
|
|
95
|
-
assertOwnDefinitionFields(input, scheduleDefinitionKeys, "`defineSchedule()` does not accept inherited options.", scheduleErrorDiagnostics.SCHEDULE_C0004);
|
|
96
|
-
const unknownKey = Object.keys(input).find((key) => !scheduleDefinitionKeys.has(key));
|
|
97
|
-
if (unknownKey) throw scheduleErrorDiagnostics.SCHEDULE_C0004({ message: `\`defineSchedule()\` does not support the "${unknownKey}" option.` });
|
|
98
|
-
validateCron(input.cron);
|
|
99
|
-
if (typeof input.handler !== "function") throw scheduleErrorDiagnostics.SCHEDULE_C0005({ message: "`defineSchedule()` requires a schedule handler." });
|
|
100
|
-
if (input.manual !== void 0 && input.manual !== true && input.manual !== false) throw scheduleErrorDiagnostics.SCHEDULE_C0006({ message: "`defineSchedule()` manual must be a boolean." });
|
|
101
|
-
if (input.timeZone !== void 0 && !isIanaTimeZone(input.timeZone)) throw scheduleErrorDiagnostics.SCHEDULE_C0006({ message: "`defineSchedule()` timeZone must be an IANA time zone, such as \"Europe/Madrid\"." });
|
|
102
|
-
const definition = {
|
|
103
|
-
cron: input.cron,
|
|
104
|
-
handler: input.handler
|
|
105
|
-
};
|
|
106
|
-
if (input.timeZone !== void 0) definition.timeZone = input.timeZone;
|
|
107
|
-
if (input.manual !== void 0) definition.options = { manual: input.manual };
|
|
108
|
-
return definition;
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
export { defineSchedule as t };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { defineDiagnostics } from "nostics";
|
|
2
|
-
//#region ../internal/src/error-diagnostics.ts
|
|
3
|
-
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
|
-
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
|
-
docsBase: () => "https://vitehub.dev/docs/reference/diagnostics",
|
|
6
|
-
codes: {
|
|
7
|
-
INTERNAL_R0012: dynamicError,
|
|
8
|
-
INTERNAL_R0013: dynamicError,
|
|
9
|
-
INTERNAL_R0014: {
|
|
10
|
-
why: ({ path }) => `Cannot read Provision State from "${path}".`,
|
|
11
|
-
fix: "Check file access and restore valid JSON while preserving existing resource IDs."
|
|
12
|
-
},
|
|
13
|
-
INTERNAL_R0020: {
|
|
14
|
-
fix: "Give the operation a name like `content.publish`, a description, a section, a kind, an input schema, and a run function.",
|
|
15
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
16
|
-
},
|
|
17
|
-
INTERNAL_R0021: {
|
|
18
|
-
fix: "Run `vitehub inspect definitions --kind operation` to list the operations of this app.",
|
|
19
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
20
|
-
},
|
|
21
|
-
INTERNAL_R0022: {
|
|
22
|
-
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
|
|
23
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
24
|
-
},
|
|
25
|
-
INTERNAL_R0024: {
|
|
26
|
-
fix: "Start the dev server with `vite dev`, or pass `--url <origin>` of a deployed app with credentials in VITEHUB_CONSOLE_AUTHORIZATION, VITEHUB_CONSOLE_COOKIE, or CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET.",
|
|
27
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
28
|
-
},
|
|
29
|
-
INTERNAL_R0023: {
|
|
30
|
-
fix: "Ask for access to the section of this operation.",
|
|
31
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
32
|
-
},
|
|
33
|
-
INTERNAL_B0001: dynamicError,
|
|
34
|
-
INTERNAL_B0002: dynamicError,
|
|
35
|
-
INTERNAL_B0003: dynamicError,
|
|
36
|
-
INTERNAL_B0004: dynamicError,
|
|
37
|
-
INTERNAL_B0005: dynamicError,
|
|
38
|
-
INTERNAL_B0006: dynamicError,
|
|
39
|
-
INTERNAL_B0007: dynamicError,
|
|
40
|
-
INTERNAL_B0008: dynamicError,
|
|
41
|
-
INTERNAL_B0009: dynamicError,
|
|
42
|
-
INTERNAL_B0010: dynamicError,
|
|
43
|
-
INTERNAL_B0011: dynamicError,
|
|
44
|
-
INTERNAL_B0012: dynamicError,
|
|
45
|
-
INTERNAL_B0013: dynamicError,
|
|
46
|
-
INTERNAL_B0014: dynamicError,
|
|
47
|
-
INTERNAL_B0015: dynamicError,
|
|
48
|
-
INTERNAL_B0016: dynamicError,
|
|
49
|
-
INTERNAL_B0017: dynamicError,
|
|
50
|
-
INTERNAL_B0018: dynamicError,
|
|
51
|
-
INTERNAL_B0019: dynamicError,
|
|
52
|
-
INTERNAL_B0020: dynamicError,
|
|
53
|
-
INTERNAL_B0021: dynamicError,
|
|
54
|
-
INTERNAL_B0022: dynamicError,
|
|
55
|
-
INTERNAL_B0023: dynamicError,
|
|
56
|
-
INTERNAL_B0024: dynamicError,
|
|
57
|
-
INTERNAL_B0025: dynamicError,
|
|
58
|
-
INTERNAL_B0026: dynamicError,
|
|
59
|
-
INTERNAL_B0027: dynamicError,
|
|
60
|
-
INTERNAL_B0028: dynamicError,
|
|
61
|
-
INTERNAL_B0029: dynamicError,
|
|
62
|
-
INTERNAL_B0030: dynamicError,
|
|
63
|
-
INTERNAL_B0031: dynamicError,
|
|
64
|
-
INTERNAL_B0032: dynamicError,
|
|
65
|
-
INTERNAL_B0033: dynamicError,
|
|
66
|
-
INTERNAL_B0034: dynamicError,
|
|
67
|
-
INTERNAL_B0035: dynamicError,
|
|
68
|
-
INTERNAL_B0036: dynamicError,
|
|
69
|
-
INTERNAL_B0037: dynamicError,
|
|
70
|
-
INTERNAL_B0038: dynamicError,
|
|
71
|
-
INTERNAL_B0039: dynamicError,
|
|
72
|
-
INTERNAL_B0040: dynamicError,
|
|
73
|
-
INTERNAL_B0041: dynamicError,
|
|
74
|
-
INTERNAL_B0042: dynamicError,
|
|
75
|
-
INTERNAL_B0043: dynamicError,
|
|
76
|
-
INTERNAL_B0044: dynamicError,
|
|
77
|
-
INTERNAL_B0045: dynamicError,
|
|
78
|
-
INTERNAL_B0046: dynamicError,
|
|
79
|
-
INTERNAL_B0047: dynamicError,
|
|
80
|
-
INTERNAL_B0048: {
|
|
81
|
-
fix: "Rename one of the two operations. A name is `<section>.<verb>` and is unique in the app.",
|
|
82
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
83
|
-
},
|
|
84
|
-
INTERNAL_B0049: {
|
|
85
|
-
fix: "Set `cli: { namespace, command }` on one of the two operations.",
|
|
86
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
87
|
-
},
|
|
88
|
-
INTERNAL_B0050: {
|
|
89
|
-
fix: "Rename one of the two operations, or set `mcp: false` on it. MCP tool names replace every character outside letters, digits, `_`, and `-` with `_`.",
|
|
90
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
91
|
-
},
|
|
92
|
-
INTERNAL_R0025: {
|
|
93
|
-
fix: "Start `vite dev` in the project that you run the command from, or pass `--url` of that server.",
|
|
94
|
-
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
95
|
-
},
|
|
96
|
-
INTERNAL_R0026: {
|
|
97
|
-
why: "The server parsed a destructive operation that the CLI did not confirm.",
|
|
98
|
-
fix: "Review the operation, then run it again with --yes to confirm the change."
|
|
99
|
-
},
|
|
100
|
-
INTERNAL_C0001: dynamicError,
|
|
101
|
-
INTERNAL_C0002: dynamicError,
|
|
102
|
-
INTERNAL_R0001: dynamicError,
|
|
103
|
-
INTERNAL_R0002: dynamicError,
|
|
104
|
-
INTERNAL_R0003: dynamicError,
|
|
105
|
-
INTERNAL_R0004: dynamicError,
|
|
106
|
-
INTERNAL_R0005: dynamicError,
|
|
107
|
-
INTERNAL_R0006: dynamicError,
|
|
108
|
-
INTERNAL_R0007: dynamicError,
|
|
109
|
-
INTERNAL_R0008: dynamicError,
|
|
110
|
-
INTERNAL_R0009: dynamicError,
|
|
111
|
-
INTERNAL_R0010: dynamicError,
|
|
112
|
-
INTERNAL_R0011: dynamicError
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
//#endregion
|
|
116
|
-
export { internalErrorDiagnostics as t };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { defineDiagnostics } from "nostics";
|
|
2
|
-
//#region src/error-diagnostics.ts
|
|
3
|
-
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
|
-
const scheduleErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
|
-
docsBase: () => "https://vitehub.dev/docs/reference/diagnostics",
|
|
6
|
-
codes: {
|
|
7
|
-
SCHEDULE_C0001: dynamicError,
|
|
8
|
-
SCHEDULE_C0002: dynamicError,
|
|
9
|
-
SCHEDULE_C0003: dynamicError,
|
|
10
|
-
SCHEDULE_C0004: dynamicError,
|
|
11
|
-
SCHEDULE_C0005: dynamicError,
|
|
12
|
-
SCHEDULE_C0006: dynamicError,
|
|
13
|
-
SCHEDULE_R0001: dynamicError,
|
|
14
|
-
SCHEDULE_R0002: dynamicError,
|
|
15
|
-
SCHEDULE_R0003: dynamicError,
|
|
16
|
-
SCHEDULE_R0004: dynamicError,
|
|
17
|
-
SCHEDULE_R0005: dynamicError,
|
|
18
|
-
SCHEDULE_R0006: dynamicError,
|
|
19
|
-
SCHEDULE_R0022: dynamicError,
|
|
20
|
-
SCHEDULE_R0023: dynamicError,
|
|
21
|
-
SCHEDULE_R0024: dynamicError,
|
|
22
|
-
SCHEDULE_R0025: dynamicError,
|
|
23
|
-
SCHEDULE_R0026: dynamicError,
|
|
24
|
-
SCHEDULE_R0027: dynamicError,
|
|
25
|
-
SCHEDULE_R0028: dynamicError,
|
|
26
|
-
SCHEDULE_R0030: dynamicError,
|
|
27
|
-
SCHEDULE_R0031: dynamicError,
|
|
28
|
-
SCHEDULE_R0032: dynamicError,
|
|
29
|
-
SCHEDULE_R0033: dynamicError,
|
|
30
|
-
SCHEDULE_R0034: dynamicError,
|
|
31
|
-
SCHEDULE_R0035: dynamicError,
|
|
32
|
-
SCHEDULE_R0036: dynamicError,
|
|
33
|
-
SCHEDULE_R0037: dynamicError,
|
|
34
|
-
SCHEDULE_R0038: dynamicError,
|
|
35
|
-
SCHEDULE_B0001: dynamicError,
|
|
36
|
-
SCHEDULE_B0002: dynamicError,
|
|
37
|
-
SCHEDULE_B0003: dynamicError,
|
|
38
|
-
SCHEDULE_B0004: dynamicError,
|
|
39
|
-
SCHEDULE_B0005: dynamicError,
|
|
40
|
-
SCHEDULE_B0006: dynamicError,
|
|
41
|
-
SCHEDULE_B0007: dynamicError
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
//#endregion
|
|
45
|
-
export { scheduleErrorDiagnostics as t };
|
package/dist/nuxt.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { i as ScheduleVitePluginOptions } from "./vite-BAVyZ8hZ.js";
|
|
2
|
-
//#region src/nuxt.d.ts
|
|
3
|
-
export interface ScheduleNuxtModuleOptions extends ScheduleVitePluginOptions {}
|
|
4
|
-
type NuxtLike = {
|
|
5
|
-
hook?: (name: "nitro:config", handler: (nitroConfig: Record<string, unknown>) => void | Promise<void>) => void;
|
|
6
|
-
options: {
|
|
7
|
-
dev?: boolean;
|
|
8
|
-
nitro?: Record<string, unknown>;
|
|
9
|
-
rootDir?: string;
|
|
10
|
-
srcDir?: string;
|
|
11
|
-
vite?: {
|
|
12
|
-
plugins?: unknown[];
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export default function viteHubScheduleNuxtModule(options?: ScheduleNuxtModuleOptions, nuxt?: NuxtLike): void;
|
|
17
|
-
//#endregion
|
package/dist/nuxt.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { n as hubSchedule, t as createScheduleNitroConfig } from "./vite-BJwZkMrn.js";
|
|
2
|
-
//#region src/nuxt.ts
|
|
3
|
-
function isScheduleVitePlugin(value) {
|
|
4
|
-
return Boolean(value && typeof value === "object" && value.name === "@vite-hub/schedule/vite");
|
|
5
|
-
}
|
|
6
|
-
function viteHubScheduleNuxtModule(options = {}, nuxt) {
|
|
7
|
-
if (!nuxt) return;
|
|
8
|
-
nuxt.options.vite ??= {};
|
|
9
|
-
const plugins = Array.isArray(nuxt.options.vite.plugins) ? nuxt.options.vite.plugins : [];
|
|
10
|
-
if (!plugins.some(isScheduleVitePlugin)) plugins.push(hubSchedule(options));
|
|
11
|
-
nuxt.options.vite.plugins = plugins;
|
|
12
|
-
nuxt.hook?.("nitro:config", async (nitroConfig) => {
|
|
13
|
-
const rootDir = nuxt.options.rootDir || process.cwd();
|
|
14
|
-
const nitro = await createScheduleNitroConfig({
|
|
15
|
-
...options,
|
|
16
|
-
command: nuxt.options.dev ? "serve" : "build",
|
|
17
|
-
nitroOwnsPaths: true,
|
|
18
|
-
nitro: nitroConfig,
|
|
19
|
-
plugins: nuxt.options.vite?.plugins,
|
|
20
|
-
projectRoot: options.projectRoot || rootDir,
|
|
21
|
-
root: nuxt.options.srcDir || rootDir
|
|
22
|
-
});
|
|
23
|
-
if (nitro) Object.assign(nitroConfig, nitro);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { viteHubScheduleNuxtModule as default };
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { t as redactInspectionText } from "./inspect-DTfAo5gS.js";
|
|
2
|
-
import { i as runSchedule } from "./execute-BJrgNgQ0.js";
|
|
3
|
-
import { t as getScheduleRunStore } from "./state-DSxmHPn3.js";
|
|
4
|
-
//#region src/runtime/operations.ts
|
|
5
|
-
function isoDate(value) {
|
|
6
|
-
if (value === void 0) return;
|
|
7
|
-
const date = value instanceof Date ? value : new Date(value);
|
|
8
|
-
return Number.isNaN(date.getTime()) ? String(value) : date.toISOString();
|
|
9
|
-
}
|
|
10
|
-
function summarizeError(error) {
|
|
11
|
-
if (!error) return;
|
|
12
|
-
const summary = { message: redactInspectionText(error.message) };
|
|
13
|
-
if (error.name) summary.name = redactInspectionText(error.name);
|
|
14
|
-
return summary;
|
|
15
|
-
}
|
|
16
|
-
function summarizeScheduleRun(run) {
|
|
17
|
-
const error = summarizeError(run.error);
|
|
18
|
-
const completedAt = isoDate(run.completedAt);
|
|
19
|
-
const startedAt = isoDate(run.startedAt);
|
|
20
|
-
const summary = {
|
|
21
|
-
attemptCount: run.attemptCount,
|
|
22
|
-
id: run.id,
|
|
23
|
-
scheduleId: run.scheduleId,
|
|
24
|
-
scheduledAt: isoDate(run.scheduledAt) ?? "",
|
|
25
|
-
status: run.status,
|
|
26
|
-
target: run.target
|
|
27
|
-
};
|
|
28
|
-
if (completedAt) summary.completedAt = completedAt;
|
|
29
|
-
if (error) summary.error = error;
|
|
30
|
-
if (run.response) summary.response = {
|
|
31
|
-
status: run.response.status,
|
|
32
|
-
statusText: redactInspectionText(run.response.statusText)
|
|
33
|
-
};
|
|
34
|
-
if (startedAt) summary.startedAt = startedAt;
|
|
35
|
-
return summary;
|
|
36
|
-
}
|
|
37
|
-
function summarizeManualScheduleRun(run) {
|
|
38
|
-
const error = summarizeError(run.error);
|
|
39
|
-
const completedAt = isoDate(run.completedAt);
|
|
40
|
-
const startedAt = isoDate(run.startedAt);
|
|
41
|
-
return {
|
|
42
|
-
...completedAt ? { completedAt } : {},
|
|
43
|
-
...error ? { error } : {},
|
|
44
|
-
id: run.id,
|
|
45
|
-
scheduleId: run.scheduleId,
|
|
46
|
-
...startedAt ? { startedAt } : {},
|
|
47
|
-
status: run.status
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function summarizeScheduleRunAttempt(attempt) {
|
|
51
|
-
const error = summarizeError(attempt.error);
|
|
52
|
-
const completedAt = isoDate(attempt.completedAt);
|
|
53
|
-
return {
|
|
54
|
-
...completedAt ? { completedAt } : {},
|
|
55
|
-
...error ? { error } : {},
|
|
56
|
-
id: attempt.id,
|
|
57
|
-
runId: attempt.runId,
|
|
58
|
-
startedAt: isoDate(attempt.startedAt) ?? "",
|
|
59
|
-
status: attempt.status
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function newestFirst(left, right) {
|
|
63
|
-
return new Date(right.scheduledAt).getTime() - new Date(left.scheduledAt).getTime();
|
|
64
|
-
}
|
|
65
|
-
/** Lists the recorded runs of one Schedule Definition, newest first. */
|
|
66
|
-
async function listScheduleRuns(scheduleId, options = {}) {
|
|
67
|
-
const runs = (await getScheduleRunStore().listRuns({
|
|
68
|
-
scheduleId,
|
|
69
|
-
limit: options.limit
|
|
70
|
-
})).filter((run) => run.scheduleId === scheduleId).sort(newestFirst);
|
|
71
|
-
return (options.limit === void 0 ? runs : runs.slice(0, options.limit)).map(summarizeScheduleRun);
|
|
72
|
-
}
|
|
73
|
-
/** Lists the attempts of one Schedule Run, oldest first. */
|
|
74
|
-
async function listScheduleRunAttempts(runId) {
|
|
75
|
-
return [...await getScheduleRunStore().listAttempts(runId)].sort((left, right) => new Date(left.startedAt).getTime() - new Date(right.startedAt).getTime()).map(summarizeScheduleRunAttempt);
|
|
76
|
-
}
|
|
77
|
-
/** Raised for the failures of a Schedule operation. `status` and `code` reach every surface. */
|
|
78
|
-
var ScheduleOperationError = class extends Error {
|
|
79
|
-
code;
|
|
80
|
-
fix;
|
|
81
|
-
status;
|
|
82
|
-
constructor(status, code, message, fix) {
|
|
83
|
-
super(message);
|
|
84
|
-
this.code = code;
|
|
85
|
-
this.status = status;
|
|
86
|
-
if (fix) this.fix = fix;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const errorStatus = {
|
|
90
|
-
SCHEDULE_DEFINITION_NOT_FOUND: 404,
|
|
91
|
-
SCHEDULE_HISTORY_INCOMPLETE: 503,
|
|
92
|
-
SCHEDULE_MANUAL_RUN_DISABLED: 403,
|
|
93
|
-
SCHEDULE_RUN_NOT_FOUND: 404
|
|
94
|
-
};
|
|
95
|
-
/** Gives a Schedule error the status and the redacted message that every surface reports. */
|
|
96
|
-
async function attempt(work) {
|
|
97
|
-
try {
|
|
98
|
-
return await work();
|
|
99
|
-
} catch (error) {
|
|
100
|
-
if (error instanceof ScheduleOperationError) throw error;
|
|
101
|
-
const code = Reflect.get(Object(error), "code");
|
|
102
|
-
const status = String(code) === code ? errorStatus[code] : void 0;
|
|
103
|
-
if (status && error instanceof Error) throw new ScheduleOperationError(status, String(code), redactInspectionText(error.message));
|
|
104
|
-
throw new ScheduleOperationError(500, "OPERATION_FAILED", "Schedule operation failed.");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function runScheduleRuns(input) {
|
|
108
|
-
return await attempt(async () => ({ runs: await listScheduleRuns(input.id, { limit: input.limit ?? 100 }) }));
|
|
109
|
-
}
|
|
110
|
-
async function runScheduleAttempts(input) {
|
|
111
|
-
return await attempt(async () => {
|
|
112
|
-
const run = await getScheduleRunStore().getRun(input.id);
|
|
113
|
-
if (!run) throw new ScheduleOperationError(404, "SCHEDULE_RUN_NOT_FOUND", "Schedule Run was not found.", "List the runs of the Schedule with `vitehub schedule runs <name>` and pass one of their ids.");
|
|
114
|
-
return {
|
|
115
|
-
attempts: await listScheduleRunAttempts(input.id),
|
|
116
|
-
run: summarizeScheduleRun(run)
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
/** The manual Static Schedule Definitions that the Console installed. Only `console.invoke` installs them. */
|
|
121
|
-
const consoleSchedulesKey = Symbol.for("vitehub.console.schedules");
|
|
122
|
-
/**
|
|
123
|
-
* Runs a Static Schedule Definition that sets `manual: true`. The registry holds only those definitions, and it is empty
|
|
124
|
-
* unless Console invocation is enabled, so anything else is "not available".
|
|
125
|
-
*/
|
|
126
|
-
async function runScheduleNow(input, registry = Reflect.get(globalThis, consoleSchedulesKey) ?? {}) {
|
|
127
|
-
if (!Object.hasOwn(registry, input.name)) throw new ScheduleOperationError(404, "SCHEDULE_DEFINITION_NOT_FOUND", "Schedule run is not available. Set manual: true on the Schedule Definition and enable Console invocation.", "Set `manual: true` in defineSchedule() and keep `console.invoke` on (it is on in development).");
|
|
128
|
-
return await attempt(async () => ({ run: summarizeManualScheduleRun(await runSchedule(input.name, { registry })) }));
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
export { listScheduleRunAttempts, listScheduleRuns, runScheduleAttempts, runScheduleNow, runScheduleRuns, summarizeScheduleRun, summarizeScheduleRunAttempt };
|
package/dist/store-QAOd8bxm.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { g as ScheduleRunStore } from "./types-CHdV9FQU.js";
|
|
2
|
-
import { t as ScheduleKVStorage } from "./kv-storage-Bv9ocZT-.js";
|
|
3
|
-
//#region src/runtime/store.d.ts
|
|
4
|
-
interface KVScheduleStoreOptions {
|
|
5
|
-
kvStore: ScheduleKVStorage;
|
|
6
|
-
prefix?: string;
|
|
7
|
-
}
|
|
8
|
-
declare function createMemoryScheduleRunStore(): ScheduleRunStore;
|
|
9
|
-
declare function createKVScheduleRunStore(options: KVScheduleStoreOptions): ScheduleRunStore;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { createKVScheduleRunStore as n, createMemoryScheduleRunStore as r, KVScheduleStoreOptions as t };
|