@mailwoman/registry 10.8.0 → 11.0.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 +93 -98
- package/data/manifests/artifacts.json +32 -0
- package/data/manifests/coverage.json +56 -0
- package/data/manifests/sources.lock.json +48 -0
- package/data/normalized/iata-airports.json +126749 -0
- package/data/normalized/iso3166-1.json +2035 -0
- package/definitions/namespaces.json +63 -0
- package/definitions/sections.json +73 -0
- package/docs/data-policy.md +81 -0
- package/docs/performance.md +146 -0
- package/docs/rgy1.md +144 -0
- package/lib/artifacts/country-airport-collision.ts +26 -0
- package/lib/artifacts/iata-airport/membership.ts +26 -0
- package/lib/artifacts/iata-airport/records.ts +26 -0
- package/lib/artifacts/iso3166-1/alpha2-membership.ts +26 -0
- package/lib/artifacts/iso3166-1/alpha3-membership.ts +26 -0
- package/lib/artifacts/iso3166-1/records.ts +26 -0
- package/lib/errors.ts +44 -0
- package/lib/iata/airports/records.ts +174 -0
- package/lib/iata/airports/validate.ts +49 -0
- package/lib/index.ts +25 -15
- package/lib/inspect.ts +56 -0
- package/lib/iso3166/alpha2.ts +48 -0
- package/lib/iso3166/alpha3.ts +51 -0
- package/lib/iso3166/records.ts +149 -0
- package/lib/iso3166/relations.ts +30 -0
- package/lib/key.ts +146 -0
- package/lib/normalize.ts +31 -0
- package/lib/overlap/country-airport.ts +108 -0
- package/lib/rgy1/base64.ts +24 -0
- package/lib/rgy1/reader.ts +316 -0
- package/lib/rgy1/sections.generated.ts +79 -0
- package/lib/rgy1/views.ts +267 -0
- package/lib/types.ts +88 -74
- package/lib/wasm.ts +285 -0
- package/out/artifacts/country-airport-collision.d.ts +15 -0
- package/out/artifacts/country-airport-collision.d.ts.map +1 -0
- package/out/artifacts/country-airport-collision.js +21 -0
- package/out/artifacts/country-airport-collision.js.map +1 -0
- package/out/artifacts/iata-airport/membership.d.ts +15 -0
- package/out/artifacts/iata-airport/membership.d.ts.map +1 -0
- package/out/artifacts/iata-airport/membership.js +21 -0
- package/out/artifacts/iata-airport/membership.js.map +1 -0
- package/out/artifacts/iata-airport/records.d.ts +15 -0
- package/out/artifacts/iata-airport/records.d.ts.map +1 -0
- package/out/artifacts/iata-airport/records.js +21 -0
- package/out/artifacts/iata-airport/records.js.map +1 -0
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts +15 -0
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/alpha2-membership.js +21 -0
- package/out/artifacts/iso3166-1/alpha2-membership.js.map +1 -0
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts +15 -0
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/alpha3-membership.js +21 -0
- package/out/artifacts/iso3166-1/alpha3-membership.js.map +1 -0
- package/out/artifacts/iso3166-1/records.d.ts +15 -0
- package/out/artifacts/iso3166-1/records.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/records.js +21 -0
- package/out/artifacts/iso3166-1/records.js.map +1 -0
- package/out/errors.d.ts +38 -0
- package/out/errors.d.ts.map +1 -0
- package/out/errors.js +35 -0
- package/out/errors.js.map +1 -0
- package/out/iata/airports/records.d.ts +44 -0
- package/out/iata/airports/records.d.ts.map +1 -0
- package/out/iata/airports/records.js +137 -0
- package/out/iata/airports/records.js.map +1 -0
- package/out/iata/airports/validate.d.ts +27 -0
- package/out/iata/airports/validate.d.ts.map +1 -0
- package/out/iata/airports/validate.js +42 -0
- package/out/iata/airports/validate.js.map +1 -0
- package/out/index.d.ts +19 -15
- package/out/index.d.ts.map +1 -1
- package/out/index.js +14 -15
- package/out/index.js.map +1 -1
- package/out/inspect.d.ts +38 -0
- package/out/inspect.d.ts.map +1 -0
- package/out/inspect.js +33 -0
- package/out/inspect.js.map +1 -0
- package/out/iso3166/alpha2.d.ts +24 -0
- package/out/iso3166/alpha2.d.ts.map +1 -0
- package/out/iso3166/alpha2.js +41 -0
- package/out/iso3166/alpha2.js.map +1 -0
- package/out/iso3166/alpha3.d.ts +29 -0
- package/out/iso3166/alpha3.d.ts.map +1 -0
- package/out/iso3166/alpha3.js +44 -0
- package/out/iso3166/alpha3.js.map +1 -0
- package/out/iso3166/records.d.ts +38 -0
- package/out/iso3166/records.d.ts.map +1 -0
- package/out/iso3166/records.js +105 -0
- package/out/iso3166/records.js.map +1 -0
- package/out/iso3166/relations.d.ts +20 -0
- package/out/iso3166/relations.d.ts.map +1 -0
- package/out/iso3166/relations.js +27 -0
- package/out/iso3166/relations.js.map +1 -0
- package/out/key.d.ts +68 -0
- package/out/key.d.ts.map +1 -0
- package/out/key.js +122 -0
- package/out/key.js.map +1 -0
- package/out/normalize.d.ts +25 -0
- package/out/normalize.d.ts.map +1 -0
- package/out/normalize.js +21 -0
- package/out/normalize.js.map +1 -0
- package/out/overlap/country-airport.d.ts +57 -0
- package/out/overlap/country-airport.d.ts.map +1 -0
- package/out/overlap/country-airport.js +71 -0
- package/out/overlap/country-airport.js.map +1 -0
- package/out/rgy1/base64.d.ts +15 -0
- package/out/rgy1/base64.d.ts.map +1 -0
- package/out/rgy1/base64.js +22 -0
- package/out/rgy1/base64.js.map +1 -0
- package/out/rgy1/reader.d.ts +103 -0
- package/out/rgy1/reader.d.ts.map +1 -0
- package/out/rgy1/reader.js +230 -0
- package/out/rgy1/reader.js.map +1 -0
- package/out/rgy1/sections.generated.d.ts +54 -0
- package/out/rgy1/sections.generated.d.ts.map +1 -0
- package/out/rgy1/sections.generated.js +69 -0
- package/out/rgy1/sections.generated.js.map +1 -0
- package/out/rgy1/views.d.ts +96 -0
- package/out/rgy1/views.d.ts.map +1 -0
- package/out/rgy1/views.js +218 -0
- package/out/rgy1/views.js.map +1 -0
- package/out/sdk/fetch.d.ts +53 -0
- package/out/sdk/fetch.d.ts.map +1 -0
- package/out/sdk/fetch.js +107 -0
- package/out/sdk/fetch.js.map +1 -0
- package/out/sdk/fetch.run.d.ts +14 -0
- package/out/sdk/fetch.run.d.ts.map +1 -0
- package/out/sdk/fetch.run.js +20 -0
- package/out/sdk/fetch.run.js.map +1 -0
- package/out/sdk/sources.d.ts +111 -0
- package/out/sdk/sources.d.ts.map +1 -0
- package/out/sdk/sources.js +98 -0
- package/out/sdk/sources.js.map +1 -0
- package/out/tools/artifact-path.d.ts +10 -0
- package/out/tools/artifact-path.d.ts.map +1 -0
- package/out/tools/artifact-path.js +12 -0
- package/out/tools/artifact-path.js.map +1 -0
- package/out/tools/bench.run.d.ts +19 -0
- package/out/tools/bench.run.d.ts.map +1 -0
- package/out/tools/bench.run.js +204 -0
- package/out/tools/bench.run.js.map +1 -0
- package/out/tools/build-wasm.run.d.ts +18 -0
- package/out/tools/build-wasm.run.d.ts.map +1 -0
- package/out/tools/build-wasm.run.js +71 -0
- package/out/tools/build-wasm.run.js.map +1 -0
- package/out/tools/generate-sections.run.d.ts +13 -0
- package/out/tools/generate-sections.run.d.ts.map +1 -0
- package/out/tools/generate-sections.run.js +136 -0
- package/out/tools/generate-sections.run.js.map +1 -0
- package/out/tools/generate.run.d.ts +18 -0
- package/out/tools/generate.run.d.ts.map +1 -0
- package/out/tools/generate.run.js +118 -0
- package/out/tools/generate.run.js.map +1 -0
- package/out/tools/normalize.d.ts +155 -0
- package/out/tools/normalize.d.ts.map +1 -0
- package/out/tools/normalize.js +303 -0
- package/out/tools/normalize.js.map +1 -0
- package/out/tools/normalize.run.d.ts +14 -0
- package/out/tools/normalize.run.d.ts.map +1 -0
- package/out/tools/normalize.run.js +29 -0
- package/out/tools/normalize.run.js.map +1 -0
- package/out/types.d.ts +90 -76
- package/out/types.d.ts.map +1 -1
- package/out/types.js +20 -4
- package/out/types.js.map +1 -1
- package/out/wasm.d.ts +98 -0
- package/out/wasm.d.ts.map +1 -0
- package/out/wasm.js +137 -0
- package/out/wasm.js.map +1 -0
- package/package.json +48 -27
- package/sdk/fetch.run.ts +24 -0
- package/sdk/fetch.ts +146 -0
- package/sdk/sources.ts +162 -0
- package/tools/artifact-path.ts +12 -0
- package/tools/bench.run.ts +265 -0
- package/tools/build-wasm.run.ts +82 -0
- package/tools/generate-sections.run.ts +152 -0
- package/tools/generate.run.ts +146 -0
- package/tools/normalize.run.ts +36 -0
- package/tools/normalize.ts +474 -0
- package/wasm/registry-simd.wasm +0 -0
- package/wasm/registry.wasm +0 -0
- package/lib/address-key.ts +0 -46
- package/lib/geocode-handler.ts +0 -37
- package/lib/geojson.ts +0 -72
- package/lib/ingest.ts +0 -349
- package/lib/learned-scorer.ts +0 -134
- package/lib/map-html.ts +0 -287
- package/lib/models/crosssource-gbt-en-us.ts +0 -43
- package/lib/models/dedup-gbt-en-us.ts +0 -47
- package/lib/models/org-crosssource-gbt-en-us.ts +0 -43
- package/lib/reconcile.ts +0 -239
- package/lib/resolve.ts +0 -569
- package/out/address-key.d.ts +0 -34
- package/out/address-key.d.ts.map +0 -1
- package/out/address-key.js +0 -41
- package/out/address-key.js.map +0 -1
- package/out/geocode-handler.d.ts +0 -20
- package/out/geocode-handler.d.ts.map +0 -1
- package/out/geocode-handler.js +0 -29
- package/out/geocode-handler.js.map +0 -1
- package/out/geojson.d.ts +0 -28
- package/out/geojson.d.ts.map +0 -1
- package/out/geojson.js +0 -62
- package/out/geojson.js.map +0 -1
- package/out/ingest.d.ts +0 -173
- package/out/ingest.d.ts.map +0 -1
- package/out/ingest.js +0 -185
- package/out/ingest.js.map +0 -1
- package/out/learned-scorer.d.ts +0 -61
- package/out/learned-scorer.d.ts.map +0 -1
- package/out/learned-scorer.js +0 -91
- package/out/learned-scorer.js.map +0 -1
- package/out/map-html.d.ts +0 -39
- package/out/map-html.d.ts.map +0 -1
- package/out/map-html.js +0 -220
- package/out/map-html.js.map +0 -1
- package/out/models/crosssource-gbt-en-us.d.ts +0 -45
- package/out/models/crosssource-gbt-en-us.d.ts.map +0 -1
- package/out/models/crosssource-gbt-en-us.js +0 -40
- package/out/models/crosssource-gbt-en-us.js.map +0 -1
- package/out/models/dedup-gbt-en-us.d.ts +0 -44
- package/out/models/dedup-gbt-en-us.d.ts.map +0 -1
- package/out/models/dedup-gbt-en-us.js +0 -44
- package/out/models/dedup-gbt-en-us.js.map +0 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +0 -45
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +0 -1
- package/out/models/org-crosssource-gbt-en-us.js +0 -40
- package/out/models/org-crosssource-gbt-en-us.js.map +0 -1
- package/out/reconcile.d.ts +0 -96
- package/out/reconcile.d.ts.map +0 -1
- package/out/reconcile.js +0 -127
- package/out/reconcile.js.map +0 -1
- package/out/resolve.d.ts +0 -264
- package/out/resolve.d.ts.map +0 -1
- package/out/resolve.js +0 -282
- package/out/resolve.js.map +0 -1
- package/out/tools/coverage-reconciliation.d.ts +0 -67
- package/out/tools/coverage-reconciliation.d.ts.map +0 -1
- package/out/tools/coverage-reconciliation.js +0 -113
- package/out/tools/coverage-reconciliation.js.map +0 -1
- package/out/tools/cross/dataset-correlation.d.ts +0 -61
- package/out/tools/cross/dataset-correlation.d.ts.map +0 -1
- package/out/tools/cross/dataset-correlation.js +0 -244
- package/out/tools/cross/dataset-correlation.js.map +0 -1
- package/out/tools/cross/source-threshold-sweep.d.ts +0 -60
- package/out/tools/cross/source-threshold-sweep.d.ts.map +0 -1
- package/out/tools/cross/source-threshold-sweep.js +0 -264
- package/out/tools/cross/source-threshold-sweep.js.map +0 -1
- package/out/tools/dedup-ceiling.d.ts +0 -62
- package/out/tools/dedup-ceiling.d.ts.map +0 -1
- package/out/tools/dedup-ceiling.js +0 -171
- package/out/tools/dedup-ceiling.js.map +0 -1
- package/out/tools/eval-geocoder.d.ts +0 -68
- package/out/tools/eval-geocoder.d.ts.map +0 -1
- package/out/tools/eval-geocoder.js +0 -13
- package/out/tools/eval-geocoder.js.map +0 -1
- package/out/tools/geocoder/namesake-probe.d.ts +0 -33
- package/out/tools/geocoder/namesake-probe.d.ts.map +0 -1
- package/out/tools/geocoder/namesake-probe.js +0 -60
- package/out/tools/geocoder/namesake-probe.js.map +0 -1
- package/out/tools/geocoder/vs-provided-coords.d.ts +0 -53
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +0 -1
- package/out/tools/geocoder/vs-provided-coords.js +0 -161
- package/out/tools/geocoder/vs-provided-coords.js.map +0 -1
- package/out/tools/gold-set-sample.d.ts +0 -67
- package/out/tools/gold-set-sample.d.ts.map +0 -1
- package/out/tools/gold-set-sample.js +0 -81
- package/out/tools/gold-set-sample.js.map +0 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +0 -77
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +0 -1
- package/out/tools/learned/scorer/clustering-eval.js +0 -207
- package/out/tools/learned/scorer/clustering-eval.js.map +0 -1
- package/out/tools/learned/scorer/crossstate-eval.d.ts +0 -65
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +0 -1
- package/out/tools/learned/scorer/crossstate-eval.js +0 -168
- package/out/tools/learned/scorer/crossstate-eval.js.map +0 -1
- package/out/tools/learned/scorer/eval.d.ts +0 -64
- package/out/tools/learned/scorer/eval.d.ts.map +0 -1
- package/out/tools/learned/scorer/eval.js +0 -275
- package/out/tools/learned/scorer/eval.js.map +0 -1
- package/out/tools/matcher-scale.d.ts +0 -40
- package/out/tools/matcher-scale.d.ts.map +0 -1
- package/out/tools/matcher-scale.js +0 -111
- package/out/tools/matcher-scale.js.map +0 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +0 -82
- package/out/tools/nppes/dedup-benchmark.d.ts.map +0 -1
- package/out/tools/nppes/dedup-benchmark.js +0 -226
- package/out/tools/nppes/dedup-benchmark.js.map +0 -1
- package/out/tools/nppes/org-name.d.ts +0 -15
- package/out/tools/nppes/org-name.d.ts.map +0 -1
- package/out/tools/nppes/org-name.js +0 -6
- package/out/tools/nppes/org-name.js.map +0 -1
- package/out/tools/nppes/overmerge-packet.d.ts +0 -43
- package/out/tools/nppes/overmerge-packet.d.ts.map +0 -1
- package/out/tools/nppes/overmerge-packet.js +0 -54
- package/out/tools/nppes/overmerge-packet.js.map +0 -1
- package/out/tools/nppes/report.d.ts +0 -97
- package/out/tools/nppes/report.d.ts.map +0 -1
- package/out/tools/nppes/report.js +0 -178
- package/out/tools/nppes/report.js.map +0 -1
- package/out/tools/nppes/sample.d.ts +0 -101
- package/out/tools/nppes/sample.d.ts.map +0 -1
- package/out/tools/nppes/sample.js +0 -127
- package/out/tools/nppes/sample.js.map +0 -1
- package/out/tools/nppes/scoring.d.ts +0 -37
- package/out/tools/nppes/scoring.d.ts.map +0 -1
- package/out/tools/nppes/scoring.js +0 -81
- package/out/tools/nppes/scoring.js.map +0 -1
- package/out/tools/nppes/settings.d.ts +0 -41
- package/out/tools/nppes/settings.d.ts.map +0 -1
- package/out/tools/nppes/settings.js +0 -79
- package/out/tools/nppes/settings.js.map +0 -1
- package/out/tools/nppes/truth-grains.d.ts +0 -63
- package/out/tools/nppes/truth-grains.d.ts.map +0 -1
- package/out/tools/nppes/truth-grains.js +0 -142
- package/out/tools/nppes/truth-grains.js.map +0 -1
- package/out/tools/shared.d.ts +0 -325
- package/out/tools/shared.d.ts.map +0 -1
- package/out/tools/shared.js +0 -453
- package/out/tools/shared.js.map +0 -1
- package/out/tools/train/cross-gbt.d.ts +0 -89
- package/out/tools/train/cross-gbt.d.ts.map +0 -1
- package/out/tools/train/cross-gbt.js +0 -132
- package/out/tools/train/cross-gbt.js.map +0 -1
- package/out/tools/train/gbt.d.ts +0 -85
- package/out/tools/train/gbt.d.ts.map +0 -1
- package/out/tools/train/gbt.js +0 -155
- package/out/tools/train/gbt.js.map +0 -1
- package/out/tools/train/org-cross-gbt.d.ts +0 -85
- package/out/tools/train/org-cross-gbt.d.ts.map +0 -1
- package/out/tools/train/org-cross-gbt.js +0 -122
- package/out/tools/train/org-cross-gbt.js.map +0 -1
- package/out/tools/txhhsc-to-oarow.d.ts +0 -42
- package/out/tools/txhhsc-to-oarow.d.ts.map +0 -1
- package/out/tools/txhhsc-to-oarow.js +0 -78
- package/out/tools/txhhsc-to-oarow.js.map +0 -1
- package/out/tools/viz/browser.d.ts +0 -31
- package/out/tools/viz/browser.d.ts.map +0 -1
- package/out/tools/viz/browser.js +0 -26
- package/out/tools/viz/browser.js.map +0 -1
- package/out/tools/viz/cross-dataset-map.d.ts +0 -39
- package/out/tools/viz/cross-dataset-map.d.ts.map +0 -1
- package/out/tools/viz/cross-dataset-map.js +0 -84
- package/out/tools/viz/cross-dataset-map.js.map +0 -1
- package/out/tools/viz/geocode-first-surface.d.ts +0 -36
- package/out/tools/viz/geocode-first-surface.d.ts.map +0 -1
- package/out/tools/viz/geocode-first-surface.js +0 -234
- package/out/tools/viz/geocode-first-surface.js.map +0 -1
- package/out/tools/viz/render/map.d.ts +0 -42
- package/out/tools/viz/render/map.d.ts.map +0 -1
- package/out/tools/viz/render/map.js +0 -40
- package/out/tools/viz/render/map.js.map +0 -1
- package/out/tools/viz/render.d.ts +0 -46
- package/out/tools/viz/render.d.ts.map +0 -1
- package/out/tools/viz/render.js +0 -49
- package/out/tools/viz/render.js.map +0 -1
- package/out/tools/viz/source-provenance-map.d.ts +0 -57
- package/out/tools/viz/source-provenance-map.d.ts.map +0 -1
- package/out/tools/viz/source-provenance-map.js +0 -82
- package/out/tools/viz/source-provenance-map.js.map +0 -1
- package/out/tools/viz/yardstick-figure.d.ts +0 -22
- package/out/tools/viz/yardstick-figure.d.ts.map +0 -1
- package/out/tools/viz/yardstick-figure.js +0 -106
- package/out/tools/viz/yardstick-figure.js.map +0 -1
- package/tools/coverage-reconciliation.ts +0 -192
- package/tools/cross/dataset-correlation.ts +0 -380
- package/tools/cross/source-threshold-sweep.ts +0 -416
- package/tools/dedup-ceiling.ts +0 -225
- package/tools/eval-geocoder.ts +0 -77
- package/tools/geocoder/namesake-probe.ts +0 -91
- package/tools/geocoder/vs-provided-coords.ts +0 -232
- package/tools/gold-set-sample.ts +0 -147
- package/tools/learned/scorer/clustering-eval.ts +0 -349
- package/tools/learned/scorer/crossstate-eval.ts +0 -280
- package/tools/learned/scorer/eval.ts +0 -429
- package/tools/matcher-scale.ts +0 -185
- package/tools/nppes/dedup-benchmark.ts +0 -364
- package/tools/nppes/org-name.ts +0 -15
- package/tools/nppes/overmerge-packet.ts +0 -98
- package/tools/nppes/report.ts +0 -380
- package/tools/nppes/sample.ts +0 -250
- package/tools/nppes/scoring.ts +0 -115
- package/tools/nppes/settings.ts +0 -102
- package/tools/nppes/truth-grains.ts +0 -185
- package/tools/shared.ts +0 -743
- package/tools/train/cross-gbt.ts +0 -214
- package/tools/train/gbt.ts +0 -261
- package/tools/train/org-cross-gbt.ts +0 -189
- package/tools/txhhsc-to-oarow.ts +0 -118
- package/tools/viz/browser.ts +0 -41
- package/tools/viz/cross-dataset-map.ts +0 -133
- package/tools/viz/geocode-first-surface.ts +0 -305
- package/tools/viz/render/map.ts +0 -61
- package/tools/viz/render.ts +0 -103
- package/tools/viz/source-provenance-map.ts +0 -154
- package/tools/viz/yardstick-figure.ts +0 -197
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Writes the section-kind constants TypeScript and Rust share from `definitions/sections.json`.
|
|
7
|
+
*
|
|
8
|
+
* Usage: `node packages/registry/tools/generate-sections.run.ts [--check]`
|
|
9
|
+
*
|
|
10
|
+
* `--check` exits non-zero when either generated file differs from what the definition produces.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { readLocalJSONFile, readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
14
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
15
|
+
import { stringifyJSON } from "@mailwoman/core/json"
|
|
16
|
+
import { workspacePath } from "@mailwoman/core/paths"
|
|
17
|
+
import { parseArguments } from "@mailwoman/core/scripting/arguments"
|
|
18
|
+
|
|
19
|
+
interface SectionDefinitions {
|
|
20
|
+
envelope: { magic: string; version: number; headerOffset: number; directoryEntryBytes: number; alignment: number }
|
|
21
|
+
kinds: Array<{ id: number; name: string; encoding: number }>
|
|
22
|
+
flags: { required: number }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { values } = parseArguments({ options: { check: { type: "boolean", default: false } } })
|
|
26
|
+
const registry = (...segments: string[]): string => workspacePath("registry", ...segments)
|
|
27
|
+
const definitions = await readLocalJSONFile<SectionDefinitions>(registry("definitions", "sections.json"))
|
|
28
|
+
|
|
29
|
+
const constant = (name: string): string => name.toUpperCase().replaceAll("-", "_")
|
|
30
|
+
|
|
31
|
+
const typescript = `/**
|
|
32
|
+
* @copyright Sister Software
|
|
33
|
+
* @license AGPL-3.0
|
|
34
|
+
* @author Teffen Ellis, et al.
|
|
35
|
+
*
|
|
36
|
+
* The RGY1 section kinds. Generated from definitions/sections.json by tools/generate-sections.run.ts. Edit the
|
|
37
|
+
* definition rather than this file.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The four ASCII bytes an artifact starts with.
|
|
42
|
+
*/
|
|
43
|
+
export const RGY1_MAGIC = ${stringifyJSON(definitions.envelope.magic)}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The envelope version this reader implements.
|
|
47
|
+
*/
|
|
48
|
+
export const RGY1_VERSION = ${definitions.envelope.version}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The byte offset of the header JSON, after the fixed envelope fields.
|
|
52
|
+
*/
|
|
53
|
+
export const RGY1_HEADER_OFFSET = ${definitions.envelope.headerOffset}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The byte length of one directory entry.
|
|
57
|
+
*/
|
|
58
|
+
export const RGY1_DIRECTORY_ENTRY_BYTES = ${definitions.envelope.directoryEntryBytes}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The alignment of the directory and of every section payload.
|
|
62
|
+
*/
|
|
63
|
+
export const RGY1_ALIGNMENT = ${definitions.envelope.alignment}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The section flag bit that marks a section required for interpretation.
|
|
67
|
+
*/
|
|
68
|
+
export const RGY1_FLAG_REQUIRED = ${definitions.flags.required}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Each section kind's identifier, as the directory entry stores it.
|
|
72
|
+
*/
|
|
73
|
+
export const SectionKind = {
|
|
74
|
+
${definitions.kinds.map((kind) => `\t${constant(kind.name)}: ${kind.id},`).join("\n")}
|
|
75
|
+
} as const
|
|
76
|
+
|
|
77
|
+
export type SectionKind = (typeof SectionKind)[keyof typeof SectionKind]
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The encoding version each kind is written with.
|
|
81
|
+
*/
|
|
82
|
+
export const SECTION_ENCODING: Readonly<Record<SectionKind, number>> = {
|
|
83
|
+
${definitions.kinds.map((kind) => `\t[SectionKind.${constant(kind.name)}]: ${kind.encoding},`).join("\n")}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Each kind's name, for diagnostics.
|
|
88
|
+
*/
|
|
89
|
+
export const SECTION_NAME: Readonly<Record<SectionKind, string>> = {
|
|
90
|
+
${definitions.kinds.map((kind) => `\t[SectionKind.${constant(kind.name)}]: ${stringifyJSON(kind.name)},`).join("\n")}
|
|
91
|
+
}
|
|
92
|
+
`
|
|
93
|
+
|
|
94
|
+
const rust = `// @copyright Sister Software
|
|
95
|
+
// @license AGPL-3.0
|
|
96
|
+
// @author Teffen Ellis, et al.
|
|
97
|
+
|
|
98
|
+
//! The RGY1 section kinds. Generated from \`definitions/sections.json\` by
|
|
99
|
+
//! \`tools/generate-sections.run.ts\`. Edit the definition rather than this file.
|
|
100
|
+
|
|
101
|
+
pub const MAGIC: &[u8; 4] = b${stringifyJSON(definitions.envelope.magic)};
|
|
102
|
+
pub const VERSION: u16 = ${definitions.envelope.version};
|
|
103
|
+
pub const HEADER_OFFSET: usize = ${definitions.envelope.headerOffset};
|
|
104
|
+
pub const DIRECTORY_ENTRY_BYTES: usize = ${definitions.envelope.directoryEntryBytes};
|
|
105
|
+
pub const ALIGNMENT: usize = ${definitions.envelope.alignment};
|
|
106
|
+
pub const FLAG_REQUIRED: u16 = ${definitions.flags.required};
|
|
107
|
+
|
|
108
|
+
${definitions.kinds.map((kind) => `pub const KIND_${constant(kind.name)}: u16 = ${kind.id};`).join("\n")}
|
|
109
|
+
|
|
110
|
+
/// The encoding version a kind is written with, or \`None\` for an unknown kind.
|
|
111
|
+
pub fn encoding_of(kind: u16) -> Option<u16> {
|
|
112
|
+
\tmatch kind {
|
|
113
|
+
${definitions.kinds.map((kind) => `\t\tKIND_${constant(kind.name)} => Some(${kind.encoding}),`).join("\n")}
|
|
114
|
+
\t\t_ => None,
|
|
115
|
+
\t}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// The kind's name, for diagnostics.
|
|
119
|
+
pub fn name_of(kind: u16) -> &'static str {
|
|
120
|
+
\tmatch kind {
|
|
121
|
+
${definitions.kinds.map((kind) => `\t\tKIND_${constant(kind.name)} => ${stringifyJSON(kind.name)},`).join("\n")}
|
|
122
|
+
\t\t_ => "unknown",
|
|
123
|
+
\t}
|
|
124
|
+
}
|
|
125
|
+
`
|
|
126
|
+
|
|
127
|
+
const outputs: Array<[string, string]> = [
|
|
128
|
+
[registry("lib", "rgy1", "sections.generated.ts"), typescript],
|
|
129
|
+
[registry("crates", "registry-core", "src", "sections.rs"), rust],
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
let stale = 0
|
|
133
|
+
|
|
134
|
+
for (const [path, content] of outputs) {
|
|
135
|
+
if (values.check) {
|
|
136
|
+
const current = await readLocalTextFile(path).catch(() => "")
|
|
137
|
+
|
|
138
|
+
if (current !== content) {
|
|
139
|
+
console.error(`${path} differs from definitions/sections.json`)
|
|
140
|
+
|
|
141
|
+
stale++
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
await writeLocalFile(content, path)
|
|
145
|
+
|
|
146
|
+
console.log(`wrote ${path}`)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (stale) {
|
|
151
|
+
process.exitCode = 1
|
|
152
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Compiles the normalized data into RGY1 artifacts with `crates/registry-build`, writes each artifact as a
|
|
7
|
+
* TypeScript module under `lib/artifacts/`, and records every artifact's SHA-256 in `data/manifests/artifacts.json`.
|
|
8
|
+
*
|
|
9
|
+
* Each artifact is its own module exporting one lazily decoded getter, so a bundle that imports the collision
|
|
10
|
+
* predicate holds the collision bitset and no airport record. The fixture profile under `test/fixtures/` is compiled
|
|
11
|
+
* too, into `test/fixtures/artifacts/*.rgy1`, so the committed fixtures stay equal to the compiler's output.
|
|
12
|
+
*
|
|
13
|
+
* Usage: `node packages/registry/tools/generate.run.ts [--check]`
|
|
14
|
+
*
|
|
15
|
+
* `--check` compiles without writing and exits non-zero when a generated module or manifest differs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { readLocalBuffer, readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
19
|
+
import { temporaryDirectory } from "@mailwoman/core/fs/temporary"
|
|
20
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
21
|
+
import { sha256File } from "@mailwoman/core/hash"
|
|
22
|
+
import { prettyJSON } from "@mailwoman/core/json"
|
|
23
|
+
import { repoRootPath, workspacePath } from "@mailwoman/core/paths"
|
|
24
|
+
import { runFile } from "@mailwoman/core/process"
|
|
25
|
+
import { parseArguments } from "@mailwoman/core/scripting/arguments"
|
|
26
|
+
|
|
27
|
+
import { artifactModulePath } from "#tools/artifact-path"
|
|
28
|
+
|
|
29
|
+
const { values } = parseArguments({ options: { check: { type: "boolean", default: false } } })
|
|
30
|
+
const registry = (...segments: string[]): string => workspacePath("registry", ...segments)
|
|
31
|
+
|
|
32
|
+
const ARTIFACTS = [
|
|
33
|
+
"iso3166-1-alpha2-membership",
|
|
34
|
+
"iso3166-1-alpha3-membership",
|
|
35
|
+
"iso3166-1-records",
|
|
36
|
+
"iata-airport-membership",
|
|
37
|
+
"iata-airport-records",
|
|
38
|
+
"country-airport-collision",
|
|
39
|
+
] as const
|
|
40
|
+
|
|
41
|
+
const camel = (name: string): string =>
|
|
42
|
+
name.replaceAll(/-(\w)/g, (_, letter: string) => letter.toUpperCase()).replace(/^(\d)/, "_$1")
|
|
43
|
+
|
|
44
|
+
await runFile("cargo", ["build", "--release", "--locked", "-p", "registry-build"], { cwd: workspacePath("registry") })
|
|
45
|
+
|
|
46
|
+
const binary = repoRootPath("target", "release", "registry-build")
|
|
47
|
+
|
|
48
|
+
async function compileProfile(normalized: string, lock: string, out: string): Promise<void> {
|
|
49
|
+
await runFile(binary, [`${normalized}/iso3166-1.json`, `${normalized}/iata-airports.json`, lock, out])
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await using scratch = await temporaryDirectory("registry-generate-")
|
|
53
|
+
const openOut = scratch.path.toString()
|
|
54
|
+
const profile = await readLocalJSONFile<{ profile: string }>(registry("data", "manifests", "sources.lock.json"))
|
|
55
|
+
|
|
56
|
+
await compileProfile(registry("data", "normalized"), registry("data", "manifests", "sources.lock.json"), openOut)
|
|
57
|
+
|
|
58
|
+
let stale = 0
|
|
59
|
+
|
|
60
|
+
async function emit(path: string, content: string | Uint8Array): Promise<void> {
|
|
61
|
+
if (values.check) {
|
|
62
|
+
const current = await readLocalBuffer(path).catch(() => null)
|
|
63
|
+
const next = typeof content === "string" ? Buffer.from(content) : Buffer.from(content)
|
|
64
|
+
|
|
65
|
+
if (!current || !current.equals(next)) {
|
|
66
|
+
console.error(`${path} differs from the generator's output`)
|
|
67
|
+
|
|
68
|
+
stale++
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
await writeLocalFile(content, path)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const manifest: Record<string, { sha256: string; bytes: number; profile: string }> = {}
|
|
76
|
+
|
|
77
|
+
for (const name of ARTIFACTS) {
|
|
78
|
+
const built = `${openOut}/${name}.rgy1`
|
|
79
|
+
const bytes = await readLocalBuffer(built)
|
|
80
|
+
const sha256 = await sha256File(built)
|
|
81
|
+
const getter = `${camel(name)}Artifact`
|
|
82
|
+
|
|
83
|
+
manifest[name] = { sha256, bytes: bytes.byteLength, profile: profile.profile }
|
|
84
|
+
|
|
85
|
+
const module = `/**
|
|
86
|
+
* @copyright Sister Software
|
|
87
|
+
* @license AGPL-3.0
|
|
88
|
+
* @author Teffen Ellis, et al.
|
|
89
|
+
*
|
|
90
|
+
* The \`${name}\` artifact of the \`${profile.profile}\` profile, ${bytes.byteLength} bytes, SHA-256 ${sha256}.
|
|
91
|
+
* Generated by tools/generate.run.ts from data/normalized. Edit the data or the compiler rather than this file.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
import { decodeBase64 } from "#rgy1/base64"
|
|
95
|
+
|
|
96
|
+
const BASE64 =
|
|
97
|
+
"${bytes.toString("base64")}"
|
|
98
|
+
|
|
99
|
+
let bytes: Uint8Array | null = null
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Returns the artifact's bytes, decoded on first call and shared afterwards.
|
|
103
|
+
*
|
|
104
|
+
* Callers read the bytes and never write them.
|
|
105
|
+
*/
|
|
106
|
+
export function ${getter}(): Uint8Array {
|
|
107
|
+
bytes ??= decodeBase64(BASE64)
|
|
108
|
+
|
|
109
|
+
return bytes
|
|
110
|
+
}
|
|
111
|
+
`
|
|
112
|
+
|
|
113
|
+
await emit(registry("lib", "artifacts", `${artifactModulePath(name)}.ts`), module)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await emit(registry("data", "manifests", "artifacts.json"), prettyJSON(manifest))
|
|
117
|
+
|
|
118
|
+
// The fixture profile, committed as bytes so the layout test and the Rust tests read the same artifacts.
|
|
119
|
+
const fixtureOut = values.check ? `${openOut}/fixtures` : registry("test", "fixtures", "artifacts")
|
|
120
|
+
|
|
121
|
+
await compileProfile(
|
|
122
|
+
registry("test", "fixtures", "normalized"),
|
|
123
|
+
registry("test", "fixtures", "normalized", "sources.lock.json"),
|
|
124
|
+
fixtureOut
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
if (values.check) {
|
|
128
|
+
for (const name of ARTIFACTS) {
|
|
129
|
+
const built = await readLocalBuffer(`${fixtureOut}/${name}.rgy1`)
|
|
130
|
+
const committed = await readLocalBuffer(registry("test", "fixtures", "artifacts", `${name}.rgy1`)).catch(() => null)
|
|
131
|
+
|
|
132
|
+
if (!committed || !committed.equals(built)) {
|
|
133
|
+
console.error(`test/fixtures/artifacts/${name}.rgy1 differs from the compiler's output`)
|
|
134
|
+
|
|
135
|
+
stale++
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (stale) {
|
|
141
|
+
process.exitCode = 1
|
|
142
|
+
} else {
|
|
143
|
+
for (const [name, entry] of Object.entries(manifest)) {
|
|
144
|
+
console.log(`${name}\t${entry.bytes} bytes\t${entry.sha256}`)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Writes `data/normalized/iso3166-1.json`, `data/normalized/iata-airports.json` and
|
|
7
|
+
* `data/manifests/coverage.json` from the pinned sources.
|
|
8
|
+
*
|
|
9
|
+
* Usage: `node packages/registry/tools/normalize.run.ts`
|
|
10
|
+
*
|
|
11
|
+
* The run refuses a source file whose digest differs from `data/manifests/sources.lock.json`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { writeLocalFile, writeLocalJSONFile } from "@mailwoman/core/fs/writers"
|
|
15
|
+
import { stringifyJSON } from "@mailwoman/core/json"
|
|
16
|
+
import { workspacePathBuilder } from "@mailwoman/core/paths"
|
|
17
|
+
|
|
18
|
+
import { readSourceLock } from "#sdk/fetch"
|
|
19
|
+
import { formatNormalized, normalizeFromLock } from "#tools/normalize"
|
|
20
|
+
|
|
21
|
+
const lock = await readSourceLock()
|
|
22
|
+
|
|
23
|
+
if (!lock) throw new Error("no sources.lock.json; run packages/registry/sdk/fetch.run.ts --repin first")
|
|
24
|
+
|
|
25
|
+
const { countries, airports, coverage } = await normalizeFromLock(lock)
|
|
26
|
+
const data = workspacePathBuilder("registry", "data")
|
|
27
|
+
|
|
28
|
+
await writeLocalFile(formatNormalized(countries), data("normalized", "iso3166-1.json"))
|
|
29
|
+
await writeLocalFile(formatNormalized(airports), data("normalized", "iata-airports.json"))
|
|
30
|
+
await writeLocalJSONFile(coverage, data("manifests", "coverage.json"))
|
|
31
|
+
|
|
32
|
+
console.log(
|
|
33
|
+
`countries: ${countries.records.length} (${stringifyJSON(coverage.namespaces["iso3166-1-alpha2"]!.statuses)})`
|
|
34
|
+
)
|
|
35
|
+
console.log(`airports: ${airports.records.length} (${stringifyJSON(coverage.namespaces["iata-location"]!.statuses)})`)
|
|
36
|
+
console.log(`country lists: ${coverage.namespaces["$countryListComparison"]!.kinds!.join("; ")}`)
|