@sanity/workflow-engine 0.20.0 → 0.21.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/CHANGELOG.md +93 -0
- package/DATAMODEL.md +168 -0
- package/dist/_chunks-cjs/invariants.cjs +223 -82
- package/dist/_chunks-es/invariants.js +213 -78
- package/dist/define.d.cts +38 -14
- package/dist/define.d.ts +38 -14
- package/dist/index.cjs +1717 -864
- package/dist/index.d.cts +434 -170
- package/dist/index.d.ts +434 -170
- package/dist/index.js +1698 -863
- package/package.json +2 -2
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?:
|
|
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
|
-
*
|
|
961
|
-
* `*[...]` reads the
|
|
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), `
|
|
966
|
-
* ({@link
|
|
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
|
|
@@ -989,7 +990,7 @@ export declare type ConditionVarBinding = "always" | "caller" | "spawn";
|
|
|
989
990
|
* carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
|
|
990
991
|
* decision that requires readers-first fleet sequencing.
|
|
991
992
|
*/
|
|
992
|
-
declare const DATA_MODEL_MIN_READER =
|
|
993
|
+
declare const DATA_MODEL_MIN_READER = 4;
|
|
993
994
|
|
|
994
995
|
export declare function defineAction(action: AuthoringAction): AuthoringAction;
|
|
995
996
|
|
|
@@ -1253,6 +1254,11 @@ export declare function groq(
|
|
|
1253
1254
|
...values: unknown[]
|
|
1254
1255
|
): string;
|
|
1255
1256
|
|
|
1257
|
+
declare type GroqRequirement = RequirementBase & {
|
|
1258
|
+
type: "groq";
|
|
1259
|
+
query: string;
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1256
1262
|
/** Type-mirror of {@link GroupSchema} — one declared group. */
|
|
1257
1263
|
declare type Group = {
|
|
1258
1264
|
name: string;
|
|
@@ -1428,6 +1434,18 @@ declare type ParsedWorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
|
|
|
1428
1434
|
declare type ParsedWorkflowDeployment =
|
|
1429
1435
|
ParsedWorkflowConfig["deployments"][number];
|
|
1430
1436
|
|
|
1437
|
+
declare type RequirementBase = {
|
|
1438
|
+
name: string;
|
|
1439
|
+
title?: string | undefined;
|
|
1440
|
+
description?: string | undefined;
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Names an author's predicate may not use — engine-owned and author names
|
|
1445
|
+
* share one namespace, so a predicate redefining a binding would silently
|
|
1446
|
+
* shadow engine behaviour. Rejected at deploy; derived from the condition
|
|
1447
|
+
* inventory.
|
|
1448
|
+
*/
|
|
1431
1449
|
export declare const RESERVED_CONDITION_VARS: readonly string[];
|
|
1432
1450
|
|
|
1433
1451
|
declare type RoleAliases = v.InferOutput<typeof RoleAliasesSchema>;
|
|
@@ -1494,6 +1512,10 @@ declare interface ScalarValidation {
|
|
|
1494
1512
|
max?: number | undefined;
|
|
1495
1513
|
}
|
|
1496
1514
|
|
|
1515
|
+
declare type SingleSubjectRequirement = RequirementBase & {
|
|
1516
|
+
type: "singleSubject";
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1497
1519
|
declare type Stage = StageFields<
|
|
1498
1520
|
FieldEntry,
|
|
1499
1521
|
Activity,
|
|
@@ -1526,7 +1548,7 @@ declare type StartBlock = StartFields & {
|
|
|
1526
1548
|
* authoring may omit it — so each variant declares it. */
|
|
1527
1549
|
declare type StartFields = {
|
|
1528
1550
|
filter?: string | undefined;
|
|
1529
|
-
|
|
1551
|
+
requirements?: StartRequirement[] | undefined;
|
|
1530
1552
|
};
|
|
1531
1553
|
|
|
1532
1554
|
/**
|
|
@@ -1540,6 +1562,8 @@ declare type StartFields = {
|
|
|
1540
1562
|
*/
|
|
1541
1563
|
declare type StartKind = (typeof START_KINDS)[number];
|
|
1542
1564
|
|
|
1565
|
+
declare type StartRequirement = GroqRequirement | SingleSubjectRequirement;
|
|
1566
|
+
|
|
1543
1567
|
/**
|
|
1544
1568
|
* Declared editability of a field — the generic edit seam's gate. Default
|
|
1545
1569
|
* (absent) is NOT editable: a field is op-only engine working memory unless the
|
|
@@ -1930,7 +1954,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
1930
1954
|
]
|
|
1931
1955
|
>;
|
|
1932
1956
|
readonly expectedMinReaderModel: v.OptionalSchema<
|
|
1933
|
-
v.CustomSchema<
|
|
1957
|
+
v.CustomSchema<4, undefined>,
|
|
1934
1958
|
undefined
|
|
1935
1959
|
>;
|
|
1936
1960
|
readonly tag: v.SchemaWithPipe<
|
|
@@ -2217,7 +2241,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2217
2241
|
v.MinLengthAction<
|
|
2218
2242
|
{
|
|
2219
2243
|
name: string;
|
|
2220
|
-
expectedMinReaderModel?:
|
|
2244
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2221
2245
|
tag: string;
|
|
2222
2246
|
workflowResource:
|
|
2223
2247
|
| {
|
|
@@ -2278,7 +2302,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2278
2302
|
v.CheckAction<
|
|
2279
2303
|
{
|
|
2280
2304
|
name: string;
|
|
2281
|
-
expectedMinReaderModel?:
|
|
2305
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2282
2306
|
tag: string;
|
|
2283
2307
|
workflowResource:
|
|
2284
2308
|
| {
|
|
@@ -2337,7 +2361,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2337
2361
|
issue: v.CheckIssue<
|
|
2338
2362
|
{
|
|
2339
2363
|
name: string;
|
|
2340
|
-
expectedMinReaderModel?:
|
|
2364
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2341
2365
|
tag: string;
|
|
2342
2366
|
workflowResource:
|
|
2343
2367
|
| {
|
|
@@ -2398,7 +2422,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2398
2422
|
v.CheckAction<
|
|
2399
2423
|
{
|
|
2400
2424
|
name: string;
|
|
2401
|
-
expectedMinReaderModel?:
|
|
2425
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2402
2426
|
tag: string;
|
|
2403
2427
|
workflowResource:
|
|
2404
2428
|
| {
|
|
@@ -2457,7 +2481,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2457
2481
|
issue: v.CheckIssue<
|
|
2458
2482
|
{
|
|
2459
2483
|
name: string;
|
|
2460
|
-
expectedMinReaderModel?:
|
|
2484
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2461
2485
|
tag: string;
|
|
2462
2486
|
workflowResource:
|
|
2463
2487
|
| {
|
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?:
|
|
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
|
-
*
|
|
961
|
-
* `*[...]` reads the
|
|
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), `
|
|
966
|
-
* ({@link
|
|
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
|
|
@@ -989,7 +990,7 @@ export declare type ConditionVarBinding = "always" | "caller" | "spawn";
|
|
|
989
990
|
* carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
|
|
990
991
|
* decision that requires readers-first fleet sequencing.
|
|
991
992
|
*/
|
|
992
|
-
declare const DATA_MODEL_MIN_READER =
|
|
993
|
+
declare const DATA_MODEL_MIN_READER = 4;
|
|
993
994
|
|
|
994
995
|
export declare function defineAction(action: AuthoringAction): AuthoringAction;
|
|
995
996
|
|
|
@@ -1253,6 +1254,11 @@ export declare function groq(
|
|
|
1253
1254
|
...values: unknown[]
|
|
1254
1255
|
): string;
|
|
1255
1256
|
|
|
1257
|
+
declare type GroqRequirement = RequirementBase & {
|
|
1258
|
+
type: "groq";
|
|
1259
|
+
query: string;
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1256
1262
|
/** Type-mirror of {@link GroupSchema} — one declared group. */
|
|
1257
1263
|
declare type Group = {
|
|
1258
1264
|
name: string;
|
|
@@ -1428,6 +1434,18 @@ declare type ParsedWorkflowConfig = v.InferOutput<typeof WorkflowConfigSchema>;
|
|
|
1428
1434
|
declare type ParsedWorkflowDeployment =
|
|
1429
1435
|
ParsedWorkflowConfig["deployments"][number];
|
|
1430
1436
|
|
|
1437
|
+
declare type RequirementBase = {
|
|
1438
|
+
name: string;
|
|
1439
|
+
title?: string | undefined;
|
|
1440
|
+
description?: string | undefined;
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Names an author's predicate may not use — engine-owned and author names
|
|
1445
|
+
* share one namespace, so a predicate redefining a binding would silently
|
|
1446
|
+
* shadow engine behaviour. Rejected at deploy; derived from the condition
|
|
1447
|
+
* inventory.
|
|
1448
|
+
*/
|
|
1431
1449
|
export declare const RESERVED_CONDITION_VARS: readonly string[];
|
|
1432
1450
|
|
|
1433
1451
|
declare type RoleAliases = v.InferOutput<typeof RoleAliasesSchema>;
|
|
@@ -1494,6 +1512,10 @@ declare interface ScalarValidation {
|
|
|
1494
1512
|
max?: number | undefined;
|
|
1495
1513
|
}
|
|
1496
1514
|
|
|
1515
|
+
declare type SingleSubjectRequirement = RequirementBase & {
|
|
1516
|
+
type: "singleSubject";
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1497
1519
|
declare type Stage = StageFields<
|
|
1498
1520
|
FieldEntry,
|
|
1499
1521
|
Activity,
|
|
@@ -1526,7 +1548,7 @@ declare type StartBlock = StartFields & {
|
|
|
1526
1548
|
* authoring may omit it — so each variant declares it. */
|
|
1527
1549
|
declare type StartFields = {
|
|
1528
1550
|
filter?: string | undefined;
|
|
1529
|
-
|
|
1551
|
+
requirements?: StartRequirement[] | undefined;
|
|
1530
1552
|
};
|
|
1531
1553
|
|
|
1532
1554
|
/**
|
|
@@ -1540,6 +1562,8 @@ declare type StartFields = {
|
|
|
1540
1562
|
*/
|
|
1541
1563
|
declare type StartKind = (typeof START_KINDS)[number];
|
|
1542
1564
|
|
|
1565
|
+
declare type StartRequirement = GroqRequirement | SingleSubjectRequirement;
|
|
1566
|
+
|
|
1543
1567
|
/**
|
|
1544
1568
|
* Declared editability of a field — the generic edit seam's gate. Default
|
|
1545
1569
|
* (absent) is NOT editable: a field is op-only engine working memory unless the
|
|
@@ -1930,7 +1954,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
1930
1954
|
]
|
|
1931
1955
|
>;
|
|
1932
1956
|
readonly expectedMinReaderModel: v.OptionalSchema<
|
|
1933
|
-
v.CustomSchema<
|
|
1957
|
+
v.CustomSchema<4, undefined>,
|
|
1934
1958
|
undefined
|
|
1935
1959
|
>;
|
|
1936
1960
|
readonly tag: v.SchemaWithPipe<
|
|
@@ -2217,7 +2241,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2217
2241
|
v.MinLengthAction<
|
|
2218
2242
|
{
|
|
2219
2243
|
name: string;
|
|
2220
|
-
expectedMinReaderModel?:
|
|
2244
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2221
2245
|
tag: string;
|
|
2222
2246
|
workflowResource:
|
|
2223
2247
|
| {
|
|
@@ -2278,7 +2302,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2278
2302
|
v.CheckAction<
|
|
2279
2303
|
{
|
|
2280
2304
|
name: string;
|
|
2281
|
-
expectedMinReaderModel?:
|
|
2305
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2282
2306
|
tag: string;
|
|
2283
2307
|
workflowResource:
|
|
2284
2308
|
| {
|
|
@@ -2337,7 +2361,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2337
2361
|
issue: v.CheckIssue<
|
|
2338
2362
|
{
|
|
2339
2363
|
name: string;
|
|
2340
|
-
expectedMinReaderModel?:
|
|
2364
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2341
2365
|
tag: string;
|
|
2342
2366
|
workflowResource:
|
|
2343
2367
|
| {
|
|
@@ -2398,7 +2422,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2398
2422
|
v.CheckAction<
|
|
2399
2423
|
{
|
|
2400
2424
|
name: string;
|
|
2401
|
-
expectedMinReaderModel?:
|
|
2425
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2402
2426
|
tag: string;
|
|
2403
2427
|
workflowResource:
|
|
2404
2428
|
| {
|
|
@@ -2457,7 +2481,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
|
|
|
2457
2481
|
issue: v.CheckIssue<
|
|
2458
2482
|
{
|
|
2459
2483
|
name: string;
|
|
2460
|
-
expectedMinReaderModel?:
|
|
2484
|
+
expectedMinReaderModel?: 4 | undefined;
|
|
2461
2485
|
tag: string;
|
|
2462
2486
|
workflowResource:
|
|
2463
2487
|
| {
|