@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
package/dist/index.mjs CHANGED
@@ -20,13 +20,13 @@ var versionExists = async (catalogDir, id, version) => {
20
20
  var findFileById = async (catalogDir, id, version) => {
21
21
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
22
22
  const matchedFiles = await searchFilesForId(files, id) || [];
23
- const latestVersion = matchedFiles.find((path5) => !path5.includes("versioned"));
23
+ const latestVersion = matchedFiles.find((path6) => !path6.includes("versioned"));
24
24
  if (!version) {
25
25
  return latestVersion;
26
26
  }
27
- const parsedFiles = matchedFiles.map((path5) => {
28
- const { data } = matter.read(path5);
29
- return { ...data, path: path5 };
27
+ const parsedFiles = matchedFiles.map((path6) => {
28
+ const { data } = matter.read(path6);
29
+ return { ...data, path: path6 };
30
30
  });
31
31
  const semverRange = validRange(version);
32
32
  if (semverRange && valid(version)) {
@@ -67,8 +67,8 @@ var getFiles = async (pattern, ignore = "") => {
67
67
  );
68
68
  }
69
69
  };
70
- var readMdxFile = async (path5) => {
71
- const { data } = matter.read(path5);
70
+ var readMdxFile = async (path6) => {
71
+ const { data } = matter.read(path6);
72
72
  const { markdown, ...frontmatter } = data;
73
73
  return { ...frontmatter, markdown };
74
74
  };
@@ -121,6 +121,7 @@ import fsSync2 from "fs";
121
121
  import { satisfies as satisfies2 } from "semver";
122
122
  import { lock, unlock } from "proper-lockfile";
123
123
  import { basename as basename2 } from "path";
124
+ import path from "path";
124
125
  var versionResource = async (catalogDir, id) => {
125
126
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
126
127
  const matchedFiles = await searchFilesForId(files, id);
@@ -160,8 +161,8 @@ var writeResource = async (catalogDir, resource, options = {
160
161
  versionExistingContent: false,
161
162
  format: "mdx"
162
163
  }) => {
163
- const path5 = options.path || `/${resource.id}`;
164
- const fullPath = join2(catalogDir, path5);
164
+ const path6 = options.path || `/${resource.id}`;
165
+ const fullPath = join2(catalogDir, path6);
165
166
  const format = options.format || "mdx";
166
167
  fsSync2.mkdirSync(fullPath, { recursive: true });
167
168
  const lockPath = join2(fullPath, `index.${format}`);
@@ -227,6 +228,11 @@ var getResourcePath = async (catalogDir, id, version) => {
227
228
  directory: dirname2(file.replace(catalogDir, ""))
228
229
  };
229
230
  };
231
+ var getResourceFolderName = async (catalogDir, id, version) => {
232
+ const paths = await getResourcePath(catalogDir, id, version);
233
+ if (!paths) return;
234
+ return paths?.directory.split(path.sep).filter(Boolean).pop();
235
+ };
230
236
  var toResource = async (catalogDir, rawContents) => {
231
237
  const { data, content } = matter2(rawContents);
232
238
  return {
@@ -288,16 +294,16 @@ var rmResourceById = async (catalogDir, id, version, options) => {
288
294
  );
289
295
  }
290
296
  };
291
- var waitForFileRemoval = async (path5, maxRetries = 50, delay = 10) => {
297
+ var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
292
298
  for (let i = 0; i < maxRetries; i++) {
293
299
  try {
294
- await fs.access(path5);
300
+ await fs.access(path6);
295
301
  await new Promise((resolve2) => setTimeout(resolve2, delay));
296
302
  } catch (error) {
297
303
  return;
298
304
  }
299
305
  }
300
- throw new Error(`File/directory ${path5} was not removed after ${maxRetries} attempts`);
306
+ throw new Error(`File/directory ${path6} was not removed after ${maxRetries} attempts`);
301
307
  };
302
308
  var addFileToResource = async (catalogDir, id, file, version) => {
303
309
  const pathToResource = await findFileById(catalogDir, id, version);
@@ -344,8 +350,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
344
350
  pathForEvent = join3(pathForEvent, event.id);
345
351
  await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
346
352
  };
347
- var rmEvent = (directory) => async (path5) => {
348
- await fs2.rm(join3(directory, path5), { recursive: true });
353
+ var rmEvent = (directory) => async (path6) => {
354
+ await fs2.rm(join3(directory, path6), { recursive: true });
349
355
  };
350
356
  var rmEventById = (directory) => async (id, version, persistFiles) => {
351
357
  await rmResourceById(directory, id, version, { type: "event", persistFiles });
@@ -380,8 +386,8 @@ var writeCommandToService = (directory) => async (command, service, options = {
380
386
  pathForCommand = join4(pathForCommand, command.id);
381
387
  await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
382
388
  };
383
- var rmCommand = (directory) => async (path5) => {
384
- await fs3.rm(join4(directory, path5), { recursive: true });
389
+ var rmCommand = (directory) => async (path6) => {
390
+ await fs3.rm(join4(directory, path6), { recursive: true });
385
391
  };
386
392
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
387
393
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
@@ -414,8 +420,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
414
420
  pathForQuery = join5(pathForQuery, query.id);
415
421
  await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
416
422
  };
417
- var rmQuery = (directory) => async (path5) => {
418
- await fs4.rm(join5(directory, path5), { recursive: true });
423
+ var rmQuery = (directory) => async (path6) => {
424
+ await fs4.rm(join5(directory, path6), { recursive: true });
419
425
  };
420
426
  var rmQueryById = (directory) => async (id, version, persistFiles) => {
421
427
  await rmResourceById(directory, id, version, { type: "query", persistFiles });
@@ -434,8 +440,8 @@ var queryHasVersion = (directory) => async (id, version) => {
434
440
  import fs5 from "fs/promises";
435
441
  import { join as join6, dirname as dirname4, extname, relative as relative2 } from "path";
436
442
  var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
437
- var getServiceByPath = (directory) => async (path5) => {
438
- const service = await getResource(directory, void 0, void 0, { type: "service" }, path5);
443
+ var getServiceByPath = (directory) => async (path6) => {
444
+ const service = await getResource(directory, void 0, void 0, { type: "service" }, path6);
439
445
  return service;
440
446
  };
441
447
  var getServices = (directory) => async (options) => getResources(directory, {
@@ -459,8 +465,8 @@ var writeService = (directory) => async (service, options = {
459
465
  };
460
466
  var writeVersionedService = (directory) => async (service) => {
461
467
  const resource = { ...service };
462
- const path5 = getVersionedDirectory(service.id, service.version);
463
- return await writeService(directory)(resource, { path: path5 });
468
+ const path6 = getVersionedDirectory(service.id, service.version);
469
+ return await writeService(directory)(resource, { path: path6 });
464
470
  };
465
471
  var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
466
472
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
@@ -468,8 +474,8 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
468
474
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
469
475
  };
470
476
  var versionService = (directory) => async (id) => versionResource(directory, id);
471
- var rmService = (directory) => async (path5) => {
472
- await fs5.rm(join6(directory, path5), { recursive: true });
477
+ var rmService = (directory) => async (path6) => {
478
+ await fs5.rm(join6(directory, path6), { recursive: true });
473
479
  };
474
480
  var rmServiceById = (directory) => async (id, version, persistFiles) => {
475
481
  await rmResourceById(directory, id, version, { type: "service", persistFiles });
@@ -533,8 +539,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
533
539
  if (!existingResource) {
534
540
  throw new Error(`Cannot find service ${id} in the catalog`);
535
541
  }
536
- const path5 = existingResource.split(/[\\/]+services/)[0];
537
- const pathToResource = join6(path5, "services");
542
+ const path6 = existingResource.split(/[\\/]+services/)[0];
543
+ const pathToResource = join6(path6, "services");
538
544
  await rmServiceById(directory)(id, version);
539
545
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
540
546
  };
@@ -542,9 +548,9 @@ var serviceHasVersion = (directory) => async (id, version) => {
542
548
  const file = await findFileById(directory, id, version);
543
549
  return !!file;
544
550
  };
545
- var isService = (directory) => async (path5) => {
546
- const service = await getServiceByPath(directory)(path5);
547
- const relativePath = relative2(directory, path5);
551
+ var isService = (directory) => async (path6) => {
552
+ const service = await getServiceByPath(directory)(path6);
553
+ const relativePath = relative2(directory, path6);
548
554
  const segments = relativePath.split(/[/\\]+/);
549
555
  return !!service && segments.includes("services");
550
556
  };
@@ -566,15 +572,51 @@ var addEntityToService = (directory) => async (id, entity, version) => {
566
572
  if (!existingResource) {
567
573
  throw new Error(`Cannot find service ${id} in the catalog`);
568
574
  }
569
- const path5 = existingResource.split(/[\\/]+services/)[0];
570
- const pathToResource = join6(path5, "services");
575
+ const path6 = existingResource.split(/[\\/]+services/)[0];
576
+ const pathToResource = join6(path6, "services");
577
+ await rmServiceById(directory)(id, version);
578
+ await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
579
+ };
580
+ var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
581
+ let service = await getService(directory)(id, version);
582
+ const servicePath = await getResourcePath(directory, id, version);
583
+ const extension = extname(servicePath?.fullPath || "");
584
+ if (operation === "writesTo") {
585
+ if (service.writesTo === void 0) {
586
+ service.writesTo = [];
587
+ }
588
+ for (let i = 0; i < service.writesTo.length; i++) {
589
+ if (service.writesTo[i].id === dataStore.id && service.writesTo[i].version === dataStore.version) {
590
+ return;
591
+ }
592
+ }
593
+ service.writesTo.push({ id: dataStore.id, version: dataStore.version });
594
+ } else if (operation === "readsFrom") {
595
+ if (service.readsFrom === void 0) {
596
+ service.readsFrom = [];
597
+ }
598
+ for (let i = 0; i < service.readsFrom.length; i++) {
599
+ if (service.readsFrom[i].id === dataStore.id && service.readsFrom[i].version === dataStore.version) {
600
+ return;
601
+ }
602
+ }
603
+ service.readsFrom.push({ id: dataStore.id, version: dataStore.version });
604
+ } else {
605
+ throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
606
+ }
607
+ const existingResource = await findFileById(directory, id, version);
608
+ if (!existingResource) {
609
+ throw new Error(`Cannot find service ${id} in the catalog`);
610
+ }
611
+ const path6 = existingResource.split(/[\\/]+services/)[0];
612
+ const pathToResource = join6(path6, "services");
571
613
  await rmServiceById(directory)(id, version);
572
614
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
573
615
  };
574
616
 
575
617
  // src/domains.ts
576
618
  import fs6 from "fs/promises";
577
- import path, { join as join7 } from "path";
619
+ import path2, { join as join7 } from "path";
578
620
  import fsSync3 from "fs";
579
621
  import matter3 from "gray-matter";
580
622
  var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
@@ -599,8 +641,8 @@ var writeDomain = (directory) => async (domain, options = {
599
641
  return await writeResource(directory, resource, { ...options, type: "domain" });
600
642
  };
601
643
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
602
- var rmDomain = (directory) => async (path5) => {
603
- await fs6.rm(join7(directory, path5), { recursive: true });
644
+ var rmDomain = (directory) => async (path6) => {
645
+ await fs6.rm(join7(directory, path6), { recursive: true });
604
646
  };
605
647
  var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
606
648
  var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -612,7 +654,7 @@ var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguage
612
654
  };
613
655
  var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
614
656
  const pathToDomain = await findFileById(directory, id, version) || "";
615
- const pathToUbiquitousLanguage = path.join(path.dirname(pathToDomain), "ubiquitous-language.mdx");
657
+ const pathToUbiquitousLanguage = path2.join(path2.dirname(pathToDomain), "ubiquitous-language.mdx");
616
658
  const fileExists = fsSync3.existsSync(pathToUbiquitousLanguage);
617
659
  if (!fileExists) {
618
660
  return void 0;
@@ -627,7 +669,7 @@ var domainHasVersion = (directory) => async (id, version) => {
627
669
  var addServiceToDomain = (directory) => async (id, service, version) => {
628
670
  let domain = await getDomain(directory)(id, version);
629
671
  const domainPath = await getResourcePath(directory, id, version);
630
- const extension = path.extname(domainPath?.fullPath || "");
672
+ const extension = path2.extname(domainPath?.fullPath || "");
631
673
  if (domain.services === void 0) {
632
674
  domain.services = [];
633
675
  }
@@ -642,7 +684,7 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
642
684
  var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
643
685
  let domain = await getDomain(directory)(id, version);
644
686
  const domainPath = await getResourcePath(directory, id, version);
645
- const extension = path.extname(domainPath?.fullPath || "");
687
+ const extension = path2.extname(domainPath?.fullPath || "");
646
688
  if (domain.domains === void 0) {
647
689
  domain.domains = [];
648
690
  }
@@ -657,7 +699,7 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
657
699
  var addEntityToDomain = (directory) => async (id, entity, version) => {
658
700
  let domain = await getDomain(directory)(id, version);
659
701
  const domainPath = await getResourcePath(directory, id, version);
660
- const extension = path.extname(domainPath?.fullPath || "");
702
+ const extension = path2.extname(domainPath?.fullPath || "");
661
703
  if (domain.entities === void 0) {
662
704
  domain.entities = [];
663
705
  }
@@ -676,8 +718,8 @@ import { join as join8, extname as extname2 } from "path";
676
718
  var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
677
719
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
678
720
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
679
- var rmChannel = (directory) => async (path5) => {
680
- await fs7.rm(join8(directory, path5), { recursive: true });
721
+ var rmChannel = (directory) => async (path6) => {
722
+ await fs7.rm(join8(directory, path6), { recursive: true });
681
723
  };
682
724
  var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
683
725
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
@@ -718,8 +760,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
718
760
  if (!existingResource) {
719
761
  throw new Error(`Cannot find message ${id} in the catalog`);
720
762
  }
721
- const path5 = existingResource.split(`/[\\/]+${collection}`)[0];
722
- const pathToResource = join8(path5, collection);
763
+ const path6 = existingResource.split(`/[\\/]+${collection}`)[0];
764
+ const pathToResource = join8(path6, collection);
723
765
  await rmMessageById(directory)(_message.id, _message.version, true);
724
766
  await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
725
767
  };
@@ -728,8 +770,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
728
770
  import { dirname as dirname5 } from "path";
729
771
  import matter4 from "gray-matter";
730
772
  import { satisfies as satisfies3, validRange as validRange2 } from "semver";
731
- var getMessageBySchemaPath = (directory) => async (path5, options) => {
732
- const pathToMessage = dirname5(path5);
773
+ var getMessageBySchemaPath = (directory) => async (path6, options) => {
774
+ const pathToMessage = dirname5(path6);
733
775
  try {
734
776
  const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
735
777
  if (!files || files.length === 0) {
@@ -801,18 +843,18 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
801
843
  }
802
844
  return { producers, consumers };
803
845
  };
804
- var getConsumersOfSchema = (directory) => async (path5) => {
846
+ var getConsumersOfSchema = (directory) => async (path6) => {
805
847
  try {
806
- const message = await getMessageBySchemaPath(directory)(path5);
848
+ const message = await getMessageBySchemaPath(directory)(path6);
807
849
  const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
808
850
  return consumers;
809
851
  } catch (error) {
810
852
  return [];
811
853
  }
812
854
  };
813
- var getProducersOfSchema = (directory) => async (path5) => {
855
+ var getProducersOfSchema = (directory) => async (path6) => {
814
856
  try {
815
- const message = await getMessageBySchemaPath(directory)(path5);
857
+ const message = await getMessageBySchemaPath(directory)(path6);
816
858
  const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
817
859
  return producers;
818
860
  } catch (error) {
@@ -821,13 +863,13 @@ var getProducersOfSchema = (directory) => async (path5) => {
821
863
  };
822
864
 
823
865
  // src/custom-docs.ts
824
- import path2, { join as join10 } from "path";
866
+ import path3, { join as join10 } from "path";
825
867
  import fsSync4 from "fs";
826
868
  import fs8 from "fs/promises";
827
869
  import matter5 from "gray-matter";
828
870
  import slugify from "slugify";
829
871
  var getCustomDoc = (directory) => async (filePath) => {
830
- const fullPath = path2.join(directory, filePath);
872
+ const fullPath = path3.join(directory, filePath);
831
873
  const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
832
874
  const fileExists = fsSync4.existsSync(fullPathWithExtension);
833
875
  if (!fileExists) {
@@ -846,8 +888,8 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
846
888
  const { fileName, ...rest } = customDoc;
847
889
  const name = fileName || slugify(customDoc.title, { lower: true });
848
890
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
849
- const fullPath = path2.join(directory, options.path || "", withExtension);
850
- fsSync4.mkdirSync(path2.dirname(fullPath), { recursive: true });
891
+ const fullPath = path3.join(directory, options.path || "", withExtension);
892
+ fsSync4.mkdirSync(path3.dirname(fullPath), { recursive: true });
851
893
  const document = matter5.stringify(customDoc.markdown.trim(), rest);
852
894
  fsSync4.writeFileSync(fullPath, document);
853
895
  };
@@ -861,7 +903,7 @@ import fs9 from "fs/promises";
861
903
  import fsSync6 from "fs";
862
904
  import { join as join12 } from "path";
863
905
  import matter7 from "gray-matter";
864
- import path3 from "path";
906
+ import path4 from "path";
865
907
 
866
908
  // src/users.ts
867
909
  import fsSync5 from "fs";
@@ -957,11 +999,11 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
957
999
  if (!resource) return [];
958
1000
  if (!resource.owners) return [];
959
1001
  for (const owner of resource.owners) {
960
- const team = await getTeam(path3.join(catalogDir, "teams"))(owner);
1002
+ const team = await getTeam(path4.join(catalogDir, "teams"))(owner);
961
1003
  if (team) {
962
1004
  owners.push(team);
963
1005
  } else {
964
- const user = await getUser(path3.join(catalogDir, "users"))(owner);
1006
+ const user = await getUser(path4.join(catalogDir, "users"))(owner);
965
1007
  if (user) {
966
1008
  owners.push(user);
967
1009
  }
@@ -972,7 +1014,7 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
972
1014
 
973
1015
  // src/eventcatalog.ts
974
1016
  import fs10 from "fs";
975
- import path4, { join as join13 } from "path";
1017
+ import path5, { join as join13 } from "path";
976
1018
  var DUMP_VERSION = "0.0.1";
977
1019
  var getEventCatalogVersion = async (catalogDir) => {
978
1020
  try {
@@ -989,7 +1031,7 @@ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false
989
1031
  const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
990
1032
  let schema = "";
991
1033
  if (resource.schemaPath && resourcePath?.fullPath) {
992
- const pathToSchema = path4.join(path4.dirname(resourcePath?.fullPath), resource.schemaPath);
1034
+ const pathToSchema = path5.join(path5.dirname(resourcePath?.fullPath), resource.schemaPath);
993
1035
  if (fs10.existsSync(pathToSchema)) {
994
1036
  schema = fs10.readFileSync(pathToSchema, "utf8");
995
1037
  }
@@ -1010,8 +1052,8 @@ var filterCollection = (collection, options) => {
1010
1052
  };
1011
1053
  var getEventCatalogConfigurationFile = (directory) => async () => {
1012
1054
  try {
1013
- const path5 = join13(directory, "eventcatalog.config.js");
1014
- const configModule = await import(path5);
1055
+ const path6 = join13(directory, "eventcatalog.config.js");
1056
+ const configModule = await import(path6);
1015
1057
  return configModule.default;
1016
1058
  } catch (error) {
1017
1059
  console.error("Error getting event catalog configuration file", error);
@@ -1077,8 +1119,8 @@ var writeEntity = (directory) => async (entity, options = {
1077
1119
  override: false,
1078
1120
  format: "mdx"
1079
1121
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1080
- var rmEntity = (directory) => async (path5) => {
1081
- await fs11.rm(join14(directory, path5), { recursive: true });
1122
+ var rmEntity = (directory) => async (path6) => {
1123
+ await fs11.rm(join14(directory, path6), { recursive: true });
1082
1124
  };
1083
1125
  var rmEntityById = (directory) => async (id, version, persistFiles) => {
1084
1126
  await rmResourceById(directory, id, version, { type: "entity", persistFiles });
@@ -1100,8 +1142,8 @@ var writeContainer = (directory) => async (data, options = {
1100
1142
  format: "mdx"
1101
1143
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1102
1144
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1103
- var rmContainer = (directory) => async (path5) => {
1104
- await fs12.rm(join15(directory, path5), { recursive: true });
1145
+ var rmContainer = (directory) => async (path6) => {
1146
+ await fs12.rm(join15(directory, path6), { recursive: true });
1105
1147
  };
1106
1148
  var rmContainerById = (directory) => async (id, version, persistFiles) => {
1107
1149
  await rmResourceById(directory, id, version, { type: "container", persistFiles });
@@ -1133,7 +1175,7 @@ var addFileToDataStore = addFileToContainer;
1133
1175
  var writeDataStoreToService = writeContainerToService;
1134
1176
 
1135
1177
  // src/index.ts
1136
- var index_default = (path5) => {
1178
+ var index_default = (path6) => {
1137
1179
  return {
1138
1180
  /**
1139
1181
  * Returns an events from EventCatalog
@@ -1141,13 +1183,13 @@ var index_default = (path5) => {
1141
1183
  * @param version - Optional id of the version to get (supports semver)
1142
1184
  * @returns Event|Undefined
1143
1185
  */
1144
- getEvent: getEvent(join16(path5)),
1186
+ getEvent: getEvent(join16(path6)),
1145
1187
  /**
1146
1188
  * Returns all events from EventCatalog
1147
1189
  * @param latestOnly - optional boolean, set to true to get only latest versions
1148
1190
  * @returns Event[]|Undefined
1149
1191
  */
1150
- getEvents: getEvents(join16(path5)),
1192
+ getEvents: getEvents(join16(path6)),
1151
1193
  /**
1152
1194
  * Adds an event to EventCatalog
1153
1195
  *
@@ -1155,7 +1197,7 @@ var index_default = (path5) => {
1155
1197
  * @param options - Optional options to write the event
1156
1198
  *
1157
1199
  */
1158
- writeEvent: writeEvent(join16(path5, "events")),
1200
+ writeEvent: writeEvent(join16(path6, "events")),
1159
1201
  /**
1160
1202
  * Adds an event to a service in EventCatalog
1161
1203
  *
@@ -1164,26 +1206,26 @@ var index_default = (path5) => {
1164
1206
  * @param options - Optional options to write the event
1165
1207
  *
1166
1208
  */
1167
- writeEventToService: writeEventToService(join16(path5)),
1209
+ writeEventToService: writeEventToService(join16(path6)),
1168
1210
  /**
1169
1211
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1170
1212
  *
1171
1213
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1172
1214
  *
1173
1215
  */
1174
- rmEvent: rmEvent(join16(path5, "events")),
1216
+ rmEvent: rmEvent(join16(path6, "events")),
1175
1217
  /**
1176
1218
  * Remove an event by an Event id
1177
1219
  *
1178
1220
  * @param id - The id of the event you want to remove
1179
1221
  *
1180
1222
  */
1181
- rmEventById: rmEventById(join16(path5)),
1223
+ rmEventById: rmEventById(join16(path6)),
1182
1224
  /**
1183
1225
  * Moves a given event id to the version directory
1184
1226
  * @param directory
1185
1227
  */
1186
- versionEvent: versionEvent(join16(path5)),
1228
+ versionEvent: versionEvent(join16(path6)),
1187
1229
  /**
1188
1230
  * Adds a file to the given event
1189
1231
  * @param id - The id of the event to add the file to
@@ -1191,7 +1233,7 @@ var index_default = (path5) => {
1191
1233
  * @param version - Optional version of the event to add the file to
1192
1234
  * @returns
1193
1235
  */
1194
- addFileToEvent: addFileToEvent(join16(path5)),
1236
+ addFileToEvent: addFileToEvent(join16(path6)),
1195
1237
  /**
1196
1238
  * Adds a schema to the given event
1197
1239
  * @param id - The id of the event to add the schema to
@@ -1199,14 +1241,14 @@ var index_default = (path5) => {
1199
1241
  * @param version - Optional version of the event to add the schema to
1200
1242
  * @returns
1201
1243
  */
1202
- addSchemaToEvent: addSchemaToEvent(join16(path5)),
1244
+ addSchemaToEvent: addSchemaToEvent(join16(path6)),
1203
1245
  /**
1204
1246
  * Check to see if an event version exists
1205
1247
  * @param id - The id of the event
1206
1248
  * @param version - The version of the event (supports semver)
1207
1249
  * @returns
1208
1250
  */
1209
- eventHasVersion: eventHasVersion(join16(path5)),
1251
+ eventHasVersion: eventHasVersion(join16(path6)),
1210
1252
  /**
1211
1253
  * ================================
1212
1254
  * Commands
@@ -1218,13 +1260,13 @@ var index_default = (path5) => {
1218
1260
  * @param version - Optional id of the version to get (supports semver)
1219
1261
  * @returns Command|Undefined
1220
1262
  */
1221
- getCommand: getCommand(join16(path5)),
1263
+ getCommand: getCommand(join16(path6)),
1222
1264
  /**
1223
1265
  * Returns all commands from EventCatalog
1224
1266
  * @param latestOnly - optional boolean, set to true to get only latest versions
1225
1267
  * @returns Command[]|Undefined
1226
1268
  */
1227
- getCommands: getCommands(join16(path5)),
1269
+ getCommands: getCommands(join16(path6)),
1228
1270
  /**
1229
1271
  * Adds an command to EventCatalog
1230
1272
  *
@@ -1232,7 +1274,7 @@ var index_default = (path5) => {
1232
1274
  * @param options - Optional options to write the command
1233
1275
  *
1234
1276
  */
1235
- writeCommand: writeCommand(join16(path5, "commands")),
1277
+ writeCommand: writeCommand(join16(path6, "commands")),
1236
1278
  /**
1237
1279
  * Adds a command to a service in EventCatalog
1238
1280
  *
@@ -1241,26 +1283,26 @@ var index_default = (path5) => {
1241
1283
  * @param options - Optional options to write the command
1242
1284
  *
1243
1285
  */
1244
- writeCommandToService: writeCommandToService(join16(path5)),
1286
+ writeCommandToService: writeCommandToService(join16(path6)),
1245
1287
  /**
1246
1288
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1247
1289
  *
1248
1290
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1249
1291
  *
1250
1292
  */
1251
- rmCommand: rmCommand(join16(path5, "commands")),
1293
+ rmCommand: rmCommand(join16(path6, "commands")),
1252
1294
  /**
1253
1295
  * Remove an command by an Event id
1254
1296
  *
1255
1297
  * @param id - The id of the command you want to remove
1256
1298
  *
1257
1299
  */
1258
- rmCommandById: rmCommandById(join16(path5)),
1300
+ rmCommandById: rmCommandById(join16(path6)),
1259
1301
  /**
1260
1302
  * Moves a given command id to the version directory
1261
1303
  * @param directory
1262
1304
  */
1263
- versionCommand: versionCommand(join16(path5)),
1305
+ versionCommand: versionCommand(join16(path6)),
1264
1306
  /**
1265
1307
  * Adds a file to the given command
1266
1308
  * @param id - The id of the command to add the file to
@@ -1268,7 +1310,7 @@ var index_default = (path5) => {
1268
1310
  * @param version - Optional version of the command to add the file to
1269
1311
  * @returns
1270
1312
  */
1271
- addFileToCommand: addFileToCommand(join16(path5)),
1313
+ addFileToCommand: addFileToCommand(join16(path6)),
1272
1314
  /**
1273
1315
  * Adds a schema to the given command
1274
1316
  * @param id - The id of the command to add the schema to
@@ -1276,14 +1318,14 @@ var index_default = (path5) => {
1276
1318
  * @param version - Optional version of the command to add the schema to
1277
1319
  * @returns
1278
1320
  */
1279
- addSchemaToCommand: addSchemaToCommand(join16(path5)),
1321
+ addSchemaToCommand: addSchemaToCommand(join16(path6)),
1280
1322
  /**
1281
1323
  * Check to see if a command version exists
1282
1324
  * @param id - The id of the command
1283
1325
  * @param version - The version of the command (supports semver)
1284
1326
  * @returns
1285
1327
  */
1286
- commandHasVersion: commandHasVersion(join16(path5)),
1328
+ commandHasVersion: commandHasVersion(join16(path6)),
1287
1329
  /**
1288
1330
  * ================================
1289
1331
  * Queries
@@ -1295,13 +1337,13 @@ var index_default = (path5) => {
1295
1337
  * @param version - Optional id of the version to get (supports semver)
1296
1338
  * @returns Query|Undefined
1297
1339
  */
1298
- getQuery: getQuery(join16(path5)),
1340
+ getQuery: getQuery(join16(path6)),
1299
1341
  /**
1300
1342
  * Returns all queries from EventCatalog
1301
1343
  * @param latestOnly - optional boolean, set to true to get only latest versions
1302
1344
  * @returns Query[]|Undefined
1303
1345
  */
1304
- getQueries: getQueries(join16(path5)),
1346
+ getQueries: getQueries(join16(path6)),
1305
1347
  /**
1306
1348
  * Adds a query to EventCatalog
1307
1349
  *
@@ -1309,7 +1351,7 @@ var index_default = (path5) => {
1309
1351
  * @param options - Optional options to write the event
1310
1352
  *
1311
1353
  */
1312
- writeQuery: writeQuery(join16(path5, "queries")),
1354
+ writeQuery: writeQuery(join16(path6, "queries")),
1313
1355
  /**
1314
1356
  * Adds a query to a service in EventCatalog
1315
1357
  *
@@ -1318,26 +1360,26 @@ var index_default = (path5) => {
1318
1360
  * @param options - Optional options to write the query
1319
1361
  *
1320
1362
  */
1321
- writeQueryToService: writeQueryToService(join16(path5)),
1363
+ writeQueryToService: writeQueryToService(join16(path6)),
1322
1364
  /**
1323
1365
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1324
1366
  *
1325
1367
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1326
1368
  *
1327
1369
  */
1328
- rmQuery: rmQuery(join16(path5, "queries")),
1370
+ rmQuery: rmQuery(join16(path6, "queries")),
1329
1371
  /**
1330
1372
  * Remove a query by a Query id
1331
1373
  *
1332
1374
  * @param id - The id of the query you want to remove
1333
1375
  *
1334
1376
  */
1335
- rmQueryById: rmQueryById(join16(path5)),
1377
+ rmQueryById: rmQueryById(join16(path6)),
1336
1378
  /**
1337
1379
  * Moves a given query id to the version directory
1338
1380
  * @param directory
1339
1381
  */
1340
- versionQuery: versionQuery(join16(path5)),
1382
+ versionQuery: versionQuery(join16(path6)),
1341
1383
  /**
1342
1384
  * Adds a file to the given query
1343
1385
  * @param id - The id of the query to add the file to
@@ -1345,7 +1387,7 @@ var index_default = (path5) => {
1345
1387
  * @param version - Optional version of the query to add the file to
1346
1388
  * @returns
1347
1389
  */
1348
- addFileToQuery: addFileToQuery(join16(path5)),
1390
+ addFileToQuery: addFileToQuery(join16(path6)),
1349
1391
  /**
1350
1392
  * Adds a schema to the given query
1351
1393
  * @param id - The id of the query to add the schema to
@@ -1353,14 +1395,14 @@ var index_default = (path5) => {
1353
1395
  * @param version - Optional version of the query to add the schema to
1354
1396
  * @returns
1355
1397
  */
1356
- addSchemaToQuery: addSchemaToQuery(join16(path5)),
1398
+ addSchemaToQuery: addSchemaToQuery(join16(path6)),
1357
1399
  /**
1358
1400
  * Check to see if an query version exists
1359
1401
  * @param id - The id of the query
1360
1402
  * @param version - The version of the query (supports semver)
1361
1403
  * @returns
1362
1404
  */
1363
- queryHasVersion: queryHasVersion(join16(path5)),
1405
+ queryHasVersion: queryHasVersion(join16(path6)),
1364
1406
  /**
1365
1407
  * ================================
1366
1408
  * Channels
@@ -1372,13 +1414,13 @@ var index_default = (path5) => {
1372
1414
  * @param version - Optional id of the version to get (supports semver)
1373
1415
  * @returns Channel|Undefined
1374
1416
  */
1375
- getChannel: getChannel(join16(path5)),
1417
+ getChannel: getChannel(join16(path6)),
1376
1418
  /**
1377
1419
  * Returns all channels from EventCatalog
1378
1420
  * @param latestOnly - optional boolean, set to true to get only latest versions
1379
1421
  * @returns Channel[]|Undefined
1380
1422
  */
1381
- getChannels: getChannels(join16(path5)),
1423
+ getChannels: getChannels(join16(path6)),
1382
1424
  /**
1383
1425
  * Adds an channel to EventCatalog
1384
1426
  *
@@ -1386,33 +1428,33 @@ var index_default = (path5) => {
1386
1428
  * @param options - Optional options to write the channel
1387
1429
  *
1388
1430
  */
1389
- writeChannel: writeChannel(join16(path5, "channels")),
1431
+ writeChannel: writeChannel(join16(path6, "channels")),
1390
1432
  /**
1391
1433
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1392
1434
  *
1393
1435
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1394
1436
  *
1395
1437
  */
1396
- rmChannel: rmChannel(join16(path5, "channels")),
1438
+ rmChannel: rmChannel(join16(path6, "channels")),
1397
1439
  /**
1398
1440
  * Remove an channel by an Event id
1399
1441
  *
1400
1442
  * @param id - The id of the channel you want to remove
1401
1443
  *
1402
1444
  */
1403
- rmChannelById: rmChannelById(join16(path5)),
1445
+ rmChannelById: rmChannelById(join16(path6)),
1404
1446
  /**
1405
1447
  * Moves a given channel id to the version directory
1406
1448
  * @param directory
1407
1449
  */
1408
- versionChannel: versionChannel(join16(path5)),
1450
+ versionChannel: versionChannel(join16(path6)),
1409
1451
  /**
1410
1452
  * Check to see if a channel version exists
1411
1453
  * @param id - The id of the channel
1412
1454
  * @param version - The version of the channel (supports semver)
1413
1455
  * @returns
1414
1456
  */
1415
- channelHasVersion: channelHasVersion(join16(path5)),
1457
+ channelHasVersion: channelHasVersion(join16(path6)),
1416
1458
  /**
1417
1459
  * Add a channel to an event
1418
1460
  *
@@ -1429,7 +1471,7 @@ var index_default = (path5) => {
1429
1471
  *
1430
1472
  * ```
1431
1473
  */
1432
- addEventToChannel: addMessageToChannel(join16(path5), "events"),
1474
+ addEventToChannel: addMessageToChannel(join16(path6), "events"),
1433
1475
  /**
1434
1476
  * Add a channel to an command
1435
1477
  *
@@ -1446,7 +1488,7 @@ var index_default = (path5) => {
1446
1488
  *
1447
1489
  * ```
1448
1490
  */
1449
- addCommandToChannel: addMessageToChannel(join16(path5), "commands"),
1491
+ addCommandToChannel: addMessageToChannel(join16(path6), "commands"),
1450
1492
  /**
1451
1493
  * Add a channel to an query
1452
1494
  *
@@ -1463,7 +1505,7 @@ var index_default = (path5) => {
1463
1505
  *
1464
1506
  * ```
1465
1507
  */
1466
- addQueryToChannel: addMessageToChannel(join16(path5), "queries"),
1508
+ addQueryToChannel: addMessageToChannel(join16(path6), "queries"),
1467
1509
  /**
1468
1510
  * ================================
1469
1511
  * SERVICES
@@ -1476,14 +1518,14 @@ var index_default = (path5) => {
1476
1518
  * @param options - Optional options to write the event
1477
1519
  *
1478
1520
  */
1479
- writeService: writeService(join16(path5, "services")),
1521
+ writeService: writeService(join16(path6, "services")),
1480
1522
  /**
1481
1523
  * Adds a versioned service to EventCatalog
1482
1524
  *
1483
1525
  * @param service - The service to write
1484
1526
  *
1485
1527
  */
1486
- writeVersionedService: writeVersionedService(join16(path5, "services")),
1528
+ writeVersionedService: writeVersionedService(join16(path6, "services")),
1487
1529
  /**
1488
1530
  * Adds a service to a domain in EventCatalog
1489
1531
  *
@@ -1492,45 +1534,45 @@ var index_default = (path5) => {
1492
1534
  * @param options - Optional options to write the event
1493
1535
  *
1494
1536
  */
1495
- writeServiceToDomain: writeServiceToDomain(join16(path5, "domains")),
1537
+ writeServiceToDomain: writeServiceToDomain(join16(path6, "domains")),
1496
1538
  /**
1497
1539
  * Returns a service from EventCatalog
1498
1540
  * @param id - The id of the service to retrieve
1499
1541
  * @param version - Optional id of the version to get (supports semver)
1500
1542
  * @returns Service|Undefined
1501
1543
  */
1502
- getService: getService(join16(path5)),
1544
+ getService: getService(join16(path6)),
1503
1545
  /**
1504
1546
  * Returns a service from EventCatalog by it's path.
1505
1547
  * @param path - The path to the service to retrieve
1506
1548
  * @returns Service|Undefined
1507
1549
  */
1508
- getServiceByPath: getServiceByPath(join16(path5)),
1550
+ getServiceByPath: getServiceByPath(join16(path6)),
1509
1551
  /**
1510
1552
  * Returns all services from EventCatalog
1511
1553
  * @param latestOnly - optional boolean, set to true to get only latest versions
1512
1554
  * @returns Service[]|Undefined
1513
1555
  */
1514
- getServices: getServices(join16(path5)),
1556
+ getServices: getServices(join16(path6)),
1515
1557
  /**
1516
1558
  * Moves a given service id to the version directory
1517
1559
  * @param directory
1518
1560
  */
1519
- versionService: versionService(join16(path5)),
1561
+ versionService: versionService(join16(path6)),
1520
1562
  /**
1521
1563
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1522
1564
  *
1523
1565
  * @param path - The path to your service, e.g. `/InventoryService`
1524
1566
  *
1525
1567
  */
1526
- rmService: rmService(join16(path5, "services")),
1568
+ rmService: rmService(join16(path6, "services")),
1527
1569
  /**
1528
1570
  * Remove an service by an service id
1529
1571
  *
1530
1572
  * @param id - The id of the service you want to remove
1531
1573
  *
1532
1574
  */
1533
- rmServiceById: rmServiceById(join16(path5)),
1575
+ rmServiceById: rmServiceById(join16(path6)),
1534
1576
  /**
1535
1577
  * Adds a file to the given service
1536
1578
  * @param id - The id of the service to add the file to
@@ -1538,21 +1580,21 @@ var index_default = (path5) => {
1538
1580
  * @param version - Optional version of the service to add the file to
1539
1581
  * @returns
1540
1582
  */
1541
- addFileToService: addFileToService(join16(path5)),
1583
+ addFileToService: addFileToService(join16(path6)),
1542
1584
  /**
1543
1585
  * Returns the specifications for a given service
1544
1586
  * @param id - The id of the service to retrieve the specifications for
1545
1587
  * @param version - Optional version of the service
1546
1588
  * @returns
1547
1589
  */
1548
- getSpecificationFilesForService: getSpecificationFilesForService(join16(path5)),
1590
+ getSpecificationFilesForService: getSpecificationFilesForService(join16(path6)),
1549
1591
  /**
1550
1592
  * Check to see if a service version exists
1551
1593
  * @param id - The id of the service
1552
1594
  * @param version - The version of the service (supports semver)
1553
1595
  * @returns
1554
1596
  */
1555
- serviceHasVersion: serviceHasVersion(join16(path5)),
1597
+ serviceHasVersion: serviceHasVersion(join16(path6)),
1556
1598
  /**
1557
1599
  * Add an event to a service by it's id.
1558
1600
  *
@@ -1572,7 +1614,24 @@ var index_default = (path5) => {
1572
1614
  *
1573
1615
  * ```
1574
1616
  */
1575
- addEventToService: addMessageToService(join16(path5)),
1617
+ addEventToService: addMessageToService(join16(path6)),
1618
+ /**
1619
+ * Add a data store to a service by it's id.
1620
+ *
1621
+ * Optionally specify a version to add the data store to a specific version of the service.
1622
+ *
1623
+ * @example
1624
+ * ```ts
1625
+ * import utils from '@eventcatalog/utils';
1626
+ *
1627
+ * const { addDataStoreToService } = utils('/path/to/eventcatalog');
1628
+ *
1629
+ * // adds a new data store (orders-db) that the InventoryService will write to
1630
+ * await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
1631
+ *
1632
+ * ```
1633
+ */
1634
+ addDataStoreToService: addDataStoreToService(join16(path6)),
1576
1635
  /**
1577
1636
  * Add a command to a service by it's id.
1578
1637
  *
@@ -1592,7 +1651,7 @@ var index_default = (path5) => {
1592
1651
  *
1593
1652
  * ```
1594
1653
  */
1595
- addCommandToService: addMessageToService(join16(path5)),
1654
+ addCommandToService: addMessageToService(join16(path6)),
1596
1655
  /**
1597
1656
  * Add a query to a service by it's id.
1598
1657
  *
@@ -1612,7 +1671,7 @@ var index_default = (path5) => {
1612
1671
  *
1613
1672
  * ```
1614
1673
  */
1615
- addQueryToService: addMessageToService(join16(path5)),
1674
+ addQueryToService: addMessageToService(join16(path6)),
1616
1675
  /**
1617
1676
  * Add an entity to a service by its id.
1618
1677
  *
@@ -1630,7 +1689,7 @@ var index_default = (path5) => {
1630
1689
  *
1631
1690
  * ```
1632
1691
  */
1633
- addEntityToService: addEntityToService(join16(path5)),
1692
+ addEntityToService: addEntityToService(join16(path6)),
1634
1693
  /**
1635
1694
  * Check to see if a service exists by it's path.
1636
1695
  *
@@ -1647,13 +1706,13 @@ var index_default = (path5) => {
1647
1706
  * @param path - The path to the service to check
1648
1707
  * @returns boolean
1649
1708
  */
1650
- isService: isService(join16(path5)),
1709
+ isService: isService(join16(path6)),
1651
1710
  /**
1652
1711
  * Converts a file to a service.
1653
1712
  * @param file - The file to convert to a service.
1654
1713
  * @returns The service.
1655
1714
  */
1656
- toService: toService(join16(path5)),
1715
+ toService: toService(join16(path6)),
1657
1716
  /**
1658
1717
  * ================================
1659
1718
  * Domains
@@ -1666,39 +1725,39 @@ var index_default = (path5) => {
1666
1725
  * @param options - Optional options to write the event
1667
1726
  *
1668
1727
  */
1669
- writeDomain: writeDomain(join16(path5, "domains")),
1728
+ writeDomain: writeDomain(join16(path6, "domains")),
1670
1729
  /**
1671
1730
  * Returns a domain from EventCatalog
1672
1731
  * @param id - The id of the domain to retrieve
1673
1732
  * @param version - Optional id of the version to get (supports semver)
1674
1733
  * @returns Domain|Undefined
1675
1734
  */
1676
- getDomain: getDomain(join16(path5, "domains")),
1735
+ getDomain: getDomain(join16(path6, "domains")),
1677
1736
  /**
1678
1737
  * Returns all domains from EventCatalog
1679
1738
  * @param latestOnly - optional boolean, set to true to get only latest versions
1680
1739
  * @returns Domain[]|Undefined
1681
1740
  */
1682
- getDomains: getDomains(join16(path5)),
1741
+ getDomains: getDomains(join16(path6)),
1683
1742
  /**
1684
1743
  * Moves a given domain id to the version directory
1685
1744
  * @param directory
1686
1745
  */
1687
- versionDomain: versionDomain(join16(path5, "domains")),
1746
+ versionDomain: versionDomain(join16(path6, "domains")),
1688
1747
  /**
1689
1748
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1690
1749
  *
1691
1750
  * @param path - The path to your domain, e.g. `/Payment`
1692
1751
  *
1693
1752
  */
1694
- rmDomain: rmDomain(join16(path5, "domains")),
1753
+ rmDomain: rmDomain(join16(path6, "domains")),
1695
1754
  /**
1696
1755
  * Remove an service by an domain id
1697
1756
  *
1698
1757
  * @param id - The id of the domain you want to remove
1699
1758
  *
1700
1759
  */
1701
- rmDomainById: rmDomainById(join16(path5, "domains")),
1760
+ rmDomainById: rmDomainById(join16(path6, "domains")),
1702
1761
  /**
1703
1762
  * Adds a file to the given domain
1704
1763
  * @param id - The id of the domain to add the file to
@@ -1706,28 +1765,28 @@ var index_default = (path5) => {
1706
1765
  * @param version - Optional version of the domain to add the file to
1707
1766
  * @returns
1708
1767
  */
1709
- addFileToDomain: addFileToDomain(join16(path5, "domains")),
1768
+ addFileToDomain: addFileToDomain(join16(path6, "domains")),
1710
1769
  /**
1711
1770
  * Adds an ubiquitous language dictionary to a domain
1712
1771
  * @param id - The id of the domain to add the ubiquitous language to
1713
1772
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1714
1773
  * @param version - Optional version of the domain to add the ubiquitous language to
1715
1774
  */
1716
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join16(path5, "domains")),
1775
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join16(path6, "domains")),
1717
1776
  /**
1718
1777
  * Get the ubiquitous language dictionary from a domain
1719
1778
  * @param id - The id of the domain to get the ubiquitous language from
1720
1779
  * @param version - Optional version of the domain to get the ubiquitous language from
1721
1780
  * @returns
1722
1781
  */
1723
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join16(path5, "domains")),
1782
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join16(path6, "domains")),
1724
1783
  /**
1725
1784
  * Check to see if a domain version exists
1726
1785
  * @param id - The id of the domain
1727
1786
  * @param version - The version of the domain (supports semver)
1728
1787
  * @returns
1729
1788
  */
1730
- domainHasVersion: domainHasVersion(join16(path5)),
1789
+ domainHasVersion: domainHasVersion(join16(path6)),
1731
1790
  /**
1732
1791
  * Adds a given service to a domain
1733
1792
  * @param id - The id of the domain
@@ -1735,7 +1794,7 @@ var index_default = (path5) => {
1735
1794
  * @param version - (Optional) The version of the domain to add the service to
1736
1795
  * @returns
1737
1796
  */
1738
- addServiceToDomain: addServiceToDomain(join16(path5, "domains")),
1797
+ addServiceToDomain: addServiceToDomain(join16(path6, "domains")),
1739
1798
  /**
1740
1799
  * Adds a given subdomain to a domain
1741
1800
  * @param id - The id of the domain
@@ -1743,7 +1802,7 @@ var index_default = (path5) => {
1743
1802
  * @param version - (Optional) The version of the domain to add the subdomain to
1744
1803
  * @returns
1745
1804
  */
1746
- addSubDomainToDomain: addSubDomainToDomain(join16(path5, "domains")),
1805
+ addSubDomainToDomain: addSubDomainToDomain(join16(path6, "domains")),
1747
1806
  /**
1748
1807
  * Adds an entity to a domain
1749
1808
  * @param id - The id of the domain
@@ -1751,7 +1810,7 @@ var index_default = (path5) => {
1751
1810
  * @param version - (Optional) The version of the domain to add the entity to
1752
1811
  * @returns
1753
1812
  */
1754
- addEntityToDomain: addEntityToDomain(join16(path5, "domains")),
1813
+ addEntityToDomain: addEntityToDomain(join16(path6, "domains")),
1755
1814
  /**
1756
1815
  * ================================
1757
1816
  * Teams
@@ -1764,25 +1823,25 @@ var index_default = (path5) => {
1764
1823
  * @param options - Optional options to write the team
1765
1824
  *
1766
1825
  */
1767
- writeTeam: writeTeam(join16(path5, "teams")),
1826
+ writeTeam: writeTeam(join16(path6, "teams")),
1768
1827
  /**
1769
1828
  * Returns a team from EventCatalog
1770
1829
  * @param id - The id of the team to retrieve
1771
1830
  * @returns Team|Undefined
1772
1831
  */
1773
- getTeam: getTeam(join16(path5, "teams")),
1832
+ getTeam: getTeam(join16(path6, "teams")),
1774
1833
  /**
1775
1834
  * Returns all teams from EventCatalog
1776
1835
  * @returns Team[]|Undefined
1777
1836
  */
1778
- getTeams: getTeams(join16(path5, "teams")),
1837
+ getTeams: getTeams(join16(path6, "teams")),
1779
1838
  /**
1780
1839
  * Remove a team by the team id
1781
1840
  *
1782
1841
  * @param id - The id of the team you want to remove
1783
1842
  *
1784
1843
  */
1785
- rmTeamById: rmTeamById(join16(path5, "teams")),
1844
+ rmTeamById: rmTeamById(join16(path6, "teams")),
1786
1845
  /**
1787
1846
  * ================================
1788
1847
  * Users
@@ -1795,25 +1854,25 @@ var index_default = (path5) => {
1795
1854
  * @param options - Optional options to write the user
1796
1855
  *
1797
1856
  */
1798
- writeUser: writeUser(join16(path5, "users")),
1857
+ writeUser: writeUser(join16(path6, "users")),
1799
1858
  /**
1800
1859
  * Returns a user from EventCatalog
1801
1860
  * @param id - The id of the user to retrieve
1802
1861
  * @returns User|Undefined
1803
1862
  */
1804
- getUser: getUser(join16(path5, "users")),
1863
+ getUser: getUser(join16(path6, "users")),
1805
1864
  /**
1806
1865
  * Returns all user from EventCatalog
1807
1866
  * @returns User[]|Undefined
1808
1867
  */
1809
- getUsers: getUsers(join16(path5)),
1868
+ getUsers: getUsers(join16(path6)),
1810
1869
  /**
1811
1870
  * Remove a user by the user id
1812
1871
  *
1813
1872
  * @param id - The id of the user you want to remove
1814
1873
  *
1815
1874
  */
1816
- rmUserById: rmUserById(join16(path5, "users")),
1875
+ rmUserById: rmUserById(join16(path6, "users")),
1817
1876
  /**
1818
1877
  * ================================
1819
1878
  * Custom Docs
@@ -1824,32 +1883,32 @@ var index_default = (path5) => {
1824
1883
  * @param path - The path to the custom doc to retrieve
1825
1884
  * @returns CustomDoc|Undefined
1826
1885
  */
1827
- getCustomDoc: getCustomDoc(join16(path5, "docs")),
1886
+ getCustomDoc: getCustomDoc(join16(path6, "docs")),
1828
1887
  /**
1829
1888
  * Returns all custom docs from EventCatalog
1830
1889
  * @param options - Optional options to get custom docs from a specific path
1831
1890
  * @returns CustomDoc[]|Undefined
1832
1891
  */
1833
- getCustomDocs: getCustomDocs(join16(path5, "docs")),
1892
+ getCustomDocs: getCustomDocs(join16(path6, "docs")),
1834
1893
  /**
1835
1894
  * Writes a custom doc to EventCatalog
1836
1895
  * @param customDoc - The custom doc to write
1837
1896
  * @param options - Optional options to write the custom doc
1838
1897
  *
1839
1898
  */
1840
- writeCustomDoc: writeCustomDoc(join16(path5, "docs")),
1899
+ writeCustomDoc: writeCustomDoc(join16(path6, "docs")),
1841
1900
  /**
1842
1901
  * Removes a custom doc from EventCatalog
1843
1902
  * @param path - The path to the custom doc to remove
1844
1903
  *
1845
1904
  */
1846
- rmCustomDoc: rmCustomDoc(join16(path5, "docs")),
1905
+ rmCustomDoc: rmCustomDoc(join16(path6, "docs")),
1847
1906
  /**
1848
1907
  * Dumps the catalog to a JSON file.
1849
1908
  * @param directory - The directory to dump the catalog to
1850
1909
  * @returns A JSON file with the catalog
1851
1910
  */
1852
- dumpCatalog: dumpCatalog(join16(path5)),
1911
+ dumpCatalog: dumpCatalog(join16(path6)),
1853
1912
  /**
1854
1913
  * Returns the event catalog configuration file.
1855
1914
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1857,7 +1916,7 @@ var index_default = (path5) => {
1857
1916
  * @param directory - The directory of the catalog.
1858
1917
  * @returns A JSON object with the configuration for the event catalog.
1859
1918
  */
1860
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join16(path5)),
1919
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join16(path6)),
1861
1920
  /**
1862
1921
  * ================================
1863
1922
  * Resources Utils
@@ -1867,6 +1926,10 @@ var index_default = (path5) => {
1867
1926
  * Returns the path to a given resource by id and version
1868
1927
  */
1869
1928
  getResourcePath,
1929
+ /**
1930
+ * Returns the folder name of a given resource
1931
+ */
1932
+ getResourceFolderName,
1870
1933
  /**
1871
1934
  * ================================
1872
1935
  * General Message Utils
@@ -1878,33 +1941,33 @@ var index_default = (path5) => {
1878
1941
  * @param path - The path to the message to retrieve
1879
1942
  * @returns Message|Undefined
1880
1943
  */
1881
- getMessageBySchemaPath: getMessageBySchemaPath(join16(path5)),
1944
+ getMessageBySchemaPath: getMessageBySchemaPath(join16(path6)),
1882
1945
  /**
1883
1946
  * Returns the producers and consumers (services) for a given message
1884
1947
  * @param id - The id of the message to get the producers and consumers for
1885
1948
  * @param version - Optional version of the message
1886
1949
  * @returns { producers: Service[], consumers: Service[] }
1887
1950
  */
1888
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join16(path5)),
1951
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join16(path6)),
1889
1952
  /**
1890
1953
  * Returns the consumers of a given schema path
1891
1954
  * @param path - The path to the schema to get the consumers for
1892
1955
  * @returns Service[]
1893
1956
  */
1894
- getConsumersOfSchema: getConsumersOfSchema(join16(path5)),
1957
+ getConsumersOfSchema: getConsumersOfSchema(join16(path6)),
1895
1958
  /**
1896
1959
  * Returns the producers of a given schema path
1897
1960
  * @param path - The path to the schema to get the producers for
1898
1961
  * @returns Service[]
1899
1962
  */
1900
- getProducersOfSchema: getProducersOfSchema(join16(path5)),
1963
+ getProducersOfSchema: getProducersOfSchema(join16(path6)),
1901
1964
  /**
1902
1965
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
1903
1966
  * @param id - The id of the resource to get the owners for
1904
1967
  * @param version - Optional version of the resource
1905
1968
  * @returns { owners: User[] }
1906
1969
  */
1907
- getOwnersForResource: getOwnersForResource(join16(path5)),
1970
+ getOwnersForResource: getOwnersForResource(join16(path6)),
1908
1971
  /**
1909
1972
  * ================================
1910
1973
  * Entities
@@ -1916,13 +1979,13 @@ var index_default = (path5) => {
1916
1979
  * @param version - Optional id of the version to get (supports semver)
1917
1980
  * @returns Entity|Undefined
1918
1981
  */
1919
- getEntity: getEntity(join16(path5)),
1982
+ getEntity: getEntity(join16(path6)),
1920
1983
  /**
1921
1984
  * Returns all entities from EventCatalog
1922
1985
  * @param latestOnly - optional boolean, set to true to get only latest versions
1923
1986
  * @returns Entity[]|Undefined
1924
1987
  */
1925
- getEntities: getEntities(join16(path5)),
1988
+ getEntities: getEntities(join16(path6)),
1926
1989
  /**
1927
1990
  * Adds an entity to EventCatalog
1928
1991
  *
@@ -1930,33 +1993,33 @@ var index_default = (path5) => {
1930
1993
  * @param options - Optional options to write the entity
1931
1994
  *
1932
1995
  */
1933
- writeEntity: writeEntity(join16(path5, "entities")),
1996
+ writeEntity: writeEntity(join16(path6, "entities")),
1934
1997
  /**
1935
1998
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
1936
1999
  *
1937
2000
  * @param path - The path to your entity, e.g. `/User`
1938
2001
  *
1939
2002
  */
1940
- rmEntity: rmEntity(join16(path5, "entities")),
2003
+ rmEntity: rmEntity(join16(path6, "entities")),
1941
2004
  /**
1942
2005
  * Remove an entity by an entity id
1943
2006
  *
1944
2007
  * @param id - The id of the entity you want to remove
1945
2008
  *
1946
2009
  */
1947
- rmEntityById: rmEntityById(join16(path5)),
2010
+ rmEntityById: rmEntityById(join16(path6)),
1948
2011
  /**
1949
2012
  * Moves a given entity id to the version directory
1950
2013
  * @param id - The id of the entity to version
1951
2014
  */
1952
- versionEntity: versionEntity(join16(path5)),
2015
+ versionEntity: versionEntity(join16(path6)),
1953
2016
  /**
1954
2017
  * Check to see if an entity version exists
1955
2018
  * @param id - The id of the entity
1956
2019
  * @param version - The version of the entity (supports semver)
1957
2020
  * @returns
1958
2021
  */
1959
- entityHasVersion: entityHasVersion(join16(path5)),
2022
+ entityHasVersion: entityHasVersion(join16(path6)),
1960
2023
  /**
1961
2024
  * ================================
1962
2025
  * Data Stores
@@ -1968,42 +2031,42 @@ var index_default = (path5) => {
1968
2031
  * @param options - Optional options to write the data store
1969
2032
  *
1970
2033
  */
1971
- writeDataStore: writeDataStore(join16(path5, "containers")),
2034
+ writeDataStore: writeDataStore(join16(path6, "containers")),
1972
2035
  /**
1973
2036
  * Returns a data store from EventCatalog
1974
2037
  * @param id - The id of the data store to retrieve
1975
2038
  * @param version - Optional id of the version to get (supports semver)
1976
2039
  * @returns Container|Undefined
1977
2040
  */
1978
- getDataStore: getDataStore(join16(path5)),
2041
+ getDataStore: getDataStore(join16(path6)),
1979
2042
  /**
1980
2043
  * Returns all data stores from EventCatalog
1981
2044
  * @param latestOnly - optional boolean, set to true to get only latest versions
1982
2045
  * @returns Container[]|Undefined
1983
2046
  */
1984
- getDataStores: getDataStores(join16(path5)),
2047
+ getDataStores: getDataStores(join16(path6)),
1985
2048
  /**
1986
2049
  * Version a data store by its id
1987
2050
  * @param id - The id of the data store to version
1988
2051
  */
1989
- versionDataStore: versionDataStore(join16(path5, "containers")),
2052
+ versionDataStore: versionDataStore(join16(path6, "containers")),
1990
2053
  /**
1991
2054
  * Remove a data store by its path
1992
2055
  * @param path - The path to the data store to remove
1993
2056
  */
1994
- rmDataStore: rmDataStore(join16(path5, "containers")),
2057
+ rmDataStore: rmDataStore(join16(path6, "containers")),
1995
2058
  /**
1996
2059
  * Remove a data store by its id
1997
2060
  * @param id - The id of the data store to remove
1998
2061
  */
1999
- rmDataStoreById: rmDataStoreById(join16(path5)),
2062
+ rmDataStoreById: rmDataStoreById(join16(path6)),
2000
2063
  /**
2001
2064
  * Check to see if a data store version exists
2002
2065
  * @param id - The id of the data store
2003
2066
  * @param version - The version of the data store (supports semver)
2004
2067
  * @returns
2005
2068
  */
2006
- dataStoreHasVersion: dataStoreHasVersion(join16(path5)),
2069
+ dataStoreHasVersion: dataStoreHasVersion(join16(path6)),
2007
2070
  /**
2008
2071
  * Adds a file to a data store by its id
2009
2072
  * @param id - The id of the data store to add the file to
@@ -2011,14 +2074,14 @@ var index_default = (path5) => {
2011
2074
  * @param version - Optional version of the data store to add the file to
2012
2075
  * @returns
2013
2076
  */
2014
- addFileToDataStore: addFileToDataStore(join16(path5)),
2077
+ addFileToDataStore: addFileToDataStore(join16(path6)),
2015
2078
  /**
2016
2079
  * Writes a data store to a service by its id
2017
2080
  * @param dataStore - The data store to write
2018
2081
  * @param service - The service to write the data store to
2019
2082
  * @returns
2020
2083
  */
2021
- writeDataStoreToService: writeDataStoreToService(join16(path5))
2084
+ writeDataStoreToService: writeDataStoreToService(join16(path6))
2022
2085
  };
2023
2086
  };
2024
2087
  export {