@eventcatalog/sdk 2.5.5 → 2.6.1

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