@lovable.dev/workflows-sdk 0.0.0-dev.15 → 0.0.0-dev.16

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
@@ -46,6 +46,37 @@ definitions as immutable after registration.
46
46
  See [the authoring example](examples/src/lib/workflows/greet/index.ts) for schemas,
47
47
  typed middleware, and a durable step. The package typecheck includes this example.
48
48
 
49
+ Every `ctx.step()` needs a static, user-facing description. Lovable's agent
50
+ supplies this text so the workflow UI can explain what the step does before and
51
+ during a run:
52
+
53
+ ```ts
54
+ await ctx.step("load-customer", () => loadCustomer(ctx.input.customerId), {
55
+ meta: { description: "Load the customer record" },
56
+ });
57
+ ```
58
+
59
+ Manifest generation rejects a missing or computed description. A step declared
60
+ inside a loop or callback also needs a group with a stable ID and user-facing
61
+ label. The group identifies the repeated callsite while each runtime step keeps
62
+ its own concrete ID:
63
+
64
+ ```ts
65
+ await Promise.all(
66
+ ctx.input.items.map((item) =>
67
+ ctx.step(`process-${item.id}`, () => processItem(item), {
68
+ meta: {
69
+ description: "Process an item",
70
+ group: { id: "process-items", label: "Process items" },
71
+ },
72
+ }),
73
+ ),
74
+ );
75
+ ```
76
+
77
+ Group IDs are unique per workflow callsite. Ordinary sequential steps and
78
+ fixed `Promise.all([stepA, stepB])` branches do not need a group.
79
+
49
80
  ## Triggers
50
81
 
51
82
  A workflow runs when something triggers it, and a schedule is the first kind of
@@ -271,22 +302,25 @@ from a Lovable template already have it. Without it — or with a copy exposing
271
302
  stable JS API, as TypeScript 7 does before 7.1 — the build still succeeds and
272
303
  every graph carries one `unknown` node and the diagnostic
273
304
  `Install typescript to infer step graphs`.
274
- Sequential awaited `ctx.step("name", callback)` calls produce order edges;
305
+ Sequential awaited `ctx.step("name", callback, options)` calls produce order edges;
275
306
  `await Promise.all([ctx.step(...), ctx.step(...)])` produces parallel branches
276
307
  that join at the next step. A `Promise.all()` mapped over a collection with the
277
308
  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.
309
+ from `meta.group.label`. Returned step promises work too. Keep step IDs literal
310
+ outside this mapped form.
280
311
 
281
312
  | Field | Meaning |
282
313
  | --- | --- |
283
314
  | `nodes[].id` | Unique occurrence ID within this graph; use as the UI node key |
284
315
  | `nodes[].kind` | Durable operation, `parallel`, or `unknown` |
285
316
  | `nodes[].stepId` | Runtime durable ID for every statically known operation |
317
+ | `nodes[].description` | User-facing description for a static step |
318
+ | `nodes[].groupId` | Stable callsite ID for a dynamic parallel node |
286
319
  | `nodes[].cardinality` | `dynamic` for a runtime-sized parallel fan-out |
287
320
  | `nodes[].operation.kind` | Durable operation repeated by a parallel node |
288
321
  | `nodes[].operation.stepIdTemplate` | Display template for steps in a dynamic parallel node |
289
- | `nodes[].label` | Step name or explanation of unsupported code |
322
+ | `nodes[].operation.description` | User-facing description shared by the repeated steps |
323
+ | `nodes[].label` | Step ID, group label, or explanation of unsupported code |
290
324
  | `edges[]` | `{ source, target, kind: "order" }`, referencing node IDs |
291
325
  | `complete` | Whether the handler uses only supported syntax |
292
326
  | `diagnostics` | Reasons the graph is partial |
@@ -417,7 +451,15 @@ There is no run store. A run's entire state is its **memo** — the list of
417
451
  settled operations — and the caller carries it between calls:
418
452
 
