@hatk/hatk 0.0.1-alpha.89 → 0.0.1-alpha.90
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/dev-entry.d.ts.map +1 -1
- package/dist/dev-entry.js +2 -1
- package/dist/indexer.d.ts +10 -0
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +37 -0
- package/dist/main.js +4 -1
- package/package.json +1 -1
package/dist/dev-entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-entry.d.ts","sourceRoot":"","sources":["../src/dev-entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev-entry.d.ts","sourceRoot":"","sources":["../src/dev-entry.ts"],"names":[],"mappings":"AAiIA,eAAO,MAAM,OAAO,yCAKlB,CAAA;AAEF,yEAAyE;AACzE,wBAAsB,YAAY,kBAEjC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/dev-entry.js
CHANGED
|
@@ -14,7 +14,7 @@ import { initOAuth } from "./oauth/server.js";
|
|
|
14
14
|
import { initServer } from "./server-init.js";
|
|
15
15
|
import { createHandler, registerCoreHandlers } from "./server.js";
|
|
16
16
|
import { setPrivateCollections } from "./private-collections.js";
|
|
17
|
-
import { auxCursorKey, startAuxIndexer, startIndexer } from "./indexer.js";
|
|
17
|
+
import { auxCursorKey, startAuxIndexer, startIndexer, sweepReferences } from "./indexer.js";
|
|
18
18
|
import { getCursor } from "./database/db.js";
|
|
19
19
|
import { runBackfill, configurePlc } from "./backfill.js";
|
|
20
20
|
import { rebuildAllIndexes } from "./database/fts.js";
|
|
@@ -91,6 +91,7 @@ startIndexer({
|
|
|
91
91
|
parallelism: config.backfill.parallelism,
|
|
92
92
|
ftsRebuildInterval: config.ftsRebuildInterval,
|
|
93
93
|
});
|
|
94
|
+
void sweepReferences();
|
|
94
95
|
for (const relayUrl of config.relays) {
|
|
95
96
|
const auxCursor = ignoreSavedCursor ? null : await getCursor(auxCursorKey(relayUrl));
|
|
96
97
|
startAuxIndexer({ relayUrl, collections: collectionSet, cursor: auxCursor });
|
package/dist/indexer.d.ts
CHANGED
|
@@ -58,6 +58,16 @@ export declare function awaitBackfill(did: string): Promise<void>;
|
|
|
58
58
|
* with it.
|
|
59
59
|
*/
|
|
60
60
|
export declare function noteReferencedRepos(collection: string, rkey: string, record: Record<string, unknown>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Apply the references to what is already indexed.
|
|
63
|
+
*
|
|
64
|
+
* A reference fires as a record comes in. Rows indexed before the reference
|
|
65
|
+
* was configured — or before this instance had it — would otherwise never
|
|
66
|
+
* name their repos until the record was written again. Run once at boot;
|
|
67
|
+
* a table of a few thousand rows is a moment, and the roster is what these
|
|
68
|
+
* point at, not the firehose.
|
|
69
|
+
*/
|
|
70
|
+
export declare function sweepReferences(): Promise<number>;
|
|
61
71
|
export declare function trackRepo(did: string): void;
|
|
62
72
|
export declare function triggerAutoBackfill(did: string, attempt?: number): Promise<void>;
|
|
63
73
|
/**
|
package/dist/indexer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AA+ChD,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,QAAQ,GAAG,QAAQ,G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C,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CvG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAE3F;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,CAmE9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,KAAK,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAc,GACrC,IAAI,CAoDN"}
|
package/dist/indexer.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { reshapeRow } from "./database/db.js";
|
|
2
|
+
import { unfilteredQuerySQL } from "./spaces/guard.js";
|
|
3
|
+
import { rkeyOf } from "./spaces/uri.js";
|
|
1
4
|
import { cborDecode } from "./cbor.js";
|
|
2
5
|
import { parseCarFrame } from "./car.js";
|
|
3
6
|
import { isPrivateCollection } from "./private-collections.js";
|
|
@@ -298,6 +301,40 @@ export function noteReferencedRepos(collection, rkey, record) {
|
|
|
298
301
|
trackRepo(did);
|
|
299
302
|
}
|
|
300
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Apply the references to what is already indexed.
|
|
306
|
+
*
|
|
307
|
+
* A reference fires as a record comes in. Rows indexed before the reference
|
|
308
|
+
* was configured — or before this instance had it — would otherwise never
|
|
309
|
+
* name their repos until the record was written again. Run once at boot;
|
|
310
|
+
* a table of a few thousand rows is a moment, and the roster is what these
|
|
311
|
+
* point at, not the firehose.
|
|
312
|
+
*/
|
|
313
|
+
export async function sweepReferences() {
|
|
314
|
+
let named = 0;
|
|
315
|
+
for (const ref of indexerReferences) {
|
|
316
|
+
let rows;
|
|
317
|
+
try {
|
|
318
|
+
rows = await unfilteredQuerySQL(`SELECT * FROM "${ref.collection}"`);
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
continue; // no table for this collection on this instance
|
|
322
|
+
}
|
|
323
|
+
for (const raw of rows) {
|
|
324
|
+
const row = reshapeRow(raw);
|
|
325
|
+
if (!row)
|
|
326
|
+
continue;
|
|
327
|
+
const did = referencedDid(row.value, rkeyOf(row.uri), ref.field);
|
|
328
|
+
if (!did)
|
|
329
|
+
continue;
|
|
330
|
+
named++;
|
|
331
|
+
trackRepo(did);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (named > 0)
|
|
335
|
+
emit('indexer', 'references_swept', { named });
|
|
336
|
+
return named;
|
|
337
|
+
}
|
|
301
338
|
export function trackRepo(did) {
|
|
302
339
|
if (indexerPinnedRepos && !indexerPinnedRepos.has(did))
|
|
303
340
|
return;
|
package/dist/main.js
CHANGED
|
@@ -22,7 +22,7 @@ import { initFeeds, listFeeds } from "./feeds.js";
|
|
|
22
22
|
import { initXrpc, listXrpc, configureRelay, configureCdn, configureOAuth, callXrpc } from "./xrpc.js";
|
|
23
23
|
import { initOpengraph } from "./opengraph.js";
|
|
24
24
|
import { initLabels, getLabelDefinitions } from "./labels.js";
|
|
25
|
-
import { auxCursorKey, startAuxIndexer, startIndexer } from "./indexer.js";
|
|
25
|
+
import { auxCursorKey, startAuxIndexer, startIndexer, sweepReferences } from "./indexer.js";
|
|
26
26
|
import { startJetstreamIndexer } from "./jetstream.js";
|
|
27
27
|
import { rebuildAllIndexes } from "./database/fts.js";
|
|
28
28
|
import { createHandler, registerCoreHandlers } from "./server.js";
|
|
@@ -248,6 +248,9 @@ else {
|
|
|
248
248
|
startAuxIndexer({ relayUrl, collections: collectionSet, cursor: auxCursor });
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
+
// What is already indexed may name repos too; a reference configured after
|
|
252
|
+
// the fact reaches them here rather than on their next write.
|
|
253
|
+
void sweepReferences();
|
|
251
254
|
// 7. Run backfill in background
|
|
252
255
|
runBackfillAndRestart();
|
|
253
256
|
// 8. Follow permissioned spaces, if this instance indexes any. Started after
|