@eventcatalog/sdk 2.8.2 → 2.8.4

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 (64) hide show
  1. package/dist/channels.js +19 -18
  2. package/dist/channels.js.map +1 -1
  3. package/dist/channels.mjs +14 -13
  4. package/dist/channels.mjs.map +1 -1
  5. package/dist/commands.js +14 -13
  6. package/dist/commands.js.map +1 -1
  7. package/dist/commands.mjs +12 -11
  8. package/dist/commands.mjs.map +1 -1
  9. package/dist/containers.js +14 -13
  10. package/dist/containers.js.map +1 -1
  11. package/dist/containers.mjs +12 -11
  12. package/dist/containers.mjs.map +1 -1
  13. package/dist/custom-docs.js +8 -7
  14. package/dist/custom-docs.js.map +1 -1
  15. package/dist/custom-docs.mjs +7 -6
  16. package/dist/custom-docs.mjs.map +1 -1
  17. package/dist/data-stores.js +14 -13
  18. package/dist/data-stores.js.map +1 -1
  19. package/dist/data-stores.mjs +12 -11
  20. package/dist/data-stores.mjs.map +1 -1
  21. package/dist/domains.js +19 -18
  22. package/dist/domains.js.map +1 -1
  23. package/dist/domains.mjs +19 -18
  24. package/dist/domains.mjs.map +1 -1
  25. package/dist/entities.js +13 -12
  26. package/dist/entities.js.map +1 -1
  27. package/dist/entities.mjs +12 -11
  28. package/dist/entities.mjs.map +1 -1
  29. package/dist/eventcatalog.js +260 -197
  30. package/dist/eventcatalog.js.map +1 -1
  31. package/dist/eventcatalog.mjs +232 -169
  32. package/dist/eventcatalog.mjs.map +1 -1
  33. package/dist/events.js +14 -13
  34. package/dist/events.js.map +1 -1
  35. package/dist/events.mjs +12 -11
  36. package/dist/events.mjs.map +1 -1
  37. package/dist/index.d.mts +26 -12
  38. package/dist/index.d.ts +26 -12
  39. package/dist/index.js +260 -197
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +232 -169
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/messages.js +13 -12
  44. package/dist/messages.js.map +1 -1
  45. package/dist/messages.mjs +11 -10
  46. package/dist/messages.mjs.map +1 -1
  47. package/dist/queries.js +14 -13
  48. package/dist/queries.js.map +1 -1
  49. package/dist/queries.mjs +12 -11
  50. package/dist/queries.mjs.map +1 -1
  51. package/dist/services.d.mts +25 -1
  52. package/dist/services.d.ts +25 -1
  53. package/dist/services.js +66 -27
  54. package/dist/services.js.map +1 -1
  55. package/dist/services.mjs +60 -22
  56. package/dist/services.mjs.map +1 -1
  57. package/dist/teams.js +13 -12
  58. package/dist/teams.js.map +1 -1
  59. package/dist/teams.mjs +8 -7
  60. package/dist/teams.mjs.map +1 -1
  61. package/dist/types.d.d.mts +2 -0
  62. package/dist/types.d.d.ts +2 -0
  63. package/dist/types.d.js.map +1 -1
  64. package/package.json +2 -2
