@lovable.dev/workflows-sdk 0.0.0-dev.26 → 0.0.0-dev.27
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 +10 -9
- package/dist/{branch-metadata-IXuazOmY.js → branch-metadata-Bv-K2WAN.js} +1 -1
- package/dist/{context-escapes-x0J0HUgC.js → context-escapes-BXC37F36.js} +1 -1
- package/dist/{duplicate-ids-NnTrnieX.js → duplicate-ids-Dv2ICco3.js} +1 -1
- package/dist/generate-Dgj2-55O.js +6893 -0
- package/dist/{graph-Qx9mvqnC.js → graph-CVgB49lW.js} +93 -81
- package/dist/index.d.ts +566 -124
- package/dist/index.js +1 -1
- package/dist/{nested-operations-DYVa5c5A.js → nested-operations-QZiiJCxT.js} +1 -1
- package/dist/{operation-descriptions-BLZC8bxV.js → operation-descriptions-CJxYUpLf.js} +1 -1
- package/dist/{step-metadata-MjyYQjOy.js → step-metadata-DelsyoE1.js} +1 -1
- package/dist/vite.js +3 -3
- package/package.json +2 -1
- package/dist/generate-DHIXkk21.js +0 -287
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as WorkflowManifestUuidNodeV1Schema, a as WorkflowManifestGraphEdgeV1Schema, c as WorkflowManifestLoopNodeV1Schema, d as WorkflowManifestParallelNodeV1Schema, f as WorkflowManifestRepeatedStepV1Schema, g as WorkflowManifestUnknownNodeV1Schema, h as WorkflowManifestStepNodeV1Schema, i as WorkflowManifestBranchNodeV1Schema, l as WorkflowManifestNowNodeV1Schema, m as WorkflowManifestSleepUntilNodeV1Schema, n as WorkflowManifestApproveNodeV1Schema, o as WorkflowManifestGraphNodeV1Schema, p as WorkflowManifestSleepNodeV1Schema, r as WorkflowManifestBranchEdgeV1Schema, s as WorkflowManifestGraphV1Schema, u as WorkflowManifestOrderEdgeV1Schema, v as WorkflowManifestWaitForEventNodeV1Schema, y as create } from "./generate-Dgj2-55O.js";
|
|
1
2
|
import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
|
|
2
3
|
//#region src/manifests/handler-source.ts
|
|
3
4
|
const nativeFunctionSource = /\{\s*\[native code\]\s*\}\s*$/;
|
|
@@ -29,36 +30,42 @@ async function loadTypeScript() {
|
|
|
29
30
|
return loaded;
|
|
30
31
|
}
|
|
31
32
|
async function extractWorkflowGraph(handler) {
|
|
32
|
-
const graph = {
|
|
33
|
+
const graph = create(WorkflowManifestGraphV1Schema, {
|
|
33
34
|
source: "inferred",
|
|
34
35
|
scope: "handler",
|
|
35
36
|
complete: true,
|
|
36
37
|
nodes: [],
|
|
37
38
|
edges: [],
|
|
38
39
|
diagnostics: []
|
|
39
|
-
};
|
|
40
|
-
function addNode(
|
|
40
|
+
});
|
|
41
|
+
function addNode(label, kind, parents) {
|
|
41
42
|
const id = `node-${graph.nodes.length}`;
|
|
42
|
-
graph.nodes.push({
|
|
43
|
+
graph.nodes.push(create(WorkflowManifestGraphNodeV1Schema, {
|
|
43
44
|
id,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
label,
|
|
46
|
+
kind
|
|
47
|
+
}));
|
|
46
48
|
const seen = /* @__PURE__ */ new Set();
|
|
47
49
|
for (const parent of parents) {
|
|
48
50
|
const key = JSON.stringify(parent);
|
|
49
51
|
if (seen.has(key)) continue;
|
|
50
52
|
seen.add(key);
|
|
51
|
-
if (parent.kind === "order") graph.edges.push({
|
|
53
|
+
if (parent.kind === "order") graph.edges.push(create(WorkflowManifestGraphEdgeV1Schema, {
|
|
52
54
|
source: parent.source,
|
|
53
55
|
target: id,
|
|
54
|
-
kind:
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
kind: {
|
|
57
|
+
case: "order",
|
|
58
|
+
value: create(WorkflowManifestOrderEdgeV1Schema)
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
else graph.edges.push(create(WorkflowManifestGraphEdgeV1Schema, {
|
|
57
62
|
source: parent.source,
|
|
58
63
|
target: id,
|
|
59
|
-
kind:
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
kind: {
|
|
65
|
+
case: "branch",
|
|
66
|
+
value: create(WorkflowManifestBranchEdgeV1Schema, { outcome: parent.outcome })
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
62
69
|
}
|
|
63
70
|
return [{
|
|
64
71
|
source: id,
|
|
@@ -71,9 +78,9 @@ async function extractWorkflowGraph(handler) {
|
|
|
71
78
|
}
|
|
72
79
|
function unknown(reason, parents) {
|
|
73
80
|
degrade(reason);
|
|
74
|
-
return addNode({
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
return addNode(reason, {
|
|
82
|
+
case: "unknown",
|
|
83
|
+
value: create(WorkflowManifestUnknownNodeV1Schema)
|
|
77
84
|
}, parents);
|
|
78
85
|
}
|
|
79
86
|
const api = await loadTypeScript();
|
|
@@ -237,11 +244,12 @@ async function extractWorkflowGraph(handler) {
|
|
|
237
244
|
if (stepId === void 0) return unknown("Dynamic step IDs are not supported yet", parents);
|
|
238
245
|
const metadata = stepMetadata(call);
|
|
239
246
|
if (!metadata) return unknown("Step descriptions must be static strings", parents);
|
|
240
|
-
return addNode({
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
247
|
+
return addNode(stepId, {
|
|
248
|
+
case: "step",
|
|
249
|
+
value: create(WorkflowManifestStepNodeV1Schema, {
|
|
250
|
+
stepId,
|
|
251
|
+
description: metadata.description
|
|
252
|
+
})
|
|
245
253
|
}, parents);
|
|
246
254
|
}
|
|
247
255
|
if (method === "approve") {
|
|
@@ -255,15 +263,13 @@ async function extractWorkflowGraph(handler) {
|
|
|
255
263
|
if (stepId === void 0) return unknown("Dynamic approval IDs are not supported yet", parents);
|
|
256
264
|
const description = stringLiteral(option(options, "description"));
|
|
257
265
|
if (description === void 0) return unknown("Approval descriptions must be static strings", parents);
|
|
258
|
-
return addNode({
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
title
|
|
264
|
-
|
|
265
|
-
},
|
|
266
|
-
label: title
|
|
266
|
+
return addNode(title, {
|
|
267
|
+
case: "approve",
|
|
268
|
+
value: create(WorkflowManifestApproveNodeV1Schema, {
|
|
269
|
+
stepId,
|
|
270
|
+
description,
|
|
271
|
+
title
|
|
272
|
+
})
|
|
267
273
|
}, parents);
|
|
268
274
|
}
|
|
269
275
|
if (method === "waitForEvent") {
|
|
@@ -280,15 +286,14 @@ async function extractWorkflowGraph(handler) {
|
|
|
280
286
|
const given = option(options, "deadline");
|
|
281
287
|
const deadline = numberLiteral(given);
|
|
282
288
|
if (given && deadline === void 0) degrade("Dynamic waitForEvent deadlines are not recorded");
|
|
283
|
-
return addNode({
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
289
|
+
return addNode(event, {
|
|
290
|
+
case: "waitForEvent",
|
|
291
|
+
value: create(WorkflowManifestWaitForEventNodeV1Schema, {
|
|
292
|
+
stepId,
|
|
293
|
+
description,
|
|
288
294
|
event,
|
|
289
295
|
...deadline === void 0 ? {} : { deadline }
|
|
290
|
-
}
|
|
291
|
-
label: event
|
|
296
|
+
})
|
|
292
297
|
}, parents);
|
|
293
298
|
}
|
|
294
299
|
if (method === "sleep") {
|
|
@@ -302,12 +307,13 @@ async function extractWorkflowGraph(handler) {
|
|
|
302
307
|
if (stepId === void 0) return unknown("Dynamic sleep IDs are not supported yet", parents);
|
|
303
308
|
const description = operationDescription(options);
|
|
304
309
|
if (description === void 0) return unknown("Sleep descriptions must be static strings", parents);
|
|
305
|
-
return addNode({
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
return addNode(`sleep ${ms}ms`, {
|
|
311
|
+
case: "sleep",
|
|
312
|
+
value: create(WorkflowManifestSleepNodeV1Schema, {
|
|
313
|
+
stepId,
|
|
314
|
+
description,
|
|
315
|
+
ms
|
|
316
|
+
})
|
|
311
317
|
}, parents);
|
|
312
318
|
}
|
|
313
319
|
if (method === "sleepUntil") {
|
|
@@ -321,12 +327,13 @@ async function extractWorkflowGraph(handler) {
|
|
|
321
327
|
if (stepId === void 0) return unknown("Dynamic sleepUntil IDs are not supported yet", parents);
|
|
322
328
|
const description = operationDescription(options);
|
|
323
329
|
if (description === void 0) return unknown("Sleep descriptions must be static strings", parents);
|
|
324
|
-
return addNode({
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
+
return addNode(`sleep until ${timestamp}`, {
|
|
331
|
+
case: "sleepUntil",
|
|
332
|
+
value: create(WorkflowManifestSleepUntilNodeV1Schema, {
|
|
333
|
+
stepId,
|
|
334
|
+
description,
|
|
335
|
+
timestamp
|
|
336
|
+
})
|
|
330
337
|
}, parents);
|
|
331
338
|
}
|
|
332
339
|
const options = readableOptions(call.arguments[0]);
|
|
@@ -334,11 +341,18 @@ async function extractWorkflowGraph(handler) {
|
|
|
334
341
|
if (stepId === void 0) return unknown(`Dynamic ${method} IDs are not supported yet`, parents);
|
|
335
342
|
const description = operationDescription(options);
|
|
336
343
|
if (description === void 0) return unknown(`${method} descriptions must be static strings`, parents);
|
|
337
|
-
return addNode({
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
344
|
+
return addNode(stepId, method === "now" ? {
|
|
345
|
+
case: "now",
|
|
346
|
+
value: create(WorkflowManifestNowNodeV1Schema, {
|
|
347
|
+
stepId,
|
|
348
|
+
description
|
|
349
|
+
})
|
|
350
|
+
} : {
|
|
351
|
+
case: "uuid",
|
|
352
|
+
value: create(WorkflowManifestUuidNodeV1Schema, {
|
|
353
|
+
stepId,
|
|
354
|
+
description
|
|
355
|
+
})
|
|
342
356
|
}, parents);
|
|
343
357
|
}
|
|
344
358
|
function path(tails, reachable = true) {
|
|
@@ -401,16 +415,15 @@ async function extractWorkflowGraph(handler) {
|
|
|
401
415
|
const mapped = mappedStep(argument);
|
|
402
416
|
if (mapped !== void 0) {
|
|
403
417
|
const metadata = stepMetadata(mapped.call);
|
|
404
|
-
const tails = metadata?.group ? addNode({
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
label: metadata.group.label
|
|
418
|
+
const tails = metadata?.group ? addNode(metadata.group.label, {
|
|
419
|
+
case: "parallel",
|
|
420
|
+
value: create(WorkflowManifestParallelNodeV1Schema, {
|
|
421
|
+
groupId: metadata.group.id,
|
|
422
|
+
step: create(WorkflowManifestRepeatedStepV1Schema, {
|
|
423
|
+
stepIdTemplate: mapped.template,
|
|
424
|
+
description: metadata.description
|
|
425
|
+
})
|
|
426
|
+
})
|
|
414
427
|
}, parents) : unknown("Dynamic parallel steps need static group metadata", parents);
|
|
415
428
|
return {
|
|
416
429
|
tails,
|
|
@@ -507,12 +520,13 @@ async function extractWorkflowGraph(handler) {
|
|
|
507
520
|
const conditionFlow = expression(statement.expression, parents);
|
|
508
521
|
const metadata = branchInfo(statement, branchDepth);
|
|
509
522
|
const condition = statement.expression.getText(source);
|
|
510
|
-
const branchTails = metadata ? addNode({
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
523
|
+
const branchTails = metadata ? addNode(metadata.description, {
|
|
524
|
+
case: "branch",
|
|
525
|
+
value: create(WorkflowManifestBranchNodeV1Schema, {
|
|
526
|
+
branchId: metadata.id,
|
|
527
|
+
condition,
|
|
528
|
+
description: metadata.description
|
|
529
|
+
})
|
|
516
530
|
}, conditionFlow.tails) : conditionFlow.tails;
|
|
517
531
|
const sourceId = metadata ? branchTails[0]?.source : void 0;
|
|
518
532
|
const thenParents = sourceId ? [{
|
|
@@ -556,17 +570,15 @@ async function extractWorkflowGraph(handler) {
|
|
|
556
570
|
if (repeated) {
|
|
557
571
|
const iterable = expression(statement.expression, parents);
|
|
558
572
|
const metadata = stepMetadata(repeated.call);
|
|
559
|
-
const tails = metadata?.group ? addNode({
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
},
|
|
569
|
-
label: metadata.group.label
|
|
573
|
+
const tails = metadata?.group ? addNode(metadata.group.label, {
|
|
574
|
+
case: "loop",
|
|
575
|
+
value: create(WorkflowManifestLoopNodeV1Schema, {
|
|
576
|
+
groupId: metadata.group.id,
|
|
577
|
+
step: create(WorkflowManifestRepeatedStepV1Schema, {
|
|
578
|
+
stepIdTemplate: repeated.template,
|
|
579
|
+
description: metadata.description
|
|
580
|
+
})
|
|
581
|
+
})
|
|
570
582
|
}, iterable.tails) : unknown("Dynamic sequential steps need static group metadata", iterable.tails);
|
|
571
583
|
return statementFlow(path(tails), mergePaths(iterable.thrown, path(tails)));
|
|
572
584
|
}
|