@camunda8/cli 4.6.0-alpha.1 → 4.6.0-alpha.2

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.
@@ -281,7 +281,10 @@ This revised dialect keeps `schemaVersion: 1` but rejects legacy `minVersion` re
281
281
  `kind` on every source. Older strict readers reject the new fields. See
282
282
  [`migration/migrates-from.schema.json`](./migration/migrates-from.schema.json) for the full format.
283
283
  Recipes are validated strictly: an unknown key or an unsupported `schemaVersion` fails the command
284
- instead of being ignored. `metadata.migratesFrom` is not part of the official element template schema.
284
+ instead of being ignored. `schemaVersion` is checked first, so a recipe with a newer version always
285
+ reports that c8ctl must be updated, whatever other keys it has. An unusable recipe embedded in the
286
+ target template, or in the latest version of the source template, fails the whole `update` run and
287
+ names that template. `metadata.migratesFrom` is not part of the official element template schema.
285
288
  Draft07 validation alone is insufficient: the parser also rejects duplicate source markers/floors,
286
289
  and owner validation checks source IDs and upgrade destinations against the template carrying the recipe.
287
290
  An optional `$schema` accepts any string, including blank strings. Paths, IDs, notes, templates,
@@ -11876,18 +11876,23 @@ function parseSource(raw, at) {
11876
11876
  }
11877
11877
  function parseRecipe(raw) {
11878
11878
  const obj = requireRecord(raw, "recipe");
11879
+ const version = obj.schemaVersion;
11880
+ const parse = typeof version === "number" ? PARSERS.get(version) : void 0;
11881
+ if (parse) {
11882
+ return parse(obj);
11883
+ }
11884
+ if (Number.isInteger(version) && Number(version) > SUPPORTED_SCHEMA_VERSION) {
11885
+ throw new RecipeError(
11886
+ `schemaVersion ${version} 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
+ function parseRecipeV1(obj) {
11879
11892
  rejectUnknownKeys(obj, ["$schema", "schemaVersion", "sources"], "recipe");
11880
11893
  if (obj.$schema !== void 0 && typeof obj.$schema !== "string") {
11881
11894
  throw new RecipeError("recipe.$schema must be a string");
11882
11895
  }
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
11896
  if (!Array.isArray(obj.sources) || obj.sources.length === 0) {
11892
11897
  throw new RecipeError("sources must be a non-empty list");
11893
11898
  }
@@ -11909,8 +11914,11 @@ function parseRecipe(raw) {
11909
11914
  }
11910
11915
  seen.add(key);
11911
11916
  }
11912
- return { schemaVersion: SUPPORTED_SCHEMA_VERSION, sources };
11917
+ return { schemaVersion: 1, sources };
11913
11918
  }
11919
+ var PARSERS = /* @__PURE__ */ new Map([
11920
+ [1, parseRecipeV1]
11921
+ ]);
11914
11922
  function validateRecipeOwner(recipe, owner) {
11915
11923
  for (const source of recipe.sources) {
11916
11924
  if (source.kind === "upgrade") {
@@ -13208,7 +13216,9 @@ function loadRecipeFile(path) {
13208
13216
  }
13209
13217
  function embeddedRecipe(template) {
13210
13218
  try {
13211
- return readEmbeddedRecipe(template);
13219
+ const recipe = readEmbeddedRecipe(template);
13220
+ if (recipe) validateRecipeOwner(recipe, template);
13221
+ return recipe;
13212
13222
  } catch (error3) {
13213
13223
  if (error3 instanceof RecipeError) {
13214
13224
  throw new Error(
@@ -13402,8 +13412,26 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13402
13412
  [target]
13403
13413
  );
13404
13414
  redaction.templates = [...lineages([templateId, target.id]), target];
13415
+ if (recipe) validateRecipeOwner(recipe, target);
13405
13416
  const targetRecipe = recipe ?? embeddedRecipe(target);
13406
- if (targetRecipe) validateRecipeOwner(targetRecipe, target);
13417
+ const fromTemplateOf = (applied) => {
13418
+ const isApplied = (t) => t.id === applied.id && (t.version ?? 0) === applied.version;
13419
+ return templates.find(isApplied) ?? lineages([applied.id]).find(isApplied) ?? {
13420
+ id: applied.id,
13421
+ version: applied.version,
13422
+ properties: []
13423
+ };
13424
+ };
13425
+ for (const { element } of selected2) {
13426
+ const applied = readAppliedTemplate(element.businessObject);
13427
+ if (!applied || applied.id === target.id) continue;
13428
+ const catalog = resolveCatalog(templates, [
13429
+ fromTemplateOf(applied),
13430
+ target
13431
+ ]);
13432
+ const sourceLatest = latestOf(catalog, applied.id);
13433
+ if (sourceLatest) embeddedRecipe(sourceLatest);
13434
+ }
13407
13435
  if (!isEngineCompatible(target, engineVersion)) {
13408
13436
  throw new Error(
13409
13437
  `Template '${target.id}' is not compatible with Camunda ${engineVersion}.`
@@ -13447,12 +13475,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13447
13475
  });
13448
13476
  continue;
13449
13477
  }
13450
- const isApplied = (t) => t.id === applied.id && (t.version ?? 0) === applied.version;
13451
- const fromTemplate = templates.find(isApplied) ?? lineages([applied.id]).find(isApplied) ?? {
13452
- id: applied.id,
13453
- version: applied.version,
13454
- properties: []
13455
- };
13478
+ const fromTemplate = fromTemplateOf(applied);
13456
13479
  try {
13457
13480
  const result = migrateElement({
13458
13481
  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`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda8/cli",
3
- "version": "4.6.0-alpha.1",
3
+ "version": "4.6.0-alpha.2",
4
4
  "description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
5
5
  "type": "module",
6
6
  "engines": {