@sanity/workflow-engine 0.19.0 → 0.20.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 CHANGED
@@ -1,5 +1,108 @@
1
1
  # @sanity/workflow-engine
2
2
 
3
+ ## 0.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ab5e454: Export project-user response validation for host adapters that consume Sanity project-user APIs.
8
+ - e3122cc: New `instancesGuardQuery(instanceIds)` — the set-shaped guard filter (`sourceInstanceId in $instanceIds`, ordered by `_id`) reactive adapters subscribe as one shared live query per resource for every co-mounted session. `instanceGuardQuery(id)` delegates to it, so the per-instance and per-set reads share one filter definition; its compiled query string changes accordingly (same rows selected).
9
+ - 7c4dd86: Reduce guard lifecycle request volume and chunk orphan cleanup transactions.
10
+
11
+ ### Patch Changes
12
+
13
+ - bce09fc: Restore automatic effect request tags while preserving concrete handler client APIs, backed by native request-prefix support in the test client.
14
+ - efb4cd9: Discriminator validation now reports an unknown field kind, field source, or op value expression at its exact `type` path instead of collapsing to "Invalid type: Expected Object but received Object". The schemas route on `type` rather than trying indistinguishable object arms in a plain union, so newer syntax used with an older engine identifies the unsupported value and the installed engine's valid options.
15
+ - 46b0285: **BREAKING:** Replace manually declared document applicability with automatic
16
+ discovery from deployed first-class subject fields.
17
+
18
+ Update Studio configuration as follows:
19
+ - `mappings` is optional. Omit it when every applicable definition declares a
20
+ first-class subject. A mapping may customize an automatically discovered
21
+ `(docType, definition)` binding or explicitly register a definition modeled
22
+ with a plain `doc.ref` instead of a first-class subject.
23
+ - Multiple workflows may target one document type. Use one mapping row for each
24
+ distinct `(docType, definition)` pair. An exact duplicate pair is a
25
+ configuration error rather than a last-row-wins override.
26
+ - Remove the top-level `autoStart` map or function. Put `autoStart: true` on
27
+ each mapping row that should start automatically. Configure workspace-specific
28
+ behavior in that workspace's mapping rows. This also works for explicitly
29
+ registered definitions using the `doc.ref` field named `subject` convention.
30
+ - Replace `workflowDefaultDocumentNode({mappings})` with
31
+ `workflowDefaultDocumentNode()`.
32
+
33
+ Before:
34
+
35
+ ```ts
36
+ structureTool({defaultDocumentNode: workflowDefaultDocumentNode({mappings})})
37
+ workflowStudioPlugin({
38
+ tag: 'production',
39
+ mappings,
40
+ autoStart: {article: ['article-review', 'legal-review']},
41
+ })
42
+ ```
43
+
44
+ After:
45
+
46
+ ```ts
47
+ structureTool({defaultDocumentNode: workflowDefaultDocumentNode()})
48
+ workflowStudioPlugin({
49
+ tag: 'production',
50
+ mappings: [
51
+ {
52
+ docType: 'article',
53
+ definition: 'article-review',
54
+ label: 'Article review',
55
+ autoStart: true,
56
+ },
57
+ {
58
+ docType: 'article',
59
+ definition: 'legal-review',
60
+ label: 'Legal review',
61
+ autoStart: true,
62
+ },
63
+ ],
64
+ })
65
+ ```
66
+
67
+ Also remove all per-schema Editorial Workflows preview wiring:
68
+ - Remove `components: {preview: WorkflowStagePreview}`.
69
+ - Remove `_id` added only for Editorial Workflows from `preview.select` and
70
+ stop passing it through `preview.prepare`.
71
+ - Remove imports of `WorkflowStagePreview`; that component is no longer a
72
+ public package export.
73
+ - Remove imports of `mappingForDocType` and `workflowDocTypes`; effective
74
+ mappings are resolved inside the plugin and those host-side helpers are no
75
+ longer exported.
76
+ - Keep each schema's native inferred or custom preview unchanged. The plugin
77
+ now installs preview middleware itself, consumes the document identity Studio
78
+ already supplies, and delegates title, subtitle, media, and custom preview
79
+ composition through `renderDefault`.
80
+
81
+ Workflow stage pills appear on Studio surfaces that invoke preview middleware,
82
+ including reference and array-item previews. Custom preview components that
83
+ replace Studio's layout must render the `status` prop they receive. Studio's
84
+ Structure document-list rows bypass both plugin and schema preview middleware,
85
+ so they do not show workflow stage pills. Workflow status remains available in
86
+ the document form, footer badge, Workflows view, and Workflows tool.
87
+
88
+ Document-reference GDRs for dataset content now reject stored draft IDs
89
+ (`drafts.<id>`) and Content Release version IDs
90
+ (`versions.<release>.<id>`). Use the stable document ID in the GDR and select
91
+ the draft or release through workflow perspective instead. The validation error
92
+ includes the corresponding stable ID so CLI and API callers can correct the
93
+ input before an unresolvable workflow instance is created.
94
+
95
+ Previously persisted draft/version GDRs remain invalid workflow identities.
96
+ Read-side Studio displays now tolerate them by showing the raw URI instead of
97
+ crashing, and query-sourced occurrences are discarded through the existing
98
+ fail-soft field-resolution path. Correct existing data by starting a new
99
+ instance with the stable document ID; perspective selects the desired draft or
100
+ release content.
101
+
102
+ - 8a76c67: Add incremental reactive-session document feeds, coalesce watched-document emissions, and reuse discovery derivations and Studio layout output. Deleted watched documents now leave the held snapshot instead of remaining as stale evaluation input. The component test runner also has aggregate-suite timeout headroom.
103
+ - 7e8f459: Batch snapshot hydration to reduce watched-document read latency.
104
+ - 98e488e: Stabilize Editorial Workflows discovery subscriptions and limit full reactive sessions to surfaces that need live evaluation.
105
+
3
106
  ## 0.19.0
