@vite-hub/schedule 0.0.0 → 0.0.2
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 +124 -1
- package/dist/client-B3cyh-BG.js +233 -0
- package/dist/definition.d.ts +7 -0
- package/dist/definition.js +42 -0
- package/dist/discovery-MXY52MTU.js +767 -0
- package/dist/due-Bbh4yIxq.js +59 -0
- package/dist/execute-BnR8oEKq.js +211 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +6 -0
- package/dist/nuxt.d.ts +19 -0
- package/dist/nuxt.js +25 -0
- package/dist/registry-module.d.ts +9 -0
- package/dist/runtime/driver.d.ts +26 -0
- package/dist/runtime/driver.js +334 -0
- package/dist/runtime/process.d.ts +11 -0
- package/dist/runtime/process.js +285 -0
- package/dist/runtime/state.d.ts +13 -0
- package/dist/runtime/state.js +2 -0
- package/dist/runtime/static.d.ts +41 -0
- package/dist/runtime/static.js +138 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.js +3 -0
- package/dist/state-BcEhBV8v.js +488 -0
- package/dist/store-D2zUgEDc.d.ts +38 -0
- package/dist/types-Bcje4dLV.d.ts +136 -0
- package/dist/vite-Dfeg9ZY3.js +1221 -0
- package/dist/vite.d.ts +36 -0
- package/dist/vite.js +2 -0
- package/dist/wait-until-CR-JjIOb.js +23 -0
- package/package.json +67 -5
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
interface ScheduleRunContext<TInput = unknown> {
|
|
3
|
+
id: string;
|
|
4
|
+
attemptId?: string;
|
|
5
|
+
input?: TInput;
|
|
6
|
+
runId?: string;
|
|
7
|
+
scheduleId?: string;
|
|
8
|
+
scheduledAt: Date;
|
|
9
|
+
target?: ScheduleTargetName;
|
|
10
|
+
waitUntil(promise: PromiseLike<unknown>): void;
|
|
11
|
+
}
|
|
12
|
+
type ScheduleHandler<TResult = unknown, TInput = unknown> = {
|
|
13
|
+
bivarianceHack(context: ScheduleRunContext<TInput>): TResult | Promise<TResult>;
|
|
14
|
+
}["bivarianceHack"];
|
|
15
|
+
interface ScheduleDefinitionInput<TResult = unknown> {
|
|
16
|
+
allowRuntimeSchedules?: boolean;
|
|
17
|
+
cron: string;
|
|
18
|
+
handler: ScheduleHandler<TResult>;
|
|
19
|
+
}
|
|
20
|
+
interface ScheduleDefinitionOptions {
|
|
21
|
+
allowRuntimeSchedules?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface ScheduleDefinition<TResult = unknown> {
|
|
24
|
+
cron: string;
|
|
25
|
+
handler: ScheduleHandler<TResult>;
|
|
26
|
+
options?: ScheduleDefinitionOptions;
|
|
27
|
+
}
|
|
28
|
+
interface ScheduleTargetDefinitionInput<TInput = unknown, TResult = unknown> {
|
|
29
|
+
handler: ScheduleHandler<TResult, TInput>;
|
|
30
|
+
}
|
|
31
|
+
interface ScheduleTargetDefinition<TInput = unknown, TResult = unknown> {
|
|
32
|
+
handler: ScheduleHandler<TResult, TInput>;
|
|
33
|
+
options: {
|
|
34
|
+
allowRuntimeSchedules: true;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
type ScheduleRegistryDefinition = ScheduleDefinition | ScheduleTargetDefinition;
|
|
38
|
+
interface ScheduleDefinitionRegistry {
|
|
39
|
+
[name: string]: () => Promise<{
|
|
40
|
+
default?: ScheduleRegistryDefinition;
|
|
41
|
+
} | ScheduleRegistryDefinition>;
|
|
42
|
+
}
|
|
43
|
+
type ScheduleTargetName = string & {};
|
|
44
|
+
interface RuntimeScheduleMetadata {
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
}
|
|
48
|
+
interface RuntimeScheduleRecord<TInput = unknown> extends RuntimeScheduleMetadata {
|
|
49
|
+
cron: string;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
id: string;
|
|
52
|
+
input?: TInput;
|
|
53
|
+
target: ScheduleTargetName;
|
|
54
|
+
timeZone?: string;
|
|
55
|
+
}
|
|
56
|
+
interface RuntimeScheduleWake {
|
|
57
|
+
scheduleId: string;
|
|
58
|
+
scheduledAt: Date;
|
|
59
|
+
}
|
|
60
|
+
interface RuntimeScheduleCreateInput<TTarget extends ScheduleTargetName = ScheduleTargetName, TInput = unknown> {
|
|
61
|
+
cron: string;
|
|
62
|
+
enabled?: boolean;
|
|
63
|
+
id?: string;
|
|
64
|
+
input?: TInput;
|
|
65
|
+
target: TTarget;
|
|
66
|
+
timeZone?: string;
|
|
67
|
+
}
|
|
68
|
+
interface RuntimeScheduleUpdateInput<TTarget extends ScheduleTargetName = ScheduleTargetName, TInput = unknown> {
|
|
69
|
+
cron?: string;
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
input?: TInput;
|
|
72
|
+
target?: TTarget;
|
|
73
|
+
timeZone?: string;
|
|
74
|
+
}
|
|
75
|
+
interface RuntimeScheduleStore {
|
|
76
|
+
create: (record: RuntimeScheduleRecord) => Promise<RuntimeScheduleRecord> | RuntimeScheduleRecord;
|
|
77
|
+
delete: (id: string) => Promise<boolean> | boolean;
|
|
78
|
+
get: (id: string) => Promise<RuntimeScheduleRecord | undefined> | RuntimeScheduleRecord | undefined;
|
|
79
|
+
list: () => Promise<RuntimeScheduleRecord[]> | RuntimeScheduleRecord[];
|
|
80
|
+
update: (id: string, patch: RuntimeScheduleUpdateInput & {
|
|
81
|
+
updatedAt: Date;
|
|
82
|
+
}) => Promise<RuntimeScheduleRecord | undefined> | RuntimeScheduleRecord | undefined;
|
|
83
|
+
}
|
|
84
|
+
type ScheduleRunStatus = "pending" | "running" | "succeeded" | "failed";
|
|
85
|
+
type ScheduleRunAttemptStatus = "running" | "succeeded" | "failed";
|
|
86
|
+
interface ScheduleRunError {
|
|
87
|
+
message: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
stack?: string;
|
|
90
|
+
}
|
|
91
|
+
interface ScheduleRunRecord {
|
|
92
|
+
attemptCount: number;
|
|
93
|
+
completedAt?: Date;
|
|
94
|
+
createdAt: Date;
|
|
95
|
+
error?: ScheduleRunError;
|
|
96
|
+
id: string;
|
|
97
|
+
scheduleId: string;
|
|
98
|
+
scheduledAt: Date;
|
|
99
|
+
startedAt?: Date;
|
|
100
|
+
status: ScheduleRunStatus;
|
|
101
|
+
target: ScheduleTargetName;
|
|
102
|
+
updatedAt: Date;
|
|
103
|
+
}
|
|
104
|
+
interface ScheduleRunAttemptRecord {
|
|
105
|
+
completedAt?: Date;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
error?: ScheduleRunError;
|
|
108
|
+
id: string;
|
|
109
|
+
runId: string;
|
|
110
|
+
startedAt: Date;
|
|
111
|
+
status: ScheduleRunAttemptStatus;
|
|
112
|
+
updatedAt: Date;
|
|
113
|
+
}
|
|
114
|
+
interface ScheduleRunStore {
|
|
115
|
+
createAttempt: (attempt: ScheduleRunAttemptRecord) => Promise<ScheduleRunAttemptRecord> | ScheduleRunAttemptRecord;
|
|
116
|
+
createRun: (run: ScheduleRunRecord) => Promise<ScheduleRunRecord> | ScheduleRunRecord;
|
|
117
|
+
getAttempt: (id: string) => Promise<ScheduleRunAttemptRecord | undefined> | ScheduleRunAttemptRecord | undefined;
|
|
118
|
+
getRun: (id: string) => Promise<ScheduleRunRecord | undefined> | ScheduleRunRecord | undefined;
|
|
119
|
+
listAttempts: (runId: string) => Promise<ScheduleRunAttemptRecord[]> | ScheduleRunAttemptRecord[];
|
|
120
|
+
listRuns: () => Promise<ScheduleRunRecord[]> | ScheduleRunRecord[];
|
|
121
|
+
updateAttempt: (id: string, patch: Partial<Pick<ScheduleRunAttemptRecord, "completedAt" | "error" | "status">> & {
|
|
122
|
+
updatedAt: Date;
|
|
123
|
+
}) => Promise<ScheduleRunAttemptRecord | undefined> | ScheduleRunAttemptRecord | undefined;
|
|
124
|
+
updateRun: (id: string, patch: Partial<Pick<ScheduleRunRecord, "attemptCount" | "completedAt" | "error" | "startedAt" | "status">> & {
|
|
125
|
+
updatedAt: Date;
|
|
126
|
+
}) => Promise<ScheduleRunRecord | undefined> | ScheduleRunRecord | undefined;
|
|
127
|
+
}
|
|
128
|
+
interface DiscoveredScheduleDefinition {
|
|
129
|
+
allowRuntimeSchedules?: boolean;
|
|
130
|
+
handler: string;
|
|
131
|
+
name: string;
|
|
132
|
+
runtimeOnly?: boolean;
|
|
133
|
+
source?: "server-schedules" | "vite-suffix";
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { ScheduleTargetName as C, ScheduleTargetDefinitionInput as S, ScheduleRunError as _, RuntimeScheduleStore as a, ScheduleRunStore as b, ScheduleDefinition as c, ScheduleDefinitionRegistry as d, ScheduleHandler as f, ScheduleRunContext as g, ScheduleRunAttemptStatus as h, RuntimeScheduleRecord as i, ScheduleDefinitionInput as l, ScheduleRunAttemptRecord as m, RuntimeScheduleCreateInput as n, RuntimeScheduleUpdateInput as o, ScheduleRegistryDefinition as p, RuntimeScheduleMetadata as r, RuntimeScheduleWake as s, DiscoveredScheduleDefinition as t, ScheduleDefinitionOptions as u, ScheduleRunRecord as v, ScheduleTargetDefinition as x, ScheduleRunStatus as y };
|