@camunda8/cli 4.6.0-alpha.4 → 4.6.0-alpha.6
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.
|
@@ -49,6 +49,9 @@ version resolution.
|
|
|
49
49
|
use a sibling temp file + `renameSync`. Anything else that
|
|
50
50
|
overwrites a user-owned file (cache or BPMN) must follow the same
|
|
51
51
|
pattern — a kill mid-write must not leave a truncated file.
|
|
52
|
+
`atomicOverwriteFile` resolves the target with `realpathSync` first,
|
|
53
|
+
so a symlinked BPMN keeps its link; locks on a BPMN path must use the
|
|
54
|
+
resolved path too.
|
|
52
55
|
- **`syncTemplates` is serialised by an advisory lockfile.** The
|
|
53
56
|
helper `withSyncLock` in `cache.ts` holds
|
|
54
57
|
`<cacheDir>/.sync.lock` while the body runs, with stale-lock
|
|
@@ -170,7 +170,8 @@ c8ctl element-template update old.id process.bpmn --dry-run --json
|
|
|
170
170
|
- Without `--in-place` the BPMN goes to stdout and the report to stderr.
|
|
171
171
|
- Lossy in-place writes and refused embedded-recipe fallbacks require `--allow-lossy`.
|
|
172
172
|
Preview with `--dry-run` first. Unusable explicit `--recipe` files always fail,
|
|
173
|
-
even with authorization; correct the source entry
|
|
173
|
+
even with authorization; correct the source entry. A floor that no compatible
|
|
174
|
+
source version reaches also fails, and `--allow-lossy` does not override it.
|
|
174
175
|
- In-place migrations take a sibling `.migration.lock` and check original input
|
|
175
176
|
contents before temporary-file preparation and again immediately before rename.
|
|
176
177
|
Changes observed during preparation are rejected. Replacement uses a sibling
|
|
@@ -179,10 +180,14 @@ c8ctl element-template update old.id process.bpmn --dry-run --json
|
|
|
179
180
|
`apply --in-place` and `edit --in-place` do not take the lock, but refuse to
|
|
180
181
|
replace a file whose contents changed since they read it, so they never
|
|
181
182
|
overwrite a migration that committed in between.
|
|
183
|
+
In-place writes follow symlinks: the link stays and its target receives the new
|
|
184
|
+
XML. The lock and temporary file sit beside the real file, so links to one file
|
|
185
|
+
share a lock. Relative local template lookup starts at the directory of the
|
|
186
|
+
path you pass, not of the link's target. Hard links are not preserved; the file gets a new inode.
|
|
182
187
|
A killed writer can leave a stale lock and temporary file; confirm no writer is
|
|
183
188
|
active before inspecting and removing them. Recovery is manual. External edits
|
|
184
|
-
between the final comparison and rename
|
|
185
|
-
|
|
189
|
+
between the final comparison and rename are not covered by the cooperative
|
|
190
|
+
lock; this design has no atomic compare-and-swap. Tests cover
|
|
186
191
|
injected ENOSPC/EIO before and after actual partial bytes and real SIGINT/SIGTERM
|
|
187
192
|
termination during paused split writes, preserving original bytes. Physical
|
|
188
193
|
disk exhaustion and interruption of an executing kernel syscall are not proven.
|
|
@@ -220,7 +225,8 @@ values are carried over by binding identity and the rest is dropped; the report
|
|
|
220
225
|
lists each drop with its old value, subject to sensitivity redaction. Unusable
|
|
221
226
|
explicit recipes fail even with `--allow-lossy`; refused embedded recipes require
|
|
222
227
|
authorization except when previewing. Diagnostics distinguish malformed recipes,
|
|
223
|
-
coverage refusal
|
|
228
|
+
coverage refusal and wrong source IDs. A source-version floor that cannot be reached
|
|
229
|
+
fails the element instead (see below). Coverage
|
|
224
230
|
covers every step, including the change to another template: an entry that reads
|
|
225
231
|
a path the reached source version does not define refuses the recipe. Guard
|
|
226
232
|
paths count as reads, including `exists` and negated guards. An empty
|
|
@@ -278,9 +284,16 @@ values, including FEEL normalization, rather than claiming planner intent as suc
|
|
|
278
284
|
|
|
279
285
|
A source with `kind: "upgrade"` requires `toVersion` and the recipe owner's ID: an element climbs
|
|
280
286
|
each destination above its applied version in ascending order. A `kind: "change"` source must name
|
|
281
|
-
a different ID and may require `minSourceVersion`, a floor on the version
|
|
282
|
-
|
|
283
|
-
|
|
287
|
+
a different ID and may require `minSourceVersion`, a floor on the source version. When the element
|
|
288
|
+
is below the best floor, the plan adds one implicit version step, with no recipe
|
|
289
|
+
entries; values are carried by binding. The step lands on the lowest compatible version at or above the best floor. The best floor is the highest one at most the newest source
|
|
290
|
+
version compatible with the BPMN's `modeler:executionPlatformVersion`; the plan never goes above
|
|
291
|
+
it. An omitted floor is the fallback entry: it never causes a bump itself and applies only when no declared floor is reachable. When a declared floor is reachable, an element below it is bumped to that floor and the fallback entry is not used. The element fails (no file is
|
|
292
|
+
written, and `--allow-lossy` does not override it) when the newest compatible version is below
|
|
293
|
+
the lowest floor. The report marks
|
|
294
|
+
the step: `The element is on vA, which is too old for this recipe. Updating it to vN first.` (vN is the version landed on) in text and `implicit: true` on the
|
|
295
|
+
step in `report.steps` of `--json`. File recipes replace only the target recipe and follow the
|
|
296
|
+
same rules.
|
|
284
297
|
This revised dialect keeps `schemaVersion: 1` but rejects legacy `minVersion` recipes and requires
|
|
285
298
|
`kind` on every source. Older strict readers reject the new fields. See
|
|
286
299
|
[`migration/migrates-from.schema.json`](./migration/migrates-from.schema.json) for the full format.
|
|
@@ -8345,6 +8345,7 @@ var import_semver = __toESM(require_semver2(), 1);
|
|
|
8345
8345
|
import {
|
|
8346
8346
|
existsSync,
|
|
8347
8347
|
readFileSync,
|
|
8348
|
+
realpathSync,
|
|
8348
8349
|
renameSync,
|
|
8349
8350
|
unlinkSync,
|
|
8350
8351
|
writeFileSync
|
|
@@ -8877,7 +8878,7 @@ function isRecord(value) {
|
|
|
8877
8878
|
}
|
|
8878
8879
|
var CONCURRENT_EDIT_MESSAGE = "BPMN changed while this command ran; refusing to overwrite concurrent edits.";
|
|
8879
8880
|
function atomicOverwriteFile(targetPath, contents, expectedContents, directWriteFallback = false) {
|
|
8880
|
-
const target =
|
|
8881
|
+
const target = realpathSync(targetPath);
|
|
8881
8882
|
const tmp = `${target}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
8882
8883
|
try {
|
|
8883
8884
|
writeFileSync(tmp, contents, "utf-8");
|
|
@@ -8898,6 +8899,9 @@ function atomicOverwriteFile(targetPath, contents, expectedContents, directWrite
|
|
|
8898
8899
|
throw error3;
|
|
8899
8900
|
}
|
|
8900
8901
|
}
|
|
8902
|
+
function pinFilePath(path) {
|
|
8903
|
+
return existsSync(path) ? realpathSync(path) : path;
|
|
8904
|
+
}
|
|
8901
8905
|
var ENGINE_VERSION_PATTERN = /^\d+\.\d+(?:\.\d+)?(?:-[0-9A-Za-z.-]+)?$/;
|
|
8902
8906
|
function isUrl(input) {
|
|
8903
8907
|
return input.startsWith("https://") || input.startsWith("http://");
|
|
@@ -10031,13 +10035,26 @@ function validateLocalTemplates(id, entries) {
|
|
|
10031
10035
|
const logger = c8ctl2.getLogger();
|
|
10032
10036
|
modeler.get("eventBus").on("elementTemplates.errors", (event) => {
|
|
10033
10037
|
const errors = isRecord(event) && Array.isArray(event.errors) ? event.errors : [];
|
|
10038
|
+
const duplicates = [];
|
|
10034
10039
|
for (const error3 of errors) {
|
|
10035
10040
|
const file = isRecord(error3) ? fileOf.get(error3.template) : void 0;
|
|
10036
10041
|
const message = error3 instanceof Error ? error3.message : String(error3);
|
|
10042
|
+
if (message.includes("already used")) {
|
|
10043
|
+
duplicates.push(isRecord(error3) ? error3.template : void 0);
|
|
10044
|
+
continue;
|
|
10045
|
+
}
|
|
10037
10046
|
logger.warn(
|
|
10038
10047
|
`Ignoring element template${file ? ` in ${file}` : ""}: ${message}`
|
|
10039
10048
|
);
|
|
10040
10049
|
}
|
|
10050
|
+
if (duplicates.length > 0) {
|
|
10051
|
+
const versions = duplicates.flatMap(
|
|
10052
|
+
(t) => isRecord(t) && t.version !== void 0 ? [String(t.version)] : []
|
|
10053
|
+
);
|
|
10054
|
+
logger.warn(
|
|
10055
|
+
`Ignoring ${duplicates.length} element template(s) for ${id} whose id and version are already used (${versions.join(", ")}); the nearest one wins.`
|
|
10056
|
+
);
|
|
10057
|
+
}
|
|
10041
10058
|
});
|
|
10042
10059
|
modeler.get("elementTemplatesLoader").setTemplates(entries.map((e) => e.template));
|
|
10043
10060
|
return modeler.get("elementTemplates").getAll(id) ?? [];
|
|
@@ -10238,6 +10255,7 @@ async function applySubcommand(args) {
|
|
|
10238
10255
|
if (parsed.inPlace && !bpmnFilePath) {
|
|
10239
10256
|
throw new Error("--in-place cannot be used with stdin input");
|
|
10240
10257
|
}
|
|
10258
|
+
const writePath = parsed.inPlace && bpmnFilePath ? pinFilePath(bpmnFilePath) : void 0;
|
|
10241
10259
|
const input = await readBpmnInput(bpmnFilePath);
|
|
10242
10260
|
if (!input) {
|
|
10243
10261
|
throw new Error(
|
|
@@ -10322,8 +10340,8 @@ async function applySubcommand(args) {
|
|
|
10322
10340
|
if (setProperties.length > 0) {
|
|
10323
10341
|
warnUnmetConditions(logger, resultXml, setProperties);
|
|
10324
10342
|
}
|
|
10325
|
-
if (
|
|
10326
|
-
atomicOverwriteFile(
|
|
10343
|
+
if (writePath) {
|
|
10344
|
+
atomicOverwriteFile(writePath, resultXml, input.xml, true);
|
|
10327
10345
|
logger.info(`Updated ${bpmnFilePath}`);
|
|
10328
10346
|
return;
|
|
10329
10347
|
}
|
|
@@ -10488,6 +10506,7 @@ async function editSubcommand(args) {
|
|
|
10488
10506
|
if (parsed.inPlace && !bpmnFilePath) {
|
|
10489
10507
|
throw new Error("--in-place cannot be used with stdin input");
|
|
10490
10508
|
}
|
|
10509
|
+
const writePath = parsed.inPlace && bpmnFilePath ? pinFilePath(bpmnFilePath) : void 0;
|
|
10491
10510
|
const input = await readBpmnInput(bpmnFilePath);
|
|
10492
10511
|
if (!input) {
|
|
10493
10512
|
throw new Error(
|
|
@@ -10555,8 +10574,8 @@ async function editSubcommand(args) {
|
|
|
10555
10574
|
}
|
|
10556
10575
|
const result = await modeler.saveXML({ format: true });
|
|
10557
10576
|
const resultXml = result.xml;
|
|
10558
|
-
if (
|
|
10559
|
-
atomicOverwriteFile(
|
|
10577
|
+
if (writePath) {
|
|
10578
|
+
atomicOverwriteFile(writePath, resultXml, input.xml, true);
|
|
10560
10579
|
logger.info(`Updated ${bpmnFilePath}`);
|
|
10561
10580
|
return;
|
|
10562
10581
|
}
|
|
@@ -11227,6 +11246,7 @@ import {
|
|
|
11227
11246
|
existsSync as existsSync5,
|
|
11228
11247
|
openSync as openSync2,
|
|
11229
11248
|
readFileSync as readFileSync5,
|
|
11249
|
+
realpathSync as realpathSync2,
|
|
11230
11250
|
unlinkSync as unlinkSync3
|
|
11231
11251
|
} from "node:fs";
|
|
11232
11252
|
import { createRequire as createRequire4 } from "node:module";
|
|
@@ -11414,11 +11434,18 @@ function mergeFacts(all) {
|
|
|
11414
11434
|
const after = facts.after;
|
|
11415
11435
|
const surviving = (field, value) => {
|
|
11416
11436
|
const actual = find2(after, field.key, field.bindingType);
|
|
11417
|
-
|
|
11437
|
+
const replaced = (facts.reset ?? []).some(
|
|
11438
|
+
(r) => sameField(r, field) && r.from === value
|
|
11439
|
+
);
|
|
11440
|
+
return actual !== void 0 && (value === void 0 || actual.value === value || actual.value === `=${value}` && !replaced);
|
|
11418
11441
|
};
|
|
11442
|
+
const stored = (field, value) => value === void 0 ? value : find2(after, field.key, field.bindingType)?.value ?? value;
|
|
11419
11443
|
failedWrites ||= moved.some((move) => !surviving(move.to, move.value)) || set2.some((write) => !surviving(write, write.value));
|
|
11420
|
-
moved = moved.filter((move) => surviving(move.to, move.value));
|
|
11421
|
-
set2 = set2.filter((write) => surviving(write, write.value))
|
|
11444
|
+
moved = moved.filter((move) => surviving(move.to, move.value)).map((move) => ({ ...move, value: stored(move.to, move.value) }));
|
|
11445
|
+
set2 = set2.filter((write) => surviving(write, write.value)).map((write) => ({
|
|
11446
|
+
...write,
|
|
11447
|
+
value: stored(write, write.value) ?? write.value
|
|
11448
|
+
}));
|
|
11422
11449
|
snapshot = after;
|
|
11423
11450
|
}
|
|
11424
11451
|
failedWrites ||= Boolean(facts.failedWrites);
|
|
@@ -11516,7 +11543,10 @@ function buildReport({
|
|
|
11516
11543
|
after,
|
|
11517
11544
|
facts,
|
|
11518
11545
|
usedRecipe,
|
|
11519
|
-
refusal
|
|
11546
|
+
refusal,
|
|
11547
|
+
steps = [],
|
|
11548
|
+
lostInImplicitSteps = [],
|
|
11549
|
+
implicitTemplates = []
|
|
11520
11550
|
}) {
|
|
11521
11551
|
const survivingMoves = facts.moved.filter((m) => {
|
|
11522
11552
|
const source = find2(before, m.from.key, m.from.bindingType);
|
|
@@ -11529,6 +11559,7 @@ function buildReport({
|
|
|
11529
11559
|
const addedSets = survivingSets.filter(
|
|
11530
11560
|
(s) => !find2(before, s.key, s.bindingType)
|
|
11531
11561
|
);
|
|
11562
|
+
const claimedByMap = (v) => survivingMoves.some((m) => m.map && sameTarget(v, m.from));
|
|
11532
11563
|
const claimedFrom = (v) => survivingMoves.some(
|
|
11533
11564
|
(m) => sameTarget(v, m.from) && (m.read === void 0 || m.read === v.value)
|
|
11534
11565
|
);
|
|
@@ -11570,19 +11601,24 @@ function buildReport({
|
|
|
11570
11601
|
const reset = hiddenIn(toTemplate, v, "some") || (facts.reset ?? []).some((r) => sameTarget(v, r) && r.from === v.value);
|
|
11571
11602
|
if (reset && !hiddenIn(fromTemplate, v, "every")) return "hidden";
|
|
11572
11603
|
};
|
|
11573
|
-
const
|
|
11604
|
+
const droppedValues = before.filter(
|
|
11605
|
+
(v) => v.value !== "" && (causeOf(v) || !claimedFrom(v) && !find2(after, v.key, v.bindingType) || lostBySource(v))
|
|
11606
|
+
);
|
|
11607
|
+
const dropped = [
|
|
11608
|
+
...droppedValues,
|
|
11609
|
+
...lostInImplicitSteps.filter(
|
|
11610
|
+
(v) => !find2(droppedValues, v.key, v.bindingType) && // A surviving map that carries the original value on is not a loss.
|
|
11611
|
+
!(claimedByMap(v) && find2(before, v.key, v.bindingType)?.value === v.value)
|
|
11612
|
+
)
|
|
11613
|
+
].map((v) => {
|
|
11574
11614
|
const cause = causeOf(v);
|
|
11575
|
-
if (!cause && (claimedFrom(v) || find2(after, v.key, v.bindingType)) && !lostBySource(v))
|
|
11576
|
-
return [];
|
|
11577
11615
|
const field = fieldOf(fromTemplate, v.key, v.bindingType);
|
|
11578
|
-
return
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
}
|
|
11585
|
-
];
|
|
11616
|
+
return {
|
|
11617
|
+
...field,
|
|
11618
|
+
value: v.value,
|
|
11619
|
+
...withNames(fromTemplate, field, v.value),
|
|
11620
|
+
...cause ? { cause } : {}
|
|
11621
|
+
};
|
|
11586
11622
|
});
|
|
11587
11623
|
const added = after.filter(
|
|
11588
11624
|
(v) => v.value !== "" && !find2(before, v.key, v.bindingType) && !isHidden(toTemplate, v.key, v.bindingType) && !claimedTo(v)
|
|
@@ -11631,13 +11667,18 @@ function buildReport({
|
|
|
11631
11667
|
template: facts.templateSkipped,
|
|
11632
11668
|
noMatch: facts.noMatch,
|
|
11633
11669
|
feel: facts.feelSkipped,
|
|
11634
|
-
unchecked: uncheckedFields(fromTemplate,
|
|
11670
|
+
unchecked: [...via, ...implicitTemplates].flatMap((template) => uncheckedFields(fromTemplate, [template])).filter(
|
|
11671
|
+
(f, i, all) => all.findIndex(
|
|
11672
|
+
(g) => g.key === f.key && g.bindingType === f.bindingType
|
|
11673
|
+
) === i
|
|
11674
|
+
)
|
|
11635
11675
|
};
|
|
11636
11676
|
return {
|
|
11637
11677
|
from: templateRef(fromTemplate),
|
|
11638
11678
|
to: templateRef(toTemplate),
|
|
11639
11679
|
usedRecipe,
|
|
11640
11680
|
refusal,
|
|
11681
|
+
steps,
|
|
11641
11682
|
dropped: inTemplateOrder(fromTemplate, dropped, (item) => item),
|
|
11642
11683
|
added: inTemplateOrder(toTemplate, added, (item) => item),
|
|
11643
11684
|
changed: inTemplateOrder(toTemplate, changed, (item) => item),
|
|
@@ -12089,13 +12130,42 @@ function reachableHop(recipe, sourceId, drainedVersion) {
|
|
|
12089
12130
|
}
|
|
12090
12131
|
return best;
|
|
12091
12132
|
}
|
|
12133
|
+
function implicitFloor({
|
|
12134
|
+
recipe,
|
|
12135
|
+
sourceId,
|
|
12136
|
+
reachedVersion,
|
|
12137
|
+
newest,
|
|
12138
|
+
engineVersion
|
|
12139
|
+
}) {
|
|
12140
|
+
const changes = recipeSourcesFor(recipe, sourceId).filter(
|
|
12141
|
+
(s) => s.kind === "change"
|
|
12142
|
+
);
|
|
12143
|
+
const floors = changes.flatMap(
|
|
12144
|
+
(s) => s.kind === "change" && s.minSourceVersion !== void 0 ? [s.minSourceVersion] : []
|
|
12145
|
+
);
|
|
12146
|
+
const reachable = floors.filter((f) => newest !== void 0 && f <= newest);
|
|
12147
|
+
if (reachable.length === 0) {
|
|
12148
|
+
const hasFallback = changes.length > floors.length;
|
|
12149
|
+
if (floors.length > 0 && !hasFallback && reachedVersion < Math.min(...floors)) {
|
|
12150
|
+
const camunda = engineVersion ? `Camunda ${engineVersion} (from the BPMN executionPlatformVersion)` : "the BPMN Camunda version";
|
|
12151
|
+
throw new Error(
|
|
12152
|
+
`Template '${sourceId}' v${Math.min(...floors)} or later is required, but ${newest === void 0 ? `no version compatible with ${camunda} is available` : `the newest version compatible with ${camunda} is v${newest}`}.`
|
|
12153
|
+
);
|
|
12154
|
+
}
|
|
12155
|
+
return void 0;
|
|
12156
|
+
}
|
|
12157
|
+
const best = Math.max(...reachable);
|
|
12158
|
+
return best > reachedVersion ? best : void 0;
|
|
12159
|
+
}
|
|
12092
12160
|
function resolveSteps({
|
|
12093
12161
|
appliedId,
|
|
12094
12162
|
appliedVersion,
|
|
12095
12163
|
appliedShapeKnown = true,
|
|
12096
12164
|
target,
|
|
12097
12165
|
templates,
|
|
12098
|
-
recipe
|
|
12166
|
+
recipe,
|
|
12167
|
+
engineVersion,
|
|
12168
|
+
isCompatible = () => true
|
|
12099
12169
|
}) {
|
|
12100
12170
|
templates = resolveCatalog(templates, [target]);
|
|
12101
12171
|
const sameId = target.id === appliedId;
|
|
@@ -12114,7 +12184,23 @@ function resolveSteps({
|
|
|
12114
12184
|
if (!sameId || rung.toVersion !== targetVersion)
|
|
12115
12185
|
loaded(templates, appliedId, rung.toVersion);
|
|
12116
12186
|
}
|
|
12117
|
-
|
|
12187
|
+
let reachedVersion = rungs.at(-1)?.toVersion ?? appliedVersion;
|
|
12188
|
+
const compatibleVersions = templates.filter(
|
|
12189
|
+
(t) => t.id === appliedId && isCompatible(t) && // A stand-in for an unavailable applied template has no real definition.
|
|
12190
|
+
(appliedShapeKnown || (versionOf(t) ?? 0) !== appliedVersion)
|
|
12191
|
+
).map((t) => versionOf(t) ?? 0).sort((a, b) => a - b);
|
|
12192
|
+
const floor = sameId ? void 0 : implicitFloor({
|
|
12193
|
+
recipe: targetRecipe,
|
|
12194
|
+
sourceId: appliedId,
|
|
12195
|
+
reachedVersion,
|
|
12196
|
+
newest: compatibleVersions.at(-1),
|
|
12197
|
+
engineVersion
|
|
12198
|
+
});
|
|
12199
|
+
if (floor !== void 0) {
|
|
12200
|
+
const landing = compatibleVersions.find((v) => v >= floor) ?? floor;
|
|
12201
|
+
rungs.push({ toVersion: landing, entries: [], implicit: true });
|
|
12202
|
+
reachedVersion = landing;
|
|
12203
|
+
}
|
|
12118
12204
|
const hop = sameId ? void 0 : reachableHop(targetRecipe, appliedId, reachedVersion);
|
|
12119
12205
|
const refusal = findCoverageGap(
|
|
12120
12206
|
rungs,
|
|
@@ -12131,7 +12217,8 @@ function resolveSteps({
|
|
|
12131
12217
|
kind: "version",
|
|
12132
12218
|
templateId: appliedId,
|
|
12133
12219
|
version: rung.toVersion,
|
|
12134
|
-
entries: rung.entries
|
|
12220
|
+
entries: rung.entries,
|
|
12221
|
+
...rung.implicit ? { implicit: true } : {}
|
|
12135
12222
|
}));
|
|
12136
12223
|
if (!sameId) {
|
|
12137
12224
|
if (hop) {
|
|
@@ -12142,15 +12229,9 @@ function resolveSteps({
|
|
|
12142
12229
|
entries: hop.entries
|
|
12143
12230
|
});
|
|
12144
12231
|
} else if (targetRecipe) {
|
|
12145
|
-
const sources = recipeSourcesFor(targetRecipe, appliedId).filter(
|
|
12146
|
-
(source) => source.kind === "change"
|
|
12147
|
-
);
|
|
12148
|
-
const floor = Math.min(
|
|
12149
|
-
...sources.map((source) => source.minSourceVersion ?? 0)
|
|
12150
|
-
);
|
|
12151
12232
|
return {
|
|
12152
12233
|
steps: [],
|
|
12153
|
-
refusal:
|
|
12234
|
+
refusal: `wrong source ID: the recipe has no change entry for "${appliedId}"`
|
|
12154
12235
|
};
|
|
12155
12236
|
}
|
|
12156
12237
|
} else if (targetRecipe && steps.length === 0 && targetVersion !== appliedVersion) {
|
|
@@ -12285,6 +12366,60 @@ function resolveMapWrites(maps, before, fromTemplate, target) {
|
|
|
12285
12366
|
}
|
|
12286
12367
|
return result;
|
|
12287
12368
|
}
|
|
12369
|
+
function advanceLineage(lineage, moved, after, implicit, reset = []) {
|
|
12370
|
+
const lost = [];
|
|
12371
|
+
for (const entry of lineage) {
|
|
12372
|
+
if (entry.places.length === 0) continue;
|
|
12373
|
+
const previous = entry.places;
|
|
12374
|
+
const candidates = [
|
|
12375
|
+
...previous,
|
|
12376
|
+
...moved.flatMap(
|
|
12377
|
+
(m) => previous.some(
|
|
12378
|
+
(p) => p.key === m.from.key && p.bindingType === m.from.bindingType
|
|
12379
|
+
) ? [
|
|
12380
|
+
{
|
|
12381
|
+
key: m.to.key,
|
|
12382
|
+
bindingType: m.to.bindingType,
|
|
12383
|
+
value: m.value ?? ""
|
|
12384
|
+
}
|
|
12385
|
+
] : []
|
|
12386
|
+
)
|
|
12387
|
+
];
|
|
12388
|
+
const survivors = [];
|
|
12389
|
+
const gone = [];
|
|
12390
|
+
for (const place of candidates) {
|
|
12391
|
+
const now = after.find(
|
|
12392
|
+
(a) => a.key === place.key && a.bindingType === place.bindingType
|
|
12393
|
+
);
|
|
12394
|
+
if (now && (place.value === "" || now.value === place.value || // A Hidden reset is a replacement, not normalization.
|
|
12395
|
+
now.value === `=${place.value}` && !reset.some(
|
|
12396
|
+
(r) => r.key === place.key && r.bindingType === place.bindingType && r.from === place.value
|
|
12397
|
+
))) {
|
|
12398
|
+
if (!survivors.some(
|
|
12399
|
+
(s) => s.key === now.key && s.bindingType === now.bindingType
|
|
12400
|
+
))
|
|
12401
|
+
survivors.push({
|
|
12402
|
+
key: now.key,
|
|
12403
|
+
bindingType: now.bindingType,
|
|
12404
|
+
value: now.value
|
|
12405
|
+
});
|
|
12406
|
+
} else if (previous.includes(place)) {
|
|
12407
|
+
gone.push(place);
|
|
12408
|
+
}
|
|
12409
|
+
}
|
|
12410
|
+
entry.places = survivors;
|
|
12411
|
+
if (implicit && survivors.length === 0) {
|
|
12412
|
+
lost.push(
|
|
12413
|
+
...gone.map((p) => ({
|
|
12414
|
+
...p,
|
|
12415
|
+
bindingType: p.bindingType ?? "",
|
|
12416
|
+
isFeel: false
|
|
12417
|
+
}))
|
|
12418
|
+
);
|
|
12419
|
+
}
|
|
12420
|
+
}
|
|
12421
|
+
return lost;
|
|
12422
|
+
}
|
|
12288
12423
|
function valuesOf(element) {
|
|
12289
12424
|
return enumerateElementValues(getExtensionElements(element.businessObject));
|
|
12290
12425
|
}
|
|
@@ -12348,7 +12483,11 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12348
12483
|
current = modeler.elementTemplates.applyTemplate(current, clone) ?? current;
|
|
12349
12484
|
const after = valuesOf(current);
|
|
12350
12485
|
const reset = values.filter(
|
|
12351
|
-
(v) => v.value !== "" && !stepWrites.some((w) => sameTarget(v, w)) &&
|
|
12486
|
+
(v) => v.value !== "" && !stepWrites.some((w) => sameTarget(v, w)) && // An active editable property owns the field, so a Hidden duplicate
|
|
12487
|
+
// is a conditional alternative, not a reset.
|
|
12488
|
+
!findPropertiesByTarget(clone.properties, v.key, v.bindingType).some(
|
|
12489
|
+
(property) => property.type !== "Hidden" && active.has(property)
|
|
12490
|
+
) && findPropertiesByTarget(clone.properties, v.key, v.bindingType).some(
|
|
12352
12491
|
(property) => property.type === "Hidden"
|
|
12353
12492
|
) && !after.some((a) => sameTarget(a, v) && a.value === v.value)
|
|
12354
12493
|
).map(({ key, bindingType, value }) => ({ key, bindingType, from: value }));
|
|
@@ -12365,6 +12504,14 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12365
12504
|
};
|
|
12366
12505
|
return {
|
|
12367
12506
|
element: current,
|
|
12507
|
+
activeTemplate: {
|
|
12508
|
+
...clone,
|
|
12509
|
+
// Unconditional properties are always active. A conditional one counts only
|
|
12510
|
+
// when a write reached it, so an unknown condition never hides a loss.
|
|
12511
|
+
properties: clone.properties.filter(
|
|
12512
|
+
(property) => active.has(property) || !("condition" in property && property.condition)
|
|
12513
|
+
)
|
|
12514
|
+
},
|
|
12368
12515
|
facts: {
|
|
12369
12516
|
...facts,
|
|
12370
12517
|
after,
|
|
@@ -12391,6 +12538,8 @@ function migrateElement({
|
|
|
12391
12538
|
target,
|
|
12392
12539
|
templates,
|
|
12393
12540
|
recipe,
|
|
12541
|
+
engineVersion,
|
|
12542
|
+
isCompatible,
|
|
12394
12543
|
maps = []
|
|
12395
12544
|
}) {
|
|
12396
12545
|
const applied = readAppliedTemplate(element.businessObject);
|
|
@@ -12406,7 +12555,9 @@ function migrateElement({
|
|
|
12406
12555
|
appliedShapeKnown: sourceKnown,
|
|
12407
12556
|
target,
|
|
12408
12557
|
templates,
|
|
12409
|
-
recipe
|
|
12558
|
+
recipe,
|
|
12559
|
+
engineVersion,
|
|
12560
|
+
isCompatible
|
|
12410
12561
|
});
|
|
12411
12562
|
const applications = resolveApplications(templates, steps, target);
|
|
12412
12563
|
for (const { step, template } of applications) {
|
|
@@ -12427,6 +12578,11 @@ function migrateElement({
|
|
|
12427
12578
|
};
|
|
12428
12579
|
const mapPlan = resolveMapWrites(maps, before, fromTemplate, target);
|
|
12429
12580
|
const allFacts = [];
|
|
12581
|
+
const lineage = before.filter((v) => v.value !== "" && !hiddenIn(fromTemplate, v, "every")).map((v) => ({
|
|
12582
|
+
places: [{ key: v.key, bindingType: v.bindingType, value: v.value }]
|
|
12583
|
+
}));
|
|
12584
|
+
const lostInImplicitSteps = [];
|
|
12585
|
+
const implicitTemplates = [];
|
|
12430
12586
|
let current = element;
|
|
12431
12587
|
let mapsApplied = false;
|
|
12432
12588
|
for (const [index, application] of applications.entries()) {
|
|
@@ -12442,6 +12598,17 @@ function migrateElement({
|
|
|
12442
12598
|
if (result) {
|
|
12443
12599
|
current = result.element;
|
|
12444
12600
|
allFacts.push(result.facts);
|
|
12601
|
+
if (application.step?.implicit)
|
|
12602
|
+
implicitTemplates.push(result.activeTemplate);
|
|
12603
|
+
lostInImplicitSteps.push(
|
|
12604
|
+
...advanceLineage(
|
|
12605
|
+
lineage,
|
|
12606
|
+
result.facts.moved,
|
|
12607
|
+
valuesOf(current),
|
|
12608
|
+
application.step?.implicit === true,
|
|
12609
|
+
result.facts.reset
|
|
12610
|
+
)
|
|
12611
|
+
);
|
|
12445
12612
|
mapsApplied ||= isFinal;
|
|
12446
12613
|
}
|
|
12447
12614
|
}
|
|
@@ -12474,10 +12641,27 @@ function migrateElement({
|
|
|
12474
12641
|
after: allFacts.at(-1)?.after ?? before,
|
|
12475
12642
|
facts,
|
|
12476
12643
|
usedRecipe: steps.length > 0,
|
|
12477
|
-
refusal
|
|
12644
|
+
refusal,
|
|
12645
|
+
lostInImplicitSteps,
|
|
12646
|
+
implicitTemplates,
|
|
12647
|
+
steps: reportSteps(steps, fromTemplate.version ?? 0)
|
|
12478
12648
|
});
|
|
12479
12649
|
return { element: current, report };
|
|
12480
12650
|
}
|
|
12651
|
+
function reportSteps(steps, appliedVersion) {
|
|
12652
|
+
let reached = appliedVersion;
|
|
12653
|
+
return steps.map((step) => {
|
|
12654
|
+
const reportStep = {
|
|
12655
|
+
kind: step.kind,
|
|
12656
|
+
templateId: step.templateId,
|
|
12657
|
+
fromVersion: reached,
|
|
12658
|
+
toVersion: step.version,
|
|
12659
|
+
...step.implicit ? { implicit: true } : {}
|
|
12660
|
+
};
|
|
12661
|
+
if (step.kind === "version") reached = step.version;
|
|
12662
|
+
return reportStep;
|
|
12663
|
+
});
|
|
12664
|
+
}
|
|
12481
12665
|
|
|
12482
12666
|
// src/core/config.ts
|
|
12483
12667
|
import { homedir, platform } from "node:os";
|
|
@@ -12982,6 +13166,13 @@ function renderReportText(report, {
|
|
|
12982
13166
|
} else {
|
|
12983
13167
|
lines.push(s.dim(" no recipe: values carried over by key"));
|
|
12984
13168
|
}
|
|
13169
|
+
for (const step of report.steps.filter((step2) => step2.implicit)) {
|
|
13170
|
+
lines.push(
|
|
13171
|
+
s.dim(
|
|
13172
|
+
` The element is on v${step.fromVersion}, which is too old for this recipe. Updating it to v${step.toVersion} first.`
|
|
13173
|
+
)
|
|
13174
|
+
);
|
|
13175
|
+
}
|
|
12985
13176
|
const { rows, dropped } = rowsOf(report, targetTemplate, s);
|
|
12986
13177
|
const all = [...rows, ...dropped];
|
|
12987
13178
|
const labelWidth = Math.min(
|
|
@@ -13131,6 +13322,7 @@ function reportToJson(report, {
|
|
|
13131
13322
|
kept: report.kept.length
|
|
13132
13323
|
},
|
|
13133
13324
|
report: {
|
|
13325
|
+
steps: report.steps,
|
|
13134
13326
|
moved: report.moved,
|
|
13135
13327
|
added: report.added,
|
|
13136
13328
|
changed: report.changed,
|
|
@@ -13423,7 +13615,7 @@ function describeDropped(report) {
|
|
|
13423
13615
|
const unchecked = report.skipped.unchecked.map((u) => u.key);
|
|
13424
13616
|
return names.length > 0 ? `${names.length} dropped (${names.join(", ")})` : unchecked.length > 0 ? `${unchecked.length} unchecked (${unchecked.join(", ")})` : report.refusal ? `recipe not used: ${report.refusal}` : "values not migrated";
|
|
13425
13617
|
}
|
|
13426
|
-
async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath }, redaction) {
|
|
13618
|
+
async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath }, redaction, lockedPath) {
|
|
13427
13619
|
const logger = c8ctl10.getLogger();
|
|
13428
13620
|
installStdoutEpipeHandler();
|
|
13429
13621
|
const dryRun = c8ctl10.dryRun === true;
|
|
@@ -13438,7 +13630,8 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13438
13630
|
);
|
|
13439
13631
|
}
|
|
13440
13632
|
const maps = parsed.maps.map(parseMapArg);
|
|
13441
|
-
const
|
|
13633
|
+
const bpmnPath = lockedPath ?? bpmnFilePath;
|
|
13634
|
+
const input = await readBpmnInput(bpmnPath);
|
|
13442
13635
|
if (!input) {
|
|
13443
13636
|
throw new Error(
|
|
13444
13637
|
"No BPMN input provided. Pass a file path or pipe BPMN XML via stdin."
|
|
@@ -13458,7 +13651,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13458
13651
|
const valuesOf2 = (element) => enumerateElementValues(getExtensionElements(element.businessObject));
|
|
13459
13652
|
redaction.values = selected2.flatMap(({ element }) => valuesOf2(element));
|
|
13460
13653
|
const pool2 = templatePool(
|
|
13461
|
-
bpmnFilePath ? dirname6(
|
|
13654
|
+
bpmnFilePath ? dirname6(resolvePath4(bpmnFilePath)) : process.cwd()
|
|
13462
13655
|
);
|
|
13463
13656
|
const localVersions = pool2.localOf(templateId).map((t) => t.version ?? 0);
|
|
13464
13657
|
if (selected2.some(
|
|
@@ -13488,9 +13681,18 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13488
13681
|
});
|
|
13489
13682
|
redaction.templates = [...lineages([templateId, target.id]), target];
|
|
13490
13683
|
const targetRecipe = recipe ?? embeddedRecipe(target);
|
|
13491
|
-
const
|
|
13492
|
-
(s) => s.kind === "change" && s.sourceTemplateId === templateId
|
|
13684
|
+
const changes = (targetRecipe?.sources ?? []).filter(
|
|
13685
|
+
(s) => s.kind === "change" && s.sourceTemplateId === templateId
|
|
13493
13686
|
);
|
|
13687
|
+
const floors = changes.flatMap(
|
|
13688
|
+
(s) => s.kind === "change" && s.minSourceVersion !== void 0 ? [s.minSourceVersion] : []
|
|
13689
|
+
);
|
|
13690
|
+
const hasFallback = changes.length > floors.length;
|
|
13691
|
+
const localCompatibleVersions = compatibleTemplates(
|
|
13692
|
+
pool2.localOf(templateId),
|
|
13693
|
+
engineVersion
|
|
13694
|
+
).flatMap((t) => t.id === templateId ? [t.version ?? 0] : []);
|
|
13695
|
+
const newestLocal = Math.max(-1, ...localCompatibleVersions);
|
|
13494
13696
|
const localLatest = latestOf(
|
|
13495
13697
|
compatibleTemplates(pool2.localOf(templateId), engineVersion),
|
|
13496
13698
|
templateId
|
|
@@ -13510,7 +13712,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13510
13712
|
const reached = reachedLocally(
|
|
13511
13713
|
readAppliedTemplate(element.businessObject)?.version ?? 0
|
|
13512
13714
|
);
|
|
13513
|
-
return floors.
|
|
13715
|
+
return !hasFallback && floors.some((floor) => floor > newestLocal && floor > reached);
|
|
13514
13716
|
})) {
|
|
13515
13717
|
pool2.cache();
|
|
13516
13718
|
}
|
|
@@ -13623,6 +13825,8 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13623
13825
|
target,
|
|
13624
13826
|
templates,
|
|
13625
13827
|
recipe,
|
|
13828
|
+
engineVersion,
|
|
13829
|
+
isCompatible: (template) => isEngineCompatible(template, engineVersion),
|
|
13626
13830
|
maps
|
|
13627
13831
|
});
|
|
13628
13832
|
redaction.values = [
|
|
@@ -13671,10 +13875,10 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13671
13875
|
}
|
|
13672
13876
|
const canWrite = !dryRun && failed.length === 0 && !wouldBlock;
|
|
13673
13877
|
const saved = canWrite && updated.length > 0 ? await modeler.saveXML({ format: true }) : void 0;
|
|
13674
|
-
if (saved && parsed.inPlace &&
|
|
13675
|
-
if (readFileSync5(
|
|
13878
|
+
if (saved && parsed.inPlace && bpmnPath) {
|
|
13879
|
+
if (readFileSync5(bpmnPath, "utf-8") !== input.xml)
|
|
13676
13880
|
throw new Error(CONCURRENT_EDIT_MESSAGE);
|
|
13677
|
-
atomicOverwriteFile(
|
|
13881
|
+
atomicOverwriteFile(bpmnPath, saved.xml, input.xml);
|
|
13678
13882
|
}
|
|
13679
13883
|
const summary = {
|
|
13680
13884
|
updated: updated.length,
|
|
@@ -13848,7 +14052,8 @@ async function runLockedMigrate(args, redaction) {
|
|
|
13848
14052
|
return runMigrateInternal(resolved, redaction);
|
|
13849
14053
|
if (!existsSync5(resolvePath4(file)))
|
|
13850
14054
|
throw new Error(`File not found: ${file}`);
|
|
13851
|
-
const
|
|
14055
|
+
const lockedPath = realpathSync2(file);
|
|
14056
|
+
const lock = `${lockedPath}.migration.lock`;
|
|
13852
14057
|
let descriptor;
|
|
13853
14058
|
try {
|
|
13854
14059
|
descriptor = openSync2(lock, "wx");
|
|
@@ -13860,7 +14065,7 @@ async function runLockedMigrate(args, redaction) {
|
|
|
13860
14065
|
}
|
|
13861
14066
|
let cleanupFailure;
|
|
13862
14067
|
try {
|
|
13863
|
-
await runMigrateInternal(resolved, redaction);
|
|
14068
|
+
await runMigrateInternal(resolved, redaction, lockedPath);
|
|
13864
14069
|
} finally {
|
|
13865
14070
|
try {
|
|
13866
14071
|
try {
|
|
@@ -266,8 +266,12 @@ that moved.
|
|
|
266
266
|
- **Steps.** An element on an old version climbs the version steps of its own
|
|
267
267
|
template in order, then makes at most one hop onto a different template. A
|
|
268
268
|
source entry declares `kind: "upgrade"` with a destination `toVersion`, or
|
|
269
|
-
`kind: "change"` with an optional `minSourceVersion` floor.
|
|
270
|
-
|
|
269
|
+
`kind: "change"` with an optional `minSourceVersion` floor. A floor above
|
|
270
|
+
the reached version adds one implicit version step (no entries, values carried
|
|
271
|
+
by binding). The best floor is the highest one at most the newest source version
|
|
272
|
+
compatible with the BPMN's `modeler:executionPlatformVersion`; the step lands on
|
|
273
|
+
the lowest compatible version at or above it. An unreachable floor throws
|
|
274
|
+
rather than refusing, so it is never authorizable with `--allow-lossy`. The revised
|
|
271
275
|
dialect keeps schema version 1 and rejects legacy `minVersion` fields.
|
|
272
276
|
Owner-relative ID/version rules and duplicate markers are semantic checks.
|
|
273
277
|
Every selected intermediate template must exist before application; the supplied
|
|
@@ -321,8 +325,8 @@ that moved.
|
|
|
321
325
|
precedes a no-op return.
|
|
322
326
|
- **Authorization.** Lossy in-place migrations and refused embedded-recipe fallback
|
|
323
327
|
require `--allow-lossy`. Explicit unusable recipes cannot be authorized. Diagnostics
|
|
324
|
-
distinguish syntax, coverage (version steps
|
|
325
|
-
|
|
328
|
+
distinguish syntax, coverage (version steps, the implicit floor step and the
|
|
329
|
+
change hop) and source-ID refusal; unreachable floors fail the element; empty recipe
|
|
326
330
|
flags fail. Preview/authorized reports retain refusal and authorization status.
|
|
327
331
|
- **Sensitivity.** Rendering uses credential-like field identity and template
|
|
328
332
|
property/group metadata to redact report values. Known sensitive before/after,
|