@boardwalk-labs/engine 0.1.3 → 0.1.5
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/engine.js +2 -2
- package/dist/scheduler/scheduler.js +0 -0
- package/dist/server/routes/api.js +1 -1
- package/dist/server/routes/ui.js +1 -1
- package/dist/server_main.js +1 -1
- package/dist/store/migrations.js +1 -1
- package/dist/store/store.d.ts +4 -4
- package/dist/store/store.js +12 -12
- package/package.json +2 -2
package/dist/engine.js
CHANGED
|
@@ -83,7 +83,7 @@ export class Engine {
|
|
|
83
83
|
this.assertOpen();
|
|
84
84
|
const manifest = extractManifest(args.program, { fileName: "index.mjs" });
|
|
85
85
|
const workflow = this.store.upsertWorkflow({
|
|
86
|
-
|
|
86
|
+
slug: manifest.slug,
|
|
87
87
|
manifest,
|
|
88
88
|
program: args.program,
|
|
89
89
|
...(args.config !== undefined ? { config: args.config } : {}),
|
|
@@ -168,7 +168,7 @@ export class Engine {
|
|
|
168
168
|
*/
|
|
169
169
|
async runOnce(args) {
|
|
170
170
|
const workflow = this.deployWorkflow(args);
|
|
171
|
-
const run = this.startRun(workflow.
|
|
171
|
+
const run = this.startRun(workflow.slug, {
|
|
172
172
|
...(args.input !== undefined ? { input: args.input } : {}),
|
|
173
173
|
});
|
|
174
174
|
return await this.waitForRun(run.id);
|
|
Binary file
|
|
@@ -29,7 +29,7 @@ function isRunStatus(value) {
|
|
|
29
29
|
/** GET /api/workflows — names + manifest-derived fields, enough to render a picker. */
|
|
30
30
|
export function handleListWorkflows(ctx) {
|
|
31
31
|
const workflows = ctx.engine.store.listWorkflows().map((row) => ({
|
|
32
|
-
|
|
32
|
+
slug: row.slug,
|
|
33
33
|
description: row.manifest.description ?? null,
|
|
34
34
|
triggers: row.manifest.triggers,
|
|
35
35
|
createdAt: row.createdAt,
|
package/dist/server/routes/ui.js
CHANGED
|
@@ -70,7 +70,7 @@ async function loadWorkflows() {
|
|
|
70
70
|
}
|
|
71
71
|
box.append(rowButton("all workflows", () => { selectedWorkflow = null; loadRuns(); }));
|
|
72
72
|
for (const workflow of workflows) {
|
|
73
|
-
box.append(rowButton(workflow.
|
|
73
|
+
box.append(rowButton(workflow.slug, () => { selectedWorkflow = workflow.slug; loadRuns(); }));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
package/dist/server_main.js
CHANGED
|
@@ -143,7 +143,7 @@ function deployWorkflowsFromDir(engine, dir, log) {
|
|
|
143
143
|
try {
|
|
144
144
|
const program = readFileSync(join(dir, file), "utf8");
|
|
145
145
|
const workflow = engine.deployWorkflow({ program });
|
|
146
|
-
log(`deployed "${workflow.
|
|
146
|
+
log(`deployed "${workflow.slug}" from ${file}`);
|
|
147
147
|
}
|
|
148
148
|
catch (err) {
|
|
149
149
|
log(`skipped ${file}: ${err instanceof Error ? err.message : String(err)}`);
|
package/dist/store/migrations.js
CHANGED
package/dist/store/store.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { RunStatus };
|
|
|
3
3
|
/** A deployed workflow: validated manifest + bundled program source + per-deploy config. */
|
|
4
4
|
export interface WorkflowRow {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
6
|
+
slug: string;
|
|
7
7
|
manifest: WorkflowManifest;
|
|
8
8
|
program: string;
|
|
9
9
|
config: Record<string, JsonValue>;
|
|
@@ -80,17 +80,17 @@ export declare class Store {
|
|
|
80
80
|
*/
|
|
81
81
|
transaction<T>(fn: () => T): T;
|
|
82
82
|
/**
|
|
83
|
-
* Insert a workflow or update it by
|
|
83
|
+
* Insert a workflow or update it by slug (deploying again is always an update — the slug is
|
|
84
84
|
* the user-facing identity, so the id stays stable across redeploys and existing runs keep
|
|
85
85
|
* their foreign keys). `updated_at` bumps on update; `created_at` and `id` never change.
|
|
86
86
|
*/
|
|
87
87
|
upsertWorkflow(args: {
|
|
88
|
-
|
|
88
|
+
slug: string;
|
|
89
89
|
manifest: WorkflowManifest;
|
|
90
90
|
program: string;
|
|
91
91
|
config?: Record<string, JsonValue>;
|
|
92
92
|
}): WorkflowRow;
|
|
93
|
-
getWorkflow(
|
|
93
|
+
getWorkflow(slug: string): WorkflowRow | null;
|
|
94
94
|
getWorkflowById(id: string): WorkflowRow | null;
|
|
95
95
|
listWorkflows(): WorkflowRow[];
|
|
96
96
|
/**
|
package/dist/store/store.js
CHANGED
|
@@ -113,7 +113,7 @@ function readEnum(row, table, column, schema) {
|
|
|
113
113
|
function mapWorkflow(row) {
|
|
114
114
|
return {
|
|
115
115
|
id: readText(row, "workflows", "id"),
|
|
116
|
-
|
|
116
|
+
slug: readText(row, "workflows", "slug"),
|
|
117
117
|
manifest: readJson(row, "workflows", "manifest", workflowManifestSchema),
|
|
118
118
|
program: readText(row, "workflows", "program"),
|
|
119
119
|
config: readJson(row, "workflows", "config", configSchema),
|
|
@@ -267,7 +267,7 @@ export class Store {
|
|
|
267
267
|
// Workflows
|
|
268
268
|
// --------------------------------------------------------------------------
|
|
269
269
|
/**
|
|
270
|
-
* Insert a workflow or update it by
|
|
270
|
+
* Insert a workflow or update it by slug (deploying again is always an update — the slug is
|
|
271
271
|
* the user-facing identity, so the id stays stable across redeploys and existing runs keep
|
|
272
272
|
* their foreign keys). `updated_at` bumps on update; `created_at` and `id` never change.
|
|
273
273
|
*/
|
|
@@ -276,29 +276,29 @@ export class Store {
|
|
|
276
276
|
// caller bug is better rejected here than persisted and discovered as INTERNAL on read.
|
|
277
277
|
const manifest = workflowManifestSchema.safeParse(args.manifest);
|
|
278
278
|
if (!manifest.success) {
|
|
279
|
-
throw new EngineError("VALIDATION", `manifest for workflow "${args.
|
|
279
|
+
throw new EngineError("VALIDATION", `manifest for workflow "${args.slug}" failed validation: ${manifest.error.message}`);
|
|
280
280
|
}
|
|
281
281
|
const manifestJson = JSON.stringify(manifest.data);
|
|
282
282
|
const configJson = JSON.stringify(args.config ?? {});
|
|
283
283
|
return this.transaction(() => {
|
|
284
284
|
const t = this.now();
|
|
285
|
-
const existing = this.prepare("SELECT id FROM workflows WHERE
|
|
285
|
+
const existing = this.prepare("SELECT id FROM workflows WHERE slug = ?").get(args.slug);
|
|
286
286
|
if (existing === undefined) {
|
|
287
|
-
this.prepare(`INSERT INTO workflows (id,
|
|
288
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`).run(ulid(t), args.
|
|
287
|
+
this.prepare(`INSERT INTO workflows (id, slug, manifest, program, config, created_at, updated_at)
|
|
288
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`).run(ulid(t), args.slug, manifestJson, args.program, configJson, t, t);
|
|
289
289
|
}
|
|
290
290
|
else {
|
|
291
|
-
this.prepare("UPDATE workflows SET manifest = ?, program = ?, config = ?, updated_at = ? WHERE
|
|
291
|
+
this.prepare("UPDATE workflows SET manifest = ?, program = ?, config = ?, updated_at = ? WHERE slug = ?").run(manifestJson, args.program, configJson, t, args.slug);
|
|
292
292
|
}
|
|
293
|
-
const row = this.getWorkflow(args.
|
|
293
|
+
const row = this.getWorkflow(args.slug);
|
|
294
294
|
if (row === null) {
|
|
295
|
-
throw new EngineError("INTERNAL", `workflow "${args.
|
|
295
|
+
throw new EngineError("INTERNAL", `workflow "${args.slug}" vanished mid-upsert`);
|
|
296
296
|
}
|
|
297
297
|
return row;
|
|
298
298
|
});
|
|
299
299
|
}
|
|
300
|
-
getWorkflow(
|
|
301
|
-
const row = this.prepare("SELECT * FROM workflows WHERE
|
|
300
|
+
getWorkflow(slug) {
|
|
301
|
+
const row = this.prepare("SELECT * FROM workflows WHERE slug = ?").get(slug);
|
|
302
302
|
return row === undefined ? null : mapWorkflow(row);
|
|
303
303
|
}
|
|
304
304
|
getWorkflowById(id) {
|
|
@@ -306,7 +306,7 @@ export class Store {
|
|
|
306
306
|
return row === undefined ? null : mapWorkflow(row);
|
|
307
307
|
}
|
|
308
308
|
listWorkflows() {
|
|
309
|
-
return this.prepare("SELECT * FROM workflows ORDER BY
|
|
309
|
+
return this.prepare("SELECT * FROM workflows ORDER BY slug ASC").all().map(mapWorkflow);
|
|
310
310
|
}
|
|
311
311
|
// --------------------------------------------------------------------------
|
|
312
312
|
// Runs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boardwalk-labs/engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "The Boardwalk single-node engine: cron scheduling, run lifecycle, SQLite state, and the local run log. Powers `boardwalk dev` and the self-hosted server.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"coverage": "vitest run --coverage"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@boardwalk-labs/workflow": "^0.1.
|
|
43
|
+
"@boardwalk-labs/workflow": "^0.1.5",
|
|
44
44
|
"zod": "^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|