@sanity/workflow-engine 0.21.0 → 0.23.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,21 @@
1
1
  # @sanity/workflow-engine
2
2
 
3
+ ## 0.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 795b4bb: `set-stage` now makes `--to` optional: omit it on an interactive terminal and the command presents a picker of the instance's declared stages, with the current stage marked and the cursor opened on it. Because `set-stage` is an admin override, every declared stage is offered — not just reachable transitions. The candidates come from the instance's pinned definition snapshot (the same model the engine validates the move against), so the menu can never offer a stage the move would reject. Off a non-interactive terminal `--to` stays required, so scripted use is unaffected. The engine now exports `parseDefinitionSnapshotValue` for reading a definition snapshot from a minimal instance shape.
8
+
9
+ ### Patch Changes
10
+
11
+ - 94d311e: Resolve account-global actor identities when a Studio client is explicitly bound to a project API host, and refuse project-scoped identities returned through custom or malformed API hosts.
12
+
13
+ ## 0.22.0
14
+
15
+ ### Patch Changes
16
+
17
+ - 88ba4ba: Allow stale reader-model acknowledgements to reach the runtime gate, which provides readers-first rollout guidance before any client access.
18
+
3
19
  ## 0.21.0
4
20
 
5
21
  ### Minor Changes
@@ -150,7 +150,7 @@ function parentRef(instance) {
150
150
  return instance.ancestors.at(-1);
151
151
  }
152
152
 
153
- const DATA_MODEL_VERSION = 4, DATA_MODEL_MIN_READER = 4, READER_MODEL_ROLLOUT_URL = "https://github.com/sanity-io/workflows/blob/main/docs/reader-model-rollout.md";
153
+ const DATA_MODEL_VERSION = 4, DATA_MODEL_MIN_READER = 4, READER_MODEL_ROLLOUT_URL = "https://www.sanity.io/docs/editorial-workflows/prerelease";
154
154
 
