@sanity/workflow-engine 0.13.0 → 0.14.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.d.cts CHANGED
@@ -98,7 +98,7 @@ declare type AuthoringEditable = v.InferOutput<typeof AuthoringEditableSchema>;
98
98
  /**
99
99
  * Authoring editability adds the `role[]` convenience: a non-empty role list
100
100
  * desugars to the same `count($actor.roles[@ in [...]]) > 0` membership
101
- * predicate `action.roles` produces. `true` opens the slot to anyone in its
101
+ * predicate `action.roles` produces. `true` opens the field to anyone in its
102
102
  * window; a bare string is a raw predicate.
103
103
  */
104
104
  declare const AuthoringEditableSchema: v.UnionSchema<
@@ -150,6 +150,292 @@ declare const AuthoringFieldRefSchema: v.StrictObjectSchema<
150
150
  undefined
151
151
  >;
152
152
 
153
+ declare type AuthoringGuard = v.InferOutput<typeof AuthoringGuardSchema>;
154
+
155
+ declare const AuthoringGuardSchema: v.StrictObjectSchema<
156
+ {
157
+ name: v.SchemaWithPipe<
158
+ readonly [
159
+ v.StringSchema<undefined>,
160
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
161
+ ]
162
+ >;
163
+ title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
164
+ description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
165
+ match: v.StrictObjectSchema<
166
+ {
167
+ /** Subject `_type`(s); empty matches any type. */
168
+ types: v.OptionalSchema<
169
+ v.ArraySchema<
170
+ v.SchemaWithPipe<
171
+ readonly [
172
+ v.StringSchema<undefined>,
173
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
174
+ ]
175
+ >,
176
+ undefined
177
+ >,
178
+ undefined
179
+ >;
180
+ /** Target docs as field reads (or the instance itself), resolved at deploy to bare ids + the resource. */
181
+ idRefs: v.OptionalSchema<
182
+ v.ArraySchema<
183
+ v.VariantSchema<
184
+ "type",
185
+ [
186
+ v.StrictObjectSchema<
187
+ {
188
+ readonly type: v.LiteralSchema<"self", undefined>;
189
+ },
190
+ undefined
191
+ >,
192
+ v.StrictObjectSchema<
193
+ {
194
+ readonly type: v.LiteralSchema<"now", undefined>;
195
+ },
196
+ undefined
197
+ >,
198
+ v.StrictObjectSchema<
199
+ {
200
+ readonly type: v.LiteralSchema<"fieldRead", undefined>;
201
+ readonly field: v.SchemaWithPipe<
202
+ readonly [
203
+ v.StringSchema<undefined>,
204
+ v.RegexAction<string, string>,
205
+ ]
206
+ >;
207
+ readonly path: v.OptionalSchema<
208
+ v.SchemaWithPipe<
209
+ readonly [
210
+ v.SchemaWithPipe<
211
+ readonly [
212
+ v.StringSchema<undefined>,
213
+ v.MinLengthAction<
214
+ string,
215
+ 1,
216
+ "must be a non-empty string"
217
+ >,
218
+ ]
219
+ >,
220
+ v.CheckAction<
221
+ string,
222
+ "a guard read path cannot contain a line break"
223
+ >,
224
+ ]
225
+ >,
226
+ undefined
227
+ >;
228
+ },
229
+ undefined
230
+ >,
231
+ v.StrictObjectSchema<
232
+ {
233
+ readonly type: v.LiteralSchema<"effectsRead", undefined>;
234
+ readonly effect: v.SchemaWithPipe<
235
+ readonly [
236
+ v.SchemaWithPipe<
237
+ readonly [
238
+ v.StringSchema<undefined>,
239
+ v.MinLengthAction<
240
+ string,
241
+ 1,
242
+ "must be a non-empty string"
243
+ >,
244
+ ]
245
+ >,
246
+ v.CheckAction<
247
+ string,
248
+ "an effect name cannot contain `'`"
249
+ >,
250
+ ]
251
+ >;
252
+ readonly path: v.OptionalSchema<
253
+ v.SchemaWithPipe<
254
+ readonly [
255
+ v.SchemaWithPipe<
256
+ readonly [
257
+ v.StringSchema<undefined>,
258
+ v.MinLengthAction<
259
+ string,
260
+ 1,
261
+ "must be a non-empty string"
262
+ >,
263
+ ]
264
+ >,
265
+ v.CheckAction<
266
+ string,
267
+ "a guard read path cannot contain a line break"
268
+ >,
269
+ ]
270
+ >,
271
+ undefined
272
+ >;
273
+ },
274
+ undefined
275
+ >,
276
+ ],
277
+ undefined
278
+ >,
279
+ undefined
280
+ >,
281
+ undefined
282
+ >;
283
+ /** Glob id patterns (bare, resource-local). */
284
+ idPatterns: v.OptionalSchema<
285
+ v.ArraySchema<
286
+ v.SchemaWithPipe<
287
+ readonly [
288
+ v.StringSchema<undefined>,
289
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
290
+ ]
291
+ >,
292
+ undefined
293
+ >,
294
+ undefined
295
+ >;
296
+ actions: v.SchemaWithPipe<
297
+ readonly [
298
+ v.ArraySchema<
299
+ v.PicklistSchema<
300
+ readonly ["create", "update", "delete", "publish", "unpublish"],
301
+ `Invalid option: expected one of ${string}`
302
+ >,
303
+ undefined
304
+ >,
305
+ v.MinLengthAction<
306
+ ("create" | "update" | "delete" | "publish" | "unpublish")[],
307
+ 1,
308
+ "a guard must match at least one action"
309
+ >,
310
+ ]
311
+ >;
312
+ },
313
+ undefined
314
+ >;
315
+ /**
316
+ * Lake GROQ predicate — a distinct eval context reading
317
+ * `document.before`/`document.after`, `mutation`, `guard`, and
318
+ * `identity()`. Bare ids/fields only. Omitted or empty means
319
+ * UNCONDITIONAL DENY.
320
+ */
321
+ predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
322
+ /**
323
+ * Projected workflow fields the predicate reads as `guard.metadata.*` —
324
+ * the only bridge from the lake eval context (which cannot see `$fields`)
325
+ * to workflow fields. Each value is a deploy-time read — a typed
326
+ * {@link GuardRead} when authoring, the printed string spelling once
327
+ * stored — resolved into a bare value at deploy and re-synced by the
328
+ * post-field-op guard refresh.
329
+ */
330
+ metadata: v.OptionalSchema<
331
+ v.RecordSchema<
332
+ v.SchemaWithPipe<
333
+ readonly [
334
+ v.StringSchema<undefined>,
335
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
336
+ ]
337
+ >,
338
+ v.VariantSchema<
339
+ "type",
340
+ [
341
+ v.StrictObjectSchema<
342
+ {
343
+ readonly type: v.LiteralSchema<"self", undefined>;
344
+ },
345
+ undefined
346
+ >,
347
+ v.StrictObjectSchema<
348
+ {
349
+ readonly type: v.LiteralSchema<"now", undefined>;
350
+ },
351
+ undefined
352
+ >,
353
+ v.StrictObjectSchema<
354
+ {
355
+ readonly type: v.LiteralSchema<"fieldRead", undefined>;
356
+ readonly field: v.SchemaWithPipe<
357
+ readonly [
358
+ v.StringSchema<undefined>,
359
+ v.RegexAction<string, string>,
360
+ ]
361
+ >;
362
+ readonly path: v.OptionalSchema<
363
+ v.SchemaWithPipe<
364
+ readonly [
365
+ v.SchemaWithPipe<
366
+ readonly [
367
+ v.StringSchema<undefined>,
368
+ v.MinLengthAction<
369
+ string,
370
+ 1,
371
+ "must be a non-empty string"
372
+ >,
373
+ ]
374
+ >,
375
+ v.CheckAction<
376
+ string,
377
+ "a guard read path cannot contain a line break"
378
+ >,
379
+ ]
380
+ >,
381
+ undefined
382
+ >;
383
+ },
384
+ undefined
385
+ >,
386
+ v.StrictObjectSchema<
387
+ {
388
+ readonly type: v.LiteralSchema<"effectsRead", undefined>;
389
+ readonly effect: v.SchemaWithPipe<
390
+ readonly [
391
+ v.SchemaWithPipe<
392
+ readonly [
393
+ v.StringSchema<undefined>,
394
+ v.MinLengthAction<
395
+ string,
396
+ 1,
397
+ "must be a non-empty string"
398
+ >,
399
+ ]
400
+ >,
401
+ v.CheckAction<string, "an effect name cannot contain `'`">,
402
+ ]
403
+ >;
404
+ readonly path: v.OptionalSchema<
405
+ v.SchemaWithPipe<
406
+ readonly [
407
+ v.SchemaWithPipe<
408
+ readonly [
409
+ v.StringSchema<undefined>,
410
+ v.MinLengthAction<
411
+ string,
412
+ 1,
413
+ "must be a non-empty string"
414
+ >,
415
+ ]
416
+ >,
417
+ v.CheckAction<
418
+ string,
419
+ "a guard read path cannot contain a line break"
420
+ >,
421
+ ]
422
+ >,
423
+ undefined
424
+ >;
425
+ },
426
+ undefined
427
+ >,
428
+ ],
429
+ undefined
430
+ >,
431
+ undefined
432
+ >,
433
+ undefined
434
+ >;
435
+ },
436
+ undefined
437
+ >;
438
+
153
439
  declare type AuthoringManualTarget = v.InferOutput<
