@nitpicker/archive 0.0.0-stage → 0.25.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.
- package/LICENSE +191 -0
- package/README.md +105 -2
- package/lib/apply-connection-pragmas.d.ts +18 -0
- package/lib/apply-connection-pragmas.js +40 -0
- package/lib/archive-accessor.d.ts +265 -0
- package/lib/archive-accessor.js +477 -0
- package/lib/archive-lock.d.ts +45 -0
- package/lib/archive-lock.js +154 -0
- package/lib/archive.d.ts +736 -0
- package/lib/archive.js +1056 -0
- package/lib/body-hash/compute-body-hash.d.ts +32 -0
- package/lib/body-hash/compute-body-hash.js +35 -0
- package/lib/cache/clear-archive-cache-entry.d.ts +18 -0
- package/lib/cache/clear-archive-cache-entry.js +24 -0
- package/lib/cache/clear-archive-cache-root.d.ts +26 -0
- package/lib/cache/clear-archive-cache-root.js +32 -0
- package/lib/cache/compute-archive-cache-key.d.ts +39 -0
- package/lib/cache/compute-archive-cache-key.js +95 -0
- package/lib/cache/extract-archive-to-cache.d.ts +57 -0
- package/lib/cache/extract-archive-to-cache.js +326 -0
- package/lib/cache/get-archive-cache-root.d.ts +20 -0
- package/lib/cache/get-archive-cache-root.js +53 -0
- package/lib/cache/is-archive-cache-disabled.d.ts +24 -0
- package/lib/cache/is-archive-cache-disabled.js +34 -0
- package/lib/cache/list-archive-cache-entries.d.ts +23 -0
- package/lib/cache/list-archive-cache-entries.js +130 -0
- package/lib/cache/path-exists.d.ts +9 -0
- package/lib/cache/path-exists.js +18 -0
- package/lib/cache/resolve-archive-cache-dir.d.ts +26 -0
- package/lib/cache/resolve-archive-cache-dir.js +32 -0
- package/lib/cache/types.d.ts +33 -0
- package/lib/cache/types.js +1 -0
- package/lib/content-type/is-html-content-type.d.ts +17 -0
- package/lib/content-type/is-html-content-type.js +19 -0
- package/lib/content-type/normalize-content-type.d.ts +14 -0
- package/lib/content-type/normalize-content-type.js +20 -0
- package/lib/create-adjunct-tables.d.ts +66 -0
- package/lib/create-adjunct-tables.js +510 -0
- package/lib/create-entity-tables.d.ts +191 -0
- package/lib/create-entity-tables.js +387 -0
- package/lib/create-progress-reporter.d.ts +30 -0
- package/lib/create-progress-reporter.js +38 -0
- package/lib/create-ref-tables.d.ts +35 -0
- package/lib/create-ref-tables.js +185 -0
- package/lib/create-template-tables.d.ts +28 -0
- package/lib/create-template-tables.js +92 -0
- package/lib/database.d.ts +549 -0
- package/lib/database.js +804 -0
- package/lib/db-ops/_shared/clear-write-ref-caches.d.ts +27 -0
- package/lib/db-ops/_shared/clear-write-ref-caches.js +35 -0
- package/lib/db-ops/_shared/compress-payload.d.ts +26 -0
- package/lib/db-ops/_shared/compress-payload.js +30 -0
- package/lib/db-ops/_shared/create-write-ref-caches.d.ts +17 -0
- package/lib/db-ops/_shared/create-write-ref-caches.js +27 -0
- package/lib/db-ops/_shared/decode-json-ref.d.ts +17 -0
- package/lib/db-ops/_shared/decode-json-ref.js +31 -0
- package/lib/db-ops/_shared/keyset-paginate-by-id.d.ts +49 -0
- package/lib/db-ops/_shared/keyset-paginate-by-id.js +69 -0
- package/lib/db-ops/_shared/load-response-headers-by-set-ids.d.ts +20 -0
- package/lib/db-ops/_shared/load-response-headers-by-set-ids.js +53 -0
- package/lib/db-ops/_shared/resolve-content-item-id.d.ts +62 -0
- package/lib/db-ops/_shared/resolve-content-item-id.js +143 -0
- package/lib/db-ops/_shared/resolve-url-or-blob.d.ts +23 -0
- package/lib/db-ops/_shared/resolve-url-or-blob.js +29 -0
- package/lib/db-ops/_shared/retry-setting.d.ts +16 -0
- package/lib/db-ops/_shared/retry-setting.js +18 -0
- package/lib/db-ops/_shared/safe-parse-json.d.ts +11 -0
- package/lib/db-ops/_shared/safe-parse-json.js +18 -0
- package/lib/db-ops/_shared/types.d.ts +94 -0
- package/lib/db-ops/_shared/types.js +1 -0
- package/lib/db-ops/_shared/upsert-blob-ref.d.ts +25 -0
- package/lib/db-ops/_shared/upsert-blob-ref.js +48 -0
- package/lib/db-ops/_shared/upsert-content-type-ref.d.ts +30 -0
- package/lib/db-ops/_shared/upsert-content-type-ref.js +45 -0
- package/lib/db-ops/_shared/upsert-json-ref.d.ts +22 -0
- package/lib/db-ops/_shared/upsert-json-ref.js +41 -0
- package/lib/db-ops/_shared/upsert-response-headers.d.ts +35 -0
- package/lib/db-ops/_shared/upsert-response-headers.js +49 -0
- package/lib/db-ops/_shared/upsert-url-ref.d.ts +39 -0
- package/lib/db-ops/_shared/upsert-url-ref.js +62 -0
- package/lib/db-ops/anchors/get-anchors-on-page.d.ts +10 -0
- package/lib/db-ops/anchors/get-anchors-on-page.js +21 -0
- package/lib/db-ops/config/get-base-url.d.ts +8 -0
- package/lib/db-ops/config/get-base-url.js +14 -0
- package/lib/db-ops/config/get-config.d.ts +10 -0
- package/lib/db-ops/config/get-config.js +29 -0
- package/lib/db-ops/config/get-created-cwd.d.ts +11 -0
- package/lib/db-ops/config/get-created-cwd.js +13 -0
- package/lib/db-ops/config/get-name.d.ts +8 -0
- package/lib/db-ops/config/get-name.js +14 -0
- package/lib/db-ops/config/info-column-allowlist.d.ts +7 -0
- package/lib/db-ops/config/info-column-allowlist.js +29 -0
- package/lib/db-ops/config/info-json-columns.d.ts +5 -0
- package/lib/db-ops/config/info-json-columns.js +11 -0
- package/lib/db-ops/config/set-config.d.ts +12 -0
- package/lib/db-ops/config/set-config.js +21 -0
- package/lib/db-ops/config/update-config.d.ts +17 -0
- package/lib/db-ops/config/update-config.js +36 -0
- package/lib/db-ops/console-logs/compute-console-log-hash.d.ts +19 -0
- package/lib/db-ops/console-logs/compute-console-log-hash.js +30 -0
- package/lib/db-ops/console-logs/replace-console-logs.d.ts +34 -0
- package/lib/db-ops/console-logs/replace-console-logs.js +123 -0
- package/lib/db-ops/console-logs/stringify-console-log-args.d.ts +16 -0
- package/lib/db-ops/console-logs/stringify-console-log-args.js +26 -0
- package/lib/db-ops/console-logs/types.d.ts +38 -0
- package/lib/db-ops/console-logs/types.js +1 -0
- package/lib/db-ops/console-logs/upsert-console-log-item.d.ts +29 -0
- package/lib/db-ops/console-logs/upsert-console-log-item.js +52 -0
- package/lib/db-ops/dedupe-cap/accumulate-dedupe-cap-rejected-count.d.ts +18 -0
- package/lib/db-ops/dedupe-cap/accumulate-dedupe-cap-rejected-count.js +23 -0
- package/lib/db-ops/dedupe-cap/finalize-dedupe-cap-event.d.ts +12 -0
- package/lib/db-ops/dedupe-cap/finalize-dedupe-cap-event.js +15 -0
- package/lib/db-ops/dedupe-cap/insert-dedupe-cap-event.d.ts +14 -0
- package/lib/db-ops/dedupe-cap/insert-dedupe-cap-event.js +30 -0
- package/lib/db-ops/dedupe-cap/list-dedupe-cap-observations.d.ts +57 -0
- package/lib/db-ops/dedupe-cap/list-dedupe-cap-observations.js +87 -0
- package/lib/db-ops/dedupe-cap/list-dedupe-cap-shape-keys.d.ts +21 -0
- package/lib/db-ops/dedupe-cap/list-dedupe-cap-shape-keys.js +27 -0
- package/lib/db-ops/errors/insert-crawl-error.d.ts +15 -0
- package/lib/db-ops/errors/insert-crawl-error.js +21 -0
- package/lib/db-ops/errors/insert-page-error.d.ts +21 -0
- package/lib/db-ops/errors/insert-page-error.js +30 -0
- package/lib/db-ops/errors/list-dns-burned-host-candidates.d.ts +33 -0
- package/lib/db-ops/errors/list-dns-burned-host-candidates.js +158 -0
- package/lib/db-ops/html/read-page-html-blob.d.ts +17 -0
- package/lib/db-ops/html/read-page-html-blob.js +20 -0
- package/lib/db-ops/lifecycle/checkpoint.d.ts +8 -0
- package/lib/db-ops/lifecycle/checkpoint.js +9 -0
- package/lib/db-ops/lifecycle/destroy.d.ts +6 -0
- package/lib/db-ops/lifecycle/destroy.js +7 -0
- package/lib/db-ops/lifecycle/init.d.ts +58 -0
- package/lib/db-ops/lifecycle/init.js +122 -0
- package/lib/db-ops/list-reconcile/record-list-reconcile-run.d.ts +22 -0
- package/lib/db-ops/list-reconcile/record-list-reconcile-run.js +41 -0
- package/lib/db-ops/meta/get-audios-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-audios-of-page.js +15 -0
- package/lib/db-ops/meta/get-buttons-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-buttons-of-page.js +15 -0
- package/lib/db-ops/meta/get-canvases-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-canvases-of-page.js +15 -0
- package/lib/db-ops/meta/get-custom-elements-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-custom-elements-of-page.js +15 -0
- package/lib/db-ops/meta/get-headings-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-headings-of-page.js +15 -0
- package/lib/db-ops/meta/get-iframes-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-iframes-of-page.js +15 -0
- package/lib/db-ops/meta/get-jsonld-of-page.d.ts +13 -0
- package/lib/db-ops/meta/get-jsonld-of-page.js +27 -0
- package/lib/db-ops/meta/get-main-content-images-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-main-content-images-of-page.js +15 -0
- package/lib/db-ops/meta/get-main-content-tables-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-main-content-tables-of-page.js +15 -0
- package/lib/db-ops/meta/get-page-technologies-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-page-technologies-of-page.js +15 -0
- package/lib/db-ops/meta/get-technology-signals-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-technology-signals-of-page.js +15 -0
- package/lib/db-ops/meta/get-videos-of-page.d.ts +11 -0
- package/lib/db-ops/meta/get-videos-of-page.js +15 -0
- package/lib/db-ops/outages/close-network-outage.d.ts +12 -0
- package/lib/db-ops/outages/close-network-outage.js +15 -0
- package/lib/db-ops/outages/close-stale-open-network-outages.d.ts +26 -0
- package/lib/db-ops/outages/close-stale-open-network-outages.js +42 -0
- package/lib/db-ops/outages/compute-outage-clamp-timestamp.d.ts +26 -0
- package/lib/db-ops/outages/compute-outage-clamp-timestamp.js +31 -0
- package/lib/db-ops/outages/insert-network-outage.d.ts +14 -0
- package/lib/db-ops/outages/insert-network-outage.js +29 -0
- package/lib/db-ops/outages/list-network-outages.d.ts +28 -0
- package/lib/db-ops/outages/list-network-outages.js +42 -0
- package/lib/db-ops/pages/order/set-url-order.d.ts +13 -0
- package/lib/db-ops/pages/order/set-url-order.js +38 -0
- package/lib/db-ops/pages/read/build-page-query.d.ts +18 -0
- package/lib/db-ops/pages/read/build-page-query.js +40 -0
- package/lib/db-ops/pages/read/get-crawling-state.d.ts +117 -0
- package/lib/db-ops/pages/read/get-crawling-state.js +161 -0
- package/lib/db-ops/pages/read/get-existing-page-urls.d.ts +15 -0
- package/lib/db-ops/pages/read/get-existing-page-urls.js +30 -0
- package/lib/db-ops/pages/read/get-page-count.d.ts +12 -0
- package/lib/db-ops/pages/read/get-page-count.js +21 -0
- package/lib/db-ops/pages/read/get-page-source-by-url.d.ts +24 -0
- package/lib/db-ops/pages/read/get-page-source-by-url.js +28 -0
- package/lib/db-ops/pages/read/get-pages-with-rels.d.ts +38 -0
- package/lib/db-ops/pages/read/get-pages-with-rels.js +107 -0
- package/lib/db-ops/pages/read/get-pages.d.ts +11 -0
- package/lib/db-ops/pages/read/get-pages.js +51 -0
- package/lib/db-ops/pages/read/get-scraped-html-page-count.d.ts +18 -0
- package/lib/db-ops/pages/read/get-scraped-html-page-count.js +25 -0
- package/lib/db-ops/pages/read/reconstruct-page-rows.d.ts +31 -0
- package/lib/db-ops/pages/read/reconstruct-page-rows.js +32 -0
- package/lib/db-ops/pages/reset/clear-page-derived-rows.d.ts +20 -0
- package/lib/db-ops/pages/reset/clear-page-derived-rows.js +37 -0
- package/lib/db-ops/pages/reset/repromote-external-pages.d.ts +30 -0
- package/lib/db-ops/pages/reset/repromote-external-pages.js +91 -0
- package/lib/db-ops/pages/reset/reset-failed-pages.d.ts +88 -0
- package/lib/db-ops/pages/reset/reset-failed-pages.js +216 -0
- package/lib/db-ops/pages/reset/reset-pages-by-urls.d.ts +80 -0
- package/lib/db-ops/pages/reset/reset-pages-by-urls.js +151 -0
- package/lib/db-ops/pages/reset/retryable-image-scan-codes.d.ts +24 -0
- package/lib/db-ops/pages/reset/retryable-image-scan-codes.js +24 -0
- package/lib/db-ops/pages/write/insert-audios.d.ts +14 -0
- package/lib/db-ops/pages/write/insert-audios.js +25 -0
- package/lib/db-ops/pages/write/insert-buttons.d.ts +14 -0
- package/lib/db-ops/pages/write/insert-buttons.js +29 -0
- package/lib/db-ops/pages/write/insert-canvases.d.ts +14 -0
- package/lib/db-ops/pages/write/insert-canvases.js +26 -0
- package/lib/db-ops/pages/write/insert-custom-elements.d.ts +27 -0
- package/lib/db-ops/pages/write/insert-custom-elements.js +40 -0
- package/lib/db-ops/pages/write/insert-headings.d.ts +15 -0
- package/lib/db-ops/pages/write/insert-headings.js +27 -0
- package/lib/db-ops/pages/write/insert-iframes.d.ts +14 -0
- package/lib/db-ops/pages/write/insert-iframes.js +28 -0
- package/lib/db-ops/pages/write/insert-inventory-content-items.d.ts +38 -0
- package/lib/db-ops/pages/write/insert-inventory-content-items.js +60 -0
- package/lib/db-ops/pages/write/insert-inventory-seeds.d.ts +36 -0
- package/lib/db-ops/pages/write/insert-inventory-seeds.js +48 -0
- package/lib/db-ops/pages/write/insert-inventory-skipped-pages.d.ts +42 -0
- package/lib/db-ops/pages/write/insert-inventory-skipped-pages.js +56 -0
- package/lib/db-ops/pages/write/insert-jsonld.d.ts +17 -0
- package/lib/db-ops/pages/write/insert-jsonld.js +49 -0
- package/lib/db-ops/pages/write/insert-main-content-images.d.ts +20 -0
- package/lib/db-ops/pages/write/insert-main-content-images.js +32 -0
- package/lib/db-ops/pages/write/insert-main-content-tables.d.ts +14 -0
- package/lib/db-ops/pages/write/insert-main-content-tables.js +29 -0
- package/lib/db-ops/pages/write/insert-page.d.ts +56 -0
- package/lib/db-ops/pages/write/insert-page.js +259 -0
- package/lib/db-ops/pages/write/insert-technologies.d.ts +25 -0
- package/lib/db-ops/pages/write/insert-technologies.js +45 -0
- package/lib/db-ops/pages/write/insert-videos.d.ts +14 -0
- package/lib/db-ops/pages/write/insert-videos.js +28 -0
- package/lib/db-ops/pages/write/link-redirect-sources.d.ts +42 -0
- package/lib/db-ops/pages/write/link-redirect-sources.js +101 -0
- package/lib/db-ops/pages/write/record-redirect.d.ts +35 -0
- package/lib/db-ops/pages/write/record-redirect.js +100 -0
- package/lib/db-ops/pages/write/set-skipped-page.d.ts +13 -0
- package/lib/db-ops/pages/write/set-skipped-page.js +24 -0
- package/lib/db-ops/pages/write/update-page.d.ts +40 -0
- package/lib/db-ops/pages/write/update-page.js +419 -0
- package/lib/db-ops/pages/write/write-page-html-blob.d.ts +19 -0
- package/lib/db-ops/pages/write/write-page-html-blob.js +41 -0
- package/lib/db-ops/referrers/get-redirects-for-pages.d.ts +9 -0
- package/lib/db-ops/referrers/get-redirects-for-pages.js +15 -0
- package/lib/db-ops/referrers/get-referrers-of-page.d.ts +17 -0
- package/lib/db-ops/referrers/get-referrers-of-page.js +32 -0
- package/lib/db-ops/referrers/get-referrers-of-resource.d.ts +8 -0
- package/lib/db-ops/referrers/get-referrers-of-resource.js +15 -0
- package/lib/db-ops/resources/build-resource-query.d.ts +25 -0
- package/lib/db-ops/resources/build-resource-query.js +29 -0
- package/lib/db-ops/resources/get-existing-resource-urls.d.ts +9 -0
- package/lib/db-ops/resources/get-existing-resource-urls.js +24 -0
- package/lib/db-ops/resources/get-resource-by-url.d.ts +13 -0
- package/lib/db-ops/resources/get-resource-by-url.js +22 -0
- package/lib/db-ops/resources/get-resource-url-list.d.ts +17 -0
- package/lib/db-ops/resources/get-resource-url-list.js +26 -0
- package/lib/db-ops/resources/get-resources.d.ts +8 -0
- package/lib/db-ops/resources/get-resources.js +11 -0
- package/lib/db-ops/resources/insert-inventory-resources.d.ts +24 -0
- package/lib/db-ops/resources/insert-inventory-resources.js +64 -0
- package/lib/db-ops/resources/insert-resource-referrers.d.ts +15 -0
- package/lib/db-ops/resources/insert-resource-referrers.js +54 -0
- package/lib/db-ops/resources/insert-resource.d.ts +34 -0
- package/lib/db-ops/resources/insert-resource.js +73 -0
- package/lib/db-ops/resources/reconstruct-resource-rows.d.ts +26 -0
- package/lib/db-ops/resources/reconstruct-resource-rows.js +30 -0
- package/lib/db-ops/templates/assign-template-labels.d.ts +60 -0
- package/lib/db-ops/templates/assign-template-labels.js +187 -0
- package/lib/db-ops/templates/replace-page-templates.d.ts +44 -0
- package/lib/db-ops/templates/replace-page-templates.js +174 -0
- package/lib/db-ops/templates/serialize-template-cluster-reason.d.ts +16 -0
- package/lib/db-ops/templates/serialize-template-cluster-reason.js +17 -0
- package/lib/db-ops/templates/types.d.ts +103 -0
- package/lib/db-ops/templates/types.js +1 -0
- package/lib/debug.d.ts +8 -0
- package/lib/debug.js +9 -0
- package/lib/decode-html-blob.d.ts +20 -0
- package/lib/decode-html-blob.js +23 -0
- package/lib/decode-page-html-blob-bytes.d.ts +25 -0
- package/lib/decode-page-html-blob-bytes.js +29 -0
- package/lib/decode-stored-blob-bytes.d.ts +25 -0
- package/lib/decode-stored-blob-bytes.js +47 -0
- package/lib/derive-lineage-from-parent.d.ts +37 -0
- package/lib/derive-lineage-from-parent.js +42 -0
- package/lib/drop-legacy-tables.d.ts +45 -0
- package/lib/drop-legacy-tables.js +56 -0
- package/lib/error-kind/classify-error-kind.d.ts +20 -0
- package/lib/error-kind/classify-error-kind.js +136 -0
- package/lib/error-kind/network-related-error-kinds.d.ts +23 -0
- package/lib/error-kind/network-related-error-kinds.js +28 -0
- package/lib/error-kind/permanent-error-kinds.d.ts +48 -0
- package/lib/error-kind/permanent-error-kinds.js +54 -0
- package/lib/error-kind/types.d.ts +54 -0
- package/lib/error-kind/types.js +1 -0
- package/lib/filesystem/append-text.d.ts +9 -0
- package/lib/filesystem/append-text.js +14 -0
- package/lib/filesystem/copy-dir-sync.d.ts +6 -0
- package/lib/filesystem/copy-dir-sync.js +9 -0
- package/lib/filesystem/copy-dir.d.ts +7 -0
- package/lib/filesystem/copy-dir.js +13 -0
- package/lib/filesystem/copy-file-with-progress.d.ts +20 -0
- package/lib/filesystem/copy-file-with-progress.js +34 -0
- package/lib/filesystem/exists.d.ts +6 -0
- package/lib/filesystem/exists.js +9 -0
- package/lib/filesystem/get-file-list.d.ts +8 -0
- package/lib/filesystem/get-file-list.js +12 -0
- package/lib/filesystem/is-dir.d.ts +6 -0
- package/lib/filesystem/is-dir.js +10 -0
- package/lib/filesystem/mkdir.d.ts +8 -0
- package/lib/filesystem/mkdir.js +15 -0
- package/lib/filesystem/output-binary.d.ts +12 -0
- package/lib/filesystem/output-binary.js +17 -0
- package/lib/filesystem/output-json.d.ts +9 -0
- package/lib/filesystem/output-json.js +14 -0
- package/lib/filesystem/output-text.d.ts +11 -0
- package/lib/filesystem/output-text.js +32 -0
- package/lib/filesystem/parse-pax-path.d.ts +18 -0
- package/lib/filesystem/parse-pax-path.js +47 -0
- package/lib/filesystem/parse-tar-size-field.d.ts +13 -0
- package/lib/filesystem/parse-tar-size-field.js +40 -0
- package/lib/filesystem/peek-tar-top-dir.d.ts +35 -0
- package/lib/filesystem/peek-tar-top-dir.js +215 -0
- package/lib/filesystem/read-json.d.ts +7 -0
- package/lib/filesystem/read-json.js +11 -0
- package/lib/filesystem/read-text.d.ts +6 -0
- package/lib/filesystem/read-text.js +10 -0
- package/lib/filesystem/readline.d.ts +11 -0
- package/lib/filesystem/readline.js +26 -0
- package/lib/filesystem/remove.d.ts +5 -0
- package/lib/filesystem/remove.js +10 -0
- package/lib/filesystem/rename.d.ts +16 -0
- package/lib/filesystem/rename.js +48 -0
- package/lib/filesystem/tar.d.ts +23 -0
- package/lib/filesystem/tar.js +78 -0
- package/lib/filesystem/untar.d.ts +33 -0
- package/lib/filesystem/untar.js +84 -0
- package/lib/get-failed-page-messages.d.ts +56 -0
- package/lib/get-failed-page-messages.js +146 -0
- package/lib/get-json.d.ts +10 -0
- package/lib/get-json.js +25 -0
- package/lib/html-snapshot/match-selector-html.d.ts +25 -0
- package/lib/html-snapshot/match-selector-html.js +28 -0
- package/lib/html-snapshot/match-selector-snapshots.d.ts +33 -0
- package/lib/html-snapshot/match-selector-snapshots.js +33 -0
- package/lib/html-snapshot/search-html-document.d.ts +29 -0
- package/lib/html-snapshot/search-html-document.js +27 -0
- package/lib/html-snapshot/search-html-snapshots.d.ts +36 -0
- package/lib/html-snapshot/search-html-snapshots.js +35 -0
- package/lib/html-snapshot/types.d.ts +111 -0
- package/lib/html-snapshot/types.js +7 -0
- package/lib/html-snapshot/validate-search-pattern.d.ts +15 -0
- package/lib/html-snapshot/validate-search-pattern.js +17 -0
- package/lib/init-schema.d.ts +48 -0
- package/lib/init-schema.js +124 -0
- package/lib/is-inventory-source.d.ts +21 -0
- package/lib/is-inventory-source.js +22 -0
- package/lib/is-within-outage-window.d.ts +49 -0
- package/lib/is-within-outage-window.js +33 -0
- package/lib/isolated-cluster/create-isolated-cluster-run.d.ts +24 -0
- package/lib/isolated-cluster/create-isolated-cluster-run.js +26 -0
- package/lib/libsql-dialect.d.ts +115 -0
- package/lib/libsql-dialect.js +116 -0
- package/lib/limited-page-ids.d.ts +9 -0
- package/lib/limited-page-ids.js +18 -0
- package/lib/meta/assert-compatible-version.d.ts +60 -0
- package/lib/meta/assert-compatible-version.js +93 -0
- package/lib/meta/classify-jsonld-type.d.ts +23 -0
- package/lib/meta/classify-jsonld-type.js +43 -0
- package/lib/meta/compare-semver.d.ts +23 -0
- package/lib/meta/compare-semver.js +51 -0
- package/lib/meta/compute-main-contents-denormalized.d.ts +41 -0
- package/lib/meta/compute-main-contents-denormalized.js +88 -0
- package/lib/meta/compute-page-denormalized.d.ts +20 -0
- package/lib/meta/compute-page-denormalized.js +35 -0
- package/lib/meta/derive-flat-from-meta.d.ts +34 -0
- package/lib/meta/derive-flat-from-meta.js +158 -0
- package/lib/meta/derive-meta-extras.d.ts +20 -0
- package/lib/meta/derive-meta-extras.js +23 -0
- package/lib/meta/extract-tags-for-archive.d.ts +17 -0
- package/lib/meta/extract-tags-for-archive.js +36 -0
- package/lib/meta/parse-main-content-class-list.d.ts +19 -0
- package/lib/meta/parse-main-content-class-list.js +34 -0
- package/lib/meta/summarize-jsonld.d.ts +17 -0
- package/lib/meta/summarize-jsonld.js +29 -0
- package/lib/meta/technologies/combine-technology-confidence.d.ts +46 -0
- package/lib/meta/technologies/combine-technology-confidence.js +93 -0
- package/lib/meta/technologies/convert-legacy-page-tags-to-inserts.d.ts +45 -0
- package/lib/meta/technologies/convert-legacy-page-tags-to-inserts.js +53 -0
- package/lib/meta/technologies/convert-tag-row-to-wappalyzer-signal.d.ts +33 -0
- package/lib/meta/technologies/convert-tag-row-to-wappalyzer-signal.js +46 -0
- package/lib/meta/technologies/extract-technologies-for-archive.d.ts +33 -0
- package/lib/meta/technologies/extract-technologies-for-archive.js +30 -0
- package/lib/meta/technologies/match-js-license-comment-signal.d.ts +21 -0
- package/lib/meta/technologies/match-js-license-comment-signal.js +23 -0
- package/lib/meta/technologies/match-structural-technology-signals.d.ts +26 -0
- package/lib/meta/technologies/match-structural-technology-signals.js +48 -0
- package/lib/meta/technologies/normalize-wappalyzer-entries.d.ts +25 -0
- package/lib/meta/technologies/normalize-wappalyzer-entries.js +35 -0
- package/lib/meta/technologies/technology-signal-definitions.d.ts +44 -0
- package/lib/meta/technologies/technology-signal-definitions.js +60 -0
- package/lib/meta/technologies/types.d.ts +70 -0
- package/lib/meta/technologies/types.js +13 -0
- package/lib/meta/types.d.ts +1490 -0
- package/lib/meta/types.js +65 -0
- package/lib/migrate-content-items-alias-of-id.d.ts +52 -0
- package/lib/migrate-content-items-alias-of-id.js +69 -0
- package/lib/migrate-content-items-dedupe-cap-event-id.d.ts +46 -0
- package/lib/migrate-content-items-dedupe-cap-event-id.js +62 -0
- package/lib/migrate-content-items-is-metadata-only.d.ts +44 -0
- package/lib/migrate-content-items-is-metadata-only.js +60 -0
- package/lib/migrate-entity-tables.d.ts +55 -0
- package/lib/migrate-entity-tables.js +66 -0
- package/lib/migrate-info-created-cwd.d.ts +17 -0
- package/lib/migrate-info-created-cwd.js +36 -0
- package/lib/migrate-info-main-content-selector.d.ts +16 -0
- package/lib/migrate-info-main-content-selector.js +35 -0
- package/lib/migrate-info-request-header-names.d.ts +16 -0
- package/lib/migrate-info-request-header-names.js +35 -0
- package/lib/migrate-info-roots.d.ts +20 -0
- package/lib/migrate-info-roots.js +52 -0
- package/lib/migrate-inventory-runs-to-list-reconcile-runs.d.ts +34 -0
- package/lib/migrate-inventory-runs-to-list-reconcile-runs.js +51 -0
- package/lib/migrate-list-reconcile-runs-exclude-skipped.d.ts +25 -0
- package/lib/migrate-list-reconcile-runs-exclude-skipped.js +44 -0
- package/lib/migrate-list-reconcile-runs-invalid-skipped.d.ts +16 -0
- package/lib/migrate-list-reconcile-runs-invalid-skipped.js +35 -0
- package/lib/migrate-main-contents-columns.d.ts +26 -0
- package/lib/migrate-main-contents-columns.js +61 -0
- package/lib/migrate-page-meta-body-hash.d.ts +44 -0
- package/lib/migrate-page-meta-body-hash.js +63 -0
- package/lib/migrate-page-meta-console-error-count.d.ts +27 -0
- package/lib/migrate-page-meta-console-error-count.js +45 -0
- package/lib/migrate-page-meta-custom-element-count.d.ts +33 -0
- package/lib/migrate-page-meta-custom-element-count.js +51 -0
- package/lib/migrate-page-meta-image-scan.d.ts +27 -0
- package/lib/migrate-page-meta-image-scan.js +52 -0
- package/lib/migrate-page-tags-to-page-technologies.d.ts +39 -0
- package/lib/migrate-page-tags-to-page-technologies.js +79 -0
- package/lib/migrate-ref-tables.d.ts +25 -0
- package/lib/migrate-ref-tables.js +38 -0
- package/lib/native-executor/check-native-executor-config.d.ts +17 -0
- package/lib/native-executor/check-native-executor-config.js +20 -0
- package/lib/page-meta-column-maps.d.ts +32 -0
- package/lib/page-meta-column-maps.js +43 -0
- package/lib/page.d.ts +546 -0
- package/lib/page.js +764 -0
- package/lib/peek-archive-lock.d.ts +40 -0
- package/lib/peek-archive-lock.js +62 -0
- package/lib/populate-entity-tables/collapse-anchor-rows.d.ts +41 -0
- package/lib/populate-entity-tables/collapse-anchor-rows.js +87 -0
- package/lib/populate-entity-tables/derive-dom-path.d.ts +35 -0
- package/lib/populate-entity-tables/derive-dom-path.js +72 -0
- package/lib/populate-entity-tables/is-blob-ref-value.d.ts +16 -0
- package/lib/populate-entity-tables/is-blob-ref-value.js +19 -0
- package/lib/populate-entity-tables/match-images-to-dom-paths.d.ts +66 -0
- package/lib/populate-entity-tables/match-images-to-dom-paths.js +96 -0
- package/lib/populate-entity-tables/populate-anchor-edges.d.ts +33 -0
- package/lib/populate-entity-tables/populate-anchor-edges.js +153 -0
- package/lib/populate-entity-tables/populate-content-items.d.ts +40 -0
- package/lib/populate-entity-tables/populate-content-items.js +141 -0
- package/lib/populate-entity-tables/populate-entities.d.ts +81 -0
- package/lib/populate-entity-tables/populate-entities.js +110 -0
- package/lib/populate-entity-tables/populate-image-items.d.ts +91 -0
- package/lib/populate-entity-tables/populate-image-items.js +226 -0
- package/lib/populate-entity-tables/populate-page-meta.d.ts +33 -0
- package/lib/populate-entity-tables/populate-page-meta.js +267 -0
- package/lib/populate-entity-tables/populate-resource-items.d.ts +22 -0
- package/lib/populate-entity-tables/populate-resource-items.js +114 -0
- package/lib/populate-entity-tables/populate-resource-ref-edges.d.ts +31 -0
- package/lib/populate-entity-tables/populate-resource-ref-edges.js +33 -0
- package/lib/populate-entity-tables/resolve-blob-refs.d.ts +31 -0
- package/lib/populate-entity-tables/resolve-blob-refs.js +100 -0
- package/lib/populate-entity-tables/resolve-content-type-refs.d.ts +22 -0
- package/lib/populate-entity-tables/resolve-content-type-refs.js +27 -0
- package/lib/populate-entity-tables/resolve-header-sets.d.ts +49 -0
- package/lib/populate-entity-tables/resolve-header-sets.js +122 -0
- package/lib/populate-entity-tables/resolve-json-refs.d.ts +25 -0
- package/lib/populate-entity-tables/resolve-json-refs.js +67 -0
- package/lib/populate-entity-tables/resolve-text-refs.d.ts +30 -0
- package/lib/populate-entity-tables/resolve-text-refs.js +61 -0
- package/lib/populate-entity-tables/resolve-url-or-blob-from-maps.d.ts +21 -0
- package/lib/populate-entity-tables/resolve-url-or-blob-from-maps.js +27 -0
- package/lib/populate-entity-tables/resolve-url-refs.d.ts +33 -0
- package/lib/populate-entity-tables/resolve-url-refs.js +60 -0
- package/lib/populate-entity-tables/test-utils/count-rows.d.ts +17 -0
- package/lib/populate-entity-tables/test-utils/count-rows.js +20 -0
- package/lib/populate-entity-tables/test-utils/seed-content-items.d.ts +25 -0
- package/lib/populate-entity-tables/test-utils/seed-content-items.js +42 -0
- package/lib/populate-entity-tables/test-utils/setup-entities-db.d.ts +30 -0
- package/lib/populate-entity-tables/test-utils/setup-entities-db.js +175 -0
- package/lib/populate-entity-tables/types.d.ts +157 -0
- package/lib/populate-entity-tables/types.js +12 -0
- package/lib/populate-entity-tables/upsert-text-refs.d.ts +38 -0
- package/lib/populate-entity-tables/upsert-text-refs.js +78 -0
- package/lib/populate-ref-tables/classify-content-type.d.ts +16 -0
- package/lib/populate-ref-tables/classify-content-type.js +52 -0
- package/lib/populate-ref-tables/compute-content-hash.d.ts +22 -0
- package/lib/populate-ref-tables/compute-content-hash.js +26 -0
- package/lib/populate-ref-tables/compute-header-flags.d.ts +16 -0
- package/lib/populate-ref-tables/compute-header-flags.js +70 -0
- package/lib/populate-ref-tables/content-type-rules.d.ts +38 -0
- package/lib/populate-ref-tables/content-type-rules.js +133 -0
- package/lib/populate-ref-tables/create-header-table-caches.d.ts +25 -0
- package/lib/populate-ref-tables/create-header-table-caches.js +49 -0
- package/lib/populate-ref-tables/data-uri-url-refs-limit.d.ts +15 -0
- package/lib/populate-ref-tables/data-uri-url-refs-limit.js +15 -0
- package/lib/populate-ref-tables/decode-data-uri.d.ts +21 -0
- package/lib/populate-ref-tables/decode-data-uri.js +126 -0
- package/lib/populate-ref-tables/decompose-header-set.d.ts +29 -0
- package/lib/populate-ref-tables/decompose-header-set.js +157 -0
- package/lib/populate-ref-tables/decompose-url.d.ts +25 -0
- package/lib/populate-ref-tables/decompose-url.js +70 -0
- package/lib/populate-ref-tables/header-stability.d.ts +19 -0
- package/lib/populate-ref-tables/header-stability.js +22 -0
- package/lib/populate-ref-tables/header-value-cache-key.d.ts +17 -0
- package/lib/populate-ref-tables/header-value-cache-key.js +19 -0
- package/lib/populate-ref-tables/normalize-mime.d.ts +24 -0
- package/lib/populate-ref-tables/normalize-mime.js +36 -0
- package/lib/populate-ref-tables/populate-blob-refs.d.ts +38 -0
- package/lib/populate-ref-tables/populate-blob-refs.js +134 -0
- package/lib/populate-ref-tables/populate-content-type-refs.d.ts +27 -0
- package/lib/populate-ref-tables/populate-content-type-refs.js +70 -0
- package/lib/populate-ref-tables/populate-header-tables.d.ts +35 -0
- package/lib/populate-ref-tables/populate-header-tables.js +80 -0
- package/lib/populate-ref-tables/populate-json-refs.d.ts +29 -0
- package/lib/populate-ref-tables/populate-json-refs.js +101 -0
- package/lib/populate-ref-tables/populate-refs.d.ts +51 -0
- package/lib/populate-ref-tables/populate-refs.js +62 -0
- package/lib/populate-ref-tables/populate-text-refs.d.ts +32 -0
- package/lib/populate-ref-tables/populate-text-refs.js +133 -0
- package/lib/populate-ref-tables/populate-url-refs.d.ts +28 -0
- package/lib/populate-ref-tables/populate-url-refs.js +148 -0
- package/lib/populate-ref-tables/test-utils/count-rows.d.ts +15 -0
- package/lib/populate-ref-tables/test-utils/count-rows.js +17 -0
- package/lib/populate-ref-tables/types.d.ts +197 -0
- package/lib/populate-ref-tables/types.js +7 -0
- package/lib/populate-ref-tables/upsert-one-header-set.d.ts +34 -0
- package/lib/populate-ref-tables/upsert-one-header-set.js +208 -0
- package/lib/populate-ref-tables/volatile-header-names.d.ts +20 -0
- package/lib/populate-ref-tables/volatile-header-names.js +33 -0
- package/lib/redirect-table.d.ts +9 -0
- package/lib/redirect-table.js +28 -0
- package/lib/release-finished-statements.d.ts +42 -0
- package/lib/release-finished-statements.js +45 -0
- package/lib/resolve-redirect-chain.d.ts +33 -0
- package/lib/resolve-redirect-chain.js +27 -0
- package/lib/resource.d.ts +46 -0
- package/lib/resource.js +62 -0
- package/lib/retarget-legacy-fk-tables.d.ts +61 -0
- package/lib/retarget-legacy-fk-tables.js +137 -0
- package/lib/safe-path.d.ts +9 -0
- package/lib/safe-path.js +17 -0
- package/lib/scope/build-scope-map.d.ts +21 -0
- package/lib/scope/build-scope-map.js +32 -0
- package/lib/scope/find-scope-entry.d.ts +25 -0
- package/lib/scope/find-scope-entry.js +45 -0
- package/lib/template-classification/classify-archive-page-templates.d.ts +42 -0
- package/lib/template-classification/classify-archive-page-templates.js +70 -0
- package/lib/template-classification/classify-page-templates.d.ts +33 -0
- package/lib/template-classification/classify-page-templates.js +60 -0
- package/lib/template-classification/collect-page-ids-with-html.d.ts +24 -0
- package/lib/template-classification/collect-page-ids-with-html.js +30 -0
- package/lib/template-classification/collect-page-stylesheet-urls.d.ts +32 -0
- package/lib/template-classification/collect-page-stylesheet-urls.js +130 -0
- package/lib/template-classification/create-content-root-hint.d.ts +41 -0
- package/lib/template-classification/create-content-root-hint.js +51 -0
- package/lib/template-classification/create-page-cluster-factory.d.ts +36 -0
- package/lib/template-classification/create-page-cluster-factory.js +52 -0
- package/lib/template-classification/load-page-cluster-candidates.d.ts +32 -0
- package/lib/template-classification/load-page-cluster-candidates.js +93 -0
- package/lib/template-classification/page-cluster/resolve-page-cluster-keys.d.ts +34 -0
- package/lib/template-classification/page-cluster/resolve-page-cluster-keys.js +236 -0
- package/lib/template-classification/page-cluster/types.d.ts +123 -0
- package/lib/template-classification/page-cluster/types.js +1 -0
- package/lib/template-classification/types.d.ts +234 -0
- package/lib/template-classification/types.js +1 -0
- package/lib/test-utils/build-full-schema-test-db.d.ts +34 -0
- package/lib/test-utils/build-full-schema-test-db.js +74 -0
- package/lib/test-utils/create-legacy-analysis-tables.d.ts +13 -0
- package/lib/test-utils/create-legacy-analysis-tables.js +37 -0
- package/lib/test-utils/fk-parent-tables.d.ts +15 -0
- package/lib/test-utils/fk-parent-tables.js +19 -0
- package/lib/test-utils/seed-content-item.d.ts +35 -0
- package/lib/test-utils/seed-content-item.js +42 -0
- package/lib/test-utils/setup-legacy-fk-db.d.ts +34 -0
- package/lib/test-utils/setup-legacy-fk-db.js +271 -0
- package/lib/transfer/attach-source-database.d.ts +31 -0
- package/lib/transfer/attach-source-database.js +40 -0
- package/lib/transfer/build-split-config.d.ts +30 -0
- package/lib/transfer/build-split-config.js +42 -0
- package/lib/transfer/clear-replaced-page-rows.d.ts +23 -0
- package/lib/transfer/clear-replaced-page-rows.js +61 -0
- package/lib/transfer/concat-archives.d.ts +55 -0
- package/lib/transfer/concat-archives.js +95 -0
- package/lib/transfer/concat-source-transfer-phases.d.ts +10 -0
- package/lib/transfer/concat-source-transfer-phases.js +17 -0
- package/lib/transfer/content-item-rank-sql.d.ts +21 -0
- package/lib/transfer/content-item-rank-sql.js +23 -0
- package/lib/transfer/copy-anchor-edges.d.ts +28 -0
- package/lib/transfer/copy-anchor-edges.js +42 -0
- package/lib/transfer/copy-dictionaries-for-concat.d.ts +39 -0
- package/lib/transfer/copy-dictionaries-for-concat.js +81 -0
- package/lib/transfer/copy-dictionaries-for-split.d.ts +29 -0
- package/lib/transfer/copy-dictionaries-for-split.js +224 -0
- package/lib/transfer/copy-header-set-children.d.ts +27 -0
- package/lib/transfer/copy-header-set-children.js +51 -0
- package/lib/transfer/copy-image-items.d.ts +21 -0
- package/lib/transfer/copy-image-items.js +62 -0
- package/lib/transfer/copy-inventory-source-lists.d.ts +30 -0
- package/lib/transfer/copy-inventory-source-lists.js +61 -0
- package/lib/transfer/copy-journal-tables.d.ts +30 -0
- package/lib/transfer/copy-journal-tables.js +56 -0
- package/lib/transfer/copy-page-console-logs.d.ts +16 -0
- package/lib/transfer/copy-page-console-logs.js +27 -0
- package/lib/transfer/copy-page-html-blobs.d.ts +31 -0
- package/lib/transfer/copy-page-html-blobs.js +43 -0
- package/lib/transfer/copy-page-meta.d.ts +27 -0
- package/lib/transfer/copy-page-meta.js +68 -0
- package/lib/transfer/copy-page-template-clusters.d.ts +31 -0
- package/lib/transfer/copy-page-template-clusters.js +56 -0
- package/lib/transfer/copy-page-template-labels.d.ts +34 -0
- package/lib/transfer/copy-page-template-labels.js +88 -0
- package/lib/transfer/copy-resource-items.d.ts +29 -0
- package/lib/transfer/copy-resource-items.js +89 -0
- package/lib/transfer/copy-resource-ref-edges.d.ts +20 -0
- package/lib/transfer/copy-resource-ref-edges.js +33 -0
- package/lib/transfer/copy-simple-page-scoped-tables.d.ts +15 -0
- package/lib/transfer/copy-simple-page-scoped-tables.js +34 -0
- package/lib/transfer/count-external-pages-in-scope.d.ts +26 -0
- package/lib/transfer/count-external-pages-in-scope.js +40 -0
- package/lib/transfer/create-transfer-temp-tables.d.ts +30 -0
- package/lib/transfer/create-transfer-temp-tables.js +59 -0
- package/lib/transfer/dictionary-copy-specs.d.ts +32 -0
- package/lib/transfer/dictionary-copy-specs.js +28 -0
- package/lib/transfer/drop-transfer-temp-tables.d.ts +9 -0
- package/lib/transfer/drop-transfer-temp-tables.js +18 -0
- package/lib/transfer/flatten-redirect-chains.d.ts +44 -0
- package/lib/transfer/flatten-redirect-chains.js +74 -0
- package/lib/transfer/insert-content-items.d.ts +35 -0
- package/lib/transfer/insert-content-items.js +116 -0
- package/lib/transfer/list-transfer-columns.d.ts +35 -0
- package/lib/transfer/list-transfer-columns.js +45 -0
- package/lib/transfer/mark-in-scope-content-items.d.ts +31 -0
- package/lib/transfer/mark-in-scope-content-items.js +54 -0
- package/lib/transfer/merge-archive-configs.d.ts +51 -0
- package/lib/transfer/merge-archive-configs.js +85 -0
- package/lib/transfer/plan-content-items-for-concat.d.ts +33 -0
- package/lib/transfer/plan-content-items-for-concat.js +51 -0
- package/lib/transfer/plan-content-items-for-split.d.ts +42 -0
- package/lib/transfer/plan-content-items-for-split.js +83 -0
- package/lib/transfer/plan-resource-items.d.ts +40 -0
- package/lib/transfer/plan-resource-items.js +69 -0
- package/lib/transfer/quote-transfer-identifier.d.ts +18 -0
- package/lib/transfer/quote-transfer-identifier.js +20 -0
- package/lib/transfer/reclassify-resource-externality.d.ts +37 -0
- package/lib/transfer/reclassify-resource-externality.js +66 -0
- package/lib/transfer/remap-redirect-dest-ids.d.ts +34 -0
- package/lib/transfer/remap-redirect-dest-ids.js +51 -0
- package/lib/transfer/replace-content-items.d.ts +39 -0
- package/lib/transfer/replace-content-items.js +83 -0
- package/lib/transfer/simple-page-scoped-tables.d.ts +25 -0
- package/lib/transfer/simple-page-scoped-tables.js +38 -0
- package/lib/transfer/split-archive.d.ts +55 -0
- package/lib/transfer/split-archive.js +98 -0
- package/lib/transfer/split-source-transfer-phases.d.ts +11 -0
- package/lib/transfer/split-source-transfer-phases.js +18 -0
- package/lib/transfer/transfer-action.d.ts +34 -0
- package/lib/transfer/transfer-action.js +32 -0
- package/lib/transfer/transfer-archive-rows.d.ts +65 -0
- package/lib/transfer/transfer-archive-rows.js +156 -0
- package/lib/transfer/transfer-dictionary-tables.d.ts +12 -0
- package/lib/transfer/transfer-dictionary-tables.js +22 -0
- package/lib/transfer/transfer-post-phases.d.ts +10 -0
- package/lib/transfer/transfer-post-phases.js +13 -0
- package/lib/transfer/transfer-source-alias.d.ts +9 -0
- package/lib/transfer/transfer-source-alias.js +9 -0
- package/lib/transfer/types.d.ts +111 -0
- package/lib/transfer/types.js +35 -0
- package/lib/types.d.ts +772 -0
- package/lib/types.js +1 -0
- package/lib/url-alias/compute-tier-a-alias-key.d.ts +44 -0
- package/lib/url-alias/compute-tier-a-alias-key.js +47 -0
- package/lib/url-alias/compute-tier-b-alias-key.d.ts +23 -0
- package/lib/url-alias/compute-tier-b-alias-key.js +26 -0
- package/lib/url-alias/group-alias-candidates.d.ts +27 -0
- package/lib/url-alias/group-alias-candidates.js +29 -0
- package/lib/url-alias/types.d.ts +12 -0
- package/lib/url-alias/types.js +1 -0
- package/lib/url-pattern/compute-shape-key.d.ts +58 -0
- package/lib/url-pattern/compute-shape-key.js +129 -0
- package/lib/url-pattern/decompose-url.d.ts +33 -0
- package/lib/url-pattern/decompose-url.js +79 -0
- package/lib/url-pattern/reconstruct-url.d.ts +15 -0
- package/lib/url-pattern/reconstruct-url.js +33 -0
- package/lib/url-sort/compute-url-sort-ranks.d.ts +30 -0
- package/lib/url-sort/compute-url-sort-ranks.js +33 -0
- package/lib/utils/array/each-splitted.d.ts +10 -0
- package/lib/utils/array/each-splitted.js +14 -0
- package/lib/utils/debug.d.ts +8 -0
- package/lib/utils/debug.js +8 -0
- package/lib/utils/error/emit-error-with-retry.d.ts +40 -0
- package/lib/utils/error/emit-error-with-retry.js +44 -0
- package/lib/utils/error/emit-error.d.ts +39 -0
- package/lib/utils/error/emit-error.js +41 -0
- package/lib/utils/object/parse-response-headers.d.ts +12 -0
- package/lib/utils/object/parse-response-headers.js +26 -0
- package/lib/utils/object/redact-request-headers.d.ts +15 -0
- package/lib/utils/object/redact-request-headers.js +27 -0
- package/lib/utils/types/types.d.ts +383 -0
- package/lib/utils/types/types.js +1 -0
- package/lib/verify-migration/capture-rejection.d.ts +24 -0
- package/lib/verify-migration/capture-rejection.js +31 -0
- package/lib/verify-migration/check-anchor-edges-count.d.ts +34 -0
- package/lib/verify-migration/check-anchor-edges-count.js +72 -0
- package/lib/verify-migration/check-anchor-edges-sum.d.ts +13 -0
- package/lib/verify-migration/check-anchor-edges-sum.js +27 -0
- package/lib/verify-migration/check-content-items-count.d.ts +16 -0
- package/lib/verify-migration/check-content-items-count.js +30 -0
- package/lib/verify-migration/check-content-type-preservation.d.ts +22 -0
- package/lib/verify-migration/check-content-type-preservation.js +40 -0
- package/lib/verify-migration/check-foreign-key-integrity.d.ts +31 -0
- package/lib/verify-migration/check-foreign-key-integrity.js +47 -0
- package/lib/verify-migration/check-image-items-count.d.ts +12 -0
- package/lib/verify-migration/check-image-items-count.js +26 -0
- package/lib/verify-migration/check-page-meta-count.d.ts +15 -0
- package/lib/verify-migration/check-page-meta-count.js +31 -0
- package/lib/verify-migration/check-reader-parity.d.ts +23 -0
- package/lib/verify-migration/check-reader-parity.js +182 -0
- package/lib/verify-migration/check-resource-items-count.d.ts +17 -0
- package/lib/verify-migration/check-resource-items-count.js +33 -0
- package/lib/verify-migration/check-url-round-trip.d.ts +43 -0
- package/lib/verify-migration/check-url-round-trip.js +112 -0
- package/lib/verify-migration/types.d.ts +70 -0
- package/lib/verify-migration/types.js +63 -0
- package/lib/verify-migration/verify-migration.d.ts +41 -0
- package/lib/verify-migration/verify-migration.js +120 -0
- package/lib/with-bulk-write-pragmas.d.ts +51 -0
- package/lib/with-bulk-write-pragmas.js +132 -0
- package/lib/write-queue.d.ts +32 -0
- package/lib/write-queue.js +55 -0
- package/package.json +360 -5
package/lib/database.js
ADDED
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { retryCall } from '@d-zero/shared/retry';
|
|
4
|
+
import { TypedAwaitEventEmitter as EventEmitter } from '@d-zero/shared/typed-await-event-emitter';
|
|
5
|
+
import knex from 'knex';
|
|
6
|
+
import { createWriteRefCaches } from './db-ops/_shared/create-write-ref-caches.js';
|
|
7
|
+
import { retrySetting } from './db-ops/_shared/retry-setting.js';
|
|
8
|
+
import { getAnchorsOnPage as getAnchorsOnPageOp } from './db-ops/anchors/get-anchors-on-page.js';
|
|
9
|
+
import { getBaseUrl as getBaseUrlOp } from './db-ops/config/get-base-url.js';
|
|
10
|
+
import { getConfig as getConfigOp } from './db-ops/config/get-config.js';
|
|
11
|
+
import { getCreatedCwd as getCreatedCwdOp } from './db-ops/config/get-created-cwd.js';
|
|
12
|
+
import { getName as getNameOp } from './db-ops/config/get-name.js';
|
|
13
|
+
import { setConfig as setConfigOp } from './db-ops/config/set-config.js';
|
|
14
|
+
import { updateConfig as updateConfigOp } from './db-ops/config/update-config.js';
|
|
15
|
+
import { replaceConsoleLogs as replaceConsoleLogsOp } from './db-ops/console-logs/replace-console-logs.js';
|
|
16
|
+
import { accumulateDedupeCapRejectedCount as accumulateDedupeCapRejectedCountOp } from './db-ops/dedupe-cap/accumulate-dedupe-cap-rejected-count.js';
|
|
17
|
+
import { finalizeDedupeCapEvent as finalizeDedupeCapEventOp } from './db-ops/dedupe-cap/finalize-dedupe-cap-event.js';
|
|
18
|
+
import { insertDedupeCapEvent as insertDedupeCapEventOp } from './db-ops/dedupe-cap/insert-dedupe-cap-event.js';
|
|
19
|
+
import { listDedupeCapObservations as listDedupeCapObservationsOp } from './db-ops/dedupe-cap/list-dedupe-cap-observations.js';
|
|
20
|
+
import { listDedupeCapShapeKeys as listDedupeCapShapeKeysOp } from './db-ops/dedupe-cap/list-dedupe-cap-shape-keys.js';
|
|
21
|
+
import { insertCrawlError as insertCrawlErrorOp } from './db-ops/errors/insert-crawl-error.js';
|
|
22
|
+
import { insertPageError as insertPageErrorOp } from './db-ops/errors/insert-page-error.js';
|
|
23
|
+
import { listDnsBurnedHostCandidates as listDnsBurnedHostCandidatesOp } from './db-ops/errors/list-dns-burned-host-candidates.js';
|
|
24
|
+
import { readPageHtmlBlob as readPageHtmlBlobOp } from './db-ops/html/read-page-html-blob.js';
|
|
25
|
+
import { checkpoint as checkpointOp } from './db-ops/lifecycle/checkpoint.js';
|
|
26
|
+
import { destroy as destroyOp } from './db-ops/lifecycle/destroy.js';
|
|
27
|
+
import { init as initOp } from './db-ops/lifecycle/init.js';
|
|
28
|
+
import { recordListReconcileRun as recordListReconcileRunOp } from './db-ops/list-reconcile/record-list-reconcile-run.js';
|
|
29
|
+
import { getAudiosOfPage as getAudiosOfPageOp } from './db-ops/meta/get-audios-of-page.js';
|
|
30
|
+
import { getButtonsOfPage as getButtonsOfPageOp } from './db-ops/meta/get-buttons-of-page.js';
|
|
31
|
+
import { getCanvasesOfPage as getCanvasesOfPageOp } from './db-ops/meta/get-canvases-of-page.js';
|
|
32
|
+
import { getCustomElementsOfPage as getCustomElementsOfPageOp } from './db-ops/meta/get-custom-elements-of-page.js';
|
|
33
|
+
import { getHeadingsOfPage as getHeadingsOfPageOp } from './db-ops/meta/get-headings-of-page.js';
|
|
34
|
+
import { getIframesOfPage as getIframesOfPageOp } from './db-ops/meta/get-iframes-of-page.js';
|
|
35
|
+
import { getJsonLdOfPage as getJsonLdOfPageOp } from './db-ops/meta/get-jsonld-of-page.js';
|
|
36
|
+
import { getMainContentImagesOfPage as getMainContentImagesOfPageOp } from './db-ops/meta/get-main-content-images-of-page.js';
|
|
37
|
+
import { getMainContentTablesOfPage as getMainContentTablesOfPageOp } from './db-ops/meta/get-main-content-tables-of-page.js';
|
|
38
|
+
import { getPageTechnologiesOfPage as getPageTechnologiesOfPageOp } from './db-ops/meta/get-page-technologies-of-page.js';
|
|
39
|
+
import { getTechnologySignalsOfPage as getTechnologySignalsOfPageOp } from './db-ops/meta/get-technology-signals-of-page.js';
|
|
40
|
+
import { getVideosOfPage as getVideosOfPageOp } from './db-ops/meta/get-videos-of-page.js';
|
|
41
|
+
import { closeNetworkOutage as closeNetworkOutageOp } from './db-ops/outages/close-network-outage.js';
|
|
42
|
+
import { insertNetworkOutage as insertNetworkOutageOp } from './db-ops/outages/insert-network-outage.js';
|
|
43
|
+
import { listNetworkOutages as listNetworkOutagesOp } from './db-ops/outages/list-network-outages.js';
|
|
44
|
+
import { setUrlOrder as setUrlOrderOp } from './db-ops/pages/order/set-url-order.js';
|
|
45
|
+
import { getCrawlingState as getCrawlingStateOp } from './db-ops/pages/read/get-crawling-state.js';
|
|
46
|
+
import { getExistingPageUrls as getExistingPageUrlsOp } from './db-ops/pages/read/get-existing-page-urls.js';
|
|
47
|
+
import { getPageCount as getPageCountOp } from './db-ops/pages/read/get-page-count.js';
|
|
48
|
+
import { getPageSourceByUrl as getPageSourceByUrlOp } from './db-ops/pages/read/get-page-source-by-url.js';
|
|
49
|
+
import { getPagesWithRels as getPagesWithRelsOp } from './db-ops/pages/read/get-pages-with-rels.js';
|
|
50
|
+
import { getPages as getPagesOp } from './db-ops/pages/read/get-pages.js';
|
|
51
|
+
import { getScrapedHtmlPageCount as getScrapedHtmlPageCountOp } from './db-ops/pages/read/get-scraped-html-page-count.js';
|
|
52
|
+
import { repromoteExternalPages as repromoteExternalPagesOp } from './db-ops/pages/reset/repromote-external-pages.js';
|
|
53
|
+
import { resetFailedPages as resetFailedPagesOp } from './db-ops/pages/reset/reset-failed-pages.js';
|
|
54
|
+
import { resetPagesByUrls as resetPagesByUrlsOp } from './db-ops/pages/reset/reset-pages-by-urls.js';
|
|
55
|
+
import { insertInventorySeeds as insertInventorySeedsOp } from './db-ops/pages/write/insert-inventory-seeds.js';
|
|
56
|
+
import { insertInventorySkippedPages as insertInventorySkippedPagesOp } from './db-ops/pages/write/insert-inventory-skipped-pages.js';
|
|
57
|
+
import { recordRedirect as recordRedirectOp } from './db-ops/pages/write/record-redirect.js';
|
|
58
|
+
import { setSkippedPage as setSkippedPageOp } from './db-ops/pages/write/set-skipped-page.js';
|
|
59
|
+
import { updatePage as updatePageOp } from './db-ops/pages/write/update-page.js';
|
|
60
|
+
import { getRedirectsForPages as getRedirectsForPagesOp } from './db-ops/referrers/get-redirects-for-pages.js';
|
|
61
|
+
import { getReferrersOfPage as getReferrersOfPageOp } from './db-ops/referrers/get-referrers-of-page.js';
|
|
62
|
+
import { getReferrersOfResource as getReferrersOfResourceOp } from './db-ops/referrers/get-referrers-of-resource.js';
|
|
63
|
+
import { getExistingResourceUrls as getExistingResourceUrlsOp } from './db-ops/resources/get-existing-resource-urls.js';
|
|
64
|
+
import { getResourceByUrl as getResourceByUrlOp } from './db-ops/resources/get-resource-by-url.js';
|
|
65
|
+
import { getResourceUrlList as getResourceUrlListOp } from './db-ops/resources/get-resource-url-list.js';
|
|
66
|
+
import { getResources as getResourcesOp } from './db-ops/resources/get-resources.js';
|
|
67
|
+
import { insertInventoryResources as insertInventoryResourcesOp } from './db-ops/resources/insert-inventory-resources.js';
|
|
68
|
+
import { insertResourceReferrers as insertResourceReferrersOp } from './db-ops/resources/insert-resource-referrers.js';
|
|
69
|
+
import { insertResource as insertResourceOp } from './db-ops/resources/insert-resource.js';
|
|
70
|
+
import { replacePageTemplates as replacePageTemplatesOp } from './db-ops/templates/replace-page-templates.js';
|
|
71
|
+
import { decodePageHtmlBlobBytes } from './decode-page-html-blob-bytes.js';
|
|
72
|
+
import { mkdir } from './filesystem/mkdir.js';
|
|
73
|
+
import { LibsqlDialect } from './libsql-dialect.js';
|
|
74
|
+
import { emitErrorAndRetry } from './utils/error/emit-error-with-retry.js';
|
|
75
|
+
import { emitError } from './utils/error/emit-error.js';
|
|
76
|
+
/**
|
|
77
|
+
* Low-level database abstraction layer for the archive's SQLite database.
|
|
78
|
+
*
|
|
79
|
+
* Every method is a thin dispatcher: the SQL itself lives in a dedicated
|
|
80
|
+
* single-export op module under `./db-ops/` (one file per operation), and
|
|
81
|
+
* the class contributes only the connection (`this.#instance`) plus the
|
|
82
|
+
* error/retry wrapper. Public methods that perform database queries use the
|
|
83
|
+
* `emitErrorAndRetry` HOF for automatic retry on transient failures combined
|
|
84
|
+
* with error-event propagation, or `emitError` when retry is not appropriate.
|
|
85
|
+
* The set of tables this layer manages is defined by `init-schema.ts` (the
|
|
86
|
+
* source of truth — query that file for the canonical list).
|
|
87
|
+
*
|
|
88
|
+
* **Label sync caveat**: each `emitError` / `emitErrorAndRetry` call passes
|
|
89
|
+
* the method name as a string literal (e.g. `'Database.getAnchorsOnPage'`).
|
|
90
|
+
* TypeScript cannot check that the string matches the enclosing method's
|
|
91
|
+
* real name — the two-way sync is manual. Renaming a method here **must**
|
|
92
|
+
* update the literal string too, otherwise debug logs and `RetryTimeoutError`
|
|
93
|
+
* messages will silently report the old name.
|
|
94
|
+
*
|
|
95
|
+
* Use the static {@link Database.connect} factory method to create instances.
|
|
96
|
+
* The constructor is private.
|
|
97
|
+
*/
|
|
98
|
+
export class Database extends EventEmitter {
|
|
99
|
+
/** The Knex query builder instance connected to the SQLite database. */
|
|
100
|
+
#instance;
|
|
101
|
+
/** Connection-scoped write-side id caches for entity/ref upserts. */
|
|
102
|
+
#writeRefCaches = createWriteRefCaches();
|
|
103
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
104
|
+
constructor(options) {
|
|
105
|
+
super();
|
|
106
|
+
// **Known caveat (libsql 0.5.x)**: passing `readonly: true` via
|
|
107
|
+
// `connection.options` is accepted by the libsql driver but is
|
|
108
|
+
// NOT enforced at the SQL layer — `CREATE TABLE` / `INSERT`
|
|
109
|
+
// against the resulting connection still succeed. The flag
|
|
110
|
+
// remains a no-op until libsql adds real read-only enforcement
|
|
111
|
+
// upstream. Read-only safety in cache mode therefore relies on:
|
|
112
|
+
//
|
|
113
|
+
// 1. `Database.#init` skipping schema init + migrations when
|
|
114
|
+
// `readOnly` is set (so no `initSchema` / `migrate*` ever
|
|
115
|
+
// writes to the shared cache directory).
|
|
116
|
+
// 2. Code review on any future internal use of
|
|
117
|
+
// `accessor.getKnex()` — there is no driver-level guard.
|
|
118
|
+
this.#instance = knex({
|
|
119
|
+
client: LibsqlDialect,
|
|
120
|
+
connection: {
|
|
121
|
+
filename: options.filename,
|
|
122
|
+
},
|
|
123
|
+
useNullAsDefault: true,
|
|
124
|
+
pool: {
|
|
125
|
+
acquireTimeoutMillis: 600_000,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Adds onto the `rejected_count` of a shape's `dedupe_cap_events` row,
|
|
131
|
+
* looked up by `shape_key` rather than `id`. Delegates to
|
|
132
|
+
* {@link accumulateDedupeCapRejectedCountOp}.
|
|
133
|
+
* @param shapeKey - The capped shape whose rejection count to accumulate.
|
|
134
|
+
* @param rejectedCount - Additional anchors rejected for this shape in the current session.
|
|
135
|
+
*/
|
|
136
|
+
async accumulateDedupeCapRejectedCount(shapeKey, rejectedCount) {
|
|
137
|
+
return emitErrorAndRetry(this, 'Database.accumulateDedupeCapRejectedCount', async () => await accumulateDedupeCapRejectedCountOp(this.#instance, shapeKey, rejectedCount), retrySetting);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Forces a WAL checkpoint, writing all pending WAL data back to the main
|
|
141
|
+
* database file. Delegates to {@link checkpointOp}.
|
|
142
|
+
*/
|
|
143
|
+
async checkpoint() {
|
|
144
|
+
await checkpointOp(this.#instance);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Closes an outage row by stamping `ended_at` — a no-op if the row is
|
|
148
|
+
* already closed. Delegates to {@link closeNetworkOutageOp}.
|
|
149
|
+
* @param id - The `network_outages.id` to close.
|
|
150
|
+
* @param endedAt - Epoch ms the outage is considered to have ended.
|
|
151
|
+
*/
|
|
152
|
+
async closeNetworkOutage(id, endedAt) {
|
|
153
|
+
return emitErrorAndRetry(this, 'Database.closeNetworkOutage', async () => await closeNetworkOutageOp(this.#instance, id, endedAt), retrySetting);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Destroys the database connection, releasing all pooled resources.
|
|
157
|
+
* Delegates to {@link destroyOp}.
|
|
158
|
+
*/
|
|
159
|
+
async destroy() {
|
|
160
|
+
await destroyOp(this.#instance);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Finalizes a `dedupe_cap_events` row by stamping `rejected_count` — a
|
|
164
|
+
* no-op if the row is already finalized. Delegates to
|
|
165
|
+
* {@link finalizeDedupeCapEventOp}.
|
|
166
|
+
* @param id - The `dedupe_cap_events.id` to finalize.
|
|
167
|
+
* @param rejectedCount - Number of anchors rejected for this shape after it capped.
|
|
168
|
+
*/
|
|
169
|
+
async finalizeDedupeCapEvent(id, rejectedCount) {
|
|
170
|
+
return emitErrorAndRetry(this, 'Database.finalizeDedupeCapEvent', async () => await finalizeDedupeCapEventOp(this.#instance, id, rejectedCount), retrySetting);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Retrieves all anchors (outgoing links) on a specific page.
|
|
174
|
+
* Delegates to {@link getAnchorsOnPageOp}.
|
|
175
|
+
* @param pageId - The database ID of the page whose anchors to retrieve.
|
|
176
|
+
* @returns An array of anchor records with resolved URL, title, status, and content type.
|
|
177
|
+
*/
|
|
178
|
+
async getAnchorsOnPage(pageId) {
|
|
179
|
+
return emitErrorAndRetry(this, 'Database.getAnchorsOnPage', async () => await getAnchorsOnPageOp(this.#instance, pageId), retrySetting);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Retrieves all `page_main_content_audios` rows for the given page id.
|
|
183
|
+
* Delegates to {@link getAudiosOfPageOp}.
|
|
184
|
+
* @param pageId
|
|
185
|
+
*/
|
|
186
|
+
async getAudiosOfPage(pageId) {
|
|
187
|
+
return emitErrorAndRetry(this, 'Database.getAudiosOfPage', async () => await getAudiosOfPageOp(this.#instance, pageId), retrySetting);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Retrieves the base URL of the crawl session from the `info` table.
|
|
191
|
+
* Delegates to {@link getBaseUrlOp}.
|
|
192
|
+
* @returns The base URL string.
|
|
193
|
+
* @throws {Error} If no base URL is found in the database.
|
|
194
|
+
*/
|
|
195
|
+
async getBaseUrl() {
|
|
196
|
+
return emitErrorAndRetry(this, 'Database.getBaseUrl', async () => await getBaseUrlOp(this.#instance), retrySetting);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Retrieves all `page_main_content_buttons` rows for the given page id.
|
|
200
|
+
* Delegates to {@link getButtonsOfPageOp}.
|
|
201
|
+
* @param pageId
|
|
202
|
+
*/
|
|
203
|
+
async getButtonsOfPage(pageId) {
|
|
204
|
+
return emitErrorAndRetry(this, 'Database.getButtonsOfPage', async () => await getButtonsOfPageOp(this.#instance, pageId), retrySetting);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Retrieves all `page_main_content_canvases` rows for the given page id.
|
|
208
|
+
* Delegates to {@link getCanvasesOfPageOp}.
|
|
209
|
+
* @param pageId
|
|
210
|
+
*/
|
|
211
|
+
async getCanvasesOfPage(pageId) {
|
|
212
|
+
return emitErrorAndRetry(this, 'Database.getCanvasesOfPage', async () => await getCanvasesOfPageOp(this.#instance, pageId), retrySetting);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Retrieves the full crawl configuration from the `info` table.
|
|
216
|
+
* Delegates to {@link getConfigOp}.
|
|
217
|
+
* @returns The parsed {@link Config} object.
|
|
218
|
+
* @throws {Error} If no configuration is found in the database.
|
|
219
|
+
*/
|
|
220
|
+
async getConfig() {
|
|
221
|
+
return emitErrorAndRetry(this, 'Database.getConfig', async () => await getConfigOp(this.#instance), retrySetting);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Retrieves the current crawling state by listing scraped and pending URLs.
|
|
225
|
+
* Delegates to {@link getCrawlingStateOp} — see the op for the strict
|
|
226
|
+
* pending-set rationale.
|
|
227
|
+
* @returns An object with `scraped` (completed URLs), `pending` (the
|
|
228
|
+
* strict set of in-scope, anchor-referenced, unfinished URLs), and
|
|
229
|
+
* `pendingMetadataOnly` (the subset of `pending` fated for a
|
|
230
|
+
* metadata-only scrape — see the op's doc).
|
|
231
|
+
*/
|
|
232
|
+
async getCrawlingState() {
|
|
233
|
+
return emitErrorAndRetry(this, 'Database.getCrawlingState', async () => await getCrawlingStateOp(this.#instance), retrySetting);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Retrieves the `info.createdCwd` value stamped at stub-creation time.
|
|
237
|
+
* Delegates to {@link getCreatedCwdOp}.
|
|
238
|
+
* @returns The recorded cwd, or `null` if never stamped.
|
|
239
|
+
*/
|
|
240
|
+
async getCreatedCwd() {
|
|
241
|
+
return emitErrorAndRetry(this, 'Database.getCreatedCwd', async () => await getCreatedCwdOp(this.#instance), retrySetting);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Retrieves all `page_main_content_custom_elements` rows for the given
|
|
245
|
+
* page id. Delegates to {@link getCustomElementsOfPageOp}.
|
|
246
|
+
* @param pageId
|
|
247
|
+
*/
|
|
248
|
+
async getCustomElementsOfPage(pageId) {
|
|
249
|
+
return emitErrorAndRetry(this, 'Database.getCustomElementsOfPage', async () => await getCustomElementsOfPageOp(this.#instance, pageId), retrySetting);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Return the subset of `urls` that already exist in the `pages` table.
|
|
253
|
+
* Delegates to {@link getExistingPageUrlsOp}.
|
|
254
|
+
* @param urls - URL strings to probe (already in `withoutHashAndAuth` form).
|
|
255
|
+
* @returns URLs found in `pages`. Order is not preserved.
|
|
256
|
+
*/
|
|
257
|
+
async getExistingPageUrls(urls) {
|
|
258
|
+
return emitError(this, 'Database.getExistingPageUrls', async () => await getExistingPageUrlsOp(this.#instance, urls));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Return the subset of `urls` that already exist in the `resources` table.
|
|
262
|
+
* Delegates to {@link getExistingResourceUrlsOp}.
|
|
263
|
+
* @param urls - URL strings to probe.
|
|
264
|
+
* @returns URLs found in `resources`.
|
|
265
|
+
*/
|
|
266
|
+
async getExistingResourceUrls(urls) {
|
|
267
|
+
return emitError(this, 'Database.getExistingResourceUrls', async () => await getExistingResourceUrlsOp(this.#instance, urls));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Retrieves all `page_main_content_headings` rows for the given page id.
|
|
271
|
+
* Delegates to {@link getHeadingsOfPageOp}.
|
|
272
|
+
* @param pageId
|
|
273
|
+
*/
|
|
274
|
+
async getHeadingsOfPage(pageId) {
|
|
275
|
+
return emitErrorAndRetry(this, 'Database.getHeadingsOfPage', async () => await getHeadingsOfPageOp(this.#instance, pageId), retrySetting);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Reads the HTML snapshot stored as a zstd-compressed BLOB for the given page.
|
|
279
|
+
* Reads the row through {@link readPageHtmlBlobOp} with retries, then
|
|
280
|
+
* decodes it once: a decode failure is in the stored bytes and would only
|
|
281
|
+
* repeat, so it is not retried.
|
|
282
|
+
* @param pageId - The database ID of the page.
|
|
283
|
+
* @returns The decompressed HTML string, or `null` if no snapshot is stored.
|
|
284
|
+
* @throws {Error} `HTML snapshot of page <id> (page_html_blobs hash <hex>) could not be decoded: …`
|
|
285
|
+
* when the snapshot is corrupt or decompresses past `MAX_DECODED_SNAPSHOT_BYTES`
|
|
286
|
+
* (also emitted as an `'error'` event).
|
|
287
|
+
*/
|
|
288
|
+
async getHtmlOfPageById(pageId) {
|
|
289
|
+
const row = await emitErrorAndRetry(this, 'Database.getHtmlOfPageById', async () => await readPageHtmlBlobOp(this.#instance, pageId), retrySetting);
|
|
290
|
+
if (!row) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
return emitError(this, 'Database.getHtmlOfPageById', () => Promise.resolve(decodePageHtmlBlobBytes({ pageId, ...row }).toString('utf8')));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Retrieves all `page_main_content_iframes` rows for the given page id.
|
|
297
|
+
* Delegates to {@link getIframesOfPageOp}.
|
|
298
|
+
* @param pageId
|
|
299
|
+
*/
|
|
300
|
+
async getIframesOfPage(pageId) {
|
|
301
|
+
return emitErrorAndRetry(this, 'Database.getIframesOfPage', async () => await getIframesOfPageOp(this.#instance, pageId), retrySetting);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Retrieves all `page_jsonld` rows for the given page id, parsed back into
|
|
305
|
+
* {@link JsonLdRow} shape. Delegates to {@link getJsonLdOfPageOp}.
|
|
306
|
+
* @param pageId
|
|
307
|
+
*/
|
|
308
|
+
async getJsonLdOfPage(pageId) {
|
|
309
|
+
return emitErrorAndRetry(this, 'Database.getJsonLdOfPage', async () => await getJsonLdOfPageOp(this.#instance, pageId), retrySetting);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Returns the underlying Knex query builder instance for direct SQL access.
|
|
313
|
+
* This enables advanced queries (GROUP BY, HAVING, JOINs) at the database
|
|
314
|
+
* layer for performance with large datasets.
|
|
315
|
+
* @returns The Knex instance connected to the SQLite database.
|
|
316
|
+
*/
|
|
317
|
+
getKnex() {
|
|
318
|
+
return this.#instance;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Retrieves all `page_main_content_images` rows for the given page id.
|
|
322
|
+
* Delegates to {@link getMainContentImagesOfPageOp}.
|
|
323
|
+
* @param pageId
|
|
324
|
+
*/
|
|
325
|
+
async getMainContentImagesOfPage(pageId) {
|
|
326
|
+
return emitErrorAndRetry(this, 'Database.getMainContentImagesOfPage', async () => await getMainContentImagesOfPageOp(this.#instance, pageId), retrySetting);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Retrieves all `page_main_content_tables` rows for the given page id.
|
|
330
|
+
* Delegates to {@link getMainContentTablesOfPageOp}.
|
|
331
|
+
* @param pageId
|
|
332
|
+
*/
|
|
333
|
+
async getMainContentTablesOfPage(pageId) {
|
|
334
|
+
return emitErrorAndRetry(this, 'Database.getMainContentTablesOfPage', async () => await getMainContentTablesOfPageOp(this.#instance, pageId), retrySetting);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Retrieves the crawl session name from the `info` table.
|
|
338
|
+
* Delegates to {@link getNameOp}.
|
|
339
|
+
* @returns The name string.
|
|
340
|
+
* @throws {Error} If no name is found in the database.
|
|
341
|
+
*/
|
|
342
|
+
async getName() {
|
|
343
|
+
return emitErrorAndRetry(this, 'Database.getName', async () => await getNameOp(this.#instance), retrySetting);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Counts the total number of pages in the database.
|
|
347
|
+
* Delegates to {@link getPageCountOp}.
|
|
348
|
+
* @returns The total page count.
|
|
349
|
+
* @throws {Error} If the count query fails.
|
|
350
|
+
*/
|
|
351
|
+
async getPageCount() {
|
|
352
|
+
return emitErrorAndRetry(this, 'Database.getPageCount', async () => await getPageCountOp(this.#instance), retrySetting);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Retrieves pages from the database with optional filtering, pagination via
|
|
356
|
+
* offset and limit. Delegates to {@link getPagesOp}.
|
|
357
|
+
* @param filter - An optional {@link PageFilter} to narrow results by content type and origin.
|
|
358
|
+
* @param offset - The number of rows to skip. Defaults to `0`.
|
|
359
|
+
* @param limit - The maximum number of rows to return. Defaults to `100000`.
|
|
360
|
+
* @returns An array of raw `DB_Page` rows.
|
|
361
|
+
*/
|
|
362
|
+
async getPages(filter, offset = 0, limit = 100_000) {
|
|
363
|
+
return emitErrorAndRetry(this, 'Database.getPages', async () => await getPagesOp(this.#instance, filter, offset, limit), retrySetting);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Look up the `source` column of a single page by its URL key.
|
|
367
|
+
* Delegates to {@link getPageSourceByUrlOp}.
|
|
368
|
+
* @param url - URL key in `url.withoutHashAndAuth` form.
|
|
369
|
+
* @returns The recorded `source`, or `undefined` when no row exists.
|
|
370
|
+
*/
|
|
371
|
+
async getPageSourceByUrl(url) {
|
|
372
|
+
return emitError(this, 'Database.getPageSourceByUrl', async () => await getPageSourceByUrlOp(this.#instance, url));
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Retrieves pages along with their related redirect, anchor, and referrer data.
|
|
376
|
+
* Results are ordered by the natural URL sort order. Only non-redirected pages
|
|
377
|
+
* are returned. Delegates to {@link getPagesWithRelsOp}.
|
|
378
|
+
* @param offset - The number of rows to skip.
|
|
379
|
+
* @param limit - The maximum number of pages to return.
|
|
380
|
+
* @returns An object containing `pages`, `redirects`, `anchors`, and `referrers` arrays.
|
|
381
|
+
*/
|
|
382
|
+
async getPagesWithRels(offset, limit) {
|
|
383
|
+
return emitErrorAndRetry(this, 'Database.getPagesWithRels', async () => await getPagesWithRelsOp(this.#instance, offset, limit), retrySetting);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Retrieves all `page_technologies` rows for the given page id.
|
|
387
|
+
* Delegates to {@link getPageTechnologiesOfPageOp}.
|
|
388
|
+
* @param pageId
|
|
389
|
+
*/
|
|
390
|
+
async getPageTechnologiesOfPage(pageId) {
|
|
391
|
+
return emitErrorAndRetry(this, 'Database.getPageTechnologiesOfPage', async () => await getPageTechnologiesOfPageOp(this.#instance, pageId), retrySetting);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Retrieves redirect sources for the given page IDs in bulk.
|
|
395
|
+
* Delegates to {@link getRedirectsForPagesOp}.
|
|
396
|
+
* @param pageIds - The database IDs of the destination pages.
|
|
397
|
+
* @returns An array of {@link DB_Redirect} records mapping destination pages to their redirect sources.
|
|
398
|
+
*/
|
|
399
|
+
async getRedirectsForPages(pageIds) {
|
|
400
|
+
return emitErrorAndRetry(this, 'Database.getRedirectsForPages', async () => await getRedirectsForPagesOp(this.#instance, pageIds), retrySetting);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Retrieves pages that link to a specific page (incoming links / referrers),
|
|
404
|
+
* resolved through redirects. Delegates to {@link getReferrersOfPageOp}.
|
|
405
|
+
* @param pageId - The database ID of the target page.
|
|
406
|
+
* @returns An array of referrer records with URL, hash, and text content.
|
|
407
|
+
*/
|
|
408
|
+
async getReferrersOfPage(pageId) {
|
|
409
|
+
return emitErrorAndRetry(this, 'Database.getReferrersOfPage', async () => await getReferrersOfPageOp(this.#instance, pageId), retrySetting);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Retrieves the page URLs that reference a specific resource.
|
|
413
|
+
* Delegates to {@link getReferrersOfResourceOp}.
|
|
414
|
+
* @param id - The database ID of the resource.
|
|
415
|
+
* @returns An array of page URL strings that reference the resource.
|
|
416
|
+
*/
|
|
417
|
+
async getReferrersOfResource(id) {
|
|
418
|
+
return emitErrorAndRetry(this, 'Database.getReferrersOfResource', async () => await getReferrersOfResourceOp(this.#instance, id), retrySetting);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Retrieves a single sub-resource from the `resources` table by its URL.
|
|
422
|
+
* Delegates to {@link getResourceByUrlOp}.
|
|
423
|
+
*
|
|
424
|
+
* Deliberately NOT wrapped with `emitError`/`emitErrorAndRetry`: the only caller (the
|
|
425
|
+
* crawler's resource-reuse hook) has a full fallback (the HEAD pre-flight),
|
|
426
|
+
* so a read failure here must not surface as a database `error` event —
|
|
427
|
+
* the orchestrator aborts the whole crawl on that event, which is the
|
|
428
|
+
* correct reaction to write failures but not to a recoverable read.
|
|
429
|
+
* @param urls - URL candidates to match against the `url` column.
|
|
430
|
+
* @returns The raw {@link DB_Resource} row, or `null` if none match.
|
|
431
|
+
*/
|
|
432
|
+
async getResourceByUrl(urls) {
|
|
433
|
+
return retryCall(async () => await getResourceByUrlOp(this.#instance, urls), {
|
|
434
|
+
...retrySetting,
|
|
435
|
+
label: 'Database.getResourceByUrl',
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Retrieves all sub-resources from the `resources` table.
|
|
440
|
+
* Delegates to {@link getResourcesOp}.
|
|
441
|
+
* @returns An array of raw {@link DB_Resource} rows.
|
|
442
|
+
*/
|
|
443
|
+
async getResources() {
|
|
444
|
+
return emitErrorAndRetry(this, 'Database.getResources', async () => await getResourcesOp(this.#instance), retrySetting);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Retrieves a flat list of all resource URLs from the `resources` table.
|
|
448
|
+
* Delegates to {@link getResourceUrlListOp}.
|
|
449
|
+
*
|
|
450
|
+
* `onProgress` is clamped to a high-water mark across retries: a
|
|
451
|
+
* transient failure partway through the keyset scan restarts
|
|
452
|
+
* {@link getResourceUrlListOp} from `id = 0` (its own `lastId` is a local
|
|
453
|
+
* closure variable, reset on every `fn` invocation `retryCall` retries),
|
|
454
|
+
* which would otherwise visibly rewind the reported progress backwards
|
|
455
|
+
* before catching back up.
|
|
456
|
+
* @param onProgress - Forwarded to {@link getResourceUrlListOp} — see
|
|
457
|
+
* that function's docs.
|
|
458
|
+
* @returns An array of resource URL strings.
|
|
459
|
+
*/
|
|
460
|
+
async getResourceUrlList(onProgress) {
|
|
461
|
+
let highWaterMark = 0;
|
|
462
|
+
const monotonicProgress = onProgress
|
|
463
|
+
? (scannedUpToId, maxId) => {
|
|
464
|
+
highWaterMark = Math.max(highWaterMark, scannedUpToId);
|
|
465
|
+
onProgress(highWaterMark, maxId);
|
|
466
|
+
}
|
|
467
|
+
: undefined;
|
|
468
|
+
return emitErrorAndRetry(this, 'Database.getResourceUrlList', async () => await getResourceUrlListOp(this.#instance, monotonicProgress), retrySetting);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Counts pages that were scraped as crawl targets (full HTML render).
|
|
472
|
+
* Delegates to {@link getScrapedHtmlPageCountOp}.
|
|
473
|
+
* @returns The number of `text/html` rows with `isTarget = 1` and `scraped = 1`.
|
|
474
|
+
*/
|
|
475
|
+
async getScrapedHtmlPageCount() {
|
|
476
|
+
return emitErrorAndRetry(this, 'Database.getScrapedHtmlPageCount', async () => await getScrapedHtmlPageCountOp(this.#instance), retrySetting);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Retrieves all `technology_signals` rows for the given page id.
|
|
480
|
+
* Delegates to {@link getTechnologySignalsOfPageOp}.
|
|
481
|
+
* @param pageId
|
|
482
|
+
*/
|
|
483
|
+
async getTechnologySignalsOfPage(pageId) {
|
|
484
|
+
return emitErrorAndRetry(this, 'Database.getTechnologySignalsOfPage', async () => await getTechnologySignalsOfPageOp(this.#instance, pageId), retrySetting);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Retrieves all `page_main_content_videos` rows for the given page id.
|
|
488
|
+
* Delegates to {@link getVideosOfPageOp}.
|
|
489
|
+
* @param pageId
|
|
490
|
+
*/
|
|
491
|
+
async getVideosOfPage(pageId) {
|
|
492
|
+
return emitErrorAndRetry(this, 'Database.getVideosOfPage', async () => await getVideosOfPageOp(this.#instance, pageId), retrySetting);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Records a crawler-level (`error` channel) failure into `crawl_errors`.
|
|
496
|
+
* Delegates to {@link insertCrawlErrorOp}.
|
|
497
|
+
* @param url - The URL the error is about, or `null` for a process-level error.
|
|
498
|
+
* @param message - The error message (one line is enough for classification).
|
|
499
|
+
* @param isExternal - Whether the URL is external to the crawl scope.
|
|
500
|
+
*/
|
|
501
|
+
async insertCrawlError(url, message, isExternal = false) {
|
|
502
|
+
return emitErrorAndRetry(this, 'Database.insertCrawlError', async () => await insertCrawlErrorOp(this.#instance, url, message, isExternal), retrySetting);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Appends one row (`rejected_count = NULL`) to the `dedupe_cap_events`
|
|
506
|
+
* journal. Delegates to {@link insertDedupeCapEventOp}.
|
|
507
|
+
* @param params - The newly-capped shape's fields to record.
|
|
508
|
+
* @returns The autoincremented `id` of the newly-inserted row.
|
|
509
|
+
*/
|
|
510
|
+
async insertDedupeCapEvent(params) {
|
|
511
|
+
return emitErrorAndRetry(this, 'Database.insertDedupeCapEvent', async () => await insertDedupeCapEventOp(this.#instance, params), retrySetting);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Pre-insert inventory non-HTML URLs into `resources` as placeholder rows.
|
|
515
|
+
* Delegates to {@link insertInventoryResourcesOp}.
|
|
516
|
+
* @param urls - URL strings (already in `withoutHashAndAuth` form).
|
|
517
|
+
*/
|
|
518
|
+
async insertInventoryResources(urls) {
|
|
519
|
+
return emitErrorAndRetry(this, 'Database.insertInventoryResources', async () => await insertInventoryResourcesOp(this.#instance, this.#writeRefCaches, urls), retrySetting);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Pre-insert inventory HTML seeds into `pages` as `scraped = 0`,
|
|
523
|
+
* `source = 'inventory-seed'` placeholders. Delegates to
|
|
524
|
+
* {@link insertInventorySeedsOp} — see the op for the Ctrl+C tolerance
|
|
525
|
+
* rationale.
|
|
526
|
+
* @param urls - URL strings already in `withoutHashAndAuth` form.
|
|
527
|
+
*/
|
|
528
|
+
async insertInventorySeeds(urls) {
|
|
529
|
+
return emitErrorAndRetry(this, 'Database.insertInventorySeeds', async () => await insertInventorySeedsOp(this.#instance, this.#writeRefCaches, urls), retrySetting);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Records exclude-matched inventory URLs as terminal skipped pages
|
|
533
|
+
* (`scraped=1`, `is_skipped=1`, `skip_reason='excluded'`,
|
|
534
|
+
* `source='inventory-seed'`). Delegates to
|
|
535
|
+
* {@link insertInventorySkippedPagesOp} — see that op's JSDoc for the
|
|
536
|
+
* normal-crawl parity rationale.
|
|
537
|
+
* @param urls - URL strings already in `withoutHashAndAuth` form.
|
|
538
|
+
*/
|
|
539
|
+
async insertInventorySkippedPages(urls) {
|
|
540
|
+
return emitErrorAndRetry(this, 'Database.insertInventorySkippedPages', async () => await insertInventorySkippedPagesOp(this.#instance, this.#writeRefCaches, urls), retrySetting);
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Appends one open (`ended_at = NULL`) row to the `network_outages`
|
|
544
|
+
* journal. Delegates to {@link insertNetworkOutageOp}.
|
|
545
|
+
* @param params - The confirmed-outage fields to record.
|
|
546
|
+
* @returns The autoincremented `id` of the newly-inserted row.
|
|
547
|
+
*/
|
|
548
|
+
async insertNetworkOutage(params) {
|
|
549
|
+
return emitErrorAndRetry(this, 'Database.insertNetworkOutage', async () => await insertNetworkOutageOp(this.#instance, params), retrySetting);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Records a partial scrape failure against the page identified by `url`.
|
|
553
|
+
* Delegates to {@link insertPageErrorOp}.
|
|
554
|
+
* @param url - URL of the page being scraped.
|
|
555
|
+
* @param phase - Scrape phase name (typically `'retryExhausted'`).
|
|
556
|
+
* @param message - Human-readable failure message.
|
|
557
|
+
* @param isExternal - Whether the URL is external. Defaults to `false`.
|
|
558
|
+
*/
|
|
559
|
+
async insertPageError(url, phase, message, isExternal = false) {
|
|
560
|
+
return emitErrorAndRetry(this, 'Database.insertPageError', async () => await insertPageErrorOp(this.#instance, this.#writeRefCaches, url, phase, message, isExternal), retrySetting);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Inserts a sub-resource into the `resources` table.
|
|
564
|
+
* Delegates to {@link insertResourceOp}.
|
|
565
|
+
* @param resource - The resource data to insert.
|
|
566
|
+
* @param source - Provenance label for new rows. `undefined` leaves the DB DEFAULT (`'crawled'`).
|
|
567
|
+
*/
|
|
568
|
+
async insertResource(resource, source) {
|
|
569
|
+
return emitErrorAndRetry(this, 'Database.insertResource', async () => await insertResourceOp(this.#instance, this.#writeRefCaches, resource, source), retrySetting);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Inserts a referrer relationship between a resource and a page into the
|
|
573
|
+
* `resources-referrers` table. Delegates to {@link insertResourceReferrersOp}.
|
|
574
|
+
* @param src - The URL of the resource.
|
|
575
|
+
* @param pageUrl - The URL of the page that references the resource.
|
|
576
|
+
*/
|
|
577
|
+
async insertResourceReferrers(src, pageUrl) {
|
|
578
|
+
return emitErrorAndRetry(this, 'Database.insertResourceReferrers', async () => await insertResourceReferrersOp(this.#instance, this.#writeRefCaches, src, pageUrl), retrySetting);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Every previously-scraped internal page's raw fields, in the shape
|
|
582
|
+
* `buildDedupeCapObservation` needs to replay this archive's prior
|
|
583
|
+
* `DedupeCapTracker` observations into a fresh tracker instance.
|
|
584
|
+
* Delegates to {@link listDedupeCapObservationsOp} — see that function
|
|
585
|
+
* for the row selection criteria.
|
|
586
|
+
* @param onProgress - Forwarded to {@link listDedupeCapObservationsOp} —
|
|
587
|
+
* see that function's docs.
|
|
588
|
+
* @returns Every qualifying page's raw fields, in `content_items.id` order.
|
|
589
|
+
*/
|
|
590
|
+
async listDedupeCapObservations(onProgress) {
|
|
591
|
+
return emitErrorAndRetry(this, 'Database.listDedupeCapObservations', async () => await listDedupeCapObservationsOp(this.#instance, onProgress), retrySetting);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Every distinct `dedupe_cap_events.shape_key` recorded in this archive.
|
|
595
|
+
* Delegates to {@link listDedupeCapShapeKeysOp}.
|
|
596
|
+
* @returns Distinct shape keys already confirmed capped, or `[]` on an
|
|
597
|
+
* archive that predates `dedupe_cap_events` or has recorded none.
|
|
598
|
+
*/
|
|
599
|
+
async listDedupeCapShapeKeys() {
|
|
600
|
+
return emitErrorAndRetry(this, 'Database.listDedupeCapShapeKeys', async () => await listDedupeCapShapeKeysOp(this.#instance), retrySetting);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Hostnames whose `crawl_errors` history is consistently DNS failures and
|
|
604
|
+
* for which no recent 2xx-3xx page or resource is recorded.
|
|
605
|
+
* Delegates to {@link listDnsBurnedHostCandidatesOp}.
|
|
606
|
+
* @returns Lower-cased hostnames safe to short-circuit.
|
|
607
|
+
*/
|
|
608
|
+
async listDnsBurnedHostCandidates() {
|
|
609
|
+
return emitErrorAndRetry(this, 'Database.listDnsBurnedHostCandidates', async () => await listDnsBurnedHostCandidatesOp(this.#instance), retrySetting);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Lists every recorded outage as a resolved {@link OutageWindow}.
|
|
613
|
+
* Delegates to {@link listNetworkOutagesOp}.
|
|
614
|
+
* @returns Resolved outage windows, or `[]` on an archive that predates
|
|
615
|
+
* `network_outages` or has recorded no outages.
|
|
616
|
+
*/
|
|
617
|
+
async listNetworkOutages() {
|
|
618
|
+
return emitErrorAndRetry(this, 'Database.listNetworkOutages', async () => await listNetworkOutagesOp(this.#instance), retrySetting);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Appends one row to the `list_reconcile_runs` audit log.
|
|
622
|
+
* Delegates to {@link recordListReconcileRunOp}.
|
|
623
|
+
* @param meta - The run metadata to record. Only `ran_at` is required.
|
|
624
|
+
* @returns The autoincremented `id` of the newly-inserted row.
|
|
625
|
+
*/
|
|
626
|
+
async recordListReconcileRun(meta) {
|
|
627
|
+
return emitErrorAndRetry(this, 'Database.recordListReconcileRun', async () => await recordListReconcileRunOp(this.#instance, meta), retrySetting);
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Records a redirect edge (source → destination) **without** re-storing the
|
|
631
|
+
* destination's content. Delegates to {@link recordRedirectOp}.
|
|
632
|
+
* @param page - HEAD-resolved page data carrying the redirect chain. Its
|
|
633
|
+
* `anchorList` / `imageList` are ignored (a redirect source owns no content).
|
|
634
|
+
* @param source - Inventory provenance forwarded by the orchestrator for
|
|
635
|
+
* the redirect-edge fast path. `undefined` keeps the DB DEFAULT
|
|
636
|
+
* `'crawled'` on a brand-new destination row.
|
|
637
|
+
*/
|
|
638
|
+
async recordRedirect(page, source) {
|
|
639
|
+
return emitErrorAndRetry(this, 'Database.recordRedirect', async () => await recordRedirectOp(this.#instance, this.#writeRefCaches, page, source), retrySetting);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Replaces one page's `page_console_logs` rows with a freshly captured
|
|
643
|
+
* set of console messages / page errors. Delegates to
|
|
644
|
+
* {@link replaceConsoleLogsOp}.
|
|
645
|
+
* @param pageUrl - The originally-requested URL, normalised (`withoutHashAndAuth` form).
|
|
646
|
+
* @param redirectPaths - The redirect chain hops captured during fetch, in order.
|
|
647
|
+
* @param entries - The console log entries to persist.
|
|
648
|
+
*/
|
|
649
|
+
async replaceConsoleLogs(pageUrl, redirectPaths, entries) {
|
|
650
|
+
return emitErrorAndRetry(this, 'Database.replaceConsoleLogs', async () => await replaceConsoleLogsOp(this.#instance, this.#writeRefCaches, pageUrl, redirectPaths, entries), retrySetting);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Replaces the stored DOM-structure template classification with a
|
|
654
|
+
* freshly generated set. Delegates to {@link replacePageTemplatesOp}.
|
|
655
|
+
* @param templateKeysByUrl - Page URL → template key.
|
|
656
|
+
* @param clusterReasonsByTemplateKey - Template key → cluster-selection
|
|
657
|
+
* evidence, if the caller captured it.
|
|
658
|
+
*/
|
|
659
|
+
async replacePageTemplates(templateKeysByUrl, clusterReasonsByTemplateKey) {
|
|
660
|
+
return emitErrorAndRetry(this, 'Database.replacePageTemplates', async () => await replacePageTemplatesOp(this.#instance, {
|
|
661
|
+
templateKeysByUrl,
|
|
662
|
+
clusterReasonsByTemplateKey,
|
|
663
|
+
}), retrySetting);
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Promote previously-external pages whose URL falls under any of the new
|
|
667
|
+
* scope entries back to a "needs scraping" state.
|
|
668
|
+
* Delegates to {@link repromoteExternalPagesOp}.
|
|
669
|
+
* @param scopes - The hostname-indexed scope map after the new roots are merged.
|
|
670
|
+
* @param options - URL parsing options forwarded to the scope matcher.
|
|
671
|
+
* @param onProgress - Forwarded to {@link repromoteExternalPagesOp} — see
|
|
672
|
+
* that function's docs.
|
|
673
|
+
* @returns The URLs of the pages that were promoted.
|
|
674
|
+
*/
|
|
675
|
+
async repromoteExternalPages(scopes, options, onProgress) {
|
|
676
|
+
return emitErrorAndRetry(this, 'Database.repromoteExternalPages', async () => await repromoteExternalPagesOp(this.#instance, scopes, options, onProgress), retrySetting);
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Reset previously-attempted pages that ended in a recoverable failure so a
|
|
680
|
+
* follow-up crawl can re-fetch them from scratch. Delegates to
|
|
681
|
+
* {@link resetFailedPagesOp} — see the op for the permanent-failure
|
|
682
|
+
* exclusion rationale.
|
|
683
|
+
* @param onProgress - Forwarded to {@link resetFailedPagesOp} — see that
|
|
684
|
+
* function's docs.
|
|
685
|
+
* @returns The URLs of the pages that were reset to pending.
|
|
686
|
+
*/
|
|
687
|
+
async resetFailedPages(onProgress) {
|
|
688
|
+
return emitErrorAndRetry(this, 'Database.resetFailedPages', async () => await resetFailedPagesOp(this.#instance, onProgress), retrySetting);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Reset pages matching an operator-supplied URL list back to pending so a
|
|
692
|
+
* follow-up crawl re-fetches them from scratch. Delegates to
|
|
693
|
+
* {@link resetPagesByUrlsOp} — see the op for the conservative exclusion
|
|
694
|
+
* rationale (redirect sources / intentionally-skipped / external pages).
|
|
695
|
+
* @param urls - URL strings to match, already in `withoutHashAndAuth` form.
|
|
696
|
+
* @param onProgress - Forwarded to {@link resetPagesByUrlsOp} — see that
|
|
697
|
+
* function's docs.
|
|
698
|
+
* @returns The reset URLs plus the excluded URLs grouped by reason.
|
|
699
|
+
*/
|
|
700
|
+
async resetPagesByUrls(urls, onProgress) {
|
|
701
|
+
return emitErrorAndRetry(this, 'Database.resetPagesByUrls', async () => await resetPagesByUrlsOp(this.#instance, urls, onProgress), retrySetting);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Stores the crawl configuration in the `info` table.
|
|
705
|
+
* Delegates to {@link setConfigOp}.
|
|
706
|
+
* @param config - The {@link Config} object to store.
|
|
707
|
+
*/
|
|
708
|
+
async setConfig(config) {
|
|
709
|
+
return emitErrorAndRetry(this, 'Database.setConfig', async () => await setConfigOp(this.#instance, config), retrySetting);
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Marks a page as skipped in the database with the given reason.
|
|
713
|
+
* Delegates to {@link setSkippedPageOp}.
|
|
714
|
+
* @param url - The URL of the skipped page.
|
|
715
|
+
* @param reason - The reason the page was skipped.
|
|
716
|
+
* @param isExternal - Whether the page is on an external domain. Defaults to `false`.
|
|
717
|
+
*/
|
|
718
|
+
async setSkippedPage(url, reason, isExternal = false) {
|
|
719
|
+
return emitErrorAndRetry(this, 'Database.setSkippedPage', async () => await setSkippedPageOp(this.#instance, this.#writeRefCaches, url, reason, isExternal), retrySetting);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Assigns natural URL sort order values to all internal pages.
|
|
723
|
+
* Delegates to {@link setUrlOrderOp}.
|
|
724
|
+
* @param onProgress - Forwarded to {@link setUrlOrderOp} — see that
|
|
725
|
+
* function's docs.
|
|
726
|
+
*/
|
|
727
|
+
async setUrlOrder(onProgress) {
|
|
728
|
+
await setUrlOrderOp(this.#instance, onProgress);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Update the single row in the `info` table with a partial config patch.
|
|
732
|
+
* Delegates to {@link updateConfigOp}.
|
|
733
|
+
* @param patch - Partial {@link Config} fields to overwrite. `undefined` values are skipped.
|
|
734
|
+
*/
|
|
735
|
+
async updateConfig(patch) {
|
|
736
|
+
return emitErrorAndRetry(this, 'Database.updateConfig', async () => await updateConfigOp(this.#instance, patch), retrySetting);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Inserts or updates a crawled page in the database, including its redirect
|
|
740
|
+
* chain, anchors, images, and (when `writeHtml`) its compressed HTML
|
|
741
|
+
* snapshot BLOB. Delegates to {@link updatePageOp}.
|
|
742
|
+
* @param page - The page data to store.
|
|
743
|
+
* @param writeHtml - When `true`, this call is allowed to insert (or clear)
|
|
744
|
+
* the page's HTML blob. `setExternalPage` passes `false` because external
|
|
745
|
+
* metadata-only scrapes never carry HTML and must not perturb an already
|
|
746
|
+
* stored body.
|
|
747
|
+
* @param isTarget - Whether this page is a crawl target.
|
|
748
|
+
* @param source - Provenance label written ONLY when the row is freshly
|
|
749
|
+
* inserted. Existing rows keep their original `source`.
|
|
750
|
+
* @param bodyHash - Precomputed body hash for the page's HTML (see
|
|
751
|
+
* `CrawlerEventTypes.page.bodyHash`). `undefined`/`null` falls back to
|
|
752
|
+
* computing it from the HTML instead.
|
|
753
|
+
* @param recursive - See {@link updatePageOp}'s `recursive` doc.
|
|
754
|
+
* @returns The database `pageId` of the inserted/updated row.
|
|
755
|
+
*/
|
|
756
|
+
async updatePage(page, writeHtml, isTarget, source, bodyHash, recursive) {
|
|
757
|
+
return emitErrorAndRetry(this, 'Database.updatePage', async () => await updatePageOp(this.#instance, this.#writeRefCaches, page, writeHtml, isTarget, source, bodyHash, recursive), retrySetting);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Initializes the database schema if tables do not exist, then runs
|
|
761
|
+
* lightweight migrations; in read-only mode both are skipped.
|
|
762
|
+
* Delegates to {@link initOp}.
|
|
763
|
+
* @param readOnly - When true, skip schema init + migrations.
|
|
764
|
+
* @param onLog - Forwarded to {@link initOp} — see
|
|
765
|
+
* {@link DatabaseOption.onLog}'s docs.
|
|
766
|
+
*/
|
|
767
|
+
async #init(readOnly, onLog) {
|
|
768
|
+
await initOp(this.#instance, readOnly, onLog);
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Creates and initializes a new Database instance.
|
|
772
|
+
*
|
|
773
|
+
* **Writer mode (default)**: creates the parent directory for the
|
|
774
|
+
* database file if needed, establishes the connection, and initializes
|
|
775
|
+
* the schema + migrations.
|
|
776
|
+
*
|
|
777
|
+
* **Read-only mode** (`options.readOnly`): refuses to resurrect a
|
|
778
|
+
* missing parent directory or db file — throws if either is absent at
|
|
779
|
+
* the time of the call. Skips schema init and migrations entirely so
|
|
780
|
+
* the user's tmpDir is never modified. Required by viewer / MCP
|
|
781
|
+
* stub-mode opens, where a TOCTOU window between classification and
|
|
782
|
+
* `connect()` could otherwise leave behind a phantom empty tmpDir.
|
|
783
|
+
* @param options - Database connection options.
|
|
784
|
+
* @returns A fully initialized Database instance.
|
|
785
|
+
* @throws {Error} In read-only mode, if the parent directory or db
|
|
786
|
+
* file does not exist when `connect()` runs.
|
|
787
|
+
*/
|
|
788
|
+
static async connect(options) {
|
|
789
|
+
if (options.readOnly) {
|
|
790
|
+
if (!existsSync(path.dirname(options.filename))) {
|
|
791
|
+
throw new Error(`Cannot open archive read-only: parent directory disappeared (${path.dirname(options.filename)}). The source may have been removed by another process.`);
|
|
792
|
+
}
|
|
793
|
+
if (!existsSync(options.filename)) {
|
|
794
|
+
throw new Error(`Cannot open archive read-only: database file missing (${options.filename}). The source may have been removed by another process.`);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
mkdir(options.filename);
|
|
799
|
+
}
|
|
800
|
+
const db = new Database(options);
|
|
801
|
+
await db.#init(options.readOnly ?? false, options.onLog);
|
|
802
|
+
return db;
|
|
803
|
+
}
|
|
804
|
+
}
|