@mailwoman/codex 9.1.0 → 9.3.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 (287) hide show
  1. package/README.md +51 -8
  2. package/{address-system-conventions.ts → lib/address-system-conventions.ts} +9 -9
  3. package/{au → lib/au}/index.ts +4 -4
  4. package/{ca → lib/ca}/index.ts +4 -4
  5. package/{ca → lib/ca}/postal-code.ts +12 -12
  6. package/{ca → lib/ca}/province.ts +1 -1
  7. package/{ca → lib/ca}/street-type.ts +10 -12
  8. package/{country → lib/country}/codes.ts +1 -1
  9. package/{country → lib/country}/country.ts +43 -14
  10. package/lib/country/display-names.ts +150 -0
  11. package/lib/country/index.ts +17 -0
  12. package/lib/country/population.ts +265 -0
  13. package/{country → lib/country}/reference.ts +2 -2
  14. package/{country → lib/country}/subdivision.ts +62 -3
  15. package/{de → lib/de}/index.ts +4 -4
  16. package/{de → lib/de}/postleitzahl.ts +3 -3
  17. package/{es → lib/es}/codigo-postal.ts +24 -6
  18. package/{es → lib/es}/index.ts +1 -1
  19. package/{fr → lib/fr}/cedex.ts +1 -1
  20. package/{fr → lib/fr}/code-postal.ts +8 -8
  21. package/{fr → lib/fr}/departement.ts +5 -2
  22. package/{fr → lib/fr}/index.ts +6 -6
  23. package/{fr → lib/fr}/region.ts +1 -1
  24. package/{fr → lib/fr}/voie.ts +5 -13
  25. package/{gb → lib/gb}/country.ts +2 -10
  26. package/{gb → lib/gb}/index.ts +4 -4
  27. package/{gb → lib/gb}/postcode-area.ts +1 -1
  28. package/{gb → lib/gb}/street-type.ts +1 -1
  29. package/{index.ts → lib/index.ts} +22 -12
  30. package/{it → lib/it}/cap.ts +23 -5
  31. package/{it → lib/it}/index.ts +1 -1
  32. package/{jp → lib/jp}/index.ts +4 -4
  33. package/{jp → lib/jp}/postal-code.ts +11 -11
  34. package/{jp → lib/jp}/prefecture.ts +7 -5
  35. package/{normalize.ts → lib/normalize.ts} +15 -1
  36. package/{nz → lib/nz}/delivery-service.ts +1 -1
  37. package/{nz → lib/nz}/index.ts +2 -2
  38. package/lib/postcode-systems.ts +198 -0
  39. package/{tools → lib/tools}/build-country-surface-lexicon.ts +10 -9
  40. package/{tools → lib/tools}/export-country-surfaces.ts +8 -8
  41. package/lib/tools/generate-country-population.ts +142 -0
  42. package/{tools → lib/tools}/generate-country-reference.ts +8 -7
  43. package/{tools → lib/tools}/generate-official-languages.ts +15 -13
  44. package/{tools → lib/tools}/index.ts +4 -4
  45. package/{us → lib/us}/index.ts +8 -8
  46. package/{us → lib/us}/po-box.ts +1 -1
  47. package/{us → lib/us}/street-directional.ts +2 -2
  48. package/{us → lib/us}/street-suffix.ts +1 -1
  49. package/{us → lib/us}/unit-designator.ts +1 -1
  50. package/{us → lib/us}/zipcode.ts +2 -2
  51. package/out/address-system-conventions.d.ts +1 -1
  52. package/out/address-system-conventions.d.ts.map +1 -1
  53. package/out/address-system-conventions.js +8 -8
  54. package/out/address-system-conventions.js.map +1 -1
  55. package/out/au/delivery-service.d.ts.map +1 -1
  56. package/out/au/delivery-service.js.map +1 -1
  57. package/out/au/index.d.ts +4 -4
  58. package/out/au/index.d.ts.map +1 -1
  59. package/out/au/index.js +4 -4
  60. package/out/au/index.js.map +1 -1
  61. package/out/au/level-designator.d.ts.map +1 -1
  62. package/out/au/level-designator.js.map +1 -1
  63. package/out/au/postcode.d.ts.map +1 -1
  64. package/out/au/postcode.js.map +1 -1
  65. package/out/au/state.d.ts.map +1 -1
  66. package/out/au/state.js.map +1 -1
  67. package/out/ca/index.d.ts +4 -4
  68. package/out/ca/index.d.ts.map +1 -1
  69. package/out/ca/index.js +4 -4
  70. package/out/ca/index.js.map +1 -1
  71. package/out/ca/postal-code.d.ts +11 -11
  72. package/out/ca/postal-code.d.ts.map +1 -1
  73. package/out/ca/postal-code.js +9 -9
  74. package/out/ca/postal-code.js.map +1 -1
  75. package/out/ca/province.d.ts.map +1 -1
  76. package/out/ca/province.js +1 -1
  77. package/out/ca/province.js.map +1 -1
  78. package/out/ca/street-type.d.ts.map +1 -1
  79. package/out/ca/street-type.js +9 -12
  80. package/out/ca/street-type.js.map +1 -1
  81. package/out/country/codes.d.ts.map +1 -1
  82. package/out/country/codes.js.map +1 -1
  83. package/out/country/country.d.ts +13 -11
  84. package/out/country/country.d.ts.map +1 -1
  85. package/out/country/country.js +35 -13
  86. package/out/country/country.js.map +1 -1
  87. package/out/country/display-names.d.ts +67 -0
  88. package/out/country/display-names.d.ts.map +1 -0
  89. package/out/country/display-names.js +118 -0
  90. package/out/country/display-names.js.map +1 -0
  91. package/out/country/index.d.ts +10 -8
  92. package/out/country/index.d.ts.map +1 -1
  93. package/out/country/index.js +10 -8
  94. package/out/country/index.js.map +1 -1
  95. package/out/country/names.d.ts.map +1 -1
  96. package/out/country/names.js.map +1 -1
  97. package/out/country/official-languages.d.ts.map +1 -1
  98. package/out/country/official-languages.js.map +1 -1
  99. package/out/country/population.d.ts +16 -0
  100. package/out/country/population.d.ts.map +1 -0
  101. package/out/country/population.js +265 -0
  102. package/out/country/population.js.map +1 -0
  103. package/out/country/reference-data.d.ts.map +1 -1
  104. package/out/country/reference-data.js.map +1 -1
  105. package/out/country/reference.d.ts +1 -1
  106. package/out/country/reference.d.ts.map +1 -1
  107. package/out/country/reference.js +2 -2
  108. package/out/country/reference.js.map +1 -1
  109. package/out/country/subdivision.d.ts +7 -0
  110. package/out/country/subdivision.d.ts.map +1 -1
  111. package/out/country/subdivision.js +52 -3
  112. package/out/country/subdivision.js.map +1 -1
  113. package/out/de/bundesland.d.ts.map +1 -1
  114. package/out/de/bundesland.js.map +1 -1
  115. package/out/de/index.d.ts +4 -4
  116. package/out/de/index.d.ts.map +1 -1
  117. package/out/de/index.js +4 -4
  118. package/out/de/index.js.map +1 -1
  119. package/out/de/postleitzahl.d.ts +3 -3
  120. package/out/de/postleitzahl.d.ts.map +1 -1
  121. package/out/de/postleitzahl.js +2 -2
  122. package/out/de/postleitzahl.js.map +1 -1
  123. package/out/de/street-type.d.ts.map +1 -1
  124. package/out/de/street-type.js.map +1 -1
  125. package/out/es/codigo-postal.d.ts +13 -2
  126. package/out/es/codigo-postal.d.ts.map +1 -1
  127. package/out/es/codigo-postal.js +21 -4
  128. package/out/es/codigo-postal.js.map +1 -1
  129. package/out/es/index.d.ts +1 -1
  130. package/out/es/index.d.ts.map +1 -1
  131. package/out/es/index.js +1 -1
  132. package/out/es/index.js.map +1 -1
  133. package/out/fr/cedex.d.ts +1 -1
  134. package/out/fr/cedex.d.ts.map +1 -1
  135. package/out/fr/cedex.js +1 -1
  136. package/out/fr/cedex.js.map +1 -1
  137. package/out/fr/code-postal.d.ts +7 -7
  138. package/out/fr/code-postal.d.ts.map +1 -1
  139. package/out/fr/code-postal.js +8 -8
  140. package/out/fr/code-postal.js.map +1 -1
  141. package/out/fr/departement.d.ts +2 -2
  142. package/out/fr/departement.d.ts.map +1 -1
  143. package/out/fr/departement.js +3 -0
  144. package/out/fr/departement.js.map +1 -1
  145. package/out/fr/index.d.ts +6 -6
  146. package/out/fr/index.d.ts.map +1 -1
  147. package/out/fr/index.js +6 -6
  148. package/out/fr/index.js.map +1 -1
  149. package/out/fr/region.d.ts.map +1 -1
  150. package/out/fr/region.js +1 -1
  151. package/out/fr/region.js.map +1 -1
  152. package/out/fr/voie.d.ts.map +1 -1
  153. package/out/fr/voie.js +4 -11
  154. package/out/fr/voie.js.map +1 -1
  155. package/out/gb/country.d.ts.map +1 -1
  156. package/out/gb/country.js +1 -9
  157. package/out/gb/country.js.map +1 -1
  158. package/out/gb/index.d.ts +4 -4
  159. package/out/gb/index.d.ts.map +1 -1
  160. package/out/gb/index.js +4 -4
  161. package/out/gb/index.js.map +1 -1
  162. package/out/gb/postcode-area.d.ts +1 -1
  163. package/out/gb/postcode-area.d.ts.map +1 -1
  164. package/out/gb/postcode-area.js.map +1 -1
  165. package/out/gb/postcode.d.ts.map +1 -1
  166. package/out/gb/postcode.js.map +1 -1
  167. package/out/gb/street-type.d.ts +1 -1
  168. package/out/gb/street-type.d.ts.map +1 -1
  169. package/out/gb/street-type.js +1 -1
  170. package/out/gb/street-type.js.map +1 -1
  171. package/out/index.d.ts +12 -12
  172. package/out/index.d.ts.map +1 -1
  173. package/out/index.js +12 -12
  174. package/out/index.js.map +1 -1
  175. package/out/it/cap.d.ts +13 -2
  176. package/out/it/cap.d.ts.map +1 -1
  177. package/out/it/cap.js +20 -3
  178. package/out/it/cap.js.map +1 -1
  179. package/out/it/index.d.ts +1 -1
  180. package/out/it/index.d.ts.map +1 -1
  181. package/out/it/index.js +1 -1
  182. package/out/it/index.js.map +1 -1
  183. package/out/jp/address-unit.d.ts.map +1 -1
  184. package/out/jp/address-unit.js.map +1 -1
  185. package/out/jp/index.d.ts +4 -4
  186. package/out/jp/index.d.ts.map +1 -1
  187. package/out/jp/index.js +4 -4
  188. package/out/jp/index.js.map +1 -1
  189. package/out/jp/postal-code.d.ts +11 -11
  190. package/out/jp/postal-code.d.ts.map +1 -1
  191. package/out/jp/postal-code.js +8 -8
  192. package/out/jp/postal-code.js.map +1 -1
  193. package/out/jp/prefecture.d.ts +4 -1
  194. package/out/jp/prefecture.d.ts.map +1 -1
  195. package/out/jp/prefecture.js +6 -5
  196. package/out/jp/prefecture.js.map +1 -1
  197. package/out/level-semantics.d.ts.map +1 -1
  198. package/out/level-semantics.js.map +1 -1
  199. package/out/normalize.d.ts +8 -0
  200. package/out/normalize.d.ts.map +1 -1
  201. package/out/normalize.js +14 -1
  202. package/out/normalize.js.map +1 -1
  203. package/out/nz/delivery-service.d.ts +1 -1
  204. package/out/nz/delivery-service.d.ts.map +1 -1
  205. package/out/nz/delivery-service.js +1 -1
  206. package/out/nz/delivery-service.js.map +1 -1
  207. package/out/nz/index.d.ts +2 -2
  208. package/out/nz/index.d.ts.map +1 -1
  209. package/out/nz/index.js +2 -2
  210. package/out/nz/index.js.map +1 -1
  211. package/out/nz/postcode.d.ts.map +1 -1
  212. package/out/nz/postcode.js.map +1 -1
  213. package/out/postcode-systems.d.ts +99 -4
  214. package/out/postcode-systems.d.ts.map +1 -1
  215. package/out/postcode-systems.js +132 -11
  216. package/out/postcode-systems.js.map +1 -1
  217. package/out/tools/build-country-surface-lexicon.d.ts +1 -1
  218. package/out/tools/build-country-surface-lexicon.d.ts.map +1 -1
  219. package/out/tools/build-country-surface-lexicon.js +10 -9
  220. package/out/tools/build-country-surface-lexicon.js.map +1 -1
  221. package/out/tools/export-country-surfaces.d.ts +1 -1
  222. package/out/tools/export-country-surfaces.d.ts.map +1 -1
  223. package/out/tools/export-country-surfaces.js +7 -7
  224. package/out/tools/export-country-surfaces.js.map +1 -1
  225. package/out/tools/generate-country-population.d.ts +42 -0
  226. package/out/tools/generate-country-population.d.ts.map +1 -0
  227. package/out/tools/generate-country-population.js +106 -0
  228. package/out/tools/generate-country-population.js.map +1 -0
  229. package/out/tools/generate-country-reference.d.ts.map +1 -1
  230. package/out/tools/generate-country-reference.js +8 -8
  231. package/out/tools/generate-country-reference.js.map +1 -1
  232. package/out/tools/generate-official-languages.d.ts.map +1 -1
  233. package/out/tools/generate-official-languages.js +14 -11
  234. package/out/tools/generate-official-languages.js.map +1 -1
  235. package/out/tools/index.d.ts +4 -4
  236. package/out/tools/index.d.ts.map +1 -1
  237. package/out/tools/index.js +4 -4
  238. package/out/tools/index.js.map +1 -1
  239. package/out/us/floor-designator.d.ts.map +1 -1
  240. package/out/us/floor-designator.js.map +1 -1
  241. package/out/us/index.d.ts +8 -8
  242. package/out/us/index.d.ts.map +1 -1
  243. package/out/us/index.js +8 -8
  244. package/out/us/index.js.map +1 -1
  245. package/out/us/military-address.d.ts.map +1 -1
  246. package/out/us/military-address.js.map +1 -1
  247. package/out/us/po-box.d.ts +1 -1
  248. package/out/us/po-box.d.ts.map +1 -1
  249. package/out/us/po-box.js +1 -1
  250. package/out/us/po-box.js.map +1 -1
  251. package/out/us/state.d.ts.map +1 -1
  252. package/out/us/state.js.map +1 -1
  253. package/out/us/street-directional.d.ts.map +1 -1
  254. package/out/us/street-directional.js +2 -2
  255. package/out/us/street-directional.js.map +1 -1
  256. package/out/us/street-suffix.d.ts +1 -1
  257. package/out/us/street-suffix.d.ts.map +1 -1
  258. package/out/us/street-suffix.js +1 -1
  259. package/out/us/street-suffix.js.map +1 -1
  260. package/out/us/unit-designator.d.ts +1 -1
  261. package/out/us/unit-designator.d.ts.map +1 -1
  262. package/out/us/unit-designator.js +1 -1
  263. package/out/us/unit-designator.js.map +1 -1
  264. package/out/us/zipcode.d.ts +2 -2
  265. package/out/us/zipcode.d.ts.map +1 -1
  266. package/out/us/zipcode.js +2 -2
  267. package/out/us/zipcode.js.map +1 -1
  268. package/package.json +129 -6
  269. package/country/index.ts +0 -15
  270. package/postcode-systems.ts +0 -70
  271. /package/{au → lib/au}/delivery-service.ts +0 -0
  272. /package/{au → lib/au}/level-designator.ts +0 -0
  273. /package/{au → lib/au}/postcode.ts +0 -0
  274. /package/{au → lib/au}/state.ts +0 -0
  275. /package/{country → lib/country}/names.ts +0 -0
  276. /package/{country → lib/country}/official-languages.ts +0 -0
  277. /package/{country → lib/country}/reference-data.ts +0 -0
  278. /package/{de → lib/de}/bundesland.ts +0 -0
  279. /package/{de → lib/de}/street-type.ts +0 -0
  280. /package/{gb → lib/gb}/postcode.ts +0 -0
  281. /package/{jp → lib/jp}/address-unit.ts +0 -0
  282. /package/{level-semantics.ts → lib/level-semantics.ts} +0 -0
  283. /package/{nz → lib/nz}/postcode.ts +0 -0
  284. /package/{us → lib/us}/floor-designator.ts +0 -0
  285. /package/{us → lib/us}/military-address.ts +0 -0
  286. /package/{us → lib/us}/state.ts +0 -0
  287. /package/{us → lib/us}/street-suffix.json +0 -0
