@eventcatalog/sdk 2.16.0 → 2.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -794,8 +794,8 @@ var getFiles = async (pattern, ignore = "") => {
794
794
  );
795
795
  }
796
796
  };
797
- var readMdxFile = async (path7) => {
798
- const { data } = matter.read(path7);
797
+ var readMdxFile = async (path8) => {
798
+ const { data } = matter.read(path8);
799
799
  const { markdown, ...frontmatter } = data;
800
800
  return { ...frontmatter, markdown };
801
801
  };
@@ -889,8 +889,8 @@ var writeResource = async (catalogDir, resource, options = {
889
889
  versionExistingContent: false,
890
890
  format: "mdx"
891
891
  }) => {
892
- const path7 = options.path || `/${resource.id}`;
893
- const fullPath = join2(catalogDir, path7);
892
+ const path8 = options.path || `/${resource.id}`;
893
+ const fullPath = join2(catalogDir, path8);
894
894
  const format = options.format || "mdx";
895
895
  fsSync2.mkdirSync(fullPath, { recursive: true });
896
896
  const lockPath = join2(fullPath, `index.${format}`);
@@ -1024,16 +1024,16 @@ var rmResourceById = async (catalogDir, id, version, options) => {
1024
1024
  }
1025
1025
  invalidateFileCache();
1026
1026
  };
1027
- var waitForFileRemoval = async (path7, maxRetries = 50, delay = 10) => {
1027
+ var waitForFileRemoval = async (path8, maxRetries = 50, delay = 10) => {
1028
1028
  for (let i = 0; i < maxRetries; i++) {
1029
1029
  try {
1030
- await fs.access(path7);
1030
+ await fs.access(path8);
1031
1031
  await new Promise((resolve2) => setTimeout(resolve2, delay));
1032
1032
  } catch (error) {
1033
1033
  return;
1034
1034
  }
1035
1035
  }
1036
- throw new Error(`File/directory ${path7} was not removed after ${maxRetries} attempts`);
1036
+ throw new Error(`File/directory ${path8} was not removed after ${maxRetries} attempts`);
1037
1037
  };
1038
1038
  var addFileToResource = async (catalogDir, id, file, version, options) => {
1039
1039
  let pathToResource;
@@ -1086,8 +1086,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
1086
1086
  pathForEvent = join3(pathForEvent, event.id);
1087
1087
  await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
1088
1088
  };
1089
- var rmEvent = (directory) => async (path7) => {
1090
- await fs2.rm(join3(directory, path7), { recursive: true });
1089
+ var rmEvent = (directory) => async (path8) => {
1090
+ await fs2.rm(join3(directory, path8), { recursive: true });
1091
1091
  invalidateFileCache();
1092
1092
  };
1093
1093
  var rmEventById = (directory) => async (id, version, persistFiles) => {
@@ -1123,8 +1123,8 @@ var writeCommandToService = (directory) => async (command, service, options = {
1123
1123
  pathForCommand = join4(pathForCommand, command.id);
1124
1124
  await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
1125
1125
  };
1126
- var rmCommand = (directory) => async (path7) => {
1127
- await fs3.rm(join4(directory, path7), { recursive: true });
1126
+ var rmCommand = (directory) => async (path8) => {
1127
+ await fs3.rm(join4(directory, path8), { recursive: true });
1128
1128
  invalidateFileCache();
1129
1129
  };
1130
1130
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
@@ -1158,8 +1158,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
1158
1158
  pathForQuery = join5(pathForQuery, query.id);
1159
1159
  await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
1160
1160
  };
1161
- var rmQuery = (directory) => async (path7) => {
1162
- await fs4.rm(join5(directory, path7), { recursive: true });
1161
+ var rmQuery = (directory) => async (path8) => {
1162
+ await fs4.rm(join5(directory, path8), { recursive: true });
1163
1163
  invalidateFileCache();
1164
1164
  };
1165
1165
  var rmQueryById = (directory) => async (id, version, persistFiles) => {
@@ -1179,8 +1179,8 @@ var queryHasVersion = (directory) => async (id, version) => {
1179
1179
  import fs5 from "fs/promises";
1180
1180
  import { join as join6, dirname as dirname4, extname, relative as relative2 } from "path";
1181
1181
  var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
1182
- var getServiceByPath = (directory) => async (path7) => {
1183
- const service = await getResource(directory, void 0, void 0, { type: "service" }, path7);
1182
+ var getServiceByPath = (directory) => async (path8) => {
1183
+ const service = await getResource(directory, void 0, void 0, { type: "service" }, path8);
1184
1184
  return service;
1185
1185
  };
1186
1186
  var getServices = (directory) => async (options) => getResources(directory, {
@@ -1215,8 +1215,8 @@ var writeService = (directory) => async (service, options = {
1215
1215
  };
1216
1216
  var writeVersionedService = (directory) => async (service) => {
1217
1217
  const resource = { ...service };
1218
- const path7 = getVersionedDirectory(service.id, service.version);
1219
- return await writeService(directory)(resource, { path: path7 });
1218
+ const path8 = getVersionedDirectory(service.id, service.version);
1219
+ return await writeService(directory)(resource, { path: path8 });
1220
1220
  };
1221
1221
  var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
1222
1222
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
@@ -1224,8 +1224,8 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
1224
1224
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
1225
1225
  };
1226
1226
  var versionService = (directory) => async (id) => versionResource(directory, id);
1227
- var rmService = (directory) => async (path7) => {
1228
- await fs5.rm(join6(directory, path7), { recursive: true });
1227
+ var rmService = (directory) => async (path8) => {
1228
+ await fs5.rm(join6(directory, path8), { recursive: true });
1229
1229
  invalidateFileCache();
1230
1230
  };
1231
1231
  var rmServiceById = (directory) => async (id, version, persistFiles) => {
@@ -1290,8 +1290,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
1290
1290
  if (!existingResource) {
1291
1291
  throw new Error(`Cannot find service ${id} in the catalog`);
1292
1292
  }
1293
- const path7 = existingResource.split(/[\\/]+services/)[0];
1294
- const pathToResource = join6(path7, "services");
1293
+ const path8 = existingResource.split(/[\\/]+services/)[0];
1294
+ const pathToResource = join6(path8, "services");
1295
1295
  await rmServiceById(directory)(id, version);
1296
1296
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
1297
1297
  };
@@ -1299,9 +1299,9 @@ var serviceHasVersion = (directory) => async (id, version) => {
1299
1299
  const file = await findFileById(directory, id, version);
1300
1300
  return !!file;
1301
1301
  };
1302
- var isService = (directory) => async (path7) => {
1303
- const service = await getServiceByPath(directory)(path7);
1304
- const relativePath = relative2(directory, path7);
1302
+ var isService = (directory) => async (path8) => {
1303
+ const service = await getServiceByPath(directory)(path8);
1304
+ const relativePath = relative2(directory, path8);
1305
1305
  const segments = relativePath.split(/[/\\]+/);
1306
1306
  return !!service && segments.includes("services");
1307
1307
  };
@@ -1323,8 +1323,8 @@ var addEntityToService = (directory) => async (id, entity, version) => {
1323
1323
  if (!existingResource) {
1324
1324
  throw new Error(`Cannot find service ${id} in the catalog`);
1325
1325
  }
1326
- const path7 = existingResource.split(/[\\/]+services/)[0];
1327
- const pathToResource = join6(path7, "services");
1326
+ const path8 = existingResource.split(/[\\/]+services/)[0];
1327
+ const pathToResource = join6(path8, "services");
1328
1328
  await rmServiceById(directory)(id, version);
1329
1329
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
1330
1330
  };
@@ -1359,8 +1359,8 @@ var addDataStoreToService = (directory) => async (id, operation, dataStore, vers
1359
1359
  if (!existingResource) {
1360
1360
  throw new Error(`Cannot find service ${id} in the catalog`);
1361
1361
  }
1362
- const path7 = existingResource.split(/[\\/]+services/)[0];
1363
- const pathToResource = join6(path7, "services");
1362
+ const path8 = existingResource.split(/[\\/]+services/)[0];
1363
+ const pathToResource = join6(path8, "services");
1364
1364
  await rmServiceById(directory)(id, version);
1365
1365
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
1366
1366
  };
@@ -1401,8 +1401,8 @@ var writeDomain = (directory) => async (domain, options = {
1401
1401
  return await writeResource(directory, resource, { ...options, type: "domain" });
1402
1402
  };
1403
1403
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
1404
- var rmDomain = (directory) => async (path7) => {
1405
- await fs6.rm(join7(directory, path7), { recursive: true });
1404
+ var rmDomain = (directory) => async (path8) => {
1405
+ await fs6.rm(join7(directory, path8), { recursive: true });
1406
1406
  invalidateFileCache();
1407
1407
  };
1408
1408
  var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
@@ -1533,8 +1533,8 @@ import { join as join8, extname as extname2 } from "path";
1533
1533
  var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
1534
1534
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
1535
1535
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
1536
- var rmChannel = (directory) => async (path7) => {
1537
- await fs7.rm(join8(directory, path7), { recursive: true });
1536
+ var rmChannel = (directory) => async (path8) => {
1537
+ await fs7.rm(join8(directory, path8), { recursive: true });
1538
1538
  invalidateFileCache();
1539
1539
  };
1540
1540
  var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
@@ -1576,18 +1576,19 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
1576
1576
  if (!existingResource) {
1577
1577
  throw new Error(`Cannot find message ${id} in the catalog`);
1578
1578
  }
1579
- const path7 = existingResource.split(`/[\\/]+${collection}`)[0];
1580
- const pathToResource = join8(path7, collection);
1579
+ const path8 = existingResource.split(`/[\\/]+${collection}`)[0];
1580
+ const pathToResource = join8(path8, collection);
1581
1581
  await rmMessageById(directory)(_message.id, _message.version, true);
1582
1582
  await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
1583
1583
  };
1584
1584
 
1585
1585
  // src/messages.ts
1586
- import { dirname as dirname5 } from "path";
1586
+ import { dirname as dirname5, join as join9 } from "path";
1587
+ import fsSync4 from "fs";
1587
1588
  import matter4 from "gray-matter";
1588
1589
  import { satisfies as satisfies4, validRange as validRange3 } from "semver";
1589
- var getMessageBySchemaPath = (directory) => async (path7, options) => {
1590
- const pathToMessage = dirname5(path7);
1590
+ var getMessageBySchemaPath = (directory) => async (path8, options) => {
1591
+ const pathToMessage = dirname5(path8);
1591
1592
  try {
1592
1593
  const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
1593
1594
  if (!files || files.length === 0) {
@@ -1659,35 +1660,49 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
1659
1660
  }
1660
1661
  return { producers, consumers };
1661
1662
  };
1662
- var getConsumersOfSchema = (directory) => async (path7) => {
1663
+ var getConsumersOfSchema = (directory) => async (path8) => {
1663
1664
  try {
1664
- const message = await getMessageBySchemaPath(directory)(path7);
1665
+ const message = await getMessageBySchemaPath(directory)(path8);
1665
1666
  const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
1666
1667
  return consumers;
1667
1668
  } catch (error) {
1668
1669
  return [];
1669
1670
  }
1670
1671
  };
1671
- var getProducersOfSchema = (directory) => async (path7) => {
1672
+ var getProducersOfSchema = (directory) => async (path8) => {
1672
1673
  try {
1673
- const message = await getMessageBySchemaPath(directory)(path7);
1674
+ const message = await getMessageBySchemaPath(directory)(path8);
1674
1675
  const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
1675
1676
  return producers;
1676
1677
  } catch (error) {
1677
1678
  return [];
1678
1679
  }
1679
1680
  };
1681
+ var getSchemaForMessage = (directory) => async (id, version) => {
1682
+ const file = await findFileById(directory, id, version);
1683
+ if (!file || !fsSync4.existsSync(file)) return void 0;
1684
+ const { data } = matter4.read(file);
1685
+ if (!data.schemaPath) return void 0;
1686
+ const resourceDirectory = dirname5(file);
1687
+ const pathToSchema = join9(resourceDirectory, data.schemaPath);
1688
+ if (!fsSync4.existsSync(pathToSchema)) return void 0;
1689
+ const schema = fsSync4.readFileSync(pathToSchema, "utf8");
1690
+ return {
1691
+ schema,
1692
+ fileName: data.schemaPath
1693
+ };
1694
+ };
1680
1695
 
1681
1696
  // src/custom-docs.ts
1682
1697
  import path3, { join as join10 } from "path";
1683
- import fsSync4 from "fs";
1698
+ import fsSync5 from "fs";
1684
1699
  import fs8 from "fs/promises";
1685
1700
  import matter5 from "gray-matter";
1686
1701
  import slugify from "slugify";
1687
1702
  var getCustomDoc = (directory) => async (filePath) => {
1688
1703
  const fullPath = path3.join(directory, filePath);
1689
1704
  const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
1690
- const fileExists = fsSync4.existsSync(fullPathWithExtension);
1705
+ const fileExists = fsSync5.existsSync(fullPathWithExtension);
1691
1706
  if (!fileExists) {
1692
1707
  return void 0;
1693
1708
  }
@@ -1705,9 +1720,9 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
1705
1720
  const name = fileName || slugify(customDoc.title, { lower: true });
1706
1721
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
1707
1722
  const fullPath = path3.join(directory, options.path || "", withExtension);
1708
- fsSync4.mkdirSync(path3.dirname(fullPath), { recursive: true });
1723
+ fsSync5.mkdirSync(path3.dirname(fullPath), { recursive: true });
1709
1724
  const document = matter5.stringify(customDoc.markdown.trim(), rest);
1710
- fsSync4.writeFileSync(fullPath, document);
1725
+ fsSync5.writeFileSync(fullPath, document);
1711
1726
  invalidateFileCache();
1712
1727
  };
1713
1728
  var rmCustomDoc = (directory) => async (filePath) => {
@@ -1718,13 +1733,13 @@ var rmCustomDoc = (directory) => async (filePath) => {
1718
1733
 
1719
1734
  // src/teams.ts
1720
1735
  import fs9 from "fs/promises";
1721
- import fsSync6 from "fs";
1736
+ import fsSync7 from "fs";
1722
1737
  import { join as join12 } from "path";
1723
1738
  import matter7 from "gray-matter";
1724
1739
  import path4 from "path";
1725
1740
 
1726
1741
  // src/users.ts
1727
- import fsSync5 from "fs";
1742
+ import fsSync6 from "fs";
1728
1743
  import { join as join11 } from "path";
1729
1744
  import matter6 from "gray-matter";
1730
1745
  var getUser = (catalogDir) => async (id) => {
@@ -1763,12 +1778,12 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
1763
1778
  }
1764
1779
  const { markdown, ...frontmatter } = resource;
1765
1780
  const document = matter6.stringify(markdown, frontmatter);
1766
- fsSync5.mkdirSync(join11(catalogDir, ""), { recursive: true });
1767
- fsSync5.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
1781
+ fsSync6.mkdirSync(join11(catalogDir, ""), { recursive: true });
1782
+ fsSync6.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
1768
1783
  invalidateFileCache();
1769
1784
  };
1770
1785
  var rmUserById = (catalogDir) => async (id) => {
1771
- fsSync5.rmSync(join11(catalogDir, `${id}.mdx`), { recursive: true });
1786
+ fsSync6.rmSync(join11(catalogDir, `${id}.mdx`), { recursive: true });
1772
1787
  invalidateFileCache();
1773
1788
  };
1774
1789
 
@@ -1807,8 +1822,8 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
1807
1822
  }
1808
1823
  const { markdown, ...frontmatter } = resource;
1809
1824
  const document = matter7.stringify(markdown, frontmatter);
1810
- fsSync6.mkdirSync(join12(catalogDir, ""), { recursive: true });
1811
- fsSync6.writeFileSync(join12(catalogDir, "", `${resource.id}.mdx`), document);
1825
+ fsSync7.mkdirSync(join12(catalogDir, ""), { recursive: true });
1826
+ fsSync7.writeFileSync(join12(catalogDir, "", `${resource.id}.mdx`), document);
1812
1827
  invalidateFileCache();
1813
1828
  };
1814
1829
  var rmTeamById = (catalogDir) => async (id) => {
@@ -1874,8 +1889,8 @@ var filterCollection = (collection, options) => {
1874
1889
  };
1875
1890
  var getEventCatalogConfigurationFile = (directory) => async () => {
1876
1891
  try {
1877
- const path7 = join13(directory, "eventcatalog.config.js");
1878
- const configModule = await import(path7);
1892
+ const path8 = join13(directory, "eventcatalog.config.js");
1893
+ const configModule = await import(path8);
1879
1894
  return configModule.default;
1880
1895
  } catch (error) {
1881
1896
  console.error("Error getting event catalog configuration file", error);
@@ -1931,10 +1946,321 @@ var dumpCatalog = (directory) => async (options) => {
1931
1946
  };
1932
1947
  };
1933
1948
 
1949
+ // src/snapshots.ts
1950
+ import fs11 from "fs";
1951
+ import path6 from "path";
1952
+ import { execSync } from "child_process";
1953
+ import { compare } from "semver";
1954
+
1955
+ // src/snapshot-diff.ts
1956
+ var stableStringify = (value) => {
1957
+ if (value === null || value === void 0 || typeof value !== "object") {
1958
+ return JSON.stringify(value);
1959
+ }
1960
+ if (Array.isArray(value)) {
1961
+ return "[" + value.map(stableStringify).join(",") + "]";
1962
+ }
1963
+ const sorted = Object.keys(value).sort().map((key) => JSON.stringify(key) + ":" + stableStringify(value[key]));
1964
+ return "{" + sorted.join(",") + "}";
1965
+ };
1966
+ var flattenResources = (snapshot) => {
1967
+ const resources = [];
1968
+ const addResources = (items, type) => {
1969
+ for (const item of items) {
1970
+ resources.push({
1971
+ resourceId: item.id,
1972
+ version: item.version,
1973
+ type,
1974
+ data: item
1975
+ });
1976
+ }
1977
+ };
1978
+ addResources(snapshot.resources.domains, "domain");
1979
+ addResources(snapshot.resources.services, "service");
1980
+ addResources(snapshot.resources.messages.events, "event");
1981
+ addResources(snapshot.resources.messages.commands, "command");
1982
+ addResources(snapshot.resources.messages.queries, "query");
1983
+ addResources(snapshot.resources.channels, "channel");
1984
+ return resources;
1985
+ };
1986
+ var EXCLUDED_FIELDS = /* @__PURE__ */ new Set(["markdown", "_eventcatalog"]);
1987
+ var getComparableFields = (data) => {
1988
+ const result = {};
1989
+ for (const [key, value] of Object.entries(data)) {
1990
+ if (!EXCLUDED_FIELDS.has(key)) {
1991
+ result[key] = value;
1992
+ }
1993
+ }
1994
+ return result;
1995
+ };
1996
+ var findChangedFields = (dataA, dataB) => {
1997
+ const fieldsA = getComparableFields(dataA);
1998
+ const fieldsB = getComparableFields(dataB);
1999
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(fieldsA), ...Object.keys(fieldsB)]);
2000
+ const changed = [];
2001
+ for (const key of allKeys) {
2002
+ if (stableStringify(fieldsA[key] ?? null) !== stableStringify(fieldsB[key] ?? null)) {
2003
+ changed.push(key);
2004
+ }
2005
+ }
2006
+ return changed;
2007
+ };
2008
+ var resourceKey = (r) => `${r.resourceId}@${r.version}`;
2009
+ var idTypeKey = (r) => `${r.resourceId}:${r.type}`;
2010
+ var computeResourceDiff = (snapshotA, snapshotB) => {
2011
+ const resourcesA = flattenResources(snapshotA);
2012
+ const resourcesB = flattenResources(snapshotB);
2013
+ const mapA = /* @__PURE__ */ new Map();
2014
+ const byIdA = /* @__PURE__ */ new Map();
2015
+ for (const r of resourcesA) {
2016
+ mapA.set(resourceKey(r), r);
2017
+ byIdA.set(idTypeKey(r), r);
2018
+ }
2019
+ const mapB = /* @__PURE__ */ new Map();
2020
+ const byIdB = /* @__PURE__ */ new Map();
2021
+ for (const r of resourcesB) {
2022
+ mapB.set(resourceKey(r), r);
2023
+ byIdB.set(idTypeKey(r), r);
2024
+ }
2025
+ const changes = [];
2026
+ const handledIds = /* @__PURE__ */ new Set();
2027
+ for (const resource of resourcesB) {
2028
+ const key = resourceKey(resource);
2029
+ if (!mapA.has(key)) {
2030
+ const idKey = idTypeKey(resource);
2031
+ const oldResource = byIdA.get(idKey);
2032
+ if (oldResource && oldResource.version !== resource.version && !handledIds.has(idKey)) {
2033
+ const changedFields = findChangedFields(oldResource.data, resource.data);
2034
+ changes.push({
2035
+ resourceId: resource.resourceId,
2036
+ version: resource.version,
2037
+ type: resource.type,
2038
+ changeType: "versioned",
2039
+ previousVersion: oldResource.version,
2040
+ newVersion: resource.version,
2041
+ changedFields: changedFields.length > 0 ? changedFields : void 0
2042
+ });
2043
+ handledIds.add(idKey);
2044
+ } else if (!handledIds.has(idKey)) {
2045
+ changes.push({
2046
+ resourceId: resource.resourceId,
2047
+ version: resource.version,
2048
+ type: resource.type,
2049
+ changeType: "added"
2050
+ });
2051
+ }
2052
+ }
2053
+ }
2054
+ for (const resource of resourcesA) {
2055
+ const key = resourceKey(resource);
2056
+ if (!mapB.has(key)) {
2057
+ const idKey = idTypeKey(resource);
2058
+ if (!handledIds.has(idKey)) {
2059
+ changes.push({
2060
+ resourceId: resource.resourceId,
2061
+ version: resource.version,
2062
+ type: resource.type,
2063
+ changeType: "removed"
2064
+ });
2065
+ }
2066
+ }
2067
+ }
2068
+ for (const resourceB of resourcesB) {
2069
+ const key = resourceKey(resourceB);
2070
+ const resourceA = mapA.get(key);
2071
+ if (resourceA) {
2072
+ const changedFields = findChangedFields(resourceA.data, resourceB.data);
2073
+ if (changedFields.length > 0) {
2074
+ changes.push({
2075
+ resourceId: resourceB.resourceId,
2076
+ version: resourceB.version,
2077
+ type: resourceB.type,
2078
+ changeType: "modified",
2079
+ changedFields
2080
+ });
2081
+ }
2082
+ }
2083
+ }
2084
+ return changes;
2085
+ };
2086
+ var getRelationshipKey = (serviceId, resourceId, resourceVersion, direction) => {
2087
+ return `${serviceId}:${direction}:${resourceId}@${resourceVersion || "latest"}`;
2088
+ };
2089
+ var extractRelationships = (snapshot) => {
2090
+ const relationships = /* @__PURE__ */ new Map();
2091
+ for (const service of snapshot.resources.services) {
2092
+ for (const direction of ["sends", "receives"]) {
2093
+ const pointers = service[direction] || [];
2094
+ for (const pointer of pointers) {
2095
+ const key = getRelationshipKey(service.id, pointer.id, pointer.version, direction);
2096
+ relationships.set(key, {
2097
+ serviceId: service.id,
2098
+ serviceVersion: service.version,
2099
+ resourceId: pointer.id,
2100
+ resourceVersion: pointer.version,
2101
+ direction
2102
+ });
2103
+ }
2104
+ }
2105
+ }
2106
+ return relationships;
2107
+ };
2108
+ var computeRelationshipDiff = (snapshotA, snapshotB) => {
2109
+ const relsA = extractRelationships(snapshotA);
2110
+ const relsB = extractRelationships(snapshotB);
2111
+ const changes = [];
2112
+ for (const [key, rel] of relsB) {
2113
+ if (!relsA.has(key)) {
2114
+ changes.push({ ...rel, changeType: "added" });
2115
+ }
2116
+ }
2117
+ for (const [key, rel] of relsA) {
2118
+ if (!relsB.has(key)) {
2119
+ changes.push({ ...rel, changeType: "removed" });
2120
+ }
2121
+ }
2122
+ return changes;
2123
+ };
2124
+
2125
+ // src/snapshots.ts
2126
+ var SNAPSHOT_VERSION = "1.0.0";
2127
+ var getEventCatalogVersion2 = (catalogDir) => {
2128
+ try {
2129
+ const packageJson = fs11.readFileSync(path6.join(catalogDir, "package.json"), "utf8");
2130
+ const packageJsonObject = JSON.parse(packageJson);
2131
+ return packageJsonObject["dependencies"]?.["@eventcatalog/core"] ?? "unknown";
2132
+ } catch {
2133
+ return "unknown";
2134
+ }
2135
+ };
2136
+ var pickCoreFields = (resource) => {
2137
+ const picked = { id: resource.id, version: resource.version, name: resource.name };
2138
+ if (resource.sends) picked.sends = resource.sends;
2139
+ if (resource.receives) picked.receives = resource.receives;
2140
+ if (resource.deprecated) picked.deprecated = resource.deprecated;
2141
+ if (resource.owners) picked.owners = resource.owners;
2142
+ return picked;
2143
+ };
2144
+ var deduplicateByLatestVersion = (resources) => {
2145
+ const seen = /* @__PURE__ */ new Map();
2146
+ for (const r of resources) {
2147
+ const existing = seen.get(r.id);
2148
+ if (!existing || compare(r.version, existing.version) > 0) {
2149
+ seen.set(r.id, r);
2150
+ }
2151
+ }
2152
+ return Array.from(seen.values());
2153
+ };
2154
+ var stripToCore = (resources) => {
2155
+ if (!resources || resources.length === 0) return [];
2156
+ return deduplicateByLatestVersion(resources).map(pickCoreFields);
2157
+ };
2158
+ var detectGitInfo = (catalogDir) => {
2159
+ try {
2160
+ const opts = { cwd: catalogDir, encoding: "utf8", stdio: "pipe" };
2161
+ const branch = execSync("git rev-parse --abbrev-ref HEAD", opts).trim();
2162
+ const commit = execSync("git rev-parse --short HEAD", opts).trim();
2163
+ const status = execSync("git status --porcelain", opts).trim();
2164
+ return { branch, commit, dirty: status.length > 0 };
2165
+ } catch {
2166
+ return void 0;
2167
+ }
2168
+ };
2169
+ var createSnapshot = (directory) => {
2170
+ return async (options) => {
2171
+ const { label, outputDir, git } = options || {};
2172
+ const sdk = src_default(directory);
2173
+ const [domains, services, events, commands, queries, channels] = await Promise.all([
2174
+ sdk.getDomains(),
2175
+ sdk.getServices(),
2176
+ sdk.getEvents(),
2177
+ sdk.getCommands(),
2178
+ sdk.getQueries(),
2179
+ sdk.getChannels()
2180
+ ]);
2181
+ const snapshotDomains = stripToCore(domains);
2182
+ const snapshotServices = stripToCore(services);
2183
+ const snapshotEvents = stripToCore(events);
2184
+ const snapshotCommands = stripToCore(commands);
2185
+ const snapshotQueries = stripToCore(queries);
2186
+ const snapshotChannels = stripToCore(channels);
2187
+ const snapshotLabel = label || (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
2188
+ const gitInfo = git || detectGitInfo(directory);
2189
+ const snapshot = {
2190
+ snapshotVersion: SNAPSHOT_VERSION,
2191
+ catalogVersion: getEventCatalogVersion2(directory),
2192
+ label: snapshotLabel,
2193
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2194
+ ...gitInfo ? { git: gitInfo } : {},
2195
+ resources: {
2196
+ domains: snapshotDomains,
2197
+ services: snapshotServices,
2198
+ messages: {
2199
+ events: snapshotEvents,
2200
+ commands: snapshotCommands,
2201
+ queries: snapshotQueries
2202
+ },
2203
+ channels: snapshotChannels
2204
+ }
2205
+ };
2206
+ const snapshotsDir = outputDir || path6.join(directory, ".snapshots");
2207
+ fs11.mkdirSync(snapshotsDir, { recursive: true });
2208
+ const fileName = `${snapshotLabel}.snapshot.json`;
2209
+ const filePath = path6.join(snapshotsDir, fileName);
2210
+ fs11.writeFileSync(filePath, JSON.stringify(snapshot));
2211
+ return { filePath, snapshot };
2212
+ };
2213
+ };
2214
+ var diffSnapshots = (directory) => async (snapshotAPath, snapshotBPath) => {
2215
+ const snapshotA = JSON.parse(fs11.readFileSync(snapshotAPath, "utf-8"));
2216
+ const snapshotB = JSON.parse(fs11.readFileSync(snapshotBPath, "utf-8"));
2217
+ const resourceChanges = computeResourceDiff(snapshotA, snapshotB);
2218
+ const relationshipChanges = computeRelationshipDiff(snapshotA, snapshotB);
2219
+ const resourceCounts = { added: 0, removed: 0, modified: 0, versioned: 0 };
2220
+ for (const r of resourceChanges) resourceCounts[r.changeType]++;
2221
+ const relCounts = { added: 0, removed: 0 };
2222
+ for (const r of relationshipChanges) relCounts[r.changeType]++;
2223
+ return {
2224
+ snapshotA: { label: snapshotA.label, createdAt: snapshotA.createdAt },
2225
+ snapshotB: { label: snapshotB.label, createdAt: snapshotB.createdAt },
2226
+ summary: {
2227
+ totalChanges: resourceChanges.length + relationshipChanges.length,
2228
+ resourcesAdded: resourceCounts.added,
2229
+ resourcesRemoved: resourceCounts.removed,
2230
+ resourcesModified: resourceCounts.modified,
2231
+ resourcesVersioned: resourceCounts.versioned,
2232
+ relationshipsAdded: relCounts.added,
2233
+ relationshipsRemoved: relCounts.removed
2234
+ },
2235
+ resources: resourceChanges,
2236
+ relationships: relationshipChanges
2237
+ };
2238
+ };
2239
+ var listSnapshots = (directory) => async () => {
2240
+ const snapshotsDir = path6.join(directory, ".snapshots");
2241
+ if (!fs11.existsSync(snapshotsDir)) return [];
2242
+ const files = fs11.readdirSync(snapshotsDir).filter((f) => f.endsWith(".snapshot.json"));
2243
+ const snapshots = [];
2244
+ for (const file of files) {
2245
+ try {
2246
+ const filePath = path6.join(snapshotsDir, file);
2247
+ const content = JSON.parse(fs11.readFileSync(filePath, "utf-8"));
2248
+ snapshots.push({
2249
+ label: content.label,
2250
+ createdAt: content.createdAt,
2251
+ filePath,
2252
+ ...content.git ? { git: content.git } : {}
2253
+ });
2254
+ } catch {
2255
+ }
2256
+ }
2257
+ return snapshots.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2258
+ };
2259
+
1934
2260
  // src/changelogs.ts
1935
- import path6, { dirname as dirname6 } from "path";
1936
- import fsSync7 from "fs";
1937
- import fs11 from "fs/promises";
2261
+ import path7, { dirname as dirname6 } from "path";
2262
+ import fsSync8 from "fs";
2263
+ import fs12 from "fs/promises";
1938
2264
  import matter8 from "gray-matter";
1939
2265
  var writeChangelog = (catalogDir) => async (id, changelog, options = {}) => {
1940
2266
  const { version, format = "mdx" } = options;
@@ -1943,7 +2269,7 @@ var writeChangelog = (catalogDir) => async (id, changelog, options = {}) => {
1943
2269
  throw new Error(`No resource found with id: ${id}${version ? ` and version: ${version}` : ""}`);
1944
2270
  }
1945
2271
  const resourceDir = dirname6(resourceFile);
1946
- const changelogPath = path6.join(resourceDir, `changelog.${format}`);
2272
+ const changelogPath = path7.join(resourceDir, `changelog.${format}`);
1947
2273
  const { markdown, ...frontmatter } = changelog;
1948
2274
  const fm = { ...frontmatter };
1949
2275
  if (fm.createdAt instanceof Date) {
@@ -1952,9 +2278,9 @@ var writeChangelog = (catalogDir) => async (id, changelog, options = {}) => {
1952
2278
  if (!fm.badges || fm.badges.length === 0) {
1953
2279
  delete fm.badges;
1954
2280
  }
1955
- fsSync7.mkdirSync(resourceDir, { recursive: true });
2281
+ fsSync8.mkdirSync(resourceDir, { recursive: true });
1956
2282
  const document = matter8.stringify(markdown.trim(), fm);
1957
- fsSync7.writeFileSync(changelogPath, document);
2283
+ fsSync8.writeFileSync(changelogPath, document);
1958
2284
  invalidateFileCache();
1959
2285
  };
1960
2286
  var appendChangelog = (catalogDir) => async (id, changelog, options = {}) => {
@@ -1964,9 +2290,9 @@ var appendChangelog = (catalogDir) => async (id, changelog, options = {}) => {
1964
2290
  throw new Error(`No resource found with id: ${id}${version ? ` and version: ${version}` : ""}`);
1965
2291
  }
1966
2292
  const resourceDir = dirname6(resourceFile);
1967
- const mdxPath = path6.join(resourceDir, "changelog.mdx");
1968
- const mdPath = path6.join(resourceDir, "changelog.md");
1969
- const existingPath = fsSync7.existsSync(mdxPath) ? mdxPath : fsSync7.existsSync(mdPath) ? mdPath : void 0;
2293
+ const mdxPath = path7.join(resourceDir, "changelog.mdx");
2294
+ const mdPath = path7.join(resourceDir, "changelog.md");
2295
+ const existingPath = fsSync8.existsSync(mdxPath) ? mdxPath : fsSync8.existsSync(mdPath) ? mdPath : void 0;
1970
2296
  if (!existingPath) {
1971
2297
  return writeChangelog(catalogDir)(id, changelog, options);
1972
2298
  }
@@ -1986,7 +2312,7 @@ ${existingContent}`;
1986
2312
  delete fm.badges;
1987
2313
  }
1988
2314
  const document = matter8.stringify(combined, fm);
1989
- fsSync7.writeFileSync(existingPath, document);
2315
+ fsSync8.writeFileSync(existingPath, document);
1990
2316
  invalidateFileCache();
1991
2317
  };
1992
2318
  var getChangelog = (catalogDir) => async (id, options = {}) => {
@@ -1994,9 +2320,9 @@ var getChangelog = (catalogDir) => async (id, options = {}) => {
1994
2320
  const resourceFile = await findFileById(catalogDir, id, version);
1995
2321
  if (!resourceFile) return void 0;
1996
2322
  const resourceDir = dirname6(resourceFile);
1997
- const mdxPath = path6.join(resourceDir, "changelog.mdx");
1998
- const mdPath = path6.join(resourceDir, "changelog.md");
1999
- const changelogPath = fsSync7.existsSync(mdxPath) ? mdxPath : fsSync7.existsSync(mdPath) ? mdPath : void 0;
2323
+ const mdxPath = path7.join(resourceDir, "changelog.mdx");
2324
+ const mdPath = path7.join(resourceDir, "changelog.md");
2325
+ const changelogPath = fsSync8.existsSync(mdxPath) ? mdxPath : fsSync8.existsSync(mdPath) ? mdPath : void 0;
2000
2326
  if (!changelogPath) return void 0;
2001
2327
  const { data, content } = matter8.read(changelogPath);
2002
2328
  return { ...data, markdown: content.trim() };
@@ -2008,19 +2334,19 @@ var rmChangelog = (catalogDir) => async (id, options = {}) => {
2008
2334
  throw new Error(`No resource found with id: ${id}${version ? ` and version: ${version}` : ""}`);
2009
2335
  }
2010
2336
  const resourceDir = dirname6(resourceFile);
2011
- const mdxPath = path6.join(resourceDir, "changelog.mdx");
2012
- const mdPath = path6.join(resourceDir, "changelog.md");
2013
- if (fsSync7.existsSync(mdxPath)) {
2014
- await fs11.rm(mdxPath);
2337
+ const mdxPath = path7.join(resourceDir, "changelog.mdx");
2338
+ const mdPath = path7.join(resourceDir, "changelog.md");
2339
+ if (fsSync8.existsSync(mdxPath)) {
2340
+ await fs12.rm(mdxPath);
2015
2341
  }
2016
- if (fsSync7.existsSync(mdPath)) {
2017
- await fs11.rm(mdPath);
2342
+ if (fsSync8.existsSync(mdPath)) {
2343
+ await fs12.rm(mdPath);
2018
2344
  }
2019
2345
  invalidateFileCache();
2020
2346
  };
2021
2347
 
2022
2348
  // src/entities.ts
2023
- import fs12 from "fs/promises";
2349
+ import fs13 from "fs/promises";
2024
2350
  import { join as join14 } from "path";
2025
2351
  var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
2026
2352
  var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
@@ -2029,8 +2355,8 @@ var writeEntity = (directory) => async (entity, options = {
2029
2355
  override: false,
2030
2356
  format: "mdx"
2031
2357
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
2032
- var rmEntity = (directory) => async (path7) => {
2033
- await fs12.rm(join14(directory, path7), { recursive: true });
2358
+ var rmEntity = (directory) => async (path8) => {
2359
+ await fs13.rm(join14(directory, path8), { recursive: true });
2034
2360
  invalidateFileCache();
2035
2361
  };
2036
2362
  var rmEntityById = (directory) => async (id, version, persistFiles) => {
@@ -2043,7 +2369,7 @@ var entityHasVersion = (directory) => async (id, version) => {
2043
2369
  };
2044
2370
 
2045
2371
  // src/containers.ts
2046
- import fs13 from "fs/promises";
2372
+ import fs14 from "fs/promises";
2047
2373
  import { join as join15 } from "path";
2048
2374
  var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
2049
2375
  var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
@@ -2053,8 +2379,8 @@ var writeContainer = (directory) => async (data, options = {
2053
2379
  format: "mdx"
2054
2380
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
2055
2381
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
2056
- var rmContainer = (directory) => async (path7) => {
2057
- await fs13.rm(join15(directory, path7), { recursive: true });
2382
+ var rmContainer = (directory) => async (path8) => {
2383
+ await fs14.rm(join15(directory, path8), { recursive: true });
2058
2384
  invalidateFileCache();
2059
2385
  };
2060
2386
  var rmContainerById = (directory) => async (id, version, persistFiles) => {
@@ -2087,7 +2413,7 @@ var addFileToDataStore = addFileToContainer;
2087
2413
  var writeDataStoreToService = writeContainerToService;
2088
2414
 
2089
2415
  // src/data-products.ts
2090
- import fs14 from "fs/promises";
2416
+ import fs15 from "fs/promises";
2091
2417
  import { join as join16 } from "path";
2092
2418
  var getDataProduct = (directory) => async (id, version) => getResource(directory, id, version, { type: "data-product" });
2093
2419
  var getDataProducts = (directory) => async (options) => getResources(directory, { type: "data-products", latestOnly: options?.latestOnly });
@@ -2101,8 +2427,8 @@ var writeDataProductToDomain = (directory) => async (dataProduct, domain, option
2101
2427
  pathForDataProduct = join16(pathForDataProduct, dataProduct.id);
2102
2428
  await writeResource(directory, { ...dataProduct }, { ...options, path: pathForDataProduct, type: "data-product" });
2103
2429
  };
2104
- var rmDataProduct = (directory) => async (path7) => {
2105
- await fs14.rm(join16(directory, path7), { recursive: true });
2430
+ var rmDataProduct = (directory) => async (path8) => {
2431
+ await fs15.rm(join16(directory, path8), { recursive: true });
2106
2432
  invalidateFileCache();
2107
2433
  };
2108
2434
  var rmDataProductById = (directory) => async (id, version, persistFiles) => {
@@ -2116,7 +2442,7 @@ var dataProductHasVersion = (directory) => async (id, version) => {
2116
2442
  var addFileToDataProduct = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
2117
2443
 
2118
2444
  // src/diagrams.ts
2119
- import fs15 from "fs/promises";
2445
+ import fs16 from "fs/promises";
2120
2446
  import { join as join17 } from "path";
2121
2447
  var getDiagram = (directory) => async (id, version) => getResource(directory, id, version, { type: "diagram" });
2122
2448
  var getDiagrams = (directory) => async (options) => getResources(directory, { type: "diagrams", latestOnly: options?.latestOnly });
@@ -2125,8 +2451,8 @@ var writeDiagram = (directory) => async (diagram, options = {
2125
2451
  override: false,
2126
2452
  format: "mdx"
2127
2453
  }) => writeResource(directory, { ...diagram }, { ...options, type: "diagram" });
2128
- var rmDiagram = (directory) => async (path7) => {
2129
- await fs15.rm(join17(directory, path7), { recursive: true });
2454
+ var rmDiagram = (directory) => async (path8) => {
2455
+ await fs16.rm(join17(directory, path8), { recursive: true });
2130
2456
  invalidateFileCache();
2131
2457
  };
2132
2458
  var rmDiagramById = (directory) => async (id, version, persistFiles) => {
@@ -2140,7 +2466,7 @@ var diagramHasVersion = (directory) => async (id, version) => {
2140
2466
  var addFileToDiagram = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version, { type: "diagram" });
2141
2467
 
2142
2468
  // src/index.ts
2143
- var src_default = (path7) => {
2469
+ var src_default = (path8) => {
2144
2470
  return {
2145
2471
  /**
2146
2472
  * Returns an events from EventCatalog
@@ -2148,13 +2474,13 @@ var src_default = (path7) => {
2148
2474
  * @param version - Optional id of the version to get (supports semver)
2149
2475
  * @returns Event|Undefined
2150
2476
  */
2151
- getEvent: getEvent(join18(path7)),
2477
+ getEvent: getEvent(join18(path8)),
2152
2478
  /**
2153
2479
  * Returns all events from EventCatalog
2154
2480
  * @param latestOnly - optional boolean, set to true to get only latest versions
2155
2481
  * @returns Event[]|Undefined
2156
2482
  */
2157
- getEvents: getEvents(join18(path7)),
2483
+ getEvents: getEvents(join18(path8)),
2158
2484
  /**
2159
2485
  * Adds an event to EventCatalog
2160
2486
  *
@@ -2162,7 +2488,7 @@ var src_default = (path7) => {
2162
2488
  * @param options - Optional options to write the event
2163
2489
  *
2164
2490
  */
2165
- writeEvent: writeEvent(join18(path7, "events")),
2491
+ writeEvent: writeEvent(join18(path8, "events")),
2166
2492
  /**
2167
2493
  * Adds an event to a service in EventCatalog
2168
2494
  *
@@ -2171,26 +2497,26 @@ var src_default = (path7) => {
2171
2497
  * @param options - Optional options to write the event
2172
2498
  *
2173
2499
  */
2174
- writeEventToService: writeEventToService(join18(path7)),
2500
+ writeEventToService: writeEventToService(join18(path8)),
2175
2501
  /**
2176
2502
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
2177
2503
  *
2178
2504
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
2179
2505
  *
2180
2506
  */
2181
- rmEvent: rmEvent(join18(path7, "events")),
2507
+ rmEvent: rmEvent(join18(path8, "events")),
2182
2508
  /**
2183
2509
  * Remove an event by an Event id
2184
2510
  *
2185
2511
  * @param id - The id of the event you want to remove
2186
2512
  *
2187
2513
  */
2188
- rmEventById: rmEventById(join18(path7)),
2514
+ rmEventById: rmEventById(join18(path8)),
2189
2515
  /**
2190
2516
  * Moves a given event id to the version directory
2191
2517
  * @param directory
2192
2518
  */
2193
- versionEvent: versionEvent(join18(path7)),
2519
+ versionEvent: versionEvent(join18(path8)),
2194
2520
  /**
2195
2521
  * Adds a file to the given event
2196
2522
  * @param id - The id of the event to add the file to
@@ -2198,7 +2524,7 @@ var src_default = (path7) => {
2198
2524
  * @param version - Optional version of the event to add the file to
2199
2525
  * @returns
2200
2526
  */
2201
- addFileToEvent: addFileToEvent(join18(path7)),
2527
+ addFileToEvent: addFileToEvent(join18(path8)),
2202
2528
  /**
2203
2529
  * Adds a schema to the given event
2204
2530
  * @param id - The id of the event to add the schema to
@@ -2206,14 +2532,14 @@ var src_default = (path7) => {
2206
2532
  * @param version - Optional version of the event to add the schema to
2207
2533
  * @returns
2208
2534
  */
2209
- addSchemaToEvent: addSchemaToEvent(join18(path7)),
2535
+ addSchemaToEvent: addSchemaToEvent(join18(path8)),
2210
2536
  /**
2211
2537
  * Check to see if an event version exists
2212
2538
  * @param id - The id of the event
2213
2539
  * @param version - The version of the event (supports semver)
2214
2540
  * @returns
2215
2541
  */
2216
- eventHasVersion: eventHasVersion(join18(path7)),
2542
+ eventHasVersion: eventHasVersion(join18(path8)),
2217
2543
  /**
2218
2544
  * ================================
2219
2545
  * Commands
@@ -2225,13 +2551,13 @@ var src_default = (path7) => {
2225
2551
  * @param version - Optional id of the version to get (supports semver)
2226
2552
  * @returns Command|Undefined
2227
2553
  */
2228
- getCommand: getCommand(join18(path7)),
2554
+ getCommand: getCommand(join18(path8)),
2229
2555
  /**
2230
2556
  * Returns all commands from EventCatalog
2231
2557
  * @param latestOnly - optional boolean, set to true to get only latest versions
2232
2558
  * @returns Command[]|Undefined
2233
2559
  */
2234
- getCommands: getCommands(join18(path7)),
2560
+ getCommands: getCommands(join18(path8)),
2235
2561
  /**
2236
2562
  * Adds an command to EventCatalog
2237
2563
  *
@@ -2239,7 +2565,7 @@ var src_default = (path7) => {
2239
2565
  * @param options - Optional options to write the command
2240
2566
  *
2241
2567
  */
2242
- writeCommand: writeCommand(join18(path7, "commands")),
2568
+ writeCommand: writeCommand(join18(path8, "commands")),
2243
2569
  /**
2244
2570
  * Adds a command to a service in EventCatalog
2245
2571
  *
@@ -2248,26 +2574,26 @@ var src_default = (path7) => {
2248
2574
  * @param options - Optional options to write the command
2249
2575
  *
2250
2576
  */
2251
- writeCommandToService: writeCommandToService(join18(path7)),
2577
+ writeCommandToService: writeCommandToService(join18(path8)),
2252
2578
  /**
2253
2579
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
2254
2580
  *
2255
2581
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
2256
2582
  *
2257
2583
  */
2258
- rmCommand: rmCommand(join18(path7, "commands")),
2584
+ rmCommand: rmCommand(join18(path8, "commands")),
2259
2585
  /**
2260
2586
  * Remove an command by an Event id
2261
2587
  *
2262
2588
  * @param id - The id of the command you want to remove
2263
2589
  *
2264
2590
  */
2265
- rmCommandById: rmCommandById(join18(path7)),
2591
+ rmCommandById: rmCommandById(join18(path8)),
2266
2592
  /**
2267
2593
  * Moves a given command id to the version directory
2268
2594
  * @param directory
2269
2595
  */
2270
- versionCommand: versionCommand(join18(path7)),
2596
+ versionCommand: versionCommand(join18(path8)),
2271
2597
  /**
2272
2598
  * Adds a file to the given command
2273
2599
  * @param id - The id of the command to add the file to
@@ -2275,7 +2601,7 @@ var src_default = (path7) => {
2275
2601
  * @param version - Optional version of the command to add the file to
2276
2602
  * @returns
2277
2603
  */
2278
- addFileToCommand: addFileToCommand(join18(path7)),
2604
+ addFileToCommand: addFileToCommand(join18(path8)),
2279
2605
  /**
2280
2606
  * Adds a schema to the given command
2281
2607
  * @param id - The id of the command to add the schema to
@@ -2283,14 +2609,14 @@ var src_default = (path7) => {
2283
2609
  * @param version - Optional version of the command to add the schema to
2284
2610
  * @returns
2285
2611
  */
2286
- addSchemaToCommand: addSchemaToCommand(join18(path7)),
2612
+ addSchemaToCommand: addSchemaToCommand(join18(path8)),
2287
2613
  /**
2288
2614
  * Check to see if a command version exists
2289
2615
  * @param id - The id of the command
2290
2616
  * @param version - The version of the command (supports semver)
2291
2617
  * @returns
2292
2618
  */
2293
- commandHasVersion: commandHasVersion(join18(path7)),
2619
+ commandHasVersion: commandHasVersion(join18(path8)),
2294
2620
  /**
2295
2621
  * ================================
2296
2622
  * Queries
@@ -2302,13 +2628,13 @@ var src_default = (path7) => {
2302
2628
  * @param version - Optional id of the version to get (supports semver)
2303
2629
  * @returns Query|Undefined
2304
2630
  */
2305
- getQuery: getQuery(join18(path7)),
2631
+ getQuery: getQuery(join18(path8)),
2306
2632
  /**
2307
2633
  * Returns all queries from EventCatalog
2308
2634
  * @param latestOnly - optional boolean, set to true to get only latest versions
2309
2635
  * @returns Query[]|Undefined
2310
2636
  */
2311
- getQueries: getQueries(join18(path7)),
2637
+ getQueries: getQueries(join18(path8)),
2312
2638
  /**
2313
2639
  * Adds a query to EventCatalog
2314
2640
  *
@@ -2316,7 +2642,7 @@ var src_default = (path7) => {
2316
2642
  * @param options - Optional options to write the event
2317
2643
  *
2318
2644
  */
2319
- writeQuery: writeQuery(join18(path7, "queries")),
2645
+ writeQuery: writeQuery(join18(path8, "queries")),
2320
2646
  /**
2321
2647
  * Adds a query to a service in EventCatalog
2322
2648
  *
@@ -2325,26 +2651,26 @@ var src_default = (path7) => {
2325
2651
  * @param options - Optional options to write the query
2326
2652
  *
2327
2653
  */
2328
- writeQueryToService: writeQueryToService(join18(path7)),
2654
+ writeQueryToService: writeQueryToService(join18(path8)),
2329
2655
  /**
2330
2656
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
2331
2657
  *
2332
2658
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
2333
2659
  *
2334
2660
  */
2335
- rmQuery: rmQuery(join18(path7, "queries")),
2661
+ rmQuery: rmQuery(join18(path8, "queries")),
2336
2662
  /**
2337
2663
  * Remove a query by a Query id
2338
2664
  *
2339
2665
  * @param id - The id of the query you want to remove
2340
2666
  *
2341
2667
  */
2342
- rmQueryById: rmQueryById(join18(path7)),
2668
+ rmQueryById: rmQueryById(join18(path8)),
2343
2669
  /**
2344
2670
  * Moves a given query id to the version directory
2345
2671
  * @param directory
2346
2672
  */
2347
- versionQuery: versionQuery(join18(path7)),
2673
+ versionQuery: versionQuery(join18(path8)),
2348
2674
  /**
2349
2675
  * Adds a file to the given query
2350
2676
  * @param id - The id of the query to add the file to
@@ -2352,7 +2678,7 @@ var src_default = (path7) => {
2352
2678
  * @param version - Optional version of the query to add the file to
2353
2679
  * @returns
2354
2680
  */
2355
- addFileToQuery: addFileToQuery(join18(path7)),
2681
+ addFileToQuery: addFileToQuery(join18(path8)),
2356
2682
  /**
2357
2683
  * Adds a schema to the given query
2358
2684
  * @param id - The id of the query to add the schema to
@@ -2360,14 +2686,14 @@ var src_default = (path7) => {
2360
2686
  * @param version - Optional version of the query to add the schema to
2361
2687
  * @returns
2362
2688
  */
2363
- addSchemaToQuery: addSchemaToQuery(join18(path7)),
2689
+ addSchemaToQuery: addSchemaToQuery(join18(path8)),
2364
2690
  /**
2365
2691
  * Check to see if an query version exists
2366
2692
  * @param id - The id of the query
2367
2693
  * @param version - The version of the query (supports semver)
2368
2694
  * @returns
2369
2695
  */
2370
- queryHasVersion: queryHasVersion(join18(path7)),
2696
+ queryHasVersion: queryHasVersion(join18(path8)),
2371
2697
  /**
2372
2698
  * ================================
2373
2699
  * Channels
@@ -2379,13 +2705,13 @@ var src_default = (path7) => {
2379
2705
  * @param version - Optional id of the version to get (supports semver)
2380
2706
  * @returns Channel|Undefined
2381
2707
  */
2382
- getChannel: getChannel(join18(path7)),
2708
+ getChannel: getChannel(join18(path8)),
2383
2709
  /**
2384
2710
  * Returns all channels from EventCatalog
2385
2711
  * @param latestOnly - optional boolean, set to true to get only latest versions
2386
2712
  * @returns Channel[]|Undefined
2387
2713
  */
2388
- getChannels: getChannels(join18(path7)),
2714
+ getChannels: getChannels(join18(path8)),
2389
2715
  /**
2390
2716
  * Adds an channel to EventCatalog
2391
2717
  *
@@ -2393,33 +2719,33 @@ var src_default = (path7) => {
2393
2719
  * @param options - Optional options to write the channel
2394
2720
  *
2395
2721
  */
2396
- writeChannel: writeChannel(join18(path7, "channels")),
2722
+ writeChannel: writeChannel(join18(path8, "channels")),
2397
2723
  /**
2398
2724
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
2399
2725
  *
2400
2726
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
2401
2727
  *
2402
2728
  */
2403
- rmChannel: rmChannel(join18(path7, "channels")),
2729
+ rmChannel: rmChannel(join18(path8, "channels")),
2404
2730
  /**
2405
2731
  * Remove an channel by an Event id
2406
2732
  *
2407
2733
  * @param id - The id of the channel you want to remove
2408
2734
  *
2409
2735
  */
2410
- rmChannelById: rmChannelById(join18(path7)),
2736
+ rmChannelById: rmChannelById(join18(path8)),
2411
2737
  /**
2412
2738
  * Moves a given channel id to the version directory
2413
2739
  * @param directory
2414
2740
  */
2415
- versionChannel: versionChannel(join18(path7)),
2741
+ versionChannel: versionChannel(join18(path8)),
2416
2742
  /**
2417
2743
  * Check to see if a channel version exists
2418
2744
  * @param id - The id of the channel
2419
2745
  * @param version - The version of the channel (supports semver)
2420
2746
  * @returns
2421
2747
  */
2422
- channelHasVersion: channelHasVersion(join18(path7)),
2748
+ channelHasVersion: channelHasVersion(join18(path8)),
2423
2749
  /**
2424
2750
  * Add a channel to an event
2425
2751
  *
@@ -2436,7 +2762,7 @@ var src_default = (path7) => {
2436
2762
  *
2437
2763
  * ```
2438
2764
  */
2439
- addEventToChannel: addMessageToChannel(join18(path7), "events"),
2765
+ addEventToChannel: addMessageToChannel(join18(path8), "events"),
2440
2766
  /**
2441
2767
  * Add a channel to an command
2442
2768
  *
@@ -2453,7 +2779,7 @@ var src_default = (path7) => {
2453
2779
  *
2454
2780
  * ```
2455
2781
  */
2456
- addCommandToChannel: addMessageToChannel(join18(path7), "commands"),
2782
+ addCommandToChannel: addMessageToChannel(join18(path8), "commands"),
2457
2783
  /**
2458
2784
  * Add a channel to an query
2459
2785
  *
@@ -2470,7 +2796,7 @@ var src_default = (path7) => {
2470
2796
  *
2471
2797
  * ```
2472
2798
  */
2473
- addQueryToChannel: addMessageToChannel(join18(path7), "queries"),
2799
+ addQueryToChannel: addMessageToChannel(join18(path8), "queries"),
2474
2800
  /**
2475
2801
  * ================================
2476
2802
  * SERVICES
@@ -2483,14 +2809,14 @@ var src_default = (path7) => {
2483
2809
  * @param options - Optional options to write the event
2484
2810
  *
2485
2811
  */
2486
- writeService: writeService(join18(path7, "services")),
2812
+ writeService: writeService(join18(path8, "services")),
2487
2813
  /**
2488
2814
  * Adds a versioned service to EventCatalog
2489
2815
  *
2490
2816
  * @param service - The service to write
2491
2817
  *
2492
2818
  */
2493
- writeVersionedService: writeVersionedService(join18(path7, "services")),
2819
+ writeVersionedService: writeVersionedService(join18(path8, "services")),
2494
2820
  /**
2495
2821
  * Adds a service to a domain in EventCatalog
2496
2822
  *
@@ -2499,45 +2825,45 @@ var src_default = (path7) => {
2499
2825
  * @param options - Optional options to write the event
2500
2826
  *
2501
2827
  */
2502
- writeServiceToDomain: writeServiceToDomain(join18(path7, "domains")),
2828
+ writeServiceToDomain: writeServiceToDomain(join18(path8, "domains")),
2503
2829
  /**
2504
2830
  * Returns a service from EventCatalog
2505
2831
  * @param id - The id of the service to retrieve
2506
2832
  * @param version - Optional id of the version to get (supports semver)
2507
2833
  * @returns Service|Undefined
2508
2834
  */
2509
- getService: getService(join18(path7)),
2835
+ getService: getService(join18(path8)),
2510
2836
  /**
2511
2837
  * Returns a service from EventCatalog by it's path.
2512
2838
  * @param path - The path to the service to retrieve
2513
2839
  * @returns Service|Undefined
2514
2840
  */
2515
- getServiceByPath: getServiceByPath(join18(path7)),
2841
+ getServiceByPath: getServiceByPath(join18(path8)),
2516
2842
  /**
2517
2843
  * Returns all services from EventCatalog
2518
2844
  * @param latestOnly - optional boolean, set to true to get only latest versions
2519
2845
  * @returns Service[]|Undefined
2520
2846
  */
2521
- getServices: getServices(join18(path7)),
2847
+ getServices: getServices(join18(path8)),
2522
2848
  /**
2523
2849
  * Moves a given service id to the version directory
2524
2850
  * @param directory
2525
2851
  */
2526
- versionService: versionService(join18(path7)),
2852
+ versionService: versionService(join18(path8)),
2527
2853
  /**
2528
2854
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
2529
2855
  *
2530
2856
  * @param path - The path to your service, e.g. `/InventoryService`
2531
2857
  *
2532
2858
  */
2533
- rmService: rmService(join18(path7, "services")),
2859
+ rmService: rmService(join18(path8, "services")),
2534
2860
  /**
2535
2861
  * Remove an service by an service id
2536
2862
  *
2537
2863
  * @param id - The id of the service you want to remove
2538
2864
  *
2539
2865
  */
2540
- rmServiceById: rmServiceById(join18(path7)),
2866
+ rmServiceById: rmServiceById(join18(path8)),
2541
2867
  /**
2542
2868
  * Adds a file to the given service
2543
2869
  * @param id - The id of the service to add the file to
@@ -2545,21 +2871,21 @@ var src_default = (path7) => {
2545
2871
  * @param version - Optional version of the service to add the file to
2546
2872
  * @returns
2547
2873
  */
2548
- addFileToService: addFileToService(join18(path7)),
2874
+ addFileToService: addFileToService(join18(path8)),
2549
2875
  /**
2550
2876
  * Returns the specifications for a given service
2551
2877
  * @param id - The id of the service to retrieve the specifications for
2552
2878
  * @param version - Optional version of the service
2553
2879
  * @returns
2554
2880
  */
2555
- getSpecificationFilesForService: getSpecificationFilesForService(join18(path7)),
2881
+ getSpecificationFilesForService: getSpecificationFilesForService(join18(path8)),
2556
2882
  /**
2557
2883
  * Check to see if a service version exists
2558
2884
  * @param id - The id of the service
2559
2885
  * @param version - The version of the service (supports semver)
2560
2886
  * @returns
2561
2887
  */
2562
- serviceHasVersion: serviceHasVersion(join18(path7)),
2888
+ serviceHasVersion: serviceHasVersion(join18(path8)),
2563
2889
  /**
2564
2890
  * Add an event to a service by it's id.
2565
2891
  *
@@ -2579,7 +2905,7 @@ var src_default = (path7) => {
2579
2905
  *
2580
2906
  * ```
2581
2907
  */
2582
- addEventToService: addMessageToService(join18(path7)),
2908
+ addEventToService: addMessageToService(join18(path8)),
2583
2909
  /**
2584
2910
  * Add a data store to a service by it's id.
2585
2911
  *
@@ -2596,7 +2922,7 @@ var src_default = (path7) => {
2596
2922
  *
2597
2923
  * ```
2598
2924
  */
2599
- addDataStoreToService: addDataStoreToService(join18(path7)),
2925
+ addDataStoreToService: addDataStoreToService(join18(path8)),
2600
2926
  /**
2601
2927
  * Add a command to a service by it's id.
2602
2928
  *
@@ -2616,7 +2942,7 @@ var src_default = (path7) => {
2616
2942
  *
2617
2943
  * ```
2618
2944
  */
2619
- addCommandToService: addMessageToService(join18(path7)),
2945
+ addCommandToService: addMessageToService(join18(path8)),
2620
2946
  /**
2621
2947
  * Add a query to a service by it's id.
2622
2948
  *
@@ -2636,7 +2962,7 @@ var src_default = (path7) => {
2636
2962
  *
2637
2963
  * ```
2638
2964
  */
2639
- addQueryToService: addMessageToService(join18(path7)),
2965
+ addQueryToService: addMessageToService(join18(path8)),
2640
2966
  /**
2641
2967
  * Add an entity to a service by its id.
2642
2968
  *
@@ -2654,7 +2980,7 @@ var src_default = (path7) => {
2654
2980
  *
2655
2981
  * ```
2656
2982
  */
2657
- addEntityToService: addEntityToService(join18(path7)),
2983
+ addEntityToService: addEntityToService(join18(path8)),
2658
2984
  /**
2659
2985
  * Check to see if a service exists by it's path.
2660
2986
  *
@@ -2671,13 +2997,13 @@ var src_default = (path7) => {
2671
2997
  * @param path - The path to the service to check
2672
2998
  * @returns boolean
2673
2999
  */
2674
- isService: isService(join18(path7)),
3000
+ isService: isService(join18(path8)),
2675
3001
  /**
2676
3002
  * Converts a file to a service.
2677
3003
  * @param file - The file to convert to a service.
2678
3004
  * @returns The service.
2679
3005
  */
2680
- toService: toService(join18(path7)),
3006
+ toService: toService(join18(path8)),
2681
3007
  /**
2682
3008
  * ================================
2683
3009
  * Domains
@@ -2690,39 +3016,39 @@ var src_default = (path7) => {
2690
3016
  * @param options - Optional options to write the event
2691
3017
  *
2692
3018
  */
2693
- writeDomain: writeDomain(join18(path7, "domains")),
3019
+ writeDomain: writeDomain(join18(path8, "domains")),
2694
3020
  /**
2695
3021
  * Returns a domain from EventCatalog
2696
3022
  * @param id - The id of the domain to retrieve
2697
3023
  * @param version - Optional id of the version to get (supports semver)
2698
3024
  * @returns Domain|Undefined
2699
3025
  */
2700
- getDomain: getDomain(join18(path7, "domains")),
3026
+ getDomain: getDomain(join18(path8, "domains")),
2701
3027
  /**
2702
3028
  * Returns all domains from EventCatalog
2703
3029
  * @param latestOnly - optional boolean, set to true to get only latest versions
2704
3030
  * @returns Domain[]|Undefined
2705
3031
  */
2706
- getDomains: getDomains(join18(path7)),
3032
+ getDomains: getDomains(join18(path8)),
2707
3033
  /**
2708
3034
  * Moves a given domain id to the version directory
2709
3035
  * @param directory
2710
3036
  */
2711
- versionDomain: versionDomain(join18(path7, "domains")),
3037
+ versionDomain: versionDomain(join18(path8, "domains")),
2712
3038
  /**
2713
3039
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
2714
3040
  *
2715
3041
  * @param path - The path to your domain, e.g. `/Payment`
2716
3042
  *
2717
3043
  */
2718
- rmDomain: rmDomain(join18(path7, "domains")),
3044
+ rmDomain: rmDomain(join18(path8, "domains")),
2719
3045
  /**
2720
3046
  * Remove an service by an domain id
2721
3047
  *
2722
3048
  * @param id - The id of the domain you want to remove
2723
3049
  *
2724
3050
  */
2725
- rmDomainById: rmDomainById(join18(path7, "domains")),
3051
+ rmDomainById: rmDomainById(join18(path8, "domains")),
2726
3052
  /**
2727
3053
  * Adds a file to the given domain
2728
3054
  * @param id - The id of the domain to add the file to
@@ -2730,28 +3056,28 @@ var src_default = (path7) => {
2730
3056
  * @param version - Optional version of the domain to add the file to
2731
3057
  * @returns
2732
3058
  */
2733
- addFileToDomain: addFileToDomain(join18(path7, "domains")),
3059
+ addFileToDomain: addFileToDomain(join18(path8, "domains")),
2734
3060
  /**
2735
3061
  * Adds an ubiquitous language dictionary to a domain
2736
3062
  * @param id - The id of the domain to add the ubiquitous language to
2737
3063
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
2738
3064
  * @param version - Optional version of the domain to add the ubiquitous language to
2739
3065
  */
2740
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join18(path7, "domains")),
3066
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join18(path8, "domains")),
2741
3067
  /**
2742
3068
  * Get the ubiquitous language dictionary from a domain
2743
3069
  * @param id - The id of the domain to get the ubiquitous language from
2744
3070
  * @param version - Optional version of the domain to get the ubiquitous language from
2745
3071
  * @returns
2746
3072
  */
2747
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join18(path7, "domains")),
3073
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join18(path8, "domains")),
2748
3074
  /**
2749
3075
  * Check to see if a domain version exists
2750
3076
  * @param id - The id of the domain
2751
3077
  * @param version - The version of the domain (supports semver)
2752
3078
  * @returns
2753
3079
  */
2754
- domainHasVersion: domainHasVersion(join18(path7)),
3080
+ domainHasVersion: domainHasVersion(join18(path8)),
2755
3081
  /**
2756
3082
  * Adds a given service to a domain
2757
3083
  * @param id - The id of the domain
@@ -2759,7 +3085,7 @@ var src_default = (path7) => {
2759
3085
  * @param version - (Optional) The version of the domain to add the service to
2760
3086
  * @returns
2761
3087
  */
2762
- addServiceToDomain: addServiceToDomain(join18(path7, "domains")),
3088
+ addServiceToDomain: addServiceToDomain(join18(path8, "domains")),
2763
3089
  /**
2764
3090
  * Adds a given subdomain to a domain
2765
3091
  * @param id - The id of the domain
@@ -2767,7 +3093,7 @@ var src_default = (path7) => {
2767
3093
  * @param version - (Optional) The version of the domain to add the subdomain to
2768
3094
  * @returns
2769
3095
  */
2770
- addSubDomainToDomain: addSubDomainToDomain(join18(path7, "domains")),
3096
+ addSubDomainToDomain: addSubDomainToDomain(join18(path8, "domains")),
2771
3097
  /**
2772
3098
  * Adds an entity to a domain
2773
3099
  * @param id - The id of the domain
@@ -2775,7 +3101,7 @@ var src_default = (path7) => {
2775
3101
  * @param version - (Optional) The version of the domain to add the entity to
2776
3102
  * @returns
2777
3103
  */
2778
- addEntityToDomain: addEntityToDomain(join18(path7, "domains")),
3104
+ addEntityToDomain: addEntityToDomain(join18(path8, "domains")),
2779
3105
  /**
2780
3106
  * Add an event to a domain by its id.
2781
3107
  *
@@ -2793,7 +3119,7 @@ var src_default = (path7) => {
2793
3119
  *
2794
3120
  * ```
2795
3121
  */
2796
- addEventToDomain: addMessageToDomain(join18(path7, "domains")),
3122
+ addEventToDomain: addMessageToDomain(join18(path8, "domains")),
2797
3123
  /**
2798
3124
  * Add a command to a domain by its id.
2799
3125
  *
@@ -2811,7 +3137,7 @@ var src_default = (path7) => {
2811
3137
  *
2812
3138
  * ```
2813
3139
  */
2814
- addCommandToDomain: addMessageToDomain(join18(path7, "domains")),
3140
+ addCommandToDomain: addMessageToDomain(join18(path8, "domains")),
2815
3141
  /**
2816
3142
  * Add a query to a domain by its id.
2817
3143
  *
@@ -2829,7 +3155,7 @@ var src_default = (path7) => {
2829
3155
  *
2830
3156
  * ```
2831
3157
  */
2832
- addQueryToDomain: addMessageToDomain(join18(path7, "domains")),
3158
+ addQueryToDomain: addMessageToDomain(join18(path8, "domains")),
2833
3159
  /**
2834
3160
  * ================================
2835
3161
  * Teams
@@ -2842,25 +3168,25 @@ var src_default = (path7) => {
2842
3168
  * @param options - Optional options to write the team
2843
3169
  *
2844
3170
  */
2845
- writeTeam: writeTeam(join18(path7, "teams")),
3171
+ writeTeam: writeTeam(join18(path8, "teams")),
2846
3172
  /**
2847
3173
  * Returns a team from EventCatalog
2848
3174
  * @param id - The id of the team to retrieve
2849
3175
  * @returns Team|Undefined
2850
3176
  */
2851
- getTeam: getTeam(join18(path7, "teams")),
3177
+ getTeam: getTeam(join18(path8, "teams")),
2852
3178
  /**
2853
3179
  * Returns all teams from EventCatalog
2854
3180
  * @returns Team[]|Undefined
2855
3181
  */
2856
- getTeams: getTeams(join18(path7, "teams")),
3182
+ getTeams: getTeams(join18(path8, "teams")),
2857
3183
  /**
2858
3184
  * Remove a team by the team id
2859
3185
  *
2860
3186
  * @param id - The id of the team you want to remove
2861
3187
  *
2862
3188
  */
2863
- rmTeamById: rmTeamById(join18(path7, "teams")),
3189
+ rmTeamById: rmTeamById(join18(path8, "teams")),
2864
3190
  /**
2865
3191
  * ================================
2866
3192
  * Users
@@ -2873,25 +3199,25 @@ var src_default = (path7) => {
2873
3199
  * @param options - Optional options to write the user
2874
3200
  *
2875
3201
  */
2876
- writeUser: writeUser(join18(path7, "users")),
3202
+ writeUser: writeUser(join18(path8, "users")),
2877
3203
  /**
2878
3204
  * Returns a user from EventCatalog
2879
3205
  * @param id - The id of the user to retrieve
2880
3206
  * @returns User|Undefined
2881
3207
  */
2882
- getUser: getUser(join18(path7, "users")),
3208
+ getUser: getUser(join18(path8, "users")),
2883
3209
  /**
2884
3210
  * Returns all user from EventCatalog
2885
3211
  * @returns User[]|Undefined
2886
3212
  */
2887
- getUsers: getUsers(join18(path7)),
3213
+ getUsers: getUsers(join18(path8)),
2888
3214
  /**
2889
3215
  * Remove a user by the user id
2890
3216
  *
2891
3217
  * @param id - The id of the user you want to remove
2892
3218
  *
2893
3219
  */
2894
- rmUserById: rmUserById(join18(path7, "users")),
3220
+ rmUserById: rmUserById(join18(path8, "users")),
2895
3221
  /**
2896
3222
  * ================================
2897
3223
  * Custom Docs
@@ -2902,32 +3228,32 @@ var src_default = (path7) => {
2902
3228
  * @param path - The path to the custom doc to retrieve
2903
3229
  * @returns CustomDoc|Undefined
2904
3230
  */
2905
- getCustomDoc: getCustomDoc(join18(path7, "docs")),
3231
+ getCustomDoc: getCustomDoc(join18(path8, "docs")),
2906
3232
  /**
2907
3233
  * Returns all custom docs from EventCatalog
2908
3234
  * @param options - Optional options to get custom docs from a specific path
2909
3235
  * @returns CustomDoc[]|Undefined
2910
3236
  */
2911
- getCustomDocs: getCustomDocs(join18(path7, "docs")),
3237
+ getCustomDocs: getCustomDocs(join18(path8, "docs")),
2912
3238
  /**
2913
3239
  * Writes a custom doc to EventCatalog
2914
3240
  * @param customDoc - The custom doc to write
2915
3241
  * @param options - Optional options to write the custom doc
2916
3242
  *
2917
3243
  */
2918
- writeCustomDoc: writeCustomDoc(join18(path7, "docs")),
3244
+ writeCustomDoc: writeCustomDoc(join18(path8, "docs")),
2919
3245
  /**
2920
3246
  * Removes a custom doc from EventCatalog
2921
3247
  * @param path - The path to the custom doc to remove
2922
3248
  *
2923
3249
  */
2924
- rmCustomDoc: rmCustomDoc(join18(path7, "docs")),
3250
+ rmCustomDoc: rmCustomDoc(join18(path8, "docs")),
2925
3251
  /**
2926
3252
  * Dumps the catalog to a JSON file.
2927
3253
  * @param directory - The directory to dump the catalog to
2928
3254
  * @returns A JSON file with the catalog
2929
3255
  */
2930
- dumpCatalog: dumpCatalog(join18(path7)),
3256
+ dumpCatalog: dumpCatalog(join18(path8)),
2931
3257
  /**
2932
3258
  * Returns the event catalog configuration file.
2933
3259
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -2935,7 +3261,7 @@ var src_default = (path7) => {
2935
3261
  * @param directory - The directory of the catalog.
2936
3262
  * @returns A JSON object with the configuration for the event catalog.
2937
3263
  */
2938
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join18(path7)),
3264
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join18(path8)),
2939
3265
  /**
2940
3266
  * ================================
2941
3267
  * Changelogs
@@ -2949,7 +3275,7 @@ var src_default = (path7) => {
2949
3275
  * @param options - Optional options (version, format)
2950
3276
  *
2951
3277
  */
2952
- writeChangelog: writeChangelog(join18(path7)),
3278
+ writeChangelog: writeChangelog(join18(path8)),
2953
3279
  /**
2954
3280
  * Appends a changelog entry to an existing changelog for a resource.
2955
3281
  * If no changelog exists, one is created.
@@ -2959,7 +3285,7 @@ var src_default = (path7) => {
2959
3285
  * @param options - Optional options (version, format)
2960
3286
  *
2961
3287
  */
2962
- appendChangelog: appendChangelog(join18(path7)),
3288
+ appendChangelog: appendChangelog(join18(path8)),
2963
3289
  /**
2964
3290
  * Returns the changelog for a resource in EventCatalog
2965
3291
  *
@@ -2967,7 +3293,7 @@ var src_default = (path7) => {
2967
3293
  * @param options - Optional options (version)
2968
3294
  * @returns Changelog|Undefined
2969
3295
  */
2970
- getChangelog: getChangelog(join18(path7)),
3296
+ getChangelog: getChangelog(join18(path8)),
2971
3297
  /**
2972
3298
  * Removes the changelog for a resource in EventCatalog
2973
3299
  *
@@ -2975,7 +3301,7 @@ var src_default = (path7) => {
2975
3301
  * @param options - Optional options (version)
2976
3302
  *
2977
3303
  */
2978
- rmChangelog: rmChangelog(join18(path7)),
3304
+ rmChangelog: rmChangelog(join18(path8)),
2979
3305
  /**
2980
3306
  * ================================
2981
3307
  * Resources Utils
@@ -3000,33 +3326,41 @@ var src_default = (path7) => {
3000
3326
  * @param path - The path to the message to retrieve
3001
3327
  * @returns Message|Undefined
3002
3328
  */
3003
- getMessageBySchemaPath: getMessageBySchemaPath(join18(path7)),
3329
+ getMessageBySchemaPath: getMessageBySchemaPath(join18(path8)),
3004
3330
  /**
3005
3331
  * Returns the producers and consumers (services) for a given message
3006
3332
  * @param id - The id of the message to get the producers and consumers for
3007
3333
  * @param version - Optional version of the message
3008
3334
  * @returns { producers: Service[], consumers: Service[] }
3009
3335
  */
3010
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join18(path7)),
3336
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join18(path8)),
3011
3337
  /**
3012
3338
  * Returns the consumers of a given schema path
3013
3339
  * @param path - The path to the schema to get the consumers for
3014
3340
  * @returns Service[]
3015
3341
  */
3016
- getConsumersOfSchema: getConsumersOfSchema(join18(path7)),
3342
+ getConsumersOfSchema: getConsumersOfSchema(join18(path8)),
3017
3343
  /**
3018
3344
  * Returns the producers of a given schema path
3019
3345
  * @param path - The path to the schema to get the producers for
3020
3346
  * @returns Service[]
3021
3347
  */
3022
- getProducersOfSchema: getProducersOfSchema(join18(path7)),
3348
+ getProducersOfSchema: getProducersOfSchema(join18(path8)),
3349
+ /**
3350
+ * Returns the schema for a given message (event, command or query) by its id and version.
3351
+ * If no version is given, the latest version is used.
3352
+ * @param id - The id of the message to get the schema for
3353
+ * @param version - Optional version of the message
3354
+ * @returns { schema: string, fileName: string } | undefined
3355
+ */
3356
+ getSchemaForMessage: getSchemaForMessage(join18(path8)),
3023
3357
  /**
3024
3358
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
3025
3359
  * @param id - The id of the resource to get the owners for
3026
3360
  * @param version - Optional version of the resource
3027
3361
  * @returns { owners: User[] }
3028
3362
  */
3029
- getOwnersForResource: getOwnersForResource(join18(path7)),
3363
+ getOwnersForResource: getOwnersForResource(join18(path8)),
3030
3364
  /**
3031
3365
  * ================================
3032
3366
  * Entities
@@ -3038,13 +3372,13 @@ var src_default = (path7) => {
3038
3372
  * @param version - Optional id of the version to get (supports semver)
3039
3373
  * @returns Entity|Undefined
3040
3374
  */
3041
- getEntity: getEntity(join18(path7)),
3375
+ getEntity: getEntity(join18(path8)),
3042
3376
  /**
3043
3377
  * Returns all entities from EventCatalog
3044
3378
  * @param latestOnly - optional boolean, set to true to get only latest versions
3045
3379
  * @returns Entity[]|Undefined
3046
3380
  */
3047
- getEntities: getEntities(join18(path7)),
3381
+ getEntities: getEntities(join18(path8)),
3048
3382
  /**
3049
3383
  * Adds an entity to EventCatalog
3050
3384
  *
@@ -3052,33 +3386,33 @@ var src_default = (path7) => {
3052
3386
  * @param options - Optional options to write the entity
3053
3387
  *
3054
3388
  */
3055
- writeEntity: writeEntity(join18(path7, "entities")),
3389
+ writeEntity: writeEntity(join18(path8, "entities")),
3056
3390
  /**
3057
3391
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
3058
3392
  *
3059
3393
  * @param path - The path to your entity, e.g. `/User`
3060
3394
  *
3061
3395
  */
3062
- rmEntity: rmEntity(join18(path7, "entities")),
3396
+ rmEntity: rmEntity(join18(path8, "entities")),
3063
3397
  /**
3064
3398
  * Remove an entity by an entity id
3065
3399
  *
3066
3400
  * @param id - The id of the entity you want to remove
3067
3401
  *
3068
3402
  */
3069
- rmEntityById: rmEntityById(join18(path7)),
3403
+ rmEntityById: rmEntityById(join18(path8)),
3070
3404
  /**
3071
3405
  * Moves a given entity id to the version directory
3072
3406
  * @param id - The id of the entity to version
3073
3407
  */
3074
- versionEntity: versionEntity(join18(path7)),
3408
+ versionEntity: versionEntity(join18(path8)),
3075
3409
  /**
3076
3410
  * Check to see if an entity version exists
3077
3411
  * @param id - The id of the entity
3078
3412
  * @param version - The version of the entity (supports semver)
3079
3413
  * @returns
3080
3414
  */
3081
- entityHasVersion: entityHasVersion(join18(path7)),
3415
+ entityHasVersion: entityHasVersion(join18(path8)),
3082
3416
  /**
3083
3417
  * ================================
3084
3418
  * Data Stores
@@ -3090,42 +3424,42 @@ var src_default = (path7) => {
3090
3424
  * @param options - Optional options to write the data store
3091
3425
  *
3092
3426
  */
3093
- writeDataStore: writeDataStore(join18(path7, "containers")),
3427
+ writeDataStore: writeDataStore(join18(path8, "containers")),
3094
3428
  /**
3095
3429
  * Returns a data store from EventCatalog
3096
3430
  * @param id - The id of the data store to retrieve
3097
3431
  * @param version - Optional id of the version to get (supports semver)
3098
3432
  * @returns Container|Undefined
3099
3433
  */
3100
- getDataStore: getDataStore(join18(path7)),
3434
+ getDataStore: getDataStore(join18(path8)),
3101
3435
  /**
3102
3436
  * Returns all data stores from EventCatalog
3103
3437
  * @param latestOnly - optional boolean, set to true to get only latest versions
3104
3438
  * @returns Container[]|Undefined
3105
3439
  */
3106
- getDataStores: getDataStores(join18(path7)),
3440
+ getDataStores: getDataStores(join18(path8)),
3107
3441
  /**
3108
3442
  * Version a data store by its id
3109
3443
  * @param id - The id of the data store to version
3110
3444
  */
3111
- versionDataStore: versionDataStore(join18(path7, "containers")),
3445
+ versionDataStore: versionDataStore(join18(path8, "containers")),
3112
3446
  /**
3113
3447
  * Remove a data store by its path
3114
3448
  * @param path - The path to the data store to remove
3115
3449
  */
3116
- rmDataStore: rmDataStore(join18(path7, "containers")),
3450
+ rmDataStore: rmDataStore(join18(path8, "containers")),
3117
3451
  /**
3118
3452
  * Remove a data store by its id
3119
3453
  * @param id - The id of the data store to remove
3120
3454
  */
3121
- rmDataStoreById: rmDataStoreById(join18(path7)),
3455
+ rmDataStoreById: rmDataStoreById(join18(path8)),
3122
3456
  /**
3123
3457
  * Check to see if a data store version exists
3124
3458
  * @param id - The id of the data store
3125
3459
  * @param version - The version of the data store (supports semver)
3126
3460
  * @returns
3127
3461
  */
3128
- dataStoreHasVersion: dataStoreHasVersion(join18(path7)),
3462
+ dataStoreHasVersion: dataStoreHasVersion(join18(path8)),
3129
3463
  /**
3130
3464
  * Adds a file to a data store by its id
3131
3465
  * @param id - The id of the data store to add the file to
@@ -3133,14 +3467,14 @@ var src_default = (path7) => {
3133
3467
  * @param version - Optional version of the data store to add the file to
3134
3468
  * @returns
3135
3469
  */
3136
- addFileToDataStore: addFileToDataStore(join18(path7)),
3470
+ addFileToDataStore: addFileToDataStore(join18(path8)),
3137
3471
  /**
3138
3472
  * Writes a data store to a service by its id
3139
3473
  * @param dataStore - The data store to write
3140
3474
  * @param service - The service to write the data store to
3141
3475
  * @returns
3142
3476
  */
3143
- writeDataStoreToService: writeDataStoreToService(join18(path7)),
3477
+ writeDataStoreToService: writeDataStoreToService(join18(path8)),
3144
3478
  /**
3145
3479
  * ================================
3146
3480
  * Data Products
@@ -3152,7 +3486,7 @@ var src_default = (path7) => {
3152
3486
  * @param options - Optional options to write the data product
3153
3487
  *
3154
3488
  */
3155
- writeDataProduct: writeDataProduct(join18(path7, "data-products")),
3489
+ writeDataProduct: writeDataProduct(join18(path8, "data-products")),
3156
3490
  /**
3157
3491
  * Writes a data product to a domain in EventCatalog
3158
3492
  * @param dataProduct - The data product to write
@@ -3160,43 +3494,43 @@ var src_default = (path7) => {
3160
3494
  * @param options - Optional options to write the data product
3161
3495
  *
3162
3496
  */
3163
- writeDataProductToDomain: writeDataProductToDomain(join18(path7, "domains")),
3497
+ writeDataProductToDomain: writeDataProductToDomain(join18(path8, "domains")),
3164
3498
  /**
3165
3499
  * Returns a data product from EventCatalog
3166
3500
  * @param id - The id of the data product to retrieve
3167
3501
  * @param version - Optional id of the version to get (supports semver)
3168
3502
  * @returns DataProduct|Undefined
3169
3503
  */
3170
- getDataProduct: getDataProduct(join18(path7)),
3504
+ getDataProduct: getDataProduct(join18(path8)),
3171
3505
  /**
3172
3506
  * Returns all data products from EventCatalog
3173
3507
  * @param latestOnly - optional boolean, set to true to get only latest versions
3174
3508
  * @returns DataProduct[]|Undefined
3175
3509
  */
3176
- getDataProducts: getDataProducts(join18(path7)),
3510
+ getDataProducts: getDataProducts(join18(path8)),
3177
3511
  /**
3178
3512
  * Version a data product by its id
3179
3513
  * @param id - The id of the data product to version
3180
3514
  */
3181
- versionDataProduct: versionDataProduct(join18(path7)),
3515
+ versionDataProduct: versionDataProduct(join18(path8)),
3182
3516
  /**
3183
3517
  * Remove a data product by its path
3184
3518
  * @param path - The path to the data product to remove
3185
3519
  */
3186
- rmDataProduct: rmDataProduct(join18(path7, "data-products")),
3520
+ rmDataProduct: rmDataProduct(join18(path8, "data-products")),
3187
3521
  /**
3188
3522
  * Remove a data product by its id
3189
3523
  * @param id - The id of the data product to remove
3190
3524
  * @param version - Optional version of the data product to remove
3191
3525
  */
3192
- rmDataProductById: rmDataProductById(join18(path7)),
3526
+ rmDataProductById: rmDataProductById(join18(path8)),
3193
3527
  /**
3194
3528
  * Check to see if a data product version exists
3195
3529
  * @param id - The id of the data product
3196
3530
  * @param version - The version of the data product (supports semver)
3197
3531
  * @returns
3198
3532
  */
3199
- dataProductHasVersion: dataProductHasVersion(join18(path7)),
3533
+ dataProductHasVersion: dataProductHasVersion(join18(path8)),
3200
3534
  /**
3201
3535
  * Adds a file to a data product by its id
3202
3536
  * @param id - The id of the data product to add the file to
@@ -3204,7 +3538,7 @@ var src_default = (path7) => {
3204
3538
  * @param version - Optional version of the data product to add the file to
3205
3539
  * @returns
3206
3540
  */
3207
- addFileToDataProduct: addFileToDataProduct(join18(path7)),
3541
+ addFileToDataProduct: addFileToDataProduct(join18(path8)),
3208
3542
  /**
3209
3543
  * Adds a data product to a domain
3210
3544
  * @param id - The id of the domain
@@ -3212,7 +3546,7 @@ var src_default = (path7) => {
3212
3546
  * @param version - (Optional) The version of the domain to add the data product to
3213
3547
  * @returns
3214
3548
  */
3215
- addDataProductToDomain: addDataProductToDomain(join18(path7, "domains")),
3549
+ addDataProductToDomain: addDataProductToDomain(join18(path8, "domains")),
3216
3550
  /**
3217
3551
  * ================================
3218
3552
  * Diagrams
@@ -3224,13 +3558,13 @@ var src_default = (path7) => {
3224
3558
  * @param version - Optional id of the version to get (supports semver)
3225
3559
  * @returns Diagram|Undefined
3226
3560
  */
3227
- getDiagram: getDiagram(join18(path7)),
3561
+ getDiagram: getDiagram(join18(path8)),
3228
3562
  /**
3229
3563
  * Returns all diagrams from EventCatalog
3230
3564
  * @param latestOnly - optional boolean, set to true to get only latest versions
3231
3565
  * @returns Diagram[]|Undefined
3232
3566
  */
3233
- getDiagrams: getDiagrams(join18(path7)),
3567
+ getDiagrams: getDiagrams(join18(path8)),
3234
3568
  /**
3235
3569
  * Adds a diagram to EventCatalog
3236
3570
  *
@@ -3238,33 +3572,33 @@ var src_default = (path7) => {
3238
3572
  * @param options - Optional options to write the diagram
3239
3573
  *
3240
3574
  */
3241
- writeDiagram: writeDiagram(join18(path7, "diagrams")),
3575
+ writeDiagram: writeDiagram(join18(path8, "diagrams")),
3242
3576
  /**
3243
3577
  * Remove a diagram from EventCatalog (modeled on the standard POSIX rm utility)
3244
3578
  *
3245
3579
  * @param path - The path to your diagram, e.g. `/ArchitectureDiagram`
3246
3580
  *
3247
3581
  */
3248
- rmDiagram: rmDiagram(join18(path7, "diagrams")),
3582
+ rmDiagram: rmDiagram(join18(path8, "diagrams")),
3249
3583
  /**
3250
3584
  * Remove a diagram by a diagram id
3251
3585
  *
3252
3586
  * @param id - The id of the diagram you want to remove
3253
3587
  *
3254
3588
  */
3255
- rmDiagramById: rmDiagramById(join18(path7)),
3589
+ rmDiagramById: rmDiagramById(join18(path8)),
3256
3590
  /**
3257
3591
  * Moves a given diagram id to the version directory
3258
3592
  * @param id - The id of the diagram to version
3259
3593
  */
3260
- versionDiagram: versionDiagram(join18(path7)),
3594
+ versionDiagram: versionDiagram(join18(path8)),
3261
3595
  /**
3262
3596
  * Check to see if a diagram version exists
3263
3597
  * @param id - The id of the diagram
3264
3598
  * @param version - The version of the diagram (supports semver)
3265
3599
  * @returns
3266
3600
  */
3267
- diagramHasVersion: diagramHasVersion(join18(path7)),
3601
+ diagramHasVersion: diagramHasVersion(join18(path8)),
3268
3602
  /**
3269
3603
  * Adds a file to the given diagram
3270
3604
  * @param id - The id of the diagram to add the file to
@@ -3272,7 +3606,7 @@ var src_default = (path7) => {
3272
3606
  * @param version - Optional version of the diagram to add the file to
3273
3607
  * @returns
3274
3608
  */
3275
- addFileToDiagram: addFileToDiagram(join18(path7)),
3609
+ addFileToDiagram: addFileToDiagram(join18(path8)),
3276
3610
  /**
3277
3611
  * ================================
3278
3612
  * DSL
@@ -3291,18 +3625,21 @@ var src_default = (path7) => {
3291
3625
  * const dsl = await sdk.toDSL(services, { type: 'service', hydrate: true });
3292
3626
  * ```
3293
3627
  */
3294
- toDSL: toDSL(join18(path7), {
3295
- getEvent: getEvent(join18(path7)),
3296
- getCommand: getCommand(join18(path7)),
3297
- getQuery: getQuery(join18(path7)),
3298
- getService: getService(join18(path7)),
3299
- getServices: getServices(join18(path7)),
3300
- getDomain: getDomain(join18(path7, "domains")),
3301
- getChannel: getChannel(join18(path7)),
3302
- getChannels: getChannels(join18(path7)),
3303
- getContainer: getDataStore(join18(path7)),
3304
- getTeam: getTeam(join18(path7, "teams")),
3305
- getUser: getUser(join18(path7, "users"))
3628
+ createSnapshot: createSnapshot(join18(path8)),
3629
+ diffSnapshots: diffSnapshots(join18(path8)),
3630
+ listSnapshots: listSnapshots(join18(path8)),
3631
+ toDSL: toDSL(join18(path8), {
3632
+ getEvent: getEvent(join18(path8)),
3633
+ getCommand: getCommand(join18(path8)),
3634
+ getQuery: getQuery(join18(path8)),
3635
+ getService: getService(join18(path8)),
3636
+ getServices: getServices(join18(path8)),
3637
+ getDomain: getDomain(join18(path8, "domains")),
3638
+ getChannel: getChannel(join18(path8)),
3639
+ getChannels: getChannels(join18(path8)),
3640
+ getContainer: getDataStore(join18(path8)),
3641
+ getTeam: getTeam(join18(path8, "teams")),
3642
+ getUser: getUser(join18(path8, "users"))
3306
3643
  })
3307
3644
  };
3308
3645
  };