@sanity/workflow-engine 0.15.0 → 0.17.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.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import * as v from "valibot";
2
2
 
3
- declare type Action = ActionFields<Op, string[]>;
3
+ declare type Action = ActionFields<Op, string[]> & {
4
+ roles?: string[] | undefined;
5
+ };
4
6
 
5
7
  /** Type-mirror of {@link actionFields}, parameterised over the op and
6
8
  * group-membership grammars. */
@@ -9,10 +11,12 @@ declare type ActionFields<TOp, TGroup> = {
9
11
  title?: string | undefined;
10
12
  description?: string | undefined;
11
13
  group?: TGroup | undefined;
14
+ when?: string | undefined;
12
15
  filter?: string | undefined;
13
16
  params?: ActionParam[] | undefined;
14
17
  ops?: TOp[] | undefined;
15
18
  effects?: Effect[] | undefined;
19
+ spawn?: Subworkflows | undefined;
16
20
  };
17
21
 
18
22
  declare type ActionParam = v.InferOutput<typeof ActionParamSchema>;
@@ -58,48 +62,29 @@ declare const ActionParamSchema: v.StrictObjectSchema<
58
62
  declare type Activity = ActivityFields<
59
63
  FieldEntry,
60
64
  Action,
61
- Op,
62
65
  ManualTarget,
63
66
  string[]
64
67
  >;
65
68
 
