@vite-hub/schedule 0.0.4 → 0.1.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.
Files changed (49) hide show
  1. package/README.md +68 -5
  2. package/dist/definition-CMiOg1lg.js +111 -0
  3. package/dist/definition.d.ts +4 -6
  4. package/dist/definition.js +2 -42
  5. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  6. package/dist/error-diagnostics-in7mif5s.js +45 -0
  7. package/dist/execute-BJrgNgQ0.js +201 -0
  8. package/dist/index.d.ts +7 -40
  9. package/dist/index.js +2 -7
  10. package/dist/inspect-DTfAo5gS.js +118 -0
  11. package/dist/kv-storage-Bv9ocZT-.d.ts +18 -0
  12. package/dist/nuxt.d.ts +4 -6
  13. package/dist/nuxt.js +2 -1
  14. package/dist/operations-gk2qzhYV.js +131 -0
  15. package/dist/operations-tNUdj3G4.d.ts +212 -0
  16. package/dist/operations.d.ts +61 -0
  17. package/dist/operations.js +921 -0
  18. package/dist/registry-module.d.ts +0 -5
  19. package/dist/runtime/kv.d.ts +4 -0
  20. package/dist/{kv-BJ1I9IlJ.js → runtime/kv.js} +1 -1
  21. package/dist/runtime/process.d.ts +26 -5
  22. package/dist/runtime/process.js +337 -75
  23. package/dist/runtime/state.d.ts +8 -12
  24. package/dist/runtime/state.js +2 -2
  25. package/dist/runtime/static.d.ts +18 -12
  26. package/dist/runtime/static.js +2 -150
  27. package/dist/runtime.d.ts +36 -4
  28. package/dist/runtime.js +5 -3
  29. package/dist/state-DSxmHPn3.js +448 -0
  30. package/dist/static-6g82xguw.js +245 -0
  31. package/dist/store-QAOd8bxm.d.ts +11 -0
  32. package/dist/types-CHdV9FQU.d.ts +113 -0
  33. package/dist/vite-BAVyZ8hZ.d.ts +474 -0
  34. package/dist/{vite-BHs17nWX.js → vite-BJwZkMrn.js} +1366 -339
  35. package/dist/vite.d.ts +2 -52
  36. package/dist/vite.js +2 -3
  37. package/dist/wait-until-BmIqRo4x.js +87 -0
  38. package/package.json +67 -21
  39. package/dist/client-DpCD4YFE.js +0 -233
  40. package/dist/discovery-DkFAN7Wd.d.ts +0 -15
  41. package/dist/discovery-DvU3B6iD.js +0 -753
  42. package/dist/due-Bbh4yIxq.js +0 -59
  43. package/dist/execute-B-pii4wf.js +0 -211
  44. package/dist/runtime/driver.d.ts +0 -26
  45. package/dist/runtime/driver.js +0 -337
  46. package/dist/state-By7WU_ks.js +0 -472
  47. package/dist/store-t-74rsM_.d.ts +0 -48
  48. package/dist/types-Bcje4dLV.d.ts +0 -136
  49. package/dist/wait-until-BzIwzXw4.js +0 -23
