@nitpicker/crawler 0.11.0 → 0.13.0

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.
Files changed (387) hide show
  1. package/README.md +6 -4
  2. package/lib/archive/archive-accessor.d.ts +2 -2
  3. package/lib/archive/archive-accessor.js +2 -2
  4. package/lib/archive/archive-lock.d.ts +7 -0
  5. package/lib/archive/archive-lock.js +7 -0
  6. package/lib/archive/archive.d.ts +175 -13
  7. package/lib/archive/archive.js +198 -14
  8. package/lib/archive/cache/compute-archive-cache-key.d.ts +39 -0
  9. package/lib/archive/cache/compute-archive-cache-key.js +95 -0
  10. package/lib/archive/cache/extract-archive-to-cache.d.ts +43 -0
  11. package/lib/archive/cache/extract-archive-to-cache.js +309 -0
  12. package/lib/archive/cache/get-archive-cache-root.d.ts +20 -0
  13. package/lib/archive/cache/get-archive-cache-root.js +53 -0
  14. package/lib/archive/cache/is-archive-cache-disabled.d.ts +24 -0
  15. package/lib/archive/cache/is-archive-cache-disabled.js +34 -0
  16. package/lib/archive/cache/resolve-archive-cache-dir.d.ts +26 -0
  17. package/lib/archive/cache/resolve-archive-cache-dir.js +32 -0
  18. package/lib/archive/create-adjunct-tables.d.ts +43 -0
  19. package/lib/archive/create-adjunct-tables.js +213 -0
  20. package/lib/archive/create-entity-tables.d.ts +173 -0
  21. package/lib/archive/create-entity-tables.js +318 -0
  22. package/lib/archive/create-progress-reporter.d.ts +30 -0
  23. package/lib/archive/create-progress-reporter.js +38 -0
  24. package/lib/archive/create-ref-tables.d.ts +35 -0
  25. package/lib/archive/create-ref-tables.js +188 -0
  26. package/lib/archive/database.d.ts +130 -182
  27. package/lib/archive/database.js +524 -1777
  28. package/lib/archive/db-ops/_shared/clear-write-ref-caches.d.ts +27 -0
  29. package/lib/archive/db-ops/_shared/clear-write-ref-caches.js +34 -0
  30. package/lib/archive/db-ops/_shared/create-write-ref-caches.d.ts +17 -0
  31. package/lib/archive/db-ops/_shared/create-write-ref-caches.js +26 -0
  32. package/lib/archive/db-ops/_shared/decode-json-ref.d.ts +17 -0
  33. package/lib/archive/db-ops/_shared/decode-json-ref.js +31 -0
  34. package/lib/archive/db-ops/_shared/load-response-headers-by-set-ids.d.ts +20 -0
  35. package/lib/archive/db-ops/_shared/load-response-headers-by-set-ids.js +53 -0
  36. package/lib/archive/db-ops/_shared/resolve-content-item-id.d.ts +61 -0
  37. package/lib/archive/db-ops/_shared/resolve-content-item-id.js +111 -0
  38. package/lib/archive/db-ops/_shared/resolve-url-or-blob.d.ts +23 -0
  39. package/lib/archive/db-ops/_shared/resolve-url-or-blob.js +29 -0
  40. package/lib/archive/db-ops/_shared/retry-setting.d.ts +16 -0
  41. package/lib/archive/db-ops/_shared/retry-setting.js +18 -0
  42. package/lib/archive/db-ops/_shared/safe-parse-json.d.ts +11 -0
  43. package/lib/archive/db-ops/_shared/safe-parse-json.js +18 -0
  44. package/lib/archive/db-ops/_shared/types.d.ts +53 -0
  45. package/lib/archive/db-ops/_shared/types.js +1 -0
  46. package/lib/archive/db-ops/_shared/upsert-blob-ref.d.ts +25 -0
  47. package/lib/archive/db-ops/_shared/upsert-blob-ref.js +48 -0
  48. package/lib/archive/db-ops/_shared/upsert-content-type-ref.d.ts +30 -0
  49. package/lib/archive/db-ops/_shared/upsert-content-type-ref.js +45 -0
  50. package/lib/archive/db-ops/_shared/upsert-json-ref.d.ts +22 -0
  51. package/lib/archive/db-ops/_shared/upsert-json-ref.js +41 -0
  52. package/lib/archive/db-ops/_shared/upsert-response-headers.d.ts +35 -0
  53. package/lib/archive/db-ops/_shared/upsert-response-headers.js +49 -0
  54. package/lib/archive/db-ops/_shared/upsert-url-ref.d.ts +39 -0
  55. package/lib/archive/db-ops/_shared/upsert-url-ref.js +62 -0
  56. package/lib/archive/db-ops/analysis/replace-analysis-violations.d.ts +28 -0
  57. package/lib/archive/db-ops/analysis/replace-analysis-violations.js +152 -0
  58. package/lib/archive/db-ops/anchors/get-anchors-on-page.d.ts +10 -0
  59. package/lib/archive/db-ops/anchors/get-anchors-on-page.js +21 -0
  60. package/lib/archive/db-ops/config/get-base-url.d.ts +8 -0
  61. package/lib/archive/db-ops/config/get-base-url.js +14 -0
  62. package/lib/archive/db-ops/config/get-config.d.ts +10 -0
  63. package/lib/archive/db-ops/config/get-config.js +27 -0
  64. package/lib/archive/db-ops/config/get-name.d.ts +8 -0
  65. package/lib/archive/db-ops/config/get-name.js +14 -0
  66. package/lib/archive/db-ops/config/info-column-allowlist.d.ts +7 -0
  67. package/lib/archive/db-ops/config/info-column-allowlist.js +26 -0
  68. package/lib/archive/db-ops/config/info-json-columns.d.ts +5 -0
  69. package/lib/archive/db-ops/config/info-json-columns.js +10 -0
  70. package/lib/archive/db-ops/config/set-config.d.ts +12 -0
  71. package/lib/archive/db-ops/config/set-config.js +21 -0
  72. package/lib/archive/db-ops/config/update-config.d.ts +17 -0
  73. package/lib/archive/db-ops/config/update-config.js +36 -0
  74. package/lib/archive/db-ops/errors/insert-crawl-error.d.ts +15 -0
  75. package/lib/archive/db-ops/errors/insert-crawl-error.js +21 -0
  76. package/lib/archive/db-ops/errors/insert-page-error.d.ts +21 -0
  77. package/lib/archive/db-ops/errors/insert-page-error.js +28 -0
  78. package/lib/archive/db-ops/errors/list-dns-burned-host-candidates.d.ts +22 -0
  79. package/lib/archive/db-ops/errors/list-dns-burned-host-candidates.js +141 -0
  80. package/lib/archive/db-ops/html/get-html-of-page-by-id.d.ts +18 -0
  81. package/lib/archive/db-ops/html/get-html-of-page-by-id.js +29 -0
  82. package/lib/archive/db-ops/inventory/record-inventory-run.d.ts +21 -0
  83. package/lib/archive/db-ops/inventory/record-inventory-run.js +38 -0
  84. package/lib/archive/db-ops/lifecycle/checkpoint.d.ts +8 -0
  85. package/lib/archive/db-ops/lifecycle/checkpoint.js +9 -0
  86. package/lib/archive/db-ops/lifecycle/destroy.d.ts +6 -0
  87. package/lib/archive/db-ops/lifecycle/destroy.js +7 -0
  88. package/lib/archive/db-ops/lifecycle/init.d.ts +22 -0
  89. package/lib/archive/db-ops/lifecycle/init.js +42 -0
  90. package/lib/archive/db-ops/meta/get-jsonld-of-page.d.ts +13 -0
  91. package/lib/archive/db-ops/meta/get-jsonld-of-page.js +27 -0
  92. package/lib/archive/db-ops/meta/get-tags-of-page.d.ts +12 -0
  93. package/lib/archive/db-ops/meta/get-tags-of-page.js +28 -0
  94. package/lib/archive/db-ops/pages/order/set-url-order.d.ts +8 -0
  95. package/lib/archive/db-ops/pages/order/set-url-order.js +32 -0
  96. package/lib/archive/db-ops/pages/read/build-page-query.d.ts +18 -0
  97. package/lib/archive/db-ops/pages/read/build-page-query.js +40 -0
  98. package/lib/archive/db-ops/pages/read/get-crawling-state.d.ts +70 -0
  99. package/lib/archive/db-ops/pages/read/get-crawling-state.js +98 -0
  100. package/lib/archive/db-ops/pages/read/get-existing-page-urls.d.ts +15 -0
  101. package/lib/archive/db-ops/pages/read/get-existing-page-urls.js +30 -0
  102. package/lib/archive/db-ops/pages/read/get-page-count.d.ts +12 -0
  103. package/lib/archive/db-ops/pages/read/get-page-count.js +21 -0
  104. package/lib/archive/db-ops/pages/read/get-page-source-by-url.d.ts +24 -0
  105. package/lib/archive/db-ops/pages/read/get-page-source-by-url.js +28 -0
  106. package/lib/archive/db-ops/pages/read/get-pages-with-rels.d.ts +38 -0
  107. package/lib/archive/db-ops/pages/read/get-pages-with-rels.js +107 -0
  108. package/lib/archive/db-ops/pages/read/get-pages.d.ts +11 -0
  109. package/lib/archive/db-ops/pages/read/get-pages.js +51 -0
  110. package/lib/archive/db-ops/pages/read/get-scraped-html-page-count.d.ts +18 -0
  111. package/lib/archive/db-ops/pages/read/get-scraped-html-page-count.js +25 -0
  112. package/lib/archive/db-ops/pages/read/reconstruct-page-rows.d.ts +31 -0
  113. package/lib/archive/db-ops/pages/read/reconstruct-page-rows.js +32 -0
  114. package/lib/archive/db-ops/pages/reset/repromote-external-pages.d.ts +24 -0
  115. package/lib/archive/db-ops/pages/reset/repromote-external-pages.js +93 -0
  116. package/lib/archive/db-ops/pages/reset/reset-failed-pages.d.ts +47 -0
  117. package/lib/archive/db-ops/pages/reset/reset-failed-pages.js +124 -0
  118. package/lib/archive/db-ops/pages/write/insert-inventory-seeds.d.ts +37 -0
  119. package/lib/archive/db-ops/pages/write/insert-inventory-seeds.js +72 -0
  120. package/lib/archive/db-ops/pages/write/insert-jsonld.d.ts +17 -0
  121. package/lib/archive/db-ops/pages/write/insert-jsonld.js +49 -0
  122. package/lib/archive/db-ops/pages/write/insert-page.d.ts +36 -0
  123. package/lib/archive/db-ops/pages/write/insert-page.js +208 -0
  124. package/lib/archive/db-ops/pages/write/insert-tags.d.ts +16 -0
  125. package/lib/archive/db-ops/pages/write/insert-tags.js +34 -0
  126. package/lib/archive/db-ops/pages/write/link-redirect-sources.d.ts +36 -0
  127. package/lib/archive/db-ops/pages/write/link-redirect-sources.js +93 -0
  128. package/lib/archive/db-ops/pages/write/record-redirect.d.ts +35 -0
  129. package/lib/archive/db-ops/pages/write/record-redirect.js +100 -0
  130. package/lib/archive/db-ops/pages/write/set-skipped-page.d.ts +13 -0
  131. package/lib/archive/db-ops/pages/write/set-skipped-page.js +22 -0
  132. package/lib/archive/db-ops/pages/write/update-page.d.ts +29 -0
  133. package/lib/archive/db-ops/pages/write/update-page.js +334 -0
  134. package/lib/archive/db-ops/pages/write/write-page-html-blob.d.ts +19 -0
  135. package/lib/archive/db-ops/pages/write/write-page-html-blob.js +41 -0
  136. package/lib/archive/db-ops/referrers/get-redirects-for-pages.d.ts +9 -0
  137. package/lib/archive/db-ops/referrers/get-redirects-for-pages.js +15 -0
  138. package/lib/archive/db-ops/referrers/get-referrers-of-page.d.ts +17 -0
  139. package/lib/archive/db-ops/referrers/get-referrers-of-page.js +32 -0
  140. package/lib/archive/db-ops/referrers/get-referrers-of-resource.d.ts +8 -0
  141. package/lib/archive/db-ops/referrers/get-referrers-of-resource.js +15 -0
  142. package/lib/archive/db-ops/resources/build-resource-query.d.ts +25 -0
  143. package/lib/archive/db-ops/resources/build-resource-query.js +29 -0
  144. package/lib/archive/db-ops/resources/get-existing-resource-urls.d.ts +9 -0
  145. package/lib/archive/db-ops/resources/get-existing-resource-urls.js +24 -0
  146. package/lib/archive/db-ops/resources/get-resource-by-url.d.ts +13 -0
  147. package/lib/archive/db-ops/resources/get-resource-by-url.js +22 -0
  148. package/lib/archive/db-ops/resources/get-resource-url-list.d.ts +9 -0
  149. package/lib/archive/db-ops/resources/get-resource-url-list.js +13 -0
  150. package/lib/archive/db-ops/resources/get-resources.d.ts +8 -0
  151. package/lib/archive/db-ops/resources/get-resources.js +11 -0
  152. package/lib/archive/db-ops/resources/insert-inventory-resources.d.ts +24 -0
  153. package/lib/archive/db-ops/resources/insert-inventory-resources.js +64 -0
  154. package/lib/archive/db-ops/resources/insert-resource-referrers.d.ts +15 -0
  155. package/lib/archive/db-ops/resources/insert-resource-referrers.js +54 -0
  156. package/lib/archive/db-ops/resources/insert-resource.d.ts +34 -0
  157. package/lib/archive/db-ops/resources/insert-resource.js +73 -0
  158. package/lib/archive/db-ops/resources/reconstruct-resource-rows.d.ts +26 -0
  159. package/lib/archive/db-ops/resources/reconstruct-resource-rows.js +30 -0
  160. package/lib/archive/decode-html-blob.d.ts +18 -0
  161. package/lib/archive/decode-html-blob.js +31 -0
  162. package/lib/archive/derive-lineage-from-parent.d.ts +37 -0
  163. package/lib/archive/derive-lineage-from-parent.js +42 -0
  164. package/lib/archive/drop-legacy-tables.d.ts +45 -0
  165. package/lib/archive/drop-legacy-tables.js +56 -0
  166. package/lib/archive/filesystem/rename.js +1 -1
  167. package/lib/archive/get-failed-page-messages.d.ts +44 -0
  168. package/lib/archive/get-failed-page-messages.js +132 -0
  169. package/lib/archive/init-schema.d.ts +35 -39
  170. package/lib/archive/init-schema.js +111 -320
  171. package/lib/archive/is-inventory-source.d.ts +21 -0
  172. package/lib/archive/is-inventory-source.js +22 -0
  173. package/lib/archive/limited-page-ids.d.ts +2 -1
  174. package/lib/archive/limited-page-ids.js +5 -4
  175. package/lib/archive/meta/assert-compatible-version.d.ts +24 -3
  176. package/lib/archive/meta/assert-compatible-version.js +24 -3
  177. package/lib/archive/meta/types.d.ts +87 -1
  178. package/lib/archive/meta/types.js +34 -2
  179. package/lib/archive/migrate-entity-tables.d.ts +45 -0
  180. package/lib/archive/migrate-entity-tables.js +56 -0
  181. package/lib/archive/migrate-ref-tables.d.ts +25 -0
  182. package/lib/archive/migrate-ref-tables.js +38 -0
  183. package/lib/archive/page-meta-column-maps.d.ts +32 -0
  184. package/lib/archive/page-meta-column-maps.js +43 -0
  185. package/lib/archive/page.d.ts +6 -6
  186. package/lib/archive/page.js +5 -5
  187. package/lib/archive/peek-archive-lock.d.ts +2 -2
  188. package/lib/archive/peek-archive-lock.js +2 -2
  189. package/lib/archive/populate-entity-tables/collapse-anchor-rows.d.ts +41 -0
  190. package/lib/archive/populate-entity-tables/collapse-anchor-rows.js +87 -0
  191. package/lib/archive/populate-entity-tables/derive-dom-path.d.ts +35 -0
  192. package/lib/archive/populate-entity-tables/derive-dom-path.js +72 -0
  193. package/lib/archive/populate-entity-tables/is-blob-ref-value.d.ts +16 -0
  194. package/lib/archive/populate-entity-tables/is-blob-ref-value.js +19 -0
  195. package/lib/archive/populate-entity-tables/match-images-to-dom-paths.d.ts +66 -0
  196. package/lib/archive/populate-entity-tables/match-images-to-dom-paths.js +96 -0
  197. package/lib/archive/populate-entity-tables/populate-anchor-edges.d.ts +33 -0
  198. package/lib/archive/populate-entity-tables/populate-anchor-edges.js +153 -0
  199. package/lib/archive/populate-entity-tables/populate-content-items.d.ts +40 -0
  200. package/lib/archive/populate-entity-tables/populate-content-items.js +141 -0
  201. package/lib/archive/populate-entity-tables/populate-entities.d.ts +81 -0
  202. package/lib/archive/populate-entity-tables/populate-entities.js +111 -0
  203. package/lib/archive/populate-entity-tables/populate-image-items.d.ts +91 -0
  204. package/lib/archive/populate-entity-tables/populate-image-items.js +223 -0
  205. package/lib/archive/populate-entity-tables/populate-page-meta.d.ts +33 -0
  206. package/lib/archive/populate-entity-tables/populate-page-meta.js +267 -0
  207. package/lib/archive/populate-entity-tables/populate-resource-items.d.ts +22 -0
  208. package/lib/archive/populate-entity-tables/populate-resource-items.js +114 -0
  209. package/lib/archive/populate-entity-tables/populate-resource-ref-edges.d.ts +31 -0
  210. package/lib/archive/populate-entity-tables/populate-resource-ref-edges.js +33 -0
  211. package/lib/archive/populate-entity-tables/resolve-blob-refs.d.ts +31 -0
  212. package/lib/archive/populate-entity-tables/resolve-blob-refs.js +100 -0
  213. package/lib/archive/populate-entity-tables/resolve-content-type-refs.d.ts +22 -0
  214. package/lib/archive/populate-entity-tables/resolve-content-type-refs.js +27 -0
  215. package/lib/archive/populate-entity-tables/resolve-header-sets.d.ts +49 -0
  216. package/lib/archive/populate-entity-tables/resolve-header-sets.js +122 -0
  217. package/lib/archive/populate-entity-tables/resolve-json-refs.d.ts +25 -0
  218. package/lib/archive/populate-entity-tables/resolve-json-refs.js +67 -0
  219. package/lib/archive/populate-entity-tables/resolve-text-refs.d.ts +30 -0
  220. package/lib/archive/populate-entity-tables/resolve-text-refs.js +61 -0
  221. package/lib/archive/populate-entity-tables/resolve-url-or-blob-from-maps.d.ts +21 -0
  222. package/lib/archive/populate-entity-tables/resolve-url-or-blob-from-maps.js +27 -0
  223. package/lib/archive/populate-entity-tables/resolve-url-refs.d.ts +33 -0
  224. package/lib/archive/populate-entity-tables/resolve-url-refs.js +60 -0
  225. package/lib/archive/populate-entity-tables/test-utils/count-rows.d.ts +17 -0
  226. package/lib/archive/populate-entity-tables/test-utils/count-rows.js +20 -0
  227. package/lib/archive/populate-entity-tables/test-utils/seed-content-items.d.ts +25 -0
  228. package/lib/archive/populate-entity-tables/test-utils/seed-content-items.js +42 -0
  229. package/lib/archive/populate-entity-tables/test-utils/setup-entities-db.d.ts +23 -0
  230. package/lib/archive/populate-entity-tables/test-utils/setup-entities-db.js +178 -0
  231. package/lib/archive/populate-entity-tables/types.d.ts +157 -0
  232. package/lib/archive/populate-entity-tables/types.js +12 -0
  233. package/lib/archive/populate-entity-tables/upsert-text-refs.d.ts +38 -0
  234. package/lib/archive/populate-entity-tables/upsert-text-refs.js +78 -0
  235. package/lib/archive/populate-ref-tables/classify-content-type.d.ts +16 -0
  236. package/lib/archive/populate-ref-tables/classify-content-type.js +52 -0
  237. package/lib/archive/populate-ref-tables/compute-content-hash.d.ts +22 -0
  238. package/lib/archive/populate-ref-tables/compute-content-hash.js +26 -0
  239. package/lib/archive/populate-ref-tables/compute-header-flags.d.ts +16 -0
  240. package/lib/archive/populate-ref-tables/compute-header-flags.js +70 -0
  241. package/lib/archive/populate-ref-tables/content-type-rules.d.ts +38 -0
  242. package/lib/archive/populate-ref-tables/content-type-rules.js +133 -0
  243. package/lib/archive/populate-ref-tables/create-header-table-caches.d.ts +25 -0
  244. package/lib/archive/populate-ref-tables/create-header-table-caches.js +49 -0
  245. package/lib/archive/populate-ref-tables/data-uri-url-refs-limit.d.ts +15 -0
  246. package/lib/archive/populate-ref-tables/data-uri-url-refs-limit.js +15 -0
  247. package/lib/archive/populate-ref-tables/decode-data-uri.d.ts +21 -0
  248. package/lib/archive/populate-ref-tables/decode-data-uri.js +126 -0
  249. package/lib/archive/populate-ref-tables/decompose-header-set.d.ts +29 -0
  250. package/lib/archive/populate-ref-tables/decompose-header-set.js +157 -0
  251. package/lib/archive/populate-ref-tables/decompose-url.d.ts +25 -0
  252. package/lib/archive/populate-ref-tables/decompose-url.js +70 -0
  253. package/lib/archive/populate-ref-tables/header-stability.d.ts +19 -0
  254. package/lib/archive/populate-ref-tables/header-stability.js +22 -0
  255. package/lib/archive/populate-ref-tables/header-value-cache-key.d.ts +17 -0
  256. package/lib/archive/populate-ref-tables/header-value-cache-key.js +19 -0
  257. package/lib/archive/populate-ref-tables/normalize-mime.d.ts +24 -0
  258. package/lib/archive/populate-ref-tables/normalize-mime.js +36 -0
  259. package/lib/archive/populate-ref-tables/populate-blob-refs.d.ts +38 -0
  260. package/lib/archive/populate-ref-tables/populate-blob-refs.js +134 -0
  261. package/lib/archive/populate-ref-tables/populate-content-type-refs.d.ts +27 -0
  262. package/lib/archive/populate-ref-tables/populate-content-type-refs.js +70 -0
  263. package/lib/archive/populate-ref-tables/populate-header-tables.d.ts +35 -0
  264. package/lib/archive/populate-ref-tables/populate-header-tables.js +80 -0
  265. package/lib/archive/populate-ref-tables/populate-json-refs.d.ts +29 -0
  266. package/lib/archive/populate-ref-tables/populate-json-refs.js +101 -0
  267. package/lib/archive/populate-ref-tables/populate-refs.d.ts +51 -0
  268. package/lib/archive/populate-ref-tables/populate-refs.js +62 -0
  269. package/lib/archive/populate-ref-tables/populate-text-refs.d.ts +32 -0
  270. package/lib/archive/populate-ref-tables/populate-text-refs.js +133 -0
  271. package/lib/archive/populate-ref-tables/populate-url-refs.d.ts +28 -0
  272. package/lib/archive/populate-ref-tables/populate-url-refs.js +148 -0
  273. package/lib/archive/populate-ref-tables/test-utils/count-rows.d.ts +15 -0
  274. package/lib/archive/populate-ref-tables/test-utils/count-rows.js +17 -0
  275. package/lib/archive/populate-ref-tables/types.d.ts +197 -0
  276. package/lib/archive/populate-ref-tables/types.js +7 -0
  277. package/lib/archive/populate-ref-tables/upsert-one-header-set.d.ts +34 -0
  278. package/lib/archive/populate-ref-tables/upsert-one-header-set.js +208 -0
  279. package/lib/archive/populate-ref-tables/volatile-header-names.d.ts +20 -0
  280. package/lib/archive/populate-ref-tables/volatile-header-names.js +33 -0
  281. package/lib/archive/redirect-table.d.ts +4 -2
  282. package/lib/archive/redirect-table.js +15 -10
  283. package/lib/archive/resolve-redirect-chain.d.ts +3 -3
  284. package/lib/archive/resolve-redirect-chain.js +2 -2
  285. package/lib/archive/resource.d.ts +1 -1
  286. package/lib/archive/retarget-legacy-fk-tables.d.ts +47 -0
  287. package/lib/archive/retarget-legacy-fk-tables.js +107 -0
  288. package/lib/archive/test-utils/fk-parent-tables.d.ts +15 -0
  289. package/lib/archive/test-utils/fk-parent-tables.js +19 -0
  290. package/lib/archive/test-utils/seed-content-item.d.ts +35 -0
  291. package/lib/archive/test-utils/seed-content-item.js +42 -0
  292. package/lib/archive/test-utils/setup-legacy-fk-db.d.ts +33 -0
  293. package/lib/archive/test-utils/setup-legacy-fk-db.js +270 -0
  294. package/lib/archive/types.d.ts +151 -15
  295. package/lib/archive/verify-migration/capture-rejection.d.ts +24 -0
  296. package/lib/archive/verify-migration/capture-rejection.js +31 -0
  297. package/lib/archive/verify-migration/check-anchor-edges-count.d.ts +34 -0
  298. package/lib/archive/verify-migration/check-anchor-edges-count.js +72 -0
  299. package/lib/archive/verify-migration/check-anchor-edges-sum.d.ts +13 -0
  300. package/lib/archive/verify-migration/check-anchor-edges-sum.js +27 -0
  301. package/lib/archive/verify-migration/check-content-items-count.d.ts +16 -0
  302. package/lib/archive/verify-migration/check-content-items-count.js +30 -0
  303. package/lib/archive/verify-migration/check-content-type-preservation.d.ts +22 -0
  304. package/lib/archive/verify-migration/check-content-type-preservation.js +40 -0
  305. package/lib/archive/verify-migration/check-foreign-key-integrity.d.ts +31 -0
  306. package/lib/archive/verify-migration/check-foreign-key-integrity.js +47 -0
  307. package/lib/archive/verify-migration/check-image-items-count.d.ts +12 -0
  308. package/lib/archive/verify-migration/check-image-items-count.js +26 -0
  309. package/lib/archive/verify-migration/check-page-meta-count.d.ts +15 -0
  310. package/lib/archive/verify-migration/check-page-meta-count.js +31 -0
  311. package/lib/archive/verify-migration/check-reader-parity.d.ts +23 -0
  312. package/lib/archive/verify-migration/check-reader-parity.js +211 -0
  313. package/lib/archive/verify-migration/check-resource-items-count.d.ts +17 -0
  314. package/lib/archive/verify-migration/check-resource-items-count.js +33 -0
  315. package/lib/archive/verify-migration/check-url-round-trip.d.ts +43 -0
  316. package/lib/archive/verify-migration/check-url-round-trip.js +112 -0
  317. package/lib/archive/verify-migration/types.d.ts +70 -0
  318. package/lib/archive/verify-migration/types.js +63 -0
  319. package/lib/archive/verify-migration/verify-migration.d.ts +41 -0
  320. package/lib/archive/verify-migration/verify-migration.js +120 -0
  321. package/lib/classify-error-kind.d.ts +19 -0
  322. package/lib/classify-error-kind.js +122 -0
  323. package/lib/crawler/build-js-redirect-edge.d.ts +68 -0
  324. package/lib/crawler/build-js-redirect-edge.js +57 -0
  325. package/lib/crawler/build-redirect-event.d.ts +24 -0
  326. package/lib/crawler/build-redirect-event.js +28 -0
  327. package/lib/crawler/capture-image-dom-paths.d.ts +33 -0
  328. package/lib/crawler/capture-image-dom-paths.js +39 -0
  329. package/lib/crawler/clear-dns-burned-host-cache.d.ts +6 -0
  330. package/lib/crawler/clear-dns-burned-host-cache.js +11 -0
  331. package/lib/crawler/collect-image-dom-paths.d.ts +23 -0
  332. package/lib/crawler/collect-image-dom-paths.js +64 -0
  333. package/lib/crawler/crawler.d.ts +22 -1
  334. package/lib/crawler/crawler.js +679 -117
  335. package/lib/crawler/derive-js-redirect-target.d.ts +68 -0
  336. package/lib/crawler/derive-js-redirect-target.js +129 -0
  337. package/lib/crawler/derive-resource-source.d.ts +25 -15
  338. package/lib/crawler/derive-resource-source.js +28 -17
  339. package/lib/crawler/dns-burned-host-cache.d.ts +26 -0
  340. package/lib/crawler/dns-burned-host-cache.js +25 -0
  341. package/lib/crawler/dns-burned-host-short-circuit-counter.d.ts +13 -0
  342. package/lib/crawler/dns-burned-host-short-circuit-counter.js +11 -0
  343. package/lib/crawler/fetch-destination.d.ts +12 -4
  344. package/lib/crawler/fetch-destination.js +94 -16
  345. package/lib/crawler/inject-scope-auth.d.ts +1 -1
  346. package/lib/crawler/inject-scope-auth.js +1 -1
  347. package/lib/crawler/is-js-redirect-error-shape.d.ts +40 -0
  348. package/lib/crawler/is-js-redirect-error-shape.js +53 -0
  349. package/lib/crawler/is-puppeteer-fallback-candidate.d.ts +16 -0
  350. package/lib/crawler/is-puppeteer-fallback-candidate.js +63 -0
  351. package/lib/crawler/link-list.d.ts +21 -1
  352. package/lib/crawler/link-list.js +23 -3
  353. package/lib/crawler/normalize-content-type.d.ts +1 -1
  354. package/lib/crawler/normalize-content-type.js +1 -1
  355. package/lib/crawler/plan-sub-resource-emits.d.ts +63 -0
  356. package/lib/crawler/plan-sub-resource-emits.js +44 -0
  357. package/lib/crawler/preload-short-circuit-error.d.ts +22 -0
  358. package/lib/crawler/preload-short-circuit-error.js +25 -0
  359. package/lib/crawler/should-burn-host.d.ts +78 -0
  360. package/lib/crawler/should-burn-host.js +61 -0
  361. package/lib/crawler/should-get-fallback-on-head-failure.d.ts +38 -0
  362. package/lib/crawler/should-get-fallback-on-head-failure.js +46 -0
  363. package/lib/crawler/types.d.ts +108 -1
  364. package/lib/crawler-orchestrator.d.ts +22 -3
  365. package/lib/crawler-orchestrator.js +312 -73
  366. package/lib/crawler.d.ts +15 -2
  367. package/lib/crawler.js +24 -1
  368. package/lib/permanent-error-kinds.d.ts +43 -0
  369. package/lib/permanent-error-kinds.js +48 -0
  370. package/lib/types.d.ts +84 -0
  371. package/lib/utils/compute-file-sha256.d.ts +24 -0
  372. package/lib/utils/compute-file-sha256.js +56 -0
  373. package/lib/utils/error/emit-error-with-retry.d.ts +40 -0
  374. package/lib/utils/error/emit-error-with-retry.js +44 -0
  375. package/lib/utils/error/emit-error.d.ts +39 -0
  376. package/lib/utils/error/emit-error.js +41 -0
  377. package/package.json +12 -12
  378. package/lib/archive/migrate-crawl-errors.d.ts +0 -20
  379. package/lib/archive/migrate-crawl-errors.js +0 -38
  380. package/lib/archive/migrate-html-blob-tables.d.ts +0 -24
  381. package/lib/archive/migrate-html-blob-tables.js +0 -53
  382. package/lib/archive/migrate-page-errors.d.ts +0 -16
  383. package/lib/archive/migrate-page-errors.js +0 -35
  384. package/lib/archive/migrate-pages-resources-source.d.ts +0 -16
  385. package/lib/archive/migrate-pages-resources-source.js +0 -46
  386. package/lib/utils/error/error-emitter.d.ts +0 -18
  387. package/lib/utils/error/error-emitter.js +0 -29