@@ -0,0 +1,265 @@
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
+ /**
14
+ * ISO 3166-1 alpha-2 → population estimate.
15
+ */
16
+ export const COUNTRY_POPULATION: Readonly<Record<string, number>> = {
17
+ AD: 77_006,
18
+ AE: 9_630_959,
19
+ AF: 37_172_386,
20
+ AG: 96_286,
21
+ AI: 13_254,
22
+ AL: 2_866_376,
23
+ AM: 3_090_500,
24
+ AN: 300_000,
25
+ AO: 30_809_762,
26
+ AR: 44_494_502,
27
+ AS: 55_465,
28
+ AT: 8_847_037,
29
+ AU: 24_992_369,
30
+ AW: 105_845,
31
+ AX: 26_711,
32
+ AZ: 10_224_900,
33
+ BA: 3_323_929,
34
+ BB: 286_641,
35
+ BD: 161_356_039,
36
+ BE: 11_422_068,
37
+ BF: 19_751_535,
38
+ BG: 7_000_039,
39
+ BH: 1_569_439,
40
+ BI: 11_175_378,
41
+ BJ: 11_485_048,
42
+ BL: 8450,
43
+ BM: 63_968,
44
+ BN: 428_962,
45
+ BO: 11_353_142,
46
+ BQ: 18_012,
47
+ BR: 209_469_333,
48
+ BS: 385_640,
49
+ BT: 754_394,
50
+ BW: 2_254_126,
51
+ BY: 9_485_386,
52
+ BZ: 383_071,
53
+ CA: 37_058_856,
54
+ CC: 628,
55
+ CD: 84_068_091,
56
+ CF: 4_666_377,
57
+ CG: 5_244_363,
58
+ CH: 8_516_543,
59
+ CI: 25_069_229,
60
+ CK: 21_388,
61
+ CL: 18_729_160,
62
+ CM: 25_216_237,
63
+ CN: 1_411_778_724,
64
+ CO: 49_648_685,
65
+ CR: 4_999_441,
66
+ CS: 10_829_175,
67
+ CU: 11_338_138,
68
+ CV: 543_767,
69
+ CW: 159_849,
70
+ CX: 1500,
71
+ CY: 1_189_265,
72
+ CZ: 10_625_695,
73
+ DE: 82_927_922,
74
+ DJ: 958_920,
75
+ DK: 5_797_446,
76
+ DM: 71_625,
77
+ DO: 10_627_165,
78
+ DZ: 42_228_429,
79
+ EC: 17_084_357,
80
+ EE: 1_320_884,
81
+ EG: 98_423_595,
82
+ EH: 273_008,
83
+ ER: 6_209_262,
84
+ ES: 46_723_749,
85
+ ET: 109_224_559,
86
+ FI: 5_518_050,
87
+ FJ: 883_483,
88
+ FK: 2638,
89
+ FM: 112_640,
90
+ FO: 48_497,
91
+ FR: 66_987_244,
92
+ GA: 2_119_275,
93
+ GB: 66_488_991,
94
+ GD: 111_454,
95
+ GE: 3_704_500,
96
+ GF: 195_506,
97
+ GG: 65_228,
98
+ GH: 29_767_108,
99
+ GI: 33_718,
100
+ GL: 56_025,
101
+ GM: 2_280_102,
102
+ GN: 12_414_318,
103
+ GP: 443_000,
104
+ GQ: 1_308_974,
105
+ GR: 10_727_668,
106
+ GS: 30,
107
+ GT: 17_247_807,
108
+ GU: 165_768,
109
+ GW: 1_874_309,
110
+ GY: 779_004,
111
+ HK: 7_396_076,
112
+ HN: 9_587_522,
113
+ HR: 3_871_833,
114
+ HT: 11_123_176,
115
+ HU: 9_768_785,
116
+ ID: 267_663_435,
117
+ IE: 4_853_506,
118
+ IL: 8_883_800,
119
+ IM: 84_077,
120
+ IN: 1_352_617_328,
121
+ IO: 4000,
122
+ IQ: 38_433_600,
123
+ IR: 81_800_269,
124
+ IS: 353_574,
125
+ IT: 60_431_283,
126
+ JE: 90_812,
127
+ JM: 2_934_855,
128
+ JO: 9_956_011,
129
+ JP: 126_529_100,
130
+ KE: 51_393_010,
131
+ KG: 6_315_800,
132
+ KH: 16_249_798,
133
+ KI: 115_847,
134
+ KM: 832_322,
135
+ KN: 52_441,
136
+ KP: 25_549_819,
137
+ KR: 51_635_256,
138
+ KW: 4_137_309,
139
+ KY: 64_174,
140
+ KZ: 18_276_499,
141
+ LA: 7_061_507,
142
+ LB: 6_848_925,
143
+ LC: 181_889,
144
+ LI: 37_910,
145
+ LK: 21_670_000,
146
+ LR: 4_818_977,
147
+ LS: 2_108_132,
148
+ LT: 2_789_533,
149
+ LU: 607_728,
150
+ LV: 1_926_542,
151
+ LY: 6_678_567,
152
+ MA: 36_029_138,
153
+ MC: 38_682,
154
+ MD: 3_545_883,
155
+ ME: 622_345,
156
+ MF: 37_264,
157
+ MG: 26_262_368,
158
+ MH: 58_413,
159
+ MK: 2_082_958,
160
+ ML: 19_077_690,
161
+ MM: 53_708_395,
162
+ MN: 3_170_208,
163
+ MO: 631_636,
164
+ MP: 56_882,
165
+ MQ: 432_900,
166
+ MR: 4_403_319,
167
+ MS: 9341,
168
+ MT: 483_530,
169
+ MU: 1_265_303,
170
+ MV: 515_696,
171
+ MW: 17_563_749,
172
+ MX: 126_190_788,
173
+ MY: 31_528_585,
174
+ MZ: 29_495_962,
175
+ NA: 2_448_255,
176
+ NC: 284_060,
177
+ NE: 22_442_948,
178
+ NF: 1828,
179
+ NG: 195_874_740,
180
+ NI: 6_465_513,
181
+ NL: 17_231_017,
182
+ NO: 5_314_336,
183
+ NP: 28_087_871,
184
+ NR: 12_704,
185
+ NU: 2166,
186
+ NZ: 4_885_500,
187
+ OM: 4_829_483,
188
+ PA: 4_176_873,
189
+ PE: 31_989_256,
190
+ PF: 277_679,
191
+ PG: 8_606_316,
192
+ PH: 106_651_922,
193
+ PK: 212_215_030,
194
+ PL: 37_978_548,
195
+ PM: 7012,
196
+ PN: 46,
197
+ PR: 3_195_153,
198
+ PS: 4_569_087,
199
+ PT: 10_281_762,
200
+ PW: 17_907,
201
+ PY: 6_956_071,
202
+ QA: 2_781_677,
203
+ RE: 776_948,
204
+ RO: 19_473_936,
205
+ RS: 6_982_084,
206
+ RU: 144_478_050,
207
+ RW: 12_301_939,
208
+ SA: 33_699_947,
209
+ SB: 652_858,
210
+ SC: 96_762,
211
+ SD: 41_801_533,
212
+ SE: 10_183_175,
213
+ SG: 5_638_676,
214
+ SH: 7460,
215
+ SI: 2_067_372,
216
+ SJ: 2550,
217
+ SK: 5_447_011,
218
+ SL: 7_650_154,
219
+ SM: 33_785,
220
+ SN: 15_854_360,
221
+ SO: 15_008_154,
222
+ SR: 575_991,
223
+ SS: 8_260_490,
224
+ ST: 197_700,
225
+ SV: 6_420_744,
226
+ SX: 40_654,
227
+ SY: 16_906_283,
228
+ SZ: 1_136_191,
229
+ TC: 37_665,
230
+ TD: 15_477_751,
231
+ TF: 140,
232
+ TG: 7_889_094,
233
+ TH: 69_428_524,
234
+ TJ: 9_100_837,
235
+ TK: 1466,
236
+ TL: 1_267_972,
237
+ TM: 5_850_908,
238
+ TN: 11_565_204,
239
+ TO: 103_197,
240
+ TR: 82_319_724,
241
+ TT: 1_389_858,
242
+ TV: 11_508,
243
+ TW: 23_451_837,
244
+ TZ: 56_318_348,
245
+ UA: 40_000_000,
246
+ UG: 42_723_139,
247
+ US: 327_167_434,
248
+ UY: 3_449_299,
249
+ UZ: 32_955_400,
250
+ VA: 921,
251
+ VC: 110_211,
252
+ VE: 28_870_195,
253
+ VG: 29_802,
254
+ VI: 106_977,
255
+ VN: 95_540_395,
256
+ VU: 292_680,
257
+ WF: 16_025,
258
+ WS: 196_130,
259
+ XK: 1_845_300,
260
+ YE: 28_498_687,
261
+ YT: 279_471,
262
+ ZA: 57_779_622,
263
+ ZM: 17_351_822,
264
+ ZW: 16_868_409,
265
+ }
@@ -6,12 +6,12 @@
6
6
  * Country-reference annotators. The flag emoji is a pure function of the ISO 3166-1 alpha-2 code
