@mailwoman/codex 9.0.0 → 9.2.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 (96) hide show
  1. package/README.md +48 -5
  2. package/ca/index.ts +1 -1
  3. package/ca/postal-code.ts +11 -11
  4. package/country/display-names.ts +150 -0
  5. package/country/index.ts +2 -0
  6. package/country/population.ts +265 -0
  7. package/country/subdivision.ts +59 -0
  8. package/de/index.ts +1 -1
  9. package/de/postleitzahl.ts +3 -3
  10. package/es/codigo-postal.ts +2 -2
  11. package/fr/code-postal.ts +6 -6
  12. package/fr/index.ts +1 -1
  13. package/index.ts +10 -1
  14. package/it/cap.ts +2 -2
  15. package/jp/index.ts +1 -1
  16. package/jp/postal-code.ts +11 -11
  17. package/out/ca/index.d.ts +1 -1
  18. package/out/ca/index.js +1 -1
  19. package/out/ca/postal-code.d.ts +10 -10
  20. package/out/ca/postal-code.js +9 -9
  21. package/out/country/display-names.d.ts +67 -0
  22. package/out/country/display-names.d.ts.map +1 -0
  23. package/out/country/display-names.js +118 -0
  24. package/out/country/display-names.js.map +1 -0
  25. package/out/country/index.d.ts +2 -0
  26. package/out/country/index.d.ts.map +1 -1
  27. package/out/country/index.js +2 -0
  28. package/out/country/index.js.map +1 -1
  29. package/out/country/population.d.ts +16 -0
  30. package/out/country/population.d.ts.map +1 -0
  31. package/out/country/population.js +265 -0
  32. package/out/country/population.js.map +1 -0
  33. package/out/country/subdivision.d.ts +7 -0
  34. package/out/country/subdivision.d.ts.map +1 -1
  35. package/out/country/subdivision.js +49 -0
  36. package/out/country/subdivision.js.map +1 -1
  37. package/out/de/index.d.ts +1 -1
  38. package/out/de/index.js +1 -1
  39. package/out/de/postleitzahl.d.ts +3 -3
  40. package/out/de/postleitzahl.js +2 -2
  41. package/out/es/codigo-postal.d.ts +2 -2
  42. package/out/es/codigo-postal.js +1 -1
  43. package/out/fr/code-postal.d.ts +5 -5
  44. package/out/fr/code-postal.js +6 -6
  45. package/out/fr/index.d.ts +1 -1
  46. package/out/fr/index.js +1 -1
  47. package/out/index.d.ts +1 -1
  48. package/out/index.d.ts.map +1 -1
  49. package/out/index.js +1 -1
  50. package/out/index.js.map +1 -1
  51. package/out/it/cap.d.ts +2 -2
  52. package/out/it/cap.js +1 -1
  53. package/out/jp/index.d.ts +1 -1
  54. package/out/jp/index.js +1 -1
  55. package/out/jp/postal-code.d.ts +11 -11
  56. package/out/jp/postal-code.js +8 -8
  57. package/out/postcode-systems.d.ts +84 -0
  58. package/out/postcode-systems.d.ts.map +1 -1
  59. package/out/postcode-systems.js +106 -0
  60. package/out/postcode-systems.js.map +1 -1
  61. package/out/tools/build-country-surface-lexicon.js +1 -1
  62. package/out/tools/build-country-surface-lexicon.js.map +1 -1
  63. package/out/tools/export-country-surfaces.js +1 -1
  64. package/out/tools/export-country-surfaces.js.map +1 -1
  65. package/out/tools/generate-country-population.d.ts +42 -0
  66. package/out/tools/generate-country-population.d.ts.map +1 -0
  67. package/out/tools/generate-country-population.js +106 -0
  68. package/out/tools/generate-country-population.js.map +1 -0
  69. package/out/tools/generate-country-reference.d.ts.map +1 -1
  70. package/out/tools/generate-country-reference.js +4 -4
  71. package/out/tools/generate-country-reference.js.map +1 -1
  72. package/out/tools/generate-official-languages.d.ts.map +1 -1
  73. package/out/tools/generate-official-languages.js +7 -4
  74. package/out/tools/generate-official-languages.js.map +1 -1
  75. package/out/tools/index.d.ts +2 -2
  76. package/out/tools/index.d.ts.map +1 -1
  77. package/out/tools/index.js +2 -2
  78. package/out/tools/index.js.map +1 -1
  79. package/out/us/street-suffix.d.ts +432 -418
  80. package/out/us/street-suffix.d.ts.map +1 -1
  81. package/out/us/street-suffix.js +28 -216
  82. package/out/us/street-suffix.js.map +1 -1
  83. package/out/us/street-suffix.json +273 -0
  84. package/out/us/zipcode.d.ts +1 -1
  85. package/out/us/zipcode.js +1 -1
  86. package/package.json +328 -4
  87. package/postcode-systems.ts +112 -0
  88. package/tools/build-country-surface-lexicon.ts +1 -1
  89. package/tools/export-country-surfaces.ts +1 -1
  90. package/tools/generate-country-population.ts +143 -0
  91. package/tools/generate-country-reference.ts +5 -3
  92. package/tools/generate-official-languages.ts +8 -4
  93. package/tools/index.ts +2 -2
  94. package/us/street-suffix.json +273 -0
  95. package/us/street-suffix.ts +32 -217
  96. package/us/zipcode.ts +1 -1
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * German postal codes (Postleitzahl, PLZ): the branded type, the shape, normalization, and the
6
+ * German postcodes (Postleitzahl, PLZ): the branded type, the shape, normalization, and the
7
7
  * first-digit → Leitzone geographic prior.