@@ -35,14 +35,14 @@ __export(eventcatalog_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(eventcatalog_exports);
37
37
  var import_fs = __toESM(require("fs"));
38
- var import_node_path17 = __toESM(require("path"));
38
+ var import_node_path18 = __toESM(require("path"));
39
39
 
40
40
  // src/index.ts
41
- var import_node_path16 = require("path");
41
+ var import_node_path17 = require("path");
42
42
 
43
43
  // src/events.ts
44
44
  var import_promises2 = __toESM(require("fs/promises"));
45
- var import_node_path3 = require("path");
45
+ var import_node_path4 = require("path");
46
46
 
47
47
  // src/internal/utils.ts
48
48
  var import_glob = require("glob");
@@ -59,13 +59,13 @@ var versionExists = async (catalogDir, id, version) => {
59
59
  var findFileById = async (catalogDir, id, version) => {
60
60
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
61
61
  const matchedFiles = await searchFilesForId(files, id) || [];
62
- const latestVersion = matchedFiles.find((path5) => !path5.includes("versioned"));
62
+ const latestVersion = matchedFiles.find((path6) => !path6.includes("versioned"));
63
63
  if (!version) {
64
64
  return latestVersion;
65
65
  }
66
- const parsedFiles = matchedFiles.map((path5) => {
67
- const { data } = import_gray_matter.default.read(path5);
68
- return { ...data, path: path5 };
66
+ const parsedFiles = matchedFiles.map((path6) => {
67
+ const { data } = import_gray_matter.default.read(path6);
68
+ return { ...data, path: path6 };
69
69
  });
70
70
  const semverRange = (0, import_semver.validRange)(version);
71
71
  if (semverRange && (0, import_semver.valid)(version)) {
@@ -106,8 +106,8 @@ var getFiles = async (pattern, ignore = "") => {
106
106
  );
107
107
  }
108
108
  };
109
- var readMdxFile = async (path5) => {
110
- const { data } = import_gray_matter.default.read(path5);
109
+ var readMdxFile = async (path6) => {
110
+ const { data } = import_gray_matter.default.read(path6);
111
111
  const { markdown, ...frontmatter } = data;
112
112
  return { ...frontmatter, markdown };
113
113
  };
@@ -160,6 +160,7 @@ var import_node_fs2 = __toESM(require("fs"));
160
160
  var import_semver2 = require("semver");
161
161
  var import_proper_lockfile = require("proper-lockfile");
162
162
  var import_node_path2 = require("path");
163
+ var import_node_path3 = __toESM(require("path"));
163
164
  var versionResource = async (catalogDir, id) => {
164
165
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
165
166
  const matchedFiles = await searchFilesForId(files, id);
@@ -199,8 +200,8 @@ var writeResource = async (catalogDir, resource, options = {
199
200
  versionExistingContent: false,
200
201
  format: "mdx"
201
202
  }) => {
202
- const path5 = options.path || `/${resource.id}`;
203
- const fullPath = (0, import_path.join)(catalogDir, path5);
203
+ const path6 = options.path || `/${resource.id}`;
204
+ const fullPath = (0, import_path.join)(catalogDir, path6);
204
205
  const format = options.format || "mdx";
205
206
  import_node_fs2.default.mkdirSync(fullPath, { recursive: true });
206
207
  const lockPath = (0, import_path.join)(fullPath, `index.${format}`);
@@ -266,6 +267,11 @@ var getResourcePath = async (catalogDir, id, version) => {
266
267
  directory: (0, import_path.dirname)(file.replace(catalogDir, ""))
267
268
  };
268
269
  };
270
+ var getResourceFolderName = async (catalogDir, id, version) => {
271
+ const paths = await getResourcePath(catalogDir, id, version);
272
+ if (!paths) return;
273
+ return paths?.directory.split(import_node_path3.default.sep).filter(Boolean).pop();
274
+ };
269
275
  var toResource = async (catalogDir, rawContents) => {
270
276
  const { data, content } = (0, import_gray_matter2.default)(rawContents);
271
277
  return {
@@ -327,16 +333,16 @@ var rmResourceById = async (catalogDir, id, version, options) => {
327
333
  );
328
334
  }
329
335
  };
330
- var waitForFileRemoval = async (path5, maxRetries = 50, delay = 10) => {
336
+ var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
331
337
  for (let i = 0; i < maxRetries; i++) {
332
338
  try {
333
- await import_promises.default.access(path5);
339
+ await import_promises.default.access(path6);
334
340
  await new Promise((resolve2) => setTimeout(resolve2, delay));
335
341
  } catch (error) {
336
342
  return;
337
343
  }
338
344
  }
339
- throw new Error(`File/directory ${path5} was not removed after ${maxRetries} attempts`);
345
+ throw new Error(`File/directory ${path6} was not removed after ${maxRetries} attempts`);
340
346
  };
341
347
  var addFileToResource = async (catalogDir, id, file, version) => {
342
348
  const pathToResource = await findFileById(catalogDir, id, version);
@@ -380,11 +386,11 @@ var writeEventToService = (directory) => async (event, service, options = { path
380
386
  throw new Error("Service not found");
381
387
  }
382
388
  let pathForEvent = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/events` : `${resourcePath.directory}/events`;
383
- pathForEvent = (0, import_node_path3.join)(pathForEvent, event.id);
389
+ pathForEvent = (0, import_node_path4.join)(pathForEvent, event.id);
384
390
  await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
385
391
  };
386
- var rmEvent = (directory) => async (path5) => {
387
- await import_promises2.default.rm((0, import_node_path3.join)(directory, path5), { recursive: true });
392
+ var rmEvent = (directory) => async (path6) => {
393
+ await import_promises2.default.rm((0, import_node_path4.join)(directory, path6), { recursive: true });
388
394
  };
389
395
  var rmEventById = (directory) => async (id, version, persistFiles) => {
390
396
  await rmResourceById(directory, id, version, { type: "event", persistFiles });
@@ -401,7 +407,7 @@ var eventHasVersion = (directory) => async (id, version) => {
401
407
 
402
408
  // src/commands.ts
403
409
  var import_promises3 = __toESM(require("fs/promises"));
404
- var import_node_path4 = require("path");
410
+ var import_node_path5 = require("path");
405
411
  var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
406
412
  var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
407
413
  var writeCommand = (directory) => async (command, options = {
@@ -416,11 +422,11 @@ var writeCommandToService = (directory) => async (command, service, options = {
416
422
  throw new Error("Service not found");
417
423
  }
418
424
  let pathForCommand = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/commands` : `${resourcePath.directory}/commands`;
419
- pathForCommand = (0, import_node_path4.join)(pathForCommand, command.id);
425
+ pathForCommand = (0, import_node_path5.join)(pathForCommand, command.id);
420
426
  await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
421
427
  };
422
- var rmCommand = (directory) => async (path5) => {
423
- await import_promises3.default.rm((0, import_node_path4.join)(directory, path5), { recursive: true });
428
+ var rmCommand = (directory) => async (path6) => {
429
+ await import_promises3.default.rm((0, import_node_path5.join)(directory, path6), { recursive: true });
424
430
  };
425
431
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
426
432
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
@@ -435,7 +441,7 @@ var commandHasVersion = (directory) => async (id, version) => {
435
441
 
436
442
  // src/queries.ts
437
443
  var import_promises4 = __toESM(require("fs/promises"));
438
- var import_node_path5 = require("path");
444
+ var import_node_path6 = require("path");
439
445
  var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
440
446
  var writeQuery = (directory) => async (query, options = {
441
447
  path: "",
@@ -450,11 +456,11 @@ var writeQueryToService = (directory) => async (query, service, options = { path
450
456
  throw new Error("Service not found");
451
457
  }
452
458
  let pathForQuery = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/queries` : `${resourcePath.directory}/queries`;
453
- pathForQuery = (0, import_node_path5.join)(pathForQuery, query.id);
459
+ pathForQuery = (0, import_node_path6.join)(pathForQuery, query.id);
454
460
  await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
455
461
  };
456
- var rmQuery = (directory) => async (path5) => {
457
- await import_promises4.default.rm((0, import_node_path5.join)(directory, path5), { recursive: true });
462
+ var rmQuery = (directory) => async (path6) => {
463
+ await import_promises4.default.rm((0, import_node_path6.join)(directory, path6), { recursive: true });
458
464
  };
459
465
  var rmQueryById = (directory) => async (id, version, persistFiles) => {
460
466
  await rmResourceById(directory, id, version, { type: "query", persistFiles });
@@ -471,10 +477,10 @@ var queryHasVersion = (directory) => async (id, version) => {
471
477
 
472
478
  // src/services.ts
473
479
  var import_promises5 = __toESM(require("fs/promises"));
474
- var import_node_path6 = require("path");
480
+ var import_node_path7 = require("path");
475
481
  var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
476
- var getServiceByPath = (directory) => async (path5) => {
477
- const service = await getResource(directory, void 0, void 0, { type: "service" }, path5);
482
+ var getServiceByPath = (directory) => async (path6) => {
483
+ const service = await getResource(directory, void 0, void 0, { type: "service" }, path6);
478
484
  return service;
479
485
  };
480
486
  var getServices = (directory) => async (options) => getResources(directory, {
@@ -498,17 +504,17 @@ var writeService = (directory) => async (service, options = {
498
504
  };
499
505
  var writeVersionedService = (directory) => async (service) => {
500
506
  const resource = { ...service };
501
- const path5 = getVersionedDirectory(service.id, service.version);
502
- return await writeService(directory)(resource, { path: path5 });
507
+ const path6 = getVersionedDirectory(service.id, service.version);
508
+ return await writeService(directory)(resource, { path: path6 });
503
509
  };
504
510
  var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
505
511
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
506
- pathForService = (0, import_node_path6.join)(pathForService, service.id);
512
+ pathForService = (0, import_node_path7.join)(pathForService, service.id);
507
513
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
508
514
  };
509
515
  var versionService = (directory) => async (id) => versionResource(directory, id);
510
- var rmService = (directory) => async (path5) => {
511
- await import_promises5.default.rm((0, import_node_path6.join)(directory, path5), { recursive: true });
516
+ var rmService = (directory) => async (path6) => {
517
+ await import_promises5.default.rm((0, import_node_path7.join)(directory, path6), { recursive: true });
512
518
  };
513
519
  var rmServiceById = (directory) => async (id, version, persistFiles) => {
514
520
  await rmResourceById(directory, id, version, { type: "service", persistFiles });
@@ -535,7 +541,7 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
535
541
  throw new Error(`Specification file name for ${fileName} is undefined`);
536
542
  }
537
543
  const rawFile = await getFileFromResource(directory, id, { fileName }, version);
538
- return { key, content: rawFile, fileName, path: (0, import_node_path6.join)((0, import_node_path6.dirname)(filePathToService), fileName) };
544
+ return { key, content: rawFile, fileName, path: (0, import_node_path7.join)((0, import_node_path7.dirname)(filePathToService), fileName) };
539
545
  });
540
546
  specs = await Promise.all(getSpecs);
541
547
  }
@@ -544,7 +550,7 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
544
550
  var addMessageToService = (directory) => async (id, direction, event, version) => {
545
551
  let service = await getService(directory)(id, version);
546
552
  const servicePath = await getResourcePath(directory, id, version);
547
- const extension = (0, import_node_path6.extname)(servicePath?.fullPath || "");
553
+ const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
548
554
  if (direction === "sends") {
549
555
  if (service.sends === void 0) {
550
556
  service.sends = [];
@@ -572,8 +578,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
572
578
  if (!existingResource) {
573
579
  throw new Error(`Cannot find service ${id} in the catalog`);
574
580
  }
575
- const path5 = existingResource.split(/[\\/]+services/)[0];
576
- const pathToResource = (0, import_node_path6.join)(path5, "services");
581
+ const path6 = existingResource.split(/[\\/]+services/)[0];
582
+ const pathToResource = (0, import_node_path7.join)(path6, "services");
577
583
  await rmServiceById(directory)(id, version);
578
584
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
579
585
  };
@@ -581,9 +587,9 @@ var serviceHasVersion = (directory) => async (id, version) => {
581
587
  const file = await findFileById(directory, id, version);
582
588
  return !!file;
583
589
  };
584
- var isService = (directory) => async (path5) => {
585
- const service = await getServiceByPath(directory)(path5);
586
- const relativePath = (0, import_node_path6.relative)(directory, path5);
590
+ var isService = (directory) => async (path6) => {
591
+ const service = await getServiceByPath(directory)(path6);
592
+ const relativePath = (0, import_node_path7.relative)(directory, path6);
587
593
  const segments = relativePath.split(/[/\\]+/);
588
594
  return !!service && segments.includes("services");
589
595
  };
@@ -591,7 +597,7 @@ var toService = (directory) => async (file) => toResource(directory, file);
591
597
  var addEntityToService = (directory) => async (id, entity, version) => {
592
598
  let service = await getService(directory)(id, version);
593
599
  const servicePath = await getResourcePath(directory, id, version);
594
- const extension = (0, import_node_path6.extname)(servicePath?.fullPath || "");
600
+ const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
595
601
  if (service.entities === void 0) {
596
602
  service.entities = [];
597
603
  }
@@ -605,15 +611,51 @@ var addEntityToService = (directory) => async (id, entity, version) => {
605
611
  if (!existingResource) {
606
612
  throw new Error(`Cannot find service ${id} in the catalog`);
607
613
  }
608
- const path5 = existingResource.split(/[\\/]+services/)[0];
609
- const pathToResource = (0, import_node_path6.join)(path5, "services");
614
+ const path6 = existingResource.split(/[\\/]+services/)[0];
615
+ const pathToResource = (0, import_node_path7.join)(path6, "services");
616
+ await rmServiceById(directory)(id, version);
617
+ await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
618
+ };
619
+ var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
620
+ let service = await getService(directory)(id, version);
621
+ const servicePath = await getResourcePath(directory, id, version);
622
+ const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
623
+ if (operation === "writesTo") {
624
+ if (service.writesTo === void 0) {
625
+ service.writesTo = [];
626
+ }
627
+ for (let i = 0; i < service.writesTo.length; i++) {
628
+ if (service.writesTo[i].id === dataStore.id && service.writesTo[i].version === dataStore.version) {
629
+ return;
630
+ }
631
+ }
632
+ service.writesTo.push({ id: dataStore.id, version: dataStore.version });
633
+ } else if (operation === "readsFrom") {
634
+ if (service.readsFrom === void 0) {
635
+ service.readsFrom = [];
636
+ }
637
+ for (let i = 0; i < service.readsFrom.length; i++) {
638
+ if (service.readsFrom[i].id === dataStore.id && service.readsFrom[i].version === dataStore.version) {
639
+ return;
640
+ }
641
+ }
642
+ service.readsFrom.push({ id: dataStore.id, version: dataStore.version });
643
+ } else {
644
+ throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
645
+ }
646
+ const existingResource = await findFileById(directory, id, version);
647
+ if (!existingResource) {
648
+ throw new Error(`Cannot find service ${id} in the catalog`);
649
+ }
650
+ const path6 = existingResource.split(/[\\/]+services/)[0];
651
+ const pathToResource = (0, import_node_path7.join)(path6, "services");
610
652
  await rmServiceById(directory)(id, version);
611
653
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
612
654
  };
613
655
 
614
656
  // src/domains.ts
615
657
  var import_promises6 = __toESM(require("fs/promises"));
616
- var import_node_path7 = __toESM(require("path"));
658
+ var import_node_path8 = __toESM(require("path"));
617
659
  var import_node_fs3 = __toESM(require("fs"));
618
660
  var import_gray_matter3 = __toESM(require("gray-matter"));
619
661
  var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
@@ -638,8 +680,8 @@ var writeDomain = (directory) => async (domain, options = {
638
680
  return await writeResource(directory, resource, { ...options, type: "domain" });
639
681
  };
640
682
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
641
- var rmDomain = (directory) => async (path5) => {
642
- await import_promises6.default.rm((0, import_node_path7.join)(directory, path5), { recursive: true });
683
+ var rmDomain = (directory) => async (path6) => {
684
+ await import_promises6.default.rm((0, import_node_path8.join)(directory, path6), { recursive: true });
643
685
  };
644
686
  var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
645
687
  var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -651,7 +693,7 @@ var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguage
651
693
  };
652
694
  var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
653
695
  const pathToDomain = await findFileById(directory, id, version) || "";
654
- const pathToUbiquitousLanguage = import_node_path7.default.join(import_node_path7.default.dirname(pathToDomain), "ubiquitous-language.mdx");
696
+ const pathToUbiquitousLanguage = import_node_path8.default.join(import_node_path8.default.dirname(pathToDomain), "ubiquitous-language.mdx");
655
697
  const fileExists = import_node_fs3.default.existsSync(pathToUbiquitousLanguage);
656
698
  if (!fileExists) {
657
699
  return void 0;
@@ -666,7 +708,7 @@ var domainHasVersion = (directory) => async (id, version) => {
666
708
  var addServiceToDomain = (directory) => async (id, service, version) => {
667
709
  let domain = await getDomain(directory)(id, version);
668
710
  const domainPath = await getResourcePath(directory, id, version);
669
- const extension = import_node_path7.default.extname(domainPath?.fullPath || "");
711
+ const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
670
712
  if (domain.services === void 0) {
671
713
  domain.services = [];
672
714
  }
@@ -681,7 +723,7 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
681
723
  var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
682
724
  let domain = await getDomain(directory)(id, version);
683
725
  const domainPath = await getResourcePath(directory, id, version);
684
- const extension = import_node_path7.default.extname(domainPath?.fullPath || "");
726
+ const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
685
727
  if (domain.domains === void 0) {
686
728
  domain.domains = [];
687
729
  }
@@ -696,7 +738,7 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
696
738
  var addEntityToDomain = (directory) => async (id, entity, version) => {
697
739
  let domain = await getDomain(directory)(id, version);
698
740
  const domainPath = await getResourcePath(directory, id, version);
699
- const extension = import_node_path7.default.extname(domainPath?.fullPath || "");
741
+ const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
700
742
  if (domain.entities === void 0) {
701
743
  domain.entities = [];
702
744
  }
@@ -711,12 +753,12 @@ var addEntityToDomain = (directory) => async (id, entity, version) => {
711
753
 
712
754
  // src/channels.ts
713
755
  var import_promises7 = __toESM(require("fs/promises"));
714
- var import_node_path8 = require("path");
756
+ var import_node_path9 = require("path");
715
757
  var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
716
758
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
717
759
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
718
- var rmChannel = (directory) => async (path5) => {
719
- await import_promises7.default.rm((0, import_node_path8.join)(directory, path5), { recursive: true });
760
+ var rmChannel = (directory) => async (path6) => {
761
+ await import_promises7.default.rm((0, import_node_path9.join)(directory, path6), { recursive: true });
720
762
  };
721
763
  var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
722
764
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
@@ -746,7 +788,7 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
746
788
  const { getMessage, rmMessageById, writeMessage } = functions[collection];
747
789
  const message = await getMessage(directory)(_message.id, _message.version);
748
790
  const messagePath = await getResourcePath(directory, _message.id, _message.version);
749
- const extension = (0, import_node_path8.extname)(messagePath?.fullPath || "");
791
+ const extension = (0, import_node_path9.extname)(messagePath?.fullPath || "");
750
792
  if (!message) throw new Error(`Message ${_message.id} with version ${_message.version} not found`);
751
793
  if (message.channels === void 0) {
752
794
  message.channels = [];
@@ -757,18 +799,18 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
757
799
  if (!existingResource) {
758
800
  throw new Error(`Cannot find message ${id} in the catalog`);
759
801
  }
760
- const path5 = existingResource.split(`/[\\/]+${collection}`)[0];
761
- const pathToResource = (0, import_node_path8.join)(path5, collection);
802
+ const path6 = existingResource.split(`/[\\/]+${collection}`)[0];
803
+ const pathToResource = (0, import_node_path9.join)(path6, collection);
762
804
  await rmMessageById(directory)(_message.id, _message.version, true);
763
805
  await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
764
806
  };
765
807
 
766
808
  // src/messages.ts
767
- var import_node_path9 = require("path");
809
+ var import_node_path10 = require("path");
768
810
  var import_gray_matter4 = __toESM(require("gray-matter"));
769
811
  var import_semver3 = require("semver");
770
- var getMessageBySchemaPath = (directory) => async (path5, options) => {
771
- const pathToMessage = (0, import_node_path9.dirname)(path5);
812
+ var getMessageBySchemaPath = (directory) => async (path6, options) => {
813
+ const pathToMessage = (0, import_node_path10.dirname)(path6);
772
814
  try {
773
815
  const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
774
816
  if (!files || files.length === 0) {
@@ -840,18 +882,18 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
840
882
  }
841
883
  return { producers, consumers };
842
884
  };
843
- var getConsumersOfSchema = (directory) => async (path5) => {
885
+ var getConsumersOfSchema = (directory) => async (path6) => {
844
886
  try {
845
- const message = await getMessageBySchemaPath(directory)(path5);
887
+ const message = await getMessageBySchemaPath(directory)(path6);
846
888
  const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
847
889
  return consumers;
848
890
  } catch (error) {
849
891
  return [];
850
892
  }
851
893
  };
852
- var getProducersOfSchema = (directory) => async (path5) => {
894
+ var getProducersOfSchema = (directory) => async (path6) => {
853
895
  try {
854
- const message = await getMessageBySchemaPath(directory)(path5);
896
+ const message = await getMessageBySchemaPath(directory)(path6);
855
897
  const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
856
898
  return producers;
857
899
  } catch (error) {
@@ -860,13 +902,13 @@ var getProducersOfSchema = (directory) => async (path5) => {
860
902
  };
861
903
 
862
904
  // src/custom-docs.ts
863
- var import_node_path10 = __toESM(require("path"));
905
+ var import_node_path11 = __toESM(require("path"));
864
906
  var import_node_fs4 = __toESM(require("fs"));
865
907
  var import_promises8 = __toESM(require("fs/promises"));
866
908
  var import_gray_matter5 = __toESM(require("gray-matter"));
867
909
  var import_slugify = __toESM(require("slugify"));
868
910
  var getCustomDoc = (directory) => async (filePath) => {
869
- const fullPath = import_node_path10.default.join(directory, filePath);
911
+ const fullPath = import_node_path11.default.join(directory, filePath);
870
912
  const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
871
913
  const fileExists = import_node_fs4.default.existsSync(fullPathWithExtension);
872
914
  if (!fileExists) {
@@ -885,26 +927,26 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
885
927
  const { fileName, ...rest } = customDoc;
886
928
  const name = fileName || (0, import_slugify.default)(customDoc.title, { lower: true });
887
929
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
888
- const fullPath = import_node_path10.default.join(directory, options.path || "", withExtension);
889
- import_node_fs4.default.mkdirSync(import_node_path10.default.dirname(fullPath), { recursive: true });
930
+ const fullPath = import_node_path11.default.join(directory, options.path || "", withExtension);
931
+ import_node_fs4.default.mkdirSync(import_node_path11.default.dirname(fullPath), { recursive: true });
890
932
  const document = import_gray_matter5.default.stringify(customDoc.markdown.trim(), rest);
891
933
  import_node_fs4.default.writeFileSync(fullPath, document);
892
934
  };
893
935
  var rmCustomDoc = (directory) => async (filePath) => {
894
936
  const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
895
- await import_promises8.default.rm((0, import_node_path10.join)(directory, withExtension), { recursive: true });
937
+ await import_promises8.default.rm((0, import_node_path11.join)(directory, withExtension), { recursive: true });
896
938
  };
897
939
 
898
940
  // src/teams.ts
899
941
  var import_promises9 = __toESM(require("fs/promises"));
900
942
  var import_node_fs6 = __toESM(require("fs"));
901
- var import_node_path12 = require("path");
943
+ var import_node_path13 = require("path");
902
944
  var import_gray_matter7 = __toESM(require("gray-matter"));
903
- var import_node_path13 = __toESM(require("path"));
945
+ var import_node_path14 = __toESM(require("path"));
904
946
 
905
947
  // src/users.ts
906
948
  var import_node_fs5 = __toESM(require("fs"));
907
- var import_node_path11 = require("path");
949
+ var import_node_path12 = require("path");
908
950
  var import_gray_matter6 = __toESM(require("gray-matter"));
909
951
  var getUser = (catalogDir) => async (id) => {
910
952
  const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
@@ -942,11 +984,11 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
942
984
  }
943
985
  const { markdown, ...frontmatter } = resource;
944
986
  const document = import_gray_matter6.default.stringify(markdown, frontmatter);
945
- import_node_fs5.default.mkdirSync((0, import_node_path11.join)(catalogDir, ""), { recursive: true });
946
- import_node_fs5.default.writeFileSync((0, import_node_path11.join)(catalogDir, "", `${resource.id}.mdx`), document);
987
+ import_node_fs5.default.mkdirSync((0, import_node_path12.join)(catalogDir, ""), { recursive: true });
988
+ import_node_fs5.default.writeFileSync((0, import_node_path12.join)(catalogDir, "", `${resource.id}.mdx`), document);
947
989
  };
948
990
  var rmUserById = (catalogDir) => async (id) => {
949
- import_node_fs5.default.rmSync((0, import_node_path11.join)(catalogDir, `${id}.mdx`), { recursive: true });
991
+ import_node_fs5.default.rmSync((0, import_node_path12.join)(catalogDir, `${id}.mdx`), { recursive: true });
950
992
  };
951
993
 
952
994
  // src/teams.ts
@@ -984,11 +1026,11 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
984
1026
  }
985
1027
  const { markdown, ...frontmatter } = resource;
986
1028
  const document = import_gray_matter7.default.stringify(markdown, frontmatter);
987
- import_node_fs6.default.mkdirSync((0, import_node_path12.join)(catalogDir, ""), { recursive: true });
988
- import_node_fs6.default.writeFileSync((0, import_node_path12.join)(catalogDir, "", `${resource.id}.mdx`), document);
1029
+ import_node_fs6.default.mkdirSync((0, import_node_path13.join)(catalogDir, ""), { recursive: true });
1030
+ import_node_fs6.default.writeFileSync((0, import_node_path13.join)(catalogDir, "", `${resource.id}.mdx`), document);
989
1031
  };
990
1032
  var rmTeamById = (catalogDir) => async (id) => {
991
- await import_promises9.default.rm((0, import_node_path12.join)(catalogDir, `${id}.mdx`), { recursive: true });
1033
+ await import_promises9.default.rm((0, import_node_path13.join)(catalogDir, `${id}.mdx`), { recursive: true });
992
1034
  };
993
1035
  var getOwnersForResource = (catalogDir) => async (id, version) => {
994
1036
  const resource = await getResource(catalogDir, id, version);
@@ -996,11 +1038,11 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
996
1038
  if (!resource) return [];
997
1039
  if (!resource.owners) return [];
998
1040
  for (const owner of resource.owners) {
999
- const team = await getTeam(import_node_path13.default.join(catalogDir, "teams"))(owner);
1041
+ const team = await getTeam(import_node_path14.default.join(catalogDir, "teams"))(owner);
1000
1042
  if (team) {
1001
1043
  owners.push(team);
1002
1044
  } else {
1003
- const user = await getUser(import_node_path13.default.join(catalogDir, "users"))(owner);
1045
+ const user = await getUser(import_node_path14.default.join(catalogDir, "users"))(owner);
1004
1046
  if (user) {
1005
1047
  owners.push(user);
1006
1048
  }
@@ -1011,7 +1053,7 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
1011
1053
 
1012
1054
  // src/entities.ts
1013
1055
  var import_promises10 = __toESM(require("fs/promises"));
1014
- var import_node_path14 = require("path");
1056
+ var import_node_path15 = require("path");
1015
1057
  var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
1016
1058
  var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
1017
1059
  var writeEntity = (directory) => async (entity, options = {
@@ -1019,8 +1061,8 @@ var writeEntity = (directory) => async (entity, options = {
1019
1061
  override: false,
1020
1062
  format: "mdx"
1021
1063
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1022
- var rmEntity = (directory) => async (path5) => {
1023
- await import_promises10.default.rm((0, import_node_path14.join)(directory, path5), { recursive: true });
1064
+ var rmEntity = (directory) => async (path6) => {
1065
+ await import_promises10.default.rm((0, import_node_path15.join)(directory, path6), { recursive: true });
1024
1066
  };
1025
1067
  var rmEntityById = (directory) => async (id, version, persistFiles) => {
1026
1068
  await rmResourceById(directory, id, version, { type: "entity", persistFiles });
@@ -1033,7 +1075,7 @@ var entityHasVersion = (directory) => async (id, version) => {
1033
1075
 
1034
1076
  // src/containers.ts
1035
1077
  var import_promises11 = __toESM(require("fs/promises"));
1036
- var import_node_path15 = require("path");
1078
+ var import_node_path16 = require("path");
1037
1079
  var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
1038
1080
  var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
1039
1081
  var writeContainer = (directory) => async (data, options = {
@@ -1042,8 +1084,8 @@ var writeContainer = (directory) => async (data, options = {
1042
1084
  format: "mdx"
1043
1085
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1044
1086
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1045
- var rmContainer = (directory) => async (path5) => {
1046
- await import_promises11.default.rm((0, import_node_path15.join)(directory, path5), { recursive: true });
1087
+ var rmContainer = (directory) => async (path6) => {
1088
+ await import_promises11.default.rm((0, import_node_path16.join)(directory, path6), { recursive: true });
1047
1089
  };
1048
1090
  var rmContainerById = (directory) => async (id, version, persistFiles) => {
1049
1091
  await rmResourceById(directory, id, version, { type: "container", persistFiles });
@@ -1059,7 +1101,7 @@ var writeContainerToService = (directory) => async (container, service, options
1059
1101
  throw new Error("Service not found");
1060
1102
  }
1061
1103
  let pathForContainer = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/containers` : `${resourcePath.directory}/containers`;
1062
- pathForContainer = (0, import_node_path15.join)(pathForContainer, container.id);
1104
+ pathForContainer = (0, import_node_path16.join)(pathForContainer, container.id);
1063
1105
  await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
1064
1106
  };
1065
1107
 
@@ -1075,7 +1117,7 @@ var addFileToDataStore = addFileToContainer;
1075
1117
  var writeDataStoreToService = writeContainerToService;
1076
1118
 
1077
1119
  // src/index.ts
1078
- var index_default = (path5) => {
1120
+ var index_default = (path6) => {
1079
1121
  return {
1080
1122
  /**
1081
1123
  * Returns an events from EventCatalog
@@ -1083,13 +1125,13 @@ var index_default = (path5) => {
1083
1125
  * @param version - Optional id of the version to get (supports semver)
1084
1126
  * @returns Event|Undefined
1085
1127
  */
1086
- getEvent: getEvent((0, import_node_path16.join)(path5)),
1128
+ getEvent: getEvent((0, import_node_path17.join)(path6)),
1087
1129
  /**
1088
1130
  * Returns all events from EventCatalog
1089
1131
  * @param latestOnly - optional boolean, set to true to get only latest versions
1090
1132
  * @returns Event[]|Undefined
1091
1133
  */
1092
- getEvents: getEvents((0, import_node_path16.join)(path5)),
1134
+ getEvents: getEvents((0, import_node_path17.join)(path6)),
1093
1135
  /**
1094
1136
  * Adds an event to EventCatalog
1095
1137
  *
@@ -1097,7 +1139,7 @@ var index_default = (path5) => {
1097
1139
  * @param options - Optional options to write the event
1098
1140
  *
1099
1141
  */
1100
- writeEvent: writeEvent((0, import_node_path16.join)(path5, "events")),
1142
+ writeEvent: writeEvent((0, import_node_path17.join)(path6, "events")),
1101
1143
  /**
1102
1144
  * Adds an event to a service in EventCatalog
1103
1145
  *
@@ -1106,26 +1148,26 @@ var index_default = (path5) => {
1106
1148
  * @param options - Optional options to write the event
1107
1149
  *
1108
1150
  */
1109
- writeEventToService: writeEventToService((0, import_node_path16.join)(path5)),
1151
+ writeEventToService: writeEventToService((0, import_node_path17.join)(path6)),
1110
1152
  /**
1111
1153
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1112
1154
  *
1113
1155
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1114
1156
  *
1115
1157
  */
1116
- rmEvent: rmEvent((0, import_node_path16.join)(path5, "events")),
1158
+ rmEvent: rmEvent((0, import_node_path17.join)(path6, "events")),
1117
1159
  /**
1118
1160
  * Remove an event by an Event id
1119
1161
  *
1120
1162
  * @param id - The id of the event you want to remove
1121
1163
  *
1122
1164
  */
1123
- rmEventById: rmEventById((0, import_node_path16.join)(path5)),
1165
+ rmEventById: rmEventById((0, import_node_path17.join)(path6)),
1124
1166
  /**
1125
1167
  * Moves a given event id to the version directory
1126
1168
  * @param directory
1127
1169
  */
1128
- versionEvent: versionEvent((0, import_node_path16.join)(path5)),
1170
+ versionEvent: versionEvent((0, import_node_path17.join)(path6)),
1129
1171
  /**
1130
1172
  * Adds a file to the given event
1131
1173
  * @param id - The id of the event to add the file to
@@ -1133,7 +1175,7 @@ var index_default = (path5) => {
1133
1175
  * @param version - Optional version of the event to add the file to
1134
1176
  * @returns
1135
1177
  */
1136
- addFileToEvent: addFileToEvent((0, import_node_path16.join)(path5)),
1178
+ addFileToEvent: addFileToEvent((0, import_node_path17.join)(path6)),
1137
1179
  /**
1138
1180
  * Adds a schema to the given event
1139
1181
  * @param id - The id of the event to add the schema to
@@ -1141,14 +1183,14 @@ var index_default = (path5) => {
1141
1183
  * @param version - Optional version of the event to add the schema to
1142
1184
  * @returns
1143
1185
  */
1144
- addSchemaToEvent: addSchemaToEvent((0, import_node_path16.join)(path5)),
1186
+ addSchemaToEvent: addSchemaToEvent((0, import_node_path17.join)(path6)),
1145
1187
  /**
1146
1188
  * Check to see if an event version exists
1147
1189
  * @param id - The id of the event
1148
1190
  * @param version - The version of the event (supports semver)
1149
1191
  * @returns
1150
1192
  */
1151
- eventHasVersion: eventHasVersion((0, import_node_path16.join)(path5)),
1193
+ eventHasVersion: eventHasVersion((0, import_node_path17.join)(path6)),
1152
1194
  /**
1153
1195
  * ================================
1154
1196
  * Commands
@@ -1160,13 +1202,13 @@ var index_default = (path5) => {
1160
1202
  * @param version - Optional id of the version to get (supports semver)
1161
1203
  * @returns Command|Undefined
1162
1204
  */
1163
- getCommand: getCommand((0, import_node_path16.join)(path5)),
1205
+ getCommand: getCommand((0, import_node_path17.join)(path6)),
1164
1206
  /**
1165
1207
  * Returns all commands from EventCatalog
1166
1208
  * @param latestOnly - optional boolean, set to true to get only latest versions
1167
1209
  * @returns Command[]|Undefined
1168
1210
  */
1169
- getCommands: getCommands((0, import_node_path16.join)(path5)),
1211
+ getCommands: getCommands((0, import_node_path17.join)(path6)),
1170
1212
  /**
1171
1213
  * Adds an command to EventCatalog
1172
1214
  *
@@ -1174,7 +1216,7 @@ var index_default = (path5) => {
1174
1216
  * @param options - Optional options to write the command
1175
1217
  *
1176
1218
  */
1177
- writeCommand: writeCommand((0, import_node_path16.join)(path5, "commands")),
1219
+ writeCommand: writeCommand((0, import_node_path17.join)(path6, "commands")),
1178
1220
  /**
1179
1221
  * Adds a command to a service in EventCatalog
1180
1222
  *
@@ -1183,26 +1225,26 @@ var index_default = (path5) => {
1183
1225
  * @param options - Optional options to write the command
1184
1226
  *
1185
1227
  */
1186
- writeCommandToService: writeCommandToService((0, import_node_path16.join)(path5)),
1228
+ writeCommandToService: writeCommandToService((0, import_node_path17.join)(path6)),
1187
1229
  /**
1188
1230
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1189
1231
  *
1190
1232
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1191
1233
  *
1192
1234
  */
1193
- rmCommand: rmCommand((0, import_node_path16.join)(path5, "commands")),
1235
+ rmCommand: rmCommand((0, import_node_path17.join)(path6, "commands")),
1194
1236
  /**
1195
1237
  * Remove an command by an Event id
1196
1238
  *
1197
1239
  * @param id - The id of the command you want to remove
1198
1240
  *
1199
1241
  */
1200
- rmCommandById: rmCommandById((0, import_node_path16.join)(path5)),
1242
+ rmCommandById: rmCommandById((0, import_node_path17.join)(path6)),
1201
1243
  /**
1202
1244
  * Moves a given command id to the version directory
1203
1245
  * @param directory
1204
1246
  */
1205
- versionCommand: versionCommand((0, import_node_path16.join)(path5)),
1247
+ versionCommand: versionCommand((0, import_node_path17.join)(path6)),
1206
1248
  /**
1207
1249
  * Adds a file to the given command
1208
1250
  * @param id - The id of the command to add the file to
@@ -1210,7 +1252,7 @@ var index_default = (path5) => {
1210
1252
  * @param version - Optional version of the command to add the file to
1211
1253
  * @returns
1212
1254
  */
1213
- addFileToCommand: addFileToCommand((0, import_node_path16.join)(path5)),
1255
+ addFileToCommand: addFileToCommand((0, import_node_path17.join)(path6)),
1214
1256
  /**
1215
1257
  * Adds a schema to the given command
1216
1258
  * @param id - The id of the command to add the schema to
@@ -1218,14 +1260,14 @@ var index_default = (path5) => {
1218
1260
  * @param version - Optional version of the command to add the schema to
1219
1261
  * @returns
1220
1262
  */
1221
- addSchemaToCommand: addSchemaToCommand((0, import_node_path16.join)(path5)),
1263
+ addSchemaToCommand: addSchemaToCommand((0, import_node_path17.join)(path6)),
1222
1264
  /**
1223
1265
  * Check to see if a command version exists
1224
1266
  * @param id - The id of the command
1225
1267
  * @param version - The version of the command (supports semver)
1226
1268
  * @returns
1227
1269
  */
1228
- commandHasVersion: commandHasVersion((0, import_node_path16.join)(path5)),
1270
+ commandHasVersion: commandHasVersion((0, import_node_path17.join)(path6)),
1229
1271
  /**
1230
1272
  * ================================
1231
1273
  * Queries
@@ -1237,13 +1279,13 @@ var index_default = (path5) => {
1237
1279
  * @param version - Optional id of the version to get (supports semver)
1238
1280
  * @returns Query|Undefined
1239
1281
  */
1240
- getQuery: getQuery((0, import_node_path16.join)(path5)),
1282
+ getQuery: getQuery((0, import_node_path17.join)(path6)),
1241
1283
  /**
1242
1284
  * Returns all queries from EventCatalog
1243
1285
  * @param latestOnly - optional boolean, set to true to get only latest versions
1244
1286
  * @returns Query[]|Undefined
1245
1287
  */
1246
- getQueries: getQueries((0, import_node_path16.join)(path5)),
1288
+ getQueries: getQueries((0, import_node_path17.join)(path6)),
1247
1289
  /**
1248
1290
  * Adds a query to EventCatalog
1249
1291
  *
@@ -1251,7 +1293,7 @@ var index_default = (path5) => {
1251
1293
  * @param options - Optional options to write the event
1252
1294
  *
1253
1295
  */
1254
- writeQuery: writeQuery((0, import_node_path16.join)(path5, "queries")),
1296
+ writeQuery: writeQuery((0, import_node_path17.join)(path6, "queries")),
1255
1297
  /**
1256
1298
  * Adds a query to a service in EventCatalog
1257
1299
  *
@@ -1260,26 +1302,26 @@ var index_default = (path5) => {
1260
1302
  * @param options - Optional options to write the query
1261
1303
  *
1262
1304
  */
1263
- writeQueryToService: writeQueryToService((0, import_node_path16.join)(path5)),
1305
+ writeQueryToService: writeQueryToService((0, import_node_path17.join)(path6)),
1264
1306
  /**
1265
1307
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1266
1308
  *
1267
1309
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1268
1310
  *
1269
1311
  */
1270
- rmQuery: rmQuery((0, import_node_path16.join)(path5, "queries")),
1312
+ rmQuery: rmQuery((0, import_node_path17.join)(path6, "queries")),
1271
1313
  /**
1272
1314
  * Remove a query by a Query id
1273
1315
  *
1274
1316
  * @param id - The id of the query you want to remove
1275
1317
  *
1276
1318
  */
1277
- rmQueryById: rmQueryById((0, import_node_path16.join)(path5)),
1319
+ rmQueryById: rmQueryById((0, import_node_path17.join)(path6)),
1278
1320
  /**
1279
1321
  * Moves a given query id to the version directory
1280
1322
  * @param directory
1281
1323
  */
1282
- versionQuery: versionQuery((0, import_node_path16.join)(path5)),
1324
+ versionQuery: versionQuery((0, import_node_path17.join)(path6)),
1283
1325
  /**
1284
1326
  * Adds a file to the given query
1285
1327
  * @param id - The id of the query to add the file to
@@ -1287,7 +1329,7 @@ var index_default = (path5) => {
1287
1329
  * @param version - Optional version of the query to add the file to
1288
1330
  * @returns
1289
1331
  */
1290
- addFileToQuery: addFileToQuery((0, import_node_path16.join)(path5)),
1332
+ addFileToQuery: addFileToQuery((0, import_node_path17.join)(path6)),
1291
1333
  /**
1292
1334
  * Adds a schema to the given query
1293
1335
  * @param id - The id of the query to add the schema to
@@ -1295,14 +1337,14 @@ var index_default = (path5) => {
1295
1337
  * @param version - Optional version of the query to add the schema to
1296
1338
  * @returns
1297
1339
  */
1298
- addSchemaToQuery: addSchemaToQuery((0, import_node_path16.join)(path5)),
1340
+ addSchemaToQuery: addSchemaToQuery((0, import_node_path17.join)(path6)),
1299
1341
  /**
1300
1342
  * Check to see if an query version exists
1301
1343
  * @param id - The id of the query
1302
1344
  * @param version - The version of the query (supports semver)
1303
1345
  * @returns
1304
1346
  */
1305
- queryHasVersion: queryHasVersion((0, import_node_path16.join)(path5)),
1347
+ queryHasVersion: queryHasVersion((0, import_node_path17.join)(path6)),
1306
1348
  /**
1307
1349
  * ================================
1308
1350
  * Channels
@@ -1314,13 +1356,13 @@ var index_default = (path5) => {
1314
1356
  * @param version - Optional id of the version to get (supports semver)
1315
1357
  * @returns Channel|Undefined
1316
1358
  */
1317
- getChannel: getChannel((0, import_node_path16.join)(path5)),
1359
+ getChannel: getChannel((0, import_node_path17.join)(path6)),
1318
1360
  /**
1319
1361
  * Returns all channels from EventCatalog
1320
1362
  * @param latestOnly - optional boolean, set to true to get only latest versions
1321
1363
  * @returns Channel[]|Undefined
1322
1364
  */
1323
- getChannels: getChannels((0, import_node_path16.join)(path5)),
1365
+ getChannels: getChannels((0, import_node_path17.join)(path6)),
1324
1366
  /**
1325
1367
  * Adds an channel to EventCatalog
1326
1368
  *
@@ -1328,33 +1370,33 @@ var index_default = (path5) => {
1328
1370
  * @param options - Optional options to write the channel
1329
1371
  *
1330
1372
  */
1331
- writeChannel: writeChannel((0, import_node_path16.join)(path5, "channels")),
1373
+ writeChannel: writeChannel((0, import_node_path17.join)(path6, "channels")),
1332
1374
  /**
1333
1375
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1334
1376
  *
1335
1377
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1336
1378
  *
1337
1379
  */
1338
- rmChannel: rmChannel((0, import_node_path16.join)(path5, "channels")),
1380
+ rmChannel: rmChannel((0, import_node_path17.join)(path6, "channels")),
1339
1381
  /**
1340
1382
  * Remove an channel by an Event id
1341
1383
  *
1342
1384
  * @param id - The id of the channel you want to remove
1343
1385
  *
1344
1386
  */
1345
- rmChannelById: rmChannelById((0, import_node_path16.join)(path5)),
1387
+ rmChannelById: rmChannelById((0, import_node_path17.join)(path6)),
1346
1388
  /**
1347
1389
  * Moves a given channel id to the version directory
1348
1390
  * @param directory
1349
1391
  */
1350
- versionChannel: versionChannel((0, import_node_path16.join)(path5)),
1392
+ versionChannel: versionChannel((0, import_node_path17.join)(path6)),
1351
1393
  /**
1352
1394
  * Check to see if a channel version exists
1353
1395
  * @param id - The id of the channel
1354
1396
  * @param version - The version of the channel (supports semver)
1355
1397
  * @returns
1356
1398
  */
1357
- channelHasVersion: channelHasVersion((0, import_node_path16.join)(path5)),
1399
+ channelHasVersion: channelHasVersion((0, import_node_path17.join)(path6)),
1358
1400
  /**
1359
1401
  * Add a channel to an event
1360
1402
  *
@@ -1371,7 +1413,7 @@ var index_default = (path5) => {
1371
1413
  *
1372
1414
  * ```
1373
1415
  */
1374
- addEventToChannel: addMessageToChannel((0, import_node_path16.join)(path5), "events"),
1416
+ addEventToChannel: addMessageToChannel((0, import_node_path17.join)(path6), "events"),
1375
1417
  /**
1376
1418
  * Add a channel to an command
1377
1419
  *
@@ -1388,7 +1430,7 @@ var index_default = (path5) => {
1388
1430
  *
1389
1431
  * ```
1390
1432
  */
1391
- addCommandToChannel: addMessageToChannel((0, import_node_path16.join)(path5), "commands"),
1433
+ addCommandToChannel: addMessageToChannel((0, import_node_path17.join)(path6), "commands"),
1392
1434
  /**
1393
1435
  * Add a channel to an query
1394
1436
  *
@@ -1405,7 +1447,7 @@ var index_default = (path5) => {
1405
1447
  *
1406
1448
  * ```
1407
1449
  */
1408
- addQueryToChannel: addMessageToChannel((0, import_node_path16.join)(path5), "queries"),
1450
+ addQueryToChannel: addMessageToChannel((0, import_node_path17.join)(path6), "queries"),
1409
1451
  /**
1410
1452
  * ================================
1411
1453
  * SERVICES
@@ -1418,14 +1460,14 @@ var index_default = (path5) => {
1418
1460
  * @param options - Optional options to write the event
1419
1461
  *
1420
1462
  */
1421
- writeService: writeService((0, import_node_path16.join)(path5, "services")),
1463
+ writeService: writeService((0, import_node_path17.join)(path6, "services")),
1422
1464
  /**
1423
1465
  * Adds a versioned service to EventCatalog
1424
1466
  *
1425
1467
  * @param service - The service to write
1426
1468
  *
1427
1469
  */
1428
- writeVersionedService: writeVersionedService((0, import_node_path16.join)(path5, "services")),
1470
+ writeVersionedService: writeVersionedService((0, import_node_path17.join)(path6, "services")),
1429
1471
  /**
1430
1472
  * Adds a service to a domain in EventCatalog
1431
1473
  *
@@ -1434,45 +1476,45 @@ var index_default = (path5) => {
1434
1476
  * @param options - Optional options to write the event
1435
1477
  *
1436
1478
  */
1437
- writeServiceToDomain: writeServiceToDomain((0, import_node_path16.join)(path5, "domains")),
1479
+ writeServiceToDomain: writeServiceToDomain((0, import_node_path17.join)(path6, "domains")),
1438
1480
  /**
1439
1481
  * Returns a service from EventCatalog
1440
1482
  * @param id - The id of the service to retrieve
1441
1483
  * @param version - Optional id of the version to get (supports semver)
1442
1484
  * @returns Service|Undefined
1443
1485
  */
1444
- getService: getService((0, import_node_path16.join)(path5)),
1486
+ getService: getService((0, import_node_path17.join)(path6)),
1445
1487
  /**
1446
1488
  * Returns a service from EventCatalog by it's path.
1447
1489
  * @param path - The path to the service to retrieve
1448
1490
  * @returns Service|Undefined
1449
1491
  */
1450
- getServiceByPath: getServiceByPath((0, import_node_path16.join)(path5)),
1492
+ getServiceByPath: getServiceByPath((0, import_node_path17.join)(path6)),
1451
1493
  /**
1452
1494
  * Returns all services from EventCatalog
1453
1495
  * @param latestOnly - optional boolean, set to true to get only latest versions
1454
1496
  * @returns Service[]|Undefined
1455
1497
  */
1456
- getServices: getServices((0, import_node_path16.join)(path5)),
1498
+ getServices: getServices((0, import_node_path17.join)(path6)),
1457
1499
  /**
1458
1500
  * Moves a given service id to the version directory
1459
1501
  * @param directory
1460
1502
  */
1461
- versionService: versionService((0, import_node_path16.join)(path5)),
1503
+ versionService: versionService((0, import_node_path17.join)(path6)),
1462
1504
  /**
1463
1505
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1464
1506
  *
1465
1507
  * @param path - The path to your service, e.g. `/InventoryService`
1466
1508
  *
1467
1509
  */
1468
- rmService: rmService((0, import_node_path16.join)(path5, "services")),
1510
+ rmService: rmService((0, import_node_path17.join)(path6, "services")),
1469
1511
  /**
1470
1512
  * Remove an service by an service id
1471
1513
  *
1472
1514
  * @param id - The id of the service you want to remove
1473
1515
  *
1474
1516
  */
1475
- rmServiceById: rmServiceById((0, import_node_path16.join)(path5)),
1517
+ rmServiceById: rmServiceById((0, import_node_path17.join)(path6)),
1476
1518
  /**
1477
1519
  * Adds a file to the given service
1478
1520
  * @param id - The id of the service to add the file to
@@ -1480,21 +1522,21 @@ var index_default = (path5) => {
1480
1522
  * @param version - Optional version of the service to add the file to
1481
1523
  * @returns
1482
1524
  */
1483
- addFileToService: addFileToService((0, import_node_path16.join)(path5)),
1525
+ addFileToService: addFileToService((0, import_node_path17.join)(path6)),
1484
1526
  /**
1485
1527
  * Returns the specifications for a given service
1486
1528
  * @param id - The id of the service to retrieve the specifications for
1487
1529
  * @param version - Optional version of the service
1488
1530
  * @returns
1489
1531
  */
1490
- getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path16.join)(path5)),
1532
+ getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path17.join)(path6)),
1491
1533
  /**
1492
1534
  * Check to see if a service version exists
1493
1535
  * @param id - The id of the service
1494
1536
  * @param version - The version of the service (supports semver)
1495
1537
  * @returns
1496
1538
  */
1497
- serviceHasVersion: serviceHasVersion((0, import_node_path16.join)(path5)),
1539
+ serviceHasVersion: serviceHasVersion((0, import_node_path17.join)(path6)),
1498
1540
  /**
1499
1541
  * Add an event to a service by it's id.
1500
1542
  *
@@ -1514,7 +1556,24 @@ var index_default = (path5) => {
1514
1556
  *
1515
1557
  * ```
1516
1558
  */
1517
- addEventToService: addMessageToService((0, import_node_path16.join)(path5)),
1559
+ addEventToService: addMessageToService((0, import_node_path17.join)(path6)),
1560
+ /**
1561
+ * Add a data store to a service by it's id.
1562
+ *
1563
+ * Optionally specify a version to add the data store to a specific version of the service.
1564
+ *
1565
+ * @example
1566
+ * ```ts
1567
+ * import utils from '@eventcatalog/utils';
1568
+ *
1569
+ * const { addDataStoreToService } = utils('/path/to/eventcatalog');
1570
+ *
1571
+ * // adds a new data store (orders-db) that the InventoryService will write to
1572
+ * await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
1573
+ *
1574
+ * ```
1575
+ */
1576
+ addDataStoreToService: addDataStoreToService((0, import_node_path17.join)(path6)),
1518
1577
  /**
1519
1578
  * Add a command to a service by it's id.
1520
1579
  *
@@ -1534,7 +1593,7 @@ var index_default = (path5) => {
1534
1593
  *
1535
1594
  * ```
1536
1595
  */
1537
- addCommandToService: addMessageToService((0, import_node_path16.join)(path5)),
1596
+ addCommandToService: addMessageToService((0, import_node_path17.join)(path6)),
1538
1597
  /**
1539
1598
  * Add a query to a service by it's id.
1540
1599
  *
@@ -1554,7 +1613,7 @@ var index_default = (path5) => {
1554
1613
  *
1555
1614
  * ```
1556
1615
  */
1557
- addQueryToService: addMessageToService((0, import_node_path16.join)(path5)),
1616
+ addQueryToService: addMessageToService((0, import_node_path17.join)(path6)),
1558
1617
  /**
1559
1618
  * Add an entity to a service by its id.
1560
1619
  *
@@ -1572,7 +1631,7 @@ var index_default = (path5) => {
1572
1631
  *
1573
1632
  * ```
1574
1633
  */
1575
- addEntityToService: addEntityToService((0, import_node_path16.join)(path5)),
1634
+ addEntityToService: addEntityToService((0, import_node_path17.join)(path6)),
1576
1635
  /**
1577
1636
  * Check to see if a service exists by it's path.
1578
1637
  *
@@ -1589,13 +1648,13 @@ var index_default = (path5) => {
1589
1648
  * @param path - The path to the service to check
1590
1649
  * @returns boolean
1591
1650
  */
1592
- isService: isService((0, import_node_path16.join)(path5)),
1651
+ isService: isService((0, import_node_path17.join)(path6)),
1593
1652
  /**
1594
1653
  * Converts a file to a service.
1595
1654
  * @param file - The file to convert to a service.
1596
1655
  * @returns The service.
1597
1656
  */
1598
- toService: toService((0, import_node_path16.join)(path5)),
1657
+ toService: toService((0, import_node_path17.join)(path6)),
1599
1658
  /**
1600
1659
  * ================================
1601
1660
  * Domains
@@ -1608,39 +1667,39 @@ var index_default = (path5) => {
1608
1667
  * @param options - Optional options to write the event
1609
1668
  *
1610
1669
  */
1611
- writeDomain: writeDomain((0, import_node_path16.join)(path5, "domains")),
1670
+ writeDomain: writeDomain((0, import_node_path17.join)(path6, "domains")),
1612
1671
  /**
1613
1672
  * Returns a domain from EventCatalog
1614
1673
  * @param id - The id of the domain to retrieve
1615
1674
  * @param version - Optional id of the version to get (supports semver)
1616
1675
  * @returns Domain|Undefined
1617
1676
  */
1618
- getDomain: getDomain((0, import_node_path16.join)(path5, "domains")),
1677
+ getDomain: getDomain((0, import_node_path17.join)(path6, "domains")),
1619
1678
  /**
1620
1679
  * Returns all domains from EventCatalog
1621
1680
  * @param latestOnly - optional boolean, set to true to get only latest versions
1622
1681
  * @returns Domain[]|Undefined
1623
1682
  */
1624
- getDomains: getDomains((0, import_node_path16.join)(path5)),
1683
+ getDomains: getDomains((0, import_node_path17.join)(path6)),
1625
1684
  /**
1626
1685
  * Moves a given domain id to the version directory
1627
1686
  * @param directory
1628
1687
  */
1629
- versionDomain: versionDomain((0, import_node_path16.join)(path5, "domains")),
1688
+ versionDomain: versionDomain((0, import_node_path17.join)(path6, "domains")),
1630
1689
  /**
1631
1690
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1632
1691
  *
1633
1692
  * @param path - The path to your domain, e.g. `/Payment`
1634
1693
  *
1635
1694
  */
1636
- rmDomain: rmDomain((0, import_node_path16.join)(path5, "domains")),
1695
+ rmDomain: rmDomain((0, import_node_path17.join)(path6, "domains")),
1637
1696
  /**
1638
1697
  * Remove an service by an domain id
1639
1698
  *
1640
1699
  * @param id - The id of the domain you want to remove
1641
1700
  *
1642
1701
  */
1643
- rmDomainById: rmDomainById((0, import_node_path16.join)(path5, "domains")),
1702
+ rmDomainById: rmDomainById((0, import_node_path17.join)(path6, "domains")),
1644
1703
  /**
1645
1704
  * Adds a file to the given domain
1646
1705
  * @param id - The id of the domain to add the file to
@@ -1648,28 +1707,28 @@ var index_default = (path5) => {
1648
1707
  * @param version - Optional version of the domain to add the file to
1649
1708
  * @returns
1650
1709
  */
1651
- addFileToDomain: addFileToDomain((0, import_node_path16.join)(path5, "domains")),
1710
+ addFileToDomain: addFileToDomain((0, import_node_path17.join)(path6, "domains")),
1652
1711
  /**
1653
1712
  * Adds an ubiquitous language dictionary to a domain
1654
1713
  * @param id - The id of the domain to add the ubiquitous language to
1655
1714
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1656
1715
  * @param version - Optional version of the domain to add the ubiquitous language to
1657
1716
  */
1658
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path16.join)(path5, "domains")),
1717
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path17.join)(path6, "domains")),
1659
1718
  /**
1660
1719
  * Get the ubiquitous language dictionary from a domain
1661
1720
  * @param id - The id of the domain to get the ubiquitous language from
1662
1721
  * @param version - Optional version of the domain to get the ubiquitous language from
1663
1722
  * @returns
1664
1723
  */
1665
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path16.join)(path5, "domains")),
1724
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path17.join)(path6, "domains")),
1666
1725
  /**
1667
1726
  * Check to see if a domain version exists
1668
1727
  * @param id - The id of the domain
1669
1728
  * @param version - The version of the domain (supports semver)
1670
1729
  * @returns
1671
1730
  */
1672
- domainHasVersion: domainHasVersion((0, import_node_path16.join)(path5)),
1731
+ domainHasVersion: domainHasVersion((0, import_node_path17.join)(path6)),
1673
1732
  /**
1674
1733
  * Adds a given service to a domain
1675
1734
  * @param id - The id of the domain
@@ -1677,7 +1736,7 @@ var index_default = (path5) => {
1677
1736
  * @param version - (Optional) The version of the domain to add the service to
1678
1737
  * @returns
1679
1738
  */
1680
- addServiceToDomain: addServiceToDomain((0, import_node_path16.join)(path5, "domains")),
1739
+ addServiceToDomain: addServiceToDomain((0, import_node_path17.join)(path6, "domains")),
1681
1740
  /**
1682
1741
  * Adds a given subdomain to a domain
1683
1742
  * @param id - The id of the domain
@@ -1685,7 +1744,7 @@ var index_default = (path5) => {
1685
1744
  * @param version - (Optional) The version of the domain to add the subdomain to
1686
1745
  * @returns
1687
1746
  */
1688
- addSubDomainToDomain: addSubDomainToDomain((0, import_node_path16.join)(path5, "domains")),
1747
+ addSubDomainToDomain: addSubDomainToDomain((0, import_node_path17.join)(path6, "domains")),
1689
1748
  /**
1690
1749
  * Adds an entity to a domain
1691
1750
  * @param id - The id of the domain
@@ -1693,7 +1752,7 @@ var index_default = (path5) => {
1693
1752
  * @param version - (Optional) The version of the domain to add the entity to
1694
1753
  * @returns
1695
1754
  */
1696
- addEntityToDomain: addEntityToDomain((0, import_node_path16.join)(path5, "domains")),
1755
+ addEntityToDomain: addEntityToDomain((0, import_node_path17.join)(path6, "domains")),
1697
1756
  /**
1698
1757
  * ================================
1699
1758
  * Teams
@@ -1706,25 +1765,25 @@ var index_default = (path5) => {
1706
1765
  * @param options - Optional options to write the team
1707
1766
  *
1708
1767
  */
1709
- writeTeam: writeTeam((0, import_node_path16.join)(path5, "teams")),
1768
+ writeTeam: writeTeam((0, import_node_path17.join)(path6, "teams")),
1710
1769
  /**
1711
1770
  * Returns a team from EventCatalog
1712
1771
  * @param id - The id of the team to retrieve
1713
1772
  * @returns Team|Undefined
1714
1773
  */
1715
- getTeam: getTeam((0, import_node_path16.join)(path5, "teams")),
1774
+ getTeam: getTeam((0, import_node_path17.join)(path6, "teams")),
1716
1775
  /**
1717
1776
  * Returns all teams from EventCatalog
1718
1777
  * @returns Team[]|Undefined
1719
1778
  */
1720
- getTeams: getTeams((0, import_node_path16.join)(path5, "teams")),
1779
+ getTeams: getTeams((0, import_node_path17.join)(path6, "teams")),
1721
1780
  /**
1722
1781
  * Remove a team by the team id
1723
1782
  *
1724
1783
  * @param id - The id of the team you want to remove
1725
1784
  *
1726
1785
  */
1727
- rmTeamById: rmTeamById((0, import_node_path16.join)(path5, "teams")),
1786
+ rmTeamById: rmTeamById((0, import_node_path17.join)(path6, "teams")),
1728
1787
  /**
1729
1788
  * ================================
1730
1789
  * Users
@@ -1737,25 +1796,25 @@ var index_default = (path5) => {
1737
1796
  * @param options - Optional options to write the user
1738
1797
  *
1739
1798
  */
1740
- writeUser: writeUser((0, import_node_path16.join)(path5, "users")),
1799
+ writeUser: writeUser((0, import_node_path17.join)(path6, "users")),
1741
1800
  /**
1742
1801
  * Returns a user from EventCatalog
1743
1802
  * @param id - The id of the user to retrieve
1744
1803
  * @returns User|Undefined
1745
1804
  */
1746
- getUser: getUser((0, import_node_path16.join)(path5, "users")),
1805
+ getUser: getUser((0, import_node_path17.join)(path6, "users")),
1747
1806
  /**
1748
1807
  * Returns all user from EventCatalog
1749
1808
  * @returns User[]|Undefined
1750
1809
  */
1751
- getUsers: getUsers((0, import_node_path16.join)(path5)),
1810
+ getUsers: getUsers((0, import_node_path17.join)(path6)),
1752
1811
  /**
1753
1812
  * Remove a user by the user id
1754
1813
  *
1755
1814
  * @param id - The id of the user you want to remove
1756
1815
  *
1757
1816
  */
1758
- rmUserById: rmUserById((0, import_node_path16.join)(path5, "users")),
1817
+ rmUserById: rmUserById((0, import_node_path17.join)(path6, "users")),
1759
1818
  /**
1760
1819
  * ================================
1761
1820
  * Custom Docs
@@ -1766,32 +1825,32 @@ var index_default = (path5) => {
1766
1825
  * @param path - The path to the custom doc to retrieve
1767
1826
  * @returns CustomDoc|Undefined
1768
1827
  */
1769
- getCustomDoc: getCustomDoc((0, import_node_path16.join)(path5, "docs")),
1828
+ getCustomDoc: getCustomDoc((0, import_node_path17.join)(path6, "docs")),
1770
1829
  /**
1771
1830
  * Returns all custom docs from EventCatalog
1772
1831
  * @param options - Optional options to get custom docs from a specific path
1773
1832
  * @returns CustomDoc[]|Undefined
1774
1833
  */
1775
- getCustomDocs: getCustomDocs((0, import_node_path16.join)(path5, "docs")),
1834
+ getCustomDocs: getCustomDocs((0, import_node_path17.join)(path6, "docs")),
1776
1835
  /**
1777
1836
  * Writes a custom doc to EventCatalog
1778
1837
  * @param customDoc - The custom doc to write
1779
1838
  * @param options - Optional options to write the custom doc
1780
1839
  *
1781
1840
  */
1782
- writeCustomDoc: writeCustomDoc((0, import_node_path16.join)(path5, "docs")),
1841
+ writeCustomDoc: writeCustomDoc((0, import_node_path17.join)(path6, "docs")),
1783
1842
  /**
1784
1843
  * Removes a custom doc from EventCatalog
1785
1844
  * @param path - The path to the custom doc to remove
1786
1845
  *
1787
1846
  */
1788
- rmCustomDoc: rmCustomDoc((0, import_node_path16.join)(path5, "docs")),
1847
+ rmCustomDoc: rmCustomDoc((0, import_node_path17.join)(path6, "docs")),
1789
1848
  /**
1790
1849
  * Dumps the catalog to a JSON file.
1791
1850
  * @param directory - The directory to dump the catalog to
1792
1851
  * @returns A JSON file with the catalog
1793
1852
  */
1794
- dumpCatalog: dumpCatalog((0, import_node_path16.join)(path5)),
1853
+ dumpCatalog: dumpCatalog((0, import_node_path17.join)(path6)),
1795
1854
  /**
1796
1855
  * Returns the event catalog configuration file.
1797
1856
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1799,7 +1858,7 @@ var index_default = (path5) => {
1799
1858
  * @param directory - The directory of the catalog.
1800
1859
  * @returns A JSON object with the configuration for the event catalog.
1801
1860
  */
1802
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path16.join)(path5)),
1861
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path17.join)(path6)),
1803
1862
  /**
1804
1863
  * ================================
1805
1864
  * Resources Utils
@@ -1809,6 +1868,10 @@ var index_default = (path5) => {
1809
1868
  * Returns the path to a given resource by id and version
1810
1869
  */
