@sanity/workflow-engine 0.2.0 → 0.4.0

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/dist/define.js CHANGED
@@ -1,506 +1,512 @@
1
1
  import * as v from "valibot";
2
+ import { GROQ_IDENTIFIER, formatValidationError, issuesFromValibot, AuthoringWorkflowSchema, AuthoringStageSchema, AuthoringTaskSchema, AuthoringActionSchema, AuthoringTransitionSchema, AuthoringStateEntrySchema, AuthoringOpSchema, GuardSchema, EffectSchema } from "./_chunks-es/schema.js";
3
+ function groq(strings, ...values) {
4
+ return strings.reduce((out, part, i) => i === 0 ? part : `${out}${serializeGroqValue(values[i - 1])}${part}`, "");
5
+ }
6
+ function serializeGroqValue(value) {
7
+ const serialized = JSON.stringify(value);
8
+ if (serialized === void 0)
9
+ throw new Error(
10
+ `groq tag cannot serialize ${typeof value} \u2014 interpolate JSON-representable values only`
11
+ );
12
+ return serialized;
13
+ }
14
+ function desugarWorkflow(authoring) {
15
+ const ctx = { issues: [], claimStates: /* @__PURE__ */ new Map(), claimedStates: /* @__PURE__ */ new Set() }, workflowState = desugarStateEntries(authoring.state, ["state"], ctx), workflowLayer = layerOf(workflowState), stages = authoring.stages.map((stage, i) => {
16
+ const path = ["stages", i], stageState = desugarStateEntries(stage.state, [...path, "state"], ctx), stageEnv = {
17
+ layers: [
18
+ { scope: "stage", entries: layerOf(stageState) },
19
+ { scope: "workflow", entries: workflowLayer }
20
+ ]
21
+ }, tasks = (stage.tasks ?? []).map(
22
+ (task, j) => desugarTask(task, [...path, "tasks", j], stageEnv, ctx)
23
+ ), transitions = (stage.transitions ?? []).map(
24
+ (transition, k) => desugarTransition(transition, [...path, "transitions", k], stageEnv, ctx)
25
+ );
26
+ return {
27
+ ...stripUndefined({
28
+ name: stage.name,
29
+ title: stage.title,
30
+ description: stage.description,
31
+ guards: stage.guards
32
+ }),
33
+ ...stageState ? { state: stageState } : {},
34
+ ...tasks.length > 0 ? { tasks } : {},
35
+ ...transitions.length > 0 ? { transitions } : {}
36
+ };
37
+ });
38
+ return checkUnclaimedClaimStates(ctx), { definition: {
39
+ ...stripUndefined({
40
+ name: authoring.name,
41
+ version: authoring.version,
42
+ title: authoring.title,
43
+ description: authoring.description,
44
+ initialStage: authoring.initialStage,
45
+ predicates: authoring.predicates
46
+ }),
47
+ ...workflowState ? { state: workflowState } : {},
48
+ stages
49
+ }, issues: ctx.issues };
50
+ }
51
+ function desugarStateEntries(entries, path, ctx) {
52
+ return !entries || entries.length === 0 ? entries === void 0 ? void 0 : [] : entries.map((entry, i) => {
53
+ if (entry.type !== "claim") return entry;
54
+ const desugared = {
55
+ ...stripUndefined({ name: entry.name, title: entry.title, description: entry.description }),
56
+ type: "value.actor",
57
+ source: { type: "write" }
58
+ };
59
+ return ctx.claimStates.set(desugared, { name: entry.name, path: [...path, i] }), desugared;
60
+ });
61
+ }
62
+ function layerOf(entries) {
63
+ return new Map((entries ?? []).map((entry) => [entry.name, entry]));
64
+ }
65
+ function desugarTask(task, path, stageEnv, ctx) {
66
+ const taskState = desugarStateEntries(task.state, [...path, "state"], ctx), env = {
67
+ layers: [{ scope: "task", entries: layerOf(taskState) }, ...stageEnv.layers]
68
+ }, ops = desugarOps(task.ops, [...path, "ops"], env, task.name, ctx), actions = (task.actions ?? []).map(
69
+ (action, a) => desugarAction(action, [...path, "actions", a], env, task.name, ctx)
70
+ );
71
+ return {
72
+ ...stripUndefined({
73
+ name: task.name,
74
+ title: task.title,
75
+ description: task.description,
76
+ filter: task.filter,
77
+ completeWhen: task.completeWhen,
78
+ failWhen: task.failWhen,
79
+ effects: task.effects,
80
+ subworkflows: task.subworkflows
81
+ }),
82
+ activation: task.activation ?? "manual",
83
+ ...taskState ? { state: taskState } : {},
84
+ ...ops ? { ops } : {},
85
+ ...actions.length > 0 ? { actions } : {}
86
+ };
87
+ }
88
+ function desugarAction(action, path, env, taskName, ctx) {
89
+ if ("type" in action)
90
+ return desugarClaimAction(action, path, env, ctx);
91
+ const filter = composeFilter([rolesCondition(action.roles), action.filter]), ops = desugarOps(action.ops, [...path, "ops"], env, taskName, ctx) ?? [];
92
+ return action.status !== void 0 && ops.push({ type: "status.set", task: taskName, status: action.status }), {
93
+ ...stripUndefined({
94
+ name: action.name,
95
+ title: action.title,
96
+ description: action.description,
97
+ params: action.params,
98
+ effects: action.effects
99
+ }),
100
+ ...filter ? { filter } : {},
101
+ ...ops.length > 0 ? { ops } : {}
102
+ };
103
+ }
104
+ function desugarClaimAction(action, path, env, ctx) {
105
+ const ref = typeof action.state == "string" ? { state: action.state } : action.state, resolved = resolveRef(ref, env, [...path, "state"], ctx);
106
+ if (resolved) {
107
+ const entry = entryAt(env, resolved);
108
+ entry && entry.type !== "value.actor" && ctx.issues.push({
109
+ path: [...path, "state"],
110
+ message: `claim action "${action.name}" references "${resolved.state}" of kind "${entry.type}" \u2014 a claim pair needs an actor-valued entry (a "claim" or "value.actor" state declaration)`
111
+ }), checkShadowedClaimTarget(action.name, ref.state, resolved, env, [...path, "state"], ctx), entry && ctx.claimedStates.add(entry);
112
+ }
113
+ const noSteal = `!defined($state.${ref.state})`, filter = composeFilter([noSteal, rolesCondition(action.roles), action.filter]), ops = resolved ? [{ type: "state.set", target: resolved, value: { type: "actor" } }] : [];
114
+ return {
115
+ ...stripUndefined({
116
+ name: action.name,
117
+ title: action.title,
118
+ description: action.description,
119
+ params: action.params,
120
+ effects: action.effects
121
+ }),
122
+ filter,
123
+ ...ops.length > 0 ? { ops } : {}
124
+ };
125
+ }
126
+ function checkShadowedClaimTarget(actionName, state, resolved, env, path, ctx) {
127
+ const nearest = env.layers.find((l) => l.entries.has(state));
128
+ nearest === void 0 || nearest.scope === resolved.scope || ctx.issues.push({
129
+ path,
130
+ message: `claim action "${actionName}" targets "${state}" at scope "${resolved.scope}", but a nearer ${nearest.scope}-scope entry of the same name shadows it in $state \u2014 the no-steal filter would read the shadowing entry while the claim writes the "${resolved.scope}" one. Rename one of the entries or claim the nearer one`
131
+ });
132
+ }
133
+ function checkUnclaimedClaimStates(ctx) {
134
+ for (const [entry, { name, path }] of ctx.claimStates)
135
+ ctx.claimedStates.has(entry) || ctx.issues.push({
136
+ path,
137
+ message: `claim state "${name}" is never referenced by a claim action \u2014 you announced the pattern and wrote half of it. Declare a defineAction({ type: "claim", state: "${name}" }) or use a raw value.actor entry`
138
+ });
139
+ }
140
+ function desugarTransition(transition, path, stageEnv, ctx) {
141
+ const ops = desugarOps(transition.ops, [...path, "ops"], stageEnv, void 0, ctx);
142
+ return {
143
+ ...stripUndefined({
144
+ name: transition.name,
145
+ title: transition.title,
146
+ description: transition.description,
147
+ to: transition.to,
148
+ effects: transition.effects
149
+ }),
150
+ filter: transition.filter ?? "$allTasksDone",
151
+ ...ops ? { ops } : {}
152
+ };
153
+ }
154
+ function desugarOps(ops, path, env, firingTask, ctx) {
155
+ if (ops)
156
+ return ops.map((op, i) => desugarOp(op, [...path, i], env, firingTask, ctx));
157
+ }
158
+ function desugarOp(op, path, env, firingTask, ctx) {
159
+ if (op.type === "status.set") {
160
+ const task = op.task ?? firingTask;
161
+ return task === void 0 && ctx.issues.push({
162
+ path: [...path, "task"],
163
+ message: "status.set outside an action must name its target task"
164
+ }), { type: "status.set", task: task ?? "", status: op.status };
165
+ }
166
+ if (op.type === "audit") return desugarAuditOp(op, path, env, ctx);
167
+ const target = resolveRef(op.target, env, [...path, "target"], ctx) ?? fallbackRef(op.target);
168
+ return { ...op, target };
169
+ }
170
+ const AUDIT_STAMPS = { actor: { type: "actor" }, at: { type: "now" } };
171
+ function desugarAuditOp(op, path, env, ctx) {
172
+ const target = resolveRef(op.target, env, [...path, "target"], ctx) ?? fallbackRef(op.target);
173
+ if (op.value.type !== "object")
174
+ return ctx.issues.push({
175
+ path: [...path, "value"],
176
+ message: `audit value must be an object source carrying the domain fields (got "${op.value.type}")`
177
+ }), { type: "state.append", target, value: op.value };
178
+ const actorField = op.stampFields?.actor ?? "actor", atField = op.stampFields?.at ?? "at", fields = { ...op.value.fields };
179
+ for (const [stamp, source] of [
180
+ [actorField, AUDIT_STAMPS.actor],
181
+ [atField, AUDIT_STAMPS.at]
182
+ ]) {
183
+ if (stamp in fields) {
184
+ ctx.issues.push({
185
+ path: [...path, "value", "fields", stamp],
186
+ message: `audit stamp field "${stamp}" collides with an authored domain field \u2014 rename yours or remap the stamp via stampFields`
187
+ });
188
+ continue;
189
+ }
190
+ fields[stamp] = source;
191
+ }
192
+ return { type: "state.append", target, value: { type: "object", fields } };
193
+ }
194
+ function resolveRef(ref, env, path, ctx) {
195
+ const layers = ref.scope === void 0 ? env.layers : env.layers.filter((l) => l.scope === ref.scope);
196
+ for (const layer of layers)
197
+ if (layer.entries.has(ref.state)) return { scope: layer.scope, state: ref.state };
198
+ const reachable = env.layers.flatMap((l) => [...l.entries.keys()].map((n) => `${l.scope}:${n}`));
199
+ ctx.issues.push({
200
+ path,
201
+ message: `state reference "${ref.state}"${ref.scope ? ` (scope "${ref.scope}")` : ""} does not resolve to a declared entry. Reachable: ${reachable.join(", ") || "(none)"}`
202
+ });
203
+ }
204
+ function entryAt(env, ref) {
205
+ return env.layers.find((l) => l.scope === ref.scope)?.entries.get(ref.state);
206
+ }
207
+ function fallbackRef(ref) {
208
+ return { scope: ref.scope ?? "workflow", state: ref.state };
209
+ }
210
+ function rolesCondition(roles) {
211
+ if (!(!roles || roles.length === 0))
212
+ return groq`count($actor.roles[@ in ${roles}]) > 0`;
213
+ }
214
+ function composeFilter(parts) {
215
+ const present = parts.filter((p) => p !== void 0);
216
+ if (present.length !== 0)
217
+ return present.length === 1 ? present[0] : present.map((p) => `(${p})`).join(" && ");
218
+ }
219
+ function stripUndefined(obj) {
220
+ const out = {};
221
+ for (const [k, value] of Object.entries(obj))
222
+ value !== void 0 && (out[k] = value);
223
+ return out;
224
+ }
225
+ const RESERVED_CONDITION_VARS = [
226
+ "state",
227
+ "actor",
228
+ "assigned",
229
+ "can",
230
+ "row",
231
+ "now",
232
+ "effects",
233
+ "tasks",
234
+ "subworkflows",
235
+ "self",
236
+ "stage",
237
+ "parent",
238
+ "ancestors",
239
+ "allTasksDone",
240
+ "anyTaskFailed"
241
+ ], PREDICATE_CALLER_VARS = ["actor", "assigned", "can"];
2
242
  function knownList(ids) {
3
243
  return [...ids].map((s) => `"${s}"`).join(", ");
4
244
  }