419
453
  ```jsonc
420
- [{ "seq": 0, "stepId": "greeting", "occurrence": 0, "kind": "step", "status": "completed", "result": "Hello, yehya!" }]
454
+ [{
455
+ "seq": 0,
456
+ "stepId": "greeting",
457
+ "occurrence": 0,
458
+ "kind": "step",
459
+ "meta": { "description": "Create a personalized greeting" },
460
+ "status": "completed",
461
+ "result": "Hello, yehya!"
462
+ }]
421
463
  ```
422
464
 
423
465
  An entry is keyed by `stepId` and `occurrence` (which call of that id in the
@@ -536,11 +578,12 @@ inside the step and return the key.
536
578
  Each call re-runs the handler from the top. Step bodies run only in their
537
579
  selected request, so side effects belong inside a step.
538
580
 
539
- `next` reports a step's `stepId` and `kind` but not its input:
540
- `ctx.step(id, fn)` closes over its arguments rather than declaring them, so the
541
- input is not knowable without running `fn`. Deterministic values (`ctx.now`,
542
- `ctx.uuid`) are pinned into `memoDelta`, so concurrent calls replay the same
543
- values after the engine merges the delta.
581
+ `next` reports a step's `stepId`, `kind`, and author-supplied `meta`, including
582
+ its description and group. It does not report the step input:
583
+ `ctx.step(id, fn, options)` closes over its arguments rather than declaring
584
+ them, so the input is not knowable without running `fn`. Deterministic values
585
+ (`ctx.now`, `ctx.uuid`) are pinned into `memoDelta`, so concurrent calls replay
586
+ the same values after the engine merges the delta.
544
587
 
545
588
  ### Waiting on something outside the app
546
589
 
@@ -1,5 +1,5 @@
1
1
  import { t as defaultDurableId } from "./durable-ids-LsygHSZC.js";
2
- import { loadTypeScript } from "./graph-Bt-31WQT.js";
2
+ import { loadTypeScript } from "./graph-BEfFBC6v.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,10 @@ function serializeSchema(schema, direction, label) {
183
183
  }
184
184
  }
