@sanity/workflow-engine 0.27.0 → 0.29.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
@@ -4,11 +4,6 @@ declare type Action = ActionFields<Op, string[]> & {
4
4
  roles?: string[] | undefined;
5
5
  };
6
6
 
7
- declare const ACTION_SEMANTICS: readonly [
8
- "decision.accept",
9
- "decision.decline",
10
- ];
11
-
12
7
  /** Type-mirror of {@link actionFields}, parameterised over the op and
13
8
  * group-membership grammars. */
14
9
  declare type ActionFields<TOp, TGroup> = {
@@ -160,7 +155,7 @@ declare const ActionParamSchema: v.SchemaWithPipe<
160
155
  ]
161
156
  >;
162
157
 
163
- declare type ActionSemantic = (typeof ACTION_SEMANTICS)[number];
158
+ declare type ActionSemantic = DecisionSemantic | Semantic;
164
159
 
165
160
  declare type Activity = ActivityFields<
166
161
  FieldEntry,
@@ -172,6 +167,7 @@ declare type Activity = ActivityFields<
172
167
  /** Type-mirror of {@link activityFields}, parameterised over field/action/target/group. */
173
168
  declare type ActivityFields<TField, TAction, TTarget, TGroup> = {
174
169
  name: string;
170
+ semantics?: Semantic[] | undefined;
175
171
  title?: string | undefined;
176
172
  description?: string | undefined;
177
173
  groups?: Group[] | undefined;
@@ -627,6 +623,31 @@ declare const AuthoringOpSchema: v.VariantSchema<
627
623
  },
628
624
  undefined
629
625
  >,
626
+ v.StrictObjectSchema<
627
+ {
628
+ readonly type: v.LiteralSchema<"field.setIfMissing", undefined>;
629
+ readonly target: v.StrictObjectSchema<
630
+ {
631
+ readonly scope: v.OptionalSchema<
632
+ v.PicklistSchema<
633
+ readonly ["workflow", "stage", "activity"],
634
+ string
635
+ >,
636
+ undefined
637
+ >;
638
+ readonly field: v.SchemaWithPipe<
639
+ readonly [
640
+ v.StringSchema<undefined>,
641
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
642
+ ]
643
+ >;
644
+ },
645
+ undefined
646
+ >;
647
+ readonly value: v.GenericSchema<ValueExprInternal>;
648
+ },
649
+ undefined
650
+ >,
630
651
  v.StrictObjectSchema<
631
652
  {
632
653
  readonly type: v.LiteralSchema<"field.unset", undefined>;
@@ -676,6 +697,62 @@ declare const AuthoringOpSchema: v.VariantSchema<
676
697
  },
677
698
  undefined
678
699
  >,
700
+ v.StrictObjectSchema<
701
+ {
702
+ readonly type: v.LiteralSchema<"field.inc", undefined>;
703
+ readonly target: v.StrictObjectSchema<
704
+ {
705
+ readonly scope: v.OptionalSchema<
706
+ v.PicklistSchema<
707
+ readonly ["workflow", "stage", "activity"],
708
+ string
709
+ >,
710
+ undefined
711
+ >;
712
+ readonly field: v.SchemaWithPipe<
713
+ readonly [
714
+ v.StringSchema<undefined>,
715
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
716
+ ]
717
+ >;
718
+ },
719
+ undefined
720
+ >;
721
+ readonly value: v.OptionalSchema<
722
+ v.GenericSchema<ValueExprInternal>,
723
+ undefined
724
+ >;
725
+ },
726
+ undefined
727
+ >,
728
+ v.StrictObjectSchema<
729
+ {
730
+ readonly type: v.LiteralSchema<"field.dec", undefined>;
731
+ readonly target: v.StrictObjectSchema<
732
+ {
733
+ readonly scope: v.OptionalSchema<
734
+ v.PicklistSchema<
735
+ readonly ["workflow", "stage", "activity"],
736
+ string
737
+ >,
738
+ undefined
739
+ >;
740
+ readonly field: v.SchemaWithPipe<
741
+ readonly [
742
+ v.StringSchema<undefined>,
743
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
744
+ ]
745
+ >;
746
+ },
747
+ undefined
748
+ >;
749
+ readonly value: v.OptionalSchema<
750
+ v.GenericSchema<ValueExprInternal>,
751
+ undefined
752
+ >;
753
+ },
754
+ undefined
755
+ >,
679
756
  v.StrictObjectSchema<
