duron 0.3.0-beta.8 → 0.3.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.
- package/dist/action-job.d.ts +33 -2
- package/dist/action-job.d.ts.map +1 -1
- package/dist/action-job.js +93 -26
- package/dist/action-manager.d.ts +44 -2
- package/dist/action-manager.d.ts.map +1 -1
- package/dist/action-manager.js +64 -3
- package/dist/action.d.ts +388 -7
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +44 -23
- package/dist/adapters/adapter.d.ts +365 -8
- package/dist/adapters/adapter.d.ts.map +1 -1
- package/dist/adapters/adapter.js +221 -15
- package/dist/adapters/postgres/base.d.ts +184 -6
- package/dist/adapters/postgres/base.d.ts.map +1 -1
- package/dist/adapters/postgres/base.js +436 -75
- package/dist/adapters/postgres/pglite.d.ts +37 -0
- package/dist/adapters/postgres/pglite.d.ts.map +1 -1
- package/dist/adapters/postgres/pglite.js +38 -0
- package/dist/adapters/postgres/postgres.d.ts +35 -0
- package/dist/adapters/postgres/postgres.d.ts.map +1 -1
- package/dist/adapters/postgres/postgres.js +42 -0
- package/dist/adapters/postgres/schema.d.ts +150 -37
- package/dist/adapters/postgres/schema.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.d.ts +151 -38
- package/dist/adapters/postgres/schema.default.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.js +2 -2
- package/dist/adapters/postgres/schema.js +60 -23
- package/dist/adapters/schemas.d.ts +124 -80
- package/dist/adapters/schemas.d.ts.map +1 -1
- package/dist/adapters/schemas.js +139 -26
- package/dist/client.d.ts +426 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +370 -20
- package/dist/constants.js +6 -0
- package/dist/errors.d.ts +166 -9
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +189 -19
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/server.d.ts +99 -37
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +84 -25
- package/dist/step-manager.d.ts +111 -4
- package/dist/step-manager.d.ts.map +1 -1
- package/dist/step-manager.js +411 -75
- package/dist/telemetry/index.d.ts +1 -4
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -4
- package/dist/telemetry/local-span-exporter.d.ts +56 -0
- package/dist/telemetry/local-span-exporter.d.ts.map +1 -0
- package/dist/telemetry/local-span-exporter.js +118 -0
- package/dist/utils/p-retry.d.ts +5 -0
- package/dist/utils/p-retry.d.ts.map +1 -1
- package/dist/utils/p-retry.js +8 -0
- package/dist/utils/wait-for-abort.d.ts +1 -0
- package/dist/utils/wait-for-abort.d.ts.map +1 -1
- package/dist/utils/wait-for-abort.js +1 -0
- package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260121160012_normal_bloodstrike}/migration.sql +32 -20
- package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260121160012_normal_bloodstrike}/snapshot.json +241 -66
- package/package.json +42 -26
- package/src/action-job.ts +43 -32
- package/src/action-manager.ts +5 -5
- package/src/action.ts +317 -149
- package/src/adapters/adapter.ts +54 -54
- package/src/adapters/postgres/base.ts +266 -86
- package/src/adapters/postgres/schema.default.ts +2 -2
- package/src/adapters/postgres/schema.ts +52 -24
- package/src/adapters/schemas.ts +91 -36
- package/src/client.ts +322 -68
- package/src/errors.ts +141 -30
- package/src/index.ts +2 -0
- package/src/server.ts +39 -37
- package/src/step-manager.ts +254 -91
- package/src/telemetry/index.ts +2 -20
- package/src/telemetry/local-span-exporter.ts +148 -0
- package/dist/telemetry/adapter.d.ts +0 -107
- package/dist/telemetry/adapter.d.ts.map +0 -1
- package/dist/telemetry/adapter.js +0 -134
- package/dist/telemetry/local.d.ts +0 -22
- package/dist/telemetry/local.d.ts.map +0 -1
- package/dist/telemetry/local.js +0 -243
- package/dist/telemetry/noop.d.ts +0 -17
- package/dist/telemetry/noop.d.ts.map +0 -1
- package/dist/telemetry/noop.js +0 -66
- package/dist/telemetry/opentelemetry.d.ts +0 -25
- package/dist/telemetry/opentelemetry.d.ts.map +0 -1
- package/dist/telemetry/opentelemetry.js +0 -312
- package/src/telemetry/adapter.ts +0 -642
- package/src/telemetry/local.ts +0 -429
- package/src/telemetry/noop.ts +0 -141
- package/src/telemetry/opentelemetry.ts +0 -453
package/dist/adapters/schemas.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { JOB_STATUSES, STEP_STATUSES } from '../constants.js';
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Status Enums
|
|
5
|
+
// ============================================================================
|
|
3
6
|
export const JobStatusSchema = z.enum(JOB_STATUSES);
|
|
4
7
|
export const StepStatusSchema = z.enum(STEP_STATUSES);
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Date Schema
|
|
10
|
+
// ============================================================================
|
|
5
11
|
const DateSchema = z.union([
|
|
6
12
|
z.date(),
|
|
7
13
|
z.string().transform((str) => new Date(str)),
|
|
@@ -13,10 +19,14 @@ export const SerializableErrorSchema = z.object({
|
|
|
13
19
|
cause: z.any().optional(),
|
|
14
20
|
stack: z.string().optional(),
|
|
15
21
|
});
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Job Schema
|
|
24
|
+
// ============================================================================
|
|
16
25
|
export const JobSchema = z.object({
|
|
17
26
|
id: z.string(),
|
|
18
27
|
actionName: z.string(),
|
|
19
28
|
groupKey: z.string(),
|
|
29
|
+
description: z.string().nullable().default(null),
|
|
20
30
|
input: z.any(),
|
|
21
31
|
output: z.any().nullable(),
|
|
22
32
|
error: z.any().nullable(),
|
|
@@ -28,8 +38,14 @@ export const JobSchema = z.object({
|
|
|
28
38
|
createdAt: DateSchema,
|
|
29
39
|
updatedAt: DateSchema,
|
|
30
40
|
concurrencyLimit: z.coerce.number(),
|
|
41
|
+
concurrencyStepLimit: z.coerce.number(),
|
|
31
42
|
clientId: z.string().nullable().optional(),
|
|
43
|
+
/** Duration in milliseconds (finishedAt - startedAt). Null if job hasn't finished. */
|
|
44
|
+
durationMs: z.coerce.number().nullable().default(null),
|
|
32
45
|
});
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// JobStep Schema
|
|
48
|
+
// ============================================================================
|
|
33
49
|
export const JobStepSchema = z.object({
|
|
34
50
|
id: z.string(),
|
|
35
51
|
jobId: z.string(),
|
|
@@ -50,9 +66,22 @@ export const JobStepSchema = z.object({
|
|
|
50
66
|
createdAt: DateSchema,
|
|
51
67
|
updatedAt: DateSchema,
|
|
52
68
|
});
|
|
69
|
+
// JobStep without output (for getJobSteps)
|
|
53
70
|
export const JobStepWithoutOutputSchema = JobStepSchema.omit({ output: true });
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// Query Option Schemas
|
|
73
|
+
// ============================================================================
|
|
54
74
|
export const SortOrderSchema = z.enum(['asc', 'desc']);
|
|
55
|
-
export const JobSortFieldSchema = z.enum([
|
|
75
|
+
export const JobSortFieldSchema = z.enum([
|
|
76
|
+
'createdAt',
|
|
77
|
+
'startedAt',
|
|
78
|
+
'finishedAt',
|
|
79
|
+
'status',
|
|
80
|
+
'actionName',
|
|
81
|
+
'expiresAt',
|
|
82
|
+
'duration',
|
|
83
|
+
'description',
|
|
84
|
+
]);
|
|
56
85
|
export const JobSortSchema = z.object({
|
|
57
86
|
field: JobSortFieldSchema,
|
|
58
87
|
order: SortOrderSchema,
|
|
@@ -62,6 +91,7 @@ export const JobFiltersSchema = z.object({
|
|
|
62
91
|
actionName: z.union([z.string(), z.array(z.string())]).optional(),
|
|
63
92
|
groupKey: z.union([z.string(), z.array(z.string())]).optional(),
|
|
64
93
|
clientId: z.union([z.string(), z.array(z.string())]).optional(),
|
|
94
|
+
description: z.string().optional(),
|
|
65
95
|
createdAt: z.union([DateSchema, z.array(DateSchema).length(2)]).optional(),
|
|
66
96
|
startedAt: z.union([DateSchema, z.array(DateSchema).length(2)]).optional(),
|
|
67
97
|
finishedAt: z.union([DateSchema, z.array(DateSchema).length(2)]).optional(),
|
|
@@ -81,66 +111,109 @@ export const GetJobStepsOptionsSchema = z.object({
|
|
|
81
111
|
search: z.string().optional(),
|
|
82
112
|
updatedAfter: DateSchema.optional(),
|
|
83
113
|
});
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Job Option Schemas
|
|
116
|
+
// ============================================================================
|
|
84
117
|
export const CreateJobOptionsSchema = z.object({
|
|
118
|
+
/** The queue name (action name) */
|
|
85
119
|
queue: z.string(),
|
|
120
|
+
/** The group key for concurrency control */
|
|
86
121
|
groupKey: z.string(),
|
|
122
|
+
/** The checksum of the action */
|
|
87
123
|
checksum: z.string(),
|
|
124
|
+
/** The job input data */
|
|
88
125
|
input: z.any(),
|
|
126
|
+
/** Timeout in milliseconds for the job */
|
|
89
127
|
timeoutMs: z.number(),
|
|
128
|
+
/** The concurrency limit for this job's group */
|
|
90
129
|
concurrencyLimit: z.number(),
|
|
130
|
+
/** The concurrency limit for steps within this job */
|
|
131
|
+
concurrencyStepLimit: z.number(),
|
|
132
|
+
/** Optional description for the job */
|
|
133
|
+
description: z.string().nullable().optional(),
|
|
91
134
|
});
|
|
92
135
|
export const RecoverJobsOptionsSchema = z.object({
|
|
136
|
+
/** The action checksums to recover jobs for */
|
|
93
137
|
checksums: z.array(z.string()),
|
|
138
|
+
/** Whether to ping other processes before recovering their jobs */
|
|
94
139
|
multiProcessMode: z.boolean().optional(),
|
|
140
|
+
/** Timeout in milliseconds to wait for process ping responses */
|
|
95
141
|
processTimeout: z.number().optional(),
|
|
96
142
|
});
|
|
97
143
|
export const FetchOptionsSchema = z.object({
|
|
144
|
+
/** Maximum number of jobs to fetch in this batch */
|
|
98
145
|
batch: z.number(),
|
|
99
146
|
});
|
|
100
147
|
export const CompleteJobOptionsSchema = z.object({
|
|
148
|
+
/** The ID of the job to complete */
|
|
101
149
|
jobId: z.string(),
|
|
150
|
+
/** The job output data */
|
|
102
151
|
output: z.any(),
|
|
103
152
|
});
|
|
104
153
|
export const FailJobOptionsSchema = z.object({
|
|
154
|
+
/** The ID of the job to fail */
|
|
105
155
|
jobId: z.string(),
|
|
156
|
+
/** The error data */
|
|
106
157
|
error: z.any(),
|
|
107
158
|
});
|
|
108
159
|
export const CancelJobOptionsSchema = z.object({
|
|
160
|
+
/** The ID of the job to cancel */
|
|
109
161
|
jobId: z.string(),
|
|
110
162
|
});
|
|
111
163
|
export const RetryJobOptionsSchema = z.object({
|
|
164
|
+
/** The ID of the job to retry */
|
|
112
165
|
jobId: z.string(),
|
|
113
166
|
});
|
|
114
167
|
export const DeleteJobOptionsSchema = z.object({
|
|
168
|
+
/** The ID of the job to delete */
|
|
115
169
|
jobId: z.string(),
|
|
116
170
|
});
|
|
117
171
|
export const DeleteJobsOptionsSchema = GetJobsOptionsSchema.optional();
|
|
118
172
|
export const TimeTravelJobOptionsSchema = z.object({
|
|
173
|
+
/** The ID of the job to time travel */
|
|
119
174
|
jobId: z.string(),
|
|
175
|
+
/** The ID of the step to restart from */
|
|
120
176
|
stepId: z.string(),
|
|
121
177
|
});
|
|
178
|
+
// ============================================================================
|
|
179
|
+
// Step Option Schemas
|
|
180
|
+
// ============================================================================
|
|
122
181
|
export const CreateOrRecoverJobStepOptionsSchema = z.object({
|
|
182
|
+
/** The ID of the job this step belongs to */
|
|
123
183
|
jobId: z.string(),
|
|
184
|
+
/** The ID of the parent step (null for root steps) */
|
|
124
185
|
parentStepId: z.string().nullable().default(null),
|
|
186
|
+
/** Whether this step runs in parallel (independent from siblings during time travel) */
|
|
125
187
|
parallel: z.boolean().default(false),
|
|
188
|
+
/** The name of the step */
|
|
126
189
|
name: z.string(),
|
|
190
|
+
/** Timeout in milliseconds for the step */
|
|
127
191
|
timeoutMs: z.number(),
|
|
192
|
+
/** Maximum number of retries for the step */
|
|
128
193
|
retriesLimit: z.number(),
|
|
129
194
|
});
|
|
130
195
|
export const CompleteJobStepOptionsSchema = z.object({
|
|
196
|
+
/** The ID of the step to complete */
|
|
131
197
|
stepId: z.string(),
|
|
198
|
+
/** The step output data */
|
|
132
199
|
output: z.any(),
|
|
133
200
|
});
|
|
134
201
|
export const FailJobStepOptionsSchema = z.object({
|
|
202
|
+
/** The ID of the step to fail */
|
|
135
203
|
stepId: z.string(),
|
|
204
|
+
/** The error data */
|
|
136
205
|
error: z.any(),
|
|
137
206
|
});
|
|
138
207
|
export const DelayJobStepOptionsSchema = z.object({
|
|
208
|
+
/** The ID of the step to delay */
|
|
139
209
|
stepId: z.string(),
|
|
210
|
+
/** The delay in milliseconds */
|
|
140
211
|
delayMs: z.number(),
|
|
212
|
+
/** The error data */
|
|
141
213
|
error: z.any(),
|
|
142
214
|
});
|
|
143
215
|
export const CancelJobStepOptionsSchema = z.object({
|
|
216
|
+
/** The ID of the step to cancel */
|
|
144
217
|
stepId: z.string(),
|
|
145
218
|
});
|
|
146
219
|
export const CreateOrRecoverJobStepResultSchema = z.object({
|
|
@@ -153,6 +226,10 @@ export const CreateOrRecoverJobStepResultSchema = z.object({
|
|
|
153
226
|
output: z.any().nullable(),
|
|
154
227
|
isNew: z.boolean(),
|
|
155
228
|
});
|
|
229
|
+
// ============================================================================
|
|
230
|
+
// Response Schemas
|
|
231
|
+
// ============================================================================
|
|
232
|
+
// Simple response schemas
|
|
156
233
|
export const JobIdResultSchema = z.union([z.string(), z.null()]);
|
|
157
234
|
export const BooleanResultSchema = z.boolean();
|
|
158
235
|
export const NumberResultSchema = z.number();
|
|
@@ -187,47 +264,83 @@ export const JobStepStatusResultSchema = z.object({
|
|
|
187
264
|
status: StepStatusSchema,
|
|
188
265
|
updatedAt: DateSchema,
|
|
189
266
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
267
|
+
// ============================================================================
|
|
268
|
+
// Span Schemas (OpenTelemetry compatible)
|
|
269
|
+
// ============================================================================
|
|
270
|
+
/**
|
|
271
|
+
* SpanKind values (OpenTelemetry standard):
|
|
272
|
+
* 0 = INTERNAL - Default, internal operation
|
|
273
|
+
* 1 = SERVER - Server-side handling of RPC/HTTP request
|
|
274
|
+
* 2 = CLIENT - Client-side of RPC/HTTP request
|
|
275
|
+
* 3 = PRODUCER - Producer of async message
|
|
276
|
+
* 4 = CONSUMER - Consumer of async message
|
|
277
|
+
*/
|
|
278
|
+
export const SpanKindSchema = z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4)]);
|
|
279
|
+
/**
|
|
280
|
+
* SpanStatusCode values (OpenTelemetry standard):
|
|
281
|
+
* 0 = UNSET - Status not set
|
|
282
|
+
* 1 = OK - Operation completed successfully
|
|
283
|
+
* 2 = ERROR - Operation failed
|
|
284
|
+
*/
|
|
285
|
+
export const SpanStatusCodeSchema = z.union([z.literal(0), z.literal(1), z.literal(2)]);
|
|
286
|
+
export const SpanEventSchema = z.object({
|
|
287
|
+
name: z.string(),
|
|
288
|
+
timeUnixNano: z.string(),
|
|
289
|
+
attributes: z.record(z.string(), z.any()).optional(),
|
|
290
|
+
});
|
|
291
|
+
export const SpanSchema = z.object({
|
|
292
|
+
id: z.number(),
|
|
293
|
+
traceId: z.string(),
|
|
294
|
+
spanId: z.string(),
|
|
295
|
+
parentSpanId: z.string().nullable(),
|
|
296
|
+
jobId: z.string().nullable(),
|
|
194
297
|
stepId: z.string().nullable(),
|
|
195
298
|
name: z.string(),
|
|
196
|
-
|
|
299
|
+
kind: SpanKindSchema,
|
|
300
|
+
startTimeUnixNano: z.string().nullable(), // Stored as bigint but serialized as string for JSON
|
|
301
|
+
endTimeUnixNano: z.string().nullable(), // Stored as bigint but serialized as string for JSON
|
|
302
|
+
statusCode: SpanStatusCodeSchema,
|
|
303
|
+
statusMessage: z.string().nullable(),
|
|
197
304
|
attributes: z.record(z.string(), z.any()),
|
|
198
|
-
|
|
199
|
-
timestamp: DateSchema,
|
|
200
|
-
createdAt: DateSchema,
|
|
305
|
+
events: z.array(SpanEventSchema),
|
|
201
306
|
});
|
|
202
|
-
export const
|
|
203
|
-
export const
|
|
204
|
-
field:
|
|
307
|
+
export const SpanSortFieldSchema = z.enum(['name', 'startTimeUnixNano', 'endTimeUnixNano']);
|
|
308
|
+
export const SpanSortSchema = z.object({
|
|
309
|
+
field: SpanSortFieldSchema,
|
|
205
310
|
order: SortOrderSchema,
|
|
206
311
|
});
|
|
207
|
-
export const
|
|
312
|
+
export const SpanFiltersSchema = z.object({
|
|
208
313
|
name: z.union([z.string(), z.array(z.string())]).optional(),
|
|
209
|
-
|
|
314
|
+
kind: z.union([SpanKindSchema, z.array(SpanKindSchema)]).optional(),
|
|
315
|
+
statusCode: z.union([SpanStatusCodeSchema, z.array(SpanStatusCodeSchema)]).optional(),
|
|
316
|
+
traceId: z.string().optional(),
|
|
210
317
|
attributesFilter: z.record(z.string(), z.any()).optional(),
|
|
211
|
-
timestampRange: z.array(DateSchema).length(2).optional(),
|
|
212
318
|
});
|
|
213
|
-
export const
|
|
214
|
-
|
|
215
|
-
|
|
319
|
+
export const InsertSpanOptionsSchema = z.object({
|
|
320
|
+
traceId: z.string(),
|
|
321
|
+
spanId: z.string(),
|
|
322
|
+
parentSpanId: z.string().nullable(),
|
|
323
|
+
jobId: z.string().nullable(),
|
|
324
|
+
stepId: z.string().nullable(),
|
|
216
325
|
name: z.string(),
|
|
217
|
-
|
|
326
|
+
kind: SpanKindSchema,
|
|
327
|
+
startTimeUnixNano: z.bigint(),
|
|
328
|
+
endTimeUnixNano: z.bigint().nullable(),
|
|
329
|
+
statusCode: SpanStatusCodeSchema,
|
|
330
|
+
statusMessage: z.string().nullable(),
|
|
218
331
|
attributes: z.record(z.string(), z.any()).optional(),
|
|
219
|
-
|
|
332
|
+
events: z.array(SpanEventSchema).optional(),
|
|
220
333
|
});
|
|
221
|
-
export const
|
|
334
|
+
export const GetSpansOptionsSchema = z.object({
|
|
222
335
|
jobId: z.string().optional(),
|
|
223
336
|
stepId: z.string().optional(),
|
|
224
|
-
filters:
|
|
225
|
-
sort:
|
|
337
|
+
filters: SpanFiltersSchema.optional(),
|
|
338
|
+
sort: SpanSortSchema.optional(),
|
|
226
339
|
});
|
|
227
|
-
export const
|
|
228
|
-
|
|
340
|
+
export const GetSpansResultSchema = z.object({
|
|
341
|
+
spans: z.array(SpanSchema),
|
|
229
342
|
total: z.number().int().nonnegative(),
|
|
230
343
|
});
|
|
231
|
-
export const
|
|
344
|
+
export const DeleteSpansOptionsSchema = z.object({
|
|
232
345
|
jobId: z.string(),
|
|
233
346
|
});
|