@hatk/hatk 0.0.1-alpha.2 → 0.0.1-alpha.20
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 +60 -1
- package/dist/backfill.d.ts.map +1 -1
- package/dist/backfill.js +154 -32
- package/dist/car.d.ts +59 -1
- package/dist/car.d.ts.map +1 -1
- package/dist/car.js +179 -7
- package/dist/cbor.d.ts +37 -0
- package/dist/cbor.d.ts.map +1 -1
- package/dist/cbor.js +36 -3
- package/dist/cid.d.ts +37 -0
- package/dist/cid.d.ts.map +1 -1
- package/dist/cid.js +38 -3
- package/dist/cli.js +75 -14
- package/dist/config.d.ts +3 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -9
- package/dist/db.d.ts +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +4 -38
- package/dist/fts.d.ts.map +1 -1
- package/dist/fts.js +5 -0
- package/dist/indexer.d.ts +1 -0
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +14 -2
- package/dist/main.js +42 -21
- package/dist/mst.d.ts +3 -1
- package/dist/mst.d.ts.map +1 -1
- package/dist/mst.js +6 -8
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +52 -8
- package/dist/test.js +4 -4
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +2 -1
- package/package.json +8 -2
- package/public/robots.txt +2 -0
package/dist/cbor.d.ts
CHANGED
|
@@ -1,7 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal CBOR (RFC 8949) decoder with DAG-CBOR CID support.
|
|
3
|
+
*
|
|
4
|
+
* Returns `{ value, offset }` so callers can decode concatenated CBOR values —
|
|
5
|
+
* the AT Protocol firehose sends frames as two back-to-back CBOR items
|
|
6
|
+
* (header + body).
|
|
7
|
+
*
|
|
8
|
+
* DAG-CBOR tag 42 (CID links) are decoded as `{ $link: "bafy..." }` objects,
|
|
9
|
+
* matching the convention used by the AT Protocol.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.rfc-editor.org/rfc/rfc8949 — CBOR spec
|
|
12
|
+
* @see https://ipld.io/specs/codecs/dag-cbor/spec/ — DAG-CBOR spec
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
1
15
|
interface DecodeResult {
|
|
16
|
+
/** The decoded JavaScript value. */
|
|
2
17
|
value: any;
|
|
18
|
+
/** Byte offset immediately after the decoded value — use as `startOffset` to decode the next item. */
|
|
3
19
|
offset: number;
|
|
4
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Decodes a single CBOR value from a byte array.
|
|
23
|
+
*
|
|
24
|
+
* Supports all major types: unsigned/negative integers, byte/text strings,
|
|
25
|
+
* arrays, maps, tags (with special handling for CID tag 42), and simple
|
|
26
|
+
* values (true, false, null).
|
|
27
|
+
*
|
|
28
|
+
* @param bytes - Raw CBOR bytes
|
|
29
|
+
* @param startOffset - Byte position to start decoding from (default `0`)
|
|
30
|
+
* @returns The decoded value and the offset of the next byte after it
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // Decode a single value
|
|
35
|
+
* const { value } = cborDecode(bytes)
|
|
36
|
+
*
|
|
37
|
+
* // Decode two concatenated values (firehose frame)
|
|
38
|
+
* const { value: header, offset } = cborDecode(frameBytes)
|
|
39
|
+
* const { value: body } = cborDecode(frameBytes, offset)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
5
42
|
export declare function cborDecode(bytes: Uint8Array, startOffset?: number): DecodeResult;
|
|
6
43
|
export {};
|
|
7
44
|
//# sourceMappingURL=cbor.d.ts.map
|
package/dist/cbor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../src/cbor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../src/cbor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,UAAU,YAAY;IACpB,oCAAoC;IACpC,KAAK,EAAE,GAAG,CAAA;IACV,sGAAsG;IACtG,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,SAAI,GAAG,YAAY,CAgF3E"}
|
package/dist/cbor.js
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Minimal CBOR (RFC 8949) decoder with DAG-CBOR CID support.
|
|
3
|
+
*
|
|
4
|
+
* Returns `{ value, offset }` so callers can decode concatenated CBOR values —
|
|
5
|
+
* the AT Protocol firehose sends frames as two back-to-back CBOR items
|
|
6
|
+
* (header + body).
|
|
7
|
+
*
|
|
8
|
+
* DAG-CBOR tag 42 (CID links) are decoded as `{ $link: "bafy..." }` objects,
|
|
9
|
+
* matching the convention used by the AT Protocol.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.rfc-editor.org/rfc/rfc8949 — CBOR spec
|
|
12
|
+
* @see https://ipld.io/specs/codecs/dag-cbor/spec/ — DAG-CBOR spec
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
4
15
|
import { cidToString } from "./cid.js";
|
|
16
|
+
/** CBOR tag number for DAG-CBOR CID links. */
|
|
5
17
|
const CBOR_TAG_CID = 42;
|
|
18
|
+
/**
|
|
19
|
+
* Decodes a single CBOR value from a byte array.
|
|
20
|
+
*
|
|
21
|
+
* Supports all major types: unsigned/negative integers, byte/text strings,
|
|
22
|
+
* arrays, maps, tags (with special handling for CID tag 42), and simple
|
|
23
|
+
* values (true, false, null).
|
|
24
|
+
*
|
|
25
|
+
* @param bytes - Raw CBOR bytes
|
|
26
|
+
* @param startOffset - Byte position to start decoding from (default `0`)
|
|
27
|
+
* @returns The decoded value and the offset of the next byte after it
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // Decode a single value
|
|
32
|
+
* const { value } = cborDecode(bytes)
|
|
33
|
+
*
|
|
34
|
+
* // Decode two concatenated values (firehose frame)
|
|
35
|
+
* const { value: header, offset } = cborDecode(frameBytes)
|
|
36
|
+
* const { value: body } = cborDecode(frameBytes, offset)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
6
39
|
export function cborDecode(bytes, startOffset = 0) {
|
|
7
40
|
let offset = startOffset;
|
|
8
41
|
function read() {
|
package/dist/cid.d.ts
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CID (Content Identifier), base32, and varint primitives.
|
|
3
|
+
*
|
|
4
|
+
* CIDs are self-describing content hashes used throughout the AT Protocol
|
|
5
|
+
* to reference blocks in repos and CAR files. This module provides the
|
|
6
|
+
* low-level encoding needed to convert raw CID bytes into their string
|
|
7
|
+
* representation (base32lower with `b` multibase prefix).
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/multiformats/cid
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Encodes raw bytes as a base32 lowercase string (RFC 4648, no padding).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* base32Encode(new Uint8Array([0x01, 0x71])) // "afyq"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
1
20
|
export declare function base32Encode(bytes: Uint8Array): string;
|
|
21
|
+
/**
|
|
22
|
+
* Converts raw CID bytes to their multibase-encoded string form (`b` prefix + base32lower).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* cidToString(cidBytes) // "bafyreig..."
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
2
29
|
export declare function cidToString(cidBytes: Uint8Array): string;
|
|
30
|
+
/**
|
|
31
|
+
* Reads an unsigned LEB128 varint from a byte array.
|
|
32
|
+
*
|
|
33
|
+
* Varints are used extensively in CID encoding and CAR framing to represent
|
|
34
|
+
* variable-length integers in a compact form.
|
|
35
|
+
*
|
|
36
|
+
* @param bytes - Source byte array
|
|
37
|
+
* @param offset - Position to start reading from
|
|
38
|
+
* @returns A tuple of `[value, nextOffset]`
|
|
39
|
+
*/
|
|
3
40
|
export declare function readVarint(bytes: Uint8Array, offset: number): [number, number];
|
|
4
41
|
//# sourceMappingURL=cid.d.ts.map
|
package/dist/cid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../src/cid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../src/cid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAmBtD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAc9E"}
|
package/dist/cid.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CID (Content Identifier), base32, and varint primitives.
|
|
3
|
+
*
|
|
4
|
+
* CIDs are self-describing content hashes used throughout the AT Protocol
|
|
5
|
+
* to reference blocks in repos and CAR files. This module provides the
|
|
6
|
+
* low-level encoding needed to convert raw CID bytes into their string
|
|
7
|
+
* representation (base32lower with `b` multibase prefix).
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/multiformats/cid
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** RFC 4648 base32 lowercase alphabet (no padding). */
|
|
3
13
|
const BASE32_ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567';
|
|
14
|
+
/**
|
|
15
|
+
* Encodes raw bytes as a base32 lowercase string (RFC 4648, no padding).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* base32Encode(new Uint8Array([0x01, 0x71])) // "afyq"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
4
22
|
export function base32Encode(bytes) {
|
|
5
23
|
let result = '';
|
|
6
24
|
let bits = 0;
|
|
@@ -18,10 +36,27 @@ export function base32Encode(bytes) {
|
|
|
18
36
|
}
|
|
19
37
|
return result;
|
|
20
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts raw CID bytes to their multibase-encoded string form (`b` prefix + base32lower).
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* cidToString(cidBytes) // "bafyreig..."
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
21
47
|
export function cidToString(cidBytes) {
|
|
22
|
-
// base32lower with 'b' multibase prefix
|
|
23
48
|
return `b${base32Encode(cidBytes)}`;
|
|
24
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Reads an unsigned LEB128 varint from a byte array.
|
|
52
|
+
*
|
|
53
|
+
* Varints are used extensively in CID encoding and CAR framing to represent
|
|
54
|
+
* variable-length integers in a compact form.
|
|
55
|
+
*
|
|
56
|
+
* @param bytes - Source byte array
|
|
57
|
+
* @param offset - Position to start reading from
|
|
58
|
+
* @returns A tuple of `[value, nextOffset]`
|
|
59
|
+
*/
|
|
25
60
|
export function readVarint(bytes, offset) {
|
|
26
61
|
let value = 0;
|
|
27
62
|
let shift = 0;
|
package/dist/cli.js
CHANGED
|
@@ -364,14 +364,18 @@ if (command === 'new') {
|
|
|
364
364
|
for (const sub of subs) {
|
|
365
365
|
mkdirSync(join(dir, sub));
|
|
366
366
|
}
|
|
367
|
-
writeFileSync(join(dir, 'config.
|
|
368
|
-
plc: http://localhost:2582
|
|
369
|
-
port: 3000
|
|
370
|
-
database: data/hatk.db
|
|
371
|
-
admins: []
|
|
367
|
+
writeFileSync(join(dir, 'hatk.config.ts'), `import { defineConfig } from '@hatk/hatk/config'
|
|
372
368
|
|
|
373
|
-
|
|
374
|
-
|
|
369
|
+
export default defineConfig({
|
|
370
|
+
relay: 'ws://localhost:2583',
|
|
371
|
+
plc: 'http://localhost:2582',
|
|
372
|
+
port: 3000,
|
|
373
|
+
database: 'data/hatk.db',
|
|
374
|
+
admins: [],
|
|
375
|
+
backfill: {
|
|
376
|
+
parallelism: 10,
|
|
377
|
+
},
|
|
378
|
+
})
|
|
375
379
|
`);
|
|
376
380
|
writeFileSync(join(dir, 'public', 'index.html'), `<!DOCTYPE html>
|
|
377
381
|
<html><head><title>${name}</title></head>
|
|
@@ -591,6 +595,53 @@ backfill:
|
|
|
591
595
|
},
|
|
592
596
|
},
|
|
593
597
|
}, null, 2) + '\n');
|
|
598
|
+
writeFileSync(join(coreLexDir, 'getPreferences.json'), JSON.stringify({
|
|
599
|
+
lexicon: 1,
|
|
600
|
+
id: 'dev.hatk.getPreferences',
|
|
601
|
+
defs: {
|
|
602
|
+
main: {
|
|
603
|
+
type: 'query',
|
|
604
|
+
description: 'Get all preferences for the authenticated user.',
|
|
605
|
+
output: {
|
|
606
|
+
encoding: 'application/json',
|
|
607
|
+
schema: {
|
|
608
|
+
type: 'object',
|
|
609
|
+
properties: {
|
|
610
|
+
preferences: { type: 'unknown' },
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
}, null, 2) + '\n');
|
|
617
|
+
writeFileSync(join(coreLexDir, 'putPreference.json'), JSON.stringify({
|
|
618
|
+
lexicon: 1,
|
|
619
|
+
id: 'dev.hatk.putPreference',
|
|
620
|
+
defs: {
|
|
621
|
+
main: {
|
|
622
|
+
type: 'procedure',
|
|
623
|
+
description: 'Set a single preference by key.',
|
|
624
|
+
input: {
|
|
625
|
+
encoding: 'application/json',
|
|
626
|
+
schema: {
|
|
627
|
+
type: 'object',
|
|
628
|
+
required: ['key', 'value'],
|
|
629
|
+
properties: {
|
|
630
|
+
key: { type: 'string' },
|
|
631
|
+
value: { type: 'unknown' },
|
|
632
|
+
},
|
|
633
|
+
},
|
|
634
|
+
},
|
|
635
|
+
output: {
|
|
636
|
+
encoding: 'application/json',
|
|
637
|
+
schema: {
|
|
638
|
+
type: 'object',
|
|
639
|
+
properties: {},
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
}, null, 2) + '\n');
|
|
594
645
|
writeFileSync(join(coreLexDir, 'getFeed.json'), JSON.stringify({
|
|
595
646
|
lexicon: 1,
|
|
596
647
|
id: 'dev.hatk.getFeed',
|
|
@@ -611,6 +662,7 @@ backfill:
|
|
|
611
662
|
encoding: 'application/json',
|
|
612
663
|
schema: {
|
|
613
664
|
type: 'object',
|
|
665
|
+
required: ['items'],
|
|
614
666
|
properties: {
|
|
615
667
|
items: { type: 'array', items: { type: 'unknown' } },
|
|
616
668
|
cursor: { type: 'string' },
|
|
@@ -668,6 +720,7 @@ backfill:
|
|
|
668
720
|
encoding: 'application/json',
|
|
669
721
|
schema: {
|
|
670
722
|
type: 'object',
|
|
723
|
+
required: ['items'],
|
|
671
724
|
properties: {
|
|
672
725
|
items: { type: 'array', items: { type: 'unknown' } },
|
|
673
726
|
cursor: { type: 'string' },
|
|
@@ -699,6 +752,7 @@ backfill:
|
|
|
699
752
|
encoding: 'application/json',
|
|
700
753
|
schema: {
|
|
701
754
|
type: 'object',
|
|
755
|
+
required: ['items'],
|
|
702
756
|
properties: {
|
|
703
757
|
items: { type: 'array', items: { type: 'unknown' } },
|
|
704
758
|
cursor: { type: 'string' },
|
|
@@ -793,11 +847,12 @@ public
|
|
|
793
847
|
writeFileSync(join(dir, 'Dockerfile'), `FROM node:25-slim
|
|
794
848
|
WORKDIR /app
|
|
795
849
|
COPY package.json package-lock.json ./
|
|
796
|
-
RUN npm ci
|
|
850
|
+
RUN npm ci
|
|
797
851
|
COPY . .
|
|
798
852
|
RUN node_modules/.bin/hatk build
|
|
853
|
+
RUN npm prune --omit=dev
|
|
799
854
|
EXPOSE 3000
|
|
800
|
-
CMD ["node", "--
|
|
855
|
+
CMD ["node", "--experimental-strip-types", "--max-old-space-size=512", "node_modules/@hatk/hatk/dist/main.js", "hatk.config.ts"]
|
|
801
856
|
`);
|
|
802
857
|
const pkgDeps = { '@hatk/oauth-client': '*', hatk: '*' };
|
|
803
858
|
const pkgDevDeps = {
|
|
@@ -807,6 +862,7 @@ CMD ["node", "--no-warnings", "node_modules/@hatk/hatk/dist/main.js", "config.ya
|
|
|
807
862
|
typescript: '^5',
|
|
808
863
|
vite: '^6',
|
|
809
864
|
vitest: '^4',
|
|
865
|
+
'@types/node': '^22',
|
|
810
866
|
};
|
|
811
867
|
if (withSvelte) {
|
|
812
868
|
pkgDevDeps['@sveltejs/adapter-static'] = '^3';
|
|
@@ -926,6 +982,7 @@ export default defineConfig({
|
|
|
926
982
|
<head>
|
|
927
983
|
<meta charset="utf-8" />
|
|
928
984
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
985
|
+
<meta name="description" content="${name}" />
|
|
929
986
|
<title>${name}</title>
|
|
930
987
|
%sveltekit.head%
|
|
931
988
|
</head>
|
|
@@ -1026,7 +1083,7 @@ a {
|
|
|
1026
1083
|
`);
|
|
1027
1084
|
}
|
|
1028
1085
|
console.log(`Created ${name}/`);
|
|
1029
|
-
console.log(` config.
|
|
1086
|
+
console.log(` hatk.config.ts`);
|
|
1030
1087
|
console.log(` lexicons/ — lexicon JSON files (core + your own)`);
|
|
1031
1088
|
console.log(` feeds/ — feed generators`);
|
|
1032
1089
|
console.log(` xrpc/ — XRPC method handlers`);
|
|
@@ -1437,7 +1494,11 @@ else if (command === 'dev') {
|
|
|
1437
1494
|
else {
|
|
1438
1495
|
// No frontend — just run the hatk server directly
|
|
1439
1496
|
const mainPath = resolve(import.meta.dirname, 'main.js');
|
|
1440
|
-
execSync(`npx tsx ${mainPath} config.
|
|
1497
|
+
execSync(`npx tsx ${mainPath} hatk.config.ts`, {
|
|
1498
|
+
stdio: 'inherit',
|
|
1499
|
+
cwd: process.cwd(),
|
|
1500
|
+
env: { ...process.env, DEV_MODE: '1' },
|
|
1501
|
+
});
|
|
1441
1502
|
}
|
|
1442
1503
|
}
|
|
1443
1504
|
catch (e) {
|
|
@@ -1463,7 +1524,7 @@ else if (command === 'build') {
|
|
|
1463
1524
|
}
|
|
1464
1525
|
}
|
|
1465
1526
|
else if (command === 'reset') {
|
|
1466
|
-
const config = loadConfig(resolve('config.
|
|
1527
|
+
const config = await loadConfig(resolve('hatk.config.ts'));
|
|
1467
1528
|
if (config.database !== ':memory:') {
|
|
1468
1529
|
for (const suffix of ['', '.wal']) {
|
|
1469
1530
|
const file = config.database + suffix;
|
|
@@ -1623,7 +1684,7 @@ else if (command === 'resolve') {
|
|
|
1623
1684
|
execSync('npx hatk generate types', { stdio: 'inherit', cwd: process.cwd() });
|
|
1624
1685
|
}
|
|
1625
1686
|
else if (command === 'schema') {
|
|
1626
|
-
const config = loadConfig(resolve('config.
|
|
1687
|
+
const config = await loadConfig(resolve('hatk.config.ts'));
|
|
1627
1688
|
if (config.database === ':memory:') {
|
|
1628
1689
|
console.error('No database file configured (database is :memory:)');
|
|
1629
1690
|
process.exit(1);
|
|
@@ -1650,7 +1711,7 @@ else if (command === 'schema') {
|
|
|
1650
1711
|
else if (command === 'start') {
|
|
1651
1712
|
try {
|
|
1652
1713
|
const mainPath = resolve(import.meta.dirname, 'main.js');
|
|
1653
|
-
execSync(`npx tsx ${mainPath} config.
|
|
1714
|
+
execSync(`npx tsx ${mainPath} hatk.config.ts`, { stdio: 'inherit', cwd: process.cwd() });
|
|
1654
1715
|
}
|
|
1655
1716
|
catch (e) {
|
|
1656
1717
|
if (e.signal === 'SIGINT' || e.signal === 'SIGTERM')
|
package/dist/config.d.ts
CHANGED
|
@@ -41,7 +41,9 @@ export interface HatkConfig {
|
|
|
41
41
|
oauth: OAuthConfig | null;
|
|
42
42
|
admins: string[];
|
|
43
43
|
}
|
|
44
|
+
/** Identity function that provides type inference for hatk config files. */
|
|
45
|
+
export declare function defineConfig(config: Partial<HatkConfig>): Partial<HatkConfig>;
|
|
44
46
|
/** Derive HTTP URL from relay WebSocket URL (ws://host → http://host) */
|
|
45
47
|
export declare function relayHttpUrl(relay: string): string;
|
|
46
|
-
export declare function loadConfig(configPath: string): HatkConfig
|
|
48
|
+
export declare function loadConfig(configPath: string): Promise<HatkConfig>;
|
|
47
49
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACrC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;IACnC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC1C,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,WAAW,EAAE,OAAO,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,QAAQ,EAAE,cAAc,CAAA;IACxB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAE7E;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAuDxE"}
|
package/dist/config.js
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
2
9
|
import { resolve, dirname } from 'node:path';
|
|
3
|
-
import
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
/** Identity function that provides type inference for hatk config files. */
|
|
12
|
+
export function defineConfig(config) {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
4
15
|
/** Derive HTTP URL from relay WebSocket URL (ws://host → http://host) */
|
|
5
16
|
export function relayHttpUrl(relay) {
|
|
6
17
|
return relay.replace(/^ws(s?):\/\//, 'http$1://');
|
|
7
18
|
}
|
|
8
|
-
export function loadConfig(configPath) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
export async function loadConfig(configPath) {
|
|
20
|
+
const resolved = resolve(configPath);
|
|
21
|
+
if (!existsSync(resolved)) {
|
|
22
|
+
console.error(`Config file not found: ${resolved}`);
|
|
23
|
+
console.error(`hatk now uses hatk.config.ts instead of config.yaml.`);
|
|
24
|
+
console.error(`Create a hatk.config.ts file or run 'hatk new' to scaffold a project.`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const configDir = dirname(resolved);
|
|
28
|
+
let mod;
|
|
29
|
+
try {
|
|
30
|
+
mod = await import(__rewriteRelativeImportExtension(resolved));
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
console.error(`Failed to load config file: ${resolved}`);
|
|
34
|
+
console.error(err.message || err);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const parsed = mod.default || {};
|
|
12
38
|
const backfillRaw = parsed.backfill || {};
|
|
13
39
|
const env = process.env;
|
|
14
40
|
const database = env.DATABASE || parsed.database;
|
|
@@ -17,17 +43,17 @@ export function loadConfig(configPath) {
|
|
|
17
43
|
plc: env.DID_PLC_URL || parsed.plc || 'https://plc.directory',
|
|
18
44
|
port: parseInt(env.PORT || '') || parsed.port || 3000,
|
|
19
45
|
database: database ? resolve(configDir, database) : ':memory:',
|
|
20
|
-
publicDir: parsed.
|
|
46
|
+
publicDir: parsed.publicDir === null ? null : resolve(configDir, parsed.publicDir || './public'),
|
|
21
47
|
collections: parsed.collections || [],
|
|
22
48
|
backfill: {
|
|
23
49
|
signalCollections: backfillRaw.signalCollections || undefined,
|
|
24
50
|
repos: env.BACKFILL_REPOS ? env.BACKFILL_REPOS.split(',').map((s) => s.trim()) : backfillRaw.repos || undefined,
|
|
25
51
|
fullNetwork: env.BACKFILL_FULL_NETWORK ? env.BACKFILL_FULL_NETWORK === 'true' : backfillRaw.fullNetwork || false,
|
|
26
|
-
parallelism: parseInt(env.BACKFILL_PARALLELISM || '') || backfillRaw.parallelism ||
|
|
52
|
+
parallelism: parseInt(env.BACKFILL_PARALLELISM || '') || backfillRaw.parallelism || 3,
|
|
27
53
|
fetchTimeout: parseInt(env.BACKFILL_FETCH_TIMEOUT || '') || backfillRaw.fetchTimeout || 300,
|
|
28
54
|
maxRetries: parseInt(env.BACKFILL_MAX_RETRIES || '') || backfillRaw.maxRetries || 5,
|
|
29
55
|
},
|
|
30
|
-
ftsRebuildInterval: parseInt(env.FTS_REBUILD_INTERVAL || '') || parsed.ftsRebuildInterval ||
|
|
56
|
+
ftsRebuildInterval: parseInt(env.FTS_REBUILD_INTERVAL || '') || parsed.ftsRebuildInterval || 5000,
|
|
31
57
|
oauth: null,
|
|
32
58
|
admins: env.ADMINS ? env.ADMINS.split(',').map((s) => s.trim()) : parsed.admins || [],
|
|
33
59
|
};
|
package/dist/db.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function setRepoStatus(did: string, status: string, rev?: string,
|
|
|
14
14
|
retryAfter?: number;
|
|
15
15
|
handle?: string | null;
|
|
16
16
|
}): Promise<void>;
|
|
17
|
+
export declare function getRepoRev(did: string): Promise<string | null>;
|
|
17
18
|
export declare function getRepoRetryInfo(did: string): Promise<{
|
|
18
19
|
retryCount: number;
|
|
19
20
|
retryAfter: number;
|
|
@@ -129,6 +130,5 @@ export declare function isTakendownDid(did: string): Promise<boolean>;
|
|
|
129
130
|
export declare function getPreferences(did: string): Promise<Record<string, any>>;
|
|
130
131
|
export declare function putPreference(did: string, key: string, value: any): Promise<void>;
|
|
131
132
|
export declare function filterTakendownDids(dids: string[]): Promise<Set<string>>;
|
|
132
|
-
export declare function backfillChildTables(): Promise<void>;
|
|
133
133
|
export {};
|
|
134
134
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAUzC,wBAAgB,aAAa,IAAI,IAAI,CAUpC;AA+DD,wBAAsB,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB/F;AAiBD,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,WAAW,EAAE,EAC3B,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,IAAI,CAAC,CAiEf;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGnE;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,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,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAW9E;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvF;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAK9E"}
|
package/dist/db.js
CHANGED
|
@@ -200,6 +200,10 @@ export async function setRepoStatus(did, status, rev, opts) {
|
|
|
200
200
|
await run(`INSERT OR IGNORE INTO _repos (did, status) VALUES ($1, $2)`, did, status);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
+
export async function getRepoRev(did) {
|
|
204
|
+
const rows = await all(`SELECT rev FROM _repos WHERE did = $1`, did);
|
|
205
|
+
return rows[0]?.rev ?? null;
|
|
206
|
+
}
|
|
203
207
|
export async function getRepoRetryInfo(did) {
|
|
204
208
|
const rows = await all(`SELECT retry_count, retry_after FROM _repos WHERE did = $1`, did);
|
|
205
209
|
if (rows.length === 0)
|
|
@@ -1321,41 +1325,3 @@ export async function filterTakendownDids(dids) {
|
|
|
1321
1325
|
const rows = await all(`SELECT did FROM _repos WHERE did IN (${placeholders}) AND status = 'takendown'`, ...dids);
|
|
1322
1326
|
return new Set(rows.map((r) => r.did));
|
|
1323
1327
|
}
|
|
1324
|
-
export async function backfillChildTables() {
|
|
1325
|
-
for (const [, schema] of schemas) {
|
|
1326
|
-
for (const child of schema.children) {
|
|
1327
|
-
// Check if child table needs backfill (significantly fewer rows than parent)
|
|
1328
|
-
const mainCount = (await all(`SELECT COUNT(*)::INTEGER as n FROM ${schema.tableName}`))[0]?.n || 0;
|
|
1329
|
-
if (mainCount === 0)
|
|
1330
|
-
continue;
|
|
1331
|
-
const childCount = (await all(`SELECT COUNT(DISTINCT parent_uri)::INTEGER as n FROM ${child.tableName}`))[0]?.n || 0;
|
|
1332
|
-
if (childCount >= mainCount * 0.9)
|
|
1333
|
-
continue;
|
|
1334
|
-
console.log(`[db] Backfilling ${child.tableName} from ${schema.tableName}...`);
|
|
1335
|
-
const snakeField = toSnakeCase(child.fieldName);
|
|
1336
|
-
const childColSelects = child.columns
|
|
1337
|
-
.map((c) => `json_extract_string(item.val, '$.${c.originalName}')`)
|
|
1338
|
-
.join(', ');
|
|
1339
|
-
const childColNames = ['parent_uri', 'parent_did', ...child.columns.map((c) => c.name)];
|
|
1340
|
-
const notNullFilters = child.columns
|
|
1341
|
-
.filter((c) => c.notNull)
|
|
1342
|
-
.map((c) => `json_extract_string(item.val, '$.${c.originalName}') IS NOT NULL`);
|
|
1343
|
-
const whereClause = [`p.${snakeField} IS NOT NULL`, ...notNullFilters].join(' AND ');
|
|
1344
|
-
try {
|
|
1345
|
-
await run(`DELETE FROM ${child.tableName}`);
|
|
1346
|
-
await run(`
|
|
1347
|
-
INSERT INTO ${child.tableName} (${childColNames.join(', ')})
|
|
1348
|
-
SELECT p.uri, p.did, ${childColSelects}
|
|
1349
|
-
FROM ${schema.tableName} p,
|
|
1350
|
-
unnest(from_json(p.${snakeField}::JSON, '["json"]')) AS item(val)
|
|
1351
|
-
WHERE ${whereClause}
|
|
1352
|
-
`);
|
|
1353
|
-
const result = await all(`SELECT COUNT(*)::INTEGER as n FROM ${child.tableName}`);
|
|
1354
|
-
console.log(`[db] Backfilled ${child.tableName}: ${result[0]?.n || 0} rows`);
|
|
1355
|
-
}
|
|
1356
|
-
catch (err) {
|
|
1357
|
-
console.warn(`[db] Backfill skipped for ${child.tableName}: ${err.message}`);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
}
|
package/dist/fts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fts.d.ts","sourceRoot":"","sources":["../src/fts.ts"],"names":[],"mappings":"AAwEA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FrE;AAokBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"fts.d.ts","sourceRoot":"","sources":["../src/fts.ts"],"names":[],"mappings":"AAwEA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FrE;AAokBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B5E"}
|
package/dist/fts.js
CHANGED
|
@@ -752,6 +752,11 @@ export async function rebuildAllIndexes(collections) {
|
|
|
752
752
|
errors.push(`${collection}: ${err.message}`);
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
+
// Compact WAL to free DuckDB memory after heavy FTS operations
|
|
756
|
+
try {
|
|
757
|
+
await runSQL('CHECKPOINT');
|
|
758
|
+
}
|
|
759
|
+
catch { }
|
|
755
760
|
emit('fts', 'rebuild', {
|
|
756
761
|
collections_total: collections.length,
|
|
757
762
|
collections_rebuilt: rebuilt,
|
package/dist/indexer.d.ts
CHANGED
package/dist/indexer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAmIA,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAgEjF;AAED,UAAU,WAAW;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACxB,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAyBD,wBAAsB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAmDxE"}
|
package/dist/indexer.js
CHANGED
|
@@ -18,7 +18,7 @@ let ftsRebuildInterval = 500;
|
|
|
18
18
|
const pendingBuffers = new Map();
|
|
19
19
|
// Track in-flight backfills to avoid duplicates
|
|
20
20
|
const backfillInFlight = new Set();
|
|
21
|
-
const
|
|
21
|
+
const pendingReschedule = new Set();
|
|
22
22
|
// In-memory cache of repo status to avoid flooding the DB read queue
|
|
23
23
|
const repoStatusCache = new Map();
|
|
24
24
|
// Set by startIndexer
|
|
@@ -27,6 +27,7 @@ let indexerSignalCollections;
|
|
|
27
27
|
let indexerPinnedRepos = null;
|
|
28
28
|
let indexerFetchTimeout;
|
|
29
29
|
let indexerMaxRetries;
|
|
30
|
+
let maxConcurrentBackfills = 3;
|
|
30
31
|
async function flushBuffer() {
|
|
31
32
|
if (buffer.length === 0)
|
|
32
33
|
return;
|
|
@@ -113,6 +114,16 @@ function bufferWrite(item) {
|
|
|
113
114
|
export async function triggerAutoBackfill(did, attempt = 0) {
|
|
114
115
|
if (backfillInFlight.has(did))
|
|
115
116
|
return;
|
|
117
|
+
if (backfillInFlight.size >= maxConcurrentBackfills) {
|
|
118
|
+
if (!pendingReschedule.has(did)) {
|
|
119
|
+
pendingReschedule.add(did);
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
pendingReschedule.delete(did);
|
|
122
|
+
triggerAutoBackfill(did, attempt);
|
|
123
|
+
}, 10_000);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
116
127
|
backfillInFlight.add(did);
|
|
117
128
|
pendingBuffers.set(did, []);
|
|
118
129
|
if (attempt === 0)
|
|
@@ -193,6 +204,7 @@ export async function startIndexer(opts) {
|
|
|
193
204
|
indexerPinnedRepos = opts.pinnedRepos || null;
|
|
194
205
|
indexerFetchTimeout = fetchTimeout;
|
|
195
206
|
indexerMaxRetries = opts.maxRetries;
|
|
207
|
+
maxConcurrentBackfills = opts.parallelism ?? 3;
|
|
196
208
|
// Pre-populate repo status cache from DB so non-signal updates
|
|
197
209
|
// (e.g. profile changes) are processed for already-tracked DIDs
|
|
198
210
|
if (repoStatusCache.size === 0) {
|
|
@@ -264,7 +276,7 @@ function processMessage(bytes, collections) {
|
|
|
264
276
|
repoStatusCache.set(did, 'unknown');
|
|
265
277
|
}
|
|
266
278
|
if (hasSignalOp && (!indexerPinnedRepos || indexerPinnedRepos.has(did))) {
|
|
267
|
-
if (repoStatus === null && backfillInFlight.size <
|
|
279
|
+
if (repoStatus === null && backfillInFlight.size < maxConcurrentBackfills) {
|
|
268
280
|
repoStatusCache.set(did, 'pending');
|
|
269
281
|
triggerAutoBackfill(did);
|
|
270
282
|
}
|