eventmodeler 0.6.9 → 0.6.10

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.
Files changed (2) hide show
  1. package/dist/index.js +58 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3876,10 +3876,13 @@ Pattern (read-modify-write):
3876
3876
  | jq '.fields += [{"name":"customerId","fieldType":"UUID","isList":false,"isGenerated":false}]')
3877
3877
  eventmodeler update event "OrderPlaced" "$NEW"
3878
3878
 
3879
- Linked-copy entries cannot be updated. They share the original's name and
3880
- fields by design edit the original and all copies pick up the change. The
3881
- CLI refuses both name-based updates (ambiguous with the original) and
3882
- --id <copy-uuid> updates (would diverge from the original).
3879
+ Linked-copy entries can be repositioned/resized but never re-identified. A
3880
+ copy shares its original's name and fields by design, so an update to a copy
3881
+ writes geometry (x, y, width, height) only any name/field keys in the
3882
+ payload are ignored. To change a copy's name or fields, edit the original and
3883
+ all copies pick up the change. Address a copy by uuid:
3884
+
3885
+ eventmodeler --id <copy-uuid> update event '{"x":120,"y":340}'
3883
3886
 
3884
3887
  Flows have no addressable name and must be updated via uuid:
3885
3888
 
@@ -3894,6 +3897,33 @@ semantics); to preserve it, round-trip via \`show screen ... | jq\`.
3894
3897
  This is a *replace*, not a patch: keys present in the previous entry but
3895
3898
  absent in the new JSON are removed.
3896
3899
  `;
3900
+ var GEOMETRY_KEYS = ["x", "y", "width", "height"];
3901
+ function extractGeometry(parsed) {
3902
+ if (!parsed || typeof parsed !== "object") {
3903
+ return { ok: false, values: {}, issues: ["payload must be a JSON object"] };
3904
+ }
3905
+ const obj = parsed;
3906
+ const values = {};
3907
+ const issues = [];
3908
+ for (const k of GEOMETRY_KEYS) {
3909
+ const v = obj[k];
3910
+ if (v === undefined)
3911
+ continue;
3912
+ if (typeof v !== "number" || !Number.isFinite(v)) {
3913
+ issues.push(`${k} must be a finite number`);
3914
+ continue;
3915
+ }
3916
+ if ((k === "width" || k === "height") && v <= 0) {
3917
+ issues.push(`${k} must be positive`);
3918
+ continue;
3919
+ }
3920
+ values[k] = v;
3921
+ }
3922
+ if (issues.length === 0 && Object.keys(values).length === 0) {
3923
+ issues.push("no geometry fields (x, y, width, height) present to update");
3924
+ }
3925
+ return { ok: issues.length === 0, values, issues };
3926
+ }
3897
3927
  function registerUpdateCommands(program) {
3898
3928
  program.command("update <type> <args...>").description(`Replace an element's shape with JSON. Types: ${knownTypeAliases().join(", ")}`).option("--model <id>", "Model id (defaults to .eventmodeler.json in cwd)").addHelpText("after", UPDATE_HELP).action(async (type, args, opts) => {
3899
3929
  const meta = resolveType(type);
@@ -3933,32 +3963,45 @@ function registerUpdateCommands(program) {
3933
3963
  if (note)
3934
3964
  console.error(note);
3935
3965
  }
3936
- const validation = validateEntry(meta.scope, parsed);
3937
- if (!validation.ok) {
3938
- console.error(`Validation failed for ${meta.type}:`);
3939
- for (const issue of validation.issues)
3940
- console.error(` - ${issue}`);
3941
- process.exit(2);
3942
- }
3943
3966
  const modelId = resolveModelId(opts.model);
3944
3967
  await withDoc(modelId, (doc) => {
3945
3968
  const { id, entry } = resolveEntity(doc, meta.scope, meta.idKey, meta.nameKey, name, {
3946
3969
  idOverride,
3947
3970
  includeLinkedCopies: Boolean(idOverride)
3948
3971
  });
3972
+ const map = getScopeMap(doc, meta.scope);
3949
3973
  if (entry.isLinkedCopy) {
3950
- const originalId = meta.originalIdKey ? entry[meta.originalIdKey] : undefined;
3951
- console.error(`Cannot update ${meta.type} ${id} — it is a linked copy. ` + `Linked copies share their original's name and fields; edit the original instead` + (originalId ? ` (--id ${originalId}).` : "."));
3974
+ const geom = extractGeometry(parsed);
3975
+ if (!geom.ok) {
3976
+ console.error(`Cannot update ${meta.type} ${id} (linked copy):`);
3977
+ for (const issue of geom.issues)
3978
+ console.error(` - ${issue}`);
3979
+ process.exit(2);
3980
+ }
3981
+ doc.transact(() => {
3982
+ const e = map.get(id);
3983
+ if (!e)
3984
+ return;
3985
+ for (const [k, v] of Object.entries(geom.values))
3986
+ e.set(k, v);
3987
+ });
3988
+ console.log(`Updated ${meta.type} geometry (linked copy — name and fields stay tied to the original).`);
3989
+ return;
3990
+ }
3991
+ const validation = validateEntry(meta.scope, parsed);
3992
+ if (!validation.ok) {
3993
+ console.error(`Validation failed for ${meta.type}:`);
3994
+ for (const issue of validation.issues)
3995
+ console.error(` - ${issue}`);
3952
3996
  process.exit(2);
3953
3997
  }
3954
- const map = getScopeMap(doc, meta.scope);
3955
3998
  const finalEntry = { ...validation.data, [meta.idKey]: id, modelId };
3956
3999
  doc.transact(() => {
3957
4000
  map.delete(id);
3958
4001
  map.set(id, deepToY(finalEntry));
3959
4002
  });
4003
+ console.log(`Updated ${meta.type}.`);
3960
4004
  });
3961
- console.log(`Updated ${meta.type}.`);
3962
4005
  });
3963
4006
  }
3964
4007
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eventmodeler",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "CLI tool for event modeling - explore, design, and generate code from your event models",
5
5
  "type": "module",
6
6
  "repository": {