@sanity/workflow-engine 0.26.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 +65 -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 +389 -88
- package/dist/index.d.cts +56 -15
- package/dist/index.d.ts +56 -15
- package/dist/index.js +302 -5
- 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
|
} : {},
|
|
@@ -5386,12 +5673,20 @@ function resolveMetadata(metadata, ctx) {
|
|
|
5386
5673
|
return out;
|
|
5387
5674
|
}
|
|
5388
5675
|
|
|
5676
|
+
function userLoginProvider(user) {
|
|
5677
|
+
return user?.provider ?? user?.loginProvider;
|
|
5678
|
+
}
|
|
5679
|
+
|
|
5389
5680
|
function isRecord(value) {
|
|
5390
5681
|
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
5391
5682
|
}
|
|
5392
5683
|
|
|
5684
|
+
function optionalString(value) {
|
|
5685
|
+
return value === void 0 || typeof value == "string";
|
|
5686
|
+
}
|
|
5687
|
+
|
|
5393
5688
|
function isClientProjectUser(value) {
|
|
5394
|
-
return isRecord(value) && typeof value.id == "string" && (value.sanityUserId
|
|
5689
|
+
return isRecord(value) && typeof value.id == "string" && optionalString(value.sanityUserId) && optionalString(value.displayName) && optionalString(value.email) && (value.imageUrl === null || optionalString(value.imageUrl)) && optionalString(value.provider) && optionalString(value.loginProvider);
|
|
5395
5690
|
}
|
|
5396
5691
|
|
|
5397
5692
|
function objectProperty(value, property) {
|
|
@@ -5890,12 +6185,14 @@ function resolveGuard({guard: guard, instance: instance, stageName: stageName, n
|
|
|
5890
6185
|
|
|
5891
6186
|
async function upsertGuard(args) {
|
|
5892
6187
|
const {client: client, doc: doc, exists: exists} = args;
|
|
5893
|
-
if (!exists) {
|
|
6188
|
+
if (!exists) try {
|
|
5894
6189
|
await client.create(doc, {
|
|
5895
6190
|
...SYNC_COMMIT,
|
|
5896
6191
|
tag: REQUEST_TAG.guardDeploy
|
|
5897
6192
|
});
|
|
5898
6193
|
return;
|
|
6194
|
+
} catch (error) {
|
|
6195
|
+
if (!isCreateIdCollision(error)) throw error;
|
|
5899
6196
|
}
|
|
5900
6197
|
const {_id: _id, _type: _type, _rev: _rev, _createdAt: _createdAt, _updatedAt: _updatedAt, ...body} = doc;
|
|
5901
6198
|
await client.patch(doc._id).set(body).commit({
|
|
@@ -6241,7 +6538,7 @@ async function persistThenDeploy({ctx: ctx, mutation: mutation, deploy: deploy})
|
|
|
6241
6538
|
committedRev: committed._rev,
|
|
6242
6539
|
restore: instanceStateFields({
|
|
6243
6540
|
...ctx.instance,
|
|
6244
|
-
minReaderModel:
|
|
6541
|
+
minReaderModel: minReaderModelOf(ctx.instance)
|
|
6245
6542
|
}),
|
|
6246
6543
|
unset: ctx.instance.completedAt === void 0 ? [ "completedAt" ] : [],
|
|
6247
6544
|
reversible: !spawned,
|
|
@@ -6607,16 +6904,16 @@ async function resolveDefinitionRef({client: client, ref: ref, tag: tag}) {
|
|
|
6607
6904
|
};
|
|
6608
6905
|
wantsExplicit && (params.version = ref.version);
|
|
6609
6906
|
const result = await client.fetch(definitionLookupGroq(wantsExplicit), params);
|
|
6610
|
-
return result ?
|
|
6907
|
+
return result ? assertReadableModel(result) : null;
|
|
6611
6908
|
}
|
|
6612
6909
|
|
|
6613
6910
|
async function prepareChildInstance(args) {
|
|
6614
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 = {
|
|
6615
6912
|
id: invariants.gdrFromResource(workflowResource, childDocId),
|
|
6616
|
-
type:
|
|
6913
|
+
type: WORKFLOW_INSTANCE_TYPE
|
|
6617
6914
|
}, ancestors = [ ...parent.ancestors, {
|
|
6618
6915
|
id: invariants.selfGdr(parent),
|
|
6619
|
-
type:
|
|
6916
|
+
type: WORKFLOW_INSTANCE_TYPE
|
|
6620
6917
|
} ], inheritedPerspective = parent.perspective, fieldDiscards = [], childFields = await resolveDeclaredFields({
|
|
6621
6918
|
entryDefs: definition.fields,
|
|
6622
6919
|
initialFields: initialFields,
|
|
@@ -7400,7 +7697,7 @@ async function runCascadeHop({client: client, instanceId: instanceId, actor: act
|
|
|
7400
7697
|
}) : await buildEngineContext({
|
|
7401
7698
|
client: client,
|
|
7402
7699
|
instance: instance,
|
|
7403
|
-
definition:
|
|
7700
|
+
definition: parseDefinitionSnapshot(instance),
|
|
7404
7701
|
...contextOptions
|
|
7405
7702
|
});
|
|
7406
7703
|
if (isTerminal(ctx)) return {
|
|
@@ -7581,7 +7878,7 @@ async function loadInstancesById(client, ids) {
|
|
|
7581
7878
|
const children = await client.fetch("*[_id in $ids]", {
|
|
7582
7879
|
ids: ids
|
|
7583
7880
|
});
|
|
7584
|
-
return new Map(children.filter(child => child._type ===
|
|
7881
|
+
return new Map(children.filter(child => child._type === WORKFLOW_INSTANCE_TYPE).map(child => {
|
|
7585
7882
|
const instance = readInstanceDoc(child);
|
|
7586
7883
|
return [ instance._id, instance ];
|
|
7587
7884
|
}));
|
|
@@ -7641,10 +7938,10 @@ async function propagateToAncestors(args) {
|
|
|
7641
7938
|
async function loadPropagationPair({client: client, instanceId: instanceId, instance: instance}) {
|
|
7642
7939
|
const child = instance ?? await getInstanceDocument(client, instanceId);
|
|
7643
7940
|
if (!child) return;
|
|
7644
|
-
const parentGdr =
|
|
7941
|
+
const parentGdr = parentRef(child);
|
|
7645
7942
|
if (parentGdr === void 0) return;
|
|
7646
7943
|
const parentDoc = await client.getDocument(invariants.toBareId(parentGdr.id));
|
|
7647
|
-
if (!(!parentDoc || parentDoc._type !==
|
|
7944
|
+
if (!(!parentDoc || parentDoc._type !== WORKFLOW_INSTANCE_TYPE)) return {
|
|
7648
7945
|
child: child,
|
|
7649
7946
|
parent: readInstanceDoc(parentDoc)
|
|
7650
7947
|
};
|
|
@@ -7671,7 +7968,7 @@ async function buildCascadeStepContext(args, instance) {
|
|
|
7671
7968
|
clientForGdr: args.clientForGdr,
|
|
7672
7969
|
refSurface: args.refSurface,
|
|
7673
7970
|
instance: instance,
|
|
7674
|
-
definition:
|
|
7971
|
+
definition: parseDefinitionSnapshot(instance),
|
|
7675
7972
|
...args.clock ? {
|
|
7676
7973
|
clock: args.clock
|
|
7677
7974
|
} : {},
|
|
@@ -7722,7 +8019,7 @@ function stampSpawnBatch({mutation: mutation, parent: parent, children: children
|
|
|
7722
8019
|
function requireSpawnBatchChild({parent: parent, children: children, childId: childId}) {
|
|
7723
8020
|
const child = children.get(childId);
|
|
7724
8021
|
if (child === void 0) throw new Error(`Spawn batch child ${childId} disappeared`);
|
|
7725
|
-
const expectedParent =
|
|
8022
|
+
const expectedParent = parentRef(child);
|
|
7726
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}`);
|
|
7727
8024
|
return child;
|
|
7728
8025
|
}
|
|
@@ -7745,7 +8042,7 @@ async function recordOrphanedPropagation({ctx: ctx, mutation: mutation, child: c
|
|
|
7745
8042
|
at: ctx.now,
|
|
7746
8043
|
instanceRef: {
|
|
7747
8044
|
id: childUri,
|
|
7748
|
-
type:
|
|
8045
|
+
type: WORKFLOW_INSTANCE_TYPE
|
|
7749
8046
|
},
|
|
7750
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.`
|
|
7751
8048
|
}), await persist(ctx, mutation));
|
|
@@ -7753,7 +8050,7 @@ async function recordOrphanedPropagation({ctx: ctx, mutation: mutation, child: c
|
|
|
7753
8050
|
|
|
7754
8051
|
function startMutation(instance) {
|
|
7755
8052
|
return {
|
|
7756
|
-
minReaderModel:
|
|
8053
|
+
minReaderModel: minReaderModelOf(instance),
|
|
7757
8054
|
currentStage: instance.currentStage,
|
|
7758
8055
|
fields: (instance.fields ?? []).map(s => ({
|
|
7759
8056
|
...s
|
|
@@ -7820,7 +8117,7 @@ function instanceStateFields(src) {
|
|
|
7820
8117
|
} : {}
|
|
7821
8118
|
};
|
|
7822
8119
|
return {
|
|
7823
|
-
...
|
|
8120
|
+
...modelStampFor({
|
|
7824
8121
|
documentType: "instance",
|
|
7825
8122
|
document: state,
|
|
7826
8123
|
storedMinReaderModel: src.minReaderModel
|
|
@@ -8696,7 +8993,7 @@ async function whatIfFireAction(args) {
|
|
|
8696
8993
|
|
|
8697
8994
|
function replayable(args) {
|
|
8698
8995
|
const {instance: instance, stage: stage, action: action} = args;
|
|
8699
|
-
if (
|
|
8996
|
+
if (terminalState(instance) !== "in-flight" || (action.params ?? []).length > 0 || action.spawn !== void 0) return !1;
|
|
8700
8997
|
const primed = new Set((findOpenStageEntry(instance)?.activities ?? []).map(e => e.name));
|
|
8701
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;
|
|
8702
8999
|
}
|
|
@@ -8836,7 +9133,7 @@ async function evaluateInstance(args) {
|
|
|
8836
9133
|
client: client,
|
|
8837
9134
|
instanceId: instanceId,
|
|
8838
9135
|
tag: tag
|
|
8839
|
-
}) ]), {actor: actor, grants: grants, localPrincipalId: localPrincipalId} = access, definition =
|
|
9136
|
+
}) ]), {actor: actor, grants: grants, localPrincipalId: localPrincipalId} = access, definition = parseDefinitionSnapshot(instance), clientForGdr = buildClientForGdr({
|
|
8840
9137
|
client: client,
|
|
8841
9138
|
workflowResource: workflowResource,
|
|
8842
9139
|
resourceClients: resourceClients
|
|
@@ -9396,7 +9693,7 @@ function idsArm(filter, params) {
|
|
|
9396
9693
|
function instancesQuery(args) {
|
|
9397
9694
|
const {tag: tag, filter: filter = {}} = args;
|
|
9398
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)}`);
|
|
9399
|
-
const conditions = [ `_type == "${
|
|
9696
|
+
const conditions = [ `_type == "${WORKFLOW_INSTANCE_TYPE}"`, invariants.tagScopeFilter() ], params = {
|
|
9400
9697
|
tag: tag
|
|
9401
9698
|
};
|
|
9402
9699
|
filter.includeCompleted !== !0 && conditions.push(inFlightFilter()), filter.definition !== void 0 && (conditions.push("definition == $definition"),
|
|
@@ -9605,7 +9902,7 @@ function planDefinitionDeploy({def: def, latest: latest, target: target}) {
|
|
|
9605
9902
|
tag: target.tag,
|
|
9606
9903
|
version: version,
|
|
9607
9904
|
contentHash: contentHash,
|
|
9608
|
-
...
|
|
9905
|
+
...modelStampFor({
|
|
9609
9906
|
documentType: "definition",
|
|
9610
9907
|
document: expanded
|
|
9611
9908
|
})
|
|
@@ -9682,7 +9979,7 @@ async function loadDefinition({client: client, definition: definition, version:
|
|
|
9682
9979
|
definition: definition,
|
|
9683
9980
|
version: version
|
|
9684
9981
|
});
|
|
9685
|
-
return
|
|
9982
|
+
return assertReadableModel(doc);
|
|
9686
9983
|
}
|
|
9687
9984
|
const latest = await loadLatestDeployed({
|
|
9688
9985
|
client: client,
|
|
@@ -9700,14 +9997,14 @@ async function loadLatestDeployed({client: client, definition: definition, tag:
|
|
|
9700
9997
|
definition: definition,
|
|
9701
9998
|
tag: tag
|
|
9702
9999
|
});
|
|
9703
|
-
return doc ?
|
|
10000
|
+
return doc ? assertReadableModel(doc) : void 0;
|
|
9704
10001
|
}
|
|
9705
10002
|
|
|
9706
10003
|
async function loadDefinitionVersions({client: client, definition: definition, tag: tag}) {
|
|
9707
10004
|
return (await client.fetch(`*[_type == "${invariants.WORKFLOW_DEFINITION_TYPE}" && name == $definition && ${invariants.tagScopeFilter()}] | order(version desc)`, {
|
|
9708
10005
|
definition: definition,
|
|
9709
10006
|
tag: tag
|
|
9710
|
-
})).map(
|
|
10007
|
+
})).map(assertReadableModel);
|
|
9711
10008
|
}
|
|
9712
10009
|
|
|
9713
10010
|
async function loadDefinitionVersionsOrThrow({client: client, definition: definition, tag: tag}) {
|
|
@@ -10095,8 +10392,8 @@ async function resumeStart(args) {
|
|
|
10095
10392
|
version: args.version
|
|
10096
10393
|
});
|
|
10097
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.`);
|
|
10098
|
-
if (existing.stages.length === 0 &&
|
|
10099
|
-
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({
|
|
10100
10397
|
instance: existing,
|
|
10101
10398
|
initialFieldCount: args.initialFieldCount,
|
|
10102
10399
|
viaSpawn: !1
|
|
@@ -10403,7 +10700,7 @@ async function deleteDefinition(args) {
|
|
|
10403
10700
|
async function assertNoSpawnReferrers({client: client, tag: tag, definition: definition, targets: targets, lastVersionGoes: lastVersionGoes}) {
|
|
10404
10701
|
const deployed = (await client.fetch(`*[_type == "${invariants.WORKFLOW_DEFINITION_TYPE}" && ${invariants.tagScopeFilter()}]`, {
|
|
10405
10702
|
tag: tag
|
|
10406
|
-
})).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)));
|
|
10407
10704
|
if (referrers.length > 0) throw new invariants.DefinitionInUseError({
|
|
10408
10705
|
definition: definition,
|
|
10409
10706
|
blockedBy: {
|
|
@@ -10418,7 +10715,7 @@ async function assertNoSpawnReferrers({client: client, tag: tag, definition: def
|
|
|
10418
10715
|
|
|
10419
10716
|
async function nonTerminalInstanceIds({client: client, tag: tag, definition: definition, version: version}) {
|
|
10420
10717
|
const versionFilter = version === void 0 ? "" : " && pinnedVersion == $version";
|
|
10421
|
-
return (await client.fetch(`*[_type == "${
|
|
10718
|
+
return (await client.fetch(`*[_type == "${WORKFLOW_INSTANCE_TYPE}" && definition == $definition && ${invariants.tagScopeFilter()} && ${inFlightFilter()}${versionFilter}] | order(_id asc){_id}`, {
|
|
10422
10719
|
definition: definition,
|
|
10423
10720
|
tag: tag,
|
|
10424
10721
|
...version !== void 0 ? {
|
|
@@ -10463,12 +10760,12 @@ async function fetchStartSlice(args) {
|
|
|
10463
10760
|
includeCompleted: !0
|
|
10464
10761
|
}
|
|
10465
10762
|
});
|
|
10466
|
-
return (await client.fetch(query, params)).map(
|
|
10763
|
+
return (await client.fetch(query, params)).map(assertReadableModel).map(projectStartSliceRow);
|
|
10467
10764
|
}
|
|
10468
10765
|
|
|
10469
10766
|
const workflow = {
|
|
10470
10767
|
deployDefinitions: async rawArgs => {
|
|
10471
|
-
|
|
10768
|
+
assertReaderModelAcknowledgement(rawArgs.expectedMinReaderModel);
|
|
10472
10769
|
const args = taggedScope(rawArgs, REQUEST_TAG.deploy), {client: client, tag: tag, resourceAliases: resourceAliases} = args;
|
|
10473
10770
|
invariants.validateTag(tag);
|
|
10474
10771
|
const definitions = args.definitions.map(def => parseDefinitionInput(def, "workflow.deployDefinitions"));
|
|
@@ -11094,7 +11391,7 @@ const workflow = {
|
|
|
11094
11391
|
instance: instance
|
|
11095
11392
|
}), reserved = await renderConditionScope({
|
|
11096
11393
|
instance: instance,
|
|
11097
|
-
definition:
|
|
11394
|
+
definition: parseDefinitionSnapshot(instance),
|
|
11098
11395
|
snapshot: snapshot,
|
|
11099
11396
|
now: clock()
|
|
11100
11397
|
}), tree = groqJs.parse(groq, {
|
|
@@ -11173,7 +11470,7 @@ const workflow = {
|
|
|
11173
11470
|
invariants.validateTag(tag);
|
|
11174
11471
|
const clock = args.clock ?? wallClock, deployed = (await client.fetch(latestDefinitionsGroq(), {
|
|
11175
11472
|
tag: tag
|
|
11176
|
-
})).map(
|
|
11473
|
+
})).map(assertReadableModel);
|
|
11177
11474
|
let slice;
|
|
11178
11475
|
return applicableDefinitions({
|
|
11179
11476
|
definitions: deployed,
|
|
@@ -11555,7 +11852,7 @@ async function verifyDeployedDefinitionsInternal(args) {
|
|
|
11555
11852
|
invariants.validateTag(tag);
|
|
11556
11853
|
const log = logger("verifyDeployedDefinitions"), definitions = (await client.fetch(definitionsListGroq("asc"), {
|
|
11557
11854
|
tag: tag
|
|
11558
|
-
})).map(
|
|
11855
|
+
})).map(assertReadableModel), seen = [], missingByName = /* @__PURE__ */ new Map;
|
|
11559
11856
|
for (const def of definitions) seen.push({
|
|
11560
11857
|
name: def.name,
|
|
11561
11858
|
version: def.version,
|
|
@@ -12000,7 +12297,7 @@ function createInstanceSession(args) {
|
|
|
12000
12297
|
}, uri = invariants.gdrFromResource(owned.resource, owned.doc._id);
|
|
12001
12298
|
if (uri === selfUri()) {
|
|
12002
12299
|
const rawStamp = owned.doc._updatedAt;
|
|
12003
|
-
!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));
|
|
12004
12301
|
return;
|
|
12005
12302
|
}
|
|
12006
12303
|
target.set(uri, owned);
|
|
@@ -12023,7 +12320,7 @@ function createInstanceSession(args) {
|
|
|
12023
12320
|
let parsedDefinition;
|
|
12024
12321
|
const definitionOf = () => (parsedDefinition?.source !== instance && (parsedDefinition = {
|
|
12025
12322
|
source: instance,
|
|
12026
|
-
definition:
|
|
12323
|
+
definition: parseDefinitionSnapshot(instance)
|
|
12027
12324
|
}), parsedDefinition.definition), siteKey = site => JSON.stringify([ site.scope, site.activity ?? null, site.name ]), stagePreview = ({target: target, mode: mode, value: value}) => {
|
|
12028
12325
|
const site = previewSiteOf({
|
|
12029
12326
|
instance: instance,
|
|
@@ -12662,7 +12959,7 @@ function attributeMember({member: member, group: group, chain: chain}) {
|
|
|
12662
12959
|
}
|
|
12663
12960
|
|
|
12664
12961
|
function diffEntry({def: rawDef, latestRaw: latestRaw, target: target}) {
|
|
12665
|
-
|
|
12962
|
+
assertReaderModelAcknowledgement(target.expectedMinReaderModel);
|
|
12666
12963
|
const def = parseDefinitionInput(rawDef, "diffEntry"), plan = planDefinitionDeploy({
|
|
12667
12964
|
def: def,
|
|
12668
12965
|
latest: asLatest(latestRaw),
|
|
@@ -12694,7 +12991,7 @@ function asLatest(raw) {
|
|
|
12694
12991
|
}
|
|
12695
12992
|
|
|
12696
12993
|
async function computeDiffEntries({client: client, defs: defs, target: target}) {
|
|
12697
|
-
|
|
12994
|
+
assertReaderModelAcknowledgement(target.expectedMinReaderModel);
|
|
12698
12995
|
const entries = [];
|
|
12699
12996
|
for (const rawDef of defs) {
|
|
12700
12997
|
const def = parseDefinitionInput(rawDef, "computeDiffEntries"), latest = await loadLatestDeployed({
|
|
@@ -12943,7 +13240,7 @@ const HISTORY_DISPLAY = {
|
|
|
12943
13240
|
title: "Workflow definition",
|
|
12944
13241
|
description: "An immutable workflow blueprint, addressed by `name` + `version`."
|
|
12945
13242
|
},
|
|
12946
|
-
[
|
|
13243
|
+
[WORKFLOW_INSTANCE_TYPE]: {
|
|
12947
13244
|
title: "Workflow instance",
|
|
12948
13245
|
description: "A running (or finished) workflow against its declared fields."
|
|
12949
13246
|
}
|
|
@@ -13022,12 +13319,6 @@ exports.CONDITION_VARS = invariants.CONDITION_VARS;
|
|
|
13022
13319
|
|
|
13023
13320
|
exports.ContractViolationError = invariants.ContractViolationError;
|
|
13024
13321
|
|
|
13025
|
-
exports.DATA_MODEL_CHANGES = invariants.DATA_MODEL_CHANGES;
|
|
13026
|
-
|
|
13027
|
-
exports.DATA_MODEL_MIN_READER = invariants.DATA_MODEL_MIN_READER;
|
|
13028
|
-
|
|
13029
|
-
exports.DATA_MODEL_VERSION = invariants.DATA_MODEL_VERSION;
|
|
13030
|
-
|
|
13031
13322
|
exports.DEFAULT_TRANSITION_WHEN = invariants.DEFAULT_TRANSITION_WHEN;
|
|
13032
13323
|
|
|
13033
13324
|
exports.DRIVER_KINDS = invariants.DRIVER_KINDS;
|
|
@@ -13050,16 +13341,10 @@ exports.GUARD_PREDICATE_VARS = invariants.GUARD_PREDICATE_VARS;
|
|
|
13050
13341
|
|
|
13051
13342
|
exports.InstanceNotFoundError = invariants.InstanceNotFoundError;
|
|
13052
13343
|
|
|
13053
|
-
exports.ModelVersionAheadError = invariants.ModelVersionAheadError;
|
|
13054
|
-
|
|
13055
13344
|
exports.PersistedDocShapeError = invariants.PersistedDocShapeError;
|
|
13056
13345
|
|
|
13057
|
-
exports.READER_MODEL_ROLLOUT_URL = invariants.READER_MODEL_ROLLOUT_URL;
|
|
13058
|
-
|
|
13059
13346
|
exports.RESERVED_CONDITION_VARS = invariants.RESERVED_CONDITION_VARS;
|
|
13060
13347
|
|
|
13061
|
-
exports.ReaderModelAcknowledgementError = invariants.ReaderModelAcknowledgementError;
|
|
13062
|
-
|
|
13063
13348
|
exports.START_FILTER_VARS = invariants.START_FILTER_VARS;
|
|
13064
13349
|
|
|
13065
13350
|
exports.START_REQUIREMENT_VARS = invariants.START_REQUIREMENT_VARS;
|
|
@@ -13070,14 +13355,8 @@ exports.SpawnContractsInvalidError = invariants.SpawnContractsInvalidError;
|
|
|
13070
13355
|
|
|
13071
13356
|
exports.WORKFLOW_DEFINITION_TYPE = invariants.WORKFLOW_DEFINITION_TYPE;
|
|
13072
13357
|
|
|
13073
|
-
exports.WORKFLOW_INSTANCE_TYPE = invariants.WORKFLOW_INSTANCE_TYPE;
|
|
13074
|
-
|
|
13075
13358
|
exports.WorkflowError = invariants.WorkflowError;
|
|
13076
13359
|
|
|
13077
|
-
exports.assertReadableModel = invariants.assertReadableModel;
|
|
13078
|
-
|
|
13079
|
-
exports.assertReaderModelAcknowledgement = invariants.assertReaderModelAcknowledgement;
|
|
13080
|
-
|
|
13081
13360
|
exports.classifyPrincipalId = invariants.classifyPrincipalId;
|
|
13082
13361
|
|
|
13083
13362
|
exports.clientConfigFromResource = invariants.clientConfigFromResource;
|
|
@@ -13096,8 +13375,6 @@ exports.errorMessage = invariants.errorMessage;
|
|
|
13096
13375
|
|
|
13097
13376
|
exports.extractDocumentId = invariants.extractDocumentId;
|
|
13098
13377
|
|
|
13099
|
-
exports.fieldTreeShape = invariants.fieldTreeShape;
|
|
13100
|
-
|
|
13101
13378
|
exports.gdrFromResource = invariants.gdrFromResource;
|
|
13102
13379
|
|
|
13103
13380
|
exports.gdrRef = invariants.gdrRef;
|
|
@@ -13128,20 +13405,8 @@ exports.isTodoListEntry = invariants.isTodoListEntry;
|
|
|
13128
13405
|
|
|
13129
13406
|
exports.isTodoListItem = invariants.isTodoListItem;
|
|
13130
13407
|
|
|
13131
|
-
exports.isUnprimed = invariants.isUnprimed;
|
|
13132
|
-
|
|
13133
13408
|
exports.lakePrincipalId = invariants.lakePrincipalId;
|
|
13134
13409
|
|
|
13135
|
-
exports.minReaderModelOf = invariants.minReaderModelOf;
|
|
13136
|
-
|
|
13137
|
-
exports.modelVersionOf = invariants.modelVersionOf;
|
|
13138
|
-
|
|
13139
|
-
exports.parentRef = invariants.parentRef;
|
|
13140
|
-
|
|
13141
|
-
exports.parseDefinitionSnapshot = invariants.parseDefinitionSnapshot;
|
|
13142
|
-
|
|
13143
|
-
exports.parseDefinitionSnapshotValue = invariants.parseDefinitionSnapshotValue;
|
|
13144
|
-
|
|
13145
13410
|
exports.parseGdr = invariants.parseGdr;
|
|
13146
13411
|
|
|
13147
13412
|
exports.parseResourceGdr = invariants.parseResourceGdr;
|
|
@@ -13164,10 +13429,6 @@ exports.releaseDocId = invariants.releaseDocId;
|
|
|
13164
13429
|
|
|
13165
13430
|
exports.releaseRef = invariants.releaseRef;
|
|
13166
13431
|
|
|
13167
|
-
exports.requiredModelFeatures = invariants.requiredModelFeatures;
|
|
13168
|
-
|
|
13169
|
-
exports.requiredReaderModel = invariants.requiredReaderModel;
|
|
13170
|
-
|
|
13171
13432
|
exports.resourceAliasesToMap = invariants.resourceAliasesToMap;
|
|
13172
13433
|
|
|
13173
13434
|
exports.resourceFromParsed = invariants.resourceFromParsed;
|
|
@@ -13184,8 +13445,6 @@ exports.startKindOf = invariants.startKindOf;
|
|
|
13184
13445
|
|
|
13185
13446
|
exports.tagScopeFilter = invariants.tagScopeFilter;
|
|
13186
13447
|
|
|
13187
|
-
exports.terminalState = invariants.terminalState;
|
|
13188
|
-
|
|
13189
13448
|
exports.toBareId = invariants.toBareId;
|
|
13190
13449
|
|
|
13191
13450
|
exports.tryParseGdr = invariants.tryParseGdr;
|
|
@@ -13310,6 +13569,12 @@ exports.ConcurrentEditFieldError = ConcurrentEditFieldError;
|
|
|
13310
13569
|
|
|
13311
13570
|
exports.ConcurrentFireActionError = ConcurrentFireActionError;
|
|
13312
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
|
+
|
|
13313
13578
|
exports.DEFAULT_CONTENT_PERSPECTIVE = DEFAULT_CONTENT_PERSPECTIVE;
|
|
13314
13579
|
|
|
13315
13580
|
exports.DEFAULT_EFFECT_LEASE_MS = DEFAULT_EFFECT_LEASE_MS;
|
|
@@ -13352,6 +13617,8 @@ exports.InitialFieldsInvalidError = InitialFieldsInvalidError;
|
|
|
13352
13617
|
|
|
13353
13618
|
exports.MissingHandlerError = MissingHandlerError;
|
|
13354
13619
|
|
|
13620
|
+
exports.ModelVersionAheadError = ModelVersionAheadError;
|
|
13621
|
+
|
|
13355
13622
|
exports.MutationGuardDeniedError = MutationGuardDeniedError;
|
|
13356
13623
|
|
|
13357
13624
|
exports.MutationGuardDocSchema = MutationGuardDocSchema;
|
|
@@ -13360,6 +13627,10 @@ exports.OP_DISPLAY = OP_DISPLAY;
|
|
|
13360
13627
|
|
|
13361
13628
|
exports.PartialGuardDeployError = PartialGuardDeployError;
|
|
13362
13629
|
|
|
13630
|
+
exports.READER_MODEL_ROLLOUT_URL = READER_MODEL_ROLLOUT_URL;
|
|
13631
|
+
|
|
13632
|
+
exports.ReaderModelAcknowledgementError = ReaderModelAcknowledgementError;
|
|
13633
|
+
|
|
13363
13634
|
exports.RefResourceUndeclaredError = RefResourceUndeclaredError;
|
|
13364
13635
|
|
|
13365
13636
|
exports.RequiredFieldNotProvidedError = RequiredFieldNotProvidedError;
|
|
@@ -13372,6 +13643,8 @@ exports.StartNotPrimedError = StartNotPrimedError;
|
|
|
13372
13643
|
|
|
13373
13644
|
exports.StartNotSettledError = StartNotSettledError;
|
|
13374
13645
|
|
|
13646
|
+
exports.WORKFLOW_INSTANCE_TYPE = WORKFLOW_INSTANCE_TYPE;
|
|
13647
|
+
|
|
13375
13648
|
exports.WorkflowActionFired = WorkflowActionFired;
|
|
13376
13649
|
|
|
13377
13650
|
exports.WorkflowActivityReset = WorkflowActivityReset;
|
|
@@ -13418,6 +13691,10 @@ exports.activityAutonomyOf = activityAutonomyOf;
|
|
|
13418
13691
|
|
|
13419
13692
|
exports.applicableDefinitions = applicableDefinitions;
|
|
13420
13693
|
|
|
13694
|
+
exports.assertReadableModel = assertReadableModel;
|
|
13695
|
+
|
|
13696
|
+
exports.assertReaderModelAcknowledgement = assertReaderModelAcknowledgement;
|
|
13697
|
+
|
|
13421
13698
|
exports.autonomySummary = autonomySummary;
|
|
13422
13699
|
|
|
13423
13700
|
exports.availableActions = availableActions;
|
|
@@ -13514,6 +13791,8 @@ exports.expandResourceAliases = expandResourceAliases;
|
|
|
13514
13791
|
|
|
13515
13792
|
exports.explainStartRequirement = explainStartRequirement;
|
|
13516
13793
|
|
|
13794
|
+
exports.fieldTreeShape = fieldTreeShape;
|
|
13795
|
+
|
|
13517
13796
|
exports.findCurrentActivityEntry = findCurrentActivityEntry;
|
|
13518
13797
|
|
|
13519
13798
|
exports.findOpenStageEntry = findOpenStageEntry;
|
|
@@ -13556,10 +13835,14 @@ exports.isFilterScopedOut = isFilterScopedOut;
|
|
|
13556
13835
|
|
|
13557
13836
|
exports.isProjectUserNotFoundError = isProjectUserNotFoundError;
|
|
13558
13837
|
|
|
13838
|
+
exports.isRevisionConflict = isRevisionConflict;
|
|
13839
|
+
|
|
13559
13840
|
exports.isTelemetryEnvDenied = isTelemetryEnvDenied;
|
|
13560
13841
|
|
|
13561
13842
|
exports.isTerminalStage = isTerminalStage;
|
|
13562
13843
|
|
|
13844
|
+
exports.isUnprimed = isUnprimed;
|
|
13845
|
+
|
|
13563
13846
|
exports.lakeGuardId = lakeGuardId;
|
|
13564
13847
|
|
|
13565
13848
|
exports.latestDefinitionsGroq = latestDefinitionsGroq;
|
|
@@ -13568,14 +13851,24 @@ exports.latestDeployedDefinitions = latestDeployedDefinitions;
|
|
|
13568
13851
|
|
|
13569
13852
|
exports.lintEffectOutputs = lintEffectOutputs;
|
|
13570
13853
|
|
|
13854
|
+
exports.minReaderModelOf = minReaderModelOf;
|
|
13855
|
+
|
|
13571
13856
|
exports.missingRequiredInputs = missingRequiredInputs;
|
|
13572
13857
|
|
|
13858
|
+
exports.modelVersionOf = modelVersionOf;
|
|
13859
|
+
|
|
13573
13860
|
exports.narrateAutonomyWaits = narrateAutonomyWaits;
|
|
13574
13861
|
|
|
13575
13862
|
exports.noopTelemetry = noopTelemetry;
|
|
13576
13863
|
|
|
13864
|
+
exports.parentRef = parentRef;
|
|
13865
|
+
|
|
13577
13866
|
exports.parseDefinitionInput = parseDefinitionInput;
|
|
13578
13867
|
|
|
13868
|
+
exports.parseDefinitionSnapshot = parseDefinitionSnapshot;
|
|
13869
|
+
|
|
13870
|
+
exports.parseDefinitionSnapshotValue = parseDefinitionSnapshotValue;
|
|
13871
|
+
|
|
13579
13872
|
exports.parseGuardDocument = parseGuardDocument;
|
|
13580
13873
|
|
|
13581
13874
|
exports.parseInstanceDocument = parseInstanceDocument;
|
|
@@ -13594,6 +13887,10 @@ exports.refsOf = refsOf;
|
|
|
13594
13887
|
|
|
13595
13888
|
exports.remediationsFor = remediationsFor;
|
|
13596
13889
|
|
|
13890
|
+
exports.requiredModelFeatures = requiredModelFeatures;
|
|
13891
|
+
|
|
13892
|
+
exports.requiredReaderModel = requiredReaderModel;
|
|
13893
|
+
|
|
13597
13894
|
exports.resolveAccess = resolveAccess;
|
|
13598
13895
|
|
|
13599
13896
|
exports.resolveActor = resolveActor;
|
|
@@ -13624,10 +13921,14 @@ exports.subscriptionDocumentsForInstance = subscriptionDocumentsForInstance;
|
|
|
13624
13921
|
|
|
13625
13922
|
exports.sweepStaleClaims = sweepStaleClaims;
|
|
13626
13923
|
|
|
13924
|
+
exports.terminalState = terminalState;
|
|
13925
|
+
|
|
13627
13926
|
exports.unboundRequirementReads = unboundRequirementReads;
|
|
13628
13927
|
|
|
13629
13928
|
exports.unsatisfiedTransitionSummaries = unsatisfiedTransitionSummaries;
|
|
13630
13929
|
|
|
13930
|
+
exports.userLoginProvider = userLoginProvider;
|
|
13931
|
+
|
|
13631
13932
|
exports.validateDefinition = validateDefinition;
|
|
13632
13933
|
|
|
13633
13934
|
exports.verdictGuardsForInstance = verdictGuardsForInstance;
|