7
7
  * (two Regional Indicator Symbols); calling code + currency come from {@link COUNTRY_REFERENCE}, a
8
8
  * table generated from mledoze/countries (provenance-tracked, not hand-typed — the
9
- * no-load-bearing-trivia rule).
9
+ * no-irrelevant-trivia rule).
10
10
  */
11
11
 
12
12
  import type { AnnotationSet, Annotator } from "@mailwoman/annotations"
13
13
 
14
- import { COUNTRY_REFERENCE } from "./reference-data.ts"
14
+ import { COUNTRY_REFERENCE } from "#country/reference-data"
15
15
 
16
16
  const REGIONAL_INDICATOR_BASE = 0x1_f1_e6
17
17
  const A_UPPER = "A".charCodeAt(0)
@@ -26,9 +26,10 @@
26
26
  * re-keys those two existing tables into one subdivision→country view.
27
27
  */
28
28
 
29
- import { CA_PROVINCES } from "../ca/province.ts"
30
- import { foldName } from "../normalize.ts"
31
- import { US_STATE_BY_ABBREVIATION } from "../us/state.ts"
29
+ import { AU_STATE_ABBREVIATIONS } from "#au/state"
30
+ import { CA_PROVINCES } from "#ca/province"
31
+ import { foldName } from "#normalize"
32
+ import { US_STATE_BY_ABBREVIATION } from "#us/state"
32
33
 