@@ -1,5 +1,5 @@
1
1
  import type { JsonLdRow, TagRow } from './meta/types.js';
2
- import type { Config, DatabaseOption, DB_Anchor, DB_Page, DB_Redirect, DB_Referrer, DB_Resource, DatabaseEvent, PageFilter, PageSource } from './types.js';
2
+ import type { Config, DatabaseOption, DB_Redirect, DB_Resource, DatabaseEvent, InventoryRunMeta, PageFilter, PageSource } from './types.js';
3
3
  import type { PageData, Resource } from '../utils/types/types.js';
4
4
  import type { ExURL, ParseURLOptions } from '@d-zero/shared/parse-url';
5
5
  import type { Knex } from 'knex';
@@ -7,11 +7,21 @@ import { TypedAwaitEventEmitter as EventEmitter } from '@d-zero/shared/typed-awa
7
7
  /**
8
8
  * Low-level database abstraction layer for the archive's SQLite database.
9
9
  *
10
- * Public methods that perform database queries use the `@retryable`
11
- * decorator for automatic retry on transient failures, and `@ErrorEmitter`
12
- * to propagate errors as events. The set of tables this layer manages is
13
- * defined by `init-schema.ts` (the source of truth query that file for
14
- * the canonical list).
10
+ * Every method is a thin dispatcher: the SQL itself lives in a dedicated
11
+ * single-export op module under `./db-ops/` (one file per operation), and
12
+ * the class contributes only the connection (`this.#instance`) plus the
13
+ * error/retry wrapper. Public methods that perform database queries use the
14
+ * `emitErrorAndRetry` HOF for automatic retry on transient failures combined
15
+ * with error-event propagation, or `emitError` when retry is not appropriate.
16
+ * The set of tables this layer manages is defined by `init-schema.ts` (the
17
+ * source of truth — query that file for the canonical list).
18
+ *
19
+ * **Label sync caveat**: each `emitError` / `emitErrorAndRetry` call passes
20
+ * the method name as a string literal (e.g. `'Database.getAnchorsOnPage'`).
21
+ * TypeScript cannot check that the string matches the enclosing method's
22
+ * real name — the two-way sync is manual. Renaming a method here **must**
23
+ * update the literal string too, otherwise debug logs and `RetryTimeoutError`
24
+ * messages will silently report the old name.
15
25
  *
16
26
  * Use the static {@link Database.connect} factory method to create instances.
17
27
  * The constructor is private.
@@ -20,45 +30,42 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
20
30
  #private;
21
31
  private constructor();
22
32
  /**
23
- * Adds the `order` column to the `pages` table for URL sort ordering.
24
- * If the column already exists, this method does nothing.
25
- * @deprecated Since v0.1.x. The column is now created during table initialization.
26
- * @returns The result of the schema alteration, or void if the column already exists.
27
- */
28
- addOrderField(): Promise<void>;
29
- /**
30
- * Forces a WAL checkpoint, writing all pending WAL data back to the main database file.
31
- * Uses TRUNCATE mode to reset the WAL file to zero bytes after checkpointing.
32
- * This ensures the database is fully self-contained in `db.sqlite` before archiving.
33
+ * Forces a WAL checkpoint, writing all pending WAL data back to the main
34
+ * database file. Delegates to {@link checkpointOp}.
33
35
  */
