@coji/durably 0.13.0 → 0.15.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/README.md +7 -3
- package/dist/{chunk-UCUP6NMJ.js → chunk-L42OCQEV.js} +3 -3
- package/dist/chunk-L42OCQEV.js.map +1 -0
- package/dist/{index-DWsJlgyh.d.ts → index-CXH4ozmK.d.ts} +104 -18
- package/dist/index.d.ts +26 -4
- package/dist/index.js +1250 -764
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/docs/llms.md +149 -17
- package/package.json +5 -5
- package/dist/chunk-UCUP6NMJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @coji/durably
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Steps that survive crashes. SQLite to PostgreSQL.
|
|
4
4
|
|
|
5
5
|
**[Documentation](https://coji.github.io/durably/)** | **[GitHub](https://github.com/coji/durably)** | **[Live Demo](https://durably-demo.vercel.app)**
|
|
6
6
|
|
|
@@ -9,10 +9,14 @@ Step-oriented resumable batch execution for Node.js and browsers using SQLite.
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
12
|
+
# libSQL (recommended default)
|
|
13
|
+
npm install @coji/durably kysely zod @libsql/client @libsql/kysely-libsql
|
|
14
|
+
|
|
15
|
+
# PostgreSQL (multi-worker)
|
|
16
|
+
npm install @coji/durably kysely zod pg
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
See
|
|
19
|
+
See [Choosing a Database](https://coji.github.io/durably/guide/databases) for all backends.
|
|
16
20
|
|
|
17
21
|
## Quick Start
|
|
18
22
|
|
|
@@ -3,8 +3,8 @@ function withLogPersistence() {
|
|
|
3
3
|
return {
|
|
4
4
|
name: "log-persistence",
|
|
5
5
|
install(durably) {
|
|
6
|
-
durably.on("log:write",
|
|
7
|
-
|
|
6
|
+
durably.on("log:write", (event) => {
|
|
7
|
+
void durably.storage.createLog({
|
|
8
8
|
runId: event.runId,
|
|
9
9
|
stepName: event.stepName,
|
|
10
10
|
level: event.level,
|
|
@@ -19,4 +19,4 @@ function withLogPersistence() {
|
|
|
19
19
|
export {
|
|
20
20
|
withLogPersistence
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-L42OCQEV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/log-persistence.ts"],"sourcesContent":["import type { DurablyPlugin } from '../durably'\n\n/**\n * Plugin that persists log events to the database.\n * Uses fire-and-forget writes — log persistence is best-effort.\n */\nexport function withLogPersistence(): DurablyPlugin {\n return {\n name: 'log-persistence',\n install(durably) {\n durably.on('log:write', (event) => {\n void durably.storage.createLog({\n runId: event.runId,\n stepName: event.stepName,\n level: event.level,\n message: event.message,\n data: event.data,\n })\n })\n },\n }\n}\n"],"mappings":";AAMO,SAAS,qBAAoC;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,SAAS;AACf,cAAQ,GAAG,aAAa,CAAC,UAAU;AACjC,aAAK,QAAQ,QAAQ,UAAU;AAAA,UAC7B,OAAO,MAAM;AAAA,UACb,UAAU,MAAM;AAAA,UAChB,OAAO,MAAM;AAAA,UACb,SAAS,MAAM;AAAA,UACf,MAAM,MAAM;AAAA,QACd,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
@@ -19,6 +19,17 @@ interface RunTriggerEvent extends BaseEvent {
|
|
|
19
19
|
input: unknown;
|
|
20
20
|
labels: Record<string, string>;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Emitted when a trigger was coalesced onto an existing pending run (same concurrency key).
|
|
24
|
+
*/
|
|
25
|
+
interface RunCoalescedEvent extends BaseEvent {
|
|
26
|
+
type: 'run:coalesced';
|
|
27
|
+
runId: string;
|
|
28
|
+
jobName: string;
|
|
29
|
+
labels: Record<string, string>;
|
|
30
|
+
skippedInput: unknown;
|
|
31
|
+
skippedLabels: Record<string, string>;
|
|
32
|
+
}
|
|
22
33
|
/**
|
|
23
34
|
* Run leased event
|
|
24
35
|
*/
|
|
@@ -173,11 +184,37 @@ interface WorkerErrorEvent extends BaseEvent {
|
|
|
173
184
|
/**
|
|
174
185
|
* All event types as discriminated union
|
|
175
186
|
*/
|
|
176
|
-
type DurablyEvent = RunTriggerEvent | RunLeasedEvent | RunLeaseRenewedEvent | RunCompleteEvent | RunFailEvent | RunCancelEvent | RunDeleteEvent | RunProgressEvent | StepStartEvent | StepCompleteEvent | StepFailEvent | StepCancelEvent | LogWriteEvent | WorkerErrorEvent;
|
|
187
|
+
type DurablyEvent = RunTriggerEvent | RunCoalescedEvent | RunLeasedEvent | RunLeaseRenewedEvent | RunCompleteEvent | RunFailEvent | RunCancelEvent | RunDeleteEvent | RunProgressEvent | StepStartEvent | StepCompleteEvent | StepFailEvent | StepCancelEvent | LogWriteEvent | WorkerErrorEvent;
|
|
177
188
|
/**
|
|
178
189
|
* Event types for type-safe event names
|
|
179
190
|
*/
|
|
180
191
|
type EventType = DurablyEvent['type'];
|
|
192
|
+
/**
|
|
193
|
+
* Domain (lifecycle) event names — run state-transition facts.
|
|
194
|
+
* Derived from DOMAIN_EVENT_TYPE_VALUES so the Set and type stay in sync.
|
|
195
|
+
*/
|
|
196
|
+
declare const DOMAIN_EVENT_TYPE_VALUES: readonly ["run:trigger", "run:coalesced", "run:complete", "run:fail", "run:cancel", "run:delete"];
|
|
197
|
+
type DomainEventType = (typeof DOMAIN_EVENT_TYPE_VALUES)[number];
|
|
198
|
+
/**
|
|
199
|
+
* Operational / diagnostic event names — execution detail and worker diagnostics.
|
|
200
|
+
*/
|
|
201
|
+
type OperationalEventType = 'run:leased' | 'run:lease-renewed' | 'run:progress' | 'step:start' | 'step:complete' | 'step:fail' | 'step:cancel' | 'log:write' | 'worker:error';
|
|
202
|
+
/**
|
|
203
|
+
* Domain events: run lifecycle facts (trigger, terminal outcomes, coalesce, delete).
|
|
204
|
+
*/
|
|
205
|
+
type DomainEvent = Extract<DurablyEvent, {
|
|
206
|
+
type: DomainEventType;
|
|
207
|
+
}>;
|
|
208
|
+
/**
|
|
209
|
+
* Operational events: leased/progress/steps/logs/worker diagnostics.
|
|
210
|
+
*/
|
|
211
|
+
type OperationalEvent = Extract<DurablyEvent, {
|
|
212
|
+
type: OperationalEventType;
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* True when `event` is a domain (lifecycle) event — uses `event.type` only.
|
|
216
|
+
*/
|
|
217
|
+
declare function isDomainEvent(event: DurablyEvent): event is DomainEvent;
|
|
181
218
|
/**
|
|
182
219
|
* Extract event by type
|
|
183
220
|
*/
|
|
@@ -191,7 +228,7 @@ type EventInput<T extends EventType> = Omit<EventByType<T>, 'timestamp' | 'seque
|
|
|
191
228
|
/**
|
|
192
229
|
* All possible event inputs as a union (properly distributed)
|
|
193
230
|
*/
|
|
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'>;
|
|
231
|
+
type AnyEventInput = EventInput<'run:trigger'> | EventInput<'run:coalesced'> | 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'>;
|
|
195
232
|
/**
|
|
196
233
|
* Event listener function
|
|
197
234
|
*/
|
|
@@ -216,6 +253,7 @@ interface RunsTable {
|
|
|
216
253
|
idempotency_key: string | null;
|
|
217
254
|
concurrency_key: string | null;
|
|
218
255
|
current_step_index: number;
|
|
256
|
+
completed_step_count: number;
|
|
219
257
|
progress: string | null;
|
|
220
258
|
output: string | null;
|
|
221
259
|
error: string | null;
|
|
@@ -275,6 +313,11 @@ interface CreateRunInput<TLabels extends Record<string, string> = Record<string,
|
|
|
275
313
|
idempotencyKey?: string;
|
|
276
314
|
concurrencyKey?: string;
|
|
277
315
|
labels?: TLabels;
|
|
316
|
+
coalesce?: 'skip';
|
|
317
|
+
}
|
|
318
|
+
interface EnqueueResult<TLabels extends Record<string, string> = Record<string, string>> {
|
|
319
|
+
run: Run<TLabels>;
|
|
320
|
+
disposition: Disposition;
|
|
278
321
|
}
|
|
279
322
|
/**
|
|
280
323
|
* Run data returned from storage
|
|
@@ -287,7 +330,7 @@ interface Run<TLabels extends Record<string, string> = Record<string, string>> {
|
|
|
287
330
|
idempotencyKey: string | null;
|
|
288
331
|
concurrencyKey: string | null;
|
|
289
332
|
currentStepIndex: number;
|
|
290
|
-
|
|
333
|
+
completedStepCount: number;
|
|
291
334
|
progress: {
|
|
292
335
|
current: number;
|
|
293
336
|
total?: number;
|
|
@@ -308,7 +351,8 @@ interface Run<TLabels extends Record<string, string> = Record<string, string>> {
|
|
|
308
351
|
* Run filter options
|
|
309
352
|
*/
|
|
310
353
|
interface RunFilter<TLabels extends Record<string, string> = Record<string, string>> {
|
|
311
|
-
status
|
|
354
|
+
/** Filter by status(es). Pass one status, or an array for multiple (OR). */
|
|
355
|
+
status?: RunStatus | RunStatus[];
|
|
312
356
|
/** Filter by job name(s). Pass a string for one, or an array for multiple (OR). */
|
|
313
357
|
jobName?: string | string[];
|
|
314
358
|
/** Filter by labels (all specified labels must match) */
|
|
@@ -391,8 +435,8 @@ interface UpdateRunData {
|
|
|
391
435
|
* Unified storage interface used by the runtime.
|
|
392
436
|
*/
|
|
393
437
|
interface Store<TLabels extends Record<string, string> = Record<string, string>> {
|
|
394
|
-
enqueue(input: CreateRunInput<TLabels>): Promise<
|
|
395
|
-
enqueueMany(inputs: CreateRunInput<TLabels>[]): Promise<
|
|
438
|
+
enqueue(input: CreateRunInput<TLabels>): Promise<EnqueueResult<TLabels>>;
|
|
439
|
+
enqueueMany(inputs: CreateRunInput<TLabels>[]): Promise<EnqueueResult<TLabels>[]>;
|
|
396
440
|
getRun<T extends Run<TLabels> = Run<TLabels>>(runId: string): Promise<T | null>;
|
|
397
441
|
getRuns<T extends Run<TLabels> = Run<TLabels>>(filter?: RunFilter<TLabels>): Promise<T[]>;
|
|
398
442
|
updateRun(runId: string, data: UpdateRunData): Promise<void>;
|
|
@@ -423,16 +467,17 @@ interface Store<TLabels extends Record<string, string> = Record<string, string>>
|
|
|
423
467
|
}
|
|
424
468
|
/**
|
|
425
469
|
* A client-safe subset of Run, excluding internal fields like
|
|
426
|
-
* leaseOwner, leaseExpiresAt, idempotencyKey, concurrencyKey, and updatedAt
|
|
470
|
+
* leaseOwner, leaseExpiresAt, idempotencyKey, concurrencyKey, and updatedAt,
|
|
471
|
+
* plus derived `isTerminal` / `isActive` flags from `status`.
|
|
427
472
|
*/
|
|
428
|
-
type ClientRun<TLabels extends Record<string, string> = Record<string, string>> = Omit<Run<TLabels>, 'idempotencyKey' | 'concurrencyKey' | 'leaseOwner' | 'leaseExpiresAt' | 'leaseGeneration' | 'updatedAt'
|
|
473
|
+
type ClientRun<TLabels extends Record<string, string> = Record<string, string>> = Omit<Run<TLabels>, 'idempotencyKey' | 'concurrencyKey' | 'leaseOwner' | 'leaseExpiresAt' | 'leaseGeneration' | 'updatedAt'> & {
|
|
474
|
+
isTerminal: boolean;
|
|
475
|
+
isActive: boolean;
|
|
476
|
+
};
|
|
429
477
|
/**
|
|
430
478
|
* Project a full Run to a ClientRun by stripping internal fields.
|
|
431
479
|
*/
|
|
432
480
|
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
481
|
declare function createKyselyStore(db: Kysely<Database>, backend?: DatabaseBackend): Store<Record<string, string>>;
|
|
437
482
|
|
|
438
483
|
/**
|
|
@@ -472,6 +517,10 @@ interface StepContext {
|
|
|
472
517
|
error(message: string, data?: unknown): void;
|
|
473
518
|
};
|
|
474
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* How a trigger was resolved relative to durable storage.
|
|
522
|
+
*/
|
|
523
|
+
type Disposition = 'created' | 'idempotent' | 'coalesced';
|
|
475
524
|
/**
|
|
476
525
|
* Trigger options for trigger() and batchTrigger()
|
|
477
526
|
*/
|
|
@@ -479,24 +528,41 @@ interface TriggerOptions<TLabels extends Record<string, string> = Record<string,
|
|
|
479
528
|
idempotencyKey?: string;
|
|
480
529
|
concurrencyKey?: string;
|
|
481
530
|
labels?: TLabels;
|
|
531
|
+
coalesce?: 'skip';
|
|
482
532
|
}
|
|
483
533
|
/**
|
|
484
|
-
* Options for
|
|
534
|
+
* Options for waiting on a run (live onProgress/onLog only; no replay of past events)
|
|
485
535
|
*/
|
|
486
|
-
interface
|
|
536
|
+
interface WaitForRunOptions {
|
|
487
537
|
/** Timeout in milliseconds */
|
|
488
538
|
timeout?: number;
|
|
539
|
+
/**
|
|
540
|
+
* Storage polling interval when waiting for a non-terminal run (cross-runtime fallback).
|
|
541
|
+
* Omitted values inherit the surrounding `createDurably({ pollingIntervalMs })` setting.
|
|
542
|
+
*/
|
|
543
|
+
pollingIntervalMs?: number;
|
|
489
544
|
/** Called when step.progress() is invoked during execution */
|
|
490
545
|
onProgress?: (progress: ProgressData$1) => void | Promise<void>;
|
|
491
546
|
/** Called when step.log is invoked during execution */
|
|
492
547
|
onLog?: (log: LogData) => void | Promise<void>;
|
|
493
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Options for triggerAndWait() (extends TriggerOptions with wait-specific options)
|
|
551
|
+
*/
|
|
552
|
+
interface TriggerAndWaitOptions<TLabels extends Record<string, string> = Record<string, string>> extends TriggerOptions<TLabels>, WaitForRunOptions {
|
|
553
|
+
}
|
|
494
554
|
/**
|
|
495
555
|
* Typed run with output type
|
|
496
556
|
*/
|
|
497
557
|
interface TypedRun<TOutput, TLabels extends Record<string, string> = Record<string, string>> extends Omit<Run<TLabels>, 'output'> {
|
|
498
558
|
output: TOutput | null;
|
|
499
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Result of trigger() / batchTrigger(): the run plus how it was resolved.
|
|
562
|
+
*/
|
|
563
|
+
type TriggerResult<TOutput, TLabels extends Record<string, string> = Record<string, string>> = TypedRun<TOutput, TLabels> & {
|
|
564
|
+
disposition: Disposition;
|
|
565
|
+
};
|
|
500
566
|
/**
|
|
501
567
|
* Batch trigger input - either just the input or input with options
|
|
502
568
|
*/
|
|
@@ -510,6 +576,7 @@ type BatchTriggerInput<TInput, TLabels extends Record<string, string> = Record<s
|
|
|
510
576
|
interface TriggerAndWaitResult<TOutput> {
|
|
511
577
|
id: string;
|
|
512
578
|
output: TOutput;
|
|
579
|
+
disposition: Disposition;
|
|
513
580
|
}
|
|
514
581
|
/**
|
|
515
582
|
* Job handle returned by defineJob
|
|
@@ -519,7 +586,7 @@ interface JobHandle<TName extends string, TInput, TOutput, TLabels extends Recor
|
|
|
519
586
|
/**
|
|
520
587
|
* Trigger a new run
|
|
521
588
|
*/
|
|
522
|
-
trigger(input: TInput, options?: TriggerOptions<TLabels>): Promise<
|
|
589
|
+
trigger(input: TInput, options?: TriggerOptions<TLabels>): Promise<TriggerResult<TOutput, TLabels>>;
|
|
523
590
|
/**
|
|
524
591
|
* Trigger a new run and wait for completion
|
|
525
592
|
* Returns the output directly, throws if the run fails
|
|
@@ -529,7 +596,7 @@ interface JobHandle<TName extends string, TInput, TOutput, TLabels extends Recor
|
|
|
529
596
|
* Trigger multiple runs in a batch
|
|
530
597
|
* All inputs are validated before any runs are created
|
|
531
598
|
*/
|
|
532
|
-
batchTrigger(inputs: BatchTriggerInput<TInput, TLabels>[]): Promise<
|
|
599
|
+
batchTrigger(inputs: BatchTriggerInput<TInput, TLabels>[]): Promise<TriggerResult<TOutput, TLabels>[]>;
|
|
533
600
|
/**
|
|
534
601
|
* Get a run by ID
|
|
535
602
|
*/
|
|
@@ -611,6 +678,10 @@ interface DurablyOptions<TLabels extends Record<string, string> = Record<string,
|
|
|
611
678
|
*/
|
|
612
679
|
singletonKey?: string;
|
|
613
680
|
pollingIntervalMs?: number;
|
|
681
|
+
/**
|
|
682
|
+
* Maximum number of runs the worker processes concurrently. Defaults to `1` (one run at a time).
|
|
683
|
+
*/
|
|
684
|
+
maxConcurrentRuns?: number;
|
|
614
685
|
leaseRenewIntervalMs?: number;
|
|
615
686
|
leaseMs?: number;
|
|
616
687
|
preserveSteps?: boolean;
|
|
@@ -638,12 +709,18 @@ interface DurablyOptions<TLabels extends Record<string, string> = Record<string,
|
|
|
638
709
|
*/
|
|
639
710
|
retainRuns?: string;
|
|
640
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* A Durably instance with erased job types.
|
|
714
|
+
* Use when the function only needs access to Durably's runtime capabilities
|
|
715
|
+
* (trigger, getRun, etc.) without constraining the registered job types.
|
|
716
|
+
*/
|
|
717
|
+
type AnyDurably<TLabels extends Record<string, string> = Record<string, string>> = Durably<Record<string, JobHandle<string, unknown, unknown, TLabels>>, TLabels>;
|
|
641
718
|
/**
|
|
642
719
|
* Plugin interface for extending Durably
|
|
643
720
|
*/
|
|
644
721
|
interface DurablyPlugin {
|
|
645
722
|
name: string;
|
|
646
|
-
install(durably:
|
|
723
|
+
install(durably: AnyDurably): void;
|
|
647
724
|
}
|
|
648
725
|
/**
|
|
649
726
|
* Helper type to transform JobDefinition record to JobHandle record
|
|
@@ -798,6 +875,14 @@ interface Durably<TJobs extends Record<string, JobHandle<string, unknown, unknow
|
|
|
798
875
|
* Returns a ReadableStream that can be used for SSE
|
|
799
876
|
*/
|
|
800
877
|
subscribe(runId: string): ReadableStream<DurablyEvent>;
|
|
878
|
+
/**
|
|
879
|
+
* Wait for an existing run to complete (no new run created).
|
|
880
|
+
* Resolves only when status is completed; failed, cancelled, or missing run throws.
|
|
881
|
+
*/
|
|
882
|
+
waitForRun(runId: string, options?: WaitForRunOptions): Promise<Run<TLabels> & {
|
|
883
|
+
status: 'completed';
|
|
884
|
+
output: unknown;
|
|
885
|
+
}>;
|
|
801
886
|
}
|
|
802
887
|
/**
|
|
803
888
|
* Create a Durably instance
|
|
@@ -808,8 +893,9 @@ declare function createDurably<TLabels extends Record<string, string> = Record<s
|
|
|
808
893
|
declare function createDurably<TLabels extends Record<string, string> = Record<string, string>>(options: DurablyOptions<TLabels>): Durably<Record<string, never>, TLabels>;
|
|
809
894
|
|
|
810
895
|
/**
|
|
811
|
-
* Plugin that persists log events to the database
|
|
896
|
+
* Plugin that persists log events to the database.
|
|
897
|
+
* Uses fire-and-forget writes — log persistence is best-effort.
|
|
812
898
|
*/
|
|
813
899
|
declare function withLogPersistence(): DurablyPlugin;
|
|
814
900
|
|
|
815
|
-
export { type
|
|
901
|
+
export { type WorkerErrorEvent as $, type AnyDurably as A, type BatchTriggerInput as B, type ClientRun as C, type Disposition as D, type EnqueueResult as E, type RunTriggerEvent as F, type RunsTable as G, type Step as H, type StepCancelEvent as I, type JobDefinition as J, type StepCompleteEvent as K, type Log as L, type StepContext as M, type StepFailEvent as N, type OperationalEvent as O, type ProgressData$1 as P, type StepStartEvent as Q, type Run as R, type SchemaVersionsTable as S, type StepsTable as T, type Store as U, type TriggerAndWaitOptions as V, type TriggerAndWaitResult as W, type TriggerOptions as X, type TriggerResult as Y, type UpdateRunData as Z, type WaitForRunOptions as _, type RunFilter as a, createDurably as a0, createKyselyStore as a1, defineJob as a2, isDomainEvent as a3, toClientRun as a4, withLogPersistence as a5, type Database as b, type DomainEvent as c, type DomainEventType as d, type Durably as e, type DurablyEvent as f, type DurablyOptions as g, type DurablyPlugin as h, type ErrorHandler as i, type EventType as j, type JobHandle as k, type JobInput as l, type JobOutput as m, type LogData as n, type LogWriteEvent as o, type LogsTable as p, type OperationalEventType as q, type RunCancelEvent as r, type RunCoalescedEvent as s, type RunCompleteEvent as t, type RunDeleteEvent as u, type RunFailEvent as v, type RunLeaseRenewedEvent as w, type RunLeasedEvent as x, type RunProgressEvent as y, type RunStatus as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Run, a as RunFilter, D as
|
|
2
|
-
export { B as BatchTriggerInput, C as ClientRun, b as Database, c as
|
|
1
|
+
import { R as Run, a as RunFilter, D as Disposition, A as AnyDurably } from './index-CXH4ozmK.js';
|
|
2
|
+
export { B as BatchTriggerInput, C as ClientRun, b as Database, c as DomainEvent, d as DomainEventType, e as Durably, f as DurablyEvent, g as DurablyOptions, h as DurablyPlugin, E as EnqueueResult, i as ErrorHandler, j as EventType, J as JobDefinition, k as JobHandle, l as JobInput, m as JobOutput, L as Log, n as LogData, o as LogWriteEvent, p as LogsTable, O as OperationalEvent, q as OperationalEventType, P as ProgressData, r as RunCancelEvent, s as RunCoalescedEvent, t as RunCompleteEvent, u as RunDeleteEvent, v as RunFailEvent, w as RunLeaseRenewedEvent, x as RunLeasedEvent, y as RunProgressEvent, z as RunStatus, F as RunTriggerEvent, G as RunsTable, S as SchemaVersionsTable, H as Step, I as StepCancelEvent, K as StepCompleteEvent, M as StepContext, N as StepFailEvent, Q as StepStartEvent, T as StepsTable, U as Store, V as TriggerAndWaitOptions, W as TriggerAndWaitResult, X as TriggerOptions, Y as TriggerResult, Z as UpdateRunData, _ as WaitForRunOptions, $ as WorkerErrorEvent, a0 as createDurably, a1 as createKyselyStore, a2 as defineJob, a3 as isDomainEvent, a4 as toClientRun, a5 as withLogPersistence } from './index-CXH4ozmK.js';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
@@ -17,6 +17,26 @@ declare class CancelledError extends Error {
|
|
|
17
17
|
declare class LeaseLostError extends Error {
|
|
18
18
|
constructor(runId: string);
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Base class for errors that map to specific HTTP status codes.
|
|
22
|
+
* Used by the HTTP handler to return appropriate responses.
|
|
23
|
+
*/
|
|
24
|
+
declare class DurablyError extends Error {
|
|
25
|
+
readonly statusCode: number;
|
|
26
|
+
constructor(message: string, statusCode: number);
|
|
27
|
+
}
|
|
28
|
+
/** 404 — Resource not found */
|
|
29
|
+
declare class NotFoundError extends DurablyError {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
/** 400 — Invalid input or request */
|
|
33
|
+
declare class ValidationError extends DurablyError {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
/** 409 — Operation conflicts with current state */
|
|
37
|
+
declare class ConflictError extends DurablyError {
|
|
38
|
+
constructor(message: string);
|
|
39
|
+
}
|
|
20
40
|
|
|
21
41
|
/**
|
|
22
42
|
* Run operation types for onRunAccess
|
|
@@ -35,12 +55,14 @@ interface TriggerRequest<TLabels extends Record<string, string> = Record<string,
|
|
|
35
55
|
idempotencyKey?: string;
|
|
36
56
|
concurrencyKey?: string;
|
|
37
57
|
labels?: TLabels;
|
|
58
|
+
coalesce?: 'skip';
|
|
38
59
|
}
|
|
39
60
|
/**
|
|
40
61
|
* Response for trigger endpoint
|
|
41
62
|
*/
|
|
42
63
|
interface TriggerResponse {
|
|
43
64
|
runId: string;
|
|
65
|
+
disposition: Disposition;
|
|
44
66
|
}
|
|
45
67
|
/**
|
|
46
68
|
* Auth middleware configuration.
|
|
@@ -105,6 +127,6 @@ interface CreateDurablyHandlerOptions<TContext = undefined, TLabels extends Reco
|
|
|
105
127
|
* Create HTTP handlers for Durably
|
|
106
128
|
* Uses Web Standard Request/Response for framework-agnostic usage
|
|
107
129
|
*/
|
|
108
|
-
declare function createDurablyHandler<TContext = undefined, TLabels extends Record<string, string> = Record<string, string>>(durably:
|
|
130
|
+
declare function createDurablyHandler<TContext = undefined, TLabels extends Record<string, string> = Record<string, string>>(durably: AnyDurably<TLabels>, options?: CreateDurablyHandlerOptions<TContext, TLabels>): DurablyHandler;
|
|
109
131
|
|
|
110
|
-
export { type AuthConfig, CancelledError, type CreateDurablyHandlerOptions,
|
|
132
|
+
export { AnyDurably, type AuthConfig, CancelledError, ConflictError, type CreateDurablyHandlerOptions, Disposition, DurablyError, type DurablyHandler, LeaseLostError, NotFoundError, Run, RunFilter, type RunOperation, type RunsSubscribeFilter, type TriggerRequest, type TriggerResponse, ValidationError, createDurablyHandler };
|