1811
1870
  getResourcePath,
1871
+ /**
1872
+ * Returns the folder name of a given resource
1873
+ */
1874
+ getResourceFolderName,
1812
1875
  /**
1813
1876
  * ================================
1814
1877
  * General Message Utils
@@ -1820,33 +1883,33 @@ var index_default = (path5) => {
1820
1883
  * @param path - The path to the message to retrieve
1821
1884
  * @returns Message|Undefined
1822
1885
  */
1823
- getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path16.join)(path5)),
1886
+ getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path17.join)(path6)),
1824
1887
  /**
1825
1888
  * Returns the producers and consumers (services) for a given message
1826
1889
  * @param id - The id of the message to get the producers and consumers for
1827
1890
  * @param version - Optional version of the message
1828
1891
  * @returns { producers: Service[], consumers: Service[] }
1829
1892
  */
1830
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path16.join)(path5)),
1893
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path17.join)(path6)),
1831
1894
  /**
1832
1895
  * Returns the consumers of a given schema path
1833
1896
  * @param path - The path to the schema to get the consumers for
1834
1897
  * @returns Service[]
1835
1898
  */
1836
- getConsumersOfSchema: getConsumersOfSchema((0, import_node_path16.join)(path5)),
1899
+ getConsumersOfSchema: getConsumersOfSchema((0, import_node_path17.join)(path6)),
1837
1900
  /**
1838
1901
  * Returns the producers of a given schema path
1839
1902
  * @param path - The path to the schema to get the producers for
1840
1903
  * @returns Service[]
1841
1904
  */
