@hatk/hatk 0.0.1-alpha.13 → 0.0.1-alpha.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../src/backfill.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,6CAA6C;AAC7C,UAAU,YAAY;IACpB,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAA;IACd,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACxB,qDAAqD;IACrD,MAAM,EAAE,cAAc,CAAA;CACvB;AAuGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwI/G;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiInE"}
1
+ {"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../src/backfill.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,6CAA6C;AAC7C,UAAU,YAAY;IACpB,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAA;IACd,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACxB,qDAAqD;IACrD,MAAM,EAAE,cAAc,CAAA;CACvB;AAuGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJ/G;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiInE"}
package/dist/backfill.js CHANGED
@@ -153,10 +153,25 @@ export async function backfillRepo(did, collections, fetchTimeout) {
153
153
  throw httpErr;
154
154
  }
155
155
  resolvedSince = lastRev;
156
- const { roots, blocks, byteLength } = await parseCarStream(res.body);
156
+ let { roots, blocks, byteLength } = await parseCarStream(res.body);
157
157
  carSizeBytes = byteLength;
158
- // Decode commit to get MST root
159
- const rootData = blocks.get(roots[0]);
158
+ // Decode commit to get MST root — if the diff CAR is missing the root block,
159
+ // fall back to a full import (the PDS compacted past our `since` rev)
160
+ let rootData = blocks.get(roots[0]);
161
+ if (!rootData && lastRev) {
162
+ lastRev = null;
163
+ resolvedSince = null;
164
+ res = await fetch(baseUrl, { signal: controller.signal });
165
+ if (!res.ok) {
166
+ const httpErr = new Error(`getRepo failed for ${did}: ${res.status}`);
167
+ httpErr.httpStatus = res.status;
168
+ throw httpErr;
169
+ }
170
+ ;
171
+ ({ roots, blocks, byteLength } = await parseCarStream(res.body));
172
+ carSizeBytes = byteLength;
173
+ rootData = blocks.get(roots[0]);
174
+ }
160
175
  if (!rootData)
161
176
  throw new Error(`No root block for ${did}`);
162
177
  const { value: commit } = cborDecode(rootData);
package/dist/main.js CHANGED
@@ -153,3 +153,8 @@ runBackfill({
153
153
  .catch((err) => {
154
154
  console.error('[main] Backfill error:', err.message);
155
155
  });
156
+ // Graceful shutdown
157
+ process.on('SIGTERM', () => {
158
+ log('[main] Received SIGTERM, shutting down...');
159
+ process.exit(0);
160
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatk/hatk",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.14",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "hatk": "dist/cli.js"