154
440
  typeof AuthoringManualTargetSchema
155
441
  >;
@@ -309,7 +595,12 @@ declare const AuthoringOpSchema: v.VariantSchema<
309
595
  },
310
596
  undefined
311
597
  >;
312
- readonly where: v.GenericSchema<OpPredicateInternal>;
598
+ readonly where: v.SchemaWithPipe<
599
+ readonly [
600
+ v.StringSchema<undefined>,
601
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
602
+ ]
603
+ >;
313
604
  readonly value: v.GenericSchema<ValueExprInternal>;
314
605
  },
315
606
  undefined
@@ -335,7 +626,12 @@ declare const AuthoringOpSchema: v.VariantSchema<
335
626
  },
336
627
  undefined
337
628
  >;
338
- readonly where: v.GenericSchema<OpPredicateInternal>;
629
+ readonly where: v.SchemaWithPipe<
630
+ readonly [
631
+ v.StringSchema<undefined>,
632
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
633
+ ]
634
+ >;
339
635
  },
340
636
  undefined
341
637
  >,
@@ -423,7 +719,10 @@ declare const AuthoringOpSchema: v.VariantSchema<
423
719
  * - `status` → a `status.set` op on the firing activity, appended **after**
424
720
  * the authored ops (deliberately never implied: a forgotten explicit
425
721
  * `status` is a visible stall, an implied default silently completes
426
- * claim-like actions).
722
+ * claim-like actions). Status is the health axis: a decision action
723
+ * (decline, send back) resolves `done` and writes the decision into a
724
+ * field the transition filter reads — `failed` is for work that
725
+ * genuinely could not complete.
427
726
  */