34
36
  checkpoint(): Promise<void>;
35
37
  /**
36
38
  * Destroys the database connection, releasing all pooled resources.
39
+ * Delegates to {@link destroyOp}.
37
40
  */
38
41
  destroy(): Promise<void>;
39
42
  /**
40
43
  * Retrieves all anchors (outgoing links) on a specific page.
41
- * Joins the `anchors` table with the `pages` table to resolve link destinations.
44
+ * Delegates to {@link getAnchorsOnPageOp}.
42
45
  * @param pageId - The database ID of the page whose anchors to retrieve.
43
46
  * @returns An array of anchor records with resolved URL, title, status, and content type.
44
47
  */
45
48
  getAnchorsOnPage(pageId: number): Promise<any[]>;
46
49
  /**
47
50
  * Retrieves the base URL of the crawl session from the `info` table.
51
+ * Delegates to {@link getBaseUrlOp}.
48
52
  * @returns The base URL string.
49
53
  * @throws {Error} If no base URL is found in the database.
50
54
  */
51
- getBaseUrl(): Promise<any>;
55
+ getBaseUrl(): Promise<string>;
52
56
  /**
53
57
  * Retrieves the full crawl configuration from the `info` table.
54
- * Deserializes JSON-encoded fields (`roots`, `excludes`, `excludeKeywords`, `excludeUrls`).
58
+ * Delegates to {@link getConfigOp}.
55
59
  * @returns The parsed {@link Config} object.
56
60
  * @throws {Error} If no configuration is found in the database.
57
61
  */
