@mailwoman/resolver 8.0.0 → 8.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.
- package/fold-name.ts +20 -0
- package/index.ts +13 -2
- package/out/fold-name.d.ts +13 -0
- package/out/fold-name.d.ts.map +1 -0
- package/out/fold-name.js +20 -0
- package/out/fold-name.js.map +1 -0
- package/out/index.d.ts +2 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -1
- package/out/index.js.map +1 -1
- package/out/plausibility.d.ts +40 -6
- package/out/plausibility.d.ts.map +1 -1
- package/out/plausibility.js +24 -5
- package/out/plausibility.js.map +1 -1
- package/out/remote-resolver.d.ts +21 -7
- package/out/remote-resolver.d.ts.map +1 -1
- package/out/remote-resolver.js +3 -1
- package/out/remote-resolver.js.map +1 -1
- package/out/rerank.d.ts +30 -10
- package/out/rerank.d.ts.map +1 -1
- package/out/rerank.js +2 -2
- package/out/rerank.js.map +1 -1
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +29 -410
- package/out/resolve.js.map +1 -1
- package/out/span-rescore.d.ts +18 -6
- package/out/span-rescore.d.ts.map +1 -1
- package/out/span-rescore.js +13 -6
- package/out/span-rescore.js.map +1 -1
- package/out/street-evidence.d.ts +30 -10
- package/out/street-evidence.d.ts.map +1 -1
- package/out/street-evidence.js +8 -6
- package/out/street-evidence.js.map +1 -1
- package/out/street-tier.d.ts +39 -0
- package/out/street-tier.d.ts.map +1 -0
- package/out/street-tier.js +415 -0
- package/out/street-tier.js.map +1 -0
- package/package.json +4 -4
- package/plausibility.ts +51 -9
- package/remote-resolver.ts +23 -7
- package/rerank.ts +37 -12
- package/resolve.ts +80 -481
- package/span-rescore.ts +33 -11
- package/street-evidence.ts +36 -15
- package/street-tier.ts +498 -0
package/fold-name.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* One shared name fold, used by the resolver's commune reconciliation and by the street tier's
|
|
7
|
+
* locality comparison. Its own module because both would otherwise import each other for it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Case/diacritic-insensitive fold for commune-name comparison (#1058) — mirrors span-rescore's `norm`.
|
|
12
|
+
*/
|
|
13
|
+
export function foldName(s: string): string {
|
|
14
|
+
return s
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.normalize("NFD")
|
|
17
|
+
.replaceAll(/[^a-z0-9 ]/g, " ")
|
|
18
|
+
.replaceAll(/\s+/g, " ")
|
|
19
|
+
.trim()
|
|
20
|
+
}
|
package/index.ts
CHANGED
|
@@ -12,16 +12,26 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export { RemoteResolver, serializableResolveOpts } from "./remote-resolver.ts"
|
|
15
|
+
|
|
15
16
|
export type {
|
|
16
17
|
RemoteResolverOpts,
|
|
17
18
|
ResolveTreeRequest,
|
|
18
19
|
ResolveTreeResponse,
|
|
19
20
|
SerializableResolveOpts,
|
|
20
21
|
} from "./remote-resolver.ts"
|
|
22
|
+
|
|
21
23
|
export { createWOFResolver } from "./resolve.ts"
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
COUNTRY_BBOX,
|
|
27
|
+
finestResolvedCoordinate,
|
|
28
|
+
isImplausibleResolution,
|
|
29
|
+
outsideExpectedCountry,
|
|
30
|
+
} from "./plausibility.ts"
|
|
31
|
+
|
|
32
|
+
export type { PlausibilityOpts, PlausibilityVerdict, ResolvedCoordinate } from "./plausibility.ts"
|
|
24
33
|
export { foldStreetSurface, isPureTypeVocabulary, pickByStreetEvidence } from "./street-evidence.ts"
|
|
34
|
+
|
|
25
35
|
export type {
|
|
26
36
|
PickByStreetEvidenceOpts,
|
|
27
37
|
StreetCandidate,
|
|
@@ -29,6 +39,7 @@ export type {
|
|
|
29
39
|
StreetEvidenceScope,
|
|
30
40
|
StreetLocalityEvidence,
|
|
31
41
|
} from "./street-evidence.ts"
|
|
42
|
+
|
|
32
43
|
export { findRescoreCandidate, hasResolvedPlace } from "./span-rescore.ts"
|
|
33
44
|
export type { RescoreCandidate, SpanRescoreOptions } from "./span-rescore.ts"
|
|
34
45
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* One shared name fold, used by the resolver's commune reconciliation and by the street tier's
|
|
7
|
+
* locality comparison. Its own module because both would otherwise import each other for it.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Case/diacritic-insensitive fold for commune-name comparison (#1058) — mirrors span-rescore's `norm`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function foldName(s: string): string;
|
|
13
|
+
//# sourceMappingURL=fold-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold-name.d.ts","sourceRoot":"","sources":["../fold-name.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1C"}
|
package/out/fold-name.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* One shared name fold, used by the resolver's commune reconciliation and by the street tier's
|
|
7
|
+
* locality comparison. Its own module because both would otherwise import each other for it.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Case/diacritic-insensitive fold for commune-name comparison (#1058) — mirrors span-rescore's `norm`.
|
|
11
|
+
*/
|
|
12
|
+
export function foldName(s) {
|
|
13
|
+
return s
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.normalize("NFD")
|
|
16
|
+
.replaceAll(/[^a-z0-9 ]/g, " ")
|
|
17
|
+
.replaceAll(/\s+/g, " ")
|
|
18
|
+
.trim();
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=fold-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold-name.js","sourceRoot":"","sources":["../fold-name.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAS;IACjC,OAAO,CAAC;SACN,WAAW,EAAE;SACb,SAAS,CAAC,KAAK,CAAC;SAChB,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC;SAC9B,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;SACvB,IAAI,EAAE,CAAA;AACT,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
export { RemoteResolver, serializableResolveOpts } from "./remote-resolver.ts";
|
|
14
14
|
export type { RemoteResolverOpts, ResolveTreeRequest, ResolveTreeResponse, SerializableResolveOpts, } from "./remote-resolver.ts";
|
|
15
15
|
export { createWOFResolver } from "./resolve.ts";
|
|
16
|
-
export { finestResolvedCoordinate, isImplausibleResolution } from "./plausibility.ts";
|
|
17
|
-
export type { PlausibilityVerdict, ResolvedCoordinate } from "./plausibility.ts";
|
|
16
|
+
export { COUNTRY_BBOX, finestResolvedCoordinate, isImplausibleResolution, outsideExpectedCountry, } from "./plausibility.ts";
|
|
17
|
+
export type { PlausibilityOpts, PlausibilityVerdict, ResolvedCoordinate } from "./plausibility.ts";
|
|
18
18
|
export { foldStreetSurface, isPureTypeVocabulary, pickByStreetEvidence } from "./street-evidence.ts";
|
|
19
19
|
export type { PickByStreetEvidenceOpts, StreetCandidate, StreetEvidencePick, StreetEvidenceScope, StreetLocalityEvidence, } from "./street-evidence.ts";
|
|
20
20
|
export { findRescoreCandidate, hasResolvedPlace } from "./span-rescore.ts";
|
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,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAE9E,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACvB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EACN,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAEpG,YAAY,EACX,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI7E,cAAc,0BAA0B,CAAA;AAExC,cAAc,aAAa,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export { RemoteResolver, serializableResolveOpts } from "./remote-resolver.js";
|
|
14
14
|
export { createWOFResolver } from "./resolve.js";
|
|
15
|
-
export { finestResolvedCoordinate, isImplausibleResolution } from "./plausibility.js";
|
|
15
|
+
export { COUNTRY_BBOX, finestResolvedCoordinate, isImplausibleResolution, outsideExpectedCountry, } from "./plausibility.js";
|
|
16
16
|
export { foldStreetSurface, isPureTypeVocabulary, pickByStreetEvidence } from "./street-evidence.js";
|
|
17
17
|
export { findRescoreCandidate, hasResolvedPlace } from "./span-rescore.js";
|
|
18
18
|
// The type contract + placetype helpers live in core (pure types, keep core a leaf). Re-export so
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAS9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EACN,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAUpG,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAG1E,kGAAkG;AAClG,8DAA8D;AAC9D,cAAc,0BAA0B,CAAA;AAExC,cAAc,aAAa,CAAA"}
|
package/out/plausibility.d.ts
CHANGED
|
@@ -25,12 +25,17 @@
|
|
|
25
25
|
* than a country" trips it.
|
|
26
26
|
*/
|
|
27
27
|
import type { AddressTree, ComponentTag } from "@mailwoman/core/decoder";
|
|
28
|
-
|
|
28
|
+
import type { CountryBBoxFact } from "@mailwoman/core/resolver";
|
|
29
|
+
/**
|
|
30
|
+
* A resolved place lifted off the tree — the coordinate a caller would serve, plus its granularity tag.
|
|
31
|
+
*/
|
|
29
32
|
export interface ResolvedCoordinate {
|
|
30
33
|
tag: ComponentTag;
|
|
31
34
|
lat: number;
|
|
32
35
|
lon: number;
|
|
33
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Canonical place URI (`wof:…`) when the resolver supplied one.
|
|
38
|
+
*/
|
|
34
39
|
placeID?: string;
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
@@ -39,9 +44,30 @@ export interface ResolvedCoordinate {
|
|
|
39
44
|
* Ties break toward the first node in document order.
|
|
40
45
|
*/
|
|
41
46
|
export declare function finestResolvedCoordinate(tree: AddressTree): ResolvedCoordinate | null;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Coarse per-country bounding boxes `[latMin, latMax, lonMin, lonMax]` for the cross-country guard (guard B). These are
|
|
49
|
+
* DELIBERATELY rough — a guard needs "obviously the wrong country", not cartography — and they mirror the boxes the
|
|
50
|
+
* 2026-07-15 coordinate-parity receipt harness measured with (`scratchpad/coord-parity.mjs`). The US box spans Alaska →
|
|
51
|
+
* the mainland east coast; continental FR only; etc. A country absent here simply never trips the guard (fail-open).
|
|
52
|
+
*
|
|
53
|
+
* FALLBACK ROLE (survey candidate #2): these boxes are also baked into the candidate gazetteer's `country_bbox`
|
|
54
|
+
* manifest table at build time (`mailwoman/gazetteer-pipeline/coverage-manifest.ts` owns the measured record). When a
|
|
55
|
+
* caller supplies artifact-declared boxes ({@link PlausibilityOpts.countryBBoxes}), those REPLACE this table wholesale
|
|
56
|
+
* — the artifact speaks for itself, and a country absent from the artifact's table fails open exactly like an absent
|
|
57
|
+
* key here. This constant is the fallback for artifacts predating the manifest; grow the manifest record, not this.
|
|
58
|
+
*/
|
|
59
|
+
export declare const COUNTRY_BBOX: Readonly<Record<string, readonly [number, number, number, number]>>;
|
|
60
|
+
/**
|
|
61
|
+
* True when the coordinate lies outside `countryCode`'s coarse bbox. Unknown country codes are fail-open (false).
|
|
62
|
+
*
|
|
63
|
+
* When `bboxes` (artifact-declared boxes, {@link GazetteerArtifactCoverage.countryBBoxes}) is supplied it REPLACES the
|
|
64
|
+
* built-in {@link COUNTRY_BBOX} table wholesale — absence from the artifact's table fails open, same semantic as an
|
|
65
|
+
* absent constant key. Omitted → the constant, byte-identical to the pre-manifest behavior.
|
|
66
|
+
*/
|
|
67
|
+
export declare function outsideExpectedCountry(countryCode: string, lat: number, lon: number, bboxes?: ReadonlyMap<string, CountryBBoxFact>): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Result of {@link isImplausibleResolution} — the boolean plus the reason, for telemetry + fallback logs.
|
|
70
|
+
*/
|
|
45
71
|
export interface PlausibilityVerdict {
|
|
46
72
|
implausible: boolean;
|
|
47
73
|
/**
|
|
@@ -49,7 +75,9 @@ export interface PlausibilityVerdict {
|
|
|
49
75
|
* `outside-expected-country` = the served coordinate lies outside the expected country's bbox (guard B).
|
|
50
76
|
*/
|
|
51
77
|
reason?: "country-centroid" | "outside-expected-country";
|
|
52
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* The coordinate the verdict was drawn from, when anything resolved.
|
|
80
|
+
*/
|
|
53
81
|
coordinate?: ResolvedCoordinate;
|
|
54
82
|
}
|
|
55
83
|
export interface PlausibilityOpts {
|
|
@@ -61,6 +89,12 @@ export interface PlausibilityOpts {
|
|
|
61
89
|
* only in the receipt harness, so the shipped residual read 5/321 while the receipt said 3/321).
|
|
62
90
|
*/
|
|
63
91
|
expectedCountry?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Artifact-declared guard-B boxes (the loaded gazetteer's `country_bbox` manifest, via
|
|
94
|
+
* `resolver.artifactCoverage?.countryBBoxes`). When supplied they replace the built-in {@link COUNTRY_BBOX} table
|
|
95
|
+
* wholesale; omitted → the constant (byte-identical fallback for artifacts predating the manifest).
|
|
96
|
+
*/
|
|
97
|
+
countryBBoxes?: ReadonlyMap<string, CountryBBoxFact>;
|
|
64
98
|
}
|
|
65
99
|
/**
|
|
66
100
|
* Decide whether a resolved tree's geocode is implausible for a structured address — the cheap guard the v7 hybrid gate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plausibility.d.ts","sourceRoot":"","sources":["../plausibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"plausibility.d.ts","sourceRoot":"","sources":["../plausibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAqB/D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,YAAY,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB,GAAG,IAAI,CAwBrF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAmB5F,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GAC3C,OAAO,CAgBT;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,WAAW,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,kBAAkB,GAAG,0BAA0B,CAAA;IACxD;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CACpD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,GAAE,gBAAqB,GAAG,mBAAmB,CAgB3G"}
|
package/out/plausibility.js
CHANGED
|
@@ -72,8 +72,14 @@ export function finestResolvedCoordinate(tree) {
|
|
|
72
72
|
* DELIBERATELY rough — a guard needs "obviously the wrong country", not cartography — and they mirror the boxes the
|
|
73
73
|
* 2026-07-15 coordinate-parity receipt harness measured with (`scratchpad/coord-parity.mjs`). The US box spans Alaska →
|
|
74
74
|
* the mainland east coast; continental FR only; etc. A country absent here simply never trips the guard (fail-open).
|
|
75
|
+
*
|
|
76
|
+
* FALLBACK ROLE (survey candidate #2): these boxes are also baked into the candidate gazetteer's `country_bbox`
|
|
77
|
+
* manifest table at build time (`mailwoman/gazetteer-pipeline/coverage-manifest.ts` owns the measured record). When a
|
|
78
|
+
* caller supplies artifact-declared boxes ({@link PlausibilityOpts.countryBBoxes}), those REPLACE this table wholesale
|
|
79
|
+
* — the artifact speaks for itself, and a country absent from the artifact's table fails open exactly like an absent
|
|
80
|
+
* key here. This constant is the fallback for artifacts predating the manifest; grow the manifest record, not this.
|
|
75
81
|
*/
|
|
76
|
-
const COUNTRY_BBOX = {
|
|
82
|
+
export const COUNTRY_BBOX = {
|
|
77
83
|
US: [18, 72, -180, -66],
|
|
78
84
|
AU: [-44, -10, 112, 154],
|
|
79
85
|
BR: [-34, 6, -74, -34],
|
|
@@ -93,9 +99,22 @@ const COUNTRY_BBOX = {
|
|
|
93
99
|
SK: [47.7, 49.7, 16.8, 22.6],
|
|
94
100
|
SI: [45.4, 46.9, 13.3, 16.6],
|
|
95
101
|
};
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
/**
|
|
103
|
+
* True when the coordinate lies outside `countryCode`'s coarse bbox. Unknown country codes are fail-open (false).
|
|
104
|
+
*
|
|
105
|
+
* When `bboxes` (artifact-declared boxes, {@link GazetteerArtifactCoverage.countryBBoxes}) is supplied it REPLACES the
|
|
106
|
+
* built-in {@link COUNTRY_BBOX} table wholesale — absence from the artifact's table fails open, same semantic as an
|
|
107
|
+
* absent constant key. Omitted → the constant, byte-identical to the pre-manifest behavior.
|
|
108
|
+
*/
|
|
109
|
+
export function outsideExpectedCountry(countryCode, lat, lon, bboxes) {
|
|
110
|
+
const cc = countryCode.toUpperCase();
|
|
111
|
+
if (bboxes) {
|
|
112
|
+
const fact = bboxes.get(cc);
|
|
113
|
+
if (!fact)
|
|
114
|
+
return false;
|
|
115
|
+
return lat < fact.latMin || lat > fact.latMax || lon < fact.lonMin || lon > fact.lonMax;
|
|
116
|
+
}
|
|
117
|
+
const b = COUNTRY_BBOX[cc];
|
|
99
118
|
if (!b)
|
|
100
119
|
return false;
|
|
101
120
|
return lat < b[0] || lat > b[1] || lon < b[2] || lon > b[3];
|
|
@@ -113,7 +132,7 @@ export function isImplausibleResolution(tree, opts = {}) {
|
|
|
113
132
|
}
|
|
114
133
|
if (coordinate &&
|
|
115
134
|
opts.expectedCountry &&
|
|
116
|
-
outsideExpectedCountry(opts.expectedCountry, coordinate.lat, coordinate.lon)) {
|
|
135
|
+
outsideExpectedCountry(opts.expectedCountry, coordinate.lat, coordinate.lon, opts.countryBBoxes)) {
|
|
117
136
|
return { implausible: true, reason: "outside-expected-country", coordinate };
|
|
118
137
|
}
|
|
119
138
|
return { implausible: false, coordinate: coordinate ?? undefined };
|
package/out/plausibility.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plausibility.js","sourceRoot":"","sources":["../plausibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"plausibility.js","sourceRoot":"","sources":["../plausibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH;;;;GAIG;AACH,MAAM,eAAe,GAA0C;IAC9D,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,CAAC;IACZ,kBAAkB,EAAE,CAAC;IACrB,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC;CACf,CAAA;AAeD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAiB;IACzD,IAAI,IAAI,GAA8B,IAAI,CAAA;IAC1C,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAA;IAEjB,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAQ,EAAE;QACzC,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAE3C,IAAI,IAAI,GAAG,QAAQ,EAAE,CAAC;gBACrB,QAAQ,GAAG,IAAI,CAAA;gBACf,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAA;YAC9E,CAAC;QAC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CAAA;AAC5D,CAAC;AAmCD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAiB,EAAE,OAAyB,EAAE;IACrF,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAA;IAEjD,IAAI,UAAU,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAA;IACrE,CAAC;IAED,IACC,UAAU;QACV,IAAI,CAAC,eAAe;QACpB,sBAAsB,CAAC,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,EAC/F,CAAC;QACF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,0BAA0B,EAAE,UAAU,EAAE,CAAA;IAC7E,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,IAAI,SAAS,EAAE,CAAA;AACnE,CAAC"}
|
package/out/remote-resolver.d.ts
CHANGED
|
@@ -22,28 +22,42 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { AddressTree } from "@mailwoman/core/decoder";
|
|
24
24
|
import type { ResolveOpts, Resolver } from "@mailwoman/core/resolver";
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* `ResolveOpts` minus the non-serializable live lookup handles. What actually crosses the wire.
|
|
27
|
+
*/
|
|
26
28
|
export type SerializableResolveOpts = Omit<ResolveOpts, "addressPoints" | "interpolation">;
|
|
27
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Strip the live lookup handles from `ResolveOpts` so the rest can be JSON-serialized over HTTP.
|
|
31
|
+
*/
|
|
28
32
|
export declare function serializableResolveOpts(opts?: ResolveOpts): SerializableResolveOpts | undefined;
|
|
29
33
|
export interface RemoteResolverOpts {
|
|
30
34
|
/**
|
|
31
35
|
* Full URL of the resolver service's resolve-tree endpoint, e.g. `http://resolver:7081/v1/resolve`.
|
|
32
36
|
*/
|
|
33
37
|
endpoint: string;
|
|
34
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Injectable fetch (tests / custom agents). Defaults to the global `fetch`.
|
|
40
|
+
*/
|
|
35
41
|
fetch?: typeof fetch;
|
|
36
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Per-request timeout in ms. Default 10000.
|
|
44
|
+
*/
|
|
37
45
|
timeoutMs?: number;
|
|
38
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Extra headers (auth, tracing). `Content-Type: application/json` is always set.
|
|
48
|
+
*/
|
|
39
49
|
headers?: Record<string, string>;
|
|
40
50
|
}
|
|
41
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The wire request body `POST <endpoint>` expects (and the matching server handler parses).
|
|
53
|
+
*/
|
|
42
54
|
export interface ResolveTreeRequest {
|
|
43
55
|
tree: AddressTree;
|
|
44
56
|
opts?: SerializableResolveOpts;
|
|
45
57
|
}
|
|
46
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* The wire response body the server returns.
|
|
60
|
+
*/
|
|
47
61
|
export interface ResolveTreeResponse {
|
|
48
62
|
tree: AddressTree;
|
|
49
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-resolver.d.ts","sourceRoot":"","sources":["../remote-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAErE
|
|
1
|
+
{"version":3,"file":"remote-resolver.d.ts","sourceRoot":"","sources":["../remote-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAErE;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,eAAe,CAAC,CAAA;AAE1F;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,uBAAuB,GAAG,SAAS,CAK/F;AAED,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,CAAC,EAAE,uBAAuB,CAAA;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,WAAW,CAAA;CACjB;AAED,qBAAa,cAAe,YAAW,QAAQ;;gBAMlC,IAAI,EAAE,kBAAkB;IAQ9B,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CA6B9E"}
|
package/out/remote-resolver.js
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
* data lives server-side, which is the whole point). All other opts (defaultCountry, calibration,
|
|
21
21
|
* hierarchyCompletion, …) ride along.
|
|
22
22
|
*/
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Strip the live lookup handles from `ResolveOpts` so the rest can be JSON-serialized over HTTP.
|
|
25
|
+
*/
|
|
24
26
|
export function serializableResolveOpts(opts) {
|
|
25
27
|
if (!opts)
|
|
26
28
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-resolver.js","sourceRoot":"","sources":["../remote-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"remote-resolver.js","sourceRoot":"","sources":["../remote-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAUH;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAkB;IACzD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAA;IAC3B,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;IAEhE,OAAO,IAAI,CAAA;AACZ,CAAC;AAoCD,MAAM,OAAO,cAAc;IACjB,SAAS,CAAQ;IACjB,MAAM,CAAc;IACpB,UAAU,CAAQ;IAClB,QAAQ,CAAwB;IAEzC,YAAY,IAAwB;QACnC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC7E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAA;QAC5C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAA;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;IACnC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAiB,EAAE,IAAkB;QACtD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;QACxC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QAEnE,IAAI,CAAC;YACJ,MAAM,IAAI,GAAuB,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAA;YAE9E,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE;gBAC7C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE;gBACjE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,UAAU,CAAC,MAAM;aACzB,CAAC,CAAA;YAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,SAAS,WAAW,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;YAC5F,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAiC,CAAA;YAE/D,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5D,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;YAC7E,CAAC;YAED,OAAO,IAAI,CAAC,IAAI,CAAA;QACjB,CAAC;gBAAS,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;IACF,CAAC;CACD"}
|
package/out/rerank.d.ts
CHANGED
|
@@ -30,27 +30,45 @@
|
|
|
30
30
|
* parity + Paris fixtures, stated in a verdict doc. Not a plausible story.
|
|
31
31
|
*/
|
|
32
32
|
import type { AddressTree } from "@mailwoman/core/decoder";
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* One candidate parse from the k-best decode, with its (within-input comparable) score.
|
|
35
|
+
*/
|
|
34
36
|
export interface RerankCandidate<T = unknown> {
|
|
35
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The parse's own score. Comparable to its siblings from the SAME input; not across inputs.
|
|
39
|
+
*/
|
|
36
40
|
score: number;
|
|
37
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The parse tree, UNRESOLVED — `rerankByResolution` resolves it via the injected resolver.
|
|
43
|
+
*/
|
|
38
44
|
tree: AddressTree;
|
|
39
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Opaque caller payload carried through to the result (the segmentation, a surface string, …).
|
|
47
|
+
*/
|
|
40
48
|
payload?: T;
|
|
41
49
|
}
|
|
42
50
|
export interface RerankedCandidate<T = unknown> extends RerankCandidate<T> {
|
|
43
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The resolved tree (the resolver's output), or null when resolution threw.
|
|
53
|
+
*/
|
|
44
54
|
resolved: AddressTree | null;
|
|
45
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* True when the resolution is implausible (today: resolves no finer than a country centroid).
|
|
57
|
+
*/
|
|
46
58
|
implausible: boolean;
|
|
47
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Why it was vetoed, when it was.
|
|
61
|
+
*/
|
|
48
62
|
reason?: string;
|
|
49
63
|
}
|
|
50
64
|
export interface RerankResult<T = unknown> {
|
|
51
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Candidates in FINAL order: plausible ones first (model order preserved), vetoed ones after.
|
|
67
|
+
*/
|
|
52
68
|
ranked: Array<RerankedCandidate<T>>;
|
|
53
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* The winner — the first plausible candidate, or the model's rank-1 when ALL were vetoed.
|
|
71
|
+
*/
|
|
54
72
|
best: RerankedCandidate<T>;
|
|
55
73
|
/**
|
|
56
74
|
* True when the winner is NOT the model's rank-1 — i.e. resolution evidence actually changed the answer. This is the
|
|
@@ -59,7 +77,9 @@ export interface RerankResult<T = unknown> {
|
|
|
59
77
|
*/
|
|
60
78
|
changed: boolean;
|
|
61
79
|
}
|
|
62
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Resolve a tree. Structural — any `Resolver`-shaped thing satisfies it.
|
|
82
|
+
*/
|
|
63
83
|
export type ResolveTree = (tree: AddressTree) => Promise<AddressTree>;
|
|
64
84
|
export interface RerankOpts {
|
|
65
85
|
/**
|
package/out/rerank.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rerank.d.ts","sourceRoot":"","sources":["../rerank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAI1D
|
|
1
|
+
{"version":3,"file":"rerank.d.ts","sourceRoot":"","sources":["../rerank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAI1D;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC3C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,IAAI,EAAE,WAAW,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAA;CACX;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACzE;;OAEG;IACH,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACxC;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC;;OAEG;IACH,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAC1B;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;AAErE,MAAM,WAAW,UAAU;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAC7C,WAAW,EAAE,WAAW,EACxB,IAAI,GAAE,UAAe,GACnB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CA4C1B"}
|
package/out/rerank.js
CHANGED
|
@@ -42,7 +42,7 @@ import { isImplausibleResolution } from "./plausibility.js";
|
|
|
42
42
|
* grounds to flag low confidence (the Phase-4b ambiguity gate).
|
|
43
43
|
*/
|
|
44
44
|
export async function rerankByResolution(candidates, resolveTree, opts = {}) {
|
|
45
|
-
if (candidates.length
|
|
45
|
+
if (!candidates.length)
|
|
46
46
|
throw new Error("rerankByResolution: candidates must not be empty");
|
|
47
47
|
const maxResolve = Math.max(1, Math.min(opts.maxResolve ?? 5, candidates.length));
|
|
48
48
|
const ranked = [];
|
|
@@ -53,7 +53,7 @@ export async function rerankByResolution(candidates, resolveTree, opts = {}) {
|
|
|
53
53
|
ranked.push({ ...candidate, resolved: null, implausible: false });
|
|
54
54
|
continue;
|
|
55
55
|
}
|
|
56
|
-
let resolved
|
|
56
|
+
let resolved;
|
|
57
57
|
try {
|
|
58
58
|
resolved = await resolveTree(candidate.tree);
|
|
59
59
|
}
|
package/out/rerank.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rerank.js","sourceRoot":"","sources":["../rerank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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AAW,EAAE,KAAK,EAAE,CAAC,CAAA;YAEjE,SAAQ;QACT,CAAC;QAED,MAAM,OAAO,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAA;QAEjD,MAAM,CAAC,IAAI,CAAC;YACX,GAAG,SAAS;YACZ,QAAQ;YACR,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrD,CAAC,CAAA;IACH,CAAC;IAED,6FAA6F;IAC7F,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IAClD,MAAM,UAAU,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC,CAAA;IAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAE,CAAA;IAE3B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;AACjE,CAAC"}
|
package/out/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EASN,KAAK,QAAQ,EACb,KAAK,eAAe,EAEpB,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EASN,KAAK,QAAQ,EACb,KAAK,eAAe,EAEpB,MAAM,0BAA0B,CAAA;AAOjC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAEpE"}
|