@emeryld/rrroutes-export 1.0.23 → 1.0.25

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
@@ -1771,6 +1771,19 @@ function flattenSourceSections(snapshot) {
1771
1771
  }
1772
1772
  return map;
1773
1773
  }
1774
+ function emptySourceSnapshotLike(snapshot) {
1775
+ return {
1776
+ id: snapshot.id,
1777
+ displayName: snapshot.displayName,
1778
+ routeKeys: [],
1779
+ sections: {
1780
+ params: {},
1781
+ query: {},
1782
+ body: {},
1783
+ output: {}
1784
+ }
1785
+ };
1786
+ }
1774
1787
  function diffSourceSchemas(before, after) {
1775
1788
  const prev = flattenSourceSections(before);
1776
1789
  const next = flattenSourceSections(after);
@@ -2148,6 +2161,7 @@ async function createSnapshot(repoRoot, moduleCandidates, exportName, commit, te
2148
2161
  commit,
2149
2162
  routesByKey: {},
2150
2163
  sourceObjectsById: {},
2164
+ missing: true,
2151
2165
  fallbackReason: "snapshot_error",
2152
2166
  fallbackError: message
2153
2167
  };
@@ -2168,12 +2182,14 @@ function diffSnapshots(previous, current) {
2168
2182
  const prevRoute = previous.routesByKey[routeKey];
2169
2183
  const nextRoute = current.routesByKey[routeKey];
2170
2184
  if (!prevRoute && nextRoute) {
2185
+ const schemaDiff2 = diffRouteSchemas({}, nextRoute.flatSchema);
2171
2186
  routeEvents.push({
2172
2187
  type: "route_added",
2173
2188
  commitSha: current.commit.sha,
2174
2189
  routeKey,
2175
2190
  method: nextRoute.method,
2176
- path: nextRoute.path
2191
+ path: nextRoute.path,
2192
+ schemaDiff: schemaDiff2.length > 0 ? schemaDiff2 : void 0
2177
2193
  });
2178
2194
  continue;
2179
2195
  }
@@ -2219,12 +2235,17 @@ function diffSnapshots(previous, current) {
2219
2235
  const prevSource = previous.sourceObjectsById[sourceObjectId];
2220
2236
  const nextSource = current.sourceObjectsById[sourceObjectId];
2221
2237
  if (!prevSource && nextSource) {
2238
+ const schemaDiff2 = diffSourceSchemas(
2239
+ emptySourceSnapshotLike(nextSource),
2240
+ nextSource
2241
+ );
2222
2242
  sourceEvents.push({
2223
2243
  type: "source_object_added",
2224
2244
  commitSha: current.commit.sha,
2225
2245
  sourceObjectId,
2226
2246
  displayName: nextSource.displayName,
2227
- impactedRoutes: nextSource.routeKeys
2247
+ impactedRoutes: nextSource.routeKeys,
2248
+ schemaDiff: schemaDiff2.length > 0 ? schemaDiff2 : void 0
2228
2249
  });
2229
2250
  continue;
2230
2251
  }
@@ -2439,14 +2460,23 @@ async function exportFinalizedLeavesChangelog(options) {
2439
2460
  }
2440
2461
  const routeEvents = [];
2441
2462
  const sourceEvents = [];
2442
- log("[changelog] diffing adjacent snapshots");
2443
- for (let i = 1; i < snapshots.length; i += 1) {
2463
+ log("[changelog] diffing successful snapshots");
2464
+ let previousSnapshot;
2465
+ for (const snapshot of snapshots) {
2466
+ if (snapshot.missing) {
2467
+ continue;
2468
+ }
2469
+ if (!previousSnapshot) {
2470
+ previousSnapshot = snapshot;
2471
+ continue;
2472
+ }
2444
2473
  const { routeEvents: nextRouteEvents, sourceEvents: nextSourceEvents } = diffSnapshots(
2445
- snapshots[i - 1],
2446
- snapshots[i]
2474
+ previousSnapshot,
2475
+ snapshot
2447
2476
  );
2448
2477
  routeEvents.push(...nextRouteEvents);
2449
2478
  sourceEvents.push(...nextSourceEvents);
2479
+ previousSnapshot = snapshot;
2450
2480
  }
2451
2481
  log(
2452
2482
  `[changelog] diff complete: route events=${routeEvents.length}, source events=${sourceEvents.length}`