@vite-hub/schedule 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +147 -76
- package/dist/{client-B3cyh-BG.js → client-DpCD4YFE.js} +2 -2
- package/dist/discovery-DkFAN7Wd.d.ts +15 -0
- package/dist/{discovery-MXY52MTU.js → discovery-DvU3B6iD.js} +28 -42
- package/dist/{execute-BnR8oEKq.js → execute-B-pii4wf.js} +2 -2
- package/dist/index.d.ts +3 -13
- package/dist/index.js +6 -5
- package/dist/kv-BJ1I9IlJ.js +6 -0
- package/dist/kv-storage-DWinmLLy.js +30 -0
- package/dist/nuxt.js +2 -1
- package/dist/runtime/driver.js +8 -5
- package/dist/runtime/state.js +1 -1
- package/dist/runtime/static.js +18 -6
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -2
- package/dist/{state-BcEhBV8v.js → state-By7WU_ks.js} +10 -26
- package/dist/{store-D2zUgEDc.d.ts → store-t-74rsM_.d.ts} +12 -2
- package/dist/vite-BHs17nWX.js +4166 -0
- package/dist/vite.d.ts +17 -1
- package/dist/vite.js +3 -2
- package/dist/{wait-until-CR-JjIOb.js → wait-until-BzIwzXw4.js} +1 -1
- package/package.json +8 -4
- package/dist/vite-Dfeg9ZY3.js +0 -1221
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
/// <reference path="./registry-module.d.ts" />
|
|
2
2
|
import { C as ScheduleTargetName, S as ScheduleTargetDefinitionInput, _ as ScheduleRunError, a as RuntimeScheduleStore, b as ScheduleRunStore, c as ScheduleDefinition, d as ScheduleDefinitionRegistry, f as ScheduleHandler, g as ScheduleRunContext, h as ScheduleRunAttemptStatus, i as RuntimeScheduleRecord, l as ScheduleDefinitionInput, m as ScheduleRunAttemptRecord, n as RuntimeScheduleCreateInput, o as RuntimeScheduleUpdateInput, p as ScheduleRegistryDefinition, r as RuntimeScheduleMetadata, t as DiscoveredScheduleDefinition, v as ScheduleRunRecord, x as ScheduleTargetDefinition, y as ScheduleRunStatus } from "./types-Bcje4dLV.js";
|
|
3
3
|
import { defineSchedule, defineScheduleTarget } from "./definition.js";
|
|
4
|
-
import {
|
|
4
|
+
import { t as discoverScheduleDefinitions } from "./discovery-DkFAN7Wd.js";
|
|
5
|
+
import { a as createMemoryScheduleRunStore, c as schedules, i as createMemoryRuntimeScheduleStore, l as validateRuntimeScheduleCron, n as createKVRuntimeScheduleStore, o as ScheduleKVStorage, r as createKVScheduleRunStore, s as createScheduleKVStorage, t as KVScheduleStoreOptions } from "./store-t-74rsM_.js";
|
|
5
6
|
import { getRuntimeScheduleStore, getScheduleRunStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, setRuntimeScheduleStore, setScheduleRunStore, setScheduleRuntimeRegistry } from "./runtime/state.js";
|
|
6
7
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
7
8
|
|
|
8
|
-
//#region src/discovery.d.ts
|
|
9
|
-
declare function discoverScheduleDefinitions(options: {
|
|
10
|
-
mode?: "vite-suffix";
|
|
11
|
-
rootDir: string;
|
|
12
|
-
scanDirs?: string[];
|
|
13
|
-
serverRootDir?: string;
|
|
14
|
-
} | {
|
|
15
|
-
mode: "server-schedules";
|
|
16
|
-
scanDirs: string[];
|
|
17
|
-
}): DiscoveredScheduleDefinition[];
|
|
18
|
-
//#endregion
|
|
19
9
|
//#region src/runtime/execute.d.ts
|
|
20
10
|
interface ExecuteScheduleOptions {
|
|
21
11
|
definition: ScheduleRegistryDefinition;
|
|
@@ -60,4 +50,4 @@ type ScheduleErrorDetails = {
|
|
|
60
50
|
valueType: ScheduleErrorValueType;
|
|
61
51
|
};
|
|
62
52
|
//#endregion
|
|
63
|
-
export { type DiscoveredScheduleDefinition, type KVScheduleStoreOptions, type RuntimeScheduleCreateInput, type RuntimeScheduleMetadata, type RuntimeScheduleRecord, type RuntimeScheduleStore, type RuntimeScheduleUpdateInput, 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 ScheduleRunRecord, type ScheduleRunStatus, type ScheduleRunStore, type ScheduleTargetDefinition, type ScheduleTargetDefinitionInput, type ScheduleTargetName, type ScheduleValidationErrorCode, createKVRuntimeScheduleStore, createKVScheduleRunStore, createMemoryRuntimeScheduleStore, createMemoryScheduleRunStore, createScheduleRun, defineSchedule, defineScheduleTarget, discoverScheduleDefinitions, executeRuntimeSchedule, executeSchedule, executeStaticSchedule, getRuntimeScheduleStore, getScheduleRunStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRunStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|
|
53
|
+
export { type DiscoveredScheduleDefinition, type KVScheduleStoreOptions, type RuntimeScheduleCreateInput, type RuntimeScheduleMetadata, type RuntimeScheduleRecord, type RuntimeScheduleStore, type RuntimeScheduleUpdateInput, 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 ScheduleRunRecord, type ScheduleRunStatus, type ScheduleRunStore, type ScheduleTargetDefinition, type ScheduleTargetDefinitionInput, type ScheduleTargetName, type ScheduleValidationErrorCode, createKVRuntimeScheduleStore, createKVScheduleRunStore, createMemoryRuntimeScheduleStore, createMemoryScheduleRunStore, createScheduleKVStorage, createScheduleRun, defineSchedule, defineScheduleTarget, discoverScheduleDefinitions, executeRuntimeSchedule, executeSchedule, executeStaticSchedule, getRuntimeScheduleStore, getScheduleRunStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRunStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineSchedule, defineScheduleTarget } from "./definition.js";
|
|
2
|
-
import { t as discoverScheduleDefinitions } from "./discovery-
|
|
3
|
-
import { a as executeStaticSchedule, i as executeSchedule, n as executeRuntimeSchedule, t as createScheduleRun } from "./execute-
|
|
4
|
-
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, d as createMemoryRuntimeScheduleStore, f as createMemoryScheduleRunStore, i as loadScheduleDefinition, l as createKVRuntimeScheduleStore, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore, u as createKVScheduleRunStore } from "./state-
|
|
5
|
-
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-
|
|
6
|
-
|
|
2
|
+
import { t as discoverScheduleDefinitions } from "./discovery-DvU3B6iD.js";
|
|
3
|
+
import { a as executeStaticSchedule, i as executeSchedule, n as executeRuntimeSchedule, t as createScheduleRun } from "./execute-B-pii4wf.js";
|
|
4
|
+
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, d as createMemoryRuntimeScheduleStore, f as createMemoryScheduleRunStore, i as loadScheduleDefinition, l as createKVRuntimeScheduleStore, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore, u as createKVScheduleRunStore } from "./state-By7WU_ks.js";
|
|
5
|
+
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-DpCD4YFE.js";
|
|
6
|
+
import { t as createScheduleKVStorage } from "./kv-storage-DWinmLLy.js";
|
|
7
|
+
export { createKVRuntimeScheduleStore, createKVScheduleRunStore, createMemoryRuntimeScheduleStore, createMemoryScheduleRunStore, createScheduleKVStorage, createScheduleRun, defineSchedule, defineScheduleTarget, discoverScheduleDefinitions, executeRuntimeSchedule, executeSchedule, executeStaticSchedule, getRuntimeScheduleStore, getScheduleRunStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRunStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/runtime/kv-storage.ts
|
|
2
|
+
function createScheduleKVStorage(kvStore) {
|
|
3
|
+
return {
|
|
4
|
+
async del(key) {
|
|
5
|
+
const [error] = await kvStore.del(key);
|
|
6
|
+
if (error) throw error;
|
|
7
|
+
},
|
|
8
|
+
async get(key) {
|
|
9
|
+
const [error, value] = await kvStore.get(key);
|
|
10
|
+
if (error) throw error;
|
|
11
|
+
return value;
|
|
12
|
+
},
|
|
13
|
+
async has(key) {
|
|
14
|
+
const [error, value] = await kvStore.has(key);
|
|
15
|
+
if (error) throw error;
|
|
16
|
+
return value ?? false;
|
|
17
|
+
},
|
|
18
|
+
async keys(base) {
|
|
19
|
+
const [error, value] = await kvStore.keys(base);
|
|
20
|
+
if (error) throw error;
|
|
21
|
+
return value ?? [];
|
|
22
|
+
},
|
|
23
|
+
async set(key, value) {
|
|
24
|
+
const [error] = await kvStore.set(key, value);
|
|
25
|
+
if (error) throw error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createScheduleKVStorage as t };
|
package/dist/nuxt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as hubSchedule, t as createScheduleNitroConfig } from "./vite-
|
|
1
|
+
import { n as hubSchedule, t as createScheduleNitroConfig } from "./vite-BHs17nWX.js";
|
|
2
2
|
//#region src/nuxt.ts
|
|
3
3
|
function isScheduleVitePlugin(value) {
|
|
4
4
|
return Boolean(value && typeof value === "object" && value.name === "@vite-hub/schedule/vite");
|
|
@@ -14,6 +14,7 @@ function viteHubScheduleNuxtModule(options = {}, nuxt) {
|
|
|
14
14
|
const nitro = await createScheduleNitroConfig({
|
|
15
15
|
...options,
|
|
16
16
|
command: nuxt.options.dev ? "serve" : "build",
|
|
17
|
+
nitroOwnsPaths: true,
|
|
17
18
|
nitro: nitroConfig,
|
|
18
19
|
projectRoot: options.projectRoot || rootDir,
|
|
19
20
|
root: nuxt.options.srcDir || rootDir
|
package/dist/runtime/driver.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { a as executeStaticSchedule, r as executeRuntimeScheduleWake } from "../execute-
|
|
2
|
-
import { c as setScheduleRuntimeRegistry, m as createScheduleError, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore } from "../state-
|
|
1
|
+
import { a as executeStaticSchedule, r as executeRuntimeScheduleWake } from "../execute-B-pii4wf.js";
|
|
2
|
+
import { c as setScheduleRuntimeRegistry, m as createScheduleError, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore } from "../state-By7WU_ks.js";
|
|
3
3
|
import { t as isRuntimeScheduleDue } from "../due-Bbh4yIxq.js";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
//#region src/runtime/driver.ts
|
|
6
6
|
const staticScheduleIdPrefix = "\0vitehub:static:";
|
|
7
|
+
function isObject(value) {
|
|
8
|
+
return Object(value) === value;
|
|
9
|
+
}
|
|
7
10
|
function isScheduleRegistryDefinition(value) {
|
|
8
|
-
return
|
|
11
|
+
return isObject(value) && "handler" in value;
|
|
9
12
|
}
|
|
10
13
|
function unwrapDefinition(loaded) {
|
|
11
14
|
if ("default" in loaded && isScheduleRegistryDefinition(loaded.default)) return loaded.default;
|
|
@@ -238,7 +241,7 @@ async function installScheduleRuntime(options) {
|
|
|
238
241
|
});
|
|
239
242
|
}
|
|
240
243
|
async function flushWaitUntil() {
|
|
241
|
-
while (pendingWork.size > 0) await Promise.allSettled(
|
|
244
|
+
while (pendingWork.size > 0) await Promise.allSettled(pendingWork);
|
|
242
245
|
}
|
|
243
246
|
const serialize = createSerializer();
|
|
244
247
|
const activeWakes = /* @__PURE__ */ new Set();
|
|
@@ -323,7 +326,7 @@ async function installScheduleRuntime(options) {
|
|
|
323
326
|
if (closePromise) return closePromise;
|
|
324
327
|
closing = true;
|
|
325
328
|
return closePromise = (async () => {
|
|
326
|
-
while (activeWakes.size > 0) await Promise.allSettled(
|
|
329
|
+
while (activeWakes.size > 0) await Promise.allSettled(activeWakes);
|
|
327
330
|
await serialize(async () => {});
|
|
328
331
|
await flushWaitUntil();
|
|
329
332
|
await installedDriver.close?.();
|
package/dist/runtime/state.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, i as loadScheduleDefinition, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore } from "../state-
|
|
1
|
+
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, i as loadScheduleDefinition, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore } from "../state-By7WU_ks.js";
|
|
2
2
|
export { getRuntimeScheduleStore, getScheduleRunStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, setRuntimeScheduleStore, setScheduleRunStore, setScheduleRuntimeRegistry };
|
package/dist/runtime/static.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createLocalWaitUntil } from "../wait-until-
|
|
1
|
+
import { t as createLocalWaitUntil } from "../wait-until-BzIwzXw4.js";
|
|
2
2
|
//#region src/runtime/static.ts
|
|
3
3
|
function createStaticScheduleRun(options) {
|
|
4
4
|
const scheduledAt = options.scheduledAt ?? /* @__PURE__ */ new Date();
|
|
@@ -57,7 +57,7 @@ function readCloudflareScheduledEvent(event) {
|
|
|
57
57
|
const cron = event.controller?.cron ?? event.cron;
|
|
58
58
|
if (!cron) throw new TypeError("[vitehub:schedule] Cloudflare scheduled event is missing a cron string.");
|
|
59
59
|
const scheduledTime = event.controller?.scheduledTime ?? event.scheduledTime;
|
|
60
|
-
const scheduledAt = scheduledTime instanceof Date ? scheduledTime :
|
|
60
|
+
const scheduledAt = scheduledTime instanceof Date ? scheduledTime : scheduledTime === void 0 ? /* @__PURE__ */ new Date() : new Date(scheduledTime);
|
|
61
61
|
if (Number.isNaN(scheduledAt.getTime())) throw new TypeError("[vitehub:schedule] Cloudflare scheduled event has an invalid scheduledTime.");
|
|
62
62
|
return {
|
|
63
63
|
cron,
|
|
@@ -87,14 +87,23 @@ async function runWithCloudflareServerEnv(event, callback, hostWaitUntil) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
async function flushPendingWork(pending) {
|
|
90
|
-
while (pending.size > 0) await Promise.allSettled(
|
|
90
|
+
while (pending.size > 0) await Promise.allSettled(pending);
|
|
91
91
|
}
|
|
92
92
|
function restoreGlobalEnv(globals, hadGlobalEnv, previousGlobalEnv) {
|
|
93
93
|
if (hadGlobalEnv) globals.__env__ = previousGlobalEnv;
|
|
94
94
|
else delete globals.__env__;
|
|
95
95
|
}
|
|
96
96
|
function isRecord(value) {
|
|
97
|
-
return
|
|
97
|
+
return Object(value) === value && !Array.isArray(value);
|
|
98
|
+
}
|
|
99
|
+
function isCallable(value) {
|
|
100
|
+
if (value === null || value === void 0 || Object(value) !== value) return false;
|
|
101
|
+
try {
|
|
102
|
+
Function.prototype.toString.call(value);
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
function readCloudflareWaitUntil(event) {
|
|
100
109
|
const context = isRecord(event.context) ? event.context : void 0;
|
|
@@ -115,7 +124,10 @@ function readCloudflareWaitUntil(event) {
|
|
|
115
124
|
runtimeCloudflare,
|
|
116
125
|
isRecord(runtimeCloudflare?.context) ? runtimeCloudflare.context : void 0
|
|
117
126
|
];
|
|
118
|
-
for (const owner of owners)
|
|
127
|
+
for (const owner of owners) {
|
|
128
|
+
const waitUntil = owner?.waitUntil;
|
|
129
|
+
if (isCallable(waitUntil)) return (promise) => Reflect.apply(waitUntil, owner, [promise]);
|
|
130
|
+
}
|
|
119
131
|
}
|
|
120
132
|
function readCloudflareEventEnv(event) {
|
|
121
133
|
if (isRecord(event.env)) return event.env;
|
|
@@ -131,7 +143,7 @@ function readCloudflareEventEnv(event) {
|
|
|
131
143
|
return isRecord(runtimeCloudflare?.env) ? runtimeCloudflare.env : void 0;
|
|
132
144
|
}
|
|
133
145
|
function unwrapScheduleDefinition(loaded) {
|
|
134
|
-
const definition =
|
|
146
|
+
const definition = "default" in loaded ? loaded.default : loaded;
|
|
135
147
|
return definition && "cron" in definition ? definition : void 0;
|
|
136
148
|
}
|
|
137
149
|
//#endregion
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./registry-module.d.ts" />
|
|
2
2
|
import { C as ScheduleTargetName, S as ScheduleTargetDefinitionInput, a as RuntimeScheduleStore, c as ScheduleDefinition, d as ScheduleDefinitionRegistry, f as ScheduleHandler, g as ScheduleRunContext, i as RuntimeScheduleRecord, n as RuntimeScheduleCreateInput, o as RuntimeScheduleUpdateInput, p as ScheduleRegistryDefinition, r as RuntimeScheduleMetadata, u as ScheduleDefinitionOptions, x as ScheduleTargetDefinition } from "./types-Bcje4dLV.js";
|
|
3
|
-
import {
|
|
3
|
+
import { c as schedules, i as createMemoryRuntimeScheduleStore, l as validateRuntimeScheduleCron } from "./store-t-74rsM_.js";
|
|
4
4
|
import { getRuntimeScheduleStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, setRuntimeScheduleStore, setScheduleRuntimeRegistry } from "./runtime/state.js";
|
|
5
5
|
export { type RuntimeScheduleCreateInput, type RuntimeScheduleMetadata, type RuntimeScheduleRecord, type RuntimeScheduleStore, type RuntimeScheduleUpdateInput, type ScheduleDefinition, type ScheduleDefinitionOptions, type ScheduleDefinitionRegistry, type ScheduleHandler, type ScheduleRegistryDefinition, type ScheduleRunContext, type ScheduleTargetDefinition, type ScheduleTargetDefinitionInput, type ScheduleTargetName, createMemoryRuntimeScheduleStore, getRuntimeScheduleStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|
package/dist/runtime.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, d as createMemoryRuntimeScheduleStore, i as loadScheduleDefinition, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, t as getRuntimeScheduleStore } from "./state-
|
|
2
|
-
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-
|
|
1
|
+
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, d as createMemoryRuntimeScheduleStore, i as loadScheduleDefinition, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, t as getRuntimeScheduleStore } from "./state-By7WU_ks.js";
|
|
2
|
+
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-DpCD4YFE.js";
|
|
3
3
|
export { createMemoryRuntimeScheduleStore, getRuntimeScheduleStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|
|
@@ -63,33 +63,17 @@ function scheduleRunBase(prefix) {
|
|
|
63
63
|
function scheduleRunAttemptBase(prefix) {
|
|
64
64
|
return joinKey(prefix, "schedule-run-attempts");
|
|
65
65
|
}
|
|
66
|
+
function isMissingKVPackage(error) {
|
|
67
|
+
if (!(error instanceof Error)) return false;
|
|
68
|
+
return error.code === "ERR_MODULE_NOT_FOUND" && error.message.includes("Cannot find package '@vite-hub/kv'");
|
|
69
|
+
}
|
|
66
70
|
async function resolveDefaultKVStore() {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
async get(key) {
|
|
74
|
-
const [error, value] = await module.kv.get(key);
|
|
75
|
-
if (error) throw error;
|
|
76
|
-
return value;
|
|
77
|
-
},
|
|
78
|
-
async has(key) {
|
|
79
|
-
const [error, value] = await module.kv.has(key);
|
|
80
|
-
if (error) throw error;
|
|
81
|
-
return value;
|
|
82
|
-
},
|
|
83
|
-
async keys(base) {
|
|
84
|
-
const [error, value] = await module.kv.keys(base);
|
|
85
|
-
if (error) throw error;
|
|
86
|
-
return value;
|
|
87
|
-
},
|
|
88
|
-
async set(key, value) {
|
|
89
|
-
const [error] = await module.kv.set(key, value);
|
|
90
|
-
if (error) throw error;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
71
|
+
try {
|
|
72
|
+
return (await import("./kv-BJ1I9IlJ.js")).scheduleKVStorage;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (isMissingKVPackage(error)) throw new Error("[vitehub:schedule] The default KV-backed stores require @vite-hub/kv. Install it with: pnpm add @vite-hub/kv", { cause: error });
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
93
77
|
}
|
|
94
78
|
function cloneRuntimeSchedule(record) {
|
|
95
79
|
return {
|
|
@@ -18,7 +18,7 @@ declare const schedules: {
|
|
|
18
18
|
update<TTarget extends ScheduleTargetName, TInput = unknown>(id: string, input: RuntimeScheduleUpdateInput<TTarget, TInput>): Promise<RuntimeScheduleRecord<TInput>>;
|
|
19
19
|
};
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region src/runtime/
|
|
21
|
+
//#region src/runtime/kv-storage.d.ts
|
|
22
22
|
interface ScheduleKVStorage {
|
|
23
23
|
del(key: string): boolean | Promise<boolean> | Promise<void> | void;
|
|
24
24
|
get<T = unknown>(key: string): Promise<T | null | undefined> | T | null | undefined;
|
|
@@ -26,6 +26,16 @@ interface ScheduleKVStorage {
|
|
|
26
26
|
keys(base?: string): Promise<string[]> | string[];
|
|
27
27
|
set<T = unknown>(key: string, value: T): Promise<void> | void;
|
|
28
28
|
}
|
|
29
|
+
interface ViteHubKVStorage {
|
|
30
|
+
del(key: string): Promise<readonly [unknown, unknown]>;
|
|
31
|
+
get<T = unknown>(key: string): Promise<readonly [unknown, T | null | undefined]>;
|
|
32
|
+
has(key: string): Promise<readonly [unknown, boolean | undefined]>;
|
|
33
|
+
keys(base?: string): Promise<readonly [unknown, string[] | undefined]>;
|
|
34
|
+
set<T = unknown>(key: string, value: T): Promise<readonly [unknown, unknown]>;
|
|
35
|
+
}
|
|
36
|
+
declare function createScheduleKVStorage(kvStore: ViteHubKVStorage): ScheduleKVStorage;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/runtime/store.d.ts
|
|
29
39
|
interface KVScheduleStoreOptions {
|
|
30
40
|
kvStore?: ScheduleKVStorage;
|
|
31
41
|
prefix?: string;
|
|
@@ -35,4 +45,4 @@ declare function createKVRuntimeScheduleStore(options?: KVScheduleStoreOptions):
|
|
|
35
45
|
declare function createMemoryScheduleRunStore(): ScheduleRunStore;
|
|
36
46
|
declare function createKVScheduleRunStore(options?: KVScheduleStoreOptions): ScheduleRunStore;
|
|
37
47
|
//#endregion
|
|
38
|
-
export {
|
|
48
|
+
export { createMemoryScheduleRunStore as a, schedules as c, createMemoryRuntimeScheduleStore as i, validateRuntimeScheduleCron as l, createKVRuntimeScheduleStore as n, ScheduleKVStorage as o, createKVScheduleRunStore as r, createScheduleKVStorage as s, KVScheduleStoreOptions as t };
|