openworkflow 0.4.0 → 0.5.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 +57 -46
- package/dist/backend-postgres/index.d.ts +44 -0
- package/dist/backend-postgres/index.d.ts.map +1 -0
- package/dist/backend-postgres/index.js +535 -0
- package/dist/backend-postgres/index.js.map +1 -0
- package/dist/backend-postgres/postgres.d.ts +42 -0
- package/dist/backend-postgres/postgres.d.ts.map +1 -0
- package/dist/backend-postgres/postgres.js +234 -0
- package/dist/backend-postgres/postgres.js.map +1 -0
- package/dist/backend-sqlite/index.d.ts +42 -0
- package/dist/backend-sqlite/index.d.ts.map +1 -0
- package/dist/backend-sqlite/index.js +655 -0
- package/dist/backend-sqlite/index.js.map +1 -0
- package/dist/backend-sqlite/sqlite.d.ts +61 -0
- package/dist/backend-sqlite/sqlite.d.ts.map +1 -0
- package/dist/backend-sqlite/sqlite.js +247 -0
- package/dist/backend-sqlite/sqlite.js.map +1 -0
- package/dist/backend.d.ts +21 -89
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +0 -21
- package/dist/backend.js.map +1 -1
- package/dist/bin/openworkflow.d.ts +3 -0
- package/dist/bin/openworkflow.d.ts.map +1 -0
- package/dist/bin/openworkflow.js +44 -0
- package/dist/bin/openworkflow.js.map +1 -0
- package/dist/client.d.ts +68 -80
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +83 -53
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +34 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +49 -0
- package/dist/config.js.map +1 -0
- package/dist/{duration.d.ts → core/duration.d.ts} +5 -2
- package/dist/core/duration.d.ts.map +1 -0
- package/dist/{duration.js → core/duration.js} +9 -6
- package/dist/core/duration.js.map +1 -0
- package/dist/core/error.d.ts +14 -0
- package/dist/core/error.d.ts.map +1 -0
- package/dist/core/error.js +18 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/json.d.ts +5 -0
- package/dist/core/json.d.ts.map +1 -0
- package/dist/core/json.js +2 -0
- package/dist/core/json.js.map +1 -0
- package/dist/core/result.d.ts +22 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/result.js +17 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/retry.d.ts +7 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +7 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/step.d.ts +89 -0
- package/dist/core/step.d.ts.map +1 -0
- package/dist/core/step.js +66 -0
- package/dist/core/step.js.map +1 -0
- package/dist/core/workflow.d.ts +63 -0
- package/dist/core/workflow.d.ts.map +1 -0
- package/dist/core/workflow.js +35 -0
- package/dist/core/workflow.js.map +1 -0
- package/dist/execution.d.ts +69 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +188 -0
- package/dist/execution.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +8 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +5 -0
- package/dist/internal.js.map +1 -0
- package/dist/pg/backend.d.ts +42 -0
- package/dist/pg/backend.d.ts.map +1 -0
- package/dist/pg/backend.js +534 -0
- package/dist/pg/backend.js.map +1 -0
- package/dist/pg/index.d.ts +3 -0
- package/dist/pg/index.d.ts.map +1 -0
- package/dist/pg/index.js +3 -0
- package/dist/pg/index.js.map +1 -0
- package/dist/pg/postgres.d.ts +42 -0
- package/dist/pg/postgres.d.ts.map +1 -0
- package/dist/pg/postgres.js +234 -0
- package/dist/pg/postgres.js.map +1 -0
- package/dist/pg/scripts/db-migrate.d.ts +2 -0
- package/dist/pg/scripts/db-migrate.d.ts.map +1 -0
- package/dist/pg/scripts/db-migrate.js +5 -0
- package/dist/pg/scripts/db-migrate.js.map +1 -0
- package/dist/pg/scripts/db-reset.d.ts +2 -0
- package/dist/pg/scripts/db-reset.d.ts.map +1 -0
- package/dist/pg/scripts/db-reset.js +6 -0
- package/dist/pg/scripts/db-reset.js.map +1 -0
- package/dist/pg/scripts/squawk.d.ts +2 -0
- package/dist/pg/scripts/squawk.d.ts.map +1 -0
- package/dist/pg/scripts/squawk.js +17 -0
- package/dist/pg/scripts/squawk.js.map +1 -0
- package/dist/pg/vitest.global-setup.d.ts +3 -0
- package/dist/pg/vitest.global-setup.d.ts.map +1 -0
- package/dist/pg/vitest.global-setup.js +8 -0
- package/dist/pg/vitest.global-setup.js.map +1 -0
- package/dist/registry.d.ts +27 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +49 -0
- package/dist/registry.js.map +1 -0
- package/dist/sqlite/backend.d.ts +40 -0
- package/dist/sqlite/backend.d.ts.map +1 -0
- package/dist/sqlite/backend.js +654 -0
- package/dist/sqlite/backend.js.map +1 -0
- package/dist/sqlite/index.d.ts +3 -0
- package/dist/sqlite/index.d.ts.map +1 -0
- package/dist/sqlite/index.js +3 -0
- package/dist/sqlite/index.js.map +1 -0
- package/dist/sqlite/sqlite.d.ts +61 -0
- package/dist/sqlite/sqlite.d.ts.map +1 -0
- package/dist/sqlite/sqlite.js +247 -0
- package/dist/sqlite/sqlite.js.map +1 -0
- package/dist/testing/backend.testsuite.d.ts +20 -0
- package/dist/testing/backend.testsuite.d.ts.map +1 -0
- package/dist/testing/backend.testsuite.js +1091 -0
- package/dist/testing/backend.testsuite.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/worker.d.ts +10 -3
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +29 -195
- package/dist/worker.js.map +1 -1
- package/dist/workflow.d.ts +60 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +49 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +16 -6
- package/dist/duration.d.ts.map +0 -1
- package/dist/duration.js.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js.map +0 -1
- /package/dist/{schema.d.ts → core/schema.d.ts} +0 -0
- /package/dist/{schema.js → core/schema.js} +0 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import postgres from "postgres";
|
|
2
|
+
export const DEFAULT_POSTGRES_URL = "postgresql://postgres:postgres@localhost:5432/postgres";
|
|
3
|
+
// The default schema to use for OpenWorkflow data. This type is more for
|
|
4
|
+
// documentation than for practical use. The only time we allow schema
|
|
5
|
+
// customization is during testing, specifically for testing migrations.
|
|
6
|
+
// Everywhere else uses the "openworkflow" schema directly for prepared
|
|
7
|
+
// statements.
|
|
8
|
+
export const DEFAULT_SCHEMA = "openworkflow";
|
|
9
|
+
/**
|
|
10
|
+
* newPostgres creates a new Postgres client.
|
|
11
|
+
* @param url - Database connection URL
|
|
12
|
+
* @param options - Postgres client options
|
|
13
|
+
* @returns A Postgres client
|
|
14
|
+
*/
|
|
15
|
+
export function newPostgres(url, options) {
|
|
16
|
+
return postgres(url, { ...options, transform: postgres.toCamel });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* newPostgresMaxOne creates a new Postgres client with a maximum pool size of
|
|
20
|
+
* one, which is useful for migrations.
|
|
21
|
+
* @param url - Database connection URL
|
|
22
|
+
* @param options - Postgres client options
|
|
23
|
+
* @returns A Postgres client
|
|
24
|
+
*/
|
|
25
|
+
export function newPostgresMaxOne(url, options) {
|
|
26
|
+
return newPostgres(url, { ...options, max: 1 });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* migrations returns the list of migration SQL statements.
|
|
30
|
+
* @param schema - Schema name
|
|
31
|
+
* @returns Migration SQL statements
|
|
32
|
+
*/
|
|
33
|
+
export function migrations(schema) {
|
|
34
|
+
return [
|
|
35
|
+
// 0 - init
|
|
36
|
+
`BEGIN;
|
|
37
|
+
|
|
38
|
+
CREATE SCHEMA IF NOT EXISTS ${schema};
|
|
39
|
+
|
|
40
|
+
CREATE TABLE IF NOT EXISTS "${schema}"."openworkflow_migrations" (
|
|
41
|
+
"version" BIGINT NOT NULL PRIMARY KEY
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
INSERT INTO "${schema}"."openworkflow_migrations" ("version")
|
|
45
|
+
VALUES (0)
|
|
46
|
+
ON CONFLICT DO NOTHING;
|
|
47
|
+
|
|
48
|
+
COMMIT;`,
|
|
49
|
+
// 1 - add workflow_runs and step_attempts tables
|
|
50
|
+
`BEGIN;
|
|
51
|
+
|
|
52
|
+
CREATE TABLE IF NOT EXISTS "${schema}"."workflow_runs" (
|
|
53
|
+
"namespace_id" TEXT NOT NULL,
|
|
54
|
+
"id" TEXT NOT NULL,
|
|
55
|
+
--
|
|
56
|
+
"workflow_name" TEXT NOT NULL,
|
|
57
|
+
"version" TEXT,
|
|
58
|
+
"status" TEXT NOT NULL,
|
|
59
|
+
"idempotency_key" TEXT,
|
|
60
|
+
"config" JSONB NOT NULL,
|
|
61
|
+
"context" JSONB,
|
|
62
|
+
"input" JSONB,
|
|
63
|
+
"output" JSONB,
|
|
64
|
+
"error" JSONB,
|
|
65
|
+
"attempts" INTEGER NOT NULL,
|
|
66
|
+
"parent_step_attempt_namespace_id" TEXT,
|
|
67
|
+
"parent_step_attempt_id" TEXT,
|
|
68
|
+
"worker_id" TEXT,
|
|
69
|
+
"available_at" TIMESTAMPTZ,
|
|
70
|
+
"deadline_at" TIMESTAMPTZ,
|
|
71
|
+
"started_at" TIMESTAMPTZ,
|
|
72
|
+
"finished_at" TIMESTAMPTZ,
|
|
73
|
+
"created_at" TIMESTAMPTZ NOT NULL,
|
|
74
|
+
"updated_at" TIMESTAMPTZ NOT NULL,
|
|
75
|
+
PRIMARY KEY ("namespace_id", "id")
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
CREATE TABLE IF NOT EXISTS "${schema}"."step_attempts" (
|
|
79
|
+
"namespace_id" TEXT NOT NULL,
|
|
80
|
+
"id" TEXT NOT NULL,
|
|
81
|
+
--
|
|
82
|
+
"workflow_run_id" TEXT NOT NULL,
|
|
83
|
+
"step_name" TEXT NOT NULL,
|
|
84
|
+
"kind" TEXT NOT NULL,
|
|
85
|
+
"status" TEXT NOT NULL,
|
|
86
|
+
"config" JSONB NOT NULL,
|
|
87
|
+
"context" JSONB,
|
|
88
|
+
"output" JSONB,
|
|
89
|
+
"error" JSONB,
|
|
90
|
+
"child_workflow_run_namespace_id" TEXT,
|
|
91
|
+
"child_workflow_run_id" TEXT,
|
|
92
|
+
"started_at" TIMESTAMPTZ,
|
|
93
|
+
"finished_at" TIMESTAMPTZ,
|
|
94
|
+
"created_at" TIMESTAMPTZ NOT NULL,
|
|
95
|
+
"updated_at" TIMESTAMPTZ NOT NULL,
|
|
96
|
+
PRIMARY KEY ("namespace_id", "id")
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
INSERT INTO "${schema}"."openworkflow_migrations" ("version")
|
|
100
|
+
VALUES (1)
|
|
101
|
+
ON CONFLICT DO NOTHING;
|
|
102
|
+
|
|
103
|
+
COMMIT;`,
|
|
104
|
+
// 2 - foreign keys
|
|
105
|
+
`BEGIN;
|
|
106
|
+
|
|
107
|
+
ALTER TABLE "${schema}"."step_attempts"
|
|
108
|
+
ADD CONSTRAINT "step_attempts_workflow_run_fk"
|
|
109
|
+
FOREIGN KEY ("namespace_id", "workflow_run_id")
|
|
110
|
+
REFERENCES "${schema}"."workflow_runs" ("namespace_id", "id")
|
|
111
|
+
ON DELETE CASCADE
|
|
112
|
+
NOT VALID;
|
|
113
|
+
|
|
114
|
+
ALTER TABLE "${schema}"."workflow_runs"
|
|
115
|
+
ADD CONSTRAINT "workflow_runs_parent_step_attempt_fk"
|
|
116
|
+
FOREIGN KEY ("parent_step_attempt_namespace_id", "parent_step_attempt_id")
|
|
117
|
+
REFERENCES "${schema}"."step_attempts" ("namespace_id", "id")
|
|
118
|
+
ON DELETE SET NULL
|
|
119
|
+
NOT VALID;
|
|
120
|
+
|
|
121
|
+
ALTER TABLE "${schema}"."step_attempts"
|
|
122
|
+
ADD CONSTRAINT "step_attempts_child_workflow_run_fk"
|
|
123
|
+
FOREIGN KEY ("child_workflow_run_namespace_id", "child_workflow_run_id")
|
|
124
|
+
REFERENCES "${schema}"."workflow_runs" ("namespace_id", "id")
|
|
125
|
+
ON DELETE SET NULL
|
|
126
|
+
NOT VALID;
|
|
127
|
+
|
|
128
|
+
INSERT INTO "${schema}"."openworkflow_migrations" ("version")
|
|
129
|
+
VALUES (2)
|
|
130
|
+
ON CONFLICT DO NOTHING;
|
|
131
|
+
|
|
132
|
+
COMMIT;`,
|
|
133
|
+
// 3 - validate foreign keys
|
|
134
|
+
`BEGIN;
|
|
135
|
+
|
|
136
|
+
ALTER TABLE "${schema}"."step_attempts"
|
|
137
|
+
VALIDATE CONSTRAINT "step_attempts_workflow_run_fk";
|
|
138
|
+
|
|
139
|
+
ALTER TABLE "${schema}"."workflow_runs" VALIDATE CONSTRAINT
|
|
140
|
+
"workflow_runs_parent_step_attempt_fk";
|
|
141
|
+
|
|
142
|
+
ALTER TABLE "${schema}"."step_attempts"
|
|
143
|
+
VALIDATE CONSTRAINT "step_attempts_child_workflow_run_fk";
|
|
144
|
+
|
|
145
|
+
INSERT INTO "${schema}"."openworkflow_migrations" ("version")
|
|
146
|
+
VALUES (3)
|
|
147
|
+
ON CONFLICT DO NOTHING;
|
|
148
|
+
|
|
149
|
+
COMMIT;`,
|
|
150
|
+
// 4 - indexes
|
|
151
|
+
`BEGIN;
|
|
152
|
+
|
|
153
|
+
CREATE INDEX IF NOT EXISTS "workflow_runs_status_available_at_created_at_idx"
|
|
154
|
+
ON "${schema}"."workflow_runs" ("namespace_id", "status", "available_at", "created_at");
|
|
155
|
+
|
|
156
|
+
CREATE INDEX IF NOT EXISTS "workflow_runs_workflow_name_idempotency_key_created_at_idx"
|
|
157
|
+
ON "${schema}"."workflow_runs" ("namespace_id", "workflow_name", "idempotency_key", "created_at");
|
|
158
|
+
|
|
159
|
+
CREATE INDEX IF NOT EXISTS "workflow_runs_parent_step_idx"
|
|
160
|
+
ON "${schema}"."workflow_runs" ("parent_step_attempt_namespace_id", "parent_step_attempt_id")
|
|
161
|
+
WHERE parent_step_attempt_namespace_id IS NOT NULL AND parent_step_attempt_id IS NOT NULL;
|
|
162
|
+
|
|
163
|
+
CREATE INDEX IF NOT EXISTS "workflow_runs_created_at_desc_idx"
|
|
164
|
+
ON "${schema}"."workflow_runs" ("namespace_id", "created_at" DESC);
|
|
165
|
+
|
|
166
|
+
CREATE INDEX IF NOT EXISTS "workflow_runs_status_created_at_desc_idx"
|
|
167
|
+
ON "${schema}"."workflow_runs" ("namespace_id", "status", "created_at" DESC);
|
|
168
|
+
|
|
169
|
+
CREATE INDEX IF NOT EXISTS "workflow_runs_workflow_name_status_created_at_desc_idx"
|
|
170
|
+
ON "${schema}"."workflow_runs" ("namespace_id", "workflow_name", "status", "created_at" DESC);
|
|
171
|
+
|
|
172
|
+
CREATE INDEX IF NOT EXISTS "step_attempts_workflow_run_created_at_idx"
|
|
173
|
+
ON "${schema}"."step_attempts" ("namespace_id", "workflow_run_id", "created_at");
|
|
174
|
+
|
|
175
|
+
CREATE INDEX IF NOT EXISTS "step_attempts_workflow_run_step_name_created_at_idx"
|
|
176
|
+
ON "${schema}"."step_attempts" ("namespace_id", "workflow_run_id", "step_name", "created_at");
|
|
177
|
+
|
|
178
|
+
CREATE INDEX IF NOT EXISTS "step_attempts_child_workflow_run_idx"
|
|
179
|
+
ON "${schema}"."step_attempts" ("child_workflow_run_namespace_id", "child_workflow_run_id")
|
|
180
|
+
WHERE child_workflow_run_namespace_id IS NOT NULL AND child_workflow_run_id IS NOT NULL;
|
|
181
|
+
|
|
182
|
+
INSERT INTO "${schema}"."openworkflow_migrations"("version")
|
|
183
|
+
VALUES (4)
|
|
184
|
+
ON CONFLICT DO NOTHING;
|
|
185
|
+
|
|
186
|
+
COMMIT;`,
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* migrate applies pending migrations to the database. Does nothing if the
|
|
191
|
+
* database is already up to date.
|
|
192
|
+
* @param pg - Postgres client
|
|
193
|
+
* @param schema - Schema name
|
|
194
|
+
* @returns Promise resolved when migrations complete
|
|
195
|
+
*/
|
|
196
|
+
export async function migrate(pg, schema) {
|
|
197
|
+
const currentMigrationVersion = await getCurrentMigrationVersion(pg, schema);
|
|
198
|
+
for (const [i, migrationSql] of migrations(schema).entries()) {
|
|
199
|
+
if (i <= currentMigrationVersion)
|
|
200
|
+
continue; // already applied
|
|
201
|
+
await pg.unsafe(migrationSql);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* dropSchema drops the specified schema from the database.
|
|
206
|
+
* @param pg - Postgres client
|
|
207
|
+
* @param schema - Schema name
|
|
208
|
+
* @returns Promise resolved when the schema is dropped
|
|
209
|
+
*/
|
|
210
|
+
export async function dropSchema(pg, schema) {
|
|
211
|
+
await pg.unsafe(`DROP SCHEMA IF EXISTS ${schema} CASCADE;`);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* getCurrentVersion returns the current migration version of the database.
|
|
215
|
+
* @param pg - Postgres client
|
|
216
|
+
* @param schema - Schema name
|
|
217
|
+
* @returns Current migration version
|
|
218
|
+
*/
|
|
219
|
+
async function getCurrentMigrationVersion(pg, schema) {
|
|
220
|
+
// check if migrations table exists
|
|
221
|
+
const existsRes = await pg.unsafe(`
|
|
222
|
+
SELECT EXISTS (
|
|
223
|
+
SELECT 1
|
|
224
|
+
FROM information_schema.tables
|
|
225
|
+
WHERE table_schema = '${schema}'
|
|
226
|
+
AND table_name = 'openworkflow_migrations'
|
|
227
|
+
)`);
|
|
228
|
+
if (!existsRes[0]?.exists)
|
|
229
|
+
return -1;
|
|
230
|
+
// get current version
|
|
231
|
+
const currentVersionRes = await pg.unsafe(`SELECT MAX("version") AS "version" FROM "${schema}"."openworkflow_migrations";`);
|
|
232
|
+
return currentVersionRes[0]?.version ?? -1;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=postgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/backend-postgres/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,CAAC,MAAM,oBAAoB,GAC/B,wDAAwD,CAAC;AAE3D,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AACxE,uEAAuE;AACvE,cAAc;AACd,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAK7C;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAAyB;IAChE,OAAO,QAAQ,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,OAAyB;IACtE,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO;QACL,WAAW;QACX;;kCAE8B,MAAM;;kCAEN,MAAM;;;;mBAIrB,MAAM;;;;YAIb;QAER,iDAAiD;QACjD;;kCAE8B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;kCA0BN,MAAM;;;;;;;;;;;;;;;;;;;;;mBAqBrB,MAAM;;;;YAIb;QAER,mBAAmB;QACnB;;mBAEe,MAAM;;;kBAGP,MAAM;;;;mBAIL,MAAM;;;kBAGP,MAAM;;;;mBAIL,MAAM;;;kBAGP,MAAM;;;;mBAIL,MAAM;;;;YAIb;QAER,4BAA4B;QA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E,OAAO,IAAI,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Backend, CancelWorkflowRunParams, ClaimWorkflowRunParams, CompleteStepAttemptParams, CompleteWorkflowRunParams, CreateStepAttemptParams, CreateWorkflowRunParams, ExtendWorkflowRunLeaseParams, FailStepAttemptParams, FailWorkflowRunParams, GetStepAttemptParams, GetWorkflowRunParams, ListStepAttemptsParams, ListWorkflowRunsParams, PaginatedResponse, SleepWorkflowRunParams } from "../backend.js";
|
|
2
|
+
import type { StepAttempt } from "../core/step.js";
|
|
3
|
+
import type { WorkflowRun } from "../core/workflow.js";
|
|
4
|
+
interface BackendSqliteOptions {
|
|
5
|
+
namespaceId?: string;
|
|
6
|
+
runMigrations?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Manages a connection to a SQLite database for workflow operations.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BackendSqlite implements Backend {
|
|
12
|
+
private db;
|
|
13
|
+
private namespaceId;
|
|
14
|
+
private constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Create and initialize a new BackendSqlite instance. This will
|
|
17
|
+
* automatically run migrations on startup unless `runMigrations` is set to
|
|
18
|
+
* false.
|
|
19
|
+
* @param path - Database path
|
|
20
|
+
* @param options - Backend options
|
|
21
|
+
* @returns A connected backend instance
|
|
22
|
+
*/
|
|
23
|
+
static connect(path: string, options?: BackendSqliteOptions): BackendSqlite;
|
|
24
|
+
stop(): Promise<void>;
|
|
25
|
+
createWorkflowRun(params: CreateWorkflowRunParams): Promise<WorkflowRun>;
|
|
26
|
+
getWorkflowRun(params: GetWorkflowRunParams): Promise<WorkflowRun | null>;
|
|
27
|
+
claimWorkflowRun(params: ClaimWorkflowRunParams): Promise<WorkflowRun | null>;
|
|
28
|
+
extendWorkflowRunLease(params: ExtendWorkflowRunLeaseParams): Promise<WorkflowRun>;
|
|
29
|
+
sleepWorkflowRun(params: SleepWorkflowRunParams): Promise<WorkflowRun>;
|
|
30
|
+
completeWorkflowRun(params: CompleteWorkflowRunParams): Promise<WorkflowRun>;
|
|
31
|
+
failWorkflowRun(params: FailWorkflowRunParams): Promise<WorkflowRun>;
|
|
32
|
+
cancelWorkflowRun(params: CancelWorkflowRunParams): Promise<WorkflowRun>;
|
|
33
|
+
listWorkflowRuns(params: ListWorkflowRunsParams): Promise<PaginatedResponse<WorkflowRun>>;
|
|
34
|
+
listStepAttempts(params: ListStepAttemptsParams): Promise<PaginatedResponse<StepAttempt>>;
|
|
35
|
+
private processPaginationResults;
|
|
36
|
+
createStepAttempt(params: CreateStepAttemptParams): Promise<StepAttempt>;
|
|
37
|
+
getStepAttempt(params: GetStepAttemptParams): Promise<StepAttempt | null>;
|
|
38
|
+
completeStepAttempt(params: CompleteStepAttemptParams): Promise<StepAttempt>;
|
|
39
|
+
failStepAttempt(params: FailStepAttemptParams): Promise<StepAttempt>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend-sqlite/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAgBvD,UAAU,oBAAoB;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB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