@mailwoman/codex 9.3.0 → 10.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 (223) hide show
  1. package/README.md +221 -75
  2. package/lib/address/format.ts +144 -0
  3. package/lib/address/key.ts +134 -0
  4. package/lib/address/layout.ts +189 -0
  5. package/lib/address/layouts/generated.ts +1576 -0
  6. package/lib/address/layouts/index.ts +213 -0
  7. package/lib/address/render.ts +176 -0
  8. package/lib/{address-system-conventions.ts → address/system-conventions.ts} +6 -5
  9. package/lib/component.ts +96 -0
  10. package/lib/country/index.ts +3 -2
  11. package/lib/country/{reference.ts → reference/index.ts} +1 -1
  12. package/lib/country/region-languages.ts +46 -0
  13. package/lib/es/co-official-languages.ts +62 -0
  14. package/lib/es/index.ts +1 -0
  15. package/lib/gb/index.ts +2 -2
  16. package/lib/index.ts +4 -2
  17. package/lib/jp/index.ts +1 -0
  18. package/lib/jp/municipality-register.ts +62 -0
  19. package/lib/kr/index.ts +10 -0
  20. package/lib/kr/sigungu-register.ts +294 -0
  21. package/lib/placetype-map.ts +157 -0
  22. package/lib/postcode/shapes.json +80 -0
  23. package/lib/postcode/shapes.ts +56 -0
  24. package/lib/{postcode-systems.ts → postcode/systems.ts} +8 -1
  25. package/lib/register-completion.ts +24 -0
  26. package/lib/us/index.ts +2 -2
  27. package/lib/us/po-box.ts +37 -10
  28. package/lib/us/{street-directional.ts → street/directional.ts} +1 -1
  29. package/lib/us/{street-suffix.ts → street/suffix.ts} +1 -1
  30. package/out/address/format.d.ts +87 -0
  31. package/out/address/format.d.ts.map +1 -0
  32. package/out/address/format.js +85 -0
  33. package/out/address/format.js.map +1 -0
  34. package/out/address/key.d.ts +67 -0
  35. package/out/address/key.d.ts.map +1 -0
  36. package/out/address/key.js +91 -0
  37. package/out/address/key.js.map +1 -0
  38. package/out/address/layout.d.ts +104 -0
  39. package/out/address/layout.d.ts.map +1 -0
  40. package/out/address/layout.js +123 -0
  41. package/out/address/layout.js.map +1 -0
  42. package/out/address/layouts/generated.d.ts +21 -0
  43. package/out/address/layouts/generated.d.ts.map +1 -0
  44. package/out/address/layouts/generated.js +1380 -0
  45. package/out/address/layouts/generated.js.map +1 -0
  46. package/out/address/layouts/index.d.ts +81 -0
  47. package/out/address/layouts/index.d.ts.map +1 -0
  48. package/out/address/layouts/index.js +184 -0
  49. package/out/address/layouts/index.js.map +1 -0
  50. package/out/address/render.d.ts +64 -0
  51. package/out/address/render.d.ts.map +1 -0
  52. package/out/address/render.js +115 -0
  53. package/out/address/render.js.map +1 -0
  54. package/out/{address-system-conventions.d.ts → address/system-conventions.d.ts} +6 -5
  55. package/out/address/system-conventions.d.ts.map +1 -0
  56. package/out/{address-system-conventions.js → address/system-conventions.js} +2 -2
  57. package/out/address/system-conventions.js.map +1 -0
  58. package/out/au/delivery-service.d.ts.map +1 -1
  59. package/out/au/level-designator.d.ts.map +1 -1
  60. package/out/au/state.d.ts.map +1 -1
  61. package/out/ca/province.d.ts.map +1 -1
  62. package/out/component.d.ts +50 -0
  63. package/out/component.d.ts.map +1 -0
  64. package/out/component.js +84 -0
  65. package/out/component.js.map +1 -0
  66. package/out/country/codes.d.ts +2 -2
  67. package/out/country/codes.d.ts.map +1 -1
  68. package/out/country/display-names.d.ts.map +1 -1
  69. package/out/country/display-names.js.map +1 -1
  70. package/out/country/index.d.ts +3 -2
  71. package/out/country/index.d.ts.map +1 -1
  72. package/out/country/index.js +3 -2
  73. package/out/country/index.js.map +1 -1
  74. package/out/country/{reference-data.d.ts → reference/data.d.ts} +1 -1
  75. package/out/country/reference/data.d.ts.map +1 -0
  76. package/out/country/{reference-data.js → reference/data.js} +1 -1
  77. package/out/country/reference/data.js.map +1 -0
  78. package/out/country/{reference.d.ts → reference/index.d.ts} +1 -1
  79. package/out/country/reference/index.d.ts.map +1 -0
  80. package/out/country/{reference.js → reference/index.js} +2 -2
  81. package/out/country/reference/index.js.map +1 -0
  82. package/out/country/region-languages.d.ts +25 -0
  83. package/out/country/region-languages.d.ts.map +1 -0
  84. package/out/country/region-languages.js +41 -0
  85. package/out/country/region-languages.js.map +1 -0
  86. package/out/de/bundesland.d.ts.map +1 -1
  87. package/out/de/postleitzahl.d.ts.map +1 -1
  88. package/out/de/street-type.d.ts.map +1 -1
  89. package/out/es/co-official-languages.d.ts +37 -0
  90. package/out/es/co-official-languages.d.ts.map +1 -0
  91. package/out/es/co-official-languages.js +61 -0
  92. package/out/es/co-official-languages.js.map +1 -0
  93. package/out/es/index.d.ts +1 -0
  94. package/out/es/index.d.ts.map +1 -1
  95. package/out/es/index.js +1 -0
  96. package/out/es/index.js.map +1 -1
  97. package/out/fr/departement.d.ts.map +1 -1
  98. package/out/fr/region.d.ts.map +1 -1
  99. package/out/gb/country.d.ts.map +1 -1
  100. package/out/gb/index.d.ts +2 -2
  101. package/out/gb/index.d.ts.map +1 -1
  102. package/out/gb/index.js +2 -2
  103. package/out/gb/index.js.map +1 -1
  104. package/out/gb/{postcode-area.d.ts → postcode/area.d.ts} +1 -1
  105. package/out/gb/postcode/area.d.ts.map +1 -0
  106. package/out/gb/{postcode-area.js → postcode/area.js} +1 -1
  107. package/out/gb/postcode/area.js.map +1 -0
  108. package/out/gb/{postcode.d.ts → postcode/index.d.ts} +1 -1
  109. package/out/gb/postcode/index.d.ts.map +1 -0
  110. package/out/gb/{postcode.js → postcode/index.js} +1 -1
  111. package/out/gb/postcode/index.js.map +1 -0
  112. package/out/gb/street-type.d.ts.map +1 -1
  113. package/out/index.d.ts +4 -2
  114. package/out/index.d.ts.map +1 -1
  115. package/out/index.js +4 -2
  116. package/out/index.js.map +1 -1
  117. package/out/jp/address-unit.d.ts.map +1 -1
  118. package/out/jp/index.d.ts +1 -0
  119. package/out/jp/index.d.ts.map +1 -1
  120. package/out/jp/index.js +1 -0
  121. package/out/jp/index.js.map +1 -1
  122. package/out/jp/municipality-register.d.ts +48 -0
  123. package/out/jp/municipality-register.d.ts.map +1 -0
  124. package/out/jp/municipality-register.js +41 -0
  125. package/out/jp/municipality-register.js.map +1 -0
  126. package/out/jp/prefecture.d.ts.map +1 -1
  127. package/out/kr/index.d.ts +10 -0
  128. package/out/kr/index.d.ts.map +1 -0
  129. package/out/kr/index.js +10 -0
  130. package/out/kr/index.js.map +1 -0
  131. package/out/kr/sigungu-register.d.ts +37 -0
  132. package/out/kr/sigungu-register.d.ts.map +1 -0
  133. package/out/kr/sigungu-register.js +283 -0
  134. package/out/kr/sigungu-register.js.map +1 -0
  135. package/out/level-semantics.d.ts.map +1 -1
  136. package/out/level-semantics.js.map +1 -1
  137. package/out/nz/delivery-service.d.ts.map +1 -1
  138. package/out/placetype-map.d.ts +83 -0
  139. package/out/placetype-map.d.ts.map +1 -0
  140. package/out/placetype-map.js +130 -0
  141. package/out/placetype-map.js.map +1 -0
  142. package/out/postcode/shapes.d.ts +47 -0
  143. package/out/postcode/shapes.d.ts.map +1 -0
  144. package/out/postcode/shapes.js +38 -0
  145. package/out/postcode/shapes.js.map +1 -0
  146. package/out/postcode/shapes.json +80 -0
  147. package/out/{postcode-systems.d.ts → postcode/systems.d.ts} +8 -1
  148. package/out/postcode/systems.d.ts.map +1 -0
  149. package/out/{postcode-systems.js → postcode/systems.js} +9 -2
  150. package/out/postcode/systems.js.map +1 -0
  151. package/out/register-completion.d.ts +14 -0
  152. package/out/register-completion.d.ts.map +1 -0
  153. package/out/register-completion.js +23 -0
  154. package/out/register-completion.js.map +1 -0
  155. package/out/us/floor-designator.d.ts.map +1 -1
  156. package/out/us/index.d.ts +2 -2
  157. package/out/us/index.js +2 -2
  158. package/out/us/military-address.d.ts.map +1 -1
  159. package/out/us/po-box.d.ts +6 -0
  160. package/out/us/po-box.d.ts.map +1 -1
  161. package/out/us/po-box.js +35 -10
  162. package/out/us/po-box.js.map +1 -1
  163. package/out/us/state.d.ts.map +1 -1
  164. package/out/us/{street-directional.d.ts → street/directional.d.ts} +1 -1
  165. package/out/us/street/directional.d.ts.map +1 -0
  166. package/out/us/{street-directional.js → street/directional.js} +2 -2
  167. package/out/us/street/directional.js.map +1 -0
  168. package/out/us/{street-suffix.d.ts → street/suffix.d.ts} +1 -1
  169. package/out/us/street/suffix.d.ts.map +1 -0
  170. package/out/us/{street-suffix.js → street/suffix.js} +2 -2
  171. package/out/us/street/suffix.js.map +1 -0
  172. package/out/us/zipcode.d.ts +1 -1
  173. package/out/us/zipcode.d.ts.map +1 -1
  174. package/package.json +120 -30
  175. package/lib/tools/build-country-surface-lexicon.ts +0 -177
  176. package/lib/tools/export-country-surfaces.ts +0 -48
  177. package/lib/tools/generate-country-population.ts +0 -142
  178. package/lib/tools/generate-country-reference.ts +0 -168
  179. package/lib/tools/generate-official-languages.ts +0 -210
  180. package/lib/tools/index.ts +0 -12
  181. package/out/address-system-conventions.d.ts.map +0 -1
  182. package/out/address-system-conventions.js.map +0 -1
  183. package/out/country/reference-data.d.ts.map +0 -1
  184. package/out/country/reference-data.js.map +0 -1
  185. package/out/country/reference.d.ts.map +0 -1
  186. package/out/country/reference.js.map +0 -1
  187. package/out/gb/postcode-area.d.ts.map +0 -1
  188. package/out/gb/postcode-area.js.map +0 -1
  189. package/out/gb/postcode.d.ts.map +0 -1
  190. package/out/gb/postcode.js.map +0 -1
  191. package/out/postcode-systems.d.ts.map +0 -1
  192. package/out/postcode-systems.js.map +0 -1
  193. package/out/tools/build-country-surface-lexicon.d.ts +0 -43
  194. package/out/tools/build-country-surface-lexicon.d.ts.map +0 -1
  195. package/out/tools/build-country-surface-lexicon.js +0 -149
  196. package/out/tools/build-country-surface-lexicon.js.map +0 -1
  197. package/out/tools/export-country-surfaces.d.ts +0 -15
  198. package/out/tools/export-country-surfaces.d.ts.map +0 -1
  199. package/out/tools/export-country-surfaces.js +0 -34
  200. package/out/tools/export-country-surfaces.js.map +0 -1
  201. package/out/tools/generate-country-population.d.ts +0 -42
  202. package/out/tools/generate-country-population.d.ts.map +0 -1
  203. package/out/tools/generate-country-population.js +0 -106
  204. package/out/tools/generate-country-population.js.map +0 -1
  205. package/out/tools/generate-country-reference.d.ts +0 -36
  206. package/out/tools/generate-country-reference.d.ts.map +0 -1
  207. package/out/tools/generate-country-reference.js +0 -107
  208. package/out/tools/generate-country-reference.js.map +0 -1
  209. package/out/tools/generate-official-languages.d.ts +0 -50
  210. package/out/tools/generate-official-languages.d.ts.map +0 -1
  211. package/out/tools/generate-official-languages.js +0 -149
  212. package/out/tools/generate-official-languages.js.map +0 -1
  213. package/out/tools/index.d.ts +0 -12
  214. package/out/tools/index.d.ts.map +0 -1
  215. package/out/tools/index.js +0 -12
  216. package/out/tools/index.js.map +0 -1
  217. package/out/us/street-directional.d.ts.map +0 -1
  218. package/out/us/street-directional.js.map +0 -1
  219. package/out/us/street-suffix.d.ts.map +0 -1
  220. package/out/us/street-suffix.js.map +0 -1
  221. /package/lib/country/{reference-data.ts → reference/data.ts} +0 -0
  222. /package/lib/gb/{postcode-area.ts → postcode/area.ts} +0 -0
  223. /package/lib/gb/{postcode.ts → postcode/index.ts} +0 -0
