@mailwoman/core 2.0.6 → 2.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/out/api/APIClient.d.ts +57 -0
- package/out/api/APIClient.d.ts.map +1 -0
- package/out/api/APIClient.js +108 -0
- package/out/api/APIClient.js.map +1 -0
- package/out/api/headless.d.ts +17 -0
- package/out/api/headless.d.ts.map +1 -0
- package/out/api/headless.js +18 -0
- package/out/api/headless.js.map +1 -0
- package/out/api/index.d.ts +11 -0
- package/out/api/index.d.ts.map +1 -0
- package/out/api/index.js +11 -0
- package/out/api/index.js.map +1 -0
- package/out/api/responses.d.ts +48 -0
- package/out/api/responses.d.ts.map +1 -0
- package/out/api/responses.js +68 -0
- package/out/api/responses.js.map +1 -0
- package/out/collections.d.ts +66 -0
- package/out/collections.d.ts.map +1 -0
- package/out/collections.js +97 -0
- package/out/collections.js.map +1 -0
- package/out/db/schema.d.ts +21 -0
- package/out/db/schema.d.ts.map +1 -0
- package/out/db/schema.js +16 -0
- package/out/db/schema.js.map +1 -0
- package/out/decoder/build-tree.d.ts +14 -1
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +37 -9
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js +2 -0
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/serialize-xml.d.ts +22 -1
- package/out/decoder/serialize-xml.d.ts.map +1 -1
- package/out/decoder/serialize-xml.js +64 -4
- package/out/decoder/serialize-xml.js.map +1 -1
- package/out/decoder/types.d.ts +45 -0
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/types.js +6 -0
- package/out/decoder/types.js.map +1 -1
- package/out/errors/index.d.ts +9 -0
- package/out/errors/index.d.ts.map +1 -0
- package/out/errors/index.js +9 -0
- package/out/errors/index.js.map +1 -0
- package/out/errors/schema.d.ts +69 -0
- package/out/errors/schema.d.ts.map +1 -0
- package/out/errors/schema.js +102 -0
- package/out/errors/schema.js.map +1 -0
- package/out/identifiers.d.ts +18 -0
- package/out/identifiers.d.ts.map +1 -0
- package/out/identifiers.js +49 -0
- package/out/identifiers.js.map +1 -0
- package/out/index.d.ts +3 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -4
- package/out/index.js.map +1 -1
- package/out/kysley/adapter.d.ts +13 -0
- package/out/kysley/adapter.d.ts.map +1 -0
- package/out/kysley/adapter.js +25 -0
- package/out/kysley/adapter.js.map +1 -0
- package/out/kysley/client.d.ts +16 -0
- package/out/kysley/client.d.ts.map +1 -0
- package/out/kysley/client.js +22 -0
- package/out/kysley/client.js.map +1 -0
- package/out/kysley/dialect-config.d.ts +27 -0
- package/out/kysley/dialect-config.d.ts.map +1 -0
- package/out/kysley/dialect-config.js +7 -0
- package/out/kysley/dialect-config.js.map +1 -0
- package/out/kysley/dialect.d.ts +39 -0
- package/out/kysley/dialect.d.ts.map +1 -0
- package/out/kysley/dialect.js +49 -0
- package/out/kysley/dialect.js.map +1 -0
- package/out/kysley/driver.d.ts +22 -0
- package/out/kysley/driver.d.ts.map +1 -0
- package/out/kysley/driver.js +114 -0
- package/out/kysley/driver.js.map +1 -0
- package/out/lifecycle/ServiceSymbol.d.ts +59 -0
- package/out/lifecycle/ServiceSymbol.d.ts.map +1 -0
- package/out/lifecycle/ServiceSymbol.js +62 -0
- package/out/lifecycle/ServiceSymbol.js.map +1 -0
- package/out/lifecycle/index.d.ts +11 -0
- package/out/lifecycle/index.d.ts.map +1 -0
- package/out/lifecycle/index.js +11 -0
- package/out/lifecycle/index.js.map +1 -0
- package/out/lifecycle/lru-cache.d.ts +22 -0
- package/out/lifecycle/lru-cache.d.ts.map +1 -0
- package/out/lifecycle/lru-cache.js +31 -0
- package/out/lifecycle/lru-cache.js.map +1 -0
- package/out/lifecycle/services.d.ts +145 -0
- package/out/lifecycle/services.d.ts.map +1 -0
- package/out/lifecycle/services.js +190 -0
- package/out/lifecycle/services.js.map +1 -0
- package/out/logging/index.d.ts +7 -0
- package/out/logging/index.d.ts.map +1 -0
- package/out/logging/index.js +7 -0
- package/out/logging/index.js.map +1 -0
- package/out/logging/shared.d.ts +60 -0
- package/out/logging/shared.d.ts.map +1 -0
- package/out/logging/shared.js +100 -0
- package/out/logging/shared.js.map +1 -0
- package/out/logging/tables.d.ts +7 -0
- package/out/logging/tables.d.ts.map +1 -0
- package/out/logging/tables.js +75 -0
- package/out/logging/tables.js.map +1 -0
- package/out/objects.d.ts +96 -0
- package/out/objects.d.ts.map +1 -0
- package/out/objects.js +96 -0
- package/out/objects.js.map +1 -0
- package/out/parser/proposal-pipeline.d.ts.map +1 -1
- package/out/parser/proposal-pipeline.js +0 -1
- package/out/parser/proposal-pipeline.js.map +1 -1
- package/out/pipeline/index.d.ts +14 -0
- package/out/pipeline/index.d.ts.map +1 -0
- package/out/pipeline/index.js +11 -0
- package/out/pipeline/index.js.map +1 -0
- package/out/pipeline/reconcile.d.ts +135 -0
- package/out/pipeline/reconcile.d.ts.map +1 -0
- package/out/pipeline/reconcile.js +355 -0
- package/out/pipeline/reconcile.js.map +1 -0
- package/out/pipeline/runtime-pipeline.d.ts +29 -0
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -0
- package/out/pipeline/runtime-pipeline.js +288 -0
- package/out/pipeline/runtime-pipeline.js.map +1 -0
- package/out/pipeline/span-logit-aggregation.d.ts +57 -0
- package/out/pipeline/span-logit-aggregation.d.ts.map +1 -0
- package/out/pipeline/span-logit-aggregation.js +105 -0
- package/out/pipeline/span-logit-aggregation.js.map +1 -0
- package/out/pipeline/types.d.ts +189 -0
- package/out/pipeline/types.d.ts.map +1 -0
- package/out/pipeline/types.js +16 -0
- package/out/pipeline/types.js.map +1 -0
- package/out/resolver/index.d.ts +9 -0
- package/out/resolver/index.d.ts.map +1 -0
- package/out/resolver/index.js +8 -0
- package/out/resolver/index.js.map +1 -0
- package/out/resolver/resolve.d.ts +21 -0
- package/out/resolver/resolve.d.ts.map +1 -0
- package/out/resolver/resolve.js +118 -0
- package/out/resolver/resolve.js.map +1 -0
- package/out/resolver/types.d.ts +118 -0
- package/out/resolver/types.d.ts.map +1 -0
- package/out/resolver/types.js +24 -0
- package/out/resolver/types.js.map +1 -0
- package/out/resources/git.d.ts +1 -1
- package/out/resources/index.d.ts +0 -1
- package/out/resources/index.d.ts.map +1 -1
- package/out/resources/index.js +0 -1
- package/out/resources/index.js.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts +0 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.js +0 -1
- package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.js +9 -6
- package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
- package/out/routing/index.d.ts +67 -0
- package/out/routing/index.d.ts.map +1 -0
- package/out/routing/index.js +114 -0
- package/out/routing/index.js.map +1 -0
- package/out/sets.d.ts +2 -0
- package/out/sets.d.ts.map +1 -0
- package/out/sets.js +2 -0
- package/out/sets.js.map +1 -0
- package/package.json +28 -2
- package/out/resources/db/index.d.ts +0 -57
- package/out/resources/db/index.d.ts.map +0 -1
- package/out/resources/db/index.js +0 -57
- package/out/resources/db/index.js.map +0 -1
|
@@ -27,25 +27,50 @@ function bioParts(label) {
|
|
|
27
27
|
const dash = label.indexOf("-");
|
|
28
28
|
return { prefix: label.slice(0, dash), tag: label.slice(dash + 1) };
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
// Unicode-aware boundary trim: shrink (start, end) past leading/trailing chars that aren't letters
|
|
31
|
+
// or numbers. Reason: BIO span boundaries from the model occasionally include a preceding comma+
|
|
32
|
+
// space or trailing punctuation token (the "boundary slip" diagnosed in v0.4.0 — see PHASE_2's
|
|
33
|
+
// v0.4.0 entry). The model's tag attribution is correct, only the boundary is fuzzy. Trimming
|
|
34
|
+
// produces a clean canonical value AND clean start/end offsets so downstream consumers slicing
|
|
35
|
+
// raw[start:end] get the same string as node.value.
|
|
36
|
+
function trimBoundary(raw, start, end) {
|
|
37
|
+
let s = start;
|
|
38
|
+
let e = end;
|
|
39
|
+
const isWordChar = (i) => /[\p{L}\p{N}]/u.test(raw[i] ?? "");
|
|
40
|
+
while (s < e && !isWordChar(s))
|
|
41
|
+
s++;
|
|
42
|
+
while (e > s && !isWordChar(e - 1))
|
|
43
|
+
e--;
|
|
44
|
+
return { start: s, end: e };
|
|
45
|
+
}
|
|
46
|
+
function flush(open, raw, out, attribution) {
|
|
31
47
|
if (!open)
|
|
32
48
|
return null;
|
|
33
|
-
const
|
|
49
|
+
const { start, end } = trimBoundary(raw, open.start, open.end);
|
|
50
|
+
// A span that trims to empty (all-punctuation) is meaningless — drop it. Confidence is moot.
|
|
51
|
+
if (start >= end)
|
|
52
|
+
return null;
|
|
53
|
+
const value = raw.slice(start, end);
|
|
34
54
|
const confidence = open.confidences.reduce((a, b) => a + b, 0) / open.confidences.length;
|
|
35
|
-
|
|
55
|
+
const node = { tag: open.tag, start, end, value, confidence, children: [] };
|
|
56
|
+
if (attribution.source !== undefined)
|
|
57
|
+
node.source = attribution.source;
|
|
58
|
+
if (attribution.sourceId !== undefined)
|
|
59
|
+
node.sourceId = attribution.sourceId;
|
|
60
|
+
out.push(node);
|
|
36
61
|
return null;
|
|
37
62
|
}
|
|
38
|
-
function emitSpans(raw, tokens) {
|
|
63
|
+
function emitSpans(raw, tokens, attribution) {
|
|
39
64
|
const out = [];
|
|
40
65
|
let open = null;
|
|
41
66
|
for (const tok of tokens) {
|
|
42
67
|
const { prefix, tag } = bioParts(tok.label);
|
|
43
68
|
if (prefix === "O") {
|
|
44
|
-
open = flush(open, raw, out);
|
|
69
|
+
open = flush(open, raw, out, attribution);
|
|
45
70
|
continue;
|
|
46
71
|
}
|
|
47
72
|
if (prefix === "B" || open === null || open.tag !== tag) {
|
|
48
|
-
open = flush(open, raw, out);
|
|
73
|
+
open = flush(open, raw, out, attribution);
|
|
49
74
|
open = { tag: tag, start: tok.start, end: tok.end, confidences: [tok.confidence] };
|
|
50
75
|
continue;
|
|
51
76
|
}
|
|
@@ -53,7 +78,7 @@ function emitSpans(raw, tokens) {
|
|
|
53
78
|
open.end = tok.end;
|
|
54
79
|
open.confidences.push(tok.confidence);
|
|
55
80
|
}
|
|
56
|
-
flush(open, raw, out);
|
|
81
|
+
flush(open, raw, out, attribution);
|
|
57
82
|
return out;
|
|
58
83
|
}
|
|
59
84
|
function distance(a, b) {
|
|
@@ -83,9 +108,12 @@ function sortByStart(nodes) {
|
|
|
83
108
|
*
|
|
84
109
|
* @param raw The original input as fed to the tokenizer.
|
|
85
110
|
* @param tokens Model output: one entry per piece with predicted BIO label + confidence.
|
|
111
|
+
* @param opts Optional attribution stamped on every emitted node. Callers in the neural pipeline
|
|
112
|
+
* pass `{ source: "neural", sourceId: <model-card-version> }` to mark provenance for the XML
|
|
113
|
+
* serializer's `src` attribute.
|
|
86
114
|
*/
|
|
87
|
-
export function buildAddressTree(raw, tokens) {
|
|
88
|
-
const spans = emitSpans(raw, tokens);
|
|
115
|
+
export function buildAddressTree(raw, tokens, opts = {}) {
|
|
116
|
+
const spans = emitSpans(raw, tokens, opts);
|
|
89
117
|
const roots = [];
|
|
90
118
|
for (const span of spans) {
|
|
91
119
|
const parent = findParent(span, spans);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-tree.js","sourceRoot":"","sources":["../../decoder/build-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"build-tree.js","sourceRoot":"","sources":["../../decoder/build-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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"version":3,"file":"proposals-to-tree.d.ts","sourceRoot":"","sources":["../../decoder/proposals-to-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAgB,MAAM,mBAAmB,CAAA;AAC7E,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,YAAY,CAAA;AAE1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,sBAAsB,EAAE,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"proposals-to-tree.d.ts","sourceRoot":"","sources":["../../decoder/proposals-to-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAgB,MAAM,mBAAmB,CAAA;AAC7E,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,YAAY,CAAA;AAE1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,sBAAsB,EAAE,GAAG,WAAW,CAatG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposals-to-tree.js","sourceRoot":"","sources":["../../decoder/proposals-to-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,SAA4C;IACxF,MAAM,KAAK,GAAkB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClD,GAAG,EAAE,CAAC,CAAC,SAAyB;QAChC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI;QAClB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK;QACnB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG;QACf,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,QAAQ,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"proposals-to-tree.js","sourceRoot":"","sources":["../../decoder/proposals-to-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,SAA4C;IACxF,MAAM,KAAK,GAAkB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClD,GAAG,EAAE,CAAC,CAAC,SAAyB;QAChC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI;QAClB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK;QACnB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG;QACf,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,QAAQ,EAAE,CAAC,CAAC,SAAS;KACrB,CAAC,CAAC,CAAA;IACH,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;IACvC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AACtB,CAAC"}
|
|
@@ -14,8 +14,15 @@
|
|
|
14
14
|
* - `conf` — aggregated confidence in [0, 1], two decimal places.
|
|
15
15
|
* - `start` / `end` — character offsets in the raw input. Preserves source order alongside the
|
|
16
16
|
* containment-derived element order.
|
|
17
|
+
* - `src` — provenance for the assertion. Formatted as `<source>:<sourceId>` when both fields are
|
|
18
|
+
* present on the node, `<source>` when only the broad category is set, omitted when neither
|
|
19
|
+
* is. Phase 4.1 surfaces classifier provenance (`rule:whos_on_first`, `neural:v0.3.1-en-us`);
|
|
20
|
+
* Phase 4.3 overlays resolver provenance (`resolver:wof-admin:101751119`).
|
|
21
|
+
* - `lat` / `lon` — resolver-supplied centroid (Phase 4.3). Emitted only when both are set.
|
|
22
|
+
* - `place` — resolver-supplied normalized place URI like `wof:101751119` (Phase 4.3). Emitted only
|
|
23
|
+
* when `node.placeId` is set; distinct from `src` so callers that want the bare place id
|
|
24
|
+
* without the vendor prefix have a direct attribute to read.
|
|
17
25
|
* - Root `<address>` carries `raw` — the full input string for round-trip.
|
|
18
|
-
* - `src` is reserved for Phase 4 (Resolver source provenance) and not emitted here.
|
|
19
26
|
*
|
|
20
27
|
* ⚠ DOM gotcha: `element.textContent` on a mixed-content node returns the concatenation of all
|
|
21
28
|
* descendant text (parent value + children values). Use `Array.from(el.childNodes).filter(n =>
|
|
@@ -30,6 +37,20 @@ export interface SerializeXmlOpts {
|
|
|
30
37
|
includeConf?: boolean;
|
|
31
38
|
/** Include `start` + `end` char-offset attributes. Default true. */
|
|
32
39
|
includeOffsets?: boolean;
|
|
40
|
+
/** Include `src` provenance attribute when the node carries source info. Default true. */
|
|
41
|
+
includeSrc?: boolean;
|
|
42
|
+
/** Include `lat` + `lon` resolver-supplied centroid attrs when set on the node. Default true. */
|
|
43
|
+
includeGeo?: boolean;
|
|
44
|
+
/** Include `place` resolver-supplied normalized place URI when set. Default true. */
|
|
45
|
+
includePlace?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Include `<alternative>` child elements for each runner-up resolver candidate on the node. When
|
|
48
|
+
* set + node.alternatives is populated, each runner-up is emitted as a self-closing element with
|
|
49
|
+
* `place`, `name`, `lat`, `lon`, `score` attributes. Default false — keeps output
|
|
50
|
+
* libpostal-compat when not explicitly requested (Springfield-class disambiguation surfaces only
|
|
51
|
+
* when the caller asks).
|
|
52
|
+
*/
|
|
53
|
+
includeAlternatives?: boolean;
|
|
33
54
|
}
|
|
34
55
|
/** Project an `AddressTree` to nested XML with optional confidence/offset attributes. */
|
|
35
56
|
export declare function decodeAsXml(tree: AddressTree, opts?: SerializeXmlOpts): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-xml.d.ts","sourceRoot":"","sources":["../../decoder/serialize-xml.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serialize-xml.d.ts","sourceRoot":"","sources":["../../decoder/serialize-xml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,YAAY,CAAA;AAE1D,MAAM,WAAW,gBAAgB;IAChC,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,iEAAiE;IACjE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,oEAAoE;IACpE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,0FAA0F;IAC1F,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iGAAiG;IACjG,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,qFAAqF;IACrF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAoFD,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,GAAE,gBAAqB,GAAG,MAAM,CAelF"}
|
|
@@ -14,8 +14,15 @@
|
|
|
14
14
|
* - `conf` — aggregated confidence in [0, 1], two decimal places.
|
|
15
15
|
* - `start` / `end` — character offsets in the raw input. Preserves source order alongside the
|
|
16
16
|
* containment-derived element order.
|
|
17
|
+
* - `src` — provenance for the assertion. Formatted as `<source>:<sourceId>` when both fields are
|
|
18
|
+
* present on the node, `<source>` when only the broad category is set, omitted when neither
|
|
19
|
+
* is. Phase 4.1 surfaces classifier provenance (`rule:whos_on_first`, `neural:v0.3.1-en-us`);
|
|
20
|
+
* Phase 4.3 overlays resolver provenance (`resolver:wof-admin:101751119`).
|
|
21
|
+
* - `lat` / `lon` — resolver-supplied centroid (Phase 4.3). Emitted only when both are set.
|
|
22
|
+
* - `place` — resolver-supplied normalized place URI like `wof:101751119` (Phase 4.3). Emitted only
|
|
23
|
+
* when `node.placeId` is set; distinct from `src` so callers that want the bare place id
|
|
24
|
+
* without the vendor prefix have a direct attribute to read.
|
|
17
25
|
* - Root `<address>` carries `raw` — the full input string for round-trip.
|
|
18
|
-
* - `src` is reserved for Phase 4 (Resolver source provenance) and not emitted here.
|
|
19
26
|
*
|
|
20
27
|
* ⚠ DOM gotcha: `element.textContent` on a mixed-content node returns the concatenation of all
|
|
21
28
|
* descendant text (parent value + children values). Use `Array.from(el.childNodes).filter(n =>
|
|
@@ -25,24 +32,73 @@
|
|
|
25
32
|
function escapeXml(s) {
|
|
26
33
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
27
34
|
}
|
|
35
|
+
function srcAttrValue(node) {
|
|
36
|
+
if (node.source && node.sourceId)
|
|
37
|
+
return `${node.source}:${node.sourceId}`;
|
|
38
|
+
if (node.source)
|
|
39
|
+
return node.source;
|
|
40
|
+
if (node.sourceId)
|
|
41
|
+
return node.sourceId;
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Centroid precision for resolver-supplied lat/lon. 6 decimal places is ~11 cm at the equator —
|
|
46
|
+
* more than enough for any postal-address resolver and short enough to stay readable.
|
|
47
|
+
*/
|
|
48
|
+
const GEO_PRECISION = 6;
|
|
28
49
|
function attrs(node, opts) {
|
|
29
50
|
const parts = [];
|
|
30
51
|
if (opts.includeOffsets)
|
|
31
52
|
parts.push(`start="${node.start}"`, `end="${node.end}"`);
|
|
32
53
|
if (opts.includeConf)
|
|
33
54
|
parts.push(`conf="${node.confidence.toFixed(2)}"`);
|
|
55
|
+
if (opts.includeSrc) {
|
|
56
|
+
const src = srcAttrValue(node);
|
|
57
|
+
if (src !== null)
|
|
58
|
+
parts.push(`src="${escapeXml(src)}"`);
|
|
59
|
+
}
|
|
60
|
+
// Emit lat + lon together — a centroid is meaningless with only one coordinate. Resolvers that
|
|
61
|
+
// can produce one but not the other shouldn't decorate the node at all.
|
|
62
|
+
if (opts.includeGeo && node.lat !== undefined && node.lon !== undefined) {
|
|
63
|
+
parts.push(`lat="${node.lat.toFixed(GEO_PRECISION)}"`, `lon="${node.lon.toFixed(GEO_PRECISION)}"`);
|
|
64
|
+
}
|
|
65
|
+
if (opts.includePlace && node.placeId !== undefined) {
|
|
66
|
+
parts.push(`place="${escapeXml(node.placeId)}"`);
|
|
67
|
+
}
|
|
34
68
|
return parts.length === 0 ? "" : " " + parts.join(" ");
|
|
35
69
|
}
|
|
70
|
+
function serializeAlternatives(node, indent) {
|
|
71
|
+
if (!node.alternatives || node.alternatives.length === 0)
|
|
72
|
+
return "";
|
|
73
|
+
const lines = node.alternatives.map((raw) => {
|
|
74
|
+
const alt = raw;
|
|
75
|
+
const place = `wof:${alt.id}`;
|
|
76
|
+
const parts = [
|
|
77
|
+
`place="${escapeXml(place)}"`,
|
|
78
|
+
`name="${escapeXml(alt.name)}"`,
|
|
79
|
+
`placetype="${escapeXml(alt.placetype)}"`,
|
|
80
|
+
`lat="${alt.lat.toFixed(GEO_PRECISION)}"`,
|
|
81
|
+
`lon="${alt.lon.toFixed(GEO_PRECISION)}"`,
|
|
82
|
+
`score="${alt.score.toFixed(3)}"`,
|
|
83
|
+
];
|
|
84
|
+
return `${indent}<alternative ${parts.join(" ")} />`;
|
|
85
|
+
});
|
|
86
|
+
return lines.join("\n");
|
|
87
|
+
}
|
|
36
88
|
function serializeNode(node, indent, opts) {
|
|
37
89
|
const a = attrs(node, opts);
|
|
38
90
|
const text = escapeXml(node.value);
|
|
39
91
|
const nl = opts.pretty ? "\n" : "";
|
|
40
92
|
const childIndent = opts.pretty ? indent + "\t" : "";
|
|
41
|
-
|
|
93
|
+
const altsBlock = opts.includeAlternatives ? serializeAlternatives(node, childIndent) : "";
|
|
94
|
+
const hasChildren = node.children.length > 0;
|
|
95
|
+
const hasAlts = altsBlock.length > 0;
|
|
96
|
+
if (!hasChildren && !hasAlts) {
|
|
42
97
|
return `${indent}<${node.tag}${a}>${text}</${node.tag}>`;
|
|
43
98
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
99
|
+
const childrenStr = node.children.map((c) => serializeNode(c, childIndent, opts)).join(nl);
|
|
100
|
+
const inner = [childrenStr, altsBlock].filter(Boolean).join(nl);
|
|
101
|
+
return `${indent}<${node.tag}${a}>${text}${nl}${inner}${nl}${indent}</${node.tag}>`;
|
|
46
102
|
}
|
|
47
103
|
/** Project an `AddressTree` to nested XML with optional confidence/offset attributes. */
|
|
48
104
|
export function decodeAsXml(tree, opts = {}) {
|
|
@@ -50,6 +106,10 @@ export function decodeAsXml(tree, opts = {}) {
|
|
|
50
106
|
pretty: opts.pretty ?? true,
|
|
51
107
|
includeConf: opts.includeConf ?? true,
|
|
52
108
|
includeOffsets: opts.includeOffsets ?? true,
|
|
109
|
+
includeSrc: opts.includeSrc ?? true,
|
|
110
|
+
includeGeo: opts.includeGeo ?? true,
|
|
111
|
+
includePlace: opts.includePlace ?? true,
|
|
112
|
+
includeAlternatives: opts.includeAlternatives ?? false,
|
|
53
113
|
};
|
|
54
114
|
const rawAttr = escapeXml(tree.raw);
|
|
55
115
|
const nl = full.pretty ? "\n" : "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-xml.js","sourceRoot":"","sources":["../../decoder/serialize-xml.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serialize-xml.js","sourceRoot":"","sources":["../../decoder/serialize-xml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA2BH,SAAS,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACpG,CAAC;AAED,SAAS,YAAY,CAAC,IAAiB;IACtC,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ;QAAE,OA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GAAG,CAAA;AACpF,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,OAAyB,EAAE;IACzE,MAAM,IAAI,GAA+B;QACxC,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI;QAC3B,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;QACrC,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI;QAC3C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;QACnC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;QACnC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI;QACvC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,IAAI,KAAK;KACtD,CAAA;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/E,OAAO,iBAAiB,OAAO,KAAK,EAAE,GAAG,QAAQ,GAAG,EAAE,YAAY,CAAA;AACnE,CAAC"}
|
package/out/decoder/types.d.ts
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
* parser availability.
|
|
19
19
|
*
|
|
20
20
|
* See `containment.ts` for the parent-of mapping that drives nesting.
|
|
21
|
+
*
|
|
22
|
+
* Phase 4.1 added optional `source` / `sourceId` on `AddressNode` so the XML serializer can emit
|
|
23
|
+
* provenance via `src="<source>:<sourceId>"`. The neural pipeline stamps these via
|
|
24
|
+
* `BuildTreeOpts`; the proposal-derived path threads them through from `ClassificationProposal`.
|
|
25
|
+
* JSON / tuple projections deliberately do not surface provenance — libpostal compat is
|
|
26
|
+
* load-bearing.
|
|
21
27
|
*/
|
|
22
28
|
import type { BioLabel, ComponentTag } from "../types/component.js";
|
|
23
29
|
export type { BioLabel, ComponentTag };
|
|
@@ -55,6 +61,45 @@ export interface AddressNode {
|
|
|
55
61
|
end: number;
|
|
56
62
|
confidence: number;
|
|
57
63
|
children: AddressNode[];
|
|
64
|
+
/**
|
|
65
|
+
* Broad category of the assertion's origin. `"rule"` and `"neural"` come from classifier
|
|
66
|
+
* proposals; `"resolver"` is set by Phase 4.3's resolver when it overwrites the classifier
|
|
67
|
+
* attribution (the displaced classifier source lands in `metadata.classifier_source`).
|
|
68
|
+
*/
|
|
69
|
+
source?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Specific identifier within `source`: a rule classifier id like `"whos_on_first"`, a neural
|
|
72
|
+
* model card version like `"neural-v0.3.1-en-us"`, or a resolver-supplied place id like
|
|
73
|
+
* `"wof-admin:101751119"`.
|
|
74
|
+
*/
|
|
75
|
+
sourceId?: string;
|
|
76
|
+
/** Resolver-supplied centroid latitude (Phase 4.3). Optional — only set when a resolver wins. */
|
|
77
|
+
lat?: number;
|
|
78
|
+
/** Resolver-supplied centroid longitude (Phase 4.3). Optional — only set when a resolver wins. */
|
|
79
|
+
lon?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Resolver-supplied normalized place URI (Phase 4.3) — `"wof:101751119"` for a WOF place.
|
|
82
|
+
* Distinct from `sourceId` (which includes the resolver vendor) so consumers that want the
|
|
83
|
+
* canonical place id without the vendor prefix have one.
|
|
84
|
+
*/
|
|
85
|
+
placeId?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Opaque per-node metadata bag. Phase 4.3 uses keys `classifier_source` and
|
|
88
|
+
* `classifier_source_id` to preserve the displaced classifier attribution when a resolver wins.
|
|
89
|
+
* Never consulted by the decoder or serializers — debugging + downstream telemetry only.
|
|
90
|
+
*/
|
|
91
|
+
metadata?: Record<string, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* Top-k alternative resolutions for this node, ranked by score (highest first). The winning
|
|
94
|
+
* candidate is reflected in `placeId` / `lat` / `lon` / `sourceId`. Surfaced for failure mode #8
|
|
95
|
+
* (Springfield-class ambiguity) — callers needing disambiguation see the runners-up. Empty /
|
|
96
|
+
* absent when the resolver returned a single candidate.
|
|
97
|
+
*
|
|
98
|
+
* Typed as `unknown[]` here to avoid a circular import on `ResolvedPlace`; resolver-emitting code
|
|
99
|
+
* sets the concrete shape, consumers may cast to `ResolvedPlace[]` from
|
|
100
|
+
* `@mailwoman/core/resolver`.
|
|
101
|
+
*/
|
|
102
|
+
alternatives?: ReadonlyArray<unknown>;
|
|
58
103
|
}
|
|
59
104
|
/**
|
|
60
105
|
* The full decoded tree for one parsed address.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../decoder/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../decoder/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEnE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAA;IACb,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAA;IACX,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,CAAA;IACf,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC3B,GAAG,EAAE,YAAY,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iGAAiG;IACjG,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kGAAkG;IAClG,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CACrC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC3B,0FAA0F;IAC1F,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,WAAW,EAAE,CAAA;CACpB"}
|
package/out/decoder/types.js
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
* parser availability.
|
|
19
19
|
*
|
|
20
20
|
* See `containment.ts` for the parent-of mapping that drives nesting.
|
|
21
|
+
*
|
|
22
|
+
* Phase 4.1 added optional `source` / `sourceId` on `AddressNode` so the XML serializer can emit
|
|
23
|
+
* provenance via `src="<source>:<sourceId>"`. The neural pipeline stamps these via
|
|
24
|
+
* `BuildTreeOpts`; the proposal-derived path threads them through from `ClassificationProposal`.
|
|
25
|
+
* JSON / tuple projections deliberately do not surface provenance — libpostal compat is
|
|
26
|
+
* load-bearing.
|
|
21
27
|
*/
|
|
22
28
|
export {};
|
|
23
29
|
//# sourceMappingURL=types.js.map
|
package/out/decoder/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../decoder/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../decoder/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import type { StatusCodes } from "http-status-codes";
|
|
7
|
+
/**
|
|
8
|
+
* Type-helper to extract the status code from a `ResourceError`.
|
|
9
|
+
*/
|
|
10
|
+
export type ExtractResourceErrorStatusCode<T> = T extends ResourceError<infer S> ? S : never;
|
|
11
|
+
declare const kResourceError = "_kResourceError";
|
|
12
|
+
/**
|
|
13
|
+
* An entity registered with the Federal Communications Commission (FCC) that provides
|
|
14
|
+
* telecommunications services.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ResourceError<S extends StatusCodes = StatusCodes> extends Error {
|
|
17
|
+
static DefaultStatus: number;
|
|
18
|
+
static DefaultMessage: string;
|
|
19
|
+
[kResourceError]: boolean;
|
|
20
|
+
static [Symbol.hasInstance](input: unknown): input is ResourceError;
|
|
21
|
+
static from<S extends StatusCodes = StatusCodes>(statusCode: S, message: string, ...urnSegments: string[]): ResourceError<S>;
|
|
22
|
+
/**
|
|
23
|
+
* Given an error, wraps it in a ResourceError instance.
|
|
24
|
+
*/
|
|
25
|
+
static wrap<E extends Error>(error: E, message?: string, ...urnSegments: string[]): E extends ResourceError<infer ActualStatusCode> ? ResourceError<ActualStatusCode> : ResourceError;
|
|
26
|
+
/**
|
|
27
|
+
* Given a possible instance of `Error`, wraps it in a `ResourceError` instance.
|
|
28
|
+
*
|
|
29
|
+
* Note that if the error is already an instance of `ResourceError`, it will be returned as-is.
|
|
30
|
+
*/
|
|
31
|
+
static wrap<S extends StatusCodes>(error: unknown, message?: string, ...urnSegments: string[]): ResourceError<S>;
|
|
32
|
+
get [Symbol.toStringTag](): string;
|
|
33
|
+
/**
|
|
34
|
+
* @title HTTP status code.
|
|
35
|
+
*
|
|
36
|
+
* A numeric status code conforming to the HTTP standard.
|
|
37
|
+
*/
|
|
38
|
+
status: S;
|
|
39
|
+
/**
|
|
40
|
+
* @title Error message.
|
|
41
|
+
*
|
|
42
|
+
* A human-readable error message explaining the error.
|
|
43
|
+
*/
|
|
44
|
+
message: string;
|
|
45
|
+
/**
|
|
46
|
+
* @title URN identifier.
|
|
47
|
+
*
|
|
48
|
+
* A unique identifier for the error, used to reference it in logs and other systems.
|
|
49
|
+
*
|
|
50
|
+
* @format uri
|
|
51
|
+
*/
|
|
52
|
+
name: string;
|
|
53
|
+
constructor(status: S | undefined, urn: string, message?: string);
|
|
54
|
+
toJSON(): {
|
|
55
|
+
name: string;
|
|
56
|
+
status: S;
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
toString(): string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @public
|
|
63
|
+
* @title Resource Error
|
|
64
|
+
*
|
|
65
|
+
* An error response from a resource, such as an API, database, or file.
|
|
66
|
+
*/
|
|
67
|
+
export type ResourceErrorSchema = Pick<ResourceError, "status" | "message" | "name">;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts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EAAE,CAAC,CAAA;IACT;;;;OAIG;IACM,OAAO,EAAG,MAAM,CAAA;IAEzB;;;;;;OAMG;IACM,IAAI,EAAE,MAAM,CAAA;gBAET,MAAM,EAAE,CAAC,YAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,SAA+B;IAQ9E,MAAM;;;;;IAQG,QAAQ,IAAI,MAAM;CASlC;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
const kResourceError = "_kResourceError";
|
|
7
|
+
/**
|
|
8
|
+
* An entity registered with the Federal Communications Commission (FCC) that provides
|
|
9
|
+
* telecommunications services.
|
|
10
|
+
*/
|
|
11
|
+
export class ResourceError extends Error {
|
|
12
|
+
static DefaultStatus = 500;
|
|
13
|
+
static DefaultMessage = "An unknown error occurred.";
|
|
14
|
+
// public readonly $schema = $ResourceError.pathname
|
|
15
|
+
[kResourceError] = true;
|
|
16
|
+
static [Symbol.hasInstance](input) {
|
|
17
|
+
if (!input)
|
|
18
|
+
return false;
|
|
19
|
+
if (typeof input !== "object")
|
|
20
|
+
return false;
|
|
21
|
+
if (kResourceError in input)
|
|
22
|
+
return true;
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
static from(statusCode, message, ...urnSegments) {
|
|
26
|
+
return new ResourceError(statusCode, urnSegments.length ? urnSegments.join(":") : "unknown", message);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Given a possible instance of `Error`, wraps it in a `ResourceError` instance.
|
|
30
|
+
*
|
|
31
|
+
* Note that if the error is already an instance of `ResourceError`, it will be returned as-is.
|
|
32
|
+
*/
|
|
33
|
+
static wrap(error, message, ...urnSegments) {
|
|
34
|
+
if (error instanceof ResourceError) {
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
let status = this.DefaultStatus;
|
|
38
|
+
if (error instanceof Error) {
|
|
39
|
+
message ||= error.message || this.DefaultMessage;
|
|
40
|
+
if ("status" in error) {
|
|
41
|
+
switch (typeof error.status) {
|
|
42
|
+
case "number":
|
|
43
|
+
status = error.status;
|
|
44
|
+
break;
|
|
45
|
+
case "string":
|
|
46
|
+
status = parseInt(error.status, 10) || this.DefaultStatus;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
message ||= this.DefaultMessage;
|
|
53
|
+
}
|
|
54
|
+
const wrapper = this.from(status, message, ...urnSegments);
|
|
55
|
+
wrapper.cause = error;
|
|
56
|
+
return wrapper;
|
|
57
|
+
}
|
|
58
|
+
get [Symbol.toStringTag]() {
|
|
59
|
+
return `ResourceError<${this.name}>`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @title HTTP status code.
|
|
63
|
+
*
|
|
64
|
+
* A numeric status code conforming to the HTTP standard.
|
|
65
|
+
*/
|
|
66
|
+
status;
|
|
67
|
+
/**
|
|
68
|
+
* @title Error message.
|
|
69
|
+
*
|
|
70
|
+
* A human-readable error message explaining the error.
|
|
71
|
+
*/
|
|
72
|
+
message;
|
|
73
|
+
/**
|
|
74
|
+
* @title URN identifier.
|
|
75
|
+
*
|
|
76
|
+
* A unique identifier for the error, used to reference it in logs and other systems.
|
|
77
|
+
*
|
|
78
|
+
* @format uri
|
|
79
|
+
*/
|
|
80
|
+
name;
|
|
81
|
+
constructor(status = 500, urn, message = "An unknown error occurred.") {
|
|
82
|
+
super(message);
|
|
83
|
+
this.message = message;
|
|
84
|
+
this.name = urn || [status, "nexus", "isp"].join(":");
|
|
85
|
+
this.status = status;
|
|
86
|
+
}
|
|
87
|
+
toJSON() {
|
|
88
|
+
return {
|
|
89
|
+
name: this.name,
|
|
90
|
+
status: this.status,
|
|
91
|
+
message: this.message,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
toString() {
|
|
95
|
+
const messageSegments = [`[${this.status}] (${this.name}) ${this.message}`];
|
|
96
|
+
if (this.cause instanceof Error && this.cause.message && this.cause !== this) {
|
|
97
|
+
messageSegments.push(`\nCaused by: ${this.cause.message}`);
|
|
98
|
+
}
|
|
99
|
+
return messageSegments.join("\n");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../errors/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAExC;;;GAGG;AACH,MAAM,OAAO,aAAmD,SAAQ,KAAK;IAC5E,MAAM,CAAC,aAAa,GAAG,GAAG,CAAA;IAC1B,MAAM,CAAC,cAAc,GAAG,4BAA4B,CAAA;IAEpD,oDAAoD;IAE7C,CAAC,cAAc,CAAC,GAAG,IAAI,CAAA;IAE9B,MAAM,CAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAc;QAClD,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAA;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QAE3C,IAAI,cAAc,IAAI,KAAK;YAAE,OAAO,IAAI,CAAA;QAExC,OAAO,KAAK,CAAA;IACb,CAAC;IAED,MAAM,CAAC,IAAI,CACV,UAAa,EACb,OAAe,EACf,GAAG,WAAqB;QAExB,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACtG,CAAC;IAiBD;;;;OAIG;IAEH,MAAM,CA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IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACrB,CAAC;IAEM,MAAM;QACZ,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAA;IACF,CAAC;IAEe,QAAQ;QACvB,MAAM,eAAe,GAAa,CAAC,IAAI,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QAErF,IAAI,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC9E,eAAe,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3D,CAAC;QAED,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CamelCase, SnakeCase } from "type-fest";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a name to snake_case, unless the name is already in all caps.
|
|
4
|
+
*/
|
|
5
|
+
export declare function smartSnakeCase<T extends string>(name: T): T extends Uppercase<T> ? T : SnakeCase<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Converts a name to camelCase, unless the name is already in all caps.
|
|
8
|
+
*/
|
|
9
|
+
export declare function smartCamelCase<T extends string>(name: T): T extends Uppercase<T> ? T : CamelCase<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Predicate to determine if a given string is uniformly cased, i.e. all uppercase or all lowercase.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isUniformlyCased(input: string | null): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Capitalizes a string, unless the string is uniformly cased, or an email address.
|
|
16
|
+
*/
|
|
17
|
+
export declare function smartCapitalCase(input: string): string;
|
|
18
|
+
//# sourceMappingURL=identifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../identifiers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAiBnG;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAMnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD"}
|