@mailwoman/codex 8.5.0 → 9.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 +1 -1
- package/ca/province.ts +2 -12
- package/country/subdivision.ts +1 -12
- package/es/codigo-postal.ts +51 -0
- package/es/index.ts +9 -0
- package/fr/region.ts +2 -12
- package/gb/postcode-area.ts +10 -0
- package/index.ts +1 -0
- package/it/cap.ts +39 -0
- package/it/index.ts +9 -0
- package/normalize.ts +53 -0
- package/nz/delivery-service.ts +17 -17
- package/nz/postcode.ts +4 -4
- package/out/ca/province.d.ts.map +1 -1
- package/out/ca/province.js +1 -11
- package/out/ca/province.js.map +1 -1
- package/out/country/subdivision.d.ts.map +1 -1
- package/out/country/subdivision.js +1 -11
- package/out/country/subdivision.js.map +1 -1
- package/out/es/codigo-postal.d.ts +39 -0
- package/out/es/codigo-postal.d.ts.map +1 -0
- package/out/es/codigo-postal.js +35 -0
- package/out/es/codigo-postal.js.map +1 -0
- package/out/es/index.d.ts +9 -0
- package/out/es/index.d.ts.map +1 -0
- package/out/es/index.js +9 -0
- package/out/es/index.js.map +1 -0
- package/out/fr/region.d.ts.map +1 -1
- package/out/fr/region.js +1 -11
- package/out/fr/region.js.map +1 -1
- package/out/gb/postcode-area.d.ts +9 -0
- package/out/gb/postcode-area.d.ts.map +1 -1
- package/out/gb/postcode-area.js +9 -0
- package/out/gb/postcode-area.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/it/cap.d.ts +32 -0
- package/out/it/cap.d.ts.map +1 -0
- package/out/it/cap.js +25 -0
- package/out/it/cap.js.map +1 -0
- package/out/it/index.d.ts +9 -0
- package/out/it/index.d.ts.map +1 -0
- package/out/it/index.js +9 -0
- package/out/it/index.js.map +1 -0
- package/out/normalize.d.ts +36 -0
- package/out/normalize.d.ts.map +1 -0
- package/out/normalize.js +51 -0
- package/out/normalize.js.map +1 -0
- package/out/nz/delivery-service.d.ts +10 -10
- package/out/nz/delivery-service.js +5 -5
- package/out/nz/postcode.d.ts +3 -3
- package/out/nz/postcode.js +2 -2
- package/out/postcode-systems.js +2 -2
- package/out/tools/build-country-surface-lexicon.js +2 -7
- package/out/tools/build-country-surface-lexicon.js.map +1 -1
- package/out/tools/generate-official-languages.d.ts.map +1 -1
- package/out/tools/generate-official-languages.js +4 -2
- package/out/tools/generate-official-languages.js.map +1 -1
- package/package.json +18 -2
- package/postcode-systems.ts +2 -2
- package/tools/build-country-surface-lexicon.ts +2 -10
- package/tools/generate-official-languages.ts +6 -1
package/postcode-systems.ts
CHANGED
|
@@ -27,7 +27,7 @@ import { normalizePLZ } from "./de/index.ts"
|
|
|
27
27
|
import { normalizeCodePostal } from "./fr/index.ts"
|
|
28
28
|
import { normalizeUkPostcode } from "./gb/index.ts"
|
|
29
29
|
import { normalizeJpPostalCode } from "./jp/index.ts"
|
|
30
|
-
import {
|
|
30
|
+
import { normalizeNZPostcode } from "./nz/index.ts"
|
|
31
31
|
import { isZipCode } from "./us/index.ts"
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -48,7 +48,7 @@ const SYSTEM_ACCEPTS: ReadonlyArray<readonly [SystemCode, (s: string) => boolean
|
|
|
48
48
|
["gb", (s) => normalizeUkPostcode(s) !== null],
|
|
49
49
|
["jp", (s) => normalizeJpPostalCode(s) !== null],
|
|
50
50
|
["au", (s) => normalizeAuPostcode(s) !== null],
|
|
51
|
-
["nz", (s) =>
|
|
51
|
+
["nz", (s) => normalizeNZPostcode(s) !== null],
|
|
52
52
|
]
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -44,6 +44,7 @@ import { mkdirSync, writeFileSync } from "node:fs"
|
|
|
44
44
|
import { dirname, resolve } from "node:path"
|
|
45
45
|
|
|
46
46
|
import { COUNTRY_SURFACE_FORMS, ISO2_TO_NAME } from "../country/country.ts"
|
|
47
|
+
import { wordNorm, wordNormLower } from "../normalize.ts"
|
|
47
48
|
import { US_STATE_ABBREVIATIONS, US_STATE_NAMES } from "../us/state.ts"
|
|
48
49
|
|
|
49
50
|
/**
|
|
@@ -71,15 +72,6 @@ const OUTPUT = resolve(import.meta.dirname, "../../data/gazetteer/country-surfac
|
|
|
71
72
|
* letters or digits (keep internal ones: "u.s.a", "timor-leste"), rejoin single-spaced. Entry keys and scanned tokens
|
|
72
73
|
* both pass through it, so "U.S.A." ≡ "u.s.a".
|
|
73
74
|
*/
|
|
74
|
-
const wordNorm = (s: string): string =>
|
|
75
|
-
s
|
|
76
|
-
.split(/\s+/)
|
|
77
|
-
.map((w) => w.replaceAll(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, ""))
|
|
78
|
-
.filter(Boolean)
|
|
79
|
-
.join(" ")
|
|
80
|
-
|
|
81
|
-
const norm = (s: string): string => wordNorm(s).toLowerCase()
|
|
82
|
-
|
|
83
75
|
/**
|
|
84
76
|
* Short alphabetic code (≤3 letters once punctuation is dropped) → exact-uppercase matching.
|
|
85
77
|
*/
|
|
@@ -125,7 +117,7 @@ function add(surface: string): void {
|
|
|
125
117
|
return
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
const key =
|
|
120
|
+
const key = wordNormLower(s)
|
|
129
121
|
|
|
130
122
|
if (!key) return
|
|
131
123
|
const words = key.split(" ")
|
|
@@ -23,6 +23,8 @@ import { readFileSync, writeFileSync } from "node:fs"
|
|
|
23
23
|
import { join } from "node:path"
|
|
24
24
|
import { fileURLToPath } from "node:url"
|
|
25
25
|
|
|
26
|
+
import { parseJSONStrict } from "@mailwoman/core/objects"
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* The committed output path, resolved relative to this module (codex/tools/ → codex/country/). The codegen is
|
|
28
30
|
* repo-only, and in the repo `@mailwoman/codex/tools` always loads from source via the `node` exports condition, so
|
|
@@ -62,7 +64,10 @@ interface LanguagePopulation {
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
async function loadCLDR(file: string, cldrDir: string | undefined, cldrVersion: string): Promise<unknown> {
|
|
65
|
-
if (cldrDir)
|
|
67
|
+
if (cldrDir) {
|
|
68
|
+
return parseJSONStrict(readFileSync(join(cldrDir, `cldr-${file}.json`), "utf8"))
|
|
69
|
+
}
|
|
70
|
+
|
|
66
71
|
const url = `https://cdn.jsdelivr.net/npm/cldr-core@${cldrVersion}/supplemental/${file}.json`
|
|
67
72
|
const res = await fetch(url)
|
|
68
73
|
|