@camunda8/cli 4.6.0-alpha.1 → 4.6.0-alpha.3
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.
|
@@ -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:
|
|
@@ -281,7 +285,10 @@ This revised dialect keeps `schemaVersion: 1` but rejects legacy `minVersion` re
|
|
|
281
285
|
`kind` on every source. Older strict readers reject the new fields. See
|
|
282
286
|
[`migration/migrates-from.schema.json`](./migration/migrates-from.schema.json) for the full format.
|
|
283
287
|
Recipes are validated strictly: an unknown key or an unsupported `schemaVersion` fails the command
|
|
284
|
-
instead of being ignored. `
|
|
288
|
+
instead of being ignored. `schemaVersion` is checked first, so a recipe with a newer version always
|
|
289
|
+
reports that c8ctl must be updated, whatever other keys it has. An unusable recipe embedded in the
|
|
290
|
+
target template, or in the latest version of the source template, fails the whole `update` run and
|
|
291
|
+
names that template. `metadata.migratesFrom` is not part of the official element template schema.
|
|
285
292
|
Draft07 validation alone is insufficient: the parser also rejects duplicate source markers/floors,
|
|
286
293
|
and owner validation checks source IDs and upgrade destinations against the template carrying the recipe.
|
|
287
294
|
An optional `$schema` accepts any string, including blank strings. Paths, IDs, notes, templates,
|
|
@@ -11367,6 +11367,7 @@ function mergeFacts(all) {
|
|
|
11367
11367
|
let moved = [];
|
|
11368
11368
|
let set2 = [];
|
|
11369
11369
|
let failedWrites = false;
|
|
11370
|
+
let snapshot;
|
|
11370
11371
|
for (const facts of all) {
|
|
11371
11372
|
const priorMoved = moved;
|
|
11372
11373
|
const priorSet = set2;
|
|
@@ -11385,10 +11386,12 @@ function mergeFacts(all) {
|
|
|
11385
11386
|
set2.push({ ...move.to, value: move.value ?? addition.value });
|
|
11386
11387
|
} else {
|
|
11387
11388
|
const prior = priorMoved.find((item) => sameField(item.to, move.from));
|
|
11389
|
+
const read = prior ? prior.read : snapshot && find2(snapshot, move.from.key, move.from.bindingType)?.value;
|
|
11388
11390
|
moved.push({
|
|
11389
11391
|
...move,
|
|
11390
11392
|
from: prior?.from ?? move.from,
|
|
11391
|
-
transformed: Boolean(prior?.transformed) || move.transformed
|
|
11393
|
+
transformed: Boolean(prior?.transformed) || move.transformed,
|
|
11394
|
+
...read === void 0 ? {} : { read }
|
|
11392
11395
|
});
|
|
11393
11396
|
}
|
|
11394
11397
|
}
|
|
@@ -11406,6 +11409,7 @@ function mergeFacts(all) {
|
|
|
11406
11409
|
failedWrites ||= moved.some((move) => !surviving(move.to, move.value)) || set2.some((write) => !surviving(write, write.value));
|
|
11407
11410
|
moved = moved.filter((move) => surviving(move.to, move.value));
|
|
11408
11411
|
set2 = set2.filter((write) => surviving(write, write.value));
|
|
11412
|
+
snapshot = after;
|
|
11409
11413
|
}
|
|
11410
11414
|
failedWrites ||= Boolean(facts.failedWrites);
|
|
11411
11415
|
}
|
|
@@ -11413,6 +11417,12 @@ function mergeFacts(all) {
|
|
|
11413
11417
|
moved,
|
|
11414
11418
|
set: set2,
|
|
11415
11419
|
failedWrites,
|
|
11420
|
+
written: all.flatMap((f) => [
|
|
11421
|
+
...f.written ?? [],
|
|
11422
|
+
...f.moved.map((move) => move.to),
|
|
11423
|
+
...f.set.map(({ key, bindingType }) => ({ key, bindingType }))
|
|
11424
|
+
]),
|
|
11425
|
+
reset: all.flatMap((f) => f.reset ?? []),
|
|
11416
11426
|
notes: all.flatMap((f) => f.notes),
|
|
11417
11427
|
guardSkipped: all.flatMap((f) => f.guardSkipped),
|
|
11418
11428
|
templateSkipped: all.flatMap((f) => f.templateSkipped),
|
|
@@ -11476,6 +11486,14 @@ function find2(values, key, bindingType) {
|
|
|
11476
11486
|
function isHidden(template, key, bindingType) {
|
|
11477
11487
|
return propertyFor(template, key, bindingType)?.type === "Hidden";
|
|
11478
11488
|
}
|
|
11489
|
+
function hiddenIn(template, v, match) {
|
|
11490
|
+
const properties = findPropertiesByTarget(
|
|
11491
|
+
template.properties,
|
|
11492
|
+
v.key,
|
|
11493
|
+
v.bindingType
|
|
11494
|
+
);
|
|
11495
|
+
return properties.length > 0 && properties[match]((property) => property.type === "Hidden");
|
|
11496
|
+
}
|
|
11479
11497
|
function withNames(template, field, value) {
|
|
11480
11498
|
const name2 = choiceName(template, field, value);
|
|
11481
11499
|
return name2 ? { valueName: name2 } : {};
|
|
@@ -11500,7 +11518,9 @@ function buildReport({
|
|
|
11500
11518
|
const addedSets = survivingSets.filter(
|
|
11501
11519
|
(s) => !find2(before, s.key, s.bindingType)
|
|
11502
11520
|
);
|
|
11503
|
-
const claimedFrom = (v) => survivingMoves.some(
|
|
11521
|
+
const claimedFrom = (v) => survivingMoves.some(
|
|
11522
|
+
(m) => sameTarget(v, m.from) && (m.read === void 0 || m.read === v.value)
|
|
11523
|
+
);
|
|
11504
11524
|
const claimedTo = (v) => survivingMoves.some((m) => sameTarget(v, m.to)) || addedSets.some((s) => sameTarget(v, s));
|
|
11505
11525
|
const moved = survivingMoves.map((m) => {
|
|
11506
11526
|
const from = fieldOf(fromTemplate, m.from.key, m.from.bindingType);
|
|
@@ -11527,15 +11547,31 @@ function buildReport({
|
|
|
11527
11547
|
const lostBySource = (v) => facts.moved.some(
|
|
11528
11548
|
(m) => !survivingMoves.includes(m) && sameTarget(v, m.from) && find2(after, m.to.key, m.to.bindingType) === void 0
|
|
11529
11549
|
);
|
|
11530
|
-
const
|
|
11531
|
-
|
|
11532
|
-
|
|
11550
|
+
const written = [
|
|
11551
|
+
...facts.written ?? [],
|
|
11552
|
+
...facts.moved.map((m) => m.to),
|
|
11553
|
+
...facts.set
|
|
11554
|
+
];
|
|
11555
|
+
const causeOf = (v) => {
|
|
11556
|
+
const actual = find2(after, v.key, v.bindingType);
|
|
11557
|
+
if (!actual || actual.value === v.value || claimedFrom(v)) return;
|
|
11558
|
+
if (written.some((w) => sameTarget(v, w))) return "displaced";
|
|
11559
|
+
const reset = hiddenIn(toTemplate, v, "some") || (facts.reset ?? []).some((r) => sameTarget(v, r) && r.from === v.value);
|
|
11560
|
+
if (reset && !hiddenIn(fromTemplate, v, "every")) return "hidden";
|
|
11561
|
+
};
|
|
11562
|
+
const dropped = before.filter((v) => v.value !== "").flatMap((v) => {
|
|
11563
|
+
const cause = causeOf(v);
|
|
11564
|
+
if (!cause && (claimedFrom(v) || find2(after, v.key, v.bindingType)) && !lostBySource(v))
|
|
11565
|
+
return [];
|
|
11533
11566
|
const field = fieldOf(fromTemplate, v.key, v.bindingType);
|
|
11534
|
-
return
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11567
|
+
return [
|
|
11568
|
+
{
|
|
11569
|
+
...field,
|
|
11570
|
+
value: v.value,
|
|
11571
|
+
...withNames(fromTemplate, field, v.value),
|
|
11572
|
+
...cause ? { cause } : {}
|
|
11573
|
+
}
|
|
11574
|
+
];
|
|
11539
11575
|
});
|
|
11540
11576
|
const added = after.filter(
|
|
11541
11577
|
(v) => v.value !== "" && !find2(before, v.key, v.bindingType) && !isHidden(toTemplate, v.key, v.bindingType) && !claimedTo(v)
|
|
@@ -11876,18 +11912,23 @@ function parseSource(raw, at) {
|
|
|
11876
11912
|
}
|
|
11877
11913
|
function parseRecipe(raw) {
|
|
11878
11914
|
const obj = requireRecord(raw, "recipe");
|
|
11915
|
+
const version = obj.schemaVersion;
|
|
11916
|
+
const parse = typeof version === "number" ? PARSERS.get(version) : void 0;
|
|
11917
|
+
if (parse) {
|
|
11918
|
+
return parse(obj);
|
|
11919
|
+
}
|
|
11920
|
+
if (Number.isInteger(version) && Number(version) > SUPPORTED_SCHEMA_VERSION) {
|
|
11921
|
+
throw new RecipeError(
|
|
11922
|
+
`schemaVersion ${version} is newer than this c8ctl supports (${SUPPORTED_SCHEMA_VERSION}). Update c8ctl to use this recipe`
|
|
11923
|
+
);
|
|
11924
|
+
}
|
|
11925
|
+
throw new RecipeError(`schemaVersion must be ${SUPPORTED_SCHEMA_VERSION}`);
|
|
11926
|
+
}
|
|
11927
|
+
function parseRecipeV1(obj) {
|
|
11879
11928
|
rejectUnknownKeys(obj, ["$schema", "schemaVersion", "sources"], "recipe");
|
|
11880
11929
|
if (obj.$schema !== void 0 && typeof obj.$schema !== "string") {
|
|
11881
11930
|
throw new RecipeError("recipe.$schema must be a string");
|
|
11882
11931
|
}
|
|
11883
|
-
if (obj.schemaVersion !== SUPPORTED_SCHEMA_VERSION) {
|
|
11884
|
-
if (Number.isInteger(obj.schemaVersion) && Number(obj.schemaVersion) > SUPPORTED_SCHEMA_VERSION) {
|
|
11885
|
-
throw new RecipeError(
|
|
11886
|
-
`schemaVersion ${obj.schemaVersion} is newer than this c8ctl supports (${SUPPORTED_SCHEMA_VERSION}). Update c8ctl to use this recipe`
|
|
11887
|
-
);
|
|
11888
|
-
}
|
|
11889
|
-
throw new RecipeError(`schemaVersion must be ${SUPPORTED_SCHEMA_VERSION}`);
|
|
11890
|
-
}
|
|
11891
11932
|
if (!Array.isArray(obj.sources) || obj.sources.length === 0) {
|
|
11892
11933
|
throw new RecipeError("sources must be a non-empty list");
|
|
11893
11934
|
}
|
|
@@ -11909,8 +11950,11 @@ function parseRecipe(raw) {
|
|
|
11909
11950
|
}
|
|
11910
11951
|
seen.add(key);
|
|
11911
11952
|
}
|
|
11912
|
-
return { schemaVersion:
|
|
11953
|
+
return { schemaVersion: 1, sources };
|
|
11913
11954
|
}
|
|
11955
|
+
var PARSERS = /* @__PURE__ */ new Map([
|
|
11956
|
+
[1, parseRecipeV1]
|
|
11957
|
+
]);
|
|
11914
11958
|
function validateRecipeOwner(recipe, owner) {
|
|
11915
11959
|
for (const source of recipe.sources) {
|
|
11916
11960
|
if (source.kind === "upgrade") {
|
|
@@ -12287,6 +12331,12 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12287
12331
|
}
|
|
12288
12332
|
}
|
|
12289
12333
|
current = modeler.elementTemplates.applyTemplate(current, clone) ?? current;
|
|
12334
|
+
const after = valuesOf(current);
|
|
12335
|
+
const reset = values.filter(
|
|
12336
|
+
(v) => v.value !== "" && !stepWrites.some((w) => sameTarget(v, w)) && findPropertiesByTarget(clone.properties, v.key, v.bindingType).some(
|
|
12337
|
+
(property) => property.type === "Hidden"
|
|
12338
|
+
) && !after.some((a) => sameTarget(a, v) && a.value === v.value)
|
|
12339
|
+
).map(({ key, bindingType, value }) => ({ key, bindingType, from: value }));
|
|
12290
12340
|
const resolvedValue = (key, bindingType) => {
|
|
12291
12341
|
const write = writes.find(
|
|
12292
12342
|
(w) => w.key === key && w.bindingType === bindingType
|
|
@@ -12302,7 +12352,8 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12302
12352
|
element: current,
|
|
12303
12353
|
facts: {
|
|
12304
12354
|
...facts,
|
|
12305
|
-
after
|
|
12355
|
+
after,
|
|
12356
|
+
reset,
|
|
12306
12357
|
moved: facts.moved.map((move) => ({
|
|
12307
12358
|
...move,
|
|
12308
12359
|
value: resolvedValue(move.to.key, move.to.bindingType)
|
|
@@ -12871,7 +12922,7 @@ function rowsOf(report, targetTemplate, s) {
|
|
|
12871
12922
|
marker: "-",
|
|
12872
12923
|
label: `${group ? `${group} \u203A ` : ""}${fieldLabel(d)}`,
|
|
12873
12924
|
value: [[shown(d.value, d.valueName, false), s.red]],
|
|
12874
|
-
source: ""
|
|
12925
|
+
source: d.cause === "hidden" ? "replaced by fixed template value" : d.cause === "displaced" ? "overwritten" : ""
|
|
12875
12926
|
};
|
|
12876
12927
|
});
|
|
12877
12928
|
return { rows, dropped };
|
|
@@ -13208,7 +13259,9 @@ function loadRecipeFile(path) {
|
|
|
13208
13259
|
}
|
|
13209
13260
|
function embeddedRecipe(template) {
|
|
13210
13261
|
try {
|
|
13211
|
-
|
|
13262
|
+
const recipe = readEmbeddedRecipe(template);
|
|
13263
|
+
if (recipe) validateRecipeOwner(recipe, template);
|
|
13264
|
+
return recipe;
|
|
13212
13265
|
} catch (error3) {
|
|
13213
13266
|
if (error3 instanceof RecipeError) {
|
|
13214
13267
|
throw new Error(
|
|
@@ -13402,8 +13455,26 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13402
13455
|
[target]
|
|
13403
13456
|
);
|
|
13404
13457
|
redaction.templates = [...lineages([templateId, target.id]), target];
|
|
13458
|
+
if (recipe) validateRecipeOwner(recipe, target);
|
|
13405
13459
|
const targetRecipe = recipe ?? embeddedRecipe(target);
|
|
13406
|
-
|
|
13460
|
+
const fromTemplateOf = (applied) => {
|
|
13461
|
+
const isApplied = (t) => t.id === applied.id && (t.version ?? 0) === applied.version;
|
|
13462
|
+
return templates.find(isApplied) ?? lineages([applied.id]).find(isApplied) ?? {
|
|
13463
|
+
id: applied.id,
|
|
13464
|
+
version: applied.version,
|
|
13465
|
+
properties: []
|
|
13466
|
+
};
|
|
13467
|
+
};
|
|
13468
|
+
for (const { element } of selected2) {
|
|
13469
|
+
const applied = readAppliedTemplate(element.businessObject);
|
|
13470
|
+
if (!applied || applied.id === target.id) continue;
|
|
13471
|
+
const catalog = resolveCatalog(templates, [
|
|
13472
|
+
fromTemplateOf(applied),
|
|
13473
|
+
target
|
|
13474
|
+
]);
|
|
13475
|
+
const sourceLatest = latestOf(catalog, applied.id);
|
|
13476
|
+
if (sourceLatest) embeddedRecipe(sourceLatest);
|
|
13477
|
+
}
|
|
13407
13478
|
if (!isEngineCompatible(target, engineVersion)) {
|
|
13408
13479
|
throw new Error(
|
|
13409
13480
|
`Template '${target.id}' is not compatible with Camunda ${engineVersion}.`
|
|
@@ -13447,12 +13518,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13447
13518
|
});
|
|
13448
13519
|
continue;
|
|
13449
13520
|
}
|
|
13450
|
-
const
|
|
13451
|
-
const fromTemplate = templates.find(isApplied) ?? lineages([applied.id]).find(isApplied) ?? {
|
|
13452
|
-
id: applied.id,
|
|
13453
|
-
version: applied.version,
|
|
13454
|
-
properties: []
|
|
13455
|
-
};
|
|
13521
|
+
const fromTemplate = fromTemplateOf(applied);
|
|
13456
13522
|
try {
|
|
13457
13523
|
const result = migrateElement({
|
|
13458
13524
|
modeler: migrationModeler,
|
|
@@ -236,7 +236,16 @@ that moved.
|
|
|
236
236
|
`--recipe` supplies the same format from a file for templates that carry none.
|
|
237
237
|
- **Versioned and strict.** The recipe has a `schemaVersion`. A reader refuses a
|
|
238
238
|
version it does not know and any unknown key, rather than applying part of a
|
|
239
|
-
recipe or silently ignoring a typo.
|
|
239
|
+
recipe or silently ignoring a typo. The version is checked first and selects
|
|
240
|
+
the parser from a version-to-parser map, so a newer recipe always asks for a
|
|
241
|
+
newer c8ctl, whatever keys it adds; a later version can then add fields without
|
|
242
|
+
older readers reporting them as typos.
|
|
243
|
+
- **Unusable embedded recipes fail the run.** A run moves one source template to
|
|
244
|
+
one target, so an unusable recipe on the target or on the latest version of the
|
|
245
|
+
source lineage affects every element in it. The run fails up front and names the
|
|
246
|
+
template carrying the recipe, instead of migrating without the author's recipe.
|
|
247
|
+
This also applies when every element is already unchanged or skipped, like any
|
|
248
|
+
other recipe validation. Successor discovery skips such templates instead.
|
|
240
249
|
- **Validation boundary.** Draft07 and the parser enforce the same JSON structure.
|
|
241
250
|
Schema validation alone is insufficient: keyed source uniqueness is checked by
|
|
242
251
|
the parser and owner-relative ID/version constraints by `validateRecipeOwner`.
|
|
@@ -267,6 +276,16 @@ that moved.
|
|
|
267
276
|
the engine cannot read are not diffed; an editable source field under one is
|
|
268
277
|
reported as unchecked, and the report is lossy, unless the target binds it
|
|
269
278
|
identically and not as Hidden, which is the case where the Modeler keeps it.
|
|
279
|
+
A field that survives can still lose its value: a Hidden target property
|
|
280
|
+
resetting an editable source value, or a move or set overwriting a different
|
|
281
|
+
populated value, is reported as dropped with a `cause`, and the report is lossy.
|
|
282
|
+
A destination that is itself moved away (a swap or chain) is not displaced.
|
|
283
|
+
A field written in any recipe step counts, also when a later step moves the
|
|
284
|
+
value on. Conditions are not evaluated here: a target counts as Hidden when any
|
|
285
|
+
duplicate for the binding is Hidden, a source only when every duplicate is.
|
|
286
|
+
Each step records the values its Hidden properties reset, so a reset in an
|
|
287
|
+
intermediate version counts, even when the final template binds the field as
|
|
288
|
+
editable again or a later step moves the reset value on.
|
|
270
289
|
- **Read/write identity.** Unqualified rename, guard and interpolation reads fail
|
|
271
290
|
when several binding types match. Qualification selects a binding type; duplicate
|
|
272
291
|
backing identities or extension containers are rejected rather than selecting an
|