@eventcatalog/sdk 2.2.8 → 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.
@@ -352,7 +352,7 @@ var queryHasVersion = (directory) => async (id, version) => {
352
352
 
353
353
  // src/services.ts
354
354
  import fs5 from "node:fs/promises";
355
- import { join as join6, dirname as dirname4 } from "node:path";
355
+ import { join as join6, dirname as dirname4, extname } from "node:path";
356
356
  var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
357
357
  var getServices = (directory) => async (options) => getResources(directory, {
358
358
  type: "services",
@@ -411,6 +411,8 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
411
411
  };
412
412
  var addMessageToService = (directory) => async (id, direction, event, version) => {
413
413
  let service = await getService(directory)(id, version);
414
+ const servicePath = await getResourcePath(directory, id, version);
415
+ const extension = extname(servicePath?.fullPath || "");
414
416
  if (direction === "sends") {
415
417
  if (service.sends === void 0) {
416
418
  service.sends = [];
@@ -441,7 +443,7 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
441
443
  const path4 = existingResource.split("/services")[0];
442
444
  const pathToResource = join6(path4, "services");
443
445
  await rmServiceById(directory)(id, version);
444
- await writeService(pathToResource)(service);
446
+ await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
445
447
  };
446
448
  var serviceHasVersion = (directory) => async (id, version) => {
447
449
  const file = await findFileById(directory, id, version);
@@ -499,6 +501,8 @@ var domainHasVersion = (directory) => async (id, version) => {
499
501
  };
500
502
  var addServiceToDomain = (directory) => async (id, service, version) => {
501
503
  let domain = await getDomain(directory)(id, version);
504
+ const domainPath = await getResourcePath(directory, id, version);
505
+ const extension = path.extname(domainPath?.fullPath || "");
502
506
  if (domain.services === void 0) {
503
507
  domain.services = [];
504
508
  }
@@ -508,12 +512,12 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
508
512
  }
509
513
  domain.services.push(service);
510
514
  await rmDomainById(directory)(id, version, true);
511
- await writeDomain(directory)(domain);
515
+ await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
512
516
  };
513
517
 
514
518
  // src/channels.ts
515
519
  import fs7 from "node:fs/promises";
516
- import { join as join8 } from "node:path";
520
+ import { join as join8, extname as extname2 } from "node:path";
517
521
  var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
518
522
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
519
523
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
@@ -547,6 +551,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
547
551
  };
548
552
  const { getMessage, rmMessageById, writeMessage } = functions[collection];
549
553
  const message = await getMessage(directory)(_message.id, _message.version);
554
+ const messagePath = await getResourcePath(directory, _message.id, _message.version);
555
+ const extension = extname2(messagePath?.fullPath || "");
550
556
  if (!message) throw new Error(`Message ${_message.id} with version ${_message.version} not found`);
551
557
  if (message.channels === void 0) {
552
558
  message.channels = [];
@@ -560,7 +566,7 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
560
566
  const path4 = existingResource.split(`/${collection}`)[0];
561
567
  const pathToResource = join8(path4, collection);
562
568
  await rmMessageById(directory)(_message.id, _message.version, true);
563
- await writeMessage(pathToResource)(message);
569
+ await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
564
570
  };
565
571
 
566
572
  // src/custom-docs.ts