eventmodeler 0.6.7 → 0.6.8

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 +100 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2742,12 +2742,22 @@ var NoteSchema = Box.extend({
2742
2742
  title: z.string().min(1),
2743
2743
  description: z.string().optional()
2744
2744
  });
2745
+ var ExcalidrawElementSchema = z.object({
2746
+ id: z.string().min(1),
2747
+ type: z.string().min(1),
2748
+ version: z.number().int().optional(),
2749
+ isDeleted: z.boolean().optional()
2750
+ }).passthrough();
2751
+ var DesignSchema = z.array(ExcalidrawElementSchema);
2745
2752
  var canonicalSticky = (idKey) => NamedBox.extend({
2746
2753
  [idKey]: z.string().uuid().optional(),
2747
2754
  modelId: z.string().uuid().optional(),
2748
2755
  fields: z.array(FieldSchema).optional(),
2749
2756
  isLinkedCopy: z.literal(false).optional()
2750
2757
  });
2758
+ var canonicalScreen = canonicalSticky("screenId").extend({
2759
+ design: DesignSchema.optional()
2760
+ });
2751
2761
  var linkedCopySticky = (idKey, originalIdKey) => Box.extend({
2752
2762
  [idKey]: z.string().uuid().optional(),
2753
2763
  modelId: z.string().uuid().optional(),
@@ -2766,7 +2776,7 @@ var stickyVariants = {
2766
2776
  linkedCopy: linkedCopySticky("readModelStickyId", "originalReadModelStickyId")
2767
2777
  },
2768
2778
  screens: {
2769
- canonical: canonicalSticky("screenId"),
2779
+ canonical: canonicalScreen,
2770
2780
  linkedCopy: linkedCopySticky("screenId", "originalScreenId")
2771
2781
  },
2772
2782
  processors: {
@@ -2783,6 +2793,41 @@ var ReadModelSchema = z.union([stickyVariants.readModels.canonical, stickyVarian
2783
2793
  var ScreenSchema = z.union([stickyVariants.screens.canonical, stickyVariants.screens.linkedCopy]);
2784
2794
  var ProcessorSchema = z.union([stickyVariants.processors.canonical, stickyVariants.processors.linkedCopy]);
2785
2795
  var ExternalEventSchema = z.union([stickyVariants.externalEvents.canonical, stickyVariants.externalEvents.linkedCopy]);
2796
+ var FlowTypeSchema = z.enum([
2797
+ "CommandToEvent",
2798
+ "EventToReadModel",
2799
+ "ReadModelToScreen",
2800
+ "ReadModelToProcessor",
2801
+ "ScreenToCommand",
2802
+ "ProcessorToCommand",
2803
+ "CommandToExternalEvent",
2804
+ "ExternalEventToProcessor"
2805
+ ]);
2806
+ var FlowHandleSchema = z.enum([
2807
+ "top-source",
2808
+ "right-source",
2809
+ "bottom-source",
2810
+ "left-source",
2811
+ "top-target",
2812
+ "right-target",
2813
+ "bottom-target",
2814
+ "left-target"
2815
+ ]);
2816
+ var FlowMappingSchema = z.object({
2817
+ mappingId: z.string().uuid().optional(),
2818
+ sourceFieldId: z.string().uuid(),
2819
+ targetFieldId: z.string().uuid()
2820
+ });
2821
+ var FlowSchema = z.object({
2822
+ flowId: z.string().uuid().optional(),
2823
+ modelId: z.string().uuid().optional(),
2824
+ flowType: FlowTypeSchema,
2825
+ sourceId: z.string().uuid(),
2826
+ targetId: z.string().uuid(),
2827
+ sourceHandle: FlowHandleSchema.optional(),
2828
+ targetHandle: FlowHandleSchema.optional(),
2829
+ mappings: z.array(FlowMappingSchema).optional()
2830
+ });
2786
2831
  var SCOPE_SCHEMAS = {
2787
2832
  commands: CommandSchema,
2788
2833
  events: EventSchema,
@@ -2796,7 +2841,8 @@ var SCOPE_SCHEMAS = {
2796
2841
  chapters: ChapterSchema,
2797
2842
  contexts: ContextSchema,
2798
2843
  swimLanes: SwimLaneSchema,
2799
- notes: NoteSchema
2844
+ notes: NoteSchema,
2845
+ flows: FlowSchema
2800
2846
  };
2801
2847
  function validateEntry(scope, data) {
2802
2848
  const schema = pickSchema(scope, data);
@@ -2975,7 +3021,19 @@ var ELEMENT_VIEW = `ElementView:
2975
3021
  "x": 0, "y": 0, "width": 0, "height": 0,
2976
3022
  "fields": [FieldView, ...],
2977
3023
  "linkedCopy": false,
2978
- "originalId": "<uuid>" // only when linkedCopy = true
3024
+ "originalId": "<uuid>", // only when linkedCopy = true
3025
+ "design": [ExcalidrawElement, ...]
3026
+ // screens only; omitted when empty/absent
3027
+ }
3028
+
3029
+ ExcalidrawElement (passthrough — Excalidraw owns the full shape):
3030
+ {
3031
+ "id": "<element-id>", // required
3032
+ "type": "rectangle" | "ellipse" | "diamond" | "arrow"
3033
+ | "line" | "freedraw" | "text" | "image" | "frame" | ...,
3034
+ "version": 1, // optional
3035
+ "isDeleted": false, // optional
3036
+ ... // any extra Excalidraw props pass through
2979
3037
  }`;
2980
3038
  var SLICE_VIEW = `SliceView:
2981
3039
  {
@@ -3318,6 +3376,9 @@ function buildElementView(e) {
3318
3376
  if (originalId)
3319
3377
  view.originalId = originalId;
3320
3378
  }
3379
+ if (e.scope === "screens" && Array.isArray(e.design) && e.design.length > 0) {
3380
+ view.design = e.design;
3381
+ }
3321
3382
  return view;
3322
3383
  }
3323
3384
  function buildSliceView(doc, slice) {
@@ -3427,6 +3488,9 @@ function buildShowElementView(doc, scope2, element) {
3427
3488
  if (element.isLinkedCopy && originalKey) {
3428
3489
  view.originalId = read(element, originalKey);
3429
3490
  }
3491
+ if (scope2 === "screens" && Array.isArray(element.design) && element.design.length > 0) {
3492
+ view.design = element.design;
3493
+ }
3430
3494
  view.copies = copies.map((c) => ({
3431
3495
  copyId: read(c, ID_KEY[scope2]),
3432
3496
  x: c.x,
@@ -3587,7 +3651,8 @@ var TYPES = [
3587
3651
  { type: "chapter", scope: "chapters", idKey: "chapterId", nameKey: "name" },
3588
3652
  { type: "context", scope: "contexts", idKey: "contextId", nameKey: "name" },
3589
3653
  { type: "swim-lane", scope: "swimLanes", idKey: "swimLaneId", nameKey: "name" },
3590
- { type: "note", scope: "notes", idKey: "noteId", nameKey: "title" }
3654
+ { type: "note", scope: "notes", idKey: "noteId", nameKey: "title" },
3655
+ { type: "flow", scope: "flows", idKey: "flowId", nameKey: "name", nameless: true }
3591
3656
  ];
3592
3657
  var ALIAS_TO_CANONICAL = {
3593
3658
  command: "command",
@@ -3625,7 +3690,9 @@ var ALIAS_TO_CANONICAL = {
3625
3690
  swimLane: "swim-lane",
3626
3691
  swimLanes: "swim-lane",
3627
3692
  note: "note",
3628
- notes: "note"
3693
+ notes: "note",
3694
+ flow: "flow",
3695
+ flows: "flow"
3629
3696
  };
3630
3697
  function resolveType(alias) {
3631
3698
  const canonical = ALIAS_TO_CANONICAL[alias];
@@ -3647,6 +3714,17 @@ type-specific fields (e.g. \`status\` on slices, \`fields\` on stickies).
3647
3714
  Notes use \`title\` instead of \`name\`. The CLI fills in the id and modelId
3648
3715
  automatically — agents do not need to supply them.
3649
3716
 
3717
+ Screens accept an optional \`design\` field — an Excalidraw scene as a JSON
3718
+ array of elements. The CLI converts the array to the Y.Doc representation that
3719
+ the canvas streams in realtime, so passing valid Excalidraw JSON is enough:
3720
+
3721
+ eventmodeler create screen '{"name":"OrderForm","x":0,"y":0,"width":400,"height":300,"fields":[],"design":[{"id":"r1","type":"rectangle","x":10,"y":10,"width":80,"height":40}]}'
3722
+
3723
+ Flows are nameless edges between elements. Provide flowType, sourceId,
3724
+ targetId, and optional handles + mappings:
3725
+
3726
+ eventmodeler create flow '{"flowType":"CommandToEvent","sourceId":"<commandStickyId>","targetId":"<eventStickyId>","sourceHandle":"right-source","targetHandle":"left-target","mappings":[{"sourceFieldId":"<uuid>","targetFieldId":"<uuid>"}]}'
3727
+
3650
3728
  Examples:
3651
3729
  eventmodeler create slice '{"name":"PlaceOrder","x":0,"y":0,"width":300,"height":200}'
3652
3730
  eventmodeler create event '{"name":"OrderPlaced","x":40,"y":40,"width":160,"height":100,"fields":[{"name":"orderId","fieldType":"UUID","isList":false,"isGenerated":true}]}'
@@ -3749,6 +3827,16 @@ fields by design — edit the original and all copies pick up the change. The
3749
3827
  CLI refuses both name-based updates (ambiguous with the original) and
3750
3828
  --id <copy-uuid> updates (would diverge from the original).
3751
3829
 
3830
+ Flows have no addressable name and must be updated via uuid:
3831
+
3832
+ eventmodeler --id <flowId> update flow '<json>'
3833
+
3834
+ Screens accept a typed \`design\` field — an array of Excalidraw elements.
3835
+ The CLI converts it to the Y.Doc array the canvas streams in realtime, so
3836
+ agents can emit Excalidraw JSON directly without worrying about CRDT wire
3837
+ shape. Omitting \`design\` on update wipes the existing design (replace
3838
+ semantics); to preserve it, round-trip via \`show screen ... | jq\`.
3839
+
3752
3840
  This is a *replace*, not a patch: keys present in the previous entry but
3753
3841
  absent in the new JSON are removed.
3754
3842
  `;
@@ -3768,6 +3856,9 @@ function registerUpdateCommands(program) {
3768
3856
  process.exit(2);
3769
3857
  }
3770
3858
  json = args[0];
3859
+ } else if (meta.nameless) {
3860
+ console.error(`${meta.type} entries have no name — address them by uuid: ` + `eventmodeler --id <${meta.idKey}> update ${meta.type} '<json>'`);
3861
+ process.exit(2);
3771
3862
  } else {
3772
3863
  if (args.length < 2) {
3773
3864
  console.error(`Usage: eventmodeler update <type> "<name>" '<json>'`);
@@ -3835,6 +3926,10 @@ function registerRemoveCommands(program) {
3835
3926
  }
3836
3927
  const modelId = resolveModelId(opts.model);
3837
3928
  const idOverride = getGlobalId();
3929
+ if (meta.nameless && !idOverride) {
3930
+ console.error(`${meta.type} entries have no name — address them by uuid: ` + `eventmodeler --id <${meta.idKey}> remove ${meta.type}`);
3931
+ process.exit(2);
3932
+ }
3838
3933
  let summary = `Removed ${meta.type}.`;
3839
3934
  await withDoc(modelId, (doc) => {
3840
3935
  const { id, entry } = resolveEntity(doc, meta.scope, meta.idKey, meta.nameKey, name, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eventmodeler",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "CLI tool for event modeling - explore, design, and generate code from your event models",
5
5
  "type": "module",
6
6
  "repository": {