@eventcatalog/sdk 2.15.1 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -794,8 +794,8 @@ var getFiles = async (pattern, ignore = "") => {
794
794
  );
795
795
  }
796
796
  };
797
- var readMdxFile = async (path6) => {
798
- const { data } = matter.read(path6);
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 path6 = options.path || `/${resource.id}`;
893
- const fullPath = join2(catalogDir, path6);
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 (path6, 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(path6);
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 ${path6} 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 (path6) => {
1090
- await fs2.rm(join3(directory, path6), { 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 (path6) => {
1127
- await fs3.rm(join4(directory, path6), { 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 (path6) => {
1162
- await fs4.rm(join5(directory, path6), { 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 (path6) => {
1183
- const service = await getResource(directory, void 0, void 0, { type: "service" }, path6);
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 path6 = getVersionedDirectory(service.id, service.version);
1219
- return await writeService(directory)(resource, { path: path6 });
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 (path6) => {
1228
- await fs5.rm(join6(directory, path6), { 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 path6 = existingResource.split(/[\\/]+services/)[0];
1294
- const pathToResource = join6(path6, "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 (path6) => {
1303
- const service = await getServiceByPath(directory)(path6);
1304
- const relativePath = relative2(directory, path6);
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 path6 = existingResource.split(/[\\/]+services/)[0];
1327
- const pathToResource = join6(path6, "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 path6 = existingResource.split(/[\\/]+services/)[0];
1363
- const pathToResource = join6(path6, "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 (path6) => {
1405
- await fs6.rm(join7(directory, path6), { 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 (path6) => {
1537
- await fs7.rm(join8(directory, path6), { 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,8 +1576,8 @@ 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 path6 = existingResource.split(`/[\\/]+${collection}`)[0];
1580
- const pathToResource = join8(path6, 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
  };
@@ -1586,8 +1586,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
1586
1586
  import { dirname as dirname5 } from "path";
1587
1587
  import matter4 from "gray-matter";
1588
1588
  import { satisfies as satisfies4, validRange as validRange3 } from "semver";
1589
- var getMessageBySchemaPath = (directory) => async (path6, options) => {
1590
- const pathToMessage = dirname5(path6);
1589
+ var getMessageBySchemaPath = (directory) => async (path8, options) => {
1590
+ const pathToMessage = dirname5(path8);
1591
1591
  try {
1592
1592
  const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
1593
1593
  if (!files || files.length === 0) {
@@ -1659,18 +1659,18 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
1659
1659
  }
1660
1660
  return { producers, consumers };
1661
1661
  };
1662
- var getConsumersOfSchema = (directory) => async (path6) => {
1662
+ var getConsumersOfSchema = (directory) => async (path8) => {
1663
1663
  try {
1664
- const message = await getMessageBySchemaPath(directory)(path6);
1664
+ const message = await getMessageBySchemaPath(directory)(path8);
1665
1665
  const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
1666
1666
  return consumers;
1667
1667
  } catch (error) {
1668
1668
  return [];
1669
1669
  }
1670
1670
  };
1671
- var getProducersOfSchema = (directory) => async (path6) => {
1671
+ var getProducersOfSchema = (directory) => async (path8) => {
1672
1672
  try {
1673
- const message = await getMessageBySchemaPath(directory)(path6);
1673
+ const message = await getMessageBySchemaPath(directory)(path8);
1674
1674
  const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
1675
1675
  return producers;
1676
1676
  } catch (error) {
@@ -1874,8 +1874,8 @@ var filterCollection = (collection, options) => {
1874
1874
  };
1875
1875
  var getEventCatalogConfigurationFile = (directory) => async () => {
1876
1876
  try {
1877
- const path6 = join13(directory, "eventcatalog.config.js");
1878
- const configModule = await import(path6);
1877
+ const path8 = join13(directory, "eventcatalog.config.js");
1878
+ const configModule = await import(path8);
1879
1879
  return configModule.default;
1880
1880
  } catch (error) {
1881
1881
  console.error("Error getting event catalog configuration file", error);
@@ -1931,8 +1931,407 @@ var dumpCatalog = (directory) => async (options) => {
1931
1931
  };
1932
1932
  };
1933
1933
 
1934
+ // src/snapshots.ts
1935
+ import fs11 from "fs";
1936
+ import path6 from "path";
1937
+ import { execSync } from "child_process";
1938
+ import { compare } from "semver";
1939
+
1940
+ // src/snapshot-diff.ts
1941
+ var stableStringify = (value) => {
1942
+ if (value === null || value === void 0 || typeof value !== "object") {
1943
+ return JSON.stringify(value);
1944
+ }
1945
+ if (Array.isArray(value)) {
1946
+ return "[" + value.map(stableStringify).join(",") + "]";
1947
+ }
1948
+ const sorted = Object.keys(value).sort().map((key) => JSON.stringify(key) + ":" + stableStringify(value[key]));
1949
+ return "{" + sorted.join(",") + "}";
1950
+ };
1951
+ var flattenResources = (snapshot) => {
1952
+ const resources = [];
1953
+ const addResources = (items, type) => {
1954
+ for (const item of items) {
1955
+ resources.push({
1956
+ resourceId: item.id,
1957
+ version: item.version,
1958
+ type,
1959
+ data: item
1960
+ });
1961
+ }
1962
+ };
1963
+ addResources(snapshot.resources.domains, "domain");
1964
+ addResources(snapshot.resources.services, "service");
1965
+ addResources(snapshot.resources.messages.events, "event");
1966
+ addResources(snapshot.resources.messages.commands, "command");
1967
+ addResources(snapshot.resources.messages.queries, "query");
1968
+ addResources(snapshot.resources.channels, "channel");
1969
+ return resources;
1970
+ };
1971
+ var EXCLUDED_FIELDS = /* @__PURE__ */ new Set(["markdown", "_eventcatalog"]);
1972
+ var getComparableFields = (data) => {
1973
+ const result = {};
1974
+ for (const [key, value] of Object.entries(data)) {
1975
+ if (!EXCLUDED_FIELDS.has(key)) {
1976
+ result[key] = value;
1977
+ }
1978
+ }
1979
+ return result;
1980
+ };
1981
+ var findChangedFields = (dataA, dataB) => {
1982
+ const fieldsA = getComparableFields(dataA);
1983
+ const fieldsB = getComparableFields(dataB);
1984
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(fieldsA), ...Object.keys(fieldsB)]);
1985
+ const changed = [];
1986
+ for (const key of allKeys) {
1987
+ if (stableStringify(fieldsA[key] ?? null) !== stableStringify(fieldsB[key] ?? null)) {
1988
+ changed.push(key);
1989
+ }
1990
+ }
1991
+ return changed;
1992
+ };
1993
+ var resourceKey = (r) => `${r.resourceId}@${r.version}`;
1994
+ var idTypeKey = (r) => `${r.resourceId}:${r.type}`;
1995
+ var computeResourceDiff = (snapshotA, snapshotB) => {
1996
+ const resourcesA = flattenResources(snapshotA);
1997
+ const resourcesB = flattenResources(snapshotB);
1998
+ const mapA = /* @__PURE__ */ new Map();
1999
+ const byIdA = /* @__PURE__ */ new Map();
2000
+ for (const r of resourcesA) {
2001
+ mapA.set(resourceKey(r), r);
2002
+ byIdA.set(idTypeKey(r), r);
2003
+ }
2004
+ const mapB = /* @__PURE__ */ new Map();
2005
+ const byIdB = /* @__PURE__ */ new Map();
2006
+ for (const r of resourcesB) {
2007
+ mapB.set(resourceKey(r), r);
2008
+ byIdB.set(idTypeKey(r), r);
2009
+ }
2010
+ const changes = [];
2011
+ const handledIds = /* @__PURE__ */ new Set();
2012
+ for (const resource of resourcesB) {
2013
+ const key = resourceKey(resource);
2014
+ if (!mapA.has(key)) {
2015
+ const idKey = idTypeKey(resource);
2016
+ const oldResource = byIdA.get(idKey);
2017
+ if (oldResource && oldResource.version !== resource.version && !handledIds.has(idKey)) {
2018
+ const changedFields = findChangedFields(oldResource.data, resource.data);
2019
+ changes.push({
2020
+ resourceId: resource.resourceId,
2021
+ version: resource.version,
2022
+ type: resource.type,
2023
+ changeType: "versioned",
2024
+ previousVersion: oldResource.version,
2025
+ newVersion: resource.version,
2026
+ changedFields: changedFields.length > 0 ? changedFields : void 0
2027
+ });
2028
+ handledIds.add(idKey);
2029
+ } else if (!handledIds.has(idKey)) {
2030
+ changes.push({
2031
+ resourceId: resource.resourceId,
2032
+ version: resource.version,
2033
+ type: resource.type,
2034
+ changeType: "added"
2035
+ });
2036
+ }
2037
+ }
2038
+ }
2039
+ for (const resource of resourcesA) {
2040
+ const key = resourceKey(resource);
2041
+ if (!mapB.has(key)) {
2042
+ const idKey = idTypeKey(resource);
2043
+ if (!handledIds.has(idKey)) {
2044
+ changes.push({
2045
+ resourceId: resource.resourceId,
2046
+ version: resource.version,
2047
+ type: resource.type,
2048
+ changeType: "removed"
2049
+ });
2050
+ }
2051
+ }
2052
+ }
2053
+ for (const resourceB of resourcesB) {
2054
+ const key = resourceKey(resourceB);
2055
+ const resourceA = mapA.get(key);
2056
+ if (resourceA) {
2057
+ const changedFields = findChangedFields(resourceA.data, resourceB.data);
2058
+ if (changedFields.length > 0) {
2059
+ changes.push({
2060
+ resourceId: resourceB.resourceId,
2061
+ version: resourceB.version,
2062
+ type: resourceB.type,
2063
+ changeType: "modified",
2064
+ changedFields
2065
+ });
2066
+ }
2067
+ }
2068
+ }
2069
+ return changes;
2070
+ };
2071
+ var getRelationshipKey = (serviceId, resourceId, resourceVersion, direction) => {
2072
+ return `${serviceId}:${direction}:${resourceId}@${resourceVersion || "latest"}`;
2073
+ };
2074
+ var extractRelationships = (snapshot) => {
2075
+ const relationships = /* @__PURE__ */ new Map();
2076
+ for (const service of snapshot.resources.services) {
2077
+ for (const direction of ["sends", "receives"]) {
2078
+ const pointers = service[direction] || [];
2079
+ for (const pointer of pointers) {
2080
+ const key = getRelationshipKey(service.id, pointer.id, pointer.version, direction);
2081
+ relationships.set(key, {
2082
+ serviceId: service.id,
2083
+ serviceVersion: service.version,
2084
+ resourceId: pointer.id,
2085
+ resourceVersion: pointer.version,
2086
+ direction
2087
+ });
2088
+ }
2089
+ }
2090
+ }
2091
+ return relationships;
2092
+ };
2093
+ var computeRelationshipDiff = (snapshotA, snapshotB) => {
2094
+ const relsA = extractRelationships(snapshotA);
2095
+ const relsB = extractRelationships(snapshotB);
2096
+ const changes = [];
2097
+ for (const [key, rel] of relsB) {
2098
+ if (!relsA.has(key)) {
2099
+ changes.push({ ...rel, changeType: "added" });
2100
+ }
2101
+ }
2102
+ for (const [key, rel] of relsA) {
2103
+ if (!relsB.has(key)) {
2104
+ changes.push({ ...rel, changeType: "removed" });
2105
+ }
2106
+ }
2107
+ return changes;
2108
+ };
2109
+
2110
+ // src/snapshots.ts
2111
+ var SNAPSHOT_VERSION = "1.0.0";
2112
+ var getEventCatalogVersion2 = (catalogDir) => {
2113
+ try {
2114
+ const packageJson = fs11.readFileSync(path6.join(catalogDir, "package.json"), "utf8");
2115
+ const packageJsonObject = JSON.parse(packageJson);
2116
+ return packageJsonObject["dependencies"]?.["@eventcatalog/core"] ?? "unknown";
2117
+ } catch {
2118
+ return "unknown";
2119
+ }
2120
+ };
2121
+ var pickCoreFields = (resource) => {
2122
+ const picked = { id: resource.id, version: resource.version, name: resource.name };
2123
+ if (resource.sends) picked.sends = resource.sends;
2124
+ if (resource.receives) picked.receives = resource.receives;
2125
+ if (resource.deprecated) picked.deprecated = resource.deprecated;
2126
+ if (resource.owners) picked.owners = resource.owners;
2127
+ return picked;
2128
+ };
2129
+ var deduplicateByLatestVersion = (resources) => {
2130
+ const seen = /* @__PURE__ */ new Map();
2131
+ for (const r of resources) {
2132
+ const existing = seen.get(r.id);
2133
+ if (!existing || compare(r.version, existing.version) > 0) {
2134
+ seen.set(r.id, r);
2135
+ }
2136
+ }
2137
+ return Array.from(seen.values());
2138
+ };
2139
+ var stripToCore = (resources) => {
2140
+ if (!resources || resources.length === 0) return [];
2141
+ return deduplicateByLatestVersion(resources).map(pickCoreFields);
2142
+ };
2143
+ var detectGitInfo = (catalogDir) => {
2144
+ try {
2145
+ const opts = { cwd: catalogDir, encoding: "utf8", stdio: "pipe" };
2146
+ const branch = execSync("git rev-parse --abbrev-ref HEAD", opts).trim();
2147
+ const commit = execSync("git rev-parse --short HEAD", opts).trim();
2148
+ const status = execSync("git status --porcelain", opts).trim();
2149
+ return { branch, commit, dirty: status.length > 0 };
2150
+ } catch {
2151
+ return void 0;
2152
+ }
2153
+ };
2154
+ var createSnapshot = (directory) => {
2155
+ return async (options) => {
2156
+ const { label, outputDir, git } = options || {};
2157
+ const sdk = src_default(directory);
2158
+ const [domains, services, events, commands, queries, channels] = await Promise.all([
2159
+ sdk.getDomains(),
2160
+ sdk.getServices(),
2161
+ sdk.getEvents(),
2162
+ sdk.getCommands(),
2163
+ sdk.getQueries(),
2164
+ sdk.getChannels()
2165
+ ]);
2166
+ const snapshotDomains = stripToCore(domains);
2167
+ const snapshotServices = stripToCore(services);
2168
+ const snapshotEvents = stripToCore(events);
2169
+ const snapshotCommands = stripToCore(commands);
2170
+ const snapshotQueries = stripToCore(queries);
2171
+ const snapshotChannels = stripToCore(channels);
2172
+ const snapshotLabel = label || (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
2173
+ const gitInfo = git || detectGitInfo(directory);
2174
+ const snapshot = {
2175
+ snapshotVersion: SNAPSHOT_VERSION,
2176
+ catalogVersion: getEventCatalogVersion2(directory),
2177
+ label: snapshotLabel,
2178
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2179
+ ...gitInfo ? { git: gitInfo } : {},
2180
+ resources: {
2181
+ domains: snapshotDomains,
2182
+ services: snapshotServices,
2183
+ messages: {
2184
+ events: snapshotEvents,
2185
+ commands: snapshotCommands,
2186
+ queries: snapshotQueries
2187
+ },
2188
+ channels: snapshotChannels
2189
+ }
2190
+ };
2191
+ const snapshotsDir = outputDir || path6.join(directory, ".snapshots");
2192
+ fs11.mkdirSync(snapshotsDir, { recursive: true });
2193
+ const fileName = `${snapshotLabel}.snapshot.json`;
2194
+ const filePath = path6.join(snapshotsDir, fileName);
2195
+ fs11.writeFileSync(filePath, JSON.stringify(snapshot));
2196
+ return { filePath, snapshot };
2197
+ };
2198
+ };
2199
+ var diffSnapshots = (directory) => async (snapshotAPath, snapshotBPath) => {
2200
+ const snapshotA = JSON.parse(fs11.readFileSync(snapshotAPath, "utf-8"));
2201
+ const snapshotB = JSON.parse(fs11.readFileSync(snapshotBPath, "utf-8"));
2202
+ const resourceChanges = computeResourceDiff(snapshotA, snapshotB);
2203
+ const relationshipChanges = computeRelationshipDiff(snapshotA, snapshotB);
2204
+ const resourceCounts = { added: 0, removed: 0, modified: 0, versioned: 0 };
2205
+ for (const r of resourceChanges) resourceCounts[r.changeType]++;
2206
+ const relCounts = { added: 0, removed: 0 };
2207
+ for (const r of relationshipChanges) relCounts[r.changeType]++;
2208
+ return {
2209
+ snapshotA: { label: snapshotA.label, createdAt: snapshotA.createdAt },
2210
+ snapshotB: { label: snapshotB.label, createdAt: snapshotB.createdAt },
2211
+ summary: {
2212
+ totalChanges: resourceChanges.length + relationshipChanges.length,
2213
+ resourcesAdded: resourceCounts.added,
2214
+ resourcesRemoved: resourceCounts.removed,
2215
+ resourcesModified: resourceCounts.modified,
2216
+ resourcesVersioned: resourceCounts.versioned,
2217
+ relationshipsAdded: relCounts.added,
2218
+ relationshipsRemoved: relCounts.removed
2219
+ },
2220
+ resources: resourceChanges,
2221
+ relationships: relationshipChanges
2222
+ };
2223
+ };
2224
+ var listSnapshots = (directory) => async () => {
2225
+ const snapshotsDir = path6.join(directory, ".snapshots");
2226
+ if (!fs11.existsSync(snapshotsDir)) return [];
2227
+ const files = fs11.readdirSync(snapshotsDir).filter((f) => f.endsWith(".snapshot.json"));
2228
+ const snapshots = [];
2229
+ for (const file of files) {
2230
+ try {
2231
+ const filePath = path6.join(snapshotsDir, file);
2232
+ const content = JSON.parse(fs11.readFileSync(filePath, "utf-8"));
2233
+ snapshots.push({
2234
+ label: content.label,
2235
+ createdAt: content.createdAt,
2236
+ filePath,
2237
+ ...content.git ? { git: content.git } : {}
2238
+ });
2239
+ } catch {
2240
+ }
2241
+ }
2242
+ return snapshots.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
2243
+ };
2244
+
2245
+ // src/changelogs.ts
2246
+ import path7, { dirname as dirname6 } from "path";
2247
+ import fsSync7 from "fs";
2248
+ import fs12 from "fs/promises";
2249
+ import matter8 from "gray-matter";
2250
+ var writeChangelog = (catalogDir) => async (id, changelog, options = {}) => {
2251
+ const { version, format = "mdx" } = options;
2252
+ const resourceFile = await findFileById(catalogDir, id, version);
2253
+ if (!resourceFile) {
2254
+ throw new Error(`No resource found with id: ${id}${version ? ` and version: ${version}` : ""}`);
2255
+ }
2256
+ const resourceDir = dirname6(resourceFile);
2257
+ const changelogPath = path7.join(resourceDir, `changelog.${format}`);
2258
+ const { markdown, ...frontmatter } = changelog;
2259
+ const fm = { ...frontmatter };
2260
+ if (fm.createdAt instanceof Date) {
2261
+ fm.createdAt = fm.createdAt;
2262
+ }
2263
+ if (!fm.badges || fm.badges.length === 0) {
2264
+ delete fm.badges;
2265
+ }
2266
+ fsSync7.mkdirSync(resourceDir, { recursive: true });
2267
+ const document = matter8.stringify(markdown.trim(), fm);
2268
+ fsSync7.writeFileSync(changelogPath, document);
2269
+ invalidateFileCache();
2270
+ };
2271
+ var appendChangelog = (catalogDir) => async (id, changelog, options = {}) => {
2272
+ const { version, format = "mdx" } = options;
2273
+ const resourceFile = await findFileById(catalogDir, id, version);
2274
+ if (!resourceFile) {
2275
+ throw new Error(`No resource found with id: ${id}${version ? ` and version: ${version}` : ""}`);
2276
+ }
2277
+ const resourceDir = dirname6(resourceFile);
2278
+ const mdxPath = path7.join(resourceDir, "changelog.mdx");
2279
+ const mdPath = path7.join(resourceDir, "changelog.md");
2280
+ const existingPath = fsSync7.existsSync(mdxPath) ? mdxPath : fsSync7.existsSync(mdPath) ? mdPath : void 0;
2281
+ if (!existingPath) {
2282
+ return writeChangelog(catalogDir)(id, changelog, options);
2283
+ }
2284
+ const existing = matter8.read(existingPath);
2285
+ const existingContent = existing.content.trim();
2286
+ const newEntry = changelog.markdown.trim();
2287
+ const combined = `${newEntry}
2288
+
2289
+ ---
2290
+
2291
+ ${existingContent}`;
2292
+ const fm = { ...existing.data };
2293
+ fm.createdAt = changelog.createdAt;
2294
+ if (changelog.badges && changelog.badges.length > 0) {
2295
+ fm.badges = changelog.badges;
2296
+ } else {
2297
+ delete fm.badges;
2298
+ }
2299
+ const document = matter8.stringify(combined, fm);
2300
+ fsSync7.writeFileSync(existingPath, document);
2301
+ invalidateFileCache();
2302
+ };
2303
+ var getChangelog = (catalogDir) => async (id, options = {}) => {
2304
+ const { version } = options;
2305
+ const resourceFile = await findFileById(catalogDir, id, version);
2306
+ if (!resourceFile) return void 0;
2307
+ const resourceDir = dirname6(resourceFile);
2308
+ const mdxPath = path7.join(resourceDir, "changelog.mdx");
2309
+ const mdPath = path7.join(resourceDir, "changelog.md");
2310
+ const changelogPath = fsSync7.existsSync(mdxPath) ? mdxPath : fsSync7.existsSync(mdPath) ? mdPath : void 0;
2311
+ if (!changelogPath) return void 0;
2312
+ const { data, content } = matter8.read(changelogPath);
2313
+ return { ...data, markdown: content.trim() };
2314
+ };
2315
+ var rmChangelog = (catalogDir) => async (id, options = {}) => {
2316
+ const { version } = options;
2317
+ const resourceFile = await findFileById(catalogDir, id, version);
2318
+ if (!resourceFile) {
2319
+ throw new Error(`No resource found with id: ${id}${version ? ` and version: ${version}` : ""}`);
2320
+ }
2321
+ const resourceDir = dirname6(resourceFile);
2322
+ const mdxPath = path7.join(resourceDir, "changelog.mdx");
2323
+ const mdPath = path7.join(resourceDir, "changelog.md");
2324
+ if (fsSync7.existsSync(mdxPath)) {
2325
+ await fs12.rm(mdxPath);
2326
+ }
2327
+ if (fsSync7.existsSync(mdPath)) {
2328
+ await fs12.rm(mdPath);
2329
+ }
2330
+ invalidateFileCache();
2331
+ };
2332
+
1934
2333
  // src/entities.ts
1935
- import fs11 from "fs/promises";
2334
+ import fs13 from "fs/promises";
1936
2335
  import { join as join14 } from "path";
1937
2336
  var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
1938
2337
  var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
@@ -1941,8 +2340,8 @@ var writeEntity = (directory) => async (entity, options = {
1941
2340
  override: false,
1942
2341
  format: "mdx"
1943
2342
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1944
- var rmEntity = (directory) => async (path6) => {
1945
- await fs11.rm(join14(directory, path6), { recursive: true });
2343
+ var rmEntity = (directory) => async (path8) => {
2344
+ await fs13.rm(join14(directory, path8), { recursive: true });
1946
2345
  invalidateFileCache();
1947
2346
  };
1948
2347
  var rmEntityById = (directory) => async (id, version, persistFiles) => {
@@ -1955,7 +2354,7 @@ var entityHasVersion = (directory) => async (id, version) => {
1955
2354
  };
1956
2355
 
1957
2356
  // src/containers.ts
1958
- import fs12 from "fs/promises";
2357
+ import fs14 from "fs/promises";
1959
2358
  import { join as join15 } from "path";
1960
2359
  var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
1961
2360
  var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
@@ -1965,8 +2364,8 @@ var writeContainer = (directory) => async (data, options = {
1965
2364
  format: "mdx"
1966
2365
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1967
2366
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1968
- var rmContainer = (directory) => async (path6) => {
1969
- await fs12.rm(join15(directory, path6), { recursive: true });
2367
+ var rmContainer = (directory) => async (path8) => {
2368
+ await fs14.rm(join15(directory, path8), { recursive: true });
1970
2369
  invalidateFileCache();
1971
2370
  };
1972
2371
  var rmContainerById = (directory) => async (id, version, persistFiles) => {
@@ -1999,7 +2398,7 @@ var addFileToDataStore = addFileToContainer;
1999
2398
  var writeDataStoreToService = writeContainerToService;
2000
2399
 
2001
2400
  // src/data-products.ts
2002
- import fs13 from "fs/promises";
2401
+ import fs15 from "fs/promises";
2003
2402
  import { join as join16 } from "path";
2004
2403
  var getDataProduct = (directory) => async (id, version) => getResource(directory, id, version, { type: "data-product" });
2005
2404
  var getDataProducts = (directory) => async (options) => getResources(directory, { type: "data-products", latestOnly: options?.latestOnly });
@@ -2013,8 +2412,8 @@ var writeDataProductToDomain = (directory) => async (dataProduct, domain, option
2013
2412
  pathForDataProduct = join16(pathForDataProduct, dataProduct.id);
2014
2413
  await writeResource(directory, { ...dataProduct }, { ...options, path: pathForDataProduct, type: "data-product" });
2015
2414
  };
2016
- var rmDataProduct = (directory) => async (path6) => {
2017
- await fs13.rm(join16(directory, path6), { recursive: true });
2415
+ var rmDataProduct = (directory) => async (path8) => {
2416
+ await fs15.rm(join16(directory, path8), { recursive: true });
2018
2417
  invalidateFileCache();
2019
2418
  };
2020
2419
  var rmDataProductById = (directory) => async (id, version, persistFiles) => {
@@ -2028,7 +2427,7 @@ var dataProductHasVersion = (directory) => async (id, version) => {
2028
2427
  var addFileToDataProduct = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
2029
2428
 
2030
2429
  // src/diagrams.ts
2031
- import fs14 from "fs/promises";
2430
+ import fs16 from "fs/promises";
2032
2431
  import { join as join17 } from "path";
2033
2432
  var getDiagram = (directory) => async (id, version) => getResource(directory, id, version, { type: "diagram" });
2034
2433
  var getDiagrams = (directory) => async (options) => getResources(directory, { type: "diagrams", latestOnly: options?.latestOnly });
@@ -2037,8 +2436,8 @@ var writeDiagram = (directory) => async (diagram, options = {
2037
2436
  override: false,
2038
2437
  format: "mdx"
2039
2438
  }) => writeResource(directory, { ...diagram }, { ...options, type: "diagram" });
2040
- var rmDiagram = (directory) => async (path6) => {
2041
- await fs14.rm(join17(directory, path6), { recursive: true });
2439
+ var rmDiagram = (directory) => async (path8) => {
2440
+ await fs16.rm(join17(directory, path8), { recursive: true });
2042
2441
  invalidateFileCache();
2043
2442
  };
2044
2443
  var rmDiagramById = (directory) => async (id, version, persistFiles) => {
@@ -2052,7 +2451,7 @@ var diagramHasVersion = (directory) => async (id, version) => {
2052
2451
  var addFileToDiagram = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version, { type: "diagram" });
2053
2452
 
2054
2453
  // src/index.ts
2055
- var src_default = (path6) => {
2454
+ var src_default = (path8) => {
2056
2455
  return {
2057
2456
  /**
2058
2457
  * Returns an events from EventCatalog
@@ -2060,13 +2459,13 @@ var src_default = (path6) => {
2060
2459
  * @param version - Optional id of the version to get (supports semver)
2061
2460
  * @returns Event|Undefined
2062
2461
  */
2063
- getEvent: getEvent(join18(path6)),
2462
+ getEvent: getEvent(join18(path8)),
2064
2463
  /**
2065
2464
  * Returns all events from EventCatalog
2066
2465
  * @param latestOnly - optional boolean, set to true to get only latest versions
2067
2466
  * @returns Event[]|Undefined
2068
2467
  */
2069
- getEvents: getEvents(join18(path6)),
2468
+ getEvents: getEvents(join18(path8)),
2070
2469
  /**
2071
2470
  * Adds an event to EventCatalog
2072
2471
  *
@@ -2074,7 +2473,7 @@ var src_default = (path6) => {
2074
2473
  * @param options - Optional options to write the event
2075
2474
  *
2076
2475
  */
2077
- writeEvent: writeEvent(join18(path6, "events")),
2476
+ writeEvent: writeEvent(join18(path8, "events")),
2078
2477
  /**
2079
2478
  * Adds an event to a service in EventCatalog
2080
2479
  *
@@ -2083,26 +2482,26 @@ var src_default = (path6) => {
2083
2482
  * @param options - Optional options to write the event
2084
2483
  *
2085
2484
  */
2086
- writeEventToService: writeEventToService(join18(path6)),
2485
+ writeEventToService: writeEventToService(join18(path8)),
2087
2486
  /**
2088
2487
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
2089
2488
  *
2090
2489
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
2091
2490
  *
2092
2491
  */
2093
- rmEvent: rmEvent(join18(path6, "events")),
2492
+ rmEvent: rmEvent(join18(path8, "events")),
2094
2493
  /**
2095
2494
  * Remove an event by an Event id
2096
2495
  *
2097
2496
  * @param id - The id of the event you want to remove
2098
2497
  *
2099
2498
  */
2100
- rmEventById: rmEventById(join18(path6)),
2499
+ rmEventById: rmEventById(join18(path8)),
2101
2500
  /**
2102
2501
  * Moves a given event id to the version directory
2103
2502
  * @param directory
2104
2503
  */
2105
- versionEvent: versionEvent(join18(path6)),
2504
+ versionEvent: versionEvent(join18(path8)),
2106
2505
  /**
2107
2506
  * Adds a file to the given event
2108
2507
  * @param id - The id of the event to add the file to
@@ -2110,7 +2509,7 @@ var src_default = (path6) => {
2110
2509
  * @param version - Optional version of the event to add the file to
2111
2510
  * @returns
2112
2511
  */
2113
- addFileToEvent: addFileToEvent(join18(path6)),
2512
+ addFileToEvent: addFileToEvent(join18(path8)),
2114
2513
  /**
2115
2514
  * Adds a schema to the given event
2116
2515
  * @param id - The id of the event to add the schema to
@@ -2118,14 +2517,14 @@ var src_default = (path6) => {
2118
2517
  * @param version - Optional version of the event to add the schema to
2119
2518
  * @returns
2120
2519
  */
2121
- addSchemaToEvent: addSchemaToEvent(join18(path6)),
2520
+ addSchemaToEvent: addSchemaToEvent(join18(path8)),
2122
2521
  /**
2123
2522
  * Check to see if an event version exists
2124
2523
  * @param id - The id of the event
2125
2524
  * @param version - The version of the event (supports semver)
2126
2525
  * @returns
2127
2526
  */
2128
- eventHasVersion: eventHasVersion(join18(path6)),
2527
+ eventHasVersion: eventHasVersion(join18(path8)),
2129
2528
  /**
2130
2529
  * ================================
2131
2530
  * Commands
@@ -2137,13 +2536,13 @@ var src_default = (path6) => {
2137
2536
  * @param version - Optional id of the version to get (supports semver)
2138
2537
  * @returns Command|Undefined
2139
2538
  */
2140
- getCommand: getCommand(join18(path6)),
2539
+ getCommand: getCommand(join18(path8)),
2141
2540
  /**
2142
2541
  * Returns all commands from EventCatalog
2143
2542
  * @param latestOnly - optional boolean, set to true to get only latest versions
2144
2543
  * @returns Command[]|Undefined
2145
2544
  */
2146
- getCommands: getCommands(join18(path6)),
2545
+ getCommands: getCommands(join18(path8)),
2147
2546
  /**
2148
2547
  * Adds an command to EventCatalog
2149
2548
  *
@@ -2151,7 +2550,7 @@ var src_default = (path6) => {
2151
2550
  * @param options - Optional options to write the command
2152
2551
  *
2153
2552
  */
2154
- writeCommand: writeCommand(join18(path6, "commands")),
2553
+ writeCommand: writeCommand(join18(path8, "commands")),
2155
2554
  /**
2156
2555
  * Adds a command to a service in EventCatalog
2157
2556
  *
@@ -2160,26 +2559,26 @@ var src_default = (path6) => {
2160
2559
  * @param options - Optional options to write the command
2161
2560
  *
2162
2561
  */
2163
- writeCommandToService: writeCommandToService(join18(path6)),
2562
+ writeCommandToService: writeCommandToService(join18(path8)),
2164
2563
  /**
2165
2564
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
2166
2565
  *
2167
2566
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
2168
2567
  *
2169
2568
  */
2170
- rmCommand: rmCommand(join18(path6, "commands")),
2569
+ rmCommand: rmCommand(join18(path8, "commands")),
2171
2570
  /**
2172
2571
  * Remove an command by an Event id
2173
2572
  *
2174
2573
  * @param id - The id of the command you want to remove
2175
2574
  *
2176
2575
  */
2177
- rmCommandById: rmCommandById(join18(path6)),
2576
+ rmCommandById: rmCommandById(join18(path8)),
2178
2577
  /**
2179
2578
  * Moves a given command id to the version directory
2180
2579
  * @param directory
2181
2580
  */
2182
- versionCommand: versionCommand(join18(path6)),
2581
+ versionCommand: versionCommand(join18(path8)),
2183
2582
  /**
2184
2583
  * Adds a file to the given command
2185
2584
  * @param id - The id of the command to add the file to
@@ -2187,7 +2586,7 @@ var src_default = (path6) => {
2187
2586
  * @param version - Optional version of the command to add the file to
2188
2587
  * @returns
2189
2588
  */
2190
- addFileToCommand: addFileToCommand(join18(path6)),
2589
+ addFileToCommand: addFileToCommand(join18(path8)),
2191
2590
  /**
2192
2591
  * Adds a schema to the given command
2193
2592
  * @param id - The id of the command to add the schema to
@@ -2195,14 +2594,14 @@ var src_default = (path6) => {
2195
2594
  * @param version - Optional version of the command to add the schema to
2196
2595
  * @returns
2197
2596
  */
2198
- addSchemaToCommand: addSchemaToCommand(join18(path6)),
2597
+ addSchemaToCommand: addSchemaToCommand(join18(path8)),
2199
2598
  /**
2200
2599
  * Check to see if a command version exists
2201
2600
  * @param id - The id of the command
2202
2601
  * @param version - The version of the command (supports semver)
2203
2602
  * @returns
2204
2603
  */
2205
- commandHasVersion: commandHasVersion(join18(path6)),
2604
+ commandHasVersion: commandHasVersion(join18(path8)),
2206
2605
  /**
2207
2606
  * ================================
2208
2607
  * Queries
@@ -2214,13 +2613,13 @@ var src_default = (path6) => {
2214
2613
  * @param version - Optional id of the version to get (supports semver)
2215
2614
  * @returns Query|Undefined
2216
2615
  */
2217
- getQuery: getQuery(join18(path6)),
2616
+ getQuery: getQuery(join18(path8)),
2218
2617
  /**
2219
2618
  * Returns all queries from EventCatalog
2220
2619
  * @param latestOnly - optional boolean, set to true to get only latest versions
2221
2620
  * @returns Query[]|Undefined
2222
2621
  */
2223
- getQueries: getQueries(join18(path6)),
2622
+ getQueries: getQueries(join18(path8)),
2224
2623
  /**
2225
2624
  * Adds a query to EventCatalog
2226
2625
  *
@@ -2228,7 +2627,7 @@ var src_default = (path6) => {
2228
2627
  * @param options - Optional options to write the event
2229
2628
  *
2230
2629
  */
2231
- writeQuery: writeQuery(join18(path6, "queries")),
2630
+ writeQuery: writeQuery(join18(path8, "queries")),
2232
2631
  /**
2233
2632
  * Adds a query to a service in EventCatalog
2234
2633
  *
@@ -2237,26 +2636,26 @@ var src_default = (path6) => {
2237
2636
  * @param options - Optional options to write the query
2238
2637
  *
2239
2638
  */
2240
- writeQueryToService: writeQueryToService(join18(path6)),
2639
+ writeQueryToService: writeQueryToService(join18(path8)),
2241
2640
  /**
2242
2641
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
2243
2642
  *
2244
2643
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
2245
2644
  *
2246
2645
  */
2247
- rmQuery: rmQuery(join18(path6, "queries")),
2646
+ rmQuery: rmQuery(join18(path8, "queries")),
2248
2647
  /**
2249
2648
  * Remove a query by a Query id
2250
2649
  *
2251
2650
  * @param id - The id of the query you want to remove
2252
2651
  *
2253
2652
  */
2254
- rmQueryById: rmQueryById(join18(path6)),
2653
+ rmQueryById: rmQueryById(join18(path8)),
2255
2654
  /**
2256
2655
  * Moves a given query id to the version directory
2257
2656
  * @param directory
2258
2657
  */
2259
- versionQuery: versionQuery(join18(path6)),
2658
+ versionQuery: versionQuery(join18(path8)),
2260
2659
  /**
2261
2660
  * Adds a file to the given query
2262
2661
  * @param id - The id of the query to add the file to
@@ -2264,7 +2663,7 @@ var src_default = (path6) => {
2264
2663
  * @param version - Optional version of the query to add the file to
2265
2664
  * @returns
2266
2665
  */
2267
- addFileToQuery: addFileToQuery(join18(path6)),
2666
+ addFileToQuery: addFileToQuery(join18(path8)),
2268
2667
  /**
2269
2668
  * Adds a schema to the given query
2270
2669
  * @param id - The id of the query to add the schema to
@@ -2272,14 +2671,14 @@ var src_default = (path6) => {
2272
2671
  * @param version - Optional version of the query to add the schema to
2273
2672
  * @returns
2274
2673
  */
2275
- addSchemaToQuery: addSchemaToQuery(join18(path6)),
2674
+ addSchemaToQuery: addSchemaToQuery(join18(path8)),
2276
2675
  /**
2277
2676
  * Check to see if an query version exists
2278
2677
  * @param id - The id of the query
2279
2678
  * @param version - The version of the query (supports semver)
2280
2679
  * @returns
2281
2680
  */
2282
- queryHasVersion: queryHasVersion(join18(path6)),
2681
+ queryHasVersion: queryHasVersion(join18(path8)),
2283
2682
  /**
2284
2683
  * ================================
2285
2684
  * Channels
@@ -2291,13 +2690,13 @@ var src_default = (path6) => {
2291
2690
  * @param version - Optional id of the version to get (supports semver)
2292
2691
  * @returns Channel|Undefined
2293
2692
  */
2294
- getChannel: getChannel(join18(path6)),
2693
+ getChannel: getChannel(join18(path8)),
2295
2694
  /**
2296
2695
  * Returns all channels from EventCatalog
2297
2696
  * @param latestOnly - optional boolean, set to true to get only latest versions
2298
2697
  * @returns Channel[]|Undefined
2299
2698
  */
2300
- getChannels: getChannels(join18(path6)),
2699
+ getChannels: getChannels(join18(path8)),
2301
2700
  /**
2302
2701
  * Adds an channel to EventCatalog
2303
2702
  *
@@ -2305,33 +2704,33 @@ var src_default = (path6) => {
2305
2704
  * @param options - Optional options to write the channel
2306
2705
  *
2307
2706
  */
2308
- writeChannel: writeChannel(join18(path6, "channels")),
2707
+ writeChannel: writeChannel(join18(path8, "channels")),
2309
2708
  /**
2310
2709
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
2311
2710
  *
2312
2711
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
2313
2712
  *
2314
2713
  */
2315
- rmChannel: rmChannel(join18(path6, "channels")),
2714
+ rmChannel: rmChannel(join18(path8, "channels")),
2316
2715
  /**
2317
2716
  * Remove an channel by an Event id
2318
2717
  *
2319
2718
  * @param id - The id of the channel you want to remove
2320
2719
  *
2321
2720
  */
2322
- rmChannelById: rmChannelById(join18(path6)),
2721
+ rmChannelById: rmChannelById(join18(path8)),
2323
2722
  /**
2324
2723
  * Moves a given channel id to the version directory
2325
2724
  * @param directory
2326
2725
  */
2327
- versionChannel: versionChannel(join18(path6)),
2726
+ versionChannel: versionChannel(join18(path8)),
2328
2727
  /**
2329
2728
  * Check to see if a channel version exists
2330
2729
  * @param id - The id of the channel
2331
2730
  * @param version - The version of the channel (supports semver)
2332
2731
  * @returns
2333
2732
  */
2334
- channelHasVersion: channelHasVersion(join18(path6)),
2733
+ channelHasVersion: channelHasVersion(join18(path8)),
2335
2734
  /**
2336
2735
  * Add a channel to an event
2337
2736
  *
@@ -2348,7 +2747,7 @@ var src_default = (path6) => {
2348
2747
  *
2349
2748
  * ```
2350
2749
  */
2351
- addEventToChannel: addMessageToChannel(join18(path6), "events"),
2750
+ addEventToChannel: addMessageToChannel(join18(path8), "events"),
2352
2751
  /**
2353
2752
  * Add a channel to an command
2354
2753
  *
@@ -2365,7 +2764,7 @@ var src_default = (path6) => {
2365
2764
  *
2366
2765
  * ```
2367
2766
  */
2368
- addCommandToChannel: addMessageToChannel(join18(path6), "commands"),
2767
+ addCommandToChannel: addMessageToChannel(join18(path8), "commands"),
2369
2768
  /**
2370
2769
  * Add a channel to an query
2371
2770
  *
@@ -2382,7 +2781,7 @@ var src_default = (path6) => {
2382
2781
  *
2383
2782
  * ```
2384
2783
  */
2385
- addQueryToChannel: addMessageToChannel(join18(path6), "queries"),
2784
+ addQueryToChannel: addMessageToChannel(join18(path8), "queries"),
2386
2785
  /**
2387
2786
  * ================================
2388
2787
  * SERVICES
@@ -2395,14 +2794,14 @@ var src_default = (path6) => {
2395
2794
  * @param options - Optional options to write the event
2396
2795
  *
2397
2796
  */
2398
- writeService: writeService(join18(path6, "services")),
2797
+ writeService: writeService(join18(path8, "services")),
2399
2798
  /**
2400
2799
  * Adds a versioned service to EventCatalog
2401
2800
  *
2402
2801
  * @param service - The service to write
2403
2802
  *
2404
2803
  */
2405
- writeVersionedService: writeVersionedService(join18(path6, "services")),
2804
+ writeVersionedService: writeVersionedService(join18(path8, "services")),
2406
2805
  /**
2407
2806
  * Adds a service to a domain in EventCatalog
2408
2807
  *
@@ -2411,45 +2810,45 @@ var src_default = (path6) => {
2411
2810
  * @param options - Optional options to write the event
2412
2811
  *
2413
2812
  */
2414
- writeServiceToDomain: writeServiceToDomain(join18(path6, "domains")),
2813
+ writeServiceToDomain: writeServiceToDomain(join18(path8, "domains")),
2415
2814
  /**
2416
2815
  * Returns a service from EventCatalog
2417
2816
  * @param id - The id of the service to retrieve
2418
2817
  * @param version - Optional id of the version to get (supports semver)
2419
2818
  * @returns Service|Undefined
2420
2819
  */
2421
- getService: getService(join18(path6)),
2820
+ getService: getService(join18(path8)),
2422
2821
  /**
2423
2822
  * Returns a service from EventCatalog by it's path.
2424
2823
  * @param path - The path to the service to retrieve
2425
2824
  * @returns Service|Undefined
2426
2825
  */
2427
- getServiceByPath: getServiceByPath(join18(path6)),
2826
+ getServiceByPath: getServiceByPath(join18(path8)),
2428
2827
  /**
2429
2828
  * Returns all services from EventCatalog
2430
2829
  * @param latestOnly - optional boolean, set to true to get only latest versions
2431
2830
  * @returns Service[]|Undefined
2432
2831
  */
2433
- getServices: getServices(join18(path6)),
2832
+ getServices: getServices(join18(path8)),
2434
2833
  /**
2435
2834
  * Moves a given service id to the version directory
2436
2835
  * @param directory
2437
2836
  */
2438
- versionService: versionService(join18(path6)),
2837
+ versionService: versionService(join18(path8)),
2439
2838
  /**
2440
2839
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
2441
2840
  *
2442
2841
  * @param path - The path to your service, e.g. `/InventoryService`
2443
2842
  *
2444
2843
  */
2445
- rmService: rmService(join18(path6, "services")),
2844
+ rmService: rmService(join18(path8, "services")),
2446
2845
  /**
2447
2846
  * Remove an service by an service id
2448
2847
  *
2449
2848
  * @param id - The id of the service you want to remove
2450
2849
  *
2451
2850
  */
2452
- rmServiceById: rmServiceById(join18(path6)),
2851
+ rmServiceById: rmServiceById(join18(path8)),
2453
2852
  /**
2454
2853
  * Adds a file to the given service
2455
2854
  * @param id - The id of the service to add the file to
@@ -2457,21 +2856,21 @@ var src_default = (path6) => {
2457
2856
  * @param version - Optional version of the service to add the file to
2458
2857
  * @returns
2459
2858
  */
2460
- addFileToService: addFileToService(join18(path6)),
2859
+ addFileToService: addFileToService(join18(path8)),
2461
2860
  /**
2462
2861
  * Returns the specifications for a given service
2463
2862
  * @param id - The id of the service to retrieve the specifications for
2464
2863
  * @param version - Optional version of the service
2465
2864
  * @returns
2466
2865
  */
2467
- getSpecificationFilesForService: getSpecificationFilesForService(join18(path6)),
2866
+ getSpecificationFilesForService: getSpecificationFilesForService(join18(path8)),
2468
2867
  /**
2469
2868
  * Check to see if a service version exists
2470
2869
  * @param id - The id of the service
2471
2870
  * @param version - The version of the service (supports semver)
2472
2871
  * @returns
2473
2872
  */
2474
- serviceHasVersion: serviceHasVersion(join18(path6)),
2873
+ serviceHasVersion: serviceHasVersion(join18(path8)),
2475
2874
  /**
2476
2875
  * Add an event to a service by it's id.
2477
2876
  *
@@ -2491,7 +2890,7 @@ var src_default = (path6) => {
2491
2890
  *
2492
2891
  * ```
2493
2892
  */
2494
- addEventToService: addMessageToService(join18(path6)),
2893
+ addEventToService: addMessageToService(join18(path8)),
2495
2894
  /**
2496
2895
  * Add a data store to a service by it's id.
2497
2896
  *
@@ -2508,7 +2907,7 @@ var src_default = (path6) => {
2508
2907
  *
2509
2908
  * ```
2510
2909
  */
2511
- addDataStoreToService: addDataStoreToService(join18(path6)),
2910
+ addDataStoreToService: addDataStoreToService(join18(path8)),
2512
2911
  /**
2513
2912
  * Add a command to a service by it's id.
2514
2913
  *
@@ -2528,7 +2927,7 @@ var src_default = (path6) => {
2528
2927
  *
2529
2928
  * ```
2530
2929
  */
2531
- addCommandToService: addMessageToService(join18(path6)),
2930
+ addCommandToService: addMessageToService(join18(path8)),
2532
2931
  /**
2533
2932
  * Add a query to a service by it's id.
2534
2933
  *
@@ -2548,7 +2947,7 @@ var src_default = (path6) => {
2548
2947
  *
2549
2948
  * ```
2550
2949
  */
2551
- addQueryToService: addMessageToService(join18(path6)),
2950
+ addQueryToService: addMessageToService(join18(path8)),
2552
2951
  /**
2553
2952
  * Add an entity to a service by its id.
2554
2953
  *
@@ -2566,7 +2965,7 @@ var src_default = (path6) => {
2566
2965
  *
2567
2966
  * ```
2568
2967
  */
2569
- addEntityToService: addEntityToService(join18(path6)),
2968
+ addEntityToService: addEntityToService(join18(path8)),
2570
2969
  /**
2571
2970
  * Check to see if a service exists by it's path.
2572
2971
  *
@@ -2583,13 +2982,13 @@ var src_default = (path6) => {
2583
2982
  * @param path - The path to the service to check
2584
2983
  * @returns boolean
2585
2984
  */
2586
- isService: isService(join18(path6)),
2985
+ isService: isService(join18(path8)),
2587
2986
  /**
2588
2987
  * Converts a file to a service.
2589
2988
  * @param file - The file to convert to a service.
2590
2989
  * @returns The service.
2591
2990
  */
2592
- toService: toService(join18(path6)),
2991
+ toService: toService(join18(path8)),
2593
2992
  /**
2594
2993
  * ================================
2595
2994
  * Domains
@@ -2602,39 +3001,39 @@ var src_default = (path6) => {
2602
3001
  * @param options - Optional options to write the event
2603
3002
  *
2604
3003
  */
2605
- writeDomain: writeDomain(join18(path6, "domains")),
3004
+ writeDomain: writeDomain(join18(path8, "domains")),
2606
3005
  /**
2607
3006
  * Returns a domain from EventCatalog
2608
3007
  * @param id - The id of the domain to retrieve
2609
3008
  * @param version - Optional id of the version to get (supports semver)
2610
3009
  * @returns Domain|Undefined
2611
3010
  */
2612
- getDomain: getDomain(join18(path6, "domains")),
3011
+ getDomain: getDomain(join18(path8, "domains")),
2613
3012
  /**
2614
3013
  * Returns all domains from EventCatalog
2615
3014
  * @param latestOnly - optional boolean, set to true to get only latest versions
2616
3015
  * @returns Domain[]|Undefined
2617
3016
  */
2618
- getDomains: getDomains(join18(path6)),
3017
+ getDomains: getDomains(join18(path8)),
2619
3018
  /**
2620
3019
  * Moves a given domain id to the version directory
2621
3020
  * @param directory
2622
3021
  */
2623
- versionDomain: versionDomain(join18(path6, "domains")),
3022
+ versionDomain: versionDomain(join18(path8, "domains")),
2624
3023
  /**
2625
3024
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
2626
3025
  *
2627
3026
  * @param path - The path to your domain, e.g. `/Payment`
2628
3027
  *
2629
3028
  */
2630
- rmDomain: rmDomain(join18(path6, "domains")),
3029
+ rmDomain: rmDomain(join18(path8, "domains")),
2631
3030
  /**
2632
3031
  * Remove an service by an domain id
2633
3032
  *
2634
3033
  * @param id - The id of the domain you want to remove
2635
3034
  *
2636
3035
  */
2637
- rmDomainById: rmDomainById(join18(path6, "domains")),
3036
+ rmDomainById: rmDomainById(join18(path8, "domains")),
2638
3037
  /**
2639
3038
  * Adds a file to the given domain
2640
3039
  * @param id - The id of the domain to add the file to
@@ -2642,28 +3041,28 @@ var src_default = (path6) => {
2642
3041
  * @param version - Optional version of the domain to add the file to
2643
3042
  * @returns
2644
3043
  */
2645
- addFileToDomain: addFileToDomain(join18(path6, "domains")),
3044
+ addFileToDomain: addFileToDomain(join18(path8, "domains")),
2646
3045
  /**
2647
3046
  * Adds an ubiquitous language dictionary to a domain
2648
3047
  * @param id - The id of the domain to add the ubiquitous language to
2649
3048
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
2650
3049
  * @param version - Optional version of the domain to add the ubiquitous language to
2651
3050
  */
2652
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join18(path6, "domains")),
3051
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join18(path8, "domains")),
2653
3052
  /**
2654
3053
  * Get the ubiquitous language dictionary from a domain
2655
3054
  * @param id - The id of the domain to get the ubiquitous language from
2656
3055
  * @param version - Optional version of the domain to get the ubiquitous language from
2657
3056
  * @returns
2658
3057
  */
2659
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join18(path6, "domains")),
3058
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join18(path8, "domains")),
2660
3059
  /**
2661
3060
  * Check to see if a domain version exists
2662
3061
  * @param id - The id of the domain
2663
3062
  * @param version - The version of the domain (supports semver)
2664
3063
  * @returns
2665
3064
  */
2666
- domainHasVersion: domainHasVersion(join18(path6)),
3065
+ domainHasVersion: domainHasVersion(join18(path8)),
2667
3066
  /**
2668
3067
  * Adds a given service to a domain
2669
3068
  * @param id - The id of the domain
@@ -2671,7 +3070,7 @@ var src_default = (path6) => {
2671
3070
  * @param version - (Optional) The version of the domain to add the service to
2672
3071
  * @returns
2673
3072
  */
2674
- addServiceToDomain: addServiceToDomain(join18(path6, "domains")),
3073
+ addServiceToDomain: addServiceToDomain(join18(path8, "domains")),
2675
3074
  /**
2676
3075
  * Adds a given subdomain to a domain
2677
3076
  * @param id - The id of the domain
@@ -2679,7 +3078,7 @@ var src_default = (path6) => {
2679
3078
  * @param version - (Optional) The version of the domain to add the subdomain to
2680
3079
  * @returns
2681
3080
  */
2682
- addSubDomainToDomain: addSubDomainToDomain(join18(path6, "domains")),
3081
+ addSubDomainToDomain: addSubDomainToDomain(join18(path8, "domains")),
2683
3082
  /**
2684
3083
  * Adds an entity to a domain
2685
3084
  * @param id - The id of the domain
@@ -2687,7 +3086,7 @@ var src_default = (path6) => {
2687
3086
  * @param version - (Optional) The version of the domain to add the entity to
2688
3087
  * @returns
2689
3088
  */
2690
- addEntityToDomain: addEntityToDomain(join18(path6, "domains")),
3089
+ addEntityToDomain: addEntityToDomain(join18(path8, "domains")),
2691
3090
  /**
2692
3091
  * Add an event to a domain by its id.
2693
3092
  *
@@ -2705,7 +3104,7 @@ var src_default = (path6) => {
2705
3104
  *
2706
3105
  * ```
2707
3106
  */
2708
- addEventToDomain: addMessageToDomain(join18(path6, "domains")),
3107
+ addEventToDomain: addMessageToDomain(join18(path8, "domains")),
2709
3108
  /**
2710
3109
  * Add a command to a domain by its id.
2711
3110
  *
@@ -2723,7 +3122,7 @@ var src_default = (path6) => {
2723
3122
  *
2724
3123
  * ```
2725
3124
  */
2726
- addCommandToDomain: addMessageToDomain(join18(path6, "domains")),
3125
+ addCommandToDomain: addMessageToDomain(join18(path8, "domains")),
2727
3126
  /**
2728
3127
  * Add a query to a domain by its id.
2729
3128
  *
@@ -2741,7 +3140,7 @@ var src_default = (path6) => {
2741
3140
  *
2742
3141
  * ```
2743
3142
  */
2744
- addQueryToDomain: addMessageToDomain(join18(path6, "domains")),
3143
+ addQueryToDomain: addMessageToDomain(join18(path8, "domains")),
2745
3144
  /**
2746
3145
  * ================================
2747
3146
  * Teams
@@ -2754,25 +3153,25 @@ var src_default = (path6) => {
2754
3153
  * @param options - Optional options to write the team
2755
3154
  *
2756
3155
  */
2757
- writeTeam: writeTeam(join18(path6, "teams")),
3156
+ writeTeam: writeTeam(join18(path8, "teams")),
2758
3157
  /**
2759
3158
  * Returns a team from EventCatalog
2760
3159
  * @param id - The id of the team to retrieve
2761
3160
  * @returns Team|Undefined
2762
3161
  */
2763
- getTeam: getTeam(join18(path6, "teams")),
3162
+ getTeam: getTeam(join18(path8, "teams")),
2764
3163
  /**
2765
3164
  * Returns all teams from EventCatalog
2766
3165
  * @returns Team[]|Undefined
2767
3166
  */
2768
- getTeams: getTeams(join18(path6, "teams")),
3167
+ getTeams: getTeams(join18(path8, "teams")),
2769
3168
  /**
2770
3169
  * Remove a team by the team id
2771
3170
  *
2772
3171
  * @param id - The id of the team you want to remove
2773
3172
  *
2774
3173
  */
2775
- rmTeamById: rmTeamById(join18(path6, "teams")),
3174
+ rmTeamById: rmTeamById(join18(path8, "teams")),
2776
3175
  /**
2777
3176
  * ================================
2778
3177
  * Users
@@ -2785,25 +3184,25 @@ var src_default = (path6) => {
2785
3184
  * @param options - Optional options to write the user
2786
3185
  *
2787
3186
  */
2788
- writeUser: writeUser(join18(path6, "users")),
3187
+ writeUser: writeUser(join18(path8, "users")),
2789
3188
  /**
2790
3189
  * Returns a user from EventCatalog
2791
3190
  * @param id - The id of the user to retrieve
2792
3191
  * @returns User|Undefined
2793
3192
  */
2794
- getUser: getUser(join18(path6, "users")),
3193
+ getUser: getUser(join18(path8, "users")),
2795
3194
  /**
2796
3195
  * Returns all user from EventCatalog
2797
3196
  * @returns User[]|Undefined
2798
3197
  */
2799
- getUsers: getUsers(join18(path6)),
3198
+ getUsers: getUsers(join18(path8)),
2800
3199
  /**
2801
3200
  * Remove a user by the user id
2802
3201
  *
2803
3202
  * @param id - The id of the user you want to remove
2804
3203
  *
2805
3204
  */
2806
- rmUserById: rmUserById(join18(path6, "users")),
3205
+ rmUserById: rmUserById(join18(path8, "users")),
2807
3206
  /**
2808
3207
  * ================================
2809
3208
  * Custom Docs
@@ -2814,32 +3213,32 @@ var src_default = (path6) => {
2814
3213
  * @param path - The path to the custom doc to retrieve
2815
3214
  * @returns CustomDoc|Undefined
2816
3215
  */
2817
- getCustomDoc: getCustomDoc(join18(path6, "docs")),
3216
+ getCustomDoc: getCustomDoc(join18(path8, "docs")),
2818
3217
  /**
2819
3218
  * Returns all custom docs from EventCatalog
2820
3219
  * @param options - Optional options to get custom docs from a specific path
2821
3220
  * @returns CustomDoc[]|Undefined
2822
3221
  */
2823
- getCustomDocs: getCustomDocs(join18(path6, "docs")),
3222
+ getCustomDocs: getCustomDocs(join18(path8, "docs")),
2824
3223
  /**
2825
3224
  * Writes a custom doc to EventCatalog
2826
3225
  * @param customDoc - The custom doc to write
2827
3226
  * @param options - Optional options to write the custom doc
2828
3227
  *
2829
3228
  */
2830
- writeCustomDoc: writeCustomDoc(join18(path6, "docs")),
3229
+ writeCustomDoc: writeCustomDoc(join18(path8, "docs")),
2831
3230
  /**
2832
3231
  * Removes a custom doc from EventCatalog
2833
3232
  * @param path - The path to the custom doc to remove
2834
3233
  *
2835
3234
  */
2836
- rmCustomDoc: rmCustomDoc(join18(path6, "docs")),
3235
+ rmCustomDoc: rmCustomDoc(join18(path8, "docs")),
2837
3236
  /**
2838
3237
  * Dumps the catalog to a JSON file.
2839
3238
  * @param directory - The directory to dump the catalog to
2840
3239
  * @returns A JSON file with the catalog
2841
3240
  */
2842
- dumpCatalog: dumpCatalog(join18(path6)),
3241
+ dumpCatalog: dumpCatalog(join18(path8)),
2843
3242
  /**
2844
3243
  * Returns the event catalog configuration file.
2845
3244
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -2847,7 +3246,47 @@ var src_default = (path6) => {
2847
3246
  * @param directory - The directory of the catalog.
2848
3247
  * @returns A JSON object with the configuration for the event catalog.
2849
3248
  */
2850
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join18(path6)),
3249
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join18(path8)),
3250
+ /**
3251
+ * ================================
3252
+ * Changelogs
3253
+ * ================================
3254
+ */
3255
+ /**
3256
+ * Writes a changelog entry to a resource in EventCatalog
3257
+ *
3258
+ * @param id - The id of the resource to write the changelog to
3259
+ * @param changelog - The changelog entry to write
3260
+ * @param options - Optional options (version, format)
3261
+ *
3262
+ */
3263
+ writeChangelog: writeChangelog(join18(path8)),
3264
+ /**
3265
+ * Appends a changelog entry to an existing changelog for a resource.
3266
+ * If no changelog exists, one is created.
3267
+ *
3268
+ * @param id - The id of the resource to append the changelog to
3269
+ * @param changelog - The changelog entry to append
3270
+ * @param options - Optional options (version, format)
3271
+ *
3272
+ */
3273
+ appendChangelog: appendChangelog(join18(path8)),
3274
+ /**
3275
+ * Returns the changelog for a resource in EventCatalog
3276
+ *
3277
+ * @param id - The id of the resource to get the changelog for
3278
+ * @param options - Optional options (version)
3279
+ * @returns Changelog|Undefined
3280
+ */
3281
+ getChangelog: getChangelog(join18(path8)),
3282
+ /**
3283
+ * Removes the changelog for a resource in EventCatalog
3284
+ *
3285
+ * @param id - The id of the resource to remove the changelog from
3286
+ * @param options - Optional options (version)
3287
+ *
3288
+ */
3289
+ rmChangelog: rmChangelog(join18(path8)),
2851
3290
  /**
2852
3291
  * ================================
2853
3292
  * Resources Utils
@@ -2872,33 +3311,33 @@ var src_default = (path6) => {
2872
3311
  * @param path - The path to the message to retrieve
2873
3312
  * @returns Message|Undefined
2874
3313
  */
2875
- getMessageBySchemaPath: getMessageBySchemaPath(join18(path6)),
3314
+ getMessageBySchemaPath: getMessageBySchemaPath(join18(path8)),
2876
3315
  /**
2877
3316
  * Returns the producers and consumers (services) for a given message
2878
3317
  * @param id - The id of the message to get the producers and consumers for
2879
3318
  * @param version - Optional version of the message
2880
3319
  * @returns { producers: Service[], consumers: Service[] }
2881
3320
  */
2882
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join18(path6)),
3321
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join18(path8)),
2883
3322
  /**
2884
3323
  * Returns the consumers of a given schema path
2885
3324
  * @param path - The path to the schema to get the consumers for
2886
3325
  * @returns Service[]
2887
3326
  */
2888
- getConsumersOfSchema: getConsumersOfSchema(join18(path6)),
3327
+ getConsumersOfSchema: getConsumersOfSchema(join18(path8)),
2889
3328
  /**
2890
3329
  * Returns the producers of a given schema path
2891
3330
  * @param path - The path to the schema to get the producers for
2892
3331
  * @returns Service[]
2893
3332
  */
2894
- getProducersOfSchema: getProducersOfSchema(join18(path6)),
3333
+ getProducersOfSchema: getProducersOfSchema(join18(path8)),
2895
3334
  /**
2896
3335
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
2897
3336
  * @param id - The id of the resource to get the owners for
2898
3337
  * @param version - Optional version of the resource
2899
3338
  * @returns { owners: User[] }
2900
3339
  */
2901
- getOwnersForResource: getOwnersForResource(join18(path6)),
3340
+ getOwnersForResource: getOwnersForResource(join18(path8)),
2902
3341
  /**
2903
3342
  * ================================
2904
3343
  * Entities
@@ -2910,13 +3349,13 @@ var src_default = (path6) => {
2910
3349
  * @param version - Optional id of the version to get (supports semver)
2911
3350
  * @returns Entity|Undefined
2912
3351
  */
2913
- getEntity: getEntity(join18(path6)),
3352
+ getEntity: getEntity(join18(path8)),
2914
3353
  /**
2915
3354
  * Returns all entities from EventCatalog
2916
3355
  * @param latestOnly - optional boolean, set to true to get only latest versions
2917
3356
  * @returns Entity[]|Undefined
2918
3357
  */
2919
- getEntities: getEntities(join18(path6)),
3358
+ getEntities: getEntities(join18(path8)),
2920
3359
  /**
2921
3360
  * Adds an entity to EventCatalog
2922
3361
  *
@@ -2924,33 +3363,33 @@ var src_default = (path6) => {
2924
3363
  * @param options - Optional options to write the entity
2925
3364
  *
2926
3365
  */
2927
- writeEntity: writeEntity(join18(path6, "entities")),
3366
+ writeEntity: writeEntity(join18(path8, "entities")),
2928
3367
  /**
2929
3368
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
2930
3369
  *
2931
3370
  * @param path - The path to your entity, e.g. `/User`
2932
3371
  *
2933
3372
  */
2934
- rmEntity: rmEntity(join18(path6, "entities")),
3373
+ rmEntity: rmEntity(join18(path8, "entities")),
2935
3374
  /**
2936
3375
  * Remove an entity by an entity id
2937
3376
  *
2938
3377
  * @param id - The id of the entity you want to remove
2939
3378
  *
2940
3379
  */
2941
- rmEntityById: rmEntityById(join18(path6)),
3380
+ rmEntityById: rmEntityById(join18(path8)),
2942
3381
  /**
2943
3382
  * Moves a given entity id to the version directory
2944
3383
  * @param id - The id of the entity to version
2945
3384
  */
2946
- versionEntity: versionEntity(join18(path6)),
3385
+ versionEntity: versionEntity(join18(path8)),
2947
3386
  /**
2948
3387
  * Check to see if an entity version exists
2949
3388
  * @param id - The id of the entity
2950
3389
  * @param version - The version of the entity (supports semver)
2951
3390
  * @returns
2952
3391
  */
2953
- entityHasVersion: entityHasVersion(join18(path6)),
3392
+ entityHasVersion: entityHasVersion(join18(path8)),
2954
3393
  /**
2955
3394
  * ================================
2956
3395
  * Data Stores
@@ -2962,42 +3401,42 @@ var src_default = (path6) => {
2962
3401
  * @param options - Optional options to write the data store
2963
3402
  *
2964
3403
  */
2965
- writeDataStore: writeDataStore(join18(path6, "containers")),
3404
+ writeDataStore: writeDataStore(join18(path8, "containers")),
2966
3405
  /**
2967
3406
  * Returns a data store from EventCatalog
2968
3407
  * @param id - The id of the data store to retrieve
2969
3408
  * @param version - Optional id of the version to get (supports semver)
2970
3409
  * @returns Container|Undefined
2971
3410
  */
2972
- getDataStore: getDataStore(join18(path6)),
3411
+ getDataStore: getDataStore(join18(path8)),
2973
3412
  /**
2974
3413
  * Returns all data stores from EventCatalog
2975
3414
  * @param latestOnly - optional boolean, set to true to get only latest versions
2976
3415
  * @returns Container[]|Undefined
2977
3416
  */
2978
- getDataStores: getDataStores(join18(path6)),
3417
+ getDataStores: getDataStores(join18(path8)),
2979
3418
  /**
2980
3419
  * Version a data store by its id
2981
3420
  * @param id - The id of the data store to version
2982
3421
  */
2983
- versionDataStore: versionDataStore(join18(path6, "containers")),
3422
+ versionDataStore: versionDataStore(join18(path8, "containers")),
2984
3423
  /**
2985
3424
  * Remove a data store by its path
2986
3425
  * @param path - The path to the data store to remove
2987
3426
  */
2988
- rmDataStore: rmDataStore(join18(path6, "containers")),
3427
+ rmDataStore: rmDataStore(join18(path8, "containers")),
2989
3428
  /**
2990
3429
  * Remove a data store by its id
2991
3430
  * @param id - The id of the data store to remove
2992
3431
  */
2993
- rmDataStoreById: rmDataStoreById(join18(path6)),
3432
+ rmDataStoreById: rmDataStoreById(join18(path8)),
2994
3433
  /**
2995
3434
  * Check to see if a data store version exists
2996
3435
  * @param id - The id of the data store
2997
3436
  * @param version - The version of the data store (supports semver)
2998
3437
  * @returns
2999
3438
  */
3000
- dataStoreHasVersion: dataStoreHasVersion(join18(path6)),
3439
+ dataStoreHasVersion: dataStoreHasVersion(join18(path8)),
3001
3440
  /**
3002
3441
  * Adds a file to a data store by its id
3003
3442
  * @param id - The id of the data store to add the file to
@@ -3005,14 +3444,14 @@ var src_default = (path6) => {
3005
3444
  * @param version - Optional version of the data store to add the file to
3006
3445
  * @returns
3007
3446
  */
3008
- addFileToDataStore: addFileToDataStore(join18(path6)),
3447
+ addFileToDataStore: addFileToDataStore(join18(path8)),
3009
3448
  /**
3010
3449
  * Writes a data store to a service by its id
3011
3450
  * @param dataStore - The data store to write
3012
3451
  * @param service - The service to write the data store to
3013
3452
  * @returns
3014
3453
  */
3015
- writeDataStoreToService: writeDataStoreToService(join18(path6)),
3454
+ writeDataStoreToService: writeDataStoreToService(join18(path8)),
3016
3455
  /**
3017
3456
  * ================================
3018
3457
  * Data Products
@@ -3024,7 +3463,7 @@ var src_default = (path6) => {
3024
3463
  * @param options - Optional options to write the data product
3025
3464
  *
3026
3465
  */
3027
- writeDataProduct: writeDataProduct(join18(path6, "data-products")),
3466
+ writeDataProduct: writeDataProduct(join18(path8, "data-products")),
3028
3467
  /**
3029
3468
  * Writes a data product to a domain in EventCatalog
3030
3469
  * @param dataProduct - The data product to write
@@ -3032,43 +3471,43 @@ var src_default = (path6) => {
3032
3471
  * @param options - Optional options to write the data product
3033
3472
  *
3034
3473
  */
3035
- writeDataProductToDomain: writeDataProductToDomain(join18(path6, "domains")),
3474
+ writeDataProductToDomain: writeDataProductToDomain(join18(path8, "domains")),
3036
3475
  /**
3037
3476
  * Returns a data product from EventCatalog
3038
3477
  * @param id - The id of the data product to retrieve
3039
3478
  * @param version - Optional id of the version to get (supports semver)
3040
3479
  * @returns DataProduct|Undefined
3041
3480
  */
3042
- getDataProduct: getDataProduct(join18(path6)),
3481
+ getDataProduct: getDataProduct(join18(path8)),
3043
3482
  /**
3044
3483
  * Returns all data products from EventCatalog
3045
3484
  * @param latestOnly - optional boolean, set to true to get only latest versions
3046
3485
  * @returns DataProduct[]|Undefined
3047
3486
  */
3048
- getDataProducts: getDataProducts(join18(path6)),
3487
+ getDataProducts: getDataProducts(join18(path8)),
3049
3488
  /**
3050
3489
  * Version a data product by its id
3051
3490
  * @param id - The id of the data product to version
3052
3491
  */
3053
- versionDataProduct: versionDataProduct(join18(path6)),
3492
+ versionDataProduct: versionDataProduct(join18(path8)),
3054
3493
  /**
3055
3494
  * Remove a data product by its path
3056
3495
  * @param path - The path to the data product to remove
3057
3496
  */
3058
- rmDataProduct: rmDataProduct(join18(path6, "data-products")),
3497
+ rmDataProduct: rmDataProduct(join18(path8, "data-products")),
3059
3498
  /**
3060
3499
  * Remove a data product by its id
3061
3500
  * @param id - The id of the data product to remove
3062
3501
  * @param version - Optional version of the data product to remove
3063
3502
  */
3064
- rmDataProductById: rmDataProductById(join18(path6)),
3503
+ rmDataProductById: rmDataProductById(join18(path8)),
3065
3504
  /**
3066
3505
  * Check to see if a data product version exists
3067
3506
  * @param id - The id of the data product
3068
3507
  * @param version - The version of the data product (supports semver)
3069
3508
  * @returns
3070
3509
  */
3071
- dataProductHasVersion: dataProductHasVersion(join18(path6)),
3510
+ dataProductHasVersion: dataProductHasVersion(join18(path8)),
3072
3511
  /**
3073
3512
  * Adds a file to a data product by its id
3074
3513
  * @param id - The id of the data product to add the file to
@@ -3076,7 +3515,7 @@ var src_default = (path6) => {
3076
3515
  * @param version - Optional version of the data product to add the file to
3077
3516
  * @returns
3078
3517
  */
3079
- addFileToDataProduct: addFileToDataProduct(join18(path6)),
3518
+ addFileToDataProduct: addFileToDataProduct(join18(path8)),
3080
3519
  /**
3081
3520
  * Adds a data product to a domain
3082
3521
  * @param id - The id of the domain
@@ -3084,7 +3523,7 @@ var src_default = (path6) => {
3084
3523
  * @param version - (Optional) The version of the domain to add the data product to
3085
3524
  * @returns
3086
3525
  */
3087
- addDataProductToDomain: addDataProductToDomain(join18(path6, "domains")),
3526
+ addDataProductToDomain: addDataProductToDomain(join18(path8, "domains")),
3088
3527
  /**
3089
3528
  * ================================
3090
3529
  * Diagrams
@@ -3096,13 +3535,13 @@ var src_default = (path6) => {
3096
3535
  * @param version - Optional id of the version to get (supports semver)
3097
3536
  * @returns Diagram|Undefined
3098
3537
  */
3099
- getDiagram: getDiagram(join18(path6)),
3538
+ getDiagram: getDiagram(join18(path8)),
3100
3539
  /**
3101
3540
  * Returns all diagrams from EventCatalog
3102
3541
  * @param latestOnly - optional boolean, set to true to get only latest versions
3103
3542
  * @returns Diagram[]|Undefined
3104
3543
  */
3105
- getDiagrams: getDiagrams(join18(path6)),
3544
+ getDiagrams: getDiagrams(join18(path8)),
3106
3545
  /**
3107
3546
  * Adds a diagram to EventCatalog
3108
3547
  *
@@ -3110,33 +3549,33 @@ var src_default = (path6) => {
3110
3549
  * @param options - Optional options to write the diagram
3111
3550
  *
3112
3551
  */
3113
- writeDiagram: writeDiagram(join18(path6, "diagrams")),
3552
+ writeDiagram: writeDiagram(join18(path8, "diagrams")),
3114
3553
  /**
3115
3554
  * Remove a diagram from EventCatalog (modeled on the standard POSIX rm utility)
3116
3555
  *
3117
3556
  * @param path - The path to your diagram, e.g. `/ArchitectureDiagram`
3118
3557
  *
3119
3558
  */
3120
- rmDiagram: rmDiagram(join18(path6, "diagrams")),
3559
+ rmDiagram: rmDiagram(join18(path8, "diagrams")),
3121
3560
  /**
3122
3561
  * Remove a diagram by a diagram id
3123
3562
  *
3124
3563
  * @param id - The id of the diagram you want to remove
3125
3564
  *
3126
3565
  */
3127
- rmDiagramById: rmDiagramById(join18(path6)),
3566
+ rmDiagramById: rmDiagramById(join18(path8)),
3128
3567
  /**
3129
3568
  * Moves a given diagram id to the version directory
3130
3569
  * @param id - The id of the diagram to version
3131
3570
  */
3132
- versionDiagram: versionDiagram(join18(path6)),
3571
+ versionDiagram: versionDiagram(join18(path8)),
3133
3572
  /**
3134
3573
  * Check to see if a diagram version exists
3135
3574
  * @param id - The id of the diagram
3136
3575
  * @param version - The version of the diagram (supports semver)
3137
3576
  * @returns
3138
3577
  */
3139
- diagramHasVersion: diagramHasVersion(join18(path6)),
3578
+ diagramHasVersion: diagramHasVersion(join18(path8)),
3140
3579
  /**
3141
3580
  * Adds a file to the given diagram
3142
3581
  * @param id - The id of the diagram to add the file to
@@ -3144,7 +3583,7 @@ var src_default = (path6) => {
3144
3583
  * @param version - Optional version of the diagram to add the file to
3145
3584
  * @returns
3146
3585
  */
3147
- addFileToDiagram: addFileToDiagram(join18(path6)),
3586
+ addFileToDiagram: addFileToDiagram(join18(path8)),
3148
3587
  /**
3149
3588
  * ================================
3150
3589
  * DSL
@@ -3163,18 +3602,21 @@ var src_default = (path6) => {
3163
3602
  * const dsl = await sdk.toDSL(services, { type: 'service', hydrate: true });
3164
3603
  * ```
3165
3604
  */
3166
- toDSL: toDSL(join18(path6), {
3167
- getEvent: getEvent(join18(path6)),
3168
- getCommand: getCommand(join18(path6)),
3169
- getQuery: getQuery(join18(path6)),
3170
- getService: getService(join18(path6)),
3171
- getServices: getServices(join18(path6)),
3172
- getDomain: getDomain(join18(path6, "domains")),
3173
- getChannel: getChannel(join18(path6)),
3174
- getChannels: getChannels(join18(path6)),
3175
- getContainer: getDataStore(join18(path6)),
3176
- getTeam: getTeam(join18(path6, "teams")),
3177
- getUser: getUser(join18(path6, "users"))
3605
+ createSnapshot: createSnapshot(join18(path8)),
3606
+ diffSnapshots: diffSnapshots(join18(path8)),
3607
+ listSnapshots: listSnapshots(join18(path8)),
3608
+ toDSL: toDSL(join18(path8), {
3609
+ getEvent: getEvent(join18(path8)),
3610
+ getCommand: getCommand(join18(path8)),
3611
+ getQuery: getQuery(join18(path8)),
3612
+ getService: getService(join18(path8)),
3613
+ getServices: getServices(join18(path8)),
3614
+ getDomain: getDomain(join18(path8, "domains")),
3615
+ getChannel: getChannel(join18(path8)),
3616
+ getChannels: getChannels(join18(path8)),
3617
+ getContainer: getDataStore(join18(path8)),
3618
+ getTeam: getTeam(join18(path8, "teams")),
3619
+ getUser: getUser(join18(path8, "users"))
3178
3620
  })
3179
3621
  };
3180
3622
  };