58
62
  getConfig(): Promise<Config>;
59
63
  /**
60
64
  * Retrieves the current crawling state by listing scraped and pending URLs.
61
- * @returns An object with `scraped` (completed URLs) and `pending` (remaining URLs) arrays.
65
+ * Delegates to {@link getCrawlingStateOp} see the op for the strict
66
+ * pending-set rationale.
67
+ * @returns An object with `scraped` (completed URLs) and `pending` (the
68
+ * strict set of in-scope, anchor-referenced, unfinished URLs).
62
69
  */
63
70
  getCrawlingState(): Promise<{
64
71
  scraped: string[];
@@ -66,47 +73,28 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
66
73
  }>;
67
74
  /**
68
75
  * Return the subset of `urls` that already exist in the `pages` table.
69
- * Chunked into batches so SQLite's `IN (?, ?, …)` parameter limit
70
- * (`SQLITE_MAX_VARIABLE_NUMBER`, default 999) cannot be hit even when the
71
- * inventory list contains tens of thousands of URLs.
72
- *
73
- * Read-only — no transaction, no lock contention with the crawler write
74
- * pipeline (callers run this BEFORE the `<archive>.bak` is taken and the
75
- * crawl is started).
76
+ * Delegates to {@link getExistingPageUrlsOp}.
76
77
  * @param urls - URL strings to probe (already in `withoutHashAndAuth` form).
77
78
  * @returns URLs found in `pages`. Order is not preserved.
78
79
  */
