@nitpicker/crawler 0.12.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 (349) 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 +63 -16
  7. package/lib/archive/archive.js +56 -17
  8. package/lib/archive/create-adjunct-tables.d.ts +43 -0
  9. package/lib/archive/create-adjunct-tables.js +213 -0
  10. package/lib/archive/create-entity-tables.d.ts +173 -0
  11. package/lib/archive/create-entity-tables.js +318 -0
  12. package/lib/archive/create-progress-reporter.d.ts +30 -0
  13. package/lib/archive/create-progress-reporter.js +38 -0
  14. package/lib/archive/create-ref-tables.d.ts +35 -0
  15. package/lib/archive/create-ref-tables.js +188 -0
  16. package/lib/archive/database.d.ts +92 -345
  17. package/lib/archive/database.js +168 -1942
  18. package/lib/archive/db-ops/_shared/clear-write-ref-caches.d.ts +27 -0
  19. package/lib/archive/db-ops/_shared/clear-write-ref-caches.js +34 -0
  20. package/lib/archive/db-ops/_shared/create-write-ref-caches.d.ts +17 -0
  21. package/lib/archive/db-ops/_shared/create-write-ref-caches.js +26 -0
  22. package/lib/archive/db-ops/_shared/decode-json-ref.d.ts +17 -0
  23. package/lib/archive/db-ops/_shared/decode-json-ref.js +31 -0
  24. package/lib/archive/db-ops/_shared/load-response-headers-by-set-ids.d.ts +20 -0
  25. package/lib/archive/db-ops/_shared/load-response-headers-by-set-ids.js +53 -0
  26. package/lib/archive/db-ops/_shared/resolve-content-item-id.d.ts +61 -0
  27. package/lib/archive/db-ops/_shared/resolve-content-item-id.js +111 -0
  28. package/lib/archive/db-ops/_shared/resolve-url-or-blob.d.ts +23 -0
  29. package/lib/archive/db-ops/_shared/resolve-url-or-blob.js +29 -0
  30. package/lib/archive/db-ops/_shared/retry-setting.d.ts +16 -0
  31. package/lib/archive/db-ops/_shared/retry-setting.js +18 -0
  32. package/lib/archive/db-ops/_shared/safe-parse-json.d.ts +11 -0
  33. package/lib/archive/db-ops/_shared/safe-parse-json.js +18 -0
  34. package/lib/archive/db-ops/_shared/types.d.ts +53 -0
  35. package/lib/archive/db-ops/_shared/types.js +1 -0
  36. package/lib/archive/db-ops/_shared/upsert-blob-ref.d.ts +25 -0
  37. package/lib/archive/db-ops/_shared/upsert-blob-ref.js +48 -0
  38. package/lib/archive/db-ops/_shared/upsert-content-type-ref.d.ts +30 -0
  39. package/lib/archive/db-ops/_shared/upsert-content-type-ref.js +45 -0
  40. package/lib/archive/db-ops/_shared/upsert-json-ref.d.ts +22 -0
  41. package/lib/archive/db-ops/_shared/upsert-json-ref.js +41 -0
  42. package/lib/archive/db-ops/_shared/upsert-response-headers.d.ts +35 -0
  43. package/lib/archive/db-ops/_shared/upsert-response-headers.js +49 -0
  44. package/lib/archive/db-ops/_shared/upsert-url-ref.d.ts +39 -0
  45. package/lib/archive/db-ops/_shared/upsert-url-ref.js +62 -0
  46. package/lib/archive/db-ops/analysis/replace-analysis-violations.d.ts +28 -0
  47. package/lib/archive/db-ops/analysis/replace-analysis-violations.js +152 -0
  48. package/lib/archive/db-ops/anchors/get-anchors-on-page.d.ts +10 -0
  49. package/lib/archive/db-ops/anchors/get-anchors-on-page.js +21 -0
  50. package/lib/archive/db-ops/config/get-base-url.d.ts +8 -0
  51. package/lib/archive/db-ops/config/get-base-url.js +14 -0
  52. package/lib/archive/db-ops/config/get-config.d.ts +10 -0
  53. package/lib/archive/db-ops/config/get-config.js +27 -0
  54. package/lib/archive/db-ops/config/get-name.d.ts +8 -0
  55. package/lib/archive/db-ops/config/get-name.js +14 -0
  56. package/lib/archive/db-ops/config/info-column-allowlist.d.ts +7 -0
  57. package/lib/archive/db-ops/config/info-column-allowlist.js +26 -0
  58. package/lib/archive/db-ops/config/info-json-columns.d.ts +5 -0
  59. package/lib/archive/db-ops/config/info-json-columns.js +10 -0
  60. package/lib/archive/db-ops/config/set-config.d.ts +12 -0
  61. package/lib/archive/db-ops/config/set-config.js +21 -0
  62. package/lib/archive/db-ops/config/update-config.d.ts +17 -0
  63. package/lib/archive/db-ops/config/update-config.js +36 -0
  64. package/lib/archive/db-ops/errors/insert-crawl-error.d.ts +15 -0
  65. package/lib/archive/db-ops/errors/insert-crawl-error.js +21 -0
  66. package/lib/archive/db-ops/errors/insert-page-error.d.ts +21 -0
  67. package/lib/archive/db-ops/errors/insert-page-error.js +28 -0
  68. package/lib/archive/db-ops/errors/list-dns-burned-host-candidates.d.ts +22 -0
  69. package/lib/archive/db-ops/errors/list-dns-burned-host-candidates.js +141 -0
  70. package/lib/archive/db-ops/html/get-html-of-page-by-id.d.ts +18 -0
  71. package/lib/archive/db-ops/html/get-html-of-page-by-id.js +29 -0
  72. package/lib/archive/db-ops/inventory/record-inventory-run.d.ts +21 -0
  73. package/lib/archive/db-ops/inventory/record-inventory-run.js +38 -0
  74. package/lib/archive/db-ops/lifecycle/checkpoint.d.ts +8 -0
  75. package/lib/archive/db-ops/lifecycle/checkpoint.js +9 -0
  76. package/lib/archive/db-ops/lifecycle/destroy.d.ts +6 -0
  77. package/lib/archive/db-ops/lifecycle/destroy.js +7 -0
  78. package/lib/archive/db-ops/lifecycle/init.d.ts +22 -0
  79. package/lib/archive/db-ops/lifecycle/init.js +42 -0
  80. package/lib/archive/db-ops/meta/get-jsonld-of-page.d.ts +13 -0
  81. package/lib/archive/db-ops/meta/get-jsonld-of-page.js +27 -0
  82. package/lib/archive/db-ops/meta/get-tags-of-page.d.ts +12 -0
  83. package/lib/archive/db-ops/meta/get-tags-of-page.js +28 -0
  84. package/lib/archive/db-ops/pages/order/set-url-order.d.ts +8 -0
  85. package/lib/archive/db-ops/pages/order/set-url-order.js +32 -0
  86. package/lib/archive/db-ops/pages/read/build-page-query.d.ts +18 -0
  87. package/lib/archive/db-ops/pages/read/build-page-query.js +40 -0
  88. package/lib/archive/db-ops/pages/read/get-crawling-state.d.ts +70 -0
  89. package/lib/archive/db-ops/pages/read/get-crawling-state.js +98 -0
  90. package/lib/archive/db-ops/pages/read/get-existing-page-urls.d.ts +15 -0
  91. package/lib/archive/db-ops/pages/read/get-existing-page-urls.js +30 -0
  92. package/lib/archive/db-ops/pages/read/get-page-count.d.ts +12 -0
  93. package/lib/archive/db-ops/pages/read/get-page-count.js +21 -0
  94. package/lib/archive/db-ops/pages/read/get-page-source-by-url.d.ts +24 -0
  95. package/lib/archive/db-ops/pages/read/get-page-source-by-url.js +28 -0
  96. package/lib/archive/db-ops/pages/read/get-pages-with-rels.d.ts +38 -0
  97. package/lib/archive/db-ops/pages/read/get-pages-with-rels.js +107 -0
  98. package/lib/archive/db-ops/pages/read/get-pages.d.ts +11 -0
  99. package/lib/archive/db-ops/pages/read/get-pages.js +51 -0
  100. package/lib/archive/db-ops/pages/read/get-scraped-html-page-count.d.ts +18 -0
  101. package/lib/archive/db-ops/pages/read/get-scraped-html-page-count.js +25 -0
  102. package/lib/archive/db-ops/pages/read/reconstruct-page-rows.d.ts +31 -0
  103. package/lib/archive/db-ops/pages/read/reconstruct-page-rows.js +32 -0
  104. package/lib/archive/db-ops/pages/reset/repromote-external-pages.d.ts +24 -0
  105. package/lib/archive/db-ops/pages/reset/repromote-external-pages.js +93 -0
  106. package/lib/archive/db-ops/pages/reset/reset-failed-pages.d.ts +47 -0
  107. package/lib/archive/db-ops/pages/reset/reset-failed-pages.js +124 -0
  108. package/lib/archive/db-ops/pages/write/insert-inventory-seeds.d.ts +37 -0
  109. package/lib/archive/db-ops/pages/write/insert-inventory-seeds.js +72 -0
  110. package/lib/archive/db-ops/pages/write/insert-jsonld.d.ts +17 -0
  111. package/lib/archive/db-ops/pages/write/insert-jsonld.js +49 -0
  112. package/lib/archive/db-ops/pages/write/insert-page.d.ts +36 -0
  113. package/lib/archive/db-ops/pages/write/insert-page.js +208 -0
  114. package/lib/archive/db-ops/pages/write/insert-tags.d.ts +16 -0
  115. package/lib/archive/db-ops/pages/write/insert-tags.js +34 -0
  116. package/lib/archive/db-ops/pages/write/link-redirect-sources.d.ts +36 -0
  117. package/lib/archive/db-ops/pages/write/link-redirect-sources.js +93 -0
  118. package/lib/archive/db-ops/pages/write/record-redirect.d.ts +35 -0
  119. package/lib/archive/db-ops/pages/write/record-redirect.js +100 -0
  120. package/lib/archive/db-ops/pages/write/set-skipped-page.d.ts +13 -0
  121. package/lib/archive/db-ops/pages/write/set-skipped-page.js +22 -0
  122. package/lib/archive/db-ops/pages/write/update-page.d.ts +29 -0
  123. package/lib/archive/db-ops/pages/write/update-page.js +334 -0
  124. package/lib/archive/db-ops/pages/write/write-page-html-blob.d.ts +19 -0
  125. package/lib/archive/db-ops/pages/write/write-page-html-blob.js +41 -0
  126. package/lib/archive/db-ops/referrers/get-redirects-for-pages.d.ts +9 -0
  127. package/lib/archive/db-ops/referrers/get-redirects-for-pages.js +15 -0
  128. package/lib/archive/db-ops/referrers/get-referrers-of-page.d.ts +17 -0
  129. package/lib/archive/db-ops/referrers/get-referrers-of-page.js +32 -0
  130. package/lib/archive/db-ops/referrers/get-referrers-of-resource.d.ts +8 -0
  131. package/lib/archive/db-ops/referrers/get-referrers-of-resource.js +15 -0
  132. package/lib/archive/db-ops/resources/build-resource-query.d.ts +25 -0
  133. package/lib/archive/db-ops/resources/build-resource-query.js +29 -0
  134. package/lib/archive/db-ops/resources/get-existing-resource-urls.d.ts +9 -0
  135. package/lib/archive/db-ops/resources/get-existing-resource-urls.js +24 -0
  136. package/lib/archive/db-ops/resources/get-resource-by-url.d.ts +13 -0
  137. package/lib/archive/db-ops/resources/get-resource-by-url.js +22 -0
  138. package/lib/archive/db-ops/resources/get-resource-url-list.d.ts +9 -0
  139. package/lib/archive/db-ops/resources/get-resource-url-list.js +13 -0
  140. package/lib/archive/db-ops/resources/get-resources.d.ts +8 -0
  141. package/lib/archive/db-ops/resources/get-resources.js +11 -0
  142. package/lib/archive/db-ops/resources/insert-inventory-resources.d.ts +24 -0
  143. package/lib/archive/db-ops/resources/insert-inventory-resources.js +64 -0
  144. package/lib/archive/db-ops/resources/insert-resource-referrers.d.ts +15 -0
  145. package/lib/archive/db-ops/resources/insert-resource-referrers.js +54 -0
  146. package/lib/archive/db-ops/resources/insert-resource.d.ts +34 -0
  147. package/lib/archive/db-ops/resources/insert-resource.js +73 -0
  148. package/lib/archive/db-ops/resources/reconstruct-resource-rows.d.ts +26 -0
  149. package/lib/archive/db-ops/resources/reconstruct-resource-rows.js +30 -0
  150. package/lib/archive/decode-html-blob.d.ts +18 -0
  151. package/lib/archive/decode-html-blob.js +31 -0
  152. package/lib/archive/derive-lineage-from-parent.d.ts +1 -1
  153. package/lib/archive/derive-lineage-from-parent.js +1 -1
  154. package/lib/archive/drop-legacy-tables.d.ts +45 -0
  155. package/lib/archive/drop-legacy-tables.js +56 -0
  156. package/lib/archive/filesystem/rename.js +1 -1
  157. package/lib/archive/get-failed-page-messages.d.ts +5 -4
  158. package/lib/archive/get-failed-page-messages.js +5 -4
  159. package/lib/archive/init-schema.d.ts +35 -39
  160. package/lib/archive/init-schema.js +99 -460
  161. package/lib/archive/limited-page-ids.d.ts +2 -1
  162. package/lib/archive/limited-page-ids.js +5 -4
  163. package/lib/archive/meta/assert-compatible-version.d.ts +24 -3
  164. package/lib/archive/meta/assert-compatible-version.js +24 -3
  165. package/lib/archive/meta/types.d.ts +87 -1
  166. package/lib/archive/meta/types.js +34 -2
  167. package/lib/archive/migrate-entity-tables.d.ts +45 -0
  168. package/lib/archive/migrate-entity-tables.js +56 -0
  169. package/lib/archive/migrate-ref-tables.d.ts +25 -0
  170. package/lib/archive/migrate-ref-tables.js +38 -0
  171. package/lib/archive/page-meta-column-maps.d.ts +32 -0
  172. package/lib/archive/page-meta-column-maps.js +43 -0
  173. package/lib/archive/page.d.ts +6 -6
  174. package/lib/archive/page.js +5 -5
  175. package/lib/archive/peek-archive-lock.d.ts +2 -2
  176. package/lib/archive/peek-archive-lock.js +2 -2
  177. package/lib/archive/populate-entity-tables/collapse-anchor-rows.d.ts +41 -0
  178. package/lib/archive/populate-entity-tables/collapse-anchor-rows.js +87 -0
  179. package/lib/archive/populate-entity-tables/derive-dom-path.d.ts +35 -0
  180. package/lib/archive/populate-entity-tables/derive-dom-path.js +72 -0
  181. package/lib/archive/populate-entity-tables/is-blob-ref-value.d.ts +16 -0
  182. package/lib/archive/populate-entity-tables/is-blob-ref-value.js +19 -0
  183. package/lib/archive/populate-entity-tables/match-images-to-dom-paths.d.ts +66 -0
  184. package/lib/archive/populate-entity-tables/match-images-to-dom-paths.js +96 -0
  185. package/lib/archive/populate-entity-tables/populate-anchor-edges.d.ts +33 -0
  186. package/lib/archive/populate-entity-tables/populate-anchor-edges.js +153 -0
  187. package/lib/archive/populate-entity-tables/populate-content-items.d.ts +40 -0
  188. package/lib/archive/populate-entity-tables/populate-content-items.js +141 -0
  189. package/lib/archive/populate-entity-tables/populate-entities.d.ts +81 -0
  190. package/lib/archive/populate-entity-tables/populate-entities.js +111 -0
  191. package/lib/archive/populate-entity-tables/populate-image-items.d.ts +91 -0
  192. package/lib/archive/populate-entity-tables/populate-image-items.js +223 -0
  193. package/lib/archive/populate-entity-tables/populate-page-meta.d.ts +33 -0
  194. package/lib/archive/populate-entity-tables/populate-page-meta.js +267 -0
  195. package/lib/archive/populate-entity-tables/populate-resource-items.d.ts +22 -0
  196. package/lib/archive/populate-entity-tables/populate-resource-items.js +114 -0
  197. package/lib/archive/populate-entity-tables/populate-resource-ref-edges.d.ts +31 -0
  198. package/lib/archive/populate-entity-tables/populate-resource-ref-edges.js +33 -0
  199. package/lib/archive/populate-entity-tables/resolve-blob-refs.d.ts +31 -0
  200. package/lib/archive/populate-entity-tables/resolve-blob-refs.js +100 -0
  201. package/lib/archive/populate-entity-tables/resolve-content-type-refs.d.ts +22 -0
  202. package/lib/archive/populate-entity-tables/resolve-content-type-refs.js +27 -0
  203. package/lib/archive/populate-entity-tables/resolve-header-sets.d.ts +49 -0
  204. package/lib/archive/populate-entity-tables/resolve-header-sets.js +122 -0
  205. package/lib/archive/populate-entity-tables/resolve-json-refs.d.ts +25 -0
  206. package/lib/archive/populate-entity-tables/resolve-json-refs.js +67 -0
  207. package/lib/archive/populate-entity-tables/resolve-text-refs.d.ts +30 -0
  208. package/lib/archive/populate-entity-tables/resolve-text-refs.js +61 -0
  209. package/lib/archive/populate-entity-tables/resolve-url-or-blob-from-maps.d.ts +21 -0
  210. package/lib/archive/populate-entity-tables/resolve-url-or-blob-from-maps.js +27 -0
  211. package/lib/archive/populate-entity-tables/resolve-url-refs.d.ts +33 -0
  212. package/lib/archive/populate-entity-tables/resolve-url-refs.js +60 -0
  213. package/lib/archive/populate-entity-tables/test-utils/count-rows.d.ts +17 -0
  214. package/lib/archive/populate-entity-tables/test-utils/count-rows.js +20 -0
  215. package/lib/archive/populate-entity-tables/test-utils/seed-content-items.d.ts +25 -0
  216. package/lib/archive/populate-entity-tables/test-utils/seed-content-items.js +42 -0
  217. package/lib/archive/populate-entity-tables/test-utils/setup-entities-db.d.ts +23 -0
  218. package/lib/archive/populate-entity-tables/test-utils/setup-entities-db.js +178 -0
  219. package/lib/archive/populate-entity-tables/types.d.ts +157 -0
  220. package/lib/archive/populate-entity-tables/types.js +12 -0
  221. package/lib/archive/populate-entity-tables/upsert-text-refs.d.ts +38 -0
  222. package/lib/archive/populate-entity-tables/upsert-text-refs.js +78 -0
  223. package/lib/archive/populate-ref-tables/classify-content-type.d.ts +16 -0
  224. package/lib/archive/populate-ref-tables/classify-content-type.js +52 -0
  225. package/lib/archive/populate-ref-tables/compute-content-hash.d.ts +22 -0
  226. package/lib/archive/populate-ref-tables/compute-content-hash.js +26 -0
  227. package/lib/archive/populate-ref-tables/compute-header-flags.d.ts +16 -0
  228. package/lib/archive/populate-ref-tables/compute-header-flags.js +70 -0
  229. package/lib/archive/populate-ref-tables/content-type-rules.d.ts +38 -0
  230. package/lib/archive/populate-ref-tables/content-type-rules.js +133 -0
  231. package/lib/archive/populate-ref-tables/create-header-table-caches.d.ts +25 -0
  232. package/lib/archive/populate-ref-tables/create-header-table-caches.js +49 -0
  233. package/lib/archive/populate-ref-tables/data-uri-url-refs-limit.d.ts +15 -0
  234. package/lib/archive/populate-ref-tables/data-uri-url-refs-limit.js +15 -0
  235. package/lib/archive/populate-ref-tables/decode-data-uri.d.ts +21 -0
  236. package/lib/archive/populate-ref-tables/decode-data-uri.js +126 -0
  237. package/lib/archive/populate-ref-tables/decompose-header-set.d.ts +29 -0
  238. package/lib/archive/populate-ref-tables/decompose-header-set.js +157 -0
  239. package/lib/archive/populate-ref-tables/decompose-url.d.ts +25 -0
  240. package/lib/archive/populate-ref-tables/decompose-url.js +70 -0
  241. package/lib/archive/populate-ref-tables/header-stability.d.ts +19 -0
  242. package/lib/archive/populate-ref-tables/header-stability.js +22 -0
  243. package/lib/archive/populate-ref-tables/header-value-cache-key.d.ts +17 -0
  244. package/lib/archive/populate-ref-tables/header-value-cache-key.js +19 -0
  245. package/lib/archive/populate-ref-tables/normalize-mime.d.ts +24 -0
  246. package/lib/archive/populate-ref-tables/normalize-mime.js +36 -0
  247. package/lib/archive/populate-ref-tables/populate-blob-refs.d.ts +38 -0
  248. package/lib/archive/populate-ref-tables/populate-blob-refs.js +134 -0
  249. package/lib/archive/populate-ref-tables/populate-content-type-refs.d.ts +27 -0
  250. package/lib/archive/populate-ref-tables/populate-content-type-refs.js +70 -0
  251. package/lib/archive/populate-ref-tables/populate-header-tables.d.ts +35 -0
  252. package/lib/archive/populate-ref-tables/populate-header-tables.js +80 -0
  253. package/lib/archive/populate-ref-tables/populate-json-refs.d.ts +29 -0
  254. package/lib/archive/populate-ref-tables/populate-json-refs.js +101 -0
  255. package/lib/archive/populate-ref-tables/populate-refs.d.ts +51 -0
  256. package/lib/archive/populate-ref-tables/populate-refs.js +62 -0
  257. package/lib/archive/populate-ref-tables/populate-text-refs.d.ts +32 -0
  258. package/lib/archive/populate-ref-tables/populate-text-refs.js +133 -0
  259. package/lib/archive/populate-ref-tables/populate-url-refs.d.ts +28 -0
  260. package/lib/archive/populate-ref-tables/populate-url-refs.js +148 -0
  261. package/lib/archive/populate-ref-tables/test-utils/count-rows.d.ts +15 -0
  262. package/lib/archive/populate-ref-tables/test-utils/count-rows.js +17 -0
  263. package/lib/archive/populate-ref-tables/types.d.ts +197 -0
  264. package/lib/archive/populate-ref-tables/types.js +7 -0
  265. package/lib/archive/populate-ref-tables/upsert-one-header-set.d.ts +34 -0
  266. package/lib/archive/populate-ref-tables/upsert-one-header-set.js +208 -0
  267. package/lib/archive/populate-ref-tables/volatile-header-names.d.ts +20 -0
  268. package/lib/archive/populate-ref-tables/volatile-header-names.js +33 -0
  269. package/lib/archive/redirect-table.d.ts +4 -2
  270. package/lib/archive/redirect-table.js +15 -10
  271. package/lib/archive/resolve-redirect-chain.d.ts +3 -3
  272. package/lib/archive/resolve-redirect-chain.js +2 -2
  273. package/lib/archive/resource.d.ts +1 -1
  274. package/lib/archive/retarget-legacy-fk-tables.d.ts +47 -0
  275. package/lib/archive/retarget-legacy-fk-tables.js +107 -0
  276. package/lib/archive/test-utils/fk-parent-tables.d.ts +15 -0
  277. package/lib/archive/test-utils/fk-parent-tables.js +19 -0
  278. package/lib/archive/test-utils/seed-content-item.d.ts +35 -0
  279. package/lib/archive/test-utils/seed-content-item.js +42 -0
  280. package/lib/archive/test-utils/setup-legacy-fk-db.d.ts +33 -0
  281. package/lib/archive/test-utils/setup-legacy-fk-db.js +270 -0
  282. package/lib/archive/types.d.ts +127 -24
  283. package/lib/archive/verify-migration/capture-rejection.d.ts +24 -0
  284. package/lib/archive/verify-migration/capture-rejection.js +31 -0
  285. package/lib/archive/verify-migration/check-anchor-edges-count.d.ts +34 -0
  286. package/lib/archive/verify-migration/check-anchor-edges-count.js +72 -0
  287. package/lib/archive/verify-migration/check-anchor-edges-sum.d.ts +13 -0
  288. package/lib/archive/verify-migration/check-anchor-edges-sum.js +27 -0
  289. package/lib/archive/verify-migration/check-content-items-count.d.ts +16 -0
  290. package/lib/archive/verify-migration/check-content-items-count.js +30 -0
  291. package/lib/archive/verify-migration/check-content-type-preservation.d.ts +22 -0
  292. package/lib/archive/verify-migration/check-content-type-preservation.js +40 -0
  293. package/lib/archive/verify-migration/check-foreign-key-integrity.d.ts +31 -0
  294. package/lib/archive/verify-migration/check-foreign-key-integrity.js +47 -0
  295. package/lib/archive/verify-migration/check-image-items-count.d.ts +12 -0
  296. package/lib/archive/verify-migration/check-image-items-count.js +26 -0
  297. package/lib/archive/verify-migration/check-page-meta-count.d.ts +15 -0
  298. package/lib/archive/verify-migration/check-page-meta-count.js +31 -0
  299. package/lib/archive/verify-migration/check-reader-parity.d.ts +23 -0
  300. package/lib/archive/verify-migration/check-reader-parity.js +211 -0
  301. package/lib/archive/verify-migration/check-resource-items-count.d.ts +17 -0
  302. package/lib/archive/verify-migration/check-resource-items-count.js +33 -0
  303. package/lib/archive/verify-migration/check-url-round-trip.d.ts +43 -0
  304. package/lib/archive/verify-migration/check-url-round-trip.js +112 -0
  305. package/lib/archive/verify-migration/types.d.ts +70 -0
  306. package/lib/archive/verify-migration/types.js +63 -0
  307. package/lib/archive/verify-migration/verify-migration.d.ts +41 -0
  308. package/lib/archive/verify-migration/verify-migration.js +120 -0
  309. package/lib/crawler/build-redirect-event.d.ts +1 -1
  310. package/lib/crawler/build-redirect-event.js +1 -1
  311. package/lib/crawler/capture-image-dom-paths.d.ts +33 -0
  312. package/lib/crawler/capture-image-dom-paths.js +39 -0
  313. package/lib/crawler/clear-dns-burned-host-cache.d.ts +1 -1
  314. package/lib/crawler/clear-dns-burned-host-cache.js +1 -1
  315. package/lib/crawler/collect-image-dom-paths.d.ts +23 -0
  316. package/lib/crawler/collect-image-dom-paths.js +64 -0
  317. package/lib/crawler/crawler.d.ts +19 -0
  318. package/lib/crawler/crawler.js +40 -26
  319. package/lib/crawler/dns-burned-host-cache.d.ts +3 -3
  320. package/lib/crawler/dns-burned-host-cache.js +3 -3
  321. package/lib/crawler/dns-burned-host-short-circuit-counter.d.ts +2 -2
  322. package/lib/crawler/dns-burned-host-short-circuit-counter.js +2 -2
  323. package/lib/crawler/inject-scope-auth.d.ts +1 -1
  324. package/lib/crawler/inject-scope-auth.js +1 -1
  325. package/lib/crawler/normalize-content-type.d.ts +1 -1
  326. package/lib/crawler/normalize-content-type.js +1 -1
  327. package/lib/crawler/types.d.ts +3 -3
  328. package/lib/crawler-orchestrator.d.ts +9 -0
  329. package/lib/crawler-orchestrator.js +44 -28
  330. package/lib/crawler.d.ts +12 -0
  331. package/lib/crawler.js +21 -0
  332. package/lib/permanent-error-kinds.d.ts +1 -1
  333. package/lib/permanent-error-kinds.js +1 -1
  334. package/lib/types.d.ts +1 -1
  335. package/lib/utils/compute-file-sha256.d.ts +5 -4
  336. package/lib/utils/compute-file-sha256.js +5 -4
  337. package/lib/utils/error/emit-error-with-retry.d.ts +1 -1
  338. package/lib/utils/error/emit-error-with-retry.js +1 -1
  339. package/package.json +10 -10
  340. package/lib/archive/migrate-crawl-errors.d.ts +0 -20
  341. package/lib/archive/migrate-crawl-errors.js +0 -38
  342. package/lib/archive/migrate-html-blob-tables.d.ts +0 -24
  343. package/lib/archive/migrate-html-blob-tables.js +0 -53
  344. package/lib/archive/migrate-inventory-runs.d.ts +0 -29
  345. package/lib/archive/migrate-inventory-runs.js +0 -52
  346. package/lib/archive/migrate-page-errors.d.ts +0 -16
  347. package/lib/archive/migrate-page-errors.js +0 -35
  348. package/lib/archive/migrate-pages-resources-source.d.ts +0 -16
  349. package/lib/archive/migrate-pages-resources-source.js +0 -46
