@sanity/workflow-engine 0.27.0 → 0.28.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 +47 -0
- package/dist/_chunks-cjs/invariants.cjs +35 -356
- package/dist/_chunks-es/invariants.js +36 -317
- package/dist/define.cjs +1 -6
- package/dist/define.d.cts +45 -15
- package/dist/define.d.ts +45 -15
- package/dist/define.js +2 -7
- package/dist/index.cjs +378 -87
- package/dist/index.d.cts +38 -15
- package/dist/index.d.ts +38 -15
- package/dist/index.js +293 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55,6 +55,53 @@ function findCurrentActivityEntry(host, activityName) {
|
|
|
55
55
|
return findOpenStageEntry(host)?.activities.find(a => a.name === activityName);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
const WORKFLOW_INSTANCE_TYPE = "sanity.workflow.instance";
|
|
59
|
+
|
|
60
|
+
function terminalState(instance) {
|
|
61
|
+
return instance.abortedAt !== void 0 ? "aborted" : instance.completedAt !== void 0 ? "completed" : "in-flight";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isUnprimed(instance) {
|
|
65
|
+
return instance.stages.length === 0 && terminalState(instance) === "in-flight";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function parseDefinitionSnapshotValue(instance) {
|
|
69
|
+
try {
|
|
70
|
+
return normalizeLegacyActivityRequirements(JSON.parse(instance.definitionSnapshot));
|
|
71
|
+
} catch (err) {
|
|
72
|
+
invariants.rethrowWithContext(err, `Failed to parse definitionSnapshot on instance "${instance._id}"`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function normalizeLegacyActivityRequirements(value) {
|
|
77
|
+
for (const stage of arrayMember(value, "stages")) for (const activity of arrayMember(stage, "activities")) normalizeLegacyRequirementMap(activity);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function arrayMember(value, key) {
|
|
82
|
+
if (typeof value != "object" || value === null) return [];
|
|
83
|
+
const member = value[key];
|
|
84
|
+
return Array.isArray(member) ? member : [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function normalizeLegacyRequirementMap(value) {
|
|
88
|
+
if (typeof value != "object" || value === null) return;
|
|
89
|
+
const activity = value, requirements = activity.requirements;
|
|
90
|
+
typeof requirements != "object" || requirements === null || Array.isArray(requirements) || (activity.requirements = Object.entries(requirements).map(([name, query]) => ({
|
|
91
|
+
type: "groq",
|
|
92
|
+
name: name,
|
|
93
|
+
query: query
|
|
94
|
+
})));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function parseDefinitionSnapshot(instance) {
|
|
98
|
+
return parseDefinitionSnapshotValue(instance);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function parentRef(instance) {
|
|
102
|
+
return instance.ancestors.at(-1);
|
|
103
|
+
}
|
|
104
|
+
|
|
58
105
|
function effectiveEditable(baseline, override) {
|
|
59
106
|
if (baseline === void 0) return;
|
|
60
107
|
if (override === void 0) return baseline;
|
|
@@ -131,7 +178,7 @@ function resolveEditTarget(args) {
|
|
|
131
178
|
}
|
|
132
179
|
|
|
133
180
|
function fieldWindowOpen(instance, site) {
|
|
134
|
-
const terminal =
|
|
181
|
+
const terminal = terminalState(instance);
|
|
135
182
|
if (terminal !== "in-flight") return {
|
|
136
183
|
open: !1,
|
|
137
184
|
detail: `instance ${terminal}`
|
|
@@ -198,7 +245,7 @@ function editDisabledReason(args) {
|
|
|
198
245
|
}
|
|
199
246
|
|
|
200
247
|
function instanceTerminalReason(instance) {
|
|
201
|
-
const terminal =
|
|
248
|
+
const terminal = terminalState(instance);
|
|
202
249
|
if (terminal === "aborted" && instance.abortedAt !== void 0) return {
|
|
203
250
|
kind: "instance-aborted",
|
|
204
251
|
abortedAt: instance.abortedAt
|
|
@@ -328,7 +375,7 @@ function instanceStartedData(args) {
|
|
|
328
375
|
function instanceStartedDataFor(args) {
|
|
329
376
|
return instanceStartedData({
|
|
330
377
|
definition: {
|
|
331
|
-
...
|
|
378
|
+
...parseDefinitionSnapshot(args.instance),
|
|
332
379
|
...args.instance.pinnedContentHash !== void 0 ? {
|
|
333
380
|
contentHash: args.instance.pinnedContentHash
|
|
334
381
|
} : {}
|
|
@@ -356,7 +403,7 @@ function stageTransitionedData(args) {
|
|
|
356
403
|
}
|
|
357
404
|
|
|
358
405
|
function openStage$1(instance) {
|
|
359
|
-
const definition =
|
|
406
|
+
const definition = parseDefinitionSnapshot(instance);
|
|
360
407
|
return {
|
|
361
408
|
definition: definition,
|
|
362
409
|
stage: definition.stages.find(s => s.name === instance.currentStage)
|
|
@@ -402,6 +449,240 @@ function fieldEditedData(args) {
|
|
|
402
449
|
};
|
|
403
450
|
}
|
|
404
451
|
|
|
452
|
+
const DATA_MODEL_VERSION = 5, DATA_MODEL_MIN_READER = 4, READER_MODEL_ROLLOUT_URL = "https://www.sanity.io/docs/editorial-workflows/prerelease";
|
|
453
|
+
|
|
454
|
+
class ReaderModelAcknowledgementError extends invariants.WorkflowError {
|
|
455
|
+
code="WORKFLOW_READER_MODEL_ACKNOWLEDGEMENT_MISMATCH";
|
|
456
|
+
expectedMinReaderModel;
|
|
457
|
+
engineMinReaderModel=DATA_MODEL_MIN_READER;
|
|
458
|
+
engineModelVersion=DATA_MODEL_VERSION;
|
|
459
|
+
documentationUrl=READER_MODEL_ROLLOUT_URL;
|
|
460
|
+
constructor(expectedMinReaderModel, context = "Deployment") {
|
|
461
|
+
const expected = expectedMinReaderModel === void 0 ? "missing" : String(expectedMinReaderModel);
|
|
462
|
+
super("reader-model-acknowledgement", `${context} expected reader floor ${expected}; the installed engine requires acknowledgement ${DATA_MODEL_MIN_READER}.\nDo not change the acknowledgement yet: accepting ${DATA_MODEL_MIN_READER} authorizes this engine to write documents that older readers will refuse.\nUpgrade every Studio, CLI, MCP server, Function, and other runtime that reads engine-owned documents; verify that rollout in every environment sharing the workflow resource; then change the literal in deployment configuration and deploy the writer.\nRollout guide: ${READER_MODEL_ROLLOUT_URL}`),
|
|
463
|
+
this.name = "ReaderModelAcknowledgementError", this.expectedMinReaderModel = expectedMinReaderModel;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function assertReaderModelAcknowledgement(expectedMinReaderModel, context) {
|
|
468
|
+
if (typeof expectedMinReaderModel != "number" || !Number.isFinite(expectedMinReaderModel) || !Number.isInteger(expectedMinReaderModel) || expectedMinReaderModel < 0 || expectedMinReaderModel !== DATA_MODEL_MIN_READER) throw new ReaderModelAcknowledgementError(expectedMinReaderModel, context);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const DATA_MODEL_CHANGES = Object.freeze([ Object.freeze({
|
|
472
|
+
id: "governed-model-stamps",
|
|
473
|
+
introducedInModel: 1,
|
|
474
|
+
minReaderModel: 0,
|
|
475
|
+
documentTypes: Object.freeze([ "definition", "instance" ]),
|
|
476
|
+
compatibility: "additive",
|
|
477
|
+
applicability: "unconditional",
|
|
478
|
+
summary: "Definition and instance documents carry model provenance and reader-floor stamps."
|
|
479
|
+
}), Object.freeze({
|
|
480
|
+
id: "subject-field-kind",
|
|
481
|
+
introducedInModel: 2,
|
|
482
|
+
minReaderModel: 0,
|
|
483
|
+
documentTypes: Object.freeze([ "definition", "instance" ]),
|
|
484
|
+
compatibility: "additive",
|
|
485
|
+
applicability: "detectable",
|
|
486
|
+
summary: "A workflow-level subject field identifies the document a workflow is about."
|
|
487
|
+
}), Object.freeze({
|
|
488
|
+
id: "typed-scalar-choice-lists",
|
|
489
|
+
introducedInModel: 2,
|
|
490
|
+
minReaderModel: 2,
|
|
491
|
+
documentTypes: Object.freeze([ "definition", "instance" ]),
|
|
492
|
+
compatibility: "reader-floor",
|
|
493
|
+
applicability: "detectable",
|
|
494
|
+
summary: "Scalar fields may constrain writes to a persisted typed choice list."
|
|
495
|
+
}), Object.freeze({
|
|
496
|
+
id: "action-semantics",
|
|
497
|
+
introducedInModel: 2,
|
|
498
|
+
minReaderModel: 0,
|
|
499
|
+
documentTypes: Object.freeze([ "definition" ]),
|
|
500
|
+
compatibility: "additive",
|
|
501
|
+
applicability: "detectable",
|
|
502
|
+
summary: "Ordinary actions may carry a closed bag of advisory workflow semantics."
|
|
503
|
+
}), Object.freeze({
|
|
504
|
+
id: "inclusive-scalar-bounds",
|
|
505
|
+
introducedInModel: 2,
|
|
506
|
+
minReaderModel: 2,
|
|
507
|
+
documentTypes: Object.freeze([ "definition", "instance" ]),
|
|
508
|
+
compatibility: "reader-floor",
|
|
509
|
+
applicability: "detectable",
|
|
510
|
+
summary: "String, text, and number values may carry persisted inclusive bounds."
|
|
511
|
+
}), Object.freeze({
|
|
512
|
+
id: "progress-field-kind",
|
|
513
|
+
introducedInModel: 3,
|
|
514
|
+
minReaderModel: 0,
|
|
515
|
+
documentTypes: Object.freeze([ "definition", "instance" ]),
|
|
516
|
+
compatibility: "additive",
|
|
517
|
+
applicability: "detectable",
|
|
518
|
+
summary: "A progress field kind carries application-defined 0–100 completion."
|
|
519
|
+
}), Object.freeze({
|
|
520
|
+
id: "effect-claim-tokens",
|
|
521
|
+
introducedInModel: 3,
|
|
522
|
+
minReaderModel: 0,
|
|
523
|
+
documentTypes: Object.freeze([ "instance" ]),
|
|
524
|
+
compatibility: "additive",
|
|
525
|
+
applicability: "detectable",
|
|
526
|
+
summary: "Pending-effect claims carry an exact-claim token gating mid-dispatch state reports."
|
|
527
|
+
}), Object.freeze({
|
|
528
|
+
id: "classified-principal-ids",
|
|
529
|
+
introducedInModel: 4,
|
|
530
|
+
minReaderModel: 4,
|
|
531
|
+
documentTypes: Object.freeze([ "instance" ]),
|
|
532
|
+
compatibility: "reader-floor",
|
|
533
|
+
applicability: "unconditional",
|
|
534
|
+
summary: "Principal ids are namespace-classified: actor and assignee writes carry the account-global user id only, and readers resolve legacy project-scoped ids through the prefix classifier at the instance read funnel."
|
|
535
|
+
}), Object.freeze({
|
|
536
|
+
id: "readiness-requirements",
|
|
537
|
+
introducedInModel: 4,
|
|
538
|
+
minReaderModel: 4,
|
|
539
|
+
documentTypes: Object.freeze([ "definition" ]),
|
|
540
|
+
compatibility: "reader-floor",
|
|
541
|
+
applicability: "detectable",
|
|
542
|
+
summary: "Start and activity readiness use named polymorphic requirement arrays."
|
|
543
|
+
}), Object.freeze({
|
|
544
|
+
id: "due-date-field-kinds",
|
|
545
|
+
introducedInModel: 5,
|
|
546
|
+
minReaderModel: 0,
|
|
547
|
+
documentTypes: Object.freeze([ "definition", "instance" ]),
|
|
548
|
+
compatibility: "additive",
|
|
549
|
+
applicability: "detectable",
|
|
550
|
+
summary: "Due-date field kinds (dueDate, dueDatetime) mark a level deadline, elevated aliases of date/datetime carrying the same stored value."
|
|
551
|
+
}) ]);
|
|
552
|
+
|
|
553
|
+
function recordOf(value) {
|
|
554
|
+
return value !== null && typeof value == "object" && !Array.isArray(value) ? value : void 0;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function recordsAt(record, key) {
|
|
558
|
+
const value = record[key];
|
|
559
|
+
return Array.isArray(value) ? value.map(recordOf).filter(item => item !== void 0) : [];
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function nestedFieldEntries(entries) {
|
|
563
|
+
return entries.flatMap(entry => [ entry, ...nestedFieldEntries(recordsAt(entry, "fields")), ...nestedFieldEntries(recordsAt(entry, "of")) ]);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function parsedDefinitionSnapshot(root) {
|
|
567
|
+
if (typeof root.definitionSnapshot == "string") return recordOf(parseDefinitionSnapshotValue({
|
|
568
|
+
_id: typeof root._id == "string" ? root._id : "<unknown instance>",
|
|
569
|
+
definitionSnapshot: root.definitionSnapshot
|
|
570
|
+
}));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function persistedFieldEntries(document) {
|
|
574
|
+
const root = recordOf(document);
|
|
575
|
+
if (root === void 0) return [];
|
|
576
|
+
const snapshot = parsedDefinitionSnapshot(root), roots = snapshot === void 0 ? [ root ] : [ root, snapshot ], stages = roots.flatMap(candidate => recordsAt(candidate, "stages")), activities = stages.flatMap(stage => recordsAt(stage, "activities")), actions = activities.flatMap(activity => recordsAt(activity, "actions")), effects = actions.flatMap(action => recordsAt(action, "effects"));
|
|
577
|
+
return nestedFieldEntries([ ...roots.flatMap(candidate => recordsAt(candidate, "fields")), ...stages.flatMap(stage => recordsAt(stage, "fields")), ...activities.flatMap(activity => recordsAt(activity, "fields")), ...actions.flatMap(action => recordsAt(action, "params")), ...effects.flatMap(effect => recordsAt(effect, "outputs")) ]);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function hasChoiceList(document) {
|
|
581
|
+
return persistedFieldEntries(document).some(entry => {
|
|
582
|
+
const options = recordOf(entry.options);
|
|
583
|
+
return options !== void 0 && Array.isArray(options.list);
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function hasFieldKind(document, kind) {
|
|
588
|
+
return persistedFieldEntries(document).some(entry => entry.type === kind || entry._type === kind);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function hasActionSemantics(document) {
|
|
592
|
+
const root = recordOf(document);
|
|
593
|
+
return root === void 0 ? !1 : recordsAt(root, "stages").flatMap(stage => recordsAt(stage, "activities")).flatMap(activity => recordsAt(activity, "actions")).some(action => Array.isArray(action.semantics));
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function hasScalarValidation(document) {
|
|
597
|
+
return persistedFieldEntries(document).some(entry => {
|
|
598
|
+
const validation = recordOf(entry.validation);
|
|
599
|
+
return typeof validation?.min == "number" || typeof validation?.max == "number";
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function hasClaimTokens(document) {
|
|
604
|
+
const root = recordOf(document);
|
|
605
|
+
return root === void 0 ? !1 : recordsAt(root, "pendingEffects").some(entry => {
|
|
606
|
+
const claim = recordOf(entry.claim);
|
|
607
|
+
return claim !== void 0 && typeof claim.claimToken == "string";
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function hasReadinessRequirements(document) {
|
|
612
|
+
const root = recordOf(document);
|
|
613
|
+
return root === void 0 ? !1 : Array.isArray(recordOf(root.start)?.requirements) ? !0 : recordsAt(root, "stages").some(stage => recordsAt(stage, "activities").some(activity => Array.isArray(activity.requirements)));
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const featureDetectors = {
|
|
617
|
+
"governed-model-stamps": () => !0,
|
|
618
|
+
"subject-field-kind": document => hasFieldKind(document, "subject"),
|
|
619
|
+
"typed-scalar-choice-lists": hasChoiceList,
|
|
620
|
+
"action-semantics": hasActionSemantics,
|
|
621
|
+
"inclusive-scalar-bounds": hasScalarValidation,
|
|
622
|
+
"progress-field-kind": document => hasFieldKind(document, "progress"),
|
|
623
|
+
"effect-claim-tokens": hasClaimTokens,
|
|
624
|
+
"classified-principal-ids": () => !0,
|
|
625
|
+
"readiness-requirements": hasReadinessRequirements,
|
|
626
|
+
"due-date-field-kinds": document => hasFieldKind(document, "dueDate") || hasFieldKind(document, "dueDatetime")
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
function requiredModelFeatures(documentType, document) {
|
|
630
|
+
return DATA_MODEL_CHANGES.filter(change => change.documentTypes.some(candidate => candidate === documentType) && featureDetectors[change.id](document));
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function requiredReaderModel(documentType, document) {
|
|
634
|
+
return Math.max(0, ...requiredModelFeatures(documentType, document).map(change => change.minReaderModel));
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function modelStampFor(args) {
|
|
638
|
+
return {
|
|
639
|
+
modelVersion: DATA_MODEL_VERSION,
|
|
640
|
+
minReaderModel: Math.max(DATA_MODEL_MIN_READER, args.storedMinReaderModel ?? 0, requiredReaderModel(args.documentType, args.document))
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function fieldTreeShape(value) {
|
|
645
|
+
if (Array.isArray(value)) return value.map(fieldTreeShape);
|
|
646
|
+
if (value === null) return "null";
|
|
647
|
+
if (typeof value == "object") {
|
|
648
|
+
const record = value;
|
|
649
|
+
return Object.fromEntries(Object.keys(record).toSorted().map(key => [ key, fieldTreeShape(record[key]) ]));
|
|
650
|
+
}
|
|
651
|
+
return typeof value;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function modelVersionOf(doc) {
|
|
655
|
+
const stamp = doc.modelVersion;
|
|
656
|
+
return typeof stamp == "number" ? stamp : 0;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function minReaderModelOf(doc) {
|
|
660
|
+
const floor = doc.minReaderModel;
|
|
661
|
+
return typeof floor == "number" ? floor : modelVersionOf(doc);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
class ModelVersionAheadError extends invariants.WorkflowError {
|
|
665
|
+
documentId;
|
|
666
|
+
documentModelVersion;
|
|
667
|
+
requiredReaderModel;
|
|
668
|
+
engineModelVersion;
|
|
669
|
+
constructor(args) {
|
|
670
|
+
super("model-version-ahead", `Document "${args.documentId}" was written by engine data model ${args.documentModelVersion} and requires a reader at model ${args.requiredReaderModel} or newer; this engine reads up to model ${DATA_MODEL_VERSION}. Upgrade @sanity/workflow-engine to a version that understands it.`),
|
|
671
|
+
this.name = "ModelVersionAheadError", this.documentId = args.documentId, this.documentModelVersion = args.documentModelVersion,
|
|
672
|
+
this.requiredReaderModel = args.requiredReaderModel, this.engineModelVersion = DATA_MODEL_VERSION;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function assertReadableModel(doc) {
|
|
677
|
+
const documentReaderModel = minReaderModelOf(doc);
|
|
678
|
+
if (documentReaderModel > DATA_MODEL_VERSION) throw new ModelVersionAheadError({
|
|
679
|
+
documentId: doc._id,
|
|
680
|
+
documentModelVersion: modelVersionOf(doc),
|
|
681
|
+
requiredReaderModel: documentReaderModel
|
|
682
|
+
});
|
|
683
|
+
return doc;
|
|
684
|
+
}
|
|
685
|
+
|
|
405
686
|
function effectSites(def) {
|
|
406
687
|
const sites = [];
|
|
407
688
|
for (const stage of def.stages ?? []) for (const activity of stage.activities ?? []) for (const action of activity.actions ?? []) for (const effect of action.effects ?? []) sites.push({
|
|
@@ -1808,7 +2089,7 @@ function buildParams(args) {
|
|
|
1808
2089
|
return {
|
|
1809
2090
|
self: invariants.selfGdr(instance),
|
|
1810
2091
|
fields: renderedFields(instance.fields ?? [], snapshot),
|
|
1811
|
-
parent:
|
|
2092
|
+
parent: parentRef(instance)?.id ?? null,
|
|
1812
2093
|
ancestors: instance.ancestors.map(a => a.id),
|
|
1813
2094
|
stage: instance.currentStage,
|
|
1814
2095
|
now: now,
|
|
@@ -2273,6 +2554,12 @@ function isRevisionConflict(error) {
|
|
|
2273
2554
|
return statusCode === 409 ? !0 : typeof message == "string" && message.includes("ifRevisionId check failed");
|
|
2274
2555
|
}
|
|
2275
2556
|
|
|
2557
|
+
function isCreateIdCollision(error) {
|
|
2558
|
+
if (typeof error != "object" || error === null) return !1;
|
|
2559
|
+
const {message: message, responseBody: responseBody} = error;
|
|
2560
|
+
return typeof message == "string" && message.includes("already exists") && (message.includes("Document by ID") || message.includes("create() failed")) ? !0 : typeof responseBody == "string" && responseBody.includes("documentAlreadyExistsError");
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2276
2563
|
class ConcurrentEditFieldError extends invariants.WorkflowError {
|
|
2277
2564
|
instanceId;
|
|
2278
2565
|
target;
|
|
@@ -3422,7 +3709,7 @@ function noTransitionFiresCause(input) {
|
|
|
3422
3709
|
}
|
|
3423
3710
|
|
|
3424
3711
|
function diagnoseInstance(input) {
|
|
3425
|
-
const {instance: instance} = input, terminal =
|
|
3712
|
+
const {instance: instance} = input, terminal = terminalState(instance);
|
|
3426
3713
|
if (terminal === "aborted" && instance.abortedAt !== void 0) {
|
|
3427
3714
|
const reason = abortReason(instance);
|
|
3428
3715
|
return {
|
|
@@ -3576,7 +3863,7 @@ function liveSubworkflowRefs(instance) {
|
|
|
3576
3863
|
}
|
|
3577
3864
|
|
|
3578
3865
|
function readsRaw(ref) {
|
|
3579
|
-
return ref.type ===
|
|
3866
|
+
return ref.type === WORKFLOW_INSTANCE_TYPE || ref.type === "system.release";
|
|
3580
3867
|
}
|
|
3581
3868
|
|
|
3582
3869
|
const DEFAULT_CONTENT_PERSPECTIVE = "drafts";
|
|
@@ -4350,7 +4637,7 @@ const TransitionVia = v__namespace.exactOptional(v__namespace.picklist([ "transi
|
|
|
4350
4637
|
_type: v__namespace.pipe(v__namespace.string(), v__namespace.check(t => !knownHistoryTypes.has(t), "must not shadow a known history variant"))
|
|
4351
4638
|
}), HistoryEntrySchema = v__namespace.union([ v__namespace.variant("_type", HISTORY_ARMS), UnknownHistoryEntry ]), WorkflowInstanceSchema = v__namespace.looseObject(invariants.tolerantEntries()({
|
|
4352
4639
|
_id: NonEmpty,
|
|
4353
|
-
_type: v__namespace.literal(
|
|
4640
|
+
_type: v__namespace.literal(WORKFLOW_INSTANCE_TYPE),
|
|
4354
4641
|
_rev: v__namespace.string(),
|
|
4355
4642
|
_createdAt: invariants.IsoTimestamp,
|
|
4356
4643
|
_updatedAt: invariants.IsoTimestamp,
|
|
@@ -4383,7 +4670,7 @@ function parseInstanceDocument(doc) {
|
|
|
4383
4670
|
return invariants.parsePersistedDoc({
|
|
4384
4671
|
schema: WorkflowInstanceSchema,
|
|
4385
4672
|
doc: doc,
|
|
4386
|
-
docType:
|
|
4673
|
+
docType: WORKFLOW_INSTANCE_TYPE
|
|
4387
4674
|
});
|
|
4388
4675
|
}
|
|
4389
4676
|
|
|
@@ -4829,7 +5116,7 @@ async function getInstanceDocument(client, instanceId) {
|
|
|
4829
5116
|
}
|
|
4830
5117
|
|
|
4831
5118
|
function readInstanceDoc(doc) {
|
|
4832
|
-
return parseInstanceDocument(
|
|
5119
|
+
return parseInstanceDocument(assertReadableModel(doc));
|
|
4833
5120
|
}
|
|
4834
5121
|
|
|
4835
5122
|
async function reload({client: client, instanceId: instanceId, tag: tag}) {
|
|
@@ -4900,7 +5187,7 @@ function buildInstanceBase(args) {
|
|
|
4900
5187
|
} : {}
|
|
4901
5188
|
}, ...args.extraHistory ?? [] ], history = executionContext !== void 0 ? stampHistoryEntries(entries, executionContext) : entries, body = {
|
|
4902
5189
|
_id: id,
|
|
4903
|
-
_type:
|
|
5190
|
+
_type: WORKFLOW_INSTANCE_TYPE,
|
|
4904
5191
|
_rev: "",
|
|
4905
5192
|
_createdAt: now,
|
|
4906
5193
|
_updatedAt: now,
|
|
@@ -4929,7 +5216,7 @@ function buildInstanceBase(args) {
|
|
|
4929
5216
|
};
|
|
4930
5217
|
return {
|
|
4931
5218
|
...body,
|
|
4932
|
-
...
|
|
5219
|
+
...modelStampFor({
|
|
4933
5220
|
documentType: "instance",
|
|
4934
5221
|
document: body
|
|
4935
5222
|
})
|
|
@@ -5027,7 +5314,7 @@ async function readBatch(args) {
|
|
|
5027
5314
|
}
|
|
5028
5315
|
|
|
5029
5316
|
function validateRawDoc(doc, perspective) {
|
|
5030
|
-
return perspective !== "raw" ? doc : doc._type ===
|
|
5317
|
+
return perspective !== "raw" ? doc : doc._type === WORKFLOW_INSTANCE_TYPE ? readInstanceDoc(doc) : assertReadableModel(doc);
|
|
5031
5318
|
}
|
|
5032
5319
|
|
|
5033
5320
|
function groupReads(reads) {
|
|
@@ -5110,7 +5397,7 @@ async function loadContext({client: client, instanceId: instanceId, options: opt
|
|
|
5110
5397
|
clientForGdr: options.clientForGdr,
|
|
5111
5398
|
refSurface: options.refSurface,
|
|
5112
5399
|
instance: instance,
|
|
5113
|
-
definition:
|
|
5400
|
+
definition: parseDefinitionSnapshot(instance),
|
|
5114
5401
|
...options.actor !== void 0 ? {
|
|
5115
5402
|
actor: options.actor
|
|
5116
5403
|
} : {},
|
|
@@ -5898,12 +6185,14 @@ function resolveGuard({guard: guard, instance: instance, stageName: stageName, n
|
|
|
5898
6185
|
|
|
5899
6186
|
async function upsertGuard(args) {
|
|
5900
6187
|
const {client: client, doc: doc, exists: exists} = args;
|
|
5901
|
-
if (!exists) {
|
|
6188
|
+
if (!exists) try {
|
|
5902
6189
|
await client.create(doc, {
|
|
5903
6190
|
...SYNC_COMMIT,
|
|
5904
6191
|
tag: REQUEST_TAG.guardDeploy
|
|
5905
6192
|
});
|
|
5906
6193
|
return;
|
|
6194
|
+
} catch (error) {
|
|
6195
|
+
if (!isCreateIdCollision(error)) throw error;
|
|
5907
6196
|
}
|
|
5908
6197
|
const {_id: _id, _type: _type, _rev: _rev, _createdAt: _createdAt, _updatedAt: _updatedAt, ...body} = doc;
|
|
5909
6198
|
await client.patch(doc._id).set(body).commit({
|
|
@@ -6249,7 +6538,7 @@ async function persistThenDeploy({ctx: ctx, mutation: mutation, deploy: deploy})
|
|
|
6249
6538
|
committedRev: committed._rev,
|
|
6250
6539
|
restore: instanceStateFields({
|
|
6251
6540
|
...ctx.instance,
|
|
6252
|
-
minReaderModel:
|
|
6541
|
+
minReaderModel: minReaderModelOf(ctx.instance)
|
|
6253
6542
|
}),
|
|
6254
6543
|
unset: ctx.instance.completedAt === void 0 ? [ "completedAt" ] : [],
|
|
6255
6544
|
reversible: !spawned,
|
|
@@ -6615,16 +6904,16 @@ async function resolveDefinitionRef({client: client, ref: ref, tag: tag}) {
|
|
|
6615
6904
|
};
|
|
6616
6905
|
wantsExplicit && (params.version = ref.version);
|
|
6617
6906
|
const result = await client.fetch(definitionLookupGroq(wantsExplicit), params);
|
|
6618
|
-
return result ?
|
|
6907
|
+
return result ? assertReadableModel(result) : null;
|
|
6619
6908
|
}
|
|
6620
6909
|
|
|
6621
6910
|
async function prepareChildInstance(args) {
|
|
6622
6911
|
const {client: client, parent: parent, definition: definition, initialFields: initialFields, context: context, actor: actor, now: now, refSurface: refSurface} = args, childTag = parent.tag, workflowResource = parent.workflowResource, childDocId = instanceDocId(childTag), childRef = {
|
|
6623
6912
|
id: invariants.gdrFromResource(workflowResource, childDocId),
|
|
6624
|
-
type:
|
|
6913
|
+
type: WORKFLOW_INSTANCE_TYPE
|
|
6625
6914
|
}, ancestors = [ ...parent.ancestors, {
|
|
6626
6915
|
id: invariants.selfGdr(parent),
|
|
6627
|
-
type:
|
|
6916
|
+
type: WORKFLOW_INSTANCE_TYPE
|
|
6628
6917
|
} ], inheritedPerspective = parent.perspective, fieldDiscards = [], childFields = await resolveDeclaredFields({
|
|
6629
6918
|
entryDefs: definition.fields,
|
|
6630
6919
|
initialFields: initialFields,
|
|
@@ -7408,7 +7697,7 @@ async function runCascadeHop({client: client, instanceId: instanceId, actor: act
|
|
|
7408
7697
|
}) : await buildEngineContext({
|
|
7409
7698
|
client: client,
|
|
7410
7699
|
instance: instance,
|
|
7411
|
-
definition:
|
|
7700
|
+
definition: parseDefinitionSnapshot(instance),
|
|
7412
7701
|
...contextOptions
|
|
7413
7702
|
});
|
|
7414
7703
|
if (isTerminal(ctx)) return {
|
|
@@ -7589,7 +7878,7 @@ async function loadInstancesById(client, ids) {
|
|
|
7589
7878
|
const children = await client.fetch("*[_id in $ids]", {
|
|
7590
7879
|
ids: ids
|
|
7591
7880
|
});
|
|
7592
|
-
return new Map(children.filter(child => child._type ===
|
|
7881
|
+
return new Map(children.filter(child => child._type === WORKFLOW_INSTANCE_TYPE).map(child => {
|
|
7593
7882
|
const instance = readInstanceDoc(child);
|
|
7594
7883
|
return [ instance._id, instance ];
|
|
7595
7884
|
}));
|
|
@@ -7649,10 +7938,10 @@ async function propagateToAncestors(args) {
|
|
|
7649
7938
|
async function loadPropagationPair({client: client, instanceId: instanceId, instance: instance}) {
|
|
7650
7939
|
const child = instance ?? await getInstanceDocument(client, instanceId);
|
|
7651
7940
|
if (!child) return;
|
|
7652
|
-
const parentGdr =
|
|
7941
|
+
const parentGdr = parentRef(child);
|
|
7653
7942
|
if (parentGdr === void 0) return;
|
|
7654
7943
|
const parentDoc = await client.getDocument(invariants.toBareId(parentGdr.id));
|
|
7655
|
-
if (!(!parentDoc || parentDoc._type !==
|
|
7944
|
+
if (!(!parentDoc || parentDoc._type !== WORKFLOW_INSTANCE_TYPE)) return {
|
|
7656
7945
|
child: child,
|
|
7657
7946
|
parent: readInstanceDoc(parentDoc)
|
|
7658
7947
|
};
|
|
@@ -7679,7 +7968,7 @@ async function buildCascadeStepContext(args, instance) {
|
|
|
7679
7968
|
clientForGdr: args.clientForGdr,
|
|
7680
7969
|
refSurface: args.refSurface,
|
|
7681
7970
|
instance: instance,
|
|
7682
|
-
definition:
|
|
7971
|
+
definition: parseDefinitionSnapshot(instance),
|
|
7683
7972
|
...args.clock ? {
|
|
7684
7973
|
clock: args.clock
|
|
7685
7974
|
} : {},
|
|
@@ -7730,7 +8019,7 @@ function stampSpawnBatch({mutation: mutation, parent: parent, children: children
|
|
|
7730
8019
|
function requireSpawnBatchChild({parent: parent, children: children, childId: childId}) {
|
|
7731
8020
|
const child = children.get(childId);
|
|
7732
8021
|
if (child === void 0) throw new Error(`Spawn batch child ${childId} disappeared`);
|
|
7733
|
-
const expectedParent =
|
|
8022
|
+
const expectedParent = parentRef(child);
|
|
7734
8023
|
if (expectedParent === void 0 || invariants.toBareId(expectedParent.id) !== parent._id) throw new Error(`Spawn batch child ${childId} does not belong to parent ${parent._id}`);
|
|
7735
8024
|
return child;
|
|
7736
8025
|
}
|
|
@@ -7753,7 +8042,7 @@ async function recordOrphanedPropagation({ctx: ctx, mutation: mutation, child: c
|
|
|
7753
8042
|
at: ctx.now,
|
|
7754
8043
|
instanceRef: {
|
|
7755
8044
|
id: childUri,
|
|
7756
|
-
type:
|
|
8045
|
+
type: WORKFLOW_INSTANCE_TYPE
|
|
7757
8046
|
},
|
|
7758
8047
|
detail: `Instance "${child._id}" names this instance as its parent but no subworkflow-registry row matches it, so its state cannot drive any gate here.`
|
|
7759
8048
|
}), await persist(ctx, mutation));
|
|
@@ -7761,7 +8050,7 @@ async function recordOrphanedPropagation({ctx: ctx, mutation: mutation, child: c
|
|
|
7761
8050
|
|
|
7762
8051
|
function startMutation(instance) {
|
|
7763
8052
|
return {
|
|
7764
|
-
minReaderModel:
|
|
8053
|
+
minReaderModel: minReaderModelOf(instance),
|
|
7765
8054
|
currentStage: instance.currentStage,
|
|
7766
8055
|
fields: (instance.fields ?? []).map(s => ({
|
|
7767
8056
|
...s
|
|
@@ -7828,7 +8117,7 @@ function instanceStateFields(src) {
|
|
|
7828
8117
|
} : {}
|
|
7829
8118
|
};
|
|
7830
8119
|
return {
|
|
7831
|
-
...
|
|
8120
|
+
...modelStampFor({
|
|
7832
8121
|
documentType: "instance",
|
|
7833
8122
|
document: state,
|
|
7834
8123
|
storedMinReaderModel: src.minReaderModel
|
|
@@ -8704,7 +8993,7 @@ async function whatIfFireAction(args) {
|
|
|
8704
8993
|
|
|
8705
8994
|
function replayable(args) {
|
|
8706
8995
|
const {instance: instance, stage: stage, action: action} = args;
|
|
8707
|
-
if (
|
|
8996
|
+
if (terminalState(instance) !== "in-flight" || (action.params ?? []).length > 0 || action.spawn !== void 0) return !1;
|
|
8708
8997
|
const primed = new Set((findOpenStageEntry(instance)?.activities ?? []).map(e => e.name));
|
|
8709
8998
|
return (stage.activities ?? []).every(declared => primed.has(declared.name)) ? !(stage.activities ?? []).flatMap(declared => declared.actions ?? []).some(sibling => invariants.isCascadeFired(sibling) && sibling.spawn !== void 0) : !1;
|
|
8710
8999
|
}
|
|
@@ -8844,7 +9133,7 @@ async function evaluateInstance(args) {
|
|
|
8844
9133
|
client: client,
|
|
8845
9134
|
instanceId: instanceId,
|
|
8846
9135
|
tag: tag
|
|
8847
|
-
}) ]), {actor: actor, grants: grants, localPrincipalId: localPrincipalId} = access, definition =
|
|
9136
|
+
}) ]), {actor: actor, grants: grants, localPrincipalId: localPrincipalId} = access, definition = parseDefinitionSnapshot(instance), clientForGdr = buildClientForGdr({
|
|
8848
9137
|
client: client,
|
|
8849
9138
|
workflowResource: workflowResource,
|
|
8850
9139
|
resourceClients: resourceClients
|
|
@@ -9404,7 +9693,7 @@ function idsArm(filter, params) {
|
|
|
9404
9693
|
function instancesQuery(args) {
|
|
9405
9694
|
const {tag: tag, filter: filter = {}} = args;
|
|
9406
9695
|
if (invariants.validateTag(tag), filter.limit !== void 0 && (!Number.isInteger(filter.limit) || filter.limit <= 0)) throw new invariants.ContractViolationError(`instancesQuery: limit must be a positive integer; got ${JSON.stringify(filter.limit)}`);
|
|
9407
|
-
const conditions = [ `_type == "${
|
|
9696
|
+
const conditions = [ `_type == "${WORKFLOW_INSTANCE_TYPE}"`, invariants.tagScopeFilter() ], params = {
|
|
9408
9697
|
tag: tag
|
|
9409
9698
|
};
|
|
9410
9699
|
filter.includeCompleted !== !0 && conditions.push(inFlightFilter()), filter.definition !== void 0 && (conditions.push("definition == $definition"),
|
|
@@ -9613,7 +9902,7 @@ function planDefinitionDeploy({def: def, latest: latest, target: target}) {
|
|
|
9613
9902
|
tag: target.tag,
|
|
9614
9903
|
version: version,
|
|
9615
9904
|
contentHash: contentHash,
|
|
9616
|
-
...
|
|
9905
|
+
...modelStampFor({
|
|
9617
9906
|
documentType: "definition",
|
|
9618
9907
|
document: expanded
|
|
9619
9908
|
})
|
|
@@ -9690,7 +9979,7 @@ async function loadDefinition({client: client, definition: definition, version:
|
|
|
9690
9979
|
definition: definition,
|
|
9691
9980
|
version: version
|
|
9692
9981
|
});
|
|
9693
|
-
return
|
|
9982
|
+
return assertReadableModel(doc);
|
|
9694
9983
|
}
|
|
9695
9984
|
const latest = await loadLatestDeployed({
|
|
9696
9985
|
client: client,
|
|
@@ -9708,14 +9997,14 @@ async function loadLatestDeployed({client: client, definition: definition, tag:
|
|
|
9708
9997
|
definition: definition,
|
|
9709
9998
|
tag: tag
|
|
9710
9999
|
});
|
|
9711
|
-
return doc ?
|
|
10000
|
+
return doc ? assertReadableModel(doc) : void 0;
|
|
9712
10001
|
}
|
|
9713
10002
|
|
|
9714
10003
|
async function loadDefinitionVersions({client: client, definition: definition, tag: tag}) {
|
|
9715
10004
|
return (await client.fetch(`*[_type == "${invariants.WORKFLOW_DEFINITION_TYPE}" && name == $definition && ${invariants.tagScopeFilter()}] | order(version desc)`, {
|
|
9716
10005
|
definition: definition,
|
|
9717
10006
|
tag: tag
|
|
9718
|
-
})).map(
|
|
10007
|
+
})).map(assertReadableModel);
|
|
9719
10008
|
}
|
|
9720
10009
|
|
|
9721
10010
|
async function loadDefinitionVersionsOrThrow({client: client, definition: definition, tag: tag}) {
|
|
@@ -10103,8 +10392,8 @@ async function resumeStart(args) {
|
|
|
10103
10392
|
version: args.version
|
|
10104
10393
|
});
|
|
10105
10394
|
if (mismatch !== void 0) throw new invariants.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.`);
|
|
10106
|
-
if (existing.stages.length === 0 &&
|
|
10107
|
-
const completesStart =
|
|
10395
|
+
if (existing.stages.length === 0 && terminalState(existing) !== "in-flight") throw new invariants.ContractViolationError(`startInstance: instanceId "${existing._id}" belongs to a start that was discarded (aborted before it finished starting) — mint a new id to start again.`);
|
|
10396
|
+
const completesStart = isUnprimed(existing), emitStarted = () => resolveTelemetry(args.telemetry).log(WorkflowInstanceStarted, instanceStartedDataFor({
|
|
10108
10397
|
instance: existing,
|
|
10109
10398
|
initialFieldCount: args.initialFieldCount,
|
|
10110
10399
|
viaSpawn: !1
|
|
@@ -10411,7 +10700,7 @@ async function deleteDefinition(args) {
|
|
|
10411
10700
|
async function assertNoSpawnReferrers({client: client, tag: tag, definition: definition, targets: targets, lastVersionGoes: lastVersionGoes}) {
|
|
10412
10701
|
const deployed = (await client.fetch(`*[_type == "${invariants.WORKFLOW_DEFINITION_TYPE}" && ${invariants.tagScopeFilter()}]`, {
|
|
10413
10702
|
tag: tag
|
|
10414
|
-
})).map(
|
|
10703
|
+
})).map(assertReadableModel), targetIds = new Set(targets.map(d => d._id)), targetVersions = new Set(targets.map(d => d.version)), referrers = deployed.filter(d => !targetIds.has(d._id)).filter(d => refsOf(d).some(ref => ref.name === definition && (typeof ref.version == "number" ? targetVersions.has(ref.version) : lastVersionGoes)));
|
|
10415
10704
|
if (referrers.length > 0) throw new invariants.DefinitionInUseError({
|
|
10416
10705
|
definition: definition,
|
|
10417
10706
|
blockedBy: {
|
|
@@ -10426,7 +10715,7 @@ async function assertNoSpawnReferrers({client: client, tag: tag, definition: def
|
|
|
10426
10715
|
|
|
10427
10716
|
async function nonTerminalInstanceIds({client: client, tag: tag, definition: definition, version: version}) {
|
|
10428
10717
|
const versionFilter = version === void 0 ? "" : " && pinnedVersion == $version";
|
|
10429
|
-
return (await client.fetch(`*[_type == "${
|
|
10718
|
+
return (await client.fetch(`*[_type == "${WORKFLOW_INSTANCE_TYPE}" && definition == $definition && ${invariants.tagScopeFilter()} && ${inFlightFilter()}${versionFilter}] | order(_id asc){_id}`, {
|
|
10430
10719
|
definition: definition,
|
|
10431
10720
|
tag: tag,
|
|
10432
10721
|
...version !== void 0 ? {
|
|
@@ -10471,12 +10760,12 @@ async function fetchStartSlice(args) {
|
|
|
10471
10760
|
includeCompleted: !0
|
|
10472
10761
|
}
|
|
10473
10762
|
});
|
|
10474
|
-
return (await client.fetch(query, params)).map(
|
|
10763
|
+
return (await client.fetch(query, params)).map(assertReadableModel).map(projectStartSliceRow);
|
|
10475
10764
|
}
|
|
10476
10765
|
|
|
10477
10766
|
const workflow = {
|
|
10478
10767
|
deployDefinitions: async rawArgs => {
|
|
10479
|
-
|
|
10768
|
+
assertReaderModelAcknowledgement(rawArgs.expectedMinReaderModel);
|
|
10480
10769
|
const args = taggedScope(rawArgs, REQUEST_TAG.deploy), {client: client, tag: tag, resourceAliases: resourceAliases} = args;
|
|
10481
10770
|
invariants.validateTag(tag);
|
|
10482
10771
|
const definitions = args.definitions.map(def => parseDefinitionInput(def, "workflow.deployDefinitions"));
|
|
@@ -11102,7 +11391,7 @@ const workflow = {
|
|
|
11102
11391
|
instance: instance
|
|
11103
11392
|
}), reserved = await renderConditionScope({
|
|
11104
11393
|
instance: instance,
|
|
11105
|
-
definition:
|
|
11394
|
+
definition: parseDefinitionSnapshot(instance),
|
|
11106
11395
|
snapshot: snapshot,
|
|
11107
11396
|
now: clock()
|
|
11108
11397
|
}), tree = groqJs.parse(groq, {
|
|
@@ -11181,7 +11470,7 @@ const workflow = {
|
|
|
11181
11470
|
invariants.validateTag(tag);
|
|
11182
11471
|
const clock = args.clock ?? wallClock, deployed = (await client.fetch(latestDefinitionsGroq(), {
|
|
11183
11472
|
tag: tag
|
|
11184
|
-
})).map(
|
|
11473
|
+
})).map(assertReadableModel);
|
|
11185
11474
|
let slice;
|
|
11186
11475
|
return applicableDefinitions({
|
|
11187
11476
|
definitions: deployed,
|
|
@@ -11563,7 +11852,7 @@ async function verifyDeployedDefinitionsInternal(args) {
|
|
|
11563
11852
|
invariants.validateTag(tag);
|
|
11564
11853
|
const log = logger("verifyDeployedDefinitions"), definitions = (await client.fetch(definitionsListGroq("asc"), {
|
|
11565
11854
|
tag: tag
|
|
11566
|
-
})).map(
|
|
11855
|
+
})).map(assertReadableModel), seen = [], missingByName = /* @__PURE__ */ new Map;
|
|
11567
11856
|
for (const def of definitions) seen.push({
|
|
11568
11857
|
name: def.name,
|
|
11569
11858
|
version: def.version,
|
|
@@ -12008,7 +12297,7 @@ function createInstanceSession(args) {
|
|
|
12008
12297
|
}, uri = invariants.gdrFromResource(owned.resource, owned.doc._id);
|
|
12009
12298
|
if (uri === selfUri()) {
|
|
12010
12299
|
const rawStamp = owned.doc._updatedAt;
|
|
12011
|
-
!invariants.isParseableInstant(rawStamp) || owned.doc._type !==
|
|
12300
|
+
!invariants.isParseableInstant(rawStamp) || owned.doc._type !== WORKFLOW_INSTANCE_TYPE ? asHeldInstance(owned.doc) : Date.parse(rawStamp) > Date.parse(instance._updatedAt) && (instance = asHeldInstance(owned.doc));
|
|
12012
12301
|
return;
|
|
12013
12302
|
}
|
|
12014
12303
|
target.set(uri, owned);
|
|
@@ -12031,7 +12320,7 @@ function createInstanceSession(args) {
|
|
|
12031
12320
|
let parsedDefinition;
|
|
12032
12321
|
const definitionOf = () => (parsedDefinition?.source !== instance && (parsedDefinition = {
|
|
12033
12322
|
source: instance,
|
|
12034
|
-
definition:
|
|
12323
|
+
definition: parseDefinitionSnapshot(instance)
|
|
12035
12324
|
}), parsedDefinition.definition), siteKey = site => JSON.stringify([ site.scope, site.activity ?? null, site.name ]), stagePreview = ({target: target, mode: mode, value: value}) => {
|
|
12036
12325
|
const site = previewSiteOf({
|
|
12037
12326
|
instance: instance,
|
|
@@ -12670,7 +12959,7 @@ function attributeMember({member: member, group: group, chain: chain}) {
|
|
|
12670
12959
|
}
|
|
12671
12960
|
|
|
12672
12961
|
function diffEntry({def: rawDef, latestRaw: latestRaw, target: target}) {
|
|
12673
|
-
|
|
12962
|
+
assertReaderModelAcknowledgement(target.expectedMinReaderModel);
|
|
12674
12963
|
const def = parseDefinitionInput(rawDef, "diffEntry"), plan = planDefinitionDeploy({
|
|
12675
12964
|
def: def,
|
|
12676
12965
|
latest: asLatest(latestRaw),
|
|
@@ -12702,7 +12991,7 @@ function asLatest(raw) {
|
|
|
12702
12991
|
}
|
|
12703
12992
|
|
|
12704
12993
|
async function computeDiffEntries({client: client, defs: defs, target: target}) {
|
|
12705
|
-
|
|
12994
|
+
assertReaderModelAcknowledgement(target.expectedMinReaderModel);
|
|
12706
12995
|
const entries = [];
|
|
12707
12996
|
for (const rawDef of defs) {
|
|
12708
12997
|
const def = parseDefinitionInput(rawDef, "computeDiffEntries"), latest = await loadLatestDeployed({
|
|
@@ -12951,7 +13240,7 @@ const HISTORY_DISPLAY = {
|
|
|
12951
13240
|
title: "Workflow definition",
|
|
12952
13241
|
description: "An immutable workflow blueprint, addressed by `name` + `version`."
|
|
12953
13242
|
},
|
|
12954
|
-
[
|
|
13243
|
+
[WORKFLOW_INSTANCE_TYPE]: {
|
|
12955
13244
|
title: "Workflow instance",
|
|
12956
13245
|
description: "A running (or finished) workflow against its declared fields."
|
|
12957
13246
|
}
|
|
@@ -13030,12 +13319,6 @@ exports.CONDITION_VARS = invariants.CONDITION_VARS;
|
|
|
13030
13319
|
|
|
13031
13320
|
exports.ContractViolationError = invariants.ContractViolationError;
|
|
13032
13321
|
|
|
13033
|
-
exports.DATA_MODEL_CHANGES = invariants.DATA_MODEL_CHANGES;
|
|
13034
|
-
|
|
13035
|
-
exports.DATA_MODEL_MIN_READER = invariants.DATA_MODEL_MIN_READER;
|
|
13036
|
-
|
|
13037
|
-
exports.DATA_MODEL_VERSION = invariants.DATA_MODEL_VERSION;
|
|
13038
|
-
|
|
13039
13322
|
exports.DEFAULT_TRANSITION_WHEN = invariants.DEFAULT_TRANSITION_WHEN;
|
|
13040
13323
|
|
|
13041
13324
|
exports.DRIVER_KINDS = invariants.DRIVER_KINDS;
|
|
@@ -13058,16 +13341,10 @@ exports.GUARD_PREDICATE_VARS = invariants.GUARD_PREDICATE_VARS;
|
|
|
13058
13341
|
|
|
13059
13342
|
exports.InstanceNotFoundError = invariants.InstanceNotFoundError;
|
|
13060
13343
|
|
|
13061
|
-
exports.ModelVersionAheadError = invariants.ModelVersionAheadError;
|
|
13062
|
-
|
|
13063
13344
|
exports.PersistedDocShapeError = invariants.PersistedDocShapeError;
|
|
13064
13345
|
|
|
13065
|
-
exports.READER_MODEL_ROLLOUT_URL = invariants.READER_MODEL_ROLLOUT_URL;
|
|
13066
|
-
|
|
13067
13346
|
exports.RESERVED_CONDITION_VARS = invariants.RESERVED_CONDITION_VARS;
|
|
13068
13347
|
|
|
13069
|
-
exports.ReaderModelAcknowledgementError = invariants.ReaderModelAcknowledgementError;
|
|
13070
|
-
|
|
13071
13348
|
exports.START_FILTER_VARS = invariants.START_FILTER_VARS;
|
|
13072
13349
|
|
|
13073
13350
|
exports.START_REQUIREMENT_VARS = invariants.START_REQUIREMENT_VARS;
|
|
@@ -13078,14 +13355,8 @@ exports.SpawnContractsInvalidError = invariants.SpawnContractsInvalidError;
|
|
|
13078
13355
|
|
|
13079
13356
|
exports.WORKFLOW_DEFINITION_TYPE = invariants.WORKFLOW_DEFINITION_TYPE;
|
|
13080
13357
|
|
|
13081
|
-
exports.WORKFLOW_INSTANCE_TYPE = invariants.WORKFLOW_INSTANCE_TYPE;
|
|
13082
|
-
|
|
13083
13358
|
exports.WorkflowError = invariants.WorkflowError;
|
|
13084
13359
|
|
|
13085
|
-
exports.assertReadableModel = invariants.assertReadableModel;
|
|
13086
|
-
|
|
13087
|
-
exports.assertReaderModelAcknowledgement = invariants.assertReaderModelAcknowledgement;
|
|
13088
|
-
|
|
13089
13360
|
exports.classifyPrincipalId = invariants.classifyPrincipalId;
|
|
13090
13361
|
|
|
13091
13362
|
exports.clientConfigFromResource = invariants.clientConfigFromResource;
|
|
@@ -13104,8 +13375,6 @@ exports.errorMessage = invariants.errorMessage;
|
|
|
13104
13375
|
|
|
13105
13376
|
exports.extractDocumentId = invariants.extractDocumentId;
|
|
13106
13377
|
|
|
13107
|
-
exports.fieldTreeShape = invariants.fieldTreeShape;
|
|
13108
|
-
|
|
13109
13378
|
exports.gdrFromResource = invariants.gdrFromResource;
|
|
13110
13379
|
|
|
13111
13380
|
exports.gdrRef = invariants.gdrRef;
|
|
@@ -13136,20 +13405,8 @@ exports.isTodoListEntry = invariants.isTodoListEntry;
|
|
|
13136
13405
|
|
|
13137
13406
|
exports.isTodoListItem = invariants.isTodoListItem;
|
|
13138
13407
|
|
|
13139
|
-
exports.isUnprimed = invariants.isUnprimed;
|
|
13140
|
-
|
|
13141
13408
|
exports.lakePrincipalId = invariants.lakePrincipalId;
|
|
13142
13409
|
|
|
13143
|
-
exports.minReaderModelOf = invariants.minReaderModelOf;
|
|
13144
|
-
|
|
13145
|
-
exports.modelVersionOf = invariants.modelVersionOf;
|
|
13146
|
-
|
|
13147
|
-
exports.parentRef = invariants.parentRef;
|
|
13148
|
-
|
|
13149
|
-
exports.parseDefinitionSnapshot = invariants.parseDefinitionSnapshot;
|
|
13150
|
-
|
|
13151
|
-
exports.parseDefinitionSnapshotValue = invariants.parseDefinitionSnapshotValue;
|
|
13152
|
-
|
|
13153
13410
|
exports.parseGdr = invariants.parseGdr;
|
|
13154
13411
|
|
|
13155
13412
|
exports.parseResourceGdr = invariants.parseResourceGdr;
|
|
@@ -13172,10 +13429,6 @@ exports.releaseDocId = invariants.releaseDocId;
|
|
|
13172
13429
|
|
|
13173
13430
|
exports.releaseRef = invariants.releaseRef;
|
|
13174
13431
|
|
|
13175
|
-
exports.requiredModelFeatures = invariants.requiredModelFeatures;
|
|
13176
|
-
|
|
13177
|
-
exports.requiredReaderModel = invariants.requiredReaderModel;
|
|
13178
|
-
|
|
13179
13432
|
exports.resourceAliasesToMap = invariants.resourceAliasesToMap;
|
|
13180
13433
|
|
|
13181
13434
|
exports.resourceFromParsed = invariants.resourceFromParsed;
|
|
@@ -13192,8 +13445,6 @@ exports.startKindOf = invariants.startKindOf;
|
|
|
13192
13445
|
|
|
13193
13446
|
exports.tagScopeFilter = invariants.tagScopeFilter;
|
|
13194
13447
|
|
|
13195
|
-
exports.terminalState = invariants.terminalState;
|
|
13196
|
-
|
|
13197
13448
|
exports.toBareId = invariants.toBareId;
|
|
13198
13449
|
|
|
13199
13450
|
exports.tryParseGdr = invariants.tryParseGdr;
|
|
@@ -13318,6 +13569,12 @@ exports.ConcurrentEditFieldError = ConcurrentEditFieldError;
|
|
|
13318
13569
|
|
|
13319
13570
|
exports.ConcurrentFireActionError = ConcurrentFireActionError;
|
|
13320
13571
|
|
|
13572
|
+
exports.DATA_MODEL_CHANGES = DATA_MODEL_CHANGES;
|
|
13573
|
+
|
|
13574
|
+
exports.DATA_MODEL_MIN_READER = DATA_MODEL_MIN_READER;
|
|
13575
|
+
|
|
13576
|
+
exports.DATA_MODEL_VERSION = DATA_MODEL_VERSION;
|
|
13577
|
+
|
|
13321
13578
|
exports.DEFAULT_CONTENT_PERSPECTIVE = DEFAULT_CONTENT_PERSPECTIVE;
|
|
13322
13579
|
|
|
13323
13580
|
exports.DEFAULT_EFFECT_LEASE_MS = DEFAULT_EFFECT_LEASE_MS;
|
|
@@ -13360,6 +13617,8 @@ exports.InitialFieldsInvalidError = InitialFieldsInvalidError;
|
|
|
13360
13617
|
|
|
13361
13618
|
exports.MissingHandlerError = MissingHandlerError;
|
|
13362
13619
|
|
|
13620
|
+
exports.ModelVersionAheadError = ModelVersionAheadError;
|
|
13621
|
+
|
|
13363
13622
|
exports.MutationGuardDeniedError = MutationGuardDeniedError;
|
|
13364
13623
|
|
|
13365
13624
|
exports.MutationGuardDocSchema = MutationGuardDocSchema;
|
|
@@ -13368,6 +13627,10 @@ exports.OP_DISPLAY = OP_DISPLAY;
|
|
|
13368
13627
|
|
|
13369
13628
|
exports.PartialGuardDeployError = PartialGuardDeployError;
|
|
13370
13629
|
|
|
13630
|
+
exports.READER_MODEL_ROLLOUT_URL = READER_MODEL_ROLLOUT_URL;
|
|
13631
|
+
|
|
13632
|
+
exports.ReaderModelAcknowledgementError = ReaderModelAcknowledgementError;
|
|
13633
|
+
|
|
13371
13634
|
exports.RefResourceUndeclaredError = RefResourceUndeclaredError;
|
|
13372
13635
|
|
|
13373
13636
|
exports.RequiredFieldNotProvidedError = RequiredFieldNotProvidedError;
|
|
@@ -13380,6 +13643,8 @@ exports.StartNotPrimedError = StartNotPrimedError;
|
|
|
13380
13643
|
|
|
13381
13644
|
exports.StartNotSettledError = StartNotSettledError;
|
|
13382
13645
|
|
|
13646
|
+
exports.WORKFLOW_INSTANCE_TYPE = WORKFLOW_INSTANCE_TYPE;
|
|
13647
|
+
|
|
13383
13648
|
exports.WorkflowActionFired = WorkflowActionFired;
|
|
13384
13649
|
|
|
13385
13650
|
exports.WorkflowActivityReset = WorkflowActivityReset;
|
|
@@ -13426,6 +13691,10 @@ exports.activityAutonomyOf = activityAutonomyOf;
|
|
|
13426
13691
|
|
|
13427
13692
|
exports.applicableDefinitions = applicableDefinitions;
|
|
13428
13693
|
|
|
13694
|
+
exports.assertReadableModel = assertReadableModel;
|
|
13695
|
+
|
|
13696
|
+
exports.assertReaderModelAcknowledgement = assertReaderModelAcknowledgement;
|
|
13697
|
+
|
|
13429
13698
|
exports.autonomySummary = autonomySummary;
|
|
13430
13699
|
|
|
13431
13700
|
exports.availableActions = availableActions;
|
|
@@ -13522,6 +13791,8 @@ exports.expandResourceAliases = expandResourceAliases;
|
|
|
13522
13791
|
|
|
13523
13792
|
exports.explainStartRequirement = explainStartRequirement;
|
|
13524
13793
|
|
|
13794
|
+
exports.fieldTreeShape = fieldTreeShape;
|
|
13795
|
+
|
|
13525
13796
|
exports.findCurrentActivityEntry = findCurrentActivityEntry;
|
|
13526
13797
|
|
|
13527
13798
|
exports.findOpenStageEntry = findOpenStageEntry;
|
|
@@ -13564,10 +13835,14 @@ exports.isFilterScopedOut = isFilterScopedOut;
|
|
|
13564
13835
|
|
|
13565
13836
|
exports.isProjectUserNotFoundError = isProjectUserNotFoundError;
|
|
13566
13837
|
|
|
13838
|
+
exports.isRevisionConflict = isRevisionConflict;
|
|
13839
|
+
|
|
13567
13840
|
exports.isTelemetryEnvDenied = isTelemetryEnvDenied;
|
|
13568
13841
|
|
|
13569
13842
|
exports.isTerminalStage = isTerminalStage;
|
|
13570
13843
|
|
|
13844
|
+
exports.isUnprimed = isUnprimed;
|
|
13845
|
+
|
|
13571
13846
|
exports.lakeGuardId = lakeGuardId;
|
|
13572
13847
|
|
|
13573
13848
|
exports.latestDefinitionsGroq = latestDefinitionsGroq;
|
|
@@ -13576,14 +13851,24 @@ exports.latestDeployedDefinitions = latestDeployedDefinitions;
|
|
|
13576
13851
|
|
|
13577
13852
|
exports.lintEffectOutputs = lintEffectOutputs;
|
|
13578
13853
|
|
|
13854
|
+
exports.minReaderModelOf = minReaderModelOf;
|
|
13855
|
+
|
|
13579
13856
|
exports.missingRequiredInputs = missingRequiredInputs;
|
|
13580
13857
|
|
|
13858
|
+
exports.modelVersionOf = modelVersionOf;
|
|
13859
|
+
|
|
13581
13860
|
exports.narrateAutonomyWaits = narrateAutonomyWaits;
|
|
13582
13861
|
|
|
13583
13862
|
exports.noopTelemetry = noopTelemetry;
|
|
13584
13863
|
|
|
13864
|
+
exports.parentRef = parentRef;
|
|
13865
|
+
|
|
13585
13866
|
exports.parseDefinitionInput = parseDefinitionInput;
|
|
13586
13867
|
|
|
13868
|
+
exports.parseDefinitionSnapshot = parseDefinitionSnapshot;
|
|
13869
|
+
|
|
13870
|
+
exports.parseDefinitionSnapshotValue = parseDefinitionSnapshotValue;
|
|
13871
|
+
|
|
13587
13872
|
exports.parseGuardDocument = parseGuardDocument;
|
|
13588
13873
|
|
|
13589
13874
|
exports.parseInstanceDocument = parseInstanceDocument;
|
|
@@ -13602,6 +13887,10 @@ exports.refsOf = refsOf;
|
|
|
13602
13887
|
|
|
13603
13888
|
exports.remediationsFor = remediationsFor;
|
|
13604
13889
|
|
|
13890
|
+
exports.requiredModelFeatures = requiredModelFeatures;
|
|
13891
|
+
|
|
13892
|
+
exports.requiredReaderModel = requiredReaderModel;
|
|
13893
|
+
|
|
13605
13894
|
exports.resolveAccess = resolveAccess;
|
|
13606
13895
|
|
|
13607
13896
|
exports.resolveActor = resolveActor;
|
|
@@ -13632,6 +13921,8 @@ exports.subscriptionDocumentsForInstance = subscriptionDocumentsForInstance;
|
|
|
13632
13921
|
|
|
13633
13922
|
exports.sweepStaleClaims = sweepStaleClaims;
|
|
13634
13923
|
|
|
13924
|
+
exports.terminalState = terminalState;
|
|
13925
|
+
|
|
13635
13926
|
exports.unboundRequirementReads = unboundRequirementReads;
|
|
13636
13927
|
|
|
13637
13928
|
exports.unsatisfiedTransitionSummaries = unsatisfiedTransitionSummaries;
|