79
80
  getExistingPageUrls(urls: readonly string[]): Promise<string[]>;
80
81
  /**
81
82
  * Return the subset of `urls` that already exist in the `resources` table.
82
- * See {@link Database.getExistingPageUrls} — same chunking strategy.
83
+ * Delegates to {@link getExistingResourceUrlsOp}.
83
84
  * @param urls - URL strings to probe.
84
85
  * @returns URLs found in `resources`.
85
86
  */
86
87
  getExistingResourceUrls(urls: readonly string[]): Promise<string[]>;
87
88
  /**
88
89
  * Reads the HTML snapshot stored as a zstd-compressed BLOB for the given page.
89
- *
90
- * Joins `page_html_ref` → `page_html_blobs` and decompresses inline. Returns
91
- * `null` when the page has no stored body (a non-HTML resource, a redirect
92
- * source, a degraded render). Read works identically on read-only / stub
93
- * connections — the special-cased "do we have a loose dir vs zip?" branching
94
- * the previous file-backed layout required is gone.
95
- *
96
- * Tables `page_html_ref` and `page_html_blobs` are created by `initSchema`.
97
- * Older `.nitpicker` archives that predate this migration must be passed
98
- * through `scripts/migrate-to-0.10.mjs` before they can be read.
90
+ * Delegates to {@link getHtmlOfPageByIdOp}.
99
91
  * @param pageId - The database ID of the page.
100
92
  * @returns The decompressed HTML string, or `null` if no snapshot is stored.
101
93
  */
