@sanity/workflow-engine 0.31.0 → 0.32.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.
@@ -40,6 +40,37 @@ function driverKind(actor) {
40
40
  return actor.kind === "person" || actor.kind === "agent" ? actor.kind : "service";
41
41
  }
42
42
 
43
+ function isFilterScopedOut(entry) {
44
+ return entry.status === "skipped" && entry.startedAt === void 0;
45
+ }
46
+
47
+ function liveSubworkflows(host) {
48
+ return (host.subworkflows ?? []).filter(row => row.resolved === void 0);
49
+ }
50
+
51
+ function resolvedChildStatus(child) {
52
+ if (!(child.completedAt === void 0 || child.completedAt === null)) return child.abortedAt !== void 0 && child.abortedAt !== null ? "aborted" : "done";
53
+ }
54
+
55
+ function condemnedSubworkflows(host) {
56
+ return liveSubworkflows(host).filter(row => row.abortPending !== void 0);
57
+ }
58
+
59
+ function condemnSubworkflow(row, owed) {
60
+ row.abortPending !== void 0 || row.resolved !== void 0 || (row.abortPending = {
61
+ at: owed.at,
62
+ reason: owed.reason
63
+ });
64
+ }
65
+
66
+ function findOpenStageEntry(host) {
67
+ return host.stages.find(s => s.name === host.currentStage && s.exitedAt === void 0);
68
+ }
69
+
70
+ function findCurrentActivityEntry(host, activityName) {
71
+ return findOpenStageEntry(host)?.activities.find(a => a.name === activityName);
72
+ }
73
+
43
74
  function errorMessage(err) {
44
75
  return (err instanceof Error ? err.message : String(err)).replace(/[^\P{Cc}\n\t]/gu, "");
45
76
  }
@@ -499,8 +530,6 @@ function desugarWorkflow(authoring) {
499
530
  checkReservedRoleAliasKeys(authoring.roleAliases, issues);
500
531
  const roleAliases = normalizeRoleAliases(authoring.roleAliases), ctx = {
501
532
  issues: issues,
502
- claimFields: /* @__PURE__ */ new Map,
503
- claimedFields: /* @__PURE__ */ new Set,
504
533
  roleAliases: roleAliases
505
534
  }, workflowFields2 = desugarFieldEntries({
506
535
  entries: authoring.fields,
@@ -559,7 +588,7 @@ function desugarWorkflow(authoring) {
559
588
  } : {}
560
589
  };
561
590
  });
