@sanity/workflow-engine 0.16.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.cts CHANGED
@@ -150,6 +150,11 @@ declare type AuthoringGuard = v.InferOutput<typeof AuthoringGuardSchema>;
150
150
 
151
151
  declare const AuthoringGuardSchema: v.StrictObjectSchema<
152
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
+ */
153
158
  name: v.SchemaWithPipe<
154
159
  readonly [
155
160
  v.StringSchema<undefined>,
@@ -311,8 +316,9 @@ declare const AuthoringGuardSchema: v.StrictObjectSchema<
311
316
  /**
312
317
  * Lake GROQ predicate — a distinct eval context: delta-mode GROQ
313
318
  * reading the `before()`/`after()` natives, `mutation`, `guard`, and
314
- * `identity()`. Bare ids/fields only. Omitted or empty means
315
- * 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.
316
322
  */
317
323
  predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
318
324
  /**
@@ -839,11 +845,14 @@ export declare interface ConditionVar {
839
845
  * the rest evaluate to `undefined` — and deploy rejects them at these
840
846
  * sites; a cascade-fired action's per-token gate is `roles`, never its
841
847
  * conditions.
842
- * 3. **The start-filter context** — a definition's `start.filter` evaluates
843
- * against a CANDIDATE (no instance exists yet): the candidate document is
844
- * the root, {@link START_FILTER_VARS} are the only bound vars, and
845
- * `*[...]` reads the WORKFLOW resource's dataset. None of the rendered
846
- * condition vars exist there.
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).
847
856
  * 4. **Guard predicates** — NOT conditions. A lake mutation guard's
848
857
  * `predicate` is groq-js **delta-mode** GROQ over a document mutation:
849
858
  * `before()`/`after()`/`identity()` are dialect natives, and the wire
@@ -857,7 +866,7 @@ export declare interface ConditionVar {
857
866
  * instance and its snapshot.
858
867
  * - `'caller'` — rides the acting caller; without one the var is `undefined`
859
868
  * (conditions referencing it fail closed). Author predicates may not read
860
- * these — they pre-evaluate once per instance, caller-free.
869
+ * these — they pre-evaluate caller-free, per evaluation context.
861
870
  * - `'spawn'` — bound only at spawn sites (the per-row `$row`).
862
871
  */
863
872
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
@@ -919,8 +928,9 @@ export declare function defineWorkflow(
919
928
  /**
920
929
  * Validate a deploy config — the binding of each definition's logical resource
921
930
  * handles to physical resources, per environment (tag). Throws a formatted,
922
- * path-prefixed error if the shape is invalid. The CLI hands the selected
923
- * 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.
924
934
  */
925
935
  export declare function defineWorkflowConfig(
926
936
  config: WorkflowConfig,
@@ -1158,6 +1168,11 @@ export declare const GUARD_PREDICATE_VARS: readonly {
1158
1168
  /** Stored guards carry the printed string reads (the deploy resolver's input). */
1159
1169
  declare const GuardSchema: v.StrictObjectSchema<
1160
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
+ */
1161
1176
  name: v.SchemaWithPipe<
1162
1177
  readonly [
1163
1178
  v.StringSchema<undefined>,
@@ -1229,8 +1244,9 @@ declare const GuardSchema: v.StrictObjectSchema<
1229
1244
  /**
1230
1245
  * Lake GROQ predicate — a distinct eval context: delta-mode GROQ
1231
1246
  * reading the `before()`/`after()` natives, `mutation`, `guard`, and
1232
- * `identity()`. Bare ids/fields only. Omitted or empty means
1233
- * 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.
1234
1250
  */
1235
1251
  predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1236
1252
  /**
@@ -1378,6 +1394,7 @@ declare type StartBlock = StartFields & {
1378
1394
  * authoring may omit it — so each variant declares it. */
1379
1395
  declare type StartFields = {
1380
1396
  filter?: string | undefined;
1397
+ allowed?: string | undefined;
1381
1398
  };
1382
1399
 
1383
1400
  /**
@@ -2198,6 +2215,12 @@ declare const WorkflowDefinitionSchema: v.GenericSchema<
2198
2215
 
2199
2216
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
2200
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
+ */
2201
2224
  name: string;
2202
2225
  title: string;
2203
2226
  description?: string | undefined;
package/dist/define.d.ts CHANGED
@@ -150,6 +150,11 @@ declare type AuthoringGuard = v.InferOutput<typeof AuthoringGuardSchema>;
150
150
 
151
151
  declare const AuthoringGuardSchema: v.StrictObjectSchema<
152
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
+ */
153
158
  name: v.SchemaWithPipe<
154
159
  readonly [
155
160
  v.StringSchema<undefined>,
@@ -311,8 +316,9 @@ declare const AuthoringGuardSchema: v.StrictObjectSchema<
311
316
  /**
312
317
  * Lake GROQ predicate — a distinct eval context: delta-mode GROQ
313
318
  * reading the `before()`/`after()` natives, `mutation`, `guard`, and
314
- * `identity()`. Bare ids/fields only. Omitted or empty means
315
- * 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.
316
322
  */
317
323
  predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
318
324
  /**
@@ -839,11 +845,14 @@ export declare interface ConditionVar {
839
845
  * the rest evaluate to `undefined` — and deploy rejects them at these
840
846
  * sites; a cascade-fired action's per-token gate is `roles`, never its
841
847
  * conditions.
842
- * 3. **The start-filter context** — a definition's `start.filter` evaluates
843
- * against a CANDIDATE (no instance exists yet): the candidate document is
844
- * the root, {@link START_FILTER_VARS} are the only bound vars, and
845
- * `*[...]` reads the WORKFLOW resource's dataset. None of the rendered
846
- * condition vars exist there.
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).
847
856
  * 4. **Guard predicates** — NOT conditions. A lake mutation guard's
848
857
  * `predicate` is groq-js **delta-mode** GROQ over a document mutation:
849
858
  * `before()`/`after()`/`identity()` are dialect natives, and the wire
@@ -857,7 +866,7 @@ export declare interface ConditionVar {
857
866
  * instance and its snapshot.
858
867
  * - `'caller'` — rides the acting caller; without one the var is `undefined`
859
868
  * (conditions referencing it fail closed). Author predicates may not read
860
- * these — they pre-evaluate once per instance, caller-free.
869
+ * these — they pre-evaluate caller-free, per evaluation context.
861
870
  * - `'spawn'` — bound only at spawn sites (the per-row `$row`).
862
871
  */
863
872
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
@@ -919,8 +928,9 @@ export declare function defineWorkflow(
919
928
  /**
920
929
  * Validate a deploy config — the binding of each definition's logical resource
921
930
  * handles to physical resources, per environment (tag). Throws a formatted,
922
- * path-prefixed error if the shape is invalid. The CLI hands the selected
923
- * 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.
924
934
  */
925
935
  export declare function defineWorkflowConfig(
926
936
  config: WorkflowConfig,
@@ -1158,6 +1168,11 @@ export declare const GUARD_PREDICATE_VARS: readonly {
1158
1168
  /** Stored guards carry the printed string reads (the deploy resolver's input). */
1159
1169
  declare const GuardSchema: v.StrictObjectSchema<
1160
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
+ */
1161
1176
  name: v.SchemaWithPipe<
1162
1177
  readonly [
1163
1178
  v.StringSchema<undefined>,
@@ -1229,8 +1244,9 @@ declare const GuardSchema: v.StrictObjectSchema<
1229
1244
  /**
1230
1245
  * Lake GROQ predicate — a distinct eval context: delta-mode GROQ
1231
1246
  * reading the `before()`/`after()` natives, `mutation`, `guard`, and
1232
- * `identity()`. Bare ids/fields only. Omitted or empty means
1233
- * 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.
1234
1250
  */
1235
1251
  predicate: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1236
1252
  /**
@@ -1378,6 +1394,7 @@ declare type StartBlock = StartFields & {
1378
1394
  * authoring may omit it — so each variant declares it. */
1379
1395
  declare type StartFields = {
1380
1396
  filter?: string | undefined;
1397
+ allowed?: string | undefined;
1381
1398
  };
1382
1399
 
1383
1400
  /**
@@ -2198,6 +2215,12 @@ declare const WorkflowDefinitionSchema: v.GenericSchema<
2198
2215
 
2199
2216
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
2200
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
+ */
2201
2224
  name: string;
2202
2225
  title: string;
2203
2226
  description?: string | undefined;