102
94
  getHtmlOfPageById(pageId: number): Promise<string | null>;
103
95
  /**
104
96
  * Retrieves all `page_jsonld` rows for the given page id, parsed back into
105
- * {@link JsonLdRow} shape (with `parsed` deserialised from its JSON column).
106
- *
107
- * Read-side counterpart to `#insertJsonLd`. Returns rows in insertion order
108
- * by `id` so the order observed by `get-page-jsonld` matches the order the
109
- * scraper saw them.
97
+ * {@link JsonLdRow} shape. Delegates to {@link getJsonLdOfPageOp}.
110
98
  * @param pageId
111
99
  */
112
100
  getJsonLdOfPage(pageId: number): Promise<JsonLdRow[]>;
@@ -119,71 +107,74 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
119
107
  getKnex(): Knex;
120
108
  /**
121
109
  * Retrieves the crawl session name from the `info` table.
110
+ * Delegates to {@link getNameOp}.
122
111
  * @returns The name string.
123
112
  * @throws {Error} If no name is found in the database.
124
113
  */
125
- getName(): Promise<any>;
114
+ getName(): Promise<string>;
126
115
  /**
127
116
  * Counts the total number of pages in the database.
117
+ * Delegates to {@link getPageCountOp}.
128
118
  * @returns The total page count.
129
119
  * @throws {Error} If the count query fails.
130
120
  */
131
121
  getPageCount(): Promise<number>;
132
122
  /**
133
- * Retrieves pages from the database with optional filtering, pagination via offset and limit.
123
+ * Retrieves pages from the database with optional filtering, pagination via
124
+ * offset and limit. Delegates to {@link getPagesOp}.
134
125
  * @param filter - An optional {@link PageFilter} to narrow results by content type and origin.
135
126
  * @param offset - The number of rows to skip. Defaults to `0`.
136
127
  * @param limit - The maximum number of rows to return. Defaults to `100000`.
137
- * @returns An array of raw {@link DB_Page} rows.
128
+ * @returns An array of raw `DB_Page` rows.
138
129
  */
139
- getPages(filter?: PageFilter, offset?: number, limit?: number): Promise<DB_Page[]>;
130
+ getPages(filter?: PageFilter, offset?: number, limit?: number): Promise<import("./types.js").DB_Page[]>;
131
+ /**
132
+ * Look up the `source` column of a single page by its URL key.
133
+ * Delegates to {@link getPageSourceByUrlOp}.
134
+ * @param url - URL key in `url.withoutHashAndAuth` form.
135
+ * @returns The recorded `source`, or `undefined` when no row exists.
136
+ */
137
+ getPageSourceByUrl(url: string): Promise<PageSource | undefined>;
140
138
  /**
141
139
  * Retrieves pages along with their related redirect, anchor, and referrer data.
142
- * Results are ordered by the natural URL sort order. Only non-redirected pages are returned.
140
+ * Results are ordered by the natural URL sort order. Only non-redirected pages
141
+ * are returned. Delegates to {@link getPagesWithRelsOp}.
143
142
  * @param offset - The number of rows to skip.
144
143
  * @param limit - The maximum number of pages to return.
145
144
  * @returns An object containing `pages`, `redirects`, `anchors`, and `referrers` arrays.
146
145
  */
147
146
  getPagesWithRels(offset: number, limit: number): Promise<{
148
- pages: DB_Page[];
147
+ pages: import("./types.js").DB_Page[];
149
148
  redirects: DB_Redirect[];
150
- anchors: DB_Anchor[];
151
- referrers: DB_Referrer[];
149
+ anchors: import("./types.js").DB_Anchor[];
150
+ referrers: import("./types.js").DB_Referrer[];
152
151
  }>;
153
152
  /**
154
153
  * Retrieves redirect sources for the given page IDs in bulk.
154
+ * Delegates to {@link getRedirectsForPagesOp}.
155
155
  * @param pageIds - The database IDs of the destination pages.
156
156
  * @returns An array of {@link DB_Redirect} records mapping destination pages to their redirect sources.
157
157
  */
158
158
  getRedirectsForPages(pageIds: number[]): Promise<DB_Redirect[]>;
159
159
  /**
160
- * Retrieves pages that link to a specific page (incoming links / referrers).
161
- *
162
- * Incoming links are resolved **through redirects**: an anchor pointing at a
163
- * redirect source (e.g. `http://x` that 301s to `https://x`) counts as a
164
- * referrer of the redirect's final destination, not of the source. This keeps
165
- * backlinks merged on the canonical page instead of splitting them across the
166
- * `http`/`https` (or any redirect source/dest) pair. The resolution mirrors
167
- * `redirectTable()` — `redirectDestId` is pre-flattened to the final
168
- * destination, so `COALESCE(target.redirectDestId, target.id)` is a single hop.
160
+ * Retrieves pages that link to a specific page (incoming links / referrers),
161
+ * resolved through redirects. Delegates to {@link getReferrersOfPageOp}.
169
162
  * @param pageId - The database ID of the target page.
170
163
  * @returns An array of referrer records with URL, hash, and text content.
171
164
  */
172
165
  getReferrersOfPage(pageId: number): Promise<any[]>;
173
166
  /**
174
167
  * Retrieves the page URLs that reference a specific resource.
168
+ * Delegates to {@link getReferrersOfResourceOp}.
175
169
  * @param id - The database ID of the resource.
176
170
  * @returns An array of page URL strings that reference the resource.
177
171
  */
178
172
  getReferrersOfResource(id: number): Promise<string[]>;
179
173
  /**
180
174
  * Retrieves a single sub-resource from the `resources` table by its URL.
175
+ * Delegates to {@link getResourceByUrlOp}.
181
176
  *
182
- * Accepts multiple URL candidates because the stored key is the resource's
183
- * `href` while callers may only know the hash-stripped form; the first match
184
- * wins.
185
- *
186
- * Deliberately NOT decorated with `@ErrorEmitter`: the only caller (the
177
+ * Deliberately NOT wrapped with `emitError`/`emitErrorAndRetry`: the only caller (the
187
178
  * crawler's resource-reuse hook) has a full fallback (the HEAD pre-flight),
188
179
  * so a read failure here must not surface as a database `error` event —
189
180
  * the orchestrator aborts the whole crawl on that event, which is the
@@ -194,63 +185,53 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
194
185
  getResourceByUrl(urls: readonly string[]): Promise<DB_Resource | null>;
195
186
  /**
196
187
  * Retrieves all sub-resources from the `resources` table.
188
+ * Delegates to {@link getResourcesOp}.
197
189
  * @returns An array of raw {@link DB_Resource} rows.
198
190
  */
199
191
  getResources(): Promise<DB_Resource[]>;