185
185
  async function generateManifests(definition) {
186
- const { extractWorkflowGraph } = await import("./graph-Bt-31WQT.js");
187
- const { findDuplicateOperationIds } = await import("./duplicate-ids-ClNLIwAz.js");
188
- const { findNestedDurableOperations } = await import("./nested-operations-Cpzs_PHo.js");
186
+ const { extractWorkflowGraph } = await import("./graph-BEfFBC6v.js");
187
+ const { findDuplicateOperationIds } = await import("./duplicate-ids-CosMS6qZ.js");
188
+ const { findNestedDurableOperations } = await import("./nested-operations-hWj5wt1m.js");
189
+ const { findStepMetadataIssues } = await import("./step-metadata-Cly35okS.js");
189
190
  const collection = registerWorkflows(definition);
190
191
  const manifests = [];
191
192
  for (const workflow of collection.workflows) {
@@ -203,6 +204,16 @@ async function generateManifests(definition) {
203
204
  const where = duplicate.reason === "loop" ? "inside a loop" : "more than once";
204
205
  throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" calls ctx.${duplicate.method}() ${where} with the default id "${duplicate.id}"; replay cannot tell the occurrences apart, so pass an explicit { id } per call site`);
205
206
  }
207
+ const metadataIssue = (await findStepMetadataIssues(workflow.handler))[0];
208
+ if (metadataIssue?.kind === "description") {
209
+ const step = metadataIssue.stepId ? `ctx.step(${JSON.stringify(metadataIssue.stepId)})` : "ctx.step()";
210
+ throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" ${step} must include a static { meta: { description: "..." } }`);
211
+ }
212
+ if (metadataIssue?.kind === "group") {
213
+ const step = metadataIssue.stepId ? `ctx.step(${JSON.stringify(metadataIssue.stepId)})` : "ctx.step()";
214
+ throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" ${step} is declared in a loop or callback and must include a static { meta: { group: { id: "...", label: "..." } } }`);
215
+ }
216
+ if (metadataIssue?.kind === "duplicate-group") throw new Error(`@lovable.dev/workflows-sdk: workflow "${workflow.id}" uses group id ${JSON.stringify(metadataIssue.groupId)} at more than one repeated step callsite; every group id must identify one callsite`);
206
217
  const metadata = {
207
218
  id: workflow.id,
208
219
  ...workflow.description === void 0 ? {} : { description: workflow.description },
@@ -104,7 +104,7 @@ async function extractWorkflowGraph(handler) {
104
104
  }
105
105
  return template;
106
106
  }
107
- function mappedStepTemplate(node) {
107
+ function mappedStep(node) {
108
108
  while (ts.isParenthesizedExpression(node)) node = node.expression;
109
109
  if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression) || node.expression.name.text !== "map" || node.arguments.length !== 1) return;
110
110
  const callback = node.arguments[0];
@@ -117,7 +117,11 @@ async function extractWorkflowGraph(handler) {
117
117
  } else body = callback.body;
118
118
  while (body && (ts.isParenthesizedExpression(body) || ts.isAwaitExpression(body))) body = body.expression;
119
119
  if (!body || !durableCall(body) || body.expression.name.text !== "step") return;
120
- return stepIdTemplate(body.arguments[0], parameters);
120
+ const template = stepIdTemplate(body.arguments[0], parameters);
121
+ return template === void 0 ? void 0 : {
122
+ call: body,
123
+ template
124
+ };
121
125
  }
122
126
  function readableOptions(node) {
123
127
  return node && ts.isObjectLiteralExpression(node) && node.properties.every(ts.isPropertyAssignment) ? node : void 0;
@@ -128,6 +132,22 @@ async function extractWorkflowGraph(handler) {
128
132
  if ((ts.isIdentifier(property.name) || ts.isStringLiteral(property.name) ? property.name.text : void 0) === name) return property.initializer;
129
133
  }
130
134
  }
135
+ function stepMetadata(call) {
136
+ const meta = readableOptions(option(readableOptions(call.arguments[2]), "meta"));
137
+ const description = stringLiteral(option(meta, "description"));
138
+ if (description === void 0) return void 0;
139
+ const groupOptions = readableOptions(option(meta, "group"));
140
+ if (!groupOptions) return { description };
141
+ const id = stringLiteral(option(groupOptions, "id"));
142
+ const label = stringLiteral(option(groupOptions, "label"));
143
+ return id === void 0 || label === void 0 ? void 0 : {
144
+ description,
145
+ group: {
146
+ id,
147
+ label
148
+ }
149
+ };
150
+ }
131
151
  function durableStepId(argument, options, fallback) {
132
152
  if (argument && !options) return void 0;
133
153
  const given = option(options, "id");
@@ -138,9 +158,12 @@ async function extractWorkflowGraph(handler) {
138
158
  if (method === "step") {
139
159
  const stepId = stringLiteral(call.arguments[0]);
140
160
  if (stepId === void 0) return unknown("Dynamic step IDs are not supported yet", parents);
161
+ const metadata = stepMetadata(call);
162
+ if (!metadata) return unknown("Step descriptions must be static strings", parents);
141
163
  return addNode({
142
164
  kind: "step",
143
165
  stepId,
166
+ description: metadata.description,
144
167
  label: stepId
145
168
  }, parents);
146
169
  }
@@ -238,16 +261,22 @@ async function extractWorkflowGraph(handler) {
238
261
  return ts.isCallExpression(element) ? expression(element, parents, true) : unknown("Dynamic Promise.all entries are not followed", parents);
239
262
  }) : parents;
240
263
  }
241
- const template = mappedStepTemplate(argument);
242
- if (template !== void 0) return addNode({
243
- kind: "parallel",
244
- cardinality: "dynamic",
245
- operation: {
246
- kind: "step",
247
- stepIdTemplate: template
248
- },
249
- label: template
250
- }, parents);
264
+ const mapped = mappedStep(argument);
265
+ if (mapped !== void 0) {
266
+ const metadata = stepMetadata(mapped.call);
267
+ if (!metadata?.group) return unknown("Dynamic parallel steps need static group metadata", parents);
268
+ return addNode({
269
+ kind: "parallel",
270
+ groupId: metadata.group.id,
271
+ cardinality: "dynamic",
272
+ operation: {
273
+ kind: "step",
274
+ stepIdTemplate: mapped.template,
275
+ description: metadata.description
276
+ },
277
+ label: metadata.group.label
278
+ }, parents);
279
+ }
251
280
  }
