@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.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/ca/province.ts +2 -12
  3. package/country/subdivision.ts +1 -12
  4. package/es/codigo-postal.ts +51 -0
  5. package/es/index.ts +9 -0
  6. package/fr/region.ts +2 -12
  7. package/gb/postcode-area.ts +10 -0
  8. package/index.ts +1 -0
  9. package/it/cap.ts +39 -0
  10. package/it/index.ts +9 -0
  11. package/normalize.ts +53 -0
  12. package/nz/delivery-service.ts +17 -17
  13. package/nz/postcode.ts +4 -4
  14. package/out/ca/province.d.ts.map +1 -1
  15. package/out/ca/province.js +1 -11
  16. package/out/ca/province.js.map +1 -1
  17. package/out/country/subdivision.d.ts.map +1 -1
  18. package/out/country/subdivision.js +1 -11
  19. package/out/country/subdivision.js.map +1 -1
  20. package/out/es/codigo-postal.d.ts +39 -0
  21. package/out/es/codigo-postal.d.ts.map +1 -0
  22. package/out/es/codigo-postal.js +35 -0
  23. package/out/es/codigo-postal.js.map +1 -0
  24. package/out/es/index.d.ts +9 -0
  25. package/out/es/index.d.ts.map +1 -0
  26. package/out/es/index.js +9 -0
  27. package/out/es/index.js.map +1 -0
  28. package/out/fr/region.d.ts.map +1 -1
  29. package/out/fr/region.js +1 -11
  30. package/out/fr/region.js.map +1 -1
  31. package/out/gb/postcode-area.d.ts +9 -0
  32. package/out/gb/postcode-area.d.ts.map +1 -1
  33. package/out/gb/postcode-area.js +9 -0
  34. package/out/gb/postcode-area.js.map +1 -1
  35. package/out/index.d.ts +1 -0
  36. package/out/index.d.ts.map +1 -1
  37. package/out/index.js +1 -0
  38. package/out/index.js.map +1 -1
  39. package/out/it/cap.d.ts +32 -0
  40. package/out/it/cap.d.ts.map +1 -0
  41. package/out/it/cap.js +25 -0
  42. package/out/it/cap.js.map +1 -0
  43. package/out/it/index.d.ts +9 -0
  44. package/out/it/index.d.ts.map +1 -0
  45. package/out/it/index.js +9 -0
  46. package/out/it/index.js.map +1 -0
  47. package/out/normalize.d.ts +36 -0
  48. package/out/normalize.d.ts.map +1 -0
  49. package/out/normalize.js +51 -0
  50. package/out/normalize.js.map +1 -0
  51. package/out/nz/delivery-service.d.ts +10 -10
  52. package/out/nz/delivery-service.js +5 -5
  53. package/out/nz/postcode.d.ts +3 -3
  54. package/out/nz/postcode.js +2 -2
  55. package/out/postcode-systems.js +2 -2
  56. package/out/tools/build-country-surface-lexicon.js +2 -7
  57. package/out/tools/build-country-surface-lexicon.js.map +1 -1
  58. package/out/tools/generate-official-languages.d.ts.map +1 -1
  59. package/out/tools/generate-official-languages.js +4 -2
  60. package/out/tools/generate-official-languages.js.map +1 -1
  61. package/package.json +18 -2
  62. package/postcode-systems.ts +2 -2
  63. package/tools/build-country-surface-lexicon.ts +2 -10
  64. package/tools/generate-official-languages.ts +6 -1
@@ -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 { normalizeNzPostcode } from "./nz/index.ts"
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) => normalizeNzPostcode(s) !== null],
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 = norm(s)
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) return JSON.parse(readFileSync(join(cldrDir, `cldr-${file}.json`), "utf8"))
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