@mailwoman/registry 9.2.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 (227) hide show
  1. package/README.md +1 -1
  2. package/{address-key.ts → lib/address-key.ts} +1 -1
  3. package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
  4. package/{geojson.ts → lib/geojson.ts} +9 -4
  5. package/{index.ts → lib/index.ts} +10 -10
  6. package/{ingest.ts → lib/ingest.ts} +75 -68
  7. package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
  8. package/{map-html.ts → lib/map-html.ts} +7 -13
  9. package/{reconcile.ts → lib/reconcile.ts} +7 -23
  10. package/{resolve.ts → lib/resolve.ts} +25 -12
  11. package/{tools → lib/tools}/coverage-reconciliation.ts +12 -14
  12. package/{tools → lib/tools}/cross-dataset-correlation.ts +60 -137
  13. package/{tools → lib/tools}/cross-source-threshold-sweep.ts +20 -31
  14. package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
  15. package/{tools → lib/tools}/eval-geocoder.ts +9 -10
  16. package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
  17. package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +9 -10
  18. package/lib/tools/gold-set-sample.ts +141 -0
  19. package/lib/tools/index.ts +31 -0
  20. package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +68 -257
  21. package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +60 -243
  22. package/{tools → lib/tools}/learned-scorer-eval.ts +62 -256
  23. package/{tools → lib/tools}/matcher-scale.ts +4 -5
  24. package/lib/tools/nppes/org-name.ts +23 -0
  25. package/{tools → lib/tools}/nppes/overmerge-packet.ts +5 -7
  26. package/{tools → lib/tools}/nppes/report.ts +22 -25
  27. package/{tools → lib/tools}/nppes/sample.ts +80 -32
  28. package/{tools/nppes/levers.ts → lib/tools/nppes/settings.ts} +10 -10
  29. package/{tools → lib/tools}/nppes/truth-grains.ts +4 -44
  30. package/{tools → lib/tools}/nppes-dedup-benchmark.ts +42 -38
  31. package/lib/tools/shared.ts +763 -0
  32. package/lib/tools/train-cross-gbt.ts +209 -0
  33. package/{tools → lib/tools}/train-gbt.ts +35 -154
  34. package/lib/tools/train-org-cross-gbt.ts +179 -0
  35. package/{tools → lib/tools}/txhhsc-to-oarow.ts +9 -27
  36. package/lib/tools/viz/browser.ts +50 -0
  37. package/{tools → lib/tools}/viz/cross-dataset-map.ts +7 -8
  38. package/{tools → lib/tools}/viz/geocode-first-surface.ts +10 -8
  39. package/{tools → lib/tools}/viz/render-map.ts +10 -23
  40. package/lib/tools/viz/render.ts +98 -0
  41. package/{tools → lib/tools}/viz/source-provenance-map.ts +8 -10
  42. package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
  43. package/out/address-key.d.ts +1 -1
  44. package/out/address-key.d.ts.map +1 -1
  45. package/out/address-key.js.map +1 -1
  46. package/out/geocode-handler.d.ts +6 -6
  47. package/out/geocode-handler.d.ts.map +1 -1
  48. package/out/geocode-handler.js +6 -6
  49. package/out/geocode-handler.js.map +1 -1
  50. package/out/geojson.d.ts +7 -2
  51. package/out/geojson.d.ts.map +1 -1
  52. package/out/geojson.js +5 -3
  53. package/out/geojson.js.map +1 -1
  54. package/out/index.d.ts +10 -10
  55. package/out/index.d.ts.map +1 -1
  56. package/out/index.js +10 -10
  57. package/out/index.js.map +1 -1
  58. package/out/ingest.d.ts +64 -46
  59. package/out/ingest.d.ts.map +1 -1
  60. package/out/ingest.js +31 -45
  61. package/out/ingest.js.map +1 -1
  62. package/out/learned-scorer.d.ts +1 -1
  63. package/out/learned-scorer.d.ts.map +1 -1
  64. package/out/learned-scorer.js.map +1 -1
  65. package/out/map-html.d.ts +3 -3
  66. package/out/map-html.d.ts.map +1 -1
  67. package/out/map-html.js +6 -11
  68. package/out/map-html.js.map +1 -1
  69. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  70. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  71. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  72. package/out/models/dedup-gbt-en-us.js.map +1 -1
  73. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  74. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  75. package/out/reconcile.d.ts +6 -1
  76. package/out/reconcile.d.ts.map +1 -1
  77. package/out/reconcile.js +5 -20
  78. package/out/reconcile.js.map +1 -1
  79. package/out/resolve.d.ts +19 -7
  80. package/out/resolve.d.ts.map +1 -1
  81. package/out/resolve.js +16 -5
  82. package/out/resolve.js.map +1 -1
  83. package/out/tools/coverage-reconciliation.d.ts +1 -1
  84. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  85. package/out/tools/coverage-reconciliation.js +11 -11
  86. package/out/tools/coverage-reconciliation.js.map +1 -1
  87. package/out/tools/cross-dataset-correlation.d.ts +4 -4
  88. package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
  89. package/out/tools/cross-dataset-correlation.js +57 -109
  90. package/out/tools/cross-dataset-correlation.js.map +1 -1
  91. package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
  92. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
  93. package/out/tools/cross-source-threshold-sweep.js +19 -27
  94. package/out/tools/cross-source-threshold-sweep.js.map +1 -1
  95. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  96. package/out/tools/dedup-ceiling.js +36 -117
  97. package/out/tools/dedup-ceiling.js.map +1 -1
  98. package/out/tools/eval-geocoder.d.ts +8 -12
  99. package/out/tools/eval-geocoder.d.ts.map +1 -1
  100. package/out/tools/eval-geocoder.js +2 -2
  101. package/out/tools/eval-geocoder.js.map +1 -1
  102. package/out/tools/geocoder-namesake-probe.d.ts +2 -2
  103. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
  104. package/out/tools/geocoder-namesake-probe.js +4 -8
  105. package/out/tools/geocoder-namesake-probe.js.map +1 -1
  106. package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
  107. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
  108. package/out/tools/geocoder-vs-provided-coords.js +8 -7
  109. package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
  110. package/out/tools/gold-set-sample.d.ts +5 -5
  111. package/out/tools/gold-set-sample.d.ts.map +1 -1
  112. package/out/tools/gold-set-sample.js +37 -122
  113. package/out/tools/gold-set-sample.js.map +1 -1
  114. package/out/tools/index.d.ts +23 -23
  115. package/out/tools/index.d.ts.map +1 -1
  116. package/out/tools/index.js +23 -23
  117. package/out/tools/index.js.map +1 -1
  118. package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
  119. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
  120. package/out/tools/learned-scorer-clustering-eval.js +35 -169
  121. package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
  122. package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
  123. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
  124. package/out/tools/learned-scorer-crossstate-eval.js +44 -166
  125. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
  126. package/out/tools/learned-scorer-eval.d.ts +1 -1
  127. package/out/tools/learned-scorer-eval.d.ts.map +1 -1
  128. package/out/tools/learned-scorer-eval.js +37 -168
  129. package/out/tools/learned-scorer-eval.js.map +1 -1
  130. package/out/tools/matcher-scale.d.ts.map +1 -1
  131. package/out/tools/matcher-scale.js +4 -4
  132. package/out/tools/matcher-scale.js.map +1 -1
  133. package/out/tools/nppes/org-name.d.ts +2 -5
  134. package/out/tools/nppes/org-name.d.ts.map +1 -1
  135. package/out/tools/nppes/org-name.js +1 -30
  136. package/out/tools/nppes/org-name.js.map +1 -1
  137. package/out/tools/nppes/overmerge-packet.d.ts +3 -3
  138. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
  139. package/out/tools/nppes/overmerge-packet.js +3 -3
  140. package/out/tools/nppes/overmerge-packet.js.map +1 -1
  141. package/out/tools/nppes/report.d.ts +5 -5
  142. package/out/tools/nppes/report.d.ts.map +1 -1
  143. package/out/tools/nppes/report.js +17 -19
  144. package/out/tools/nppes/report.js.map +1 -1
  145. package/out/tools/nppes/sample.d.ts +32 -6
  146. package/out/tools/nppes/sample.d.ts.map +1 -1
  147. package/out/tools/nppes/sample.js +44 -26
  148. package/out/tools/nppes/sample.js.map +1 -1
  149. package/out/tools/nppes/scoring.d.ts.map +1 -1
  150. package/out/tools/nppes/scoring.js.map +1 -1
  151. package/out/tools/nppes/{levers.d.ts → settings.d.ts} +8 -8
  152. package/out/tools/nppes/settings.d.ts.map +1 -0
  153. package/out/tools/nppes/{levers.js → settings.js} +8 -8
  154. package/out/tools/nppes/settings.js.map +1 -0
  155. package/out/tools/nppes/truth-grains.d.ts +2 -2
  156. package/out/tools/nppes/truth-grains.d.ts.map +1 -1
  157. package/out/tools/nppes/truth-grains.js +4 -29
  158. package/out/tools/nppes/truth-grains.js.map +1 -1
  159. package/out/tools/nppes-dedup-benchmark.d.ts +4 -4
  160. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
  161. package/out/tools/nppes-dedup-benchmark.js +40 -34
  162. package/out/tools/nppes-dedup-benchmark.js.map +1 -1
  163. package/out/tools/shared.d.ts +244 -7
  164. package/out/tools/shared.d.ts.map +1 -1
  165. package/out/tools/shared.js +349 -18
  166. package/out/tools/shared.js.map +1 -1
  167. package/out/tools/train-cross-gbt.d.ts +7 -7
  168. package/out/tools/train-cross-gbt.d.ts.map +1 -1
  169. package/out/tools/train-cross-gbt.js +47 -145
  170. package/out/tools/train-cross-gbt.js.map +1 -1
  171. package/out/tools/train-gbt.d.ts +7 -7
  172. package/out/tools/train-gbt.d.ts.map +1 -1
  173. package/out/tools/train-gbt.js +31 -111
  174. package/out/tools/train-gbt.js.map +1 -1
  175. package/out/tools/train-org-cross-gbt.d.ts +7 -5
  176. package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
  177. package/out/tools/train-org-cross-gbt.js +45 -141
  178. package/out/tools/train-org-cross-gbt.js.map +1 -1
  179. package/out/tools/txhhsc-to-oarow.d.ts +2 -2
  180. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  181. package/out/tools/txhhsc-to-oarow.js +8 -22
  182. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  183. package/out/tools/viz/browser.d.ts +34 -0
  184. package/out/tools/viz/browser.d.ts.map +1 -0
  185. package/out/tools/viz/browser.js +33 -0
  186. package/out/tools/viz/browser.js.map +1 -0
  187. package/out/tools/viz/cross-dataset-map.d.ts +2 -2
  188. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  189. package/out/tools/viz/cross-dataset-map.js +6 -6
  190. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  191. package/out/tools/viz/geocode-first-surface.d.ts +4 -3
  192. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  193. package/out/tools/viz/geocode-first-surface.js +7 -5
  194. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  195. package/out/tools/viz/render-map.d.ts +3 -6
  196. package/out/tools/viz/render-map.d.ts.map +1 -1
  197. package/out/tools/viz/render-map.js +9 -19
  198. package/out/tools/viz/render-map.js.map +1 -1
  199. package/out/tools/viz/render.d.ts +4 -9
  200. package/out/tools/viz/render.d.ts.map +1 -1
  201. package/out/tools/viz/render.js +24 -39
  202. package/out/tools/viz/render.js.map +1 -1
  203. package/out/tools/viz/source-provenance-map.d.ts +2 -2
  204. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  205. package/out/tools/viz/source-provenance-map.js +6 -7
  206. package/out/tools/viz/source-provenance-map.js.map +1 -1
  207. package/out/tools/viz/yardstick-figure.d.ts +2 -2
  208. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  209. package/out/tools/viz/yardstick-figure.js +5 -4
  210. package/out/tools/viz/yardstick-figure.js.map +1 -1
  211. package/out/types.d.ts.map +1 -1
  212. package/out/types.js.map +1 -1
  213. package/package.json +115 -15
  214. package/out/tools/nppes/levers.d.ts.map +0 -1
  215. package/out/tools/nppes/levers.js.map +0 -1
  216. package/tools/gold-set-sample.ts +0 -254
  217. package/tools/index.ts +0 -31
  218. package/tools/nppes/org-name.ts +0 -56
  219. package/tools/shared.ts +0 -162
  220. package/tools/train-cross-gbt.ts +0 -359
  221. package/tools/train-org-cross-gbt.ts +0 -330
  222. package/tools/viz/render.ts +0 -113
  223. /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
  224. /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
  225. /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
  226. /package/{tools → lib/tools}/nppes/scoring.ts +0 -0
  227. /package/{types.ts → lib/types.ts} +0 -0
