@camunda8/cli 4.6.0-alpha.2 → 4.6.0-alpha.4
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.
|
@@ -43,7 +43,8 @@ version resolution.
|
|
|
43
43
|
Detection happens in `parseTemplateRef()` in `template-ref.ts`
|
|
44
44
|
before any cache call. An id found locally (`.camunda/element-templates/`
|
|
45
45
|
or the Modeler user-data dir, see `resolveTemplateId`) never reaches
|
|
46
|
-
`requireCachePresent()`; only the OOTB fallback does.
|
|
46
|
+
`requireCachePresent()`; only the OOTB fallback does. `update` reads the
|
|
47
|
+
cache only on a local gap (see `templatePool` in `commands/migrate.ts`).
|
|
47
48
|
- **`saveCache` and `apply --in-place` writes are atomic.** Both
|
|
48
49
|
use a sibling temp file + `renameSync`. Anything else that
|
|
49
50
|
overwrites a user-owned file (cache or BPMN) must follow the same
|
|
@@ -147,6 +147,10 @@ c8ctl element-template update old.id process.bpmn --dry-run --json
|
|
|
147
147
|
identically and not as Hidden, `report.skipped.unchecked` lists it and the
|
|
148
148
|
migration counts as lossy. Without the source template's definition, every such
|
|
149
149
|
value set on the element counts.
|
|
150
|
+
- A value whose field survives can still be lost. A Hidden target property that
|
|
151
|
+
resets an editable source value, and a move or set that overwrites a different
|
|
152
|
+
populated value, both list the old value in `dropped` with `cause` `hidden` or
|
|
153
|
+
`displaced`, and the migration counts as lossy.
|
|
150
154
|
- All selected elements migrate in memory and the file is written once, only if
|
|
151
155
|
every element succeeds. A dry run exits 1 when an element would fail to migrate or the write would
|
|
152
156
|
need `--allow-lossy`. It does not serialize the BPMN. JSON output is one document:
|
|
@@ -8700,7 +8700,7 @@ function emptyFacts() {
|
|
|
8700
8700
|
feelSkipped: []
|
|
8701
8701
|
};
|
|
8702
8702
|
}
|
|
8703
|
-
function buildStepPlan(entries, sourceValues, template) {
|
|
8703
|
+
function buildStepPlan(entries, sourceValues, template, unverifiedReads = false) {
|
|
8704
8704
|
const facts = emptyFacts();
|
|
8705
8705
|
const writes = [];
|
|
8706
8706
|
const write = (entry, to, value) => {
|
|
@@ -8726,6 +8726,13 @@ function buildStepPlan(entries, sourceValues, template) {
|
|
|
8726
8726
|
return target;
|
|
8727
8727
|
};
|
|
8728
8728
|
for (const entry of entries) {
|
|
8729
|
+
if (unverifiedReads) {
|
|
8730
|
+
for (const guard of entry.when) {
|
|
8731
|
+
if (!lookup(sourceValues, guard.path)) {
|
|
8732
|
+
facts.noMatch.push({ from: guard.path, to: entry.to });
|
|
8733
|
+
}
|
|
8734
|
+
}
|
|
8735
|
+
}
|
|
8729
8736
|
const active = entry.when.every((g) => evalGuard(g, sourceValues));
|
|
8730
8737
|
if (entry.kind === "set") {
|
|
8731
8738
|
if (active) {
|
|
@@ -8768,6 +8775,9 @@ function buildStepPlan(entries, sourceValues, template) {
|
|
|
8768
8775
|
continue;
|
|
8769
8776
|
}
|
|
8770
8777
|
if (!source) {
|
|
8778
|
+
if (unverifiedReads) {
|
|
8779
|
+
facts.noMatch.push({ from: entry.from, to: entry.to });
|
|
8780
|
+
}
|
|
8771
8781
|
continue;
|
|
8772
8782
|
}
|
|
8773
8783
|
let value = source.value;
|
|
@@ -10064,12 +10074,12 @@ async function resolveTemplateId(ref, {
|
|
|
10064
10074
|
async function resolveOotbTemplate(ref, {
|
|
10065
10075
|
executionPlatformVersion,
|
|
10066
10076
|
requireEngineCompatibility = false,
|
|
10067
|
-
|
|
10077
|
+
loadTemplates
|
|
10068
10078
|
} = {}) {
|
|
10069
10079
|
const logger = c8ctl2.getLogger();
|
|
10070
10080
|
requireCachePresent();
|
|
10071
10081
|
nudgeIfStale(logger);
|
|
10072
|
-
const candidates =
|
|
10082
|
+
const candidates = loadTemplates ? loadTemplates().filter((t) => t.id === ref.id) : findById(ref.id);
|
|
10073
10083
|
if (candidates.length === 0) {
|
|
10074
10084
|
throw new Error(
|
|
10075
10085
|
`Element template '${ref.id}' not found. Run 'c8ctl element-template sync' to refresh the cache, or use 'c8ctl element-template search <query>' to find an id.`
|
|
@@ -11367,6 +11377,7 @@ function mergeFacts(all) {
|
|
|
11367
11377
|
let moved = [];
|
|
11368
11378
|
let set2 = [];
|
|
11369
11379
|
let failedWrites = false;
|
|
11380
|
+
let snapshot;
|
|
11370
11381
|
for (const facts of all) {
|
|
11371
11382
|
const priorMoved = moved;
|
|
11372
11383
|
const priorSet = set2;
|
|
@@ -11385,10 +11396,12 @@ function mergeFacts(all) {
|
|
|
11385
11396
|
set2.push({ ...move.to, value: move.value ?? addition.value });
|
|
11386
11397
|
} else {
|
|
11387
11398
|
const prior = priorMoved.find((item) => sameField(item.to, move.from));
|
|
11399
|
+
const read = prior ? prior.read : snapshot && find2(snapshot, move.from.key, move.from.bindingType)?.value;
|
|
11388
11400
|
moved.push({
|
|
11389
11401
|
...move,
|
|
11390
11402
|
from: prior?.from ?? move.from,
|
|
11391
|
-
transformed: Boolean(prior?.transformed) || move.transformed
|
|
11403
|
+
transformed: Boolean(prior?.transformed) || move.transformed,
|
|
11404
|
+
...read === void 0 ? {} : { read }
|
|
11392
11405
|
});
|
|
11393
11406
|
}
|
|
11394
11407
|
}
|
|
@@ -11406,6 +11419,7 @@ function mergeFacts(all) {
|
|
|
11406
11419
|
failedWrites ||= moved.some((move) => !surviving(move.to, move.value)) || set2.some((write) => !surviving(write, write.value));
|
|
11407
11420
|
moved = moved.filter((move) => surviving(move.to, move.value));
|
|
11408
11421
|
set2 = set2.filter((write) => surviving(write, write.value));
|
|
11422
|
+
snapshot = after;
|
|
11409
11423
|
}
|
|
11410
11424
|
failedWrites ||= Boolean(facts.failedWrites);
|
|
11411
11425
|
}
|
|
@@ -11413,6 +11427,12 @@ function mergeFacts(all) {
|
|
|
11413
11427
|
moved,
|
|
11414
11428
|
set: set2,
|
|
11415
11429
|
failedWrites,
|
|
11430
|
+
written: all.flatMap((f) => [
|
|
11431
|
+
...f.written ?? [],
|
|
11432
|
+
...f.moved.map((move) => move.to),
|
|
11433
|
+
...f.set.map(({ key, bindingType }) => ({ key, bindingType }))
|
|
11434
|
+
]),
|
|
11435
|
+
reset: all.flatMap((f) => f.reset ?? []),
|
|
11416
11436
|
notes: all.flatMap((f) => f.notes),
|
|
11417
11437
|
guardSkipped: all.flatMap((f) => f.guardSkipped),
|
|
11418
11438
|
templateSkipped: all.flatMap((f) => f.templateSkipped),
|
|
@@ -11476,6 +11496,14 @@ function find2(values, key, bindingType) {
|
|
|
11476
11496
|
function isHidden(template, key, bindingType) {
|
|
11477
11497
|
return propertyFor(template, key, bindingType)?.type === "Hidden";
|
|
11478
11498
|
}
|
|
11499
|
+
function hiddenIn(template, v, match) {
|
|
11500
|
+
const properties = findPropertiesByTarget(
|
|
11501
|
+
template.properties,
|
|
11502
|
+
v.key,
|
|
11503
|
+
v.bindingType
|
|
11504
|
+
);
|
|
11505
|
+
return properties.length > 0 && properties[match]((property) => property.type === "Hidden");
|
|
11506
|
+
}
|
|
11479
11507
|
function withNames(template, field, value) {
|
|
11480
11508
|
const name2 = choiceName(template, field, value);
|
|
11481
11509
|
return name2 ? { valueName: name2 } : {};
|
|
@@ -11483,6 +11511,7 @@ function withNames(template, field, value) {
|
|
|
11483
11511
|
function buildReport({
|
|
11484
11512
|
fromTemplate,
|
|
11485
11513
|
toTemplate,
|
|
11514
|
+
via = [toTemplate],
|
|
11486
11515
|
before,
|
|
11487
11516
|
after,
|
|
11488
11517
|
facts,
|
|
@@ -11500,7 +11529,9 @@ function buildReport({
|
|
|
11500
11529
|
const addedSets = survivingSets.filter(
|
|
11501
11530
|
(s) => !find2(before, s.key, s.bindingType)
|
|
11502
11531
|
);
|
|
11503
|
-
const claimedFrom = (v) => survivingMoves.some(
|
|
11532
|
+
const claimedFrom = (v) => survivingMoves.some(
|
|
11533
|
+
(m) => sameTarget(v, m.from) && (m.read === void 0 || m.read === v.value)
|
|
11534
|
+
);
|
|
11504
11535
|
const claimedTo = (v) => survivingMoves.some((m) => sameTarget(v, m.to)) || addedSets.some((s) => sameTarget(v, s));
|
|
11505
11536
|
const moved = survivingMoves.map((m) => {
|
|
11506
11537
|
const from = fieldOf(fromTemplate, m.from.key, m.from.bindingType);
|
|
@@ -11527,15 +11558,31 @@ function buildReport({
|
|
|
11527
11558
|
const lostBySource = (v) => facts.moved.some(
|
|
11528
11559
|
(m) => !survivingMoves.includes(m) && sameTarget(v, m.from) && find2(after, m.to.key, m.to.bindingType) === void 0
|
|
11529
11560
|
);
|
|
11530
|
-
const
|
|
11531
|
-
|
|
11532
|
-
|
|
11561
|
+
const written = [
|
|
11562
|
+
...facts.written ?? [],
|
|
11563
|
+
...facts.moved.map((m) => m.to),
|
|
11564
|
+
...facts.set
|
|
11565
|
+
];
|
|
11566
|
+
const causeOf = (v) => {
|
|
11567
|
+
const actual = find2(after, v.key, v.bindingType);
|
|
11568
|
+
if (!actual || actual.value === v.value || claimedFrom(v)) return;
|
|
11569
|
+
if (written.some((w) => sameTarget(v, w))) return "displaced";
|
|
11570
|
+
const reset = hiddenIn(toTemplate, v, "some") || (facts.reset ?? []).some((r) => sameTarget(v, r) && r.from === v.value);
|
|
11571
|
+
if (reset && !hiddenIn(fromTemplate, v, "every")) return "hidden";
|
|
11572
|
+
};
|
|
11573
|
+
const dropped = before.filter((v) => v.value !== "").flatMap((v) => {
|
|
11574
|
+
const cause = causeOf(v);
|
|
11575
|
+
if (!cause && (claimedFrom(v) || find2(after, v.key, v.bindingType)) && !lostBySource(v))
|
|
11576
|
+
return [];
|
|
11533
11577
|
const field = fieldOf(fromTemplate, v.key, v.bindingType);
|
|
11534
|
-
return
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11578
|
+
return [
|
|
11579
|
+
{
|
|
11580
|
+
...field,
|
|
11581
|
+
value: v.value,
|
|
11582
|
+
...withNames(fromTemplate, field, v.value),
|
|
11583
|
+
...cause ? { cause } : {}
|
|
11584
|
+
}
|
|
11585
|
+
];
|
|
11539
11586
|
});
|
|
11540
11587
|
const added = after.filter(
|
|
11541
11588
|
(v) => v.value !== "" && !find2(before, v.key, v.bindingType) && !isHidden(toTemplate, v.key, v.bindingType) && !claimedTo(v)
|
|
@@ -11584,7 +11631,7 @@ function buildReport({
|
|
|
11584
11631
|
template: facts.templateSkipped,
|
|
11585
11632
|
noMatch: facts.noMatch,
|
|
11586
11633
|
feel: facts.feelSkipped,
|
|
11587
|
-
unchecked: uncheckedFields(fromTemplate,
|
|
11634
|
+
unchecked: uncheckedFields(fromTemplate, via)
|
|
11588
11635
|
};
|
|
11589
11636
|
return {
|
|
11590
11637
|
from: templateRef(fromTemplate),
|
|
@@ -11603,10 +11650,12 @@ function buildReport({
|
|
|
11603
11650
|
).length && survivingSets.length === facts.set.length && dropped.length === 0 && skipped.guard.length === 0 && skipped.template.length === 0 && skipped.noMatch.length === 0 && skipped.unchecked.length === 0
|
|
11604
11651
|
};
|
|
11605
11652
|
}
|
|
11606
|
-
function uncheckedFields(fromTemplate,
|
|
11653
|
+
function uncheckedFields(fromTemplate, via) {
|
|
11607
11654
|
return fromTemplate.properties.filter(
|
|
11608
|
-
(p) => p.binding && p.type !== "Hidden" && bindingTargetKey(p.binding) === void 0 &&
|
|
11609
|
-
(
|
|
11655
|
+
(p) => p.binding && p.type !== "Hidden" && bindingTargetKey(p.binding) === void 0 && via.some(
|
|
11656
|
+
(template) => !template.properties.some(
|
|
11657
|
+
(t) => t.type !== "Hidden" && sameBinding(t.binding, p.binding)
|
|
11658
|
+
)
|
|
11610
11659
|
)
|
|
11611
11660
|
).map((p) => {
|
|
11612
11661
|
const binding = { ...p.binding };
|
|
@@ -11998,10 +12047,10 @@ function readPaths(entry) {
|
|
|
11998
12047
|
}
|
|
11999
12048
|
return paths;
|
|
12000
12049
|
}
|
|
12001
|
-
function findCoverageGap(steps, appliedId, appliedVersion, templates, hop) {
|
|
12002
|
-
let shape = templates.find(
|
|
12050
|
+
function findCoverageGap(steps, appliedId, appliedVersion, appliedShapeKnown, templates, hop) {
|
|
12051
|
+
let shape = appliedShapeKnown ? templates.find(
|
|
12003
12052
|
(t) => t.id === appliedId && (versionOf(t) ?? 0) === appliedVersion
|
|
12004
|
-
);
|
|
12053
|
+
) : void 0;
|
|
12005
12054
|
for (const step of steps) {
|
|
12006
12055
|
for (const entry of step.entries) {
|
|
12007
12056
|
for (const path of readPaths(entry)) {
|
|
@@ -12043,6 +12092,7 @@ function reachableHop(recipe, sourceId, drainedVersion) {
|
|
|
12043
12092
|
function resolveSteps({
|
|
12044
12093
|
appliedId,
|
|
12045
12094
|
appliedVersion,
|
|
12095
|
+
appliedShapeKnown = true,
|
|
12046
12096
|
target,
|
|
12047
12097
|
templates,
|
|
12048
12098
|
recipe
|
|
@@ -12070,6 +12120,7 @@ function resolveSteps({
|
|
|
12070
12120
|
rungs,
|
|
12071
12121
|
appliedId,
|
|
12072
12122
|
appliedVersion,
|
|
12123
|
+
appliedShapeKnown,
|
|
12073
12124
|
templates,
|
|
12074
12125
|
hop && { targetId: target.id, entries: hop.entries }
|
|
12075
12126
|
);
|
|
@@ -12237,7 +12288,7 @@ function resolveMapWrites(maps, before, fromTemplate, target) {
|
|
|
12237
12288
|
function valuesOf(element) {
|
|
12238
12289
|
return enumerateElementValues(getExtensionElements(element.businessObject));
|
|
12239
12290
|
}
|
|
12240
|
-
function applyApplication(modeler, catalog, element, application, mapWrites = []) {
|
|
12291
|
+
function applyApplication(modeler, catalog, element, application, mapWrites = [], unverifiedReads = false) {
|
|
12241
12292
|
const { template, step } = application;
|
|
12242
12293
|
const applied = readAppliedTemplate(element.businessObject);
|
|
12243
12294
|
if (applied?.id === template.id && applied.version === (template.version ?? 0)) {
|
|
@@ -12249,7 +12300,7 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12249
12300
|
writes: recipeWrites,
|
|
12250
12301
|
facts,
|
|
12251
12302
|
activeProperties
|
|
12252
|
-
} = buildStepPlan(step?.entries ?? [], values, clone);
|
|
12303
|
+
} = buildStepPlan(step?.entries ?? [], values, clone, unverifiedReads);
|
|
12253
12304
|
assertNoAmbiguousWrites([...recipeWrites, ...mapWrites]);
|
|
12254
12305
|
const stepWrites = [...recipeWrites, ...mapWrites];
|
|
12255
12306
|
const writes = [
|
|
@@ -12295,6 +12346,12 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12295
12346
|
}
|
|
12296
12347
|
}
|
|
12297
12348
|
current = modeler.elementTemplates.applyTemplate(current, clone) ?? current;
|
|
12349
|
+
const after = valuesOf(current);
|
|
12350
|
+
const reset = values.filter(
|
|
12351
|
+
(v) => v.value !== "" && !stepWrites.some((w) => sameTarget(v, w)) && findPropertiesByTarget(clone.properties, v.key, v.bindingType).some(
|
|
12352
|
+
(property) => property.type === "Hidden"
|
|
12353
|
+
) && !after.some((a) => sameTarget(a, v) && a.value === v.value)
|
|
12354
|
+
).map(({ key, bindingType, value }) => ({ key, bindingType, from: value }));
|
|
12298
12355
|
const resolvedValue = (key, bindingType) => {
|
|
12299
12356
|
const write = writes.find(
|
|
12300
12357
|
(w) => w.key === key && w.bindingType === bindingType
|
|
@@ -12310,7 +12367,8 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12310
12367
|
element: current,
|
|
12311
12368
|
facts: {
|
|
12312
12369
|
...facts,
|
|
12313
|
-
after
|
|
12370
|
+
after,
|
|
12371
|
+
reset,
|
|
12314
12372
|
moved: facts.moved.map((move) => ({
|
|
12315
12373
|
...move,
|
|
12316
12374
|
value: resolvedValue(move.to.key, move.to.bindingType)
|
|
@@ -12329,6 +12387,7 @@ function migrateElement({
|
|
|
12329
12387
|
modeler,
|
|
12330
12388
|
element,
|
|
12331
12389
|
fromTemplate,
|
|
12390
|
+
sourceKnown = true,
|
|
12332
12391
|
target,
|
|
12333
12392
|
templates,
|
|
12334
12393
|
recipe,
|
|
@@ -12344,6 +12403,7 @@ function migrateElement({
|
|
|
12344
12403
|
const { steps, refusal } = resolveSteps({
|
|
12345
12404
|
appliedId: fromTemplate.id,
|
|
12346
12405
|
appliedVersion: fromTemplate.version ?? 0,
|
|
12406
|
+
appliedShapeKnown: sourceKnown,
|
|
12347
12407
|
target,
|
|
12348
12408
|
templates,
|
|
12349
12409
|
recipe
|
|
@@ -12376,7 +12436,8 @@ function migrateElement({
|
|
|
12376
12436
|
catalog,
|
|
12377
12437
|
current,
|
|
12378
12438
|
application,
|
|
12379
|
-
isFinal ? mapPlan.writes : []
|
|
12439
|
+
isFinal ? mapPlan.writes : [],
|
|
12440
|
+
index === 0 && !sourceKnown
|
|
12380
12441
|
);
|
|
12381
12442
|
if (result) {
|
|
12382
12443
|
current = result.element;
|
|
@@ -12408,6 +12469,7 @@ function migrateElement({
|
|
|
12408
12469
|
const report = buildReport({
|
|
12409
12470
|
fromTemplate: reportSource,
|
|
12410
12471
|
toTemplate: target,
|
|
12472
|
+
via: applications.map((a) => a.template),
|
|
12411
12473
|
before,
|
|
12412
12474
|
after: allFacts.at(-1)?.after ?? before,
|
|
12413
12475
|
facts,
|
|
@@ -12879,7 +12941,7 @@ function rowsOf(report, targetTemplate, s) {
|
|
|
12879
12941
|
marker: "-",
|
|
12880
12942
|
label: `${group ? `${group} \u203A ` : ""}${fieldLabel(d)}`,
|
|
12881
12943
|
value: [[shown(d.value, d.valueName, false), s.red]],
|
|
12882
|
-
source: ""
|
|
12944
|
+
source: d.cause === "hidden" ? "replaced by fixed template value" : d.cause === "displaced" ? "overwritten" : ""
|
|
12883
12945
|
};
|
|
12884
12946
|
});
|
|
12885
12947
|
return { rows, dropped };
|
|
@@ -13238,22 +13300,33 @@ function createModeler() {
|
|
|
13238
13300
|
moddleExtensions: { zeebe: vendor.ZeebeModdleExtension }
|
|
13239
13301
|
});
|
|
13240
13302
|
}
|
|
13241
|
-
function templatePool(
|
|
13303
|
+
function templatePool(searchDir) {
|
|
13242
13304
|
const local = /* @__PURE__ */ new Map();
|
|
13243
13305
|
const localOf = (id) => {
|
|
13244
13306
|
const templates = local.get(id) ?? findLocalTemplates(searchDir, id);
|
|
13245
13307
|
local.set(id, templates);
|
|
13246
13308
|
return templates;
|
|
13247
13309
|
};
|
|
13310
|
+
const withoutCache = /* @__PURE__ */ new Set();
|
|
13311
|
+
let cached;
|
|
13312
|
+
const cache = () => {
|
|
13313
|
+
cached ??= loadCache() ?? [];
|
|
13314
|
+
return cached;
|
|
13315
|
+
};
|
|
13248
13316
|
const identity2 = (t) => JSON.stringify([t.id, t.version ?? 0]);
|
|
13249
13317
|
return {
|
|
13250
13318
|
localOf,
|
|
13319
|
+
cache,
|
|
13320
|
+
resolvedWithoutCache: (id) => withoutCache.add(id),
|
|
13251
13321
|
pool(ids) {
|
|
13252
|
-
const
|
|
13322
|
+
const known = [...new Set(ids)].filter((id) => id !== void 0);
|
|
13323
|
+
const shadowing = known.flatMap(localOf);
|
|
13324
|
+
const isLocal = (id) => withoutCache.has(id) || localOf(id).length > 0;
|
|
13325
|
+
if (cached === void 0 && known.every(isLocal)) return shadowing;
|
|
13253
13326
|
const shadowed = new Set(shadowing.map(identity2));
|
|
13254
13327
|
return [
|
|
13255
13328
|
...shadowing,
|
|
13256
|
-
...
|
|
13329
|
+
...cache().filter((t) => !shadowed.has(identity2(t)))
|
|
13257
13330
|
];
|
|
13258
13331
|
}
|
|
13259
13332
|
};
|
|
@@ -13262,27 +13335,28 @@ async function resolveTarget({
|
|
|
13262
13335
|
templateId,
|
|
13263
13336
|
to,
|
|
13264
13337
|
executionPlatformVersion,
|
|
13265
|
-
cachedTemplates,
|
|
13266
13338
|
templatePool: templatePool2
|
|
13267
13339
|
}) {
|
|
13268
13340
|
const arg = to ?? templateId;
|
|
13269
13341
|
const ref = parseTemplateRef(arg);
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
)
|
|
13275
|
-
);
|
|
13276
|
-
}
|
|
13342
|
+
const checkConflicts = (id) => resolveCatalog(
|
|
13343
|
+
migrationTemplates(templatePool2.pool([id]).filter((t) => t.id === id))
|
|
13344
|
+
);
|
|
13345
|
+
if (ref?.kind === "id") checkConflicts(ref.id);
|
|
13277
13346
|
const target = ref?.kind === "id" ? await resolveTemplateId(ref, {
|
|
13278
13347
|
localTemplates: templatePool2.localOf(ref.id),
|
|
13279
13348
|
executionPlatformVersion,
|
|
13280
13349
|
requireEngineCompatibility: true,
|
|
13281
|
-
|
|
13350
|
+
loadTemplates: () => {
|
|
13351
|
+
const cached = templatePool2.cache();
|
|
13352
|
+
checkConflicts(ref.id);
|
|
13353
|
+
return cached;
|
|
13354
|
+
}
|
|
13282
13355
|
}) : await readTemplateFromPathOrUrl(arg);
|
|
13283
13356
|
if (!isMigrationTemplate(target)) {
|
|
13284
13357
|
throw new Error("The target template has no id.");
|
|
13285
13358
|
}
|
|
13359
|
+
if (ref?.kind !== "id") templatePool2.resolvedWithoutCache(target.id);
|
|
13286
13360
|
return target;
|
|
13287
13361
|
}
|
|
13288
13362
|
var selected = (element, id) => ({
|
|
@@ -13383,13 +13457,23 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13383
13457
|
const selected2 = selectElements(modeler, templateId, elementId);
|
|
13384
13458
|
const valuesOf2 = (element) => enumerateElementValues(getExtensionElements(element.businessObject));
|
|
13385
13459
|
redaction.values = selected2.flatMap(({ element }) => valuesOf2(element));
|
|
13386
|
-
const cachedTemplates = loadCache() ?? [];
|
|
13387
13460
|
const pool2 = templatePool(
|
|
13388
|
-
cachedTemplates,
|
|
13389
13461
|
bpmnFilePath ? dirname6(input.source) : process.cwd()
|
|
13390
13462
|
);
|
|
13463
|
+
const localVersions = pool2.localOf(templateId).map((t) => t.version ?? 0);
|
|
13464
|
+
if (selected2.some(
|
|
13465
|
+
({ element }) => !localVersions.includes(
|
|
13466
|
+
readAppliedTemplate(element.businessObject)?.version ?? 0
|
|
13467
|
+
)
|
|
13468
|
+
)) {
|
|
13469
|
+
pool2.cache();
|
|
13470
|
+
}
|
|
13391
13471
|
const lineages = (ids) => migrationTemplates(pool2.pool(ids)).filter((t) => ids.includes(t.id));
|
|
13392
|
-
redaction.templates = lineages([templateId
|
|
13472
|
+
redaction.templates = lineages([templateId]);
|
|
13473
|
+
const toRef = parseTemplateRef(parsed.to);
|
|
13474
|
+
if (toRef?.kind === "id") {
|
|
13475
|
+
redaction.templates = lineages([templateId, toRef.id]);
|
|
13476
|
+
}
|
|
13393
13477
|
const recipe = parsed.recipePath ? loadRecipeFile(parsed.recipePath) : void 0;
|
|
13394
13478
|
if (recipe && !recipe.sources.some((s) => s.sourceTemplateId === templateId)) {
|
|
13395
13479
|
throw new Error(
|
|
@@ -13400,9 +13484,60 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13400
13484
|
templateId,
|
|
13401
13485
|
to: parsed.to,
|
|
13402
13486
|
executionPlatformVersion: engineVersion,
|
|
13403
|
-
cachedTemplates,
|
|
13404
13487
|
templatePool: pool2
|
|
13405
13488
|
});
|
|
13489
|
+
redaction.templates = [...lineages([templateId, target.id]), target];
|
|
13490
|
+
const targetRecipe = recipe ?? embeddedRecipe(target);
|
|
13491
|
+
const floors = (targetRecipe?.sources ?? []).flatMap(
|
|
13492
|
+
(s) => s.kind === "change" && s.sourceTemplateId === templateId ? [s.minSourceVersion ?? 0] : []
|
|
13493
|
+
);
|
|
13494
|
+
const localLatest = latestOf(
|
|
13495
|
+
compatibleTemplates(pool2.localOf(templateId), engineVersion),
|
|
13496
|
+
templateId
|
|
13497
|
+
);
|
|
13498
|
+
let localRecipe;
|
|
13499
|
+
try {
|
|
13500
|
+
localRecipe = localLatest && readEmbeddedRecipe(localLatest);
|
|
13501
|
+
} catch {
|
|
13502
|
+
}
|
|
13503
|
+
const reachedLocally = (appliedVersion) => Math.max(
|
|
13504
|
+
appliedVersion,
|
|
13505
|
+
...(localRecipe?.sources ?? []).flatMap(
|
|
13506
|
+
(s) => s.kind === "upgrade" && s.sourceTemplateId === templateId && s.toVersion > appliedVersion && s.toVersion <= (localLatest?.version ?? 0) ? [s.toVersion] : []
|
|
13507
|
+
)
|
|
13508
|
+
);
|
|
13509
|
+
if (floors.length > 0 && selected2.some(({ element }) => {
|
|
13510
|
+
const reached = reachedLocally(
|
|
13511
|
+
readAppliedTemplate(element.businessObject)?.version ?? 0
|
|
13512
|
+
);
|
|
13513
|
+
return floors.every((floor) => floor > reached);
|
|
13514
|
+
})) {
|
|
13515
|
+
pool2.cache();
|
|
13516
|
+
}
|
|
13517
|
+
const sourceLatest = target.id === templateId ? void 0 : latestOf(
|
|
13518
|
+
compatibleTemplates(pool2.pool([templateId]), engineVersion).filter(
|
|
13519
|
+
(t) => t.id === templateId
|
|
13520
|
+
),
|
|
13521
|
+
templateId
|
|
13522
|
+
);
|
|
13523
|
+
let sourceRecipe;
|
|
13524
|
+
try {
|
|
13525
|
+
sourceRecipe = sourceLatest && readEmbeddedRecipe(sourceLatest);
|
|
13526
|
+
} catch {
|
|
13527
|
+
}
|
|
13528
|
+
const stepVersions = [targetRecipe, sourceRecipe].flatMap((r) => r?.sources ?? []).flatMap(
|
|
13529
|
+
(s) => s.kind === "upgrade" && s.sourceTemplateId === templateId ? [s.toVersion] : []
|
|
13530
|
+
);
|
|
13531
|
+
const lowestApplied = Math.min(
|
|
13532
|
+
...selected2.map(
|
|
13533
|
+
({ element }) => readAppliedTemplate(element.businessObject)?.version ?? 0
|
|
13534
|
+
)
|
|
13535
|
+
);
|
|
13536
|
+
if (stepVersions.some(
|
|
13537
|
+
(v) => v > lowestApplied && !localVersions.includes(v) && !(target.id === templateId && (target.version ?? 0) === v)
|
|
13538
|
+
)) {
|
|
13539
|
+
pool2.cache();
|
|
13540
|
+
}
|
|
13406
13541
|
const cache = compatibleTemplates(
|
|
13407
13542
|
pool2.pool([templateId, target.id]),
|
|
13408
13543
|
engineVersion
|
|
@@ -13412,25 +13547,28 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13412
13547
|
[target]
|
|
13413
13548
|
);
|
|
13414
13549
|
redaction.templates = [...lineages([templateId, target.id]), target];
|
|
13415
|
-
if (
|
|
13416
|
-
const targetRecipe = recipe ?? embeddedRecipe(target);
|
|
13550
|
+
if (targetRecipe) validateRecipeOwner(targetRecipe, target);
|
|
13417
13551
|
const fromTemplateOf = (applied) => {
|
|
13418
13552
|
const isApplied = (t) => t.id === applied.id && (t.version ?? 0) === applied.version;
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13553
|
+
const source = templates.find(isApplied) ?? lineages([applied.id]).find(isApplied);
|
|
13554
|
+
return {
|
|
13555
|
+
source,
|
|
13556
|
+
fromTemplate: source ?? {
|
|
13557
|
+
id: applied.id,
|
|
13558
|
+
version: applied.version,
|
|
13559
|
+
properties: []
|
|
13560
|
+
}
|
|
13423
13561
|
};
|
|
13424
13562
|
};
|
|
13425
13563
|
for (const { element } of selected2) {
|
|
13426
13564
|
const applied = readAppliedTemplate(element.businessObject);
|
|
13427
13565
|
if (!applied || applied.id === target.id) continue;
|
|
13428
13566
|
const catalog = resolveCatalog(templates, [
|
|
13429
|
-
fromTemplateOf(applied),
|
|
13567
|
+
fromTemplateOf(applied).fromTemplate,
|
|
13430
13568
|
target
|
|
13431
13569
|
]);
|
|
13432
|
-
const
|
|
13433
|
-
if (
|
|
13570
|
+
const sourceLatest2 = latestOf(catalog, applied.id);
|
|
13571
|
+
if (sourceLatest2) embeddedRecipe(sourceLatest2);
|
|
13434
13572
|
}
|
|
13435
13573
|
if (!isEngineCompatible(target, engineVersion)) {
|
|
13436
13574
|
throw new Error(
|
|
@@ -13475,12 +13613,13 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13475
13613
|
});
|
|
13476
13614
|
continue;
|
|
13477
13615
|
}
|
|
13478
|
-
const fromTemplate = fromTemplateOf(applied);
|
|
13616
|
+
const { source, fromTemplate } = fromTemplateOf(applied);
|
|
13479
13617
|
try {
|
|
13480
13618
|
const result = migrateElement({
|
|
13481
13619
|
modeler: migrationModeler,
|
|
13482
13620
|
element,
|
|
13483
13621
|
fromTemplate,
|
|
13622
|
+
sourceKnown: source !== void 0,
|
|
13484
13623
|
target,
|
|
13485
13624
|
templates,
|
|
13486
13625
|
recipe,
|
|
@@ -228,7 +228,17 @@ that moved.
|
|
|
228
228
|
templates first (see above), with `isEngineCompatible` as the eligibility
|
|
229
229
|
rule; the cache is required only on the fallback. Steps, the applied source
|
|
230
230
|
and redaction read template versions from the cache, with the local versions
|
|
231
|
-
of the involved ids shadowing cached ones of the same id and version.
|
|
231
|
+
of the involved ids shadowing cached ones of the same id and version. The
|
|
232
|
+
cache is read only on a local gap: the target falls back to it, an involved
|
|
233
|
+
id has neither a local template nor a `--to` file or URL, or an applied
|
|
234
|
+
version or a recipe step version has no local template. A fully local
|
|
235
|
+
update never reads the cache, so a corrupt cache does not stop it.
|
|
236
|
+
- **Unavailable source.** When the applied version is found nowhere, the
|
|
237
|
+
engine gets a stub with the applied id and version and no properties. Recipe
|
|
238
|
+
reads against the stub are not checked for coverage. Values it cannot read,
|
|
239
|
+
such as `zeebe:calledElement`, are taken from the element and count as
|
|
240
|
+
unchecked unless the target binds them identically, so a write still needs
|
|
241
|
+
`--allow-lossy`.
|
|
232
242
|
- **Recipe location.** A recipe is carried by the template it migrates *to*, in
|
|
233
243
|
`metadata.migratesFrom`, so it travels with the template through the
|
|
234
244
|
marketplace and the cache. `metadata` is the schema's free-form area; it
|
|
@@ -276,6 +286,16 @@ that moved.
|
|
|
276
286
|
the engine cannot read are not diffed; an editable source field under one is
|
|
277
287
|
reported as unchecked, and the report is lossy, unless the target binds it
|
|
278
288
|
identically and not as Hidden, which is the case where the Modeler keeps it.
|
|
289
|
+
A field that survives can still lose its value: a Hidden target property
|
|
290
|
+
resetting an editable source value, or a move or set overwriting a different
|
|
291
|
+
populated value, is reported as dropped with a `cause`, and the report is lossy.
|
|
292
|
+
A destination that is itself moved away (a swap or chain) is not displaced.
|
|
293
|
+
A field written in any recipe step counts, also when a later step moves the
|
|
294
|
+
value on. Conditions are not evaluated here: a target counts as Hidden when any
|
|
295
|
+
duplicate for the binding is Hidden, a source only when every duplicate is.
|
|
296
|
+
Each step records the values its Hidden properties reset, so a reset in an
|
|
297
|
+
intermediate version counts, even when the final template binds the field as
|
|
298
|
+
editable again or a later step moves the reset value on.
|
|
279
299
|
- **Read/write identity.** Unqualified rename, guard and interpolation reads fail
|
|
280
300
|
when several binding types match. Qualification selects a binding type; duplicate
|
|
281
301
|
backing identities or extension containers are rejected rather than selecting an
|