1842
- getProducersOfSchema: getProducersOfSchema((0, import_node_path16.join)(path5)),
1905
+ getProducersOfSchema: getProducersOfSchema((0, import_node_path17.join)(path6)),
1843
1906
  /**
1844
1907
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
1845
1908
  * @param id - The id of the resource to get the owners for
1846
1909
  * @param version - Optional version of the resource
1847
1910
  * @returns { owners: User[] }
1848
1911
  */
1849
- getOwnersForResource: getOwnersForResource((0, import_node_path16.join)(path5)),
1912
+ getOwnersForResource: getOwnersForResource((0, import_node_path17.join)(path6)),
1850
1913
  /**
1851
1914
  * ================================
1852
1915
  * Entities
@@ -1858,13 +1921,13 @@ var index_default = (path5) => {
1858
1921
  * @param version - Optional id of the version to get (supports semver)
1859
1922
  * @returns Entity|Undefined
1860
1923
  */
1861
- getEntity: getEntity((0, import_node_path16.join)(path5)),
1924
+ getEntity: getEntity((0, import_node_path17.join)(path6)),
1862
1925
  /**
1863
1926
  * Returns all entities from EventCatalog
1864
1927
  * @param latestOnly - optional boolean, set to true to get only latest versions
1865
1928
  * @returns Entity[]|Undefined
1866
1929
  */
