@mailwoman/registry 10.0.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +11 -14
  2. package/lib/address-key.ts +14 -10
  3. package/lib/geocode-handler.ts +7 -5
  4. package/lib/geojson.ts +13 -7
  5. package/lib/ingest.ts +70 -92
  6. package/lib/learned-scorer.ts +38 -44
  7. package/lib/map-html.ts +26 -72
  8. package/lib/models/crosssource-gbt-en-us.ts +9 -7
  9. package/lib/models/dedup-gbt-en-us.ts +9 -8
  10. package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
  11. package/lib/reconcile.ts +45 -54
  12. package/lib/resolve.ts +187 -130
  13. package/lib/types.ts +35 -29
  14. package/out/address-key.d.ts +14 -10
  15. package/out/address-key.d.ts.map +1 -1
  16. package/out/address-key.js +14 -10
  17. package/out/address-key.js.map +1 -1
  18. package/out/geocode-handler.d.ts +6 -4
  19. package/out/geocode-handler.d.ts.map +1 -1
  20. package/out/geocode-handler.js +7 -5
  21. package/out/geocode-handler.js.map +1 -1
  22. package/out/geojson.d.ts +9 -5
  23. package/out/geojson.d.ts.map +1 -1
  24. package/out/geojson.js +13 -7
  25. package/out/geojson.js.map +1 -1
  26. package/out/ingest.d.ts +49 -76
  27. package/out/ingest.d.ts.map +1 -1
  28. package/out/ingest.js +37 -62
  29. package/out/ingest.js.map +1 -1
  30. package/out/learned-scorer.d.ts +29 -26
  31. package/out/learned-scorer.d.ts.map +1 -1
  32. package/out/learned-scorer.js +31 -39
  33. package/out/learned-scorer.js.map +1 -1
  34. package/out/map-html.d.ts +13 -32
  35. package/out/map-html.d.ts.map +1 -1
  36. package/out/map-html.js +11 -64
  37. package/out/map-html.js.map +1 -1
  38. package/out/models/crosssource-gbt-en-us.d.ts +9 -7
  39. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  40. package/out/models/crosssource-gbt-en-us.js +9 -7
  41. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  42. package/out/models/dedup-gbt-en-us.d.ts +9 -8
  43. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  44. package/out/models/dedup-gbt-en-us.js +9 -8
  45. package/out/models/dedup-gbt-en-us.js.map +1 -1
  46. package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
  47. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  48. package/out/models/org-crosssource-gbt-en-us.js +10 -8
  49. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  50. package/out/reconcile.d.ts +36 -50
  51. package/out/reconcile.d.ts.map +1 -1
  52. package/out/reconcile.js +18 -42
  53. package/out/reconcile.js.map +1 -1
  54. package/out/resolve.d.ts +152 -91
  55. package/out/resolve.d.ts.map +1 -1
  56. package/out/resolve.js +67 -68
  57. package/out/resolve.js.map +1 -1
  58. package/out/tools/coverage-reconciliation.d.ts +23 -23
  59. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  60. package/out/tools/coverage-reconciliation.js +15 -26
  61. package/out/tools/coverage-reconciliation.js.map +1 -1
  62. package/out/tools/cross/dataset-correlation.d.ts +23 -27
  63. package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
  64. package/out/tools/cross/dataset-correlation.js +9 -61
  65. package/out/tools/cross/dataset-correlation.js.map +1 -1
  66. package/out/tools/cross/source-threshold-sweep.d.ts +20 -26
  67. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
  68. package/out/tools/cross/source-threshold-sweep.js +14 -40
  69. package/out/tools/cross/source-threshold-sweep.js.map +1 -1
  70. package/out/tools/dedup-ceiling.d.ts +23 -26
  71. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  72. package/out/tools/dedup-ceiling.js +22 -41
  73. package/out/tools/dedup-ceiling.js.map +1 -1
  74. package/out/tools/eval-geocoder.d.ts +25 -16
  75. package/out/tools/eval-geocoder.d.ts.map +1 -1
  76. package/out/tools/eval-geocoder.js +5 -6
  77. package/out/tools/eval-geocoder.js.map +1 -1
  78. package/out/tools/geocoder/namesake-probe.d.ts +9 -8
  79. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
  80. package/out/tools/geocoder/namesake-probe.js +6 -7
  81. package/out/tools/geocoder/namesake-probe.js.map +1 -1
  82. package/out/tools/geocoder/vs-provided-coords.d.ts +18 -15
  83. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
  84. package/out/tools/geocoder/vs-provided-coords.js +30 -27
  85. package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
  86. package/out/tools/gold-set-sample.d.ts +27 -18
  87. package/out/tools/gold-set-sample.d.ts.map +1 -1
  88. package/out/tools/gold-set-sample.js +18 -22
  89. package/out/tools/gold-set-sample.js.map +1 -1
  90. package/out/tools/learned/scorer/clustering-eval.d.ts +30 -27
  91. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
  92. package/out/tools/learned/scorer/clustering-eval.js +28 -38
  93. package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
  94. package/out/tools/learned/scorer/crossstate-eval.d.ts +24 -18
  95. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
  96. package/out/tools/learned/scorer/crossstate-eval.js +19 -25
  97. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
  98. package/out/tools/learned/scorer/eval.d.ts +26 -39
  99. package/out/tools/learned/scorer/eval.d.ts.map +1 -1
  100. package/out/tools/learned/scorer/eval.js +11 -71
  101. package/out/tools/learned/scorer/eval.js.map +1 -1
  102. package/out/tools/matcher-scale.d.ts +12 -17
  103. package/out/tools/matcher-scale.d.ts.map +1 -1
  104. package/out/tools/matcher-scale.js +11 -29
  105. package/out/tools/matcher-scale.js.map +1 -1
  106. package/out/tools/nppes/dedup-benchmark.d.ts +22 -41
  107. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
  108. package/out/tools/nppes/dedup-benchmark.js +21 -67
  109. package/out/tools/nppes/dedup-benchmark.js.map +1 -1
  110. package/out/tools/nppes/org-name.d.ts +5 -11
  111. package/out/tools/nppes/org-name.d.ts.map +1 -1
  112. package/out/tools/nppes/org-name.js +2 -9
  113. package/out/tools/nppes/org-name.js.map +1 -1
  114. package/out/tools/nppes/overmerge-packet.d.ts +15 -11
  115. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
  116. package/out/tools/nppes/overmerge-packet.js +6 -7
  117. package/out/tools/nppes/overmerge-packet.js.map +1 -1
  118. package/out/tools/nppes/report.d.ts +17 -13
  119. package/out/tools/nppes/report.d.ts.map +1 -1
  120. package/out/tools/nppes/report.js +6 -14
  121. package/out/tools/nppes/report.js.map +1 -1
  122. package/out/tools/nppes/sample.d.ts +29 -18
  123. package/out/tools/nppes/sample.d.ts.map +1 -1
  124. package/out/tools/nppes/sample.js +24 -28
  125. package/out/tools/nppes/sample.js.map +1 -1
  126. package/out/tools/nppes/scoring.d.ts +7 -6
  127. package/out/tools/nppes/scoring.d.ts.map +1 -1
  128. package/out/tools/nppes/scoring.js +6 -5
  129. package/out/tools/nppes/scoring.js.map +1 -1
  130. package/out/tools/nppes/settings.d.ts +10 -7
  131. package/out/tools/nppes/settings.d.ts.map +1 -1
  132. package/out/tools/nppes/settings.js +16 -16
  133. package/out/tools/nppes/settings.js.map +1 -1
  134. package/out/tools/nppes/truth-grains.d.ts +36 -23
  135. package/out/tools/nppes/truth-grains.d.ts.map +1 -1
  136. package/out/tools/nppes/truth-grains.js +36 -20
  137. package/out/tools/nppes/truth-grains.js.map +1 -1
  138. package/out/tools/shared.d.ts +68 -72
  139. package/out/tools/shared.d.ts.map +1 -1
  140. package/out/tools/shared.js +50 -67
  141. package/out/tools/shared.js.map +1 -1
  142. package/out/tools/train/cross-gbt.d.ts +37 -26
  143. package/out/tools/train/cross-gbt.d.ts.map +1 -1
  144. package/out/tools/train/cross-gbt.js +14 -25
  145. package/out/tools/train/cross-gbt.js.map +1 -1
  146. package/out/tools/train/gbt.d.ts +36 -20
  147. package/out/tools/train/gbt.d.ts.map +1 -1
  148. package/out/tools/train/gbt.js +27 -31
  149. package/out/tools/train/gbt.js.map +1 -1
  150. package/out/tools/train/org-cross-gbt.d.ts +38 -24
  151. package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
  152. package/out/tools/train/org-cross-gbt.js +18 -22
  153. package/out/tools/train/org-cross-gbt.js.map +1 -1
  154. package/out/tools/txhhsc-to-oarow.d.ts +14 -9
  155. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  156. package/out/tools/txhhsc-to-oarow.js +16 -15
  157. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  158. package/out/tools/viz/browser.d.ts +6 -5
  159. package/out/tools/viz/browser.d.ts.map +1 -1
  160. package/out/tools/viz/browser.js +6 -5
  161. package/out/tools/viz/browser.js.map +1 -1
  162. package/out/tools/viz/cross-dataset-map.d.ts +7 -4
  163. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  164. package/out/tools/viz/cross-dataset-map.js +9 -6
  165. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  166. package/out/tools/viz/geocode-first-surface.d.ts +11 -5
  167. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  168. package/out/tools/viz/geocode-first-surface.js +16 -11
  169. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  170. package/out/tools/viz/render/map.d.ts +5 -5
  171. package/out/tools/viz/render/map.d.ts.map +1 -1
  172. package/out/tools/viz/render/map.js +6 -5
  173. package/out/tools/viz/render/map.js.map +1 -1
  174. package/out/tools/viz/{render/index.d.ts → render.d.ts} +13 -9
  175. package/out/tools/viz/render.d.ts.map +1 -0
  176. package/out/tools/viz/{render/index.js → render.js} +9 -8
  177. package/out/tools/viz/render.js.map +1 -0
  178. package/out/tools/viz/source-provenance-map.d.ts +19 -7
  179. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  180. package/out/tools/viz/source-provenance-map.js +11 -8
  181. package/out/tools/viz/source-provenance-map.js.map +1 -1
  182. package/out/tools/viz/yardstick-figure.d.ts +2 -21
  183. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  184. package/out/tools/viz/yardstick-figure.js +3 -39
  185. package/out/tools/viz/yardstick-figure.js.map +1 -1
  186. package/out/types.d.ts +35 -29
  187. package/out/types.d.ts.map +1 -1
  188. package/out/types.js +2 -2
  189. package/out/types.js.map +1 -1
  190. package/package.json +42 -185
  191. package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
  192. package/{lib/tools → tools}/cross/dataset-correlation.ts +35 -73
  193. package/{lib/tools → tools}/cross/source-threshold-sweep.ts +29 -46
  194. package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
  195. package/tools/eval-geocoder.ts +77 -0
  196. package/{lib/tools → tools}/geocoder/namesake-probe.ts +9 -8
  197. package/{lib/tools → tools}/geocoder/vs-provided-coords.ts +40 -31
  198. package/{lib/tools → tools}/gold-set-sample.ts +35 -29
  199. package/{lib/tools → tools}/learned/scorer/clustering-eval.ts +49 -45
  200. package/{lib/tools → tools}/learned/scorer/crossstate-eval.ts +34 -30
  201. package/{lib/tools → tools}/learned/scorer/eval.ts +39 -78
  202. package/{lib/tools → tools}/matcher-scale.ts +21 -33
  203. package/{lib/tools → tools}/nppes/dedup-benchmark.ts +39 -83
  204. package/tools/nppes/org-name.ts +15 -0
  205. package/{lib/tools → tools}/nppes/overmerge-packet.ts +16 -12
  206. package/{lib/tools → tools}/nppes/report.ts +32 -25
  207. package/{lib/tools → tools}/nppes/sample.ts +43 -38
  208. package/{lib/tools → tools}/nppes/scoring.ts +7 -6
  209. package/{lib/tools → tools}/nppes/settings.ts +16 -16
  210. package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
  211. package/{lib/tools → tools}/shared.ts +79 -98
  212. package/{lib/tools → tools}/train/cross-gbt.ts +39 -34
  213. package/{lib/tools → tools}/train/gbt.ts +55 -41
  214. package/{lib/tools → tools}/train/org-cross-gbt.ts +40 -30
  215. package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
  216. package/{lib/tools → tools}/viz/browser.ts +6 -5
  217. package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
  218. package/{lib/tools → tools}/viz/geocode-first-surface.ts +29 -17
  219. package/{lib/tools → tools}/viz/render/map.ts +7 -6
  220. package/{lib/tools/viz/render/index.ts → tools/viz/render.ts} +16 -11
  221. package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
  222. package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
  223. package/lib/tools/eval-geocoder.ts +0 -67
  224. package/lib/tools/index.ts +0 -31
  225. package/lib/tools/nppes/org-name.ts +0 -23
  226. package/out/tools/index.d.ts +0 -31
  227. package/out/tools/index.d.ts.map +0 -1
  228. package/out/tools/index.js +0 -31
  229. package/out/tools/index.js.map +0 -1
  230. package/out/tools/viz/render/index.d.ts.map +0 -1
  231. package/out/tools/viz/render/index.js.map +0 -1