680
757
  {
681
758
  readonly type: v.LiteralSchema<"field.updateWhere", undefined>;
@@ -983,6 +1060,25 @@ export declare interface ConditionVar {
983
1060
  */
984
1061
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
985
1062
 
1063
+ /** A define-time validated `custom.<camelCaseMeaning>` value. */
1064
+ declare type CustomSemantic = `custom.${string}`;
1065
+
1066
+ /**
1067
+ * The maximum reader floor this writer can emit. Individual documents derive
1068
+ * their `minReaderModel` from the compatibility-bearing features actually
1069
+ * present; a document written at {@link DATA_MODEL_VERSION} may therefore
1070
+ * carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
1071
+ * decision that requires readers-first fleet sequencing.
1072
+ */
1073
+ declare const DATA_MODEL_MIN_READER = 4;
1074
+
1075
+ declare const DECISION_SEMANTICS: readonly [
1076
+ "decision.accept",
1077
+ "decision.decline",
1078
+ ];
1079
+
1080
+ declare type DecisionSemantic = (typeof DECISION_SEMANTICS)[number];
1081
+
986
1082
  export declare function defineAction(action: AuthoringAction): AuthoringAction;
987
1083
 
988
1084
  export declare function defineActivity(
@@ -1043,9 +1139,18 @@ export declare function defineWorkflow(
1043
1139
  * path-prefixed error if the shape is invalid. The CLI collapses the selected
1044
1140
  * deployment's bindings via {@link resourceAliasesToMap} into the
1045
1141
  * `resourceAliases` map `deployDefinitions` expands against.
1142
+ *
1143
+ * Validates shape only — NOT the reader-floor acknowledgement. That is a
1144
+ * selected-deployment gate (`deployDefinitions`, the CLI's
1145
+ * `deploymentToTarget` / `buildBatches` / `resolveContext`, and blueprint
1146
+ * provision each assert the deployment they target), so a command that never
1147
+ * selects a deployment loads a config with a stale or missing floor on an
1148
+ * untargeted entry without failing. Authors must still acknowledge the floor
1149
+ * at compile time — each {@link WorkflowDeploymentInput} requires it; the
1150
+ * returned {@link WorkflowConfig} is the looser parsed shape.
1046
1151
  */
1047
1152
  export declare function defineWorkflowConfig(
1048
- config: WorkflowConfig,
1153
+ config: WorkflowConfigInput,
1049
1154
  ): WorkflowConfig;
1050
1155
 
1051
1156
  declare type Editable = v.InferOutput<typeof StoredEditableSchema>;
@@ -1422,11 +1527,6 @@ declare type NotesField = FieldBase<AuthoringEditable, GroupMembership> & {
1422
1527
 
1423
1528
  declare type Op = v.InferOutput<typeof StoredOpSchema>;
1424
1529
 
1425
- declare type ParsedWorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
1426
-
1427
- declare type ParsedWorkflowDeployment =
1428
- ParsedWorkflowConfig["deployments"][number];
1429
-
1430
1530
  declare type RequirementBase = {
1431
1531
  name: string;
1432
1532
  title?: string | undefined;
@@ -1505,6 +1605,16 @@ declare interface ScalarValidation {
1505
1605
  max?: number | undefined;
1506
1606
  }
1507
1607
 
1608
+ declare type Semantic = SignalSemantic | CustomSemantic;
1609
+
1610
+ declare const SIGNAL_SEMANTICS: readonly [
1611
+ "signal.positive",
1612
+ "signal.caution",
1613
+ "signal.critical",
1614
+ ];
1615
+
1616
+ declare type SignalSemantic = (typeof SIGNAL_SEMANTICS)[number];
1617
+
1508
1618
  declare type SingleSubjectRequirement = RequirementBase & {
1509
1619
  type: "singleSubject";
1510
1620
  };
@@ -1520,6 +1630,7 @@ declare type Stage = StageFields<
1520
1630
  /** Type-mirror of {@link stageFields}, parameterised over field/activity/transition/guard/editable. */
1521
1631
  declare type StageFields<TField, TActivity, TTransition, TGuard, TEditable> = {
1522
1632
  name: string;
1633
+ semantics?: Semantic[] | undefined;
1523
1634
  title?: string | undefined;
1524
1635
  description?: string | undefined;
1525
1636
  groups?: Group[] | undefined;
@@ -1562,9 +1673,9 @@ declare type StartRequirement = GroqRequirement | SingleSubjectRequirement;
1562
1673
  * (absent) is NOT editable: a field is op-only engine working memory unless the
1563
1674
  * modeler opens it. The stored form is `true` (editable by anyone within the
1564
1675
  * field's scope window) or an EDIT CONDITION — rendered-scope GROQ (`$actor`,
1565
- * `$can`, `$fields`, `$assigned`), checked like an action filter to decide
1566
- * who-may-edit. ADVISORY like every engine gate — it disables the inline field
1567
- * and explains; a {@link Guard} declares the intended write-lock.
1676
+ * `$can`, `$attributes`, `$fields`, `$assigned`), checked like an action filter
1677
+ * to decide who-may-edit. ADVISORY like every engine gate — it disables the
1678
+ * inline field and explains; a {@link Guard} declares the intended write-lock.
1568
1679
  */
1569
1680
  declare const StoredEditableSchema: v.UnionSchema<
1570
1681
  [
@@ -1645,6 +1756,28 @@ declare const StoredOpSchema: v.VariantSchema<
1645
1756
  },
1646
1757
  undefined
1647
1758
  >,
1759
+ v.StrictObjectSchema<
1760
+ {
1761
+ readonly type: v.LiteralSchema<"field.setIfMissing", undefined>;
1762
+ readonly target: v.StrictObjectSchema<
1763
+ {
1764
+ readonly scope: v.PicklistSchema<
1765
+ readonly ["workflow", "stage", "activity"],
1766
+ string
1767
+ >;
1768
+ readonly field: v.SchemaWithPipe<
1769
+ readonly [
1770
+ v.StringSchema<undefined>,
1771
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1772
+ ]
1773
+ >;
1774
+ },
1775
+ undefined
1776
+ >;
1777
+ readonly value: v.GenericSchema<ValueExprInternal>;
1778
+ },
1779
+ undefined
1780
+ >,
1648
1781
  v.StrictObjectSchema<
1649
1782
  {
1650
1783
  readonly type: v.LiteralSchema<"field.unset", undefined>;
@@ -1688,6 +1821,56 @@ declare const StoredOpSchema: v.VariantSchema<
1688
1821
  },
1689
1822
  undefined
1690
1823
  >,
1824
+ v.StrictObjectSchema<
1825
+ {
1826
+ readonly type: v.LiteralSchema<"field.inc", undefined>;
1827
+ readonly target: v.StrictObjectSchema<
1828
+ {
1829
+ readonly scope: v.PicklistSchema<
1830
+ readonly ["workflow", "stage", "activity"],
1831
+ string
1832
+ >;
1833
+ readonly field: v.SchemaWithPipe<
1834
+ readonly [
1835
+ v.StringSchema<undefined>,
1836
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1837
+ ]
1838
+ >;
1839
+ },
1840
+ undefined
1841
+ >;
1842
+ readonly value: v.OptionalSchema<
1843
+ v.GenericSchema<ValueExprInternal>,
1844
+ undefined
1845
+ >;
1846
+ },
1847
+ undefined
1848
+ >,
1849
+ v.StrictObjectSchema<
1850
+ {
1851
+ readonly type: v.LiteralSchema<"field.dec", undefined>;
1852
+ readonly target: v.StrictObjectSchema<
1853
+ {
1854
+ readonly scope: v.PicklistSchema<
1855
+ readonly ["workflow", "stage", "activity"],
1856
+ string
1857
+ >;
1858
+ readonly field: v.SchemaWithPipe<
1859
+ readonly [
1860
+ v.StringSchema<undefined>,
1861
+ v.MinLengthAction<string, 1, "must be a non-empty string">,
1862
+ ]
1863
+ >;
1864
+ },
1865
+ undefined
1866
+ >;
1867
+ readonly value: v.OptionalSchema<
1868
+ v.GenericSchema<ValueExprInternal>,
1869
+ undefined
1870
+ >;
1871
+ },
1872
+ undefined
1873
+ >,
1691
1874
  v.StrictObjectSchema<
1692
1875
  {
1693
1876
  readonly type: v.LiteralSchema<"field.updateWhere", undefined>;
@@ -1929,8 +2112,15 @@ declare type ValueExprInternal =
1929
2112
 
1930
2113
  declare const WORKFLOW_LIFECYCLES: readonly ["standalone", "child"];
1931
2114
 
1932
- declare type WorkflowConfig = Omit<ParsedWorkflowConfig, "deployments"> & {
1933
- deployments: WorkflowDeployment[];
2115
+ declare type WorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
2116
+
2117
+ /**
2118
+ * What an author writes for a whole config: every deployment is a
2119
+ * {@link WorkflowDeploymentInput}. `defineWorkflowConfig` accepts this and
2120
+ * returns the looser {@link WorkflowConfig}.
2121
+ */
2122
+ declare type WorkflowConfigInput = Omit<WorkflowConfig, "deployments"> & {
2123
+ deployments: WorkflowDeploymentInput[];
1934
2124
  };
1935
2125
 
1936
2126
  declare const WorkflowConfigSchema: v.ObjectSchema<
@@ -2196,6 +2386,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2196
2386
  v.CustomSchema<
2197
2387
  {
2198
2388
  name: string;
2389
+ semantics?: Semantic[] | undefined;
2199
2390
  title: string;
2200
2391
  description?: string | undefined;
2201
2392
  groups?: Group[] | undefined;
@@ -2214,6 +2405,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2214
2405
  v.MinLengthAction<
2215
2406
  {
2216
2407
  name: string;
2408
+ semantics?: Semantic[] | undefined;
2217
2409
  title: string;
2218
2410
  description?: string | undefined;
2219
2411
  groups?: Group[] | undefined;
@@ -2281,6 +2473,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2281
2473
  | undefined;
2282
2474
  definitions: {
2283
2475
  name: string;
2476
+ semantics?: Semantic[] | undefined;
2284
2477
  title: string;
2285
2478
  description?: string | undefined;
2286
2479
  groups?: Group[] | undefined;
@@ -2342,6 +2535,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2342
2535
  | undefined;
2343
2536
  definitions: {
2344
2537
  name: string;
2538
+ semantics?: Semantic[] | undefined;
2345
2539
  title: string;
2346
2540
  description?: string | undefined;
2347
2541
  groups?: Group[] | undefined;
@@ -2401,6 +2595,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2401
2595
  | undefined;
2402
2596
  definitions: {
2403
2597
  name: string;
2598
+ semantics?: Semantic[] | undefined;
2404
2599
  title: string;
2405
2600
  description?: string | undefined;
2406
2601
  groups?: Group[] | undefined;
@@ -2462,6 +2657,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2462
2657
  | undefined;
2463
2658
  definitions: {
2464
2659
  name: string;
2660
+ semantics?: Semantic[] | undefined;
2465
2661
  title: string;
2466
2662
  description?: string | undefined;
2467
2663
  groups?: Group[] | undefined;
@@ -2521,6 +2717,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2521
2717
  | undefined;
2522
2718
  definitions: {
2523
2719
  name: string;
2720
+ semantics?: Semantic[] | undefined;
2524
2721
  title: string;
2525
2722
  description?: string | undefined;
2526
2723
  groups?: Group[] | undefined;
@@ -2578,15 +2775,25 @@ declare const WorkflowDefinitionSchema: v.GenericSchema<
2578
2775
  WorkflowFields<FieldEntry, Stage, StartBlock>
2579
2776
  >;
2580
2777
 
2581
- declare type WorkflowDeployment = Omit<
2582
- ParsedWorkflowDeployment,
2778
+ /** One deployment as loaded from a config: the floor is optional/unverified so
2779
+ * a command that never selects a deployment can hold a stale or missing
2780
+ * acknowledgement. Deployment-scoped paths assert before they act; authors
2781
+ * write {@link WorkflowDeploymentInput}. */
2782
+ declare type WorkflowDeployment = WorkflowConfig["deployments"][number];
2783
+
2784
+ /**
2785
+ * What an author writes for one deployment: the current reader floor as the
2786
+ * reviewed literal. Compile-time only — omitting it or setting a wrong value
2787
+ * is a type error in the editor. Runtime parse still tolerates a stale or
2788
+ * missing floor on {@link WorkflowDeployment} so commands that never select a
2789
+ * deployment still run; deployment-scoped paths assert the selected
2790
+ * deployment (instance-id commands do not).
2791
+ */
2792
+ declare type WorkflowDeploymentInput = Omit<
2793
+ WorkflowDeployment,
2583
2794
  "expectedMinReaderModel"
2584
2795
  > & {
2585
- /**
2586
- * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
2587
- * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
2588
- */
2589
- expectedMinReaderModel: number;
2796
+ expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2590
2797
  };
2591
2798
 
2592
2799
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
@@ -2598,6 +2805,7 @@ declare type WorkflowFields<TField, TStage, TStart> = {
2598
2805
  * subworkflows resolve by it.
2599
2806
  */
2600
2807
  name: string;
2808
+ semantics?: Semantic[] | undefined;
2601
2809
  title: string;
2602
2810
  description?: string | undefined;
2603
2811
  groups?: Group[] | undefined;
package/dist/define.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parseOrThrow, desugarWorkflow, checkWorkflowInvariants, formatValidationError, WorkflowConfigSchema, assertReaderModelAcknowledgement, AuthoringWorkflowSchema, labelFor, AuthoringStageSchema, AuthoringActivitySchema, AuthoringActionSchema, AuthoringTransitionSchema, AuthoringFieldEntrySchema, AuthoringOpSchema, GroupSchema, AuthoringGuardSchema, EffectSchema } from "./_chunks-es/invariants.js";
1
+ import { parseOrThrow, desugarWorkflow, checkWorkflowInvariants, formatValidationError, AuthoringWorkflowSchema, labelFor, WorkflowConfigSchema, AuthoringStageSchema, AuthoringActivitySchema, AuthoringActionSchema, AuthoringTransitionSchema, AuthoringFieldEntrySchema, AuthoringOpSchema, GroupSchema, AuthoringGuardSchema, EffectSchema } from "./_chunks-es/invariants.js";
2
2
 
3
3
  import { CONDITION_VARS, FILTER_SCOPE_VARS, GUARD_PREDICATE_VARS, RESERVED_CONDITION_VARS, groq } from "./_chunks-es/invariants.js";
4
4
 
@@ -13,16 +13,11 @@ function defineWorkflow(definition) {
13
13
  }
14
14
 
15
15
  function defineWorkflowConfig(config) {
16
- const parsed = parseOrThrow({
16
+ return parseOrThrow({
17
17
  schema: WorkflowConfigSchema,
18
18
  input: config,
19
19
  label: "defineWorkflowConfig"
20
20
  });
21
- return assertDeploymentAcknowledgements(parsed), parsed;
22
- }
23
-
24
- function assertDeploymentAcknowledgements(config) {
25
- for (const [index, deployment] of config.deployments.entries()) assertReaderModelAcknowledgement(deployment.expectedMinReaderModel, `Deployment ${deployment.name || `at deployments[${index}]`}`);
26
21
  }
27
22
 
28
23
  function defineStage(stage) {