@@ -5,10 +5,11 @@ import { crawlerLog } from '../debug.js';
5
5
  * Compute the SHA-256 digest of a file's bytes, streaming so memory stays
6
6
  * O(1) regardless of file size.
7
7
  *
8
- * Used by {@link CrawlerOrchestrator.inventory} to fingerprint the source
9
- * URL list `.txt` and store the digest on the `inventory_runs` row.
10
- * Phase 3 (`--refresh`) will key dedupe on this column; Phase 1 just
11
- * records it for operator audit.
8
+ * Used by `CrawlerOrchestrator.inventory` to fingerprint the source
9
+ * URL list `.txt` and store the digest on the `inventory_runs` row. The
10
+ * digest is the content-identity key for "was this exact list applied
11
+ * before" recorded for operator audit; nothing dedupes on it at write
12
+ * time.
12
13
  *
13
14
  * Returns `null` instead of throwing when the file cannot be read (e.g.
14
15
  * vanished mid-run, permissions issue) so the inventory run's audit row
@@ -21,7 +21,7 @@ interface Emitter {
21
21
  * derived automatically by the `@retry` decorator via
22
22
  * `ClassMethodDecoratorContext.name`).
23
23
  *
24
- * Inlined try/catch rather than composing {@link emitError} with a
24
+ * Inlined try/catch rather than composing `emitError` with a
25
25
  * `() => retryCall(...)` closure to keep the per-invocation closure count