66
- declare const ACTIVITY_KINDS: readonly [
67
- "user",
68
- "service",
69
- "script",
70
- "manual",
71
- "receive",
72
- ];
73
-
74
- /** Type-mirror of {@link activityFields}, parameterised over field/action/op/target/group. */
75
- declare type ActivityFields<TField, TAction, TOp, TTarget, TGroup> = {
69
+ /** Type-mirror of {@link activityFields}, parameterised over field/action/target/group. */
70
+ declare type ActivityFields<TField, TAction, TTarget, TGroup> = {
76
71
  name: string;
77
72
  title?: string | undefined;
78
73
  description?: string | undefined;
79
74
  groups?: Group[] | undefined;
80
75
  group?: TGroup | undefined;
81
- kind?: ActivityKind | undefined;
82
76
  target?: TTarget | undefined;
83
- activation?: "auto" | "manual" | undefined;
84
77
  filter?: string | undefined;
85
78
  requirements?: Record<string, string> | undefined;
86
- completeWhen?: string | undefined;
87
- failWhen?: string | undefined;
88
- ops?: TOp[] | undefined;
89
- effects?: Effect[] | undefined;
90
79
  actions?: TAction[] | undefined;
91
- subworkflows?: Subworkflows | undefined;
92
80
  fields?: TField[] | undefined;
93
81
  };
94
82
 
95
- declare type ActivityKind = (typeof ACTIVITY_KINDS)[number];
96
-
97
83
  declare type AuthoringAction = AuthoringRawAction | ClaimAction;
98
84
 
99
85
  declare type AuthoringActivity = ActivityFields<
100
86
  AuthoringFieldEntry,
101
87
  AuthoringAction,
102
- AuthoringOp,
103
88
  AuthoringManualTarget,
104
89
  GroupMembership
105
90
  >;
@@ -165,6 +150,11 @@ declare type AuthoringGuard = v.InferOutput<typeof AuthoringGuardSchema>;
165
150
 
166
151
  declare const AuthoringGuardSchema: v.StrictObjectSchema<
167
152
  {
153
+ /**
154
+ * Lake-id-segment grammar (`^[a-z0-9][a-z0-9-]*$`, deploy-enforced): the
155
+ * guard's lake `_id` derives from `(instanceId, name)` at stage entry.
156
+ * Unique per definition.
157
+ */
168
158
  name: v.SchemaWithPipe<
169
159
  readonly [
170
160
  v.StringSchema<undefined>,
@@ -326,8 +316,9 @@ declare const AuthoringGuardSchema: v.StrictObjectSchema<
326
316
  /**
327
317
  * Lake GROQ predicate — a distinct eval context: delta-mode GROQ
328
318
  * reading the `before()`/`after()` natives, `mutation`, `guard`, and
329
- * `identity()`. Bare ids/fields only. Omitted or empty means
330
- * UNCONDITIONAL DENY.
319
+ * `identity()`. Bare ids/fields only. Polarity: a result of strictly
320
+ * `true` ALLOWS the matched mutation; anything else (false, null, an
321
+ * evaluation error) DENIES. Omitted or empty means UNCONDITIONAL DENY.
331
322
  */
332
323
  predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
333
324
  /**
@@ -659,7 +650,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
659
650
  undefined
660
651
  >;
661
652
  readonly status: v.PicklistSchema<
662
- readonly ["pending", "active", "done", "skipped", "failed"],
653
+ readonly ["active", "done", "skipped", "failed"],
663
654
  `Invalid option: expected one of ${string}`
664
655
  >;
665
656
  },
@@ -724,15 +715,21 @@ declare const AuthoringOpSchema: v.VariantSchema<
724
715
  * Authoring action — the stored fields plus two field sugars with one
725
716
  * defined expansion each:
726
717
  *
727
- * - `roles` a `count($actor.roles[@ in [...]]) > 0` membership condition
728
- * ANDed with the authored `filter`. The definition's `roleAliases`
729
- * ({@link RoleAliasesSchema}) widen that membership at desugar time.
718
+ * - `roles` on a fireAction-fired action (no `when`) it desugars to a
719
+ * `count($actor.roles[@ in [...]]) > 0` membership condition ANDed with
720
+ * the authored `filter` (for a caller, "not yours to fire" and "doesn't
721
+ * exist for you" are the same advisory answer). On a CASCADE-FIRED
722
+ * action it stores VERBATIM — the pin on which identities may execute
723
+ * the trigger; folding it into `filter` would make the action's
724
+ * existence depend on whose token happens to cascade. The definition's
725
+ * `roleAliases` ({@link RoleAliasesSchema}) widen the membership either
726
+ * way.
730
727
  * - `status` → a `status.set` op on the firing activity, appended **after**
731
728
  * the authored ops (deliberately never implied: a forgotten explicit
732
729
  * `status` is a visible stall, an implied default silently completes
733
730
  * claim-like actions). Status is the health axis: a decision action
734
731
  * (decline, send back) resolves `done` and writes the decision into a
735
- * field the transition filter reads — `failed` is for work that
732
+ * field the transition trigger reads — `failed` is for work that
736
733
  * genuinely could not complete.
737
734
  */
738
735
  declare type AuthoringRawAction = ActionFields<AuthoringOp, GroupMembership> & {
@@ -753,216 +750,24 @@ declare type AuthoringStage = StageFields<
753
750
  AuthoringEditable
754
751
  >;
755
752
 
756
- declare type AuthoringTransition = TransitionFields<AuthoringTransitionOp> & {
757
- filter?: string | undefined;
753
+ declare type AuthoringStartBlock = StartFields & {
754
+ kind?: StartKind | undefined;
758
755
  };
759
756
 
760
- declare type AuthoringTransitionOp = v.InferOutput<
761
- typeof AuthoringTransitionOpSchema
762
- >;
763
-
764
757
  /**
765
- * Authoring transitions may omit `filter`; desugar fills the safe,
766
- * overwhelmingly-common gate `"$allActivitiesDone"`. "Fire unconditionally"
767
- * stays spellable as an explicit `filter: "true"`.
758
+ * Authoring transitions may omit `when`; desugar fills the safe,
759
+ * overwhelmingly-common trigger `"$allActivitiesDone"`. "Fire unconditionally"
760
+ * stays spellable as an explicit `when: "true"`.
768
761
  */
769
- declare const AuthoringTransitionOpSchema: v.VariantSchema<
770
- "type",
771
- [
772
- v.StrictObjectSchema<
773
- {
774
- readonly type: v.LiteralSchema<"field.set", undefined>;
775
- readonly target: v.StrictObjectSchema<
776
- {
777
- readonly scope: v.OptionalSchema<
778
- v.PicklistSchema<
779
- readonly ["workflow", "stage", "activity"],
780
- `Invalid option: expected one of ${string}`
781
- >,
782
- undefined
783
- >;
784
- readonly field: v.SchemaWithPipe<
785
- readonly [
786
- v.StringSchema<undefined>,
787
- v.MinLengthAction<string, 1, "must be a non-empty string">,
788
- ]
789
- >;
790
- },
791
- undefined
792
- >;
793
- readonly value: v.GenericSchema<ValueExprInternal>;
794
- },
795
- undefined
796
- >,
797
- v.StrictObjectSchema<
798
- {
799
- readonly type: v.LiteralSchema<"field.unset", undefined>;
800
- readonly target: v.StrictObjectSchema<
801
- {
802
- readonly scope: v.OptionalSchema<
803
- v.PicklistSchema<
804
- readonly ["workflow", "stage", "activity"],
805
- `Invalid option: expected one of ${string}`
806
- >,
807
- undefined
808
- >;
809
- readonly field: v.SchemaWithPipe<
810
- readonly [
811
- v.StringSchema<undefined>,
812
- v.MinLengthAction<string, 1, "must be a non-empty string">,
813
- ]
814
- >;
815
- },
816
- undefined
817
- >;
818
- },
819
- undefined
820
- >,
821
- v.StrictObjectSchema<
822
- {
823
- readonly type: v.LiteralSchema<"field.append", undefined>;
824
- readonly target: v.StrictObjectSchema<
825
- {
826
- readonly scope: v.OptionalSchema<
827
- v.PicklistSchema<
828
- readonly ["workflow", "stage", "activity"],
829
- `Invalid option: expected one of ${string}`
830
- >,
831
- undefined
832
- >;
833
- readonly field: v.SchemaWithPipe<
834
- readonly [
835
- v.StringSchema<undefined>,
836
- v.MinLengthAction<string, 1, "must be a non-empty string">,
837
- ]
838
- >;
839
- },
840
- undefined
841
- >;
842
- readonly value: v.GenericSchema<ValueExprInternal>;
843
- },
844
- undefined
845
- >,
846
- v.StrictObjectSchema<
847
- {
848
- readonly type: v.LiteralSchema<"field.updateWhere", undefined>;
849
- readonly target: v.StrictObjectSchema<
850
- {
851
- readonly scope: v.OptionalSchema<
852
- v.PicklistSchema<
853
- readonly ["workflow", "stage", "activity"],
854
- `Invalid option: expected one of ${string}`
855
- >,
856
- undefined
857
- >;
858
- readonly field: v.SchemaWithPipe<
859
- readonly [
860
- v.StringSchema<undefined>,
861
- v.MinLengthAction<string, 1, "must be a non-empty string">,
862
- ]
863
- >;
864
- },
865
- undefined
866
- >;
867
- readonly where: v.SchemaWithPipe<
868
- readonly [
869
- v.StringSchema<undefined>,
870
- v.MinLengthAction<string, 1, "must be a non-empty string">,
871
- ]
872
- >;
873
- readonly value: v.GenericSchema<ValueExprInternal>;
874
- },
875
- undefined
876
- >,
877
- v.StrictObjectSchema<
878
- {
879
- readonly type: v.LiteralSchema<"field.removeWhere", undefined>;
880
- readonly target: v.StrictObjectSchema<
881
- {
882
- readonly scope: v.OptionalSchema<
883
- v.PicklistSchema<
884
- readonly ["workflow", "stage", "activity"],
885
- `Invalid option: expected one of ${string}`
886
- >,
887
- undefined
888
- >;
889
- readonly field: v.SchemaWithPipe<
890
- readonly [
891
- v.StringSchema<undefined>,
892
- v.MinLengthAction<string, 1, "must be a non-empty string">,
893
- ]
894
- >;
895
- },
896
- undefined
897
- >;
898
- readonly where: v.SchemaWithPipe<
899
- readonly [
900
- v.StringSchema<undefined>,
901
- v.MinLengthAction<string, 1, "must be a non-empty string">,
902
- ]
903
- >;
904
- },
905
- undefined
906
- >,
907
- v.StrictObjectSchema<
908
- {
909
- readonly type: v.LiteralSchema<"audit", undefined>;
910
- readonly target: v.StrictObjectSchema<
911
- {
912
- readonly scope: v.OptionalSchema<
913
- v.PicklistSchema<
914
- readonly ["workflow", "stage", "activity"],
915
- `Invalid option: expected one of ${string}`
916
- >,
917
- undefined
918
- >;
919
- readonly field: v.SchemaWithPipe<
920
- readonly [
921
- v.StringSchema<undefined>,
922
- v.MinLengthAction<string, 1, "must be a non-empty string">,
923
- ]
924
- >;
925
- },
926
- undefined
927
- >;
928
- readonly value: v.GenericSchema<ValueExprInternal>;
929
- readonly stampFields: v.OptionalSchema<
930
- v.StrictObjectSchema<
931
- {
932
- readonly actor: v.OptionalSchema<
933
- v.SchemaWithPipe<
934
- readonly [
935
- v.StringSchema<undefined>,
936
- v.MinLengthAction<string, 1, "must be a non-empty string">,
937
- ]
938
- >,
939
- undefined
940
- >;
941
- readonly at: v.OptionalSchema<
942
- v.SchemaWithPipe<
943
- readonly [
944
- v.StringSchema<undefined>,
945
- v.MinLengthAction<string, 1, "must be a non-empty string">,
946
- ]
947
- >,
948
- undefined
949
- >;
950
- },
951
- undefined
952
- >,
953
- undefined
954
- >;
955
- },
956
- undefined
957
- >,
958
- ],
959
- undefined
960
- >;
762
+ declare type AuthoringTransition = TransitionFields & {
763
+ when?: string | undefined;
764
+ };
961
765
 
962
766
  /** The authoring surface: stored primitives plus the define-time sugar. */
963
767
  declare type AuthoringWorkflow = WorkflowFields<
964
768
  AuthoringFieldEntry,
965
- AuthoringStage
769
+ AuthoringStage,
770
+ AuthoringStartBlock
966
771
  >;
967
772
 
968
773
  /**
@@ -1022,25 +827,33 @@ export declare interface ConditionVar {
1022
827
  * The condition-variable inventory — the single source of truth for every
1023
828
  * `$var` the engine binds when it evaluates a {@link Condition}.
1024
829
  *
1025
- * Three evaluation contexts read a definition's GROQ:
830
+ * Four evaluation contexts read a definition's GROQ:
1026
831
  *
1027
832
  * 1. **Rendered condition scope** — every condition site in a definition
1028
- * (transition filters, `completeWhen`/`failWhen`, action filters, effect
1029
- * bindings, `subworkflows` reads, where-op `where`s, editability
1030
- * predicates, author predicates). {@link CONDITION_VARS} is its inventory;
1031
- * each entry's `binding` says when the var actually holds a value. The
833
+ * (transition `when`s, activity filters, action `when`s/filters, effect
834
+ * bindings, `spawn` reads, where-op `where`s, editability predicates,
835
+ * author predicates). {@link CONDITION_VARS} is its inventory; each
836
+ * entry's `binding` says when the var actually holds a value. The
1032
837
  * where-op context is the one closed subset — its bound set is statically
1033
838
  * fixed and deploy-enforced (see the op-where scope's param-name list in
1034
839
  * the op applier).
1035
- * 2. **Filter evaluation without a caller** — the engine's cascade evaluates
1036
- * transition filters and the activity gates (`filter`, `completeWhen`,
1037
- * `failWhen`) with no caller, so only the `'always'`-bound subset carries
1038
- * values there ({@link FILTER_SCOPE_VARS}). Caller-bound vars fail closed —
1039
- * `$assigned` binds its caller-free constant `false`, the rest evaluate to
1040
- * `undefined` — and deploy rejects them at these sites: routing and gate
1041
- * resolution must resolve identically no matter whose token triggers the
1042
- * evaluation.
1043
- * 3. **Guard predicates** — NOT conditions. A lake mutation guard's
840
+ * 2. **Cascade gates** — transition `when`s, activity filters, and a
841
+ * cascade-fired action's `when`/`filter` must resolve identically no
842
+ * matter whose token drives the cascade, so only the `'always'`-bound
843
+ * subset carries values there ({@link FILTER_SCOPE_VARS}). Caller-bound
844
+ * vars fail closed — `$assigned` binds its caller-free constant `false`,
845
+ * the rest evaluate to `undefined` — and deploy rejects them at these
846
+ * sites; a cascade-fired action's per-token gate is `roles`, never its
847
+ * conditions.
848
+ * 3. **The start contexts** — a definition's `start.filter` and
849
+ * `start.allowed` evaluate against a CANDIDATE (no instance exists yet):
850
+ * `*[...]` reads the WORKFLOW resource's dataset and none of the rendered
851
+ * condition vars exist. The two split on what a surface can know:
852
+ * `filter` is browse-time-pure (candidate document as root,
853
+ * {@link START_FILTER_VARS} — no `$fields`, which cannot exist before
854
+ * inputs do), `allowed` is the start-time permission predicate
855
+ * ({@link START_ALLOWED_VARS} — `$fields` bound, never a root).
856
+ * 4. **Guard predicates** — NOT conditions. A lake mutation guard's
1044
857
  * `predicate` is groq-js **delta-mode** GROQ over a document mutation:
1045
858
  * `before()`/`after()`/`identity()` are dialect natives, and the wire
1046
859
  * format binds the identifiers in {@link GUARD_PREDICATE_VARS}. None of
@@ -1053,8 +866,8 @@ export declare interface ConditionVar {
1053
866
  * instance and its snapshot.
1054
867
  * - `'caller'` — rides the acting caller; without one the var is `undefined`
1055
868
  * (conditions referencing it fail closed). Author predicates may not read
1056
- * these — they pre-evaluate once per instance, caller-free.
1057
- * - `'spawn'` — bound only at `subworkflows` sites (the per-row `$row`).
869
+ * these — they pre-evaluate caller-free, per evaluation context.
870
+ * - `'spawn'` — bound only at spawn sites (the per-row `$row`).
1058
871
  */
1059
872
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
1060
873
 
@@ -1115,8 +928,9 @@ export declare function defineWorkflow(
1115
928
  /**
1116
929
  * Validate a deploy config — the binding of each definition's logical resource
1117
930
  * handles to physical resources, per environment (tag). Throws a formatted,
1118
- * path-prefixed error if the shape is invalid. The CLI hands the selected
1119
- * deployment's {@link resourceAliasesToMap} map to {@link deployDefinitions}.
931
+ * path-prefixed error if the shape is invalid. The CLI collapses the selected
932
+ * deployment's bindings via {@link resourceAliasesToMap} into the
933
+ * `resourceAliases` map `deployDefinitions` expands against.
1120
934
  */
1121
935
  export declare function defineWorkflowConfig(
1122
936
  config: WorkflowConfig,
@@ -1187,8 +1001,9 @@ declare const EffectSchema: v.StrictObjectSchema<
1187
1001
  * doesn't fit its shape — fails the completion (nothing is stored). Omitting
1188
1002
  * `outputs` is an EMPTY allowlist: the effect produces nothing, so any returned
1189
1003
  * output is rejected — the bound is universal, not opt-in.
1190
- * Why strict: `effectsContext` lives on the instance document, so the allowlist
1191
- * keeps it bounded — a handler can't accidentally spread a whole API response
1004
+ * Why strict: outputs land on the instance document's `effectHistory`, so
1005
+ * the allowlist keeps it bounded — a handler can't accidentally spread a
1006
+ * whole API response
1192
1007
  * into the instance — and the declared shapes let tooling (e.g. the simulator's
1193
1008
  * drain UI) suggest an effect's exact output keys. Declaring outputs also
1194
1009
  * powers the advisory deploy-time producer/consumer lint.
@@ -1254,8 +1069,6 @@ declare type FieldEntryFields<TEditable, TGroup> = FieldBase<
1254
1069
  of?: FieldShape[] | undefined;
1255
1070
  };
1256
1071
 
1257
- declare type FieldOp = v.InferOutput<typeof StoredFieldOpSchema>;
1258
-
1259
1072
  declare type FieldReadExpr = {
1260
1073
  type: "fieldRead";
1261
1074
  scope?: "workflow" | "stage" | undefined;
@@ -1289,9 +1102,8 @@ declare type FieldSourceInternal =
1289
1102
  declare type FieldValueKind = (typeof FIELD_VALUE_KINDS)[number];
1290
1103
 
1291
1104
  /**
1292
- * The subset that holds a value when the engine evaluates filters without a
1293
- * caller (the cascade path: transition filters, activity `filter`/
1294
- * `completeWhen`/`failWhen`).
1105
+ * The subset that holds a value in the cascade gates (transition `when`s,
1106
+ * activity filters, a cascade-fired action's `when`/`filter`).
1295
1107
  */
1296
1108
  export declare const FILTER_SCOPE_VARS: readonly string[];
1297
1109
 
@@ -1356,6 +1168,11 @@ export declare const GUARD_PREDICATE_VARS: readonly {
1356
1168
  /** Stored guards carry the printed string reads (the deploy resolver's input). */
1357
1169
  declare const GuardSchema: v.StrictObjectSchema<
1358
1170
  {
1171
+ /**
1172
+ * Lake-id-segment grammar (`^[a-z0-9][a-z0-9-]*$`, deploy-enforced): the
1173
+ * guard's lake `_id` derives from `(instanceId, name)` at stage entry.
1174
+ * Unique per definition.
1175
+ */
1359
1176
  name: v.SchemaWithPipe<
1360
1177
  readonly [
1361
1178
  v.StringSchema<undefined>,
@@ -1427,8 +1244,9 @@ declare const GuardSchema: v.StrictObjectSchema<
1427
1244
  /**
1428
1245
  * Lake GROQ predicate — a distinct eval context: delta-mode GROQ
1429
1246
  * reading the `before()`/`after()` natives, `mutation`, `guard`, and
1430
- * `identity()`. Bare ids/fields only. Omitted or empty means
1431
- * UNCONDITIONAL DENY.
1247
+ * `identity()`. Bare ids/fields only. Polarity: a result of strictly
1248
+ * `true` ALLOWS the matched mutation; anything else (false, null, an
1249
+ * evaluation error) DENIES. Omitted or empty means UNCONDITIONAL DENY.
1432
1250
  */
1433
1251
  predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1434
1252
  /**
@@ -1565,6 +1383,31 @@ declare type StageFields<TField, TActivity, TTransition, TGuard, TEditable> = {
1565
1383
  editable?: Record<string, TEditable> | undefined;
1566
1384
  };
1567
1385
 
1386
+ declare const START_KINDS: readonly ["interactive", "autonomous"];
1387
+
1388
+ declare type StartBlock = StartFields & {
1389
+ kind: StartKind;
1390
+ };
1391
+
1392
+ /** Type-mirror of {@link startFields}: how standalone runs of this workflow
1393
+ * begin. Stored requires `kind` (desugar fills the `'interactive'` default);
1394
+ * authoring may omit it — so each variant declares it. */
1395
+ declare type StartFields = {
1396
+ filter?: string | undefined;
1397
+ allowed?: string | undefined;
1398
+ };
1399
+
1400
+ /**
1401
+ * Who initiates a standalone run of this workflow: a person picking it from a
1402
+ * start surface (`'interactive'`, the default) or a system reacting to a
1403
+ * document event (`'autonomous'`). PURE CLASSIFICATION — consumers use it to
1404
+ * shape their surfaces (hide autonomous workflows from human pickers, list
1405
+ * interactive ones for editors); `startInstance` is one verb and one code
1406
+ * path for every kind, and an interactive start of an autonomous workflow is
1407
+ * legal.
1408
+ */
1409
+ declare type StartKind = (typeof START_KINDS)[number];
1410
+
1568
1411
  /**
1569
1412
  * Declared editability of a field — the generic edit seam's gate. Default
1570
1413
  * (absent) is NOT editable: a field is op-only engine working memory unless the
@@ -1587,142 +1430,6 @@ declare const StoredEditableSchema: v.UnionSchema<
1587
1430
  undefined
1588
1431
  >;
1589
1432
 
1590
- /**
1591
- * The `field.*` subset — every mutation op EXCEPT `status.set`. Shared by the
1592
- * boundaries that write fields but must not set an activity status: a transition
1593
- * (its stage's activities are tearing down, so `status.set` has no coherent
1594
- * target) and an effect's completion (an effect is OUTSIDE the activity's own
1595
- * awaiting — it reports its result through fields, never by flipping a status;
1596
- * the activity/stage gate then reads those fields). The full {@link StoredOpSchema}
1597
- * (these plus `status.set`) is what actions and activity boundaries carry.
1598
- */
1599
- declare const StoredFieldOpSchema: v.VariantSchema<
1600
- "type",
1601
- [
1602
- v.StrictObjectSchema<
1603
- {
1604
- readonly type: v.LiteralSchema<"field.set", undefined>;
1605
- readonly target: v.StrictObjectSchema<
1606
- {
1607
- readonly scope: v.PicklistSchema<
1608
- readonly ["workflow", "stage", "activity"],
1609
- `Invalid option: expected one of ${string}`
1610
- >;
1611
- readonly field: v.SchemaWithPipe<
1612
- readonly [
1613
- v.StringSchema<undefined>,
1614
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1615
- ]
1616
- >;
1617
- },
1618
- undefined
1619
- >;
1620
- readonly value: v.GenericSchema<ValueExprInternal>;
1621
- },
1622
- undefined
1623
- >,
1624
- v.StrictObjectSchema<
1625
- {
1626
- readonly type: v.LiteralSchema<"field.unset", undefined>;
1627
- readonly target: v.StrictObjectSchema<
1628
- {
1629
- readonly scope: v.PicklistSchema<
1630
- readonly ["workflow", "stage", "activity"],
1631
- `Invalid option: expected one of ${string}`
1632
- >;
1633
- readonly field: v.SchemaWithPipe<
1634
- readonly [
1635
- v.StringSchema<undefined>,
1636
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1637
- ]
1638
- >;
1639
- },
1640
- undefined
1641
- >;
1642
- },
1643
- undefined
1644
- >,
1645
- v.StrictObjectSchema<
1646
- {
1647
- readonly type: v.LiteralSchema<"field.append", undefined>;
1648
- readonly target: v.StrictObjectSchema<
1649
- {
1650
- readonly scope: v.PicklistSchema<
1651
- readonly ["workflow", "stage", "activity"],
1652
- `Invalid option: expected one of ${string}`
1653
- >;
1654
- readonly field: v.SchemaWithPipe<
1655
- readonly [
1656
- v.StringSchema<undefined>,
1657
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1658
- ]
1659
- >;
1660
- },
1661
- undefined
1662
- >;
1663
- readonly value: v.GenericSchema<ValueExprInternal>;
1664
- },
1665
- undefined
1666
- >,
1667
- v.StrictObjectSchema<
1668
- {
1669
- readonly type: v.LiteralSchema<"field.updateWhere", undefined>;
1670
- readonly target: v.StrictObjectSchema<
1671
- {
1672
- readonly scope: v.PicklistSchema<
1673
- readonly ["workflow", "stage", "activity"],
1674
- `Invalid option: expected one of ${string}`
1675
- >;
1676
- readonly field: v.SchemaWithPipe<
1677
- readonly [
1678
- v.StringSchema<undefined>,
1679
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1680
- ]
1681
- >;
1682
- },
1683
- undefined
1684
- >;
1685
- readonly where: v.SchemaWithPipe<
1686
- readonly [
1687
- v.StringSchema<undefined>,
1688
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1689
- ]
1690
- >;
1691
- readonly value: v.GenericSchema<ValueExprInternal>;
1692
- },
1693
- undefined
1694
- >,
1695
- v.StrictObjectSchema<
1696
- {
1697
- readonly type: v.LiteralSchema<"field.removeWhere", undefined>;
1698
- readonly target: v.StrictObjectSchema<
1699
- {
1700
- readonly scope: v.PicklistSchema<
1701
- readonly ["workflow", "stage", "activity"],
1702
- `Invalid option: expected one of ${string}`
1703
- >;
1704
- readonly field: v.SchemaWithPipe<
1705
- readonly [
1706
- v.StringSchema<undefined>,
1707
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1708
- ]
1709
- >;
1710
- },
1711
- undefined
1712
- >;
1713
- readonly where: v.SchemaWithPipe<
1714
- readonly [
1715
- v.StringSchema<undefined>,
1716
- v.MinLengthAction<string, 1, "must be a non-empty string">,
1717
- ]
1718
- >;
1719
- },
1720
- undefined
1721
- >,
1722
- ],
1723
- undefined
1724
- >;
1725
-
1726
1433
  declare const StoredManualTargetSchema: v.VariantSchema<
1727
1434
  "type",
1728
1435
  [
@@ -1897,7 +1604,7 @@ declare const StoredOpSchema: v.VariantSchema<
1897
1604
  ]
1898
1605
  >;
1899
1606
  readonly status: v.PicklistSchema<
1900
- readonly ["pending", "active", "done", "skipped", "failed"],
1607
+ readonly ["active", "done", "skipped", "failed"],
1901
1608
  `Invalid option: expected one of ${string}`
1902
1609
  >;
1903
1610
  },
@@ -1973,8 +1680,8 @@ declare const SubworkflowsSchema: v.StrictObjectSchema<
1973
1680
  >;
1974
1681
  /**
1975
1682
  * Extra values evaluated in the parent's rendered scope at spawn time and
1976
- * delivered into each subworkflow's `$effects` bag — the parent→child
1977
- * handoff, read exactly like an effect output.
1683
+ * delivered into each subworkflow's `$context` bag — the parent→child
1684
+ * handoff.
1978
1685
  */
1979
1686
  readonly context: v.OptionalSchema<
1980
1687
  v.RecordSchema<
@@ -1996,13 +1703,13 @@ declare const SubworkflowsSchema: v.StrictObjectSchema<
1996
1703
  >;
1997
1704
  /**
1998
1705
  * What happens to still-live children when their cohort's scope stops
1999
- * applying — the spawning stage exits, or a re-entry's `forEach` no longer
1706
+ * applying — the spawning stage exits, or a re-fire's `forEach` no longer
2000
1707
  * discovers their row. `'detach'` (the default) lets them run to
2001
1708
  * completion outside the gate; `'abort'` kills them (recursively). The
2002
1709
  * engine never destroys in-flight work implicitly — `'abort'` is always
2003
1710
  * an authored choice. Note this governs only the CHILDREN's fate; whether
2004
- * the parent may move at all is what gates (`completeWhen`, transition
2005
- * filters over `$subworkflows`) decide.
1711
+ * the parent may move at all is what gates (conditions over
1712
+ * `$subworkflows`) decide.
2006
1713
  */
2007
1714
  readonly onExit: v.OptionalSchema<
2008
1715
  v.PicklistSchema<
@@ -2033,23 +1740,19 @@ declare type TodoListField = FieldBase<AuthoringEditable, GroupMembership> & {
2033
1740
  type: "todoList";
2034
1741
  };
2035
1742
 
2036
- declare type Transition = TransitionFields<TransitionOp> & {
2037
- filter: string;
1743
+ declare type Transition = TransitionFields & {
1744
+ when: string;
2038
1745
  };
2039
1746
 
2040
- /** Type-mirror of {@link transitionFields} minus `filter` — stored requires it,
1747
+ /** Type-mirror of {@link transitionFields} minus `when` — stored requires it,
2041
1748
  * authoring omits it (desugar fills the default), so each variant declares it. */
2042
- declare type TransitionFields<TOp> = {
1749
+ declare type TransitionFields = {
2043
1750
  name: string;
2044
1751
  title?: string | undefined;
2045
1752
  description?: string | undefined;
2046
1753
  to: string;
2047
- ops?: TOp[] | undefined;
2048
- effects?: Effect[] | undefined;
2049
1754
  };
2050
1755
 
2051
- declare type TransitionOp = FieldOp;
2052
-
2053
1756
  declare type ValueExprInternal =
2054
1757
  | LiteralExpr
2055
1758
  | FieldReadExpr
@@ -2314,7 +2017,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2314
2017
  description?: string | undefined;
2315
2018
  groups?: Group[] | undefined;
2316
2019
  lifecycle?: WorkflowLifecycle | undefined;
2317
- applicableWhen?: string | undefined;
2020
+ start?: StartBlock | undefined;
2318
2021
  initialStage: string;
2319
2022
  fields?: FieldEntry[] | undefined;
2320
2023
  stages: Stage[];
@@ -2332,7 +2035,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2332
2035
  description?: string | undefined;
2333
2036
  groups?: Group[] | undefined;
2334
2037
  lifecycle?: WorkflowLifecycle | undefined;
2335
- applicableWhen?: string | undefined;
2038
+ start?: StartBlock | undefined;
2336
2039
  initialStage: string;
2337
2040
  fields?: FieldEntry[] | undefined;
2338
2041
  stages: Stage[];
@@ -2398,7 +2101,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2398
2101
  description?: string | undefined;
2399
2102
  groups?: Group[] | undefined;
2400
2103
  lifecycle?: WorkflowLifecycle | undefined;
2401
- applicableWhen?: string | undefined;
2104
+ start?: StartBlock | undefined;
2402
2105
  initialStage: string;
2403
2106
  fields?: FieldEntry[] | undefined;
2404
2107
  stages: Stage[];
@@ -2458,7 +2161,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2458
2161
  description?: string | undefined;
2459
2162
  groups?: Group[] | undefined;
2460
2163
  lifecycle?: WorkflowLifecycle | undefined;
2461
- applicableWhen?: string | undefined;
2164
+ start?: StartBlock | undefined;
2462
2165
  initialStage: string;
2463
2166
  fields?: FieldEntry[] | undefined;
2464
2167
  stages: Stage[];
@@ -2507,17 +2210,23 @@ declare type WorkflowDefinition = v.InferOutput<
2507
2210
  * mints the next version.
2508
2211
  */
2509
2212
  declare const WorkflowDefinitionSchema: v.GenericSchema<
2510
- WorkflowFields<FieldEntry, Stage>
2213
+ WorkflowFields<FieldEntry, Stage, StartBlock>
2511
2214
  >;
2512
2215
 
2513
- /** Type-mirror of {@link workflowFields}, parameterised over field/stage. */
2514
- declare type WorkflowFields<TField, TStage> = {
2216
+ /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
2217
+ declare type WorkflowFields<TField, TStage, TStart> = {
2218
+ /**
2219
+ * Lake-id-segment grammar (`^[a-z0-9][a-z0-9-]*$`, deploy-enforced): the
2220
+ * name interpolates into every deployed document id
2221
+ * (`<tag>.<name>.v<version>`). Stable identity — instances pin to it,
2222
+ * subworkflows resolve by it.
2223
+ */
2515
2224
  name: string;
2516
2225
  title: string;
2517
2226
  description?: string | undefined;
2518
2227
  groups?: Group[] | undefined;
2519
2228
  lifecycle?: WorkflowLifecycle | undefined;
2520
- applicableWhen?: string | undefined;
2229
+ start?: TStart | undefined;
2521
2230
  initialStage: string;
2522
2231
  fields?: TField[] | undefined;
2523
2232
  stages: TStage[];