@eventcatalog/sdk 2.5.4 → 2.6.0

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 (52) hide show
  1. package/dist/channels.js +2 -1
  2. package/dist/channels.js.map +1 -1
  3. package/dist/channels.mjs +2 -1
  4. package/dist/channels.mjs.map +1 -1
  5. package/dist/commands.js +2 -1
  6. package/dist/commands.js.map +1 -1
  7. package/dist/commands.mjs +2 -1
  8. package/dist/commands.mjs.map +1 -1
  9. package/dist/custom-docs.js.map +1 -1
  10. package/dist/custom-docs.mjs.map +1 -1
  11. package/dist/domains.js +2 -1
  12. package/dist/domains.js.map +1 -1
  13. package/dist/domains.mjs +2 -1
  14. package/dist/domains.mjs.map +1 -1
  15. package/dist/eventcatalog.js +204 -110
  16. package/dist/eventcatalog.js.map +1 -1
  17. package/dist/eventcatalog.mjs +200 -106
  18. package/dist/eventcatalog.mjs.map +1 -1
  19. package/dist/events.d.mts +4 -4
  20. package/dist/events.d.ts +4 -4
  21. package/dist/events.js +2 -1
  22. package/dist/events.js.map +1 -1
  23. package/dist/events.mjs +2 -1
  24. package/dist/events.mjs.map +1 -1
  25. package/dist/index.d.mts +49 -12
  26. package/dist/index.d.ts +49 -12
  27. package/dist/index.js +204 -110
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +200 -106
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/messages.d.mts +37 -0
  32. package/dist/messages.d.ts +37 -0
  33. package/dist/messages.js +271 -0
  34. package/dist/messages.js.map +1 -0
  35. package/dist/messages.mjs +235 -0
  36. package/dist/messages.mjs.map +1 -0
  37. package/dist/queries.js +2 -1
  38. package/dist/queries.js.map +1 -1
  39. package/dist/queries.mjs +2 -1
  40. package/dist/queries.mjs.map +1 -1
  41. package/dist/services.js +2 -1
  42. package/dist/services.js.map +1 -1
  43. package/dist/services.mjs +2 -1
  44. package/dist/services.mjs.map +1 -1
  45. package/dist/teams.js.map +1 -1
  46. package/dist/teams.mjs.map +1 -1
  47. package/dist/types.d.d.mts +2 -2
  48. package/dist/types.d.d.ts +2 -2
  49. package/dist/types.d.js.map +1 -1
  50. package/dist/users.js.map +1 -1
  51. package/dist/users.mjs.map +1 -1
  52. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  // src/eventcatalog.ts
2
2
  import fs10 from "fs";
3
- import path3, { join as join13 } from "path";
3
+ import path3, { join as join14 } from "path";
4
4
 
5
5
  // src/index.ts
6
- import { join as join12 } from "path";
6
+ import { join as join13 } from "path";
7
7
 
8
8
  // src/events.ts
9
9
  import fs2 from "fs/promises";
@@ -77,7 +77,8 @@ var readMdxFile = async (path4) => {
77
77
  return { ...frontmatter, markdown };
78
78
  };