@@ -1,149 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Build the COUNTRY-SURFACE LEXICON for the country-lexicon soft-feed channel (#1104). This is the
7
- * third atlas channel, a sibling of the postcode anchor (#239/#240) and the gazetteer anchor
8
- * (#464): a per-token multi-hot clue the neural GRAMMAR conditions on but never obeys. Country is a
9
- * CLOSED, ENUMERABLE class (~250 surfaces) — atlas, not grammar — so a dictionary phrase-lookup
10
- * recovers the WOF-admin / resolver hierarchy case ("United States of America, Wyoming, <locality>")
11
- * the learned tagger reads as a leading STREET. Pelias handled the same class the same way
12
- * (`WhosOnFirstClassifier extends PhraseClassifier`); this is the model-first analogue.
13
- *
14
- * WHY A DEDICATED LEXICON (not just the gazetteer's `country` slot): the gazetteer already carries
15
- * these surfaces in slot 0, and the shipped model already consumes them — yet the WOF-admin case
16
- * still fails (model-card #1104: golden country recall 82.0% vs 88.6%). The country bit is one of a
17
- * 5-hot vector sharing ONE learned projection with region/po_box/cedex/homograph, and it is ZEROED
18
- * adjacent to a postcode by `suppress_gazetteer_near_postcode` (exactly where a trailing "…12345
19
- * USA" sits). A dedicated channel de-entangles the country signal (its own projection + confidence
20
- * weight) and is immune to that suppression. See
21
- * docs/superpowers/plans/2026-07-14-country-lexicon-channel.md.
22
- *
23
- * The matcher REUSES the gazetteer's phrase-scan (longest-first n-gram over whitespace words,
24
- * case-insensitive `entries` + uppercase-exact `code_entries`, char→piece projection) — one tested
25
- * algorithm, two vocabularies. Only the vocabulary + the emitted feature differ. The emitted
26
- * feature is 2-dim per piece: `[country_surface, country_ambiguous]`.
27
- *
28
- * - `country_surface` (bit 1): the piece is part of a recognized country surface phrase.
29
- * - `country_ambiguous` (bit 2): the SURFACE is a homograph (also a US region) or a common-word
30
- * name ("Georgia", "America", "England", "IN") — a SOFT version of Pelias's hard blacklist. The
31
- * model learns to trust `surface & !ambiguous` (unambiguous long/code forms) strongly and
32
- * `surface & ambiguous` weakly, using context — model-first, never a hard drop, so recall on
33
- * "Republic of Georgia" is preserved.
34
- *
35
- * Source of truth: `@mailwoman/codex` (COUNTRY_SURFACE_FORMS + ISO2_TO_NAME) — the SAME data the
36
- * corpus-python bridge `country-surfaces.json` is generated from (export-country-surfaces.ts), so
37
- * the channel and the corpus extract synthesizer cannot diverge on what a country surface IS.
38
- *
39
- * Output: data/gazetteer/country-surface-lexicon-v1.json (small, committed, provenance-tracked).
40
- * Regenerate: `node codex/tools/build-country-surface-lexicon.ts`
41
- */
42
- import { makeDirectories, writeLocalTextFile } from "@mailwoman/core/fs/writers";
43
- import { repoRootPath } from "@mailwoman/core/paths";
44
- import { dirname } from "path-ts";
45
- import { COUNTRY_SURFACE_FORMS, ISO2_TO_NAME } from "#country/country";
46
- import { wordNorm, wordNormLower } from "#normalize";
47
- import { US_STATE_ABBREVIATIONS, US_STATE_NAMES } from "#us/state";
48
- /**
49
- * Ambiguous entries printed before the list is truncated.
50
- */
51
- const MAX_LISTED_AMBIGUOUS = 12;
52
- /**
53
- * Letters at or below which a token reads as an abbreviation rather than a word.
54
- */
55
- const MAX_ABBREVIATION_LETTERS = 3;
56
- const BIT = { country_surface: 1, country_ambiguous: 2 };
57
- const SLOTS = ["country_surface", "country_ambiguous"];
58
- /**
59
- * Committed output path (a codex-derived artifact, like export-country-surfaces.ts — no argv, so the no-process-globals
60
- * lint policy holds; codex stays zero-runtime-dep).
61
- */
62
- const OUTPUT = repoRootPath("data", "gazetteer", "country-surface-lexicon-v1.json");
63
- /**
64
- * THE shared word-normalization rule (identical to build-gazetteer-anchor-lexicon.mjs and mirrored in
65
- * gazetteer_char_paint on both sides): per whitespace-word, strip LEADING/TRAILING characters that are not Unicode
66
- * letters or digits (keep internal ones: "u.s.a", "timor-leste"), rejoin single-spaced. Entry keys and scanned tokens
67
- * both pass through it, so "U.S.A." ≡ "u.s.a".
68
- */
69
- /**
70
- * Short alphabetic code (≤3 letters once punctuation is dropped) → exact-uppercase matching.
71
- */
72
- const isShortCode = (s) => {
73
- const letters = s.replaceAll(/[^\p{L}]/gu, "");
74
- return letters.length > 0 && letters.length <= MAX_ABBREVIATION_LETTERS && /^[\p{L}.\s]+$/u.test(s);
75
- };
76
- // Homograph set: a single-word country surface that is ALSO a US region (name or abbreviation) reads
77
- // ambiguously (Georgia the country vs the state, IN = India vs Indiana). Computed from codex so it
78
- // tracks the US region table, never hand-maintained.
79
- const usStateNames = new Set(US_STATE_NAMES.map((n) => n.toLowerCase()));
80
- const usStateAbbrevs = new Set(US_STATE_ABBREVIATIONS);
81
- /**
82
- * Curated common-word country surfaces — single tokens that appear far more often as ordinary street/venue/locality
83
- * words than as a trailing country. A SOFT flag (the model still decides), the model-first analogue of Pelias's
84
- * blacklist (north/south/east/west/street/city/king). Tunable.
85
- */
86
- const COMMON_WORD_AMBIGUOUS = new Set(["america", "england", "britain", "turkey", "chad", "jordan", "jersey", "guinea"]);
87
- const isAmbiguousName = (lowerKey) => usStateNames.has(lowerKey) || COMMON_WORD_AMBIGUOUS.has(lowerKey);
88
- // surface → bits, split across the two match-rule maps (mirrors the gazetteer builder).
89
- const entries = new Map(); // lowercase key
90
- const codeEntries = new Map(); // exact-uppercase key
91
- let maxNgram = 1;
92
- function add(surface) {
93
- const s = surface.trim();
94
- if (!s)
95
- return;
96
- if (isShortCode(s)) {
97
- const key = wordNorm(s).toUpperCase();
98
- if (!key)
99
- return;
100
- // A code that collides with a US-state abbreviation (CA/IN/AL/CO/…) is a homograph → ambiguous.
101
- const bits = BIT.country_surface | (usStateAbbrevs.has(key) ? BIT.country_ambiguous : 0);
102
- codeEntries.set(key, (codeEntries.get(key) ?? 0) | bits);
103
- return;
104
- }
105
- const key = wordNormLower(s);
106
- if (!key)
107
- return;
108
- const words = key.split(" ");
109
- maxNgram = Math.max(maxNgram, words.length);
110
- // Multi-word phrases are unambiguous by construction; single tokens consult the homograph +
111
- // common-word rule.
112
- const ambiguous = words.length === 1 && isAmbiguousName(key);
113
- const bits = BIT.country_surface | (ambiguous ? BIT.country_ambiguous : 0);
114
- entries.set(key, (entries.get(key) ?? 0) | bits);
115
- }
116
- // Curated rich surface forms first (US/GB/DE/… endonyms + abbreviations), then the canonical English
117
- // name for every remaining ISO 3166-1 alpha-2 — exactly the merge country-surfaces.json performs.
118
- for (const forms of Object.values(COUNTRY_SURFACE_FORMS)) {
119
- for (const f of forms) {
120
- add(f);
121
- }
122
- }
123
- for (const [, name] of ISO2_TO_NAME) {
124
- add(name);
125
- }
126
- const ambiguousEntries = [...entries, ...codeEntries].filter(([, b]) => b & BIT.country_ambiguous).map(([k]) => k);
127
- const lexicon = {
128
- version: 1,
129
- generated_by: "codex/tools/build-country-surface-lexicon.ts (source: @mailwoman/codex COUNTRY_SURFACE_FORMS + ISO2_TO_NAME)",
130
- feature_dim: SLOTS.length,
131
- slots: SLOTS,
132
- bits: BIT,
133
- max_ngram: maxNgram,
134
- rules: {
135
- word_norm: "per whitespace-word: strip leading/trailing chars that are not Unicode letters/digits " +
136
- "(keep internal: 'timor-leste', 'u.s.a'); rejoin single-spaced. Applied to BOTH entry keys and scanned tokens.",
137
- entries: "case-insensitive; key = word_norm lowercased. country_surface always set; country_ambiguous set for single-token homographs (US region) or curated common-word names.",
138
- code_entries: "case-SENSITIVE exact: word_norm(token) == key (keys uppercase; 'in' the word ≠ 'IN' India). n-gram length 1. country_ambiguous set when the code is also a US-state abbreviation.",
139
- scan: "longest-first n-gram over whitespace words, left to right, non-overlapping (shared with the gazetteer matcher)",
140
- feature: "emitted per-piece row = [country_surface, country_ambiguous] (the raw bits); confidence = 1.0 where country_surface fires.",
141
- },
142
- entries: Object.fromEntries([...entries].toSorted(([a], [b]) => a.localeCompare(b))),
143
- code_entries: Object.fromEntries([...codeEntries].toSorted(([a], [b]) => a.localeCompare(b))),
144
- };
145
- await makeDirectories(dirname(OUTPUT));
146
- await writeLocalTextFile(JSON.stringify(lexicon, null, 1) + "\n", OUTPUT);
147
- process.stderr.write(`wrote ${OUTPUT}: ${entries.size} entries + ${codeEntries.size} code_entries, ` +
148
- `max_ngram=${maxNgram}, ${ambiguousEntries.length} ambiguous: ${ambiguousEntries.slice(0, MAX_LISTED_AMBIGUOUS).join(", ")}${ambiguousEntries.length > MAX_LISTED_AMBIGUOUS ? ", …" : ""}\n`);
149
- //# sourceMappingURL=build-country-surface-lexicon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-country-surface-lexicon.js","sourceRoot":"","sources":["../../lib/tools/build-country-surface-lexicon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,E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O,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7F,CAAA;AAED,MAAM,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AACtC,MAAM,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;AAEzE,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB,SAAS,MAAM,KAAK,OAAO,CAAC,IAAI,cAAc,WAAW,CAAC,IAAI,iBAAiB;IAC9E,aAAa,QAAQ,KAAK,gBAAgB,CAAC,MAAM,eAAe,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAC7L,CAAA"}
@@ -1,15 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * codex → corpus-python bridge: emit the authoritative country surface forms as JSON so the Python
7
- * extract generators can synthesize address tails ("…, USA" / "…, United States of America") without
8
- * re-deriving the country name/alias data. `@mailwoman/codex` stays the single source of truth
9
- * (COUNTRY_SURFACE_FORMS + ISO2_TO_NAME, salvaged from isp-nexus spatial/countries); this writes a
10
- * snapshot the language boundary can't import directly.
11
- *
12
- * Regenerate: `node codex/tools/export-country-surfaces.ts` (writes the corpus-python data file).
13
- */
14
- export {};
15
- //# sourceMappingURL=export-country-surfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export-country-surfaces.d.ts","sourceRoot":"","sources":["../../lib/tools/export-country-surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -1,34 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * codex → corpus-python bridge: emit the authoritative country surface forms as JSON so the Python
7
- * extract generators can synthesize address tails ("…, USA" / "…, United States of America") without
8
- * re-deriving the country name/alias data. `@mailwoman/codex` stays the single source of truth
9
- * (COUNTRY_SURFACE_FORMS + ISO2_TO_NAME, salvaged from isp-nexus spatial/countries); this writes a
10
- * snapshot the language boundary can't import directly.
11
- *
12
- * Regenerate: `node codex/tools/export-country-surfaces.ts` (writes the corpus-python data file).
13
- */
14
- import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
15
- import { repoRootPath } from "@mailwoman/core/paths";
16
- import { COUNTRY_SURFACE_FORMS, ISO2_TO_NAME } from "#country/country";
17
- // Merge: rich surface forms where the codex curates them, else the canonical English name for every
18
- // ISO 3166-1 alpha-2. Canonical-name-first (the codex's own ordering) so the common form leads.
19
- const surfaces = {};
20
- for (const [iso2, forms] of Object.entries(COUNTRY_SURFACE_FORMS)) {
21
- surfaces[iso2] = [...forms];
22
- }
23
- for (const [iso2, name] of ISO2_TO_NAME) {
24
- if (!surfaces[iso2]) {
25
- surfaces[iso2] = [name];
26
- }
27
- }
28
- const out = repoRootPath("corpus-python", "src", "mailwoman_train", "data", "country-surfaces.json");
29
- await writeLocalTextFile(JSON.stringify({
30
- _generated: "codex/tools/export-country-surfaces.ts from @mailwoman/codex COUNTRY_SURFACE_FORMS + ISO2_TO_NAME",
31
- surfaces,
32
- }, null, 2) + "\n", out);
33
- process.stderr.write(`wrote ${Object.keys(surfaces).length} countries → ${out}\n`);
34
- //# sourceMappingURL=export-country-surfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export-country-surfaces.js","sourceRoot":"","sources":["../../lib/tools/export-country-surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEtE,oGAAoG;AACpG,gGAAgG;AAChG,MAAM,QAAQ,GAA6B,EAAE,CAAA;AAE7C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;IACnE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;AAC5B,CAAC;AAED,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC;IACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;AACF,CAAC;AAED,MAAM,GAAG,GAAG,YAAY,CAAC,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,uBAAuB,CAAC,CAAA;AAEpG,MAAM,kBAAkB,CACvB,IAAI,CAAC,SAAS,CACb;IACC,UAAU,EAAE,mGAAmG;IAC/G,QAAQ;CACR,EACD,IAAI,EACJ,CAAC,CACD,GAAG,IAAI,EACR,GAAG,CACH,CAAA;AAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAA"}
@@ -1,42 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Regenerate `codex/country/population.ts` — the per-country population table — from GeoNames
7
- * `countryInfo.txt` (https://download.geonames.org/export/dump/countryInfo.txt, CC-BY-4.0). The
8
- * output is committed; this tool makes it reproducible (provenance), not a hand-typed dictionary.
9
- *
10
- * Why it exists (#1650): WOF carries no readable population for 147 of 237 country records
11
- * (measured against the 2026-08-18 candidate build), so those countries entered every prominence
12
- * race at an asserted ZERO — ranked below any namesake hamlet. The magnitude is what a fame race
13
- * reads, so a census-vintage figure is entirely sufficient; currency of the estimate is not the
14
- * point.
15
- *
16
- * Rows whose GeoNames population is 0 are DROPPED rather than emitted: an entry in this table is a
17
- * positive claim, and the consumer's absence branch (`?? undefined`) must stay reachable for
18
- * territories GeoNames itself declines to estimate (the meaning-of-zero rule).
19
- *
20
- * Usage: mailwoman dev generate country-population
21
- */
22
- /**
23
- * Options for {@linkcode generateCountryPopulation}.
24
- */
25
- export interface GenerateCountryPopulationOptions {
26
- /**
27
- * Output path override. Default: `codex/country/population.ts` (the committed table).
28
- */
29
- out?: string;
30
- }
31
- /**
32
- * Summary returned by {@linkcode generateCountryPopulation}.
33
- */
34
- export interface GenerateCountryPopulationSummary {
35
- countries: number;
36
- outPath: string;
37
- }
38
- /**
39
- * Fetch GeoNames `countryInfo.txt` and regenerate the committed `COUNTRY_POPULATION` table.
40
- */
41
- export declare function generateCountryPopulation(options?: GenerateCountryPopulationOptions, report?: (line: string) => void): Promise<GenerateCountryPopulationSummary>;
42
- //# sourceMappingURL=generate-country-population.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-country-population.d.ts","sourceRoot":"","sources":["../../lib/tools/generate-country-population.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAmCH;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,GAAE,gCAAqC,EAC9C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,gCAAgC,CAAC,CA8D3C"}
@@ -1,106 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Regenerate `codex/country/population.ts` — the per-country population table — from GeoNames
7
- * `countryInfo.txt` (https://download.geonames.org/export/dump/countryInfo.txt, CC-BY-4.0). The
8
- * output is committed; this tool makes it reproducible (provenance), not a hand-typed dictionary.
9
- *
10
- * Why it exists (#1650): WOF carries no readable population for 147 of 237 country records
11
- * (measured against the 2026-08-18 candidate build), so those countries entered every prominence
12
- * race at an asserted ZERO — ranked below any namesake hamlet. The magnitude is what a fame race
13
- * reads, so a census-vintage figure is entirely sufficient; currency of the estimate is not the
14
- * point.
15
- *
16
- * Rows whose GeoNames population is 0 are DROPPED rather than emitted: an entry in this table is a
17
- * positive claim, and the consumer's absence branch (`?? undefined`) must stay reachable for
18
- * territories GeoNames itself declines to estimate (the meaning-of-zero rule).
19
- *
20
- * Usage: mailwoman dev generate country-population
21
- */
22
- import { APIClient, pluckResponseData } from "@mailwoman/core/api";
23
- import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
24
- import { resolvePackagePath } from "@mailwoman/core/module/resolvers";
25
- const SOURCE = "https://download.geonames.org/export/dump/countryInfo.txt";
26
- /**
27
- * The committed output path, resolved relative to this module (codex/tools/ → codex/country/). See
28
- * `generate-country-reference.ts` for why this is `import.meta.url` rather than a `core` path helper (codex is
29
- * zero-runtime-dep and `core` already references `codex` — importing core here would cycle the project graph).
30
- */
31
- const DEFAULT_OUT = resolvePackagePath("@mailwoman/codex", "lib", "country", "population.ts");
32
- /**
33
- * Tab positions this tool reads from `countryInfo.txt`'s 19-column rows. Named so the parse states which columns it
34
- * believes in; a GeoNames format change fails the count guard below rather than silently reading the wrong column.
35
- */
36
- const COLUMN_ISO2 = 0;
37
- const COLUMN_POPULATION = 7;
38
- const MINIMUM_COLUMNS = 8;
39
- /**
40
- * GeoNames publishes ~250 countries/territories; a parse recovering fewer than this read the wrong column or a
41
- * truncated body, and the guard fails loudly instead of committing a hollow table.
42
- */
43
- const MINIMUM_PLAUSIBLE_COUNTRIES = 200;
44
- /**
45
- * Numbers below five digits are emitted bare — the house numeric-separator style groups by three and only from five
46
- * digits up (`8450`, not `8_450`).
47
- */
48
- const SEPARATOR_MINIMUM = 10_000;
49
- /**
50
- * Fetch GeoNames `countryInfo.txt` and regenerate the committed `COUNTRY_POPULATION` table.
51
- */
52
- export async function generateCountryPopulation(options = {}, report) {
53
- const outPath = options.out ?? DEFAULT_OUT;
54
- // `responseType: "text"` because the source is a tab-separated dump, not JSON.
55
- const text = await new APIClient({ displayName: "geonames-country-info", retry: true })
56
- .fetch({ url: SOURCE, responseType: "text" })
57
- .then(pluckResponseData);
58
- const rows = {};
59
- // oxlint-disable-next-line mailwoman/prefer-spliterator -- countryInfo.txt is ~35 kB and bounded (~300 rows)
60
- for (const line of text.split("\n")) {
61
- if (!line || line.startsWith("#"))
62
- continue;
63
- // oxlint-disable-next-line mailwoman/prefer-spliterator -- one 19-column row
64
- const columns = line.split("\t");
65
- if (columns.length < MINIMUM_COLUMNS)
66
- continue;
67
- const alpha2 = columns[COLUMN_ISO2].trim();
68
- const population = Number(columns[COLUMN_POPULATION]);
69
- if (!/^[A-Z]{2}$/.test(alpha2))
70
- continue;
71
- if (!Number.isFinite(population) || population <= 0)
72
- continue;
73
- rows[alpha2] = population;
74
- }
75
- if (Object.keys(rows).length < MINIMUM_PLAUSIBLE_COUNTRIES) {
76
- throw new Error(`generateCountryPopulation: only ${Object.keys(rows).length} rows parsed — format drift?`);
77
- }
78
- const body = Object.keys(rows)
79
- .toSorted()
80
- .map((k) => {
81
- const n = rows[k];
82
- const literal = n >= SEPARATOR_MINIMUM ? n.toLocaleString("en-US").replaceAll(",", "_") : String(n);
83
- return `\t${k}: ${literal},`;
84
- })
85
- .join("\n");
86
- const header = `/**
87
- * @copyright Sister Software
88
- * @license AGPL-3.0
89
- * @author Teffen Ellis, et al.
90
- *
91
- * GENERATED — do not edit by hand. Per-country population, derived from GeoNames countryInfo.txt
92
- * (https://download.geonames.org/export/dump/countryInfo.txt, CC-BY-4.0). Estimates are
93
- * census-vintage; a prominence race reads the magnitude, not the currency. Countries GeoNames
94
- * declines to estimate are ABSENT, never zero.
95
- * Regenerate with: mailwoman dev generate country-population
96
- */
97
-
98
- /**
99
- * ISO 3166-1 alpha-2 → population estimate.
100
- */
101
- export const COUNTRY_POPULATION: Readonly<Record<string, number>> = {`;
102
- await writeLocalTextFile(`${header}\n${body}\n}\n`, outPath);
103
- report?.(`wrote ${outPath} (${Object.keys(rows).length} countries)`);
104
- return { countries: Object.keys(rows).length, outPath };
105
- }
106
- //# sourceMappingURL=generate-country-population.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-country-population.js","sourceRoot":"","sources":["../../lib/tools/generate-country-population.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAErE,MAAM,MAAM,GAAG,2DAA2D,CAAA;AAE1E;;;;GAIG;AACH,MAAM,WAAW,GAAG,kBAAkB,CAAC,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,CAAC,CAAA;AAE7F;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,M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E7D,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,CAAA;IAC1B,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,2BAA2B,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,mCAAmC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,8BAA8B,CAAC,CAAA;IAC3G,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SAC5B,QAAQ,EAAE;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACV,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAA;QAClB,MAAM,OAAO,GAAG,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAEnG,OAAO,KAAK,CAAC,KAAK,OAAO,GAAG,CAAA;IAC7B,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;sEAesD,CAAA;IAErE,MAAM,kBAAkB,CAAC,GAAG,MAAM,KAAK,IAAI,OAAO,EAAE,OAAO,CAAC,CAAA;IAC5D,MAAM,EAAE,CAAC,SAAS,OAAO,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,aAAa,CAAC,CAAA;IAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,CAAA;AACxD,CAAC"}
@@ -1,36 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Regenerate `codex/country/reference-data.ts` — the per-country calling code (E.164) + currency
7
- * (ISO 4217) table — from mledoze/countries (https://github.com/mledoze/countries, ODbL). The
8
- * output is committed; this tool makes it reproducible (provenance), not a hand-typed dictionary.
9
- *
10
- * Calling-code rule: mledoze splits the code as `idd.root` + `idd.suffixes`. For most countries a
11
- * single suffix completes the code (GB `+4` + `4` = 44); NANP members share root `+1` with their
12
- * area code as the suffix, so they map to 1.
13
- *
14
- * Usage: mailwoman dev generate country-reference
15
- */
16
- /**
17
- * Options for {@linkcode generateCountryReference}.
18
- */
19
- export interface GenerateCountryReferenceOptions {
20
- /**
21
- * Output path override. Default: `codex/country/reference-data.ts` (the committed table).
22
- */
23
- out?: string;
24
- }
25
- /**
26
- * Summary returned by {@linkcode generateCountryReference}.
27
- */
28
- export interface GenerateCountryReferenceSummary {
29
- countries: number;
30
- outPath: string;
31
- }
32
- /**
33
- * Fetch mledoze/countries and regenerate the committed `COUNTRY_REFERENCE` table.
34
- */
35
- export declare function generateCountryReference(options?: GenerateCountryReferenceOptions, report?: (line: string) => void): Promise<GenerateCountryReferenceSummary>;
36
- //# sourceMappingURL=generate-country-reference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-country-reference.d.ts","sourceRoot":"","sources":["../../lib/tools/generate-country-reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiCH;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CACf;AA6BD;;GAEG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,GAAE,+BAAoC,EAC7C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,+BAA+B,CAAC,CAqE1C"}
@@ -1,107 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Regenerate `codex/country/reference-data.ts` — the per-country calling code (E.164) + currency
7
- * (ISO 4217) table — from mledoze/countries (https://github.com/mledoze/countries, ODbL). The
8
- * output is committed; this tool makes it reproducible (provenance), not a hand-typed dictionary.
9
- *
10
- * Calling-code rule: mledoze splits the code as `idd.root` + `idd.suffixes`. For most countries a
11
- * single suffix completes the code (GB `+4` + `4` = 44); NANP members share root `+1` with their
12
- * area code as the suffix, so they map to 1.
13
- *
14
- * Usage: mailwoman dev generate country-reference
15
- */
16
- import { APIClient, pluckResponseData } from "@mailwoman/core/api";
17
- import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
18
- import { resolvePackagePath } from "@mailwoman/core/module/resolvers";
19
- const SOURCE = "https://raw.githubusercontent.com/mledoze/countries/master/countries.json";
20
- /**
21
- * The committed output path, resolved relative to this module (codex/tools/ → codex/country/). The codegen is
22
- * repo-only, and in the repo `@mailwoman/codex/tools` always loads from source via the `node` exports condition, so
23
- * `import.meta.url` points at the source tree. (`@mailwoman/core`'s `repoRootPath` would also work, but codex is
24
- * zero-runtime-dep and `core` already references `codex` — importing core here would cycle the project graph.)
25
- */
26
- const DEFAULT_OUT = resolvePackagePath("@mailwoman/codex", "lib", "country", "reference-data.ts");
27
- function callingCode(country) {
28
- const root = (country.idd?.root ?? "").replace("+", "");
29
- const suffixes = country.idd?.suffixes ?? [];
30
- if (!root)
31
- return undefined;
32
- if (root === "1")
33
- return 1;
34
- if (suffixes.length === 1) {
35
- const n = Number(root + suffixes[0]);
36
- return Number.isFinite(n) ? n : undefined;
37
- }
38
- const n = Number(root);
39
- return Number.isFinite(n) ? n : undefined;
40
- }
41
- const serialize = (o) => JSON.stringify(o, null, 0)
42
- .replaceAll('"isoCode"', "isoCode")
43
- .replaceAll('"callingCode"', "callingCode")
44
- .replaceAll('"currency"', "currency")
45
- .replaceAll('"name"', "name")
46
- .replaceAll('"symbol"', "symbol");
47
- /**
48
- * Fetch mledoze/countries and regenerate the committed `COUNTRY_REFERENCE` table.
49
- */
50
- export async function generateCountryReference(options = {}, report) {
51
- const outPath = options.out ?? DEFAULT_OUT;
52
- const countries = await new APIClient({ displayName: "mledoze-countries", retry: true })
53
- .fetch({ url: SOURCE })
54
- .then(pluckResponseData);
55
- const rows = {};
56
- for (const country of countries) {
57
- const alpha2 = country.cca2;
58
- if (!alpha2)
59
- continue;
60
- const entry = {};
61
- const cc = callingCode(country);
62
- if (cc != null) {
63
- entry.callingCode = cc;
64
- }
65
- const currencyCodes = Object.keys(country.currencies ?? {}).toSorted();
66
- if (currencyCodes.length) {
67
- const code = currencyCodes[0];
68
- const info = country.currencies[code] ?? {};
69
- entry.currency = { isoCode: code };
70
- if (info.name) {
71
- entry.currency.name = info.name;
72
- }
73
- if (info.symbol) {
74
- entry.currency.symbol = info.symbol;
75
- }
76
- }
77
- if (Object.keys(entry).length) {
78
- rows[alpha2] = entry;
79
- }
80
- }
81
- const body = Object.keys(rows)
82
- .toSorted()
83
- .map((k) => `\t${k}: ${serialize(rows[k])},`)
84
- .join("\n");
85
- const header = `/**
86
- * @copyright Sister Software
87
- * @license AGPL-3.0
88
- * @author Teffen Ellis, et al.
89
- *
90
- * GENERATED — do not edit by hand. Country calling codes (E.164) + currencies (ISO 4217), derived
91
- * from mledoze/countries (https://github.com/mledoze/countries, ODbL). NANP members map to 1.
92
- * Regenerate with: mailwoman dev generate country-reference
93
- */
94
-
95
- /** Static per-country reference: calling code + currency. */
96
- export interface CountryReference {
97
- callingCode?: number
98
- currency?: { isoCode: string; name?: string; symbol?: string }
99
- }
100
-
101
- /** ISO 3166-1 alpha-2 → reference. */
102
- export const COUNTRY_REFERENCE: Record<string, CountryReference> = {`;
103
- await writeLocalTextFile(`${header}\n${body}\n}\n`, outPath);
104
- report?.(`wrote ${outPath} (${Object.keys(rows).length} countries)`);
105
- return { countries: Object.keys(rows).length, outPath };
106
- }
107
- //# sourceMappingURL=generate-country-reference.js.map
@@ -1 +0,0 @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, et al.
5
- *
6
- * Regenerates `codex/country/official-languages.ts` from Unicode CLDR supplemental data
7
- * (territoryInfo `_officialStatus` + languageAlias). The emitted table is the #936 ingest bit's
8
- * authority for "is this name row in an official language of its country?" — consumed by the
9
- * gazetteer builders (`mailwoman gazetteer build`, `@mailwoman/resolver-wof-sqlite`'s GeoNames
10
- * fold), never at query time.
11
- *
12
- * Each language is emitted under EVERY ISO-639 spelling CLDR aliases to it (fi + fin, sv + swe)
13
- * so consumers can test WOF's 639-3 tags, Overture's BCP-47 keys, and GeoNames' mixed 2/3-letter
14
- * codes without a mapping step.
15
- *
16
- * Usage: mailwoman dev generate official-languages [--cldr-dir <dir>] [--cldr-version 47.0.0]
17
- *
18
- * With `cldrDir`, reads cldr-territoryInfo.json + cldr-aliases.json from disk; otherwise fetches
19
- * the pinned cldr-core release from jsdelivr.
20
- */
21
- /**
22
- * Options for {@linkcode generateOfficialLanguages}.
23
- */
24
- export interface GenerateOfficialLanguagesOptions {
25
- /**
26
- * Read cldr-territoryInfo.json + cldr-aliases.json from this directory instead of fetching.
27
- */
28
- cldrDir?: string;
29
- /**
30
- * Pinned cldr-core release fetched from jsdelivr when {@linkcode GenerateOfficialLanguagesOptions.cldrDir} is absent.
31
- */
32
- cldrVersion?: string;
33
- /**
34
- * Output path override. Default: `codex/country/official-languages.ts` (the committed table).
35
- */
36
- out?: string;
37
- }
38
- /**
39
- * Summary returned by {@linkcode generateOfficialLanguages}.
40
- */
41
- export interface GenerateOfficialLanguagesSummary {
42
- territories: number;
43
- cldrVersion: string;
44
- outPath: string;
45
- }
46
- /**
47
- * Regenerate the committed `OFFICIAL_LANGUAGES` table from CLDR supplemental data.
48
- */
49
- export declare function generateOfficialLanguages(options?: GenerateOfficialLanguagesOptions, report?: (line: string) => void): Promise<GenerateOfficialLanguagesSummary>;
50
- //# sourceMappingURL=generate-official-languages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-official-languages.d.ts","sourceRoot":"","sources":["../../lib/tools/generate-official-languages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAcH;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CACf;AAsBD;;GAEG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,GAAE,gCAAqC,EAC9C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,gCAAgC,CAAC,CA2H3C"}