@lovable.dev/workflows-sdk 0.0.0-dev.13 → 0.0.0-dev.14
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 +16 -8
- package/dist/{duplicate-ids-CzUHGRC_.js → duplicate-ids-DFD8TO2y.js} +1 -1
- package/dist/{generate-CKSL3f8L.js → generate-CUlH7Z2x.js} +3 -3
- package/dist/{graph-CPDci8jW.js → graph-CZDg07_0.js} +53 -7
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/{nested-operations-BnWB9UhQ.js → nested-operations-OEvIJ3AZ.js} +1 -1
- package/dist/vite.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -273,13 +273,19 @@ every graph carries one `unknown` node and the diagnostic
|
|
|
273
273
|
`Install typescript to infer step graphs`.
|
|
274
274
|
Sequential awaited `ctx.step("name", callback)` calls produce order edges;
|
|
275
275
|
`await Promise.all([ctx.step(...), ctx.step(...)])` produces parallel branches
|
|
276
|
-
that join at the next step.
|
|
276
|
+
that join at the next step. A `Promise.all()` mapped over a collection with the
|
|
277
|
+
step ID template `step-${item.id}` produces one dynamic parallel node labeled
|
|
278
|
+
`step-{item.id}`. Returned step promises work too. Keep step IDs literal outside
|
|
279
|
+
this mapped form.
|
|
277
280
|
|
|
278
281
|
| Field | Meaning |
|
|
279
282
|
| --- | --- |
|
|
280
283
|
| `nodes[].id` | Unique occurrence ID within this graph; use as the UI node key |
|
|
281
|
-
| `nodes[].kind` | `
|
|
282
|
-
| `nodes[].stepId` | Literal step name, present for
|
|
284
|
+
| `nodes[].kind` | Durable operation, `parallel`, or `unknown` |
|
|
285
|
+
| `nodes[].stepId` | Literal step name, present for statically named steps |
|
|
286
|
+
| `nodes[].cardinality` | `dynamic` for a runtime-sized parallel fan-out |
|
|
287
|
+
| `nodes[].operation.kind` | Durable operation repeated by a parallel node |
|
|
288
|
+
| `nodes[].operation.stepIdTemplate` | Display template for steps in a dynamic parallel node |
|
|
283
289
|
| `nodes[].label` | Step name or explanation of unsupported code |
|
|
284
290
|
| `edges[]` | `{ source, target, kind: "order" }`, referencing node IDs |
|
|
285
291
|
| `complete` | Whether the handler uses only supported syntax |
|
|
@@ -292,11 +298,13 @@ is edited.
|
|
|
292
298
|
|
|
293
299
|
Graphs have `source: "inferred"` and `scope: "handler"`. They describe source
|
|
294
300
|
structure, not run history or data dependencies, and exclude middleware and
|
|
295
|
-
initialization.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
301
|
+
initialization. A mapped `Promise.all` is complete when its callback directly
|
|
302
|
+
returns `ctx.step()` with a template-literal ID derived from a callback parameter.
|
|
303
|
+
Other branches, loops, helper calls, dynamic step IDs, and unawaited steps produce
|
|
304
|
+
`unknown` nodes and `complete: false`; steps inside unsupported code are not
|
|
305
|
+
expanded. The UI should show these unknown nodes and mark partial graphs.
|
|
306
|
+
Transforms that rewrite the handler may also produce a partial graph. A handler
|
|
307
|
+
with no steps can have an empty graph.
|
|
300
308
|
|
|
301
309
|
A step body is one atomic execution unit. Manifest generation rejects statically
|
|
302
310
|
visible durable calls inside it, including `ctx.step`, `ctx.sleep`, `ctx.now`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
2
|
-
import { loadTypeScript } from "./graph-
|
|
2
|
+
import { loadTypeScript } from "./graph-CZDg07_0.js";
|
|
3
3
|
//#region src/manifests/duplicate-ids.ts
|
|
4
4
|
/** Where an explicit `{ id }` would sit for each operation. */
|
|
5
5
|
const optionsArgument = {
|
|
@@ -183,9 +183,9 @@ function serializeSchema(schema, direction, label) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
async function generateManifests(definition) {
|
|
186
|
-
const { extractWorkflowGraph } = await import("./graph-
|
|
187
|
-
const { findDuplicateOperationIds } = await import("./duplicate-ids-
|
|
188
|
-
const { findNestedDurableOperations } = await import("./nested-operations-
|
|
186
|
+
const { extractWorkflowGraph } = await import("./graph-CZDg07_0.js");
|
|
187
|
+
const { findDuplicateOperationIds } = await import("./duplicate-ids-DFD8TO2y.js");
|
|
188
|
+
const { findNestedDurableOperations } = await import("./nested-operations-OEvIJ3AZ.js");
|
|
189
189
|
const collection = registerWorkflows(definition);
|
|
190
190
|
const manifests = [];
|
|
191
191
|
for (const workflow of collection.workflows) {
|
|
@@ -85,6 +85,39 @@ async function extractWorkflowGraph(handler) {
|
|
|
85
85
|
const value = Number(node.text);
|
|
86
86
|
return Number.isFinite(value) ? value : void 0;
|
|
87
87
|
}
|
|
88
|
+
function templateReference(node, parameters) {
|
|
89
|
+
while (ts.isParenthesizedExpression(node)) node = node.expression;
|
|
90
|
+
if (ts.isIdentifier(node)) return parameters.has(node.text) ? node.text : void 0;
|
|
91
|
+
if (ts.isPropertyAccessExpression(node) && !node.questionDotToken) {
|
|
92
|
+
const expression = templateReference(node.expression, parameters);
|
|
93
|
+
return expression === void 0 ? void 0 : `${expression}.${node.name.text}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function stepIdTemplate(node, parameters) {
|
|
97
|
+
if (!node || !ts.isTemplateExpression(node)) return void 0;
|
|
98
|
+
let template = node.head.text;
|
|
99
|
+
for (const span of node.templateSpans) {
|
|
100
|
+
const reference = templateReference(span.expression, parameters);
|
|
101
|
+
if (reference === void 0) return void 0;
|
|
102
|
+
template += `{${reference}}${span.literal.text}`;
|
|
103
|
+
}
|
|
104
|
+
return template;
|
|
105
|
+
}
|
|
106
|
+
function mappedStepTemplate(node) {
|
|
107
|
+
while (ts.isParenthesizedExpression(node)) node = node.expression;
|
|
108
|
+
if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression) || node.expression.name.text !== "map" || node.arguments.length !== 1) return;
|
|
109
|
+
const callback = node.arguments[0];
|
|
110
|
+
if (!ts.isArrowFunction(callback) && !ts.isFunctionExpression(callback)) return void 0;
|
|
111
|
+
const parameters = new Set(callback.parameters.flatMap((parameter) => ts.isIdentifier(parameter.name) ? [parameter.name.text] : []));
|
|
112
|
+
let body;
|
|
113
|
+
if (ts.isBlock(callback.body)) {
|
|
114
|
+
const statement = callback.body.statements.length === 1 ? callback.body.statements[0] : void 0;
|
|
115
|
+
body = statement && ts.isReturnStatement(statement) ? statement.expression : void 0;
|
|
116
|
+
} else body = callback.body;
|
|
117
|
+
while (body && (ts.isParenthesizedExpression(body) || ts.isAwaitExpression(body))) body = body.expression;
|
|
118
|
+
if (!body || !durableCall(body) || body.expression.name.text !== "step") return;
|
|
119
|
+
return stepIdTemplate(body.arguments[0], parameters);
|
|
120
|
+
}
|
|
88
121
|
function readableOptions(node) {
|
|
89
122
|
return node && ts.isObjectLiteralExpression(node) && node.properties.every(ts.isPropertyAssignment) ? node : void 0;
|
|
90
123
|
}
|
|
@@ -164,13 +197,26 @@ async function extractWorkflowGraph(handler) {
|
|
|
164
197
|
if (node.arguments.some((argument) => contains(argument, durableCall))) return unknown("Nested durable calls are not supported yet", tails);
|
|
165
198
|
return tails;
|
|
166
199
|
}
|
|
167
|
-
if (awaited && ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && node.expression.expression.text === "Promise" && node.expression.name.text === "all" && node.arguments.length === 1
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return
|
|
173
|
-
|
|
200
|
+
if (awaited && ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && node.expression.expression.text === "Promise" && node.expression.name.text === "all" && node.arguments.length === 1) {
|
|
201
|
+
const argument = node.arguments[0];
|
|
202
|
+
if (ts.isArrayLiteralExpression(argument)) {
|
|
203
|
+
const elements = argument.elements;
|
|
204
|
+
if (elements.some((element) => contains(element, ts.isAwaitExpression, true))) return unknown("Await expressions inside Promise.all are not supported yet", parents);
|
|
205
|
+
return elements.length > 0 ? elements.flatMap((element) => {
|
|
206
|
+
while (ts.isParenthesizedExpression(element)) element = element.expression;
|
|
207
|
+
return ts.isCallExpression(element) ? expression(element, parents, true) : unknown("Dynamic Promise.all entries are not followed", parents);
|
|
208
|
+
}) : parents;
|
|
209
|
+
}
|
|
210
|
+
const template = mappedStepTemplate(argument);
|
|
211
|
+
if (template !== void 0) return addNode({
|
|
212
|
+
kind: "parallel",
|
|
213
|
+
cardinality: "dynamic",
|
|
214
|
+
operation: {
|
|
215
|
+
kind: "step",
|
|
216
|
+
stepIdTemplate: template
|
|
217
|
+
},
|
|
218
|
+
label: template
|
|
219
|
+
}, parents);
|
|
174
220
|
}
|
|
175
221
|
if (contains(node, (child) => ts.isCallExpression(child) || ts.isAwaitExpression(child) || ts.isNewExpression(child))) return unknown("Helper calls and dynamic expressions are not followed", parents);
|
|
176
222
|
if (ts.isIdentifier(node) && node.text === context) return unknown("Workflow context aliases are not followed", parents);
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,13 @@ declare function registerWorkflows<const TWorkflows extends readonly AnyWorkflow
|
|
|
55
55
|
type WorkflowGraphNodeDetails = {
|
|
56
56
|
kind: "step";
|
|
57
57
|
stepId: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "parallel";
|
|
60
|
+
cardinality: "dynamic";
|
|
61
|
+
operation: {
|
|
62
|
+
kind: "step";
|
|
63
|
+
stepIdTemplate: string;
|
|
64
|
+
};
|
|
58
65
|
} | {
|
|
59
66
|
kind: "approve";
|
|
60
67
|
config: {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineSchedule, c as weekly, i as registerWorkflows, n as createMiddleware, o as daily, r as createWorkflow, s as hourly, t as generateManifests } from "./generate-
|
|
1
|
+
import { a as defineSchedule, c as weekly, i as registerWorkflows, n as createMiddleware, o as daily, r as createWorkflow, s as hourly, t as generateManifests } from "./generate-CUlH7Z2x.js";
|
|
2
2
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
3
3
|
import { WorkflowRequestParseError, inMemoryRunStore, parseWorkflowRequest, runWorkflow } from "@tanstack/workflow-core";
|
|
4
4
|
//#region src/stacks/tanstack/sse.ts
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as generateManifests } from "./generate-
|
|
1
|
+
import { t as generateManifests } from "./generate-CUlH7Z2x.js";
|
|
2
2
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { createServer } from "vite";
|
|
4
4
|
import { lstat, mkdir, mkdtemp, readdir, rename, rm, writeFile } from "node:fs/promises";
|