428
727
  declare type AuthoringRawAction = ActionFields<AuthoringOp> & {
429
728
  roles?: string[] | undefined;
@@ -436,6 +735,7 @@ declare type AuthoringStage = StageFields<
436
735
  AuthoringFieldEntry,
437
736
  AuthoringActivity,
438
737
  AuthoringTransition,
738
+ AuthoringGuard,
439
739
  AuthoringEditable
440
740
  >;
441
741
 
@@ -550,7 +850,12 @@ declare const AuthoringTransitionOpSchema: v.VariantSchema<
550
850
  },
551
851
  undefined
552
852
  >;
553
- readonly where: v.GenericSchema<OpPredicateInternal>;
853
+ readonly where: v.SchemaWithPipe<
854
+ readonly [
855
+ v.StringSchema<undefined>,
856
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
857
+ ]
858
+ >;
554
859
  readonly value: v.GenericSchema<ValueExprInternal>;
555
860
  },
556
861
  undefined
@@ -576,7 +881,12 @@ declare const AuthoringTransitionOpSchema: v.VariantSchema<
576
881
  },
577
882
  undefined
578
883
  >;
579
- readonly where: v.GenericSchema<OpPredicateInternal>;
884
+ readonly where: v.SchemaWithPipe<
885
+ readonly [
886
+ v.StringSchema<undefined>,
887
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
888
+ ]
889
+ >;
580
890
  },
581
891
  undefined
582
892
  >,