1867
- getEntities: getEntities((0, import_node_path16.join)(path5)),
1930
+ getEntities: getEntities((0, import_node_path17.join)(path6)),
1868
1931
  /**
1869
1932
  * Adds an entity to EventCatalog
1870
1933
  *
@@ -1872,33 +1935,33 @@ var index_default = (path5) => {
1872
1935
  * @param options - Optional options to write the entity
1873
1936
  *
1874
1937
  */
1875
- writeEntity: writeEntity((0, import_node_path16.join)(path5, "entities")),
1938
+ writeEntity: writeEntity((0, import_node_path17.join)(path6, "entities")),
1876
1939
  /**
1877
1940
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
1878
1941
  *
1879
1942
  * @param path - The path to your entity, e.g. `/User`
1880
1943
  *
1881
1944
  */
1882
- rmEntity: rmEntity((0, import_node_path16.join)(path5, "entities")),
1945
+ rmEntity: rmEntity((0, import_node_path17.join)(path6, "entities")),
1883
1946
  /**
1884
1947
  * Remove an entity by an entity id
1885
1948
  *
1886
1949
  * @param id - The id of the entity you want to remove
1887
1950
  *
1888
1951
  */
1889
- rmEntityById: rmEntityById((0, import_node_path16.join)(path5)),
1952
+ rmEntityById: rmEntityById((0, import_node_path17.join)(path6)),
1890
1953
  /**
1891
1954
  * Moves a given entity id to the version directory
1892
1955
  * @param id - The id of the entity to version
1893
1956
  */
