@hatk/hatk 0.0.1-alpha.17 → 0.0.1-alpha.19
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/backfill.d.ts +1 -1
- package/dist/backfill.d.ts.map +1 -1
- package/dist/backfill.js +2 -1
- package/dist/main.js +26 -20
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -2
- package/package.json +1 -1
package/dist/backfill.d.ts
CHANGED
|
@@ -65,6 +65,6 @@ export declare function backfillRepo(did: string, collections: Set<string>, fetc
|
|
|
65
65
|
* })
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
export declare function runBackfill(opts: BackfillOpts): Promise<
|
|
68
|
+
export declare function runBackfill(opts: BackfillOpts): Promise<number>;
|
|
69
69
|
export {};
|
|
70
70
|
//# sourceMappingURL=backfill.d.ts.map
|
package/dist/backfill.d.ts.map
CHANGED
|
@@ -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,CAsJ/G;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,
|
|
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,MAAM,CAAC,CAkIrE"}
|
package/dist/backfill.js
CHANGED
|
@@ -388,7 +388,7 @@ export async function runBackfill(opts) {
|
|
|
388
388
|
parallelism: config.parallelism,
|
|
389
389
|
status: 'success',
|
|
390
390
|
});
|
|
391
|
-
return;
|
|
391
|
+
return 0;
|
|
392
392
|
}
|
|
393
393
|
// 3. Backfill with worker pool
|
|
394
394
|
let totalRecords = 0;
|
|
@@ -446,4 +446,5 @@ export async function runBackfill(opts) {
|
|
|
446
446
|
retry_rounds: retryRound,
|
|
447
447
|
status: failedCount > 0 ? 'partial' : 'success',
|
|
448
448
|
});
|
|
449
|
+
return totalRecords;
|
|
449
450
|
}
|
package/dist/main.js
CHANGED
|
@@ -113,7 +113,31 @@ if (config.oauth) {
|
|
|
113
113
|
logMemory('before-server');
|
|
114
114
|
// 5. Start server immediately (don't wait for backfill)
|
|
115
115
|
const collectionSet = new Set(collections);
|
|
116
|
-
|
|
116
|
+
const backfillOpts = {
|
|
117
|
+
pdsUrl: relayHttpUrl(config.relay),
|
|
118
|
+
plcUrl: config.plc,
|
|
119
|
+
collections: collectionSet,
|
|
120
|
+
config: config.backfill,
|
|
121
|
+
};
|
|
122
|
+
function runBackfillAndRestart() {
|
|
123
|
+
runBackfill(backfillOpts)
|
|
124
|
+
.then((recordCount) => {
|
|
125
|
+
log('[main] Backfill complete, rebuilding FTS indexes...');
|
|
126
|
+
return rebuildAllIndexes(collections).then(() => recordCount);
|
|
127
|
+
})
|
|
128
|
+
.then((recordCount) => {
|
|
129
|
+
log('[main] FTS indexes ready');
|
|
130
|
+
if (recordCount > 0) {
|
|
131
|
+
logMemory('after-backfill');
|
|
132
|
+
log('[main] Restarting to reclaim memory...');
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
.catch((err) => {
|
|
137
|
+
console.error('[main] Backfill error:', err.message);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
startServer(config.port, collections, config.publicDir, config.oauth, config.admins, undefined, runBackfillAndRestart);
|
|
117
141
|
log(`\nhatk running:`);
|
|
118
142
|
log(` Relay: ${config.relay}`);
|
|
119
143
|
log(` Database: ${config.database}`);
|
|
@@ -137,25 +161,7 @@ startIndexer({
|
|
|
137
161
|
ftsRebuildInterval: config.ftsRebuildInterval,
|
|
138
162
|
});
|
|
139
163
|
// 7. Run backfill in background
|
|
140
|
-
|
|
141
|
-
pdsUrl: relayHttpUrl(config.relay),
|
|
142
|
-
plcUrl: config.plc,
|
|
143
|
-
collections: collectionSet,
|
|
144
|
-
config: config.backfill,
|
|
145
|
-
})
|
|
146
|
-
.then(() => {
|
|
147
|
-
log('[main] Backfill complete, rebuilding FTS indexes...');
|
|
148
|
-
return rebuildAllIndexes(collections);
|
|
149
|
-
})
|
|
150
|
-
.then(() => {
|
|
151
|
-
log('[main] FTS indexes ready');
|
|
152
|
-
logMemory('after-backfill');
|
|
153
|
-
log('[main] Restarting to reclaim memory...');
|
|
154
|
-
process.exit(0);
|
|
155
|
-
})
|
|
156
|
-
.catch((err) => {
|
|
157
|
-
console.error('[main] Backfill error:', err.message);
|
|
158
|
-
});
|
|
164
|
+
runBackfillAndRestart();
|
|
159
165
|
// Graceful shutdown
|
|
160
166
|
process.on('SIGTERM', () => {
|
|
161
167
|
log('[main] Received SIGTERM, shutting down...');
|
package/dist/server.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { type Server, type IncomingMessage } from 'node:http';
|
|
|
2
2
|
import type { OAuthConfig } from './config.ts';
|
|
3
3
|
export declare function startServer(port: number, collections: string[], publicDir: string | null, oauth: OAuthConfig | null, admins?: string[], resolveViewer?: (req: IncomingMessage) => {
|
|
4
4
|
did: string;
|
|
5
|
-
} | null): Server;
|
|
5
|
+
} | null, onResync?: () => void): Server;
|
|
6
6
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAmD3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA2B9C,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,MAAM,GAAE,MAAM,EAAO,EACrB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAmD3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA2B9C,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,MAAM,GAAE,MAAM,EAAO,EACrB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAChE,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,MAAM,CA28BR"}
|
package/dist/server.js
CHANGED
|
@@ -39,7 +39,7 @@ function readBodyRaw(req) {
|
|
|
39
39
|
req.on('error', reject);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
export function startServer(port, collections, publicDir, oauth, admins = [], resolveViewer) {
|
|
42
|
+
export function startServer(port, collections, publicDir, oauth, admins = [], resolveViewer, onResync) {
|
|
43
43
|
const coreXrpc = (method) => `/xrpc/dev.hatk.${method}`;
|
|
44
44
|
const devMode = process.env.DEV_MODE === '1';
|
|
45
45
|
function requireAdmin(viewer, res) {
|
|
@@ -450,9 +450,10 @@ export function startServer(port, collections, publicDir, oauth, admins = [], re
|
|
|
450
450
|
}
|
|
451
451
|
for (const did of repoList) {
|
|
452
452
|
await setRepoStatus(did, 'pending');
|
|
453
|
-
triggerAutoBackfill(did);
|
|
454
453
|
}
|
|
455
454
|
jsonResponse(res, { resyncing: repoList.length });
|
|
455
|
+
if (onResync)
|
|
456
|
+
onResync();
|
|
456
457
|
return;
|
|
457
458
|
}
|
|
458
459
|
// POST /admin/repos/remove — remove DIDs from tracking
|