@coji/durably 0.11.0 → 0.13.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/{index-fppJjkF-.d.ts → index-DWsJlgyh.d.ts} +149 -66
- package/dist/index.d.ts +11 -5
- package/dist/index.js +1000 -460
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/docs/llms.md +40 -20
- package/package.json +27 -21
- package/LICENSE +0 -21
|
@@ -20,13 +20,23 @@ interface RunTriggerEvent extends BaseEvent {
|
|
|
20
20
|
labels: Record<string, string>;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Run
|
|
23
|
+
* Run leased event
|
|
24
24
|
*/
|
|
25
|
-
interface
|
|
26
|
-
type: 'run:
|
|
25
|
+
interface RunLeasedEvent extends BaseEvent {
|
|
26
|
+
type: 'run:leased';
|
|
27
27
|
runId: string;
|
|
28
28
|
jobName: string;
|
|
29
29
|
input: unknown;
|
|
30
|
+
leaseOwner: string;
|
|
31
|
+
leaseExpiresAt: string;
|
|
32
|
+
labels: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
interface RunLeaseRenewedEvent extends BaseEvent {
|
|
35
|
+
type: 'run:lease-renewed';
|
|
36
|
+
runId: string;
|
|
37
|
+
jobName: string;
|
|
38
|
+
leaseOwner: string;
|
|
39
|
+
leaseExpiresAt: string;
|
|
30
40
|
labels: Record<string, string>;
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
@@ -69,19 +79,10 @@ interface RunDeleteEvent extends BaseEvent {
|
|
|
69
79
|
jobName: string;
|
|
70
80
|
labels: Record<string, string>;
|
|
71
81
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Run retry event (emitted when a failed run is retried)
|
|
74
|
-
*/
|
|
75
|
-
interface RunRetryEvent extends BaseEvent {
|
|
76
|
-
type: 'run:retry';
|
|
77
|
-
runId: string;
|
|
78
|
-
jobName: string;
|
|
79
|
-
labels: Record<string, string>;
|
|
80
|
-
}
|
|
81
82
|
/**
|
|
82
83
|
* Progress data reported by step.progress()
|
|
83
84
|
*/
|
|
84
|
-
interface ProgressData {
|
|
85
|
+
interface ProgressData$1 {
|
|
85
86
|
current: number;
|
|
86
87
|
total?: number;
|
|
87
88
|
message?: string;
|
|
@@ -93,7 +94,7 @@ interface RunProgressEvent extends BaseEvent {
|
|
|
93
94
|
type: 'run:progress';
|
|
94
95
|
runId: string;
|
|
95
96
|
jobName: string;
|
|
96
|
-
progress: ProgressData;
|
|
97
|
+
progress: ProgressData$1;
|
|
97
98
|
labels: Record<string, string>;
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
@@ -172,7 +173,7 @@ interface WorkerErrorEvent extends BaseEvent {
|
|
|
172
173
|
/**
|
|
173
174
|
* All event types as discriminated union
|
|
174
175
|
*/
|
|
175
|
-
type DurablyEvent = RunTriggerEvent |
|
|
176
|
+
type DurablyEvent = RunTriggerEvent | RunLeasedEvent | RunLeaseRenewedEvent | RunCompleteEvent | RunFailEvent | RunCancelEvent | RunDeleteEvent | RunProgressEvent | StepStartEvent | StepCompleteEvent | StepFailEvent | StepCancelEvent | LogWriteEvent | WorkerErrorEvent;
|
|
176
177
|
/**
|
|
177
178
|
* Event types for type-safe event names
|
|
178
179
|
*/
|
|
@@ -190,7 +191,7 @@ type EventInput<T extends EventType> = Omit<EventByType<T>, 'timestamp' | 'seque
|
|
|
190
191
|
/**
|
|
191
192
|
* All possible event inputs as a union (properly distributed)
|
|
192
193
|
*/
|
|
193
|
-
type AnyEventInput = EventInput<'run:trigger'> | EventInput<'run:
|
|
194
|
+
type AnyEventInput = EventInput<'run:trigger'> | EventInput<'run:leased'> | EventInput<'run:lease-renewed'> | EventInput<'run:complete'> | EventInput<'run:fail'> | EventInput<'run:cancel'> | EventInput<'run:delete'> | EventInput<'run:progress'> | EventInput<'step:start'> | EventInput<'step:complete'> | EventInput<'step:fail'> | EventInput<'step:cancel'> | EventInput<'log:write'> | EventInput<'worker:error'>;
|
|
194
195
|
/**
|
|
195
196
|
* Event listener function
|
|
196
197
|
*/
|
|
@@ -211,7 +212,7 @@ interface RunsTable {
|
|
|
211
212
|
id: string;
|
|
212
213
|
job_name: string;
|
|
213
214
|
input: string;
|
|
214
|
-
status: 'pending' | '
|
|
215
|
+
status: 'pending' | 'leased' | 'completed' | 'failed' | 'cancelled';
|
|
215
216
|
idempotency_key: string | null;
|
|
216
217
|
concurrency_key: string | null;
|
|
217
218
|
current_step_index: number;
|
|
@@ -219,7 +220,9 @@ interface RunsTable {
|
|
|
219
220
|
output: string | null;
|
|
220
221
|
error: string | null;
|
|
221
222
|
labels: string;
|
|
222
|
-
|
|
223
|
+
lease_owner: string | null;
|
|
224
|
+
lease_expires_at: string | null;
|
|
225
|
+
lease_generation: number;
|
|
223
226
|
started_at: string | null;
|
|
224
227
|
completed_at: string | null;
|
|
225
228
|
created_at: string;
|
|
@@ -245,17 +248,24 @@ interface LogsTable {
|
|
|
245
248
|
data: string | null;
|
|
246
249
|
created_at: string;
|
|
247
250
|
}
|
|
251
|
+
interface RunLabelsTable {
|
|
252
|
+
run_id: string;
|
|
253
|
+
key: string;
|
|
254
|
+
value: string;
|
|
255
|
+
}
|
|
248
256
|
interface SchemaVersionsTable {
|
|
249
257
|
version: number;
|
|
250
258
|
applied_at: string;
|
|
251
259
|
}
|
|
252
260
|
interface Database {
|
|
253
261
|
durably_runs: RunsTable;
|
|
262
|
+
durably_run_labels: RunLabelsTable;
|
|
254
263
|
durably_steps: StepsTable;
|
|
255
264
|
durably_logs: LogsTable;
|
|
256
265
|
durably_schema_versions: SchemaVersionsTable;
|
|
257
266
|
}
|
|
258
267
|
|
|
268
|
+
type RunStatus = 'pending' | 'leased' | 'completed' | 'failed' | 'cancelled';
|
|
259
269
|
/**
|
|
260
270
|
* Run data for creating a new run
|
|
261
271
|
*/
|
|
@@ -273,7 +283,7 @@ interface Run<TLabels extends Record<string, string> = Record<string, string>> {
|
|
|
273
283
|
id: string;
|
|
274
284
|
jobName: string;
|
|
275
285
|
input: unknown;
|
|
276
|
-
status:
|
|
286
|
+
status: RunStatus;
|
|
277
287
|
idempotencyKey: string | null;
|
|
278
288
|
concurrencyKey: string | null;
|
|
279
289
|
currentStepIndex: number;
|
|
@@ -286,34 +296,19 @@ interface Run<TLabels extends Record<string, string> = Record<string, string>> {
|
|
|
286
296
|
output: unknown | null;
|
|
287
297
|
error: string | null;
|
|
288
298
|
labels: TLabels;
|
|
289
|
-
|
|
299
|
+
leaseOwner: string | null;
|
|
300
|
+
leaseExpiresAt: string | null;
|
|
301
|
+
leaseGeneration: number;
|
|
290
302
|
startedAt: string | null;
|
|
291
303
|
completedAt: string | null;
|
|
292
304
|
createdAt: string;
|
|
293
305
|
updatedAt: string;
|
|
294
306
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Run update data
|
|
297
|
-
*/
|
|
298
|
-
interface UpdateRunInput {
|
|
299
|
-
status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
300
|
-
currentStepIndex?: number;
|
|
301
|
-
progress?: {
|
|
302
|
-
current: number;
|
|
303
|
-
total?: number;
|
|
304
|
-
message?: string;
|
|
305
|
-
} | null;
|
|
306
|
-
output?: unknown;
|
|
307
|
-
error?: string | null;
|
|
308
|
-
heartbeatAt?: string;
|
|
309
|
-
startedAt?: string;
|
|
310
|
-
completedAt?: string;
|
|
311
|
-
}
|
|
312
307
|
/**
|
|
313
308
|
* Run filter options
|
|
314
309
|
*/
|
|
315
310
|
interface RunFilter<TLabels extends Record<string, string> = Record<string, string>> {
|
|
316
|
-
status?:
|
|
311
|
+
status?: RunStatus;
|
|
317
312
|
/** Filter by job name(s). Pass a string for one, or an array for multiple (OR). */
|
|
318
313
|
jobName?: string | string[];
|
|
319
314
|
/** Filter by labels (all specified labels must match) */
|
|
@@ -326,10 +321,9 @@ interface RunFilter<TLabels extends Record<string, string> = Record<string, stri
|
|
|
326
321
|
offset?: number;
|
|
327
322
|
}
|
|
328
323
|
/**
|
|
329
|
-
* Step data for
|
|
324
|
+
* Step data for persisting a step checkpoint
|
|
330
325
|
*/
|
|
331
326
|
interface CreateStepInput {
|
|
332
|
-
runId: string;
|
|
333
327
|
name: string;
|
|
334
328
|
index: number;
|
|
335
329
|
status: 'completed' | 'failed' | 'cancelled';
|
|
@@ -373,32 +367,73 @@ interface Log {
|
|
|
373
367
|
data: unknown | null;
|
|
374
368
|
createdAt: string;
|
|
375
369
|
}
|
|
370
|
+
interface ProgressData {
|
|
371
|
+
current: number;
|
|
372
|
+
total?: number;
|
|
373
|
+
message?: string;
|
|
374
|
+
}
|
|
375
|
+
type DatabaseBackend = 'generic' | 'postgres';
|
|
376
376
|
/**
|
|
377
|
-
*
|
|
378
|
-
* heartbeatAt, idempotencyKey, concurrencyKey, and updatedAt.
|
|
379
|
-
*/
|
|
380
|
-
type ClientRun<TLabels extends Record<string, string> = Record<string, string>> = Omit<Run<TLabels>, 'idempotencyKey' | 'concurrencyKey' | 'heartbeatAt' | 'updatedAt'>;
|
|
381
|
-
/**
|
|
382
|
-
* Project a full Run to a ClientRun by stripping internal fields.
|
|
377
|
+
* Data for updating a run
|
|
383
378
|
*/
|
|
384
|
-
|
|
379
|
+
interface UpdateRunData {
|
|
380
|
+
status?: RunStatus;
|
|
381
|
+
currentStepIndex?: number;
|
|
382
|
+
progress?: ProgressData | null;
|
|
383
|
+
output?: unknown;
|
|
384
|
+
error?: string | null;
|
|
385
|
+
leaseOwner?: string | null;
|
|
386
|
+
leaseExpiresAt?: string | null;
|
|
387
|
+
startedAt?: string;
|
|
388
|
+
completedAt?: string;
|
|
389
|
+
}
|
|
385
390
|
/**
|
|
386
|
-
*
|
|
391
|
+
* Unified storage interface used by the runtime.
|
|
387
392
|
*/
|
|
388
|
-
interface
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
393
|
+
interface Store<TLabels extends Record<string, string> = Record<string, string>> {
|
|
394
|
+
enqueue(input: CreateRunInput<TLabels>): Promise<Run<TLabels>>;
|
|
395
|
+
enqueueMany(inputs: CreateRunInput<TLabels>[]): Promise<Run<TLabels>[]>;
|
|
396
|
+
getRun<T extends Run<TLabels> = Run<TLabels>>(runId: string): Promise<T | null>;
|
|
397
|
+
getRuns<T extends Run<TLabels> = Run<TLabels>>(filter?: RunFilter<TLabels>): Promise<T[]>;
|
|
398
|
+
updateRun(runId: string, data: UpdateRunData): Promise<void>;
|
|
392
399
|
deleteRun(runId: string): Promise<void>;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
400
|
+
claimNext(workerId: string, now: string, leaseMs: number): Promise<Run<TLabels> | null>;
|
|
401
|
+
renewLease(runId: string, leaseGeneration: number, now: string, leaseMs: number): Promise<boolean>;
|
|
402
|
+
releaseExpiredLeases(now: string): Promise<number>;
|
|
403
|
+
completeRun(runId: string, leaseGeneration: number, output: unknown, completedAt: string): Promise<boolean>;
|
|
404
|
+
failRun(runId: string, leaseGeneration: number, error: string, completedAt: string): Promise<boolean>;
|
|
405
|
+
cancelRun(runId: string, now: string): Promise<boolean>;
|
|
406
|
+
/**
|
|
407
|
+
* Atomically persist a step checkpoint, guarded by lease generation.
|
|
408
|
+
* Inserts the step record and advances currentStepIndex (for completed
|
|
409
|
+
* steps only) in a single transaction. Returns null if the generation
|
|
410
|
+
* does not match (lease was lost).
|
|
411
|
+
*/
|
|
412
|
+
persistStep(runId: string, leaseGeneration: number, input: CreateStepInput): Promise<Step | null>;
|
|
397
413
|
getSteps(runId: string): Promise<Step[]>;
|
|
398
414
|
getCompletedStep(runId: string, name: string): Promise<Step | null>;
|
|
415
|
+
deleteSteps(runId: string): Promise<void>;
|
|
416
|
+
updateProgress(runId: string, leaseGeneration: number, progress: ProgressData | null): Promise<void>;
|
|
417
|
+
purgeRuns(options: {
|
|
418
|
+
olderThan: string;
|
|
419
|
+
limit?: number;
|
|
420
|
+
}): Promise<number>;
|
|
399
421
|
createLog(input: CreateLogInput): Promise<Log>;
|
|
400
422
|
getLogs(runId: string): Promise<Log[]>;
|
|
401
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* A client-safe subset of Run, excluding internal fields like
|
|
426
|
+
* leaseOwner, leaseExpiresAt, idempotencyKey, concurrencyKey, and updatedAt.
|
|
427
|
+
*/
|
|
428
|
+
type ClientRun<TLabels extends Record<string, string> = Record<string, string>> = Omit<Run<TLabels>, 'idempotencyKey' | 'concurrencyKey' | 'leaseOwner' | 'leaseExpiresAt' | 'leaseGeneration' | 'updatedAt'>;
|
|
429
|
+
/**
|
|
430
|
+
* Project a full Run to a ClientRun by stripping internal fields.
|
|
431
|
+
*/
|
|
432
|
+
declare function toClientRun<TLabels extends Record<string, string> = Record<string, string>>(run: Run<TLabels>): ClientRun<TLabels>;
|
|
433
|
+
/**
|
|
434
|
+
* Create a Kysely-based Store implementation
|
|
435
|
+
*/
|
|
436
|
+
declare function createKyselyStore(db: Kysely<Database>, backend?: DatabaseBackend): Store<Record<string, string>>;
|
|
402
437
|
|
|
403
438
|
/**
|
|
404
439
|
* Step context passed to the job function
|
|
@@ -408,6 +443,18 @@ interface StepContext {
|
|
|
408
443
|
* The ID of the current run
|
|
409
444
|
*/
|
|
410
445
|
readonly runId: string;
|
|
446
|
+
/**
|
|
447
|
+
* AbortSignal for cooperative cancellation or lease-loss handling.
|
|
448
|
+
*/
|
|
449
|
+
readonly signal: AbortSignal;
|
|
450
|
+
/**
|
|
451
|
+
* Whether this execution should stop cooperatively.
|
|
452
|
+
*/
|
|
453
|
+
isAborted(): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Throw if execution has been cancelled or lease ownership was lost.
|
|
456
|
+
*/
|
|
457
|
+
throwIfAborted(): void;
|
|
411
458
|
/**
|
|
412
459
|
* Execute a step with automatic persistence and replay
|
|
413
460
|
*/
|
|
@@ -440,7 +487,7 @@ interface TriggerAndWaitOptions<TLabels extends Record<string, string> = Record<
|
|
|
440
487
|
/** Timeout in milliseconds */
|
|
441
488
|
timeout?: number;
|
|
442
489
|
/** Called when step.progress() is invoked during execution */
|
|
443
|
-
onProgress?: (progress: ProgressData) => void | Promise<void>;
|
|
490
|
+
onProgress?: (progress: ProgressData$1) => void | Promise<void>;
|
|
444
491
|
/** Called when step.log is invoked during execution */
|
|
445
492
|
onLog?: (log: LogData) => void | Promise<void>;
|
|
446
493
|
}
|
|
@@ -558,9 +605,15 @@ declare function defineJob<TName extends string, TInputSchema extends z.ZodType,
|
|
|
558
605
|
*/
|
|
559
606
|
interface DurablyOptions<TLabels extends Record<string, string> = Record<string, string>, TJobs extends Record<string, JobDefinition<string, any, any>> = Record<string, never>> {
|
|
560
607
|
dialect: Dialect;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
608
|
+
/**
|
|
609
|
+
* Browser-local singleton key used to detect multiple runtimes against the same local database in one tab.
|
|
610
|
+
* When omitted, Durably will use browser-local dialect metadata if available.
|
|
611
|
+
*/
|
|
612
|
+
singletonKey?: string;
|
|
613
|
+
pollingIntervalMs?: number;
|
|
614
|
+
leaseRenewIntervalMs?: number;
|
|
615
|
+
leaseMs?: number;
|
|
616
|
+
preserveSteps?: boolean;
|
|
564
617
|
/**
|
|
565
618
|
* Zod schema for labels. When provided:
|
|
566
619
|
* - Labels are type-checked at compile time
|
|
@@ -578,6 +631,12 @@ interface DurablyOptions<TLabels extends Record<string, string> = Record<string,
|
|
|
578
631
|
* ```
|
|
579
632
|
*/
|
|
580
633
|
jobs?: TJobs;
|
|
634
|
+
/**
|
|
635
|
+
* Auto-delete terminal runs older than the specified duration.
|
|
636
|
+
* Only runs in terminal states (completed, failed, cancelled) are purged.
|
|
637
|
+
* @example '30d' (30 days), '24h' (24 hours), '60m' (60 minutes)
|
|
638
|
+
*/
|
|
639
|
+
retainRuns?: string;
|
|
581
640
|
}
|
|
582
641
|
/**
|
|
583
642
|
* Plugin interface for extending Durably
|
|
@@ -624,7 +683,7 @@ interface Durably<TJobs extends Record<string, JobHandle<string, unknown, unknow
|
|
|
624
683
|
/**
|
|
625
684
|
* Storage layer for database operations
|
|
626
685
|
*/
|
|
627
|
-
readonly storage:
|
|
686
|
+
readonly storage: Store<TLabels>;
|
|
628
687
|
/**
|
|
629
688
|
* Register an event listener
|
|
630
689
|
* @returns Unsubscribe function
|
|
@@ -652,19 +711,34 @@ interface Durably<TJobs extends Record<string, JobHandle<string, unknown, unknow
|
|
|
652
711
|
* ```
|
|
653
712
|
*/
|
|
654
713
|
register<TNewJobs extends Record<string, JobDefinition<string, any, any>>>(jobDefs: TNewJobs): Durably<TJobs & TransformToHandles<TNewJobs, TLabels>, TLabels>;
|
|
714
|
+
/**
|
|
715
|
+
* Process a single claimable run.
|
|
716
|
+
*/
|
|
717
|
+
processOne(options?: {
|
|
718
|
+
workerId?: string;
|
|
719
|
+
}): Promise<boolean>;
|
|
720
|
+
/**
|
|
721
|
+
* Process runs until the queue appears idle.
|
|
722
|
+
*/
|
|
723
|
+
processUntilIdle(options?: {
|
|
724
|
+
workerId?: string;
|
|
725
|
+
maxRuns?: number;
|
|
726
|
+
}): Promise<number>;
|
|
655
727
|
/**
|
|
656
728
|
* Start the worker polling loop
|
|
657
729
|
*/
|
|
658
|
-
start(
|
|
730
|
+
start(options?: {
|
|
731
|
+
workerId?: string;
|
|
732
|
+
}): void;
|
|
659
733
|
/**
|
|
660
734
|
* Stop the worker after current run completes
|
|
661
735
|
*/
|
|
662
736
|
stop(): Promise<void>;
|
|
663
737
|
/**
|
|
664
|
-
*
|
|
665
|
-
* @throws Error if run is
|
|
738
|
+
* Create a fresh run from a completed, failed, or cancelled run
|
|
739
|
+
* @throws Error if run is pending, running, or does not exist
|
|
666
740
|
*/
|
|
667
|
-
|
|
741
|
+
retrigger(runId: string): Promise<Run<TLabels>>;
|
|
668
742
|
/**
|
|
669
743
|
* Cancel a pending or running run
|
|
670
744
|
* @throws Error if run is already completed, failed, or cancelled
|
|
@@ -675,6 +749,15 @@ interface Durably<TJobs extends Record<string, JobHandle<string, unknown, unknow
|
|
|
675
749
|
* @throws Error if run is pending or running, or does not exist
|
|
676
750
|
*/
|
|
677
751
|
deleteRun(runId: string): Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Delete terminal runs older than the specified cutoff.
|
|
754
|
+
* Only runs in terminal states (completed, failed, cancelled) are purged.
|
|
755
|
+
* @returns Number of deleted runs
|
|
756
|
+
*/
|
|
757
|
+
purgeRuns(options: {
|
|
758
|
+
olderThan: Date;
|
|
759
|
+
limit?: number;
|
|
760
|
+
}): Promise<number>;
|
|
678
761
|
/**
|
|
679
762
|
* Get a run by ID
|
|
680
763
|
* @example
|
|
@@ -729,4 +812,4 @@ declare function createDurably<TLabels extends Record<string, string> = Record<s
|
|
|
729
812
|
*/
|
|
730
813
|
declare function withLogPersistence(): DurablyPlugin;
|
|
731
814
|
|
|
732
|
-
export { type
|
|
815
|
+
export { type StepFailEvent as A, type BatchTriggerInput as B, type ClientRun as C, type Durably as D, type ErrorHandler as E, type StepStartEvent as F, type StepsTable as G, type Store as H, type TriggerAndWaitResult as I, type JobDefinition as J, type TriggerOptions as K, type Log as L, createDurably as M, createKyselyStore as N, defineJob as O, type ProgressData$1 as P, toClientRun as Q, type Run as R, type SchemaVersionsTable as S, type TriggerAndWaitOptions as T, type UpdateRunData as U, withLogPersistence as V, type WorkerErrorEvent as W, type RunFilter as a, type Database as b, type DurablyEvent as c, type DurablyOptions as d, type DurablyPlugin as e, type EventType as f, type JobHandle as g, type JobInput as h, type JobOutput as i, type LogData as j, type LogWriteEvent as k, type LogsTable as l, type RunCancelEvent as m, type RunCompleteEvent as n, type RunDeleteEvent as o, type RunFailEvent as p, type RunLeaseRenewedEvent as q, type RunLeasedEvent as r, type RunProgressEvent as s, type RunStatus as t, type RunTriggerEvent as u, type RunsTable as v, type Step as w, type StepCancelEvent as x, type StepCompleteEvent as y, type StepContext as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Run, a as RunFilter, D as Durably } from './index-
|
|
2
|
-
export { B as BatchTriggerInput, C as ClientRun, b as Database, c as DurablyEvent, d as DurablyOptions, e as DurablyPlugin, E as ErrorHandler, f as EventType, J as JobDefinition, g as JobHandle, h as JobInput, i as JobOutput, L as Log, j as LogData, k as LogWriteEvent, l as LogsTable, P as ProgressData, m as RunCancelEvent, n as RunCompleteEvent, o as RunDeleteEvent, p as RunFailEvent, q as
|
|
1
|
+
import { R as Run, a as RunFilter, D as Durably } from './index-DWsJlgyh.js';
|
|
2
|
+
export { B as BatchTriggerInput, C as ClientRun, b as Database, c as DurablyEvent, d as DurablyOptions, e as DurablyPlugin, E as ErrorHandler, f as EventType, J as JobDefinition, g as JobHandle, h as JobInput, i as JobOutput, L as Log, j as LogData, k as LogWriteEvent, l as LogsTable, P as ProgressData, m as RunCancelEvent, n as RunCompleteEvent, o as RunDeleteEvent, p as RunFailEvent, q as RunLeaseRenewedEvent, r as RunLeasedEvent, s as RunProgressEvent, t as RunStatus, u as RunTriggerEvent, v as RunsTable, S as SchemaVersionsTable, w as Step, x as StepCancelEvent, y as StepCompleteEvent, z as StepContext, A as StepFailEvent, F as StepStartEvent, G as StepsTable, H as Store, T as TriggerAndWaitOptions, I as TriggerAndWaitResult, K as TriggerOptions, U as UpdateRunData, W as WorkerErrorEvent, M as createDurably, N as createKyselyStore, O as defineJob, Q as toClientRun, V as withLogPersistence } from './index-DWsJlgyh.js';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
@@ -11,11 +11,17 @@ import 'zod';
|
|
|
11
11
|
declare class CancelledError extends Error {
|
|
12
12
|
constructor(runId: string);
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when a worker loses lease ownership during execution.
|
|
16
|
+
*/
|
|
17
|
+
declare class LeaseLostError extends Error {
|
|
18
|
+
constructor(runId: string);
|
|
19
|
+
}
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* Run operation types for onRunAccess
|
|
17
23
|
*/
|
|
18
|
-
type RunOperation = 'read' | 'subscribe' | 'steps' | '
|
|
24
|
+
type RunOperation = 'read' | 'subscribe' | 'steps' | 'retrigger' | 'cancel' | 'delete';
|
|
19
25
|
/**
|
|
20
26
|
* Subscription filter — only fields that SSE subscriptions actually support.
|
|
21
27
|
*/
|
|
@@ -70,7 +76,7 @@ interface DurablyHandler {
|
|
|
70
76
|
* - GET {basePath}/run?runId=xxx - Get single run
|
|
71
77
|
* - GET {basePath}/steps?runId=xxx - Get steps
|
|
72
78
|
* - POST {basePath}/trigger - Trigger a job
|
|
73
|
-
* - POST {basePath}/
|
|
79
|
+
* - POST {basePath}/retrigger?runId=xxx - Create a fresh run from a terminal run
|
|
74
80
|
* - POST {basePath}/cancel?runId=xxx - Cancel a run
|
|
75
81
|
* - DELETE {basePath}/run?runId=xxx - Delete a run
|
|
76
82
|
*/
|
|
@@ -101,4 +107,4 @@ interface CreateDurablyHandlerOptions<TContext = undefined, TLabels extends Reco
|
|
|
101
107
|
*/
|
|
102
108
|
declare function createDurablyHandler<TContext = undefined, TLabels extends Record<string, string> = Record<string, string>>(durably: Durably<any, TLabels>, options?: CreateDurablyHandlerOptions<TContext, TLabels>): DurablyHandler;
|
|
103
109
|
|
|
104
|
-
export { type AuthConfig, CancelledError, type CreateDurablyHandlerOptions, Durably, type DurablyHandler, Run, RunFilter, type RunOperation, type RunsSubscribeFilter, type TriggerRequest, type TriggerResponse, createDurablyHandler };
|
|
110
|
+
export { type AuthConfig, CancelledError, type CreateDurablyHandlerOptions, Durably, type DurablyHandler, LeaseLostError, Run, RunFilter, type RunOperation, type RunsSubscribeFilter, type TriggerRequest, type TriggerResponse, createDurablyHandler };
|