155
155
  class ReaderModelAcknowledgementError extends WorkflowError {
156
156
  code="WORKFLOW_READER_MODEL_ACKNOWLEDGEMENT_MISMATCH";
@@ -160,7 +160,7 @@ class ReaderModelAcknowledgementError extends WorkflowError {
160
160
  documentationUrl=READER_MODEL_ROLLOUT_URL;
161
161
  constructor(expectedMinReaderModel, context = "Deployment") {
162
162
  const expected = expectedMinReaderModel === void 0 ? "missing" : String(expectedMinReaderModel);
163
- super("reader-model-acknowledgement", `${context} expected reader floor ${expected}; the installed engine requires acknowledgement ${DATA_MODEL_MIN_READER}. Dependency upgrades can change writer compatibility. Upgrade all readers and Functions before accepting a higher floor; after verifying the rollout, change the literal in deployment configuration. Instances written before the new floor may stop matching user-identity queries, and older readers refuse documents this engine touches a prerelease deployment with no data worth migrating can reset every engine-owned document with \`sanity-workflows nuke\` and start fresh. ${READER_MODEL_ROLLOUT_URL}`),
163
+ super("reader-model-acknowledgement", `${context} expected reader floor ${expected}; the installed engine requires acknowledgement ${DATA_MODEL_MIN_READER}. Do not change the acknowledgement yet: accepting ${DATA_MODEL_MIN_READER} authorizes this engine to write documents that older readers will refuse. Upgrade every Studio, CLI, MCP server, Function, and other runtime that reads engine-owned documents; verify that rollout in every environment sharing the workflow resource; then change the literal in deployment configuration and deploy the writer. Rollout guide: ${READER_MODEL_ROLLOUT_URL}`),
164
164
  this.name = "ReaderModelAcknowledgementError", this.expectedMinReaderModel = expectedMinReaderModel;
165
165
  }
166
166
  }
@@ -4182,6 +4182,8 @@ exports.parentRef = parentRef;
4182
4182
 
4183
4183
  exports.parseDefinitionSnapshot = parseDefinitionSnapshot;
4184
4184
 
4185
+ exports.parseDefinitionSnapshotValue = parseDefinitionSnapshotValue;
4186
+
4185
4187
  exports.parseFieldValue = parseFieldValue;
4186
4188
 
4187
4189
  exports.parseGdr = parseGdr;
@@ -136,7 +136,7 @@ function parentRef(instance) {
136
136
  return instance.ancestors.at(-1);
137
137
  }
138
138
 
139
- const DATA_MODEL_VERSION = 4, DATA_MODEL_MIN_READER = 4, READER_MODEL_ROLLOUT_URL = "https://github.com/sanity-io/workflows/blob/main/docs/reader-model-rollout.md";
139
+ const DATA_MODEL_VERSION = 4, DATA_MODEL_MIN_READER = 4, READER_MODEL_ROLLOUT_URL = "https://www.sanity.io/docs/editorial-workflows/prerelease";
140
140
 
141
141
  class ReaderModelAcknowledgementError extends WorkflowError {
142
142
  code="WORKFLOW_READER_MODEL_ACKNOWLEDGEMENT_MISMATCH";
@@ -146,7 +146,7 @@ class ReaderModelAcknowledgementError extends WorkflowError {
146
146
  documentationUrl=READER_MODEL_ROLLOUT_URL;
147
147
  constructor(expectedMinReaderModel, context = "Deployment") {
148
148
  const expected = expectedMinReaderModel === void 0 ? "missing" : String(expectedMinReaderModel);
149
- super("reader-model-acknowledgement", `${context} expected reader floor ${expected}; the installed engine requires acknowledgement ${DATA_MODEL_MIN_READER}. Dependency upgrades can change writer compatibility. Upgrade all readers and Functions before accepting a higher floor; after verifying the rollout, change the literal in deployment configuration. Instances written before the new floor may stop matching user-identity queries, and older readers refuse documents this engine touches a prerelease deployment with no data worth migrating can reset every engine-owned document with \`sanity-workflows nuke\` and start fresh. ${READER_MODEL_ROLLOUT_URL}`),
149
+ super("reader-model-acknowledgement", `${context} expected reader floor ${expected}; the installed engine requires acknowledgement ${DATA_MODEL_MIN_READER}. Do not change the acknowledgement yet: accepting ${DATA_MODEL_MIN_READER} authorizes this engine to write documents that older readers will refuse. Upgrade every Studio, CLI, MCP server, Function, and other runtime that reads engine-owned documents; verify that rollout in every environment sharing the workflow resource; then change the literal in deployment configuration and deploy the writer. Rollout guide: ${READER_MODEL_ROLLOUT_URL}`),
150
150
  this.name = "ReaderModelAcknowledgementError", this.expectedMinReaderModel = expectedMinReaderModel;
151
151
  }
152
152
  }
@@ -3936,4 +3936,4 @@ function checkWorkflowInvariants(def) {
3936
3936
  checkGroups(def, issues), issues;
3937
3937
  }
3938
3938
 
3939
- export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_STATUSES, ACTOR_KINDS, ANONYMOUS_IDENTITY, 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_FILTER_VARS, START_REQUIREMENT_VARS, SYSTEM_IDENTITY, SpawnContractsInvalidError, StoredFieldOpSchema, VersionSpecificDatasetGdrError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowConfigSchema, WorkflowError, actorFulfillsRole, andConditions, assertReadableModel, assertReaderModelAcknowledgement, checkWorkflowInvariants, choiceValueIssues, classifyPrincipalId, 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, lakePrincipalId, minReaderModelOf, modelStampFor, modelVersionOf, parentRef, parseDefinitionSnapshot, parseFieldValue, 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 };
3939
+ export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_STATUSES, ACTOR_KINDS, ANONYMOUS_IDENTITY, 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_FILTER_VARS, START_REQUIREMENT_VARS, SYSTEM_IDENTITY, SpawnContractsInvalidError, StoredFieldOpSchema, VersionSpecificDatasetGdrError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowConfigSchema, WorkflowError, actorFulfillsRole, andConditions, assertReadableModel, assertReaderModelAcknowledgement, checkWorkflowInvariants, choiceValueIssues, classifyPrincipalId, 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, lakePrincipalId, minReaderModelOf, modelStampFor, modelVersionOf, parentRef, parseDefinitionSnapshot, parseDefinitionSnapshotValue, parseFieldValue, 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
@@ -983,15 +983,6 @@ export declare interface ConditionVar {
983
983
  */
984
984
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
985
985
 
986
- /**
987
- * The maximum reader floor this writer can emit. Individual documents derive
988
- * their `minReaderModel` from the compatibility-bearing features actually
989
- * present; a document written at {@link DATA_MODEL_VERSION} may therefore
990
- * carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
991
- * decision that requires readers-first fleet sequencing.
992
- */
993
- declare const DATA_MODEL_MIN_READER = 4;
994
-
995
986
  export declare function defineAction(action: AuthoringAction): AuthoringAction;
996
987
 
997
988
  export declare function defineActivity(
@@ -1954,7 +1945,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
1954
1945
  ]
1955
1946
  >;
1956
1947
  readonly expectedMinReaderModel: v.OptionalSchema<
1957
- v.CustomSchema<4, undefined>,
1948
+ v.CustomSchema<number, undefined>,
1958
1949
  undefined
1959
1950
  >;
1960
1951
  readonly tag: v.SchemaWithPipe<
@@ -2241,7 +2232,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2241
2232
  v.MinLengthAction<
2242
2233
  {
2243
2234
  name: string;
2244
- expectedMinReaderModel?: 4 | undefined;
2235
+ expectedMinReaderModel?: number | undefined;
2245
2236
  tag: string;
2246
2237
  workflowResource:
2247
2238
  | {
@@ -2302,7 +2293,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2302
2293
  v.CheckAction<
2303
2294
  {
2304
2295
  name: string;
2305
- expectedMinReaderModel?: 4 | undefined;
2296
+ expectedMinReaderModel?: number | undefined;
2306
2297
  tag: string;
2307
2298
  workflowResource:
2308
2299
  | {
@@ -2361,7 +2352,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2361
2352
  issue: v.CheckIssue<
2362
2353
  {
2363
2354
  name: string;
2364
- expectedMinReaderModel?: 4 | undefined;
2355
+ expectedMinReaderModel?: number | undefined;
2365
2356
  tag: string;
2366
2357
  workflowResource:
2367
2358
  | {
@@ -2422,7 +2413,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2422
2413
  v.CheckAction<
2423
2414
  {
2424
2415
  name: string;
2425
- expectedMinReaderModel?: 4 | undefined;
2416
+ expectedMinReaderModel?: number | undefined;
2426
2417
  tag: string;
2427
2418
  workflowResource:
2428
2419
  | {
@@ -2481,7 +2472,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2481
2472
  issue: v.CheckIssue<
2482
2473
  {
2483
2474
  name: string;
2484
- expectedMinReaderModel?: 4 | undefined;
2475
+ expectedMinReaderModel?: number | undefined;
2485
2476
  tag: string;
2486
2477
  workflowResource:
2487
2478
  | {
@@ -2585,7 +2576,11 @@ declare type WorkflowDeployment = Omit<
2585
2576
  ParsedWorkflowDeployment,
2586
2577
  "expectedMinReaderModel"
2587
2578
  > & {
2588
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2579
+ /**
2580
+ * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
2581
+ * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
2582
+ */
2583
+ expectedMinReaderModel: number;
2589
2584
  };
2590
2585
 
2591
2586
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
package/dist/define.d.ts CHANGED
@@ -983,15 +983,6 @@ export declare interface ConditionVar {
983
983
  */
984
984
  export declare type ConditionVarBinding = "always" | "caller" | "spawn";
985
985
 
986
- /**
987
- * The maximum reader floor this writer can emit. Individual documents derive
988
- * their `minReaderModel` from the compatibility-bearing features actually
989
- * present; a document written at {@link DATA_MODEL_VERSION} may therefore
990
- * carry a lower floor. Raising this maximum is a declared, DATAMODEL.md-logged
991
- * decision that requires readers-first fleet sequencing.
992
- */
993
- declare const DATA_MODEL_MIN_READER = 4;
994
-
995
986
  export declare function defineAction(action: AuthoringAction): AuthoringAction;
996
987
 
997
988
  export declare function defineActivity(
@@ -1954,7 +1945,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
1954
1945
  ]
1955
1946
  >;
1956
1947
  readonly expectedMinReaderModel: v.OptionalSchema<
1957
- v.CustomSchema<4, undefined>,
1948
+ v.CustomSchema<number, undefined>,
1958
1949
  undefined
1959
1950
  >;
1960
1951
  readonly tag: v.SchemaWithPipe<
@@ -2241,7 +2232,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2241
2232
  v.MinLengthAction<
2242
2233
  {
2243
2234
  name: string;
2244
- expectedMinReaderModel?: 4 | undefined;
2235
+ expectedMinReaderModel?: number | undefined;
2245
2236
  tag: string;
2246
2237
  workflowResource:
2247
2238
  | {
@@ -2302,7 +2293,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2302
2293
  v.CheckAction<
2303
2294
  {
2304
2295
  name: string;
2305
- expectedMinReaderModel?: 4 | undefined;
2296
+ expectedMinReaderModel?: number | undefined;
2306
2297
  tag: string;
2307
2298
  workflowResource:
2308
2299
  | {
@@ -2361,7 +2352,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2361
2352
  issue: v.CheckIssue<
2362
2353
  {
2363
2354
  name: string;
2364
- expectedMinReaderModel?: 4 | undefined;
2355
+ expectedMinReaderModel?: number | undefined;
2365
2356
  tag: string;
2366
2357
  workflowResource:
2367
2358
  | {
@@ -2422,7 +2413,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2422
2413
  v.CheckAction<
2423
2414
  {
2424
2415
  name: string;
2425
- expectedMinReaderModel?: 4 | undefined;
2416
+ expectedMinReaderModel?: number | undefined;
2426
2417
  tag: string;
2427
2418
  workflowResource:
2428
2419
  | {
@@ -2481,7 +2472,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
2481
2472
  issue: v.CheckIssue<
2482
2473
  {
2483
2474
  name: string;
2484
- expectedMinReaderModel?: 4 | undefined;
2475
+ expectedMinReaderModel?: number | undefined;
2485
2476
  tag: string;
2486
2477
  workflowResource:
2487
2478
  | {
@@ -2585,7 +2576,11 @@ declare type WorkflowDeployment = Omit<
2585
2576
  ParsedWorkflowDeployment,
2586
2577
  "expectedMinReaderModel"
2587
2578
  > & {
2588
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2579
+ /**
2580
+ * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
2581
+ * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
2582
+ */
2583
+ expectedMinReaderModel: number;
2589
2584
  };
2590
2585
 
2591
2586
  /** Type-mirror of {@link workflowFields}, parameterised over field/stage/start. */
package/dist/index.cjs CHANGED
@@ -8493,9 +8493,13 @@ async function fetchGlobalUser(client) {
8493
8493
  reason: "the client cannot reach the global API host (no withConfig)"
8494
8494
  };
8495
8495
  let globalRequest, globalClient;
8496
+ const hostResolution = resolveGlobalApiHost(client);
8496
8497
  try {
8497
8498
  globalClient = client.withConfig({
8498
- useProjectHostname: !1
8499
+ useProjectHostname: !1,
8500
+ ...hostResolution.apiHost === void 0 ? {} : {
8501
+ apiHost: hostResolution.apiHost
8502
+ }
8499
8503
  }), globalRequest = lazyRequest(globalClient);
8500
8504
  } catch (err) {
8501
8505
  return {
@@ -8509,11 +8513,15 @@ async function fetchGlobalUser(client) {
8509
8513
  reason: "the global-host sibling client cannot issue requests"
8510
8514
  };
8511
8515
  try {
8512
- return {
8513
- user: await globalRequest({
8514
- uri: "/users/me",
8515
- tag: REQUEST_TAG.accessResolveActor
8516
- })
8516
+ const user = await globalRequest({
8517
+ uri: "/users/me",
8518
+ tag: REQUEST_TAG.accessResolveActor
8519
+ }), id = usableId(user);
8520
+ return hostResolution.requireGlobalPrincipal && id !== void 0 && invariants.classifyPrincipalId(id).namespace === "project" ? {
8521
+ user: void 0,
8522
+ reason: `global-host /users/me returned project-scoped principal "${id}"; the sibling client is still bound to a project API host`
8523
+ } : {
8524
+ user: user
8517
8525
  };
8518
8526
  } catch (err) {
8519
8527
  return {
@@ -8524,6 +8532,34 @@ async function fetchGlobalUser(client) {
8524
8532
  }
8525
8533
  }
8526
8534
 
8535
+ function resolveGlobalApiHost(client) {
8536
+ if (typeof client.config != "function") return {
8537
+ requireGlobalPrincipal: !1
8538
+ };
8539
+ const apiHost = client.config().apiHost;
8540
+ if (apiHost === void 0) return {
8541
+ requireGlobalPrincipal: !1
8542
+ };
8543
+ let parsed;
8544
+ try {
8545
+ parsed = new URL(apiHost);
8546
+ } catch {
8547
+ return {
8548
+ requireGlobalPrincipal: !0
8549
+ };
8550
+ }
8551
+ if (/^api\.sanity\.(io|work)$/.test(parsed.hostname)) return {
8552
+ requireGlobalPrincipal: !1
8553
+ };
8554
+ const match = /^[^.]+\.api\.sanity\.(io|work)$/.exec(parsed.hostname);
8555
+ return match === null ? {
8556
+ requireGlobalPrincipal: !0
8557
+ } : (parsed.hostname = `api.sanity.${match[1]}`, {
8558
+ apiHost: parsed.origin,
8559
+ requireGlobalPrincipal: !0
8560
+ });
8561
+ }
8562
+
8527
8563
  async function fetchGrantsCached(requestFn, resourcePath) {
8528
8564
  try {
8529
8565
  return await fetchGrants({
@@ -13023,6 +13059,8 @@ exports.parentRef = invariants.parentRef;
13023
13059
 
13024
13060
  exports.parseDefinitionSnapshot = invariants.parseDefinitionSnapshot;
13025
13061
 
13062
+ exports.parseDefinitionSnapshotValue = invariants.parseDefinitionSnapshotValue;
13063
+
13026
13064
  exports.parseGdr = invariants.parseGdr;
13027
13065
 
13028
13066
  exports.parseResourceGdr = invariants.parseResourceGdr;
package/dist/index.d.cts CHANGED
@@ -2693,8 +2693,13 @@ export declare interface DeployDefinitionResult {
2693
2693
  export declare interface DeployDefinitionsArgs<
2694
2694
  T extends WorkflowDefinitionInput<T> = WorkflowDefinition,
2695
2695
  > {
2696
- /** Reviewed literal acknowledging the installed writer's maximum reader-floor capability. */
2697
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2696
+ /**
2697
+ * Reviewed numeric literal acknowledging the installed writer's maximum reader-floor capability.
2698
+ * The deploy gate checks the exact installed value and links the readers-first rollout; do not
2699
+ * import {@link DATA_MODEL_MIN_READER}, because that would auto-advance this acknowledgement on
2700
+ * upgrade.
2701
+ */
2702
+ expectedMinReaderModel: number;
2698
2703
  /**
2699
2704
  * Resource-alias bindings for this deploy (alias name → physical resource).
2700
2705
  * A deploy-time abstraction ONLY: every `@<alias>:` reference in a
@@ -2764,7 +2769,8 @@ export declare function deployStageGuards(args: StageGuardArgs): Promise<void>;
2764
2769
  * definitions themselves — carrying `resourceAliases` here is what keeps a diff
2765
2770
  * fingerprinting the same physical content `deployDefinitions` would. */
2766
2771
  export declare interface DeployTarget {
2767
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2772
+ /** Reviewed numeric literal, checked against the exact installed floor before client access. */
2773
+ expectedMinReaderModel: number;
2768
2774
  tag: string;
2769
2775
  workflowResource: WorkflowResource;
2770
2776
  resourceAliases?: ResourceAliases;
@@ -6490,6 +6496,16 @@ export declare function parseDefinitionSnapshot(
6490
6496
  instance: WorkflowInstance,
6491
6497
  ): WorkflowDefinition;
6492
6498
 
6499
+ /**
6500
+ * The canonical parser for an instance's frozen
6501
+ * {@link WorkflowInstance.definitionSnapshot}. Accepting the persisted pair
6502
+ * keeps compatibility scanners and full instance consumers on the same
6503
+ * contextual failure path.
6504
+ */
6505
+ export declare function parseDefinitionSnapshotValue(
6506
+ instance: Pick<WorkflowInstance, "_id" | "definitionSnapshot">,
6507
+ ): WorkflowDefinition;
6508
+
6493
6509
  export declare interface ParsedGdr {
6494
6510
  scheme: GdrScheme;
6495
6511
  /** For `dataset`: `<projectId>` */
@@ -6773,7 +6789,7 @@ export declare interface QueryInScopeArgs extends InstanceRefArgs, QueryArgs {}
6773
6789
  export { quoted };
6774
6790
 
6775
6791
  export declare const READER_MODEL_ROLLOUT_URL =
6776
- "https://github.com/sanity-io/workflows/blob/main/docs/reader-model-rollout.md";
6792
+ "https://www.sanity.io/docs/editorial-workflows/prerelease";
6777
6793
 
6778
6794
  /** A producer has not explicitly acknowledged this engine's writer capability. */
6779
6795
  export declare class ReaderModelAcknowledgementError extends WorkflowError<"reader-model-acknowledgement"> {
@@ -6782,7 +6798,7 @@ export declare class ReaderModelAcknowledgementError extends WorkflowError<"read
6782
6798
  readonly engineMinReaderModel = 4;
6783
6799
  readonly engineModelVersion = 4;
6784
6800
  readonly documentationUrl =
6785
- "https://github.com/sanity-io/workflows/blob/main/docs/reader-model-rollout.md";
6801
+ "https://www.sanity.io/docs/editorial-workflows/prerelease";
6786
6802
  constructor(expectedMinReaderModel: unknown, context?: string);
6787
6803
  }
6788
6804
 
@@ -9315,6 +9331,13 @@ export declare interface WorkflowAutonomy extends AutonomyAnswer {
9315
9331
  }
9316
9332
 
9317
9333
  export declare interface WorkflowClient {
9334
+ /**
9335
+ * Read the effective client configuration. The engine probes `apiHost`
9336
+ * before deriving the global `/users/me` sibling because `@sanity/client`
9337
+ * shallow-merges `withConfig` overrides and otherwise preserves an explicit
9338
+ * project host even when `useProjectHostname` is set to `false`.
9339
+ */
9340
+ config?: () => WorkflowClientConfig;
9318
9341
  fetch: <T = unknown>(
9319
9342
  query: string,
9320
9343
  params?: Record<string, unknown>,
@@ -9442,6 +9465,8 @@ export declare interface WorkflowClientConfig {
9442
9465
  resource?: WorkflowResource;
9443
9466
  projectId?: string;
9444
9467
  dataset?: string;
9468
+ /** Explicit API origin, mirroring `@sanity/client`'s `apiHost`. */
9469
+ apiHost?: string;
9445
9470
  apiVersion?: string;
9446
9471
  requestTagPrefix?: string;
9447
9472
  /**
@@ -9500,7 +9525,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9500
9525
  ]
9501
9526
  >;
9502
9527
  readonly expectedMinReaderModel: v.OptionalSchema<
9503
- v.CustomSchema<4, undefined>,
9528
+ v.CustomSchema<number, undefined>,
9504
9529
  undefined
9505
9530
  >;
9506
9531
  readonly tag: v.SchemaWithPipe<
@@ -9787,7 +9812,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9787
9812
  v.MinLengthAction<
9788
9813
  {
9789
9814
  name: string;
9790
- expectedMinReaderModel?: 4 | undefined;
9815
+ expectedMinReaderModel?: number | undefined;
9791
9816
  tag: string;
9792
9817
  workflowResource:
9793
9818
  | {
@@ -9848,7 +9873,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9848
9873
  v.CheckAction<
9849
9874
  {
9850
9875
  name: string;
9851
- expectedMinReaderModel?: 4 | undefined;
9876
+ expectedMinReaderModel?: number | undefined;
9852
9877
  tag: string;
9853
9878
  workflowResource:
9854
9879
  | {
@@ -9907,7 +9932,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9907
9932
  issue: v.CheckIssue<
9908
9933
  {
9909
9934
  name: string;
9910
- expectedMinReaderModel?: 4 | undefined;
9935
+ expectedMinReaderModel?: number | undefined;
9911
9936
  tag: string;
9912
9937
  workflowResource:
9913
9938
  | {
@@ -9968,7 +9993,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9968
9993
  v.CheckAction<
9969
9994
  {
9970
9995
  name: string;
9971
- expectedMinReaderModel?: 4 | undefined;
9996
+ expectedMinReaderModel?: number | undefined;
9972
9997
  tag: string;
9973
9998
  workflowResource:
9974
9999
  | {
@@ -10027,7 +10052,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
10027
10052
  issue: v.CheckIssue<
10028
10053
  {
10029
10054
  name: string;
10030
- expectedMinReaderModel?: 4 | undefined;
10055
+ expectedMinReaderModel?: number | undefined;
10031
10056
  tag: string;
10032
10057
  workflowResource:
10033
10058
  | {
@@ -10194,7 +10219,11 @@ export declare type WorkflowDeployment = Omit<
10194
10219
  ParsedWorkflowDeployment,
10195
10220
  "expectedMinReaderModel"
10196
10221
  > & {
10197
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
10222
+ /**
10223
+ * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
10224
+ * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
10225
+ */
10226
+ expectedMinReaderModel: number;
10198
10227
  };
10199
10228
 
10200
10229
  export declare const WorkflowEffectCompleted: WorkflowTelemetryEvent<WorkflowEffectCompletedData>;
package/dist/index.d.ts CHANGED
@@ -2693,8 +2693,13 @@ export declare interface DeployDefinitionResult {
2693
2693
  export declare interface DeployDefinitionsArgs<
2694
2694
  T extends WorkflowDefinitionInput<T> = WorkflowDefinition,
2695
2695
  > {
2696
- /** Reviewed literal acknowledging the installed writer's maximum reader-floor capability. */
2697
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2696
+ /**
2697
+ * Reviewed numeric literal acknowledging the installed writer's maximum reader-floor capability.
2698
+ * The deploy gate checks the exact installed value and links the readers-first rollout; do not
2699
+ * import {@link DATA_MODEL_MIN_READER}, because that would auto-advance this acknowledgement on
2700
+ * upgrade.
2701
+ */
2702
+ expectedMinReaderModel: number;
2698
2703
  /**
2699
2704
  * Resource-alias bindings for this deploy (alias name → physical resource).
2700
2705
  * A deploy-time abstraction ONLY: every `@<alias>:` reference in a
@@ -2764,7 +2769,8 @@ export declare function deployStageGuards(args: StageGuardArgs): Promise<void>;
2764
2769
  * definitions themselves — carrying `resourceAliases` here is what keeps a diff
2765
2770
  * fingerprinting the same physical content `deployDefinitions` would. */
2766
2771
  export declare interface DeployTarget {
2767
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
2772
+ /** Reviewed numeric literal, checked against the exact installed floor before client access. */
2773
+ expectedMinReaderModel: number;
2768
2774
  tag: string;
2769
2775
  workflowResource: WorkflowResource;
2770
2776
  resourceAliases?: ResourceAliases;
@@ -6490,6 +6496,16 @@ export declare function parseDefinitionSnapshot(
6490
6496
  instance: WorkflowInstance,
6491
6497
  ): WorkflowDefinition;
6492
6498
 
6499
+ /**
6500
+ * The canonical parser for an instance's frozen
6501
+ * {@link WorkflowInstance.definitionSnapshot}. Accepting the persisted pair
6502
+ * keeps compatibility scanners and full instance consumers on the same
6503
+ * contextual failure path.
6504
+ */
6505
+ export declare function parseDefinitionSnapshotValue(
6506
+ instance: Pick<WorkflowInstance, "_id" | "definitionSnapshot">,
6507
+ ): WorkflowDefinition;
6508
+
6493
6509
  export declare interface ParsedGdr {
6494
6510
  scheme: GdrScheme;
6495
6511
  /** For `dataset`: `<projectId>` */
@@ -6773,7 +6789,7 @@ export declare interface QueryInScopeArgs extends InstanceRefArgs, QueryArgs {}
6773
6789
  export { quoted };
6774
6790
 
6775
6791
  export declare const READER_MODEL_ROLLOUT_URL =
6776
- "https://github.com/sanity-io/workflows/blob/main/docs/reader-model-rollout.md";
6792
+ "https://www.sanity.io/docs/editorial-workflows/prerelease";
6777
6793
 
6778
6794
  /** A producer has not explicitly acknowledged this engine's writer capability. */
6779
6795
  export declare class ReaderModelAcknowledgementError extends WorkflowError<"reader-model-acknowledgement"> {
@@ -6782,7 +6798,7 @@ export declare class ReaderModelAcknowledgementError extends WorkflowError<"read
6782
6798
  readonly engineMinReaderModel = 4;
6783
6799
  readonly engineModelVersion = 4;
6784
6800
  readonly documentationUrl =
6785
- "https://github.com/sanity-io/workflows/blob/main/docs/reader-model-rollout.md";
6801
+ "https://www.sanity.io/docs/editorial-workflows/prerelease";
6786
6802
  constructor(expectedMinReaderModel: unknown, context?: string);
6787
6803
  }
6788
6804
 
@@ -9315,6 +9331,13 @@ export declare interface WorkflowAutonomy extends AutonomyAnswer {
9315
9331
  }
9316
9332
 
9317
9333
  export declare interface WorkflowClient {
9334
+ /**
9335
+ * Read the effective client configuration. The engine probes `apiHost`
9336
+ * before deriving the global `/users/me` sibling because `@sanity/client`
9337
+ * shallow-merges `withConfig` overrides and otherwise preserves an explicit
9338
+ * project host even when `useProjectHostname` is set to `false`.
9339
+ */
9340
+ config?: () => WorkflowClientConfig;
9318
9341
  fetch: <T = unknown>(
9319
9342
  query: string,
9320
9343
  params?: Record<string, unknown>,
@@ -9442,6 +9465,8 @@ export declare interface WorkflowClientConfig {
9442
9465
  resource?: WorkflowResource;
9443
9466
  projectId?: string;
9444
9467
  dataset?: string;
9468
+ /** Explicit API origin, mirroring `@sanity/client`'s `apiHost`. */
9469
+ apiHost?: string;
9445
9470
  apiVersion?: string;
9446
9471
  requestTagPrefix?: string;
9447
9472
  /**
@@ -9500,7 +9525,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9500
9525
  ]
9501
9526
  >;
9502
9527
  readonly expectedMinReaderModel: v.OptionalSchema<
9503
- v.CustomSchema<4, undefined>,
9528
+ v.CustomSchema<number, undefined>,
9504
9529
  undefined
9505
9530
  >;
9506
9531
  readonly tag: v.SchemaWithPipe<
@@ -9787,7 +9812,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9787
9812
  v.MinLengthAction<
9788
9813
  {
9789
9814
  name: string;
9790
- expectedMinReaderModel?: 4 | undefined;
9815
+ expectedMinReaderModel?: number | undefined;
9791
9816
  tag: string;
9792
9817
  workflowResource:
9793
9818
  | {
@@ -9848,7 +9873,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9848
9873
  v.CheckAction<
9849
9874
  {
9850
9875
  name: string;
9851
- expectedMinReaderModel?: 4 | undefined;
9876
+ expectedMinReaderModel?: number | undefined;
9852
9877
  tag: string;
9853
9878
  workflowResource:
9854
9879
  | {
@@ -9907,7 +9932,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9907
9932
  issue: v.CheckIssue<
9908
9933
  {
9909
9934
  name: string;
9910
- expectedMinReaderModel?: 4 | undefined;
9935
+ expectedMinReaderModel?: number | undefined;
9911
9936
  tag: string;
9912
9937
  workflowResource:
9913
9938
  | {
@@ -9968,7 +9993,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
9968
9993
  v.CheckAction<
9969
9994
  {
9970
9995
  name: string;
9971
- expectedMinReaderModel?: 4 | undefined;
9996
+ expectedMinReaderModel?: number | undefined;
9972
9997
  tag: string;
9973
9998
  workflowResource:
9974
9999
  | {
@@ -10027,7 +10052,7 @@ declare const WorkflowConfigSchema: v.ObjectSchema<
10027
10052
  issue: v.CheckIssue<
10028
10053
  {
10029
10054
  name: string;
10030
- expectedMinReaderModel?: 4 | undefined;
10055
+ expectedMinReaderModel?: number | undefined;
10031
10056
  tag: string;
10032
10057
  workflowResource:
10033
10058
  | {
@@ -10194,7 +10219,11 @@ export declare type WorkflowDeployment = Omit<
10194
10219
  ParsedWorkflowDeployment,
10195
10220
  "expectedMinReaderModel"
10196
10221
  > & {
10197
- expectedMinReaderModel: typeof DATA_MODEL_MIN_READER;
10222
+ /**
10223
+ * Reviewed numeric literal. Runtime validation owns the exact installed-floor check so a stale
10224
+ * acknowledgement reaches the readers-first rollout guidance instead of becoming a type error.
10225
+ */
10226
+ expectedMinReaderModel: number;
10198
10227
  };
10199
10228
 
10200
10229
  export declare const WorkflowEffectCompleted: WorkflowTelemetryEvent<WorkflowEffectCompletedData>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { terminalState, andConditions, deriveActivityKind, parseDefinitionSnapshot, CALLER_BOUND_VARS, START_REQUIREMENT_VARS, CONDITION_VARS, isSubjectEntry, isUnevaluable, ContractViolationError, isStartableDefinition, conditionFieldReadNames, rethrowWithContext, isGdr, errorMessage, conditionParameterNames, START_FILTER_VARS, gdrFromResource, selfGdr, isSingleDocRefKind, parentRef, actorFulfillsRole, toBareId, WorkflowError, sameResource, resourceFromParsed, tryParseGdr, isTerminalActivityStatus, FieldValueShapeError, validateFieldValue, validateFieldAppendItem, evaluateCondition, isSingleDocRefEntry, choiceValueIssues, scalarValidationIssues, StoredFieldOpSchema, formatIssues, conditionSyntaxIssues, checkWorkflowInvariants, formatIssuePath, isGuardReadExpr, conditionEffectReads, EFFECTS_READ, datasetResourceParts, evaluatePredicates, WORKFLOW_DEFINITION_TYPE, tagScopeFilter, isCascadeFired, WORKFLOW_INSTANCE_TYPE, parseGdr, isGdrUri, gdrRef, isInputSourced, parseFieldValue, VersionSpecificDatasetGdrError, toPhysicalGdr, isBareSeedId, tolerantEntries, NonEmptyString, FIELD_VALUE_KINDS, tolerantObject, ActorShape, IsoTimestamp, ACTIVITY_STATUSES, GdrShape, DRIVER_KINDS, FIELD_SCOPES, fieldValueSchemas, parsePersistedDoc, ACTOR_KINDS, classifyPrincipalId, assertReadableModel, InstanceNotFoundError, modelStampFor, evaluateConditionOutcome, runGroq, FIELD_READ, MUTATION_GUARD_ACTIONS, resourceGdr, minReaderModelOf, resourceFromGdrUri, refTypeIssues, rejectedRefTypes, DOCUMENT_VALUE_PERMISSIONS, lakePrincipalId, driverKind, EffectNotFoundError, deriveExecutorClassification, validateTag, extractDocumentId, parseStoredDefinition, validateResourceAliasName, labelFor, DefinitionNotFoundError, definitionDocId, SpawnContractsInvalidError, gdrResourcePrefix, RESOURCE_ALIAS_NAME_SOURCE, isUnprimed, DefinitionInUseError, assertReaderModelAcknowledgement, isParseableInstant, groupMembershipNames } from "./_chunks-es/invariants.js";
2
2
 
3
- import { ACTION_SEMANTICS, ACTIVITY_KINDS, ANONYMOUS_IDENTITY, DATA_MODEL_CHANGES, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DEFAULT_TRANSITION_WHEN, EXECUTOR_CLASSIFICATIONS, FILTER_SCOPE_VARS, GROUP_KINDS, GUARD_PREDICATE_VARS, ModelVersionAheadError, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, ReaderModelAcknowledgementError, SYSTEM_IDENTITY, clientConfigFromResource, fieldTreeShape, gdrUri, isNotesEntry, isTodoListEntry, isTodoListItem, modelVersionOf, parseResourceGdr, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, releaseDocId, releaseRef, requiredModelFeatures, requiredReaderModel, resourceAliasesToMap, schemaTreeShape, startKindOf } from "./_chunks-es/invariants.js";
3
+ import { ACTION_SEMANTICS, ACTIVITY_KINDS, ANONYMOUS_IDENTITY, DATA_MODEL_CHANGES, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DEFAULT_TRANSITION_WHEN, EXECUTOR_CLASSIFICATIONS, FILTER_SCOPE_VARS, GROUP_KINDS, GUARD_PREDICATE_VARS, ModelVersionAheadError, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, ReaderModelAcknowledgementError, SYSTEM_IDENTITY, clientConfigFromResource, fieldTreeShape, gdrUri, isNotesEntry, isTodoListEntry, isTodoListItem, modelVersionOf, parseDefinitionSnapshotValue, parseResourceGdr, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, releaseDocId, releaseRef, requiredModelFeatures, requiredReaderModel, resourceAliasesToMap, schemaTreeShape, startKindOf } from "./_chunks-es/invariants.js";
4
4
 
5
5
  import { atomNode, dedupeBy, analyzeCondition, atomReadsDataset, checklistLines as checklistLines$1, phrase, quoted, listAnd, describeAtom as describeAtom$1, describeCondition as describeCondition$1, guillemets, formatValue, humanize, listOr, scopeReadOf, describeRead, explainCondition, dedupeReads, whatIfCondition, MAX_COUNTERFACTUAL_INDEX } from "@sanity/groq-condition-describe";
6
6
 
@@ -8477,9 +8477,13 @@ async function fetchGlobalUser(client) {
8477
8477
  reason: "the client cannot reach the global API host (no withConfig)"
8478
8478
  };
8479
8479
  let globalRequest, globalClient;
8480
+ const hostResolution = resolveGlobalApiHost(client);
8480
8481
  try {
8481
8482
  globalClient = client.withConfig({
8482
- useProjectHostname: !1
8483
+ useProjectHostname: !1,
8484
+ ...hostResolution.apiHost === void 0 ? {} : {
8485
+ apiHost: hostResolution.apiHost
8486
+ }
8483
8487
  }), globalRequest = lazyRequest(globalClient);
8484
8488
  } catch (err) {
8485
8489
  return {
@@ -8493,11 +8497,15 @@ async function fetchGlobalUser(client) {
8493
8497
  reason: "the global-host sibling client cannot issue requests"
8494
8498
  };
8495
8499
  try {
8496
- return {
8497
- user: await globalRequest({
8498
- uri: "/users/me",
8499
- tag: REQUEST_TAG.accessResolveActor
8500
- })
8500
+ const user = await globalRequest({
8501
+ uri: "/users/me",
8502
+ tag: REQUEST_TAG.accessResolveActor
8503
+ }), id = usableId(user);
8504
+ return hostResolution.requireGlobalPrincipal && id !== void 0 && classifyPrincipalId(id).namespace === "project" ? {
8505
+ user: void 0,
8506
+ reason: `global-host /users/me returned project-scoped principal "${id}"; the sibling client is still bound to a project API host`
8507
+ } : {
8508
+ user: user
8501
8509
  };
8502
8510
  } catch (err) {
8503
8511
  return {
@@ -8508,6 +8516,34 @@ async function fetchGlobalUser(client) {
8508
8516
  }
8509
8517
  }
8510
8518
 
8519
+ function resolveGlobalApiHost(client) {
8520
+ if (typeof client.config != "function") return {
8521
+ requireGlobalPrincipal: !1
8522
+ };
8523
+ const apiHost = client.config().apiHost;
8524
+ if (apiHost === void 0) return {
8525
+ requireGlobalPrincipal: !1
8526
+ };
8527
+ let parsed;
8528
+ try {
8529
+ parsed = new URL(apiHost);
8530
+ } catch {
8531
+ return {
8532
+ requireGlobalPrincipal: !0
8533
+ };
8534
+ }
8535
+ if (/^api\.sanity\.(io|work)$/.test(parsed.hostname)) return {
8536
+ requireGlobalPrincipal: !1
8537
+ };
8538
+ const match = /^[^.]+\.api\.sanity\.(io|work)$/.exec(parsed.hostname);
8539
+ return match === null ? {
8540
+ requireGlobalPrincipal: !0
8541
+ } : (parsed.hostname = `api.sanity.${match[1]}`, {
8542
+ apiHost: parsed.origin,
8543
+ requireGlobalPrincipal: !0
8544
+ });
8545
+ }
8546
+
8511
8547
  async function fetchGrantsCached(requestFn, resourcePath) {
8512
8548
  try {
8513
8549
  return await fetchGrants({
@@ -12877,4 +12913,4 @@ function displayDescription(typeKey) {
12877
12913
  if (typeKey) return DISPLAY[typeKey]?.description;
12878
12914
  }
12879
12915
 
12880
- export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_KIND_DISPLAY, ACTOR_KINDS, ANONYMOUS_IDENTITY, AUTHORING_DISPLAY, ActionDisabledError, ActionParamsInvalidError, CONDITION_VARS, CONTEXT_ENTRY_DISPLAY, CascadeLimitError, ConcurrentCommitEffectOpsError, ConcurrentCompleteEffectError, ConcurrentEditFieldError, ConcurrentFireActionError, ContractViolationError, DATA_MODEL_CHANGES, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DEFAULT_CONTENT_PERSPECTIVE, DEFAULT_EFFECT_LEASE_MS, DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_TRANSITION_WHEN, DISPLAY, DRIVER_KINDS, DRIVER_KIND_DISPLAY, DefinitionInUseError, DefinitionNotFoundError, EFFECT_COMMIT_DISPATCH_CAP, EFFECT_COMMIT_QUEUE_DEPTH, ENGINE_API_VERSION, EXECUTION_KINDS, EXECUTOR_CLASSIFICATIONS, EXECUTOR_CLASSIFICATION_DISPLAY, EditFieldDeniedError, EffectCommitQueueOverflowError, EffectNotFoundError, EffectOpsInvalidError, EffectOutputsInvalidError, FIELD_KIND_DISPLAY, FILTER_SCOPE_VARS, FieldValueShapeError, GROUP_KINDS, GROUP_KIND_DISPLAY, GUARD_DOC_TYPE, GUARD_OWNER, GUARD_PREDICATE_VARS, HISTORY_DISPLAY, InitialFieldsInvalidError, InstanceNotFoundError, MAX_COUNTERFACTUAL_INDEX2 as MAX_COUNTERFACTUAL_INDEX, MissingHandlerError, ModelVersionAheadError, MutationGuardDeniedError, MutationGuardDocSchema, OP_DISPLAY, PartialGuardDeployError, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, ReaderModelAcknowledgementError, RefResourceUndeclaredError, RequiredFieldNotProvidedError, START_FILTER_VARS, START_REQUIREMENT_VARS, SYSTEM_IDENTITY, SpawnContractsInvalidError, StaleEffectClaimError, StartNotAllowedError, StartNotPrimedError, StartNotSettledError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowActionFired, WorkflowActivityReset, WorkflowDefinitionDeleted, WorkflowDefinitionDeployed, WorkflowEffectCompleted, WorkflowEffectStateReported, WorkflowEffectsDrained, WorkflowError, WorkflowFieldEdited, WorkflowInstanceAborted, WorkflowInstanceSchema, WorkflowInstanceStarted, WorkflowInstanceTicked, WorkflowStageSet, WorkflowStageTransitioned, WorkflowStateDivergedError, abortReason, acceptsDocumentType, aclPathForResource, actionDisabledDetail, actionRendering, actionVerdict, activityAutonomyOf, analyzeCondition2 as analyzeCondition, applicableDefinitions, assertReadableModel, assertReaderModelAcknowledgement, atomReadsDataset2 as atomReadsDataset, autonomySummary, availableActions, buildInitialFields, buildSnapshot, checklistLines, classifyPrincipalId, clientConfigFromResource, clientProjectUserDirectory, compileGuard, computeDiffEntries, conditionFieldReadNames, conditionSitesOf, contentDocQuery, contentDraftFallback, contentReleaseName, contextMap, createEngine, createTelemetryIntake, datasetResourceParts, defaultLoggerFactory, definitionDeployedData, definitionLookupGroq, definitionsListGroq, deniedGuardLabels, deniedGuardRefs, denyingGuards, deployStageGuards, deriveActivityKind, deriveExecutorClassification, deriveWorkflowAutonomy, describeAtom, describeAutonomyWait, describeCondition, describeDefinition, describeFieldInsight, describeNode, describeSite, describeSiteHeading, diagnoseInputFromEvaluation, diagnoseInstance, diffEntry, displayDescription, displayTitle, documentActionDenials, documentPrefilter, driverKind, effectOutputsMap, entryDocRefs, errorMessage, evaluateFromSnapshot, evaluateMutationGuard, evaluateStartFilter, expandResourceAliases, explainCondition2 as explainCondition, explainStartRequirement, extractDocumentId, fieldTreeShape, findCurrentActivityEntry, findOpenStageEntry, formatRead, gdrFromResource, gdrRef, gdrUri, groupMembershipNames, groupSitesOf, guardMatches, guardsForDefinition, guardsForInstance, guardsForResource, guillemets2 as guillemets, hasSingleSubjectRequirement, hashDefinitionContent, humanize2 as humanize, inFlightFilter, initialFieldIssues, instanceDocId, instanceGuardQuery, instanceWatchesDocument, instancesGuardQuery, instancesQuery, isCascadeFired, isClaimExpired, isClientProjectUser, isComparisonOp, isDefinitionApplicable, isFilterScopedOut, isGdr, isInputSourced, isNotesEntry, isProjectUserNotFoundError, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTelemetryEnvDenied, isTerminalActivityStatus, isTerminalStage, isTodoListEntry, isTodoListItem, isUnprimed, lakeGuardId, lakePrincipalId, latestDefinitionsGroq, latestDeployedDefinitions, lintEffectOutputs, minReaderModelOf, missingRequiredInputs, modelVersionOf, narrateAutonomyWaits, noopTelemetry, parentRef, parseDefinitionInput, parseDefinitionSnapshot, parseGdr, parseGuardDocument, parseInstanceDocument, parseResourceGdr, processShellUserProperties, projectStartSliceRow, projectToWatchRef, quoted2 as quoted, readInstanceDoc, readsRaw, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, refsOf, rejectedRefTypes, releaseDocId, releaseRef, remediationsFor, requiredModelFeatures, requiredReaderModel, resolveAccess, resolveActor, resolveClientActor, resolveFieldEntry$1 as resolveFieldEntry, resourceAliasesToMap, resourceFromParsed, resourceGdr, retractStageGuards, sameResource, scalarValidationIssues, schemaTreeShape, sentenceCase, silentLogger, singleSubjectRequirementRefused, stageAutonomyOf, startFieldsParam, startKindOf, startRefusal, stripSystemFields, subjectDenialLabels, subscriptionDocument, subscriptionDocumentsForInstance, sweepStaleClaims, tagScopeFilter, terminalState, toBareId, tryParseGdr, unboundRequirementReads, unsatisfiedTransitionSummaries, validateDefinition, validateTag, verdictGuardsForInstance, wallClock, whatIfCondition2 as whatIfCondition, withAssignment, workflow };
12916
+ export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_KIND_DISPLAY, ACTOR_KINDS, ANONYMOUS_IDENTITY, AUTHORING_DISPLAY, ActionDisabledError, ActionParamsInvalidError, CONDITION_VARS, CONTEXT_ENTRY_DISPLAY, CascadeLimitError, ConcurrentCommitEffectOpsError, ConcurrentCompleteEffectError, ConcurrentEditFieldError, ConcurrentFireActionError, ContractViolationError, DATA_MODEL_CHANGES, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DEFAULT_CONTENT_PERSPECTIVE, DEFAULT_EFFECT_LEASE_MS, DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_TRANSITION_WHEN, DISPLAY, DRIVER_KINDS, DRIVER_KIND_DISPLAY, DefinitionInUseError, DefinitionNotFoundError, EFFECT_COMMIT_DISPATCH_CAP, EFFECT_COMMIT_QUEUE_DEPTH, ENGINE_API_VERSION, EXECUTION_KINDS, EXECUTOR_CLASSIFICATIONS, EXECUTOR_CLASSIFICATION_DISPLAY, EditFieldDeniedError, EffectCommitQueueOverflowError, EffectNotFoundError, EffectOpsInvalidError, EffectOutputsInvalidError, FIELD_KIND_DISPLAY, FILTER_SCOPE_VARS, FieldValueShapeError, GROUP_KINDS, GROUP_KIND_DISPLAY, GUARD_DOC_TYPE, GUARD_OWNER, GUARD_PREDICATE_VARS, HISTORY_DISPLAY, InitialFieldsInvalidError, InstanceNotFoundError, MAX_COUNTERFACTUAL_INDEX2 as MAX_COUNTERFACTUAL_INDEX, MissingHandlerError, ModelVersionAheadError, MutationGuardDeniedError, MutationGuardDocSchema, OP_DISPLAY, PartialGuardDeployError, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, ReaderModelAcknowledgementError, RefResourceUndeclaredError, RequiredFieldNotProvidedError, START_FILTER_VARS, START_REQUIREMENT_VARS, SYSTEM_IDENTITY, SpawnContractsInvalidError, StaleEffectClaimError, StartNotAllowedError, StartNotPrimedError, StartNotSettledError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowActionFired, WorkflowActivityReset, WorkflowDefinitionDeleted, WorkflowDefinitionDeployed, WorkflowEffectCompleted, WorkflowEffectStateReported, WorkflowEffectsDrained, WorkflowError, WorkflowFieldEdited, WorkflowInstanceAborted, WorkflowInstanceSchema, WorkflowInstanceStarted, WorkflowInstanceTicked, WorkflowStageSet, WorkflowStageTransitioned, WorkflowStateDivergedError, abortReason, acceptsDocumentType, aclPathForResource, actionDisabledDetail, actionRendering, actionVerdict, activityAutonomyOf, analyzeCondition2 as analyzeCondition, applicableDefinitions, assertReadableModel, assertReaderModelAcknowledgement, atomReadsDataset2 as atomReadsDataset, autonomySummary, availableActions, buildInitialFields, buildSnapshot, checklistLines, classifyPrincipalId, clientConfigFromResource, clientProjectUserDirectory, compileGuard, computeDiffEntries, conditionFieldReadNames, conditionSitesOf, contentDocQuery, contentDraftFallback, contentReleaseName, contextMap, createEngine, createTelemetryIntake, datasetResourceParts, defaultLoggerFactory, definitionDeployedData, definitionLookupGroq, definitionsListGroq, deniedGuardLabels, deniedGuardRefs, denyingGuards, deployStageGuards, deriveActivityKind, deriveExecutorClassification, deriveWorkflowAutonomy, describeAtom, describeAutonomyWait, describeCondition, describeDefinition, describeFieldInsight, describeNode, describeSite, describeSiteHeading, diagnoseInputFromEvaluation, diagnoseInstance, diffEntry, displayDescription, displayTitle, documentActionDenials, documentPrefilter, driverKind, effectOutputsMap, entryDocRefs, errorMessage, evaluateFromSnapshot, evaluateMutationGuard, evaluateStartFilter, expandResourceAliases, explainCondition2 as explainCondition, explainStartRequirement, extractDocumentId, fieldTreeShape, findCurrentActivityEntry, findOpenStageEntry, formatRead, gdrFromResource, gdrRef, gdrUri, groupMembershipNames, groupSitesOf, guardMatches, guardsForDefinition, guardsForInstance, guardsForResource, guillemets2 as guillemets, hasSingleSubjectRequirement, hashDefinitionContent, humanize2 as humanize, inFlightFilter, initialFieldIssues, instanceDocId, instanceGuardQuery, instanceWatchesDocument, instancesGuardQuery, instancesQuery, isCascadeFired, isClaimExpired, isClientProjectUser, isComparisonOp, isDefinitionApplicable, isFilterScopedOut, isGdr, isInputSourced, isNotesEntry, isProjectUserNotFoundError, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTelemetryEnvDenied, isTerminalActivityStatus, isTerminalStage, isTodoListEntry, isTodoListItem, isUnprimed, lakeGuardId, lakePrincipalId, latestDefinitionsGroq, latestDeployedDefinitions, lintEffectOutputs, minReaderModelOf, missingRequiredInputs, modelVersionOf, narrateAutonomyWaits, noopTelemetry, parentRef, parseDefinitionInput, parseDefinitionSnapshot, parseDefinitionSnapshotValue, parseGdr, parseGuardDocument, parseInstanceDocument, parseResourceGdr, processShellUserProperties, projectStartSliceRow, projectToWatchRef, quoted2 as quoted, readInstanceDoc, readsRaw, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, refsOf, rejectedRefTypes, releaseDocId, releaseRef, remediationsFor, requiredModelFeatures, requiredReaderModel, resolveAccess, resolveActor, resolveClientActor, resolveFieldEntry$1 as resolveFieldEntry, resourceAliasesToMap, resourceFromParsed, resourceGdr, retractStageGuards, sameResource, scalarValidationIssues, schemaTreeShape, sentenceCase, silentLogger, singleSubjectRequirementRefused, stageAutonomyOf, startFieldsParam, startKindOf, startRefusal, stripSystemFields, subjectDenialLabels, subscriptionDocument, subscriptionDocumentsForInstance, sweepStaleClaims, tagScopeFilter, terminalState, toBareId, tryParseGdr, unboundRequirementReads, unsatisfiedTransitionSummaries, validateDefinition, validateTag, verdictGuardsForInstance, wallClock, whatIfCondition2 as whatIfCondition, withAssignment, workflow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/workflow-engine",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Workflow / BPM engine for Sanity content — define workflows as data, run them as instances against a Sanity client.",
5
5
  "keywords": [
6
6
  "bpm",