@sanity/workflow-engine 0.20.0 → 0.22.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
@@ -178,7 +178,7 @@ declare type ActivityFields<TField, TAction, TTarget, TGroup> = {
178
178
  group?: TGroup | undefined;
179
179
  target?: TTarget | undefined;
180
180
  filter?: string | undefined;
181
- requirements?: Record<string, string> | undefined;
181
+ requirements?: GroqRequirement[] | undefined;
182
182
  actions?: TAction[] | undefined;
183
183
  fields?: TField[] | undefined;
184
184
  };
@@ -956,14 +956,15 @@ export declare interface ConditionVar {
956
956
  * the rest evaluate to `undefined` — and deploy rejects them at these
957
957
  * sites; a cascade-fired action's per-token gate is `roles`, never its
958
958
  * conditions.
959
- * 3. **The start contexts** — a definition's `start.filter` and
960
- * `start.allowed` evaluate against a CANDIDATE (no instance exists yet):
961
- * `*[...]` reads the WORKFLOW resource's dataset and none of the rendered
959
+ * 3. **The start contexts** — a definition's `start.filter` and start GROQ
960
+ * requirements evaluate against a CANDIDATE (no instance exists yet):
961
+ * `*[...]` reads the engine-owned `{definition, subject, completedAt}`
962
+ * projection of the tag's instances and none of the rendered
962
963
  * condition vars exist. The two split on what a surface can know:
963
964
  * `filter` is browse-time-pure (candidate document as root,
964
965
  * {@link START_FILTER_VARS} — no `$fields`, which cannot exist before
965
- * inputs do), `allowed` is the start-time permission predicate
966
- * ({@link START_ALLOWED_VARS} — `$fields` bound, never a root).
966
+ * inputs do), a `groq` requirement is the start-time readiness predicate
967
+ * ({@link START_REQUIREMENT_VARS} — `$fields` bound, never a root).
967
968
  * 4. **Guard predicates** — NOT conditions. A lake mutation guard's
968
969
  * `predicate` is groq-js **delta-mode** GROQ over a document mutation:
969
970
  * `before()`/`after()`/`identity()` are dialect natives, and the wire
