@lovable.dev/workflows-sdk 0.0.0-dev.20 → 0.0.0-dev.21
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 +3 -1
- package/dist/{branch-metadata-CZOTNcFb.js → branch-metadata-D3f-8DT-.js} +1 -1
- package/dist/{context-escapes-B25pWh07.js → context-escapes-DPKbDPIx.js} +1 -1
- package/dist/{duplicate-ids-DElsXi_P.js → duplicate-ids-C4Ug3kFs.js} +1 -1
- package/dist/{generate-BXCYaFf_.js → generate-CrIdSenf.js} +7 -7
- package/dist/{graph-CHhlUDD3.js → graph-BDLuv4B_.js} +129 -61
- package/dist/index.js +1 -1
- package/dist/{nested-operations-A16hbdxU.js → nested-operations-IG6_OTsi.js} +1 -1
- package/dist/{operation-descriptions-BgyQzZ2-.js → operation-descriptions-DWsquPYE.js} +1 -1
- package/dist/{step-metadata-DJ1CNwqI.js → step-metadata-CPpfxR2q.js} +1 -1
- package/dist/vite.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -315,7 +315,9 @@ Sequential awaited `ctx.step("name", callback, options)` calls produce order edg
|
|
|
315
315
|
that join at the next step. A `Promise.all()` mapped over a collection with the
|
|
316
316
|
step ID template `step-${item.id}` produces one dynamic parallel node labeled
|
|
317
317
|
from `meta.group.label`. Returned step promises work too. Keep step IDs literal
|
|
318
|
-
outside this mapped form.
|
|
318
|
+
outside this mapped form. A `try` block retains its durable operations when the
|
|
319
|
+
`catch` only handles the error in ordinary code. Durable operations in a `catch`
|
|
320
|
+
remain visible in a partial graph because edges do not encode error outcomes.
|
|
319
321
|
|
|
320
322
|
An `if` whose body contains durable operations produces a `branch` node. Every
|
|
321
323
|
durable operation inside it includes an outer-to-inner `meta.branches` path;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
2
|
-
import { loadTypeScript, t as workflowHandlerSource } from "./graph-
|
|
2
|
+
import { loadTypeScript, t as workflowHandlerSource } from "./graph-BDLuv4B_.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,13 +183,13 @@ function serializeSchema(schema, direction, label) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
async function generateManifests(definition) {
|
|
186
|
-
const { extractWorkflowGraph } = await import("./graph-
|
|
187
|
-
const { findBranchMetadataIssues } = await import("./branch-metadata-
|
|
188
|
-
const { findWorkflowContextEscapes } = await import("./context-escapes-
|
|
189
|
-
const { findDuplicateOperationIds } = await import("./duplicate-ids-
|
|
190
|
-
const { findNestedDurableOperations } = await import("./nested-operations-
|
|
191
|
-
const { findOperationDescriptionIssues } = await import("./operation-descriptions-
|
|
192
|
-
const { findStepMetadataIssues } = await import("./step-metadata-
|
|
186
|
+
const { extractWorkflowGraph } = await import("./graph-BDLuv4B_.js");
|
|
187
|
+
const { findBranchMetadataIssues } = await import("./branch-metadata-D3f-8DT-.js");
|
|
188
|
+
const { findWorkflowContextEscapes } = await import("./context-escapes-DPKbDPIx.js");
|
|
189
|
+
const { findDuplicateOperationIds } = await import("./duplicate-ids-C4Ug3kFs.js");
|
|
190
|
+
const { findNestedDurableOperations } = await import("./nested-operations-IG6_OTsi.js");
|
|
191
|
+
const { findOperationDescriptionIssues } = await import("./operation-descriptions-DWsquPYE.js");
|
|
192
|
+
const { findStepMetadataIssues } = await import("./step-metadata-CPpfxR2q.js");
|
|
193
193
|
const collection = registerWorkflows(definition);
|
|
194
194
|
const manifests = [];
|
|
195
195
|
for (const workflow of collection.workflows) {
|
|
@@ -320,30 +320,67 @@ async function extractWorkflowGraph(handler) {
|
|
|
320
320
|
label: stepId
|
|
321
321
|
}, parents);
|
|
322
322
|
}
|
|
323
|
+
function path(tails, reachable = true) {
|
|
324
|
+
return {
|
|
325
|
+
tails: reachable ? tails : [],
|
|
326
|
+
reachable
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function mergePaths(...items) {
|
|
330
|
+
const tails = [];
|
|
331
|
+
const seen = /* @__PURE__ */ new Set();
|
|
332
|
+
for (const item of items) for (const tail of item.tails) {
|
|
333
|
+
const key = JSON.stringify(tail);
|
|
334
|
+
if (seen.has(key)) continue;
|
|
335
|
+
seen.add(key);
|
|
336
|
+
tails.push(tail);
|
|
337
|
+
}
|
|
338
|
+
return path(tails, items.some((item) => item.reachable));
|
|
339
|
+
}
|
|
323
340
|
function expression(node, parents, awaited = false) {
|
|
324
341
|
if (ts.isParenthesizedExpression(node)) return expression(node.expression, parents, awaited);
|
|
325
342
|
if (ts.isAwaitExpression(node)) return expression(node.expression, parents, true);
|
|
326
343
|
if (durableCall(node)) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
344
|
+
let tails = awaited ? durableNode(node, parents) : unknown("Unawaited durable calls are not supported yet", parents);
|
|
345
|
+
if (node.arguments.some((argument) => contains(argument, durableCall))) tails = unknown("Nested durable calls are not supported yet", tails);
|
|
346
|
+
return {
|
|
347
|
+
tails,
|
|
348
|
+
thrown: path(tails)
|
|
349
|
+
};
|
|
331
350
|
}
|
|
332
351
|
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) {
|
|
333
352
|
const argument = node.arguments[0];
|
|
334
353
|
if (ts.isArrayLiteralExpression(argument)) {
|
|
335
354
|
const elements = argument.elements;
|
|
336
|
-
if (elements.some((element) => contains(element, ts.isAwaitExpression, true)))
|
|
337
|
-
|
|
355
|
+
if (elements.some((element) => contains(element, ts.isAwaitExpression, true))) {
|
|
356
|
+
const tails = unknown("Await expressions inside Promise.all are not supported yet", parents);
|
|
357
|
+
return {
|
|
358
|
+
tails,
|
|
359
|
+
thrown: path(tails)
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (elements.length === 0) return {
|
|
363
|
+
tails: parents,
|
|
364
|
+
thrown: path([], false)
|
|
365
|
+
};
|
|
366
|
+
const flows = elements.map((element) => {
|
|
338
367
|
while (ts.isParenthesizedExpression(element)) element = element.expression;
|
|
339
|
-
|
|
340
|
-
|
|
368
|
+
if (ts.isCallExpression(element)) return expression(element, parents, true);
|
|
369
|
+
const tails = unknown("Dynamic Promise.all entries are not followed", parents);
|
|
370
|
+
return {
|
|
371
|
+
tails,
|
|
372
|
+
thrown: path(tails)
|
|
373
|
+
};
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
tails: flows.flatMap((flow) => flow.tails),
|
|
377
|
+
thrown: mergePaths(...flows.map((flow) => flow.thrown))
|
|
378
|
+
};
|
|
341
379
|
}
|
|
342
380
|
const mapped = mappedStep(argument);
|
|
343
381
|
if (mapped !== void 0) {
|
|
344
382
|
const metadata = stepMetadata(mapped.call);
|
|
345
|
-
|
|
346
|
-
return addNode({
|
|
383
|
+
const tails = metadata?.group ? addNode({
|
|
347
384
|
kind: "parallel",
|
|
348
385
|
groupId: metadata.group.id,
|
|
349
386
|
cardinality: "dynamic",
|
|
@@ -353,12 +390,28 @@ async function extractWorkflowGraph(handler) {
|
|
|
353
390
|
description: metadata.description
|
|
354
391
|
},
|
|
355
392
|
label: metadata.group.label
|
|
356
|
-
}, parents);
|
|
393
|
+
}, parents) : unknown("Dynamic parallel steps need static group metadata", parents);
|
|
394
|
+
return {
|
|
395
|
+
tails,
|
|
396
|
+
thrown: path(tails)
|
|
397
|
+
};
|
|
357
398
|
}
|
|
358
399
|
}
|
|
359
|
-
if (contains(node, (child) => ts.isCallExpression(child) || ts.isAwaitExpression(child) || ts.isNewExpression(child)))
|
|
360
|
-
|
|
361
|
-
|
|
400
|
+
if (contains(node, (child) => ts.isCallExpression(child) || ts.isAwaitExpression(child) || ts.isNewExpression(child))) {
|
|
401
|
+
const tails = unknown("Helper calls and dynamic expressions are not followed", parents);
|
|
402
|
+
return {
|
|
403
|
+
tails,
|
|
404
|
+
thrown: path(tails)
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
if (ts.isIdentifier(node) && node.text === context) return {
|
|
408
|
+
tails: unknown("Workflow context aliases are not followed", parents),
|
|
409
|
+
thrown: path([], false)
|
|
410
|
+
};
|
|
411
|
+
return {
|
|
412
|
+
tails: parents,
|
|
413
|
+
thrown: path([], false)
|
|
414
|
+
};
|
|
362
415
|
}
|
|
363
416
|
function branchInfo(statement, depth) {
|
|
364
417
|
let result;
|
|
@@ -374,51 +427,57 @@ async function extractWorkflowGraph(handler) {
|
|
|
374
427
|
if (statement.elseStatement) visit(statement.elseStatement);
|
|
375
428
|
return result;
|
|
376
429
|
}
|
|
377
|
-
function
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
430
|
+
function statementFlow(normal, thrown = path([], false), returned = path([], false)) {
|
|
431
|
+
return {
|
|
432
|
+
normal,
|
|
433
|
+
thrown,
|
|
434
|
+
returned
|
|
381
435
|
};
|
|
436
|
+
}
|
|
437
|
+
function statements(items, parents, branchDepth) {
|
|
438
|
+
let normal = path(parents);
|
|
439
|
+
let thrown = path([], false);
|
|
440
|
+
let returned = path([], false);
|
|
382
441
|
for (const statement of items) {
|
|
383
|
-
if (!
|
|
384
|
-
flow = walkStatement(statement,
|
|
442
|
+
if (!normal.reachable) break;
|
|
443
|
+
const flow = walkStatement(statement, normal.tails, branchDepth);
|
|
444
|
+
normal = flow.normal;
|
|
445
|
+
thrown = mergePaths(thrown, flow.thrown);
|
|
446
|
+
returned = mergePaths(returned, flow.returned);
|
|
385
447
|
}
|
|
386
|
-
return
|
|
448
|
+
return statementFlow(normal, thrown, returned);
|
|
387
449
|
}
|
|
388
450
|
function walkStatement(statement, parents, branchDepth) {
|
|
389
451
|
if (ts.isBlock(statement)) return statements(statement.statements, parents, branchDepth);
|
|
390
452
|
if (ts.isReturnStatement(statement)) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
fallsThrough: false
|
|
453
|
+
const result = statement.expression ? expression(statement.expression, parents, true) : {
|
|
454
|
+
tails: parents,
|
|
455
|
+
thrown: path([], false)
|
|
395
456
|
};
|
|
457
|
+
return statementFlow(path([], false), result.thrown, path(result.tails));
|
|
396
458
|
}
|
|
397
459
|
if (ts.isThrowStatement(statement)) {
|
|
398
|
-
expression(statement.expression, parents);
|
|
399
|
-
return
|
|
400
|
-
tails: [],
|
|
401
|
-
fallsThrough: false
|
|
402
|
-
};
|
|
460
|
+
const result = expression(statement.expression, parents);
|
|
461
|
+
return statementFlow(path([], false), mergePaths(result.thrown, path(result.tails)));
|
|
403
462
|
}
|
|
404
463
|
if (ts.isVariableStatement(statement)) {
|
|
405
|
-
if (statement.declarationList.declarations.some((item) => contains(item.name, (child) => ts.isIdentifier(child) && (child.text === "Promise" || child.text === context)))) return
|
|
406
|
-
tails: unknown("Shadowed context or Promise bindings are not supported yet", parents),
|
|
407
|
-
fallsThrough: false
|
|
408
|
-
};
|
|
464
|
+
if (statement.declarationList.declarations.some((item) => contains(item.name, (child) => ts.isIdentifier(child) && (child.text === "Promise" || child.text === context)))) return statementFlow(path(unknown("Shadowed context or Promise bindings are not supported yet", parents)));
|
|
409
465
|
let tails = parents;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
466
|
+
let thrown = path([], false);
|
|
467
|
+
for (const item of statement.declarationList.declarations) {
|
|
468
|
+
if (!item.initializer) continue;
|
|
469
|
+
const result = expression(item.initializer, tails);
|
|
470
|
+
tails = result.tails;
|
|
471
|
+
thrown = mergePaths(thrown, result.thrown);
|
|
472
|
+
}
|
|
473
|
+
return statementFlow(path(tails), thrown);
|
|
474
|
+
}
|
|
475
|
+
if (ts.isExpressionStatement(statement)) {
|
|
476
|
+
const result = expression(statement.expression, parents);
|
|
477
|
+
return statementFlow(path(result.tails), result.thrown);
|
|
415
478
|
}
|
|
416
|
-
if (ts.isExpressionStatement(statement)) return {
|
|
417
|
-
tails: expression(statement.expression, parents),
|
|
418
|
-
fallsThrough: true
|
|
419
|
-
};
|
|
420
479
|
if (ts.isIfStatement(statement)) {
|
|
421
|
-
const
|
|
480
|
+
const conditionFlow = expression(statement.expression, parents);
|
|
422
481
|
const metadata = branchInfo(statement, branchDepth);
|
|
423
482
|
const condition = statement.expression.getText(source);
|
|
424
483
|
const branchTails = metadata ? addNode({
|
|
@@ -427,7 +486,7 @@ async function extractWorkflowGraph(handler) {
|
|
|
427
486
|
condition,
|
|
428
487
|
description: metadata.description,
|
|
429
488
|
label: metadata.description
|
|
430
|
-
},
|
|
489
|
+
}, conditionFlow.tails) : conditionFlow.tails;
|
|
431
490
|
const sourceId = metadata ? branchTails[0]?.source : void 0;
|
|
432
491
|
const thenParents = sourceId ? [{
|
|
433
492
|
source: sourceId,
|
|
@@ -440,23 +499,32 @@ async function extractWorkflowGraph(handler) {
|
|
|
440
499
|
outcome: false
|
|
441
500
|
}] : branchTails;
|
|
442
501
|
const thenFlow = walkStatement(statement.thenStatement, thenParents, branchDepth + 1);
|
|
443
|
-
const elseFlow = statement.elseStatement ? walkStatement(statement.elseStatement, elseParents, branchDepth + 1) :
|
|
444
|
-
|
|
445
|
-
fallsThrough: true
|
|
446
|
-
};
|
|
447
|
-
return {
|
|
448
|
-
tails: [...thenFlow.fallsThrough ? thenFlow.tails : [], ...elseFlow.fallsThrough ? elseFlow.tails : []],
|
|
449
|
-
fallsThrough: thenFlow.fallsThrough || elseFlow.fallsThrough
|
|
450
|
-
};
|
|
502
|
+
const elseFlow = statement.elseStatement ? walkStatement(statement.elseStatement, elseParents, branchDepth + 1) : statementFlow(path(elseParents));
|
|
503
|
+
return statementFlow(mergePaths(thenFlow.normal, elseFlow.normal), mergePaths(conditionFlow.thrown, thenFlow.thrown, elseFlow.thrown), mergePaths(thenFlow.returned, elseFlow.returned));
|
|
451
504
|
}
|
|
452
|
-
if (ts.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
505
|
+
if (ts.isTryStatement(statement)) {
|
|
506
|
+
const tryFlow = walkStatement(statement.tryBlock, parents, branchDepth);
|
|
507
|
+
const catchBlock = statement.catchClause?.block;
|
|
508
|
+
const catchHasDurableOperations = catchBlock ? contains(catchBlock, durableCall) : false;
|
|
509
|
+
const catchHasAbruptCompletion = catchBlock ? contains(catchBlock, (node) => ts.isReturnStatement(node) || ts.isThrowStatement(node), true) : false;
|
|
510
|
+
let catchFlow = statementFlow(path([], false));
|
|
511
|
+
if (catchBlock && (tryFlow.thrown.reachable || catchHasDurableOperations || catchHasAbruptCompletion)) if (catchHasDurableOperations || catchHasAbruptCompletion) catchFlow = walkStatement(catchBlock, unknown(catchHasDurableOperations ? "Durable catch paths are conditional on errors" : "Catch completion paths are conditional on errors", tryFlow.thrown.reachable ? tryFlow.thrown.tails : parents), branchDepth);
|
|
512
|
+
else catchFlow = statementFlow(path(tryFlow.thrown.tails));
|
|
513
|
+
const normal = mergePaths(tryFlow.normal, catchFlow.normal);
|
|
514
|
+
const thrown = catchBlock ? catchFlow.thrown : tryFlow.thrown;
|
|
515
|
+
const returned = mergePaths(tryFlow.returned, catchFlow.returned);
|
|
516
|
+
const flow = statementFlow(normal, thrown, returned);
|
|
517
|
+
if (!statement.finallyBlock) return flow;
|
|
518
|
+
const finallyHasDurableOperations = contains(statement.finallyBlock, durableCall);
|
|
519
|
+
const finallyHasAbruptCompletion = contains(statement.finallyBlock, (node) => ts.isReturnStatement(node) || ts.isThrowStatement(node), true);
|
|
520
|
+
if (!finallyHasDurableOperations && !finallyHasAbruptCompletion) return flow;
|
|
521
|
+
const finallyParents = mergePaths(normal, thrown, returned);
|
|
522
|
+
const finallyFlow = walkStatement(statement.finallyBlock, finallyParents.tails, branchDepth);
|
|
523
|
+
const completedFinally = finallyFlow.normal.reachable;
|
|
524
|
+
return statementFlow(path(finallyFlow.normal.tails, normal.reachable && completedFinally), mergePaths(finallyFlow.thrown, path(finallyFlow.normal.tails, thrown.reachable && completedFinally)), mergePaths(finallyFlow.returned, path(finallyFlow.normal.tails, returned.reachable && completedFinally)));
|
|
525
|
+
}
|
|
526
|
+
if (ts.isEmptyStatement(statement)) return statementFlow(path(parents));
|
|
527
|
+
return statementFlow(path(unknown("Loops and other control flow are not supported yet", parents)));
|
|
460
528
|
}
|
|
461
529
|
const tails = [];
|
|
462
530
|
if (!ts.isBlock(fn.body)) {
|
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-CrIdSenf.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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadTypeScript, t as workflowHandlerSource } from "./graph-
|
|
1
|
+
import { loadTypeScript, t as workflowHandlerSource } from "./graph-BDLuv4B_.js";
|
|
2
2
|
//#region src/manifests/step-metadata.ts
|
|
3
3
|
async function findStepMetadataIssues(handler) {
|
|
4
4
|
const api = await loadTypeScript();
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as generateManifests } from "./generate-
|
|
1
|
+
import { t as generateManifests } from "./generate-CrIdSenf.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";
|