8
8
  *
9
9
  * The US analog is `us/zipcode.ts`, and the contrast is the informative part. A US ZIP's first
@@ -18,7 +18,7 @@
18
18
  import type { Tagged } from "type-fest"
19
19
 
20
20
  /**
21
- * A German postal code: five digits since the 1993 reform (`12623`). A bare 5-digit string, same shape as a US ZIP or a
21
+ * A German postcode: five digits since the 1993 reform (`12623`). A bare 5-digit string, same shape as a US ZIP or a
22
22
  * French code postal — disambiguation is the parser's job, not the shape's.
23
23
  *
24
24
  * @category Postal
@@ -45,7 +45,7 @@ export function normalizePLZ(raw: unknown): Postleitzahl | null {
45
45
  }
46
46
 
47
47
  /**
48
- * Type-predicate for a (normalized) German postal code.
48
+ * Type-predicate for a (normalized) German postcode.
49
49
  */
50
50
  export function isPostleitzahl(input: unknown): input is Postleitzahl {
51
51
  return typeof input === "string" && PLZ_PATTERN.test(input)
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Spanish postal codes (código postal): the branded type, the shape, and the province prior.
6
+ * Spanish postcodes (código postal): the branded type, the shape, and the province prior.
7
7
  *
8
8
  * The contrast with a German PLZ is the informative part. A PLZ's leading digit maps to a Leitzone
9
9
  * that deliberately CROSSES state borders, so it cannot tell you the Bundesland. A Spanish código
@@ -16,7 +16,7 @@
16
16
  import type { Tagged } from "type-fest"
17
17
 
18
18
  /**
19
- * A Spanish postal code: five digits, `PPNNN`, where `PP` is the province (`28001` is Madrid).
19
+ * A Spanish postcode: five digits, `PPNNN`, where `PP` is the province (`28001` is Madrid).
20
20
  *
21
21
  * @category Postal
22
22
  * @type string
package/fr/code-postal.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * French postal codes (code postal): the branded type, the shape, normalization, and the
6
+ * French postcodes (code postal): the branded type, the shape, normalization, and the
7
7
  * first-two-digits → département mapping — the cleanest postcode→admin prior of the three
8
8
  * systems.
9
9
  *
@@ -30,7 +30,7 @@ import { departementInfo, type DepartementCode, type DepartementInfo } from "./d
30
30
  import { FR_REGIONS, type FrenchRegionInfo } from "./region.ts"
31
31
 
32
32
  /**
33
- * A French postal code: five digits (`75008`). Same shape as a US ZIP or a German PLZ — the shape alone does not
33
+ * A French postcode: five digits (`75008`). Same shape as a US ZIP or a German PLZ — the shape alone does not
34
34
  * disambiguate the country.
35
35
  *
36
36
  * @category Postal
@@ -63,14 +63,14 @@ export function normalizeCodePostal(raw: unknown): CodePostal | null {
63
63
  }
64
64
 
65
65
  /**
66
- * Type-predicate for a (normalized) French postal code.
66
+ * Type-predicate for a (normalized) French postcode.
67
67
  */
68
68
  export function isCodePostal(input: unknown): input is CodePostal {
69
69
  return typeof input === "string" && CODE_POSTAL_PATTERN.test(input)
70
70
  }
71
71
 
72
72
  /**
73
- * The département code a postal code belongs to. The clean rule plus its two exceptions:
73
+ * The département code a postcode belongs to. The clean rule plus its two exceptions:
74
74
  *
75
75
  * - `20xxx` → Corsica. The split is by the rest of the code: roughly `20000`–`20199` → `2A` (Ajaccio side), `20200`+ →
76
76
  * `2B` (Bastia side). Approximate at the boundary, exact for the bulk.
@@ -102,14 +102,14 @@ export function departementOfCodePostal(codePostal: unknown): DepartementCode |
102
102
  }
103
103
 
104
104
  /**
105
- * The full département record a postal code resolves to (name + région), or null.
105
+ * The full département record a postcode resolves to (name + région), or null.
106
106
  */
107
107
  export function departementForCodePostal(codePostal: unknown): DepartementInfo | null {
108
108
  return departementInfo(departementOfCodePostal(codePostal))
109
109
  }
110
110
 
111
111
  /**
112
- * The région a postal code resolves to, via its département; null if the code maps to no département.
112
+ * The région a postcode resolves to, via its département; null if the code maps to no département.
113
113
  */
114
114
  export function regionForCodePostal(codePostal: unknown): FrenchRegionInfo | null {
115
115
  const dep = departementForCodePostal(codePostal)
package/fr/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The French address system (La Poste / ISO 3166-2:FR): street types (voie), postal codes (code
6
+ * The French address system (La Poste / ISO 3166-2:FR): street types (voie), postcodes (code
7
7
  * postal), and the admin hierarchy of départements and régions.
8
8
  */
9
9
 
package/index.ts CHANGED
@@ -36,5 +36,14 @@ export * as gb from "./gb/index.ts"
36
36
  export * as jp from "./jp/index.ts"
37
37
  export * as levels from "./level-semantics.ts"
38
38
  export * as nz from "./nz/index.ts"
39
- export { candidateSystemsForPostcode, type SystemCode } from "./postcode-systems.ts"
39
+
40
+ export {
41
+ AREA_POSTCODE_FINER_THAN_LOCALITY,
42
+ areaPostcodeLeadsLocality,
43
+ candidateSystemsForPostcode,
44
+ isUnitGradePostcodeHit,
45
+ type SystemCode,
46
+ UNIT_GRADE_POSTCODE,
47
+ } from "./postcode-systems.ts"
48
+
40
49
  export * as us from "./us/index.ts"
package/it/cap.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Italian postal codes (Codice di Avviamento Postale, CAP): the branded type and the shape.
6
+ * Italian postcodes (Codice di Avviamento Postale, CAP): the branded type and the shape.
7
7
  *
8
8
  * Five digits like the Spanish, French and German forms, but do NOT infer a province from the
9
9
  * leading digits the way `es/codigo-postal.ts` documents for Spain. Italy's large cities are
@@ -15,7 +15,7 @@
15
15
  import type { Tagged } from "type-fest"
16
16
 
17
17
  /**
18
- * An Italian postal code: five digits (`00184` is Rome, Rione Monti).
18
+ * An Italian postcode: five digits (`00184` is Rome, Rione Monti).
19
19
  *
20
20
  * @category Postal
21
21
  * @type string
package/jp/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The Japanese address system (Japan Post / ISO 3166-2:JP): the 47 prefectures, the postal code
6
+ * The Japanese address system (Japan Post / ISO 3166-2:JP): the 47 prefectures, the postcode
7
7
  * that is the country's most reliable geographic anchor, and the address-unit markers that stand
8
8
  * in for the street names Japan does not use.
9
9
  */
package/jp/postal-code.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Japanese postal codes (郵便番号, yūbin-bangō): the branded type, the shape, normalization, and the
6
+ * Japanese postcodes (郵便番号, yūbin-bangō): the branded type, the shape, normalization, and the
7
7
  * first-digit → coarse-region prior.
8
8
  *
9
9
  * This file is the far end of a spectrum whose other end is `us/zipcode.ts`. A US address leans on
@@ -16,7 +16,7 @@
16
16
  * navigate by named streets; you navigate by nested administrative areas and numbered
17
17
  * blocks/lots (丁目 / 番地 / 号 — see `address-unit.ts`).
18
18
  *
19
- * With no street name to anchor on and a reverse field order, the **postal code is the single most
19
+ * With no street name to anchor on and a reverse field order, the **postcode is the single most
20
20
  * reliable geographic anchor** for a Japanese address — it pins the chōme-level area directly,
21
21
  * far tighter than a US ZIP pins a US address. So where the US parser treats the postcode as a
22
22
  * tie-breaker behind the street, the Japan parser should treat it as the primary key.
@@ -25,9 +25,9 @@
25
25
  import type { Tagged } from "type-fest"
26
26
 
27
27
  /**
28
- * A Japanese postal code: three digits, a hyphen, then four digits (`100-0001`), conventionally written after the 〒
29
- * mark (`〒100-0001`). Branded so a normalized code is distinct from an arbitrary string — the 7-digit shape alone does
30
- * not prove a code is real, only well-formed.
28
+ * A Japanese postcode: three digits, a hyphen, then four digits (`100-0001`), conventionally written after the 〒 mark
29
+ * (`〒100-0001`). Branded so a normalized code is distinct from an arbitrary string — the 7-digit shape alone does not
30
+ * prove a code is real, only well-formed.
31
31
  *
32
32
  * @category Postal
33
33
  * @type string
@@ -57,17 +57,17 @@ export function normalizeJpPostalCode(raw: unknown): PostalCode | null {
57
57
  }
58
58
 
59
59
  /**
60
- * Type-predicate for a Japanese postal code (hyphen optional, `100-0001` or `1000001`).
60
+ * Type-predicate for a Japanese postcode (hyphen optional, `100-0001` or `1000001`).
61
61
  */
62
62
  export function isJpPostalCode(input: unknown): input is PostalCode {
63
63
  return typeof input === "string" && JP_POSTAL_CODE_PATTERN.test(input)
64
64
  }
65
65
 
66
66
  /**
67
- * First digit of the postal code → a coarse region label. Japan Post's numbering grows roughly outward from Tokyo
68
- * (`1xx`) and is **approximate** at this granularity — a single leading digit spans large, irregular areas and the
69
- * boundaries are postal-routing, not administrative. Use it as a weak prior, never as a hard region assignment; the
70
- * full code is what actually anchors the address.
67
+ * First digit of the postcode → a coarse region label. Japan Post's numbering grows roughly outward from Tokyo (`1xx`)
68
+ * and is **approximate** at this granularity — a single leading digit spans large, irregular areas and the boundaries
69
+ * are postal-routing, not administrative. Use it as a weak prior, never as a hard region assignment; the full code is
70
+ * what actually anchors the address.
71
71
  *
72
72
  * Approximate — the labels below are illustrative routing regions, not precise prefecture sets.
73
73
  */
@@ -85,7 +85,7 @@ export const JP_FIRST_DIGIT_REGION: Record<string, string> = {
85
85
  }
86
86
 
87
87
  /**
88
- * The coarse region label for a postal code's first digit, or null if the input is not a Japanese postal code. A weak,
88
+ * The coarse region label for a postcode's first digit, or null if the input is not a Japanese postcode. A weak,
89
89
  * approximate prior (see {@link JP_FIRST_DIGIT_REGION}); the full code anchors the address.
90
90
  */
91
91
  export function firstDigitRegion(postalCode: unknown): string | null {
package/out/ca/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
6
  * The Canadian address system (Canada Post / ISO 3166-2:CA): bilingual street types, alphanumeric
7
- * postal codes, and the provinces and territories.
7
+ * postcodes, and the provinces and territories.
8
8
  */
9
9
  export * from "./postal-code.ts";
10
10
  export * from "./province.ts";
package/out/ca/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
6
  * The Canadian address system (Canada Post / ISO 3166-2:CA): bilingual street types, alphanumeric
7
- * postal codes, and the provinces and territories.
7
+ * postcodes, and the provinces and territories.
8
8
  */
9
9
  export * from "./postal-code.js";
10
10
  export * from "./province.js";
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Canadian postal codes: the branded type, the shape, normalization, and the FSA-letter →
6
+ * Canadian postcodes: the branded type, the shape, normalization, and the FSA-letter →
7
7
  * province/territory prior — the only ALPHANUMERIC postcode of the systems the codex models.
8
8
  *
9
9
  * The informative contrast across `us/zipcode.ts`, `de/postleitzahl.ts`, `fr/code-postal.ts`, and
@@ -12,7 +12,7 @@
12
12
  * - A US ZIP is numeric; its first digit maps to a loose BAND of states.
13
13
  * - A German PLZ is numeric; its first digit maps to a Leitzone that CROSSES Bundesland borders.
14
14
  * - A French code postal is numeric; its first TWO digits ARE the département.
15
- * - A Canadian postal code is `A1A 1A1` — Letter Digit Letter, then Digit Letter Digit — and its
15
+ * - A Canadian postcode is `A1A 1A1` — Letter Digit Letter, then Digit Letter Digit — and its
16
16
  * first LETTER pins the province or territory directly (`M` → Ontario, `H` → Quebec, `V` →
17
17
  * British Columbia). So like the French prefix it is a clean admin prior, but it does the job
18
18
  * with a single ALPHA character rather than digits.
@@ -27,13 +27,13 @@
27
27
  import type { Tagged } from "type-fest";
28
28
  import type { CanadianProvinceCode } from "./province.ts";
29
29
  /**
30
- * A Canadian postal code: `A1A 1A1`. Six alphanumeric characters in a strict Letter-Digit-Letter-Digit-Letter-Digit
30
+ * A Canadian postcode: `A1A 1A1`. Six alphanumeric characters in a strict Letter-Digit-Letter-Digit-Letter-Digit
31
31
  * pattern, conventionally written with a single space after the third. Unlike the other systems' bare five digits, the
32
32
  * shape alone already says "Canada".
33
33
  *
34
34
  * @category Postal
35
35
  * @type string
36
- * @title Postal Code
36
+ * @title Postcode
37
37
  * @pattern ^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] ?\d[ABCEGHJ-NPRSTV-Z]\d$
38
38
  */
39
39
  export type PostalCode = Tagged<string, "CaPostalCode">;
@@ -46,11 +46,11 @@ export declare const CA_POSTAL_CODE_PATTERN: RegExp;
46
46
  /**
47
47
  * Normalize a postal-code surface form to canonical `A1A 1A1`: uppercase and ensure exactly one space between the FSA
48
48
  * (first three chars) and the LDU (last three) — `K1A0B1` → `K1A 0B1`, `k1a 0b1` → `K1A 0B1`. Returns null if the input
49
- * is not a valid Canadian postal code.
49
+ * is not a valid Canadian postcode.
50
50
  */
51
51
  export declare function normalizeCaPostalCode(raw: unknown): PostalCode | null;
52
52
  /**
53
- * Type-predicate for a Canadian postal code (accepts the spaced or unspaced surface form).
53
+ * Type-predicate for a Canadian postcode (accepts the spaced or unspaced surface form).
54
54
  */
55
55
  export declare function isCaPostalCode(input: unknown): input is PostalCode;
56
56
  /**
@@ -60,13 +60,13 @@ export declare function isCaPostalCode(input: unknown): input is PostalCode;
60
60
  */
61
61
  export declare const FSA_LETTER_TO_PROVINCE: Record<string, CanadianProvinceCode | CanadianProvinceCode[]>;
62
62
  /**
63
- * The province/territory a postal code belongs to, via its FSA first letter. Returns the single code for the clean
64
- * letters, the `["NT", "NU"]` pair for the shared `X`, and null if the input is not a valid Canadian postal code (or
65
- * its first letter has no province, which the pattern already forbids).
63
+ * The province/territory a postcode belongs to, via its FSA first letter. Returns the single code for the clean
64
+ * letters, the `["NT", "NU"]` pair for the shared `X`, and null if the input is not a valid Canadian postcode (or its
65
+ * first letter has no province, which the pattern already forbids).
66
66
  */
67
67
  export declare function provinceOfPostalCode(postalCode: unknown): CanadianProvinceCode | CanadianProvinceCode[] | null;
68
68
  /**
69
- * True when a postal code is RURAL: its SECOND character (the FSA's first digit) is `0`. Canada Post uses a `0` in that
69
+ * True when a postcode is RURAL: its SECOND character (the FSA's first digit) is `0`. Canada Post uses a `0` in that
70
70
  * position to mark the lower-density delivery zones (rural routes, small communities) — the contrast with the urban
71
71
  * `1`–`9` FSAs. Returns false for a non-code.
72
72
  */
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Canadian postal codes: the branded type, the shape, normalization, and the FSA-letter →
6
+ * Canadian postcodes: the branded type, the shape, normalization, and the FSA-letter →
7
7
  * province/territory prior — the only ALPHANUMERIC postcode of the systems the codex models.
8
8
  *
9
9
  * The informative contrast across `us/zipcode.ts`, `de/postleitzahl.ts`, `fr/code-postal.ts`, and
@@ -12,7 +12,7 @@
12
12
  * - A US ZIP is numeric; its first digit maps to a loose BAND of states.
13
13
  * - A German PLZ is numeric; its first digit maps to a Leitzone that CROSSES Bundesland borders.
14
14
  * - A French code postal is numeric; its first TWO digits ARE the département.
15
- * - A Canadian postal code is `A1A 1A1` — Letter Digit Letter, then Digit Letter Digit — and its
15
+ * - A Canadian postcode is `A1A 1A1` — Letter Digit Letter, then Digit Letter Digit — and its
16
16
  * first LETTER pins the province or territory directly (`M` → Ontario, `H` → Quebec, `V` →
17
17
  * British Columbia). So like the French prefix it is a clean admin prior, but it does the job
18
18
  * with a single ALPHA character rather than digits.
@@ -25,7 +25,7 @@
25
25
  * the bridge to the wider, lower-density delivery zones.
26
26
  */
27
27
  /**
28
- * Characters in a Canadian postal code once spaces are stripped: `A1A1A1`.
28
+ * Characters in a Canadian postcode once spaces are stripped: `A1A1A1`.
29
29
  */
30
30
  const POSTAL_CODE_LENGTH = 6;
31
31
  /**
@@ -37,7 +37,7 @@ export const CA_POSTAL_CODE_PATTERN = /^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] ?
37
37
  /**
38
38
  * Normalize a postal-code surface form to canonical `A1A 1A1`: uppercase and ensure exactly one space between the FSA
39
39
  * (first three chars) and the LDU (last three) — `K1A0B1` → `K1A 0B1`, `k1a 0b1` → `K1A 0B1`. Returns null if the input
40
- * is not a valid Canadian postal code.
40
+ * is not a valid Canadian postcode.
41
41
  */
42
42
  export function normalizeCaPostalCode(raw) {
43
43
  if (typeof raw !== "string")
@@ -49,7 +49,7 @@ export function normalizeCaPostalCode(raw) {
49
49
  return CA_POSTAL_CODE_PATTERN.test(spaced) ? spaced : null;
50
50
  }
51
51
  /**
52
- * Type-predicate for a Canadian postal code (accepts the spaced or unspaced surface form).
52
+ * Type-predicate for a Canadian postcode (accepts the spaced or unspaced surface form).
53
53
  */
54
54
  export function isCaPostalCode(input) {
55
55
  return typeof input === "string" && CA_POSTAL_CODE_PATTERN.test(input);
@@ -80,9 +80,9 @@ export const FSA_LETTER_TO_PROVINCE = {
80
80
  Y: "YT",
81
81
  };
82
82
  /**
83
- * The province/territory a postal code belongs to, via its FSA first letter. Returns the single code for the clean
84
- * letters, the `["NT", "NU"]` pair for the shared `X`, and null if the input is not a valid Canadian postal code (or
85
- * its first letter has no province, which the pattern already forbids).
83
+ * The province/territory a postcode belongs to, via its FSA first letter. Returns the single code for the clean
84
+ * letters, the `["NT", "NU"]` pair for the shared `X`, and null if the input is not a valid Canadian postcode (or its
85
+ * first letter has no province, which the pattern already forbids).
86
86
  */
87
87
  export function provinceOfPostalCode(postalCode) {
88
88
  const normalized = normalizeCaPostalCode(postalCode);
@@ -91,7 +91,7 @@ export function provinceOfPostalCode(postalCode) {
91
91
  return FSA_LETTER_TO_PROVINCE[normalized[0]] ?? null;
92
92
  }
93
93
  /**
94
- * True when a postal code is RURAL: its SECOND character (the FSA's first digit) is `0`. Canada Post uses a `0` in that
94
+ * True when a postcode is RURAL: its SECOND character (the FSA's first digit) is `0`. Canada Post uses a `0` in that
95
95
  * position to mark the lower-density delivery zones (rural routes, small communities) — the contrast with the urban
96
96
  * `1`–`9` FSAs. Returns false for a non-code.
97
97
  */
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Country surface forms across scripts, enumerated from the RUNTIME's own ICU via `Intl.DisplayNames`.
7
+ *
8
+ * The gazetteer holds country names in English and little else, which is why a bare `格鲁吉亚` (Georgia the country,
9
+ * Chinese), `沙特阿拉伯` or `巴布亚新几内亚` resolves to nothing while `佐治亚州` (Georgia the US state) resolves
10
+ * correctly — the state is a real WOF record carrying multilingual names, and 140 of the 237 country rows are
11
+ * synthetic and carry only a canonical English name. Measured 2026-08-15; WOF has no Chinese country names at all,
12
+ * and `geonames-aliases.ts` filters every alias through a Latin-script regex.
13
+ *
14
+ * ICU already knows all of it. No download, no vendored corpus, no licence question, and no drift against a snapshot
15
+ * we would otherwise have to refresh: the names come from the same ICU the runtime uses for every other
16
+ * locale-sensitive operation. Measured coverage at time of writing: **280 regions, 5,244 distinct surfaces** across
17
+ * the locale × style grid below.
18
+ *
19
+ * This module ENUMERATES. It does not decide what the gazetteer stores — see the candidate build for that, and note
20
+ * that a surface here is a NAME THE WORLD USES, never an authority's designation.
21
+ */
22
+ /**
23
+ * The locales whose display names are enumerated. Chosen for script coverage rather than speaker count: each entry
24
+ * either contributes a distinct script (Han simplified/traditional, Kana, Hangul, Arabic, Cyrillic, Devanagari, Hebrew,
25
+ * Greek, Thai) or a major Latin-script exonym set that diverges from English.
26
+ *
27
+ * Adding a locale is additive and safe — surfaces are deduplicated — but every addition grows the candidate table, so
28
+ * it earns its place by contributing surfaces a user would plausibly type.
29
+ */
30
+ export declare const DISPLAY_NAME_LOCALES: readonly ["en", "zh-Hans", "zh-Hant", "ja", "ko", "ar", "ru", "es", "fr", "de", "hi", "pt", "it", "nl", "pl", "tr", "vi", "th", "id", "fa", "he", "uk", "sv", "el"];
31
+ /**
32
+ * `long` is the ordinary name, `short` supplies the abbreviations people actually type (`UK`, `US`, `アメリカ`), and
33
+ * `narrow` occasionally differs again. All three are enumerated because the query register is whatever the user wrote.
34
+ */
35
+ export declare const DISPLAY_NAME_STYLES: readonly ["long", "short", "narrow"];
36
+ /**
37
+ * One country surface and where it came from.
38
+ */
39
+ export interface CountryDisplayName {
40
+ /**
41
+ * ISO 3166-1 alpha-2.
42
+ */
43
+ iso2: string;
44
+ /**
45
+ * The surface as ICU renders it, unmodified — normalisation is the consumer's job, and the raw form is what a
46
+ * provenance record needs to be auditable.
47
+ */
48
+ name: string;
49
+ /**
50
+ * BCP-47 tag this surface came from. Carried so a consumer can scope by locale rather than accepting every script for
51
+ * every query.
52
+ */
53
+ locale: string;
54
+ }
55
+ /**
56
+ * Enumerate every AA–ZZ code against the locale × style grid, keeping what ICU recognises.
57
+ *
58
+ * Deduplicated per (iso2, name): the same surface reached from several locales is one row, and the FIRST locale that
59
+ * produced it wins the attribution — deterministic because {@link DISPLAY_NAME_LOCALES} is ordered.
60
+ */
61
+ export declare function enumerateCountryDisplayNames(locales?: readonly string[]): Generator<CountryDisplayName>;
62
+ /**
63
+ * Every surface ICU knows for one country. Convenience over {@link enumerateCountryDisplayNames} for a single lookup;
64
+ * the generator is the bulk path.
65
+ */
66
+ export declare function countryDisplayNames(iso2: string, locales?: readonly string[]): string[];
67
+ //# sourceMappingURL=display-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-names.d.ts","sourceRoot":"","sources":["../../country/display-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,qKAyBvB,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,mBAAmB,sCAAuC,CAAA;AAEvE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAiBD;;;;;GAKG;AACH,wBAAiB,4BAA4B,CAC5C,OAAO,GAAE,SAAS,MAAM,EAAyB,GAC/C,SAAS,CAAC,kBAAkB,CAAC,CAiC/B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAIvF"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Country surface forms across scripts, enumerated from the RUNTIME's own ICU via `Intl.DisplayNames`.
7
+ *
8
+ * The gazetteer holds country names in English and little else, which is why a bare `格鲁吉亚` (Georgia the country,
9
+ * Chinese), `沙特阿拉伯` or `巴布亚新几内亚` resolves to nothing while `佐治亚州` (Georgia the US state) resolves
10
+ * correctly — the state is a real WOF record carrying multilingual names, and 140 of the 237 country rows are
11
+ * synthetic and carry only a canonical English name. Measured 2026-08-15; WOF has no Chinese country names at all,
12
+ * and `geonames-aliases.ts` filters every alias through a Latin-script regex.
13
+ *
14
+ * ICU already knows all of it. No download, no vendored corpus, no licence question, and no drift against a snapshot
15
+ * we would otherwise have to refresh: the names come from the same ICU the runtime uses for every other
16
+ * locale-sensitive operation. Measured coverage at time of writing: **280 regions, 5,244 distinct surfaces** across
17
+ * the locale × style grid below.
18
+ *
19
+ * This module ENUMERATES. It does not decide what the gazetteer stores — see the candidate build for that, and note
20
+ * that a surface here is a NAME THE WORLD USES, never an authority's designation.
21
+ */
22
+ /**
23
+ * The locales whose display names are enumerated. Chosen for script coverage rather than speaker count: each entry
24
+ * either contributes a distinct script (Han simplified/traditional, Kana, Hangul, Arabic, Cyrillic, Devanagari, Hebrew,
25
+ * Greek, Thai) or a major Latin-script exonym set that diverges from English.
26
+ *
27
+ * Adding a locale is additive and safe — surfaces are deduplicated — but every addition grows the candidate table, so
28
+ * it earns its place by contributing surfaces a user would plausibly type.
29
+ */
30
+ export const DISPLAY_NAME_LOCALES = [
31
+ "en",
32
+ "zh-Hans",
33
+ "zh-Hant",
34
+ "ja",
35
+ "ko",
36
+ "ar",
37
+ "ru",
38
+ "es",
39
+ "fr",
40
+ "de",
41
+ "hi",
42
+ "pt",
43
+ "it",
44
+ "nl",
45
+ "pl",
46
+ "tr",
47
+ "vi",
48
+ "th",
49
+ "id",
50
+ "fa",
51
+ "he",
52
+ "uk",
53
+ "sv",
54
+ "el",
55
+ ];
56
+ /**
57
+ * `long` is the ordinary name, `short` supplies the abbreviations people actually type (`UK`, `US`, `アメリカ`), and
58
+ * `narrow` occasionally differs again. All three are enumerated because the query register is whatever the user wrote.
59
+ */
60
+ export const DISPLAY_NAME_STYLES = ["long", "short", "narrow"];
61
+ /**
62
+ * Two-letter sequences that are not ISO 3166-1 regions. `Intl.DisplayNames.of` echoes its input for an unknown code, so
63
+ * the echo IS the miss signal — no separate region list to keep in sync.
64
+ */
65
+ /**
66
+ * The AA–ZZ sweep bounds. ISO 3166-1 alpha-2 is exactly two uppercase ASCII letters, so enumerating the whole square
67
+ * and keeping what ICU recognises avoids carrying a region list that would need its own upkeep.
68
+ */
69
+ const ASCII_A = 65;
70
+ const ASCII_Z = 90;
71
+ function isEcho(code, rendered) {
72
+ return !rendered || rendered === code;
73
+ }
74
+ /**
75
+ * Enumerate every AA–ZZ code against the locale × style grid, keeping what ICU recognises.
76
+ *
77
+ * Deduplicated per (iso2, name): the same surface reached from several locales is one row, and the FIRST locale that
78
+ * produced it wins the attribution — deterministic because {@link DISPLAY_NAME_LOCALES} is ordered.
79
+ */
80
+ export function* enumerateCountryDisplayNames(locales = DISPLAY_NAME_LOCALES) {
81
+ const formatters = locales.flatMap((locale) => DISPLAY_NAME_STYLES.map((style) => {
82
+ try {
83
+ return { locale, formatter: new Intl.DisplayNames([locale], { type: "region", style }) };
84
+ }
85
+ catch {
86
+ // A runtime without this locale's data degrades to fewer surfaces, never to an error.
87
+ return undefined;
88
+ }
89
+ }).filter((f) => f !== null && f !== undefined));
90
+ for (let a = ASCII_A; a <= ASCII_Z; a++) {
91
+ for (let b = ASCII_A; b <= ASCII_Z; b++) {
92
+ const iso2 = String.fromCharCode(a, b);
93
+ const seen = new Set();
94
+ for (const { locale, formatter } of formatters) {
95
+ let rendered;
96
+ try {
97
+ rendered = formatter.of(iso2);
98
+ }
99
+ catch {
100
+ continue;
101
+ }
102
+ if (isEcho(iso2, rendered) || seen.has(rendered))
103
+ continue;
104
+ seen.add(rendered);
105
+ yield { iso2, name: rendered, locale };
106
+ }
107
+ }
108
+ }
109
+ }
110
+ /**
111
+ * Every surface ICU knows for one country. Convenience over {@link enumerateCountryDisplayNames} for a single lookup;
112
+ * the generator is the bulk path.
113
+ */
114
+ export function countryDisplayNames(iso2, locales) {
115
+ const upper = iso2.toUpperCase();
116
+ return [...enumerateCountryDisplayNames(locales)].filter((n) => n.iso2 === upper).map((n) => n.name);
117
+ }
118
+ //# sourceMappingURL=display-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-names.js","sourceRoot":"","sources":["../../country/display-names.ts"],"names":[],"mappings":"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"}
@@ -7,8 +7,10 @@
7
7
  */
8
8
  export * from "./codes.ts";
9
9
  export * from "./country.ts";
10
+ export * from "./display-names.ts";
10
11
  export * from "./names.ts";
11
12
  export * from "./official-languages.ts";
13
+ export * from "./population.ts";
12
14
  export * from "./reference-data.ts";
13
15
  export * from "./reference.ts";
14
16
  export * from "./subdivision.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../country/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../country/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
@@ -7,8 +7,10 @@
7
7
  */
8
8
  export * from "./codes.js";
9
9
  export * from "./country.js";
10
+ export * from "./display-names.js";
10
11
  export * from "./names.js";
11
12
  export * from "./official-languages.js";
13
+ export * from "./population.js";
12
14
  export * from "./reference-data.js";
13
15
  export * from "./reference.js";
14
16
  export * from "./subdivision.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../country/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../country/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * GENERATED — do not edit by hand. Per-country population, derived from GeoNames countryInfo.txt
7
+ * (https://download.geonames.org/export/dump/countryInfo.txt, CC-BY-4.0). Estimates are
8
+ * census-vintage; a prominence race reads the magnitude, not the currency. Countries GeoNames
9
+ * declines to estimate are ABSENT, never zero.
10
+ * Regenerate with: mailwoman dev generate country-population
11
+ */
12
+ /**
13
+ * ISO 3166-1 alpha-2 → population estimate.
14
+ */
15
+ export declare const COUNTRY_POPULATION: Readonly<Record<string, number>>;
16
+ //# sourceMappingURL=population.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"population.d.ts","sourceRoot":"","sources":["../../country/population.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAyP/D,CAAA"}