562
- return checkUnclaimedClaimFields(ctx), {
591
+ return {
563
592
  definition: {
564
593
  ...stripUndefined({
565
594
  name: authoring.name,
@@ -640,11 +669,6 @@ function desugarFieldEntries({entries: entries, path: path, ctx: ctx}) {
640
669
  }
641
670
 
642
671
  function desugarFieldEntry({entry: entry, path: path, ctx: ctx}) {
643
- if (entry.type === "claim") return desugarClaimField({
644
- entry: entry,
645
- path: path,
646
- ctx: ctx
647
- });
648
672
  if (entry.type === "todoList" || entry.type === "notes") return desugarListField({
649
673
  entry: entry,
650
674
  path: path,
@@ -675,22 +699,6 @@ function desugarFieldEntry({entry: entry, path: path, ctx: ctx}) {
675
699
  };
676
700
  }
677
701
 
678
- function desugarClaimField({entry: entry, path: path, ctx: ctx}) {
679
- const desugared = {
680
- ...stripUndefined({
681
- name: entry.name,
682
- title: entry.title,
683
- description: entry.description,
684
- group: normalizeGroup(entry.group)
685
- }),
686
- type: "actor"
687
- };
688
- return ctx.claimFields.set(desugared, {
689
- name: entry.name,
690
- path: path
691
- }), desugared;
692
- }
693
-
694
702
  function desugarListField({entry: entry, path: path, ctx: ctx}) {
695
703
  const editable = normalizeEditable({
696
704
  editable: entry.editable,
@@ -855,12 +863,6 @@ function desugarActionOps(args) {
855
863
  }
856
864
 
857
865
  function desugarAction({action: action, path: path, env: env, activityName: activityName, ctx: ctx}) {
858
- if ("type" in action) return desugarClaimAction({
859
- action: action,
860
- path: path,
861
- env: env,
862
- ctx: ctx
863
- });
864
866
  reportEmptyActionRoles({
865
867
  action: action,
866
868
  path: path,
@@ -897,67 +899,6 @@ function desugarAction({action: action, path: path, env: env, activityName: acti
897
899
  };
898
900
  }
899
901
 
900
- function desugarClaimAction({action: action, path: path, env: env, ctx: ctx}) {
901
- const ref = typeof action.field == "string" ? {
902
- field: action.field
903
- } : action.field, resolved = resolveRef({
904
- ref: ref,
905
- env: env,
906
- path: [ ...path, "field" ],
907
- ctx: ctx
908
- });
909
- if (resolved) {
910
- const entry = entryAt(env, resolved);
911
- entry && entry.type !== "actor" && ctx.issues.push({
912
- path: [ ...path, "field" ],
913
- message: `claim action "${action.name}" references "${resolved.field}" of kind "${entry.type}" — a claim pair needs an actor-valued entry (a "claim" or "actor" field declaration)`
914
- }), checkShadowedClaimTarget({
915
- actionName: action.name,
916
- field: ref.field,
917
- resolved: resolved,
918
- env: env,
919
- path: [ ...path, "field" ],
920
- ctx: ctx
921
- }), entry && ctx.claimedFields.add(entry);
922
- }
923
- const noSteal = `!defined($fields.${ref.field})`, filter = andConditions([ noSteal, rolesCondition(action.roles, ctx.roleAliases), action.filter ]), ops = resolved ? [ {
924
- type: "field.set",
925
- target: resolved,
926
- value: {
927
- type: "actor"
928
- }
929
- } ] : [];
930
- return {
931
- ...stripUndefined({
932
- name: action.name,
933
- title: action.title,
934
- description: action.description,
935
- group: normalizeGroup(action.group),
936
- params: action.params,
937
- effects: action.effects
938
- }),
939
- filter: filter,
940
- ...ops.length > 0 ? {
941
- ops: ops
942
- } : {}
943
- };
944
- }
945
-
946
- function checkShadowedClaimTarget({actionName: actionName, field: field, resolved: resolved, env: env, path: path, ctx: ctx}) {
947
- const nearest = env.layers.find(l => l.entries.has(field));
948
- nearest === void 0 || nearest.scope === resolved.scope || ctx.issues.push({
949
- path: path,
950
- message: `claim action "${actionName}" targets "${field}" at scope "${resolved.scope}", but a nearer ${nearest.scope}-scope entry of the same name shadows it in $fields — the no-steal filter would read the shadowing entry while the claim writes the "${resolved.scope}" one. Rename one of the entries or claim the nearer one`
951
- });
952
- }
953
-
954
- function checkUnclaimedClaimFields(ctx) {
955
- for (const [entry, {name: name, path: path}] of ctx.claimFields) ctx.claimedFields.has(entry) || ctx.issues.push({
956
- path: path,
957
- message: `claim field "${name}" is never referenced by a claim action — you announced the pattern and wrote half of it. Declare a defineAction({ type: "claim", field: "${name}" }) or use a raw actor entry`
958
- });
959
- }
960
-
961
902
  const DEFAULT_TRANSITION_WHEN = "$allActivitiesDone";
962
903
 
963
904
  function desugarTransition({transition: transition}) {
@@ -1257,13 +1198,23 @@ function walkAstNodes(node, visit) {
1257
1198
  }
1258
1199
  }
1259
1200
 
1260
- const ACTIVITY_STATUSES = [ "active", "done", "skipped", "failed" ], TERMINAL_ACTIVITY_STATUSES = [ "done", "skipped", "failed" ];
1201
+ const ACTIVITY_STATUSES = groqConditionDescribe._exhaustiveOptions()([ "active", "done", "skipped", "failed" ]), TERMINAL_ACTIVITY_STATUSES = groqConditionDescribe._exhaustiveOptions()([ "done", "skipped", "failed" ]);
1261
1202
 
1262
1203
  function isTerminalActivityStatus(status) {
1263
1204
  return TERMINAL_ACTIVITY_STATUSES.includes(status);
1264
1205
  }
1265
1206
 
1266
- const SIGNAL_SEMANTICS = [ "signal.positive", "signal.caution", "signal.critical" ], DECISION_SEMANTICS = [ "decision.accept", "decision.decline" ], ACTION_SEMANTICS = [ ...DECISION_SEMANTICS, ...SIGNAL_SEMANTICS ], FIELD_SCOPES = [ "workflow", "stage", "activity" ], DOCUMENT_VALUE_PERMISSIONS = [ "create", "read", "update" ], MUTATION_GUARD_ACTIONS = [ "create", "update", "delete", "publish", "unpublish" ], ACTIVITY_KINDS = [ "user", "service", "script", "manual", "receive" ], EXECUTOR_CLASSIFICATIONS = [ "autonomous", "interactive", "off-system", "hybrid" ], GROUP_KINDS = [ "core", "details" ], DRIVER_KINDS = [ "person", "agent", "service", "engine" ];
1207
+ const SIGNAL_SEMANTICS = [ "signal.positive", "signal.caution", "signal.critical" ], DECISION_SEMANTICS = [ "decision.accept", "decision.decline" ], ACTION_SEMANTICS = [ ...DECISION_SEMANTICS, ...SIGNAL_SEMANTICS ], FIELD_SCOPES = groqConditionDescribe._exhaustiveOptions()([ "workflow", "stage", "activity" ]), DOCUMENT_VALUE_PERMISSIONS = [ "create", "manage", "read", "update" ], LAKE_MUTATION_GUARD_ACTIONS = groqConditionDescribe._exhaustiveOptions()([ "create", "update", "delete" ]), MUTATION_GUARD_ACTIONS = groqConditionDescribe._exhaustiveOptions()([ ...LAKE_MUTATION_GUARD_ACTIONS, "publish", "unpublish" ]), GUARD_ACTIONS_REQUIRED_MESSAGE = "a guard must match at least one action", MUTATION_GUARD_ID_SPACES = [ "authored", "edit", "published" ];
1208
+
1209
+ function mutationGuardActionIdSpace(action) {
1210
+ return action === "update" ? "edit" : action === "publish" || action === "unpublish" ? "published" : "authored";
1211
+ }
1212
+
1213
+ function mutationGuardRequiresSplitEmission(actions) {
1214
+ return new Set(actions.map(mutationGuardActionIdSpace)).size > 1;
1215
+ }
1216
+
1217
+ const ACTIVITY_KINDS = [ "user", "service", "script", "manual", "receive" ], EXECUTOR_CLASSIFICATIONS = [ "autonomous", "interactive", "off-system", "hybrid" ], GROUP_KINDS = [ "core", "details" ], DRIVER_KINDS = [ "person", "agent", "service", "engine" ];
1267
1218
 
1268
1219
  function releaseDocId(releaseName) {
1269
1220
  return `_.releases.${releaseName}`;
@@ -1279,7 +1230,7 @@ function releaseRef({res: res, releaseName: releaseName}) {
1279
1230
  }
1280
1231
 
1281
1232
  function isAlwaysArrayFieldKind(kind) {
1282
- return kind === "doc.refs" || kind === "assignees" || kind === "array";
1233
+ return kind === "doc.refs" || kind === "assignee" || kind === "assignees" || kind === "array";
1283
1234
  }
1284
1235
 
1285
1236
  function isSingleDocRefKind(kind) {
@@ -1434,6 +1385,9 @@ const CONDITION_VARS = [ {
1434
1385
  label: "the start's input fields",
1435
1386
  description: "The caller's input entries by name (`initialFields` — at `startInstance`, the values the start would seed; at a pre-flight, the values gathered so far, so a read of a not-yet-supplied entry is GROQ null). Document references bind as GDR envelopes — `$fields.<entry>.id` is the GDR URI, never a string authors assemble — a singular `doc.ref` or `subject` included (nothing hydrates at the gate or the pre-flight). Pathed reads are deploy-checked against these envelope shapes."
1436
1387
  } ], GUARD_PREDICATE_VARS = [ {
1388
+ name: "document",
1389
+ description: "The attempted mutation images, exposed as `document.before` and `document.after`."
1390
+ }, {
1437
1391
  name: "guard",
1438
1392
  description: "The guard document itself (its `metadata` carries deploy-time resolved values)."
1439
1393
  }, {
@@ -1567,7 +1521,65 @@ function documentIdOf(doc) {
1567
1521
  return "(unknown id)";
1568
1522
  }
1569
1523
 
1570
- const ACTOR_KINDS = [ "person", "agent", "system" ], ANONYMOUS_IDENTITY = "<anonymous>", SYSTEM_IDENTITY = "<system>", E_PREFIXED_PROJECT_ID = /^e-(.+)$/;
1524
+ const ACTOR_KINDS = [ "person", "agent", "system" ];
1525
+
1526
+ function normalizeAssignmentMembers(value) {
1527
+ return value === null ? [] : Array.isArray(value) ? value : [ value ];
1528
+ }
1529
+
1530
+ function assignmentMembers(entries) {
1531
+ return entries.flatMap(entry => isAssignmentFieldEntry(entry) ? normalizeAssignmentMembers(entry.value) : []);
1532
+ }
1533
+
1534
+ function assignmentState(members) {
1535
+ return members.length === 0 ? "unrouted" : members.some(member => member.type === "user") ? "held" : "routed";
1536
+ }
1537
+
1538
+ function activeAssignmentMembers(members) {
1539
+ const users = members.filter(member => member.type === "user");
1540
+ return users.length > 0 ? users : members;
1541
+ }
1542
+
1543
+ function assignmentMatch(members, identity) {
1544
+ const active = activeAssignmentMembers(members);
1545
+ return active.some(member => member.type === "user" && member.id === identity.userId) ? "user" : active.some(member => member.type === "role" && identity.roles.includes(member.role)) ? "role" : void 0;
1546
+ }
1547
+
1548
+ function identityMatchesAssignment(members, identity) {
1549
+ return assignmentMatch(members, identity) !== void 0;
1550
+ }
1551
+
1552
+ function assignmentStateCounts(assignments, identity) {
1553
+ const counts = {
1554
+ unrouted: 0,
1555
+ routed: 0,
1556
+ held: 0
1557
+ };
1558
+ for (const members of assignments) {
1559
+ const state = assignmentState(members);
1560
+ state === "unrouted" ? counts.unrouted += 1 : identityMatchesAssignment(members, identity) && (counts[state] += 1);
1561
+ }
1562
+ return counts;
1563
+ }
1564
+
1565
+ function openActivityAssignments(instance) {
1566
+ return (findOpenStageEntry(instance)?.activities ?? []).filter(activity => activity.status === "active").map(activity => assignmentMembers(activity.fields ?? []));
1567
+ }
1568
+
1569
+ function instanceAssignmentStateCounts(instance, identity) {
1570
+ return assignmentStateCounts(openActivityAssignments(instance), identity);
1571
+ }
1572
+
1573
+ function actorMatchesAssignment(args) {
1574
+ const actor = args.actor;
1575
+ return actor === void 0 ? !1 : activeAssignmentMembers(args.members).some(member => member.type === "user" ? member.id === actor.id : actorFulfillsRole({
1576
+ actorRoles: actor.roles,
1577
+ required: member.role,
1578
+ aliases: args.roleAliases
1579
+ }));
1580
+ }
1581
+
1582
+ const ANONYMOUS_IDENTITY = "<anonymous>", SYSTEM_IDENTITY = "<system>", E_PREFIXED_PROJECT_ID = /^e-(.+)$/;
1571
1583
 
1572
1584
  function classifyPrincipalId(id) {
1573
1585
  if (id === ANONYMOUS_IDENTITY || id === SYSTEM_IDENTITY) return {
@@ -1644,7 +1656,7 @@ const GdrUriSchema = v__namespace.custom(s => typeof s == "string" && isGdrUri(s
1644
1656
  }), tolerantObject()({
1645
1657
  type: v__namespace.literal("role"),
1646
1658
  role: NonEmptyString
1647
- }) ]), NullableString = v__namespace.union([ v__namespace.null(), v__namespace.string() ]), NullableNumber = v__namespace.union([ v__namespace.null(), v__namespace.number() ]), NullableBoolean = v__namespace.union([ v__namespace.null(), v__namespace.boolean() ]), NullableProgress = v__namespace.union([ v__namespace.null(), v__namespace.pipe(v__namespace.number(), v__namespace.finite("progress must be a finite number"), v__namespace.minValue(0, "progress must be at least 0"), v__namespace.maxValue(100, "progress must be at most 100")) ]), NullableDateTime = v__namespace.union([ v__namespace.null(), IsoTimestamp ]), NullableDate = v__namespace.union([ v__namespace.null(), v__namespace.pipe(v__namespace.string(), v__namespace.regex(/^\d{4}-\d{2}-\d{2}$/, "must be a `YYYY-MM-DD` date")) ]), NullableUrl = NullableString, CHOICE_KINDS = /* @__PURE__ */ new Set([ "string", "text", "number", "url", "date", "dueDate", "datetime", "dueDatetime", "dateTime" ]);
1659
+ }) ]), AssigneeListShape = v__namespace.pipe(v__namespace.union([ v__namespace.null(), AssigneeShape, v__namespace.array(AssigneeShape) ]), v__namespace.transform(normalizeAssignmentMembers)), NullableString = v__namespace.union([ v__namespace.null(), v__namespace.string() ]), NullableNumber = v__namespace.union([ v__namespace.null(), v__namespace.number() ]), NullableBoolean = v__namespace.union([ v__namespace.null(), v__namespace.boolean() ]), NullableProgress = v__namespace.union([ v__namespace.null(), v__namespace.pipe(v__namespace.number(), v__namespace.finite("progress must be a finite number"), v__namespace.minValue(0, "progress must be at least 0"), v__namespace.maxValue(100, "progress must be at most 100")) ]), NullableDateTime = v__namespace.union([ v__namespace.null(), IsoTimestamp ]), NullableDate = v__namespace.union([ v__namespace.null(), v__namespace.pipe(v__namespace.string(), v__namespace.regex(/^\d{4}-\d{2}-\d{2}$/, "must be a `YYYY-MM-DD` date")) ]), NullableUrl = NullableString, CHOICE_KINDS = /* @__PURE__ */ new Set([ "string", "text", "number", "url", "date", "dueDate", "datetime", "dueDatetime", "dateTime" ]);
1648
1660
 
1649
1661
  function normalizedChoiceKind(kind) {
1650
1662
  return kind === "dateTime" ? "datetime" : kind;
@@ -1684,7 +1696,7 @@ const fieldValueSchemas = {
1684
1696
  dueDatetime: NullableDateTime,
1685
1697
  url: NullableUrl,
1686
1698
  actor: v__namespace.union([ v__namespace.null(), ActorShape ]),
1687
- assignee: v__namespace.union([ v__namespace.null(), AssigneeShape ]),
1699
+ assignee: AssigneeListShape,
1688
1700
  assignees: v__namespace.array(AssigneeShape)
1689
1701
  }, WritePrincipalId = v__namespace.pipe(NonEmptyString, v__namespace.rawTransform(({dataset: dataset, addIssue: addIssue}) => {
1690
1702
  const classified = classifyPrincipalId(dataset.value);
@@ -1696,16 +1708,16 @@ const fieldValueSchemas = {
1696
1708
  id: WritePrincipalId,
1697
1709
  roles: v__namespace.exactOptional(v__namespace.array(v__namespace.string())),
1698
1710
  onBehalfOf: v__namespace.exactOptional(v__namespace.string())
1699
- }), AssigneeWriteShape = v__namespace.union([ tolerantObject()({
1711
+ }), AssigneePrincipalId = v__namespace.pipe(WritePrincipalId, v__namespace.check(id => classifyPrincipalId(id).namespace !== "robot", "robot principals cannot be assignment members")), AssigneeWriteShape = v__namespace.union([ tolerantObject()({
1700
1712
  type: v__namespace.literal("user"),
1701
- id: WritePrincipalId
1713
+ id: AssigneePrincipalId
1702
1714
  }), tolerantObject()({
1703
1715
  type: v__namespace.literal("role"),
1704
1716
  role: NonEmptyString
1705
- }) ]), valueSchemas = {
1717
+ }) ]), SingularAssigneeWriteShape = v__namespace.pipe(v__namespace.union([ AssigneeWriteShape, v__namespace.array(AssigneeWriteShape) ]), v__namespace.transform(normalizeAssignmentMembers), v__namespace.check(members => members.filter(member => member.type === "user").length <= 1, "must contain at most one user member")), valueSchemas = {
1706
1718
  ...fieldValueSchemas,
1707
1719
  actor: v__namespace.nullable(ActorWriteShape),
1708
- assignee: v__namespace.nullable(AssigneeWriteShape),
1720
+ assignee: SingularAssigneeWriteShape,
1709
1721
  assignees: v__namespace.array(AssigneeWriteShape),
1710
1722
  query: v__namespace.any()
1711
1723
  };
@@ -1796,7 +1808,7 @@ function appendItemSchema(entryType, shape) {
1796
1808
  leaf: valueSchemas
1797
1809
  });
1798
1810
  if (entryType === "doc.refs") return GdrShape;
1799
- if (entryType === "assignees") return AssigneeWriteShape;
1811
+ if (entryType === "assignee" || entryType === "assignees") return AssigneeWriteShape;
1800
1812
  }
1801
1813
 
1802
1814
  function rejectedRefTypes(args) {
@@ -1893,7 +1905,7 @@ function consumeRetainedAssignment(args) {
1893
1905
 
1894
1906
  function previousAssignmentIdentities(args) {
1895
1907
  const retained = /* @__PURE__ */ new Map;
1896
- if (args.previousValue === void 0 || args.entryType === "assignee") return retained;
1908
+ if (args.previousValue === void 0) return retained;
1897
1909
  const schema = wholeValueSchema({
1898
1910
  entryType: args.entryType,
1899
1911
  shape: args,
@@ -1936,7 +1948,7 @@ function visitAssignmentEntries(args, visit) {
1936
1948
 
1937
1949
  function visitAssignmentCandidates(args, visit) {
1938
1950
  if (args.roles === void 0) return;
1939
- const indexedValues = args.entryType === "assignees" && Array.isArray(args.value) ? args.value.map(value => ({
1951
+ const indexedValues = Array.isArray(args.value) ? args.value.map(value => ({
1940
1952
  value: value,
1941
1953
  path: args.path
1942
1954
  })) : [ {
@@ -2005,14 +2017,22 @@ function validateFieldValue(args) {
2005
2017
  return check.output;
2006
2018
  }
2007
2019
 
2008
- const BARE_ID_SOURCE = "[A-Za-z0-9_][A-Za-z0-9._-]*", BARE_ID_RE = new RegExp(`^${BARE_ID_SOURCE}$`), ALIAS_REF_RE = new RegExp(`^@${RESOURCE_ALIAS_NAME_SOURCE}:${BARE_ID_SOURCE}$`);
2020
+ const BARE_ID_SOURCE = "[A-Za-z0-9_][A-Za-z0-9._-]{0,127}", BARE_ID_RE = new RegExp(`^${BARE_ID_SOURCE}$`), ALIAS_REF_RE = new RegExp(`^@${RESOURCE_ALIAS_NAME_SOURCE}:${BARE_ID_SOURCE}$`);
2021
+
2022
+ function isBareDocumentId(id) {
2023
+ return BARE_ID_RE.test(id) && !id.includes("..");
2024
+ }
2009
2025
 
2010
2026
  function isAuthoringRefId(id) {
2011
- return id.startsWith("@") ? ALIAS_REF_RE.test(id) : id.includes(":") ? isGdrUri(id) : BARE_ID_RE.test(id);
2027
+ if (id.startsWith("@")) {
2028
+ const separator = id.indexOf(":");
2029
+ return ALIAS_REF_RE.test(id) && isBareDocumentId(id.slice(separator + 1));
2030
+ }
2031
+ return id.includes(":") ? isGdrUri(id) : isBareDocumentId(id);
2012
2032
  }
2013
2033
 
2014
2034
  function isBareSeedId(id) {
2015
- return BARE_ID_RE.test(id);
2035
+ return isBareDocumentId(id);
2016
2036
  }
2017
2037
 
2018
2038
  const AuthoringRefId = v__namespace.pipe(v__namespace.string(), v__namespace.check(isAuthoringRefId, "must be a bare document id, a GDR URI, or a portable `@<alias>:<id>` reference")), AuthoringGdrShape = v__namespace.looseObject({
@@ -2078,7 +2098,7 @@ function validateFieldAppendItem(args) {
2078
2098
  }
2079
2099
 
2080
2100
  function appendAssignmentEntryType(entryType) {
2081
- return entryType === "assignees" ? "assignee" : entryType === "array" ? "object" : entryType;
2101
+ return entryType === "assignee" || entryType === "assignees" ? "assignee" : entryType === "array" ? "object" : entryType;
2082
2102
  }
2083
2103
 
2084
2104
  function formatIssues(issues, formatMessage = issue => issue.message) {
@@ -2103,10 +2123,6 @@ function invalidOptionMessage(options) {
2103
2123
  return `Invalid option: expected one of ${options.map(option => `"${option}"`).join("|")}`;
2104
2124
  }
2105
2125
 
2106
- function exhaustiveOptions() {
2107
- return options => options;
2108
- }
2109
-
2110
2126
  function pinned() {
2111
2127
  return (schema, ..._exact) => schema;
2112
2128
  }
@@ -2166,7 +2182,7 @@ function manualTargetSchema(ref) {
2166
2182
  }) ]);
2167
2183
  }
2168
2184
 
2169
- const StoredManualTargetSchema = manualTargetSchema(StoredFieldRefSchema), AuthoringManualTargetSchema = manualTargetSchema(v__namespace.union([ NonEmpty, AuthoringFieldRefSchema ])), ConditionSchema = NonEmpty;
2185
+ const StoredManualTargetSchema = pinned()(manualTargetSchema(StoredFieldRefSchema)), AuthoringManualTargetSchema = pinned()(manualTargetSchema(v__namespace.union([ NonEmpty, AuthoringFieldRefSchema ]))), ConditionSchema = NonEmpty;
2170
2186
 
2171
2187
  function opSchemas(targetSchema) {
2172
2188
  return [ v__namespace.strictObject({
@@ -2204,11 +2220,11 @@ function opSchemas(targetSchema) {
2204
2220
  }) ];
2205
2221
  }
2206
2222
 
2207
- const StoredFieldOpSchema = v__namespace.variant("type", [ ...opSchemas(StoredFieldRefSchema) ]), StoredOpSchema = v__namespace.variant("type", [ ...opSchemas(StoredFieldRefSchema), v__namespace.strictObject({
2223
+ const StoredFieldOpSchema = pinned()(v__namespace.variant("type", [ ...opSchemas(StoredFieldRefSchema) ])), StoredOpSchema = pinned()(v__namespace.variant("type", [ ...opSchemas(StoredFieldRefSchema), v__namespace.strictObject({
2208
2224
  type: v__namespace.literal("status.set"),
2209
2225
  activity: NonEmpty,
2210
2226
  status: picklist(ACTIVITY_STATUSES)
2211
- }) ]), AuditOpSchema = v__namespace.strictObject({
2227
+ }) ])), AuditOpSchema = v__namespace.strictObject({
2212
2228
  type: v__namespace.literal("audit"),
2213
2229
  target: AuthoringFieldRefSchema,
2214
2230
  value: ValueExprSchema,
@@ -2216,11 +2232,11 @@ const StoredFieldOpSchema = v__namespace.variant("type", [ ...opSchemas(StoredFi
2216
2232
  actor: v__namespace.optional(NonEmpty),
2217
2233
  at: v__namespace.optional(NonEmpty)
2218
2234
  }))
2219
- }), AuthoringOpSchema = v__namespace.variant("type", [ ...opSchemas(AuthoringFieldRefSchema), v__namespace.strictObject({
2235
+ }), AuthoringOpSchema = pinned()(v__namespace.variant("type", [ ...opSchemas(AuthoringFieldRefSchema), v__namespace.strictObject({
2220
2236
  type: v__namespace.literal("status.set"),
2221
2237
  activity: v__namespace.optional(NonEmpty),
2222
2238
  status: picklist(ACTIVITY_STATUSES)
2223
- }), AuditOpSchema ]), GroupName = v__namespace.pipe(v__namespace.string(), v__namespace.regex(GROQ_IDENTIFIER, "must be an identifier (letters, digits, underscore; not starting with a digit)")), GroupSchema = pinned()(v__namespace.strictObject({
2239
+ }), AuditOpSchema ])), GroupName = v__namespace.pipe(v__namespace.string(), v__namespace.regex(GROQ_IDENTIFIER, "must be an identifier (letters, digits, underscore; not starting with a digit)")), GroupSchema = pinned()(v__namespace.strictObject({
2224
2240
  name: GroupName,
2225
2241
  title: v__namespace.optional(v__namespace.string()),
2226
2242
  description: v__namespace.optional(v__namespace.string()),
@@ -2231,7 +2247,7 @@ function groupMembershipNames(group) {
2231
2247
  return group === void 0 ? [] : typeof group == "string" ? [ group ] : [ ...group ];
2232
2248
  }
2233
2249
 
2234
- const FIELD_VALUE_KINDS = [ "doc.ref", "doc.refs", "subject", "release.ref", "string", "text", "number", "progress", "boolean", "date", "dueDate", "datetime", "dueDatetime", "url", "actor", "assignee", "assignees", "object", "array" ], FieldValueKindSchema = picklist(FIELD_VALUE_KINDS), FieldKindSchema = picklist(FIELD_VALUE_KINDS), AUTHORING_FIELD_SUGAR_KINDS = exhaustiveOptions()([ "claim", "todoList", "notes" ]), AUTHORING_FIELD_KINDS = [ ...FIELD_VALUE_KINDS, ...AUTHORING_FIELD_SUGAR_KINDS ], AuthoringRawFieldKindSchema = v__namespace.picklist(FIELD_VALUE_KINDS, issue => `${invalidOptionMessage(AUTHORING_FIELD_KINDS)} but received ${JSON.stringify(issue.input)}`), FieldEntryName = groqIdentifier("`$fields.<name>`"), FiniteNumber = v__namespace.pipe(v__namespace.number(), v__namespace.finite("must be finite")), ScalarValidationSchema = v__namespace.pipe(v__namespace.strictObject({
2250
+ const FIELD_VALUE_KINDS = [ "doc.ref", "doc.refs", "subject", "release.ref", "string", "text", "number", "progress", "boolean", "date", "dueDate", "datetime", "dueDatetime", "url", "actor", "assignee", "assignees", "object", "array" ], FieldValueKindSchema = picklist(FIELD_VALUE_KINDS), FieldKindSchema = picklist(FIELD_VALUE_KINDS), AUTHORING_FIELD_SUGAR_KINDS = groqConditionDescribe._exhaustiveOptions()([ "todoList", "notes" ]), AUTHORING_FIELD_KINDS = [ ...FIELD_VALUE_KINDS, ...AUTHORING_FIELD_SUGAR_KINDS ], AuthoringRawFieldKindSchema = v__namespace.picklist(FIELD_VALUE_KINDS, issue => `${invalidOptionMessage(AUTHORING_FIELD_KINDS)} but received ${JSON.stringify(issue.input)}`), FieldEntryName = groqIdentifier("`$fields.<name>`"), FiniteNumber = v__namespace.pipe(v__namespace.number(), v__namespace.finite("must be finite")), ScalarValidationSchema = v__namespace.pipe(v__namespace.strictObject({
2235
2251
  min: v__namespace.optional(FiniteNumber),
2236
2252
  max: v__namespace.optional(FiniteNumber)
2237
2253
  }), v__namespace.check(validation => validation.min !== void 0 || validation.max !== void 0, "declare at least one bound, or omit `validation`"), v__namespace.check(validation => validation.min === void 0 || validation.max === void 0 || validation.min <= validation.max, "`min` must be less than or equal to `max`")), ChoiceOptionsSchema = v__namespace.strictObject({
@@ -2283,7 +2299,7 @@ const AssignmentRolesSchema = v__namespace.pipe(v__namespace.array(NonEmpty), v_
2283
2299
  roles: v__namespace.optional(AssignmentRolesSchema),
2284
2300
  fields: v__namespace.optional(v__namespace.array(FieldShapeSchema)),
2285
2301
  of: v__namespace.optional(v__namespace.array(FieldShapeSchema))
2286
- }), choiceOptionsCheck(), scalarValidationCheck(), assignmentRolesCheck())), StoredEditableSchema = v__namespace.union([ v__namespace.literal(!0), NonEmpty ]), AuthoringEditableSchema = v__namespace.union([ v__namespace.literal(!0), v__namespace.array(NonEmpty), NonEmpty ]);
2302
+ }), choiceOptionsCheck(), scalarValidationCheck(), assignmentRolesCheck())), StoredEditableSchema = pinned()(v__namespace.union([ v__namespace.literal(!0), NonEmpty ])), AuthoringEditableSchema = pinned()(v__namespace.union([ v__namespace.literal(!0), v__namespace.array(NonEmpty), NonEmpty ]));
2287
2303
 
2288
2304
  function fieldBase(editable, group) {
2289
2305
  return {
@@ -2373,13 +2389,7 @@ const FieldEntrySchema = pinned()(v__namespace.pipe(compositeChecked(fieldEntryF
2373
2389
  editable: AuthoringEditableSchema,
2374
2390
  group: AuthoringGroupMembershipSchema,
2375
2391
  kind: AuthoringRawFieldKindSchema
2376
- })), refTypesCheck(), assignmentRolesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), ClaimFieldSchema = pinned()(v__namespace.strictObject({
2377
- type: v__namespace.literal("claim"),
2378
- name: FieldEntryName,
2379
- title: v__namespace.optional(v__namespace.string()),
2380
- description: v__namespace.optional(v__namespace.string()),
2381
- group: v__namespace.optional(AuthoringGroupMembershipSchema)
2382
- }));
2392
+ })), refTypesCheck(), assignmentRolesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck()));
2383
2393
 
2384
2394
  function listSugarFields(type) {
2385
2395
  return {
@@ -2390,7 +2400,7 @@ function listSugarFields(type) {
2390
2400
 
2391
2401
  const TodoListFieldSchema = pinned()(v__namespace.strictObject(listSugarFields("todoList"))), NotesFieldSchema = pinned()(v__namespace.strictObject(listSugarFields("notes"))), AuthoringFieldEntrySchema = pinned()(v__namespace.lazy(input => {
2392
2402
  const type = asShape(input).type;
2393
- return type === "claim" ? ClaimFieldSchema : type === "todoList" ? TodoListFieldSchema : type === "notes" ? NotesFieldSchema : RawAuthoringFieldEntrySchema;
2403
+ return type === "todoList" ? TodoListFieldSchema : type === "notes" ? NotesFieldSchema : RawAuthoringFieldEntrySchema;
2394
2404
  })), EffectSchema = v__namespace.strictObject({
2395
2405
  name: NonEmpty,
2396
2406
  title: v__namespace.optional(v__namespace.string()),
@@ -2455,18 +2465,7 @@ const StoredActionSchema = pinned()(v__namespace.strictObject({
2455
2465
  ...actionFields(AuthoringOpSchema, AuthoringGroupMembershipSchema),
2456
2466
  roles: v__namespace.optional(v__namespace.array(NonEmpty)),
2457
2467
  status: v__namespace.optional(TerminalActivityStatus)
2458
- })), ClaimActionSchema = pinned()(v__namespace.strictObject({
2459
- type: v__namespace.literal("claim"),
2460
- name: NonEmpty,
2461
- title: v__namespace.optional(v__namespace.string()),
2462
- description: v__namespace.optional(v__namespace.string()),
2463
- group: v__namespace.optional(AuthoringGroupMembershipSchema),
2464
- field: v__namespace.union([ NonEmpty, AuthoringFieldRefSchema ]),
2465
- roles: v__namespace.optional(v__namespace.array(NonEmpty)),
2466
- filter: v__namespace.optional(ConditionSchema),
2467
- params: v__namespace.optional(v__namespace.array(ActionParamSchema)),
2468
- effects: v__namespace.optional(v__namespace.array(EffectSchema))
2469
- })), AuthoringActionSchema = pinned()(v__namespace.lazy(input => typeof input == "object" && input !== null && "type" in input ? ClaimActionSchema : RawAuthoringActionSchema)), requirementBase = {
2468
+ })), AuthoringActionSchema = pinned()(RawAuthoringActionSchema), requirementBase = {
2470
2469
  name: NonEmpty,
2471
2470
  title: v__namespace.optional(v__namespace.string()),
2472
2471
  description: v__namespace.optional(v__namespace.string())
@@ -2517,7 +2516,7 @@ function transitionFields(when) {
2517
2516
  };
2518
2517
  }
2519
2518
 
2520
- const StoredTransitionSchema = pinned()(v__namespace.strictObject(transitionFields(ConditionSchema))), AuthoringTransitionSchema = pinned()(v__namespace.strictObject(transitionFields(v__namespace.optional(ConditionSchema)))), GuardActionSchema = picklist(MUTATION_GUARD_ACTIONS), GuardReadPath = v__namespace.pipe(NonEmpty, v__namespace.check(path => !/[\r\n\u2028\u2029]/.test(path), "a guard read path cannot contain a line break")), GuardReadSchema = v__namespace.variant("type", [ v__namespace.strictObject({
2519
+ const StoredTransitionSchema = pinned()(v__namespace.strictObject(transitionFields(ConditionSchema))), AuthoringTransitionSchema = pinned()(v__namespace.strictObject(transitionFields(v__namespace.optional(ConditionSchema)))), GuardActionSchema = picklist(MUTATION_GUARD_ACTIONS), GuardActionsSchema = v__namespace.array(GuardActionSchema), NonEmptyGuardActionsSchema = v__namespace.pipe(GuardActionsSchema, v__namespace.minLength(1, GUARD_ACTIONS_REQUIRED_MESSAGE)), GuardReadPath = v__namespace.pipe(NonEmpty, v__namespace.check(path => !/[\r\n\u2028\u2029]/.test(path), "a guard read path cannot contain a line break")), GuardReadSchema = pinned()(v__namespace.variant("type", [ v__namespace.strictObject({
2521
2520
  type: v__namespace.literal("self")
2522
2521
  }), v__namespace.strictObject({
2523
2522
  type: v__namespace.literal("now")
@@ -2529,29 +2528,29 @@ const StoredTransitionSchema = pinned()(v__namespace.strictObject(transitionFiel
2529
2528
  type: v__namespace.literal("effectsRead"),
2530
2529
  effect: v__namespace.pipe(NonEmpty, v__namespace.check(name => !name.includes("'"), "an effect name cannot contain `'`")),
2531
2530
  path: v__namespace.optional(GuardReadPath)
2532
- }) ]);
2531
+ }) ]));
2533
2532
 
2534
- function guardMatchFields(read) {
2533
+ function guardMatchFields(read, actions) {
2535
2534
  return {
2536
2535
  types: v__namespace.optional(v__namespace.array(NonEmpty)),
2537
2536
  idRefs: v__namespace.optional(v__namespace.array(read)),
2538
2537
  idPatterns: v__namespace.optional(v__namespace.array(NonEmpty)),
2539
- actions: v__namespace.pipe(v__namespace.array(GuardActionSchema), v__namespace.minLength(1, "a guard must match at least one action"))
2538
+ actions: actions
2540
2539
  };
2541
2540
  }
2542
2541
 
2543
- function guardFields(read) {
2542
+ function guardFields(read, actions) {
2544
2543
  return {
2545
2544
  name: NonEmpty,
2546
2545
  title: v__namespace.optional(v__namespace.string()),
2547
2546
  description: v__namespace.optional(v__namespace.string()),
2548
- match: v__namespace.strictObject(guardMatchFields(read)),
2547
+ match: v__namespace.strictObject(guardMatchFields(read, actions)),
2549
2548
  predicate: v__namespace.optional(v__namespace.string()),
2550
2549
  metadata: v__namespace.optional(v__namespace.record(NonEmpty, read))
2551
2550
  };
2552
2551
  }
2553
2552
 
2554
- const GuardSchema = v__namespace.strictObject(guardFields(NonEmpty)), AuthoringGuardSchema = v__namespace.strictObject(guardFields(GuardReadSchema));
2553
+ const GuardSchema = v__namespace.strictObject(guardFields(NonEmpty, GuardActionsSchema)), AuthoringGuardSchema = v__namespace.strictObject(guardFields(GuardReadSchema, NonEmptyGuardActionsSchema));
2555
2554
 
2556
2555
  function stageFields({field: field, activity: activity, transition: transition, guard: guard, editable: editable}) {
2557
2556
  return {
@@ -2580,7 +2579,7 @@ const StoredStageSchema = pinned()(v__namespace.strictObject(stageFields({
2580
2579
  transition: AuthoringTransitionSchema,
2581
2580
  guard: AuthoringGuardSchema,
2582
2581
  editable: AuthoringEditableSchema
2583
- }))), RoleAliasesSchema = v__namespace.record(NonEmpty, v__namespace.pipe(v__namespace.array(NonEmpty), v__namespace.minLength(1, "a role alias must list at least one fulfilling role"))), WORKFLOW_LIFECYCLES = [ "standalone", "child" ], START_KINDS = [ "interactive", "autonomous" ];
2582
+ }))), RoleAliasesSchema = pinned()(v__namespace.record(NonEmpty, v__namespace.pipe(v__namespace.array(NonEmpty), v__namespace.minLength(1, "a role alias must list at least one fulfilling role")))), WORKFLOW_LIFECYCLES = groqConditionDescribe._exhaustiveOptions()([ "standalone", "child" ]), START_KINDS = groqConditionDescribe._exhaustiveOptions()([ "interactive", "autonomous" ]);
2584
2583
 
2585
2584
  function startFields(kind) {
2586
2585
  return {
@@ -4097,6 +4096,8 @@ exports.FieldValueShapeError = FieldValueShapeError;
4097
4096
 
4098
4097
  exports.GROUP_KINDS = GROUP_KINDS;
4099
4098
 
4099
+ exports.GUARD_ACTIONS_REQUIRED_MESSAGE = GUARD_ACTIONS_REQUIRED_MESSAGE;
4100
+
4100
4101
  exports.GUARD_PREDICATE_VARS = GUARD_PREDICATE_VARS;
4101
4102
 
4102
4103
  exports.GdrShape = GdrShape;
@@ -4107,8 +4108,12 @@ exports.InstanceNotFoundError = InstanceNotFoundError;
4107
4108
 
4108
4109
  exports.IsoTimestamp = IsoTimestamp;
4109
4110
 
4111
+ exports.LAKE_MUTATION_GUARD_ACTIONS = LAKE_MUTATION_GUARD_ACTIONS;
4112
+
4110
4113
  exports.MUTATION_GUARD_ACTIONS = MUTATION_GUARD_ACTIONS;
4111
4114
 
4115
+ exports.MUTATION_GUARD_ID_SPACES = MUTATION_GUARD_ID_SPACES;
4116
+
4112
4117
  exports.NonEmptyString = NonEmptyString;
4113
4118
 
4114
4119
  exports.PersistedDocShapeError = PersistedDocShapeError;
@@ -4129,6 +4134,8 @@ exports.SpawnContractsInvalidError = SpawnContractsInvalidError;
4129
4134
 
4130
4135
  exports.StoredFieldOpSchema = StoredFieldOpSchema;
4131
4136
 
4137
+ exports.UNIVERSAL_ROLE_ALIAS_KEY = UNIVERSAL_ROLE_ALIAS_KEY;
4138
+
4132
4139
  exports.VersionSpecificDatasetGdrError = VersionSpecificDatasetGdrError;
4133
4140
 
4134
4141
  exports.WORKFLOW_DEFINITION_TYPE = WORKFLOW_DEFINITION_TYPE;
@@ -4137,12 +4144,24 @@ exports.WorkflowConfigSchema = WorkflowConfigSchema;
4137
4144
 
4138
4145
  exports.WorkflowError = WorkflowError;
4139
4146
 
4147
+ exports.activeAssignmentMembers = activeAssignmentMembers;
4148
+
4140
4149
  exports.actorFulfillsRole = actorFulfillsRole;
4141
4150
 
4151
+ exports.actorMatchesAssignment = actorMatchesAssignment;
4152
+
4142
4153
  exports.andConditions = andConditions;
4143
4154
 
4144
4155
  exports.assignmentKindAcceptsRoles = assignmentKindAcceptsRoles;
4145
4156
 
4157
+ exports.assignmentMatch = assignmentMatch;
4158
+
4159
+ exports.assignmentMembers = assignmentMembers;
4160
+
4161
+ exports.assignmentState = assignmentState;
4162
+
4163
+ exports.assignmentStateCounts = assignmentStateCounts;
4164
+
4146
4165
  exports.checkWorkflowInvariants = checkWorkflowInvariants;
4147
4166
 
4148
4167
  exports.choiceValueIssues = choiceValueIssues;
@@ -4151,6 +4170,10 @@ exports.classifyPrincipalId = classifyPrincipalId;
4151
4170
 
4152
4171
  exports.clientConfigFromResource = clientConfigFromResource;
4153
4172
 
4173
+ exports.condemnSubworkflow = condemnSubworkflow;
4174
+
4175
+ exports.condemnedSubworkflows = condemnedSubworkflows;
4176
+
4154
4177
  exports.conditionEffectReads = conditionEffectReads;
4155
4178
 
4156
4179
  exports.conditionFieldReadNames = conditionFieldReadNames;
@@ -4185,6 +4208,10 @@ exports.extractDocumentId = extractDocumentId;
4185
4208
 
4186
4209
  exports.fieldValueSchemas = fieldValueSchemas;
4187
4210
 
4211
+ exports.findCurrentActivityEntry = findCurrentActivityEntry;
4212
+
4213
+ exports.findOpenStageEntry = findOpenStageEntry;
4214
+
4188
4215
  exports.firstCarriedGlobalId = firstCarriedGlobalId;
4189
4216
 
4190
4217
  exports.formatIssuePath = formatIssuePath;
@@ -4205,14 +4232,22 @@ exports.groq = groq;
4205
4232
 
4206
4233
  exports.groupMembershipNames = groupMembershipNames;
4207
4234
 
4235
+ exports.identityMatchesAssignment = identityMatchesAssignment;
4236
+
4237
+ exports.instanceAssignmentStateCounts = instanceAssignmentStateCounts;
4238
+
4208
4239
  exports.isAlwaysArrayFieldKind = isAlwaysArrayFieldKind;
4209
4240
 
4210
4241
  exports.isAssignmentFieldEntry = isAssignmentFieldEntry;
4211
4242
 
4243
+ exports.isBareDocumentId = isBareDocumentId;
4244
+
4212
4245
  exports.isBareSeedId = isBareSeedId;
4213
4246
 
4214
4247
  exports.isCascadeFired = isCascadeFired;
4215
4248
 
4249
+ exports.isFilterScopedOut = isFilterScopedOut;
4250
+
4216
4251
  exports.isGdr = isGdr;
4217
4252
 
4218
4253
  exports.isGdrUri = isGdrUri;
@@ -4247,6 +4282,16 @@ exports.labelFor = labelFor;
4247
4282
 
4248
4283
  exports.lakePrincipalId = lakePrincipalId;
4249
4284
 
4285
+ exports.liveSubworkflows = liveSubworkflows;
4286
+
4287
+ exports.mutationGuardActionIdSpace = mutationGuardActionIdSpace;
4288
+
4289
+ exports.mutationGuardRequiresSplitEmission = mutationGuardRequiresSplitEmission;
4290
+
4291
+ exports.normalizeAssignmentMembers = normalizeAssignmentMembers;
4292
+
4293
+ exports.openActivityAssignments = openActivityAssignments;
4294
+
4250
4295
  exports.parseFieldValue = parseFieldValue;
4251
4296
 
4252
4297
  exports.parseGdr = parseGdr;
@@ -4279,6 +4324,8 @@ exports.releaseDocId = releaseDocId;
4279
4324
 
4280
4325
  exports.releaseRef = releaseRef;
4281
4326
 
4327
+ exports.resolvedChildStatus = resolvedChildStatus;
4328
+
4282
4329
  exports.resourceAliasesToMap = resourceAliasesToMap;
4283
4330
 
4284
4331
  exports.resourceFromGdrUri = resourceFromGdrUri;