1894
- versionEntity: versionEntity((0, import_node_path16.join)(path5)),
1957
+ versionEntity: versionEntity((0, import_node_path17.join)(path6)),
1895
1958
  /**
1896
1959
  * Check to see if an entity version exists
1897
1960
  * @param id - The id of the entity
1898
1961
  * @param version - The version of the entity (supports semver)
1899
1962
  * @returns
1900
1963
  */
1901
- entityHasVersion: entityHasVersion((0, import_node_path16.join)(path5)),
1964
+ entityHasVersion: entityHasVersion((0, import_node_path17.join)(path6)),
1902
1965
  /**
1903
1966
  * ================================
1904
1967
  * Data Stores
@@ -1910,42 +1973,42 @@ var index_default = (path5) => {
1910
1973
  * @param options - Optional options to write the data store
1911
1974
  *
1912
1975
  */
1913
- writeDataStore: writeDataStore((0, import_node_path16.join)(path5, "containers")),
1976
+ writeDataStore: writeDataStore((0, import_node_path17.join)(path6, "containers")),
1914
1977
  /**
1915
1978
  * Returns a data store from EventCatalog
1916
1979
  * @param id - The id of the data store to retrieve
1917
1980
  * @param version - Optional id of the version to get (supports semver)
1918
1981
  * @returns Container|Undefined
1919
1982
  */