200
192
  /**
201
193
  * Retrieves a flat list of all resource URLs from the `resources` table.
194
+ * Delegates to {@link getResourceUrlListOp}.
202
195
  * @returns An array of resource URL strings.
203
196
  */
204
- getResourceUrlList(): Promise<any[]>;
197
+ getResourceUrlList(): Promise<string[]>;
205
198
  /**
206
199
  * Counts pages that were scraped as crawl targets (full HTML render).
207
- *
208
- * Used by the crawler to seed its `pagesScraped` counter on resume so the
209
- * progress display reflects all browser-rendered HTML pages across sessions,
210
- * not just the current one.
211
- *
212
- * "HTML page" is guaranteed by `contentType = 'text/html'`, NOT by `isTarget`
213
- * alone: `isTarget` means "in-scope crawl target" and is set for in-scope
214
- * non-HTML resources too (e.g. a PDF reached via the HEAD pre-flight is
215
- * `isTarget = 1`). Counting those would over-report the HTML page total, so
216
- * page-ness is asserted at the read layer here rather than by trusting
217
- * `isTarget`.
200
+ * Delegates to {@link getScrapedHtmlPageCountOp}.
218
201
  * @returns The number of `text/html` rows with `isTarget = 1` and `scraped = 1`.
219
202
  */
220
203
  getScrapedHtmlPageCount(): Promise<number>;
221
204
  /**
222
205
  * Retrieves all `page_tags` rows for the given page id, parsed back into
223
- * {@link TagRow} shape (with `categories` and `sources` JSON columns
224
- * deserialised).
225
- *
226
- * Read-side counterpart to `#insertTags`.
206
+ * {@link TagRow} shape. Delegates to {@link getTagsOfPageOp}.
227
207
  * @param pageId
228
208
  */
229
209
  getTagsOfPage(pageId: number): Promise<TagRow[]>;
230
210
  /**
231
211
  * Records a crawler-level (`error` channel) failure into `crawl_errors`.
232
- *
233
- * Unlike {@link insertPageError} this is not tied to a scraped page: `url`
234
- * may be an external link that never became a page row, or `null` for a
235
- * process-level error. The cause is intentionally not stored — it is derived
236
- * on read so that older archives (which only have `error.log`) and freshly
237
- * captured rows classify identically.
212
+ * Delegates to {@link insertCrawlErrorOp}.
238
213
  * @param url - The URL the error is about, or `null` for a process-level error.
239
214
  * @param message - The error message (one line is enough for classification).
240
215
  * @param isExternal - Whether the URL is external to the crawl scope.
241
216
  */
242
217
  insertCrawlError(url: string | null, message: string, isExternal?: boolean): Promise<void>;
218
+ /**
219
+ * Pre-insert inventory non-HTML URLs into `resources` as placeholder rows.
220
+ * Delegates to {@link insertInventoryResourcesOp}.
221
+ * @param urls - URL strings (already in `withoutHashAndAuth` form).
222
+ */
223
+ insertInventoryResources(urls: readonly string[]): Promise<void>;
224
+ /**
225
+ * Pre-insert inventory HTML seeds into `pages` as `scraped = 0`,
226
+ * `source = 'inventory-seed'` placeholders. Delegates to
227
+ * {@link insertInventorySeedsOp} — see the op for the Ctrl+C tolerance
228
+ * rationale.
229
+ * @param urls - URL strings already in `withoutHashAndAuth` form.
230
+ */
231
+ insertInventorySeeds(urls: readonly string[]): Promise<void>;
243
232
  /**
244
233
  * Records a partial scrape failure against the page identified by `url`.
245
- *
246
- * The page row is resolved (or inserted as a stub) via
247
- * {@link Database.#getIdByUrl} so the error can be recorded even before
248
- * `setPage` has run — useful when the failure fires during scraping
249
- * (e.g. mid-`scrapeStart`) and the orchestrator enqueues this write
250
- * before the success write for the same URL.
251
- *
252
- * A single page can have multiple `page_errors` rows (e.g. both
253
- * `desktop-compact` and `mobile-small` viewports failing).
234
+ * Delegates to {@link insertPageErrorOp}.
254
235
  * @param url - URL of the page being scraped.
255
236
  * @param phase - Scrape phase name (typically `'retryExhausted'`).
256
237
  * @param message - Human-readable failure message.
@@ -259,102 +240,83 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
259
240
  insertPageError(url: string, phase: string, message: string, isExternal?: boolean): Promise<void>;
260
241
  /**
261
242
  * Inserts a sub-resource into the `resources` table.
262
- * Ignores duplicate URLs (uses `ON CONFLICT IGNORE`).
263
- *
264
- * The `source` provenance label is written ONLY on insert; an
265
- * `ON CONFLICT IGNORE` collision leaves an existing row's source untouched
266
- * (this is what makes a second `crawl --inventory` non-destructive — see
267
- * the inventory plan).
243
+ * Delegates to {@link insertResourceOp}.
268
244
  * @param resource - The resource data to insert.
269
245
  * @param source - Provenance label for new rows. `undefined` leaves the DB DEFAULT (`'crawled'`).
270
246
  */
271
247
  insertResource(resource: Resource, source?: PageSource): Promise<void>;
272
248
  /**
273
249
  * Inserts a referrer relationship between a resource and a page into the
274
- * `resources-referrers` table. Silently skips if the resource is not found.
250
+ * `resources-referrers` table. Delegates to {@link insertResourceReferrersOp}.
275
251
  * @param src - The URL of the resource.
276
252
  * @param pageUrl - The URL of the page that references the resource.
277
253
  */
278
254
  insertResourceReferrers(src: string, pageUrl: string): Promise<void>;
255
+ /**
256
+ * Hostnames whose `crawl_errors` history is consistently DNS failures and
257
+ * for which no recent 2xx-3xx page or resource is recorded.
258
+ * Delegates to {@link listDnsBurnedHostCandidatesOp}.
259
+ * @returns Lower-cased hostnames safe to short-circuit.
260
+ */
261
+ listDnsBurnedHostCandidates(): Promise<string[]>;
262
+ /**
263
+ * Appends one row to the `inventory_runs` audit log.
264
+ * Delegates to {@link recordInventoryRunOp}.
265
+ * @param meta - The run metadata to record. Only `ran_at` is required.
266
+ * @returns The autoincremented `id` of the newly-inserted row.
267
+ */
268
+ recordInventoryRun(meta: InventoryRunMeta): Promise<number>;
279
269
  /**
280
270
  * Records a redirect edge (source → destination) **without** re-storing the
281
- * destination's content.
282
- *
283
- * The crawler renders a many-to-one redirect destination exactly once. For
284
- * every subsequent source URL that redirects to that already-rendered
285
- * destination, it calls this instead of {@link updatePage} (#73). Routing a
286
- * content-less HEAD result through `updatePage` would funnel it into
287
- * `#insertPage` and overwrite the destination's good title / meta with empty
288
- * values, so the dedicated edge-only path is required.
289
- *
290
- * The destination row is resolved (created on demand if a concurrent in-flight
291
- * render has not committed it yet) so the edge always points at a valid id;
292
- * the single render fills in the destination's content under that same id.
293
- * The destination's existing anchors / images are never touched here.
271
+ * destination's content. Delegates to {@link recordRedirectOp}.
294
272
  * @param page - HEAD-resolved page data carrying the redirect chain. Its
295
273
  * `anchorList` / `imageList` are ignored (a redirect source owns no content).
296
- */
297
- recordRedirect(page: PageData): Promise<void>;
298
- /**
299
- * Promote previously-external pages whose URL falls under any of the new scope
300
- * entries back to a "needs scraping" state so that the next crawl picks them up
301
- * as full internal pages.
302
- *
303
- * For each matching page:
304
- * - clears the scrape metadata (status, headers, snapshot path, etc.),
305
- * - flips `isExternal` to `0` and `scraped` to `0`,
306
- * - removes stale `anchors`, `images`, and `resources-referrers` rows so that
307
- * the re-scrape can re-insert fresh ones without duplicates.
308
- *
309
- * The page row itself is kept (id is preserved) so existing referrers via
310
- * `anchors.hrefId` remain valid. SELECT and UPDATE/DELETE statements are
311
- * chunked to stay below SQLite's `SQLITE_LIMIT_VARIABLE_NUMBER`.
274
+ * @param source - Inventory provenance forwarded by the orchestrator for
275
+ * the redirect-edge fast path. `undefined` keeps the DB DEFAULT
276
+ * `'crawled'` on a brand-new destination row.
277
+ */
278
+ recordRedirect(page: PageData, source?: PageSource): Promise<void>;
279
+ /**
280
+ * Replaces the stored analysis violations with a freshly generated set.
281
+ * Delegates to {@link replaceAnalysisViolationsOp}.
282
+ * @param violations - Flat violation list from the analyze phase.
283
+ */
284
+ replaceAnalysisViolations(violations: readonly {
285
+ validator: string;
286
+ severity: string;
287
+ rule: string;
288
+ code?: string | null;
289
+ message: string;
290
+ url: string;
291
+ line?: number | null;
292
+ col?: number | null;
293
+ }[]): Promise<void>;
294
+ /**
295
+ * Promote previously-external pages whose URL falls under any of the new
296
+ * scope entries back to a "needs scraping" state.
297
+ * Delegates to {@link repromoteExternalPagesOp}.
312
298
  * @param scopes - The hostname-indexed scope map after the new roots are merged.
313
- * @param options - URL parsing options forwarded to {@link findScopeEntry}.
299
+ * @param options - URL parsing options forwarded to the scope matcher.
314
300
  * @returns The URLs of the pages that were promoted.
315
301
  */
