@mailwoman/registry 4.16.1 → 5.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.
- package/out/address-key.d.ts +9 -10
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js +10 -11
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +18 -0
- package/out/geocode-handler.d.ts.map +1 -0
- package/out/geocode-handler.js +27 -0
- package/out/geocode-handler.js.map +1 -0
- package/out/geojson.d.ts +2 -2
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +3 -3
- package/out/geojson.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/ingest.d.ts +78 -51
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +96 -63
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +12 -15
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js +9 -10
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +5 -5
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +21 -22
- package/out/map-html.js.map +1 -1
- package/out/reconcile.d.ts +9 -11
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +10 -12
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +60 -70
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +14 -17
- package/out/resolve.js.map +1 -1
- package/out/types.d.ts +6 -7
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +15 -15
package/out/address-key.d.ts
CHANGED
|
@@ -7,25 +7,24 @@
|
|
|
7
7
|
* resolved {@link SourceRecord} and exposes it as a blocking key — the deterministic,
|
|
8
8
|
* exact-canonical-address complement to the fuzzy Fellegi-Sunter / GBT scoring. Two uses:
|
|
9
9
|
*
|
|
10
|
-
* - **As a pre-dedup / join key:** `GROUP BY
|
|
10
|
+
* - **As a pre-dedup / join key:** `GROUP BY postalAddressID(record)` collapses records that resolve
|
|
11
11
|
* to the same place AND share a canonical address with NO scoring at all — the cheap, certain
|
|
12
12
|
* slice of dedup before the matcher does the fuzzy rest.
|
|
13
|
-
* - **As a blocking key:** {@link
|
|
13
|
+
* - **As a blocking key:** {@link addressIDBlockingKey} adds the address-id to the blocking union, so
|
|
14
14
|
* records sharing one are guaranteed to be compared.
|
|
15
15
|
*/
|
|
16
16
|
import { type PostalAddressID } from "@mailwoman/address-id";
|
|
17
17
|
import { type BlockingKey } from "@mailwoman/match";
|
|
18
18
|
import type { SourceRecord } from "./types.js";
|
|
19
19
|
/**
|
|
20
|
-
* The stable address primary key for a record, or null when it isn't geocoded (no coordinate → no
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* The stable address primary key for a record, or null when it isn't geocoded (no coordinate → no locality cell) or
|
|
21
|
+
* carries no raw address to hash. Uses the resolved coordinate + the raw address; the state prefix is plucked from the
|
|
22
|
+
* address when present.
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function postalAddressID(record: SourceRecord): PostalAddressID | null;
|
|
25
25
|
/**
|
|
26
|
-
* A blocking key on the {@link
|
|
27
|
-
*
|
|
28
|
-
* address join should never be missed.
|
|
26
|
+
* A blocking key on the {@link postalAddressID} — records that resolve to the same place with the same canonical address
|
|
27
|
+
* block together. Add it to {@link defaultBlockingKeys}'s union when an exact address join should never be missed.
|
|
29
28
|
*/
|
|
30
|
-
export declare function
|
|
29
|
+
export declare function addressIDBlockingKey(): BlockingKey<SourceRecord>;
|
|
31
30
|
//# sourceMappingURL=address-key.d.ts.map
|
package/out/address-key.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/out/address-key.js
CHANGED
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
* resolved {@link SourceRecord} and exposes it as a blocking key — the deterministic,
|
|
8
8
|
* exact-canonical-address complement to the fuzzy Fellegi-Sunter / GBT scoring. Two uses:
|
|
9
9
|
*
|
|
10
|
-
* - **As a pre-dedup / join key:** `GROUP BY
|
|
10
|
+
* - **As a pre-dedup / join key:** `GROUP BY postalAddressID(record)` collapses records that resolve
|
|
11
11
|
* to the same place AND share a canonical address with NO scoring at all — the cheap, certain
|
|
12
12
|
* slice of dedup before the matcher does the fuzzy rest.
|
|
13
|
-
* - **As a blocking key:** {@link
|
|
13
|
+
* - **As a blocking key:** {@link addressIDBlockingKey} adds the address-id to the blocking union, so
|
|
14
14
|
* records sharing one are guaranteed to be compared.
|
|
15
15
|
*/
|
|
16
16
|
import { createPostalAddressID } from "@mailwoman/address-id";
|
|
17
17
|
import { exactKey } from "@mailwoman/match";
|
|
18
18
|
/**
|
|
19
|
-
* The stable address primary key for a record, or null when it isn't geocoded (no coordinate → no
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* The stable address primary key for a record, or null when it isn't geocoded (no coordinate → no locality cell) or
|
|
20
|
+
* carries no raw address to hash. Uses the resolved coordinate + the raw address; the state prefix is plucked from the
|
|
21
|
+
* address when present.
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
23
|
+
export function postalAddressID(record) {
|
|
24
24
|
const coordinate = record.address?.geocode?.coordinate;
|
|
25
25
|
const address = record.address?.raw;
|
|
26
26
|
if (!coordinate || !address)
|
|
@@ -28,11 +28,10 @@ export function postalAddressId(record) {
|
|
|
28
28
|
return createPostalAddressID({ coordinate, address });
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* A blocking key on the {@link
|
|
32
|
-
*
|
|
33
|
-
* address join should never be missed.
|
|
31
|
+
* A blocking key on the {@link postalAddressID} — records that resolve to the same place with the same canonical address
|
|
32
|
+
* block together. Add it to {@link defaultBlockingKeys}'s union when an exact address join should never be missed.
|
|
34
33
|
*/
|
|
35
|
-
export function
|
|
36
|
-
return exactKey((record) =>
|
|
34
|
+
export function addressIDBlockingKey() {
|
|
35
|
+
return exactKey((record) => postalAddressID(record));
|
|
37
36
|
}
|
|
38
37
|
//# sourceMappingURL=address-key.js.map
|
package/out/address-key.js.map
CHANGED
|
@@ -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;
|
|
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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
import { type ColumnMapping, type GeocodeAddress } from "./ingest.js";
|
|
10
|
+
import type { SourceRecord } from "./types.js";
|
|
11
|
+
/**
|
|
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.
|
|
14
|
+
* Records with no mapped address pass through untouched (no geocode call). The default separator matches
|
|
15
|
+
* {@link ingestRow}'s `addressSeparator`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function makeGeocodeHandler(seam: GeocodeAddress, mapping: ColumnMapping, addressSeparator?: string): (record: SourceRecord) => Promise<SourceRecord>;
|
|
18
|
+
//# sourceMappingURL=geocode-handler.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
import { pick } from "./ingest.js";
|
|
10
|
+
/**
|
|
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.
|
|
13
|
+
* Records with no mapped address pass through untouched (no geocode call). The default separator matches
|
|
14
|
+
* {@link ingestRow}'s `addressSeparator`.
|
|
15
|
+
*/
|
|
16
|
+
export function makeGeocodeHandler(seam, mapping, addressSeparator = ", ") {
|
|
17
|
+
return async (record) => {
|
|
18
|
+
if (!record.raw)
|
|
19
|
+
return record;
|
|
20
|
+
const addressValue = pick(record.raw, mapping.address, addressSeparator);
|
|
21
|
+
if (!addressValue)
|
|
22
|
+
return record;
|
|
23
|
+
const address = (await seam(addressValue)) ?? undefined;
|
|
24
|
+
return { ...record, address };
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=geocode-handler.js.map
|
|
@@ -0,0 +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"}
|
package/out/geojson.d.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
import type { GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
|
|
13
13
|
import type { EntityGeoData, ResolvedEntity } from "./types.js";
|
|
14
14
|
/**
|
|
15
|
-
* Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS. Entities
|
|
16
|
-
*
|
|
15
|
+
* Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS. Entities with no resolved
|
|
16
|
+
* coordinate are skipped.
|
|
17
17
|
*/
|
|
18
18
|
export declare function toGeoJSON(entities: readonly ResolvedEntity[]): GeoFeatureCollection<PointLiteral, EntityGeoData>;
|
|
19
19
|
//# sourceMappingURL=geojson.d.ts.map
|
package/out/geojson.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAc,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAc,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAA;AAyC7E;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAKhH"}
|
package/out/geojson.js
CHANGED
|
@@ -31,7 +31,7 @@ function toFeature(entity) {
|
|
|
31
31
|
coordinates: [entity.coordinate.longitude, entity.coordinate.latitude],
|
|
32
32
|
},
|
|
33
33
|
properties: {
|
|
34
|
-
|
|
34
|
+
entityID: entity.id,
|
|
35
35
|
recordCount: entity.records.length,
|
|
36
36
|
cohesion: entity.cohesion,
|
|
37
37
|
sourceIds: entity.records.map((r) => r.id),
|
|
@@ -45,8 +45,8 @@ function toFeature(entity) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS. Entities
|
|
49
|
-
*
|
|
48
|
+
* Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS. Entities with no resolved
|
|
49
|
+
* coordinate are skipped.
|
|
50
50
|
*/
|
|
51
51
|
export function toGeoJSON(entities) {
|
|
52
52
|
return {
|
package/out/geojson.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson.js","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"geojson.js","sourceRoot":"","sources":["../geojson.ts"],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EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACjG,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC;YACtB,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,SAAS,IAAI,IAAI;YACjD,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,SAAS,IAAI,IAAI;YACvC,WAAW,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI;SAC/C;KACD,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAmC;IAC5D,OAAO;QACN,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;KACvE,CAAA;AACF,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
export * from "./address-key.js";
|
|
14
14
|
export * from "./geojson.js";
|
|
15
15
|
export * from "./ingest.js";
|
|
16
|
+
export * from "./geocode-handler.js";
|
|
16
17
|
export * from "./learned-scorer.js";
|
|
17
18
|
export * from "./map-html.js";
|
|
18
19
|
export * from "./models/dedup-gbt-en-us.js";
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
export * from "./address-key.js";
|
|
14
14
|
export * from "./geojson.js";
|
|
15
15
|
export * from "./ingest.js";
|
|
16
|
+
export * from "./geocode-handler.js";
|
|
16
17
|
export * from "./learned-scorer.js";
|
|
17
18
|
export * from "./map-html.js";
|
|
18
19
|
export * from "./models/dedup-gbt-en-us.js";
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
package/out/ingest.d.ts
CHANGED
|
@@ -31,30 +31,27 @@ export type Delimiter = "comma" | "tab";
|
|
|
31
31
|
/** Infer the delimiter from a path's extension (`.tsv` → tab, else comma). */
|
|
32
32
|
export declare function delimiterFor(path: string): Delimiter;
|
|
33
33
|
/**
|
|
34
|
-
* Stream a delimited file's rows lazily as header-keyed objects — the same shape {@link
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* you geocode.
|
|
34
|
+
* Stream a delimited file's rows lazily as header-keyed objects — the same shape {@link parseCSV} returns, but
|
|
35
|
+
* **without loading the file into memory**. A multi-GB source (the NPPES registry is ~4.8 GB / 9.6M rows — too big for
|
|
36
|
+
* `readFileSync`, which throws `ERR_STRING_TOO_LONG`) streams line by line. Keys are the original header names so a
|
|
37
|
+
* {@link ColumnMapping} written against the source's headers matches. Filter/sample the stream before
|
|
38
|
+
* {@link ingestRows} to keep only the rows you geocode.
|
|
40
39
|
*
|
|
41
|
-
* We stream _lines_ with spliterator's `TextSpliterator` (pure-Node, the part that handles the huge
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* revisit when it's fixed.)
|
|
40
|
+
* We stream _lines_ with spliterator's `TextSpliterator` (pure-Node, the part that handles the huge file) and split
|
|
41
|
+
* each line into columns here with `String.prototype.split`. We deliberately do NOT use `CSVSpliterator`: its column
|
|
42
|
+
* tokenizer hard-codes `skipEmpty` (it builds the column spliterator as `{ delimiter }` with no `skipEmpty: false`), so
|
|
43
|
+
* consecutive delimiters collapse and EMPTY FIELDS ARE DROPPED — fatal for a fixed-width registry like NPPES where a
|
|
44
|
+
* row of 330 columns full of empties would mis-parse to 40 and shift every value. (Upstream `spliterator` bug; revisit
|
|
45
|
+
* when it's fixed.)
|
|
48
46
|
*
|
|
49
|
-
* Assumes an unquoted delimited file (no fields containing the delimiter) — true for these
|
|
50
|
-
*
|
|
47
|
+
* Assumes an unquoted delimited file (no fields containing the delimiter) — true for these government TSVs. For small,
|
|
48
|
+
* possibly-quoted CSVs use {@link parseCSV} (quote-aware, in-memory).
|
|
51
49
|
*/
|
|
52
50
|
export declare function streamRows(source: string, opts?: {
|
|
53
51
|
delimiter?: Delimiter;
|
|
54
52
|
}): AsyncGenerator<Record<string, string>>;
|
|
55
53
|
/**
|
|
56
|
-
* Maps dataset columns to record fields. A field may draw from several columns (joined with
|
|
57
|
-
* spaces).
|
|
54
|
+
* Maps dataset columns to record fields. A field may draw from several columns (joined with spaces).
|
|
58
55
|
*/
|
|
59
56
|
export interface ColumnMapping {
|
|
60
57
|
/** Column holding a stable row id. Falls back to the row index. */
|
|
@@ -67,21 +64,19 @@ export interface ColumnMapping {
|
|
|
67
64
|
phone?: string;
|
|
68
65
|
email?: string;
|
|
69
66
|
/**
|
|
70
|
-
* Extra secondary-identifier fields → the column(s) to draw each from (joined with spaces). Land
|
|
71
|
-
*
|
|
72
|
-
*
|
|
67
|
+
* Extra secondary-identifier fields → the column(s) to draw each from (joined with spaces). Land on
|
|
68
|
+
* `SourceRecord.attributes` under the same key, for the matcher's `discriminators` (authorized-official name,
|
|
69
|
+
* taxonomy, license…).
|
|
73
70
|
*/
|
|
74
71
|
attributes?: Record<string, string | string[]>;
|
|
75
72
|
}
|
|
76
73
|
/**
|
|
77
|
-
* Best-effort {@link ColumnMapping} inferred from a header row — the "point it at any CSV"
|
|
78
|
-
*
|
|
79
|
-
* a
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* answer there), but it nails tidy and semi-tidy files with no hand-mapping. Unmatched columns are
|
|
84
|
-
* left out.
|
|
74
|
+
* Best-effort {@link ColumnMapping} inferred from a header row — the "point it at any CSV" convenience. Each column name
|
|
75
|
+
* is matched (case- and punctuation-insensitive, on whole tokens) to a field by keyword, in a precedence that resolves
|
|
76
|
+
* the common ambiguities: a dedicated id / phone / email column is claimed before the generic sweep, an org / facility
|
|
77
|
+
* column beats a person "name", and address columns (street / city / state / zip…) collect into one multi-column field.
|
|
78
|
+
* Imperfect on bespoke headers (an explicit mapping or the LLM-assisted inference #603 is the answer there), but it
|
|
79
|
+
* nails tidy and semi-tidy files with no hand-mapping. Unmatched columns are left out.
|
|
85
80
|
*/
|
|
86
81
|
export declare function inferMapping(header: readonly string[]): ColumnMapping;
|
|
87
82
|
/** Options for {@link ingestRows}. */
|
|
@@ -89,29 +84,45 @@ export interface IngestOptions {
|
|
|
89
84
|
/** The geocoding seam. Without it, records carry name/org but no resolved address. */
|
|
90
85
|
geocodeAddress?: GeocodeAddress;
|
|
91
86
|
/**
|
|
92
|
-
* Separator for joining a multi-column ADDRESS mapping (name/org always join with a space).
|
|
93
|
-
*
|
|
94
|
-
* 78701"`)
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* coords, so this flip is paired with a GBT re-validation (#694). Pass `" "` to restore the
|
|
100
|
-
* legacy space-join for a byte-stable A/B.
|
|
87
|
+
* Separator for joining a multi-column ADDRESS mapping (name/org always join with a space). Default `" "`. Pass `",
|
|
88
|
+
* "` to give the parser delimited input (`"214 Main St, Austin, TX 78701"`) instead of a concatenated run (`"214 Main
|
|
89
|
+
* St Austin TX 78701"`) — the latter strips the parser's segmentation boundaries and is partly OOD (it also breaks
|
|
90
|
+
* all-caps case-normalization; #694). **Default `", "` (#694 flip, validated).** Comma-join is the correct shape for
|
|
91
|
+
* an address built from separate columns, and #700 measured it at +15% cross-dataset rooftop (579→667) with no
|
|
92
|
+
* comma-less crater. The dedup GBT was trained on the old space-joined coords, so this flip is paired with a GBT
|
|
93
|
+
* re-validation (#694). Pass `" "` to restore the legacy space-join for a byte-stable A/B.
|
|
101
94
|
*/
|
|
102
95
|
addressSeparator?: string;
|
|
103
96
|
}
|
|
104
97
|
/** Parse a CSV string (with a header row) into row objects keyed by column name. */
|
|
105
|
-
export declare function
|
|
98
|
+
export declare function parseCSV(text: string): Record<string, string>[];
|
|
99
|
+
/** Join the named column(s) of a row into a single trimmed string, or undefined if empty. */
|
|
100
|
+
export declare function pick(row: Record<string, string>, columns?: string | string[], separator?: string): string | undefined;
|
|
106
101
|
/**
|
|
107
|
-
* Normalize tabular
|
|
108
|
-
*
|
|
109
|
-
*
|
|
102
|
+
* Normalize one tabular row into a {@link SourceRecord} under a {@link ColumnMapping}: parse the person name,
|
|
103
|
+
* canonicalize the org, and (if `opts.geocodeAddress` is provided) geocode the joined address. `id` falls back to the
|
|
104
|
+
* caller-supplied row index. Pure aside from the optional geocode seam, so the deterministic normalization can run
|
|
105
|
+
* single-threaded (see {@link normalizeCSV}) while geocoding is offloaded (see `geocodeStream`).
|
|
106
|
+
*/
|
|
107
|
+
export declare function ingestRow(row: Record<string, string>, mapping: ColumnMapping, index: number, opts?: IngestOptions): Promise<SourceRecord>;
|
|
108
|
+
/**
|
|
109
|
+
* Normalize tabular rows into {@link SourceRecord}s under a {@link ColumnMapping}. Accepts a sync OR async iterable, so
|
|
110
|
+
* {@link parseCSV} (in-memory) and {@link streamRows} (lazy, for huge files) both thread straight through.
|
|
110
111
|
*/
|
|
111
112
|
export declare function ingestRows(rows: Iterable<Record<string, string>> | AsyncIterable<Record<string, string>>, mapping: ColumnMapping, opts?: IngestOptions): Promise<SourceRecord[]>;
|
|
112
113
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
114
|
+
* Stream a delimited file as normalized {@link SourceRecord}s — `streamRows` + {@link ingestRow} with **no geocoding**.
|
|
115
|
+
* This is the single-threaded, "fast enough" ergonomic core: column mapping, name parsing, and org canonicalization for
|
|
116
|
+
* a multi-GB file, line by line. Geocode separately by piping the output through `geocodeStream` (the only heavy step
|
|
117
|
+
* worth threading); for a light file (e.g. one that already carries geo cells) just consume this and stop.
|
|
118
|
+
*/
|
|
119
|
+
export declare function normalizeCSV(source: string, opts: {
|
|
120
|
+
mapping: ColumnMapping;
|
|
121
|
+
delimiter?: Delimiter;
|
|
122
|
+
}): AsyncGenerator<SourceRecord>;
|
|
123
|
+
/**
|
|
124
|
+
* The subset of mailwoman's `GeocodeResult` the adapter consumes — kept structural so this package never imports the
|
|
125
|
+
* heavy geocoder, yet a real `GeocodeResult` maps straight in.
|
|
115
126
|
*/
|
|
116
127
|
export interface RawGeocode {
|
|
117
128
|
lat: number | null;
|
|
@@ -120,16 +131,32 @@ export interface RawGeocode {
|
|
|
120
131
|
uncertainty_m: number | null;
|
|
121
132
|
hierarchy?: AddressGeocode["hierarchy"];
|
|
122
133
|
}
|
|
134
|
+
/** The component map {@link toPostalAddress} consumes (kept structural so this package never imports the geocoder). */
|
|
135
|
+
type GeocodeComponents = Parameters<typeof toPostalAddress>[0];
|
|
123
136
|
/**
|
|
124
|
-
* Build a {@link GeocodeAddress} from mailwoman's real parse + geocode primitives (injected — the
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
137
|
+
* Build a {@link GeocodeAddress} from mailwoman's real parse + geocode primitives (injected — the CLI constructs the
|
|
138
|
+
* neural parser, resolver, and shards and passes them in). Parse → components → {@link toPostalAddress} (which fills
|
|
139
|
+
* the canonical key + formatted form) → attach the resolved coordinate. When geocoding can't place the address, the
|
|
140
|
+
* parsed-but-unlocated address is still returned.
|
|
141
|
+
*
|
|
142
|
+
* Two shapes:
|
|
143
|
+
*
|
|
144
|
+
* - `{ parse, geocode }` — the original: two independent calls. mailwoman's `geocodeAddress` re-parses internally, so
|
|
145
|
+
* this parses the address twice (fine when the two callbacks don't share a parser).
|
|
146
|
+
* - `{ parseAndGeocode }` — parse the address ONCE and return both the components and the geocode. Use this when the
|
|
147
|
+
* parse is the expensive step you'd rather not pay for twice (e.g. share `parseForGeocode`'s tree between the
|
|
148
|
+
* PostalAddress and `geocodeAddress`'s `parsedTree`). ~1.3× over the two-call shape on a real geocode pipeline.
|
|
129
149
|
*/
|
|
130
150
|
export declare function geocodeAddressVia(deps: {
|
|
131
|
-
parse: (raw: string) => Promise<Parameters<typeof toPostalAddress>[0]> | Parameters<typeof toPostalAddress>[0];
|
|
132
|
-
geocode: (raw: string) => Promise<RawGeocode | null> | RawGeocode | null;
|
|
133
151
|
country?: string;
|
|
134
|
-
}
|
|
152
|
+
} & ({
|
|
153
|
+
parse: (raw: string) => Promise<GeocodeComponents> | GeocodeComponents;
|
|
154
|
+
geocode: (raw: string) => Promise<RawGeocode | null> | RawGeocode | null;
|
|
155
|
+
} | {
|
|
156
|
+
parseAndGeocode: (raw: string) => Promise<{
|
|
157
|
+
components: GeocodeComponents;
|
|
158
|
+
geo: RawGeocode | null;
|
|
159
|
+
}>;
|
|
160
|
+
})): GeocodeAddress;
|
|
161
|
+
export {};
|
|
135
162
|
//# sourceMappingURL=ingest.d.ts.map
|
package/out/ingest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAiD,eAAe,EAAe,MAAM,mBAAmB,CAAA;AAI/G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,mGAAmG;AACnG,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;AAElG,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,CAAA;AAEvC,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,E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