4
107
 
5
108
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var v = require("valibot"), groqConditionDescribe = require("@sanity/groq-condition-describe"), groqJs = require("groq-js");
3
+ var v = require("valibot"), groqConditionDescribe = require("@sanity/groq-condition-describe"), groqJs = require("groq-js"), idUtils = require("@sanity/id-utils");
4
4
 
5
5
  function _interopNamespaceCompat(e) {
6
6
  if (e && typeof e == "object" && "default" in e) return e;
@@ -358,6 +358,21 @@ function andConditions(parts) {
358
358
 
359
359
  const KNOWN_SCHEMES = /* @__PURE__ */ new Set([ "dataset", "canvas", "media-library", "dashboard" ]), KNOWN_SCHEMES_TEXT = [ ...KNOWN_SCHEMES ].join(", ");
360
360
 
361
+ class VersionSpecificDatasetGdrError extends Error {
362
+ documentId;
363
+ stableDocumentId;
364
+ constructor(documentId, uri) {
365
+ const stableDocumentId = idUtils.getPublishedId(documentId);
366
+ super(`Invalid GDR "${uri}": dataset document ID "${documentId}" identifies a stored draft or release version. Use the stable document ID "${stableDocumentId}" and select drafts/releases through the workflow perspective.`),
367
+ this.name = "VersionSpecificDatasetGdrError", this.documentId = documentId, this.stableDocumentId = stableDocumentId;
368
+ }
369
+ }
370
+
371
+ function assertStableDatasetDocumentId(documentId, uri) {
372
+ const sanityId = documentId;
373
+ if (!(!idUtils.isDraftId(sanityId) && !idUtils.isVersionId(sanityId))) throw new VersionSpecificDatasetGdrError(documentId, uri);
374
+ }
375
+
361
376
  function parseGdr(uri) {
362
377
  const colon = uri.indexOf(":");
363
378
  if (colon < 0) throw new Error(`Invalid GDR "${uri}": must be a URI of form "<scheme>:<...id-parts>". Known schemes: ${KNOWN_SCHEMES_TEXT}.`);
@@ -367,11 +382,12 @@ function parseGdr(uri) {
367
382
  if (parts.some(part => part.length === 0)) throw new Error(`Invalid GDR "${uri}": id parts must be non-empty (no leading, trailing, or doubled ":").`);
368
383
  if (scheme === "dataset") {
369
384
  if (parts.length !== 3) throw new Error(`Invalid GDR "${uri}": dataset scheme requires <projectId>:<dataset>:<documentId> (3 parts after scheme); got ${parts.length}.`);
370
- return {
385
+ const documentId = parts[2];
386
+ return assertStableDatasetDocumentId(documentId, uri), {
371
387
  scheme: "dataset",
372
388
  projectId: parts[0],
373
389
  dataset: parts[1],
374
- documentId: parts[2]
390
+ documentId: documentId
375
391
  };
376
392
  }
377
393
  if (parts.length !== 2) throw new Error(`Invalid GDR "${uri}": ${scheme} scheme requires <resourceId>:<documentId> (2 parts after scheme); got ${parts.length}.`);
@@ -391,7 +407,11 @@ function tryParseGdr(uri) {
391
407
  }
392
408
 
393
409
  function gdrUri(parts) {
394
- return parts.scheme === "dataset" ? `dataset:${parts.projectId}:${parts.dataset}:${parts.documentId}` : `${parts.scheme}:${parts.resourceId}:${parts.documentId}`;
410
+ if (parts.scheme === "dataset") {
411
+ const uri = `dataset:${parts.projectId}:${parts.dataset}:${parts.documentId}`;
412
+ return assertStableDatasetDocumentId(parts.documentId, uri), uri;
413
+ }
414
+ return `${parts.scheme}:${parts.resourceId}:${parts.documentId}`;
395
415
  }
396
416
 
397
417
  function extractDocumentId(gdrUriString) {
@@ -2029,7 +2049,15 @@ function groqIdentifier(referencedAs) {
2029
2049
  }
2030
2050
 
2031
2051
  function picklist(options) {
2032
- return v__namespace.picklist(options, `Invalid option: expected one of ${options.map(o => `"${o}"`).join("|")}`);
2052
+ return v__namespace.picklist(options, invalidOptionMessage(options));
2053
+ }
2054
+
2055
+ function invalidOptionMessage(options) {
2056
+ return `Invalid option: expected one of ${options.map(option => `"${option}"`).join("|")}`;
2057
+ }
2058
+
2059
+ function exhaustiveOptions() {
2060
+ return options => options;
2033
2061
  }
2034
2062
 
2035
2063
  function pinned() {
@@ -2044,12 +2072,12 @@ const LiteralSchema = v__namespace.strictObject({
2044
2072
  scope: v__namespace.optional(v__namespace.union([ v__namespace.literal("workflow"), v__namespace.literal("stage") ])),
2045
2073
  field: NonEmpty,
2046
2074
  path: v__namespace.optional(v__namespace.string())
2047
- }), FieldSourceSchema = v__namespace.union([ v__namespace.strictObject({
2075
+ }), FieldSourceSchema = v__namespace.variant("type", [ v__namespace.strictObject({
2048
2076
  type: v__namespace.literal("input")
2049
2077
  }), v__namespace.strictObject({
2050
2078
  type: v__namespace.literal("query"),
2051
2079
  query: NonEmpty
2052
- }), LiteralSchema, FieldReadSchema ]), ValueExprSchema = v__namespace.lazy(() => v__namespace.union([ LiteralSchema, FieldReadSchema, v__namespace.strictObject({
2080
+ }), LiteralSchema, FieldReadSchema ]), ValueExprSchema = v__namespace.lazy(() => v__namespace.variant("type", [ LiteralSchema, FieldReadSchema, v__namespace.strictObject({
2053
2081
  type: v__namespace.literal("param"),
2054
2082
  param: NonEmpty
2055
2083
  }), v__namespace.strictObject({
@@ -2144,7 +2172,7 @@ function groupMembershipNames(group) {
2144
2172
  return group === void 0 ? [] : typeof group == "string" ? [ group ] : [ ...group ];
2145
2173
  }
2146
2174
 
2147
- const FIELD_VALUE_KINDS = [ "doc.ref", "doc.refs", "subject", "release.ref", "string", "text", "number", "progress", "boolean", "date", "datetime", "url", "actor", "assignee", "assignees", "object", "array" ], FieldValueKindSchema = picklist(FIELD_VALUE_KINDS), FieldKindSchema = picklist(FIELD_VALUE_KINDS), FieldEntryName = groqIdentifier("`$fields.<name>`"), FiniteNumber = v__namespace.pipe(v__namespace.number(), v__namespace.finite("must be finite")), ScalarValidationSchema = v__namespace.pipe(v__namespace.strictObject({
2175
+ const FIELD_VALUE_KINDS = [ "doc.ref", "doc.refs", "subject", "release.ref", "string", "text", "number", "progress", "boolean", "date", "datetime", "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({
2148
2176
  min: v__namespace.optional(FiniteNumber),
2149
2177
  max: v__namespace.optional(FiniteNumber)
2150
2178
  }), 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({
@@ -2209,9 +2237,9 @@ function fieldBase(editable, group) {
2209
2237
  };
2210
2238
  }
2211
2239
 
2212
- function fieldEntryFields(editable, group) {
2240
+ function fieldEntryFields({editable: editable, group: group, kind: kind = FieldKindSchema}) {
2213
2241
  return {
2214
- type: FieldKindSchema,
2242
+ type: kind,
2215
2243
  ...fieldBase(editable, group),
2216
2244
  options: v__namespace.optional(ChoiceOptionsSchema),
2217
2245
  validation: v__namespace.optional(ScalarValidationSchema),
@@ -2272,7 +2300,14 @@ function scalarValidationDeclarationIssues(entry) {
2272
2300
  return issues.length === 0 ? void 0 : issues;
2273
2301
  }
2274
2302
 
2275
- const FieldEntrySchema = pinned()(v__namespace.pipe(compositeChecked(fieldEntryFields(StoredEditableSchema, StoredGroupMembershipSchema)), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), RawAuthoringFieldEntrySchema = pinned()(v__namespace.pipe(compositeChecked(fieldEntryFields(AuthoringEditableSchema, AuthoringGroupMembershipSchema)), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), ClaimFieldSchema = pinned()(v__namespace.strictObject({
2303
+ const FieldEntrySchema = pinned()(v__namespace.pipe(compositeChecked(fieldEntryFields({
2304
+ editable: StoredEditableSchema,
2305
+ group: StoredGroupMembershipSchema
2306
+ })), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), RawAuthoringFieldEntrySchema = pinned()(v__namespace.pipe(compositeChecked(fieldEntryFields({
2307
+ editable: AuthoringEditableSchema,
2308
+ group: AuthoringGroupMembershipSchema,
2309
+ kind: AuthoringRawFieldKindSchema
2310
+ })), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), ClaimFieldSchema = pinned()(v__namespace.strictObject({
2276
2311
  type: v__namespace.literal("claim"),
2277
2312
  name: FieldEntryName,
2278
2313
  title: v__namespace.optional(v__namespace.string()),
@@ -2287,7 +2322,10 @@ function listSugarFields(type) {
2287
2322
  };
2288
2323
  }
2289
2324
 
2290
- const TodoListFieldSchema = pinned()(v__namespace.strictObject(listSugarFields("todoList"))), NotesFieldSchema = pinned()(v__namespace.strictObject(listSugarFields("notes"))), AuthoringFieldEntrySchema = pinned()(v__namespace.union([ RawAuthoringFieldEntrySchema, ClaimFieldSchema, TodoListFieldSchema, NotesFieldSchema ])), EffectSchema = v__namespace.strictObject({
2325
+ const TodoListFieldSchema = pinned()(v__namespace.strictObject(listSugarFields("todoList"))), NotesFieldSchema = pinned()(v__namespace.strictObject(listSugarFields("notes"))), AuthoringFieldEntrySchema = pinned()(v__namespace.lazy(input => {
2326
+ const type = asShape(input).type;
2327
+ return type === "claim" ? ClaimFieldSchema : type === "todoList" ? TodoListFieldSchema : type === "notes" ? NotesFieldSchema : RawAuthoringFieldEntrySchema;
2328
+ })), EffectSchema = v__namespace.strictObject({
2291
2329
  name: NonEmpty,
2292
2330
  title: v__namespace.optional(v__namespace.string()),
2293
2331
  description: v__namespace.optional(v__namespace.string()),
@@ -3881,6 +3919,8 @@ exports.SpawnContractsInvalidError = SpawnContractsInvalidError;
3881
3919
 
3882
3920
  exports.StoredFieldOpSchema = StoredFieldOpSchema;
3883
3921
 
3922
+ exports.VersionSpecificDatasetGdrError = VersionSpecificDatasetGdrError;
3923
+
3884
3924
  exports.WORKFLOW_DEFINITION_TYPE = WORKFLOW_DEFINITION_TYPE;
3885
3925
 
3886
3926
  exports.WORKFLOW_INSTANCE_TYPE = WORKFLOW_INSTANCE_TYPE;
@@ -4,6 +4,8 @@ import { conditionOutcome, runGroq as runGroq$1, evaluateConditionOutcome as eva
4
4
 
5
5
  import { parse } from "groq-js";
6
6
 
7
+ import { isDraftId, isVersionId, getPublishedId } from "@sanity/id-utils";
8
+
7
9
  class WorkflowError extends Error {
8
10
  kind;
9
11
  constructor(kind, message, options) {
@@ -342,6 +344,21 @@ function andConditions(parts) {
342
344
 
343
345
  const KNOWN_SCHEMES = /* @__PURE__ */ new Set([ "dataset", "canvas", "media-library", "dashboard" ]), KNOWN_SCHEMES_TEXT = [ ...KNOWN_SCHEMES ].join(", ");
344
346
 
347
+ class VersionSpecificDatasetGdrError extends Error {
348
+ documentId;
349
+ stableDocumentId;
350
+ constructor(documentId, uri) {
351
+ const stableDocumentId = getPublishedId(documentId);
352
+ super(`Invalid GDR "${uri}": dataset document ID "${documentId}" identifies a stored draft or release version. Use the stable document ID "${stableDocumentId}" and select drafts/releases through the workflow perspective.`),
353
+ this.name = "VersionSpecificDatasetGdrError", this.documentId = documentId, this.stableDocumentId = stableDocumentId;
354
+ }
355
+ }
356
+
357
+ function assertStableDatasetDocumentId(documentId, uri) {
358
+ const sanityId = documentId;
359
+ if (!(!isDraftId(sanityId) && !isVersionId(sanityId))) throw new VersionSpecificDatasetGdrError(documentId, uri);
360
+ }
361
+
345
362
  function parseGdr(uri) {
346
363
  const colon = uri.indexOf(":");
347
364
  if (colon < 0) throw new Error(`Invalid GDR "${uri}": must be a URI of form "<scheme>:<...id-parts>". Known schemes: ${KNOWN_SCHEMES_TEXT}.`);
@@ -351,11 +368,12 @@ function parseGdr(uri) {
351
368
  if (parts.some(part => part.length === 0)) throw new Error(`Invalid GDR "${uri}": id parts must be non-empty (no leading, trailing, or doubled ":").`);
352
369
  if (scheme === "dataset") {
353
370
  if (parts.length !== 3) throw new Error(`Invalid GDR "${uri}": dataset scheme requires <projectId>:<dataset>:<documentId> (3 parts after scheme); got ${parts.length}.`);
354
- return {
371
+ const documentId = parts[2];
372
+ return assertStableDatasetDocumentId(documentId, uri), {
355
373
  scheme: "dataset",
356
374
  projectId: parts[0],
357
375
  dataset: parts[1],
358
- documentId: parts[2]
376
+ documentId: documentId
359
377
  };
360
378
  }
361
379
  if (parts.length !== 2) throw new Error(`Invalid GDR "${uri}": ${scheme} scheme requires <resourceId>:<documentId> (2 parts after scheme); got ${parts.length}.`);
@@ -375,7 +393,11 @@ function tryParseGdr(uri) {
375
393
  }
376
394
 
377
395
  function gdrUri(parts) {
378
- return parts.scheme === "dataset" ? `dataset:${parts.projectId}:${parts.dataset}:${parts.documentId}` : `${parts.scheme}:${parts.resourceId}:${parts.documentId}`;
396
+ if (parts.scheme === "dataset") {
397
+ const uri = `dataset:${parts.projectId}:${parts.dataset}:${parts.documentId}`;
398
+ return assertStableDatasetDocumentId(parts.documentId, uri), uri;
399
+ }
400
+ return `${parts.scheme}:${parts.resourceId}:${parts.documentId}`;
379
401
  }
380
402
 
381
403
  function extractDocumentId(gdrUriString) {
@@ -2013,7 +2035,15 @@ function groqIdentifier(referencedAs) {
2013
2035
  }
2014
2036
 
2015
2037
  function picklist(options) {
2016
- return v.picklist(options, `Invalid option: expected one of ${options.map(o => `"${o}"`).join("|")}`);
2038
+ return v.picklist(options, invalidOptionMessage(options));
2039
+ }
2040
+
2041
+ function invalidOptionMessage(options) {
2042
+ return `Invalid option: expected one of ${options.map(option => `"${option}"`).join("|")}`;
2043
+ }
2044
+
2045
+ function exhaustiveOptions() {
2046
+ return options => options;
2017
2047
  }
2018
2048
 
2019
2049
  function pinned() {
@@ -2028,12 +2058,12 @@ const LiteralSchema = v.strictObject({
2028
2058
  scope: v.optional(v.union([ v.literal("workflow"), v.literal("stage") ])),
2029
2059
  field: NonEmpty,
2030
2060
  path: v.optional(v.string())
2031
- }), FieldSourceSchema = v.union([ v.strictObject({
2061
+ }), FieldSourceSchema = v.variant("type", [ v.strictObject({
2032
2062
  type: v.literal("input")
2033
2063
  }), v.strictObject({
2034
2064
  type: v.literal("query"),
2035
2065
  query: NonEmpty
2036
- }), LiteralSchema, FieldReadSchema ]), ValueExprSchema = v.lazy(() => v.union([ LiteralSchema, FieldReadSchema, v.strictObject({
2066
+ }), LiteralSchema, FieldReadSchema ]), ValueExprSchema = v.lazy(() => v.variant("type", [ LiteralSchema, FieldReadSchema, v.strictObject({
2037
2067
  type: v.literal("param"),
2038
2068
  param: NonEmpty
2039
2069
  }), v.strictObject({
@@ -2128,7 +2158,7 @@ function groupMembershipNames(group) {
2128
2158
  return group === void 0 ? [] : typeof group == "string" ? [ group ] : [ ...group ];
2129
2159
  }
2130
2160
 
2131
- const FIELD_VALUE_KINDS = [ "doc.ref", "doc.refs", "subject", "release.ref", "string", "text", "number", "progress", "boolean", "date", "datetime", "url", "actor", "assignee", "assignees", "object", "array" ], FieldValueKindSchema = picklist(FIELD_VALUE_KINDS), FieldKindSchema = picklist(FIELD_VALUE_KINDS), FieldEntryName = groqIdentifier("`$fields.<name>`"), FiniteNumber = v.pipe(v.number(), v.finite("must be finite")), ScalarValidationSchema = v.pipe(v.strictObject({
2161
+ const FIELD_VALUE_KINDS = [ "doc.ref", "doc.refs", "subject", "release.ref", "string", "text", "number", "progress", "boolean", "date", "datetime", "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.picklist(FIELD_VALUE_KINDS, issue => `${invalidOptionMessage(AUTHORING_FIELD_KINDS)} but received ${JSON.stringify(issue.input)}`), FieldEntryName = groqIdentifier("`$fields.<name>`"), FiniteNumber = v.pipe(v.number(), v.finite("must be finite")), ScalarValidationSchema = v.pipe(v.strictObject({
2132
2162
  min: v.optional(FiniteNumber),
2133
2163
  max: v.optional(FiniteNumber)
2134
2164
  }), v.check(validation => validation.min !== void 0 || validation.max !== void 0, "declare at least one bound, or omit `validation`"), v.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.strictObject({
@@ -2193,9 +2223,9 @@ function fieldBase(editable, group) {
2193
2223
  };
2194
2224
  }
2195
2225
 
2196
- function fieldEntryFields(editable, group) {
2226
+ function fieldEntryFields({editable: editable, group: group, kind: kind = FieldKindSchema}) {
2197
2227
  return {
2198
- type: FieldKindSchema,
2228
+ type: kind,
2199
2229
  ...fieldBase(editable, group),
2200
2230
  options: v.optional(ChoiceOptionsSchema),
2201
2231
  validation: v.optional(ScalarValidationSchema),
@@ -2256,7 +2286,14 @@ function scalarValidationDeclarationIssues(entry) {
2256
2286
  return issues.length === 0 ? void 0 : issues;
2257
2287
  }
2258
2288
 
2259
- const FieldEntrySchema = pinned()(v.pipe(compositeChecked(fieldEntryFields(StoredEditableSchema, StoredGroupMembershipSchema)), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), RawAuthoringFieldEntrySchema = pinned()(v.pipe(compositeChecked(fieldEntryFields(AuthoringEditableSchema, AuthoringGroupMembershipSchema)), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), ClaimFieldSchema = pinned()(v.strictObject({
2289
+ const FieldEntrySchema = pinned()(v.pipe(compositeChecked(fieldEntryFields({
2290
+ editable: StoredEditableSchema,
2291
+ group: StoredGroupMembershipSchema
2292
+ })), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), RawAuthoringFieldEntrySchema = pinned()(v.pipe(compositeChecked(fieldEntryFields({
2293
+ editable: AuthoringEditableSchema,
2294
+ group: AuthoringGroupMembershipSchema,
2295
+ kind: AuthoringRawFieldKindSchema
2296
+ })), refTypesCheck(), choiceOptionsCheck(), scalarValidationCheck(), literalSeedCheck())), ClaimFieldSchema = pinned()(v.strictObject({
2260
2297
  type: v.literal("claim"),
2261
2298
  name: FieldEntryName,
2262
2299
  title: v.optional(v.string()),
@@ -2271,7 +2308,10 @@ function listSugarFields(type) {
2271
2308
  };
2272
2309
  }
2273
2310
 
2274
- const TodoListFieldSchema = pinned()(v.strictObject(listSugarFields("todoList"))), NotesFieldSchema = pinned()(v.strictObject(listSugarFields("notes"))), AuthoringFieldEntrySchema = pinned()(v.union([ RawAuthoringFieldEntrySchema, ClaimFieldSchema, TodoListFieldSchema, NotesFieldSchema ])), EffectSchema = v.strictObject({
2311
+ const TodoListFieldSchema = pinned()(v.strictObject(listSugarFields("todoList"))), NotesFieldSchema = pinned()(v.strictObject(listSugarFields("notes"))), AuthoringFieldEntrySchema = pinned()(v.lazy(input => {
2312
+ const type = asShape(input).type;
2313
+ return type === "claim" ? ClaimFieldSchema : type === "todoList" ? TodoListFieldSchema : type === "notes" ? NotesFieldSchema : RawAuthoringFieldEntrySchema;
2314
+ })), EffectSchema = v.strictObject({
2275
2315
  name: NonEmpty,
2276
2316
  title: v.optional(v.string()),
2277
2317
  description: v.optional(v.string()),
@@ -3761,4 +3801,4 @@ function checkWorkflowInvariants(def) {
3761
3801
  checkGroups(def, issues), issues;
3762
3802
  }
3763
3803
 
3764
- export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_STATUSES, ACTOR_KINDS, ActorShape, AuthoringActionSchema, AuthoringActivitySchema, AuthoringFieldEntrySchema, AuthoringGuardSchema, AuthoringOpSchema, AuthoringStageSchema, AuthoringTransitionSchema, AuthoringWorkflowSchema, CALLER_BOUND_VARS, CONDITION_VARS, ContractViolationError, DATA_MODEL_CHANGES, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DEFAULT_TRANSITION_WHEN, DOCUMENT_VALUE_PERMISSIONS, DRIVER_KINDS, DefinitionInUseError, DefinitionNotFoundError, EFFECTS_READ, EXECUTOR_CLASSIFICATIONS, EffectNotFoundError, EffectSchema, FIELD_READ, FIELD_SCOPES, FIELD_VALUE_KINDS, FILTER_SCOPE_VARS, FieldValueShapeError, GROUP_KINDS, GUARD_PREDICATE_VARS, GdrShape, GroupSchema, InstanceNotFoundError, IsoTimestamp, MUTATION_GUARD_ACTIONS, ModelVersionAheadError, NonEmptyString, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, RESOURCE_ALIAS_NAME_SOURCE, ReaderModelAcknowledgementError, START_ALLOWED_VARS, START_FILTER_VARS, SUBJECT_HAS_IN_FLIGHT_INSTANCE_VAR, SpawnContractsInvalidError, StoredFieldOpSchema, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowConfigSchema, WorkflowError, actorFulfillsRole, andConditions, assertReadableModel, assertReaderModelAcknowledgement, checkFieldValue, checkWorkflowInvariants, choiceValueIssues, clientConfigFromResource, conditionEffectReads, conditionFieldReadNames, conditionParameterNames, conditionSyntaxIssues, datasetResourceParts, definitionDocId, deriveActivityKind, deriveExecutorClassification, desugarWorkflow, driverKind, errorMessage, evaluateCondition, evaluateConditionOutcome, evaluatePredicates, extractDocumentId, fieldTreeShape, fieldValueSchemas, formatIssuePath, formatIssues, formatValidationError, gdrFromResource, gdrRef, gdrResourcePrefix, gdrUri, groq, groupMembershipNames, isBareSeedId, isCascadeFired, isGdr, isGdrUri, isGuardReadExpr, isInputSourced, isNotesEntry, isParseableInstant, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTerminalActivityStatus, isTodoListEntry, isTodoListItem, isUnevaluable, isUnprimed, labelFor, minReaderModelOf, modelStampFor, modelVersionOf, parentRef, parseDefinitionSnapshot, parseGdr, parseOrThrow, parsePersistedDoc, parseResourceGdr, parseStoredDefinition, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, refTypeIssues, rejectedRefTypes, releaseDocId, releaseRef, requiredModelFeatures, requiredReaderModel, resourceAliasesToMap, resourceFromGdrUri, resourceFromParsed, resourceGdr, rethrowWithContext, runGroq, sameResource, scalarValidationIssues, schemaTreeShape, selfGdr, startKindOf, tagScopeFilter, terminalState, toBareId, toPhysicalGdr, tolerantEntries, tolerantObject, tryParseGdr, validateFieldAppendItem, validateFieldValue, validateResourceAliasName, validateTag };
3804
+ export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_STATUSES, ACTOR_KINDS, ActorShape, AuthoringActionSchema, AuthoringActivitySchema, AuthoringFieldEntrySchema, AuthoringGuardSchema, AuthoringOpSchema, AuthoringStageSchema, AuthoringTransitionSchema, AuthoringWorkflowSchema, CALLER_BOUND_VARS, CONDITION_VARS, ContractViolationError, DATA_MODEL_CHANGES, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DEFAULT_TRANSITION_WHEN, DOCUMENT_VALUE_PERMISSIONS, DRIVER_KINDS, DefinitionInUseError, DefinitionNotFoundError, EFFECTS_READ, EXECUTOR_CLASSIFICATIONS, EffectNotFoundError, EffectSchema, FIELD_READ, FIELD_SCOPES, FIELD_VALUE_KINDS, FILTER_SCOPE_VARS, FieldValueShapeError, GROUP_KINDS, GUARD_PREDICATE_VARS, GdrShape, GroupSchema, InstanceNotFoundError, IsoTimestamp, MUTATION_GUARD_ACTIONS, ModelVersionAheadError, NonEmptyString, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, RESOURCE_ALIAS_NAME_SOURCE, ReaderModelAcknowledgementError, START_ALLOWED_VARS, START_FILTER_VARS, SUBJECT_HAS_IN_FLIGHT_INSTANCE_VAR, SpawnContractsInvalidError, StoredFieldOpSchema, VersionSpecificDatasetGdrError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowConfigSchema, WorkflowError, actorFulfillsRole, andConditions, assertReadableModel, assertReaderModelAcknowledgement, checkFieldValue, checkWorkflowInvariants, choiceValueIssues, clientConfigFromResource, conditionEffectReads, conditionFieldReadNames, conditionParameterNames, conditionSyntaxIssues, datasetResourceParts, definitionDocId, deriveActivityKind, deriveExecutorClassification, desugarWorkflow, driverKind, errorMessage, evaluateCondition, evaluateConditionOutcome, evaluatePredicates, extractDocumentId, fieldTreeShape, fieldValueSchemas, formatIssuePath, formatIssues, formatValidationError, gdrFromResource, gdrRef, gdrResourcePrefix, gdrUri, groq, groupMembershipNames, isBareSeedId, isCascadeFired, isGdr, isGdrUri, isGuardReadExpr, isInputSourced, isNotesEntry, isParseableInstant, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTerminalActivityStatus, isTodoListEntry, isTodoListItem, isUnevaluable, isUnprimed, labelFor, minReaderModelOf, modelStampFor, modelVersionOf, parentRef, parseDefinitionSnapshot, parseGdr, parseOrThrow, parsePersistedDoc, parseResourceGdr, parseStoredDefinition, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, refTypeIssues, rejectedRefTypes, releaseDocId, releaseRef, requiredModelFeatures, requiredReaderModel, resourceAliasesToMap, resourceFromGdrUri, resourceFromParsed, resourceGdr, rethrowWithContext, runGroq, sameResource, scalarValidationIssues, schemaTreeShape, selfGdr, startKindOf, tagScopeFilter, terminalState, toBareId, toPhysicalGdr, tolerantEntries, tolerantObject, tryParseGdr, validateFieldAppendItem, validateFieldValue, validateResourceAliasName, validateTag };
package/dist/define.d.cts CHANGED
@@ -49,7 +49,7 @@ declare const ActionParamSchema: v.SchemaWithPipe<
49
49
  "doc.refs",
50
50
  "json",
51
51
  ],
52
- `Invalid option: expected one of ${string}`
52
+ string
53
53
  >;
54
54
  readonly name: v.SchemaWithPipe<
55
55
  readonly [
@@ -233,10 +233,7 @@ declare type AuthoringFieldRef = v.InferOutput<typeof AuthoringFieldRefSchema>;
233
233
  declare const AuthoringFieldRefSchema: v.StrictObjectSchema<
234
234
  {
235
235
  readonly scope: v.OptionalSchema<
236
- v.PicklistSchema<
237
- readonly ["workflow", "stage", "activity"],
238
- `Invalid option: expected one of ${string}`
239
- >,
236
+ v.PicklistSchema<readonly ["workflow", "stage", "activity"], string>,
240
237
  undefined
241
238
  >;
242
239
  readonly field: v.SchemaWithPipe<
@@ -402,7 +399,7 @@ declare const AuthoringGuardSchema: v.StrictObjectSchema<
402
399
  v.ArraySchema<
403
400
  v.PicklistSchema<
404
401
  readonly ["create", "update", "delete", "publish", "unpublish"],
405
- `Invalid option: expected one of ${string}`
402
+ string
406
403
  >,
407
404
  undefined
408
405
  >,
@@ -577,7 +574,7 @@ declare const AuthoringManualTargetSchema: v.VariantSchema<
577
574
  readonly scope: v.OptionalSchema<
578
575
  v.PicklistSchema<
579
576
  readonly ["workflow", "stage", "activity"],
580
- `Invalid option: expected one of ${string}`
577
+ string
581
578
  >,
582
579
  undefined
583
580
  >;
@@ -613,7 +610,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
613
610
  readonly scope: v.OptionalSchema<
614
611
  v.PicklistSchema<
615
612
  readonly ["workflow", "stage", "activity"],
616
- `Invalid option: expected one of ${string}`
613
+ string
617
614
  >,
618
615
  undefined
619
616
  >;
@@ -638,7 +635,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
638
635
  readonly scope: v.OptionalSchema<
639
636
  v.PicklistSchema<
640
637
  readonly ["workflow", "stage", "activity"],
641
- `Invalid option: expected one of ${string}`
638
+ string
642
639
  >,
643
640
  undefined
644
641
  >;
@@ -662,7 +659,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
662
659
  readonly scope: v.OptionalSchema<
663
660
  v.PicklistSchema<
664
661
  readonly ["workflow", "stage", "activity"],
665
- `Invalid option: expected one of ${string}`
662
+ string
666
663
  >,
667
664
  undefined
668
665
  >;
@@ -687,7 +684,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
687
684
  readonly scope: v.OptionalSchema<
688
685
  v.PicklistSchema<
689
686
  readonly ["workflow", "stage", "activity"],
690
- `Invalid option: expected one of ${string}`
687
+ string
691
688
  >,
692
689
  undefined
693
690
  >;
@@ -718,7 +715,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
718
715
  readonly scope: v.OptionalSchema<
719
716
  v.PicklistSchema<
720
717
  readonly ["workflow", "stage", "activity"],
721
- `Invalid option: expected one of ${string}`
718
+ string
722
719
  >,
723
720
  undefined
724
721
  >;
@@ -754,7 +751,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
754
751
  >;
755
752
  readonly status: v.PicklistSchema<
756
753
  readonly ["active", "done", "skipped", "failed"],
757
- `Invalid option: expected one of ${string}`
754
+ string
758
755
  >;
759
756
  },
760
757
  undefined
@@ -767,7 +764,7 @@ declare const AuthoringOpSchema: v.VariantSchema<
767
764
  readonly scope: v.OptionalSchema<
768
765
  v.PicklistSchema<
769
766
  readonly ["workflow", "stage", "activity"],
770
- `Invalid option: expected one of ${string}`
767
+ string
771
768
  >,
772
769
  undefined
773
770
  >;
@@ -1356,7 +1353,7 @@ declare const GuardSchema: v.StrictObjectSchema<
1356
1353
  v.ArraySchema<
1357
1354
  v.PicklistSchema<
1358
1355
  readonly ["create", "update", "delete", "publish", "unpublish"],
1359
- `Invalid option: expected one of ${string}`
1356
+ string
1360
1357
  >,
1361
1358
  undefined
1362
1359
  >,
@@ -1588,7 +1585,7 @@ declare const StoredManualTargetSchema: v.VariantSchema<
1588
1585
  {
1589
1586
  readonly scope: v.PicklistSchema<
1590
1587
  readonly ["workflow", "stage", "activity"],
1591
- `Invalid option: expected one of ${string}`
1588
+ string
1592
1589
  >;
1593
1590
  readonly field: v.SchemaWithPipe<
1594
1591
  readonly [
@@ -1616,7 +1613,7 @@ declare const StoredOpSchema: v.VariantSchema<
1616
1613
  {
1617
1614
  readonly scope: v.PicklistSchema<
1618
1615
  readonly ["workflow", "stage", "activity"],
1619
- `Invalid option: expected one of ${string}`
1616
+ string
1620
1617
  >;
1621
1618
  readonly field: v.SchemaWithPipe<
1622
1619
  readonly [
@@ -1638,7 +1635,7 @@ declare const StoredOpSchema: v.VariantSchema<
1638
1635
  {
1639
1636
  readonly scope: v.PicklistSchema<
1640
1637
  readonly ["workflow", "stage", "activity"],
1641
- `Invalid option: expected one of ${string}`
1638
+ string
1642
1639
  >;
1643
1640
  readonly field: v.SchemaWithPipe<
1644
1641
  readonly [
@@ -1659,7 +1656,7 @@ declare const StoredOpSchema: v.VariantSchema<
1659
1656
  {
1660
1657
  readonly scope: v.PicklistSchema<
1661
1658
  readonly ["workflow", "stage", "activity"],
1662
- `Invalid option: expected one of ${string}`
1659
+ string
1663
1660
  >;
1664
1661
  readonly field: v.SchemaWithPipe<
1665
1662
  readonly [
@@ -1681,7 +1678,7 @@ declare const StoredOpSchema: v.VariantSchema<
1681
1678
  {
1682
1679
  readonly scope: v.PicklistSchema<
1683
1680
  readonly ["workflow", "stage", "activity"],
1684
- `Invalid option: expected one of ${string}`
1681
+ string
1685
1682
  >;
1686
1683
  readonly field: v.SchemaWithPipe<
1687
1684
  readonly [
@@ -1709,7 +1706,7 @@ declare const StoredOpSchema: v.VariantSchema<
1709
1706
  {
1710
1707
  readonly scope: v.PicklistSchema<
1711
1708
  readonly ["workflow", "stage", "activity"],
1712
- `Invalid option: expected one of ${string}`
1709
+ string
1713
1710
  >;
1714
1711
  readonly field: v.SchemaWithPipe<
1715
1712
  readonly [
@@ -1740,7 +1737,7 @@ declare const StoredOpSchema: v.VariantSchema<
1740
1737
  >;
1741
1738
  readonly status: v.PicklistSchema<
1742
1739
  readonly ["active", "done", "skipped", "failed"],
1743
- `Invalid option: expected one of ${string}`
1740
+ string
1744
1741
  >;
1745
1742
  },
1746
1743
  undefined
@@ -1847,10 +1844,7 @@ declare const SubworkflowsSchema: v.StrictObjectSchema<
1847
1844
  * `$subworkflows`) decide.
1848
1845
  */
1849
1846
  readonly onExit: v.OptionalSchema<
1850
- v.PicklistSchema<
1851
- readonly ["detach", "abort"],
1852
- `Invalid option: expected one of ${string}`
1853
- >,
1847
+ v.PicklistSchema<readonly ["detach", "abort"], string>,
1854
1848
  undefined
1855
1849
  >;
1856
1850
  },