@lovable.dev/workflows-sdk 0.0.0-dev.19 → 0.0.0-dev.20

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.
@@ -1,4 +1,4 @@
1
- import { loadTypeScript } from "./graph-V2yqSs3X.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CHhlUDD3.js";
2
2
  //#region src/manifests/branch-metadata.ts
3
3
  const optionsArgument = {
4
4
  step: 2,
@@ -13,10 +13,11 @@ async function findBranchMetadataIssues(handler) {
13
13
  const api = await loadTypeScript();
14
14
  if (!api) return [];
15
15
  const ts = api;
16
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
17
- const declaration = source.statements[0];
16
+ const handlerSource = workflowHandlerSource(handler);
17
+ if (!handlerSource) return [];
18
+ const declaration = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS).statements[0];
18
19
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
19
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) return [];
20
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return [];
20
21
  const parameter = fn.parameters[0]?.name;
21
22
  if (!parameter || !ts.isIdentifier(parameter)) return [];
22
23
  const context = parameter.text;
@@ -1,4 +1,4 @@
1
- import { loadTypeScript } from "./graph-V2yqSs3X.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CHhlUDD3.js";
2
2
  //#region src/manifests/context-escapes.ts
3
3
  const durableMethods = /* @__PURE__ */ new Set([
4
4
  "step",
@@ -13,10 +13,11 @@ async function findWorkflowContextEscapes(handler) {
13
13
  const api = await loadTypeScript();
14
14
  if (!api) return [];
15
15
  const ts = api;
16
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
17
- const declaration = source.statements[0];
16
+ const handlerSource = workflowHandlerSource(handler);
17
+ if (!handlerSource) return [];
18
+ const declaration = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS).statements[0];
18
19
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
19
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) return [];
20
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return [];
20
21
  const parameter = fn.parameters[0]?.name;
21
22
  if (!parameter) return [];
22
23
  if (!ts.isIdentifier(parameter)) return [{ kind: "destructured" }];
@@ -59,7 +60,7 @@ async function findWorkflowContextEscapes(handler) {
59
60
  }
60
61
  if (ts.isIdentifier(node) && node.text === context && identifierIsValue(node)) {
61
62
  const parent = node.parent;
62
- if (!((ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === node)) {
63
+ if (!(ts.isPropertyAccessExpression(parent) && parent.expression === node || ts.isElementAccessExpression(parent) && parent.expression === node && parent.argumentExpression && (ts.isStringLiteral(parent.argumentExpression) || ts.isNoSubstitutionTemplateLiteral(parent.argumentExpression)))) {
63
64
  escapes.push({
64
65
  kind: "context",
65
66
  context
@@ -70,7 +71,7 @@ async function findWorkflowContextEscapes(handler) {
70
71
  }
71
72
  ts.forEachChild(node, (child) => visit(child, shadowed));
72
73
  };
73
- visit(fn.body, false);
74
+ visit(fn, false);
74
75
  return escapes;
75
76
  }
76
77
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
2
- import { loadTypeScript } from "./graph-V2yqSs3X.js";
2
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CHhlUDD3.js";
3
3
  //#region src/manifests/duplicate-ids.ts
4
4
  /** Where an explicit `{ id }` would sit for each operation. */
5
5
  const optionsArgument = {
@@ -16,10 +16,11 @@ async function findDuplicateOperationIds(handler) {
16
16
  const api = await loadTypeScript();
17
17
  if (!api) return [];
18
18
  const ts = api;
19
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
20
- const declaration = source.statements[0];
19
+ const handlerSource = workflowHandlerSource(handler);
20
+ if (!handlerSource) return [];
21
+ const declaration = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS).statements[0];
21
22
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
22
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) return [];
23
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return [];
23
24
  const parameter = fn.parameters[0]?.name;
24
25
  if (!parameter || !ts.isIdentifier(parameter)) return [];
25
26
  const context = parameter.text;
@@ -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-V2yqSs3X.js");
187
- const { findBranchMetadataIssues } = await import("./branch-metadata-DeUhEFah.js");
188
- const { findWorkflowContextEscapes } = await import("./context-escapes-DRzfr4f6.js");
189
- const { findDuplicateOperationIds } = await import("./duplicate-ids-BSJNfUhh.js");
190
- const { findNestedDurableOperations } = await import("./nested-operations-DsecXS12.js");
191
- const { findOperationDescriptionIssues } = await import("./operation-descriptions-C_f87Bmr.js");
192
- const { findStepMetadataIssues } = await import("./step-metadata-D4OpY6r1.js");
186
+ const { extractWorkflowGraph } = await import("./graph-CHhlUDD3.js");
187
+ const { findBranchMetadataIssues } = await import("./branch-metadata-CZOTNcFb.js");
188
+ const { findWorkflowContextEscapes } = await import("./context-escapes-B25pWh07.js");
189
+ const { findDuplicateOperationIds } = await import("./duplicate-ids-DElsXi_P.js");
190
+ const { findNestedDurableOperations } = await import("./nested-operations-A16hbdxU.js");
191
+ const { findOperationDescriptionIssues } = await import("./operation-descriptions-BgyQzZ2-.js");
192
+ const { findStepMetadataIssues } = await import("./step-metadata-DJ1CNwqI.js");
193
193
  const collection = registerWorkflows(definition);
194
194
  const manifests = [];
195
195
  for (const workflow of collection.workflows) {
@@ -1,4 +1,11 @@
1
1
  import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
2
+ //#region src/manifests/handler-source.ts
3
+ const nativeFunctionSource = /\{\s*\[native code\]\s*\}\s*$/;
4
+ function workflowHandlerSource(handler) {
5
+ const source = Function.prototype.toString.call(handler);
6
+ return nativeFunctionSource.test(source) ? void 0 : source;
7
+ }
8
+ //#endregion
2
9
  //#region src/manifests/graph.ts
3
10
  const durableMethods = {
4
11
  step: 0,
@@ -75,10 +82,15 @@ async function extractWorkflowGraph(handler) {
75
82
  return graph;
76
83
  }
77
84
  const ts = api;
78
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
85
+ const handlerSource = workflowHandlerSource(handler);
86
+ if (!handlerSource) {
87
+ unknown("Handler source is unavailable", []);
88
+ return graph;
89
+ }
90
+ const source = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
79
91
  const declaration = source.statements[0];
80
92
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
81
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) {
93
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) {
82
94
  unknown("Handler source is unavailable", []);
83
95
  return graph;
84
96
  }
@@ -455,4 +467,4 @@ async function extractWorkflowGraph(handler) {
455
467
  return graph;
456
468
  }
457
469
  //#endregion
458
- export { extractWorkflowGraph, loadTypeScript };
470
+ export { extractWorkflowGraph, loadTypeScript, workflowHandlerSource as t };
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-CLOdvpgq.js";
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-BXCYaFf_.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 } from "./graph-V2yqSs3X.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CHhlUDD3.js";
2
2
  //#region src/manifests/nested-operations.ts
3
3
  const durableMethods = [
4
4
  "step",
@@ -13,10 +13,11 @@ async function findNestedDurableOperations(handler) {
13
13
  const api = await loadTypeScript();
14
14
  if (!api) return [];
15
15
  const ts = api;
16
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
17
- const declaration = source.statements[0];
16
+ const handlerSource = workflowHandlerSource(handler);
17
+ if (!handlerSource) return [];
18
+ const declaration = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS).statements[0];
18
19
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
19
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) return [];
20
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return [];
20
21
  const parameter = fn.parameters[0]?.name;
21
22
  if (!parameter || !ts.isIdentifier(parameter)) return [];
22
23
  const context = parameter.text;
@@ -1,4 +1,4 @@
1
- import { loadTypeScript } from "./graph-V2yqSs3X.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CHhlUDD3.js";
2
2
  //#region src/manifests/operation-descriptions.ts
3
3
  const optionsArgument = {
4
4
  approve: 0,
@@ -12,10 +12,11 @@ async function findOperationDescriptionIssues(handler) {
12
12
  const api = await loadTypeScript();
13
13
  if (!api) return [];
14
14
  const ts = api;
15
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
16
- const declaration = source.statements[0];
15
+ const handlerSource = workflowHandlerSource(handler);
16
+ if (!handlerSource) return [];
17
+ const declaration = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS).statements[0];
17
18
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
18
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) return [];
19
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return [];
19
20
  const parameter = fn.parameters[0]?.name;
20
21
  if (!parameter || !ts.isIdentifier(parameter)) return [];
21
22
  const context = parameter.text;
@@ -1,13 +1,14 @@
1
- import { loadTypeScript } from "./graph-V2yqSs3X.js";
1
+ import { loadTypeScript, t as workflowHandlerSource } from "./graph-CHhlUDD3.js";
2
2
  //#region src/manifests/step-metadata.ts
3
3
  async function findStepMetadataIssues(handler) {
4
4
  const api = await loadTypeScript();
5
5
  if (!api) return [];
6
6
  const ts = api;
7
- const source = ts.createSourceFile("handler.js", `const handler = ${Function.prototype.toString.call(handler)};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS);
8
- const declaration = source.statements[0];
7
+ const handlerSource = workflowHandlerSource(handler);
8
+ if (!handlerSource) return [];
9
+ const declaration = ts.createSourceFile("handler.js", `const handler = ${handlerSource};`, ts.ScriptTarget.ESNext, true, ts.ScriptKind.JS).statements[0];
9
10
  const fn = declaration && ts.isVariableStatement(declaration) ? declaration.declarationList.declarations[0]?.initializer : void 0;
10
- if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn) || source.text.includes("[native code]")) return [];
11
+ if (!fn || !ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn)) return [];
11
12
  const parameter = fn.parameters[0]?.name;
12
13
  if (!parameter || !ts.isIdentifier(parameter)) return [];
13
14
  const context = parameter.text;
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as generateManifests } from "./generate-CLOdvpgq.js";
1
+ import { t as generateManifests } from "./generate-BXCYaFf_.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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/workflows-sdk",
3
- "version": "0.0.0-dev.19",
3
+ "version": "0.0.0-dev.20",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "dev",