@@ -14,30 +14,12 @@
14
14
  * Run: `mailwoman registry convert tx-hhsc [--src <tsv>] [--out /tmp/txhhsc-oarow.jsonl]`
15
15
  */
16
16
 
17
- import { readFileSync, writeFileSync } from "node:fs"
18
-
19
- import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
17
+ import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
18
+ import { readLocalTextFile } from "@mailwoman/core/fs/readers"
19
+ import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
20
20
  import { TSVSpliterator } from "spliterator"
21
21
 
22
- /**
23
- * Texas bounding box, used to reject rows whose coordinates landed in the wrong state.
24
- */
25
- const TX_MIN_LATITUDE = 25
26
-
27
- /**
28
- * See {@link TX_MIN_LATITUDE}.
29
- */
30
- const TX_MAX_LATITUDE = 37
31
-
32
- /**
33
- * See {@link TX_MIN_LATITUDE}.
34
- */
35
- const TX_MIN_LONGITUDE = -107
36
-
37
- /**
38
- * See {@link TX_MIN_LATITUDE}.
39
- */
40
- const TX_MAX_LONGITUDE = -93
22
+ import { inTXBBOX } from "#tools/shared"
41
23
 
42
24
  /**
43
25
  * Options for {@linkcode convertTXHHSC}.
@@ -58,10 +40,10 @@ const GEO = /^\s*(-?\d+\.\d+)\s*,\s*(-?\d+\.\d+)\s*$/
58
40
  /**
59
41
  * Convert the TX HHSC nursing-facilities TSV into OaRow JSONL for `oa-resolver-eval`.
60
42
  */