@@ -982,15 +983,6 @@ export declare interface ConditionVar {
982
983
  */
983
984
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
984
985
 
985
- /**
986
- * The maximum reader floor this writer can emit. Individual documents derive
987
- * their `minReaderModel` from the compatibility-bearing features actually
988
- * present; a document written at {@link DATA_MODEL_VERSION} may therefore
989
- * carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
990
- * decision that requires readers-first fleet sequencing.
991
- */
992
- declare const DATA_MODEL_MIN_READER = 2;
993
-
994
986
  export declare function defineAction(action: AuthoringAction): AuthoringAction;
995
987
 
996
988
  export declare function defineActivity(
@@ -1253,6 +1245,11 @@ export declare function groq(
1253
1245
  ...values: unknown[]
1254
1246
  ): string;
1255
1247
 
1248
+ declare type GroqRequirement = RequirementBase & {
1249
+ type: "groq";
1250
+ query: string;
1251
+ };
1252
+
1256
1253
  /** Type-mirror of {@link GroupSchema} — one declared group. */
1257
1254
  declare type Group = {
1258
1255
  name: string;
@@ -1428,6 +1425,18 @@ declare type ParsedWorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
1428
1425
  declare type ParsedWorkflowDeployment =
1429
1426
  ParsedWorkflowConfig["deployments"][number];
1430
1427
 
1428
+ declare type RequirementBase = {
1429
+ name: string;
1430
+ title?: string | undefined;
1431
+ description?: string | undefined;
1432
+ };
1433
+
1434
+ /**
1435
+ * Names an author's predicate may not use — engine-owned and author names
1436
+ * share one namespace, so a predicate redefining a binding would silently
1437
+ * shadow engine behaviour. Rejected at deploy; derived from the condition
1438
+ * inventory.
1439
+ */
1431
1440
  export declare const RESERVED_CONDITION_VARS: readonly string[];
1432
1441
 
1433
1442
  declare type RoleAliases = v.InferOutput<typeof RoleAliasesSchema>;
@@ -1494,6 +1503,10 @@ declare interface ScalarValidation {
1494
1503
  max?: number | undefined;
1495
1504
  }
1496
1505
 
1506
+ declare type SingleSubjectRequirement = RequirementBase & {
1507
+ type: "singleSubject";
1508
+ };
1509
+
1497
1510
  declare type Stage = StageFields<
1498
1511
  FieldEntry,
1499
1512
  Activity,
@@ -1526,7 +1539,7 @@ declare type StartBlock = StartFields & {
1526
1539
  * authoring may omit it — so each variant declares it. */
1527
1540
  declare type StartFields = {
1528
1541
  filter?: string | undefined;
1529
- allowed?: string | undefined;
1542
+ requirements?: StartRequirement[] | undefined;
1530
1543
  };
1531
1544
 
1532
1545
  /**
@@ -1540,6 +1553,8 @@ declare type StartFields = {
1540
1553
  */
1541
1554
  declare type StartKind = (typeof START_KINDS)[number];
1542
1555
 
1556
+ declare type StartRequirement = GroqRequirement | SingleSubjectRequirement;
1557
+
1543
1558
  /**
1544
1559
  * Declared editability of a field — the generic edit seam's gate. Default
1545
1560
  * (absent) is NOT editable: a field is op-only engine working memory unless the
@@ -1930,7 +1945,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
1930
1945
  ]
1931
1946
  >;
1932
1947
  readonly expectedMinReaderModel: v.OptionalSchema<
1933
- v.CustomSchema<2, undefined>,
1948
+ v.CustomSchema<number, undefined>,
1934
1949
  undefined
1935
1950
  >;
1936
1951
  readonly tag: v.SchemaWithPipe<
@@ -2217,7 +2232,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2217
2232
  v.MinLengthAction<
2218
2233
  {
2219
2234
  name: string;
2220
- expectedMinReaderModel?: 2 | undefined;
2235
+ expectedMinReaderModel?: number | undefined;
2221
2236
  tag: string;
2222
2237
  workflowResource:
2223
2238
  | {
@@ -2278,7 +2293,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2278
2293
  v.CheckAction<
2279
2294
  {
2280
2295
  name: string;
2281
- expectedMinReaderModel?: 2 | undefined;
2296
+ expectedMinReaderModel?: number | undefined;
2282
2297
  tag: string;
2283
2298
  workflowResource:
2284
2299
  | {
@@ -2337,7 +2352,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2337
2352
  issue: v.CheckIssue<
2338
2353
  {
2339
2354
  name: string;
2340
- expectedMinReaderModel?: 2 | undefined;
2355
+ expectedMinReaderModel?: number | undefined;
2341
2356
  tag: string;
2342
2357
  workflowResource:
2343
2358
  | {
@@ -2398,7 +2413,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2398
2413
  v.CheckAction<
2399
2414
  {
2400
2415
  name: string;
2401
- expectedMinReaderModel?: 2 | undefined;
2416
+ expectedMinReaderModel?: number | undefined;
2402
2417
  tag: string;
2403
2418
  workflowResource:
2404
2419
  | {
@@ -2457,7 +2472,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2457
2472
  issue: v.CheckIssue<
2458
2473
  {
2459
2474
  name: string;
2460
- expectedMinReaderModel?: 2 | undefined;
2475
+ expectedMinReaderModel?: number | undefined;
2461
2476
  tag: string;
2462
2477
  workflowResource:
2463
2478
  | {
@@ -2561,7 +2576,11 @@ declare type WorkflowDeployment = Omit<
2561
2576
  ParsedWorkflowDeployment,
2562
2577
  "expectedMinReaderModel"
2563
2578
  > & {
2564
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2579
+ /**
2580
+ * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
2581
+ * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
2582
+ */
2583
+ expectedMinReaderModel: number;
2565
2584
  };
2566
2585
 
2567
2586
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
package/dist/define.d.ts CHANGED
@@ -178,7 +178,7 @@ declare type ActivityFields<TField, TAction, TTarget, TGroup> = {
178
178
  group?: TGroup | undefined;
179
179
  target?: TTarget | undefined;
180
180
  filter?: string | undefined;
181
- requirements?: Record<string, string> | undefined;
181
+ requirements?: GroqRequirement[] | undefined;
182
182
  actions?: TAction[] | undefined;
183
183
  fields?: TField[] | undefined;
184
184
  };
@@ -956,14 +956,15 @@ export declare interface ConditionVar {
956
956
  * the rest evaluate to `undefined` — and deploy rejects them at these
957
957
  * sites; a cascade-fired action's per-token gate is `roles`, never its
958
958
  * conditions.
959
- * 3. **The start contexts** — a definition's `start.filter` and
960
- * `start.allowed` evaluate against a CANDIDATE (no instance exists yet):
961
- * `*[...]` reads the WORKFLOW resource's dataset and none of the rendered
959
+ * 3. **The start contexts** — a definition's `start.filter` and start GROQ
960
+ * requirements evaluate against a CANDIDATE (no instance exists yet):
961
+ * `*[...]` reads the engine-owned `{definition, subject, completedAt}`
962
+ * projection of the tag's instances and none of the rendered
962
963
  * condition vars exist. The two split on what a surface can know:
963
964
  * `filter` is browse-time-pure (candidate document as root,
964
965
  * {@link START_FILTER_VARS} — no `$fields`, which cannot exist before
965
- * inputs do), `allowed` is the start-time permission predicate
966
- * ({@link START_ALLOWED_VARS} — `$fields` bound, never a root).
966
+ * inputs do), a `groq` requirement is the start-time readiness predicate
967
+ * ({@link START_REQUIREMENT_VARS} — `$fields` bound, never a root).
967
968
  * 4. **Guard predicates** — NOT conditions. A lake mutation guard's
968
969
  * `predicate` is groq-js **delta-mode** GROQ over a document mutation:
969
970
  * `before()`/`after()`/`identity()` are dialect natives, and the wire
@@ -982,15 +983,6 @@ export declare interface ConditionVar {
982
983
  */
983
984
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
984
985
 
985
- /**
986
- * The maximum reader floor this writer can emit. Individual documents derive
987
- * their `minReaderModel` from the compatibility-bearing features actually
988
- * present; a document written at {@link DATA_MODEL_VERSION} may therefore
989
- * carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
990
- * decision that requires readers-first fleet sequencing.
991
- */
992
- declare const DATA_MODEL_MIN_READER = 2;
993
-
994
986
  export declare function defineAction(action: AuthoringAction): AuthoringAction;
995
987
 
996
988
  export declare function defineActivity(
@@ -1253,6 +1245,11 @@ export declare function groq(
1253
1245
  ...values: unknown[]
1254
1246
  ): string;
1255
1247
 
1248
+ declare type GroqRequirement = RequirementBase & {
1249
+ type: "groq";
1250
+ query: string;
1251
+ };
1252
+
1256
1253
  /** Type-mirror of {@link GroupSchema} — one declared group. */
1257
1254
  declare type Group = {
1258
1255
  name: string;
@@ -1428,6 +1425,18 @@ declare type ParsedWorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
1428
1425
  declare type ParsedWorkflowDeployment =
1429
1426
  ParsedWorkflowConfig["deployments"][number];
1430
1427
 
1428
+ declare type RequirementBase = {
1429
+ name: string;
1430
+ title?: string | undefined;
1431
+ description?: string | undefined;
1432
+ };
1433
+
1434
+ /**
1435
+ * Names an author's predicate may not use — engine-owned and author names
1436
+ * share one namespace, so a predicate redefining a binding would silently
1437
+ * shadow engine behaviour. Rejected at deploy; derived from the condition
1438
+ * inventory.
1439
+ */
1431
1440
  export declare const RESERVED_CONDITION_VARS: readonly string[];
1432
1441
 
1433
1442
  declare type RoleAliases = v.InferOutput<typeof RoleAliasesSchema>;
@@ -1494,6 +1503,10 @@ declare interface ScalarValidation {
1494
1503
  max?: number | undefined;
1495
1504
  }
1496
1505
 
1506
+ declare type SingleSubjectRequirement = RequirementBase & {
1507
+ type: "singleSubject";
1508
+ };
1509
+
1497
1510
  declare type Stage = StageFields<
1498
1511
  FieldEntry,
1499
1512
  Activity,
@@ -1526,7 +1539,7 @@ declare type StartBlock = StartFields & {
1526
1539
  * authoring may omit it — so each variant declares it. */
1527
1540
  declare type StartFields = {
1528
1541
  filter?: string | undefined;
1529
- allowed?: string | undefined;
1542
+ requirements?: StartRequirement[] | undefined;
1530
1543
  };
1531
1544
 
1532
1545
  /**
@@ -1540,6 +1553,8 @@ declare type StartFields = {
1540
1553
  */
1541
1554
  declare type StartKind = (typeof START_KINDS)[number];
1542
1555
 
1556
+ declare type StartRequirement = GroqRequirement | SingleSubjectRequirement;
1557
+
1543
1558
  /**
1544
1559
  * Declared editability of a field — the generic edit seam's gate. Default
1545
1560
  * (absent) is NOT editable: a field is op-only engine working memory unless the
@@ -1930,7 +1945,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
1930
1945
  ]
1931
1946
  >;
1932
1947
  readonly expectedMinReaderModel: v.OptionalSchema<
1933
- v.CustomSchema<2, undefined>,
1948
+ v.CustomSchema<number, undefined>,
1934
1949
  undefined
1935
1950
  >;
1936
1951
  readonly tag: v.SchemaWithPipe<
@@ -2217,7 +2232,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2217
2232
  v.MinLengthAction<
2218
2233
  {
2219
2234
  name: string;
2220
- expectedMinReaderModel?: 2 | undefined;
2235
+ expectedMinReaderModel?: number | undefined;
2221
2236
  tag: string;
2222
2237
  workflowResource:
2223
2238
  | {
@@ -2278,7 +2293,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2278
2293
  v.CheckAction<
2279
2294
  {
2280
2295
  name: string;
2281
- expectedMinReaderModel?: 2 | undefined;
2296
+ expectedMinReaderModel?: number | undefined;
2282
2297
  tag: string;
2283
2298
  workflowResource:
2284
2299
  | {
@@ -2337,7 +2352,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2337
2352
  issue: v.CheckIssue<
2338
2353
  {
2339
2354
  name: string;
2340
- expectedMinReaderModel?: 2 | undefined;
2355
+ expectedMinReaderModel?: number | undefined;
2341
2356
  tag: string;
2342
2357
  workflowResource:
2343
2358
  | {
@@ -2398,7 +2413,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2398
2413
  v.CheckAction<
2399
2414
  {
2400
2415
  name: string;
2401
- expectedMinReaderModel?: 2 | undefined;
2416
+ expectedMinReaderModel?: number | undefined;
2402
2417
  tag: string;
2403
2418
  workflowResource:
2404
2419
  | {
@@ -2457,7 +2472,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2457
2472
  issue: v.CheckIssue<
2458
2473
  {
2459
2474
  name: string;
2460
- expectedMinReaderModel?: 2 | undefined;
2475
+ expectedMinReaderModel?: number | undefined;
2461
2476
  tag: string;
2462
2477
  workflowResource:
2463
2478
  | {
@@ -2561,7 +2576,11 @@ declare type WorkflowDeployment = Omit<
2561
2576
  ParsedWorkflowDeployment,
2562
2577
  "expectedMinReaderModel"
2563
2578
  > & {
2564
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2579
+ /**
2580
+ * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
2581
+ * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
2582
+ */
2583
+ expectedMinReaderModel: number;
2565
2584
  };
2566
2585
 
2567
2586
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */