@coji/durably 0.13.0 → 0.14.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-CDCdrLgw.d.ts} +4 -2
- package/dist/index.d.ts +23 -3
- package/dist/index.js +295 -210
- 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 +50 -5
- package/package.json +1 -1
- 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":[]}
|
|
@@ -216,6 +216,7 @@ interface RunsTable {
|
|
|
216
216
|
idempotency_key: string | null;
|
|
217
217
|
concurrency_key: string | null;
|
|
218
218
|
current_step_index: number;
|
|
219
|
+
completed_step_count: number;
|
|
219
220
|
progress: string | null;
|
|
220
221
|
output: string | null;
|
|
221
222
|
error: string | null;
|
|
@@ -287,7 +288,7 @@ interface Run<TLabels extends Record<string, string> = Record<string, string>> {
|
|
|
287
288
|
idempotencyKey: string | null;
|
|
288
289
|
concurrencyKey: string | null;
|
|
289
290
|
currentStepIndex: number;
|
|
290
|
-
|
|
291
|
+
completedStepCount: number;
|
|
291
292
|
progress: {
|
|
292
293
|
current: number;
|
|
293
294
|
total?: number;
|
|
@@ -808,7 +809,8 @@ declare function createDurably<TLabels extends Record<string, string> = Record<s
|
|
|
808
809
|
declare function createDurably<TLabels extends Record<string, string> = Record<string, string>>(options: DurablyOptions<TLabels>): Durably<Record<string, never>, TLabels>;
|
|
809
810
|
|
|
810
811
|
/**
|
|
811
|
-
* Plugin that persists log events to the database
|
|
812
|
+
* Plugin that persists log events to the database.
|
|
813
|
+
* Uses fire-and-forget writes — log persistence is best-effort.
|
|
812
814
|
*/
|
|
813
815
|
declare function withLogPersistence(): DurablyPlugin;
|
|
814
816
|
|
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 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-
|
|
1
|
+
import { R as Run, a as RunFilter, D as Durably } from './index-CDCdrLgw.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-CDCdrLgw.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
|
|
@@ -107,4 +127,4 @@ interface CreateDurablyHandlerOptions<TContext = undefined, TLabels extends Reco
|
|
|
107
127
|
*/
|
|
108
128
|
declare function createDurablyHandler<TContext = undefined, TLabels extends Record<string, string> = Record<string, string>>(durably: Durably<any, TLabels>, options?: CreateDurablyHandlerOptions<TContext, TLabels>): DurablyHandler;
|
|
109
129
|
|
|
110
|
-
export { type AuthConfig, CancelledError, type CreateDurablyHandlerOptions, Durably, type DurablyHandler, LeaseLostError, Run, RunFilter, type RunOperation, type RunsSubscribeFilter, type TriggerRequest, type TriggerResponse, createDurablyHandler };
|
|
130
|
+
export { type AuthConfig, CancelledError, ConflictError, type CreateDurablyHandlerOptions, Durably, DurablyError, type DurablyHandler, LeaseLostError, NotFoundError, Run, RunFilter, type RunOperation, type RunsSubscribeFilter, type TriggerRequest, type TriggerResponse, ValidationError, createDurablyHandler };
|