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