26
26
  * at 1 — this method is called on the DB write hot path (`updatePage`,
27
27
  * `insertResource`), where wrapping decorators previously ran with zero
@@ -15,7 +15,7 @@ const errorLog = log.extend('ErrorEmitter');
15
15
  * derived automatically by the `@retry` decorator via
16
16
  * `ClassMethodDecoratorContext.name`).
17
17
  *
18
- * Inlined try/catch rather than composing {@link emitError} with a
18
+ * Inlined try/catch rather than composing `emitError` with a
19
19
  * `() => retryCall(...)` closure to keep the per-invocation closure count
20
20
  * at 1 — this method is called on the DB write hot path (`updatePage`,
21
21
  * `insertResource`), where wrapping decorators previously ran with zero
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitpicker/crawler",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Web crawler engine with headless browser rendering and archive storage",
5
5
  "author": "D-ZERO",
6
6
  "license": "Apache-2.0",
@@ -27,19 +27,19 @@
27
27
  "clean": "tsc --build --clean"
28
28
  },
29
29
  "dependencies": {
30
- "@d-zero/beholder": "3.1.3",
31
- "@d-zero/dealer": "1.9.3",
32
- "@d-zero/fs": "0.2.5",
33
- "@d-zero/shared": "0.22.1",
30
+ "@d-zero/beholder": "3.1.5",
31
+ "@d-zero/dealer": "1.9.4",
32
+ "@d-zero/fs": "0.2.6",
33
+ "@d-zero/shared": "0.22.2",
34
34
  "ansi-colors": "4.1.3",
35
35
  "debug": "4.4.3",
36
36
  "follow-redirects": "1.16.0",
37
- "fs-extra": "11.3.5",
38
- "knex": "3.2.10",
37
+ "fs-extra": "11.3.6",
38
+ "knex": "3.3.0",
39
39
  "libsql": "0.5.29",
40
- "puppeteer": "24.37.5",
40
+ "puppeteer": "25.3.0",
41
41
  "robots-parser": "3.0.1",
42
- "tar": "7.5.16"
42
+ "tar": "7.5.20"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "4.1.13",
@@ -48,5 +48,5 @@
48
48
  "@types/tar": "7.0.87",
49
49
  "@types/unzipper": "0.10.11"
50
50
  },
