@hatk/hatk 0.0.1-alpha.6 → 0.0.1-alpha.8
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.map +1 -1
- package/dist/backfill.js +26 -18
- package/dist/cli.js +1 -1
- package/package.json +1 -1
package/dist/backfill.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../src/backfill.ts"],"names":[],"mappings":"AAgBA,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,
|
|
1
|
+
{"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../src/backfill.ts"],"names":[],"mappings":"AAgBA,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,CA2H/G;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiInE"}
|
package/dist/backfill.js
CHANGED
|
@@ -156,7 +156,24 @@ export async function backfillRepo(did, collections, fetchTimeout) {
|
|
|
156
156
|
const { value: commit } = cborDecode(rootData);
|
|
157
157
|
// Walk MST to find all record paths
|
|
158
158
|
const entries = walkMst(blocks, commit.data.$link);
|
|
159
|
-
|
|
159
|
+
// Delete existing records for this DID before re-importing so deletions are reflected
|
|
160
|
+
for (const col of collections) {
|
|
161
|
+
const schema = getSchema(col);
|
|
162
|
+
if (!schema)
|
|
163
|
+
continue;
|
|
164
|
+
await runSQL(`DELETE FROM ${schema.tableName} WHERE did = $1`, did);
|
|
165
|
+
for (const child of schema.children) {
|
|
166
|
+
await runSQL(`DELETE FROM ${child.tableName} WHERE parent_did = $1`, did);
|
|
167
|
+
}
|
|
168
|
+
for (const union of schema.unions) {
|
|
169
|
+
for (const branch of union.branches) {
|
|
170
|
+
await runSQL(`DELETE FROM ${branch.tableName} WHERE parent_did = $1`, did);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Insert records in chunks to limit memory usage
|
|
175
|
+
const CHUNK_SIZE = 1000;
|
|
176
|
+
let chunk = [];
|
|
160
177
|
for (const entry of entries) {
|
|
161
178
|
const collection = entry.path.split('/')[0];
|
|
162
179
|
if (!collections.has(collection))
|
|
@@ -170,7 +187,11 @@ export async function backfillRepo(did, collections, fetchTimeout) {
|
|
|
170
187
|
continue;
|
|
171
188
|
const rkey = entry.path.split('/').slice(1).join('/');
|
|
172
189
|
const uri = `at://${did}/${collection}/${rkey}`;
|
|
173
|
-
|
|
190
|
+
chunk.push({ collection, uri, cid: entry.cid, did, record });
|
|
191
|
+
if (chunk.length >= CHUNK_SIZE) {
|
|
192
|
+
count += await bulkInsertRecords(chunk);
|
|
193
|
+
chunk = [];
|
|
194
|
+
}
|
|
174
195
|
}
|
|
175
196
|
catch (recordErr) {
|
|
176
197
|
emit('backfill', 'record_error', {
|
|
@@ -181,23 +202,10 @@ export async function backfillRepo(did, collections, fetchTimeout) {
|
|
|
181
202
|
});
|
|
182
203
|
}
|
|
183
204
|
}
|
|
184
|
-
blocks = null; // free block map
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const schema = getSchema(col);
|
|
188
|
-
if (!schema)
|
|
189
|
-
continue;
|
|
190
|
-
await runSQL(`DELETE FROM ${schema.tableName} WHERE did = $1`, did);
|
|
191
|
-
for (const child of schema.children) {
|
|
192
|
-
await runSQL(`DELETE FROM ${child.tableName} WHERE parent_did = $1`, did);
|
|
193
|
-
}
|
|
194
|
-
for (const union of schema.unions) {
|
|
195
|
-
for (const branch of union.branches) {
|
|
196
|
-
await runSQL(`DELETE FROM ${branch.tableName} WHERE parent_did = $1`, did);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
205
|
+
blocks = null; // free block map
|
|
206
|
+
if (chunk.length > 0) {
|
|
207
|
+
count += await bulkInsertRecords(chunk);
|
|
199
208
|
}
|
|
200
|
-
count = await bulkInsertRecords(bulk);
|
|
201
209
|
await setRepoStatus(did, 'active', commit.rev, { handle });
|
|
202
210
|
return count;
|
|
203
211
|
}
|
package/dist/cli.js
CHANGED
|
@@ -848,7 +848,7 @@ COPY . .
|
|
|
848
848
|
RUN node_modules/.bin/hatk build
|
|
849
849
|
RUN npm prune --omit=dev
|
|
850
850
|
EXPOSE 3000
|
|
851
|
-
CMD ["node", "--max-old-space-size=
|
|
851
|
+
CMD ["node", "--max-old-space-size=512", "node_modules/@hatk/hatk/dist/main.js", "config.yaml"]
|
|
852
852
|
`);
|
|
853
853
|
const pkgDeps = { '@hatk/oauth-client': '*', hatk: '*' };
|
|
854
854
|
const pkgDevDeps = {
|