61
- export function convertTXHHSC(
43
+ export async function convertTXHHSC(
62
44
  options: TXHHSCConvertOptions = {},
63
45
  report?: (line: string) => void
64
- ): { written: number; skipped: number; out: string } {
46
+ ): Promise<{ written: number; skipped: number; out: string }> {
65
47
  const src = options.src || String(dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv"))
66
48
  const out = options.out || tempRootPath("txhhsc-oarow.jsonl")
67
49
 
@@ -76,7 +58,7 @@ export function convertTXHHSC(
76
58
  let cGeo = -1
77
59
  let sawHeader = false
78
60
 
79
- for (const f of TSVSpliterator.from(readFileSync(src, "utf8"), { header: false })) {
61
+ for (const f of TSVSpliterator.from(await readLocalTextFile(src), { header: false })) {
80
62
  if (f.every((value) => !value.trim())) continue
81
63
 
82
64
  if (!sawHeader) {
@@ -105,7 +87,7 @@ export function convertTXHHSC(
105
87
  const lon = Number(m[2])
106
88
 
107
89
  // Sanity: TX bounding box (rejects swapped/garbage coords).
108
- if (lat < TX_MIN_LATITUDE || lat > TX_MAX_LATITUDE || lon > TX_MAX_LONGITUDE || lon < TX_MIN_LONGITUDE) {
90
+ if (!inTXBBOX(lat, lon)) {
109
91
  skipped++
110
92
 
111
93
  continue
@@ -123,7 +105,7 @@ export function convertTXHHSC(
123
105
  )
124
106
  }
125
107
 
126
- writeFileSync(out, records.join("\n") + "\n")
108
+ await writeLocalTextFile(records.join("\n") + "\n", out)
127
109
  report?.(`wrote ${records.length} rows (skipped ${skipped}) → ${out}`)
128
110
 
129
111
  return { written: records.length, skipped, out }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper,
7
+ * not a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
8
+ * the browser launches on ANGLE's SwiftShader software rasterizer (`--use-gl=angle
9
+ * --use-angle=swiftshader --enable-unsafe-swiftshader`); each caller owns its own navigation +
10
+ * wait strategy and screenshots inside the callback.
11
+ *
12
+ * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported at call time (the
13
+ * corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never pays for
14
+ * it.
15
+ */
16
+
17
+ import type { Page } from "playwright"
18
+
19
+ /**
20
+ * Options for {@linkcode withChromiumPage}.
21
+ */
22
+ export interface ChromiumPageOptions {
23
+ viewport: { width: number; height: number }
24
+ }
25
+
26
+ /**
27
+ * Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`, collect console + page errors,
28
+ * run `fn`, and dispose the browser. The callback owns navigation, waits, and the screenshot.
29
+ */
30
+ export async function withChromiumPage<T>(
31
+ options: ChromiumPageOptions,
32
+ fn: (page: Page) => Promise<T>
33
+ ): Promise<{ result: T; consoleErrors: string[] }> {
34
+ const { chromium } = await import("playwright")
35
+
36
+ const browser = await chromium.launch({
37
+ args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
38
+ })
39
+
40
+ const page = await browser.newPage({ viewport: options.viewport, deviceScaleFactor: 2 })
41
+
42
+ const errors: string[] = []
43
+ page.on("console", (m) => m.type() === "error" && errors.push(m.text()))
44
+ page.on("pageerror", (e) => errors.push(String(e)))
45
+
46
+ const result = await fn(page)
47
+ await browser[Symbol.asyncDispose]()
48
+
49
+ return { result, consoleErrors: errors }
50
+ }
@@ -7,10 +7,9 @@
7
7
  * `crossAgencyOnly` removes links whose sources belong to one agency.
8
8
  */
9
9
 
10
- import { readFileSync, writeFileSync } from "node:fs"
11
-
12
- import { parseJSONStrict } from "@mailwoman/core/objects"
13
- import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
10
+ import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
11
+ import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
12
+ import { writeLocalFile } from "@mailwoman/core/fs/writers"
14
13
  import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
15
14
 
16
15
  import { type MapFeatureData, toMapHTML } from "#index"
@@ -69,15 +68,15 @@ const sourcesOf = (f: GeoFeature<PointLiteral, MapFeatureData>): string[] =>
69
68
  /**
70
69
  * Render the cross-dataset-links GeoJSON to a bucket-colored MapLibre HTML page.
71
70
  */
72
- export function crossDatasetMap(
71
+ export async function crossDatasetMap(
73
72
  options: CrossDatasetMapOptions = {},
74
73
  report?: (line: string) => void
75
- ): { outHTML: string; kept: number; total: number; triple: number } {
74
+ ): Promise<{ outHTML: string; kept: number; total: number; triple: number }> {
76
75
  const IN = options.in || dataRootPath("record-matcher", "2026-06-16-cross-dataset-links.geojson")
77
76
  const OUT = options.outHTML || tempRootPath("cross-dataset-map.html")
78
77
  const CROSS_AGENCY_ONLY = options.crossAgencyOnly ?? false
79
78
 
80
- const parsed = parseJSONStrict<GeoFeatureCollection<PointLiteral, MapFeatureData>>(readFileSync(IN, "utf8"))
79
+ const parsed = await readLocalJSONFile<GeoFeatureCollection<PointLiteral, MapFeatureData>>(IN)
81
80
 
82
81
  const total = parsed.features.length
83
82
 
@@ -114,7 +113,7 @@ export function crossDatasetMap(
114
113
  colorBy: "bucket",
115
114
  })
116
115
 
117
- writeFileSync(OUT, html)
116
+ await writeLocalFile(html, OUT)
118
117
  report?.(`[written] ${OUT} (${kept}${CROSS_AGENCY_ONLY ? ` of ${total} cross-AGENCY` : ""} entities)`)
119
118
  report?.(` source combinations:`)
120
119
 
@@ -7,9 +7,8 @@
7
7
  * Fellegi-Sunter weights. The supplied prior is illustrative and the output is self-contained HTML.
8
8
  */
9
9
 
10
- import { writeFileSync } from "node:fs"
11
-
12
- import { tempRootPath } from "@mailwoman/core/utils"
10
+ import { tempRootPath } from "@mailwoman/core/data-root"
11
+ import { writeLocalFile } from "@mailwoman/core/fs/writers"
13
12
 
14
13
  /**
15
14
  * Options for {@linkcode geocodeFirstSurface}.
@@ -17,7 +16,8 @@ import { tempRootPath } from "@mailwoman/core/utils"
17
16
  export interface GeocodeFirstSurfaceOptions {
18
17
  /**
19
18
  * Illustrative prior λ. Production's record matcher uses λ=1e-4 (calibrated for the full multi-field model with phone
20
- * + spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
19
+ *
20
+ * - Spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
21
21
  */
22
22
  lambda?: number
23
23
  /**
@@ -82,10 +82,10 @@ function distanceWeight(km: number): number {
82
82
  /**
83
83
  * Emit the geocode-first decision-surface Plotly HTML — see the module doc.
84
84
  */
85
- export function geocodeFirstSurface(
85
+ export async function geocodeFirstSurface(
86
86
  options: GeocodeFirstSurfaceOptions = {},
87
87
  report?: (line: string) => void
88
- ): { outHTML: string } {
88
+ ): Promise<{ outHTML: string }> {
89
89
  const LAMBDA = options.lambda ?? 0.02
90
90
  const OUT_HTML = options.outHTML || tempRootPath("geocode-first-surface.html")
91
91
 
@@ -171,7 +171,9 @@ export function geocodeFirstSurface(
171
171
  prior: PRIOR,
172
172
  }
173
173
 
174
- const safe = JSON.stringify(data).replaceAll(/<\/script>/gi, "<\\/script>")
174
+ // EVERY `<`, not only `</script>`: `<!--` also leaves script-data state in the HTML tokenizer, after which a
175
+ // later `</script>` no longer ends the element. `\u003c` is the same string to a JSON reader.
176
+ const safe = JSON.stringify(data).replaceAll("<", "\\u003c")
175
177
 
176
178
  const html = `<!doctype html><html><head><meta charset="utf-8"/>
177
179
  <script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
@@ -277,7 +279,7 @@ document.getElementByID("cap").innerHTML =
277
279
  </script>
278
280
  </body></html>`
279
281
 
280
- writeFileSync(OUT_HTML, html)
282
+ await writeLocalFile(html, OUT_HTML)
281
283
  report?.(`[written] ${OUT_HTML}`)
282
284
  report?.(`λ=${LAMBDA} prior=${PRIOR.toFixed(2)} bits`)
283
285
 
@@ -9,20 +9,19 @@
9
9
  *
10
10
  * Two house-stack constraints make this fiddlier than the Plotly/SVG renderers:
11
11
  *
12
- * - MapLibre needs a real WebGL context → ANGLE's SwiftShader software rasterizer (the same flags the
13
- * 3D Plotly render uses).
14
- * - The basemap tiles come from `tiles.sister.software`, which CORS-restricts to localhost + the docs
12
+ * - MapLibre needs a real WebGL context — the shared harness (`./browser.ts`) provides one through
13
+ * SwiftShader.
14
+ * - The basemap tiles come from `tiles.mailwoman.ai`, which CORS-restricts to localhost + the docs
15
15
  * domains — so the page MUST be SERVED OVER LOCALHOST, not opened as a file (a file:// page
16
16
  * renders accurate markers on a blank basemap). Serve the output dir first, e.g. `python3 -m
17
17
  * http.server 8899 -d <dir>`, then point this at `http://localhost:8899/<page>.html`.
18
18
  *
19
19
  * The map paints asynchronously after the network settles; we wait for networkidle, then a fixed
20
20
  * beat for the basemap tiles + marker layer to finish compositing.
21
- *
22
- * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
23
- * fn (the corpus-tools lazy-import convention).
24
21
  */
25
22
 
23
+ import { withChromiumPage } from "#tools/viz/browser"
24
+
26
25
  /**
27
26
  * Options for {@linkcode renderServedMapToPNG}.
28
27
  */
@@ -44,25 +43,13 @@ export async function renderServedMapToPNG(
44
43
  options: RenderMapOptions,
45
44
  report?: (line: string) => void
46
45
  ): Promise<{ outPNG: string; consoleErrors: string[] }> {
47
- // playwright + Chromium are heavy — lazy import (the pipeline convention).
48
- const { chromium } = await import("playwright")
49
-
50
- const browser = await chromium.launch({
51
- args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
46
+ const { consoleErrors: errors } = await withChromiumPage({ viewport: { width: 1100, height: 760 } }, async (page) => {
47
+ await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 })
48
+ // MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
49
+ await page.waitForTimeout(4000)
50
+ await page.screenshot({ path: options.outPNG })
52
51
  })
53
52
 
54
- const page = await browser.newPage({ viewport: { width: 1100, height: 760 }, deviceScaleFactor: 2 })
55
-
56
- const errors: string[] = []
57
- page.on("console", (m) => m.type() === "error" && errors.push(m.text()))
58
- page.on("pageerror", (e) => errors.push(String(e)))
59
-
60
- await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 })
61
- // MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
62
- await page.waitForTimeout(4000)
63
- await page.screenshot({ path: options.outPNG })
64
- await browser.close()
65
-
66
53
  report?.(`[map-render] ${options.outPNG}; console errors=${errors.length}`)
67
54
 
68
55
  for (const e of errors.slice(0, 6)) {
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Render a self-contained Plotly HTML to a PNG via headless Chromium — the shared renderer behind
7
+ * the `registry viz` figures (an internal helper, not a command).
8
+ *
9
+ * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context, which the shared harness
10
+ * (`./browser.ts`) provides through SwiftShader; 2D traces (`contour`/`heatmap`) render on the 2D
11
+ * canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div rather
12
+ * than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
13
+ */
14
+
15
+ import { pathToFileURL } from "@mailwoman/core/module/file-url"
16
+ import { resolvePath as resolve } from "path-ts"
17
+
18
+ import { withChromiumPage } from "#tools/viz/browser"
19
+
20
+ /**
21
+ * Options for {@linkcode renderPlotlyHTMLToPNG}.
22
+ */
23
+ export interface RenderPlotlyOptions {
24
+ /**
25
+ * The self-contained Plotly HTML file.
26
+ */
27
+ inHTML: string
28
+ /**
29
+ * Output PNG path.
30
+ */
31
+ outPNG: string
32
+ /**
33
+ * Viewport width. Default 1160.
34
+ */
35
+ width?: number
36
+ /**
37
+ * Viewport height. Default 1000.
38
+ */
39
+ height?: number
40
+ }
41
+
42
+ /**
43
+ * Screenshot a Plotly HTML page after every graph div's `plotly_afterplot` fires.
44
+ */
45
+ export async function renderPlotlyHTMLToPNG(
46
+ options: RenderPlotlyOptions,
47
+ report?: (line: string) => void
48
+ ): Promise<{ outPNG: string; consoleErrors: string[] }> {
49
+ const { consoleErrors: errors } = await withChromiumPage(
50
+ { viewport: { width: options.width ?? 1160, height: options.height ?? 1000 } },
51
+ async (page) => {
52
+ await page.goto(pathToFileURL(resolve(options.inHTML)).href, { waitUntil: "networkidle" })
53
+
54
+ // Resolve once every Plotly graph div has fired plotly_afterplot (3D paints land async, after
55
+ // newPlot's promise resolves), with a per-div fallback so an already-painted div can't hang us.
56
+ await page.evaluate(async () => {
57
+ // Runs in the BROWSER — reach DOM/Plotly globals via globalThis so the script needs no DOM lib.
58
+ interface PlotlyDiv {
59
+ _fullLayout?: unknown
60
+ on?: (event: string, cb: () => void) => void
61
+ }
62
+
63
+ const doc = Reflect.get(globalThis, "document") as { querySelectorAll(s: string): Iterable<unknown> }
64
+
65
+ const divs = [...doc.querySelectorAll("div")]
66
+ .map((d) => d as PlotlyDiv)
67
+ .filter((d) => d._fullLayout && typeof d.on === "function")
68
+
69
+ await Promise.all(
70
+ divs.map(
71
+ (d) =>
72
+ new Promise<void>((res) => {
73
+ d.on!("plotly_afterplot", () => res())
74
+ setTimeout(() => res(), 2000)
75
+ })
76
+ )
77
+ )
78
+ })
79
+
80
+ // Final settle for the software WebGL rasterizer.
81
+ await page.waitForTimeout(800)
82
+
83
+ await page.screenshot({ path: resolve(options.outPNG), fullPage: true })
84
+ }
85
+ )
86
+
87
+ if (errors.length) {
88
+ report?.(`[render] ${errors.length} console error(s):`)
89
+
90
+ for (const e of errors.slice(0, 8)) {
91
+ report?.(" " + e)
92
+ }
93
+ }
94
+
95
+ report?.(`[render] ${options.outPNG}`)
96
+
97
+ return { outPNG: options.outPNG, consoleErrors: errors }
98
+ }
@@ -7,12 +7,12 @@
7
7
  * The output requires an HTTP origin because the tile server does not serve `file:` origins.
8
8
  */
9
9
 
10
- import { writeFileSync } from "node:fs"
11
- import { DatabaseSync } from "node:sqlite"
12
-
10
+ import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
11
+ import { writeLocalFile } from "@mailwoman/core/fs/writers"
13
12
  import { isPresent } from "@mailwoman/core/objects"
14
- import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
13
+ import type { AddressPointDatabase } from "@mailwoman/resolver-wof-sqlite/address"
15
14
  import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
15
+ import { DatabaseClient } from "@mailwoman/sqlite/client"
16
16
 
17
17
  import { type MapFeatureData, toMapHTML } from "#index"
18
18
 
@@ -70,10 +70,10 @@ type Row = { lat: number; lon: number; source: string; number: string | null; st
70
70
  /**
71
71
  * Render the per-state address-point provenance map — see the module doc.
72
72
  */
73
- export function sourceProvenanceMap(
73
+ export async function sourceProvenanceMap(
74
74
  options: SourceProvenanceMapOptions = {},
75
75
  report?: (line: string) => void
76
- ): { outHTML: string; points: number } {
76
+ ): Promise<{ outHTML: string; points: number }> {
77
77
  const STATE = (options.state || "ny").toLowerCase()
78
78
  const DB = options.db || String(dataRootPath("address-points", `address-points-us-${STATE}.db`))
79
79
  const OUT = options.outHTML || tempRootPath("source-provenance.html")
@@ -81,7 +81,7 @@ export function sourceProvenanceMap(
81
81
  const OA_MOD = options.oaMod ?? 120 // keep ~1/120 of OpenAddresses points
82
82
  const CAP = options.cap ?? 7000 // per-source marker cap
83
83
 
84
- const db = new DatabaseSync(DB, { readOnly: true })
84
+ using db = new DatabaseClient<AddressPointDatabase>(DB, { readOnly: true })
85
85
 
86
86
  // Two stratified samples so the smaller source (OpenAddresses, ~1/6 of NY) stays visible next to NAD.
87
87
  // abs(random()) % mod == 0 keeps a spatially-uniform ~1/mod fraction; LIMIT caps the marker count.
@@ -99,8 +99,6 @@ export function sourceProvenanceMap(
99
99
  ...sample("source LIKE 'overture:OpenAddresses%'", OA_MOD),
100
100
  ]
101
101
 
102
- db.close()
103
-
104
102
  const counts = new Map<string, number>()
105
103
 
106
104
  const features: GeoFeature<PointLiteral, MapFeatureData>[] = rows.map((r) => {
@@ -130,7 +128,7 @@ export function sourceProvenanceMap(
130
128
  colorBy: "bucket",
131
129
  })
132
130
 
133
- writeFileSync(OUT, html)
131
+ await writeLocalFile(html, OUT)
134
132
  report?.(`[written] ${OUT} (${features.length} points)`)
135
133
 
136
134
  for (const [bucket, n] of [...counts.entries()].toSorted((a, b) => b[1] - a[1])) {
@@ -24,7 +24,8 @@
24
24
  * [--out-svg docs/records/evals/charts/dedup-yardstick.svg]`
25
25
  */
26
26
 
27
- import { writeFileSync } from "node:fs"
27
+ import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
28
+ import { escapeHTML } from "@mailwoman/core/strings/escape"
28
29
 
29
30
  /**
30
31
  * Options for {@linkcode yardstickFigure}.
@@ -93,15 +94,15 @@ const MODELS = [
93
94
  { key: "FS", label: "FS full stack", color: "#9ca3af", width: 2, dash: "5 4" },
94
95
  ]
95
96
 
96
- const esc = (s: string) => s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")
97
+ const esc = escapeHTML
97
98
 
98
99
  /**
99
100
  * Emit the dedup-yardstick slope chart as a self-contained SVG — see the module doc.
100
101
  */
101
- export function yardstickFigure(
102
+ export async function yardstickFigure(
102
103
  options: YardstickFigureOptions = {},
103
104
  report?: (line: string) => void
104
- ): { outSVG: string } {
105
+ ): Promise<{ outSVG: string }> {
105
106
  const OUT = options.outSVG || "docs/records/evals/charts/dedup-yardstick.svg"
106
107
 
107
108
  const parts: string[] = []
@@ -220,7 +221,7 @@ export function yardstickFigure(
220
221
 
221
222
  push(`</svg>`)
222
223
 
223
- writeFileSync(OUT, parts.join(""))
224
+ await writeLocalTextFile(parts.join(""), OUT)
224
225
  report?.(`[written] ${OUT}`)
225
226
 
226
227
  report?.(
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { type PostalAddressID } from "@mailwoman/address-id";
17
17
  import { type BlockingKey } from "@mailwoman/match";
18
- import type { SourceRecord } from "./types.ts";
18
+ import type { SourceRecord } from "#types";
19
19
  /**
20
20
  * The stable address primary key for a record, or null when it isn't geocoded (no coordinate → no locality cell) or
21
21
  * carries no raw address to hash. Uses the resolved coordinate + the raw address; the state prefix is plucked from the
@@ -1 +1 @@
1
- {"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI,CAO5E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,YAAY,CAAC,CAEhE"}
1
+ {"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../lib/address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI,CAO5E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,YAAY,CAAC,CAEhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"address-key.js","sourceRoot":"","sources":["../address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAI7D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IACnD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAA;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAA;IAEnC,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAExC,OAAO,qBAAqB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAA;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;AACrD,CAAC"}
1
+ {"version":3,"file":"address-key.js","sourceRoot":"","sources":["../lib/address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAI7D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IACnD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAA;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAA;IAEnC,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAExC,OAAO,qBAAqB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAA;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;AACrD,CAAC"}
@@ -3,16 +3,16 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The per-record geocode step, factored out of the worker so it unit-tests against a fake seam (no
7
- * neural model / SQLite). `geocode-worker.ts` builds the real seam from config and wraps this.
6
+ * The per-record geocode step, factored out of the worker so it unit-tests against a fake geocoder (no
7
+ * neural model / SQLite). `geocode-worker.ts` builds the real geocoder from config and wraps this.
8
8
  */
9
- import { type ColumnMapping, type GeocodeAddress } from "./ingest.ts";
10
- import type { SourceRecord } from "./types.ts";
9
+ import { type ColumnMapping, type GeocodeAddress } from "#ingest";
10
+ import type { SourceRecord } from "#types";
11
11
  /**
12
12
  * Build the handler `geocodeStream` runs per normalized record: recompute the joined address string from `record.raw` +
13
- * `mapping.address` (the worker can't receive the original closure), geocode it via `seam`, and attach the result.
13
+ * `mapping.address` (the worker can't receive the original closure), geocode it via `geocode`, and attach the result.
14
14
  * Records with no mapped address pass through untouched (no geocode call). The default separator matches
15
15
  * {@link ingestRow}'s `addressSeparator`.
16
16
  */
17
- export declare function makeGeocodeHandler(seam: GeocodeAddress, mapping: ColumnMapping, addressSeparator?: string): (record: SourceRecord) => Promise<SourceRecord>;
17
+ export declare function makeGeocodeHandler(geocode: GeocodeAddress, mapping: ColumnMapping, addressSeparator?: string): (record: SourceRecord) => Promise<SourceRecord>;
18
18
  //# sourceMappingURL=geocode-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geocode-handler.d.ts","sourceRoot":"","sources":["../geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAQ,MAAM,aAAa,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,aAAa,EACtB,gBAAgB,SAAO,GACrB,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAYjD"}
1
+ {"version":3,"file":"geocode-handler.d.ts","sourceRoot":"","sources":["../lib/geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAQ,MAAM,SAAS,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,aAAa,EACtB,gBAAgB,SAAO,GACrB,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAYjD"}
@@ -3,24 +3,24 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The per-record geocode step, factored out of the worker so it unit-tests against a fake seam (no
7
- * neural model / SQLite). `geocode-worker.ts` builds the real seam from config and wraps this.
6
+ * The per-record geocode step, factored out of the worker so it unit-tests against a fake geocoder (no
7
+ * neural model / SQLite). `geocode-worker.ts` builds the real geocoder from config and wraps this.
8
8
  */
9
- import { pick } from "./ingest.js";
9
+ import { pick } from "#ingest";
10
10
  /**
11
11
  * Build the handler `geocodeStream` runs per normalized record: recompute the joined address string from `record.raw` +
12
- * `mapping.address` (the worker can't receive the original closure), geocode it via `seam`, and attach the result.
12
+ * `mapping.address` (the worker can't receive the original closure), geocode it via `geocode`, and attach the result.
13
13
  * Records with no mapped address pass through untouched (no geocode call). The default separator matches
14
14
  * {@link ingestRow}'s `addressSeparator`.
15
15
  */
16
- export function makeGeocodeHandler(seam, mapping, addressSeparator = ", ") {
16
+ export function makeGeocodeHandler(geocode, mapping, addressSeparator = ", ") {
17
17
  return async (record) => {
18
18
  if (!record.raw)
19
19
  return record;
20
20
  const addressValue = pick(record.raw, mapping.address, addressSeparator);
21
21
  if (!addressValue)
22
22
  return record;
23
- const address = (await seam(addressValue)) ?? undefined;
23
+ const address = (await geocode(addressValue)) ?? undefined;
24
24
  return { ...record, address };
25
25
  };
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geocode-handler.js","sourceRoot":"","sources":["../geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA2C,IAAI,EAAE,MAAM,aAAa,CAAA;AAG3E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAoB,EACpB,OAAsB,EACtB,gBAAgB,GAAG,IAAI;IAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG;YAAE,OAAO,MAAM,CAAA;QAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;QAExE,IAAI,CAAC,YAAY;YAAE,OAAO,MAAM,CAAA;QAEhC,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,SAAS,CAAA;QAEvD,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAA;IAC9B,CAAC,CAAA;AACF,CAAC"}
1
+ {"version":3,"file":"geocode-handler.js","sourceRoot":"","sources":["../lib/geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA2C,IAAI,EAAE,MAAM,SAAS,CAAA;AAGvE;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,OAAuB,EACvB,OAAsB,EACtB,gBAAgB,GAAG,IAAI;IAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG;YAAE,OAAO,MAAM,CAAA;QAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;QAExE,IAAI,CAAC,YAAY;YAAE,OAAO,MAAM,CAAA;QAEhC,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,SAAS,CAAA;QAE1D,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAA;IAC9B,CAAC,CAAA;AACF,CAAC"}
package/out/geojson.d.ts CHANGED
@@ -9,8 +9,13 @@
9
9
  * (so rooftop-precise entities can be styled apart from admin-centroid guesses). Entities without
10
10
  * a coordinate are omitted (a Point feature needs one).
11
11
  */
12
- import type { GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
13
- import type { EntityGeoData, ResolvedEntity } from "./types.ts";
12
+ import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
13
+ import type { EntityGeoData, ResolvedEntity } from "#types";
14
+ /**
15
+ * One entity → one GeoJSON Point feature. `extra` merges over (and may override) the standard properties — the
16
+ * reconciliation flow adds its `bucket` and swaps the display name for the representative's org-or-person form.
17
+ */
18
+ export declare function toFeature(entity: ResolvedEntity, extra?: Partial<EntityGeoData>): GeoFeature<PointLiteral, EntityGeoData>;
14
19
  /**
15
20
  * Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS. Entities with no resolved
16
21
  * coordinate are skipped.
@@ -1 +1 @@
1
- {"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAc,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAA;AA8C7E;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAKhH"}
1
+ {"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../lib/geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,QAAQ,CAAA;AAkBzE;;;GAGG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,cAAc,EACtB,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,UAAU,CAAC,YAAY,EAAE,aAAa,CAAC,CAwBzC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAKhH"}
package/out/geojson.js CHANGED
@@ -24,9 +24,10 @@ function displayName(record) {
24
24
  return joined || null;
25
25
  }
26
26
  /**
27
- * One entity → one GeoJSON Point feature.
27
+ * One entity → one GeoJSON Point feature. `extra` merges over (and may override) the standard properties — the
28
+ * reconciliation flow adds its `bucket` and swaps the display name for the representative's org-or-person form.
28
29
  */
29
- function toFeature(entity) {
30
+ export function toFeature(entity, extra) {
30
31
  const rep = entity.representative;
31
32
  return {
32
33
  type: "Feature",
@@ -46,6 +47,7 @@ function toFeature(entity) {
46
47
  organization: rep.organization?.canonical ?? null,
47
48
  address: rep.address?.formatted ?? null,
48
49
  geocodeTier: rep.address?.geocode?.tier ?? null,
50
+ ...extra,
49
51
  },
50
52
  };
51
53
  }
@@ -56,7 +58,7 @@ function toFeature(entity) {
56
58
  export function toGeoJSON(entities) {
57
59
  return {
58
60
  type: "FeatureCollection",
59
- features: entities.filter((entity) => entity.coordinate).map(toFeature),
61
+ features: entities.filter((entity) => entity.coordinate).map((entity) => toFeature(entity)),
60
62
  };
61
63
  }
62
64
  //# sourceMappingURL=geojson.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geojson.js","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD;;GAEG;AACH,SAAS,WA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