252
281
  if (contains(node, (child) => ts.isCallExpression(child) || ts.isAwaitExpression(child) || ts.isNewExpression(child))) return unknown("Helper calls and dynamic expressions are not followed", parents);
253
282
  if (ts.isIdentifier(node) && node.text === context) return unknown("Workflow context aliases are not followed", parents);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, Ctx, RunStore, StepContext, StepOptions, WorkflowDefinition, WorkflowEvent, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowOutput, WorkflowState, createMiddleware, createWorkflow } from "@tanstack/workflow-core";
1
+ import { AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, Ctx, RunStore, StepContext, StepOptions, WorkflowDefinition, WorkflowEvent, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowMetadata, WorkflowOutput, WorkflowState, createMiddleware, createWorkflow } from "@tanstack/workflow-core";
2
2
  import "typescript";
3
3
  //#region src/core/cadence.d.ts
4
4
  type Weekday = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
@@ -51,16 +51,29 @@ declare function registerWorkflows<const TWorkflows extends readonly AnyWorkflow
51
51
  triggers?: readonly TriggerDefinition[];
52
52
  }): WorkflowsDefinition<TWorkflows[number]>;
53
53
  //#endregion
54
+ //#region src/core/step-metadata.d.ts
55
+ interface WorkflowStepGroup {
56
+ id: string;
57
+ label: string;
58
+ }
59
+ type WorkflowStepMetadata = Record<string, unknown> & {
60
+ description: string;
61
+ group?: WorkflowStepGroup;
62
+ };
63
+ //#endregion
54
64
  //#region src/manifests/graph.d.ts