33
34
  /**
34
35
  * A resolved subdivision: its ISO 3166-2 code (sans country prefix), canonical English name, and ISO 3166-1 country.
@@ -91,3 +92,61 @@ export function matchSubdivision(token: string | null | undefined): SubdivisionM
91
92
 
92
93
  return SUBDIVISION_LOOKUP.get(foldName(token)) ?? null
93
94
  }
95
+
96
+ /**
97
+ * Per-country subdivision lookups for callers that already KNOW the country. Kept separate from
98
+ * {@link SUBDIVISION_LOOKUP} on purpose: the combined map is only unambiguous because the US and CA sets are disjoint,
99
+ * and Australia breaks that property twice — `WA` collides with Washington and `NT` with the Northwest Territories. A
100
+ * country-scoped caller (the admin-coherence check reads the winner's resolver-stamped country) dissolves the collision
101
+ * instead of arbitrating it.
102
+ */
103
+ const SCOPED_SUBDIVISION_LOOKUP: ReadonlyMap<string, ReadonlyMap<string, SubdivisionMatch>> = (() => {
104
+ const byCountry = new Map<string, Map<string, SubdivisionMatch>>()
105
+
106
+ const put = (country: string, key: string, match: SubdivisionMatch): void => {
107
+ const folded = foldName(key)
108
+
109
+ if (!folded.length) return
110
+
111
+ const scoped = byCountry.get(country) ?? new Map<string, SubdivisionMatch>()
112
+
113
+ byCountry.set(country, scoped)
114
+
115
+ if (!scoped.has(folded)) {
116
+ scoped.set(folded, match)
117
+ }
118
+ }
119
+
120
+ for (const [code, name] of Object.entries(US_STATE_BY_ABBREVIATION)) {
121
+ const match: SubdivisionMatch = { code, name, country: "US" }
122
+ put("US", code, match)
123
+ put("US", name, match)
124
+ }
125
+
126
+ for (const info of Object.values(CA_PROVINCES)) {
127
+ const match: SubdivisionMatch = { code: info.code, name: info.name, country: "CA" }
128
+ put("CA", info.code, match)
129
+ put("CA", info.name, match)
130
+ put("CA", info.french, match)
131
+ }
132
+
133
+ for (const [code, name] of Object.entries(AU_STATE_ABBREVIATIONS)) {
134
+ const match: SubdivisionMatch = { code, name, country: "AU" }
135
+ put("AU", code, match)
136
+ put("AU", name, match)
137
+ }
138
+
139
+ return byCountry
140
+ })()
141
+
142
+ /**
143
+ * Resolve a subdivision surface form WITHIN one country. Same folding and return shape as {@link matchSubdivision}, but
144
+ * scoped: `WA` under `AU` is Western Australia, under `US` Washington, and under any other country null. Use this
145
+ * whenever the country is already established; the unscoped lookup exists for the address-line case where the
146
+ * subdivision itself is the country evidence.
147
+ */
148
+ export function matchSubdivisionIn(countryAlpha2: string, token: string | null | undefined): SubdivisionMatch | null {
149
+ if (!token || typeof token !== "string") return null
150
+
151
+ return SCOPED_SUBDIVISION_LOOKUP.get(countryAlpha2.toUpperCase())?.get(foldName(token)) ?? null
152
+ }
@@ -3,10 +3,10 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The German address system (Deutsche Post / ISO 3166-2:DE): street types, postal codes
6
+ * The German address system (Deutsche Post / ISO 3166-2:DE): street types, postcodes
7
7
  * (Postleitzahl), and the federal states (Bundesländer).