316
302
  repromoteExternalPages(scopes: ReadonlyMap<string, readonly ExURL[]>, options?: ParseURLOptions): Promise<string[]>;
317
303
  /**
318
304
  * Reset previously-attempted pages that ended in a recoverable failure so a
319
- * follow-up crawl can re-fetch them from scratch.
320
- *
321
- * A page qualifies as a recoverable failure when it was already scraped
322
- * (`scraped = 1`), is not a redirect source (`redirectDestId IS NULL`), was
323
- * not intentionally skipped (`isSkipped` is not `1`), and one of the
324
- * following holds:
325
- *
326
- * - `status = -1` — the sentinel a hard scrape failure (network error,
327
- * timeout, browser crash) is recorded with (see `handle-scrape-error.ts`);
328
- * - `status IS NULL` — no status was ever stored for the row;
329
- * - `contentType IS NULL` — the content type could not be determined;
330
- * - `status` is in the `5xx` range — a (frequently transient) server error.
331
- *
332
- * Definitive `4xx` responses are intentionally excluded: re-fetching a 404
333
- * almost always yields the same answer. Matching rows — internal and
334
- * external alike — are demoted back to pending (`scraped = 0`) and have their
335
- * stale scrape metadata cleared. The page row itself is kept (id preserved)
336
- * so existing `anchors.hrefId` referrers stay valid, and `isExternal` is left
337
- * untouched so the next pass re-classifies each page from the crawl scope.
338
- * Related `anchors`, `images`, `resources-referrers`, and `page_errors` rows
339
- * are deleted so the re-scrape can re-insert fresh data without duplicates.
340
- *
341
- * SELECT and UPDATE/DELETE statements are chunked to stay below SQLite's
342
- * `SQLITE_LIMIT_VARIABLE_NUMBER`.
305
+ * follow-up crawl can re-fetch them from scratch. Delegates to
306
+ * {@link resetFailedPagesOp} — see the op for the permanent-failure
307
+ * exclusion rationale.
343
308
  * @returns The URLs of the pages that were reset to pending.
344
309
  */
345
310
  resetFailedPages(): Promise<string[]>;
346
311
  /**
347
312
  * Stores the crawl configuration in the `info` table.
348
- * Only fields in {@link INFO_COLUMN_ALLOWLIST} are forwarded — any extra
349
- * runtime-only field on the input is silently dropped so callers can splat
350
- * a wider config object without producing SQL errors. JSON-array fields
351
- * are serialized via `JSON.stringify`.
313
+ * Delegates to {@link setConfigOp}.
352
314
  * @param config - The {@link Config} object to store.
353
315
  */
354
316
  setConfig(config: Config): Promise<number[]>;
355
317
  /**
356
318
  * Marks a page as skipped in the database with the given reason.
357
- * Creates the page row if it does not already exist.
319
+ * Delegates to {@link setSkippedPageOp}.
358
320
  * @param url - The URL of the skipped page.
359
321
  * @param reason - The reason the page was skipped.
360
322
  * @param isExternal - Whether the page is on an external domain. Defaults to `false`.
@@ -362,31 +324,19 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
362
324
  setSkippedPage(url: string, reason: string, isExternal?: boolean): Promise<void>;
363
325
  /**
364
326
  * Assigns natural URL sort order values to all internal pages.
365
- * Pages are sorted using {@link pathComparator} and assigned sequential order numbers.
327
+ * Delegates to {@link setUrlOrderOp}.
366
328
  */
367
329
  setUrlOrder(): Promise<void>;
368
330
  /**
369
331
  * Update the single row in the `info` table with a partial config patch.
370
- *
371
- * Used by the append flow to extend `roots` (and any other tweakable
372
- * field) without replacing the entire row. JSON-array fields are serialized on
373
- * the fly; primitive fields are written verbatim. Unspecified fields stay as-is.
374
- *
375
- * Unknown keys (anything outside the allow-list of `info`-table columns) are
376
- * silently dropped instead of being passed to SQL, so callers that splat a
377
- * wider runtime config (e.g. `CrawlConfig` with `cwd` / `executablePath`)
378
- * cannot accidentally trigger a "no such column" SQL error.
332
+ * Delegates to {@link updateConfigOp}.
379
333
  * @param patch - Partial {@link Config} fields to overwrite. `undefined` values are skipped.
380
334
  */
381
335
  updateConfig(patch: Partial<Config>): Promise<void>;
382
336
  /**
383
- * Inserts or updates a crawled page in the database, including its redirect chain,
384
- * anchors, images, and (when `writeHtml`) its compressed HTML snapshot BLOB.
385
- *
386
- * Self-redirects (where the source URL equals the destination URL after normalization)
387
- * are skipped to avoid marking a page as redirected to itself — a situation caused by
388
- * authentication challenges (e.g. Basic Auth 302) that would otherwise exclude the page
389
- * from reports via the `whereNull('redirectDestId')` filter.
337
+ * Inserts or updates a crawled page in the database, including its redirect
338
+ * chain, anchors, images, and (when `writeHtml`) its compressed HTML
339
+ * snapshot BLOB. Delegates to {@link updatePageOp}.
390
340
  * @param page - The page data to store.
391
341
  * @param writeHtml - When `true`, this call is allowed to insert (or clear)
392
342
  * the page's HTML blob. `setExternalPage` passes `false` because external
@@ -394,9 +344,7 @@ export declare class Database extends EventEmitter<DatabaseEvent> {
394
344
  * stored body.
395
345
  * @param isTarget - Whether this page is a crawl target.
396
346
  * @param source - Provenance label written ONLY when the row is freshly
397
- * inserted. Existing rows keep their original `source` (this is why a
398
- * second `crawl --inventory` does not "demote" an `'inventory-seed'` row
399
- * that was discovered earlier).
347
+ * inserted. Existing rows keep their original `source`.
400
348
  * @returns The database `pageId` of the inserted/updated row.
401
349
  */
402
350
  updatePage(page: PageData, writeHtml: boolean, isTarget: boolean, source?: PageSource): Promise<number>;