@taskcast/server 0.3.0 → 0.3.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/dist/index.d.ts +29 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -5
- package/dist/index.js.map +1 -1
- package/dist/routes/sse.d.ts +2 -2
- package/dist/routes/sse.d.ts.map +1 -1
- package/dist/routes/sse.js +35 -4
- package/dist/routes/sse.js.map +1 -1
- package/dist/routes/tasks.d.ts +2 -2
- package/dist/routes/tasks.d.ts.map +1 -1
- package/dist/routes/tasks.js +157 -43
- package/dist/routes/tasks.js.map +1 -1
- package/dist/routes/worker-ws.d.ts +9 -1
- package/dist/routes/worker-ws.d.ts.map +1 -1
- package/dist/routes/worker-ws.js +21 -1
- package/dist/routes/worker-ws.js.map +1 -1
- package/dist/routes/workers.d.ts +3 -3
- package/dist/routes/workers.d.ts.map +1 -1
- package/dist/routes/workers.js +95 -19
- package/dist/routes/workers.js.map +1 -1
- package/dist/schemas.d.ts +352 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +138 -0
- package/dist/schemas.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const TaskStatusSchema: z.ZodEnum<["pending", "assigned", "running", "paused", "blocked", "completed", "failed", "timeout", "cancelled"]>;
|
|
3
|
+
export declare const LevelSchema: z.ZodEnum<["debug", "info", "warn", "error"]>;
|
|
4
|
+
export declare const SeriesModeSchema: z.ZodEnum<["keep-all", "accumulate", "latest"]>;
|
|
5
|
+
export declare const AssignModeSchema: z.ZodEnum<["external", "pull", "ws-offer", "ws-race"]>;
|
|
6
|
+
export declare const DisconnectPolicySchema: z.ZodEnum<["reassign", "mark", "fail"]>;
|
|
7
|
+
export declare const TaskErrorSchema: z.ZodObject<{
|
|
8
|
+
code: z.ZodOptional<z.ZodString>;
|
|
9
|
+
message: z.ZodString;
|
|
10
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
message: string;
|
|
13
|
+
code?: string | undefined;
|
|
14
|
+
details?: Record<string, unknown> | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
message: string;
|
|
17
|
+
code?: string | undefined;
|
|
18
|
+
details?: Record<string, unknown> | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const TaskSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
type: z.ZodOptional<z.ZodString>;
|
|
23
|
+
status: z.ZodEnum<["pending", "assigned", "running", "paused", "blocked", "completed", "failed", "timeout", "cancelled"]>;
|
|
24
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
25
|
+
result: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
code: z.ZodOptional<z.ZodString>;
|
|
28
|
+
message: z.ZodString;
|
|
29
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
message: string;
|
|
32
|
+
code?: string | undefined;
|
|
33
|
+
details?: Record<string, unknown> | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
message: string;
|
|
36
|
+
code?: string | undefined;
|
|
37
|
+
details?: Record<string, unknown> | undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
40
|
+
createdAt: z.ZodNumber;
|
|
41
|
+
updatedAt: z.ZodNumber;
|
|
42
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
45
|
+
assignMode: z.ZodOptional<z.ZodEnum<["external", "pull", "ws-offer", "ws-race"]>>;
|
|
46
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
assignedWorker: z.ZodOptional<z.ZodString>;
|
|
48
|
+
disconnectPolicy: z.ZodOptional<z.ZodEnum<["reassign", "mark", "fail"]>>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
status: "pending" | "assigned" | "running" | "paused" | "blocked" | "completed" | "failed" | "timeout" | "cancelled";
|
|
51
|
+
id: string;
|
|
52
|
+
createdAt: number;
|
|
53
|
+
updatedAt: number;
|
|
54
|
+
type?: string | undefined;
|
|
55
|
+
error?: {
|
|
56
|
+
message: string;
|
|
57
|
+
code?: string | undefined;
|
|
58
|
+
details?: Record<string, unknown> | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
assignMode?: "external" | "pull" | "ws-offer" | "ws-race" | undefined;
|
|
61
|
+
disconnectPolicy?: "reassign" | "mark" | "fail" | undefined;
|
|
62
|
+
result?: Record<string, unknown> | undefined;
|
|
63
|
+
tags?: string[] | undefined;
|
|
64
|
+
params?: Record<string, unknown> | undefined;
|
|
65
|
+
metadata?: Record<string, unknown> | undefined;
|
|
66
|
+
completedAt?: number | undefined;
|
|
67
|
+
ttl?: number | undefined;
|
|
68
|
+
cost?: number | undefined;
|
|
69
|
+
assignedWorker?: string | undefined;
|
|
70
|
+
}, {
|
|
71
|
+
status: "pending" | "assigned" | "running" | "paused" | "blocked" | "completed" | "failed" | "timeout" | "cancelled";
|
|
72
|
+
id: string;
|
|
73
|
+
createdAt: number;
|
|
74
|
+
updatedAt: number;
|
|
75
|
+
type?: string | undefined;
|
|
76
|
+
error?: {
|
|
77
|
+
message: string;
|
|
78
|
+
code?: string | undefined;
|
|
79
|
+
details?: Record<string, unknown> | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
assignMode?: "external" | "pull" | "ws-offer" | "ws-race" | undefined;
|
|
82
|
+
disconnectPolicy?: "reassign" | "mark" | "fail" | undefined;
|
|
83
|
+
result?: Record<string, unknown> | undefined;
|
|
84
|
+
tags?: string[] | undefined;
|
|
85
|
+
params?: Record<string, unknown> | undefined;
|
|
86
|
+
metadata?: Record<string, unknown> | undefined;
|
|
87
|
+
completedAt?: number | undefined;
|
|
88
|
+
ttl?: number | undefined;
|
|
89
|
+
cost?: number | undefined;
|
|
90
|
+
assignedWorker?: string | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
export declare const TaskEventSchema: z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
taskId: z.ZodString;
|
|
95
|
+
index: z.ZodNumber;
|
|
96
|
+
timestamp: z.ZodNumber;
|
|
97
|
+
type: z.ZodString;
|
|
98
|
+
level: z.ZodEnum<["debug", "info", "warn", "error"]>;
|
|
99
|
+
data: z.ZodUnknown;
|
|
100
|
+
seriesId: z.ZodOptional<z.ZodString>;
|
|
101
|
+
seriesMode: z.ZodOptional<z.ZodEnum<["keep-all", "accumulate", "latest"]>>;
|
|
102
|
+
seriesAccField: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
type: string;
|
|
105
|
+
level: "error" | "debug" | "info" | "warn";
|
|
106
|
+
index: number;
|
|
107
|
+
timestamp: number;
|
|
108
|
+
id: string;
|
|
109
|
+
taskId: string;
|
|
110
|
+
seriesMode?: "keep-all" | "accumulate" | "latest" | undefined;
|
|
111
|
+
data?: unknown;
|
|
112
|
+
seriesId?: string | undefined;
|
|
113
|
+
seriesAccField?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
type: string;
|
|
116
|
+
level: "error" | "debug" | "info" | "warn";
|
|
117
|
+
index: number;
|
|
118
|
+
timestamp: number;
|
|
119
|
+
id: string;
|
|
120
|
+
taskId: string;
|
|
121
|
+
seriesMode?: "keep-all" | "accumulate" | "latest" | undefined;
|
|
122
|
+
data?: unknown;
|
|
123
|
+
seriesId?: string | undefined;
|
|
124
|
+
seriesAccField?: string | undefined;
|
|
125
|
+
}>;
|
|
126
|
+
export declare const WorkerSchema: z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
status: z.ZodEnum<["idle", "busy", "draining", "offline"]>;
|
|
129
|
+
matchRule: z.ZodObject<{
|
|
130
|
+
taskTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
131
|
+
tags: z.ZodOptional<z.ZodObject<{
|
|
132
|
+
all: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
133
|
+
any: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
134
|
+
none: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
all?: string[] | undefined;
|
|
137
|
+
none?: string[] | undefined;
|
|
138
|
+
any?: string[] | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
all?: string[] | undefined;
|
|
141
|
+
none?: string[] | undefined;
|
|
142
|
+
any?: string[] | undefined;
|
|
143
|
+
}>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
tags?: {
|
|
146
|
+
all?: string[] | undefined;
|
|
147
|
+
none?: string[] | undefined;
|
|
148
|
+
any?: string[] | undefined;
|
|
149
|
+
} | undefined;
|
|
150
|
+
taskTypes?: string[] | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
tags?: {
|
|
153
|
+
all?: string[] | undefined;
|
|
154
|
+
none?: string[] | undefined;
|
|
155
|
+
any?: string[] | undefined;
|
|
156
|
+
} | undefined;
|
|
157
|
+
taskTypes?: string[] | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
capacity: z.ZodNumber;
|
|
160
|
+
usedSlots: z.ZodNumber;
|
|
161
|
+
weight: z.ZodNumber;
|
|
162
|
+
connectionMode: z.ZodEnum<["pull", "websocket"]>;
|
|
163
|
+
connectedAt: z.ZodNumber;
|
|
164
|
+
lastHeartbeatAt: z.ZodNumber;
|
|
165
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
status: "idle" | "busy" | "draining" | "offline";
|
|
168
|
+
connectionMode: "pull" | "websocket";
|
|
169
|
+
id: string;
|
|
170
|
+
matchRule: {
|
|
171
|
+
tags?: {
|
|
172
|
+
all?: string[] | undefined;
|
|
173
|
+
none?: string[] | undefined;
|
|
174
|
+
any?: string[] | undefined;
|
|
175
|
+
} | undefined;
|
|
176
|
+
taskTypes?: string[] | undefined;
|
|
177
|
+
};
|
|
178
|
+
capacity: number;
|
|
179
|
+
usedSlots: number;
|
|
180
|
+
weight: number;
|
|
181
|
+
connectedAt: number;
|
|
182
|
+
lastHeartbeatAt: number;
|
|
183
|
+
metadata?: Record<string, unknown> | undefined;
|
|
184
|
+
}, {
|
|
185
|
+
status: "idle" | "busy" | "draining" | "offline";
|
|
186
|
+
connectionMode: "pull" | "websocket";
|
|
187
|
+
id: string;
|
|
188
|
+
matchRule: {
|
|
189
|
+
tags?: {
|
|
190
|
+
all?: string[] | undefined;
|
|
191
|
+
none?: string[] | undefined;
|
|
192
|
+
any?: string[] | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
taskTypes?: string[] | undefined;
|
|
195
|
+
};
|
|
196
|
+
capacity: number;
|
|
197
|
+
usedSlots: number;
|
|
198
|
+
weight: number;
|
|
199
|
+
connectedAt: number;
|
|
200
|
+
lastHeartbeatAt: number;
|
|
201
|
+
metadata?: Record<string, unknown> | undefined;
|
|
202
|
+
}>;
|
|
203
|
+
export declare const ErrorSchema: z.ZodObject<{
|
|
204
|
+
error: z.ZodString;
|
|
205
|
+
}, "strip", z.ZodTypeAny, {
|
|
206
|
+
error: string;
|
|
207
|
+
}, {
|
|
208
|
+
error: string;
|
|
209
|
+
}>;
|
|
210
|
+
export declare const CreateTaskSchema: z.ZodObject<{
|
|
211
|
+
id: z.ZodOptional<z.ZodString>;
|
|
212
|
+
type: z.ZodOptional<z.ZodString>;
|
|
213
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
214
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
215
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
webhooks: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
217
|
+
cleanup: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
rules: z.ZodArray<z.ZodUnknown, "many">;
|
|
219
|
+
}, "strip", z.ZodTypeAny, {
|
|
220
|
+
rules: unknown[];
|
|
221
|
+
}, {
|
|
222
|
+
rules: unknown[];
|
|
223
|
+
}>>;
|
|
224
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
225
|
+
assignMode: z.ZodOptional<z.ZodEnum<["external", "pull", "ws-offer", "ws-race"]>>;
|
|
226
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
disconnectPolicy: z.ZodOptional<z.ZodEnum<["reassign", "mark", "fail"]>>;
|
|
228
|
+
authConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
type?: string | undefined;
|
|
231
|
+
webhooks?: unknown[] | undefined;
|
|
232
|
+
cleanup?: {
|
|
233
|
+
rules: unknown[];
|
|
234
|
+
} | undefined;
|
|
235
|
+
authConfig?: Record<string, unknown> | undefined;
|
|
236
|
+
assignMode?: "external" | "pull" | "ws-offer" | "ws-race" | undefined;
|
|
237
|
+
disconnectPolicy?: "reassign" | "mark" | "fail" | undefined;
|
|
238
|
+
tags?: string[] | undefined;
|
|
239
|
+
params?: Record<string, unknown> | undefined;
|
|
240
|
+
id?: string | undefined;
|
|
241
|
+
metadata?: Record<string, unknown> | undefined;
|
|
242
|
+
ttl?: number | undefined;
|
|
243
|
+
cost?: number | undefined;
|
|
244
|
+
}, {
|
|
245
|
+
type?: string | undefined;
|
|
246
|
+
webhooks?: unknown[] | undefined;
|
|
247
|
+
cleanup?: {
|
|
248
|
+
rules: unknown[];
|
|
249
|
+
} | undefined;
|
|
250
|
+
authConfig?: Record<string, unknown> | undefined;
|
|
251
|
+
assignMode?: "external" | "pull" | "ws-offer" | "ws-race" | undefined;
|
|
252
|
+
disconnectPolicy?: "reassign" | "mark" | "fail" | undefined;
|
|
253
|
+
tags?: string[] | undefined;
|
|
254
|
+
params?: Record<string, unknown> | undefined;
|
|
255
|
+
id?: string | undefined;
|
|
256
|
+
metadata?: Record<string, unknown> | undefined;
|
|
257
|
+
ttl?: number | undefined;
|
|
258
|
+
cost?: number | undefined;
|
|
259
|
+
}>;
|
|
260
|
+
export declare const TransitionSchema: z.ZodObject<{
|
|
261
|
+
status: z.ZodEnum<["pending", "assigned", "running", "paused", "blocked", "completed", "failed", "timeout", "cancelled"]>;
|
|
262
|
+
result: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
263
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
264
|
+
code: z.ZodOptional<z.ZodString>;
|
|
265
|
+
message: z.ZodString;
|
|
266
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
267
|
+
}, "strip", z.ZodTypeAny, {
|
|
268
|
+
message: string;
|
|
269
|
+
code?: string | undefined;
|
|
270
|
+
details?: Record<string, unknown> | undefined;
|
|
271
|
+
}, {
|
|
272
|
+
message: string;
|
|
273
|
+
code?: string | undefined;
|
|
274
|
+
details?: Record<string, unknown> | undefined;
|
|
275
|
+
}>>;
|
|
276
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
277
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
278
|
+
resumeAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
279
|
+
blockedRequest: z.ZodOptional<z.ZodObject<{
|
|
280
|
+
type: z.ZodString;
|
|
281
|
+
data: z.ZodUnknown;
|
|
282
|
+
}, "strip", z.ZodTypeAny, {
|
|
283
|
+
type: string;
|
|
284
|
+
data?: unknown;
|
|
285
|
+
}, {
|
|
286
|
+
type: string;
|
|
287
|
+
data?: unknown;
|
|
288
|
+
}>>;
|
|
289
|
+
}, "strip", z.ZodTypeAny, {
|
|
290
|
+
status: "pending" | "assigned" | "running" | "paused" | "blocked" | "completed" | "failed" | "timeout" | "cancelled";
|
|
291
|
+
error?: {
|
|
292
|
+
message: string;
|
|
293
|
+
code?: string | undefined;
|
|
294
|
+
details?: Record<string, unknown> | undefined;
|
|
295
|
+
} | undefined;
|
|
296
|
+
result?: Record<string, unknown> | undefined;
|
|
297
|
+
ttl?: number | undefined;
|
|
298
|
+
reason?: string | undefined;
|
|
299
|
+
resumeAfterMs?: number | undefined;
|
|
300
|
+
blockedRequest?: {
|
|
301
|
+
type: string;
|
|
302
|
+
data?: unknown;
|
|
303
|
+
} | undefined;
|
|
304
|
+
}, {
|
|
305
|
+
status: "pending" | "assigned" | "running" | "paused" | "blocked" | "completed" | "failed" | "timeout" | "cancelled";
|
|
306
|
+
error?: {
|
|
307
|
+
message: string;
|
|
308
|
+
code?: string | undefined;
|
|
309
|
+
details?: Record<string, unknown> | undefined;
|
|
310
|
+
} | undefined;
|
|
311
|
+
result?: Record<string, unknown> | undefined;
|
|
312
|
+
ttl?: number | undefined;
|
|
313
|
+
reason?: string | undefined;
|
|
314
|
+
resumeAfterMs?: number | undefined;
|
|
315
|
+
blockedRequest?: {
|
|
316
|
+
type: string;
|
|
317
|
+
data?: unknown;
|
|
318
|
+
} | undefined;
|
|
319
|
+
}>;
|
|
320
|
+
export declare const PublishEventSchema: z.ZodObject<{
|
|
321
|
+
type: z.ZodString;
|
|
322
|
+
level: z.ZodEnum<["debug", "info", "warn", "error"]>;
|
|
323
|
+
data: z.ZodUnknown;
|
|
324
|
+
seriesId: z.ZodOptional<z.ZodString>;
|
|
325
|
+
seriesMode: z.ZodOptional<z.ZodEnum<["keep-all", "accumulate", "latest"]>>;
|
|
326
|
+
seriesAccField: z.ZodOptional<z.ZodString>;
|
|
327
|
+
}, "strip", z.ZodTypeAny, {
|
|
328
|
+
type: string;
|
|
329
|
+
level: "error" | "debug" | "info" | "warn";
|
|
330
|
+
seriesMode?: "keep-all" | "accumulate" | "latest" | undefined;
|
|
331
|
+
data?: unknown;
|
|
332
|
+
seriesId?: string | undefined;
|
|
333
|
+
seriesAccField?: string | undefined;
|
|
334
|
+
}, {
|
|
335
|
+
type: string;
|
|
336
|
+
level: "error" | "debug" | "info" | "warn";
|
|
337
|
+
seriesMode?: "keep-all" | "accumulate" | "latest" | undefined;
|
|
338
|
+
data?: unknown;
|
|
339
|
+
seriesId?: string | undefined;
|
|
340
|
+
seriesAccField?: string | undefined;
|
|
341
|
+
}>;
|
|
342
|
+
export declare const DeclineSchema: z.ZodObject<{
|
|
343
|
+
workerId: z.ZodString;
|
|
344
|
+
blacklist: z.ZodOptional<z.ZodBoolean>;
|
|
345
|
+
}, "strip", z.ZodTypeAny, {
|
|
346
|
+
workerId: string;
|
|
347
|
+
blacklist?: boolean | undefined;
|
|
348
|
+
}, {
|
|
349
|
+
workerId: string;
|
|
350
|
+
blacklist?: boolean | undefined;
|
|
351
|
+
}>;
|
|
352
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAIrC,eAAO,MAAM,gBAAgB,mHAU3B,CAAA;AAEF,eAAO,MAAM,WAAW,+CAA6C,CAAA;AAErE,eAAO,MAAM,gBAAgB,iDAA+C,CAAA;AAE5E,eAAO,MAAM,gBAAgB,wDAAsD,CAAA;AAEnF,eAAO,MAAM,sBAAsB,yCAAuC,CAAA;AAI1E,eAAO,MAAM,eAAe;;;;;;;;;;;;EAML,CAAA;AAEvB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBL,CAAA;AAElB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaL,CAAA;AAEvB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBL,CAAA;AAEpB,eAAO,MAAM,WAAW;;;;;;EAIL,CAAA;AAInB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,CAAA;AAE7B,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBA,CAAA;AAE7B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EASA,CAAA;AAE/B,eAAO,MAAM,aAAa;;;;;;;;;EAKA,CAAA"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
// ─── Enums ──────────────────────────────────────────────────────────────────
|
|
3
|
+
export const TaskStatusSchema = z.enum([
|
|
4
|
+
'pending',
|
|
5
|
+
'assigned',
|
|
6
|
+
'running',
|
|
7
|
+
'paused',
|
|
8
|
+
'blocked',
|
|
9
|
+
'completed',
|
|
10
|
+
'failed',
|
|
11
|
+
'timeout',
|
|
12
|
+
'cancelled',
|
|
13
|
+
]);
|
|
14
|
+
export const LevelSchema = z.enum(['debug', 'info', 'warn', 'error']);
|
|
15
|
+
export const SeriesModeSchema = z.enum(['keep-all', 'accumulate', 'latest']);
|
|
16
|
+
export const AssignModeSchema = z.enum(['external', 'pull', 'ws-offer', 'ws-race']);
|
|
17
|
+
export const DisconnectPolicySchema = z.enum(['reassign', 'mark', 'fail']);
|
|
18
|
+
// ─── Response Schemas ───────────────────────────────────────────────────────
|
|
19
|
+
export const TaskErrorSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
code: z.string().optional(),
|
|
22
|
+
message: z.string(),
|
|
23
|
+
details: z.record(z.unknown()).optional(),
|
|
24
|
+
})
|
|
25
|
+
.openapi('TaskError');
|
|
26
|
+
export const TaskSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
id: z.string(),
|
|
29
|
+
type: z.string().optional(),
|
|
30
|
+
status: TaskStatusSchema,
|
|
31
|
+
params: z.record(z.unknown()).optional(),
|
|
32
|
+
result: z.record(z.unknown()).optional(),
|
|
33
|
+
error: TaskErrorSchema.optional(),
|
|
34
|
+
metadata: z.record(z.unknown()).optional(),
|
|
35
|
+
createdAt: z.number(),
|
|
36
|
+
updatedAt: z.number(),
|
|
37
|
+
completedAt: z.number().optional(),
|
|
38
|
+
ttl: z.number().int().positive().optional(),
|
|
39
|
+
tags: z.array(z.string()).optional(),
|
|
40
|
+
assignMode: AssignModeSchema.optional(),
|
|
41
|
+
cost: z.number().int().positive().optional(),
|
|
42
|
+
assignedWorker: z.string().optional(),
|
|
43
|
+
disconnectPolicy: DisconnectPolicySchema.optional(),
|
|
44
|
+
})
|
|
45
|
+
.openapi('Task');
|
|
46
|
+
export const TaskEventSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
taskId: z.string(),
|
|
50
|
+
index: z.number().int(),
|
|
51
|
+
timestamp: z.number(),
|
|
52
|
+
type: z.string(),
|
|
53
|
+
level: LevelSchema,
|
|
54
|
+
data: z.unknown(),
|
|
55
|
+
seriesId: z.string().optional(),
|
|
56
|
+
seriesMode: SeriesModeSchema.optional(),
|
|
57
|
+
seriesAccField: z.string().optional(),
|
|
58
|
+
})
|
|
59
|
+
.openapi('TaskEvent');
|
|
60
|
+
export const WorkerSchema = z
|
|
61
|
+
.object({
|
|
62
|
+
id: z.string(),
|
|
63
|
+
status: z.enum(['idle', 'busy', 'draining', 'offline']),
|
|
64
|
+
matchRule: z.object({
|
|
65
|
+
taskTypes: z.array(z.string()).optional(),
|
|
66
|
+
tags: z
|
|
67
|
+
.object({
|
|
68
|
+
all: z.array(z.string()).optional(),
|
|
69
|
+
any: z.array(z.string()).optional(),
|
|
70
|
+
none: z.array(z.string()).optional(),
|
|
71
|
+
})
|
|
72
|
+
.optional(),
|
|
73
|
+
}),
|
|
74
|
+
capacity: z.number().int(),
|
|
75
|
+
usedSlots: z.number().int(),
|
|
76
|
+
weight: z.number(),
|
|
77
|
+
connectionMode: z.enum(['pull', 'websocket']),
|
|
78
|
+
connectedAt: z.number(),
|
|
79
|
+
lastHeartbeatAt: z.number(),
|
|
80
|
+
metadata: z.record(z.unknown()).optional(),
|
|
81
|
+
})
|
|
82
|
+
.openapi('Worker');
|
|
83
|
+
export const ErrorSchema = z
|
|
84
|
+
.object({
|
|
85
|
+
error: z.string(),
|
|
86
|
+
})
|
|
87
|
+
.openapi('Error');
|
|
88
|
+
// ─── Request Body Schemas ───────────────────────────────────────────────────
|
|
89
|
+
export const CreateTaskSchema = z
|
|
90
|
+
.object({
|
|
91
|
+
id: z.string().optional(),
|
|
92
|
+
type: z.string().optional(),
|
|
93
|
+
params: z.record(z.unknown()).optional(),
|
|
94
|
+
metadata: z.record(z.unknown()).optional(),
|
|
95
|
+
ttl: z.number().int().positive().optional(),
|
|
96
|
+
webhooks: z.array(z.unknown()).optional(),
|
|
97
|
+
cleanup: z.object({ rules: z.array(z.unknown()) }).optional(),
|
|
98
|
+
tags: z.array(z.string()).optional(),
|
|
99
|
+
assignMode: AssignModeSchema.optional(),
|
|
100
|
+
cost: z.number().int().positive().optional(),
|
|
101
|
+
disconnectPolicy: DisconnectPolicySchema.optional(),
|
|
102
|
+
authConfig: z.record(z.unknown()).optional(),
|
|
103
|
+
})
|
|
104
|
+
.openapi('CreateTaskInput');
|
|
105
|
+
export const TransitionSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
status: TaskStatusSchema,
|
|
108
|
+
result: z.record(z.unknown()).optional(),
|
|
109
|
+
error: z
|
|
110
|
+
.object({
|
|
111
|
+
code: z.string().optional(),
|
|
112
|
+
message: z.string(),
|
|
113
|
+
details: z.record(z.unknown()).optional(),
|
|
114
|
+
})
|
|
115
|
+
.optional(),
|
|
116
|
+
reason: z.string().optional(),
|
|
117
|
+
ttl: z.number().int().positive().optional(),
|
|
118
|
+
resumeAfterMs: z.number().int().positive().optional(),
|
|
119
|
+
blockedRequest: z.object({ type: z.string(), data: z.unknown() }).optional(),
|
|
120
|
+
})
|
|
121
|
+
.openapi('TransitionInput');
|
|
122
|
+
export const PublishEventSchema = z
|
|
123
|
+
.object({
|
|
124
|
+
type: z.string(),
|
|
125
|
+
level: LevelSchema,
|
|
126
|
+
data: z.unknown(),
|
|
127
|
+
seriesId: z.string().optional(),
|
|
128
|
+
seriesMode: SeriesModeSchema.optional(),
|
|
129
|
+
seriesAccField: z.string().optional(),
|
|
130
|
+
})
|
|
131
|
+
.openapi('PublishEventInput');
|
|
132
|
+
export const DeclineSchema = z
|
|
133
|
+
.object({
|
|
134
|
+
workerId: z.string(),
|
|
135
|
+
blacklist: z.boolean().optional(),
|
|
136
|
+
})
|
|
137
|
+
.openapi('DeclineInput');
|
|
138
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAErC,+EAA+E;AAE/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC;IACrC,SAAS;IACT,UAAU;IACV,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;IACX,QAAQ;IACR,SAAS;IACT,WAAW;CACZ,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAA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E;CACtC,CAAC;KACD,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC;KACD,OAAO,CAAC,cAAc,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskcast/server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Hono HTTP server — REST + SSE + auth + webhooks for Taskcast.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
"provenance": true
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@hono/zod-openapi": "^0.19.10",
|
|
32
|
+
"@scalar/hono-api-reference": "^0.10.0",
|
|
31
33
|
"hono": "^4.6.0",
|
|
32
34
|
"jose": "^5.9.0",
|
|
33
35
|
"zod": "^3.23.0",
|
|
34
|
-
"@taskcast/core": "0.3.
|
|
36
|
+
"@taskcast/core": "0.3.1"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@hono/node-server": "^1.19.9",
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"testcontainers": "^10.13.0",
|
|
41
43
|
"typescript": "^5.7.0",
|
|
42
44
|
"vitest": "^2.1.0",
|
|
43
|
-
"@taskcast/redis": "0.3.
|
|
45
|
+
"@taskcast/redis": "0.3.1"
|
|
44
46
|
},
|
|
45
47
|
"scripts": {
|
|
46
48
|
"build": "tsc",
|