79
79
  var searchFilesForId = async (files, id, version) => {
80
- const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${id}['"]?\\s*$`, "m");
80
+ const escapedId = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
81
+ const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${escapedId}['"]?\\s*$`, "m");
81
82
  const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
82
83
  const matches = files.map((file) => {
83
84
  const content = fsSync.readFileSync(file, "utf-8");
@@ -294,6 +295,12 @@ var getFileFromResource = async (catalogDir, id, file, version) => {
294
295
  var getVersionedDirectory = (sourceDirectory, version) => {
295
296
  return join2(sourceDirectory, "versioned", version);
296
297
  };
298
+ var isLatestVersion = async (catalogDir, id, version) => {
299
+ const resource = await getResource(catalogDir, id, version);
300
+ if (!resource) return false;
301
+ const pathToResource = await getResourcePath(catalogDir, id, version);
302
+ return !pathToResource?.relativePath.replace(/\\/g, "/").includes("/versioned/");
303
+ };
297
304
 
298
305
  // src/events.ts
299
306
  var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
@@ -635,11 +642,79 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
635
642
  await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
636
643
  };
637
644
 
645
+ // src/messages.ts
646
+ import { dirname as dirname5 } from "path";
647
+ import matter4 from "gray-matter";
648
+ var getMessageBySchemaPath = (directory) => async (path4, options) => {
649
+ const pathToMessage = dirname5(path4);
650
+ try {
651
+ const files = await getFiles(`${pathToMessage}/index.{md,mdx}`);
652
+ if (!files || files.length === 0) {
653
+ throw new Error(`No message definition file (index.md or index.mdx) found in directory: ${pathToMessage}`);
654
+ }
655
+ const messageFile = files[0];
656
+ const { data } = matter4.read(messageFile);
657
+ const { id, version } = data;
658
+ if (!id || !version) {
659
+ throw new Error(`Message definition file at ${messageFile} is missing 'id' or 'version' in its frontmatter.`);
660
+ }
661
+ const message = await getResource(directory, id, version, { type: "message", ...options });
662
+ if (!message) {
663
+ throw new Error(`Message resource with id '${id}' and version '${version}' not found, as referenced in ${messageFile}.`);
664
+ }
665
+ return message;
666
+ } catch (error) {
667
+ console.error(`Failed to get message for schema path ${path4}. Error processing directory ${pathToMessage}:`, error);
668
+ if (error instanceof Error) {
669
+ error.message = `Failed to retrieve message from ${pathToMessage}: ${error.message}`;
670
+ throw error;
671
+ }
672
+ throw new Error(`Failed to retrieve message from ${pathToMessage} due to an unknown error.`);
673
+ }
674
+ };
675
+ var getProducersAndConsumersForMessage = (directory) => async (id, version) => {
676
+ const services = await getServices(directory)({ latestOnly: true });
677
+ const message = await getResource(directory, id, version, { type: "message" });
678
+ const isMessageLatestVersion = await isLatestVersion(directory, id, version);
679
+ if (!message) {
680
+ throw new Error(`Message resource with id '${id}' and version '${version}' not found.`);
681
+ }
682
+ const producers = [];
683
+ const consumers = [];
684
+ for (const service of services) {
685
+ const servicePublishesMessage = service.sends?.some((_message) => {
686
+ if (_message.version) {
687
+ return _message.id === message.id && _message.version === message.version;
688
+ }
689
+ if (isMessageLatestVersion && _message.id === message.id) {
690
+ return true;
691
+ }
692
+ return false;
693
+ });
694
+ const serviceSubscribesToMessage = service.receives?.some((_message) => {
695
+ if (_message.version) {
696
+ return _message.id === message.id && _message.version === message.version;
697
+ }
698
+ if (isMessageLatestVersion && _message.id === message.id) {
699
+ return true;
700
+ }
701
+ return false;
702
+ });
703
+ if (servicePublishesMessage) {
704
+ producers.push(service);
705
+ }
706
+ if (serviceSubscribesToMessage) {
707
+ consumers.push(service);
708
+ }
709
+ }
710
+ return { producers, consumers };
711
+ };
712
+
638
713
  // src/custom-docs.ts
639
- import path2, { join as join9 } from "path";
714
+ import path2, { join as join10 } from "path";
640
715
  import fsSync4 from "fs";
641
716
  import fs8 from "fs/promises";
642
- import matter4 from "gray-matter";
717
+ import matter5 from "gray-matter";
643
718
  import slugify from "slugify";
644
719
  var getCustomDoc = (directory) => async (filePath) => {
645
720
  const fullPath = path2.join(directory, filePath);
@@ -663,24 +738,24 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
663
738
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
664
739
  const fullPath = path2.join(directory, options.path || "", withExtension);
665
740
  fsSync4.mkdirSync(path2.dirname(fullPath), { recursive: true });
666
- const document = matter4.stringify(customDoc.markdown.trim(), rest);
741
+ const document = matter5.stringify(customDoc.markdown.trim(), rest);
667
742
  fsSync4.writeFileSync(fullPath, document);
668
743
  };
669
744
  var rmCustomDoc = (directory) => async (filePath) => {
670
745
  const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
671
- await fs8.rm(join9(directory, withExtension), { recursive: true });
746
+ await fs8.rm(join10(directory, withExtension), { recursive: true });
672
747
  };
673
748
 
674
749
  // src/teams.ts
675
750
  import fs9 from "fs/promises";
676
751
  import fsSync5 from "fs";
677
- import { join as join10 } from "path";
678
- import matter5 from "gray-matter";
752
+ import { join as join11 } from "path";
753
+ import matter6 from "gray-matter";
679
754
  var getTeam = (catalogDir) => async (id) => {
680
755
  const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
681
756
  if (files.length == 0) return void 0;
682
757
  const file = files[0];
683
- const { data, content } = matter5.read(file);
758
+ const { data, content } = matter6.read(file);
684
759
  return {
685
760
  ...data,
686
761
  id: data.id,
@@ -692,7 +767,7 @@ var getTeams = (catalogDir) => async (options) => {
692
767
  const files = await getFiles(`${catalogDir}/teams/*.{md,mdx}`);
693
768
  if (files.length === 0) return [];
694
769
  return files.map((file) => {
695
- const { data, content } = matter5.read(file);
770
+ const { data, content } = matter6.read(file);
696
771
  return {
697
772
  ...data,
698
773
  id: data.id,
@@ -709,23 +784,23 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
709
784
  throw new Error(`Failed to write ${resource.id} (team) as it already exists`);
710
785
  }
711
786
  const { markdown, ...frontmatter } = resource;
712
- const document = matter5.stringify(markdown, frontmatter);
713
- fsSync5.mkdirSync(join10(catalogDir, ""), { recursive: true });
714
- fsSync5.writeFileSync(join10(catalogDir, "", `${resource.id}.mdx`), document);
787
+ const document = matter6.stringify(markdown, frontmatter);
788
+ fsSync5.mkdirSync(join11(catalogDir, ""), { recursive: true });
789
+ fsSync5.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
715
790
  };
716
791
  var rmTeamById = (catalogDir) => async (id) => {
717
- await fs9.rm(join10(catalogDir, `${id}.mdx`), { recursive: true });
792
+ await fs9.rm(join11(catalogDir, `${id}.mdx`), { recursive: true });
718
793
  };
719
794
 
720
795
  // src/users.ts
721
796
  import fsSync6 from "fs";
722
- import { join as join11 } from "path";
723
- import matter6 from "gray-matter";
797
+ import { join as join12 } from "path";
798
+ import matter7 from "gray-matter";
724
799
  var getUser = (catalogDir) => async (id) => {
725
800
  const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
726
801
  if (files.length == 0) return void 0;
727
802
  const file = files[0];
728
- const { data, content } = matter6.read(file);
803
+ const { data, content } = matter7.read(file);
729
804
  return {
730
805
  ...data,
731
806
  id: data.id,
@@ -738,7 +813,7 @@ var getUsers = (catalogDir) => async (options) => {
738
813
  const files = await getFiles(`${catalogDir}/users/*.{md,mdx}`);
739
814
  if (files.length === 0) return [];
740
815
  return files.map((file) => {
741
- const { data, content } = matter6.read(file);
816
+ const { data, content } = matter7.read(file);
742
817
  return {
743
818
  ...data,
744
819
  id: data.id,
@@ -756,12 +831,12 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
756
831
  throw new Error(`Failed to write ${resource.id} (user) as it already exists`);
757
832
  }
758
833
  const { markdown, ...frontmatter } = resource;
759
- const document = matter6.stringify(markdown, frontmatter);
760
- fsSync6.mkdirSync(join11(catalogDir, ""), { recursive: true });
761
- fsSync6.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
834
+ const document = matter7.stringify(markdown, frontmatter);
835
+ fsSync6.mkdirSync(join12(catalogDir, ""), { recursive: true });
836
+ fsSync6.writeFileSync(join12(catalogDir, "", `${resource.id}.mdx`), document);
762
837
  };
763
838
  var rmUserById = (catalogDir) => async (id) => {
764
- fsSync6.rmSync(join11(catalogDir, `${id}.mdx`), { recursive: true });
839
+ fsSync6.rmSync(join12(catalogDir, `${id}.mdx`), { recursive: true });
765
840
  };
766
841
 
767
842
  // src/index.ts
@@ -773,13 +848,13 @@ var index_default = (path4) => {
773
848
  * @param version - Optional id of the version to get (supports semver)
774
849
  * @returns Event|Undefined
775
850
  */
776
- getEvent: getEvent(join12(path4)),
851
+ getEvent: getEvent(join13(path4)),
777
852
  /**
778
853
  * Returns all events from EventCatalog
779
854
  * @param latestOnly - optional boolean, set to true to get only latest versions
780
855
  * @returns Event[]|Undefined
781
856
  */
782
- getEvents: getEvents(join12(path4)),
857
+ getEvents: getEvents(join13(path4)),
783
858
  /**
784
859
  * Adds an event to EventCatalog
785
860
  *
@@ -787,7 +862,7 @@ var index_default = (path4) => {
787
862
  * @param options - Optional options to write the event
788
863
  *
789
864
  */
790
- writeEvent: writeEvent(join12(path4, "events")),
865
+ writeEvent: writeEvent(join13(path4, "events")),
791
866
  /**
792
867
  * Adds an event to a service in EventCatalog
793
868
  *
@@ -796,26 +871,26 @@ var index_default = (path4) => {
796
871
  * @param options - Optional options to write the event
797
872
  *
798
873
  */
799
- writeEventToService: writeEventToService(join12(path4)),
874
+ writeEventToService: writeEventToService(join13(path4)),
800
875
  /**
801
876
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
802
877
  *
803
878
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
804
879
  *
805
880
  */
806
- rmEvent: rmEvent(join12(path4, "events")),
881
+ rmEvent: rmEvent(join13(path4, "events")),
807
882
  /**
808
883
  * Remove an event by an Event id
809
884
  *
810
885
  * @param id - The id of the event you want to remove
811
886
  *
812
887
  */
813
- rmEventById: rmEventById(join12(path4)),
888
+ rmEventById: rmEventById(join13(path4)),
814
889
  /**
815
890
  * Moves a given event id to the version directory
816
891
  * @param directory
817
892
  */
818
- versionEvent: versionEvent(join12(path4)),
893
+ versionEvent: versionEvent(join13(path4)),
819
894
  /**
820
895
  * Adds a file to the given event
821
896
  * @param id - The id of the event to add the file to
@@ -823,7 +898,7 @@ var index_default = (path4) => {
823
898
  * @param version - Optional version of the event to add the file to
824
899
  * @returns
825
900
  */
826
- addFileToEvent: addFileToEvent(join12(path4)),
901
+ addFileToEvent: addFileToEvent(join13(path4)),
827
902
  /**
828
903
  * Adds a schema to the given event
829
904
  * @param id - The id of the event to add the schema to
@@ -831,14 +906,14 @@ var index_default = (path4) => {
831
906
  * @param version - Optional version of the event to add the schema to
832
907
  * @returns
833
908
  */
834
- addSchemaToEvent: addSchemaToEvent(join12(path4)),
909
+ addSchemaToEvent: addSchemaToEvent(join13(path4)),
835
910
  /**
836
911
  * Check to see if an event version exists
837
912
  * @param id - The id of the event
838
913
  * @param version - The version of the event (supports semver)
839
914
  * @returns
840
915
  */
841
- eventHasVersion: eventHasVersion(join12(path4)),
916
+ eventHasVersion: eventHasVersion(join13(path4)),
842
917
  /**
843
918
  * ================================
844
919
  * Commands
@@ -850,13 +925,13 @@ var index_default = (path4) => {
850
925
  * @param version - Optional id of the version to get (supports semver)
851
926
  * @returns Command|Undefined
852
927
  */
853
- getCommand: getCommand(join12(path4)),
928
+ getCommand: getCommand(join13(path4)),
854
929
  /**
855
930
  * Returns all commands from EventCatalog
856
931
  * @param latestOnly - optional boolean, set to true to get only latest versions
857
932
  * @returns Command[]|Undefined
858
933
  */
859
- getCommands: getCommands(join12(path4)),
934
+ getCommands: getCommands(join13(path4)),
860
935
  /**
861
936
  * Adds an command to EventCatalog
862
937
  *
@@ -864,7 +939,7 @@ var index_default = (path4) => {
864
939
  * @param options - Optional options to write the command
865
940
  *
866
941
  */
867
- writeCommand: writeCommand(join12(path4, "commands")),
942
+ writeCommand: writeCommand(join13(path4, "commands")),
868
943
  /**
869
944
  * Adds a command to a service in EventCatalog
870
945
  *
@@ -873,26 +948,26 @@ var index_default = (path4) => {
873
948
  * @param options - Optional options to write the command
874
949
  *
875
950
  */
876
- writeCommandToService: writeCommandToService(join12(path4)),
951
+ writeCommandToService: writeCommandToService(join13(path4)),
877
952
  /**
878
953
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
879
954
  *
880
955
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
881
956
  *
882
957
  */
883
- rmCommand: rmCommand(join12(path4, "commands")),
958
+ rmCommand: rmCommand(join13(path4, "commands")),
884
959
  /**
885
960
  * Remove an command by an Event id
886
961
  *
887
962
  * @param id - The id of the command you want to remove
888
963
  *
889
964
  */
890
- rmCommandById: rmCommandById(join12(path4)),
965
+ rmCommandById: rmCommandById(join13(path4)),
891
966
  /**
892
967
  * Moves a given command id to the version directory
893
968
  * @param directory
894
969
  */
895
- versionCommand: versionCommand(join12(path4)),
970
+ versionCommand: versionCommand(join13(path4)),
896
971
  /**
897
972
  * Adds a file to the given command
898
973
  * @param id - The id of the command to add the file to
@@ -900,7 +975,7 @@ var index_default = (path4) => {
900
975
  * @param version - Optional version of the command to add the file to
901
976
  * @returns
902
977
  */
903
- addFileToCommand: addFileToCommand(join12(path4)),
978
+ addFileToCommand: addFileToCommand(join13(path4)),
904
979
  /**
905
980
  * Adds a schema to the given command
906
981
  * @param id - The id of the command to add the schema to
@@ -908,14 +983,14 @@ var index_default = (path4) => {
908
983
  * @param version - Optional version of the command to add the schema to
909
984
  * @returns
910
985
  */
911
- addSchemaToCommand: addSchemaToCommand(join12(path4)),
986
+ addSchemaToCommand: addSchemaToCommand(join13(path4)),
912
987
  /**
913
988
  * Check to see if a command version exists
914
989
  * @param id - The id of the command
915
990
  * @param version - The version of the command (supports semver)
916
991
  * @returns
917
992
  */
918
- commandHasVersion: commandHasVersion(join12(path4)),
993
+ commandHasVersion: commandHasVersion(join13(path4)),
919
994
  /**
920
995
  * ================================
921
996
  * Queries
@@ -927,13 +1002,13 @@ var index_default = (path4) => {
927
1002
  * @param version - Optional id of the version to get (supports semver)
928
1003
  * @returns Query|Undefined
929
1004
  */
930
- getQuery: getQuery(join12(path4)),
1005
+ getQuery: getQuery(join13(path4)),
931
1006
  /**
932
1007
  * Returns all queries from EventCatalog
933
1008
  * @param latestOnly - optional boolean, set to true to get only latest versions
934
1009
  * @returns Query[]|Undefined
935
1010
  */
936
- getQueries: getQueries(join12(path4)),
1011
+ getQueries: getQueries(join13(path4)),
937
1012
  /**
938
1013
  * Adds a query to EventCatalog
939
1014
  *
@@ -941,7 +1016,7 @@ var index_default = (path4) => {
941
1016
  * @param options - Optional options to write the event
942
1017
  *
943
1018
  */
944
- writeQuery: writeQuery(join12(path4, "queries")),
1019
+ writeQuery: writeQuery(join13(path4, "queries")),
945
1020
  /**
946
1021
  * Adds a query to a service in EventCatalog
947
1022
  *
@@ -950,26 +1025,26 @@ var index_default = (path4) => {
950
1025
  * @param options - Optional options to write the query
951
1026
  *
952
1027
  */
953
- writeQueryToService: writeQueryToService(join12(path4)),
1028
+ writeQueryToService: writeQueryToService(join13(path4)),
954
1029
  /**
955
1030
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
956
1031
  *
957
1032
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
958
1033
  *
959
1034
  */
960
- rmQuery: rmQuery(join12(path4, "queries")),
1035
+ rmQuery: rmQuery(join13(path4, "queries")),
961
1036
  /**
962
1037
  * Remove a query by a Query id
963
1038
  *
964
1039
  * @param id - The id of the query you want to remove
965
1040
  *
966
1041
  */
967
- rmQueryById: rmQueryById(join12(path4)),
1042
+ rmQueryById: rmQueryById(join13(path4)),
968
1043
  /**
969
1044
  * Moves a given query id to the version directory
970
1045
  * @param directory
971
1046
  */
972
- versionQuery: versionQuery(join12(path4)),
1047
+ versionQuery: versionQuery(join13(path4)),
973
1048
  /**
974
1049
  * Adds a file to the given query
975
1050
  * @param id - The id of the query to add the file to
@@ -977,7 +1052,7 @@ var index_default = (path4) => {
977
1052
  * @param version - Optional version of the query to add the file to
978
1053
  * @returns
979
1054
  */
980
- addFileToQuery: addFileToQuery(join12(path4)),
1055
+ addFileToQuery: addFileToQuery(join13(path4)),
981
1056
  /**
982
1057
  * Adds a schema to the given query
983
1058
  * @param id - The id of the query to add the schema to
@@ -985,14 +1060,14 @@ var index_default = (path4) => {
985
1060
  * @param version - Optional version of the query to add the schema to
986
1061
  * @returns
987
1062
  */
988
- addSchemaToQuery: addSchemaToQuery(join12(path4)),
1063
+ addSchemaToQuery: addSchemaToQuery(join13(path4)),
989
1064
  /**
990
1065
  * Check to see if an query version exists
991
1066
  * @param id - The id of the query
992
1067
  * @param version - The version of the query (supports semver)
993
1068
  * @returns
994
1069
  */
995
- queryHasVersion: queryHasVersion(join12(path4)),
1070
+ queryHasVersion: queryHasVersion(join13(path4)),
996
1071
  /**
997
1072
  * ================================
998
1073
  * Channels
@@ -1004,13 +1079,13 @@ var index_default = (path4) => {
1004
1079
  * @param version - Optional id of the version to get (supports semver)
1005
1080
  * @returns Channel|Undefined
1006
1081
  */
1007
- getChannel: getChannel(join12(path4)),
1082
+ getChannel: getChannel(join13(path4)),
1008
1083
  /**
1009
1084
  * Returns all channels from EventCatalog
1010
1085
  * @param latestOnly - optional boolean, set to true to get only latest versions
1011
1086
  * @returns Channel[]|Undefined
1012
1087
  */
1013
- getChannels: getChannels(join12(path4)),
1088
+ getChannels: getChannels(join13(path4)),
1014
1089
  /**
1015
1090
  * Adds an channel to EventCatalog
1016
1091
  *
@@ -1018,33 +1093,33 @@ var index_default = (path4) => {
1018
1093
  * @param options - Optional options to write the channel
1019
1094
  *
1020
1095
  */
1021
- writeChannel: writeChannel(join12(path4, "channels")),
1096
+ writeChannel: writeChannel(join13(path4, "channels")),
1022
1097
  /**
1023
1098
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1024
1099
  *
1025
1100
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1026
1101
  *
1027
1102
  */
1028
- rmChannel: rmChannel(join12(path4, "channels")),
1103
+ rmChannel: rmChannel(join13(path4, "channels")),
1029
1104
  /**
1030
1105
  * Remove an channel by an Event id
1031
1106
  *
1032
1107
  * @param id - The id of the channel you want to remove
1033
1108
  *
1034
1109
  */
1035
- rmChannelById: rmChannelById(join12(path4)),
1110
+ rmChannelById: rmChannelById(join13(path4)),
1036
1111
  /**
1037
1112
  * Moves a given channel id to the version directory
1038
1113
  * @param directory
1039
1114
  */
1040
- versionChannel: versionChannel(join12(path4)),
1115
+ versionChannel: versionChannel(join13(path4)),
1041
1116
  /**
1042
1117
  * Check to see if a channel version exists
1043
1118
  * @param id - The id of the channel
1044
1119
  * @param version - The version of the channel (supports semver)
1045
1120
  * @returns
1046
1121
  */
1047
- channelHasVersion: channelHasVersion(join12(path4)),
1122
+ channelHasVersion: channelHasVersion(join13(path4)),
1048
1123
  /**
1049
1124
  * Add a channel to an event
1050
1125
  *
@@ -1061,7 +1136,7 @@ var index_default = (path4) => {
1061
1136
  *
1062
1137
  * ```
1063
1138
  */
1064
- addEventToChannel: addMessageToChannel(join12(path4), "events"),
1139
+ addEventToChannel: addMessageToChannel(join13(path4), "events"),
1065
1140
  /**
1066
1141
  * Add a channel to an command
1067
1142
  *
@@ -1078,7 +1153,7 @@ var index_default = (path4) => {
1078
1153
  *
1079
1154
  * ```
1080
1155
  */
1081
- addCommandToChannel: addMessageToChannel(join12(path4), "commands"),
1156
+ addCommandToChannel: addMessageToChannel(join13(path4), "commands"),
1082
1157
  /**
1083
1158
  * Add a channel to an query
1084
1159
  *
@@ -1095,7 +1170,7 @@ var index_default = (path4) => {
1095
1170
  *
1096
1171
  * ```
1097
1172
  */
1098
- addQueryToChannel: addMessageToChannel(join12(path4), "queries"),
1173
+ addQueryToChannel: addMessageToChannel(join13(path4), "queries"),
1099
1174
  /**
1100
1175
  * ================================
1101
1176
  * SERVICES
@@ -1108,14 +1183,14 @@ var index_default = (path4) => {
1108
1183
  * @param options - Optional options to write the event
1109
1184
  *
1110
1185
  */
1111
- writeService: writeService(join12(path4, "services")),
1186
+ writeService: writeService(join13(path4, "services")),
1112
1187
  /**
1113
1188
  * Adds a versioned service to EventCatalog
1114
1189
  *
1115
1190
  * @param service - The service to write
1116
1191
  *
1117
1192
  */
1118
- writeVersionedService: writeVersionedService(join12(path4, "services")),
1193
+ writeVersionedService: writeVersionedService(join13(path4, "services")),
1119
1194
  /**
1120
1195
  * Adds a service to a domain in EventCatalog
1121
1196
  *
@@ -1124,39 +1199,39 @@ var index_default = (path4) => {
1124
1199
  * @param options - Optional options to write the event
1125
1200
  *
1126
1201
  */
1127
- writeServiceToDomain: writeServiceToDomain(join12(path4, "domains")),
1202
+ writeServiceToDomain: writeServiceToDomain(join13(path4, "domains")),
1128
1203
  /**
1129
1204
  * Returns a service from EventCatalog
1130
1205
  * @param id - The id of the service to retrieve
1131
1206
  * @param version - Optional id of the version to get (supports semver)
1132
1207
  * @returns Service|Undefined
1133
1208
  */
1134
- getService: getService(join12(path4)),
1209
+ getService: getService(join13(path4)),
1135
1210
  /**
1136
1211
  * Returns all services from EventCatalog
1137
1212
  * @param latestOnly - optional boolean, set to true to get only latest versions
1138
1213
  * @returns Service[]|Undefined
1139
1214
  */
1140
- getServices: getServices(join12(path4)),
1215
+ getServices: getServices(join13(path4)),
1141
1216
  /**
1142
1217
  * Moves a given service id to the version directory
1143
1218
  * @param directory
1144
1219
  */
1145
- versionService: versionService(join12(path4)),
1220
+ versionService: versionService(join13(path4)),
1146
1221
  /**
1147
1222
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1148
1223
  *
1149
1224
  * @param path - The path to your service, e.g. `/InventoryService`
1150
1225
  *
1151
1226
  */
1152
- rmService: rmService(join12(path4, "services")),
1227
+ rmService: rmService(join13(path4, "services")),
1153
1228
  /**
1154
1229
  * Remove an service by an service id
1155
1230
  *
1156
1231
  * @param id - The id of the service you want to remove
1157
1232
  *
1158
1233
  */
1159
- rmServiceById: rmServiceById(join12(path4)),
1234
+ rmServiceById: rmServiceById(join13(path4)),
1160
1235
  /**
1161
1236
  * Adds a file to the given service
1162
1237
  * @param id - The id of the service to add the file to
@@ -1164,21 +1239,21 @@ var index_default = (path4) => {
1164
1239
  * @param version - Optional version of the service to add the file to
1165
1240
  * @returns
1166
1241
  */
1167
- addFileToService: addFileToService(join12(path4)),
1242
+ addFileToService: addFileToService(join13(path4)),
1168
1243
  /**
1169
1244
  * Returns the specifications for a given service
1170
1245
  * @param id - The id of the service to retrieve the specifications for
1171
1246
  * @param version - Optional version of the service
1172
1247
  * @returns
1173
1248
  */
1174
- getSpecificationFilesForService: getSpecificationFilesForService(join12(path4)),
1249
+ getSpecificationFilesForService: getSpecificationFilesForService(join13(path4)),
1175
1250
  /**
1176
1251
  * Check to see if a service version exists
1177
1252
  * @param id - The id of the service
1178
1253
  * @param version - The version of the service (supports semver)
1179
1254
  * @returns
1180
1255
  */
1181
- serviceHasVersion: serviceHasVersion(join12(path4)),
1256
+ serviceHasVersion: serviceHasVersion(join13(path4)),
1182
1257
  /**
1183
1258
  * Add an event to a service by it's id.
1184
1259
  *
@@ -1198,7 +1273,7 @@ var index_default = (path4) => {
1198
1273
  *
1199
1274
  * ```
1200
1275
  */
1201
- addEventToService: addMessageToService(join12(path4)),
1276
+ addEventToService: addMessageToService(join13(path4)),
1202
1277
  /**
1203
1278
  * Add a command to a service by it's id.
1204
1279
  *
@@ -1218,7 +1293,7 @@ var index_default = (path4) => {
1218
1293
  *
1219
1294
  * ```
1220
1295
  */
1221
- addCommandToService: addMessageToService(join12(path4)),
1296
+ addCommandToService: addMessageToService(join13(path4)),
1222
1297
  /**
1223
1298
  * Add a query to a service by it's id.
1224
1299
  *
@@ -1238,7 +1313,7 @@ var index_default = (path4) => {
1238
1313
  *
1239
1314
  * ```
1240
1315
  */
1241
- addQueryToService: addMessageToService(join12(path4)),
1316
+ addQueryToService: addMessageToService(join13(path4)),
1242
1317
  /**
1243
1318
  * ================================
1244
1319
  * Domains
@@ -1251,39 +1326,39 @@ var index_default = (path4) => {
1251
1326
  * @param options - Optional options to write the event
1252
1327
  *
1253
1328
  */
1254
- writeDomain: writeDomain(join12(path4, "domains")),
1329
+ writeDomain: writeDomain(join13(path4, "domains")),
1255
1330
  /**
1256
1331
  * Returns a domain from EventCatalog
1257
1332
  * @param id - The id of the domain to retrieve
1258
1333
  * @param version - Optional id of the version to get (supports semver)
1259
1334
  * @returns Domain|Undefined
1260
1335
  */
1261
- getDomain: getDomain(join12(path4, "domains")),
1336
+ getDomain: getDomain(join13(path4, "domains")),
1262
1337
  /**
1263
1338
  * Returns all domains from EventCatalog
1264
1339
  * @param latestOnly - optional boolean, set to true to get only latest versions
1265
1340
  * @returns Domain[]|Undefined
1266
1341
  */
1267
- getDomains: getDomains(join12(path4)),
1342
+ getDomains: getDomains(join13(path4)),
1268
1343
  /**
1269
1344
  * Moves a given domain id to the version directory
1270
1345
  * @param directory
1271
1346
  */
1272
- versionDomain: versionDomain(join12(path4, "domains")),
1347
+ versionDomain: versionDomain(join13(path4, "domains")),
1273
1348
  /**
1274
1349
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1275
1350
  *
1276
1351
  * @param path - The path to your domain, e.g. `/Payment`
1277
1352
  *
1278
1353
  */
1279
- rmDomain: rmDomain(join12(path4, "domains")),
1354
+ rmDomain: rmDomain(join13(path4, "domains")),
1280
1355
  /**
1281
1356
  * Remove an service by an domain id
1282
1357
  *
1283
1358
  * @param id - The id of the domain you want to remove
1284
1359
  *
1285
1360
  */
1286
- rmDomainById: rmDomainById(join12(path4, "domains")),
1361
+ rmDomainById: rmDomainById(join13(path4, "domains")),
1287
1362
  /**
1288
1363
  * Adds a file to the given domain
1289
1364
  * @param id - The id of the domain to add the file to
@@ -1291,28 +1366,28 @@ var index_default = (path4) => {
1291
1366
  * @param version - Optional version of the domain to add the file to
1292
1367
  * @returns
1293
1368
  */
1294
- addFileToDomain: addFileToDomain(join12(path4, "domains")),
1369
+ addFileToDomain: addFileToDomain(join13(path4, "domains")),
1295
1370
  /**
1296
1371
  * Adds an ubiquitous language dictionary to a domain
1297
1372
  * @param id - The id of the domain to add the ubiquitous language to
1298
1373
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1299
1374
  * @param version - Optional version of the domain to add the ubiquitous language to
1300
1375
  */
1301
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join12(path4, "domains")),
1376
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join13(path4, "domains")),
1302
1377
  /**
1303
1378
  * Get the ubiquitous language dictionary from a domain
1304
1379
  * @param id - The id of the domain to get the ubiquitous language from
1305
1380
  * @param version - Optional version of the domain to get the ubiquitous language from
1306
1381
  * @returns
1307
1382
  */
1308
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join12(path4, "domains")),
1383
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join13(path4, "domains")),
1309
1384
  /**
1310
1385
  * Check to see if a domain version exists
1311
1386
  * @param id - The id of the domain
1312
1387
  * @param version - The version of the domain (supports semver)
1313
1388
  * @returns
1314
1389
  */
1315
- domainHasVersion: domainHasVersion(join12(path4)),
1390
+ domainHasVersion: domainHasVersion(join13(path4)),
1316
1391
  /**
1317
1392
  * Adds a given service to a domain
1318
1393
  * @param id - The id of the domain
@@ -1320,7 +1395,7 @@ var index_default = (path4) => {
1320
1395
  * @param version - (Optional) The version of the domain to add the service to
1321
1396
  * @returns
1322
1397
  */
1323
- addServiceToDomain: addServiceToDomain(join12(path4, "domains")),
1398
+ addServiceToDomain: addServiceToDomain(join13(path4, "domains")),
1324
1399
  /**
1325
1400
  * Adds a given subdomain to a domain
1326
1401
  * @param id - The id of the domain
@@ -1328,7 +1403,7 @@ var index_default = (path4) => {
1328
1403
  * @param version - (Optional) The version of the domain to add the subdomain to
1329
1404
  * @returns
1330
1405
  */
1331
- addSubDomainToDomain: addSubDomainToDomain(join12(path4, "domains")),
1406
+ addSubDomainToDomain: addSubDomainToDomain(join13(path4, "domains")),
1332
1407
  /**
1333
1408
  * ================================
1334
1409
  * Teams
@@ -1341,25 +1416,25 @@ var index_default = (path4) => {
1341
1416
  * @param options - Optional options to write the team
1342
1417
  *
1343
1418
  */
1344
- writeTeam: writeTeam(join12(path4, "teams")),
1419
+ writeTeam: writeTeam(join13(path4, "teams")),
1345
1420
  /**
1346
1421
  * Returns a team from EventCatalog
1347
1422
  * @param id - The id of the team to retrieve
1348
1423
  * @returns Team|Undefined
1349
1424
  */
1350
- getTeam: getTeam(join12(path4, "teams")),
1425
+ getTeam: getTeam(join13(path4, "teams")),
1351
1426
  /**
1352
1427
  * Returns all teams from EventCatalog
1353
1428
  * @returns Team[]|Undefined
1354
1429
  */
1355
- getTeams: getTeams(join12(path4)),
1430
+ getTeams: getTeams(join13(path4)),
1356
1431
  /**
1357
1432
  * Remove a team by the team id
1358
1433
  *
1359
1434
  * @param id - The id of the team you want to remove
1360
1435
  *
1361
1436
  */
1362
- rmTeamById: rmTeamById(join12(path4, "teams")),
1437
+ rmTeamById: rmTeamById(join13(path4, "teams")),
1363
1438
  /**
1364
1439
  * ================================
1365
1440
  * Users
@@ -1372,25 +1447,25 @@ var index_default = (path4) => {
1372
1447
  * @param options - Optional options to write the user
1373
1448
  *
1374
1449
  */
1375
- writeUser: writeUser(join12(path4, "users")),
1450
+ writeUser: writeUser(join13(path4, "users")),
1376
1451
  /**
1377
1452
  * Returns a user from EventCatalog
1378
1453
  * @param id - The id of the user to retrieve
1379
1454
  * @returns User|Undefined
1380
1455
  */
1381
- getUser: getUser(join12(path4, "users")),
1456
+ getUser: getUser(join13(path4, "users")),
1382
1457
  /**
1383
1458
  * Returns all user from EventCatalog
1384
1459
  * @returns User[]|Undefined
1385
1460
  */
1386
- getUsers: getUsers(join12(path4)),
1461
+ getUsers: getUsers(join13(path4)),
1387
1462
  /**
1388
1463
  * Remove a user by the user id
1389
1464
  *
1390
1465
  * @param id - The id of the user you want to remove
1391
1466
  *
1392
1467
  */
1393
- rmUserById: rmUserById(join12(path4, "users")),
1468
+ rmUserById: rmUserById(join13(path4, "users")),
1394
1469
  /**
1395
1470
  * ================================
1396
1471
  * Custom Docs
@@ -1401,32 +1476,32 @@ var index_default = (path4) => {
1401
1476
  * @param path - The path to the custom doc to retrieve
1402
1477
  * @returns CustomDoc|Undefined
1403
1478
  */
1404
- getCustomDoc: getCustomDoc(join12(path4, "docs")),
1479
+ getCustomDoc: getCustomDoc(join13(path4, "docs")),
1405
1480
  /**
1406
1481
  * Returns all custom docs from EventCatalog
1407
1482
  * @param options - Optional options to get custom docs from a specific path
1408
1483
  * @returns CustomDoc[]|Undefined
1409
1484
  */
1410
- getCustomDocs: getCustomDocs(join12(path4, "docs")),
1485
+ getCustomDocs: getCustomDocs(join13(path4, "docs")),
1411
1486
  /**
1412
1487
  * Writes a custom doc to EventCatalog
1413
1488
  * @param customDoc - The custom doc to write
1414
1489
  * @param options - Optional options to write the custom doc
1415
1490
  *
1416
1491
  */
1417
- writeCustomDoc: writeCustomDoc(join12(path4, "docs")),
1492
+ writeCustomDoc: writeCustomDoc(join13(path4, "docs")),
1418
1493
  /**
1419
1494
  * Removes a custom doc from EventCatalog
1420
1495
  * @param path - The path to the custom doc to remove
1421
1496
  *
1422
1497
  */
1423
- rmCustomDoc: rmCustomDoc(join12(path4, "docs")),
1498
+ rmCustomDoc: rmCustomDoc(join13(path4, "docs")),
1424
1499
  /**
1425
1500
  * Dumps the catalog to a JSON file.
1426
1501
  * @param directory - The directory to dump the catalog to
1427
1502
  * @returns A JSON file with the catalog
1428
1503
  */
1429
- dumpCatalog: dumpCatalog(join12(path4)),
1504
+ dumpCatalog: dumpCatalog(join13(path4)),
1430
1505
  /**
1431
1506
  * Returns the event catalog configuration file.
1432
1507
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1434,7 +1509,7 @@ var index_default = (path4) => {
1434
1509
  * @param directory - The directory of the catalog.
1435
1510
  * @returns A JSON object with the configuration for the event catalog.
1436
1511
  */
1437
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join12(path4)),
1512
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join13(path4)),
1438
1513
  /**
1439
1514
  * ================================
1440
1515
  * Resources Utils
@@ -1443,7 +1518,26 @@ var index_default = (path4) => {
1443
1518
  /**
1444
1519
  * Returns the path to a given resource by id and version
1445
1520
  */
1446
- getResourcePath
1521
+ getResourcePath,
1522
+ /**
1523
+ * ================================
1524
+ * General Message Utils
1525
+ * ================================
1526
+ */
1527
+ /**
1528
+ * Returns a message from EventCatalog by a given schema path.
1529
+ *
1530
+ * @param path - The path to the message to retrieve
1531
+ * @returns Message|Undefined
1532
+ */
1533
+ getMessageBySchemaPath: getMessageBySchemaPath(join13(path4)),
1534
+ /**
1535
+ * Returns the producers and consumers (services) for a given message
1536
+ * @param id - The id of the message to get the producers and consumers for
1537
+ * @param version - Optional version of the message
1538
+ * @returns { producers: Service[], consumers: Service[] }
1539
+ */
1540
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join13(path4))
1447
1541
  };
1448
1542
  };
1449
1543
 
@@ -1451,7 +1545,7 @@ var index_default = (path4) => {
1451
1545
  var DUMP_VERSION = "0.0.1";
1452
1546
  var getEventCatalogVersion = async (catalogDir) => {
1453
1547
  try {
1454
- const packageJson = fs10.readFileSync(join13(catalogDir, "package.json"), "utf8");
1548
+ const packageJson = fs10.readFileSync(join14(catalogDir, "package.json"), "utf8");
1455
1549
  const packageJsonObject = JSON.parse(packageJson);
1456
1550
  return packageJsonObject["dependencies"]["@eventcatalog/core"];
1457
1551
  } catch (error) {
@@ -1485,7 +1579,7 @@ var filterCollection = (collection, options) => {
1485
1579
  };
1486
1580
  var getEventCatalogConfigurationFile = (directory) => async () => {
1487
1581
  try {
1488
- const path4 = join13(directory, "eventcatalog.config.js");
1582
+ const path4 = join14(directory, "eventcatalog.config.js");
1489
1583
  const configModule = await import(path4);
1490
1584
  return configModule.default;
1491
1585
  } catch (error) {