@mailwoman/registry 11.0.0 → 11.1.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 +3 -3
- package/docs/data-policy.md +5 -5
- package/docs/performance.md +1 -1
- package/docs/rgy1.md +5 -5
- package/lib/artifacts/country-airport-collision.ts +7 -5
- package/lib/artifacts/iata-airport/membership.ts +7 -5
- package/lib/artifacts/iata-airport/records.ts +7 -5
- package/lib/artifacts/iso3166-1/alpha2-membership.ts +7 -5
- package/lib/artifacts/iso3166-1/alpha3-membership.ts +7 -5
- package/lib/artifacts/iso3166-1/records.ts +7 -5
- package/lib/errors.ts +11 -8
- package/lib/iata/airports/records.ts +3 -4
- package/lib/iata/airports/validate.ts +6 -5
- package/lib/index.ts +10 -6
- package/lib/inspect.ts +5 -5
- package/lib/iso3166/alpha2.ts +5 -5
- package/lib/iso3166/alpha3.ts +6 -6
- package/lib/iso3166/records.ts +9 -8
- package/lib/iso3166/relations.ts +5 -5
- package/lib/key.ts +9 -7
- package/lib/normalize.ts +12 -8
- package/lib/overlap/country-airport.ts +14 -12
- package/lib/rgy1/base64.ts +3 -4
- package/lib/rgy1/reader.ts +8 -7
- package/lib/rgy1/sections.generated.ts +6 -5
- package/lib/rgy1/views.ts +5 -6
- package/lib/types.ts +8 -7
- package/lib/wasm.ts +11 -9
- package/out/artifacts/country-airport-collision.d.ts +0 -8
- package/out/artifacts/country-airport-collision.d.ts.map +1 -1
- package/out/artifacts/country-airport-collision.js +6 -5
- package/out/artifacts/country-airport-collision.js.map +1 -1
- package/out/artifacts/iata-airport/membership.d.ts +0 -8
- package/out/artifacts/iata-airport/membership.d.ts.map +1 -1
- package/out/artifacts/iata-airport/membership.js +6 -5
- package/out/artifacts/iata-airport/membership.js.map +1 -1
- package/out/artifacts/iata-airport/records.d.ts +0 -8
- package/out/artifacts/iata-airport/records.d.ts.map +1 -1
- package/out/artifacts/iata-airport/records.js +6 -5
- package/out/artifacts/iata-airport/records.js.map +1 -1
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts +0 -8
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts.map +1 -1
- package/out/artifacts/iso3166-1/alpha2-membership.js +6 -5
- package/out/artifacts/iso3166-1/alpha2-membership.js.map +1 -1
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts +0 -8
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts.map +1 -1
- package/out/artifacts/iso3166-1/alpha3-membership.js +6 -5
- package/out/artifacts/iso3166-1/alpha3-membership.js.map +1 -1
- package/out/artifacts/iso3166-1/records.d.ts +0 -8
- package/out/artifacts/iso3166-1/records.d.ts.map +1 -1
- package/out/artifacts/iso3166-1/records.js +6 -5
- package/out/artifacts/iso3166-1/records.js.map +1 -1
- package/out/errors.d.ts +8 -8
- package/out/errors.d.ts.map +1 -1
- package/out/errors.js +10 -8
- package/out/errors.js.map +1 -1
- package/out/iata/airports/records.d.ts +0 -7
- package/out/iata/airports/records.d.ts.map +1 -1
- package/out/iata/airports/records.js +2 -4
- package/out/iata/airports/records.js.map +1 -1
- package/out/iata/airports/validate.d.ts +0 -8
- package/out/iata/airports/validate.d.ts.map +1 -1
- package/out/iata/airports/validate.js +5 -5
- package/out/iata/airports/validate.js.map +1 -1
- package/out/index.d.ts +5 -6
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -11
- package/out/index.js.map +1 -1
- package/out/inspect.d.ts +2 -5
- package/out/inspect.d.ts.map +1 -1
- package/out/inspect.js +4 -5
- package/out/inspect.js.map +1 -1
- package/out/iso3166/alpha2.d.ts +0 -8
- package/out/iso3166/alpha2.d.ts.map +1 -1
- package/out/iso3166/alpha2.js +4 -5
- package/out/iso3166/alpha2.js.map +1 -1
- package/out/iso3166/alpha3.d.ts +1 -9
- package/out/iso3166/alpha3.d.ts.map +1 -1
- package/out/iso3166/alpha3.js +5 -6
- package/out/iso3166/alpha3.js.map +1 -1
- package/out/iso3166/records.d.ts +0 -11
- package/out/iso3166/records.d.ts.map +1 -1
- package/out/iso3166/records.js +8 -8
- package/out/iso3166/records.js.map +1 -1
- package/out/iso3166/relations.d.ts +0 -7
- package/out/iso3166/relations.d.ts.map +1 -1
- package/out/iso3166/relations.js +4 -5
- package/out/iso3166/relations.js.map +1 -1
- package/out/key.d.ts +6 -7
- package/out/key.d.ts.map +1 -1
- package/out/key.js +8 -7
- package/out/key.js.map +1 -1
- package/out/normalize.d.ts +9 -8
- package/out/normalize.d.ts.map +1 -1
- package/out/normalize.js +2 -12
- package/out/normalize.js.map +1 -1
- package/out/overlap/country-airport.d.ts +2 -16
- package/out/overlap/country-airport.d.ts.map +1 -1
- package/out/overlap/country-airport.js +13 -12
- package/out/overlap/country-airport.js.map +1 -1
- package/out/rgy1/base64.d.ts +0 -4
- package/out/rgy1/base64.d.ts.map +1 -1
- package/out/rgy1/base64.js +2 -4
- package/out/rgy1/base64.js.map +1 -1
- package/out/rgy1/reader.d.ts +0 -11
- package/out/rgy1/reader.d.ts.map +1 -1
- package/out/rgy1/reader.js +7 -7
- package/out/rgy1/reader.js.map +1 -1
- package/out/rgy1/sections.generated.d.ts +3 -5
- package/out/rgy1/sections.generated.d.ts.map +1 -1
- package/out/rgy1/sections.generated.js +5 -5
- package/out/rgy1/sections.generated.js.map +1 -1
- package/out/rgy1/views.d.ts +2 -9
- package/out/rgy1/views.d.ts.map +1 -1
- package/out/rgy1/views.js +4 -6
- package/out/rgy1/views.js.map +1 -1
- package/out/sdk/fetch.d.ts +1 -5
- package/out/sdk/fetch.d.ts.map +1 -1
- package/out/sdk/fetch.js +5 -7
- package/out/sdk/fetch.js.map +1 -1
- package/out/sdk/fetch.run.d.ts +0 -12
- package/out/sdk/fetch.run.d.ts.map +1 -1
- package/out/sdk/fetch.run.js +6 -7
- package/out/sdk/fetch.run.js.map +1 -1
- package/out/sdk/sources.d.ts +6 -15
- package/out/sdk/sources.d.ts.map +1 -1
- package/out/sdk/sources.js +16 -13
- package/out/sdk/sources.js.map +1 -1
- package/out/tools/artifact-path.d.ts +0 -5
- package/out/tools/artifact-path.d.ts.map +1 -1
- package/out/tools/artifact-path.js +2 -5
- package/out/tools/artifact-path.js.map +1 -1
- package/out/tools/bench.run.d.ts +0 -17
- package/out/tools/bench.run.d.ts.map +1 -1
- package/out/tools/bench.run.js +13 -10
- package/out/tools/bench.run.js.map +1 -1
- package/out/tools/build-wasm.run.d.ts +0 -16
- package/out/tools/build-wasm.run.d.ts.map +1 -1
- package/out/tools/build-wasm.run.js +8 -10
- package/out/tools/build-wasm.run.js.map +1 -1
- package/out/tools/generate-sections.run.d.ts +0 -11
- package/out/tools/generate-sections.run.d.ts.map +1 -1
- package/out/tools/generate-sections.run.js +5 -14
- package/out/tools/generate-sections.run.js.map +1 -1
- package/out/tools/generate.run.d.ts +0 -16
- package/out/tools/generate.run.d.ts.map +1 -1
- package/out/tools/generate.run.js +11 -14
- package/out/tools/generate.run.js.map +1 -1
- package/out/tools/normalize.d.ts +1 -13
- package/out/tools/normalize.d.ts.map +1 -1
- package/out/tools/normalize.js +14 -14
- package/out/tools/normalize.js.map +1 -1
- package/out/tools/normalize.run.d.ts +0 -12
- package/out/tools/normalize.run.d.ts.map +1 -1
- package/out/tools/normalize.run.js +4 -6
- package/out/tools/normalize.run.js.map +1 -1
- package/out/types.d.ts +5 -7
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -11
- package/out/types.js.map +1 -1
- package/out/wasm.d.ts +0 -13
- package/out/wasm.d.ts.map +1 -1
- package/out/wasm.js +10 -9
- package/out/wasm.js.map +1 -1
- package/package.json +8 -3
- package/sdk/fetch.run.ts +7 -7
- package/sdk/fetch.ts +6 -7
- package/sdk/sources.ts +17 -13
- package/tools/artifact-path.ts +2 -5
- package/tools/bench.run.ts +19 -10
- package/tools/build-wasm.run.ts +9 -10
- package/tools/generate-sections.run.ts +6 -14
- package/tools/generate.run.ts +12 -14
- package/tools/normalize.run.ts +5 -6
- package/tools/normalize.ts +15 -14
package/tools/bench.run.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
5
|
* Measures the readers on this host and prints a Markdown report for `docs/performance.md`.
|
|
7
6
|
*
|
|
8
|
-
* Arms: a JavaScript `Set` of strings as the baseline, the TypeScript bitset reader,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Arms: a JavaScript `Set` of strings as the baseline, the TypeScript bitset reader,
|
|
8
|
+
* and the WebAssembly batch kernels, scalar and simd.
|
|
9
|
+
* Inputs: strings end to end, and packed bytes where an arm takes them.
|
|
10
|
+
*
|
|
11
|
+
* Batch sizes 1, 16, 256, 4,096 and the whole 17,576-key domain.
|
|
12
|
+
* Distributions: hits, misses, and a shuffled sweep of the domain.
|
|
13
|
+
*
|
|
14
|
+
* Startup: module import, artifact decode and validation, wasm compile and instantiate, first query.
|
|
15
|
+
* Every result is consumed so the work is kept.
|
|
13
16
|
*
|
|
14
17
|
* Usage: `node packages/registry/tools/bench.run.ts [--json]`
|
|
15
18
|
*
|
|
16
|
-
* The numbers describe one host and one run.
|
|
19
|
+
* The numbers describe one host and one run.
|
|
20
|
+
* The report records the host, Node and the artifact digests beside them.
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
23
|
import { readLocalBuffer, readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
@@ -85,13 +89,17 @@ const firstQueryNs = nanoseconds(firstQueryStart)
|
|
|
85
89
|
const countries = await readLocalJSONFile<{ records: Array<{ alpha3: string; status: string }> }>(
|
|
86
90
|
workspacePath("registry", "data", "normalized", "iso3166-1.json")
|
|
87
91
|
)
|
|
92
|
+
|
|
88
93
|
const airports = await readLocalJSONFile<{ records: Array<{ iata: string }> }>(
|
|
89
94
|
workspacePath("registry", "data", "normalized", "iata-airports.json")
|
|
90
95
|
)
|
|
96
|
+
|
|
91
97
|
const setStart = process.hrtime.bigint()
|
|
98
|
+
|
|
92
99
|
const countrySet = new Set(
|
|
93
100
|
countries.records.filter((record) => record.status === "officially-assigned").map((record) => record.alpha3)
|
|
94
101
|
)
|
|
102
|
+
|
|
95
103
|
const airportSet = new Set(airports.records.map((record) => record.iata))
|
|
96
104
|
const collisionSet = new Set([...countrySet].filter((code) => airportSet.has(code)))
|
|
97
105
|
const setBuildNs = nanoseconds(setStart)
|
|
@@ -162,6 +170,7 @@ for (const [distribution, codes] of [
|
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
const variants = wasm.preferredWasmVariant() === "simd" ? (["scalar", "simd"] as const) : (["scalar"] as const)
|
|
173
|
+
|
|
165
174
|
const startup: Record<string, number> = {
|
|
166
175
|
"module import": importNs,
|
|
167
176
|
"artifact decode + validate (3 bitsets)": decodeNs,
|
package/tools/build-wasm.run.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Builds `crates/registry-wasm` for `wasm32-unknown-unknown` twice, once with `simd128` and once without, and
|
|
7
|
-
* writes `wasm/registry-simd.wasm` and `wasm/registry.wasm`.
|
|
5
|
+
* Builds `crates/registry-wasm` for `wasm32-unknown-unknown` twice, once with `simd128`
|
|
6
|
+
* and once without, and writes `wasm/registry-simd.wasm` and `wasm/registry.wasm`.
|
|
8
7
|
*
|
|
9
|
-
* The two builds use separate target directories, because a `RUSTFLAGS` change would
|
|
10
|
-
* crate in the shared target directory.
|
|
8
|
+
* The two builds use separate target directories, because a `RUSTFLAGS` change would
|
|
9
|
+
* otherwise invalidate every crate in the shared target directory.
|
|
11
10
|
*
|
|
12
|
-
* With `--check`, the tool builds without writing and exits non-zero
|
|
13
|
-
* committed binary's.
|
|
11
|
+
* With `--check`, the tool builds without writing and exits non-zero
|
|
12
|
+
* when a build's SHA-256 differs from the committed binary's.
|
|
14
13
|
*
|
|
15
14
|
* Usage: `node packages/registry/tools/build-wasm.run.ts [--check]`
|
|
16
15
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
5
|
* Writes the section-kind constants TypeScript and Rust share from `definitions/sections.json`.
|
|
7
6
|
*
|
|
8
7
|
* Usage: `node packages/registry/tools/generate-sections.run.ts [--check]`
|
|
@@ -15,6 +14,7 @@ import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
|
15
14
|
import { stringifyJSON } from "@mailwoman/core/json"
|
|
16
15
|
import { workspacePath } from "@mailwoman/core/paths"
|
|
17
16
|
import { parseArguments } from "@mailwoman/core/scripting/arguments"
|
|
17
|
+
import { SourceHeaderSyntax, spdxHeaderText } from "@mailwoman/core/spdx-header"
|
|
18
18
|
|
|
19
19
|
interface SectionDefinitions {
|
|
20
20
|
envelope: { magic: string; version: number; headerOffset: number; directoryEntryBytes: number; alignment: number }
|
|
@@ -28,11 +28,7 @@ const definitions = await readLocalJSONFile<SectionDefinitions>(registry("defini
|
|
|
28
28
|
|
|
29
29
|
const constant = (name: string): string => name.toUpperCase().replaceAll("-", "_")
|
|
30
30
|
|
|
31
|
-
const typescript =
|
|
32
|
-
* @copyright Sister Software
|
|
33
|
-
* @license AGPL-3.0
|
|
34
|
-
* @author Teffen Ellis, et al.
|
|
35
|
-
*
|
|
31
|
+
const typescript = `${spdxHeaderText(SourceHeaderSyntax.Slash)}/**
|
|
36
32
|
* The RGY1 section kinds. Generated from definitions/sections.json by tools/generate-sections.run.ts. Edit the
|
|
37
33
|
* definition rather than this file.
|
|
38
34
|
*/
|
|
@@ -91,11 +87,7 @@ ${definitions.kinds.map((kind) => `\t[SectionKind.${constant(kind.name)}]: ${str
|
|
|
91
87
|
}
|
|
92
88
|
`
|
|
93
89
|
|
|
94
|
-
const rust =
|
|
95
|
-
// @license AGPL-3.0
|
|
96
|
-
// @author Teffen Ellis, et al.
|
|
97
|
-
|
|
98
|
-
//! The RGY1 section kinds. Generated from \`definitions/sections.json\` by
|
|
90
|
+
const rust = `${spdxHeaderText(SourceHeaderSyntax.Slash)}//! The RGY1 section kinds. Generated from \`definitions/sections.json\` by
|
|
99
91
|
//! \`tools/generate-sections.run.ts\`. Edit the definition rather than this file.
|
|
100
92
|
|
|
101
93
|
pub const MAGIC: &[u8; 4] = b${stringifyJSON(definitions.envelope.magic)};
|
package/tools/generate.run.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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`.
|
|
5
|
+
* Compiles the normalized data into RGY1 artifacts with `crates/registry-build`,
|
|
6
|
+
* writes each artifact as a TypeScript module under `lib/artifacts/`, and records
|
|
7
|
+
* every artifact's SHA-256 in `data/manifests/artifacts.json`.
|
|
8
8
|
*
|
|
9
|
-
* Each artifact is its own module exporting one lazily decoded getter, so a bundle that
|
|
10
|
-
* predicate holds the collision bitset and no airport record.
|
|
11
|
-
* too, into `test/fixtures/artifacts/*.rgy1`,
|
|
9
|
+
* Each artifact is its own module exporting one lazily decoded getter, so a bundle that
|
|
10
|
+
* imports the collision predicate holds the collision bitset and no airport record.
|
|
11
|
+
* The fixture profile under `test/fixtures/` is compiled too, into `test/fixtures/artifacts/*.rgy1`,
|
|
12
|
+
* so the committed fixtures stay equal to the compiler's output.
|
|
12
13
|
*
|
|
13
14
|
* Usage: `node packages/registry/tools/generate.run.ts [--check]`
|
|
14
15
|
*
|
|
@@ -23,6 +24,7 @@ import { prettyJSON } from "@mailwoman/core/json"
|
|
|
23
24
|
import { repoRootPath, workspacePath } from "@mailwoman/core/paths"
|
|
24
25
|
import { runFile } from "@mailwoman/core/process"
|
|
25
26
|
import { parseArguments } from "@mailwoman/core/scripting/arguments"
|
|
27
|
+
import { SourceHeaderSyntax, spdxHeaderText } from "@mailwoman/core/spdx-header"
|
|
26
28
|
|
|
27
29
|
import { artifactModulePath } from "#tools/artifact-path"
|
|
28
30
|
|
|
@@ -82,11 +84,7 @@ for (const name of ARTIFACTS) {
|
|
|
82
84
|
|
|
83
85
|
manifest[name] = { sha256, bytes: bytes.byteLength, profile: profile.profile }
|
|
84
86
|
|
|
85
|
-
const module =
|
|
86
|
-
* @copyright Sister Software
|
|
87
|
-
* @license AGPL-3.0
|
|
88
|
-
* @author Teffen Ellis, et al.
|
|
89
|
-
*
|
|
87
|
+
const module = `${spdxHeaderText(SourceHeaderSyntax.Slash)}/**
|
|
90
88
|
* The \`${name}\` artifact of the \`${profile.profile}\` profile, ${bytes.byteLength} bytes, SHA-256 ${sha256}.
|
|
91
89
|
* Generated by tools/generate.run.ts from data/normalized. Edit the data or the compiler rather than this file.
|
|
92
90
|
*/
|
package/tools/normalize.run.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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.
|
|
5
|
+
* Writes `data/normalized/iso3166-1.json`, `data/normalized/iata-airports.json`
|
|
6
|
+
* and `data/manifests/coverage.json` from the pinned sources.
|
|
8
7
|
*
|
|
9
8
|
* Usage: `node packages/registry/tools/normalize.run.ts`
|
|
10
9
|
*
|
package/tools/normalize.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
5
|
* Turns the pinned sources into the reviewable normalized JSON the compiler reads.
|
|
7
6
|
*
|
|
8
|
-
* Every record keeps the source's own identity (`entityID`), the code as the
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Every record keeps the source's own identity (`entityID`), the code as the
|
|
8
|
+
* source spells it, and the source's status words.
|
|
9
|
+
* Each record comes from one source: a country record from Wikidata, an airport record from OurAirports.
|
|
10
|
+
*
|
|
11
|
+
* An airport's `country` is the alpha-2 string OurAirports states, with a status that records
|
|
12
|
+
* whether that string is an officially assigned ISO code, a source extension such as `XK`, or absent.
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
import { readLocalJSONFile, readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
@@ -16,7 +17,7 @@ import { sha256File } from "@mailwoman/core/hash"
|
|
|
16
17
|
import { stringifyJSON } from "@mailwoman/core/json"
|
|
17
18
|
import { TextSpliterator } from "spliterator"
|
|
18
19
|
|
|
19
|
-
import { type SourceDefinition, type SourceLock,
|
|
20
|
+
import { pinnedSourceFile, type SourceDefinition, type SourceLock, SOURCES } from "#sdk/sources"
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* One ISO 3166-1 entry.
|
|
@@ -434,7 +435,7 @@ export function formatNormalized(collection: NormalizedCountries | NormalizedAir
|
|
|
434
435
|
}
|
|
435
436
|
|
|
436
437
|
/**
|
|
437
|
-
* Reads the three pinned sources and normalizes them, refusing bytes the lock
|
|
438
|
+
* Reads the three pinned sources and normalizes them, refusing bytes the lock doesn't describe.
|
|
438
439
|
*/
|
|
439
440
|
export async function normalizeFromLock(lock: SourceLock): Promise<{
|
|
440
441
|
countries: NormalizedCountries
|
|
@@ -443,7 +444,7 @@ export async function normalizeFromLock(lock: SourceLock): Promise<{
|
|
|
443
444
|
}> {
|
|
444
445
|
for (const definition of SOURCES.filter((candidate) => candidate.terms.elected)) {
|
|
445
446
|
const locked = lock.sources[definition.id]
|
|
446
|
-
const digest = await sha256File(
|
|
447
|
+
const digest = await sha256File(pinnedSourceFile(definition))
|
|
447
448
|
|
|
448
449
|
if (!locked) throw new Error(`${definition.id} is outside the lock`)
|
|
449
450
|
|
|
@@ -452,7 +453,7 @@ export async function normalizeFromLock(lock: SourceLock): Promise<{
|
|
|
452
453
|
}
|
|
453
454
|
}
|
|
454
455
|
|
|
455
|
-
const results = await readLocalJSONFile<SPARQLResults>(
|
|
456
|
+
const results = await readLocalJSONFile<SPARQLResults>(pinnedSourceFile(sourceDefinition("wikidata-iso3166-1")))
|
|
456
457
|
const countries = normalizeCountries(results, lock.profile)
|
|
457
458
|
|
|
458
459
|
const current = new Set(
|
|
@@ -460,14 +461,14 @@ export async function normalizeFromLock(lock: SourceLock): Promise<{
|
|
|
460
461
|
)
|
|
461
462
|
|
|
462
463
|
const airports = normalizeAirports(
|
|
463
|
-
await readLocalTextFile(
|
|
464
|
+
await readLocalTextFile(pinnedSourceFile(sourceDefinition("ourairports-airports"))),
|
|
464
465
|
current,
|
|
465
466
|
lock.profile
|
|
466
467
|
)
|
|
467
468
|
|
|
468
469
|
const comparison = compareCountryLists(
|
|
469
470
|
countries.records,
|
|
470
|
-
await readLocalTextFile(
|
|
471
|
+
await readLocalTextFile(pinnedSourceFile(sourceDefinition("ourairports-countries")))
|
|
471
472
|
)
|
|
472
473
|
|
|
473
474
|
return { countries, airports, coverage: declareCoverage(countries, airports, comparison) }
|