51
- "gitHead": "58b68416e0b6e3dcdd92772bee754f186a35505f"
51
+ "gitHead": "2cd462ea6b183f4462b7caba27b4db04aaba7c70"
52
52
  }
@@ -1,20 +0,0 @@
1
- import type { Knex } from 'knex';
2
- /**
3
- * Adds the `crawl_errors` table to archives created before structured capture
4
- * of the crawler-level `error` channel landed.
5
- *
6
- * `crawl_errors` records errors that previously only reached `error.log` (DNS
7
- * failures, connection resets, TLS problems, process-level errors), in a
8
- * queryable form so the `error-kinds` analysis can classify them without
9
- * parsing the text log. Older `.nitpicker` files predate this table; this
10
- * migration creates it idempotently. Existing archives stay empty until they
11
- * are crawled again (resume / append / retry), at which point new errors are
12
- * written here — analysis of pre-existing data falls back to parsing
13
- * `error.log`.
14
- *
15
- * Idempotent: when the table already exists, the function exits without
16
- * touching the schema or writing to stderr. It also skips empty archives (no
17
- * `pages` table), which the regular initSchema path will fully provision.
18
- * @param instance - The Knex query builder instance connected to the database.
19
- */
20
- export declare function migrateCrawlErrors(instance: Knex): Promise<void>;
@@ -1,38 +0,0 @@
1
- /**
2
- * Adds the `crawl_errors` table to archives created before structured capture
3
- * of the crawler-level `error` channel landed.
4
- *
5
- * `crawl_errors` records errors that previously only reached `error.log` (DNS
6
- * failures, connection resets, TLS problems, process-level errors), in a
7
- * queryable form so the `error-kinds` analysis can classify them without
8
- * parsing the text log. Older `.nitpicker` files predate this table; this
9
- * migration creates it idempotently. Existing archives stay empty until they
10
- * are crawled again (resume / append / retry), at which point new errors are
11
- * written here — analysis of pre-existing data falls back to parsing
12
- * `error.log`.
13
- *
14
- * Idempotent: when the table already exists, the function exits without
15
- * touching the schema or writing to stderr. It also skips empty archives (no
16
- * `pages` table), which the regular initSchema path will fully provision.
17
- * @param instance - The Knex query builder instance connected to the database.
18
- */
19
- export async function migrateCrawlErrors(instance) {
20
- const hasTable = await instance.schema.hasTable('crawl_errors');
21
- if (hasTable) {
22
- return;
23
- }
24
- const hasPages = await instance.schema.hasTable('pages');
25
- if (!hasPages) {
26
- // Empty archive; the regular initSchema path will create the table.
27
- return;
28
- }
29
- await instance.schema.createTable('crawl_errors', (t) => {
30
- t.increments('id');
31
- t.string('url', 8190).nullable();
32
- t.boolean('isExternal');
33
- t.text('message').notNullable();
34
- t.integer('createdAt').notNullable();
35
- });
36
- // eslint-disable-next-line no-console
37
- console.error('[migrate] crawl_errors table created');
38
- }
@@ -1,24 +0,0 @@
1
- import type { Knex } from 'knex';
2
- /**
3
- * Adds the BLOB-backed HTML snapshot tables (`page_html_blobs` +
4
- * `page_html_ref`) to archives created before #75.
5
- *
6
- * A pre-#75 `.nitpicker` already has the `info` table, so `initSchema`'s
7
- * early-return path skips the freshly-introduced `CREATE TABLE`s. This
8
- * migration brings the schema forward idempotently so the read API stops
9
- * raising raw "no such table" errors against legacy archives. It does NOT
10
- * touch the `pages.html` column or backfill the new tables from the
11
- * archive's `snapshot-html.zip`: that data migration belongs to the
12
- * `scripts/migrate-to-0.10.mjs` one-shot, which can run whenever the
13
- * user is ready to commit the (multi-hour) CPU cost.
14
- *
15
- * Outcome on a legacy archive that has NOT yet been data-migrated:
16
- * - new tables exist but are empty,
17
- * - `getHtmlOfPageById` returns `null` for every page (no row in `page_html_ref`),
18
- * - viewer / MCP / analyze plugins see "snapshot unavailable" instead of crashing.
19
- *
20
- * The migration prints a one-line notice when it runs so the user knows
21
- * the archive was upgraded in place.
22
- * @param instance - The Knex query builder instance connected to the database.
23
- */
24
- export declare function migrateHtmlBlobTables(instance: Knex): Promise<void>;
@@ -1,53 +0,0 @@
1
- /**
2
- * Adds the BLOB-backed HTML snapshot tables (`page_html_blobs` +
3
- * `page_html_ref`) to archives created before #75.
4
- *
5
- * A pre-#75 `.nitpicker` already has the `info` table, so `initSchema`'s
6
- * early-return path skips the freshly-introduced `CREATE TABLE`s. This
7
- * migration brings the schema forward idempotently so the read API stops
8
- * raising raw "no such table" errors against legacy archives. It does NOT
9
- * touch the `pages.html` column or backfill the new tables from the
10
- * archive's `snapshot-html.zip`: that data migration belongs to the
11
- * `scripts/migrate-to-0.10.mjs` one-shot, which can run whenever the
12
- * user is ready to commit the (multi-hour) CPU cost.
13
- *
14
- * Outcome on a legacy archive that has NOT yet been data-migrated:
15
- * - new tables exist but are empty,
16
- * - `getHtmlOfPageById` returns `null` for every page (no row in `page_html_ref`),
17
- * - viewer / MCP / analyze plugins see "snapshot unavailable" instead of crashing.
18
- *
19
- * The migration prints a one-line notice when it runs so the user knows
20
- * the archive was upgraded in place.
21
- * @param instance - The Knex query builder instance connected to the database.
22
- */
23
- export async function migrateHtmlBlobTables(instance) {
24
- const hasBlobs = await instance.schema.hasTable('page_html_blobs');
25
- if (hasBlobs) {
26
- return;
27
- }
28
- const hasPages = await instance.schema.hasTable('pages');
29
- if (!hasPages) {
30
- // Empty archive; initSchema will create both tables on the
31
- // fresh-DB path. Nothing to migrate.
32
- return;
33
- }
34
- await instance.raw(`
35
- CREATE TABLE page_html_blobs (
36
- hash BLOB PRIMARY KEY,
37
- body BLOB NOT NULL,
38
- codec TEXT NOT NULL CHECK(codec IN ('zstd', 'none')),
39
- size_raw INTEGER NOT NULL,
40
- size_stored INTEGER NOT NULL
41
- ) WITHOUT ROWID
42
- `);
43
- await instance.raw(`
44
- CREATE TABLE page_html_ref (
45
- page_id INTEGER PRIMARY KEY REFERENCES pages(id) ON DELETE CASCADE,
46
- hash BLOB NOT NULL REFERENCES page_html_blobs(hash)
47
- ) WITHOUT ROWID
48
- `);
49
- await instance.raw('CREATE INDEX idx_page_html_ref_hash ON page_html_ref(hash)');
50
- // eslint-disable-next-line no-console
51
- console.error('[migrate] page_html_blobs / page_html_ref tables created. ' +
52
- 'HTML snapshots are empty until `node scripts/migrate-to-0.10.mjs` is run on the original archive.');
53
- }
@@ -1,29 +0,0 @@
1
- import type { Knex } from 'knex';
2
- /**
3
- * Adds the `inventory_runs` audit-log table to archives created before
4
- * Phase 1 of inventory run tracking shipped.
5
- *
6
- * `inventory_runs` records one row per successful `--inventory <list>`
7
- * invocation, capturing which deploy list was applied when and what
8
- * scale it operated at. The motivation is operational: client /
9
- * director conversations repeatedly ask "did you apply last month's
10
- * list" / "we didn't double-apply, right" — the archive itself had no
11
- * trace of inventory passes (`.bak` is unlinked on success), so this
12
- * table is the durable provenance record.
13
- *
14
- * Schema details (column semantics, NULL policy, index) live in
15
- * {@link initSchema} — this migration only re-creates the table shape
16
- * on legacy archives so the rest of the codebase can treat the table
17
- * as always-present once a writer connection has opened the file.
18
- *
19
- * Idempotent: when the table already exists, the function exits
20
- * silently — the `[migrate] inventory_runs table created` stderr line
21
- * fires **only** on the first run against a legacy archive, matching
22
- * the established pattern of `migrate-page-errors.ts` /
23
- * `migrate-crawl-errors.ts`. Operators can rely on the log line as a
24
- * stable "first time this archive saw Phase 1 schema" event marker.
25
- * Empty archives (no `pages` table) are skipped entirely; the regular
26
- * `initSchema` path provisions them at first crawl.
27
- * @param instance - The Knex query builder instance connected to the database.
28
- */
29
- export declare function migrateInventoryRuns(instance: Knex): Promise<void>;
@@ -1,52 +0,0 @@
1
- /**
2
- * Adds the `inventory_runs` audit-log table to archives created before
3
- * Phase 1 of inventory run tracking shipped.
4
- *
5
- * `inventory_runs` records one row per successful `--inventory <list>`
6
- * invocation, capturing which deploy list was applied when and what
7
- * scale it operated at. The motivation is operational: client /
8
- * director conversations repeatedly ask "did you apply last month's
9
- * list" / "we didn't double-apply, right" — the archive itself had no
10
- * trace of inventory passes (`.bak` is unlinked on success), so this
11
- * table is the durable provenance record.
12
- *
13
- * Schema details (column semantics, NULL policy, index) live in
14
- * {@link initSchema} — this migration only re-creates the table shape
15
- * on legacy archives so the rest of the codebase can treat the table
16
- * as always-present once a writer connection has opened the file.
17
- *
18
- * Idempotent: when the table already exists, the function exits
19
- * silently — the `[migrate] inventory_runs table created` stderr line
20
- * fires **only** on the first run against a legacy archive, matching
21
- * the established pattern of `migrate-page-errors.ts` /
22
- * `migrate-crawl-errors.ts`. Operators can rely on the log line as a
23
- * stable "first time this archive saw Phase 1 schema" event marker.
24
- * Empty archives (no `pages` table) are skipped entirely; the regular
25
- * `initSchema` path provisions them at first crawl.
26
- * @param instance - The Knex query builder instance connected to the database.
27
- */
28
- export async function migrateInventoryRuns(instance) {
29
- const hasTable = await instance.schema.hasTable('inventory_runs');
30
- if (hasTable) {
31
- return;
32
- }
33
- const hasPages = await instance.schema.hasTable('pages');
34
- if (!hasPages) {
35
- // Empty archive; the regular initSchema path will create the table.
36
- return;
37
- }
38
- await instance.schema.createTable('inventory_runs', (t) => {
39
- t.increments('id');
40
- t.string('ran_at').notNullable();
41
- t.string('list_label').nullable();
42
- t.string('source_file_sha256', 64).nullable();
43
- t.integer('total_lines').nullable();
44
- t.integer('new_pages').nullable();
45
- t.integer('new_resources').nullable();
46
- t.integer('scope_skipped').nullable();
47
- t.text('notes').nullable();
48
- t.index('ran_at');
49
- });
50
- // eslint-disable-next-line no-console
51
- console.error('[migrate] inventory_runs table created');
52
- }
@@ -1,16 +0,0 @@
1
- import type { Knex } from 'knex';
2
- /**
3
- * Adds the `page_errors` table to archives created before partial-failure
4
- * recording landed.
5
- *
6
- * `page_errors` captures secondary scrape failures (e.g. a viewport switch
7
- * that detaches the frame and surfaces `retryExhausted`) so they show up in
8
- * the archive instead of being lost to stdout logs. Older `.nitpicker` files
9
- * predate this table; this migration creates it idempotently.
10
- *
11
- * Idempotent: when the table already exists, the function exits without
12
- * touching the schema or writing to stderr. When it has to run, a single
13
- * notice is written so the user knows the file was upgraded.
14
- * @param instance - The Knex query builder instance connected to the database.
15
- */
16
- export declare function migratePageErrors(instance: Knex): Promise<void>;
@@ -1,35 +0,0 @@
1
- /**
2
- * Adds the `page_errors` table to archives created before partial-failure
3
- * recording landed.
4
- *
5
- * `page_errors` captures secondary scrape failures (e.g. a viewport switch
6
- * that detaches the frame and surfaces `retryExhausted`) so they show up in
7
- * the archive instead of being lost to stdout logs. Older `.nitpicker` files
8
- * predate this table; this migration creates it idempotently.
9
- *
10
- * Idempotent: when the table already exists, the function exits without
11
- * touching the schema or writing to stderr. When it has to run, a single
12
- * notice is written so the user knows the file was upgraded.
13
- * @param instance - The Knex query builder instance connected to the database.
14
- */
15
- export async function migratePageErrors(instance) {
16
- const hasTable = await instance.schema.hasTable('page_errors');
17
- if (hasTable) {
18
- return;
19
- }
20
- const hasPages = await instance.schema.hasTable('pages');
21
- if (!hasPages) {
22
- // Empty archive; the regular initSchema path will create both tables.
23
- return;
24
- }
25
- await instance.schema.createTable('page_errors', (t) => {
26
- t.increments('id');
27
- t.integer('pageId').notNullable().unsigned().references('pages.id');
28
- t.string('phase').notNullable();
29
- t.text('message').notNullable();
30
- t.integer('createdAt').notNullable();
31
- t.index('pageId');
32
- });
33
- // eslint-disable-next-line no-console
34
- console.error('[migrate] page_errors table created');
35
- }
@@ -1,16 +0,0 @@
1
- import type { Knex } from 'knex';
2
- /**
3
- * Add `pages.source` and `resources.source` columns (provenance taxonomy:
4
- * `crawled` / `inventory-seed` / `inventory-discovered`) and their indexes
5
- * to archives that pre-date the `crawl --inventory` feature.
6
- *
7
- * Idempotent: a no-op when both columns already exist. SQLite's
8
- * `ALTER TABLE ADD COLUMN` with a NOT NULL DEFAULT applies the default to
9
- * every existing row at column-add time, so no explicit `UPDATE` is needed
10
- * to backfill — pre-existing rows become `'crawled'` automatically.
11
- *
12
- * Runs only on writer-side {@link Database.connect}; read-only viewer
13
- * attaches skip this so the user's tmpDir is never rewritten.
14
- * @param instance - The Knex query builder instance connected to the database.
15
- */
16
- export declare function migratePagesResourcesSource(instance: Knex): Promise<void>;
@@ -1,46 +0,0 @@
1
- /**
2
- * Add `pages.source` and `resources.source` columns (provenance taxonomy:
3
- * `crawled` / `inventory-seed` / `inventory-discovered`) and their indexes
4
- * to archives that pre-date the `crawl --inventory` feature.
5
- *
6
- * Idempotent: a no-op when both columns already exist. SQLite's
7
- * `ALTER TABLE ADD COLUMN` with a NOT NULL DEFAULT applies the default to
8
- * every existing row at column-add time, so no explicit `UPDATE` is needed
9
- * to backfill — pre-existing rows become `'crawled'` automatically.
10
- *
11
- * Runs only on writer-side {@link Database.connect}; read-only viewer
12
- * attaches skip this so the user's tmpDir is never rewritten.
13
- * @param instance - The Knex query builder instance connected to the database.
14
- */
15
- export async function migratePagesResourcesSource(instance) {
16
- const hasPages = await instance.schema.hasTable('pages');
17
- const hasResources = await instance.schema.hasTable('resources');
18
- if (!hasPages && !hasResources) {
19
- return;
20
- }
21
- const hasPagesSource = hasPages && (await instance.schema.hasColumn('pages', 'source'));
22
- const hasResourcesSource = hasResources && (await instance.schema.hasColumn('resources', 'source'));
23
- if (hasPagesSource && hasResourcesSource) {
24
- return;
25
- }
26
- const changes = [];
27
- if (hasPages && !hasPagesSource) {
28
- await instance.schema.table('pages', (t) => {
29
- t.string('source').notNullable().defaultTo('crawled');
30
- t.index('source');
31
- });
32
- changes.push('pages.source added');
33
- }
34
- if (hasResources && !hasResourcesSource) {
35
- await instance.schema.table('resources', (t) => {
36
- t.string('source').notNullable().defaultTo('crawled');
37
- t.index('source');
38
- });
39
- changes.push('resources.source added');
40
- }
41
- if (changes.length === 0) {
42
- return;
43
- }
44
- // eslint-disable-next-line no-console
45
- console.error(`[migrate] ${changes.join(', ')}`);
46
- }