@lovable.dev/workflows-sdk 0.0.0-dev.1 → 0.0.0-dev.2
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
CHANGED
|
@@ -103,6 +103,12 @@ synchronizing the returned manifests to `.lovable/workflows/` a required build s
|
|
|
103
103
|
|
|
104
104
|
Each manifest's `graph` contains `nodes` and directed `edges`. The SDK parses the
|
|
105
105
|
handler's function source without executing it. No additional registration is needed.
|
|
106
|
+
|
|
107
|
+
Graph inference reads the app's own `typescript`, an optional peer. Apps built
|
|
108
|
+
from a Lovable template already have it. Without it — or with a copy exposing no
|
|
109
|
+
stable JS API, as TypeScript 7 does before 7.1 — the build still succeeds and
|
|
110
|
+
every graph carries one `unknown` node and the diagnostic
|
|
111
|
+
`Install typescript to infer step graphs`.
|
|
106
112
|
Sequential awaited `ctx.step("name", callback)` calls produce order edges;
|
|
107
113
|
`await Promise.all([ctx.step(...), ctx.step(...)])` produces parallel branches
|
|
108
114
|
that join at the next step. Returned step promises work too. Keep step IDs literal.
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
1
|
//#region src/graph-extract.ts
|
|
3
|
-
|
|
2
|
+
let loaded;
|
|
3
|
+
async function loadTypeScript() {
|
|
4
|
+
if (loaded !== void 0) return loaded;
|
|
5
|
+
try {
|
|
6
|
+
const module = await import("typescript");
|
|
7
|
+
const api = module.default ?? module;
|
|
8
|
+
loaded = typeof api?.createSourceFile === "function" ? api : null;
|
|
9
|
+
} catch {
|
|
10
|
+
loaded = null;
|
|
11
|
+
}
|
|
12
|
+
return loaded;
|
|
13
|
+
}
|
|
14
|
+
async function extractWorkflowGraph(handler) {
|
|
4
15
|
const graph = {
|
|
5
16
|
source: "inferred",
|
|
6
17
|
scope: "handler",
|
|
@@ -9,7 +20,6 @@ function extractWorkflowGraph(handler) {
|
|
|
9
20
|
edges: [],
|
|
10
21
|
diagnostics: []
|
|
11
22
|
};
|
|
12
|
-
const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
|
|
13
23
|
function addNode(node, parents) {
|
|
14
24
|
const id = `node-${graph.nodes.length}`;
|
|
15
25
|
graph.nodes.push({
|
|
@@ -31,6 +41,13 @@ function extractWorkflowGraph(handler) {
|
|
|
31
41
|
label: reason
|
|
32
42
|
}, parents);
|
|
33
43
|
}
|
|
44
|
+
const api = await loadTypeScript();
|
|
45
|
+
if (!api) {
|
|
46
|
+
unknown("Install typescript to infer step graphs", []);
|
|
47
|
+
return graph;
|
|
48
|
+
}
|
|
49
|
+
const ts = api;
|
|
50
|
+
const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
|
|
34
51
|
const declaration = source.statements[0];
|
|
35
52
|
const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
|
|
36
53
|
if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as registerWorkflows, r as defineSchedule, t as generateManifests } from "./manifest-
|
|
1
|
+
import { n as registerWorkflows, r as defineSchedule, t as generateManifests } from "./manifest-DIeHMgS8.js";
|
|
2
2
|
import { createMiddleware, createWorkflow } from "@tanstack/workflow-core";
|
|
3
3
|
export { createMiddleware, createWorkflow, defineSchedule, generateManifests, registerWorkflows };
|
|
@@ -70,7 +70,7 @@ function jsonSchema(schema, direction, label) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
async function generateManifests(definition) {
|
|
73
|
-
const { extractWorkflowGraph } = await import("./graph-extract-
|
|
73
|
+
const { extractWorkflowGraph } = await import("./graph-extract-CGLWzaln.js");
|
|
74
74
|
const collection = registerWorkflows(definition);
|
|
75
75
|
const manifests = [];
|
|
76
76
|
for (const workflow of collection.workflows) {
|
|
@@ -103,7 +103,7 @@ async function generateManifests(definition) {
|
|
|
103
103
|
version: 1,
|
|
104
104
|
workflow: metadata,
|
|
105
105
|
schedules,
|
|
106
|
-
graph: extractWorkflowGraph(workflow.handler)
|
|
106
|
+
graph: await extractWorkflowGraph(workflow.handler)
|
|
107
107
|
};
|
|
108
108
|
toJson(manifest, "manifest");
|
|
109
109
|
manifests.push(manifest);
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as generateManifests } from "./manifest-
|
|
1
|
+
import { t as generateManifests } from "./manifest-DIeHMgS8.js";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { createServer } from "vite";
|
|
4
4
|
import { lstat, mkdir, mkdtemp, readdir, rename, rm, writeFile } from "node:fs/promises";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/workflows-sdk",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"tag": "dev",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
32
31
|
"@standard-schema/spec": "^1.1.0",
|
|
33
32
|
"@tanstack/workflow-core": "0.0.4"
|
|
34
33
|
},
|
|
@@ -36,20 +35,25 @@
|
|
|
36
35
|
"@types/node": "22.13.13",
|
|
37
36
|
"vite": "^7.3.1",
|
|
38
37
|
"zod": "^4.1.13",
|
|
39
|
-
"tsdown": "^0.22.5"
|
|
38
|
+
"tsdown": "^0.22.5",
|
|
39
|
+
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"vite": ">=7.3.1 <9"
|
|
42
|
+
"vite": ">=7.3.1 <9",
|
|
43
|
+
"typescript": ">=5.4"
|
|
43
44
|
},
|
|
44
45
|
"peerDependenciesMeta": {
|
|
45
46
|
"vite": {
|
|
46
47
|
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"typescript": {
|
|
50
|
+
"optional": true
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
53
|
"scripts": {
|
|
50
54
|
"build": "tsdown",
|
|
51
55
|
"test": "node --test src/graph.test.mjs",
|
|
52
|
-
"typecheck": "
|
|
53
|
-
"check:package": "tmp=$(mktemp -d) && pnpm pack --out \"$tmp/pkg.tgz\" && tar -xzf \"$tmp/pkg.tgz\" -C \"$tmp\" && publint \"$tmp/package\" --strict && attw \"$tmp/pkg.tgz\""
|
|
56
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
57
|
+
"check:package": "tmp=$(mktemp -d) && pnpm pack --out \"$tmp/pkg.tgz\" && tar -xzf \"$tmp/pkg.tgz\" -C \"$tmp\" && publint \"$tmp/package\" --strict && attw \"$tmp/pkg.tgz\" && node scripts/check-deps.mjs \"$tmp/package/package.json\""
|
|
54
58
|
}
|
|
55
59
|
}
|