@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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { terminalState, andConditions, deriveActivityKind, parseDefinitionSnapshot, CALLER_BOUND_VARS, START_ALLOWED_VARS, CONDITION_VARS, SUBJECT_HAS_IN_FLIGHT_INSTANCE_VAR, isSubjectEntry, isUnevaluable, ContractViolationError, isStartableDefinition, conditionFieldReadNames, rethrowWithContext, conditionParameterNames, isGdr, WORKFLOW_INSTANCE_TYPE, START_FILTER_VARS, gdrFromResource, selfGdr, isSingleDocRefKind, parentRef, actorFulfillsRole, toBareId, WorkflowError, sameResource, resourceFromParsed, tryParseGdr, isTerminalActivityStatus, errorMessage, FieldValueShapeError, validateFieldValue, validateFieldAppendItem, evaluateCondition, isSingleDocRefEntry, choiceValueIssues, scalarValidationIssues, StoredFieldOpSchema, formatIssues, conditionSyntaxIssues, checkWorkflowInvariants, formatIssuePath, isGuardReadExpr, conditionEffectReads, EFFECTS_READ, datasetResourceParts, evaluatePredicates, WORKFLOW_DEFINITION_TYPE, tagScopeFilter, isCascadeFired, parseGdr, isGdrUri, gdrRef, isInputSourced, checkFieldValue, toPhysicalGdr, isBareSeedId, tolerantEntries, NonEmptyString, FIELD_VALUE_KINDS, tolerantObject, ActorShape, IsoTimestamp, ACTIVITY_STATUSES, GdrShape, DRIVER_KINDS, FIELD_SCOPES, fieldValueSchemas, parsePersistedDoc, assertReadableModel, InstanceNotFoundError, modelStampFor, evaluateConditionOutcome, runGroq, FIELD_READ, MUTATION_GUARD_ACTIONS, resourceGdr, minReaderModelOf, resourceFromGdrUri, refTypeIssues, rejectedRefTypes, DOCUMENT_VALUE_PERMISSIONS, 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";
1
+ import { terminalState, andConditions, deriveActivityKind, parseDefinitionSnapshot, CALLER_BOUND_VARS, START_ALLOWED_VARS, CONDITION_VARS, SUBJECT_HAS_IN_FLIGHT_INSTANCE_VAR, isSubjectEntry, isUnevaluable, ContractViolationError, isStartableDefinition, conditionFieldReadNames, rethrowWithContext, conditionParameterNames, isGdr, WORKFLOW_INSTANCE_TYPE, START_FILTER_VARS, gdrFromResource, selfGdr, isSingleDocRefKind, parentRef, actorFulfillsRole, toBareId, WorkflowError, sameResource, resourceFromParsed, tryParseGdr, isTerminalActivityStatus, errorMessage, FieldValueShapeError, validateFieldValue, validateFieldAppendItem, evaluateCondition, isSingleDocRefEntry, choiceValueIssues, scalarValidationIssues, StoredFieldOpSchema, formatIssues, conditionSyntaxIssues, checkWorkflowInvariants, formatIssuePath, isGuardReadExpr, conditionEffectReads, EFFECTS_READ, datasetResourceParts, evaluatePredicates, WORKFLOW_DEFINITION_TYPE, tagScopeFilter, isCascadeFired, parseGdr, isGdrUri, gdrRef, isInputSourced, checkFieldValue, VersionSpecificDatasetGdrError, toPhysicalGdr, isBareSeedId, tolerantEntries, NonEmptyString, FIELD_VALUE_KINDS, tolerantObject, ActorShape, IsoTimestamp, ACTIVITY_STATUSES, GdrShape, DRIVER_KINDS, FIELD_SCOPES, fieldValueSchemas, parsePersistedDoc, assertReadableModel, InstanceNotFoundError, modelStampFor, evaluateConditionOutcome, runGroq, FIELD_READ, MUTATION_GUARD_ACTIONS, resourceGdr, minReaderModelOf, resourceFromGdrUri, refTypeIssues, rejectedRefTypes, DOCUMENT_VALUE_PERMISSIONS, 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
3
  import { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTOR_KINDS, 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, 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";
4
4
 
@@ -4001,12 +4001,27 @@ function assertInputValueShape(entry, value) {
4001
4001
  function assertGdrShape(value, context) {
4002
4002
  if (typeof value != "object" || value === null) throw new ContractViolationError(`Invalid GDR for ${context}: expected { id: "<scheme>:...", type: "<schema>" }, got ${typeof value}.`);
4003
4003
  const v2 = value;
4004
- if (typeof v2.id != "string" || !isGdrUri(v2.id)) throw new ContractViolationError(`Invalid GDR for ${context}: \`id\` must be a GDR URI ("<scheme>:<...id-parts>" with scheme dataset|canvas|media-library|dashboard). Got ${JSON.stringify(v2.id)}. Construct via \`gdrFromResource\` / \`refDataset\` / \`refCanvas\` etc. — bare document ids are not accepted.`);
4004
+ if (typeof v2.id != "string") throw invalidGdrUriError(context, v2.id);
4005
+ try {
4006
+ parseGdr(v2.id);
4007
+ } catch (error) {
4008
+ throw error instanceof VersionSpecificDatasetGdrError ? new ContractViolationError(`Invalid GDR for ${context}: ${error.message}`) : invalidGdrUriError(context, v2.id);
4009
+ }
4005
4010
  if (typeof v2.type != "string" || v2.type.length === 0) throw new ContractViolationError(`Invalid GDR for ${context}: \`type\` (schema name) must be a non-empty string. Got ${JSON.stringify(v2.type)}.`);
4006
4011
  }
4007
4012
 
4013
+ function invalidGdrUriError(context, id) {
4014
+ return new ContractViolationError(`Invalid GDR for ${context}: \`id\` must be a GDR URI ("<scheme>:<...id-parts>" with scheme dataset|canvas|media-library|dashboard). Got ${JSON.stringify(id)}. Construct via \`gdrFromResource\` / \`refDataset\` / \`refCanvas\` etc. — bare document ids are not accepted.`);
4015
+ }
4016
+
4008
4017
  function normalizeQueryResult({entryType: entryType, raw: raw, workflowResource: workflowResource}) {
4009
- return raw == null ? raw : isSingleDocRefKind(entryType) ? coerceToGdr(raw, workflowResource) : entryType === "doc.refs" ? Array.isArray(raw) ? raw.map(item => coerceToGdr(item, workflowResource)).filter(v2 => v2 !== null) : [] : raw;
4018
+ if (raw == null) return raw;
4019
+ try {
4020
+ return isSingleDocRefKind(entryType) ? coerceToGdr(raw, workflowResource) : entryType === "doc.refs" ? Array.isArray(raw) ? raw.map(item => coerceToGdr(item, workflowResource)).filter(v2 => v2 !== null) : [] : raw;
4021
+ } catch (error) {
4022
+ if (error instanceof VersionSpecificDatasetGdrError) return raw;
4023
+ throw error;
4024
+ }
4010
4025
  }
4011
4026
 
4012
4027
  function coerceGdrShape(raw, workflowResource) {
@@ -4462,65 +4477,119 @@ function buildInstanceBase(args) {
4462
4477
  }
4463
4478
 
4464
4479
  async function hydrateSnapshot(args) {
4465
- const {client: client, clientForGdr: clientForGdr, instance: instance, overlay: overlay} = args, loaded = [], visited = /* @__PURE__ */ new Set, loadInto = async (uri, perspective) => {
4466
- if (visited.has(uri)) return;
4467
- const held = overlay?.get(uri);
4468
- if (held !== void 0) {
4469
- loaded.push(held), visited.add(uri);
4470
- return;
4471
- }
4472
- const fetched = await loadByGdr({
4473
- defaultClient: client,
4474
- clientForGdr: clientForGdr,
4475
- defaultResource: instance.workflowResource,
4476
- uri: uri,
4477
- perspective: perspective
4478
- });
4479
- fetched && (loaded.push(fetched), visited.add(uri));
4480
- };
4480
+ const {client: client, clientForGdr: clientForGdr, instance: instance, overlay: overlay} = args, loaded = [], visited = /* @__PURE__ */ new Set;
4481
4481
  loaded.push({
4482
4482
  doc: instance,
4483
4483
  resource: instance.workflowResource
4484
4484
  }), visited.add(selfGdr(instance));
4485
- for (const ref of collectWatchRefs(instance)) await loadInto(ref.id, readsRaw(ref) ? "raw" : instance.perspective ?? DEFAULT_CONTENT_PERSPECTIVE);
4485
+ const {pending: pending, ordered: ordered} = planReads({
4486
+ client: client,
4487
+ clientForGdr: clientForGdr,
4488
+ instance: instance,
4489
+ overlay: overlay,
4490
+ visited: visited
4491
+ }), fetched = await readPending(pending);
4492
+ for (const entry of ordered) if (!isPendingRead(entry)) loaded.push(entry); else {
4493
+ const doc = fetched.get(entry);
4494
+ doc !== void 0 && loaded.push({
4495
+ doc: doc,
4496
+ resource: entry.resource
4497
+ });
4498
+ }
4486
4499
  return buildSnapshot({
4487
4500
  docs: loaded
4488
4501
  });
4489
4502
  }
4490
4503
 
4491
- async function loadByGdr({defaultClient: defaultClient, clientForGdr: clientForGdr, defaultResource: defaultResource, uri: uri, perspective: perspective}) {
4492
- const parsed = tryParseGdr(uri);
4493
- if (parsed === void 0) {
4494
- const doc2 = await readDoc({
4495
- client: defaultClient,
4496
- id: uri,
4497
- perspective: perspective
4498
- });
4499
- return doc2 ? {
4500
- doc: doc2,
4501
- resource: defaultResource
4502
- } : null;
4504
+ function planReads(args) {
4505
+ const {client: client, clientForGdr: clientForGdr, instance: instance, overlay: overlay, visited: visited} = args, pending = [], ordered = [];
4506
+ for (const ref of collectWatchRefs(instance)) {
4507
+ if (visited.has(ref.id)) continue;
4508
+ visited.add(ref.id);
4509
+ const held = overlay?.get(ref.id);
4510
+ if (held !== void 0) ordered.push(held); else {
4511
+ const read = routeRead({
4512
+ defaultClient: client,
4513
+ clientForGdr: clientForGdr,
4514
+ defaultResource: instance.workflowResource,
4515
+ uri: ref.id,
4516
+ perspective: readsRaw(ref) ? "raw" : instance.perspective ?? DEFAULT_CONTENT_PERSPECTIVE
4517
+ });
4518
+ pending.push(read), ordered.push(read);
4519
+ }
4503
4520
  }
4504
- const routed = clientForGdr(parsed), doc = await readDoc({
4505
- client: routed,
4521
+ return {
4522
+ pending: pending,
4523
+ ordered: ordered
4524
+ };
4525
+ }
4526
+
4527
+ function isPendingRead(entry) {
4528
+ return "client" in entry;
4529
+ }
4530
+
4531
+ const SNAPSHOT_READ_BATCH_SIZE = 100, SNAPSHOT_READ_CONCURRENCY = 4, snapshotDocsQuery = "*[_id in $ids]";
4532
+
4533
+ function routeRead({defaultClient: defaultClient, clientForGdr: clientForGdr, defaultResource: defaultResource, uri: uri, perspective: perspective}) {
4534
+ const parsed = tryParseGdr(uri);
4535
+ return parsed === void 0 ? {
4536
+ client: defaultClient,
4537
+ id: uri,
4538
+ perspective: perspective,
4539
+ resource: defaultResource
4540
+ } : {
4541
+ client: clientForGdr(parsed),
4506
4542
  id: parsed.documentId,
4507
- perspective: perspective
4508
- });
4509
- return doc ? {
4510
- doc: doc,
4543
+ perspective: perspective,
4511
4544
  resource: resourceFromParsed(parsed)
4512
- } : null;
4545
+ };
4513
4546
  }
4514
4547
 
4515
- async function readDoc({client: client, id: id, perspective: perspective}) {
4516
- if (perspective === "raw") {
4517
- const doc2 = await client.getDocument(id) ?? null;
4518
- return doc2 ? doc2._type === WORKFLOW_INSTANCE_TYPE ? readInstanceDoc(doc2) : assertReadableModel(doc2) : null;
4548
+ async function readPending(reads) {
4549
+ const batches = groupReads(reads).flatMap(group => chunks(group.reads, SNAPSHOT_READ_BATCH_SIZE).map(batch => ({
4550
+ group: group,
4551
+ batch: batch
4552
+ }))), results = [];
4553
+ for (const wave of chunks(batches, SNAPSHOT_READ_CONCURRENCY)) results.push(...await Promise.all(wave.map(readBatch)));
4554
+ return new Map(results.flat());
4555
+ }
4556
+
4557
+ async function readBatch(args) {
4558
+ const {group: group, batch: batch} = args, ids = batch.map(read => read.id), docs = await group.client.fetch(snapshotDocsQuery, {
4559
+ ids: ids
4560
+ }, {
4561
+ perspective: group.perspective
4562
+ }), byId = new Map(docs.map(doc => [ doc._id, validateRawDoc(doc, group.perspective) ]));
4563
+ return batch.flatMap(read => {
4564
+ const doc = byId.get(read.id);
4565
+ return doc === void 0 ? [] : [ [ read, doc ] ];
4566
+ });
4567
+ }
4568
+
4569
+ function validateRawDoc(doc, perspective) {
4570
+ return perspective !== "raw" ? doc : doc._type === WORKFLOW_INSTANCE_TYPE ? readInstanceDoc(doc) : assertReadableModel(doc);
4571
+ }
4572
+
4573
+ function groupReads(reads) {
4574
+ const byClient = /* @__PURE__ */ new Map;
4575
+ for (const read of reads) {
4576
+ let clientGroups = byClient.get(read.client);
4577
+ clientGroups === void 0 && (clientGroups = /* @__PURE__ */ new Map, byClient.set(read.client, clientGroups));
4578
+ const key = JSON.stringify(read.perspective);
4579
+ let group = clientGroups.get(key);
4580
+ group === void 0 && (group = {
4581
+ client: read.client,
4582
+ perspective: read.perspective,
4583
+ reads: []
4584
+ }, clientGroups.set(key, group)), group.reads.push(read);
4519
4585
  }
4520
- const {query: query, params: params} = contentDocQuery(id);
4521
- return await client.fetch(query, params, {
4522
- perspective: perspective
4523
- }) ?? null;
4586
+ return [ ...byClient.values() ].flatMap(groups => [ ...groups.values() ]);
4587
+ }
4588
+
4589
+ function chunks(values, size) {
4590
+ return Array.from({
4591
+ length: Math.ceil(values.length / size)
4592
+ }, (_, index) => values.slice(index * size, (index + 1) * size));
4524
4593
  }
4525
4594
 
4526
4595
  function collectEntryDocUris(resolvedFieldEntries) {
@@ -4924,7 +4993,7 @@ function unwrapPatch(patch) {
4924
4993
  return typeof patch == "object" && patch !== null && RAW_PATCH in patch ? patch[RAW_PATCH] : patch;
4925
4994
  }
4926
4995
 
4927
- const wrapperCache = /* @__PURE__ */ new WeakMap, RAW_CLIENT = /* @__PURE__ */ Symbol("workflow-engine.raw-client");
4996
+ const wrapperCache = /* @__PURE__ */ new WeakMap, effectHandlerClientCache = /* @__PURE__ */ new WeakMap, RAW_CLIENT = /* @__PURE__ */ Symbol("workflow-engine.raw-client");
4928
4997
 
4929
4998
  function unwrapRequestTag(client) {
4930
4999
  let current = client;
@@ -4941,6 +5010,30 @@ function withRequestTag(client, fallback) {
4941
5010
  return byTag.set(fallback, wrapped), wrapped;
4942
5011
  }
4943
5012
 
5013
+ function effectHandlerClient(client) {
5014
+ const cached = effectHandlerClientCache.get(client);
5015
+ if (cached !== void 0) return cached;
5016
+ let tagged;
5017
+ if (client.withConfig === void 0) tagged = withRequestTag(client, REQUEST_TAG.effect); else {
5018
+ const prefix = clientRequestTagPrefix(client), effectTag = composeRequestTag(prefix, REQUEST_TAG.effect);
5019
+ tagged = client.withConfig({
5020
+ requestTagPrefix: effectTag
5021
+ });
5022
+ }
5023
+ return effectHandlerClientCache.set(client, tagged), tagged;
5024
+ }
5025
+
5026
+ function effectHandlerResolver(resolver) {
5027
+ return mapResourceClientResolver(resolver, effectHandlerClient);
5028
+ }
5029
+
5030
+ function mapResourceClientResolver(resolver, mapClient) {
5031
+ if (resolver !== void 0) return parsed => {
5032
+ const client = resolver(parsed);
5033
+ return client === void 0 ? void 0 : mapClient(client);
5034
+ };
5035
+ }
5036
+
4944
5037
  function isWorkflowsFamilyPrefix(prefix) {
4945
5038
  return prefix === void 0 ? !1 : prefix === "sanity.workflows" || prefix.startsWith("sanity.workflows.") || prefix === "sanity.workflows-mcp";
4946
5039
  }
@@ -4950,8 +5043,18 @@ function clientRequestTagPrefix(client) {
4950
5043
  return typeof probe.config == "function" ? probe.config().requestTagPrefix : void 0;
4951
5044
  }
4952
5045
 
5046
+ function composeRequestTag(prefix, tag) {
5047
+ if (prefix === void 0) return tag;
5048
+ const relative = isWorkflowsFamilyPrefix(prefix) ? stripWorkflowRoot(tag) : tag;
5049
+ return `${prefix}.${relative}`;
5050
+ }
5051
+
5052
+ function stripWorkflowRoot(tag) {
5053
+ return tag.startsWith("workflow.") ? tag.slice(9) : tag;
5054
+ }
5055
+
4953
5056
  function buildTaggedClient(client, fallback) {
4954
- const strip = isWorkflowsFamilyPrefix(clientRequestTagPrefix(unwrapRequestTag(client))), normalize = tag => strip && tag.startsWith("workflow.") ? tag.slice(9) : tag, stamp = options => options === void 0 ? {
5057
+ const strip = isWorkflowsFamilyPrefix(clientRequestTagPrefix(unwrapRequestTag(client))), normalize = tag => strip ? stripWorkflowRoot(tag) : tag, stamp = options => options === void 0 ? {
4955
5058
  tag: normalize(fallback)
4956
5059
  } : options.tag === void 0 ? {
4957
5060
  ...options,
@@ -4981,8 +5084,7 @@ function buildTaggedClient(client, fallback) {
4981
5084
  commit: options => target.commit(stamp(options))
4982
5085
  };
4983
5086
  return wrapped;
4984
- };
4985
- return {
5087
+ }, overrides = {
4986
5088
  [RAW_CLIENT]: unwrapRequestTag(client),
4987
5089
  fetch: (query, params, options) => client.fetch(query, params, stamp(options)),
4988
5090
  getDocument: (id, options) => client.getDocument(id, stamp(options)),
@@ -4999,6 +5101,14 @@ function buildTaggedClient(client, fallback) {
4999
5101
  request: opts => client.request(stamp(opts))
5000
5102
  } : {}
5001
5103
  };
5104
+ return new Proxy(client, {
5105
+ has: (target, property) => Object.hasOwn(overrides, property) || property in target,
5106
+ get: (target, property) => {
5107
+ if (Object.hasOwn(overrides, property)) return Reflect.get(overrides, property, overrides);
5108
+ const value = Reflect.get(target, property, target);
5109
+ return typeof value == "function" ? value.bind(target) : value;
5110
+ }
5111
+ });
5002
5112
  }
5003
5113
 
5004
5114
  const pinCache = /* @__PURE__ */ new WeakMap, enginePinned = /* @__PURE__ */ new WeakSet;
@@ -5013,10 +5123,7 @@ function pinApiVersion(client) {
5013
5123
  }
5014
5124
 
5015
5125
  function taggedResolver(resolver, fallback) {
5016
- if (resolver !== void 0) return parsed => {
5017
- const client = resolver(parsed);
5018
- return client === void 0 ? void 0 : withRequestTag(pinApiVersion(client), fallback);
5019
- };
5126
+ return mapResourceClientResolver(resolver, client => withRequestTag(pinApiVersion(client), fallback));
5020
5127
  }
5021
5128
 
5022
5129
  function taggedScope(args, tag) {
@@ -5046,16 +5153,20 @@ function guardsForResource(client) {
5046
5153
  });
5047
5154
  }
5048
5155
 
5049
- function instanceGuardQuery(instanceId) {
5156
+ function instancesGuardQuery(instanceIds) {
5050
5157
  return {
5051
- query: "*[_type == $guardType && sourceInstanceId == $instanceId]",
5158
+ query: "*[_type == $guardType && sourceInstanceId in $instanceIds] | order(_id asc)",
5052
5159
  params: {
5053
5160
  guardType: GUARD_DOC_TYPE,
5054
- instanceId: instanceId
5161
+ instanceIds: [ ...instanceIds ]
5055
5162
  }
5056
5163
  };
5057
5164
  }
5058
5165
 
5166
+ function instanceGuardQuery(instanceId) {
5167
+ return instancesGuardQuery([ instanceId ]);
5168
+ }
5169
+
5059
5170
  function verdictGuardsForInstance(client, instanceId) {
5060
5171
  const {query: query, params: params} = instanceGuardQuery(instanceId);
5061
5172
  return fetchGuards({
@@ -5157,7 +5268,7 @@ function dedupById(guards) {
5157
5268
  return [ ...new Map(guards.map(g => [ g._id, g ])).values() ].sort((a, b) => a._id.localeCompare(b._id));
5158
5269
  }
5159
5270
 
5160
- const GUARD_OWNER = "robot:workflow-engine";
5271
+ const GUARD_OWNER = "robot:workflow-engine", DELETE_CHUNK_SIZE = 200;
5161
5272
 
5162
5273
  function resolveGuardRoute(guard, ctx) {
5163
5274
  const targets = resolveIdRefTargets(guard.match.idRefs, ctx);
@@ -5210,10 +5321,9 @@ function resolveGuard({guard: guard, instance: instance, stageName: stageName, n
5210
5321
  };
5211
5322
  }
5212
5323
 
5213
- async function upsertGuard(client, doc) {
5214
- if (!await client.getDocument(doc._id, {
5215
- tag: REQUEST_TAG.guardDeploy
5216
- })) {
5324
+ async function upsertGuard(args) {
5325
+ const {client: client, doc: doc, exists: exists} = args;
5326
+ if (!exists) {
5217
5327
  await client.create(doc, {
5218
5328
  ...SYNC_COMMIT,
5219
5329
  tag: REQUEST_TAG.guardDeploy
@@ -5239,7 +5349,8 @@ function resolvedStageGuards(args) {
5239
5349
  });
5240
5350
  resolved !== null && out.push({
5241
5351
  client: args.clientForGdr(resolved.routeGdr),
5242
- doc: resolved.doc
5352
+ resourceKey: resourceGdr(resourceFromParsed(resolved.routeGdr)),
5353
+ value: resolved.doc
5243
5354
  });
5244
5355
  }
5245
5356
  return out;
@@ -5256,12 +5367,54 @@ function resolvedStageGuardRoutes(args) {
5256
5367
  const route = resolveGuardRoute(guard, ctx);
5257
5368
  route !== null && out.push({
5258
5369
  client: args.clientForGdr(route.routeGdr),
5259
- guardId: route.guardId
5370
+ resourceKey: resourceGdr(resourceFromParsed(route.routeGdr)),
5371
+ value: route.guardId
5260
5372
  });
5261
5373
  }
5262
5374
  return out;
5263
5375
  }
5264
5376
 
5377
+ function groupByResource(routed) {
5378
+ const groups = /* @__PURE__ */ new Map;
5379
+ for (const item of routed) {
5380
+ const existing = groups.get(item.resourceKey);
5381
+ if (existing !== void 0) {
5382
+ existing.values.push(item.value);
5383
+ continue;
5384
+ }
5385
+ groups.set(item.resourceKey, {
5386
+ client: item.client,
5387
+ resourceKey: item.resourceKey,
5388
+ values: [ item.value ]
5389
+ });
5390
+ }
5391
+ return [ ...groups.values() ];
5392
+ }
5393
+
5394
+ async function existingGuardIds(groups) {
5395
+ const entries = await Promise.all(groups.map(async ({client: client, resourceKey: resourceKey, values: values}) => {
5396
+ const ids = values.map(doc => doc._id), existing = await client.fetch("*[_id in $ids]._id", {
5397
+ ids: ids
5398
+ }, {
5399
+ tag: REQUEST_TAG.guardDeploy
5400
+ });
5401
+ return [ resourceKey, new Set(existing) ];
5402
+ }));
5403
+ return new Map(entries);
5404
+ }
5405
+
5406
+ async function observedGuards(groups) {
5407
+ const entries = await Promise.all(groups.map(async ({client: client, resourceKey: resourceKey, values: ids}) => {
5408
+ const guards = await client.fetch("*[_id in $ids]{_id, predicate, _rev}", {
5409
+ ids: ids
5410
+ }, {
5411
+ tag: REQUEST_TAG.guardRetract
5412
+ });
5413
+ return [ resourceKey, new Map(guards.map(guard => [ guard._id, guard ])) ];
5414
+ }));
5415
+ return new Map(entries);
5416
+ }
5417
+
5265
5418
  async function committedInstance(args) {
5266
5419
  return getInstanceDocument(args.client, args.instance._id);
5267
5420
  }
@@ -5269,10 +5422,15 @@ async function committedInstance(args) {
5269
5422
  async function deployStageGuards(args) {
5270
5423
  const live = await committedInstance(args);
5271
5424
  if (live === void 0 || live.currentStage !== args.stageName || live.abortedAt !== void 0) return;
5425
+ const routed = resolvedStageGuards(args), existingByResource = await existingGuardIds(groupByResource(routed));
5272
5426
  let deployed = 0;
5273
- for (const {client: client, doc: doc} of resolvedStageGuards(args)) {
5427
+ for (const {client: client, resourceKey: resourceKey, value: doc} of routed) {
5274
5428
  try {
5275
- await upsertGuard(client, doc);
5429
+ await upsertGuard({
5430
+ client: client,
5431
+ doc: doc,
5432
+ exists: existingByResource.get(resourceKey)?.has(doc._id) ?? !1
5433
+ });
5276
5434
  } catch (cause) {
5277
5435
  throw deployed > 0 ? new PartialGuardDeployError({
5278
5436
  stageName: args.stageName,
@@ -5285,13 +5443,11 @@ async function deployStageGuards(args) {
5285
5443
  }
5286
5444
 
5287
5445
  async function retractStageGuards(args) {
5288
- const observed = [];
5289
- for (const {client: client, guardId: guardId} of resolvedStageGuardRoutes(args)) {
5290
- const guard = await client.getDocument(guardId, {
5291
- tag: REQUEST_TAG.guardRetract
5292
- });
5446
+ const observed = [], routed = resolvedStageGuardRoutes(args), guardsByResource = await observedGuards(groupByResource(routed));
5447
+ for (const {client: client, resourceKey: resourceKey, value: guardId} of routed) {
5448
+ const guard = guardsByResource.get(resourceKey)?.get(guardId);
5293
5449
  if (guard) {
5294
- if (guard._rev === void 0) throw new Error(`Cannot retract guard ${guardId}: persisted document has no revision`);
5450
+ if (guard._rev === void 0 || guard._rev === null) throw new Error(`Cannot retract guard ${guardId}: persisted document has no revision`);
5295
5451
  observed.push({
5296
5452
  client: client,
5297
5453
  guardId: guardId,
@@ -5322,10 +5478,11 @@ async function deleteOrphanedDefinitionGuards(args) {
5322
5478
  let count = 0;
5323
5479
  for (const {client: resourceClient, guards: guards} of perClient) {
5324
5480
  const own = guards.filter(guard => guard.sourceInstanceId.startsWith(ownPartitionPrefix));
5325
- if (own.length === 0) continue;
5326
- const tx = resourceClient.transaction();
5327
- for (const guard of own) tx.delete(guard._id);
5328
- await tx.commit(), count += own.length;
5481
+ if (own.length !== 0) for (let start = 0; start < own.length; start += DELETE_CHUNK_SIZE) {
5482
+ const chunk = own.slice(start, start + DELETE_CHUNK_SIZE), tx = resourceClient.transaction();
5483
+ for (const guard of chunk) tx.delete(guard._id);
5484
+ await tx.commit(), count += chunk.length;
5485
+ }
5329
5486
  }
5330
5487
  return count;
5331
5488
  }
@@ -7757,26 +7914,26 @@ async function subjectResourceGrants(args) {
7757
7914
  async function evaluateInstance(args) {
7758
7915
  const {client: client, tag: tag, workflowResource: workflowResource, instanceId: instanceId, resourceClients: resourceClients} = args, now = (args.clock ?? wallClock)();
7759
7916
  validateTag(tag);
7760
- const {actor: actor, grants: grants} = await resolveAccess(client, {
7917
+ const [access, instance] = await Promise.all([ resolveAccess(client, {
7761
7918
  ...args.grantsFromPath !== void 0 ? {
7762
7919
  grantsFromPath: args.grantsFromPath
7763
7920
  } : {}
7764
- }), instance = await reload({
7921
+ }), reload({
7765
7922
  client: client,
7766
7923
  instanceId: instanceId,
7767
7924
  tag: tag
7768
- }), definition = parseDefinitionSnapshot(instance), clientForGdr = buildClientForGdr({
7925
+ }) ]), {actor: actor, grants: grants} = access, definition = parseDefinitionSnapshot(instance), clientForGdr = buildClientForGdr({
7769
7926
  client: client,
7770
7927
  workflowResource: workflowResource,
7771
7928
  resourceClients: resourceClients
7772
- }), snapshot = await hydrateSnapshot({
7929
+ }), [snapshot, guards, resourceGrants] = await Promise.all([ hydrateSnapshot({
7773
7930
  client: client,
7774
7931
  clientForGdr: clientForGdr,
7775
7932
  instance: instance
7776
- }), guards = await verdictGuardsForInstance(client, instance._id), resourceGrants = await subjectResourceGrants({
7933
+ }), verdictGuardsForInstance(client, instance._id), subjectResourceGrants({
7777
7934
  clientForGdr: clientForGdr,
7778
7935
  instance: instance
7779
- });
7936
+ }) ]);
7780
7937
  return evaluateFromSnapshot({
7781
7938
  instance: instance,
7782
7939
  definition: definition,
@@ -8306,14 +8463,14 @@ function documentPrefilter(documents, params) {
8306
8463
 
8307
8464
  function documentArm(filter, params) {
8308
8465
  if (filter.documents === void 0 && filter.document === void 0) return;
8309
- const documents = [ ...filter.documents ?? [], ...filter.document !== void 0 ? [ filter.document ] : [] ];
8466
+ const documents = [ .../* @__PURE__ */ new Set([ ...filter.documents ?? [], ...filter.document !== void 0 ? [ filter.document ] : [] ]) ].sort();
8310
8467
  return documentPrefilter(documents, params);
8311
8468
  }
8312
8469
 
8313
8470
  function idsArm(filter, params) {
8314
8471
  if (filter.ids !== void 0) {
8315
8472
  for (const id of filter.ids) if (isGdrUri(id)) throw new ContractViolationError(`instancesQuery: every id must be a bare instance document id (an instance's _id is never resource-qualified); got a GDR URI: ${JSON.stringify(id)}`);
8316
- return params.ids = [ ...filter.ids ], "_id in $ids";
8473
+ return params.ids = [ ...new Set(filter.ids) ].sort(), "_id in $ids";
8317
8474
  }
8318
8475
  }
8319
8476
 
@@ -10524,7 +10681,7 @@ function isCancelledCompletion(data) {
10524
10681
  }
10525
10682
 
10526
10683
  async function drainEffectsInternal(args) {
10527
- const {tag: tag, workflowResource: workflowResource, instanceId: instanceId, effectHandlers: effectHandlers, missingHandler: missingHandler, logger: logger, handlerClient: handlerClient, handlerResourceClients: handlerResourceClients} = args, cascadeTelemetry = drainCascadeTelemetry(args.telemetry), {client: client, resourceClients: resourceClients} = taggedScope(args, REQUEST_TAG.drain), leaseMs = args.leaseMs ?? DEFAULT_EFFECT_LEASE_MS, clock = args.clock ?? wallClock, routeGdr = buildClientForGdr({
10684
+ const {tag: tag, workflowResource: workflowResource, instanceId: instanceId, effectHandlers: effectHandlers, missingHandler: missingHandler, logger: logger, handlerClient: rawHandlerClient, handlerResourceClients: rawHandlerResourceClients} = args, cascadeTelemetry = drainCascadeTelemetry(args.telemetry), {client: client, resourceClients: resourceClients} = taggedScope(args, REQUEST_TAG.drain), leaseMs = args.leaseMs ?? DEFAULT_EFFECT_LEASE_MS, clock = args.clock ?? wallClock, handlerClient = effectHandlerClient(rawHandlerClient), handlerResourceClients = effectHandlerResolver(rawHandlerResourceClients), routeGdr = buildClientForGdr({
10528
10685
  client: handlerClient,
10529
10686
  workflowResource: workflowResource,
10530
10687
  resourceClients: handlerResourceClients
@@ -10890,22 +11047,30 @@ function createInstanceSession(args) {
10890
11047
  }, tickScope = opScope(REQUEST_TAG.tick), fireScope = opScope(REQUEST_TAG.fireAction), editScope = opScope(REQUEST_TAG.editField), evalScope = opScope(REQUEST_TAG.evaluate);
10891
11048
  let overlay = /* @__PURE__ */ new Map;
10892
11049
  const previews = /* @__PURE__ */ new Map;
10893
- let heldGuards = [], committing = !1, buffered, deferredUpdateError;
10894
- const selfUri = () => gdrFromResource(instance.workflowResource, instance._id), applyUpdate = docs => {
10895
- const next = /* @__PURE__ */ new Map;
10896
- for (const ld of docs) {
10897
- const owned = {
10898
- doc: structuredClone(ld.doc),
10899
- resource: ld.resource
10900
- }, uri = gdrFromResource(owned.resource, owned.doc._id);
10901
- if (uri === selfUri()) {
10902
- const rawStamp = owned.doc._updatedAt;
10903
- !isParseableInstant(rawStamp) || owned.doc._type !== WORKFLOW_INSTANCE_TYPE ? asHeldInstance(owned.doc) : Date.parse(rawStamp) > Date.parse(instance._updatedAt) && (instance = asHeldInstance(owned.doc));
10904
- continue;
10905
- }
10906
- next.set(uri, owned);
11050
+ let heldGuards = [], committing = !1, buffered;
11051
+ const bufferedDocuments = /* @__PURE__ */ new Map;
11052
+ let deferredUpdateError;
11053
+ const flushDeferredError = () => {
11054
+ if (deferredUpdateError === void 0) return;
11055
+ const failure = deferredUpdateError;
11056
+ throw deferredUpdateError = void 0, failure;
11057
+ }, selfUri = () => gdrFromResource(instance.workflowResource, instance._id), applyDocument = (ld, target) => {
11058
+ const owned = {
11059
+ doc: structuredClone(ld.doc),
11060
+ resource: ld.resource
11061
+ }, uri = gdrFromResource(owned.resource, owned.doc._id);
11062
+ if (uri === selfUri()) {
11063
+ const rawStamp = owned.doc._updatedAt;
11064
+ !isParseableInstant(rawStamp) || owned.doc._type !== WORKFLOW_INSTANCE_TYPE ? asHeldInstance(owned.doc) : Date.parse(rawStamp) > Date.parse(instance._updatedAt) && (instance = asHeldInstance(owned.doc));
11065
+ return;
10907
11066
  }
11067
+ target.set(uri, owned);
11068
+ }, applyUpdate = docs => {
11069
+ const next = /* @__PURE__ */ new Map;
11070
+ for (const ld of docs) applyDocument(ld, next);
10908
11071
  overlay = next;
11072
+ }, applyDocumentUpdate = doc => {
11073
+ applyDocument(doc, overlay);
10909
11074
  }, access = () => resolveAccess(client, {
10910
11075
  ...args.grantsFromPath !== void 0 ? {
10911
11076
  grantsFromPath: args.grantsFromPath
@@ -11031,6 +11196,12 @@ function createInstanceSession(args) {
11031
11196
  deferredUpdateError = err;
11032
11197
  }
11033
11198
  }
11199
+ for (const next of bufferedDocuments.values()) try {
11200
+ applyDocumentUpdate(next);
11201
+ } catch (err) {
11202
+ deferredUpdateError = err;
11203
+ }
11204
+ bufferedDocuments.clear();
11034
11205
  }
11035
11206
  };
11036
11207
  return {
@@ -11038,15 +11209,26 @@ function createInstanceSession(args) {
11038
11209
  return subscriptionDocumentsForInstance(instance);
11039
11210
  },
11040
11211
  update(docs) {
11041
- if (committing) buffered = docs; else try {
11212
+ if (committing) buffered = docs, bufferedDocuments.clear(); else try {
11042
11213
  applyUpdate(docs);
11043
11214
  } catch (err) {
11044
11215
  throw deferredUpdateError = void 0, err;
11045
11216
  }
11046
- if (deferredUpdateError !== void 0) {
11047
- const failure = deferredUpdateError;
11048
- throw deferredUpdateError = void 0, failure;
11217
+ flushDeferredError();
11218
+ },
11219
+ updateDocument(doc) {
11220
+ if (committing) {
11221
+ const uri = gdrFromResource(doc.resource, doc.doc._id);
11222
+ bufferedDocuments.set(uri, {
11223
+ doc: structuredClone(doc.doc),
11224
+ resource: doc.resource
11225
+ });
11226
+ } else try {
11227
+ applyDocumentUpdate(doc);
11228
+ } catch (err) {
11229
+ throw deferredUpdateError = void 0, err;
11049
11230
  }
11231
+ flushDeferredError();
11050
11232
  },
11051
11233
  updateGuards(guards) {
11052
11234
  heldGuards = guards.map(guard => parseGuardDocument(structuredClone(guard)));
@@ -11860,4 +12042,4 @@ function displayDescription(typeKey) {
11860
12042
  if (typeKey) return DISPLAY[typeKey]?.description;
11861
12043
  }
11862
12044
 
11863
- export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_KIND_DISPLAY, ACTOR_KINDS, 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_ALLOWED_VARS, START_FILTER_VARS, SpawnContractsInvalidError, StaleEffectClaimError, StartNotAllowedError, StartNotPrimedError, StartNotSettledError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowActionFired, 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, 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, explainStartAllowed, extractDocumentId, fieldTreeShape, findCurrentActivityEntry, findOpenStageEntry, formatRead, gdrFromResource, gdrRef, gdrUri, groupMembershipNames, groupSitesOf, guardMatches, guardsForDefinition, guardsForInstance, guardsForResource, guillemets2 as guillemets, hashDefinitionContent, humanize2 as humanize, inFlightFilter, initialFieldIssues, instanceDocId, instanceGuardQuery, instanceWatchesDocument, instancesQuery, isCascadeFired, isClaimExpired, isComparisonOp, isDefinitionApplicable, isFilterScopedOut, isGdr, isInputSourced, isNotesEntry, isProjectUserNotFoundError, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTelemetryEnvDenied, isTerminalActivityStatus, isTerminalStage, isTodoListEntry, isTodoListItem, isUnprimed, lakeGuardId, latestDeployedDefinitions, lintEffectOutputs, minReaderModelOf, missingRequiredInputs, modelVersionOf, narrateAutonomyWaits, noopTelemetry, parentRef, parseDefinitionInput, parseDefinitionSnapshot, parseGdr, parseGuardDocument, parseInstanceDocument, parseResourceGdr, processShellUserProperties, 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, stageAutonomyOf, startFieldsParam, startKindOf, startRefusal, stripSystemFields, subjectDenialLabels, subscriptionDocument, subscriptionDocumentsForInstance, sweepStaleClaims, tagScopeFilter, terminalState, toBareId, tryParseGdr, unboundAllowedReads, unsatisfiedTransitionSummaries, validateDefinition, validateTag, verdictGuardsForInstance, wallClock, whatIfCondition2 as whatIfCondition, withAssignment, workflow };
12045
+ export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_KIND_DISPLAY, ACTOR_KINDS, 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_ALLOWED_VARS, START_FILTER_VARS, SpawnContractsInvalidError, StaleEffectClaimError, StartNotAllowedError, StartNotPrimedError, StartNotSettledError, WORKFLOW_DEFINITION_TYPE, WORKFLOW_INSTANCE_TYPE, WorkflowActionFired, 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, 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, explainStartAllowed, extractDocumentId, fieldTreeShape, findCurrentActivityEntry, findOpenStageEntry, formatRead, gdrFromResource, gdrRef, gdrUri, groupMembershipNames, groupSitesOf, guardMatches, guardsForDefinition, guardsForInstance, guardsForResource, guillemets2 as guillemets, 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, latestDeployedDefinitions, lintEffectOutputs, minReaderModelOf, missingRequiredInputs, modelVersionOf, narrateAutonomyWaits, noopTelemetry, parentRef, parseDefinitionInput, parseDefinitionSnapshot, parseGdr, parseGuardDocument, parseInstanceDocument, parseResourceGdr, processShellUserProperties, 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, stageAutonomyOf, startFieldsParam, startKindOf, startRefusal, stripSystemFields, subjectDenialLabels, subscriptionDocument, subscriptionDocumentsForInstance, sweepStaleClaims, tagScopeFilter, terminalState, toBareId, tryParseGdr, unboundAllowedReads, unsatisfiedTransitionSummaries, validateDefinition, validateTag, verdictGuardsForInstance, wallClock, whatIfCondition2 as whatIfCondition, withAssignment, workflow };