@eventcatalog/sdk 2.17.1 → 2.17.3

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
@@ -1292,7 +1292,7 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
1292
1292
  }
1293
1293
  const path8 = existingResource.split(/[\\/]+services/)[0];
1294
1294
  const pathToResource = join6(path8, "services");
1295
- await rmServiceById(directory)(id, version);
1295
+ await rmServiceById(directory)(id, version, true);
1296
1296
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
1297
1297
  };
1298
1298
  var serviceHasVersion = (directory) => async (id, version) => {
@@ -1325,7 +1325,7 @@ var addEntityToService = (directory) => async (id, entity, version) => {
1325
1325
  }
1326
1326
  const path8 = existingResource.split(/[\\/]+services/)[0];
1327
1327
  const pathToResource = join6(path8, "services");
1328
- await rmServiceById(directory)(id, version);
1328
+ await rmServiceById(directory)(id, version, true);
1329
1329
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
1330
1330
  };
1331
1331
  var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
@@ -1361,7 +1361,7 @@ var addDataStoreToService = (directory) => async (id, operation, dataStore, vers
1361
1361
  }
1362
1362
  const path8 = existingResource.split(/[\\/]+services/)[0];
1363
1363
  const pathToResource = join6(path8, "services");
1364
- await rmServiceById(directory)(id, version);
1364
+ await rmServiceById(directory)(id, version, true);
1365
1365
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
1366
1366
  };
1367
1367
 
@@ -1949,6 +1949,7 @@ var dumpCatalog = (directory) => async (options) => {
1949
1949
  // src/snapshots.ts
1950
1950
  import fs11 from "fs";
1951
1951
  import path6 from "path";
1952
+ import { createHash } from "crypto";
1952
1953
  import { execSync } from "child_process";
1953
1954
  import { compare } from "semver";
1954
1955
 
@@ -2139,6 +2140,8 @@ var pickCoreFields = (resource) => {
2139
2140
  if (resource.receives) picked.receives = resource.receives;
2140
2141
  if (resource.deprecated) picked.deprecated = resource.deprecated;
2141
2142
  if (resource.owners) picked.owners = resource.owners;
2143
+ if (resource.schemaPath) picked.schemaPath = resource.schemaPath;
2144
+ if (resource.schemaHash) picked.schemaHash = resource.schemaHash;
2142
2145
  return picked;
2143
2146
  };
2144
2147
  var deduplicateByLatestVersion = (resources) => {
@@ -2166,6 +2169,16 @@ var detectGitInfo = (catalogDir) => {
2166
2169
  return void 0;
2167
2170
  }
2168
2171
  };
2172
+ var enrichWithSchemaHashes = async (getSchemaForMessage2, resources) => {
2173
+ await Promise.all(
2174
+ resources.map(async (resource) => {
2175
+ if (!resource.schemaPath) return;
2176
+ const schema = await getSchemaForMessage2(resource.id, resource.version);
2177
+ if (!schema) return;
2178
+ resource.schemaHash = createHash("sha256").update(schema.schema).digest("hex");
2179
+ })
2180
+ );
2181
+ };
2169
2182
  var createSnapshot = (directory) => {
2170
2183
  return async (options) => {
2171
2184
  const { label, outputDir, git } = options || {};
@@ -2178,6 +2191,11 @@ var createSnapshot = (directory) => {
2178
2191
  sdk.getQueries(),
2179
2192
  sdk.getChannels()
2180
2193
  ]);
2194
+ await Promise.all([
2195
+ enrichWithSchemaHashes(sdk.getSchemaForMessage, events || []),
2196
+ enrichWithSchemaHashes(sdk.getSchemaForMessage, commands || []),
2197
+ enrichWithSchemaHashes(sdk.getSchemaForMessage, queries || [])
2198
+ ]);
2181
2199
  const snapshotDomains = stripToCore(domains);
2182
2200
  const snapshotServices = stripToCore(services);
2183
2201
  const snapshotEvents = stripToCore(events);