@vite-hub/schedule 0.4.1 → 0.5.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 +12 -7
- package/dist/{console-wEhr0LWn.d.ts → console-DFI1QBkP.d.ts} +2 -4
- package/dist/cron-BT3ef48f.js +68 -0
- package/dist/definition.d.ts +2 -4
- package/dist/definition.js +4 -6
- package/dist/{due-sOJvF_6Z.js → due-D-0trD1g.js} +23 -9
- package/dist/durability.d.ts +3 -5
- package/dist/durability.js +6 -7
- package/dist/{error-diagnostics-BBtYYl8j.js → error-diagnostics-B1AaIGWP.js} +2 -7
- package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
- package/dist/index.d.ts +3 -13
- package/dist/index.js +5 -8
- package/dist/{started-name-ruCM1EtQ.js → inspect-CW0qwt9p.js} +3 -9
- package/dist/{kv-storage-2kZtP2CC.js → kv-storage-Dsr3TL9c.js} +1 -2
- package/dist/{kv-storage-Bm9aYLfZ.d.ts → kv-storage-hI2IOjb5.d.ts} +0 -2
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/{operations-DqwmJ8MN.js → operations-BTUQeba1.js} +7 -11
- package/dist/operations.d.ts +2 -6
- package/dist/operations.js +11 -16
- package/dist/os.d.ts +0 -9
- package/dist/os.js +23 -104
- package/dist/out-By90R-Bo.js +22706 -0
- package/dist/rolldown-runtime-DegdyBIC.js +25 -0
- package/dist/runtime/console.d.ts +2 -4
- package/dist/runtime/console.js +3 -4
- package/dist/runtime/kv.d.ts +2 -4
- package/dist/runtime/kv.js +2 -3
- package/dist/runtime/process.d.ts +1 -3
- package/dist/runtime/process.js +28 -52
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/state.js +1 -2
- package/dist/runtime/static.d.ts +2 -73
- package/dist/runtime/static.js +3 -2
- package/dist/runtime.d.ts +5 -7
- package/dist/runtime.js +5 -5
- package/dist/{started-B0pc3JY0.js → started-B1Se_Iwo.js} +6 -8
- package/dist/{started-Bk2Icknk.js → started-Bzvr4t5f.js} +26 -9
- package/dist/{started-errors-DEmYH-vp.js → started-errors-IG9DlT2A.js} +49 -12
- package/dist/started-name-w6n9uDdt.js +4 -0
- package/dist/{state-CPd10SXq.d.ts → state-BDEDVlyr.d.ts} +3 -6
- package/dist/{state-D4SZH6zk.js → state-BZLy46UJ.js} +73 -122
- package/dist/static-Bg7Jj92L.js +603 -0
- package/dist/static-DeRvJqcQ.d.ts +92 -0
- package/dist/{store-DeMojnXM.d.ts → store-CEv3cScg.d.ts} +4 -12
- package/dist/{time-zone-SBldrUgt.js → time-zone-pMp_g8Uu.js} +1 -2
- package/dist/{types-Cw5LjPuc.d.ts → types-DTVPVY5O.d.ts} +0 -2
- package/dist/vite.d.ts +6 -20
- package/dist/vite.js +2943 -297
- package/package.json +9 -9
- package/dist/invariant-DolT9EEx.js +0 -22
- package/dist/static-7JCga3Iu.js +0 -281
- package/dist/wait-until-Dy4Bn3ZN.js +0 -112
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ export default defineSchedule({
|
|
|
104
104
|
|
|
105
105
|
Static Schedule Definitions use five-field cron expressions. The cron uses UTC unless the definition sets `timeZone` to an IANA name, such as `Europe/Madrid`. `timeZone` works with the Process Runtime and with every host's cron output.
|
|
106
106
|
|
|
107
|
-
The integration can generate host-specific output for Cloudflare Cron Triggers, Vercel Cron Jobs, Netlify Scheduled Functions, standalone `Deno.cron`, Nitro's Cloudflare schedule hook, and Netlify Scheduled Functions that run in Nitro's server bundle. A build writes only the output of its host: Nitro's resolved preset, or else `nitro.preset`, `NITRO_PRESET`, `SERVER_PRESET`, or `VITEHUB_HOST`. It writes the output of every host only when no host is known. Host selection, local execution, deployment proof, limits, and billing still come from the selected host. Check the [runtime and host support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) before deploying.
|
|
107
|
+
The integration can generate host-specific output for Cloudflare Cron Triggers, Vercel Cron Jobs, Netlify Scheduled Functions, standalone `Deno.cron`, Nitro's Cloudflare schedule hook, and Netlify Scheduled Functions that run in Nitro's server bundle. A build writes only the output of its host: Nitro's resolved preset, or else `nitro.preset`, `NITRO_PRESET`, `SERVER_PRESET`, or `VITEHUB_HOST`. It writes the output of every host only when no host is known. Host selection, local execution, deployment proof, limits, and billing still come from the selected host. Check the [runtime and host support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) before deploying. Write weekdays as standard cron numbers, 0 to 6 from Sunday. Cloudflare and Deno number weekdays 1 to 7 from Sunday, so their output writes weekday names: `0 4 * * 1-5` becomes `0 4 * * MON,TUE,WED,THU,FRI`.
|
|
108
108
|
|
|
109
109
|
Applications that use the framework distribution turn Schedule on with a file in `server/schedules/`, with no `schedule` key, and import the definition helper from `vite-hub/schedule`. On Deno, the build writes standalone cron output and a `.output/main.ts` entrypoint that loads it before the Nitro server.
|
|
110
110
|
|
|
@@ -156,7 +156,8 @@ export default defineSchedule({
|
|
|
156
156
|
cron: "0 7 * * *",
|
|
157
157
|
timeZone: "Europe/Stockholm",
|
|
158
158
|
async handler({ idempotencyKey }) {
|
|
159
|
-
await email.send({ from, to, subject: "Today's lesson", text, idempotencyKey });
|
|
159
|
+
const [error] = await email.send({ from, to, subject: "Today's lesson", text, idempotencyKey });
|
|
160
|
+
if (error) throw error;
|
|
160
161
|
},
|
|
161
162
|
});
|
|
162
163
|
```
|
|
@@ -197,9 +198,9 @@ Every server checks every Schedule. Before a server runs an occurrence, it takes
|
|
|
197
198
|
- If the server loses the Database, or its event loop pauses, for longer than `leaseTtlMs`, its lease can expire while its handler still runs. Another server can run the same occurrence at the same time. The runtime reports renewal failures, but cannot stop the handler or undo its effects. Choose a TTL longer than expected pauses and make external effects idempotent.
|
|
198
199
|
- If the lease store fails before a run starts, the server reports the error and retries at its next scan while the occurrence is inside `catchUpMs`.
|
|
199
200
|
- A failed run is final, as on one server. It is not retried.
|
|
200
|
-
- When a server stops during a run, for example after a crash, its lease ends after `leaseTtlMs`. Then another server runs the occurrence, unless it has a done marker. With shared run history, the run gets a new attempt, and the stopped attempt is marked as failed. This also works when every server restarts: at start, a server reads the runs inside `catchUpMs` that are still pending or running, and tries them again.
|
|
201
|
+
- When a server stops during a run, for example after a crash, its lease ends after `leaseTtlMs`. Then another server runs the occurrence, unless it has a done marker. A server that found the lease held tries the occurrence again until `catchUpMs` plus `leaseTtlMs` plus one minute after its scheduled minute, also with `catchUpMs: 0`. With shared run history, the run gets a new attempt, and the stopped attempt is marked as failed. This also works when every server restarts: at start, a server reads the runs inside `catchUpMs` that are still pending or running, and tries them again.
|
|
201
202
|
|
|
202
|
-
The generated runtime keeps the leases in the `vitehub_leases` table of the Default Database, through `useLeases()` from `@vite-hub/database`. That works on Postgres, remote libSQL, and D1. A local libSQL file is safe for one server process only, because `@libsql/client` can lose writes when several processes write to one file. The server prints a warning at the first lease in that case. Without a Database, the leases stay in memory and the build reports the hint `SCHEDULE_PROCESS_CLAIMS_IN_MEMORY` in its output and in `.vitehub/hints.json`: each server then runs every occurrence, so run one server only. The run history stays in KV. Use a KV store that all servers share, such as Upstash, so catch-up and the Console see the runs of every server.
|
|
203
|
+
The generated runtime keeps the leases in the `vitehub_leases` table of the Default Database, through `useLeases()` from `@vite-hub/database`. That works on Postgres, with postgres.js or node-postgres, remote libSQL, and D1. With `VITEHUB_INSTANCES` greater than 1, a Node server with a Postgres or remote libSQL Default Database reports Schedule as `shared` at boot. A local libSQL file is safe for one server process only, because `@libsql/client` can lose writes when several processes write to one file. The server prints a warning at the first lease in that case. Without a Database, the leases stay in memory and the build reports the hint `SCHEDULE_PROCESS_CLAIMS_IN_MEMORY` in its output and in `.vitehub/hints.json`: each server then runs every occurrence, so run one server only. The run history stays in KV. Use a KV store that all servers share, such as Upstash, so catch-up and the Console see the runs of every server.
|
|
203
204
|
|
|
204
205
|
With the Process Runtime, the default `providerOutput: "auto"` emits no host Provider Output, so the process owns Static Schedule wakes. Set `providerOutput: "standalone"` or `"nitro"` to move Static Schedule wakes to that Provider Output. `providerOutput: false` records the same wake ownership as `"auto"` in this configuration.
|
|
205
206
|
|
|
@@ -250,15 +251,19 @@ Custom stores must apply the `listRuns({ scheduleId, idPrefix, limit })` filters
|
|
|
250
251
|
|
|
251
252
|
## Run and inspect schedules
|
|
252
253
|
|
|
253
|
-
`hubSchedule()` contributes the `schedule.runs`, `schedule.attempts`, `schedule.run`, `schedule.list`, `schedule.start`, and `schedule.cancel` operations. They are the `vitehub schedule runs <id> [--limit <n>]`, `
|
|
254
|
+
`hubSchedule()` contributes the `schedule.runs`, `schedule.attempts`, `schedule.run`, `schedule.list`, `schedule.start`, and `schedule.cancel` operations. They are the `vitehub schedule runs list <id> [--limit <n>]`, `runs get <runId>`, `run <name>`, `list [name]`, `start <name>`, and `cancel <id>` commands, and the Console runs them too. Each command accepts `--json` and `--url`. Without `--url` the command calls the dev server of the project, whose Nitro runtime owns the same stores and registry as the running app.
|
|
254
255
|
|
|
255
256
|
Set `manual: true` on a Static Schedule Definition to allow an on-demand run, then invoke it with `vitehub schedule run <name>`. The name is the discovered schedule file name. Add `--url <app-url>` to run it on a deployment that enables `console.invoke`. The command signs the call with `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>`, so a CI job needs only that secret. `vitehub secret console-key ci` prints a new key pair. Server code can call `runSchedule(name)` from `@vite-hub/schedule`. It reads the generated registry and returns `[error, run]`. A failed handler gives a run with `status: "failed"`. An invalid `scheduledAt` or a failed run store gives `error`. An unknown name or a Definition without `manual: true` throws. Each manual run gets a new `srun_manual_` id.
|
|
256
257
|
|
|
257
|
-
Add `--at <ISO date-time>` to run it as if the cron fired at that time, for example `vitehub schedule run close-month --at 2026-01-31T23:59:00Z`. The handler gets the time as `scheduledAt`, and the run records it, so `vitehub schedule runs` lists it under that time. `runSchedule()` takes the same value as `scheduledAt`. The value needs `Z` or an offset. A value without a time zone, a date only, or a day that does not exist fails with `SCHEDULE_INVALID_SCHEDULED_AT` before the handler runs. `runSchedule()` returns it as `error`. The time is not checked against the cron. Manual runs do not advance the Process Runtime's catch-up cursor, even when their scheduled time is in the future.
|
|
258
|
+
Add `--at <ISO date-time>` to run it as if the cron fired at that time, for example `vitehub schedule run close-month --at 2026-01-31T23:59:00Z`. The handler gets the time as `scheduledAt`, and the run records it, so `vitehub schedule runs list` lists it under that time. `runSchedule()` takes the same value as `scheduledAt`. The value needs `Z` or an offset. A value without a time zone, a date only, or a day that does not exist fails with `SCHEDULE_INVALID_SCHEDULED_AT` before the handler runs. `runSchedule()` returns it as `error`. The time is not checked against the cron. Manual runs do not advance the Process Runtime's catch-up cursor, even when their scheduled time is in the future.
|
|
258
259
|
|
|
259
260
|
Discovery reads `manual` as a literal boolean from directly exported Definitions. Use identifier keys or quoted keys without escape sequences. Spreads, computed keys, escaped keys, and metadata getters or methods fail with the source file and line.
|
|
260
261
|
|
|
261
|
-
The Console Schedules section lists Schedule Definitions with their cron, time zone, and manual state. It reads them at build time. When the server runs the Process Runtime, the cron and time zone come from the loaded Definitions on each request, so they are the values that the runtime uses. `vitehub inspect definitions` reads them from the source file and shows `Not a static string` for a value that it cannot read there. Use `vitehub schedule runs <name>` to list the runs that the runtime recorded. The CLI and the Console redact credentials in error messages.
|
|
262
|
+
The Console Schedules section lists Schedule Definitions with their cron, time zone, and manual state. It reads them at build time. When the server runs the Process Runtime, the cron and time zone come from the loaded Definitions on each request, so they are the values that the runtime uses. `vitehub inspect definitions` reads them from the source file and shows `Not a static string` for a value that it cannot read there. Use `vitehub schedule runs list <name>` to list the runs that the runtime recorded. The CLI and the Console redact credentials in error messages.
|
|
263
|
+
|
|
264
|
+
## Runs in logs
|
|
265
|
+
|
|
266
|
+
With the evlog Nitro module registered, each Schedule handler run inside Nitro gets its own evlog event, `schedule: { name, source, scheduledAt, ms, outcome }`, with the error when it fails. Standalone provider wakes do not send these events. This includes Vercel and Deno cron wakes by default, and Cloudflare or Netlify when you select standalone output. Without evlog, failures go to the console and runtimes with a run store keep their run history. See [Server API](https://vitehub.dev/docs/schedule/server-api#see-schedule-runs-in-logs).
|
|
262
267
|
|
|
263
268
|
## Import runtime helpers
|
|
264
269
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../internal/src/inspect.d.ts
|
|
2
1
|
interface ViteHubDefinitionField {
|
|
3
2
|
label: string;
|
|
4
3
|
value: string;
|
|
@@ -48,6 +47,8 @@ interface ViteHubResourceSummary {
|
|
|
48
47
|
owner: string;
|
|
49
48
|
/** Absent when no id is known yet. */
|
|
50
49
|
source?: ViteHubResourceIdSource;
|
|
50
|
+
/** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
|
|
51
|
+
standalone?: boolean;
|
|
51
52
|
}
|
|
52
53
|
interface ViteHubInspectionContributor {
|
|
53
54
|
definitions?: readonly ViteHubDefinitionInspector[];
|
|
@@ -58,8 +59,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
|
|
|
58
59
|
interface ViteHubInspectionPluginMetadata {
|
|
59
60
|
inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
|
|
60
61
|
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region ../internal/src/console.d.ts
|
|
63
62
|
type MaybePromise<T> = T | Promise<T>;
|
|
64
63
|
/** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
|
|
65
64
|
interface ViteHubConsoleDefinitionCatalogView {
|
|
@@ -326,5 +325,4 @@ interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteH
|
|
|
326
325
|
*/
|
|
327
326
|
entry?: (options: TOptions) => MaybePromise<string | undefined>;
|
|
328
327
|
}
|
|
329
|
-
//#endregion
|
|
330
328
|
export { ViteHubInspectionPluginMetadata as i, ViteHubConsoleRuntimeRecordTableSection as n, ViteHubDefinitionSummary as r, ViteHubConsoleRecord as t };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineDiagnostics } from "nostics";
|
|
2
|
+
import { parseCronExpression } from "cron-schedule";
|
|
3
|
+
// ../internal/src/invariant.ts
|
|
4
|
+
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
|
+
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
6
|
+
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
7
|
+
why: ({ what }) => `ViteHub reached a state that it does not expect: ${what}`,
|
|
8
|
+
fix: "This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace."
|
|
9
|
+
} }
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* The error for a state that only a ViteHub bug can reach, such as an impossible branch. `what` says which rule broke.
|
|
13
|
+
* Use a code from the package catalog when a developer can cause the error or fix it.
|
|
14
|
+
*/
|
|
15
|
+
function invariantError(what) {
|
|
16
|
+
return invariantDiagnostics.INTERNAL_INVARIANT_FAILED({ what });
|
|
17
|
+
}
|
|
18
|
+
/** Throws `INTERNAL_INVARIANT_FAILED` when `condition` is falsy. */
|
|
19
|
+
function invariant(condition, what) {
|
|
20
|
+
if (!condition) throw invariantError(what);
|
|
21
|
+
}
|
|
22
|
+
// src/os/cron.ts
|
|
23
|
+
const allMonths = range(1, 12);
|
|
24
|
+
const allWeekdays = range(0, 6);
|
|
25
|
+
function range(first, last) {
|
|
26
|
+
return Array.from({ length: last - first + 1 }, (_, index) => first + index);
|
|
27
|
+
}
|
|
28
|
+
/** Reads a five-field cron. Returns `undefined` for anything else. */
|
|
29
|
+
function parseCronFields(cron) {
|
|
30
|
+
if (cron.trim() !== cron || cron.split(/\s+/).length !== 5) return void 0;
|
|
31
|
+
try {
|
|
32
|
+
const parsed = parseCronExpression(cron);
|
|
33
|
+
const sorted = (values) => [...new Set(values)].sort((left, right) => left - right);
|
|
34
|
+
return {
|
|
35
|
+
minutes: sorted(parsed.minutes),
|
|
36
|
+
hours: sorted(parsed.hours),
|
|
37
|
+
days: sorted(parsed.days),
|
|
38
|
+
months: sorted(parsed.months.map((month) => month + 1)),
|
|
39
|
+
weekdays: sorted(parsed.weekdays.map((weekday) => weekday % 7))
|
|
40
|
+
};
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function isDayRestricted(fields) {
|
|
46
|
+
return fields.days.length !== 31;
|
|
47
|
+
}
|
|
48
|
+
function isWeekdayRestricted(fields) {
|
|
49
|
+
return fields.weekdays.length !== allWeekdays.length;
|
|
50
|
+
}
|
|
51
|
+
function isMonthRestricted(fields) {
|
|
52
|
+
return fields.months.length !== allMonths.length;
|
|
53
|
+
}
|
|
54
|
+
/** True when every day field holds every value, so the cron runs on every day. */
|
|
55
|
+
function runsEveryDay(fields) {
|
|
56
|
+
return !isDayRestricted(fields) && !isWeekdayRestricted(fields) && !isMonthRestricted(fields);
|
|
57
|
+
}
|
|
58
|
+
/** Minutes of the day when the cron runs, sorted. */
|
|
59
|
+
function timesOfDay(fields) {
|
|
60
|
+
return fields.hours.flatMap((hour) => fields.minutes.map((minute) => hour * 60 + minute));
|
|
61
|
+
}
|
|
62
|
+
/** The step of a sorted list of two or more values with equal gaps, else `undefined`. One value has step 0. */
|
|
63
|
+
function arithmeticStep(values) {
|
|
64
|
+
if (values.length < 2) return 0;
|
|
65
|
+
const step = values[1] - values[0];
|
|
66
|
+
return values.every((value, index) => index === 0 || value - values[index - 1] === step) ? step : void 0;
|
|
67
|
+
}
|
|
68
|
+
export { parseCronFields as a, timesOfDay as c, isWeekdayRestricted as i, invariant as l, isDayRestricted as n, range as o, isMonthRestricted as r, runsEveryDay as s, arithmeticStep as t, invariantError as u };
|
package/dist/definition.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { n as ScheduleDefinition, r as ScheduleDefinitionInput } from "./types-
|
|
2
|
-
//#region src/definition.d.ts
|
|
1
|
+
import { n as ScheduleDefinition, r as ScheduleDefinitionInput } from "./types-DTVPVY5O.js";
|
|
3
2
|
export declare function defineSchedule<TResult = unknown>(input: ScheduleDefinitionInput<TResult> & {
|
|
4
3
|
cron: string;
|
|
5
4
|
}): ScheduleDefinition<TResult> & {
|
|
6
5
|
cron: string;
|
|
7
6
|
};
|
|
8
|
-
export declare function defineSchedule<TResult = unknown>(input: ScheduleDefinitionInput<TResult>): ScheduleDefinition<TResult>;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function defineSchedule<TResult = unknown>(input: ScheduleDefinitionInput<TResult>): ScheduleDefinition<TResult>;
|
package/dist/definition.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as isIanaTimeZone } from "./time-zone-
|
|
2
|
-
import { t as isRecord } from "./object-
|
|
3
|
-
import { t as scheduleErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
|
|
1
|
+
import { t as isIanaTimeZone } from "./time-zone-pMp_g8Uu.js";
|
|
2
|
+
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
3
|
+
import { t as scheduleErrorDiagnostics } from "./error-diagnostics-B1AaIGWP.js";
|
|
4
|
+
// src/definition.ts
|
|
5
5
|
const cronFieldPattern = /^[^\s]+$/;
|
|
6
6
|
const scheduleDefinitionKeys = /* @__PURE__ */ new Set([
|
|
7
7
|
"manual",
|
|
@@ -21,7 +21,6 @@ function validateCron(cron) {
|
|
|
21
21
|
const fields = cron.split(/\s+/);
|
|
22
22
|
if (fields.length !== 5 || !fields.every((field) => cronFieldPattern.test(field))) throw scheduleErrorDiagnostics.SCHEDULE_C0002({ message: "`defineSchedule()` cron must be a five-field cron expression." });
|
|
23
23
|
}
|
|
24
|
-
/** The `defineSchedule(cron, handler, options)` form was removed. Name the object form in the error. */
|
|
25
24
|
const positionalFormMessage = "`defineSchedule(cron, handler)` was removed. Pass one object: `defineSchedule({ cron: \"0 9 * * *\", handler })`, with `manual` and `timeZone` in the same object.";
|
|
26
25
|
function defineSchedule(input, ...removed) {
|
|
27
26
|
if (isCronString(input) || removed.length) throw scheduleErrorDiagnostics.SCHEDULE_C0007({ message: positionalFormMessage });
|
|
@@ -44,5 +43,4 @@ function defineSchedule(input, ...removed) {
|
|
|
44
43
|
if (input.manual !== void 0) definition.options = { manual: input.manual };
|
|
45
44
|
return definition;
|
|
46
45
|
}
|
|
47
|
-
//#endregion
|
|
48
46
|
export { defineSchedule };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as scheduleErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as scheduleErrorDiagnostics } from "./error-diagnostics-B1AaIGWP.js";
|
|
2
2
|
import { parseCronExpression } from "cron-schedule";
|
|
3
|
-
|
|
3
|
+
// src/runtime/due.ts
|
|
4
4
|
const weekdayIndexes = /* @__PURE__ */ new Map([
|
|
5
5
|
["Sun", 0],
|
|
6
6
|
["Mon", 1],
|
|
@@ -90,7 +90,6 @@ function localEpochMs(fields) {
|
|
|
90
90
|
function sameLocalMinute(left, right) {
|
|
91
91
|
return left.minute === right.minute && left.hour === right.hour && left.day === right.day && left.month === right.month && left.year === right.year;
|
|
92
92
|
}
|
|
93
|
-
/** Detect a repeated local minute using the actual offset before the transition (including historical 23-hour rollbacks). */
|
|
94
93
|
function isRepeatedFixedLocalTime(cron, fields, scheduledAt, timeZone) {
|
|
95
94
|
if (!timeZone || timeZone === "UTC" || cron.minutes.length === hourMinutes || cron.hours.length === 24) return false;
|
|
96
95
|
const previous = /* @__PURE__ */ new Date(scheduledAt.getTime() - dayMinutes * minuteMs);
|
|
@@ -99,10 +98,6 @@ function isRepeatedFixedLocalTime(cron, fields, scheduledAt, timeZone) {
|
|
|
99
98
|
if (previousOffset <= currentOffset) return false;
|
|
100
99
|
return sameLocalMinute(scheduleDateFields(new Date(scheduledAt.getTime() - (previousOffset - currentOffset)), timeZone), fields);
|
|
101
100
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Detect a local time that the clock skipped on a spring-forward day, read with the offset from before the gap, as
|
|
104
|
-
* RFC 5545 and `Temporal` do. `02:30` in a gap from `02:00` to `03:00` maps to `03:30`, so it runs once that day.
|
|
105
|
-
*/
|
|
106
101
|
function matchesSkippedLocalTime(cron, fields, scheduledAt, timeZone) {
|
|
107
102
|
if (!timeZone || timeZone === "UTC") return false;
|
|
108
103
|
const currentOffset = localEpochMs(fields) - scheduledAt.getTime();
|
|
@@ -140,5 +135,24 @@ function latestCronMinute(cron, at) {
|
|
|
140
135
|
for (let time = latest; time > latest - dayMinutes * minuteMs; time -= minuteMs) if (isScheduleDue(record, new Date(time))) return new Date(time);
|
|
141
136
|
return new Date(latest);
|
|
142
137
|
}
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
const weekdayNames = [
|
|
139
|
+
"SUN",
|
|
140
|
+
"MON",
|
|
141
|
+
"TUE",
|
|
142
|
+
"WED",
|
|
143
|
+
"THU",
|
|
144
|
+
"FRI",
|
|
145
|
+
"SAT"
|
|
146
|
+
];
|
|
147
|
+
/**
|
|
148
|
+
* Returns `cron` with its weekday field written as names, such as `0 4 * * MON,FRI`. Cloudflare and Deno number
|
|
149
|
+
* weekdays 1-7 from Sunday, so standard 0-6 numbers fire one day early or fail to deploy. Names have one meaning on
|
|
150
|
+
* every host.
|
|
151
|
+
*/
|
|
152
|
+
function cronWithWeekdayNames(cron) {
|
|
153
|
+
const fields = cron.trim().split(/\s+/);
|
|
154
|
+
if (fields.length !== 5 || fields[4] === "*") return fields.join(" ");
|
|
155
|
+
fields[4] = parseCronExpression(fields.join(" ")).weekdays.map((day) => weekdayNames[day]).join(",");
|
|
156
|
+
return fields.join(" ");
|
|
157
|
+
}
|
|
158
|
+
export { timeZoneOffsetMinutes as i, isScheduleDue as n, latestCronMinute as r, cronWithWeekdayNames as t };
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Durability, DurabilityContext } from "@vite-hub/runtime/durability";
|
|
2
|
-
//#region src/durability.d.ts
|
|
3
2
|
/** What the build passes to `scheduleDurability()`. */
|
|
4
3
|
export interface ScheduleDurabilityInput {
|
|
5
4
|
driver: "process";
|
|
@@ -7,8 +6,7 @@ export interface ScheduleDurabilityInput {
|
|
|
7
6
|
leases?: boolean;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
|
-
* The durability of schedule claims. With SQL leases in a Postgres Default Database, one instance runs
|
|
11
|
-
* occurrence. Without them, each process claims each occurrence for itself.
|
|
9
|
+
* The durability of schedule claims. With SQL leases in a Postgres or remote libSQL Default Database, one instance runs
|
|
10
|
+
* each occurrence. Without them, each process claims each occurrence for itself.
|
|
12
11
|
*/
|
|
13
|
-
export declare function scheduleDurability(input: ScheduleDurabilityInput, context: DurabilityContext): Durability[];
|
|
14
|
-
//#endregion
|
|
12
|
+
export declare function scheduleDurability(input: ScheduleDurabilityInput, context: DurabilityContext): Durability[];
|
package/dist/durability.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// src/durability.ts
|
|
2
2
|
/**
|
|
3
|
-
* The durability of schedule claims. With SQL leases in a Postgres Default Database, one instance runs
|
|
4
|
-
* occurrence. Without them, each process claims each occurrence for itself.
|
|
3
|
+
* The durability of schedule claims. With SQL leases in a Postgres or remote libSQL Default Database, one instance runs
|
|
4
|
+
* each occurrence. Without them, each process claims each occurrence for itself.
|
|
5
5
|
*/
|
|
6
6
|
function scheduleDurability(input, context) {
|
|
7
7
|
const database = input.leases ? context.find("database") : void 0;
|
|
8
|
-
if (database?.store === "postgres") return [{
|
|
8
|
+
if (database?.scope === "shared" && (database.store === "postgres" || database.store === "libsql")) return [{
|
|
9
9
|
primitive: "schedule",
|
|
10
|
-
store:
|
|
10
|
+
store: database.store,
|
|
11
11
|
scope: "shared",
|
|
12
12
|
reason: "Leases in the Default Database. One instance runs each occurrence."
|
|
13
13
|
}];
|
|
@@ -16,8 +16,7 @@ function scheduleDurability(input, context) {
|
|
|
16
16
|
store: input.driver,
|
|
17
17
|
scope: "process",
|
|
18
18
|
reason: database ? `Leases in the ${database.store} Default Database do not lock across processes. Every instance can run every occurrence.` : "This process claims each occurrence. Every instance runs every occurrence.",
|
|
19
|
-
fix: input.leases ? "Define the Default Database with `dialect: \"postgresql\"
|
|
19
|
+
fix: input.leases ? "Define the Default Database with `dialect: \"postgresql\"` or a remote libSQL URL." : "Turn on Database and define a Postgres or remote libSQL Default Database. The instances then share Schedule leases."
|
|
20
20
|
}];
|
|
21
21
|
}
|
|
22
|
-
//#endregion
|
|
23
22
|
export { scheduleDurability };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// src/error-diagnostics.ts
|
|
3
3
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
4
|
const scheduleErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
5
|
docsBase: "https://vitehub.dev/docs/schedule/diagnostics",
|
|
@@ -8,17 +8,13 @@ const scheduleErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
8
8
|
why: "Schedule run is not available. Set manual: true on the Schedule Definition and enable Console invocation.",
|
|
9
9
|
fix: "Set `manual: true` in defineSchedule() and keep `console.invoke` on (it is on in development)."
|
|
10
10
|
},
|
|
11
|
-
SCHEDULE_HISTORY_INCOMPLETE: {
|
|
12
|
-
why: ({ maxRecords, recordCount }) => `Schedule run history is incomplete because ${recordCount} records have no usable metadata index (maximum fallback is ${maxRecords}). Rebuild the schedule run index before listing history.`,
|
|
13
|
-
fix: "Rebuild the Schedule run index of the store, as the message says, before you list the history."
|
|
14
|
-
},
|
|
15
11
|
SCHEDULE_OPERATION_FAILED: {
|
|
16
12
|
why: "Schedule operation failed.",
|
|
17
13
|
fix: "Read `error.cause` for the error of the Schedule store or handler. Check that the store is reachable, then retry."
|
|
18
14
|
},
|
|
19
15
|
SCHEDULE_RUN_NOT_FOUND: {
|
|
20
16
|
why: "Schedule Run was not found.",
|
|
21
|
-
fix: "List the runs of the Schedule with `vitehub schedule runs <name>` and pass one of their ids."
|
|
17
|
+
fix: "List the runs of the Schedule with `vitehub schedule runs list <name>` and pass one of their ids."
|
|
22
18
|
},
|
|
23
19
|
SCHEDULE_C0001: {
|
|
24
20
|
...dynamicError,
|
|
@@ -166,5 +162,4 @@ const scheduleErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
166
162
|
}
|
|
167
163
|
}
|
|
168
164
|
});
|
|
169
|
-
//#endregion
|
|
170
165
|
export { scheduleErrorDiagnostics as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// ../internal/src/error-diagnostics.ts
|
|
3
3
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
4
|
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
5
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
@@ -25,7 +25,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
25
25
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
26
26
|
},
|
|
27
27
|
INTERNAL_R0022: {
|
|
28
|
-
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
|
|
28
|
+
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields, and the list_operations tool of the ViteHub MCP gives the input schema of each operation.",
|
|
29
29
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
30
30
|
},
|
|
31
31
|
INTERNAL_R0024: {
|
|
@@ -244,6 +244,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
244
244
|
why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
|
|
245
245
|
fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
|
|
246
246
|
},
|
|
247
|
+
INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT: {
|
|
248
|
+
why: ({ first, name, second }) => `[vitehub] One server function needs ${name} from two installations: ${first} and ${second}.`,
|
|
249
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`, then build again."
|
|
250
|
+
},
|
|
247
251
|
INTERNAL_SECRET_PURPOSE_MISSING: {
|
|
248
252
|
why: "[vitehub] A derived secret requires a purpose.",
|
|
249
253
|
fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
|
|
@@ -252,6 +256,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
252
256
|
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
253
257
|
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
254
258
|
},
|
|
259
|
+
INTERNAL_SITE_TOKEN_TOO_LONG: {
|
|
260
|
+
why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
|
|
261
|
+
fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
|
|
262
|
+
},
|
|
255
263
|
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
256
264
|
why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
|
|
257
265
|
fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
|
|
@@ -266,5 +274,4 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
276
|
});
|
|
269
|
-
//#endregion
|
|
270
277
|
export { internalErrorDiagnostics as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference path="./registry-module.d.ts" />
|
|
2
|
-
import { _ as StartScheduleOptions, a as ScheduleDefinitionRegistry, b as StartedScheduleStore, c as ScheduleRunAttemptRecord, d as ScheduleRunError, f as ScheduleRunListOptions, g as ScheduleRunStore, h as ScheduleRunStatus, l as ScheduleRunAttemptStatus, m as ScheduleRunResponse, n as ScheduleDefinition, o as ScheduleHandler, p as ScheduleRunRecord, r as ScheduleDefinitionInput, s as ScheduleRegistryDefinition, t as DiscoveredScheduleDefinition, u as ScheduleRunContext, v as StartScheduleTiming, y as StartedSchedule } from "./types-Cw5LjPuc.js";
|
|
3
2
|
import { defineSchedule } from "./definition.js";
|
|
4
|
-
import { i as RunScheduleOptions, t as KVScheduleStoreOptions } from "./store-
|
|
5
|
-
import { t as
|
|
3
|
+
import { i as RunScheduleOptions, t as KVScheduleStoreOptions } from "./store-CEv3cScg.js";
|
|
4
|
+
import { _ as StartScheduleOptions, a as ScheduleDefinitionRegistry, b as StartedScheduleStore, c as ScheduleRunAttemptRecord, d as ScheduleRunError, f as ScheduleRunListOptions, g as ScheduleRunStore, h as ScheduleRunStatus, l as ScheduleRunAttemptStatus, m as ScheduleRunResponse, n as ScheduleDefinition, o as ScheduleHandler, p as ScheduleRunRecord, r as ScheduleDefinitionInput, s as ScheduleRegistryDefinition, t as DiscoveredScheduleDefinition, u as ScheduleRunContext, v as StartScheduleTiming, y as StartedSchedule } from "./types-DTVPVY5O.js";
|
|
5
|
+
import { t as ScheduleKVStorage } from "./kv-storage-hI2IOjb5.js";
|
|
6
6
|
import { ErrorCatalog, Result, ViteHubError } from "@vite-hub/runtime";
|
|
7
|
-
//#region src/run-errors.d.ts
|
|
8
7
|
type RunScheduleErrorCodes = {
|
|
9
8
|
SCHEDULE_INVALID_SCHEDULED_AT: {
|
|
10
9
|
fix: string;
|
|
@@ -16,16 +15,12 @@ type RunScheduleErrorCodes = {
|
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
17
|
type RunScheduleErrorCode = keyof RunScheduleErrorCodes;
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/run.d.ts
|
|
21
18
|
/**
|
|
22
19
|
* Runs a Static Schedule Definition that sets `manual: true` now, as if its cron fired at `scheduledAt` (default: now).
|
|
23
20
|
* It returns `[error, run]`. A failed handler is a run with `status: "failed"`, not an error. An invalid `scheduledAt`
|
|
24
21
|
* or a failed run store is `error`. Definition loading errors, unknown names, and Definitions without `manual: true` throw.
|
|
25
22
|
*/
|
|
26
23
|
export declare function runSchedule(name: string, options?: RunScheduleOptions): Promise<Result<ScheduleRunRecord, RunScheduleErrorCode>>;
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/started-errors.d.ts
|
|
29
24
|
type StartedScheduleErrorCodes = {
|
|
30
25
|
SCHEDULE_INVALID_OPTIONS: {
|
|
31
26
|
fix: string;
|
|
@@ -55,8 +50,6 @@ type StartedScheduleErrorCodes = {
|
|
|
55
50
|
};
|
|
56
51
|
};
|
|
57
52
|
type StartedScheduleErrorCode = keyof StartedScheduleErrorCodes;
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/started.d.ts
|
|
60
53
|
/**
|
|
61
54
|
* Starts the Schedule Definition `name`, which declares no `cron`, at a time that code picks: once at `at`, or on each
|
|
62
55
|
* occurrence of `cron` in `timeZone` until `cancelSchedule()`. The store keeps it across restarts and deploys. The handler
|
|
@@ -71,8 +64,6 @@ export declare function listSchedules(options?: {
|
|
|
71
64
|
}): Promise<Result<StartedSchedule[], StartedScheduleErrorCode>>;
|
|
72
65
|
/** Removes a started Schedule, so it does not run again. A run that already started finishes. */
|
|
73
66
|
export declare function cancelSchedule(id: string): Promise<Result<StartedSchedule, StartedScheduleErrorCode>>;
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/errors.d.ts
|
|
76
67
|
declare const scheduleErrorCodes: readonly ["SCHEDULE_DEFINITION_NOT_FOUND", "SCHEDULE_INVALID_CRON", "SCHEDULE_INVALID_SCHEDULED_AT", "SCHEDULE_MANUAL_RUN_DISABLED", "SCHEDULE_NOT_DUE", "SCHEDULE_RUN_NOT_FOUND"];
|
|
77
68
|
declare const scheduleErrorFields: readonly ["cron", "scheduledAt"];
|
|
78
69
|
declare const scheduleErrorValueTypes: readonly ["array", "bigint", "boolean", "date", "function", "null", "number", "object", "string", "symbol", "undefined", "unknown"];
|
|
@@ -84,5 +75,4 @@ type ScheduleErrorDetails = {
|
|
|
84
75
|
field: ScheduleErrorField;
|
|
85
76
|
valueType: ScheduleErrorValueType;
|
|
86
77
|
};
|
|
87
|
-
//#endregion
|
|
88
78
|
export { type DiscoveredScheduleDefinition, type KVScheduleStoreOptions, type RunScheduleErrorCode, type RunScheduleOptions, type ScheduleDefinition, type ScheduleDefinitionInput, type ScheduleDefinitionRegistry, type ScheduleErrorCode, type ScheduleErrorDetails, type ScheduleErrorField, type ScheduleErrorValueType, type ScheduleHandler, type ScheduleKVStorage, type ScheduleRegistryDefinition, type ScheduleRunAttemptRecord, type ScheduleRunAttemptStatus, type ScheduleRunContext, type ScheduleRunError, type ScheduleRunListOptions, type ScheduleRunRecord, type ScheduleRunResponse, type ScheduleRunStatus, type ScheduleRunStore, type ScheduleValidationErrorCode, type StartScheduleOptions, type StartScheduleTiming, type StartedSchedule, type StartedScheduleErrorCode, type StartedScheduleStore, defineSchedule };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineSchedule } from "./definition.js";
|
|
2
|
-
import {
|
|
3
|
-
import { r as executeManualSchedule, s as resolveManualSchedule } from "./started-errors-
|
|
4
|
-
import { i as startSchedule, n as getSchedule, r as listSchedules, t as cancelSchedule } from "./started-
|
|
2
|
+
import { S as createScheduleError, y as parseScheduledAt } from "./static-Bg7Jj92L.js";
|
|
3
|
+
import { r as executeManualSchedule, s as resolveManualSchedule } from "./started-errors-IG9DlT2A.js";
|
|
4
|
+
import { i as startSchedule, n as getSchedule, r as listSchedules, t as cancelSchedule } from "./started-B1Se_Iwo.js";
|
|
5
5
|
import { defineErrors } from "@vite-hub/runtime";
|
|
6
|
-
|
|
6
|
+
// src/run-errors.ts
|
|
7
7
|
const runScheduleErrors = /*#__PURE__*/ defineErrors({
|
|
8
8
|
docs: "https://vitehub.dev/docs/schedule/diagnostics",
|
|
9
9
|
codes: {
|
|
@@ -17,10 +17,8 @@ const runScheduleErrors = /*#__PURE__*/ defineErrors({
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
//#region src/run.ts
|
|
20
|
+
// src/run.ts
|
|
22
21
|
const registryModule = "#vitehub/schedule/registry";
|
|
23
|
-
/** The registry that the Schedule Vite plugin generates. It loads on the first run, so importing the root stays cheap. */
|
|
24
22
|
async function loadRegistry() {
|
|
25
23
|
try {
|
|
26
24
|
return (await import(
|
|
@@ -52,5 +50,4 @@ async function runSchedule(name, options = {}) {
|
|
|
52
50
|
return [runScheduleErrors.SCHEDULE_RUN_STORE_FAILED({ cause }), void 0];
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
//#endregion
|
|
56
53
|
export { cancelSchedule, defineSchedule, getSchedule, listSchedules, runSchedule, startSchedule };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
2
2
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3
3
|
function normalizeWindowsPath(input = "") {
|
|
4
4
|
if (!input) return input;
|
|
@@ -95,8 +95,7 @@ const dirname = function(p) {
|
|
|
95
95
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
96
96
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
97
97
|
};
|
|
98
|
-
|
|
99
|
-
//#region ../internal/src/inspect.ts
|
|
98
|
+
// ../internal/src/inspect.ts
|
|
100
99
|
function relativeDefinitionFile(projectRoot, file) {
|
|
101
100
|
return relative(projectRoot, file).replaceAll("\\", "/");
|
|
102
101
|
}
|
|
@@ -114,9 +113,4 @@ const embeddedSecretAssignmentPattern = new RegExp(String.raw`\b([\w-]*(?:${secr
|
|
|
114
113
|
function redactInspectionText(value) {
|
|
115
114
|
return value.replace(embeddedUrlCredentialPattern, `$1${redactedInspectionValue}@`).replace(embeddedAuthorizationPattern, `$1${redactedInspectionValue}`).replace(embeddedCookiePattern, `$1${redactedInspectionValue}`).replace(embeddedBearerPattern, `Bearer ${redactedInspectionValue}`).replace(embeddedSecretAssignmentPattern, `$1${redactedInspectionValue}`);
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
//#region src/runtime/started-name.ts
|
|
119
|
-
/** Name of the Schedule that runs due started Schedules each minute. Discovery adds it when a Definition has no `cron`. */
|
|
120
|
-
const startedSchedulesTickName = "vitehub/started-schedules";
|
|
121
|
-
//#endregion
|
|
122
|
-
export { isAbsolute as a, dirname as i, redactInspectionText as n, relative as o, relativeDefinitionFile as r, resolve as s, startedSchedulesTickName as t };
|
|
116
|
+
export { relative as a, isAbsolute as i, relativeDefinitionFile as n, resolve as o, dirname as r, redactInspectionText as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/kv-storage.ts
|
|
2
2
|
function createScheduleKVStorage(kvStore) {
|
|
3
3
|
return {
|
|
4
4
|
async delete(key) {
|
|
@@ -26,5 +26,4 @@ function createScheduleKVStorage(kvStore) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
//#endregion
|
|
30
29
|
export { createScheduleKVStorage as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/kv-storage.d.ts
|
|
2
1
|
interface ScheduleKVStorage {
|
|
3
2
|
delete(key: string): boolean | Promise<boolean> | Promise<void> | void;
|
|
4
3
|
get<T = unknown>(key: string): Promise<T | null | undefined> | T | null | undefined;
|
|
@@ -18,5 +17,4 @@ interface ViteHubKVStorage {
|
|
|
18
17
|
set<T = unknown>(key: string, value: T): Promise<readonly [unknown, unknown]>;
|
|
19
18
|
}
|
|
20
19
|
declare function createScheduleKVStorage(kvStore: ViteHubKVStorage): ScheduleKVStorage;
|
|
21
|
-
//#endregion
|
|
22
20
|
export { createScheduleKVStorage as n, ScheduleKVStorage as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/object.ts
|
|
2
2
|
/** A non-null object that is not an array. Functions do not pass. */
|
|
3
3
|
function isRecord(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -7,5 +7,4 @@ function isRecord(value) {
|
|
|
7
7
|
function isRecordOrFunction(value) {
|
|
8
8
|
return Object(value) === value && !Array.isArray(value);
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { isRecordOrFunction as n, isRecord as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
2
1
|
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
3
2
|
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
3
|
/** The Standard properties. */
|
|
@@ -74,8 +73,6 @@ declare namespace StandardSchemaV1 {
|
|
|
74
73
|
/** Infers the output type of a Standard. */
|
|
75
74
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
75
|
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region ../internal/src/operation-definition.d.ts
|
|
79
76
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
80
77
|
type OperationKind = "read" | "write" | "destructive";
|
|
81
78
|
/** The signed-in user of a call. */
|
|
@@ -104,6 +101,11 @@ interface OperationAccess {
|
|
|
104
101
|
*/
|
|
105
102
|
readonly sections: "all" | readonly string[];
|
|
106
103
|
readonly user?: OperationUser;
|
|
104
|
+
/**
|
|
105
|
+
* Who signed the call: `"console"` when the ViteHub Console signed it for a person, whose `user` is then a Console
|
|
106
|
+
* account and not an app user, or `"cli"` for a key. Not set for other calls.
|
|
107
|
+
*/
|
|
108
|
+
readonly via?: "console" | "cli";
|
|
107
109
|
}
|
|
108
110
|
interface OperationContext {
|
|
109
111
|
/** The checked Console access of the call. */
|
|
@@ -166,7 +168,8 @@ interface OperationDefinition<Input, Output> {
|
|
|
166
168
|
/** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
|
|
167
169
|
input: StandardSchemaV1<unknown, Input>;
|
|
168
170
|
output?: StandardSchemaV1<unknown, Output>;
|
|
169
|
-
|
|
171
|
+
/** `false`: no `vitehub` command. The Console and MCP still call the operation. */
|
|
172
|
+
cli?: false | {
|
|
170
173
|
/** Defaults: namespace = section, command = verb. */
|
|
171
174
|
namespace?: string;
|
|
172
175
|
/** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
|
|
@@ -207,7 +210,7 @@ interface OperationDefinition<Input, Output> {
|
|
|
207
210
|
/** An operation of any input and output, as a registry holds it. */
|
|
208
211
|
interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
|
|
209
212
|
readOnlyWhen?: (input: never) => boolean;
|
|
210
|
-
cli?: {
|
|
213
|
+
cli?: false | {
|
|
211
214
|
namespace?: string;
|
|
212
215
|
command?: string;
|
|
213
216
|
default?: boolean;
|
|
@@ -235,5 +238,4 @@ interface OperationContributionEntry {
|
|
|
235
238
|
/** `false`: the app already has these operations at runtime. Only tools such as the CLI and `vitehub inspect` read the entry. */
|
|
236
239
|
runtime?: false;
|
|
237
240
|
}
|
|
238
|
-
//#endregion
|
|
239
241
|
export { OperationContributionEntry as n, AnyOperation as t };
|