@@ -664,7 +974,7 @@ declare type ClaimAction = {
664
974
  /**
665
975
  * Authoring fields accept the raw entries plus the `claim` sugar type — the
666
976
  * field half of the mirrored claim pair. Expansion: an `actor` working-
667
- * memory slot (no `initialValue`; the claim action's op fills it), strictly
977
+ * memory field (no `initialValue`; the claim action's op fills it), strictly
668
978
  * within this entry.
669
979
  */
670
980
  declare type ClaimField = {
@@ -674,6 +984,57 @@ declare type ClaimField = {
674
984
  description?: string | undefined;
675
985
  };
676
986
 
987
+ /**
988
+ * Every variable the engine binds for conditions, in one place. The
989
+ * deploy-time shadow check ({@link RESERVED_CONDITION_VARS}) and the docs on
990
+ * {@link Condition} derive from this list — extend it here when the engine
991
+ * grows a binding, never in a comment elsewhere.
992
+ */
993
+ export declare const CONDITION_VARS: readonly ConditionVar[];
994
+
995
+ export declare interface ConditionVar {
996
+ /** The GROQ param name, read as `$<name>`. */
997
+ name: string;
998
+ binding: ConditionVarBinding;
999
+ description: string;
1000
+ }
1001
+
1002
+ /**
1003
+ * The condition-variable inventory — the single source of truth for every
1004
+ * `$var` the engine binds when it evaluates a {@link Condition}.
1005
+ *
1006
+ * Three evaluation contexts read a definition's GROQ:
1007
+ *
1008
+ * 1. **Rendered condition scope** — every condition site in a definition
1009
+ * (transition filters, `completeWhen`/`failWhen`, action filters, effect
1010
+ * bindings, `subworkflows` reads, where-op `where`s, editability
1011
+ * predicates, author predicates). {@link CONDITION_VARS} is its inventory;
1012
+ * each entry's `binding` says when the var actually holds a value. The
1013
+ * where-op context is the one closed subset — its bound set is statically
1014
+ * fixed and deploy-enforced (see the op-where scope's param-name list in
1015
+ * the op applier).
1016
+ * 2. **Filter evaluation without a caller** — the engine's cascade evaluates
1017
+ * transition filters and `completeWhen`/`failWhen` with no caller, so only
1018
+ * the `'always'`-bound subset carries values there ({@link FILTER_SCOPE_VARS}).
1019
+ * Caller-bound vars evaluate to `undefined` and fail closed.
1020
+ * 3. **Guard predicates** — NOT conditions. A lake mutation guard's
1021
+ * `predicate` is groq-js **delta-mode** GROQ over a document mutation:
1022
+ * `before()`/`after()`/`identity()` are dialect natives, and the wire
1023
+ * format binds the identifiers in {@link GUARD_PREDICATE_VARS}. None of
1024
+ * the condition vars exist there.
1025
+ */
1026
+ /**
1027
+ * When a condition var holds a value:
1028
+ *
1029
+ * - `'always'` — bound in every condition evaluation, derived from the
1030
+ * instance and its snapshot.
1031
+ * - `'caller'` — rides the acting caller; without one the var is `undefined`
1032
+ * (conditions referencing it fail closed). Author predicates may not read
1033
+ * these — they pre-evaluate once per instance, caller-free.
1034
+ * - `'spawn'` — bound only at `subworkflows` sites.
1035
+ */
1036
+ export declare type ConditionVarBinding = "always" | "caller" | "spawn";
1037
+
677
1038
  export declare function defineAction(action: AuthoringAction): AuthoringAction;
678
1039
 
679
1040
  export declare function defineActivity(
@@ -694,7 +1055,7 @@ export declare function defineField(
694
1055
  entry: AuthoringFieldEntry,
695
1056
  ): AuthoringFieldEntry;
696
1057
 
697
- export declare function defineGuard(guard: Guard): Guard;
1058
+ export declare function defineGuard(guard: AuthoringGuard): AuthoringGuard;
698
1059
 
699
1060
  export declare function defineOp(op: AuthoringOp): AuthoringOp;
700
1061
 
@@ -720,6 +1081,16 @@ export declare function defineWorkflow(
720
1081
  definition: AuthoringWorkflow,
721
1082
  ): WorkflowDefinition;
722
1083
 
1084
+ /**
1085
+ * Validate a deploy config — the binding of each definition's logical resource
1086
+ * handles to physical resources, per environment (tag). Throws a formatted,
1087
+ * path-prefixed error if the shape is invalid. The CLI hands the selected
1088
+ * deployment's {@link resourceAliasesToMap} map to {@link deployDefinitions}.
1089
+ */
1090
+ export declare function defineWorkflowConfig(
1091
+ config: WorkflowConfig,
1092
+ ): WorkflowConfig;
1093
+
723
1094
  declare type Editable = v.InferOutput<typeof StoredEditableSchema>;
724
1095
 
725
1096
  declare type Effect = v.InferOutput<typeof EffectSchema>;
@@ -803,11 +1174,21 @@ declare const FIELD_VALUE_KINDS: readonly [
803
1174
  "array",
804
1175
  ];
805
1176
 
1177
+ /** Type-mirror of {@link fieldBase}, parameterised over the `editable` grammar. */
1178
+ declare type FieldBase<TEditable> = {
1179
+ name: string;
1180
+ title?: string | undefined;
1181
+ description?: string | undefined;
1182
+ required?: boolean | undefined;
1183
+ initialValue?: FieldSource | undefined;
1184
+ editable?: TEditable | undefined;
1185
+ };
1186
+
806
1187
  declare type FieldEntry = FieldEntryFields<Editable>;
807
1188
 
808
1189
  /** Type-mirror of {@link fieldEntryFields}: a raw field entry of the given
809
1190
  * editability grammar. */
810
- declare type FieldEntryFields<TEditable> = SlotFields<TEditable> & {
1191
+ declare type FieldEntryFields<TEditable> = FieldBase<TEditable> & {
811
1192
  type: FieldValueKind;
812
1193
  fields?: FieldShape[] | undefined;
813
1194
  of?: FieldShape[] | undefined;
@@ -847,6 +1228,12 @@ declare type FieldSourceInternal =
847
1228
  /** The union a value (or nested {@link FieldShape}) kind may take — see {@link FIELD_VALUE_KINDS}. */
848
1229
  declare type FieldValueKind = (typeof FIELD_VALUE_KINDS)[number];
849
1230
 
1231
+ /**
1232
+ * The subset that holds a value when the engine evaluates filters without a
1233
+ * caller (the cascade path: transition filters, `completeWhen`/`failWhen`).
1234
+ */
1235
+ export declare const FILTER_SCOPE_VARS: readonly string[];
1236
+
850
1237
  /**
851
1238
  * Hygienic GROQ interpolation for define-time condition building.
852
1239
  *
@@ -869,23 +1256,33 @@ export declare function groq(
869
1256
 
870
1257
  declare type Guard = v.InferOutput<typeof GuardSchema>;
871
1258
 
1259
+ /**
1260
+ * The identifiers a lake mutation guard's `predicate` reads — the wire
1261
+ * dialect, not the condition scope (so no {@link ConditionVarBinding}: these
1262
+ * bind only when a guard evaluates a mutation). `before()`/`after()`/
1263
+ * `identity()` are groq-js delta-mode natives on top of these. Bound in one
1264
+ * place: `guardPredicateParams` in the guard evaluator.
1265
+ */
1266
+ export declare const GUARD_PREDICATE_VARS: readonly {
1267
+ name: string;
1268
+ description: string;
1269
+ }[];
1270
+
1271
+ /** Stored guards carry the printed string reads (the deploy resolver's input). */
872
1272
  declare const GuardSchema: v.StrictObjectSchema<
873
1273
  {
874
- readonly name: v.SchemaWithPipe<
1274
+ name: v.SchemaWithPipe<
875
1275
  readonly [
876
1276
  v.StringSchema<undefined>,
877
1277
  v.MinLengthAction<string, 1, "must be a non-empty string">,
878
1278
  ]
879
1279
  >;
880
- readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
881
- readonly description: v.OptionalSchema<
882
- v.StringSchema<undefined>,
883
- undefined
884
- >;
885
- readonly match: v.StrictObjectSchema<
1280
+ title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1281
+ description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1282
+ match: v.StrictObjectSchema<
886
1283
  {
887
1284
  /** Subject `_type`(s); empty matches any type. */
888
- readonly types: v.OptionalSchema<
1285
+ types: v.OptionalSchema<
889
1286
  v.ArraySchema<
890
1287
  v.SchemaWithPipe<
891
1288
  readonly [
@@ -897,8 +1294,8 @@ declare const GuardSchema: v.StrictObjectSchema<
897
1294
  >,
898
1295
  undefined
899
1296
  >;
900
- /** Target docs as `$fields` reads (or `"$self"`), resolved at deploy to bare ids + the resource. */
901
- readonly idRefs: v.OptionalSchema<
1297
+ /** Target docs as field reads (or the instance itself), resolved at deploy to bare ids + the resource. */
1298
+ idRefs: v.OptionalSchema<
902
1299
  v.ArraySchema<
903
1300
  v.SchemaWithPipe<
904
1301
  readonly [
@@ -911,7 +1308,7 @@ declare const GuardSchema: v.StrictObjectSchema<
911
1308
  undefined
912
1309
  >;
913
1310
  /** Glob id patterns (bare, resource-local). */
914
- readonly idPatterns: v.OptionalSchema<
1311
+ idPatterns: v.OptionalSchema<
915
1312
  v.ArraySchema<
916
1313
  v.SchemaWithPipe<
917
1314
  readonly [
@@ -923,7 +1320,7 @@ declare const GuardSchema: v.StrictObjectSchema<
923
1320
  >,
924
1321
  undefined
925
1322
  >;
926
- readonly actions: v.SchemaWithPipe<
1323
+ actions: v.SchemaWithPipe<
927
1324
  readonly [
928
1325
  v.ArraySchema<
929
1326
  v.PicklistSchema<
@@ -948,16 +1345,16 @@ declare const GuardSchema: v.StrictObjectSchema<
948
1345
  * `identity()`. Bare ids/fields only. Omitted or empty means
949
1346
  * UNCONDITIONAL DENY.
950
1347
  */
951
- readonly predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1348
+ predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
952
1349
  /**
953
1350
  * Projected workflow fields the predicate reads as `guard.metadata.*` —
954
1351
  * the only bridge from the lake eval context (which cannot see `$fields`)
955
- * to workflow fields. Values are NOT GROQ: each is a deploy-time read in
956
- * the guard mini-language `"$self"`, `"$now"`, or
957
- * `"$fields.<name>[.path]"` — resolved into a bare value at deploy and
958
- * re-synced by the post-field-op guard refresh.
1352
+ * to workflow fields. Each value is a deploy-time read — a typed
1353
+ * {@link GuardRead} when authoring, the printed string spelling once
1354
+ * stored — resolved into a bare value at deploy and re-synced by the
1355
+ * post-field-op guard refresh.
959
1356
  */
960
- readonly metadata: v.OptionalSchema<
1357
+ metadata: v.OptionalSchema<
961
1358
  v.RecordSchema<
962
1359
  v.SchemaWithPipe<
963
1360
  readonly [
@@ -991,26 +1388,19 @@ declare type ManualTarget = v.InferOutput<typeof StoredManualTargetSchema>;
991
1388
  * { body, actor, at }` (the `actor`/`at` sub-fields match the `audit` op's
992
1389
  * stamp names, so it pairs with it). Never a stored kind.
993
1390
  */
994
- declare type NotesField = SlotFields<AuthoringEditable> & {
1391
+ declare type NotesField = FieldBase<AuthoringEditable> & {
995
1392
  type: "notes";
996
1393
  };
997
1394
 
998
1395
  declare type Op = v.InferOutput<typeof StoredOpSchema>;
999
1396
 
1000
- declare type OpPredicateInternal =
1001
- | {
1002
- type: "field";
1003
- field: string;
1004
- equals: ValueExpr;
1005
- }
1006
- | {
1007
- type: "all";
1008
- of: OpPredicateInternal[];
1009
- }
1010
- | {
1011
- type: "any";
1012
- of: OpPredicateInternal[];
1013
- };
1397
+ /**
1398
+ * Names an author's predicate may not use — engine-owned and author names
1399
+ * share one namespace, so a predicate redefining a binding would silently
1400
+ * shadow engine behaviour. Rejected at deploy; derived from
1401
+ * {@link CONDITION_VARS}.
1402
+ */
1403
+ export declare const RESERVED_CONDITION_VARS: readonly string[];
1014
1404
 
1015
1405
  declare type RoleAliases = v.InferOutput<typeof RoleAliasesSchema>;
1016
1406
 
@@ -1069,38 +1459,34 @@ declare const RoleAliasesSchema: v.RecordSchema<
1069
1459
  undefined
1070
1460
  >;
1071
1461
 
1072
- /** Type-mirror of {@link slotFields}, parameterised over the `editable` grammar. */
1073
- declare type SlotFields<TEditable> = {
1074
- name: string;
1075
- title?: string | undefined;
1076
- description?: string | undefined;
1077
- required?: boolean | undefined;
1078
- initialValue?: FieldSource | undefined;
1079
- editable?: TEditable | undefined;
1080
- };
1081
-
1082
- declare type Stage = StageFields<FieldEntry, Activity, Transition, Editable>;
1462
+ declare type Stage = StageFields<
1463
+ FieldEntry,
1464
+ Activity,
1465
+ Transition,
1466
+ Guard,
1467
+ Editable
1468
+ >;
1083
1469
 
1084
- /** Type-mirror of {@link stageFields}, parameterised over field/activity/transition/editable. */
1085
- declare type StageFields<TField, TActivity, TTransition, TEditable> = {
1470
+ /** Type-mirror of {@link stageFields}, parameterised over field/activity/transition/guard/editable. */
1471
+ declare type StageFields<TField, TActivity, TTransition, TGuard, TEditable> = {
1086
1472
  name: string;
1087
1473
  title?: string | undefined;
1088
1474
  description?: string | undefined;
1089
1475
  activities?: TActivity[] | undefined;
1090
1476
  transitions?: TTransition[] | undefined;
1091
- guards?: Guard[] | undefined;
1477
+ guards?: TGuard[] | undefined;
1092
1478
  fields?: TField[] | undefined;
1093
1479
  editable?: Record<string, TEditable> | undefined;
1094
1480
  };
1095
1481
 
1096
1482
  /**
1097
- * Declared editability of a field slot — the generic edit seam's gate. Default
1098
- * (absent) is NOT editable: a slot is op-only engine working memory unless the
1483
+ * Declared editability of a field — the generic edit seam's gate. Default
1484
+ * (absent) is NOT editable: a field is op-only engine working memory unless the
1099
1485
  * modeler opens it. The stored form is `true` (editable by anyone within the
1100
- * slot's scope window) or a GROQ predicate over the rendered scope (`$actor`,
1486
+ * field's scope window) or an EDIT CONDITION rendered-scope GROQ (`$actor`,
1101
1487
  * `$can`, `$fields`, `$assigned`), checked like an action filter to decide
1102
1488
  * who-may-edit. ADVISORY like every engine gate — it disables the inline field
1103
- * and explains; real immutability needs a lake {@link Guard}.
1489
+ * and explains; a {@link Guard} declares the intended write-lock.
1104
1490
  */
1105
1491
  declare const StoredEditableSchema: v.UnionSchema<
1106
1492
  [
@@ -1210,7 +1596,12 @@ declare const StoredFieldOpSchema: v.VariantSchema<
1210
1596
  },
1211
1597
  undefined
1212
1598
  >;
1213
- readonly where: v.GenericSchema<OpPredicateInternal>;
1599
+ readonly where: v.SchemaWithPipe<
1600
+ readonly [
1601
+ v.StringSchema<undefined>,
1602
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1603
+ ]
1604
+ >;
1214
1605
  readonly value: v.GenericSchema<ValueExprInternal>;
1215
1606
  },
1216
1607
  undefined
@@ -1233,7 +1624,12 @@ declare const StoredFieldOpSchema: v.VariantSchema<
1233
1624
  },
1234
1625
  undefined
1235
1626
  >;
1236
- readonly where: v.GenericSchema<OpPredicateInternal>;
1627
+ readonly where: v.SchemaWithPipe<
1628
+ readonly [
1629
+ v.StringSchema<undefined>,
1630
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1631
+ ]
1632
+ >;
1237
1633
  },
1238
1634
  undefined
1239
1635
  >,
@@ -1368,7 +1764,12 @@ declare const StoredOpSchema: v.VariantSchema<
1368
1764
  },
1369
1765
  undefined
1370
1766
  >;
1371
- readonly where: v.GenericSchema<OpPredicateInternal>;
1767
+ readonly where: v.SchemaWithPipe<
1768
+ readonly [
1769
+ v.StringSchema<undefined>,
1770
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1771
+ ]
1772
+ >;
1372
1773
  readonly value: v.GenericSchema<ValueExprInternal>;
1373
1774
  },
1374
1775
  undefined
@@ -1391,7 +1792,12 @@ declare const StoredOpSchema: v.VariantSchema<
1391
1792
  },
1392
1793
  undefined
1393
1794
  >;
1394
- readonly where: v.GenericSchema<OpPredicateInternal>;
1795
+ readonly where: v.SchemaWithPipe<
1796
+ readonly [
1797
+ v.StringSchema<undefined>,
1798
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1799
+ ]
1800
+ >;
1395
1801
  },
1396
1802
  undefined
1397
1803
  >,
@@ -1513,7 +1919,7 @@ declare type TerminalActivityStatus =
1513
1919
  * { label, status, assignee?, dueDate? }`; a plain checklist is this used with
1514
1920
  * `{label, status}` only (open ↔ done). Never a stored kind.
1515
1921
  */
1516
- declare type TodoListField = SlotFields<AuthoringEditable> & {
1922
+ declare type TodoListField = FieldBase<AuthoringEditable> & {
1517
1923
  type: "todoList";
1518
1924
  };
1519
1925
 
@@ -1534,8 +1940,6 @@ declare type TransitionFields<TOp> = {
1534
1940
 
1535
1941
  declare type TransitionOp = FieldOp;
1536
1942
 
1537
- declare type ValueExpr = ValueExprInternal;
1538
-
1539
1943
  declare type ValueExprInternal =
1540
1944
  | LiteralExpr
1541
1945
  | FieldReadExpr
@@ -1560,7 +1964,397 @@ declare type ValueExprInternal =
1560
1964
  fields: Record<string, ValueExprInternal>;
1561
1965
  };
1562
1966
 
1563
- declare const WORKFLOW_ROLES: readonly ["workflow", "child"];
1967
+ declare const WORKFLOW_LIFECYCLES: readonly ["standalone", "child"];
1968
+
1969
+ declare type WorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
1970
+
1971
+ declare const WorkflowConfigSchema: v.ObjectSchema<
1972
+ {
1973
+ readonly deployments: v.SchemaWithPipe<
1974
+ readonly [
1975
+ v.ArraySchema<
1976
+ v.ObjectSchema<
1977
+ {
1978
+ readonly name: v.SchemaWithPipe<
1979
+ readonly [
1980
+ v.StringSchema<undefined>,
1981
+ v.NonEmptyAction<string, "must not be empty">,
1982
+ ]
1983
+ >;
1984
+ readonly tag: v.SchemaWithPipe<
1985
+ readonly [
1986
+ v.StringSchema<undefined>,
1987
+ v.NonEmptyAction<string, undefined>,
1988
+ v.CheckAction<
1989
+ string,
1990
+ "invalid tag — lowercase letters, digits and dashes only, no leading dash, no dots"
1991
+ >,
1992
+ ]
1993
+ >;
1994
+ readonly workflowResource: v.VariantSchema<
1995
+ "type",
1996
+ [
1997
+ v.ObjectSchema<
1998
+ {
1999
+ readonly type: v.LiteralSchema<"dataset", undefined>;
2000
+ readonly id: v.SchemaWithPipe<
2001
+ readonly [
2002
+ v.SchemaWithPipe<
2003
+ readonly [
2004
+ v.StringSchema<undefined>,
2005
+ v.NonEmptyAction<string, "must not be empty">,
2006
+ ]
2007
+ >,
2008
+ v.CheckAction<
2009
+ string,
2010
+ 'invalid dataset resource id — expected "<projectId>.<dataset>"'
2011
+ >,
2012
+ ]
2013
+ >;
2014
+ },
2015
+ undefined
2016
+ >,
2017
+ v.ObjectSchema<
2018
+ {
2019
+ readonly type: v.LiteralSchema<"canvas", undefined>;
2020
+ readonly id: v.SchemaWithPipe<
2021
+ readonly [
2022
+ v.StringSchema<undefined>,
2023
+ v.NonEmptyAction<string, "must not be empty">,
2024
+ ]
2025
+ >;
2026
+ },
2027
+ undefined
2028
+ >,
2029
+ v.ObjectSchema<
2030
+ {
2031
+ readonly type: v.LiteralSchema<
2032
+ "media-library",
2033
+ undefined
2034
+ >;
2035
+ readonly id: v.SchemaWithPipe<
2036
+ readonly [
2037
+ v.StringSchema<undefined>,
2038
+ v.NonEmptyAction<string, "must not be empty">,
2039
+ ]
2040
+ >;
2041
+ },
2042
+ undefined
2043
+ >,
2044
+ v.ObjectSchema<
2045
+ {
2046
+ readonly type: v.LiteralSchema<"dashboard", undefined>;
2047
+ readonly id: v.SchemaWithPipe<
2048
+ readonly [
2049
+ v.StringSchema<undefined>,
2050
+ v.NonEmptyAction<string, "must not be empty">,
2051
+ ]
2052
+ >;
2053
+ },
2054
+ undefined
2055
+ >,
2056
+ ],
2057
+ undefined
2058
+ >;
2059
+ readonly resourceAliases: v.OptionalSchema<
2060
+ v.SchemaWithPipe<
2061
+ readonly [
2062
+ v.ArraySchema<
2063
+ v.ObjectSchema<
2064
+ {
2065
+ readonly name: v.SchemaWithPipe<
2066
+ readonly [
2067
+ v.SchemaWithPipe<
2068
+ readonly [
2069
+ v.StringSchema<undefined>,
2070
+ v.NonEmptyAction<string, "must not be empty">,
2071
+ ]
2072
+ >,
2073
+ v.CheckAction<
2074
+ string,
2075
+ "invalid resource handle name — lowercase letters, digits and dashes only, no leading dash"
2076
+ >,
2077
+ ]
2078
+ >;
2079
+ readonly resource: v.VariantSchema<
2080
+ "type",
2081
+ [
2082
+ v.ObjectSchema<
2083
+ {
2084
+ readonly type: v.LiteralSchema<
2085
+ "dataset",
2086
+ undefined
2087
+ >;
2088
+ readonly id: v.SchemaWithPipe<
2089
+ readonly [
2090
+ v.SchemaWithPipe<
2091
+ readonly [
2092
+ v.StringSchema<undefined>,
2093
+ v.NonEmptyAction<
2094
+ string,
2095
+ "must not be empty"
2096
+ >,
2097
+ ]
2098
+ >,
2099
+ v.CheckAction<
2100
+ string,
2101
+ 'invalid dataset resource id — expected "<projectId>.<dataset>"'
2102
+ >,
2103
+ ]
2104
+ >;
2105
+ },
2106
+ undefined
2107
+ >,
2108
+ v.ObjectSchema<
2109
+ {
2110
+ readonly type: v.LiteralSchema<
2111
+ "canvas",
2112
+ undefined
2113
+ >;
2114
+ readonly id: v.SchemaWithPipe<
2115
+ readonly [
2116
+ v.StringSchema<undefined>,
2117
+ v.NonEmptyAction<
2118
+ string,
2119
+ "must not be empty"
2120
+ >,
2121
+ ]
2122
+ >;
2123
+ },
2124
+ undefined
2125
+ >,
2126
+ v.ObjectSchema<
2127
+ {
2128
+ readonly type: v.LiteralSchema<
2129
+ "media-library",
2130
+ undefined
2131
+ >;
2132
+ readonly id: v.SchemaWithPipe<
2133
+ readonly [
2134
+ v.StringSchema<undefined>,
2135
+ v.NonEmptyAction<
2136
+ string,
2137
+ "must not be empty"
2138
+ >,
2139
+ ]
2140
+ >;
2141
+ },
2142
+ undefined
2143
+ >,
2144
+ v.ObjectSchema<
2145
+ {
2146
+ readonly type: v.LiteralSchema<
2147
+ "dashboard",
2148
+ undefined
2149
+ >;
2150
+ readonly id: v.SchemaWithPipe<
2151
+ readonly [
2152
+ v.StringSchema<undefined>,
2153
+ v.NonEmptyAction<
2154
+ string,
2155
+ "must not be empty"
2156
+ >,
2157
+ ]
2158
+ >;
2159
+ },
2160
+ undefined
2161
+ >,
2162
+ ],
2163
+ undefined
2164
+ >;
2165
+ },
2166
+ undefined
2167
+ >,
2168
+ undefined
2169
+ >,
2170
+ v.CheckAction<
2171
+ {
2172
+ name: string;
2173
+ resource:
2174
+ | {
2175
+ type: "dataset";
2176
+ id: string;
2177
+ }
2178
+ | {
2179
+ type: "canvas";
2180
+ id: string;
2181
+ }
2182
+ | {
2183
+ type: "media-library";
2184
+ id: string;
2185
+ }
2186
+ | {
2187
+ type: "dashboard";
2188
+ id: string;
2189
+ };
2190
+ }[],
2191
+ "duplicate resource handle name — each binding name must be unique within a deployment"
2192
+ >,
2193
+ ]
2194
+ >,
2195
+ undefined
2196
+ >;
2197
+ readonly definitions: v.SchemaWithPipe<
2198
+ readonly [
2199
+ v.ArraySchema<
2200
+ v.CustomSchema<
2201
+ {
2202
+ name: string;
2203
+ title: string;
2204
+ description?: string | undefined;
2205
+ lifecycle?: WorkflowLifecycle | undefined;
2206
+ initialStage: string;
2207
+ fields?: FieldEntry[] | undefined;
2208
+ stages: Stage[];
2209
+ predicates?: Record<string, string> | undefined;
2210
+ roleAliases?: RoleAliases | undefined;
2211
+ },
2212
+ v.ErrorMessage<v.CustomIssue> | undefined
2213
+ >,
2214
+ undefined
2215
+ >,
2216
+ v.MinLengthAction<
2217
+ {
2218
+ name: string;
2219
+ title: string;
2220
+ description?: string | undefined;
2221
+ lifecycle?: WorkflowLifecycle | undefined;
2222
+ initialStage: string;
2223
+ fields?: FieldEntry[] | undefined;
2224
+ stages: Stage[];
2225
+ predicates?: Record<string, string> | undefined;
2226
+ roleAliases?: RoleAliases | undefined;
2227
+ }[],
2228
+ 1,
2229
+ "a deployment needs at least one definition"
2230
+ >,
2231
+ ]
2232
+ >;
2233
+ },
2234
+ undefined
2235
+ >,
2236
+ undefined
2237
+ >,
2238
+ v.MinLengthAction<
2239
+ {
2240
+ name: string;
2241
+ tag: string;
2242
+ workflowResource:
2243
+ | {
2244
+ type: "dataset";
2245
+ id: string;
2246
+ }
2247
+ | {
2248
+ type: "canvas";
2249
+ id: string;
2250
+ }
2251
+ | {
2252
+ type: "media-library";
2253
+ id: string;
2254
+ }
2255
+ | {
2256
+ type: "dashboard";
2257
+ id: string;
2258
+ };
2259
+ resourceAliases?:
2260
+ | {
2261
+ name: string;
2262
+ resource:
2263
+ | {
2264
+ type: "dataset";
2265
+ id: string;
2266
+ }
2267
+ | {
2268
+ type: "canvas";
2269
+ id: string;
2270
+ }
2271
+ | {
2272
+ type: "media-library";
2273
+ id: string;
2274
+ }
2275
+ | {
2276
+ type: "dashboard";
2277
+ id: string;
2278
+ };
2279
+ }[]
2280
+ | undefined;
2281
+ definitions: {
2282
+ name: string;
2283
+ title: string;
2284
+ description?: string | undefined;
2285
+ lifecycle?: WorkflowLifecycle | undefined;
2286
+ initialStage: string;
2287
+ fields?: FieldEntry[] | undefined;
2288
+ stages: Stage[];
2289
+ predicates?: Record<string, string> | undefined;
2290
+ roleAliases?: RoleAliases | undefined;
2291
+ }[];
2292
+ }[],
2293
+ 1,
2294
+ "a config needs at least one deployment"
2295
+ >,
2296
+ v.CheckAction<
2297
+ {
2298
+ name: string;
2299
+ tag: string;
2300
+ workflowResource:
2301
+ | {
2302
+ type: "dataset";
2303
+ id: string;
2304
+ }
2305
+ | {
2306
+ type: "canvas";
2307
+ id: string;
2308
+ }
2309
+ | {
2310
+ type: "media-library";
2311
+ id: string;
2312
+ }
2313
+ | {
2314
+ type: "dashboard";
2315
+ id: string;
2316
+ };
2317
+ resourceAliases?:
2318
+ | {
2319
+ name: string;
2320
+ resource:
2321
+ | {
2322
+ type: "dataset";
2323
+ id: string;
2324
+ }
2325
+ | {
2326
+ type: "canvas";
2327
+ id: string;
2328
+ }
2329
+ | {
2330
+ type: "media-library";
2331
+ id: string;
2332
+ }
2333
+ | {
2334
+ type: "dashboard";
2335
+ id: string;
2336
+ };
2337
+ }[]
2338
+ | undefined;
2339
+ definitions: {
2340
+ name: string;
2341
+ title: string;
2342
+ description?: string | undefined;
2343
+ lifecycle?: WorkflowLifecycle | undefined;
2344
+ initialStage: string;
2345
+ fields?: FieldEntry[] | undefined;
2346
+ stages: Stage[];
2347
+ predicates?: Record<string, string> | undefined;
2348
+ roleAliases?: RoleAliases | undefined;
2349
+ }[];
2350
+ }[],
2351
+ "duplicate deployment tag — each deployment must use a unique tag"
2352
+ >,
2353
+ ]
2354
+ >;
2355
+ },
2356
+ undefined
2357
+ >;
1564
2358
 
1565
2359
  declare type WorkflowDefinition = v.InferOutput<
1566
2360
  typeof WorkflowDefinitionSchema
@@ -1588,7 +2382,7 @@ declare type WorkflowFields<TField, TStage> = {
1588
2382
  name: string;
1589
2383
  title: string;
1590
2384
  description?: string | undefined;
1591
- role?: WorkflowRole | undefined;
2385
+ lifecycle?: WorkflowLifecycle | undefined;
1592
2386
  initialStage: string;
1593
2387
  fields?: TField[] | undefined;
1594
2388
  stages: TStage[];
@@ -1596,7 +2390,9 @@ declare type WorkflowFields<TField, TStage> = {
1596
2390
  roleAliases?: RoleAliases | undefined;
1597
2391
  };
1598
2392
 
1599
- /** A definition's lifecycle role. `'child'` is spawn-only see {@link isStartableDefinition}. */
1600
- declare type WorkflowRole = (typeof WORKFLOW_ROLES)[number];
2393
+ /** How instances of a definition come to exist: started standalone (the
2394
+ * default) or spawned by a parent. `'child'` is spawn-only — see
2395
+ * {@link isStartableDefinition}. */
2396
+ declare type WorkflowLifecycle = (typeof WORKFLOW_LIFECYCLES)[number];
1601
2397
 
1602
2398
  export {};