@sanity/workflow-engine 0.33.0 → 0.35.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 +32 -0
- package/DATAMODEL.md +13 -0
- package/dist/_chunks-cjs/invariants.cjs +504 -2
- package/dist/_chunks-es/invariants.js +423 -1
- package/dist/index.cjs +254 -608
- package/dist/index.d.cts +79 -13
- package/dist/index.d.ts +79 -13
- package/dist/index.js +136 -492
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CALLER_BOUND_VARS, START_REQUIREMENT_VARS, CONDITION_VARS, editableFieldsInStage, isSubjectEntry, isUnevaluable, ContractViolationError, isStartableDefinition, conditionFieldReadNames, rethrowWithContext, isGdr, errorMessage, conditionParameterNames, START_FILTER_VARS, WorkflowError, gdrFromResource, selfGdr, isGdrUri, MUTATION_GUARD_ID_SPACES, mutationGuardActionIdSpace, LAKE_MUTATION_GUARD_ACTIONS, isBareDocumentId, toBareId, parseDefinitionSnapshotValue, normalizeAssignmentMembers, isSingleDocRefKind, findOpenStageEntry, parentRef, findCurrentActivityEntry, actorMatchesAssignment, assignmentMembers, resolvedChildStatus, sameResource, resourceFromParsed, tryParseGdr, isTerminalActivityStatus, FieldValueShapeError, validateFieldValue, validateFieldAppendItem, isAssignmentFieldEntry, isAlwaysArrayFieldKind, evaluateCondition, isRecord, isSingleDocRefEntry, choiceValueIssues, scalarValidationIssues, StoredFieldOpSchema, formatIssues, conditionSyntaxIssues, checkWorkflowInvariants, formatIssuePath, isGuardReadExpr, GUARD_ACTIONS_REQUIRED_MESSAGE, conditionEffectReads, EFFECTS_READ, datasetResourceParts, refKindAcceptsTypes, mutationGuardRequiresSplitEmission, MUTATION_GUARD_ACTIONS, assignmentKindAcceptsRoles, evaluatePredicates, WORKFLOW_DEFINITION_TYPE, tagScopeFilter, terminalState, liveSubworkflows, isCascadeFired, classifyPrincipalId, directoryBridgeId, WORKFLOW_INSTANCE_TYPE, parseGdr, gdrRef, isInputSourced, parseFieldValue, VersionSpecificDatasetGdrError, toPhysicalGdr, isBareSeedId, isParseableInstant, NonEmptyString, tolerantEntries, FIELD_VALUE_KINDS, tolerantObject, ActorShape, IsoTimestamp, ACTIVITY_STATUSES, GdrShape, DRIVER_KINDS, FIELD_SCOPES, fieldValueSchemas, parsePersistedDoc, ACTOR_KINDS, InstanceNotFoundError, resolveTelemetry, evaluateConditionOutcome, parseDefinitionSnapshot, runGroq as runGroq$1, FIELD_READ, resourceGdr, condemnSubworkflow, WorkflowEffectCompleted, definitionHashFragment, executionContextFragment, resourceFromGdrUri, instanceStartedData, refTypeIssues, rejectedRefTypes, WorkflowStageTransitioned, stageTransitionedData, DOCUMENT_VALUE_PERMISSIONS, lakePrincipalId, firstCarriedGlobalId, driverKind, actorFulfillsRole, condemnedSubworkflows, WorkflowInstanceStarted, EffectNotFoundError, _fieldTargetLabel, isFilterScopedOut, deriveExecutorClassification, deriveActivityKind, validateTag, fieldWindowOpen, fieldProvenance, readFieldValue, editDisabledReason, activeAssignmentMembers, instanceTerminalReason, extractDocumentId, UNIVERSAL_ROLE_ALIAS_KEY, parseStoredDefinition, validateResourceAliasName, labelFor, DefinitionNotFoundError, definitionDocId, SpawnContractsInvalidError, gdrResourcePrefix, RESOURCE_ALIAS_NAME_SOURCE, resolveEditTarget, DEFAULT_EDIT_MODE, instanceStartedDataFor, isUnprimed, editTargetMatches, SCOPE_PRECEDENCE, DefinitionInUseError, WorkflowInstanceTicked, WorkflowDefinitionDeleted, WorkflowDefinitionDeployed, definitionDeployedData, WorkflowEffectStateReported, WorkflowActivityReset, WorkflowInstanceAborted, WorkflowStageSet, WorkflowFieldEdited, fieldEditedData, WorkflowActionFired, actionFiredData, effectBackoffMs, WorkflowEffectsDrained, groupMembershipNames } from "./_chunks-es/invariants.js";
|
|
2
2
|
|
|
3
|
-
import { ACTION_SEMANTICS, ACTIVITY_KINDS, ANONYMOUS_IDENTITY, DECISION_SEMANTICS, DEFAULT_TRANSITION_WHEN, EXECUTOR_CLASSIFICATIONS, FILTER_SCOPE_VARS, GROUP_KINDS, GUARD_PREDICATE_VARS, PersistedDocShapeError, RESERVED_CONDITION_VARS, SIGNAL_SEMANTICS, SYSTEM_IDENTITY, assignmentMatch, assignmentState, assignmentStateCounts, clientConfigFromResource, gdrUri, identityMatchesAssignment, instanceAssignmentStateCounts, isNotesEntry, isTodoListEntry, isTodoListItem, openActivityAssignments, parseResourceGdr, readsRootDocument, refCanvas, refDashboard, refDataset, refMediaLibrary, releaseDocId, releaseRef, resourceAliasesToMap, schemaTreeShape, startKindOf } from "./_chunks-es/invariants.js";
|
|
3
|
+
import { ACTION_SEMANTICS, ACTIVITY_KINDS, ANONYMOUS_IDENTITY, DECISION_SEMANTICS, DEFAULT_TRANSITION_WHEN, EXECUTOR_CLASSIFICATIONS, FILTER_SCOPE_VARS, GROUP_KINDS, GUARD_PREDICATE_VARS, PersistedDocShapeError, RESERVED_CONDITION_VARS, SIGNAL_SEMANTICS, SYSTEM_IDENTITY, assignmentMatch, assignmentState, assignmentStateCounts, clientConfigFromResource, gdrUri, identityMatchesAssignment, instanceAssignmentStateCounts, isNotesEntry, isTodoListEntry, isTodoListItem, noopTelemetry, openActivityAssignments, parseResourceGdr, readsRootDocument, refCanvas, refDashboard, refDataset, refMediaLibrary, releaseDocId, releaseRef, resolveFieldEntry, 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, _exhaustiveOptions, whatIfCondition, runGroq, formatRead, dedupeReads, MAX_COUNTERFACTUAL_INDEX } from "@sanity/groq-condition-describe";
|
|
6
6
|
|
|
@@ -12,405 +12,48 @@ import { getPublishedId, getDraftId, DocumentId } from "@sanity/id-utils";
|
|
|
12
12
|
|
|
13
13
|
import * as v from "valibot";
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
return normalizeLegacyActivityRequirements(JSON.parse(instance.definitionSnapshot));
|
|
28
|
-
} catch (err) {
|
|
29
|
-
rethrowWithContext(err, `Failed to parse definitionSnapshot on instance "${instance._id}"`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function normalizeLegacyActivityRequirements(value) {
|
|
34
|
-
for (const stage of arrayMember(value, "stages")) for (const activity of arrayMember(stage, "activities")) normalizeLegacyRequirementMap(activity);
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function arrayMember(value, key) {
|
|
39
|
-
if (typeof value != "object" || value === null) return [];
|
|
40
|
-
const member = value[key];
|
|
41
|
-
return Array.isArray(member) ? member : [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function normalizeLegacyRequirementMap(value) {
|
|
45
|
-
if (typeof value != "object" || value === null) return;
|
|
46
|
-
const activity = value, requirements = activity.requirements;
|
|
47
|
-
typeof requirements != "object" || requirements === null || Array.isArray(requirements) || (activity.requirements = Object.entries(requirements).map(([name, query]) => ({
|
|
48
|
-
type: "groq",
|
|
49
|
-
name: name,
|
|
50
|
-
query: query
|
|
51
|
-
})));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function parseDefinitionSnapshot(instance) {
|
|
55
|
-
return parseDefinitionSnapshotValue(instance);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function parentRef(instance) {
|
|
59
|
-
return instance.ancestors.at(-1);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function effectiveEditable(baseline, override) {
|
|
63
|
-
if (baseline === void 0) return;
|
|
64
|
-
if (override === void 0) return baseline;
|
|
65
|
-
if (baseline === !0 && override === !0) return !0;
|
|
66
|
-
const parts = [ baseline, override ].map(e => e === !0 ? void 0 : e);
|
|
67
|
-
return andConditions(parts) ?? !0;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const DEFAULT_EDIT_MODE = "set";
|
|
15
|
+
const EXECUTION_KINDS = {
|
|
16
|
+
interactive: "interactive",
|
|
17
|
+
server: "server",
|
|
18
|
+
cli: "cli",
|
|
19
|
+
mcp: "mcp",
|
|
20
|
+
drainer: "drainer",
|
|
21
|
+
script: "script",
|
|
22
|
+
test: "test",
|
|
23
|
+
studio: "studio",
|
|
24
|
+
sdkApp: "sdk"
|
|
25
|
+
};
|
|
71
26
|
|
|
72
|
-
function
|
|
73
|
-
|
|
27
|
+
function detectRuntime() {
|
|
28
|
+
const g = globalThis;
|
|
29
|
+
if (g.Deno !== void 0) return "deno";
|
|
30
|
+
if (g.Bun !== void 0) return "bun";
|
|
31
|
+
if (g.EdgeRuntime !== void 0) return "edge";
|
|
32
|
+
if (g.window !== void 0 && g.document !== void 0) return "browser";
|
|
33
|
+
if (g.WorkerGlobalScope !== void 0 && g.self !== void 0) return "worker";
|
|
34
|
+
const proc = g.process;
|
|
35
|
+
return typeof proc == "object" && proc !== null && typeof proc.versions?.node == "string" ? "node" : "unknown";
|
|
74
36
|
}
|
|
75
37
|
|
|
76
|
-
|
|
77
|
-
const sites = [];
|
|
78
|
-
for (const entry of definition.fields ?? []) sites.push({
|
|
79
|
-
scope: "workflow",
|
|
80
|
-
entry: entry
|
|
81
|
-
});
|
|
82
|
-
for (const entry of stage.fields ?? []) sites.push({
|
|
83
|
-
scope: "stage",
|
|
84
|
-
entry: entry
|
|
85
|
-
});
|
|
86
|
-
for (const activity of stage.activities ?? []) for (const entry of activity.fields ?? []) sites.push({
|
|
87
|
-
scope: "activity",
|
|
88
|
-
activity: activity.name,
|
|
89
|
-
entry: entry
|
|
90
|
-
});
|
|
91
|
-
return sites;
|
|
92
|
-
}
|
|
38
|
+
let inferredRuntime;
|
|
93
39
|
|
|
94
|
-
function
|
|
95
|
-
return {
|
|
96
|
-
|
|
97
|
-
...
|
|
98
|
-
|
|
99
|
-
} : {},
|
|
100
|
-
name: site.entry.name,
|
|
101
|
-
type: site.entry.type,
|
|
102
|
-
...site.entry.title !== void 0 ? {
|
|
103
|
-
title: site.entry.title
|
|
104
|
-
} : {},
|
|
105
|
-
...site.entry.validation !== void 0 ? {
|
|
106
|
-
validation: site.entry.validation
|
|
107
|
-
} : {},
|
|
108
|
-
...site.entry.roles !== void 0 ? {
|
|
109
|
-
roles: site.entry.roles
|
|
40
|
+
function resolveExecutionContext(declared) {
|
|
41
|
+
return inferredRuntime ??= detectRuntime(), {
|
|
42
|
+
runtime: inferredRuntime,
|
|
43
|
+
...declared?.kind !== void 0 ? {
|
|
44
|
+
kind: declared.kind
|
|
110
45
|
} : {},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
field: site.entry.name
|
|
114
|
-
},
|
|
115
|
-
effective: effectiveEditable(site.entry.editable, stage.editable?.[site.entry.name])
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function editableFieldsInStage(definition, stage) {
|
|
120
|
-
return fieldSites(definition, stage).filter(site => site.entry.editable !== void 0).map(site => resolveFieldSite(site, stage));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function editTargetMatches(site, target) {
|
|
124
|
-
return site.name !== target.field ? !1 : target.activity !== void 0 ? site.scope === "activity" && site.activity === target.activity : target.scope !== void 0 ? site.scope === target.scope : !0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const SCOPE_PRECEDENCE = {
|
|
128
|
-
activity: 0,
|
|
129
|
-
stage: 1,
|
|
130
|
-
workflow: 2
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
function resolveEditTarget(args) {
|
|
134
|
-
const {definition: definition, stage: stage, target: target} = args, found = fieldSites(definition, stage).filter(site => editTargetMatches({
|
|
135
|
-
scope: site.scope,
|
|
136
|
-
name: site.entry.name,
|
|
137
|
-
...site.activity !== void 0 ? {
|
|
138
|
-
activity: site.activity
|
|
46
|
+
...declared?.id !== void 0 ? {
|
|
47
|
+
id: declared.id
|
|
139
48
|
} : {}
|
|
140
|
-
}, target)).sort((a, b) => SCOPE_PRECEDENCE[a.scope] - SCOPE_PRECEDENCE[b.scope])[0];
|
|
141
|
-
return found ? resolveFieldSite(found, stage) : void 0;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function fieldWindowOpen(instance, site) {
|
|
145
|
-
const terminal = terminalState(instance);
|
|
146
|
-
if (terminal !== "in-flight") return {
|
|
147
|
-
open: !1,
|
|
148
|
-
detail: `instance ${terminal}`
|
|
149
49
|
};
|
|
150
|
-
if (site.scope !== "activity") return {
|
|
151
|
-
open: !0
|
|
152
|
-
};
|
|
153
|
-
const status = findCurrentActivityEntry(instance, site.activity)?.status;
|
|
154
|
-
return status === "active" ? {
|
|
155
|
-
open: !0
|
|
156
|
-
} : {
|
|
157
|
-
open: !1,
|
|
158
|
-
detail: `activity "${site.activity}" is ${status ?? "not active"}`
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function readFieldValue(instance, site) {
|
|
163
|
-
return resolveFieldEntry$1(instance, site)?.value;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function resolveFieldEntry$1(instance, site) {
|
|
167
|
-
return fieldEntryHost(instance, site)?.find(e => e.name === site.name);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function fieldEntryHost(instance, site) {
|
|
171
|
-
if (site.scope === "workflow") return instance.fields;
|
|
172
|
-
const stageEntry = findOpenStageEntry(instance);
|
|
173
|
-
return site.scope === "stage" ? stageEntry?.fields : stageEntry?.activities.find(t => t.name === site.activity)?.fields;
|
|
174
50
|
}
|
|
175
51
|
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
...entry.actor !== void 0 ? {
|
|
181
|
-
actor: entry.actor
|
|
182
|
-
} : {}
|
|
52
|
+
function stampHistoryEntries(entries, stamp) {
|
|
53
|
+
return entries.map(entry => ({
|
|
54
|
+
...entry,
|
|
55
|
+
executionContext: stamp
|
|
183
56
|
}));
|
|
184
|
-
return latest === void 0 ? {} : {
|
|
185
|
-
...latest.actor !== void 0 ? {
|
|
186
|
-
setBy: latest.actor
|
|
187
|
-
} : {},
|
|
188
|
-
setAt: latest.at
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function editDisabledReason(args) {
|
|
193
|
-
const {effective: effective, instance: instance, window: window, guardDenial: guardDenial, predicateSatisfied: predicateSatisfied} = args;
|
|
194
|
-
if (effective === void 0) return {
|
|
195
|
-
kind: "not-editable"
|
|
196
|
-
};
|
|
197
|
-
if (!window.open) {
|
|
198
|
-
const terminalReason = instanceTerminalReason(instance);
|
|
199
|
-
return terminalReason !== void 0 ? terminalReason : {
|
|
200
|
-
kind: "edit-window-closed",
|
|
201
|
-
detail: window.detail ?? "closed"
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
if (guardDenial !== void 0) return guardDenial;
|
|
205
|
-
if (!predicateSatisfied) return {
|
|
206
|
-
kind: "editor-not-permitted",
|
|
207
|
-
predicate: effective === !0 ? "true" : effective
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function instanceTerminalReason(instance) {
|
|
212
|
-
const terminal = terminalState(instance);
|
|
213
|
-
if (terminal === "aborted" && instance.abortedAt !== void 0) return {
|
|
214
|
-
kind: "instance-aborted",
|
|
215
|
-
abortedAt: instance.abortedAt
|
|
216
|
-
};
|
|
217
|
-
if (terminal === "completed" && instance.completedAt !== void 0) return {
|
|
218
|
-
kind: "instance-completed",
|
|
219
|
-
completedAt: instance.completedAt
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function defineWorkflowEvent(options) {
|
|
224
|
-
return {
|
|
225
|
-
type: "log",
|
|
226
|
-
...options
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const noopTelemetry = {
|
|
231
|
-
log: () => {}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
function resolveTelemetry(telemetry) {
|
|
235
|
-
return telemetry === void 0 ? noopTelemetry : {
|
|
236
|
-
log: (event, data) => {
|
|
237
|
-
try {
|
|
238
|
-
telemetry.log(event, data);
|
|
239
|
-
} catch (error) {
|
|
240
|
-
console.warn(`[workflow-engine] telemetry logger threw while logging "${event.name}" — event dropped`, error);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const HIGH_FREQUENCY_SAMPLE_MS = 6e4, WorkflowDefinitionDeployed = defineWorkflowEvent({
|
|
247
|
-
name: "Workflows Definition Deployed",
|
|
248
|
-
version: 1,
|
|
249
|
-
description: "A definition went through a deploy — status distinguishes a newly minted version from an unchanged redeploy"
|
|
250
|
-
}), WorkflowInstanceStarted = defineWorkflowEvent({
|
|
251
|
-
name: "Workflows Instance Started",
|
|
252
|
-
version: 1,
|
|
253
|
-
description: "A workflow instance was started from a deployed definition"
|
|
254
|
-
}), WorkflowStageTransitioned = defineWorkflowEvent({
|
|
255
|
-
name: "Workflows Stage Transitioned",
|
|
256
|
-
version: 1,
|
|
257
|
-
description: "A committed stage move — one event per hop, cascades included, whichever verb drove it. Unsampled: funnel and dwell reads need complete counts, and volume is bounded by actual movement"
|
|
258
|
-
}), WorkflowActionFired = defineWorkflowEvent({
|
|
259
|
-
name: "Workflows Action Fired",
|
|
260
|
-
version: 1,
|
|
261
|
-
description: "An action was fired against an activity"
|
|
262
|
-
}), WorkflowFieldEdited = defineWorkflowEvent({
|
|
263
|
-
name: "Workflows Field Edited",
|
|
264
|
-
version: 1,
|
|
265
|
-
description: "A declared-editable field was edited through the generic edit seam",
|
|
266
|
-
maxSampleRate: HIGH_FREQUENCY_SAMPLE_MS
|
|
267
|
-
}), WorkflowInstanceTicked = defineWorkflowEvent({
|
|
268
|
-
name: "Workflows Instance Ticked",
|
|
269
|
-
version: 1,
|
|
270
|
-
description: "An instance was re-evaluated for auto-transitions and due waits",
|
|
271
|
-
maxSampleRate: HIGH_FREQUENCY_SAMPLE_MS
|
|
272
|
-
}), WorkflowEffectsDrained = defineWorkflowEvent({
|
|
273
|
-
name: "Workflows Effects Drained",
|
|
274
|
-
version: 1,
|
|
275
|
-
description: "A drain pass ran — drainedCount/drainedEffects report the successful dispatches. Unsampled when non-empty (outcome counts must be complete; volume is bounded by real effect work); empty polls are machine-cadence noise, throttled engine-side to at most one per minute"
|
|
276
|
-
}), WorkflowEffectStateReported = defineWorkflowEvent({
|
|
277
|
-
name: "Workflows Effect State Reported",
|
|
278
|
-
version: 1,
|
|
279
|
-
description: "A running effect handler committed mid-dispatch field state through commitEffectOps. Sampled (high-frequency by design — a dispatch may report many times): an adoption and usage signal, not an exact per-run report count",
|
|
280
|
-
maxSampleRate: HIGH_FREQUENCY_SAMPLE_MS
|
|
281
|
-
}), WorkflowEffectCompleted = defineWorkflowEvent({
|
|
282
|
-
name: "Workflows Effect Completed",
|
|
283
|
-
version: 1,
|
|
284
|
-
description: "An effect outcome was recorded — reported directly through completeEffect, or cancelled by the abort verb (external runtimes; engine-drained effects surface via Workflows Effects Drained instead — each outcome counts once)"
|
|
285
|
-
}), WorkflowInstanceAborted = defineWorkflowEvent({
|
|
286
|
-
name: "Workflows Instance Aborted",
|
|
287
|
-
version: 1,
|
|
288
|
-
description: "The abort admin override was invoked (changed: false = instance already terminal)"
|
|
289
|
-
}), WorkflowStageSet = defineWorkflowEvent({
|
|
290
|
-
name: "Workflows Stage Set",
|
|
291
|
-
version: 1,
|
|
292
|
-
description: "The set-stage admin override was invoked (changed: false = already at the target stage)"
|
|
293
|
-
}), WorkflowActivityReset = defineWorkflowEvent({
|
|
294
|
-
name: "Workflows Activity Reset",
|
|
295
|
-
version: 1,
|
|
296
|
-
description: "The reset-activity admin override was invoked (changed: false = already at the target status, or the instance was terminal)"
|
|
297
|
-
}), WorkflowDefinitionDeleted = defineWorkflowEvent({
|
|
298
|
-
name: "Workflows Definition Deleted",
|
|
299
|
-
version: 1,
|
|
300
|
-
description: "A deployed definition (or one version of it) was removed via the admin verb"
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
function definitionDeployedData(definition, outcome) {
|
|
304
|
-
const stages = definition.stages, activities = stages.flatMap(stage => stage.activities ?? []), actions = activities.flatMap(activity => activity.actions ?? []), transitions = stages.flatMap(stage => stage.transitions ?? []), fieldEntries2 = [ ...definition.fields ?? [], ...stages.flatMap(stage => stage.fields ?? []), ...activities.flatMap(activity => activity.fields ?? []) ];
|
|
305
|
-
return {
|
|
306
|
-
contentHash: outcome.contentHash,
|
|
307
|
-
status: outcome.status,
|
|
308
|
-
deployId: outcome.deployId,
|
|
309
|
-
stageCount: stages.length,
|
|
310
|
-
activityCount: activities.length,
|
|
311
|
-
actionCount: actions.length,
|
|
312
|
-
transitionCount: transitions.length,
|
|
313
|
-
fieldCount: fieldEntries2.length,
|
|
314
|
-
activityKinds: [ ...new Set(activities.map(deriveActivityKind)) ].sort(),
|
|
315
|
-
fieldKinds: [ ...new Set(fieldEntries2.map(entry => entry.type)) ].sort(),
|
|
316
|
-
guardCount: stages.reduce((n, stage) => n + (stage.guards ?? []).length, 0),
|
|
317
|
-
effectCount: actions.reduce((n, action) => n + (action.effects ?? []).length, 0),
|
|
318
|
-
subworkflowCount: actions.filter(action => action.spawn !== void 0).length,
|
|
319
|
-
lifecycle: definition.lifecycle ?? "standalone"
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function definitionHashFragment(contentHash) {
|
|
324
|
-
return contentHash !== void 0 ? {
|
|
325
|
-
definitionContentHash: contentHash
|
|
326
|
-
} : {};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function instanceStartedData(args) {
|
|
330
|
-
return {
|
|
331
|
-
...definitionHashFragment(args.definition.contentHash),
|
|
332
|
-
instanceId: args.instanceId,
|
|
333
|
-
initialFieldCount: args.initialFieldCount,
|
|
334
|
-
viaSpawn: args.viaSpawn,
|
|
335
|
-
lifecycle: args.definition.lifecycle ?? "standalone"
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function instanceStartedDataFor(args) {
|
|
340
|
-
return instanceStartedData({
|
|
341
|
-
definition: {
|
|
342
|
-
...parseDefinitionSnapshot(args.instance),
|
|
343
|
-
...args.instance.pinnedContentHash !== void 0 ? {
|
|
344
|
-
contentHash: args.instance.pinnedContentHash
|
|
345
|
-
} : {}
|
|
346
|
-
},
|
|
347
|
-
instanceId: args.instance._id,
|
|
348
|
-
initialFieldCount: args.initialFieldCount,
|
|
349
|
-
viaSpawn: args.viaSpawn
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function stageTransitionedData(args) {
|
|
354
|
-
const stageIndex = name => args.definition.stages.findIndex(stage => stage.name === name), openEntry = findOpenStageEntry(args.instance), dwellMs = openEntry !== void 0 ? Date.parse(args.at) - Date.parse(openEntry.enteredAt) : Number.NaN;
|
|
355
|
-
return {
|
|
356
|
-
...definitionHashFragment(args.instance.pinnedContentHash),
|
|
357
|
-
instanceId: args.instance._id,
|
|
358
|
-
fromStageIndex: stageIndex(args.instance.currentStage),
|
|
359
|
-
toStageIndex: stageIndex(args.toStage),
|
|
360
|
-
toIsTerminal: args.toIsTerminal,
|
|
361
|
-
isRevisit: args.instance.stages.some(entry => entry.name === args.toStage),
|
|
362
|
-
...Number.isFinite(dwellMs) ? {
|
|
363
|
-
dwellMs: dwellMs
|
|
364
|
-
} : {},
|
|
365
|
-
via: args.via
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function openStage$1(instance) {
|
|
370
|
-
const definition = parseDefinitionSnapshot(instance);
|
|
371
|
-
return {
|
|
372
|
-
definition: definition,
|
|
373
|
-
stage: definition.stages.find(s => s.name === instance.currentStage)
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function firedActivityKind(instance, activity) {
|
|
378
|
-
const node = openStage$1(instance).stage?.activities?.find(a => a.name === activity);
|
|
379
|
-
return node === void 0 ? void 0 : deriveActivityKind(node);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function editedFieldKind(instance, target) {
|
|
383
|
-
const {definition: definition, stage: stage} = openStage$1(instance);
|
|
384
|
-
return stage === void 0 ? void 0 : resolveEditTarget({
|
|
385
|
-
definition: definition,
|
|
386
|
-
stage: stage,
|
|
387
|
-
target: target
|
|
388
|
-
})?.type;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function actionFiredData(args) {
|
|
392
|
-
const kind = firedActivityKind(args.instance, args.activity);
|
|
393
|
-
return {
|
|
394
|
-
...definitionHashFragment(args.instance.pinnedContentHash),
|
|
395
|
-
instanceId: args.instance._id,
|
|
396
|
-
...kind !== void 0 ? {
|
|
397
|
-
activityKind: kind
|
|
398
|
-
} : {},
|
|
399
|
-
hasParams: args.params !== void 0,
|
|
400
|
-
cascaded: args.cascaded
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function fieldEditedData(args) {
|
|
405
|
-
const kind = editedFieldKind(args.instance, args.target);
|
|
406
|
-
return {
|
|
407
|
-
...definitionHashFragment(args.instance.pinnedContentHash),
|
|
408
|
-
instanceId: args.instance._id,
|
|
409
|
-
...kind !== void 0 ? {
|
|
410
|
-
fieldKind: kind
|
|
411
|
-
} : {},
|
|
412
|
-
mode: args.mode ?? DEFAULT_EDIT_MODE
|
|
413
|
-
};
|
|
414
57
|
}
|
|
415
58
|
|
|
416
59
|
function effectSites(def) {
|
|
@@ -732,11 +375,11 @@ function siblingsAutonomy(scope) {
|
|
|
732
375
|
function fieldAutonomy(read, scope) {
|
|
733
376
|
const [head] = read.path;
|
|
734
377
|
if (typeof head != "string") return UNDECIDABLE;
|
|
735
|
-
const resolved =
|
|
378
|
+
const resolved = resolveFieldEntry2(head, scope);
|
|
736
379
|
return resolved === void 0 ? UNDECIDABLE : scope.memoized(fieldKeyOf(resolved), () => fieldProducers(resolved, scope));
|
|
737
380
|
}
|
|
738
381
|
|
|
739
|
-
function
|
|
382
|
+
function resolveFieldEntry2(name, scope) {
|
|
740
383
|
const {stage: stage, activity: activity} = scope.site, activityEntry = (activity?.fields ?? []).find(entry => entry.name === name);
|
|
741
384
|
if (activityEntry !== void 0 && activity !== void 0) return {
|
|
742
385
|
entry: activityEntry,
|
|
@@ -4744,50 +4387,6 @@ function assertRoleConstrainedAssignmentResource(args) {
|
|
|
4744
4387
|
if (hasRoleConstrainedAssignments(args.definition) && args.workflowResource.type !== "dataset") throw new Error(`${args.context}: definition "${args.definition.name}" uses role-constrained assignment fields, which require a dataset workflow resource; received resource type "${args.workflowResource.type}"`);
|
|
4745
4388
|
}
|
|
4746
4389
|
|
|
4747
|
-
const EXECUTION_KINDS = {
|
|
4748
|
-
interactive: "interactive",
|
|
4749
|
-
server: "server",
|
|
4750
|
-
cli: "cli",
|
|
4751
|
-
mcp: "mcp",
|
|
4752
|
-
drainer: "drainer",
|
|
4753
|
-
script: "script",
|
|
4754
|
-
test: "test",
|
|
4755
|
-
studio: "studio",
|
|
4756
|
-
sdkApp: "sdk-app"
|
|
4757
|
-
};
|
|
4758
|
-
|
|
4759
|
-
function detectRuntime() {
|
|
4760
|
-
const g = globalThis;
|
|
4761
|
-
if (g.Deno !== void 0) return "deno";
|
|
4762
|
-
if (g.Bun !== void 0) return "bun";
|
|
4763
|
-
if (g.EdgeRuntime !== void 0) return "edge";
|
|
4764
|
-
if (g.window !== void 0 && g.document !== void 0) return "browser";
|
|
4765
|
-
if (g.WorkerGlobalScope !== void 0 && g.self !== void 0) return "worker";
|
|
4766
|
-
const proc = g.process;
|
|
4767
|
-
return typeof proc == "object" && proc !== null && typeof proc.versions?.node == "string" ? "node" : "unknown";
|
|
4768
|
-
}
|
|
4769
|
-
|
|
4770
|
-
let inferredRuntime;
|
|
4771
|
-
|
|
4772
|
-
function resolveExecutionContext(declared) {
|
|
4773
|
-
return inferredRuntime ??= detectRuntime(), {
|
|
4774
|
-
runtime: inferredRuntime,
|
|
4775
|
-
...declared?.kind !== void 0 ? {
|
|
4776
|
-
kind: declared.kind
|
|
4777
|
-
} : {},
|
|
4778
|
-
...declared?.id !== void 0 ? {
|
|
4779
|
-
id: declared.id
|
|
4780
|
-
} : {}
|
|
4781
|
-
};
|
|
4782
|
-
}
|
|
4783
|
-
|
|
4784
|
-
function stampHistoryEntries(entries, stamp) {
|
|
4785
|
-
return entries.map(entry => ({
|
|
4786
|
-
...entry,
|
|
4787
|
-
executionContext: stamp
|
|
4788
|
-
}));
|
|
4789
|
-
}
|
|
4790
|
-
|
|
4791
4390
|
function collectWatchRefs(instance) {
|
|
4792
4391
|
return [ gdrRef({
|
|
4793
4392
|
res: instance.workflowResource,
|
|
@@ -7589,6 +7188,7 @@ async function commitAbort({ctx: ctx, reason: reason, requestRecord: requestReco
|
|
|
7589
7188
|
snapshot: ctx.snapshot
|
|
7590
7189
|
});
|
|
7591
7190
|
for (const {effect: effect, origin: origin} of cancelled) ctx.telemetry.log(WorkflowEffectCompleted, {
|
|
7191
|
+
...executionContextFragment(ctx.executionContext),
|
|
7592
7192
|
...definitionHashFragment(ctx.instance.pinnedContentHash),
|
|
7593
7193
|
instanceId: ctx.instance._id,
|
|
7594
7194
|
effect: effect,
|
|
@@ -8283,14 +7883,17 @@ async function commitStageMove({ctx: ctx, mutation: mutation, fromStage: fromSta
|
|
|
8283
7883
|
}
|
|
8284
7884
|
|
|
8285
7885
|
function emitStageTransitioned({ctx: ctx, nextStage: nextStage, at: at, via: via}) {
|
|
8286
|
-
ctx.telemetry.log(WorkflowStageTransitioned,
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
7886
|
+
ctx.telemetry.log(WorkflowStageTransitioned, {
|
|
7887
|
+
...executionContextFragment(ctx.executionContext),
|
|
7888
|
+
...stageTransitionedData({
|
|
7889
|
+
instance: ctx.instance,
|
|
7890
|
+
definition: ctx.definition,
|
|
7891
|
+
toStage: nextStage.name,
|
|
7892
|
+
toIsTerminal: isTerminalStage(nextStage),
|
|
7893
|
+
at: at,
|
|
7894
|
+
via: via
|
|
7895
|
+
})
|
|
7896
|
+
});
|
|
8294
7897
|
}
|
|
8295
7898
|
|
|
8296
7899
|
function exitOpenStage({mutation: mutation, stage: stage, at: at}) {
|
|
@@ -9771,7 +9374,10 @@ async function persist(ctx, mutation) {
|
|
|
9771
9374
|
actor: actorForPriming,
|
|
9772
9375
|
settlingCohorts: settlingCohorts
|
|
9773
9376
|
});
|
|
9774
|
-
for (const {started: started} of pendingCreates) ctx.telemetry.log(WorkflowInstanceStarted,
|
|
9377
|
+
for (const {started: started} of pendingCreates) ctx.telemetry.log(WorkflowInstanceStarted, {
|
|
9378
|
+
...executionContextFragment(ctx.executionContext),
|
|
9379
|
+
...started
|
|
9380
|
+
});
|
|
9775
9381
|
const reloaded = await getInstanceDocument(ctx.client, ctx.instance._id);
|
|
9776
9382
|
if (!reloaded) throw new Error(`Instance ${ctx.instance._id} disappeared after transaction commit`);
|
|
9777
9383
|
return reloaded;
|
|
@@ -11921,6 +11527,14 @@ function parseDefinitionInput(def, caller) {
|
|
|
11921
11527
|
return parseStoredDefinition(content, label);
|
|
11922
11528
|
}
|
|
11923
11529
|
|
|
11530
|
+
function _parseDefinitionsWithReaderModel(definitions, caller) {
|
|
11531
|
+
const parsed = definitions.map(def => parseDefinitionInput(def, caller));
|
|
11532
|
+
return {
|
|
11533
|
+
definitions: parsed,
|
|
11534
|
+
requiredMinReaderModel: requiredDefinitionReaderModel(parsed)
|
|
11535
|
+
};
|
|
11536
|
+
}
|
|
11537
|
+
|
|
11924
11538
|
function stripSystemFields(doc) {
|
|
11925
11539
|
const out = {};
|
|
11926
11540
|
for (const [k, v2] of Object.entries(doc)) k === "_rev" || k === "_createdAt" || k === "_updatedAt" || (out[k] = v2);
|
|
@@ -12445,11 +12059,14 @@ async function resumeStart(args) {
|
|
|
12445
12059
|
});
|
|
12446
12060
|
if (mismatch !== void 0) throw new ContractViolationError(`startInstance: instanceId "${existing._id}" already exists and ${mismatch}. A supplied instanceId is start's idempotency key — reuse one only to retry the same start.`);
|
|
12447
12061
|
if (existing.stages.length === 0 && terminalState(existing) !== "in-flight") throw new ContractViolationError(`startInstance: instanceId "${existing._id}" belongs to a start that was discarded (aborted before it finished starting) — mint a new id to start again.`);
|
|
12448
|
-
const completesStart = isUnprimed(existing), emitStarted = () => resolveTelemetry(args.telemetry).log(WorkflowInstanceStarted,
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12062
|
+
const completesStart = isUnprimed(existing), emitStarted = () => resolveTelemetry(args.telemetry).log(WorkflowInstanceStarted, {
|
|
12063
|
+
...executionContextFragment(resolveExecutionContext(args.executionContext)),
|
|
12064
|
+
...instanceStartedDataFor({
|
|
12065
|
+
instance: existing,
|
|
12066
|
+
initialFieldCount: initialFieldCount,
|
|
12067
|
+
viaSpawn: !1
|
|
12068
|
+
})
|
|
12069
|
+
}), settled = await settleStart({
|
|
12453
12070
|
...settlementArgs,
|
|
12454
12071
|
instanceId: existing._id,
|
|
12455
12072
|
...completesStart ? {
|
|
@@ -12822,9 +12439,9 @@ const workflow = {
|
|
|
12822
12439
|
deployDefinitions: async rawArgs => {
|
|
12823
12440
|
const args = taggedScope(rawArgs, REQUEST_TAG.deploy), {client: client, tag: tag, workflowResource: workflowResource, resourceAliases: resourceAliases} = args;
|
|
12824
12441
|
validateTag(tag);
|
|
12825
|
-
const definitions = args.definitions
|
|
12442
|
+
const {definitions: definitions, requiredMinReaderModel: requiredMinReaderModel} = _parseDefinitionsWithReaderModel(args.definitions, "workflow.deployDefinitions");
|
|
12826
12443
|
definitions.forEach(validateDefinition), assertReaderModelAcknowledgement(args.expectedMinReaderModel, {
|
|
12827
|
-
requiredMinReaderModel:
|
|
12444
|
+
requiredMinReaderModel: requiredMinReaderModel
|
|
12828
12445
|
});
|
|
12829
12446
|
const roleWarnings = await validateDefinitionRoles({
|
|
12830
12447
|
client: client,
|
|
@@ -12879,12 +12496,15 @@ const workflow = {
|
|
|
12879
12496
|
});
|
|
12880
12497
|
}
|
|
12881
12498
|
hasWrites && await tx.commit();
|
|
12882
|
-
const deployId = randomKey(), telemetry = resolveTelemetry(args.telemetry);
|
|
12883
|
-
for (const {def: def, contentHash: contentHash, status: status} of deployed) telemetry.log(WorkflowDefinitionDeployed,
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12499
|
+
const deployId = randomKey(), telemetry = resolveTelemetry(args.telemetry), execution = resolveExecutionContext(args.executionContext);
|
|
12500
|
+
for (const {def: def, contentHash: contentHash, status: status} of deployed) telemetry.log(WorkflowDefinitionDeployed, {
|
|
12501
|
+
...executionContextFragment(execution),
|
|
12502
|
+
...definitionDeployedData(def, {
|
|
12503
|
+
contentHash: contentHash,
|
|
12504
|
+
status: status,
|
|
12505
|
+
deployId: deployId
|
|
12506
|
+
})
|
|
12507
|
+
});
|
|
12888
12508
|
return {
|
|
12889
12509
|
results: results,
|
|
12890
12510
|
deployId: deployId
|
|
@@ -12893,6 +12513,7 @@ const workflow = {
|
|
|
12893
12513
|
deleteDefinition: async rawArgs => {
|
|
12894
12514
|
const args = taggedScope(rawArgs, REQUEST_TAG.deleteDefinition), result = await deleteDefinition(args);
|
|
12895
12515
|
return resolveTelemetry(args.telemetry).log(WorkflowDefinitionDeleted, {
|
|
12516
|
+
...executionContextFragment(resolveExecutionContext(args.executionContext)),
|
|
12896
12517
|
deletedVersionCount: result.deletedVersions.length,
|
|
12897
12518
|
cascadeAbortedCount: result.abortedInstanceIds.length,
|
|
12898
12519
|
deletedGuardCount: result.deletedGuardCount
|
|
@@ -13008,12 +12629,15 @@ const workflow = {
|
|
|
13008
12629
|
} : {}
|
|
13009
12630
|
}))
|
|
13010
12631
|
});
|
|
13011
|
-
return resolveTelemetry(args.telemetry).log(WorkflowActionFired,
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
12632
|
+
return resolveTelemetry(args.telemetry).log(WorkflowActionFired, {
|
|
12633
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
12634
|
+
...actionFiredData({
|
|
12635
|
+
instance: before,
|
|
12636
|
+
activity: activity,
|
|
12637
|
+
params: params,
|
|
12638
|
+
cascaded: result.cascaded
|
|
12639
|
+
})
|
|
12640
|
+
}), result;
|
|
13017
12641
|
}
|
|
13018
12642
|
});
|
|
13019
12643
|
},
|
|
@@ -13078,11 +12702,14 @@ const workflow = {
|
|
|
13078
12702
|
} : {}
|
|
13079
12703
|
}))
|
|
13080
12704
|
});
|
|
13081
|
-
return resolveTelemetry(args.telemetry).log(WorkflowFieldEdited,
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
12705
|
+
return resolveTelemetry(args.telemetry).log(WorkflowFieldEdited, {
|
|
12706
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
12707
|
+
...fieldEditedData({
|
|
12708
|
+
instance: before,
|
|
12709
|
+
target: target,
|
|
12710
|
+
mode: mode
|
|
12711
|
+
})
|
|
12712
|
+
}), result;
|
|
13086
12713
|
}
|
|
13087
12714
|
});
|
|
13088
12715
|
},
|
|
@@ -13142,6 +12769,7 @@ const workflow = {
|
|
|
13142
12769
|
telemetry: args.telemetry
|
|
13143
12770
|
});
|
|
13144
12771
|
return resolveTelemetry(args.telemetry).log(WorkflowEffectCompleted, {
|
|
12772
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
13145
12773
|
...definitionHashFragment(settled.instance.pinnedContentHash),
|
|
13146
12774
|
instanceId: instanceId,
|
|
13147
12775
|
effect: completion.effect,
|
|
@@ -13197,6 +12825,7 @@ const workflow = {
|
|
|
13197
12825
|
telemetry: args.telemetry
|
|
13198
12826
|
});
|
|
13199
12827
|
return resolveTelemetry(args.telemetry).log(WorkflowEffectStateReported, {
|
|
12828
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
13200
12829
|
...definitionHashFragment(settled.instance.pinnedContentHash),
|
|
13201
12830
|
instanceId: instanceId,
|
|
13202
12831
|
effect: report.effect,
|
|
@@ -13230,6 +12859,7 @@ const workflow = {
|
|
|
13230
12859
|
telemetry: args.telemetry
|
|
13231
12860
|
});
|
|
13232
12861
|
return resolveTelemetry(args.telemetry).log(WorkflowInstanceTicked, {
|
|
12862
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
13233
12863
|
...definitionHashFragment(settled.instance.pinnedContentHash),
|
|
13234
12864
|
instanceId: instanceId,
|
|
13235
12865
|
cascaded: settled.cascaded
|
|
@@ -13265,6 +12895,7 @@ const workflow = {
|
|
|
13265
12895
|
})
|
|
13266
12896
|
});
|
|
13267
12897
|
return resolveTelemetry(args.telemetry).log(WorkflowStageSet, {
|
|
12898
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
13268
12899
|
...definitionHashFragment(before.pinnedContentHash),
|
|
13269
12900
|
instanceId: instanceId,
|
|
13270
12901
|
changed: result.fired
|
|
@@ -13315,6 +12946,7 @@ const workflow = {
|
|
|
13315
12946
|
} : {}
|
|
13316
12947
|
});
|
|
13317
12948
|
return resolveTelemetry(args.telemetry).log(WorkflowInstanceAborted, {
|
|
12949
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
13318
12950
|
...definitionHashFragment(before.pinnedContentHash),
|
|
13319
12951
|
instanceId: instanceId,
|
|
13320
12952
|
changed: changed
|
|
@@ -13356,6 +12988,7 @@ const workflow = {
|
|
|
13356
12988
|
})
|
|
13357
12989
|
});
|
|
13358
12990
|
return resolveTelemetry(args.telemetry).log(WorkflowActivityReset, {
|
|
12991
|
+
...executionContextFragment(resolveExecutionContext(executionContext)),
|
|
13359
12992
|
...definitionHashFragment(before.pinnedContentHash),
|
|
13360
12993
|
instanceId: instanceId,
|
|
13361
12994
|
changed: result.fired
|
|
@@ -13668,7 +13301,7 @@ async function startFreshInstance(args) {
|
|
|
13668
13301
|
tag: tag
|
|
13669
13302
|
}), id = instanceId ?? instanceDocId(tag);
|
|
13670
13303
|
assertInitialStageExists(definition);
|
|
13671
|
-
const now = clock();
|
|
13304
|
+
const now = clock(), execution = resolveExecutionContext(executionContext);
|
|
13672
13305
|
await assertStartInputs({
|
|
13673
13306
|
client: client,
|
|
13674
13307
|
tag: tag,
|
|
@@ -13704,7 +13337,7 @@ async function startFreshInstance(args) {
|
|
|
13704
13337
|
perspective: perspective ?? derivePerspectiveFromFields(resolvedFields),
|
|
13705
13338
|
initialStage: definition.initialStage,
|
|
13706
13339
|
actor: actor,
|
|
13707
|
-
executionContext:
|
|
13340
|
+
executionContext: execution,
|
|
13708
13341
|
...fieldDiscards.length > 0 ? {
|
|
13709
13342
|
extraHistory: fieldDiscards
|
|
13710
13343
|
} : {}
|
|
@@ -13725,12 +13358,15 @@ async function startFreshInstance(args) {
|
|
|
13725
13358
|
...startArgs.telemetry !== void 0 ? {
|
|
13726
13359
|
telemetry: startArgs.telemetry
|
|
13727
13360
|
} : {},
|
|
13728
|
-
emitStarted: () => resolveTelemetry(startArgs.telemetry).log(WorkflowInstanceStarted,
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13361
|
+
emitStarted: () => resolveTelemetry(startArgs.telemetry).log(WorkflowInstanceStarted, {
|
|
13362
|
+
...executionContextFragment(execution),
|
|
13363
|
+
...instanceStartedData({
|
|
13364
|
+
definition: definition,
|
|
13365
|
+
instanceId: id,
|
|
13366
|
+
initialFieldCount: seedFields.length,
|
|
13367
|
+
viaSpawn: !1
|
|
13368
|
+
})
|
|
13369
|
+
})
|
|
13734
13370
|
});
|
|
13735
13371
|
return settledResult({
|
|
13736
13372
|
...settled,
|
|
@@ -14457,7 +14093,7 @@ async function applyEditPreviews(args) {
|
|
|
14457
14093
|
}
|
|
14458
14094
|
|
|
14459
14095
|
function createInstanceSession(args) {
|
|
14460
|
-
const {client: client, tag: tag, clock: clock, executionContext: executionContext} = args, telemetry = resolveTelemetry(args.telemetry);
|
|
14096
|
+
const {client: client, tag: tag, clock: clock, executionContext: executionContext} = args, telemetry = resolveTelemetry(args.telemetry), execution = resolveExecutionContext(executionContext);
|
|
14461
14097
|
let instance = asHeldInstance(args.instance);
|
|
14462
14098
|
const opScope = opTag => {
|
|
14463
14099
|
const scoped = taggedScope(args, opTag);
|
|
@@ -14735,6 +14371,7 @@ function createInstanceSession(args) {
|
|
|
14735
14371
|
instanceId: instance._id,
|
|
14736
14372
|
tag: tag
|
|
14737
14373
|
}), telemetry.log(WorkflowInstanceTicked, {
|
|
14374
|
+
...executionContextFragment(execution),
|
|
14738
14375
|
...definitionHashFragment(instance.pinnedContentHash),
|
|
14739
14376
|
instanceId: instance._id,
|
|
14740
14377
|
cascaded: settled.cascaded
|
|
@@ -14791,12 +14428,15 @@ function createInstanceSession(args) {
|
|
|
14791
14428
|
scope: fireScope,
|
|
14792
14429
|
memberRolesLoader: memberRolesLoader
|
|
14793
14430
|
});
|
|
14794
|
-
return telemetry.log(WorkflowActionFired,
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14431
|
+
return telemetry.log(WorkflowActionFired, {
|
|
14432
|
+
...executionContextFragment(execution),
|
|
14433
|
+
...actionFiredData({
|
|
14434
|
+
instance: preOp,
|
|
14435
|
+
activity: activity,
|
|
14436
|
+
params: params,
|
|
14437
|
+
cascaded: result.cascaded
|
|
14438
|
+
})
|
|
14439
|
+
}), result;
|
|
14800
14440
|
});
|
|
14801
14441
|
},
|
|
14802
14442
|
editField({target: target, mode: mode, value: value}) {
|
|
@@ -14853,11 +14493,14 @@ function createInstanceSession(args) {
|
|
|
14853
14493
|
scope: editScope,
|
|
14854
14494
|
memberRolesLoader: memberRolesLoader
|
|
14855
14495
|
});
|
|
14856
|
-
return telemetry.log(WorkflowFieldEdited,
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14496
|
+
return telemetry.log(WorkflowFieldEdited, {
|
|
14497
|
+
...executionContextFragment(execution),
|
|
14498
|
+
...fieldEditedData({
|
|
14499
|
+
instance: preOp,
|
|
14500
|
+
target: target,
|
|
14501
|
+
mode: mode
|
|
14502
|
+
})
|
|
14503
|
+
}), result;
|
|
14861
14504
|
}).finally(() => {
|
|
14862
14505
|
stagedKey !== void 0 && previews.delete(stagedKey);
|
|
14863
14506
|
});
|
|
@@ -14895,7 +14538,7 @@ function createEngine(args) {
|
|
|
14895
14538
|
const effects = {
|
|
14896
14539
|
handlers: args.effects?.handlers ?? {},
|
|
14897
14540
|
missingHandler: args.effects?.missingHandler ?? "fail"
|
|
14898
|
-
}, logger = args.loggerFactory ?? defaultLoggerFactory, telemetry = resolveTelemetry(args.telemetry), EMPTY_DRAIN_LOG_INTERVAL_MS = 6e4;
|
|
14541
|
+
}, logger = args.loggerFactory ?? defaultLoggerFactory, telemetry = resolveTelemetry(args.telemetry), execution = resolveExecutionContext(executionContext), EMPTY_DRAIN_LOG_INTERVAL_MS = 6e4;
|
|
14899
14542
|
let lastEmptyDrainLoggedAt;
|
|
14900
14543
|
const emptyDrainDue = () => {
|
|
14901
14544
|
const now = Date.parse((clock ?? wallClock)());
|
|
@@ -14991,6 +14634,7 @@ function createEngine(args) {
|
|
|
14991
14634
|
} : {}
|
|
14992
14635
|
}), drained = result.drained;
|
|
14993
14636
|
return (drained.length > 0 || emptyDrainDue()) && telemetry.log(WorkflowEffectsDrained, {
|
|
14637
|
+
...executionContextFragment(execution),
|
|
14994
14638
|
...definitionHashFragment(result.definitionContentHash),
|
|
14995
14639
|
instanceId: instanceId,
|
|
14996
14640
|
drainedCount: drained.length,
|
|
@@ -15565,4 +15209,4 @@ function displayDescription(typeKey) {
|
|
|
15565
15209
|
if (typeKey) return DISPLAY[typeKey]?.description;
|
|
15566
15210
|
}
|
|
15567
15211
|
|
|
15568
|
-
export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_KIND_DISPLAY, ACTOR_KINDS, ANONYMOUS_IDENTITY, AUTHORING_DISPLAY, ActionDisabledError, ActionParamsInvalidError, CONDITION_VARS, CONTEXT_ENTRY_DISPLAY, CascadeLimitError, ConcurrentCascadeError, ConcurrentCommitEffectOpsError, ConcurrentCompleteEffectError, ConcurrentEditFieldError, ConcurrentFireActionError, ContractViolationError, DATA_MODEL_CHANGES, DATA_MODEL_MAX_READER, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DECISION_SEMANTICS, DEFAULT_CONTENT_PERSPECTIVE, DEFAULT_EFFECT_LEASE_MS, DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_TRANSITION_WHEN, DISPLAY, DOCUMENT_VALUE_PERMISSIONS, 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, NEUTRAL_MARK, OP_DISPLAY, OUTCOME_MARKS, PartialGuardDeployError, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, ReaderModelAcknowledgementError, RefResourceUndeclaredError, RequiredFieldNotProvidedError, SIGNAL_SEMANTICS, 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, WorkflowInstancePreviewSchema, WorkflowInstanceSchema, WorkflowInstanceStarted, WorkflowInstanceTicked, WorkflowStageSet, WorkflowStageTransitioned, WorkflowStateDivergedError, _additionalMissingDocuments, _fieldTargetLabel, _missingDocumentsSummary, _requestProjectMembers, _resolveTelemetryEnvironment, abortReason, acceptsDocumentType, aclPathForResource, actionDisabledDetail, actionRendering, actionVerdict, activeAssignmentMembers, activityAutonomyOf, actorFulfillsRole, actorMatchesAssignment, analyzeCondition2 as analyzeCondition, applicableDefinitions, assertReadableModel, assertReaderModelAcknowledgement, assignmentMatch, assignmentMembers, assignmentPrefilter, assignmentState, assignmentStateCounts, atomReadsDataset2 as atomReadsDataset, autonomySummary, availableActions, buildInitialFields, buildSnapshot, checklistLines, classifyPrincipalId, clientConfigFromResource, clientGuardDereference, clientProjectUserDirectory, compileGuards, computeDiffEntries, conditionFieldReadNames, conditionSitesOf, contentDocQuery, contentDraftFallback, contentReleaseName, contextMap, createEngine, createTelemetryIntake, datasetResourceParts, defaultLoggerFactory, definitionDeployedData, definitionLookupGroq, definitionRoleNames, definitionTagsGroq, definitionsListGroq, deniedGuardLabels, deniedGuardRefs, denyingGuards, deployStageGuards, deployedTagsGroq, deriveActivityKind, deriveExecutorClassification, deriveWorkflowAutonomy, describeAtom, describeAutonomyWait, describeCondition, describeDefinition, describeFieldInsight, describeNode, describeSite, describeSiteHeading, diagnoseInputFromEvaluation, diagnoseInstance, diffEntry, displayDescription, displayTitle, documentActionDenials, documentPrefilter, documentStuckCause, driverKind, effectOutputsMap, effectSites, entryDocRefs, errorMessage, evaluateFromSnapshot, evaluateMutationGuard, evaluateStartFilter, expandResourceAliases, explainCondition2 as explainCondition, explainStartRequirement, extractDocumentId, fieldTreeShape, findActivityNode, findCurrentActivityEntry, findOpenStageEntry, findStageNode, formatRead2 as formatRead, gdrFromResource, gdrRef, gdrUri, groupMembershipNames, groupSitesOf, guardMatches, guardsForDefinition, guardsForInstance, guardsForResource, guillemets2 as guillemets, hasSingleSubjectRequirement, hashDefinitionContent, humanize2 as humanize, identityMatchesAssignment, inFlightFilter, initialFieldIssues, instanceAssignmentStateCounts, instanceChangesQuery, instanceDocId, instanceGuardQuery, instancePreviewsQuery, instanceWatchesDocument, instancesGuardQuery, instancesQuery, isCascadeFired, isClaimExpired, isClientProjectUser, isComparisonOp, isDefinitionApplicable, isFilterScopedOut, isGdr, isInputSourced, isNotesEntry, isProjectUserNotFoundError, isRevisionConflict, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTelemetryEnvDenied, isTerminalActivityStatus, isTerminalStage, isTodoListEntry, isTodoListItem, isUnprimed, lakeGuardId, lakePrincipalId, latestDefinitionsGroq, latestDeployedDefinitions, lintEffectOutputs, minReaderModelOf, missingRequiredInputs, modelVersionOf, narrateAutonomyWaits, noopTelemetry, openActivityAssignments, parentRef, parseDefinitionInput, parseDefinitionSnapshot, parseDefinitionSnapshotValue, parseGdr, parseGuardDocument, parseInstanceDocument, parseInstancePreviewDocument, parseResourceGdr, processShellUserProperties, projectStartSliceRow, projectToWatchRef, quoted2 as quoted, readInstanceDoc, readInstancePreviewDoc, readsRaw, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, refsOf, rejectedRefTypes, releaseDocId, releaseRef, remediationsFor, requiredDefinitionReaderModel, requiredModelFeatures, requiredReaderModel, resolveAccess, resolveActor, resolveClientActor, resolveFieldEntry
|
|
15212
|
+
export { ACTION_SEMANTICS, ACTIVITY_KINDS, ACTIVITY_KIND_DISPLAY, ACTOR_KINDS, ANONYMOUS_IDENTITY, AUTHORING_DISPLAY, ActionDisabledError, ActionParamsInvalidError, CONDITION_VARS, CONTEXT_ENTRY_DISPLAY, CascadeLimitError, ConcurrentCascadeError, ConcurrentCommitEffectOpsError, ConcurrentCompleteEffectError, ConcurrentEditFieldError, ConcurrentFireActionError, ContractViolationError, DATA_MODEL_CHANGES, DATA_MODEL_MAX_READER, DATA_MODEL_MIN_READER, DATA_MODEL_VERSION, DECISION_SEMANTICS, DEFAULT_CONTENT_PERSPECTIVE, DEFAULT_EFFECT_LEASE_MS, DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_TRANSITION_WHEN, DISPLAY, DOCUMENT_VALUE_PERMISSIONS, 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, NEUTRAL_MARK, OP_DISPLAY, OUTCOME_MARKS, PartialGuardDeployError, PersistedDocShapeError, READER_MODEL_ROLLOUT_URL, RESERVED_CONDITION_VARS, ReaderModelAcknowledgementError, RefResourceUndeclaredError, RequiredFieldNotProvidedError, SIGNAL_SEMANTICS, 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, WorkflowInstancePreviewSchema, WorkflowInstanceSchema, WorkflowInstanceStarted, WorkflowInstanceTicked, WorkflowStageSet, WorkflowStageTransitioned, WorkflowStateDivergedError, _additionalMissingDocuments, _fieldTargetLabel, _missingDocumentsSummary, _parseDefinitionsWithReaderModel, _requestProjectMembers, _resolveTelemetryEnvironment, abortReason, acceptsDocumentType, aclPathForResource, actionDisabledDetail, actionRendering, actionVerdict, activeAssignmentMembers, activityAutonomyOf, actorFulfillsRole, actorMatchesAssignment, analyzeCondition2 as analyzeCondition, applicableDefinitions, assertReadableModel, assertReaderModelAcknowledgement, assignmentMatch, assignmentMembers, assignmentPrefilter, assignmentState, assignmentStateCounts, atomReadsDataset2 as atomReadsDataset, autonomySummary, availableActions, buildInitialFields, buildSnapshot, checklistLines, classifyPrincipalId, clientConfigFromResource, clientGuardDereference, clientProjectUserDirectory, compileGuards, computeDiffEntries, conditionFieldReadNames, conditionSitesOf, contentDocQuery, contentDraftFallback, contentReleaseName, contextMap, createEngine, createTelemetryIntake, datasetResourceParts, defaultLoggerFactory, definitionDeployedData, definitionLookupGroq, definitionRoleNames, definitionTagsGroq, definitionsListGroq, deniedGuardLabels, deniedGuardRefs, denyingGuards, deployStageGuards, deployedTagsGroq, deriveActivityKind, deriveExecutorClassification, deriveWorkflowAutonomy, describeAtom, describeAutonomyWait, describeCondition, describeDefinition, describeFieldInsight, describeNode, describeSite, describeSiteHeading, diagnoseInputFromEvaluation, diagnoseInstance, diffEntry, displayDescription, displayTitle, documentActionDenials, documentPrefilter, documentStuckCause, driverKind, effectOutputsMap, effectSites, entryDocRefs, errorMessage, evaluateFromSnapshot, evaluateMutationGuard, evaluateStartFilter, expandResourceAliases, explainCondition2 as explainCondition, explainStartRequirement, extractDocumentId, fieldTreeShape, findActivityNode, findCurrentActivityEntry, findOpenStageEntry, findStageNode, formatRead2 as formatRead, gdrFromResource, gdrRef, gdrUri, groupMembershipNames, groupSitesOf, guardMatches, guardsForDefinition, guardsForInstance, guardsForResource, guillemets2 as guillemets, hasSingleSubjectRequirement, hashDefinitionContent, humanize2 as humanize, identityMatchesAssignment, inFlightFilter, initialFieldIssues, instanceAssignmentStateCounts, instanceChangesQuery, instanceDocId, instanceGuardQuery, instancePreviewsQuery, instanceWatchesDocument, instancesGuardQuery, instancesQuery, isCascadeFired, isClaimExpired, isClientProjectUser, isComparisonOp, isDefinitionApplicable, isFilterScopedOut, isGdr, isInputSourced, isNotesEntry, isProjectUserNotFoundError, isRevisionConflict, isSingleDocRefEntry, isSingleDocRefKind, isStartableDefinition, isSubjectEntry, isTelemetryEnvDenied, isTerminalActivityStatus, isTerminalStage, isTodoListEntry, isTodoListItem, isUnprimed, lakeGuardId, lakePrincipalId, latestDefinitionsGroq, latestDeployedDefinitions, lintEffectOutputs, minReaderModelOf, missingRequiredInputs, modelVersionOf, narrateAutonomyWaits, noopTelemetry, openActivityAssignments, parentRef, parseDefinitionInput, parseDefinitionSnapshot, parseDefinitionSnapshotValue, parseGdr, parseGuardDocument, parseInstanceDocument, parseInstancePreviewDocument, parseResourceGdr, processShellUserProperties, projectStartSliceRow, projectToWatchRef, quoted2 as quoted, readInstanceDoc, readInstancePreviewDoc, readsRaw, readsRootDocument, refCanvas, refDashboard, refDataset, refKindAcceptsTypes, refMediaLibrary, refsOf, rejectedRefTypes, releaseDocId, releaseRef, remediationsFor, requiredDefinitionReaderModel, requiredModelFeatures, requiredReaderModel, resolveAccess, resolveActor, resolveClientActor, resolveFieldEntry, resolveUserAttributes, resourceAliasesToMap, resourceFromParsed, resourceGdr, retractStageGuards, sameResource, scalarValidationIssues, schemaTreeShape, sentenceCase, silentLogger, singleSubjectRequirementRefused, snapshotGuardDereference, stageAutonomyOf, startFieldsParam, startKindOf, startRefusal, stripSystemFields, subjectDenialLabels, subscriptionDocument, subscriptionDocumentsForInstance, sweepStaleClaims, tagScopeFilter, terminalState, toBareId, tryParseGdr, unboundRequirementReads, unsatisfiedTransitionSummaries, userLoginProvider, validateDefinition, validateTag, verdictGuardsForInstance, wallClock, whatIfCondition2 as whatIfCondition, withAssignment, workflow };
|