5
- function checkStagesAndTasks(def, issues) {
6
- const stageIds = /* @__PURE__ */ new Set();
7
- for (const [i, stage] of def.stages.entries())
8
- stageIds.has(stage.id) && issues.push({
9
- path: ["stages", i, "id"],
10
- message: `duplicate stage id "${stage.id}" (already declared earlier)`
11
- }), stageIds.add(stage.id), stage.kind === "terminal" && stage.transitions && stage.transitions.length > 0 && issues.push({
12
- path: ["stages", i, "transitions"],
13
- message: `terminal stage "${stage.id}" must not declare transitions`
14
- }), checkDuplicateTaskIds(stage, i, issues);
15
- return stageIds;
16
- }
17
- function checkDuplicateTaskIds(stage, i, issues) {
18
- const taskIds = /* @__PURE__ */ new Set();
19
- for (const [j, task] of (stage.tasks ?? []).entries())
20
- taskIds.has(task.id) && issues.push({
21
- path: ["stages", i, "tasks", j, "id"],
22
- message: `duplicate task id "${task.id}" in stage "${stage.id}"`
23
- }), taskIds.add(task.id);
24
- }
25
- function checkInitialStage(def, stageIds, issues) {
26
- stageIds.has(def.initialStageId) || issues.push({
27
- path: ["initialStageId"],
28
- message: `initialStageId "${def.initialStageId}" is not a declared stage. Known stages: ${knownList(stageIds)}`
245
+ function checkDuplicates(names, what, issues) {
246
+ const seen = /* @__PURE__ */ new Set();
247
+ for (const { name, path } of names)
248
+ seen.has(name) && issues.push({ path, message: `duplicate ${what} "${name}" (already declared earlier)` }), seen.add(name);
249
+ return seen;
250
+ }
251
+ function checkStages(def, issues) {
252
+ const stageNames = checkDuplicates(
253
+ def.stages.map((stage, i) => ({ name: stage.name, path: ["stages", i, "name"] })),
254
+ "stage name",
255
+ issues
256
+ );
257
+ for (const [i, stage] of def.stages.entries()) {
258
+ const taskNames = checkDuplicates(
259
+ (stage.tasks ?? []).map((task, j) => ({
260
+ name: task.name,
261
+ path: ["stages", i, "tasks", j, "name"]
262
+ })),
263
+ `task name in stage "${stage.name}"`,
264
+ issues
265
+ );
266
+ checkDuplicates(
267
+ (stage.transitions ?? []).map((t, k) => ({
268
+ name: t.name,
269
+ path: ["stages", i, "transitions", k, "name"]
270
+ })),
271
+ `transition name in stage "${stage.name}"`,
272
+ issues
273
+ ), checkTasks(def, i, taskNames, issues);
274
+ }
275
+ return stageNames;
276
+ }
277
+ function checkTasks(def, i, taskNames, issues) {
278
+ const stage = def.stages[i];
279
+ for (const [j, task] of (stage.tasks ?? []).entries()) {
280
+ const path = ["stages", i, "tasks", j];
281
+ checkDuplicates(
282
+ (task.actions ?? []).map((action, a) => ({
283
+ name: action.name,
284
+ path: [...path, "actions", a, "name"]
285
+ })),
286
+ `action name in task "${task.name}"`,
287
+ issues
288
+ ), checkStatusSetTargets(task, taskNames, path, issues);
289
+ }
290
+ }
291
+ function checkStatusSetTargets(task, taskNames, path, issues) {
292
+ checkStatusSetOps(task.ops, taskNames, [...path, "ops"], issues);
293
+ for (const [a, action] of (task.actions ?? []).entries())
294
+ checkStatusSetOps(action.ops, taskNames, [...path, "actions", a, "ops"], issues);
295
+ }
296
+ function checkStatusSetOps(ops, taskNames, path, issues) {
297
+ for (const [o, op] of (ops ?? []).entries())
298
+ op.type !== "status.set" || taskNames.has(op.task) || issues.push({
299
+ path: [...path, o, "task"],
300
+ message: `status.set targets task "${op.task}" which is not declared in this stage. Known tasks: ${knownList(taskNames)}`
301
+ });
302
+ }
303
+ function checkInitialStage(def, stageNames, issues) {
304
+ stageNames.has(def.initialStage) || issues.push({
305
+ path: ["initialStage"],
306
+ message: `initialStage "${def.initialStage}" is not a declared stage. Known stages: ${knownList(stageNames)}`
29
307
  });
30
308
  }
31
- function checkTransitionTargets(def, stageIds, issues) {
309
+ function checkTransitionTargets(def, stageNames, issues) {
32
310
  for (const [i, stage] of def.stages.entries())
33
311
  for (const [k, t] of (stage.transitions ?? []).entries())
34
- stageIds.has(t.to) || issues.push({
312
+ stageNames.has(t.to) || issues.push({
35
313
  path: ["stages", i, "transitions", k, "to"],
36
- message: `transition target "${t.to}" is not a declared stage. Known stages: ${knownList(stageIds)}`
314
+ message: `transition target "${t.to}" is not a declared stage. Known stages: ${knownList(stageNames)}`
37
315
  });
38
316
  }
39
- function collectPredicateIds(def, issues) {
40
- const predicateIds = /* @__PURE__ */ new Set();
41
- for (const [i, p] of (def.predicates ?? []).entries())
42
- predicateIds.has(p.id) && issues.push({
43
- path: ["predicates", i, "id"],
44
- message: `duplicate predicate id "${p.id}"`
45
- }), predicateIds.add(p.id);
46
- return predicateIds;
47
- }
48
- function checkFilterRefs(def, predicateIds, issues) {
49
- const visit = (g, path) => {
50
- g === void 0 || typeof g == "string" || predicateIds.has(g.ref) || issues.push({
51
- path: [...path, "ref"],
52
- message: `Filter references predicate "${g.ref}" which is not declared. Known predicates: ${knownList(predicateIds) || "(none)"}`
53
- });
54
- };
317
+ function checkEffectNames(def, issues) {
318
+ const sites = [];
55
319
  for (const [i, stage] of def.stages.entries()) {
56
- visit(stage.completion, ["stages", i, "completion"]);
57
320
  for (const [j, task] of (stage.tasks ?? []).entries()) {
58
- visit(task.filter, ["stages", i, "tasks", j, "filter"]), visit(task.completeWhen, ["stages", i, "tasks", j, "completeWhen"]), visit(task.failWhen, ["stages", i, "tasks", j, "failWhen"]);
321
+ collectEffects(task.effects, ["stages", i, "tasks", j, "effects"], sites);
59
322
  for (const [a, action] of (task.actions ?? []).entries())
60
- visit(action.filter, ["stages", i, "tasks", j, "actions", a, "filter"]);
323
+ collectEffects(action.effects, ["stages", i, "tasks", j, "actions", a, "effects"], sites);
61
324
  }
62
325
  for (const [k, t] of (stage.transitions ?? []).entries())
63
- visit(t.filter, ["stages", i, "transitions", k, "filter"]);
326
+ collectEffects(t.effects, ["stages", i, "transitions", k, "effects"], sites);
64
327
  }
328
+ checkDuplicates(sites, "effect name (registry key \u2014 unique per definition)", issues);
65
329
  }
66
- function checkWorkflowInvariants(def) {
67
- const issues = [], stageIds = checkStagesAndTasks(def, issues);
68
- checkInitialStage(def, stageIds, issues), checkTransitionTargets(def, stageIds, issues);
69
- const predicateIds = collectPredicateIds(def, issues);
70
- return checkFilterRefs(def, predicateIds, issues), issues;
71
- }
72
- const TASK_STATUSES = ["pending", "active", "done", "skipped", "failed"], STATE_SCOPES = ["workflow", "stage", "task"], DOCUMENT_VALUE_PERMISSIONS = ["create", "read", "update"], MUTATION_GUARD_ACTIONS = [
73
- "create",
74
- "update",
75
- "delete",
76
- "publish",
77
- "unpublish"
78
- ], NonEmpty = v.pipe(v.string(), v.minLength(1, "must be a non-empty string")), PositiveInt = v.pipe(v.number(), v.integer(), v.minValue(1));
79
- function picklist(options) {
80
- return v.picklist(
81
- options,
82
- `Invalid option: expected one of ${options.map((o) => `"${o}"`).join("|")}`
330
+ function collectEffects(effects, path, sites) {
331
+ for (const [e, effect] of (effects ?? []).entries())
332
+ sites.push({ name: effect.name, path: [...path, e, "name"] });
333
+ }
334
+ function checkGuardNames(def, issues) {
335
+ const sites = def.stages.flatMap(
336
+ (stage, i) => (stage.guards ?? []).map((guard, g) => ({
337
+ name: guard.name,
338
+ path: ["stages", i, "guards", g, "name"]
339
+ }))
340
+ );
341
+ checkDuplicates(
342
+ sites,
343
+ "guard name (the guard lake _id derives from it \u2014 unique per definition)",
344
+ issues
83
345
  );
84
346
  }
85
- const GdrSchema = v.strictObject({
86
- id: v.pipe(
87
- v.string(),
88
- v.regex(
89
- /^(dataset|canvas|media-library|dashboard):/,
90
- "must be a GDR URI of form '<scheme>:<...id-parts>' where scheme is one of: dataset, canvas, media-library, dashboard"
91
- )
92
- ),
93
- type: NonEmpty
94
- }), SourceSchema = v.lazy(
95
- () => v.union([
96
- v.strictObject({
97
- source: v.literal("literal"),
98
- value: v.union([v.string(), v.number(), v.boolean(), v.null()])
99
- }),
100
- v.strictObject({ source: v.literal("param"), paramId: NonEmpty }),
101
- v.strictObject({ source: v.literal("actor") }),
102
- v.strictObject({ source: v.literal("now") }),
103
- v.strictObject({ source: v.literal("self") }),
104
- v.strictObject({ source: v.literal("stageId") }),
105
- v.strictObject({
106
- source: v.literal("stateRead"),
107
- scope: picklist(STATE_SCOPES),
108
- slotId: NonEmpty,
109
- path: v.optional(v.string())
110
- }),
111
- // effectsContext lookup reads from `instance.effectsContext[id === ID].value`.
112
- // Used by chained effects where one handler's output feeds another's binding.
113
- v.strictObject({
114
- source: v.literal("effectOutput"),
115
- contextId: NonEmpty,
116
- path: v.optional(v.string())
117
- }),
118
- v.strictObject({ source: v.literal("row"), path: v.optional(v.string()) }),
119
- v.strictObject({
120
- source: v.literal("parentState"),
121
- slotId: NonEmpty,
122
- path: v.optional(v.string())
123
- }),
124
- // Compound object source resolves each field's Source recursively
125
- // and packages the result into a JSON object. Lets ops append rich
126
- // rows to `checklist` / `notes` / `assignees` slots, e.g.
127
- // `{ source: "object", fields: { signer: { source: "actor" },
128
- // at: { source: "now" } } }`.
129
- v.strictObject({
130
- source: v.literal("object"),
131
- fields: v.record(NonEmpty, SourceSchema)
132
- })
133
- ])
134
- ), ScopeKeySchema = v.strictObject({
135
- scope: picklist(STATE_SCOPES),
136
- slotId: NonEmpty
137
- }), OpPredicateSchema = v.lazy(
138
- () => v.union([
139
- v.strictObject({
140
- field: NonEmpty,
141
- equals: SourceSchema
142
- }),
143
- v.strictObject({ all: v.array(OpPredicateSchema) }),
144
- v.strictObject({ any: v.array(OpPredicateSchema) })
347
+ function stateScopes(def) {
348
+ const scopes = [{ entries: def.state, path: ["state"], label: "workflow state" }];
349
+ for (const [i, stage] of def.stages.entries()) {
350
+ scopes.push({
351
+ entries: stage.state,
352
+ path: ["stages", i, "state"],
353
+ label: `stage "${stage.name}" state`
354
+ });
355
+ for (const [j, task] of (stage.tasks ?? []).entries())
356
+ scopes.push({
357
+ entries: task.state,
358
+ path: ["stages", i, "tasks", j, "state"],
359
+ label: `task "${task.name}" state`
360
+ });
361
+ }
362
+ return scopes;
363
+ }
364
+ function checkStateEntryNames(def, issues) {
365
+ for (const { entries, path, label } of stateScopes(def))
366
+ checkDuplicates(
367
+ (entries ?? []).map((entry, n) => ({ name: entry.name, path: [...path, n, "name"] })),
368
+ `state entry name in ${label}`,
369
+ issues
370
+ );
371
+ }
372
+ function checkPredicates(def, issues) {
373
+ const reserved = new Set(RESERVED_CONDITION_VARS), names = Object.keys(def.predicates ?? {});
374
+ for (const name of names)
375
+ reserved.has(name) && issues.push({
376
+ path: ["predicates", name],
377
+ message: `predicate "${name}" shadows the built-in $${name} \u2014 pick another name`
378
+ });
379
+ for (const [name, groq2] of Object.entries(def.predicates ?? {}))
380
+ checkPredicateBody(name, groq2, names, issues);
381
+ }
382
+ function checkPredicateBody(name, groq2, names, issues) {
383
+ for (const caller of PREDICATE_CALLER_VARS)
384
+ referencesVar(groq2, caller) && issues.push({
385
+ path: ["predicates", name],
386
+ message: `predicate "${name}" reads $${caller} \u2014 predicates are instance-level (pre-evaluated once, without a caller); compose caller gates at the condition site instead`
387
+ });
388
+ for (const other of names)
389
+ other === name || !referencesVar(groq2, other) || issues.push({
390
+ path: ["predicates", name],
391
+ message: `predicate "${name}" references predicate $${other} \u2014 predicates may read built-in vars only (no cross-references; compose at the condition site instead)`
392
+ });
393
+ }
394
+ function referencesVar(groq2, name) {
395
+ return GROQ_IDENTIFIER.test(name) ? new RegExp(`\\$${name}\\b`).test(groq2) : !1;
396
+ }
397
+ function checkCanOutsideActionFilters(def, issues) {
398
+ for (const site of nonActionFilterConditionSites(def))
399
+ referencesVar(site.groq, "can") && issues.push({
400
+ path: site.path,
401
+ message: `${site.label} reads $can \u2014 $can (the caller's grants) is bound only when an action fires, so it may appear in action filters only`
402
+ });
403
+ }
404
+ function nonActionFilterConditionSites(def) {
405
+ const sites = [];
406
+ for (const [i, stage] of def.stages.entries()) {
407
+ for (const [k, t] of (stage.transitions ?? []).entries())
408
+ sites.push({
409
+ groq: t.filter,
410
+ path: ["stages", i, "transitions", k, "filter"],
411
+ label: `transition "${t.name}" filter`
412
+ }), collectBindingSites(
413
+ t.effects,
414
+ ["stages", i, "transitions", k, "effects"],
415
+ `transition "${t.name}"`,
416
+ sites
417
+ );
418
+ for (const [j, task] of (stage.tasks ?? []).entries())
419
+ collectTaskConditionSites(task, ["stages", i, "tasks", j], sites);
420
+ }
421
+ return sites;
422
+ }
423
+ function collectTaskConditionSites(task, path, sites) {
424
+ for (const field of ["filter", "completeWhen", "failWhen"]) {
425
+ const groq2 = task[field];
426
+ groq2 !== void 0 && sites.push({ groq: groq2, path: [...path, field], label: `task "${task.name}".${field}` });
427
+ }
428
+ collectBindingSites(task.effects, [...path, "effects"], `task "${task.name}"`, sites);
429
+ for (const [a, action] of (task.actions ?? []).entries())
430
+ collectBindingSites(
431
+ action.effects,
432
+ [...path, "actions", a, "effects"],
433
+ `action "${action.name}"`,
434
+ sites
435
+ );
436
+ collectSubworkflowSites(task, path, sites);
437
+ }
438
+ function collectSubworkflowSites(task, path, sites) {
439
+ const sub = task.subworkflows;
440
+ if (sub === void 0) return;
441
+ const subPath = [...path, "subworkflows"];
442
+ sites.push({
443
+ groq: sub.forEach,
444
+ path: [...subPath, "forEach"],
445
+ label: `task "${task.name}".subworkflows.forEach`
446
+ });
447
+ for (const [group, record] of [
448
+ ["with", sub.with],
449
+ ["context", sub.context]
145
450
  ])
146
- ), OpSchema = v.variant("type", [
147
- v.strictObject({
148
- type: v.literal("workflow.op.state.set"),
149
- target: ScopeKeySchema,
150
- value: SourceSchema
151
- }),
152
- v.strictObject({
153
- type: v.literal("workflow.op.state.append"),
154
- target: ScopeKeySchema,
155
- item: SourceSchema
156
- }),
157
- v.strictObject({
158
- type: v.literal("workflow.op.state.updateWhere"),
159
- target: ScopeKeySchema,
160
- where: OpPredicateSchema,
161
- merge: v.record(NonEmpty, SourceSchema)
162
- }),
163
- v.strictObject({
164
- type: v.literal("workflow.op.state.removeWhere"),
165
- target: ScopeKeySchema,
166
- where: OpPredicateSchema
167
- }),
168
- v.strictObject({
169
- type: v.literal("workflow.op.status.set"),
170
- taskId: NonEmpty,
171
- status: picklist(TASK_STATUSES)
172
- })
173
- ]), StateSlotSourceSchema = v.union([
174
- v.strictObject({ kind: v.literal("init") }),
175
- v.strictObject({
176
- kind: v.literal("query"),
177
- query: NonEmpty,
178
- resource: v.optional(v.union([v.literal("workflow"), v.literal("subject"), GdrSchema]))
179
- }),
180
- v.strictObject({ kind: v.literal("write") }),
181
- /**
182
- * Pre-populate the slot at resolution time with a constant value.
183
- * Useful for stage- or task-scope slots that should start non-empty
184
- * (e.g. a default headline, a starting tally).
185
- */
186
- v.strictObject({ kind: v.literal("literal"), value: v.unknown() }),
187
- /**
188
- * Pre-populate by reading another already-resolved slot. `scope:
189
- * "workflow"` reads from the workflow-scope `state[]` (resolved at
190
- * startInstance). `scope: "stage"` reads from an earlier slot in
191
- * this same stage entry's `state[]` (sequential resolution).
192
- * Optional `path` selects a nested field (e.g. `path: "id"` on a
193
- * doc.ref slot).
194
- */
195
- v.strictObject({
196
- kind: v.literal("stateRead"),
197
- scope: v.union([v.literal("workflow"), v.literal("stage")]),
198
- slotId: NonEmpty,
199
- path: v.optional(v.string())
200
- })
201
- ]), StateSlotKindSchema = picklist([
202
- "workflow.state.doc.ref",
203
- "workflow.state.doc.refs",
204
- // Release reference. A workflow declares this slot to say "I target a
205
- // Content Release"; the runtime fills it with a specific release at
206
- // start time, and the engine auto-derives the instance's read
207
- // perspective from it.
208
- "workflow.state.release.ref",
209
- "workflow.state.query",
210
- "workflow.state.value.string",
211
- "workflow.state.value.url",
212
- "workflow.state.value.number",
213
- "workflow.state.value.boolean",
214
- "workflow.state.value.dateTime",
215
- "workflow.state.value.actor",
216
- "workflow.state.checklist",
217
- "workflow.state.notes",
218
- "workflow.state.assignees"
219
- ]), StateSlotSchema = v.strictObject({
220
- type: StateSlotKindSchema,
221
- id: NonEmpty,
222
- title: v.optional(v.string()),
223
- description: v.optional(v.string()),
224
- source: StateSlotSourceSchema
225
- }), FilterSchema = v.union([
226
- // Inline GROQ — only reserved params allowed at runtime.
227
- NonEmpty,
228
- // Reference to a named predicate, optionally with named args.
229
- v.strictObject({
230
- ref: NonEmpty,
231
- args: v.optional(v.record(v.string(), v.unknown()))
232
- })
233
- ]), PredicateParamSchema = v.strictObject({
234
- id: NonEmpty,
235
- title: v.optional(v.string()),
236
- description: v.optional(v.string()),
237
- type: picklist(["string", "number", "boolean", "string[]", "reference"]),
238
- enum: v.optional(v.array(v.string()))
239
- }), PredicateSchema = v.strictObject({
240
- type: v.optional(v.literal("workflow.predicate")),
241
- id: NonEmpty,
242
- title: v.optional(v.string()),
243
- description: v.optional(v.string()),
244
- groq: NonEmpty,
245
- params: v.optional(v.array(PredicateParamSchema))
246
- }), EffectSchema = v.strictObject({
247
- type: v.optional(v.literal("workflow.effect")),
248
- id: NonEmpty,
249
- title: v.optional(v.string()),
250
- description: v.optional(v.string()),
251
- // Bindings resolve typed Source values at commit time, producing
252
- // concrete JSON in the queued effect's `params`. NO GROQ.
253
- bindings: v.optional(v.record(v.string(), SourceSchema)),
254
- input: v.optional(v.record(v.string(), v.unknown()))
255
- }), TerminalTaskStatus = picklist(["done", "skipped", "failed"]), PermissionSchema = picklist(DOCUMENT_VALUE_PERMISSIONS), ActionParamSchema = v.strictObject({
256
- type: v.optional(v.literal("workflow.action.param")),
257
- id: NonEmpty,
258
- title: v.optional(v.string()),
259
- description: v.optional(v.string()),
260
- paramType: picklist([
261
- "string",
262
- "number",
263
- "boolean",
264
- "url",
265
- "dateTime",
266
- "actor",
267
- "doc.ref",
268
- "doc.refs",
269
- "json"
270
- ]),
271
- required: v.optional(v.boolean())
272
- }), ActionSchema = v.strictObject({
273
- type: v.optional(v.literal("workflow.action")),
274
- id: NonEmpty,
275
- title: v.optional(v.string()),
276
- description: v.optional(v.string()),
277
- filter: v.optional(FilterSchema),
278
- /** Caller-supplied params, validated before ops/effects run. */
279
- params: v.optional(v.array(ActionParamSchema)),
280
- /**
281
- * Status the task flips to when this action fires. Omit to leave
282
- * the task status unchanged — used by intermediate `claim` /
283
- * `assign` / partial-update actions where the task should stay
284
- * active so a later action can fire on it. Declared values must
285
- * be terminal (`done` / `skipped` / `failed`); the engine never
286
- * mid-flip back to `active` outside of the `workflow.op.status.set`
287
- * op explicit path.
288
- */
289
- setStatus: v.optional(TerminalTaskStatus),
290
- /**
291
- * Inline state-mutation primitives executed during the action commit.
292
- * Each op runs against the in-memory mutation (deterministic, no
293
- * external I/O). Resolved Sources turn into concrete JSON before the
294
- * op applies. Logged on `history[]` as `workflow.history.opApplied`
295
- * and surfaced on the `ActionResult.ranOps`.
296
- */
297
- ops: v.optional(v.array(OpSchema)),
298
- effects: v.optional(v.array(EffectSchema)),
299
- /**
300
- * Role gating — OR-match against `Actor.roles[]`. If omitted, no role
301
- * gate. `"*"` in Actor.roles always matches (bench / all-access).
302
- */
303
- roles: v.optional(v.array(NonEmpty)),
304
- /**
305
- * When true, the actor must appear in the task's `assignees[]` (as a
306
- * user-kind assignee matching by id) for the action to be allowed.
307
- */
308
- requireAssignment: v.optional(v.boolean()),
309
- /**
310
- * Which permission on the workflow.instance document the actor must
311
- * hold (per supplied `grants`). Defaults to "update". Only checked
312
- * when grants are supplied at evaluate/fireAction time.
313
- */
314
- requiredPermission: v.optional(PermissionSchema)
315
- }), CompletionPolicySchema = v.union([
316
- v.strictObject({ kind: v.literal("all") }),
317
- v.strictObject({ kind: v.literal("any") }),
318
- v.strictObject({
319
- kind: v.literal("count"),
320
- n: PositiveInt
321
- })
322
- ]), LogicalDefinitionRefSchema = v.strictObject({
323
- workflowId: NonEmpty,
324
- version: v.optional(v.union([PositiveInt, v.literal("latest")]))
325
- }), SpawnForEachSchema = v.strictObject({
326
- groq: NonEmpty,
327
- as: v.strictObject({
328
- initialState: v.optional(
329
- v.array(
330
- v.strictObject({
331
- type: StateSlotKindSchema,
332
- id: NonEmpty,
333
- value: SourceSchema
334
- })
335
- )
336
- ),
337
- effectsContext: v.optional(v.record(v.string(), SourceSchema))
338
- })
339
- }), SpawnSchema = v.strictObject({
340
- type: v.optional(v.literal("workflow.spawn")),
341
- id: v.optional(v.string()),
342
- title: v.optional(v.string()),
343
- description: v.optional(v.string()),
344
- definitionRef: LogicalDefinitionRefSchema,
345
- forEach: SpawnForEachSchema,
346
- completionPolicy: v.optional(CompletionPolicySchema)
347
- }), AssigneeSchema = v.variant("kind", [
348
- v.strictObject({ kind: v.literal("user"), id: NonEmpty }),
349
- v.strictObject({ kind: v.literal("role"), role: NonEmpty })
350
- ]), TaskSchema = v.strictObject({
351
- type: v.optional(v.literal("workflow.task")),
352
- id: NonEmpty,
353
- title: v.optional(v.string()),
354
- description: v.optional(v.string()),
355
- assignees: v.optional(v.array(AssigneeSchema)),
356
- filter: v.optional(FilterSchema),
357
- invokeOn: v.optional(picklist(["stageEnter", "manual"])),
358
- /**
359
- * Auto-completion predicate — same shape as `transition.filter`. When
360
- * truthy at activation or on any subsequent cascade, the engine
361
- * flips the task to `done` with a `{ kind: "system", id: "engine.completeWhen" }`
362
- * actor. A full filter, not just a wall-clock deadline.
363
- */
364
- completeWhen: v.optional(FilterSchema),
365
- /**
366
- * Auto-failure predicate — symmetric to `completeWhen`. Same shape,
367
- * same evaluation cadence (activation + every cascade), but flips
368
- * the task to `failed` (not `done`) with a `{ kind: "system",
369
- * id: "engine.failWhen" }` actor. When both `completeWhen` and
370
- * `failWhen` resolve truthy on the same evaluation, `failWhen`
371
- * wins — failure is the more notable signal and should not be
372
- * silently swallowed.
373
- */
374
- failWhen: v.optional(FilterSchema),
375
- effects: v.optional(v.array(EffectSchema)),
376
- actions: v.optional(v.array(ActionSchema)),
377
- spawns: v.optional(SpawnSchema),
378
- contentRefs: v.optional(v.array(v.unknown())),
379
- /** Task-scoped state slots. Resolved at task activation time. */
380
- state: v.optional(v.array(StateSlotSchema))
381
- }), TransitionSchema = v.strictObject({
382
- type: v.optional(v.literal("workflow.transition")),
383
- id: NonEmpty,
384
- title: v.optional(v.string()),
385
- description: v.optional(v.string()),
386
- to: NonEmpty,
387
- on: v.optional(v.string()),
388
- filter: v.optional(FilterSchema),
389
- effects: v.optional(v.array(EffectSchema))
390
- }), GuardActionSchema = picklist(MUTATION_GUARD_ACTIONS), GuardMatchSchema = v.strictObject({
391
- /** Subject `_type`(s); empty matches any type. */
392
- types: v.optional(v.array(NonEmpty)),
393
- /** Target docs as `Source`s resolved at deploy to bare ids + the resource. */
394
- idRefs: v.optional(v.array(SourceSchema)),
395
- /** Glob id patterns (bare, resource-local). */
396
- idPatterns: v.optional(v.array(NonEmpty)),
397
- actions: v.pipe(
398
- v.array(GuardActionSchema),
399
- v.minLength(1, "a guard must match at least one action")
400
- )
401
- }), GuardSchema = v.strictObject({
402
- name: v.optional(v.string()),
403
- description: v.optional(v.string()),
404
- match: GuardMatchSchema,
405
- /**
406
- * Lake GROQ predicate. Reads `document.before`/`document.after`, `mutation`,
407
- * `guard`, and `identity()`. Bare ids/fields only — no GDRs. Omitted or
408
- * empty means UNCONDITIONAL DENY.
409
- */
410
- predicate: v.optional(v.string()),
411
- /**
412
- * Projected workflow state the predicate reads as `guard.metadata.*`. Values
413
- * are `Source`s resolved at deploy and re-synced by the engine. Copied data,
414
- * never a cross-resource pointer.
415
- */
416
- metadata: v.optional(v.record(NonEmpty, SourceSchema))
417
- }), StageKindSchema = picklist(["initial", "intermediate", "terminal", "waiting"]), StageSchema = v.strictObject({
418
- type: v.optional(v.literal("workflow.stage")),
419
- id: NonEmpty,
420
- title: v.optional(v.string()),
421
- description: v.optional(v.string()),
422
- kind: v.optional(StageKindSchema),
423
- tasks: v.optional(v.array(TaskSchema)),
424
- transitions: v.optional(v.array(TransitionSchema)),
425
- completion: v.optional(FilterSchema),
426
- onEnter: v.optional(v.array(EffectSchema)),
427
- onExit: v.optional(v.array(EffectSchema)),
428
- /**
429
- * Lake mutation guards active while this stage holds. Each compiles to a
430
- * `temp.system.guard` doc deployed on stage entry and retracted on exit.
431
- * Plural because one stage's intent may span resources (one guard each).
432
- */
433
- guards: v.optional(v.array(GuardSchema)),
434
- contentRefs: v.optional(v.array(v.unknown())),
435
- /** Stage-scoped state slots. Resolved at stage entry and persisted on
436
- * the StageEntry. */
437
- state: v.optional(v.array(StateSlotSchema))
438
- }), WorkflowDefinitionSchema = v.strictObject({
439
- workflowId: NonEmpty,
440
- version: PositiveInt,
441
- title: NonEmpty,
442
- description: v.optional(v.string()),
443
- initialStageId: NonEmpty,
444
- /**
445
- * Workflow-level state slots. Persist for the instance lifetime.
446
- * Every stage's filters/ops can read them via
447
- * `*[_id == $self][0].state[key == "<key>"][0].value`. Init-sourced
448
- * slots are supplied at `startInstance` via `initialState`.
449
- */
450
- state: v.optional(v.array(StateSlotSchema)),
451
- stages: v.pipe(v.array(StageSchema), v.minLength(1, "must declare at least one stage")),
452
- predicates: v.optional(v.array(PredicateSchema))
453
- });
454
- function formatValidationError(label, issues) {
455
- const lines = issues.map((issue) => ` - ${issue.path.length === 0 ? "(root)" : formatPath(issue.path)}: ${issue.message}`);
456
- return `${label} failed validation (${issues.length} issue${issues.length === 1 ? "" : "s"}):
457
- ${lines.join(`
458
- `)}`;
459
- }
460
- function issuesFromValibot(issues) {
461
- return issues.map((issue) => ({
462
- path: issue.path ? issue.path.map((item) => item.key) : [],
463
- message: issue.message
464
- }));
465
- }
466
- function formatPath(path) {
467
- let out = "";
468
- for (const seg of path)
469
- typeof seg == "number" ? out += `[${seg}]` : out += out.length === 0 ? String(seg) : `.${String(seg)}`;
470
- return out;
451
+ for (const [key, groq2] of Object.entries(record ?? {}))
452
+ sites.push({
453
+ groq: groq2,
454
+ path: [...subPath, group, key],
455
+ label: `task "${task.name}".subworkflows.${group} "${key}"`
456
+ });
457
+ }
458
+ function collectBindingSites(effects, path, label, sites) {
459
+ for (const [e, effect] of (effects ?? []).entries())
460
+ for (const [key, groq2] of Object.entries(effect.bindings ?? {}))
461
+ sites.push({
462
+ groq: groq2,
463
+ path: [...path, e, "bindings", key],
464
+ label: `${label} effect "${effect.name}" binding "${key}"`
465
+ });
466
+ }
467
+ function checkAssigneesEntries(def, issues) {
468
+ for (const { entries, path } of stateScopes(def))
469
+ (entries ?? []).filter((e) => e.type === "assignees").length <= 1 || issues.push({
470
+ path,
471
+ message: "at most one assignees-kind state entry per scope \u2014 the inbox reads it by kind"
472
+ });
473
+ }
474
+ function checkWorkflowInvariants(def) {
475
+ const issues = [], stageNames = checkStages(def, issues);
476
+ return checkInitialStage(def, stageNames, issues), checkTransitionTargets(def, stageNames, issues), checkEffectNames(def, issues), checkGuardNames(def, issues), checkStateEntryNames(def, issues), checkPredicates(def, issues), checkCanOutsideActionFilters(def, issues), checkAssigneesEntries(def, issues), issues;
471
477
  }
472
478
  function defineWorkflow(definition) {
473
- const workflowId = definition.workflowId, label = typeof workflowId == "string" ? `defineWorkflow("${workflowId}")` : "defineWorkflow", parsed = parseOrThrow(WorkflowDefinitionSchema, definition, label), issues = checkWorkflowInvariants(parsed);
479
+ const label = labelFor("defineWorkflow", definition), parsed = parseOrThrow(AuthoringWorkflowSchema, definition, label), { definition: stored, issues: desugarIssues } = desugarWorkflow(parsed), issues = [...desugarIssues, ...checkWorkflowInvariants(stored)];
474
480
  if (issues.length > 0) throw new Error(formatValidationError(label, issues));
475
- return parsed;
481
+ return stored;
476
482
  }
477
483
  function defineStage(stage) {
478
- return parseOrThrow(StageSchema, stage, labelFor("defineStage", stage, "id"));
484
+ return parseOrThrow(AuthoringStageSchema, stage, labelFor("defineStage", stage));
479
485
  }
480
486
  function defineTask(task) {
481
- return parseOrThrow(TaskSchema, task, labelFor("defineTask", task, "id"));
487
+ return parseOrThrow(AuthoringTaskSchema, task, labelFor("defineTask", task));
482
488
  }
483
489
  function defineAction(action) {
484
- return parseOrThrow(ActionSchema, action, labelFor("defineAction", action, "id"));
490
+ return parseOrThrow(AuthoringActionSchema, action, labelFor("defineAction", action));
485
491
  }
486
492
  function defineTransition(transition) {
487
- return parseOrThrow(
488
- TransitionSchema,
489
- transition,
490
- typeof transition.id == "string" ? `defineTransition("${transition.id}")` : typeof transition.to == "string" ? `defineTransition(\u2192 "${transition.to}")` : "defineTransition"
491
- );
493
+ return parseOrThrow(AuthoringTransitionSchema, transition, transitionLabel(transition));
492
494
  }
493
- function defineFilter(filter) {
494
- return parseOrThrow(FilterSchema, filter, "defineFilter");
495
+ function defineState(entry) {
496
+ return parseOrThrow(AuthoringStateEntrySchema, entry, labelFor("defineState", entry));
495
497
  }
496
- function defineAssignee(assignee) {
497
- return parseOrThrow(AssigneeSchema, assignee, "defineAssignee");
498
+ function defineOp(op) {
499
+ return parseOrThrow(AuthoringOpSchema, op, "defineOp");
498
500
  }
499
- function definePredicate(predicate) {
500
- return parseOrThrow(PredicateSchema, predicate, labelFor("definePredicate", predicate, "id"));
501
+ function defineGuard(guard) {
502
+ return parseOrThrow(GuardSchema, guard, labelFor("defineGuard", guard));
501
503
  }
502
504
  function defineEffect(effect) {
503
- return parseOrThrow(EffectSchema, effect, labelFor("defineEffect", effect, "id"));
505
+ return parseOrThrow(EffectSchema, effect, labelFor("defineEffect", effect));
506
+ }
507
+ function transitionLabel(transition) {
508
+ const { name, to } = transition;
509
+ return typeof name == "string" ? `defineTransition("${name}")` : typeof to == "string" ? `defineTransition(\u2192 "${to}")` : "defineTransition";
504
510
  }
505
511
  function defineEffectDescriptor(descriptor) {
506
512
  if (!descriptor.name) throw new Error("EffectDescriptor missing name");
@@ -512,23 +518,24 @@ function parseOrThrow(schema, input, label) {
512
518
  throw new Error(formatValidationError(label, issuesFromValibot(result.issues)));
513
519
  return result.output;
514
520
  }
515
- function labelFor(fn, value, key) {
516
- if (value && typeof value == "object" && key in value) {
517
- const raw = value[key];
521
+ function labelFor(fn, value) {
522
+ if (value && typeof value == "object" && "name" in value) {
523
+ const raw = value.name;
518
524
  if (typeof raw == "string") return `${fn}("${raw}")`;
519
525
  }
520
526
  return fn;
521
527
  }
522
528
  export {
523
529
  defineAction,
524
- defineAssignee,
525
530
  defineEffect,
526
531
  defineEffectDescriptor,
527
- defineFilter,
528
- definePredicate,
532
+ defineGuard,
533
+ defineOp,
529
534
  defineStage,
535
+ defineState,
530
536
  defineTask,
531
537
  defineTransition,
532
- defineWorkflow
538
+ defineWorkflow,
539
+ groq
533
540
  };
534
541
  //# sourceMappingURL=define.js.map