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