package/out/ingest.js CHANGED
@@ -3,23 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Ingest — turn messy tabular data (CSV, SQLite, hand-keyed spreadsheets) into normalized
7
- * {@link SourceRecord}s, the front of the cascade.
8
- *
9
- * Two concerns, kept separate:
10
- *
11
- * 1. **Column mapping + normalization** (this is pure): a {@link ColumnMapping} says which column(s)
12
- * hold the name, organization, address, phone, email; each row is normalized with
13
- * `@mailwoman/record` (parse the person name, canonicalize the org). This is deterministic
14
- * and testable with no heavy runtime.
15
- * 2. **Geocoding** (the heavy part) is an injected dependency — a {@link GeocodeAddress} the caller provides.
16
- * Ingest never imports the neural parser, the resolver, or the extracts; it just calls the
17
- * call per address. {@link geocodeAddressVia} builds that geocoder from mailwoman's real parse +
18
- * geocode primitives (which the CLI constructs with the model + data in hand), so the wiring
19
- * is concrete and testable without pinning the heavy runtime into this package.
20
- *
21
- * LLM-assisted column mapping (infer the mapping from a header + samples) is a documented
22
- * fast-follow; the mapping is an explicit input here.
6
+ * Column mapping and normalization are pure. The caller injects geocoding, so this package never imports the neural parser, resolver, or extracts.
23
7
  */
