@nitpicker/crawler 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/lib/archive/archive-accessor.d.ts +2 -2
- package/lib/archive/archive-accessor.js +2 -2
- package/lib/archive/archive-lock.d.ts +7 -0
- package/lib/archive/archive-lock.js +7 -0
- package/lib/archive/archive.d.ts +63 -16
- package/lib/archive/archive.js +56 -17
- package/lib/archive/create-adjunct-tables.d.ts +43 -0
- package/lib/archive/create-adjunct-tables.js +213 -0
- package/lib/archive/create-entity-tables.d.ts +173 -0
- package/lib/archive/create-entity-tables.js +318 -0
- package/lib/archive/create-progress-reporter.d.ts +30 -0
- package/lib/archive/create-progress-reporter.js +38 -0
- package/lib/archive/create-ref-tables.d.ts +35 -0
- package/lib/archive/create-ref-tables.js +188 -0
- package/lib/archive/database.d.ts +92 -345
- package/lib/archive/database.js +168 -1942
- package/lib/archive/db-ops/_shared/clear-write-ref-caches.d.ts +27 -0
- package/lib/archive/db-ops/_shared/clear-write-ref-caches.js +34 -0
- package/lib/archive/db-ops/_shared/create-write-ref-caches.d.ts +17 -0
- package/lib/archive/db-ops/_shared/create-write-ref-caches.js +26 -0
- package/lib/archive/db-ops/_shared/decode-json-ref.d.ts +17 -0
- package/lib/archive/db-ops/_shared/decode-json-ref.js +31 -0
- package/lib/archive/db-ops/_shared/load-response-headers-by-set-ids.d.ts +20 -0
- package/lib/archive/db-ops/_shared/load-response-headers-by-set-ids.js +53 -0
- package/lib/archive/db-ops/_shared/resolve-content-item-id.d.ts +61 -0
- package/lib/archive/db-ops/_shared/resolve-content-item-id.js +111 -0
- package/lib/archive/db-ops/_shared/resolve-url-or-blob.d.ts +23 -0
- package/lib/archive/db-ops/_shared/resolve-url-or-blob.js +29 -0
- package/lib/archive/db-ops/_shared/retry-setting.d.ts +16 -0
- package/lib/archive/db-ops/_shared/retry-setting.js +18 -0
- package/lib/archive/db-ops/_shared/safe-parse-json.d.ts +11 -0
- package/lib/archive/db-ops/_shared/safe-parse-json.js +18 -0
- package/lib/archive/db-ops/_shared/types.d.ts +53 -0
- package/lib/archive/db-ops/_shared/types.js +1 -0
- package/lib/archive/db-ops/_shared/upsert-blob-ref.d.ts +25 -0
- package/lib/archive/db-ops/_shared/upsert-blob-ref.js +48 -0
- package/lib/archive/db-ops/_shared/upsert-content-type-ref.d.ts +30 -0
- package/lib/archive/db-ops/_shared/upsert-content-type-ref.js +45 -0
- package/lib/archive/db-ops/_shared/upsert-json-ref.d.ts +22 -0
- package/lib/archive/db-ops/_shared/upsert-json-ref.js +41 -0
- package/lib/archive/db-ops/_shared/upsert-response-headers.d.ts +35 -0
- package/lib/archive/db-ops/_shared/upsert-response-headers.js +49 -0
- package/lib/archive/db-ops/_shared/upsert-url-ref.d.ts +39 -0
- package/lib/archive/db-ops/_shared/upsert-url-ref.js +62 -0
- package/lib/archive/db-ops/analysis/replace-analysis-violations.d.ts +28 -0
- package/lib/archive/db-ops/analysis/replace-analysis-violations.js +152 -0
- package/lib/archive/db-ops/anchors/get-anchors-on-page.d.ts +10 -0
- package/lib/archive/db-ops/anchors/get-anchors-on-page.js +21 -0
- package/lib/archive/db-ops/config/get-base-url.d.ts +8 -0
- package/lib/archive/db-ops/config/get-base-url.js +14 -0
- package/lib/archive/db-ops/config/get-config.d.ts +10 -0
- package/lib/archive/db-ops/config/get-config.js +27 -0
- package/lib/archive/db-ops/config/get-name.d.ts +8 -0
- package/lib/archive/db-ops/config/get-name.js +14 -0
- package/lib/archive/db-ops/config/info-column-allowlist.d.ts +7 -0
- package/lib/archive/db-ops/config/info-column-allowlist.js +26 -0
- package/lib/archive/db-ops/config/info-json-columns.d.ts +5 -0
- package/lib/archive/db-ops/config/info-json-columns.js +10 -0
- package/lib/archive/db-ops/config/set-config.d.ts +12 -0
- package/lib/archive/db-ops/config/set-config.js +21 -0
- package/lib/archive/db-ops/config/update-config.d.ts +17 -0
- package/lib/archive/db-ops/config/update-config.js +36 -0
- package/lib/archive/db-ops/errors/insert-crawl-error.d.ts +15 -0
- package/lib/archive/db-ops/errors/insert-crawl-error.js +21 -0
- package/lib/archive/db-ops/errors/insert-page-error.d.ts +21 -0
- package/lib/archive/db-ops/errors/insert-page-error.js +28 -0
- package/lib/archive/db-ops/errors/list-dns-burned-host-candidates.d.ts +22 -0
- package/lib/archive/db-ops/errors/list-dns-burned-host-candidates.js +141 -0
- package/lib/archive/db-ops/html/get-html-of-page-by-id.d.ts +18 -0
- package/lib/archive/db-ops/html/get-html-of-page-by-id.js +29 -0
- package/lib/archive/db-ops/inventory/record-inventory-run.d.ts +21 -0
- package/lib/archive/db-ops/inventory/record-inventory-run.js +38 -0
- package/lib/archive/db-ops/lifecycle/checkpoint.d.ts +8 -0
- package/lib/archive/db-ops/lifecycle/checkpoint.js +9 -0
- package/lib/archive/db-ops/lifecycle/destroy.d.ts +6 -0
- package/lib/archive/db-ops/lifecycle/destroy.js +7 -0
- package/lib/archive/db-ops/lifecycle/init.d.ts +22 -0
- package/lib/archive/db-ops/lifecycle/init.js +42 -0
- package/lib/archive/db-ops/meta/get-jsonld-of-page.d.ts +13 -0
- package/lib/archive/db-ops/meta/get-jsonld-of-page.js +27 -0
- package/lib/archive/db-ops/meta/get-tags-of-page.d.ts +12 -0
- package/lib/archive/db-ops/meta/get-tags-of-page.js +28 -0
- package/lib/archive/db-ops/pages/order/set-url-order.d.ts +8 -0
- package/lib/archive/db-ops/pages/order/set-url-order.js +32 -0
- package/lib/archive/db-ops/pages/read/build-page-query.d.ts +18 -0
- package/lib/archive/db-ops/pages/read/build-page-query.js +40 -0
- package/lib/archive/db-ops/pages/read/get-crawling-state.d.ts +70 -0
- package/lib/archive/db-ops/pages/read/get-crawling-state.js +98 -0
- package/lib/archive/db-ops/pages/read/get-existing-page-urls.d.ts +15 -0
- package/lib/archive/db-ops/pages/read/get-existing-page-urls.js +30 -0
- package/lib/archive/db-ops/pages/read/get-page-count.d.ts +12 -0
- package/lib/archive/db-ops/pages/read/get-page-count.js +21 -0
- package/lib/archive/db-ops/pages/read/get-page-source-by-url.d.ts +24 -0
- package/lib/archive/db-ops/pages/read/get-page-source-by-url.js +28 -0
- package/lib/archive/db-ops/pages/read/get-pages-with-rels.d.ts +38 -0
- package/lib/archive/db-ops/pages/read/get-pages-with-rels.js +107 -0
- package/lib/archive/db-ops/pages/read/get-pages.d.ts +11 -0
- package/lib/archive/db-ops/pages/read/get-pages.js +51 -0
- package/lib/archive/db-ops/pages/read/get-scraped-html-page-count.d.ts +18 -0
- package/lib/archive/db-ops/pages/read/get-scraped-html-page-count.js +25 -0
- package/lib/archive/db-ops/pages/read/reconstruct-page-rows.d.ts +31 -0
- package/lib/archive/db-ops/pages/read/reconstruct-page-rows.js +32 -0
- package/lib/archive/db-ops/pages/reset/repromote-external-pages.d.ts +24 -0
- package/lib/archive/db-ops/pages/reset/repromote-external-pages.js +93 -0
- package/lib/archive/db-ops/pages/reset/reset-failed-pages.d.ts +47 -0
- package/lib/archive/db-ops/pages/reset/reset-failed-pages.js +124 -0
- package/lib/archive/db-ops/pages/write/insert-inventory-seeds.d.ts +37 -0
- package/lib/archive/db-ops/pages/write/insert-inventory-seeds.js +72 -0
- package/lib/archive/db-ops/pages/write/insert-jsonld.d.ts +17 -0
- package/lib/archive/db-ops/pages/write/insert-jsonld.js +49 -0
- package/lib/archive/db-ops/pages/write/insert-page.d.ts +36 -0
- package/lib/archive/db-ops/pages/write/insert-page.js +208 -0
- package/lib/archive/db-ops/pages/write/insert-tags.d.ts +16 -0
- package/lib/archive/db-ops/pages/write/insert-tags.js +34 -0
- package/lib/archive/db-ops/pages/write/link-redirect-sources.d.ts +36 -0
- package/lib/archive/db-ops/pages/write/link-redirect-sources.js +93 -0
- package/lib/archive/db-ops/pages/write/record-redirect.d.ts +35 -0
- package/lib/archive/db-ops/pages/write/record-redirect.js +100 -0
- package/lib/archive/db-ops/pages/write/set-skipped-page.d.ts +13 -0
- package/lib/archive/db-ops/pages/write/set-skipped-page.js +22 -0
- package/lib/archive/db-ops/pages/write/update-page.d.ts +29 -0
- package/lib/archive/db-ops/pages/write/update-page.js +334 -0
- package/lib/archive/db-ops/pages/write/write-page-html-blob.d.ts +19 -0
- package/lib/archive/db-ops/pages/write/write-page-html-blob.js +41 -0
- package/lib/archive/db-ops/referrers/get-redirects-for-pages.d.ts +9 -0
- package/lib/archive/db-ops/referrers/get-redirects-for-pages.js +15 -0
- package/lib/archive/db-ops/referrers/get-referrers-of-page.d.ts +17 -0
- package/lib/archive/db-ops/referrers/get-referrers-of-page.js +32 -0
- package/lib/archive/db-ops/referrers/get-referrers-of-resource.d.ts +8 -0
- package/lib/archive/db-ops/referrers/get-referrers-of-resource.js +15 -0
- package/lib/archive/db-ops/resources/build-resource-query.d.ts +25 -0
- package/lib/archive/db-ops/resources/build-resource-query.js +29 -0
- package/lib/archive/db-ops/resources/get-existing-resource-urls.d.ts +9 -0
- package/lib/archive/db-ops/resources/get-existing-resource-urls.js +24 -0
- package/lib/archive/db-ops/resources/get-resource-by-url.d.ts +13 -0
- package/lib/archive/db-ops/resources/get-resource-by-url.js +22 -0
- package/lib/archive/db-ops/resources/get-resource-url-list.d.ts +9 -0
- package/lib/archive/db-ops/resources/get-resource-url-list.js +13 -0
- package/lib/archive/db-ops/resources/get-resources.d.ts +8 -0
- package/lib/archive/db-ops/resources/get-resources.js +11 -0
- package/lib/archive/db-ops/resources/insert-inventory-resources.d.ts +24 -0
- package/lib/archive/db-ops/resources/insert-inventory-resources.js +64 -0
- package/lib/archive/db-ops/resources/insert-resource-referrers.d.ts +15 -0
- package/lib/archive/db-ops/resources/insert-resource-referrers.js +54 -0
- package/lib/archive/db-ops/resources/insert-resource.d.ts +34 -0
- package/lib/archive/db-ops/resources/insert-resource.js +73 -0
- package/lib/archive/db-ops/resources/reconstruct-resource-rows.d.ts +26 -0
- package/lib/archive/db-ops/resources/reconstruct-resource-rows.js +30 -0
- package/lib/archive/decode-html-blob.d.ts +18 -0
- package/lib/archive/decode-html-blob.js +31 -0
- package/lib/archive/derive-lineage-from-parent.d.ts +1 -1
- package/lib/archive/derive-lineage-from-parent.js +1 -1
- package/lib/archive/drop-legacy-tables.d.ts +45 -0
- package/lib/archive/drop-legacy-tables.js +56 -0
- package/lib/archive/filesystem/rename.js +1 -1
- package/lib/archive/get-failed-page-messages.d.ts +5 -4
- package/lib/archive/get-failed-page-messages.js +5 -4
- package/lib/archive/init-schema.d.ts +35 -39
- package/lib/archive/init-schema.js +99 -460
- package/lib/archive/limited-page-ids.d.ts +2 -1
- package/lib/archive/limited-page-ids.js +5 -4
- package/lib/archive/meta/assert-compatible-version.d.ts +24 -3
- package/lib/archive/meta/assert-compatible-version.js +24 -3
- package/lib/archive/meta/types.d.ts +87 -1
- package/lib/archive/meta/types.js +34 -2
- package/lib/archive/migrate-entity-tables.d.ts +45 -0
- package/lib/archive/migrate-entity-tables.js +56 -0
- package/lib/archive/migrate-ref-tables.d.ts +25 -0
- package/lib/archive/migrate-ref-tables.js +38 -0
- package/lib/archive/page-meta-column-maps.d.ts +32 -0
- package/lib/archive/page-meta-column-maps.js +43 -0
- package/lib/archive/page.d.ts +6 -6
- package/lib/archive/page.js +5 -5
- package/lib/archive/peek-archive-lock.d.ts +2 -2
- package/lib/archive/peek-archive-lock.js +2 -2
- package/lib/archive/populate-entity-tables/collapse-anchor-rows.d.ts +41 -0
- package/lib/archive/populate-entity-tables/collapse-anchor-rows.js +87 -0
- package/lib/archive/populate-entity-tables/derive-dom-path.d.ts +35 -0
- package/lib/archive/populate-entity-tables/derive-dom-path.js +72 -0
- package/lib/archive/populate-entity-tables/is-blob-ref-value.d.ts +16 -0
- package/lib/archive/populate-entity-tables/is-blob-ref-value.js +19 -0
- package/lib/archive/populate-entity-tables/match-images-to-dom-paths.d.ts +66 -0
- package/lib/archive/populate-entity-tables/match-images-to-dom-paths.js +96 -0
- package/lib/archive/populate-entity-tables/populate-anchor-edges.d.ts +33 -0
- package/lib/archive/populate-entity-tables/populate-anchor-edges.js +153 -0
- package/lib/archive/populate-entity-tables/populate-content-items.d.ts +40 -0
- package/lib/archive/populate-entity-tables/populate-content-items.js +141 -0
- package/lib/archive/populate-entity-tables/populate-entities.d.ts +81 -0
- package/lib/archive/populate-entity-tables/populate-entities.js +111 -0
- package/lib/archive/populate-entity-tables/populate-image-items.d.ts +91 -0
- package/lib/archive/populate-entity-tables/populate-image-items.js +223 -0
- package/lib/archive/populate-entity-tables/populate-page-meta.d.ts +33 -0
- package/lib/archive/populate-entity-tables/populate-page-meta.js +267 -0
- package/lib/archive/populate-entity-tables/populate-resource-items.d.ts +22 -0
- package/lib/archive/populate-entity-tables/populate-resource-items.js +114 -0
- package/lib/archive/populate-entity-tables/populate-resource-ref-edges.d.ts +31 -0
- package/lib/archive/populate-entity-tables/populate-resource-ref-edges.js +33 -0
- package/lib/archive/populate-entity-tables/resolve-blob-refs.d.ts +31 -0
- package/lib/archive/populate-entity-tables/resolve-blob-refs.js +100 -0
- package/lib/archive/populate-entity-tables/resolve-content-type-refs.d.ts +22 -0
- package/lib/archive/populate-entity-tables/resolve-content-type-refs.js +27 -0
- package/lib/archive/populate-entity-tables/resolve-header-sets.d.ts +49 -0
- package/lib/archive/populate-entity-tables/resolve-header-sets.js +122 -0
- package/lib/archive/populate-entity-tables/resolve-json-refs.d.ts +25 -0
- package/lib/archive/populate-entity-tables/resolve-json-refs.js +67 -0
- package/lib/archive/populate-entity-tables/resolve-text-refs.d.ts +30 -0
- package/lib/archive/populate-entity-tables/resolve-text-refs.js +61 -0
- package/lib/archive/populate-entity-tables/resolve-url-or-blob-from-maps.d.ts +21 -0
- package/lib/archive/populate-entity-tables/resolve-url-or-blob-from-maps.js +27 -0
- package/lib/archive/populate-entity-tables/resolve-url-refs.d.ts +33 -0
- package/lib/archive/populate-entity-tables/resolve-url-refs.js +60 -0
- package/lib/archive/populate-entity-tables/test-utils/count-rows.d.ts +17 -0
- package/lib/archive/populate-entity-tables/test-utils/count-rows.js +20 -0
- package/lib/archive/populate-entity-tables/test-utils/seed-content-items.d.ts +25 -0
- package/lib/archive/populate-entity-tables/test-utils/seed-content-items.js +42 -0
- package/lib/archive/populate-entity-tables/test-utils/setup-entities-db.d.ts +23 -0
- package/lib/archive/populate-entity-tables/test-utils/setup-entities-db.js +178 -0
- package/lib/archive/populate-entity-tables/types.d.ts +157 -0
- package/lib/archive/populate-entity-tables/types.js +12 -0
- package/lib/archive/populate-entity-tables/upsert-text-refs.d.ts +38 -0
- package/lib/archive/populate-entity-tables/upsert-text-refs.js +78 -0
- package/lib/archive/populate-ref-tables/classify-content-type.d.ts +16 -0
- package/lib/archive/populate-ref-tables/classify-content-type.js +52 -0
- package/lib/archive/populate-ref-tables/compute-content-hash.d.ts +22 -0
- package/lib/archive/populate-ref-tables/compute-content-hash.js +26 -0
- package/lib/archive/populate-ref-tables/compute-header-flags.d.ts +16 -0
- package/lib/archive/populate-ref-tables/compute-header-flags.js +70 -0
- package/lib/archive/populate-ref-tables/content-type-rules.d.ts +38 -0
- package/lib/archive/populate-ref-tables/content-type-rules.js +133 -0
- package/lib/archive/populate-ref-tables/create-header-table-caches.d.ts +25 -0
- package/lib/archive/populate-ref-tables/create-header-table-caches.js +49 -0
- package/lib/archive/populate-ref-tables/data-uri-url-refs-limit.d.ts +15 -0
- package/lib/archive/populate-ref-tables/data-uri-url-refs-limit.js +15 -0
- package/lib/archive/populate-ref-tables/decode-data-uri.d.ts +21 -0
- package/lib/archive/populate-ref-tables/decode-data-uri.js +126 -0
- package/lib/archive/populate-ref-tables/decompose-header-set.d.ts +29 -0
- package/lib/archive/populate-ref-tables/decompose-header-set.js +157 -0
- package/lib/archive/populate-ref-tables/decompose-url.d.ts +25 -0
- package/lib/archive/populate-ref-tables/decompose-url.js +70 -0
- package/lib/archive/populate-ref-tables/header-stability.d.ts +19 -0
- package/lib/archive/populate-ref-tables/header-stability.js +22 -0
- package/lib/archive/populate-ref-tables/header-value-cache-key.d.ts +17 -0
- package/lib/archive/populate-ref-tables/header-value-cache-key.js +19 -0
- package/lib/archive/populate-ref-tables/normalize-mime.d.ts +24 -0
- package/lib/archive/populate-ref-tables/normalize-mime.js +36 -0
- package/lib/archive/populate-ref-tables/populate-blob-refs.d.ts +38 -0
- package/lib/archive/populate-ref-tables/populate-blob-refs.js +134 -0
- package/lib/archive/populate-ref-tables/populate-content-type-refs.d.ts +27 -0
- package/lib/archive/populate-ref-tables/populate-content-type-refs.js +70 -0
- package/lib/archive/populate-ref-tables/populate-header-tables.d.ts +35 -0
- package/lib/archive/populate-ref-tables/populate-header-tables.js +80 -0
- package/lib/archive/populate-ref-tables/populate-json-refs.d.ts +29 -0
- package/lib/archive/populate-ref-tables/populate-json-refs.js +101 -0
- package/lib/archive/populate-ref-tables/populate-refs.d.ts +51 -0
- package/lib/archive/populate-ref-tables/populate-refs.js +62 -0
- package/lib/archive/populate-ref-tables/populate-text-refs.d.ts +32 -0
- package/lib/archive/populate-ref-tables/populate-text-refs.js +133 -0
- package/lib/archive/populate-ref-tables/populate-url-refs.d.ts +28 -0
- package/lib/archive/populate-ref-tables/populate-url-refs.js +148 -0
- package/lib/archive/populate-ref-tables/test-utils/count-rows.d.ts +15 -0
- package/lib/archive/populate-ref-tables/test-utils/count-rows.js +17 -0
- package/lib/archive/populate-ref-tables/types.d.ts +197 -0
- package/lib/archive/populate-ref-tables/types.js +7 -0
- package/lib/archive/populate-ref-tables/upsert-one-header-set.d.ts +34 -0
- package/lib/archive/populate-ref-tables/upsert-one-header-set.js +208 -0
- package/lib/archive/populate-ref-tables/volatile-header-names.d.ts +20 -0
- package/lib/archive/populate-ref-tables/volatile-header-names.js +33 -0
- package/lib/archive/redirect-table.d.ts +4 -2
- package/lib/archive/redirect-table.js +15 -10
- package/lib/archive/resolve-redirect-chain.d.ts +3 -3
- package/lib/archive/resolve-redirect-chain.js +2 -2
- package/lib/archive/resource.d.ts +1 -1
- package/lib/archive/retarget-legacy-fk-tables.d.ts +47 -0
- package/lib/archive/retarget-legacy-fk-tables.js +107 -0
- package/lib/archive/test-utils/fk-parent-tables.d.ts +15 -0
- package/lib/archive/test-utils/fk-parent-tables.js +19 -0
- package/lib/archive/test-utils/seed-content-item.d.ts +35 -0
- package/lib/archive/test-utils/seed-content-item.js +42 -0
- package/lib/archive/test-utils/setup-legacy-fk-db.d.ts +33 -0
- package/lib/archive/test-utils/setup-legacy-fk-db.js +270 -0
- package/lib/archive/types.d.ts +127 -24
- package/lib/archive/verify-migration/capture-rejection.d.ts +24 -0
- package/lib/archive/verify-migration/capture-rejection.js +31 -0
- package/lib/archive/verify-migration/check-anchor-edges-count.d.ts +34 -0
- package/lib/archive/verify-migration/check-anchor-edges-count.js +72 -0
- package/lib/archive/verify-migration/check-anchor-edges-sum.d.ts +13 -0
- package/lib/archive/verify-migration/check-anchor-edges-sum.js +27 -0
- package/lib/archive/verify-migration/check-content-items-count.d.ts +16 -0
- package/lib/archive/verify-migration/check-content-items-count.js +30 -0
- package/lib/archive/verify-migration/check-content-type-preservation.d.ts +22 -0
- package/lib/archive/verify-migration/check-content-type-preservation.js +40 -0
- package/lib/archive/verify-migration/check-foreign-key-integrity.d.ts +31 -0
- package/lib/archive/verify-migration/check-foreign-key-integrity.js +47 -0
- package/lib/archive/verify-migration/check-image-items-count.d.ts +12 -0
- package/lib/archive/verify-migration/check-image-items-count.js +26 -0
- package/lib/archive/verify-migration/check-page-meta-count.d.ts +15 -0
- package/lib/archive/verify-migration/check-page-meta-count.js +31 -0
- package/lib/archive/verify-migration/check-reader-parity.d.ts +23 -0
- package/lib/archive/verify-migration/check-reader-parity.js +211 -0
- package/lib/archive/verify-migration/check-resource-items-count.d.ts +17 -0
- package/lib/archive/verify-migration/check-resource-items-count.js +33 -0
- package/lib/archive/verify-migration/check-url-round-trip.d.ts +43 -0
- package/lib/archive/verify-migration/check-url-round-trip.js +112 -0
- package/lib/archive/verify-migration/types.d.ts +70 -0
- package/lib/archive/verify-migration/types.js +63 -0
- package/lib/archive/verify-migration/verify-migration.d.ts +41 -0
- package/lib/archive/verify-migration/verify-migration.js +120 -0
- package/lib/crawler/build-redirect-event.d.ts +1 -1
- package/lib/crawler/build-redirect-event.js +1 -1
- package/lib/crawler/capture-image-dom-paths.d.ts +33 -0
- package/lib/crawler/capture-image-dom-paths.js +39 -0
- package/lib/crawler/clear-dns-burned-host-cache.d.ts +1 -1
- package/lib/crawler/clear-dns-burned-host-cache.js +1 -1
- package/lib/crawler/collect-image-dom-paths.d.ts +23 -0
- package/lib/crawler/collect-image-dom-paths.js +64 -0
- package/lib/crawler/crawler.d.ts +19 -0
- package/lib/crawler/crawler.js +40 -26
- package/lib/crawler/dns-burned-host-cache.d.ts +3 -3
- package/lib/crawler/dns-burned-host-cache.js +3 -3
- package/lib/crawler/dns-burned-host-short-circuit-counter.d.ts +2 -2
- package/lib/crawler/dns-burned-host-short-circuit-counter.js +2 -2
- package/lib/crawler/inject-scope-auth.d.ts +1 -1
- package/lib/crawler/inject-scope-auth.js +1 -1
- package/lib/crawler/normalize-content-type.d.ts +1 -1
- package/lib/crawler/normalize-content-type.js +1 -1
- package/lib/crawler/types.d.ts +3 -3
- package/lib/crawler-orchestrator.d.ts +9 -0
- package/lib/crawler-orchestrator.js +44 -28
- package/lib/crawler.d.ts +12 -0
- package/lib/crawler.js +21 -0
- package/lib/permanent-error-kinds.d.ts +1 -1
- package/lib/permanent-error-kinds.js +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/utils/compute-file-sha256.d.ts +5 -4
- package/lib/utils/compute-file-sha256.js +5 -4
- package/lib/utils/error/emit-error-with-retry.d.ts +1 -1
- package/lib/utils/error/emit-error-with-retry.js +1 -1
- package/package.json +10 -10
- package/lib/archive/migrate-crawl-errors.d.ts +0 -20
- package/lib/archive/migrate-crawl-errors.js +0 -38
- package/lib/archive/migrate-html-blob-tables.d.ts +0 -24
- package/lib/archive/migrate-html-blob-tables.js +0 -53
- package/lib/archive/migrate-inventory-runs.d.ts +0 -29
- package/lib/archive/migrate-inventory-runs.js +0 -52
- package/lib/archive/migrate-page-errors.d.ts +0 -16
- package/lib/archive/migrate-page-errors.js +0 -35
- package/lib/archive/migrate-pages-resources-source.d.ts +0 -16
- package/lib/archive/migrate-pages-resources-source.js +0 -46
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header names — always lower-cased — that are EXCLUDED from `stable_hash`.
|
|
3
|
+
* These change on every response (timestamps / request IDs / cache
|
|
4
|
+
* telemetry) and would defeat the dedup goal if hashed alongside the
|
|
5
|
+
* stable set.
|
|
6
|
+
*
|
|
7
|
+
* `set-cookie` sits here because per-session cookies rotate constantly on
|
|
8
|
+
* authenticated sites — it is deliberately classified as volatile even
|
|
9
|
+
* though it is technically a stable security signal.
|
|
10
|
+
*
|
|
11
|
+
* Any header not in this set is
|
|
12
|
+
* treated as **stable** by {@link ./header-stability.ts:isVolatileHeader}
|
|
13
|
+
* — the safer default because a genuinely volatile header misclassified
|
|
14
|
+
* as stable only weakens dedup (its per-response values fork
|
|
15
|
+
* otherwise-identical stable profiles into separate `stable_hash`
|
|
16
|
+
* clusters), while a stable header misclassified as volatile would drop
|
|
17
|
+
* a meaningful signal from `stable_hash` and falsely cluster distinct
|
|
18
|
+
* header configurations together.
|
|
19
|
+
*/
|
|
20
|
+
export const VOLATILE_HEADER_NAMES = new Set([
|
|
21
|
+
'date',
|
|
22
|
+
'expires',
|
|
23
|
+
'last-modified',
|
|
24
|
+
'etag',
|
|
25
|
+
'age',
|
|
26
|
+
'via',
|
|
27
|
+
'x-cache',
|
|
28
|
+
'cf-ray',
|
|
29
|
+
'x-request-id',
|
|
30
|
+
'set-cookie',
|
|
31
|
+
'server-timing',
|
|
32
|
+
'x-amz-request-id',
|
|
33
|
+
]);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
2
|
/**
|
|
3
|
-
* Returns a Knex subquery builder that joins
|
|
4
|
-
*
|
|
3
|
+
* Returns a Knex subquery builder that joins `content_items` with their
|
|
4
|
+
* redirect destinations (resolved via `url_refs` for both sides). When
|
|
5
|
+
* `includeNull` is true, also includes pages without redirects
|
|
6
|
+
* (self-referencing).
|
|
5
7
|
* @param includeNull - Whether to include non-redirected pages in the result. Defaults to `true`.
|
|
6
8
|
*/
|
|
7
9
|
export declare function redirectTable(includeNull?: boolean): (qb: Knex.QueryBuilder<Record<string, unknown>, unknown>) => Promise<void>;
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns a Knex subquery builder that joins
|
|
3
|
-
*
|
|
2
|
+
* Returns a Knex subquery builder that joins `content_items` with their
|
|
3
|
+
* redirect destinations (resolved via `url_refs` for both sides). When
|
|
4
|
+
* `includeNull` is true, also includes pages without redirects
|
|
5
|
+
* (self-referencing).
|
|
4
6
|
* @param includeNull - Whether to include non-redirected pages in the result. Defaults to `true`.
|
|
5
7
|
*/
|
|
6
8
|
export function redirectTable(includeNull = true) {
|
|
7
9
|
return async (qb) => {
|
|
8
10
|
const list = qb
|
|
9
|
-
.select('A.id as fromId', '
|
|
10
|
-
.from('
|
|
11
|
-
.join('
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
.select('A.id as fromId', 'A_url.url as from', 'B_url.url as to', 'B.id as toId')
|
|
12
|
+
.from('content_items as A')
|
|
13
|
+
.join('url_refs as A_url', 'A.url_id', 'A_url.id')
|
|
14
|
+
.join('content_items as B', (j) => {
|
|
15
|
+
j.on('A.redirect_dest_id', '=', 'B.id').andOnNotNull('A.redirect_dest_id');
|
|
16
|
+
})
|
|
17
|
+
.join('url_refs as B_url', 'B.url_id', 'B_url.id');
|
|
14
18
|
if (includeNull) {
|
|
15
19
|
await list.union(async (qb) => {
|
|
16
20
|
await qb
|
|
17
|
-
.select('A.id as fromId', '
|
|
18
|
-
.from('
|
|
19
|
-
.
|
|
21
|
+
.select('A.id as fromId', 'A_url.url as from', 'A_url.url as to', 'A.id as toId')
|
|
22
|
+
.from('content_items as A')
|
|
23
|
+
.join('url_refs as A_url', 'A.url_id', 'A_url.id')
|
|
24
|
+
.whereNull('A.redirect_dest_id');
|
|
20
25
|
});
|
|
21
26
|
}
|
|
22
27
|
};
|
|
@@ -5,7 +5,7 @@ export interface RedirectChain {
|
|
|
5
5
|
/** The final destination URL the chain lands on (normalised). */
|
|
6
6
|
destUrl: string;
|
|
7
7
|
/**
|
|
8
|
-
* The source URLs that redirect to {@link destUrl}: the originally requested
|
|
8
|
+
* The source URLs that redirect to {@link RedirectChain.destUrl}: the originally requested
|
|
9
9
|
* URL followed by every intermediate hop. Empty when the page was not
|
|
10
10
|
* redirected at all.
|
|
11
11
|
*/
|
|
@@ -22,8 +22,8 @@ export interface RedirectChain {
|
|
|
22
22
|
* every intermediate hop are the sources. When the page was not redirected,
|
|
23
23
|
* the destination is the page URL itself and there are no sources.
|
|
24
24
|
*
|
|
25
|
-
* Used by both
|
|
26
|
-
* destination) and
|
|
25
|
+
* Used by both `Database.updatePage` (which renders and stores the
|
|
26
|
+
* destination) and `Database.recordRedirect` (the #73 convergence
|
|
27
27
|
* optimisation, which records the edge for a destination already rendered
|
|
28
28
|
* elsewhere without touching its content).
|
|
29
29
|
* @param pageUrl - The originally requested URL (normalised, without hash/auth).
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* every intermediate hop are the sources. When the page was not redirected,
|
|
10
10
|
* the destination is the page URL itself and there are no sources.
|
|
11
11
|
*
|
|
12
|
-
* Used by both
|
|
13
|
-
* destination) and
|
|
12
|
+
* Used by both `Database.updatePage` (which renders and stores the
|
|
13
|
+
* destination) and `Database.recordRedirect` (the #73 convergence
|
|
14
14
|
* optimisation, which records the edge for a destination already rendered
|
|
15
15
|
* elsewhere without touching its content).
|
|
16
16
|
* @param pageUrl - The originally requested URL (normalised, without hash/auth).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
/**
|
|
3
|
+
* Rewrites the FK declarations of the adjunct tables from the legacy
|
|
4
|
+
* `pages(id)` to `content_items(id)` by rebuilding each table. SQLite has
|
|
5
|
+
* no `ALTER TABLE … DROP CONSTRAINT`, so the only way to change an FK
|
|
6
|
+
* target is to recreate the table:
|
|
7
|
+
*
|
|
8
|
+
* 1. Stage each table's rows into a constraint-free `<table>__retarget`
|
|
9
|
+
* copy (`CREATE TABLE … AS SELECT *`) and drop the original, freeing
|
|
10
|
+
* its index names.
|
|
11
|
+
* 2. Recreate every table through {@link createAdjunctTables} — the same
|
|
12
|
+
* DDL fresh archives get, so migrated archives end up identical in
|
|
13
|
+
* shape and index naming. Rebuilding the DDL inline here instead
|
|
14
|
+
* would recreate the exact drift this function repairs.
|
|
15
|
+
* 3. Copy the staged rows back using the recreated table's own column
|
|
16
|
+
* list (read via `pragma_table_info`). A column the canonical DDL has
|
|
17
|
+
* but the input archive lacks aborts the INSERT with a clear error —
|
|
18
|
+
* never a silent data drop.
|
|
19
|
+
*
|
|
20
|
+
* A rename-based recipe (`ALTER TABLE x RENAME TO x__retarget`, skip
|
|
21
|
+
* copy #1) is deliberately NOT used: SQLite keeps the renamed table's
|
|
22
|
+
* indexes attached under their original names, which collide with the
|
|
23
|
+
* index names {@link createAdjunctTables} declares — and the old index
|
|
24
|
+
* names vary by the era of the archive's original provisioning, so
|
|
25
|
+
* dropping them first would require enumerating unknown names. The
|
|
26
|
+
* copy-out is cheap at these tables' scale (a handful of rows per page).
|
|
27
|
+
*
|
|
28
|
+
* Adjunct tables that do not exist on the input archive (e.g. a 0.10
|
|
29
|
+
* archive that never ran `analyze`, so `analysis_violations` was never
|
|
30
|
+
* lazily provisioned) are simply created empty by step 2.
|
|
31
|
+
*
|
|
32
|
+
* The migrated-archive PK-preservation contract makes the copy safe:
|
|
33
|
+
* `content_items.id` reuses the legacy `pages.id` values verbatim, so
|
|
34
|
+
* every staged `pageId` / `page_id` resolves to the same row under the
|
|
35
|
+
* new FK target. Run inside a transaction with `PRAGMA foreign_keys = ON`
|
|
36
|
+
* so the copy-back doubles as a row-level FK validation — a stale id
|
|
37
|
+
* aborts the transaction here rather than surfacing later as a
|
|
38
|
+
* `foreign_key_check` finding.
|
|
39
|
+
* @param trx - Knex transaction on the archive being migrated
|
|
40
|
+
* (`scripts/migrate-to-0.13.mjs` is the caller).
|
|
41
|
+
* @example
|
|
42
|
+
* await db.transaction(async (trx) => {
|
|
43
|
+
* await retargetLegacyFkTables(trx);
|
|
44
|
+
* });
|
|
45
|
+
* // pragma_foreign_key_list('page_errors') now reports content_items.
|
|
46
|
+
*/
|
|
47
|
+
export declare function retargetLegacyFkTables(trx: Knex): Promise<void>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createAdjunctTables } from './create-adjunct-tables.js';
|
|
2
|
+
/**
|
|
3
|
+
* The adjunct tables whose FK declarations may still point at the legacy
|
|
4
|
+
* `pages(id)` on migrated archives. Only names are listed — the column
|
|
5
|
+
* set is derived at runtime from the canonical table recreated by
|
|
6
|
+
* {@link createAdjunctTables}, so a future column addition there cannot
|
|
7
|
+
* silently drift from a hardcoded list (a missing column in the staged
|
|
8
|
+
* copy fails the copy-back INSERT loudly instead of dropping data).
|
|
9
|
+
*/
|
|
10
|
+
const RETARGET_TABLES = [
|
|
11
|
+
'page_html_ref',
|
|
12
|
+
'page_tags',
|
|
13
|
+
'page_jsonld',
|
|
14
|
+
'page_errors',
|
|
15
|
+
'analysis_violations',
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Canonical columns that a staged (pre-migration) table may legitimately
|
|
19
|
+
* lack because {@link createAdjunctTables}'s DDL gained them after the
|
|
20
|
+
* table was first lazily provisioned on the input archive (`analysis_violations`
|
|
21
|
+
* predates its `line`/`col` columns — issue #225). Missing columns listed
|
|
22
|
+
* here are copied back as `NULL` instead of aborting the migration; this is
|
|
23
|
+
* safe only because the column did not exist when the staged data was
|
|
24
|
+
* written, so `NULL` is the only value it could ever have had. Any other
|
|
25
|
+
* canonical column absent from the staged table still aborts the copy (see
|
|
26
|
+
* {@link retargetLegacyFkTables} JSDoc) — that case must stay loud, since a
|
|
27
|
+
* genuine rename/drop cannot be told apart from benign schema growth by
|
|
28
|
+
* column existence alone.
|
|
29
|
+
*/
|
|
30
|
+
const NULLABLE_ON_RETARGET = {
|
|
31
|
+
analysis_violations: ['line', 'col'],
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Rewrites the FK declarations of the adjunct tables from the legacy
|
|
35
|
+
* `pages(id)` to `content_items(id)` by rebuilding each table. SQLite has
|
|
36
|
+
* no `ALTER TABLE … DROP CONSTRAINT`, so the only way to change an FK
|
|
37
|
+
* target is to recreate the table:
|
|
38
|
+
*
|
|
39
|
+
* 1. Stage each table's rows into a constraint-free `<table>__retarget`
|
|
40
|
+
* copy (`CREATE TABLE … AS SELECT *`) and drop the original, freeing
|
|
41
|
+
* its index names.
|
|
42
|
+
* 2. Recreate every table through {@link createAdjunctTables} — the same
|
|
43
|
+
* DDL fresh archives get, so migrated archives end up identical in
|
|
44
|
+
* shape and index naming. Rebuilding the DDL inline here instead
|
|
45
|
+
* would recreate the exact drift this function repairs.
|
|
46
|
+
* 3. Copy the staged rows back using the recreated table's own column
|
|
47
|
+
* list (read via `pragma_table_info`). A column the canonical DDL has
|
|
48
|
+
* but the input archive lacks aborts the INSERT with a clear error —
|
|
49
|
+
* never a silent data drop.
|
|
50
|
+
*
|
|
51
|
+
* A rename-based recipe (`ALTER TABLE x RENAME TO x__retarget`, skip
|
|
52
|
+
* copy #1) is deliberately NOT used: SQLite keeps the renamed table's
|
|
53
|
+
* indexes attached under their original names, which collide with the
|
|
54
|
+
* index names {@link createAdjunctTables} declares — and the old index
|
|
55
|
+
* names vary by the era of the archive's original provisioning, so
|
|
56
|
+
* dropping them first would require enumerating unknown names. The
|
|
57
|
+
* copy-out is cheap at these tables' scale (a handful of rows per page).
|
|
58
|
+
*
|
|
59
|
+
* Adjunct tables that do not exist on the input archive (e.g. a 0.10
|
|
60
|
+
* archive that never ran `analyze`, so `analysis_violations` was never
|
|
61
|
+
* lazily provisioned) are simply created empty by step 2.
|
|
62
|
+
*
|
|
63
|
+
* The migrated-archive PK-preservation contract makes the copy safe:
|
|
64
|
+
* `content_items.id` reuses the legacy `pages.id` values verbatim, so
|
|
65
|
+
* every staged `pageId` / `page_id` resolves to the same row under the
|
|
66
|
+
* new FK target. Run inside a transaction with `PRAGMA foreign_keys = ON`
|
|
67
|
+
* so the copy-back doubles as a row-level FK validation — a stale id
|
|
68
|
+
* aborts the transaction here rather than surfacing later as a
|
|
69
|
+
* `foreign_key_check` finding.
|
|
70
|
+
* @param trx - Knex transaction on the archive being migrated
|
|
71
|
+
* (`scripts/migrate-to-0.13.mjs` is the caller).
|
|
72
|
+
* @example
|
|
73
|
+
* await db.transaction(async (trx) => {
|
|
74
|
+
* await retargetLegacyFkTables(trx);
|
|
75
|
+
* });
|
|
76
|
+
* // pragma_foreign_key_list('page_errors') now reports content_items.
|
|
77
|
+
*/
|
|
78
|
+
export async function retargetLegacyFkTables(trx) {
|
|
79
|
+
const staged = [];
|
|
80
|
+
for (const table of RETARGET_TABLES) {
|
|
81
|
+
if (!(await trx.schema.hasTable(table))) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
await trx.raw(`CREATE TABLE "${table}__retarget" AS SELECT * FROM "${table}"`);
|
|
85
|
+
await trx.raw(`DROP TABLE "${table}"`);
|
|
86
|
+
staged.push(table);
|
|
87
|
+
}
|
|
88
|
+
await createAdjunctTables(trx);
|
|
89
|
+
for (const table of staged) {
|
|
90
|
+
const columns = await trx
|
|
91
|
+
.select('name')
|
|
92
|
+
.from(trx.raw('pragma_table_info(?)', [table]));
|
|
93
|
+
const stagedColumns = await trx
|
|
94
|
+
.select('name')
|
|
95
|
+
.from(trx.raw('pragma_table_info(?)', [`${table}__retarget`]));
|
|
96
|
+
const stagedColumnNames = new Set(stagedColumns.map((column) => column.name));
|
|
97
|
+
const nullableOnRetarget = NULLABLE_ON_RETARGET[table] ?? [];
|
|
98
|
+
const insertColumnList = columns.map((column) => `"${column.name}"`).join(', ');
|
|
99
|
+
const selectColumnList = columns
|
|
100
|
+
.map((column) => !stagedColumnNames.has(column.name) && nullableOnRetarget.includes(column.name)
|
|
101
|
+
? `NULL AS "${column.name}"`
|
|
102
|
+
: `"${column.name}"`)
|
|
103
|
+
.join(', ');
|
|
104
|
+
await trx.raw(`INSERT INTO "${table}" (${insertColumnList}) SELECT ${selectColumnList} FROM "${table}__retarget"`);
|
|
105
|
+
await trx.raw(`DROP TABLE "${table}__retarget"`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the set of parent table names referenced by `table`'s FK
|
|
4
|
+
* clauses, read via SQLite's `pragma_foreign_key_list` table-valued
|
|
5
|
+
* function. Shared by the specs that assert FK declarations were
|
|
6
|
+
* retargeted from the legacy `pages(id)` to `content_items(id)`.
|
|
7
|
+
* @param db - Knex connected to the test DB.
|
|
8
|
+
* @param table - Table whose FK declarations to inspect.
|
|
9
|
+
* @returns Parent table names, deduplicated.
|
|
10
|
+
* @example
|
|
11
|
+
* const parents = await fkParentTables(db, 'page_errors');
|
|
12
|
+
* expect(parents.has('content_items')).toBe(true);
|
|
13
|
+
* expect(parents.has('pages')).toBe(false);
|
|
14
|
+
*/
|
|
15
|
+
export declare function fkParentTables(db: Knex, table: string): Promise<Set<string>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the set of parent table names referenced by `table`'s FK
|
|
3
|
+
* clauses, read via SQLite's `pragma_foreign_key_list` table-valued
|
|
4
|
+
* function. Shared by the specs that assert FK declarations were
|
|
5
|
+
* retargeted from the legacy `pages(id)` to `content_items(id)`.
|
|
6
|
+
* @param db - Knex connected to the test DB.
|
|
7
|
+
* @param table - Table whose FK declarations to inspect.
|
|
8
|
+
* @returns Parent table names, deduplicated.
|
|
9
|
+
* @example
|
|
10
|
+
* const parents = await fkParentTables(db, 'page_errors');
|
|
11
|
+
* expect(parents.has('content_items')).toBe(true);
|
|
12
|
+
* expect(parents.has('pages')).toBe(false);
|
|
13
|
+
*/
|
|
14
|
+
export async function fkParentTables(db, table) {
|
|
15
|
+
const rows = await db
|
|
16
|
+
.select('table')
|
|
17
|
+
.from(db.raw('pragma_foreign_key_list(?)', [table]));
|
|
18
|
+
return new Set(rows.map((row) => row.table));
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PageSource } from '../types.js';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
/**
|
|
4
|
+
* Optional column overrides for {@link seedContentItem}. Defaults model a
|
|
5
|
+
* scraped, internal, targeted page with no content type.
|
|
6
|
+
*/
|
|
7
|
+
interface SeedContentItemOptions {
|
|
8
|
+
/** `content_items.scraped` (default 1). */
|
|
9
|
+
scraped?: 0 | 1;
|
|
10
|
+
/** `content_items.is_target` (default 1). */
|
|
11
|
+
isTarget?: 0 | 1;
|
|
12
|
+
/** `content_items.is_external` (default 0). */
|
|
13
|
+
isExternal?: 0 | 1;
|
|
14
|
+
/** `content_items.source` (default: schema default `'crawled'`). */
|
|
15
|
+
source?: PageSource;
|
|
16
|
+
/** Registers the value in `content_type_refs` and links it (default: none). */
|
|
17
|
+
contentType?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inserts one `url_refs` + `content_items` pair — the minimal seeding
|
|
21
|
+
* contract for specs that exercise entity-table readers. Shared so a
|
|
22
|
+
* schema change to the pair (e.g. a new NOT NULL column) is fixed in one
|
|
23
|
+
* place instead of drifting across per-spec copies.
|
|
24
|
+
* @param db - Knex connected to the test DB.
|
|
25
|
+
* @param url - URL string to register in `url_refs`.
|
|
26
|
+
* @param options - Column overrides; see {@link SeedContentItemOptions}.
|
|
27
|
+
* @returns The inserted `content_items.id`.
|
|
28
|
+
* @example
|
|
29
|
+
* const pageId = await seedContentItem(db, 'https://example.com/');
|
|
30
|
+
* const pdfId = await seedContentItem(db, 'https://example.com/doc.pdf', {
|
|
31
|
+
* contentType: 'application/pdf',
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
export declare function seedContentItem(db: Knex, url: string, options?: SeedContentItemOptions): Promise<number>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inserts one `url_refs` + `content_items` pair — the minimal seeding
|
|
3
|
+
* contract for specs that exercise entity-table readers. Shared so a
|
|
4
|
+
* schema change to the pair (e.g. a new NOT NULL column) is fixed in one
|
|
5
|
+
* place instead of drifting across per-spec copies.
|
|
6
|
+
* @param db - Knex connected to the test DB.
|
|
7
|
+
* @param url - URL string to register in `url_refs`.
|
|
8
|
+
* @param options - Column overrides; see {@link SeedContentItemOptions}.
|
|
9
|
+
* @returns The inserted `content_items.id`.
|
|
10
|
+
* @example
|
|
11
|
+
* const pageId = await seedContentItem(db, 'https://example.com/');
|
|
12
|
+
* const pdfId = await seedContentItem(db, 'https://example.com/doc.pdf', {
|
|
13
|
+
* contentType: 'application/pdf',
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export async function seedContentItem(db, url, options = {}) {
|
|
17
|
+
const [urlRef] = await db('url_refs').insert({ url }).returning('id');
|
|
18
|
+
let contentTypeId = null;
|
|
19
|
+
if (options.contentType !== undefined) {
|
|
20
|
+
const [ctRef] = await db('content_type_refs')
|
|
21
|
+
.insert({
|
|
22
|
+
raw: options.contentType,
|
|
23
|
+
normalized: options.contentType,
|
|
24
|
+
category: 'other',
|
|
25
|
+
})
|
|
26
|
+
.onConflict('raw')
|
|
27
|
+
.merge({ raw: options.contentType })
|
|
28
|
+
.returning('id');
|
|
29
|
+
contentTypeId = ctRef.id;
|
|
30
|
+
}
|
|
31
|
+
const [item] = await db('content_items')
|
|
32
|
+
.insert({
|
|
33
|
+
url_id: urlRef.id,
|
|
34
|
+
scraped: options.scraped ?? 1,
|
|
35
|
+
is_target: options.isTarget ?? 1,
|
|
36
|
+
is_external: options.isExternal ?? 0,
|
|
37
|
+
content_type_id: contentTypeId,
|
|
38
|
+
...(options.source === undefined ? {} : { source: options.source }),
|
|
39
|
+
})
|
|
40
|
+
.returning('id');
|
|
41
|
+
return item.id;
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
/**
|
|
3
|
+
* Provisions the pre-0.13 legacy table shape on a test database:
|
|
4
|
+
* the five legacy write-model tables (`pages` / `anchors` / `images` /
|
|
5
|
+
* `resources` / `resources-referrers`) plus the five adjunct tables in
|
|
6
|
+
* their old form whose FK columns still point at `pages(id)`
|
|
7
|
+
* (`page_html_ref` / `page_tags` / `page_jsonld` / `page_errors` /
|
|
8
|
+
* `analysis_violations`, with their companion tables `page_html_blobs` /
|
|
9
|
+
* `analysis_text_refs`).
|
|
10
|
+
*
|
|
11
|
+
* `initSchema` no longer creates any of these shapes — fresh archives get
|
|
12
|
+
* neither the legacy write-model tables nor `pages(id)`-referencing
|
|
13
|
+
* adjunct tables — so specs that exercise the migration input format
|
|
14
|
+
* (`scripts/migrate-to-0.13.mjs` integration, `retargetLegacyFkTables`,
|
|
15
|
+
* `dropLegacyTables`) build it through this helper instead. The DDL is a
|
|
16
|
+
* verbatim copy of what pre-0.13 archives actually contain: the legacy
|
|
17
|
+
* write-model tables match the pre-0.13 `initSchema`, and the adjunct
|
|
18
|
+
* tables match the `scripts/migrate-to-0.10.mjs` / lazy-runtime-migration
|
|
19
|
+
* output of that era.
|
|
20
|
+
*
|
|
21
|
+
* Any current-form adjunct tables already present (e.g. created by
|
|
22
|
+
* `Archive.create()` on the current schema) are dropped first so the
|
|
23
|
+
* old-FK versions can take their place — callers get a deterministic
|
|
24
|
+
* "genuine pre-0.13 archive" shape regardless of how the underlying DB
|
|
25
|
+
* was provisioned.
|
|
26
|
+
* @param db - Knex connected to the test DB (or a transaction).
|
|
27
|
+
* @example
|
|
28
|
+
* await createRefTables(db);
|
|
29
|
+
* await createEntityTables(db);
|
|
30
|
+
* await setupLegacyFkDb(db);
|
|
31
|
+
* await db('pages').insert({ url: 'https://example.com/', scraped: 1, isTarget: 1 });
|
|
32
|
+
*/
|
|
33
|
+
export declare function setupLegacyFkDb(db: Knex): Promise<void>;
|