eventmodeler 0.3.8 → 0.3.9

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.
@@ -330,6 +330,18 @@ function formatSliceXml(model, slice) {
330
330
  : ` <command type="${escapeXml(name)}"/>\n`;
331
331
  xml += ' </when>\n';
332
332
  }
333
+ else if (scenario.whenEvents && scenario.whenEvents.length > 0) {
334
+ xml += ' <when>\n';
335
+ for (const whenEvent of scenario.whenEvents) {
336
+ const evt = model.events.get(whenEvent.eventStickyId);
337
+ const name = evt?.name ?? 'UnknownEvent';
338
+ const values = formatFieldValues(whenEvent.fieldValues);
339
+ xml += values
340
+ ? ` <event type="${escapeXml(name)}">${escapeXmlText(values)}</event>\n`
341
+ : ` <event type="${escapeXml(name)}"/>\n`;
342
+ }
343
+ xml += ' </when>\n';
344
+ }
333
345
  xml += ' <then>\n';
334
346
  if (scenario.then.type === 'error') {
335
347
  xml += ` <error`;
@@ -347,6 +359,14 @@ function formatSliceXml(model, slice) {
347
359
  : ` <event type="${escapeXml(name)}"/>\n`;
348
360
  }
349
361
  }
362
+ else if (scenario.then.type === 'command' && scenario.then.expectedCommand) {
363
+ const cmd = model.commands.get(scenario.then.expectedCommand.commandStickyId);
364
+ const name = cmd?.name ?? 'UnknownCommand';
365
+ const values = formatFieldValues(scenario.then.expectedCommand.fieldValues);
366
+ xml += values
367
+ ? ` <command type="${escapeXml(name)}">${escapeXmlText(values)}</command>\n`
368
+ : ` <command type="${escapeXml(name)}"/>\n`;
369
+ }
350
370
  else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
351
371
  const assertion = scenario.then.readModelAssertion;
352
372
  const rm = model.readModels.get(assertion.readModelStickyId);
@@ -571,6 +591,17 @@ function formatSliceJson(model, slice) {
571
591
  ...(scenario.whenCommand.fieldValues && Object.keys(scenario.whenCommand.fieldValues).length > 0 ? { fieldValues: scenario.whenCommand.fieldValues } : {})
572
592
  };
573
593
  }
594
+ else if (scenario.whenEvents && scenario.whenEvents.length > 0) {
595
+ scenarioObj.when = {
596
+ events: scenario.whenEvents.map(whenEvent => {
597
+ const evt = model.events.get(whenEvent.eventStickyId);
598
+ return {
599
+ eventType: evt?.name ?? 'UnknownEvent',
600
+ ...(whenEvent.fieldValues && Object.keys(whenEvent.fieldValues).length > 0 ? { fieldValues: whenEvent.fieldValues } : {})
601
+ };
602
+ })
603
+ };
604
+ }
574
605
  if (scenario.then.type === 'error') {
575
606
  scenarioObj.then = {
576
607
  type: 'error',
@@ -590,6 +621,14 @@ function formatSliceJson(model, slice) {
590
621
  })
591
622
  };
592
623
  }
624
+ else if (scenario.then.type === 'command' && scenario.then.expectedCommand) {
625
+ const cmd = model.commands.get(scenario.then.expectedCommand.commandStickyId);
626
+ scenarioObj.then = {
627
+ type: 'command',
628
+ commandType: cmd?.name ?? 'UnknownCommand',
629
+ ...(scenario.then.expectedCommand.fieldValues && Object.keys(scenario.then.expectedCommand.fieldValues).length > 0 ? { fieldValues: scenario.then.expectedCommand.fieldValues } : {})
630
+ };
631
+ }
593
632
  else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
594
633
  const assertion = scenario.then.readModelAssertion;
595
634
  const rm = model.readModels.get(assertion.readModelStickyId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eventmodeler",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "CLI tool for interacting with Event Model files - query, update, and export event models from the terminal",
5
5
  "type": "module",
6
6
  "bin": {