package/dist/vite.d.ts CHANGED
@@ -1,52 +1,2 @@
1
- import { t as DiscoveredScheduleDefinition } from "./types-Bcje4dLV.js";
2
- import { t as discoverScheduleDefinitions } from "./discovery-DkFAN7Wd.js";
3
-
4
- //#region src/vite.d.ts
5
- declare function readScheduleDefinitionCrons(definitions: DiscoveredScheduleDefinition[]): Promise<Map<string, string>>;
6
- interface ScheduleProcessRuntimeOptions {
7
- concurrency?: number;
8
- driver: "process";
9
- intervalMs?: number;
10
- prefix?: string;
11
- }
12
- interface ScheduleVitePluginOptions {
13
- providerOutput?: "auto" | "standalone" | "nitro" | false;
14
- projectRoot?: string;
15
- runtime?: ScheduleProcessRuntimeOptions;
16
- }
17
- interface ScheduleNitroConfigOptions extends ScheduleVitePluginOptions {
18
- command?: "build" | "serve";
19
- /** @internal Resolve generated Nitro registrations from the ViteHub project root. */
20
- nitroOwnsPaths?: boolean;
21
- nitro?: unknown;
22
- root?: string;
23
- /** @internal Framework-resolved server definition directories. */
24
- serverDirs?: string[];
25
- }
26
- interface ScheduleVitePlugin {
27
- name: string;
28
- [hook: string]: unknown;
29
- }
30
- type NitroConfig = Record<string, unknown> & {
31
- cloudflare?: {
32
- wrangler?: {
33
- triggers?: {
34
- crons?: string[];
35
- } & Record<string, unknown>;
36
- } & Record<string, unknown>;
37
- } & Record<string, unknown>;
38
- modules?: unknown[];
39
- plugins?: unknown[];
40
- vercel?: {
41
- config?: {
42
- crons?: Array<{
43
- path: string;
44
- schedule: string;
45
- }>;
46
- } & Record<string, unknown>;
47
- } & Record<string, unknown>;
48
- };
49
- declare function createScheduleNitroConfig(options?: ScheduleNitroConfigOptions): Promise<NitroConfig | null>;
50
- declare function hubSchedule(options?: ScheduleVitePluginOptions): ScheduleVitePlugin;
51
- //#endregion
52
- export { ScheduleNitroConfigOptions, ScheduleProcessRuntimeOptions, ScheduleVitePlugin, ScheduleVitePluginOptions, createScheduleNitroConfig, discoverScheduleDefinitions, hubSchedule, readScheduleDefinitionCrons };
1
+ import { _ as ScheduleContributionContext, a as createScheduleNitroConfig, c as ScheduleInspectionOptions, d as ScheduleDiscoveryOptions, f as contributedScheduleSource, g as ScheduleContribution, h as ScheduleContributingPlugin, i as ScheduleVitePluginOptions, l as inspectScheduleDefinitions, m as CollectedScheduleContribution, n as ScheduleProcessRuntimeOptions, o as hubSchedule, p as discoverScheduleDefinitions, r as ScheduleVitePlugin, s as readScheduleDefinitionCrons, t as ScheduleNitroConfigOptions, u as scheduleConsoleSection, v as ScheduleContributionFactory, y as collectScheduleContributions } from "./vite-BAVyZ8hZ.js";
2
+ export { type CollectedScheduleContribution, type ScheduleContributingPlugin, type ScheduleContribution, type ScheduleContributionContext, type ScheduleContributionFactory, type ScheduleDiscoveryOptions, type ScheduleInspectionOptions, ScheduleNitroConfigOptions, ScheduleProcessRuntimeOptions, ScheduleVitePlugin, ScheduleVitePluginOptions, collectScheduleContributions, contributedScheduleSource, createScheduleNitroConfig, discoverScheduleDefinitions, hubSchedule, inspectScheduleDefinitions, readScheduleDefinitionCrons, scheduleConsoleSection };
package/dist/vite.js CHANGED
@@ -1,3 +1,2 @@
1
- import { t as discoverScheduleDefinitions } from "./discovery-DvU3B6iD.js";
2
- import { n as hubSchedule, r as readScheduleDefinitionCrons, t as createScheduleNitroConfig } from "./vite-BHs17nWX.js";
3
- export { createScheduleNitroConfig, discoverScheduleDefinitions, hubSchedule, readScheduleDefinitionCrons };
1
+ import { a as scheduleConsoleSection, c as collectScheduleContributions, i as inspectScheduleDefinitions, n as hubSchedule, o as contributedScheduleSource, r as readScheduleDefinitionCrons, s as discoverScheduleDefinitions, t as createScheduleNitroConfig } from "./vite-BJwZkMrn.js";
2
+ export { collectScheduleContributions, contributedScheduleSource, createScheduleNitroConfig, discoverScheduleDefinitions, hubSchedule, inspectScheduleDefinitions, readScheduleDefinitionCrons, scheduleConsoleSection };
@@ -0,0 +1,87 @@
1
+ import { ViteHubError } from "@vite-hub/runtime";
2
+ //#region src/errors.ts
3
+ const scheduleErrorMessages = {
4
+ SCHEDULE_DEFINITION_NOT_FOUND: "Static Schedule Definition was not found.",
5
+ SCHEDULE_INVALID_CRON: "Schedule cron is invalid.",
6
+ SCHEDULE_INVALID_SCHEDULED_AT: "Schedule scheduledAt value is invalid.",
7
+ SCHEDULE_MANUAL_RUN_DISABLED: "Schedule Definition does not allow manual runs. Set manual: true to allow them.",
8
+ SCHEDULE_NOT_DUE: "Schedule is not due.",
9
+ SCHEDULE_RUN_NOT_FOUND: "Schedule Run was not found."
10
+ };
11
+ function isDateValue(value) {
12
+ if (value instanceof Date) return true;
13
+ try {
14
+ Date.prototype.getTime.call(value);
15
+ return true;
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ function invalidScheduleValueDetails(field, value) {
21
+ let valueType;
22
+ try {
23
+ valueType = value === null ? "null" : Array.isArray(value) ? "array" : isDateValue(value) ? "date" : typeof value;
24
+ } catch {
25
+ valueType = "unknown";
26
+ }
27
+ return {
28
+ field,
29
+ valueType
30
+ };
31
+ }
32
+ function createScheduleError(code, options = {}) {
33
+ return new ViteHubError(code, scheduleErrorMessages[code], options);
34
+ }
35
+ //#endregion
36
+ //#region src/runtime/date.ts
37
+ function isScheduleDate(value) {
38
+ try {
39
+ return !Number.isNaN(Date.prototype.getTime.call(value));
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+ function validateScheduledAt(scheduledAt) {
45
+ const value = scheduledAt ?? /* @__PURE__ */ new Date();
46
+ if (!isScheduleDate(value)) throw createScheduleError("SCHEDULE_INVALID_SCHEDULED_AT", { details: invalidScheduleValueDetails("scheduledAt", value) });
47
+ return new Date(Date.prototype.getTime.call(value));
48
+ }
49
+ //#endregion
50
+ //#region src/runtime/wait-until.ts
51
+ function createLocalWaitUntil() {
52
+ const pending = /* @__PURE__ */ new Set();
53
+ let error;
54
+ let failed = false;
55
+ return {
56
+ async flush() {
57
+ while (pending.size > 0) await Promise.allSettled(pending);
58
+ if (failed) throw error;
59
+ },
60
+ waitUntil(value) {
61
+ const promise = Promise.resolve(value);
62
+ pending.add(promise);
63
+ promise.then(() => pending.delete(promise), (reason) => {
64
+ pending.delete(promise);
65
+ if (!failed) error = reason;
66
+ failed = true;
67
+ });
68
+ }
69
+ };
70
+ }
71
+ /** Complete local deferred work while preserving a handler's failure over a deferred failure. */
72
+ async function runWithScheduleWaitUntil(run, hostWaitUntil) {
73
+ if (hostWaitUntil) return await run(hostWaitUntil);
74
+ const local = createLocalWaitUntil();
75
+ try {
76
+ const result = await run(local.waitUntil);
77
+ await local.flush();
78
+ return result;
79
+ } catch (error) {
80
+ try {
81
+ await local.flush();
82
+ } catch {}
83
+ throw error;
84
+ }
85
+ }
86
+ //#endregion
87
+ export { invalidScheduleValueDetails as a, createScheduleError as i, isScheduleDate as n, validateScheduledAt as r, runWithScheduleWaitUntil as t };
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@vite-hub/schedule",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "description": "Schedule primitives and definition discovery for ViteHub.",
5
5
  "keywords": [
6
+ "cloudflare",
6
7
  "cron",
8
+ "cron-jobs",
9
+ "netlify",
10
+ "nuxt",
11
+ "nuxt-module",
7
12
  "schedule",
13
+ "typescript",
14
+ "vercel",
8
15
  "vite",
9
16
  "vitehub"
10
17
  ],
11
- "homepage": "https://github.com/vite-hub/vitehub#readme",
18
+ "homepage": "https://vitehub.dev",
12
19
  "bugs": "https://github.com/vite-hub/vitehub/issues",
13
20
  "license": "Apache-2.0",
14
21
  "author": "onmax <maximogarciamtnez@gmail.com>",
@@ -25,34 +32,73 @@
25
32
  "sideEffects": false,
26
33
  "types": "./dist/index.d.ts",
27
34
  "exports": {
28
- ".": "./dist/index.js",
29
- "./nuxt": "./dist/nuxt.js",
30
- "./runtime": "./dist/runtime.js",
31
- "./runtime/driver": "./dist/runtime/driver.js",
32
- "./runtime/process": "./dist/runtime/process.js",
33
- "./runtime/state": "./dist/runtime/state.js",
34
- "./runtime/static": "./dist/runtime/static.js",
35
- "./vite": "./dist/vite.js",
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "default": "./dist/index.js"
39
+ },
40
+ "./nuxt": {
41
+ "types": "./dist/nuxt.d.ts",
42
+ "import": "./dist/nuxt.js",
43
+ "default": "./dist/nuxt.js"
44
+ },
45
+ "./operations": {
46
+ "types": "./dist/operations.d.ts",
47
+ "import": "./dist/operations.js",
48
+ "default": "./dist/operations.js"
49
+ },
50
+ "./runtime": {
51
+ "types": "./dist/runtime.d.ts",
52
+ "import": "./dist/runtime.js",
53
+ "default": "./dist/runtime.js"
54
+ },
55
+ "./runtime/kv": {
56
+ "types": "./dist/runtime/kv.d.ts",
57
+ "import": "./dist/runtime/kv.js",
58
+ "default": "./dist/runtime/kv.js"
59
+ },
60
+ "./runtime/process": {
61
+ "types": "./dist/runtime/process.d.ts",
62
+ "import": "./dist/runtime/process.js",
63
+ "default": "./dist/runtime/process.js"
64
+ },
65
+ "./runtime/state": {
66
+ "types": "./dist/runtime/state.d.ts",
67
+ "import": "./dist/runtime/state.js",
68
+ "default": "./dist/runtime/state.js"
69
+ },
70
+ "./runtime/static": {
71
+ "types": "./dist/runtime/static.d.ts",
72
+ "import": "./dist/runtime/static.js",
73
+ "default": "./dist/runtime/static.js"
74
+ },
75
+ "./vite": {
76
+ "types": "./dist/vite.d.ts",
77
+ "import": "./dist/vite.js",
78
+ "default": "./dist/vite.js"
79
+ },
36
80
  "./package.json": "./package.json"
37
81
  },
38
82
  "dependencies": {
39
- "@vite-hub/runtime": "0.0.4",
83
+ "@vite-hub/runtime": "0.1.0",
40
84
  "cron-schedule": "^6.0.0",
41
- "effect": "4.0.0-beta.99",
42
- "esbuild": "^0.28.1"
85
+ "effect": "4.0.0-rc.112",
86
+ "esbuild": "^0.28.2",
87
+ "nostics": "1.3.0",
88
+ "valibot": "^1.5.0"
43
89
  },
44
90
  "devDependencies": {
45
- "@types/node": "^24.13.3",
46
- "@vite-hub/kv": "0.0.4",
47
- "publint": "^0.3.21",
91
+ "@types/node": "^24.19.1",
92
+ "@vite-hub/kv": "0.1.0",
93
+ "publint": "^0.3.25",
48
94
  "typescript": "^6.0.3",
49
- "vite": "^8.0.8",
50
- "vite-plus": "^0.1.24",
51
- "vitest": "^4.1.4",
95
+ "vite": "^8.2.2",
96
+ "vite-plus": "^0.3.3",
97
+ "vitest": "^4.1.11",
52
98
  "@vite-hub/internal": "0.0.1"
53
99
  },
54
100
  "peerDependencies": {
55
- "@vite-hub/kv": "0.0.4",
101
+ "@vite-hub/kv": "0.1.0",
56
102
  "vite": ">=8.0.0"
57
103
  },
58
104
  "peerDependenciesMeta": {
@@ -69,7 +115,7 @@
69
115
  "scripts": {
70
116
  "build": "vp pack",
71
117
  "dev": "vp pack --watch",
72
- "typecheck": "tsc --noEmit -p ./tsconfig.json",
118
+ "typecheck": "vp run --cache -t @vite-hub/schedule#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
73
119
  "test": "vp run -t @vite-hub/schedule#build && vp test"
74
120
  }
75
121
  }
@@ -1,233 +0,0 @@
1
- import { n as executeRuntimeSchedule, o as randomId } from "./execute-B-pii4wf.js";
2
- import { h as invalidScheduleValueDetails, i as loadScheduleDefinition, m as createScheduleError, n as getScheduleRunStore, p as assertRuntimeScheduleId, t as getRuntimeScheduleStore } from "./state-By7WU_ks.js";
3
- //#region ../internal/src/runtime/time-zone.ts
4
- const slashlessIanaTimeZones = new Set([
5
- "CET",
6
- "CST6CDT",
7
- "Cuba",
8
- "EET",
9
- "EST",
10
- "EST5EDT",
11
- "Egypt",
12
- "Eire",
13
- "Factory",
14
- "GB",
15
- "GB-Eire",
16
- "GMT",
17
- "GMT+0",
18
- "GMT-0",
19
- "GMT0",
20
- "Greenwich",
21
- "HST",
22
- "Hongkong",
23
- "Iceland",
24
- "Iran",
25
- "Israel",
26
- "Jamaica",
27
- "Japan",
28
- "Kwajalein",
29
- "Libya",
30
- "MET",
31
- "MST",
32
- "MST7MDT",
33
- "NZ",
34
- "NZ-CHAT",
35
- "Navajo",
36
- "PRC",
37
- "PST8PDT",
38
- "Poland",
39
- "Portugal",
40
- "ROC",
41
- "ROK",
42
- "Singapore",
43
- "Turkey",
44
- "UCT",
45
- "UTC",
46
- "Universal",
47
- "W-SU",
48
- "WET",
49
- "Zulu"
50
- ]);
51
- function isIanaTimeZone(timeZone) {
52
- if (typeof timeZone !== "string" || !timeZone.includes("/") && !slashlessIanaTimeZones.has(timeZone)) return false;
53
- try {
54
- new Intl.DateTimeFormat("en-US", { timeZone });
55
- return true;
56
- } catch {
57
- return false;
58
- }
59
- }
60
- //#endregion
61
- //#region src/runtime/client.ts
62
- const cronRange = {
63
- dayOfMonth: {
64
- max: 31,
65
- min: 1
66
- },
67
- dayOfWeek: {
68
- max: 7,
69
- min: 0
70
- },
71
- hour: {
72
- max: 23,
73
- min: 0
74
- },
75
- minute: {
76
- max: 59,
77
- min: 0
78
- },
79
- month: {
80
- max: 12,
81
- min: 1
82
- }
83
- };
84
- const cronFieldRanges = [
85
- cronRange.minute,
86
- cronRange.hour,
87
- cronRange.dayOfMonth,
88
- cronRange.month,
89
- cronRange.dayOfWeek
90
- ];
91
- const runtimeScheduleCreateInputKeys = new Set([
92
- "cron",
93
- "enabled",
94
- "id",
95
- "input",
96
- "target",
97
- "timeZone"
98
- ]);
99
- const runtimeScheduleUpdateInputKeys = new Set([
100
- "cron",
101
- "enabled",
102
- "input",
103
- "target",
104
- "timeZone"
105
- ]);
106
- function parseCronNumber(value, range) {
107
- if (!/^\d+$/.test(value)) throw new Error("not a number");
108
- const parsed = Number(value);
109
- if (!Number.isInteger(parsed) || parsed < range.min || parsed > range.max) throw new Error("out of range");
110
- return parsed;
111
- }
112
- function validateCronPart(part, range) {
113
- const [value, step, extra] = part.split("/");
114
- if (extra !== void 0 || value === void 0 || value.length === 0) throw new Error("invalid step");
115
- if (step !== void 0) {
116
- if (parseCronNumber(step, {
117
- max: range.max,
118
- min: 1
119
- }) < 1) throw new Error("invalid step");
120
- }
121
- if (value === "*") return;
122
- const [start, end, extraRange] = value.split("-");
123
- if (extraRange !== void 0 || start === void 0 || start.length === 0) throw new Error("invalid range");
124
- const parsedStart = parseCronNumber(start, range);
125
- if (end === void 0) return;
126
- if (parseCronNumber(end, range) < parsedStart) throw new Error("invalid range");
127
- }
128
- function validateRuntimeScheduleCron(cron) {
129
- if (typeof cron !== "string" || cron.trim() !== cron || cron.length === 0) throw createScheduleError("SCHEDULE_INVALID_CRON", { details: invalidScheduleValueDetails("cron", cron) });
130
- const fields = cron.split(/\s+/);
131
- if (fields.length !== 5) throw createScheduleError("SCHEDULE_INVALID_CRON", { details: invalidScheduleValueDetails("cron", cron) });
132
- try {
133
- fields.forEach((field, index) => {
134
- if (field.length === 0) throw new Error("empty field");
135
- for (const part of field.split(",")) validateCronPart(part, cronFieldRanges[index]);
136
- });
137
- } catch {
138
- throw createScheduleError("SCHEDULE_INVALID_CRON", { details: invalidScheduleValueDetails("cron", cron) });
139
- }
140
- }
141
- function validateRuntimeScheduleTimeZone(timeZone) {
142
- if (!isIanaTimeZone(timeZone)) throw createScheduleError("SCHEDULE_INVALID_TIME_ZONE", { details: invalidScheduleValueDetails("timeZone", timeZone) });
143
- }
144
- async function assertRuntimeTarget(target) {
145
- if (typeof target !== "string" || !target.trim()) throw createScheduleError("SCHEDULE_INVALID_TARGET", { details: invalidScheduleValueDetails("target", target) });
146
- const definition = await loadScheduleDefinition(target);
147
- if (!definition) throw createScheduleError("SCHEDULE_TARGET_NOT_FOUND");
148
- if (definition.options?.allowRuntimeSchedules !== true) throw createScheduleError("SCHEDULE_TARGET_NOT_ELIGIBLE");
149
- }
150
- function assertRuntimeScheduleInputObject(input) {
151
- if (typeof input !== "object" || input === null || Array.isArray(input)) throw createScheduleError("SCHEDULE_INVALID_INPUT", { details: invalidScheduleValueDetails("input", input) });
152
- }
153
- function assertRuntimeScheduleInputKeys(input, allowed) {
154
- if (Object.keys(input).find((key) => !allowed.has(key))) throw createScheduleError("SCHEDULE_INVALID_INPUT", { details: invalidScheduleValueDetails("input", input) });
155
- }
156
- async function validateCreateInput(input) {
157
- assertRuntimeScheduleInputObject(input);
158
- assertRuntimeScheduleInputKeys(input, runtimeScheduleCreateInputKeys);
159
- await assertRuntimeTarget(input.target);
160
- validateRuntimeScheduleCron(input.cron);
161
- if (input.id !== void 0) assertRuntimeScheduleId(input.id);
162
- if (input.enabled !== void 0 && typeof input.enabled !== "boolean") throw createScheduleError("SCHEDULE_INVALID_ENABLED", { details: invalidScheduleValueDetails("enabled", input.enabled) });
163
- if (input.timeZone !== void 0) validateRuntimeScheduleTimeZone(input.timeZone);
164
- }
165
- async function validateUpdateInput(input) {
166
- assertRuntimeScheduleInputObject(input);
167
- assertRuntimeScheduleInputKeys(input, runtimeScheduleUpdateInputKeys);
168
- if (input.target !== void 0) await assertRuntimeTarget(input.target);
169
- if (input.cron !== void 0) validateRuntimeScheduleCron(input.cron);
170
- if (input.enabled !== void 0 && typeof input.enabled !== "boolean") throw createScheduleError("SCHEDULE_INVALID_ENABLED", { details: invalidScheduleValueDetails("enabled", input.enabled) });
171
- if (input.timeZone !== void 0) validateRuntimeScheduleTimeZone(input.timeZone);
172
- }
173
- async function updateRuntimeSchedule(id, input) {
174
- assertRuntimeScheduleId(id);
175
- await validateUpdateInput(input);
176
- const updated = await getRuntimeScheduleStore().update(id, {
177
- ...input,
178
- updatedAt: /* @__PURE__ */ new Date()
179
- });
180
- if (!updated) throw createScheduleError("SCHEDULE_NOT_FOUND");
181
- return updated;
182
- }
183
- const schedules = {
184
- async create(input) {
185
- await validateCreateInput(input);
186
- const now = /* @__PURE__ */ new Date();
187
- return await getRuntimeScheduleStore().create({
188
- createdAt: now,
189
- cron: input.cron,
190
- enabled: input.enabled ?? true,
191
- id: input.id ?? randomId("sched"),
192
- ...input.input !== void 0 ? { input: input.input } : {},
193
- target: input.target,
194
- ...input.timeZone ? { timeZone: input.timeZone } : {},
195
- updatedAt: now
196
- });
197
- },
198
- async delete(id) {
199
- return await getRuntimeScheduleStore().delete(id);
200
- },
201
- async disable(id) {
202
- return await updateRuntimeSchedule(id, { enabled: false });
203
- },
204
- async enable(id) {
205
- return await updateRuntimeSchedule(id, { enabled: true });
206
- },
207
- async get(id) {
208
- return await getRuntimeScheduleStore().get(id);
209
- },
210
- async getRun(id) {
211
- return await getScheduleRunStore().getRun(id);
212
- },
213
- async list() {
214
- return await getRuntimeScheduleStore().list();
215
- },
216
- async listAttempts(runId) {
217
- return await getScheduleRunStore().listAttempts(runId);
218
- },
219
- async listRuns() {
220
- return await getScheduleRunStore().listRuns();
221
- },
222
- async run(id, options = {}) {
223
- return await executeRuntimeSchedule({
224
- id,
225
- scheduledAt: options.scheduledAt
226
- });
227
- },
228
- async update(id, input) {
229
- return await updateRuntimeSchedule(id, input);
230
- }
231
- };
232
- //#endregion
233
- export { validateRuntimeScheduleCron as n, schedules as t };
@@ -1,15 +0,0 @@
1
- import { t as DiscoveredScheduleDefinition } from "./types-Bcje4dLV.js";
2
-
3
- //#region src/discovery.d.ts
4
- declare function discoverScheduleDefinitions(options: {
5
- mode?: "vite-suffix";
6
- rootDir: string;
7
- scanDirs?: string[];
8
- serverDirs?: string[];
9
- serverRootDir?: string;
10
- } | {
11
- mode: "server-schedules";
12
- scanDirs: string[];
13
- }): DiscoveredScheduleDefinition[];
14
- //#endregion
15
- export { discoverScheduleDefinitions as t };