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