8
8
  */
9
9
 
10
- export * from "./bundesland.ts"
11
- export * from "./postleitzahl.ts"
12
- export * from "./street-type.ts"
10
+ export * from "#de/bundesland"
11
+ export * from "#de/postleitzahl"
12
+ export * from "#de/street-type"
@@ -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
@@ -32,20 +32,38 @@ export type CodigoPostal = Tagged<string, "CodigoPostal">
32
32
  export const CODIGO_POSTAL_PATTERN = /^\d{5}$/
33
33
 
34
34
  /**
35
- * Narrow a string to a {@link CodigoPostal}, or `null` when it is not one.
35
+ * Normalize a código-postal surface form to the bare five digits: trim surrounding whitespace (`" 28001 "` →
36
+ * `"28001"`). Returns null when the result is not a five-digit code.
36
37
  */
37
- export function parseCodigoPostal(input: string): CodigoPostal | null {
38
- const s = input.trim()
38
+ export function normalizeCodigoPostal(raw: unknown): CodigoPostal | null {
39
+ if (typeof raw !== "string") return null
40
+ const s = raw.trim()
39
41
 
40
42
  return CODIGO_POSTAL_PATTERN.test(s) ? (s as CodigoPostal) : null
41
43
  }
42
44
 
45
+ /**
46
+ * Type-predicate for a (normalized) Spanish código postal.
47
+ */
48
+ export function isCodigoPostal(input: unknown): input is CodigoPostal {
49
+ return typeof input === "string" && CODIGO_POSTAL_PATTERN.test(input)
50
+ }
51
+
52
+ /**
53
+ * Narrow a string to a {@link CodigoPostal}, or `null` when it is not one.
54
+ *
55
+ * @deprecated Use {@link normalizeCodigoPostal}.
56
+ */
57
+ export function parseCodigoPostal(input: string): CodigoPostal | null {
58
+ return normalizeCodigoPostal(input)
59
+ }
60
+
43
61
  /**
44
62
  * The two-digit province prefix (`"28001"` → `"28"`), or `null` for a non-postcode. Callers map it through their own
45
63
  * province table; this module deliberately does not ship one, since the campaign that needed it only needs the shape.
46
64
  */
47
65
  export function codigoPostalProvincePrefix(input: string): string | null {
48
- const code = parseCodigoPostal(input)
66
+ const code = normalizeCodigoPostal(input)
49
67
 
50
68
  return code ? code.slice(0, 2) : null
51
69
  }
@@ -6,4 +6,4 @@
6
6
  * Spanish (ES) address-system reference data.
7
7
  */
8
8
 
9
- export * from "./codigo-postal.ts"
9
+ export * from "#es/codigo-postal"
@@ -9,7 +9,7 @@
9
9
  * optionally followed by a 1–2 digit office number. The component is the `CEDEX [NN]` phrase
10
10
  * itself (the schema's `cedex` tag); the preceding postcode/locality keep their own tags.
11
11
  *
12
- * This slice closes the gap PR #516 documented: the shard builder sourced the shape from SCHEMA.mdx
12
+ * This slice closes the gap PR #516 documented: the extract builder sourced the shape from SCHEMA.mdx
13
13
  * prose because codex had no cedex home. Now it does — the builder and any future consumer import
14
14
  * from here (the provenance-first discipline: one provenanced source).
15
15
  */
@@ -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
  *
@@ -26,11 +26,11 @@
26
26
 
27
27
  import type { Tagged } from "type-fest"
28
28
 
29
- import { departementInfo, type DepartementCode, type DepartementInfo } from "./departement.ts"
30
- import { FR_REGIONS, type FrenchRegionInfo } from "./region.ts"
29
+ import { departementInfo, type DepartementCode, type DepartementInfo } from "#fr/departement"
30
+ import { FR_REGIONS, type FrenchRegionInfo } from "#fr/region"
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)
@@ -11,7 +11,7 @@
11
11
  * département. This table is therefore the hinge between `code-postal.ts` and `region.ts`.
12
12
  */
13
13
 
14
- import type { FrenchRegionCode } from "./region.ts"
14
+ import type { FrenchRegionCode } from "#fr/region"
15
15
 
16
16
  /**
17
17
  * Per-département record: code (2-digit, or `2A`/`2B`, or 3-digit DOM) + name + its région.
@@ -146,7 +146,10 @@ export type DepartementCode = keyof typeof FR_DEPARTEMENTS
146
146
  /**
147
147
  * Look up a département by code (case-insensitive for the Corsica `2A`/`2B` letters); null if unknown.
148
148
  */
149
- export function departementInfo(code: string | null | undefined): DepartementInfo | null {
149
+ // `unknown`, not `string | null | undefined`: this function's whole job is to answer null for anything that is not a
150
+ // departement code, and its callers hand it values off a CSV row or a JSON body. A narrower parameter did not make
151
+ // those callers safer — it made the test that proves the guard work assert its way past the signature.
152
+ export function departementInfo(code: unknown): DepartementInfo | null {
150
153
  if (!code || typeof code !== "string") return null
151
154
  const key = code.trim().toUpperCase()
152
155
 
@@ -3,12 +3,12 @@
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
 
10
- export * from "./cedex.ts"
11
- export * from "./code-postal.ts"
12
- export * from "./departement.ts"
13
- export * from "./region.ts"
14
- export * from "./voie.ts"
10
+ export * from "#fr/cedex"
11
+ export * from "#fr/code-postal"
12
+ export * from "#fr/departement"
13
+ export * from "#fr/region"
14
+ export * from "#fr/voie"
@@ -13,7 +13,7 @@
13
13
  * `code-postal.ts`).
14
14
  */
15
15
 
16
- import { foldName } from "../normalize.ts"
16
+ import { foldName } from "#normalize"
17
17
 
18
18
  /**
19
19
  * Per-region record: ISO 3166-2:FR code (sans `FR-` prefix) + French name.
@@ -17,6 +17,8 @@
17
17
  * {@link isFrenchStreetWord} matches a whole token rather than a suffix.
18
18
  */
19
19
 
20
+ import { foldToken } from "#normalize"
21
+
20
22
  /**
21
23
  * Canonical French voie type → common written abbreviations. The leading word of a French street name. The first entry
22
24
  * of each list is the most common abbreviation where one exists.
@@ -65,19 +67,13 @@ export type FrenchVoieType = keyof typeof FR_VOIE_TYPES
65
67
  * matching. `Allée`/`allee`/`all` all resolve here.
66
68
  */
67
69
  const VOIE_TOKEN_SET: ReadonlySet<string> = (() => {
68
- const fold = (s: string): string =>
69
- s
70
- .toLowerCase()
71
- .normalize("NFD")
72
- .replaceAll(/[\u0300-\u036F]/g, "")
73
-
74
70
  const out = new Set<string>()
75
71
 
76
72
  for (const canonical of Object.keys(FR_VOIE_TYPES) as FrenchVoieType[]) {
77
- out.add(fold(canonical))
73
+ out.add(foldToken(canonical))
78
74
 
79
75
  for (const abbr of FR_VOIE_TYPES[canonical]) {
80
- out.add(fold(abbr))
76
+ out.add(foldToken(abbr))
81
77
  }
82
78
  }
83
79
 
@@ -92,11 +88,7 @@ const VOIE_TOKEN_SET: ReadonlySet<string> = (() => {
92
88
  export function isFrenchStreetWord(token: unknown): boolean {
93
89
  if (typeof token !== "string") return false
94
90
 
95
- const t = token
96
- .toLowerCase()
97
- .normalize("NFD")
98
- .replaceAll(/[\u0300-\u036F]/g, "")
99
- .replaceAll(/[^a-z-]/g, "")
91
+ const t = foldToken(token).replaceAll(/[^a-z-]/g, "")
100
92
 
101
93
  return t.length > 0 && VOIE_TOKEN_SET.has(t)
102
94
  }
@@ -14,6 +14,8 @@
14
14
  * postcode is the thing that actually carries the geography.
15
15
  */
16
16
 
17
+ import { foldName } from "#normalize"
18
+
17
19
  /**
18
20
  * Per-country record: ISO 3166-2:GB code (sans `GB-` prefix) + English name.
19
21
  */
@@ -52,16 +54,6 @@ export function isUkCountryCode(input: unknown): input is UkCountryCode {
52
54
  return typeof input === "string" && COUNTRY_CODE_SET.has(input.toUpperCase())
53
55
  }
54
56
 
55
- /**
56
- * Lowercase + collapse non-alphanumerics so `Northern Ireland`, `northern-ireland` key alike.
57
- */
58
- function foldName(s: string): string {
59
- return s
60
- .toLowerCase()
61
- .replaceAll(/[^a-z0-9]+/g, " ")
62
- .trim()
63
- }
64
-
65
57
  /**
66
58
  * Folded country name / code → ISO 3166-2:GB code, so a surface form maps regardless of casing.
67
59
  */
@@ -8,7 +8,7 @@
8
8
  * vocabulary.
9
9
  */
10
10
 
11
- export * from "./country.ts"
12
- export * from "./postcode-area.ts"
13
- export * from "./postcode.ts"
14
- export * from "./street-type.ts"
11
+ export * from "#gb/country"
12
+ export * from "#gb/postcode-area"
13
+ export * from "#gb/postcode"
14
+ export * from "#gb/street-type"
@@ -22,7 +22,7 @@
22
22
  * a UK postcode is not a county.
23
23
  */
24
24
 
25
- import type { UkCountryCode } from "./country.ts"
25
+ import type { UkCountryCode } from "#gb/country"
26
26
 
27
27
  /**
28
28
  * Northern Ireland is a single postcode area: BT (Belfast).
@@ -51,7 +51,7 @@ export const GB_STREET_TYPES = [
51
51
  "vale",
52
52
  "wharf",
53
53
  "yard",
54
- "gate",
54
+ "check",
55
55
  "croft",
56
56
  "dene",
57
57
  "end",