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