1920
- getDataStore: getDataStore((0, import_node_path16.join)(path5)),
1983
+ getDataStore: getDataStore((0, import_node_path17.join)(path6)),
1921
1984
  /**
1922
1985
  * Returns all data stores from EventCatalog
1923
1986
  * @param latestOnly - optional boolean, set to true to get only latest versions
1924
1987
  * @returns Container[]|Undefined
1925
1988
  */
1926
- getDataStores: getDataStores((0, import_node_path16.join)(path5)),
1989
+ getDataStores: getDataStores((0, import_node_path17.join)(path6)),
1927
1990
  /**
1928
1991
  * Version a data store by its id
1929
1992
  * @param id - The id of the data store to version
1930
1993
  */
1931
- versionDataStore: versionDataStore((0, import_node_path16.join)(path5, "containers")),
1994
+ versionDataStore: versionDataStore((0, import_node_path17.join)(path6, "containers")),
1932
1995
  /**
1933
1996
  * Remove a data store by its path
1934
1997
  * @param path - The path to the data store to remove
1935
1998
  */
1936
- rmDataStore: rmDataStore((0, import_node_path16.join)(path5, "containers")),
1999
+ rmDataStore: rmDataStore((0, import_node_path17.join)(path6, "containers")),
1937
2000
  /**
1938
2001
  * Remove a data store by its id
1939
2002
  * @param id - The id of the data store to remove
1940
2003
  */
