@eventcatalog/sdk 2.17.2 → 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
@@ -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);