@eventcatalog/sdk 2.2.9 → 2.2.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.
package/dist/index.d.mts CHANGED
@@ -464,7 +464,12 @@ declare const _default: (path: string) => {
464
464
  direction?: string;
465
465
  }, options?: {
466
466
  path?: string;
467
- format?: "md" | "mdx";
467
+ format? /**
468
+ * Remove an command by an Event id
469
+ *
470
+ * @param id - The id of the command you want to remove
471
+ *
472
+ */: "md" | "mdx";
468
473
  }) => Promise<void>;
469
474
  /**
470
475
  * Returns a service from EventCatalog
package/dist/index.d.ts CHANGED
@@ -464,7 +464,12 @@ declare const _default: (path: string) => {
464
464
  direction?: string;
465
465
  }, options?: {
466
466
  path?: string;
467
- format?: "md" | "mdx";
467
+ format? /**
468
+ * Remove an command by an Event id
469
+ *
470
+ * @param id - The id of the command you want to remove
471
+ *
472
+ */: "md" | "mdx";
468
473
  }) => Promise<void>;
469
474
  /**
470
475
  * Returns a service from EventCatalog
package/dist/index.js CHANGED
@@ -441,6 +441,8 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
441
441
  };
442
442
  var addMessageToService = (directory) => async (id, direction, event, version) => {
443
443
  let service = await getService(directory)(id, version);
444
+ const servicePath = await getResourcePath(directory, id, version);
445
+ const extension = (0, import_node_path5.extname)(servicePath?.fullPath || "");
444
446
  if (direction === "sends") {
445
447
  if (service.sends === void 0) {
446
448
  service.sends = [];
@@ -471,7 +473,7 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
471
473
  const path4 = existingResource.split("/services")[0];
472
474
  const pathToResource = (0, import_node_path5.join)(path4, "services");
473
475
  await rmServiceById(directory)(id, version);
474
- await writeService(pathToResource)(service);
476
+ await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
475
477
  };
476
478
  var serviceHasVersion = (directory) => async (id, version) => {
477
479
  const file = await findFileById(directory, id, version);
@@ -529,6 +531,8 @@ var domainHasVersion = (directory) => async (id, version) => {
529
531
  };
530
532
  var addServiceToDomain = (directory) => async (id, service, version) => {
531
533
  let domain = await getDomain(directory)(id, version);
534
+ const domainPath = await getResourcePath(directory, id, version);
535
+ const extension = import_node_path6.default.extname(domainPath?.fullPath || "");
532
536
  if (domain.services === void 0) {
533
537
  domain.services = [];
534
538
  }
@@ -538,7 +542,7 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
538
542
  }
539
543
  domain.services.push(service);
540
544
  await rmDomainById(directory)(id, version, true);
541
- await writeDomain(directory)(domain);
545
+ await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
542
546
  };
543
547
 
544
548
  // src/channels.ts
@@ -577,6 +581,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
577
581
  };
578
582
  const { getMessage, rmMessageById, writeMessage } = functions[collection];
579
583
  const message = await getMessage(directory)(_message.id, _message.version);
584
+ const messagePath = await getResourcePath(directory, _message.id, _message.version);
585
+ const extension = (0, import_node_path7.extname)(messagePath?.fullPath || "");
580
586
  if (!message) throw new Error(`Message ${_message.id} with version ${_message.version} not found`);
581
587
  if (message.channels === void 0) {
582
588
  message.channels = [];
@@ -590,7 +596,7 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
590
596
  const path4 = existingResource.split(`/${collection}`)[0];
591
597
  const pathToResource = (0, import_node_path7.join)(path4, collection);
592
598
  await rmMessageById(directory)(_message.id, _message.version, true);
593
- await writeMessage(pathToResource)(message);
599
+ await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
594
600
  };
595
601
 
596
602
  // src/eventcatalog.ts