55
65
  type WorkflowGraphNodeDetails = {
56
66
  kind: "step";
57
67
  stepId: string;
68
+ description: string;
58
69
  } | {
59
70
  kind: "parallel";
71
+ groupId: string;
60
72
  cardinality: "dynamic";
61
73
  operation: {
62
74
  kind: "step";
63
75
  stepIdTemplate: string;
76
+ description: string;
64
77
  };
65
78
  } | {
66
79
  kind: "approve";
@@ -176,6 +189,7 @@ interface MemoEntry {
176
189
  /** Key of the step whose body recorded this, if any; a memoized parent hides it. */
177
190
  parent?: string;
178
191
  kind: StepKind;
192
+ meta?: WorkflowMetadata;
179
193
  status: "completed" | "failed";
180
194
  result?: unknown;
181
195
  error?: string;
@@ -186,6 +200,7 @@ interface StepIntentBase {
186
200
  occurrence: number;
187
201
  /** Kind-specific detail: sleep `ms`, `waitForEvent` name, approval title. */
188
202
  config?: Record<string, unknown>;
203
+ meta?: WorkflowMetadata;
189
204
  }
190
205
  /** A durable operation the replay reached but could not answer. */
191
206
  type StepIntent = StepIntentBase & ({
@@ -198,6 +213,7 @@ interface StepResult<K extends StepKind = StepKind> {
198
213
  stepId: string;
199
214
  occurrence: number;
200
215
  kind: K;
216
+ meta?: WorkflowMetadata;
201
217
  status: "completed" | "failed";
202
218
  result?: unknown;
203
219
  error?: string;
@@ -272,4 +288,4 @@ declare function createStepsHandler(collection: WorkflowCollection, options?: St
272
288
  */
273
289
  declare function toServerSentEventsResponse(events: AsyncIterable<WorkflowEvent>): Response;
274
290
  //#endregion
275
- export { type AnyWorkflowDefinition, type Cadence, type Ctx, type MemoEntry, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type ScheduleDefinition, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepReference, type StepResult, type StepsDisposition, type StepsHandler, type StepsHandlerOptions, type StepsRequest, type StepsResponse, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type Weekday, type WorkflowCollection, type WorkflowDefinition, type WorkflowGraph, type WorkflowGraphNode, type WorkflowGraphNodeDetails, type WorkflowInput, type WorkflowManifest, type WorkflowOutput, type WorkflowState, type WorkflowsDefinition, createMiddleware, createStepsHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, generateManifests, hourly, registerWorkflows, toServerSentEventsResponse, weekly };
291
+ export { type AnyWorkflowDefinition, type Cadence, type Ctx, type MemoEntry, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type ScheduleDefinition, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepReference, type StepResult, type StepsDisposition, type StepsHandler, type StepsHandlerOptions, type StepsRequest, type StepsResponse, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type Weekday, type WorkflowCollection, type WorkflowDefinition, type WorkflowGraph, type WorkflowGraphNode, type WorkflowGraphNodeDetails, type WorkflowInput, type WorkflowManifest, type WorkflowOutput, type WorkflowState, type WorkflowStepGroup, type WorkflowStepMetadata, type WorkflowsDefinition, createMiddleware, createStepsHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, generateManifests, hourly, registerWorkflows, toServerSentEventsResponse, weekly };
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-CVoNE4Kn.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-DTzFAh96.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
@@ -129,6 +129,12 @@ const EXECUTABLE = /* @__PURE__ */ new Set([
129
129
  function describe(error) {
130
130
  return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
131
131
  }
132
+ function groupId(meta) {
133
+ const group = meta?.group;
134
+ if (group === null || typeof group !== "object") return void 0;
135
+ const id = group.id;
136
+ return typeof id === "string" ? id : void 0;
137
+ }
132
138
  function runtimeContext() {
133
139
  return {
134
140
  timeRemaining: () => Number.POSITIVE_INFINITY,
@@ -178,6 +184,7 @@ async function replay(options) {
178
184
  stepId: entry.stepId,
179
185
  occurrence: entry.occurrence,
180
186
  kind: entry.kind,
187
+ ...entry.meta ? { meta: entry.meta } : {},
181
188
  status: entry.status,
182
189
  result: entry.result,
183
190
  error: entry.error
@@ -185,7 +192,7 @@ async function replay(options) {
185
192
  results.push(result);
186
193
  options.onStepSettle?.(result);
187
194
  }
188
- function durable(kind, stepId, run, config, defaulted = false) {
195
+ function durable(kind, stepId, run, config, defaulted = false, meta) {
189
196
  const index = seq++;
190
197
  const occurrence = occurrences.get(stepId) ?? 0;
191
198
  occurrences.set(stepId, occurrence + 1);
@@ -205,6 +212,11 @@ async function replay(options) {
205
212
  nonDeterminism = `memo has ${answered.kind} "${stepId}" (#${occurrence}), replay produced ${kind}`;
206
213
  return never;
207
214
  }
215
+ const recordedGroupId = groupId(answered.meta);
216
+ if (recordedGroupId !== void 0 && recordedGroupId !== groupId(meta)) {
217
+ nonDeterminism = `memo has group "${recordedGroupId}" for step "${stepId}", replay produced a different group`;
218
+ return never;
219
+ }
208
220
  if (answered.status === "completed") return Promise.resolve(answered.result);
209
221
  return Promise.reject(new Error(answered.error ?? `step "${stepId}" failed`));
210
222
  }
@@ -214,7 +226,8 @@ async function replay(options) {
214
226
  stepId,
215
227
  occurrence,
216
228
  kind,
217
- ...config ? { config } : {}
229
+ ...config ? { config } : {},
230
+ ...meta ? { meta } : {}
218
231
  };
219
232
  if (!run || !EXECUTABLE.has(kind) || !allow(intent, pass)) {
220
233
  pending.push(intent);
@@ -237,7 +250,8 @@ async function replay(options) {
237
250
  kind,
238
251
  status: "completed",
239
252
  result,
240
- ...parent ? { parent } : {}
253
+ ...parent ? { parent } : {},
254
+ ...meta ? { meta } : {}
241
255
  });
242
256
  return result;
243
257
  }, (error) => {
@@ -248,7 +262,8 @@ async function replay(options) {
248
262
  kind,
249
263
  status: "failed",
250
264
  error: describe(error),
251
- ...parent ? { parent } : {}
265
+ ...parent ? { parent } : {},
266
+ ...meta ? { meta } : {}
252
267
  });
253
268
  throw error;
254
269
  });
@@ -264,12 +279,12 @@ async function replay(options) {
264
279
  state,
265
280
  signal: controller.signal,
266
281
  runtime,
267
- step: (id, fn, _options) => durable("step", id, async () => fn({
282
+ step: (id, fn, stepOptions) => durable("step", id, async () => fn({
268
283
  id,
269
284
  attempt: 1,
270
285
  runtime,
271
286
  signal: controller.signal
272
- })),
287
+ }), void 0, false, stepOptions?.meta),
273
288
  sleep: (ms, opts) => durable("sleep", opts?.id ?? defaultDurableId({
274
289
  kind: "sleep",
275
290
  ms
@@ -1,4 +1,4 @@
1
- import { loadTypeScript } from "./graph-Bt-31WQT.js";
1
+ import { loadTypeScript } from "./graph-BEfFBC6v.js";
2
2
  //#region src/manifests/nested-operations.ts
3
3
  const durableMethods = [
4
4
  "step",
@@ -0,0 +1,63 @@
1
+ import { loadTypeScript } from "./graph-BEfFBC6v.js";
2
+ //#region src/manifests/step-metadata.ts
3
+ async function findStepMetadataIssues(handler) {
4
+ const api = await loadTypeScript();
5
+ if (!api) return [];
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];
9
+ 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
+ const parameter = fn.parameters[0]?.name;
12
+ if (!parameter || !ts.isIdentifier(parameter)) return [];
13
+ const context = parameter.text;
14
+ function literalString(node) {
15
+ return node && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) ? node.text : void 0;
16
+ }
17
+ function property(node, name) {
18
+ if (!node || !ts.isObjectLiteralExpression(node)) return void 0;
19
+ for (const entry of node.properties) {
20
+ if (!ts.isPropertyAssignment(entry)) continue;
21
+ if ((ts.isIdentifier(entry.name) || ts.isStringLiteral(entry.name) ? entry.name.text : void 0) === name) return entry.initializer;
22
+ }
23
+ }
24
+ function repeatable(call) {
25
+ let parent = call.parent;
26
+ while (parent && parent !== fn) {
27
+ if (ts.isForStatement(parent) || ts.isForOfStatement(parent) || ts.isForInStatement(parent) || ts.isWhileStatement(parent) || ts.isDoStatement(parent) || ts.isFunctionLike(parent)) return true;
28
+ parent = parent.parent;
29
+ }
30
+ return false;
31
+ }
32
+ const issues = [];
33
+ const groups = /* @__PURE__ */ new Set();
34
+ const visit = (node) => {
35
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && node.expression.expression.text === context && node.expression.name.text === "step") {
36
+ const stepId = literalString(node.arguments[0]);
37
+ const meta = property(node.arguments[2], "meta");
38
+ if (literalString(property(meta, "description")) === void 0) issues.push({
39
+ kind: "description",
40
+ ...stepId === void 0 ? {} : { stepId }
41
+ });
42
+ if (repeatable(node)) {
43
+ const group = property(meta, "group");
44
+ const groupId = literalString(property(group, "id"));
45
+ const label = literalString(property(group, "label"));
46
+ if (groupId === void 0 || label === void 0) issues.push({
47
+ kind: "group",
48
+ ...stepId === void 0 ? {} : { stepId }
49
+ });
50
+ else if (groups.has(groupId)) issues.push({
51
+ kind: "duplicate-group",
52
+ groupId
53
+ });
54
+ else groups.add(groupId);
55
+ }
56
+ }
57
+ ts.forEachChild(node, visit);
58
+ };
59
+ visit(fn);
60
+ return issues;
61
+ }
62
+ //#endregion
63
+ export { findStepMetadataIssues };
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as generateManifests } from "./generate-CVoNE4Kn.js";
1
+ import { t as generateManifests } from "./generate-DTzFAh96.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.15",
3
+ "version": "0.0.0-dev.16",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "dev",