24
8
  import { isPresent } from "@mailwoman/core/objects";
25
9
  import { canonicalizeOrganizationName, parsePersonName, toPostalAddress, withGeocode } from "@mailwoman/record";
@@ -27,8 +11,8 @@ import { CSVSpliterator, Delimiters } from "spliterator";
27
11
  /**
28
12
  * The column delimiters a tabular source may declare, by name, each the spliterator's own byte.
29
13
  *
30
- * The `satisfies` clause keys every name to a member of spliterator's `Delimiters` const, so a delimiter this map names
31
- * that spliterator no longer ships is a compile error rather than a silently parallel vocabulary.
14
+ * The `satisfies` clause makes a delimiter name spliterator no longer ships a compile error
15
+ * rather than a silently parallel vocabulary.
32
16
  */
33
17
  const COLUMN_DELIMITERS = {
34
18
  comma: Delimiters.Comma,
@@ -43,26 +27,22 @@ export function delimiterFor(path) {
43
27
  /**
44
28
  * Stream a delimited file's rows lazily as header-keyed objects.
45
29
  *
46
- * Returns the spliterator's own {@linkcode AsyncSequence}: nothing is opened until something iterates, a `take` that is
47
- * satisfied (or a `break` out of `for await`) closes the file handle, and any `map`/`filter` a caller composes fuses
48
- * into the same pull loop. Wrapping this in an `async function*` would cost an async frame per row and take those
49
- * operators away.
30
+ * @returns The spliterator's own {@linkcode AsyncSequence}, whose `map`/`filter`
31
+ * fuse into the same pull loop.
32
+ * An `async function*` wrapper would add an async frame per row and remove those operators.
50
33
  */
51
34
  export function streamRows(source, opts = {}) {
52
- return CSVSpliterator.fromAsync(source, {
53
- columnDelimiter: COLUMN_DELIMITERS[opts.delimiter ?? delimiterFor(source)],
54
- // A {@linkcode ColumnMapping} names columns in the PUBLISHER's spelling — `Facility Name`, not
55
- // `facility_name` — so the keys must arrive as the file writes them. The reader's default normalizes.
35
+ const path = source.toString();
36
+ return CSVSpliterator.fromAsync(path, {
37
+ columnDelimiter: COLUMN_DELIMITERS[opts.delimiter ?? delimiterFor(path)],
38
+ // A {@linkcode ColumnMapping} holds columns in the publisher's spelling rather than a
39
+ // normalized key such as `facility_name`, so the keys must arrive as the file writes them.
40
+ // The reader's default normalizes.
56
41
  normalizeKeys: false,
57
42
  });
58
43
  }
59
44
  /**
60
- * Best-effort {@link ColumnMapping} inferred from a header row — the "point it at any CSV" convenience. Each column name
61
- * is matched (case- and punctuation-insensitive, on whole tokens) to a field by keyword, in a precedence that resolves
62
- * the common ambiguities: a dedicated id / phone / email column is claimed before the generic sweep, an org / facility
63
- * column beats a person "name", and address columns (street / city / state / zip…) collect into one multi-column field.
64
- * Imperfect on bespoke headers (an explicit mapping or the LLM-assisted inference #603 is the answer there), but it
65
- * nails tidy and semi-tidy files with no hand-mapping. Unmatched columns are left out.
45
+ * Best-effort {@link ColumnMapping} inferred from a header row, the "point it at any CSV" convenience.
66
46
  */
67
47
  export function inferMapping(header) {
68
48
  // Pad to whole-token boundaries so "state" doesn't match inside "statement".
@@ -104,31 +84,30 @@ export function inferMapping(header) {
104
84
  return mapping;
105
85
  }
106
86
  /**
107
- * Join the named column(s) of a row into a single trimmed string, or undefined if empty.
87
+ * Join the selected columns of a row into a single trimmed string, or null if empty.
108
88
  */
109
89
  export function pick(row, columns, separator = " ") {
110
90
  if (!columns)
111
- return undefined;
91
+ return null;
112
92
  const list = Array.isArray(columns) ? columns : [columns];
113
93
  const value = list
114
- .map((c) => row[c]?.trim())
94
+ .map((c) => row[c])
115
95
  .filter(isPresent)
116
96
  .join(separator)
117
97
  .trim();
118
- return value || undefined;
98
+ return value || null;
119
99
  }
120
100
  /**
121
- * Normalize one tabular row into a {@link SourceRecord} under a {@link ColumnMapping}: parse the person name,
122
- * canonicalize the org, and (if `opts.geocodeAddress` is provided) geocode the joined address. `id` falls back to the
123
- * caller-supplied row index. Pure aside from the optional geocode interface, so the deterministic normalization can run
124
- * single-threaded (see {@link normalizeCSV}) while geocoding is offloaded (see `geocodeStream`).
101
+ * Normalize one tabular row into a {@link SourceRecord} under a {@link ColumnMapping},
102
+ * pure aside from the optional geocode interface so the deterministic normalization
103
+ * can run single-threaded while geocoding is offloaded.
125
104
  */
126
105
  export async function ingestRow(row, mapping, index, opts = {}) {
127
- const id = (mapping.id ? row[mapping.id]?.trim() : "") || String(index);
106
+ const id = (mapping.id ? row[mapping.id] : "") || String(index);
128
107
  const nameValue = pick(row, mapping.name);
129
108
  const orgValue = pick(row, mapping.organization);
130
109
  const addressValue = pick(row, mapping.address, opts.addressSeparator ?? ", ");
131
- let attributes;
110
+ let attributes = null;
132
111
  if (mapping.attributes) {
133
112
  for (const [key, columns] of Object.entries(mapping.attributes)) {
134
113
  const value = pick(row, columns);
@@ -140,12 +119,12 @@ export async function ingestRow(row, mapping, index, opts = {}) {
140
119
  }
141
120
  return {
142
121
  id,
143
- source: mapping.source,
144
- name: nameValue ? parsePersonName(nameValue) : undefined,
145
- organization: orgValue ? canonicalizeOrganizationName(orgValue) : undefined,
146
- phone: (mapping.phone && row[mapping.phone]?.trim()) || undefined,
147
- email: (mapping.email && row[mapping.email]?.trim()?.toLowerCase()) || undefined,
148
- address: addressValue && opts.geocodeAddress ? ((await opts.geocodeAddress(addressValue)) ?? undefined) : undefined,
122
+ source: mapping.source ?? null,
123
+ name: nameValue ? parsePersonName(nameValue) : null,
124
+ organization: orgValue ? canonicalizeOrganizationName(orgValue) : null,
125
+ phone: (mapping.phone && row[mapping.phone]) || null,
126
+ email: (mapping.email && row[mapping.email]?.toLowerCase()) || null,
127
+ address: addressValue && opts.geocodeAddress ? ((await opts.geocodeAddress(addressValue)) ?? null) : null,
149
128
  attributes,
150
129
  raw: row,
151
130
  };
@@ -153,7 +132,7 @@ export async function ingestRow(row, mapping, index, opts = {}) {
153
132
  /**
154
133
  * Normalize tabular rows into {@link SourceRecord}s under a {@link ColumnMapping}.
155
134
  *
156
- * @see {@link streamRows} for the streaming path, which is the preferred way to handle multi-GB files.
135
+ * @see {@link streamRows} for the streaming path. It is preferred for multi-GB files.
157
136
  */
158
137
  export async function ingestRows(rows, mapping, opts = {}) {
159
138
  const records = [];
@@ -165,22 +144,16 @@ export async function ingestRows(rows, mapping, opts = {}) {
165
144
  return records;
166
145
  }
167
146
  /**
168
- * Stream a delimited file as normalized {@link SourceRecord}s — `streamRows` + {@link ingestRow} with **no geocoding**.
169
- * This is the single-threaded, "fast enough" ergonomic core: column mapping, name parsing, and org canonicalization for
170
- * a multi-GB file, line by line. Geocode separately by piping the output through `geocodeStream` (the only heavy step
171
- * worth threading); for a light file (e.g. one that already carries geo cells) just consume this and stop.
172
- *
173
- * Records come out in file order: the sequence's `map` settles each row before pulling the next, and its counter is the
174
- * row's index — the id a row without a mapped `id` column falls back to.
147
+ * Stream a delimited file as normalized {@link SourceRecord}s in file order with no geocoding.
148
+ * Geocode separately through `geocodeStream`.
175
149
  */
176
150
  export function normalizeCSV(source, opts) {
177
151
  return streamRows(source, { delimiter: opts.delimiter }).map((row, index) => ingestRow(row, opts.mapping, index));
178
152
  }
179
153
  /**
180
- * Build a {@link GeocodeAddress} from mailwoman's real parse + geocode primitives (injected — the CLI constructs the
181
- * neural parser, resolver, and extracts and passes them in). Parse → components → {@link toPostalAddress} (which fills
182
- * the canonical key + formatted form) → attach the resolved coordinate. When geocoding can't place the address, the
183
- * parsed-but-unlocated address is still returned.
154
+ * Build a {@link GeocodeAddress} from injected parse and geocode primitives.
155
+ *
156
+ * When geocoding can't place the address, the parsed-but-unlocated address is still returned.
184
157
  */
185
158
  export function geocodeAddressVia(deps) {
186
159
  return async (raw) => {
@@ -202,7 +175,9 @@ export function geocodeAddressVia(deps) {
202
175
  coordinate: { latitude: resolved.lat, longitude: resolved.lon },
203
176
  tier: resolved.resolution_tier,
204
177
  uncertaintyMeters: resolved.uncertainty_m,
205
- hierarchy: resolved.hierarchy,
178
+ hierarchy: resolved.hierarchy ?? null,
179
+ poBox: null,
180
+ multiUnit: null,
206
181
  };
207
182
  return withGeocode(base, geocode);
208
183
  };
package/out/ingest.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ingest.js","sourceRoot":"","sources":["../lib/ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,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,CAAC,GAAG,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QAE5E,MAAM,OAAO,GAAmB;YAC/B,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,EAAE;YAC/D,IAAI,EAAE,QAAQ,CAAC,eAAe;YAC9B,iBAAiB,EAAE,QAAQ,CAAC,aAAa;YACzC,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,IAAI;YACrC,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;SACf,CAAA;QAED,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC,CAAA;AACF,CAAC"}
@@ -3,24 +3,19 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The learned scorer (#603) — the production wiring for the gradient-boosted-tree model behind
7
- * {@link ResolveConfig.scorer}. Two pieces:
6
+ * The learned scorer, the production wiring for the gradient-boosted-tree model behind
7
+ * {@link ResolveConfig.scorer}.
8
8
  *
9
- * 1. {@link createMatchFeaturizer} — the ONE feature extractor for a candidate pair, used identically
10
- * at train time (`registry/tools/train-gbt.ts`), eval time (the learned-scorer
11
- * evals), and inference time (here). A pair → one-hot of each comparison's agreement level +
12
- * the over-merge interaction terms (co-located × name/org disagreement) + address
13
- * crowdedness.
14
- * 2. {@link createGBTScorer} — wraps a trained {@link GBT} + the featurizer into the `(a, b) => number`
15
- * the resolve pipeline's `scorer` hook expects (a logit, threshold-comparable with the
16
- * Fellegi-Sunter weight it replaces).
9
+ * {@link createMatchFeaturizer} is the one feature extractor for a candidate pair, used
10
+ * identically at train time (`registry/tools/train-gbt.ts`), eval time and inference time.
11
+ * {@link createGBTScorer} wraps a trained {@link GBT} and the featurizer into the `(a, b) => number`
12
+ * the resolve pipeline's `scorer` hook expects (a logit, threshold-comparable with the
13
+ * Fellegi-Sunter weight it replaces).
17
14
  *
18
- * Both take the comparison set as INPUT (rather than importing {@link buildDefaultModel}) so this
19
- * module has no dependency cycle with `resolve.ts`. The contract that keeps train ≡ inference:
20
- * feed the comparisons from `buildDefaultModel({ collapseSpatial: true, addressFrequency })` —
21
- * the model's structure (and thus the feature layout) is fixed by that config; only the frequency
22
- * VALUES differ between the training corpus and the matched set, which is the point (the model
23
- * generalizes, as the cross-state eval showed).
15
+ * Both take the comparison set as input rather than importing {@link buildDefaultModel}, so this
16
+ * module has no dependency cycle with `resolve.ts`. Feed the comparisons from
17
+ * `buildDefaultModel({ collapseSpatial: true, addressFrequency })`, since that config fixes the
18
+ * feature layout.
24
19
  */
25
20
  import { type Comparison, type GBT, type TermFrequencyTable } from "@mailwoman/match";
26
21
  import type { SourceRecord } from "#types";
@@ -29,10 +24,13 @@ import type { SourceRecord } from "#types";
29
24
  */
30
25
  export interface LearnedFeatureConfig {
31
26
  /**
32
- * The comparison set the features are built over — MUST be `buildDefaultModel({ collapseSpatial: true,
33
- * addressFrequency }).comparisons` so the feature layout matches the trained model. (`usePhone` / `discriminators`
34
- * are NOT part of the learned feature model — the GBT replaces the FS weight wholesale and owns its own feature
35
- * vector.)
27
+ * The comparison set the features are built over.
28
+ *
29
+ * It must be `buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons`
30
+ * so the feature layout matches the trained model.
31
+ *
32
+ * `usePhone` and `discriminators` are not part of the learned feature model,
33
+ * since the GBT replaces the Fellegi-Sunter weight wholesale and owns its feature vector.
36
34
  */
37
35
  comparisons: Comparison<SourceRecord>[];
38
36
  /**
@@ -41,16 +39,21 @@ export interface LearnedFeatureConfig {
41
39
  addressFrequency: TermFrequencyTable;
42
40
  }
43
41
  /**
44
- * Build the per-pair feature extractor. The vector is: one-hot of each comparison's agreement level, then the two
45
- * over-merge interaction terms (spatial-exact × name-disagree, spatial-exact × org-disagree — the "same place,
46
- * different names" signature that drives co-located over-merges), then address crowdedness scaled into [0, 1].
42
+ * Build the per-pair feature extractor.
43
+ *
44
+ * The vector is: one-hot of each comparison's agreement level, then the two over-merge
45
+ * interaction terms (spatial-exact × name-disagree, spatial-exact × org-disagree,
46
+ * the "same place, different names" signature that drives co-located over-merges),
47
+ * then address crowdedness scaled into [0, 1].
47
48
  * Deterministic and EM-independent, so it is identical across train / eval / inference.
48
49
  */
49
50
  export declare function createMatchFeaturizer(config: LearnedFeatureConfig): (a: SourceRecord, b: SourceRecord) => number[];
50
51
  /**
51
- * Wrap a trained {@link GBT} into the `(a, b) => number` link scorer for {@link ResolveConfig.scorer}. The returned
52
- * weight is the model's logit — same threshold-comparable units as the Fellegi-Sunter weight it replaces, so the
53
- * pipeline's clustering + threshold semantics are unchanged.
52
+ * Wrap a trained {@link GBT} into the `(a, b) => number` link scorer for {@link ResolveConfig.scorer}.
53
+ *
54
+ * The returned weight is the model's logit.
55
+ * Same threshold-comparable units as the Fellegi-Sunter weight it replaces,
56
+ * so the pipeline's clustering + threshold semantics are unchanged.
54
57
  */
55
58
  export declare function createGBTScorer(config: LearnedFeatureConfig & {
56
59
  model: GBT;
@@ -1 +1 @@
1
- {"version":3,"file":"learned-scorer.d.ts","sourceRoot":"","sources":["../lib/learned-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,GAAG,EAGR,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAS1C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,WAAW,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAA;IACvC;;OAEG;IACH,gBAAgB,EAAE,kBAAkB,CAAA;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,MAAM,EAAE,CA2DlH;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,oBAAoB,GAAG;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,GAC3C,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,MAAM,CAK9C"}
1
+ {"version":3,"file":"learned-scorer.d.ts","sourceRoot":"","sources":["../lib/learned-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,GAAG,EAGR,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAS1C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;OAQG;IACH,WAAW,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAA;IACvC;;OAEG;IACH,gBAAgB,EAAE,kBAAkB,CAAA;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,MAAM,EAAE,CAkDlH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,oBAAoB,GAAG;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,GAC3C,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,MAAM,CAK9C"}
@@ -3,36 +3,34 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The learned scorer (#603) — the production wiring for the gradient-boosted-tree model behind
7
- * {@link ResolveConfig.scorer}. Two pieces:
6
+ * The learned scorer, the production wiring for the gradient-boosted-tree model behind
7
+ * {@link ResolveConfig.scorer}.
8
8
  *
9
- * 1. {@link createMatchFeaturizer} — the ONE feature extractor for a candidate pair, used identically
10
- * at train time (`registry/tools/train-gbt.ts`), eval time (the learned-scorer
11
- * evals), and inference time (here). A pair → one-hot of each comparison's agreement level +
12
- * the over-merge interaction terms (co-located × name/org disagreement) + address
13
- * crowdedness.
14
- * 2. {@link createGBTScorer} — wraps a trained {@link GBT} + the featurizer into the `(a, b) => number`
15
- * the resolve pipeline's `scorer` hook expects (a logit, threshold-comparable with the
16
- * Fellegi-Sunter weight it replaces).
9
+ * {@link createMatchFeaturizer} is the one feature extractor for a candidate pair, used
10
+ * identically at train time (`registry/tools/train-gbt.ts`), eval time and inference time.
11
+ * {@link createGBTScorer} wraps a trained {@link GBT} and the featurizer into the `(a, b) => number`
12
+ * the resolve pipeline's `scorer` hook expects (a logit, threshold-comparable with the
13
+ * Fellegi-Sunter weight it replaces).
17
14
  *
18
- * Both take the comparison set as INPUT (rather than importing {@link buildDefaultModel}) so this
19
- * module has no dependency cycle with `resolve.ts`. The contract that keeps train ≡ inference:
20
- * feed the comparisons from `buildDefaultModel({ collapseSpatial: true, addressFrequency })` —
21
- * the model's structure (and thus the feature layout) is fixed by that config; only the frequency
22
- * VALUES differ between the training corpus and the matched set, which is the point (the model
23
- * generalizes, as the cross-state eval showed).
15
+ * Both take the comparison set as input rather than importing {@link buildDefaultModel}, so this
16
+ * module has no dependency cycle with `resolve.ts`. Feed the comparisons from
17
+ * `buildDefaultModel({ collapseSpatial: true, addressFrequency })`, since that config fixes the
18
+ * feature layout.
24
19
  */
25
20
  import { agreementPattern, gbtScore, nameSimilarity, } from "@mailwoman/match";
26
21
  /**
27
- * Similarity at which two official names count as the same organisation. Set high because the feature is a near-exact
28
- * agreement signal, not a fuzzy one — the fuzzy comparison is a separate feature and this one exists to distinguish
29
- * it.
22
+ * Similarity at which two official names count as the same organization.
23
+ *
24
+ * Set high because the feature is a near-exact agreement signal rather than a fuzzy one.
30
25
  */
31
26
  const OFFICIAL_NAME_AGREEMENT = 0.93;
32
27
  /**
33
- * Build the per-pair feature extractor. The vector is: one-hot of each comparison's agreement level, then the two
34
- * over-merge interaction terms (spatial-exact × name-disagree, spatial-exact × org-disagree — the "same place,
35
- * different names" signature that drives co-located over-merges), then address crowdedness scaled into [0, 1].
28
+ * Build the per-pair feature extractor.
29
+ *
30
+ * The vector is: one-hot of each comparison's agreement level, then the two over-merge
31
+ * interaction terms (spatial-exact × name-disagree, spatial-exact × org-disagree,
32
+ * the "same place, different names" signature that drives co-located over-merges),
33
+ * then address crowdedness scaled into [0, 1].
36
34
  * Deterministic and EM-independent, so it is identical across train / eval / inference.
37
35
  */
38
36
  export function createMatchFeaturizer(config) {
@@ -53,7 +51,6 @@ export function createMatchFeaturizer(config) {
53
51
  f.push(lvl === l ? 1 : 0);
54
52
  }
55
53
  }
56
- // Interaction: co-located (spatial exact = level 0) AND names/org disagree (catch-all level).
57
54
  const spatialExact = spatialI !== undefined && pat[spatialI] === 0 ? 1 : 0;
58
55
  const nameDisagree = givenI !== undefined &&
59
56
  familyI !== undefined &&
@@ -62,34 +59,29 @@ export function createMatchFeaturizer(config) {
62
59
  ? 1
63
60
  : 0;
64
61
  const orgDisagree = orgI !== undefined && pat[orgI] === lastLevel(orgI) ? 1 : 0;
65
- f.push(spatialExact * nameDisagree); // the over-merge signature: same place, names disagree
62
+ f.push(spatialExact * nameDisagree);
66
63
  f.push(spatialExact * orgDisagree);
67
- // Address crowdedness (how shared this address is) — high → "same address" is weak evidence.
68
64
  const freq = a.address?.raw ? addressFrequency.frequency(a.address.raw) : 0;
69
65
  f.push(Math.min(1, freq * 1000));
70
- // #625 roll-up signature (2026-07-06 adjudication): every genuine over-merge in the adjudicated
71
- // packet was a MANAGEMENT-COMPANY roll-up — differently-branded operating entities at a shared
72
- // corporate/billing address where the AUTHORIZED OFFICIAL also agrees (the operator signs
73
- // everything). The official is NOT in the comparison set (discriminators are excluded from the
74
- // learned feature model), so the GBT could never see — let alone learn — that officialAgree in
75
- // the presence of orgDisagree is ANTI-identity evidence. These three appended features express
76
- // it directly from `attributes.authorizedOfficial`; appended at the END so models trained
77
- // without them (the cross-source GBT) keep scoring unchanged (trailing features are ignored).
66
+ // Roll-up signature: a shared corporate address can host differently-branded
67
+ // operating entities whose authorized official also agrees.
68
+ // The official is not in the comparison set, so these three features express that evidence directly.
69
+ // They are appended at the end, so models trained without them keep scoring unchanged.
78
70
  const offA = a.attributes?.["authorizedOfficial"]?.trim();
79
71
  const offB = b.attributes?.["authorizedOfficial"]?.trim();
80
72
  const officialAgree = offA && offB && nameSimilarity(offA, offB) >= OFFICIAL_NAME_AGREEMENT ? 1 : 0;
81
73
  f.push(officialAgree);
82
- f.push(officialAgree * orgDisagree); // the roll-up core: same signer, different brand
74
+ f.push(officialAgree * orgDisagree);
83
75
  f.push(officialAgree * orgDisagree * spatialExact);
84
- // …at the same place
85
- // scale into a usable range
86
76
  return f;
87
77
  };
88
78
  }
89
79
  /**
90
- * Wrap a trained {@link GBT} into the `(a, b) => number` link scorer for {@link ResolveConfig.scorer}. The returned
91
- * weight is the model's logit — same threshold-comparable units as the Fellegi-Sunter weight it replaces, so the
92
- * pipeline's clustering + threshold semantics are unchanged.
80
+ * Wrap a trained {@link GBT} into the `(a, b) => number` link scorer for {@link ResolveConfig.scorer}.
81
+ *
82
+ * The returned weight is the model's logit.
83
+ * Same threshold-comparable units as the Fellegi-Sunter weight it replaces,
84
+ * so the pipeline's clustering + threshold semantics are unchanged.
93
85
  */
94
86
  export function createGBTScorer(config) {
95
87
  const featurize = createMatchFeaturizer(config);
@@ -1 +1 @@
1
- {"version":3,"file":"learned-scorer.js","sourceRoot":"","sources":["../lib/learned-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACN,gBAAgB,EAGhB,QAAQ,EACR,cAAc,GAEd,MAAM,kBAAkB,CAAA;AAIzB;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAA;AAmBpC;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA4B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C,aAAa,CAAC,CAAA;QACrB,CAAC,CAAC,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,CAAA;QACnC,CAAC,CAAC,IAAI,CAAC,aAAa,GAAG,WAAW,GAAG,YAAY,CAAC,CAAA;QAElD,OAAO,CAAC,CAAA;IACT,CAAC,CAAA;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC9B,MAA6C;IAE7C,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAExB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC"}
package/out/map-html.d.ts CHANGED
@@ -2,27 +2,6 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * Render resolved entities as a standalone map page — the visual complement to {@link toGeoJSON}'s
7
- * QGIS/analyst export. `toMapHTML(featureCollection)` returns one HTML file you open in a
8
- * browser; no server, no build.
9
- *
10
- * It renders on the HOUSE stack: MapLibre GL + a Protomaps basemap (`@protomaps/basemaps` generates
11
- * the `layers()` for a named flavor) over the `basemap-v4` vector tiles served from R2 at
12
- * `tiles.mailwoman.ai` — the same basemap the demo uses. Each entity is a circle sized by
13
- * records-merged and colored by cross-dataset-link status (≥2 sources stand out), or
14
- * categorically by `bucket` when the reconciliation output carries one. Pure: GeoJSON in, HTML
15
- * string out (the Protomaps layer specs are generated at this point and inlined). The generated
16
- * page fetches MapLibre, the basemap tiles, and glyphs/sprite over the network when opened (the
17
- * house infra).
18
- *
19
- * SERVE IT OVER LOCALHOST, don't open it as a file. The house tile server (`tiles.mailwoman.ai`)
20
- * CORS-restricts to localhost + the docs domains, so a `file://` page shows the (accurate)
21
- * markers on a blank basemap. `npx serve` / `python3 -m http.server` in the output directory is
22
- * enough; the page also surfaces a hint banner when it detects it's running from `file://`.
23
- *
24
- * Neutral entity-resolution view: it shows what resolved to what and how confidently (cohesion).
25
- * Bucket labels render verbatim from the data, never editorialized.
26
5
  */
27
6
  import type { GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
28
7
  import type { MapFeatureData } from "#types";
@@ -30,29 +9,31 @@ import type { MapFeatureData } from "#types";
30
9
  * Protomaps stock flavors (shipped by `@protomaps/basemaps`).
31
10
  */
32
11
  export type MapFlavor = "light" | "dark" | "white" | "grayscale" | "black";
12
+ /**
13
+ * Options for {@link toMapHTML}.
14
+ *
15
+ * With `colorBy: "auto"`, markers are colored by `bucket` when any feature has one
16
+ * and otherwise by whether two or more sources agree.
17
+ */
33
18
  export interface MapHTMLOptions {
34
19
  /**
35
- * Document `<title>` + on-map heading. Default: "Mailwoman — resolved entities".
20
+ * Sets the document title and on-map heading, defaulting to `Mailwoman — resolved entities`.
36
21
  */
37
22
  title?: string;
38
23
  /**
39
- * Protomaps basemap flavor. Default: "light" (data points read cleanly over it).
24
+ * Selects the Protomaps basemap flavor, defaulting to `light`, over which the markers read clearly.
40
25
  */
41
26
  flavor?: MapFlavor;
42
27
  /**
43
- * How to color the markers:
44
- *
45
- * - `"auto"` (default) — by `bucket` if any feature carries one (reconciliation output), else by cross-dataset-link
46
- * status.
47
- * - `"sources"` — always by cross-dataset-link status (≥2 sources stand out).
48
- * - `"bucket"` — always by the `bucket` property.
28
+ * Chooses marker colors: `bucket` uses the `bucket` property, `sources` shows
29
+ * whether two or more sources are linked.
30
+ * The default `auto` picks `bucket` when any feature has one.
49
31
  */
50
32
  colorBy?: "auto" | "sources" | "bucket";
51
33
  }
52
34
  /**
53
- * Render `geojson` (a {@link toGeoJSON} / reconciliation FeatureCollection) as a complete, standalone HTML document.
54
- * Entities without a coordinate are already absent from those collections; an empty collection renders a friendly empty
55
- * state rather than a broken map.
35
+ * Renders a {@link toGeoJSON} or reconciliation feature collection as a standalone MapLibre
36
+ * HTML document, with an empty-state panel when the collection has no features.
56
37
  */
57
38
  export declare function toMapHTML(geojson: GeoFeatureCollection<PointLiteral, MapFeatureData>, options?: MapHTMLOptions): string;
58
39
  //# sourceMappingURL=map-html.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map-html.d.ts","sourceRoot":"","sources":["../lib/map-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAwB5C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAA;AAE1E,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAA;CACvC;AA4BD;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,OAAO,EAAE,oBAAoB,CAAC,YAAY,EAAE,cAAc,CAAC,EAC3D,OAAO,GAAE,cAAmB,GAC1B,MAAM,CA0NR"}
1
+ {"version":3,"file":"map-html.d.ts","sourceRoot":"","sources":["../lib/map-html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAa5C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAA;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;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