1941
- rmDataStoreById: rmDataStoreById((0, import_node_path16.join)(path5)),
2004
+ rmDataStoreById: rmDataStoreById((0, import_node_path17.join)(path6)),
1942
2005
  /**
1943
2006
  * Check to see if a data store version exists
1944
2007
  * @param id - The id of the data store
1945
2008
  * @param version - The version of the data store (supports semver)
1946
2009
  * @returns
1947
2010
  */
1948
- dataStoreHasVersion: dataStoreHasVersion((0, import_node_path16.join)(path5)),
2011
+ dataStoreHasVersion: dataStoreHasVersion((0, import_node_path17.join)(path6)),
1949
2012
  /**
1950
2013
  * Adds a file to a data store by its id
1951
2014
  * @param id - The id of the data store to add the file to
@@ -1953,14 +2016,14 @@ var index_default = (path5) => {
1953
2016
  * @param version - Optional version of the data store to add the file to
1954
2017
  * @returns
1955
2018
  */
1956
- addFileToDataStore: addFileToDataStore((0, import_node_path16.join)(path5)),
2019
+ addFileToDataStore: addFileToDataStore((0, import_node_path17.join)(path6)),
1957
2020
  /**
1958
2021
  * Writes a data store to a service by its id
1959
2022
  * @param dataStore - The data store to write
1960
2023
  * @param service - The service to write the data store to
1961
2024
  * @returns
1962
2025
  */
1963
- writeDataStoreToService: writeDataStoreToService((0, import_node_path16.join)(path5))
2026
+ writeDataStoreToService: writeDataStoreToService((0, import_node_path17.join)(path6))
1964
2027
  };
1965
2028
  };
1966
2029
 
@@ -1968,7 +2031,7 @@ var index_default = (path5) => {
1968
2031
  var DUMP_VERSION = "0.0.1";
1969
2032
  var getEventCatalogVersion = async (catalogDir) => {
1970
2033
  try {
1971
- const packageJson = import_fs.default.readFileSync((0, import_node_path17.join)(catalogDir, "package.json"), "utf8");
2034
+ const packageJson = import_fs.default.readFileSync((0, import_node_path18.join)(catalogDir, "package.json"), "utf8");
1972
2035
  const packageJsonObject = JSON.parse(packageJson);
1973
2036
  return packageJsonObject["dependencies"]["@eventcatalog/core"];
1974
2037
  } catch (error) {
@@ -1981,7 +2044,7 @@ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false
1981
2044
  const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
1982
2045
  let schema = "";
1983
2046
  if (resource.schemaPath && resourcePath?.fullPath) {
1984
- const pathToSchema = import_node_path17.default.join(import_node_path17.default.dirname(resourcePath?.fullPath), resource.schemaPath);
2047
+ const pathToSchema = import_node_path18.default.join(import_node_path18.default.dirname(resourcePath?.fullPath), resource.schemaPath);
1985
2048
  if (import_fs.default.existsSync(pathToSchema)) {
1986
2049
  schema = import_fs.default.readFileSync(pathToSchema, "utf8");
1987
2050
  }
@@ -2002,8 +2065,8 @@ var filterCollection = (collection, options) => {
2002
2065
  };
2003
2066
  var getEventCatalogConfigurationFile = (directory) => async () => {
2004
2067
  try {
2005
- const path5 = (0, import_node_path17.join)(directory, "eventcatalog.config.js");
2006
- const configModule = await import(path5);
2068
+ const path6 = (0, import_node_path18.join)(directory, "eventcatalog.config.js");
2069
+ const configModule = await import(path6);
2007
2070
  return configModule.default;
2008
2071
  } catch (error) {
2009
2072
  console.error("Error getting event catalog configuration file", error);