@mailwoman/codex 4.3.0 → 4.5.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-system-conventions.d.ts +2 -2
- package/out/address-system-conventions.js +4 -4
- package/out/au/delivery-service.d.ts +165 -0
- package/out/au/delivery-service.d.ts.map +1 -0
- package/out/au/delivery-service.js +132 -0
- package/out/au/delivery-service.js.map +1 -0
- package/out/au/index.d.ts +15 -0
- package/out/au/index.d.ts.map +1 -0
- package/out/au/index.js +15 -0
- package/out/au/index.js.map +1 -0
- package/out/au/level-designator.d.ts +150 -0
- package/out/au/level-designator.d.ts.map +1 -0
- package/out/au/level-designator.js +156 -0
- package/out/au/level-designator.js.map +1 -0
- package/out/au/postcode.d.ts +40 -0
- package/out/au/postcode.d.ts.map +1 -0
- package/out/au/postcode.js +37 -0
- package/out/au/postcode.js.map +1 -0
- package/out/au/state.d.ts +31 -0
- package/out/au/state.d.ts.map +1 -0
- package/out/au/state.js +31 -0
- package/out/au/state.js.map +1 -0
- package/out/country/country.d.ts +18 -17
- package/out/country/country.d.ts.map +1 -1
- package/out/country/country.js +17 -16
- package/out/country/country.js.map +1 -1
- package/out/country/index.d.ts +1 -1
- package/out/country/index.d.ts.map +1 -1
- package/out/country/index.js +1 -1
- package/out/country/index.js.map +1 -1
- package/out/country/names.d.ts +1 -1
- package/out/country/names.js +1 -1
- package/out/fr/cedex.d.ts +35 -0
- package/out/fr/cedex.d.ts.map +1 -0
- package/out/fr/cedex.js +43 -0
- package/out/fr/cedex.js.map +1 -0
- package/out/fr/index.d.ts +1 -0
- package/out/fr/index.d.ts.map +1 -1
- package/out/fr/index.js +1 -0
- package/out/fr/index.js.map +1 -1
- package/out/index.d.ts +3 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -0
- package/out/index.js.map +1 -1
- package/out/nz/delivery-service.d.ts +102 -0
- package/out/nz/delivery-service.d.ts.map +1 -0
- package/out/nz/delivery-service.js +110 -0
- package/out/nz/delivery-service.js.map +1 -0
- package/out/nz/index.d.ts +12 -0
- package/out/nz/index.d.ts.map +1 -0
- package/out/nz/index.js +12 -0
- package/out/nz/index.js.map +1 -0
- package/out/nz/postcode.d.ts +31 -0
- package/out/nz/postcode.d.ts.map +1 -0
- package/out/nz/postcode.js +28 -0
- package/out/nz/postcode.js.map +1 -0
- package/out/postcode-systems.d.ts +1 -1
- package/out/postcode-systems.d.ts.map +1 -1
- package/out/postcode-systems.js +4 -0
- package/out/postcode-systems.js.map +1 -1
- package/out/us/floor-designator.d.ts +104 -0
- package/out/us/floor-designator.d.ts.map +1 -0
- package/out/us/floor-designator.js +84 -0
- package/out/us/floor-designator.js.map +1 -0
- package/out/us/index.d.ts +6 -2
- package/out/us/index.d.ts.map +1 -1
- package/out/us/index.js +6 -2
- package/out/us/index.js.map +1 -1
- package/out/us/military-address.d.ts +143 -0
- package/out/us/military-address.d.ts.map +1 -0
- package/out/us/military-address.js +156 -0
- package/out/us/military-address.js.map +1 -0
- package/out/us/street-directional.d.ts +4 -2
- package/out/us/street-directional.d.ts.map +1 -1
- package/out/us/street-directional.js +4 -2
- package/out/us/street-directional.js.map +1 -1
- package/out/us/zipcode.d.ts +1 -1
- package/package.json +4 -2
package/out/fr/cedex.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* CEDEX — Courrier d'Entreprise à Distribution EXceptionnelle (La Poste business routing, NF Z
|
|
7
|
+
* 10-011 §3.4). A CEDEX line replaces the ordinary delivery line for high-volume business
|
|
8
|
+
* recipients: `75008 PARIS CEDEX 08` — the word CEDEX after the distribution office name,
|
|
9
|
+
* optionally followed by a 1–2 digit office number. The component is the `CEDEX [NN]` phrase
|
|
10
|
+
* itself (the schema's `cedex` tag); the preceding postcode/locality keep their own tags.
|
|
11
|
+
*
|
|
12
|
+
* This slice closes the gap PR #516 documented: the shard builder sourced the shape from SCHEMA.mdx
|
|
13
|
+
* prose because codex had no cedex home. Now it does — the builder and any future consumer import
|
|
14
|
+
* from here (the no-load-bearing-trivia discipline: one provenanced source).
|
|
15
|
+
*/
|
|
16
|
+
/** Matches a CEDEX phrase: the keyword plus an optional 1–2 digit office number. */
|
|
17
|
+
export const CEDEX_PATTERN = /\bCEDEX(?:\s+(\d{1,2}))?\b/i;
|
|
18
|
+
/**
|
|
19
|
+
* Find the CEDEX phrase in a line, if any. Returns the LAST match — a CEDEX line places the phrase
|
|
20
|
+
* terminally (NF Z 10-011), and any earlier occurrence in pathological input is more likely a venue
|
|
21
|
+
* name fragment.
|
|
22
|
+
*/
|
|
23
|
+
export function matchCedex(text) {
|
|
24
|
+
let match = null;
|
|
25
|
+
const re = new RegExp(CEDEX_PATTERN.source, "gi");
|
|
26
|
+
for (const m of text.matchAll(re)) {
|
|
27
|
+
match = {
|
|
28
|
+
matched: m[0],
|
|
29
|
+
start: m.index,
|
|
30
|
+
end: m.index + m[0].length,
|
|
31
|
+
...(m[1] ? { office: m[1] } : {}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return match;
|
|
35
|
+
}
|
|
36
|
+
/** True when the string is exactly a CEDEX phrase (the component-value validator). */
|
|
37
|
+
export function isCedex(input) {
|
|
38
|
+
if (typeof input !== "string")
|
|
39
|
+
return false;
|
|
40
|
+
const m = input.trim().match(CEDEX_PATTERN);
|
|
41
|
+
return m !== null && m[0].length === input.trim().length;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cedex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cedex.js","sourceRoot":"","sources":["../../fr/cedex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,6BAA6B,CAAA;AAY1D;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,IAAI,KAAK,GAAsB,IAAI,CAAA;IACnC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,KAAK,GAAG;YACP,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YACb,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,GAAG,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;YAC1B,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjC,CAAA;IACF,CAAC;IACD,OAAO,KAAK,CAAA;AACb,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,OAAO,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAC3C,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAA;AACzD,CAAC"}
|
package/out/fr/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* The French address system (La Poste / ISO 3166-2:FR): street types (voie), postal codes (code
|
|
7
7
|
* postal), and the admin hierarchy of départements and régions.
|
|
8
8
|
*/
|
|
9
|
+
export * from "./cedex.js";
|
|
9
10
|
export * from "./code-postal.js";
|
|
10
11
|
export * from "./departement.js";
|
|
11
12
|
export * from "./region.js";
|
package/out/fr/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
|
package/out/fr/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* The French address system (La Poste / ISO 3166-2:FR): street types (voie), postal codes (code
|
|
7
7
|
* postal), and the admin hierarchy of départements and régions.
|
|
8
8
|
*/
|
|
9
|
+
export * from "./cedex.js";
|
|
9
10
|
export * from "./code-postal.js";
|
|
10
11
|
export * from "./departement.js";
|
|
11
12
|
export * from "./region.js";
|
package/out/fr/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../fr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../fr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
|
package/out/index.d.ts
CHANGED
|
@@ -17,12 +17,14 @@
|
|
|
17
17
|
* `candidateSystemsForPostcode` (the inverse of the per-slice postcode patterns) is a top-level
|
|
18
18
|
* export.
|
|
19
19
|
*/
|
|
20
|
-
export { ADDRESS_SYSTEM_CONVENTIONS, type AddressSystemConventions,
|
|
20
|
+
export { ADDRESS_SYSTEM_CONVENTIONS, conventionsForSystem, type AddressSystemConventions, } from "./address-system-conventions.js";
|
|
21
|
+
export * as au from "./au/index.js";
|
|
21
22
|
export * as ca from "./ca/index.js";
|
|
22
23
|
export * as de from "./de/index.js";
|
|
23
24
|
export * as fr from "./fr/index.js";
|
|
24
25
|
export * as gb from "./gb/index.js";
|
|
25
26
|
export * as jp from "./jp/index.js";
|
|
27
|
+
export * as nz from "./nz/index.js";
|
|
26
28
|
export { candidateSystemsForPostcode, type SystemCode } from "./postcode-systems.js";
|
|
27
29
|
export * as us from "./us/index.js";
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACN,0BAA0B,EAC1B,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACN,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,wBAAwB,GAC7B,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,2BAA2B,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
* export.
|
|
19
19
|
*/
|
|
20
20
|
export { ADDRESS_SYSTEM_CONVENTIONS, conventionsForSystem, } from "./address-system-conventions.js";
|
|
21
|
+
export * as au from "./au/index.js";
|
|
21
22
|
export * as ca from "./ca/index.js";
|
|
22
23
|
export * as de from "./de/index.js";
|
|
23
24
|
export * as fr from "./fr/index.js";
|
|
24
25
|
export * as gb from "./gb/index.js";
|
|
25
26
|
export * as jp from "./jp/index.js";
|
|
27
|
+
export * as nz from "./nz/index.js";
|
|
26
28
|
export { candidateSystemsForPostcode } from "./postcode-systems.js";
|
|
27
29
|
export * as us from "./us/index.js";
|
|
28
30
|
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACN,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACN,0BAA0B,EAC1B,oBAAoB,GAEpB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,2BAA2B,EAAmB,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* NZ Post delivery-service types — the second half of the Commonwealth po_box vocabulary: `PO Box
|
|
7
|
+
* 24999`, `Private Bag 106999`, `CMB B99`, plus the identifier-less counter services.
|
|
8
|
+
*
|
|
9
|
+
* Sourcing (accessed 2026-06-11):
|
|
10
|
+
*
|
|
11
|
+
* - NZ Post Address Standards (ADV358, October 2021 edition hosted on nzpost.co.nz) is the
|
|
12
|
+
* authoritative document. Verbatim: "The Delivery Service Type is mandatory. It may be PO
|
|
13
|
+
* Box, Private Bag, CMB, Response Bag, Counter Delivery or Poste Restante." Its Delivery
|
|
14
|
+
* Service Elements table gives the descriptions reproduced in
|
|
15
|
+
* {@link NZ_DELIVERY_SERVICE_TYPES}, and the identifier rules: "The Delivery Service
|
|
16
|
+
* Identifier must have no leading zeros and no spaces, separators or other punctuation"; "The
|
|
17
|
+
* Delivery Service Identifier is not used for Counter Delivery or Poste Restante. It is also
|
|
18
|
+
* not used for Private Bags that do not have an identifier allocated by New Zealand Post".
|
|
19
|
+
* Examples: `PO Box 24999`, `Private Bag 106999`, `Response Bag 500999`, `CMB B99`, `Counter
|
|
20
|
+
* Delivery`, `Poste Restante`. The standard's incorrect-form examples show `P O Box 4 099`
|
|
21
|
+
* and `PB 39990` as wrong — `PB` is a common error, not a designator, so it is NOT in this
|
|
22
|
+
* table.
|
|
23
|
+
* - The live addressing-standards page repeats the format rules: "PO Box and Private Bag numbers are
|
|
24
|
+
* space-free (eg. 'PO Box 23226', not 'PO Box 23 226')", "'PO' is space-free … and
|
|
25
|
+
* punctuation-free".
|
|
26
|
+
*
|
|
27
|
+
* All six types are CURRENT in the October 2021 ADV358 (including CMB — no legacy flag is needed
|
|
28
|
+
* for the NZ slice). "Private Box" — a colloquial NZ synonym for a PO Box that the postal arena's
|
|
29
|
+
* gold rows carry — does NOT appear in ADV358 or the live standards pages and is therefore
|
|
30
|
+
* excluded here (see the issue #517 sourcing note: a smaller sourced list beats a larger guessed
|
|
31
|
+
* one).
|
|
32
|
+
* @see {@link https://www.nzpost.co.nz/sites/nz/files/2021-10/adv358-address-standards.pdf NZ Post Address Standards (ADV358, Oct 2021)}
|
|
33
|
+
* @see {@link https://www.nzpost.co.nz/business/shipping-in-nz/addressing-standards NZ Post addressing standards}
|
|
34
|
+
* @see {@link https://www.nzpost.co.nz/personal/sending-in-nz/how-to-address-mail NZ Post — how to address mail}
|
|
35
|
+
*/
|
|
36
|
+
/** Identifier requirement per ADV358's Delivery Service Elements rules. */
|
|
37
|
+
export type NzIdentifierRule = "required-if-allocated" | "optional" | "not-used";
|
|
38
|
+
/** One Delivery Service Type row from ADV358. */
|
|
39
|
+
export interface NzDeliveryServiceType {
|
|
40
|
+
/** The Delivery Service Type, verbatim casing per ADV358 ("PO Box", "Private Bag", "CMB"). */
|
|
41
|
+
type: string;
|
|
42
|
+
/** The ADV358 description, verbatim. */
|
|
43
|
+
description: string;
|
|
44
|
+
/**
|
|
45
|
+
* Identifier rule: PO Box/Response Bag/CMB identifiers are mandatory if allocated; Private Bag
|
|
46
|
+
* may legitimately have none ("not used … for Private Bags that do not have an identifier
|
|
47
|
+
* allocated by New Zealand Post"); Counter Delivery and Poste Restante never carry one.
|
|
48
|
+
*/
|
|
49
|
+
identifier: NzIdentifierRule;
|
|
50
|
+
}
|
|
51
|
+
/** The six Delivery Service Types, verbatim from ADV358 (see the module header). */
|
|
52
|
+
export declare const NZ_DELIVERY_SERVICE_TYPES: readonly [{
|
|
53
|
+
readonly type: "PO Box";
|
|
54
|
+
readonly description: "Post Box, PO Box";
|
|
55
|
+
readonly identifier: "required-if-allocated";
|
|
56
|
+
}, {
|
|
57
|
+
readonly type: "Private Bag";
|
|
58
|
+
readonly description: "Private Bag";
|
|
59
|
+
readonly identifier: "optional";
|
|
60
|
+
}, {
|
|
61
|
+
readonly type: "Response Bag";
|
|
62
|
+
readonly description: "Response Bag (used for competitions)";
|
|
63
|
+
readonly identifier: "required-if-allocated";
|
|
64
|
+
}, {
|
|
65
|
+
readonly type: "CMB";
|
|
66
|
+
readonly description: "Community Mail Box in postal outlet or on a thoroughfare";
|
|
67
|
+
readonly identifier: "required-if-allocated";
|
|
68
|
+
}, {
|
|
69
|
+
readonly type: "Counter Delivery";
|
|
70
|
+
readonly description: "Hold for Counter Delivery collection - domestic mail";
|
|
71
|
+
readonly identifier: "not-used";
|
|
72
|
+
}, {
|
|
73
|
+
readonly type: "Poste Restante";
|
|
74
|
+
readonly description: "Hold for Poste Restante collection - international mail";
|
|
75
|
+
readonly identifier: "not-used";
|
|
76
|
+
}];
|
|
77
|
+
/** A canonical NZ Delivery Service Type. */
|
|
78
|
+
export type NzDeliveryServiceTypeName = (typeof NZ_DELIVERY_SERVICE_TYPES)[number]["type"];
|
|
79
|
+
/** Result of an NZ delivery-service parse. */
|
|
80
|
+
export interface NzDeliveryServiceMatch {
|
|
81
|
+
/** The designator phrase as it appeared ("PO Box", "private bag"). */
|
|
82
|
+
matched: string;
|
|
83
|
+
/** The canonical Delivery Service Type ("PO Box", "Private Bag", "CMB", …). */
|
|
84
|
+
type: NzDeliveryServiceTypeName;
|
|
85
|
+
/** The Delivery Service Identifier when present ("24999", "B99"). */
|
|
86
|
+
id?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* If `input` is a standalone NZ delivery-service phrase ("PO Box 24999", "Private Bag 106999", "CMB
|
|
90
|
+
* B99", bare "Private Bag", "Counter Delivery"), return the canonical type and identifier. Null
|
|
91
|
+
* otherwise — including for "PB 39990" (an error of form per ADV358) and "Private Box" (not a
|
|
92
|
+
* Delivery Service Type).
|
|
93
|
+
*/
|
|
94
|
+
export declare function matchNzDeliveryService(input: unknown): NzDeliveryServiceMatch | null;
|
|
95
|
+
/** Type-predicate: does the input look like a standalone NZ delivery-service address line? */
|
|
96
|
+
export declare function isNzDeliveryService(input: unknown): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Normalize a recognized phrase to the ADV358 form (`"p.o. box 24999"` → `"PO Box 24999"`). Returns
|
|
99
|
+
* the input unchanged if it isn't a delivery-service phrase.
|
|
100
|
+
*/
|
|
101
|
+
export declare function normalizeNzDeliveryService(input: string): string;
|
|
102
|
+
//# sourceMappingURL=delivery-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-service.d.ts","sourceRoot":"","sources":["../../nz/delivery-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,GAAG,UAAU,GAAG,UAAU,CAAA;AAEhF,iDAAiD;AACjD,MAAM,WAAW,qBAAqB;IACrC,8FAA8F;IAC9F,IAAI,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,UAAU,EAAE,gBAAgB,CAAA;CAC5B;AAED,oFAAoF;AACpF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;EAmBe,CAAA;AAErD,4CAA4C;AAC5C,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AA6B1F,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACtC,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAA;IACf,+EAA+E;IAC/E,IAAI,EAAE,yBAAyB,CAAA;IAC/B,qEAAqE;IACrE,EAAE,CAAC,EAAE,MAAM,CAAA;CACX;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,GAAG,IAAI,CAQpF;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE3D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* NZ Post delivery-service types — the second half of the Commonwealth po_box vocabulary: `PO Box
|
|
7
|
+
* 24999`, `Private Bag 106999`, `CMB B99`, plus the identifier-less counter services.
|
|
8
|
+
*
|
|
9
|
+
* Sourcing (accessed 2026-06-11):
|
|
10
|
+
*
|
|
11
|
+
* - NZ Post Address Standards (ADV358, October 2021 edition hosted on nzpost.co.nz) is the
|
|
12
|
+
* authoritative document. Verbatim: "The Delivery Service Type is mandatory. It may be PO
|
|
13
|
+
* Box, Private Bag, CMB, Response Bag, Counter Delivery or Poste Restante." Its Delivery
|
|
14
|
+
* Service Elements table gives the descriptions reproduced in
|
|
15
|
+
* {@link NZ_DELIVERY_SERVICE_TYPES}, and the identifier rules: "The Delivery Service
|
|
16
|
+
* Identifier must have no leading zeros and no spaces, separators or other punctuation"; "The
|
|
17
|
+
* Delivery Service Identifier is not used for Counter Delivery or Poste Restante. It is also
|
|
18
|
+
* not used for Private Bags that do not have an identifier allocated by New Zealand Post".
|
|
19
|
+
* Examples: `PO Box 24999`, `Private Bag 106999`, `Response Bag 500999`, `CMB B99`, `Counter
|
|
20
|
+
* Delivery`, `Poste Restante`. The standard's incorrect-form examples show `P O Box 4 099`
|
|
21
|
+
* and `PB 39990` as wrong — `PB` is a common error, not a designator, so it is NOT in this
|
|
22
|
+
* table.
|
|
23
|
+
* - The live addressing-standards page repeats the format rules: "PO Box and Private Bag numbers are
|
|
24
|
+
* space-free (eg. 'PO Box 23226', not 'PO Box 23 226')", "'PO' is space-free … and
|
|
25
|
+
* punctuation-free".
|
|
26
|
+
*
|
|
27
|
+
* All six types are CURRENT in the October 2021 ADV358 (including CMB — no legacy flag is needed
|
|
28
|
+
* for the NZ slice). "Private Box" — a colloquial NZ synonym for a PO Box that the postal arena's
|
|
29
|
+
* gold rows carry — does NOT appear in ADV358 or the live standards pages and is therefore
|
|
30
|
+
* excluded here (see the issue #517 sourcing note: a smaller sourced list beats a larger guessed
|
|
31
|
+
* one).
|
|
32
|
+
* @see {@link https://www.nzpost.co.nz/sites/nz/files/2021-10/adv358-address-standards.pdf NZ Post Address Standards (ADV358, Oct 2021)}
|
|
33
|
+
* @see {@link https://www.nzpost.co.nz/business/shipping-in-nz/addressing-standards NZ Post addressing standards}
|
|
34
|
+
* @see {@link https://www.nzpost.co.nz/personal/sending-in-nz/how-to-address-mail NZ Post — how to address mail}
|
|
35
|
+
*/
|
|
36
|
+
/** The six Delivery Service Types, verbatim from ADV358 (see the module header). */
|
|
37
|
+
export const NZ_DELIVERY_SERVICE_TYPES = [
|
|
38
|
+
{ type: "PO Box", description: "Post Box, PO Box", identifier: "required-if-allocated" },
|
|
39
|
+
{ type: "Private Bag", description: "Private Bag", identifier: "optional" },
|
|
40
|
+
{ type: "Response Bag", description: "Response Bag (used for competitions)", identifier: "required-if-allocated" },
|
|
41
|
+
{
|
|
42
|
+
type: "CMB",
|
|
43
|
+
description: "Community Mail Box in postal outlet or on a thoroughfare",
|
|
44
|
+
identifier: "required-if-allocated",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "Counter Delivery",
|
|
48
|
+
description: "Hold for Counter Delivery collection - domestic mail",
|
|
49
|
+
identifier: "not-used",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: "Poste Restante",
|
|
53
|
+
description: "Hold for Poste Restante collection - international mail",
|
|
54
|
+
identifier: "not-used",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* Per-type surface patterns (designator phrase only). Recognition is deliberately wider than the
|
|
59
|
+
* prescriptive standard — mail in the wild writes "P.O. Box" even though ADV358 says `PO` is
|
|
60
|
+
* punctuation-free — but it does NOT admit forms the standard names as errors of TYPE (`PB`) or
|
|
61
|
+
* types that don't exist ("Private Box").
|
|
62
|
+
*/
|
|
63
|
+
const TYPE_PATTERNS = [
|
|
64
|
+
["PO Box", String.raw `p\.?\s*o\.?\s*box|post\s+box`],
|
|
65
|
+
["Private Bag", String.raw `private\s+bag`],
|
|
66
|
+
["Response Bag", String.raw `response\s+bag`],
|
|
67
|
+
["CMB", String.raw `community\s+mail\s+box|cmb`],
|
|
68
|
+
["Counter Delivery", String.raw `counter\s+delivery`],
|
|
69
|
+
["Poste Restante", String.raw `poste\s+restante`],
|
|
70
|
+
];
|
|
71
|
+
const IDENTIFIER_RULES = new Map(NZ_DELIVERY_SERVICE_TYPES.map((t) => [t.type, t.identifier]));
|
|
72
|
+
// One anchored regex per type. The identifier shape follows ADV358 (alphanumeric, no spaces or
|
|
73
|
+
// separators — `24999`, `B99`); the identifier-less counter services take no tail at all.
|
|
74
|
+
const MATCHERS = TYPE_PATTERNS.map(([type, src]) => {
|
|
75
|
+
const rule = IDENTIFIER_RULES.get(type);
|
|
76
|
+
const tail = rule === "not-used" ? "" : String.raw `(?:\s+([\dA-Za-z]+))${rule === "optional" ? "?" : ""}`;
|
|
77
|
+
return { type, re: new RegExp(String.raw `^\s*(${src})${tail}\s*$`, "i") };
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* If `input` is a standalone NZ delivery-service phrase ("PO Box 24999", "Private Bag 106999", "CMB
|
|
81
|
+
* B99", bare "Private Bag", "Counter Delivery"), return the canonical type and identifier. Null
|
|
82
|
+
* otherwise — including for "PB 39990" (an error of form per ADV358) and "Private Box" (not a
|
|
83
|
+
* Delivery Service Type).
|
|
84
|
+
*/
|
|
85
|
+
export function matchNzDeliveryService(input) {
|
|
86
|
+
if (typeof input !== "string")
|
|
87
|
+
return null;
|
|
88
|
+
for (const { type, re } of MATCHERS) {
|
|
89
|
+
const m = re.exec(input);
|
|
90
|
+
if (!m)
|
|
91
|
+
continue;
|
|
92
|
+
return { matched: m[1].trim(), type, ...(m[2] ? { id: m[2] } : {}) };
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
/** Type-predicate: does the input look like a standalone NZ delivery-service address line? */
|
|
97
|
+
export function isNzDeliveryService(input) {
|
|
98
|
+
return matchNzDeliveryService(input) !== null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Normalize a recognized phrase to the ADV358 form (`"p.o. box 24999"` → `"PO Box 24999"`). Returns
|
|
102
|
+
* the input unchanged if it isn't a delivery-service phrase.
|
|
103
|
+
*/
|
|
104
|
+
export function normalizeNzDeliveryService(input) {
|
|
105
|
+
const m = matchNzDeliveryService(input);
|
|
106
|
+
if (!m)
|
|
107
|
+
return input;
|
|
108
|
+
return m.id ? `${m.type} ${m.id.toUpperCase()}` : m.type;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=delivery-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-service.js","sourceRoot":"","sources":["../../nz/delivery-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAmBH,oFAAoF;AACpF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,uBAAuB,EAAE;IACxF,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE;IAC3E,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,sCAAsC,EAAE,UAAU,EAAE,uBAAuB,EAAE;IAClH;QACC,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,0DAA0D;QACvE,UAAU,EAAE,uBAAuB;KACnC;IACD;QACC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AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The New Zealand address system (NZ Post / ISO 3166-2:NZ; ADV358 Address Standards):
|
|
7
|
+
* delivery-service types (PO Box, Private Bag, CMB, Response Bag, Counter Delivery, Poste
|
|
8
|
+
* Restante) and the 4-digit postcode. NZ addresses carry no state/region line.
|
|
9
|
+
*/
|
|
10
|
+
export * from "./delivery-service.js";
|
|
11
|
+
export * from "./postcode.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../nz/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA"}
|
package/out/nz/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The New Zealand address system (NZ Post / ISO 3166-2:NZ; ADV358 Address Standards):
|
|
7
|
+
* delivery-service types (PO Box, Private Bag, CMB, Response Bag, Counter Delivery, Poste
|
|
8
|
+
* Restante) and the 4-digit postcode. NZ addresses carry no state/region line.
|
|
9
|
+
*/
|
|
10
|
+
export * from "./delivery-service.js";
|
|
11
|
+
export * from "./postcode.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../nz/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* New Zealand postcodes: four digits, after the town/city on the last line (`Timaru 7942`).
|
|
7
|
+
* Verbatim from NZ Post's Address Standards (ADV358, Oct 2021, accessed 2026-06-11): "Postcode is
|
|
8
|
+
* mandatory and is four digits. It follows the city or town." Note NZ has no state/region line —
|
|
9
|
+
* "The province, region, district or territory is not to be used."
|
|
10
|
+
*
|
|
11
|
+
* The shape collides with Australia's (also 4 digits) — `candidateSystemsForPostcode` returns both,
|
|
12
|
+
* by design (shape test, not membership test).
|
|
13
|
+
* @see {@link https://www.nzpost.co.nz/sites/nz/files/2021-10/adv358-address-standards.pdf NZ Post Address Standards (ADV358, Oct 2021)}
|
|
14
|
+
*/
|
|
15
|
+
import type { Tagged } from "type-fest";
|
|
16
|
+
/**
|
|
17
|
+
* A New Zealand postcode: four digits.
|
|
18
|
+
*
|
|
19
|
+
* @category Postal
|
|
20
|
+
* @type string
|
|
21
|
+
* @title New Zealand postcode
|
|
22
|
+
* @pattern ^\d{4}$
|
|
23
|
+
*/
|
|
24
|
+
export type NzPostcode = Tagged<string, "NzPostcode">;
|
|
25
|
+
/** The NZ postcode shape: exactly four digits. */
|
|
26
|
+
export declare const NZ_POSTCODE_PATTERN: RegExp;
|
|
27
|
+
/** Normalize a postcode surface form (trim only — NZ has no country-prefix courtesy form). */
|
|
28
|
+
export declare function normalizeNzPostcode(raw: unknown): NzPostcode | null;
|
|
29
|
+
/** Type-predicate for a (normalized) New Zealand postcode. */
|
|
30
|
+
export declare function isNzPostcode(input: unknown): input is NzPostcode;
|
|
31
|
+
//# sourceMappingURL=postcode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode.d.ts","sourceRoot":"","sources":["../../nz/postcode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AAErD,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,QAAY,CAAA;AAE5C,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAInE;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* New Zealand postcodes: four digits, after the town/city on the last line (`Timaru 7942`).
|
|
7
|
+
* Verbatim from NZ Post's Address Standards (ADV358, Oct 2021, accessed 2026-06-11): "Postcode is
|
|
8
|
+
* mandatory and is four digits. It follows the city or town." Note NZ has no state/region line —
|
|
9
|
+
* "The province, region, district or territory is not to be used."
|
|
10
|
+
*
|
|
11
|
+
* The shape collides with Australia's (also 4 digits) — `candidateSystemsForPostcode` returns both,
|
|
12
|
+
* by design (shape test, not membership test).
|
|
13
|
+
* @see {@link https://www.nzpost.co.nz/sites/nz/files/2021-10/adv358-address-standards.pdf NZ Post Address Standards (ADV358, Oct 2021)}
|
|
14
|
+
*/
|
|
15
|
+
/** The NZ postcode shape: exactly four digits. */
|
|
16
|
+
export const NZ_POSTCODE_PATTERN = /^\d{4}$/;
|
|
17
|
+
/** Normalize a postcode surface form (trim only — NZ has no country-prefix courtesy form). */
|
|
18
|
+
export function normalizeNzPostcode(raw) {
|
|
19
|
+
if (typeof raw !== "string")
|
|
20
|
+
return null;
|
|
21
|
+
const s = raw.trim();
|
|
22
|
+
return NZ_POSTCODE_PATTERN.test(s) ? s : null;
|
|
23
|
+
}
|
|
24
|
+
/** Type-predicate for a (normalized) New Zealand postcode. */
|
|
25
|
+
export function isNzPostcode(input) {
|
|
26
|
+
return typeof input === "string" && NZ_POSTCODE_PATTERN.test(input);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=postcode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode.js","sourceRoot":"","sources":["../../nz/postcode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH,kDAAkD;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE5C,8FAA8F;AAC9F,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACxC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IACpB,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAgB,CAAC,CAAC,CAAC,IAAI,CAAA;AAC9D,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,YAAY,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* for".
|
|
22
22
|
*/
|
|
23
23
|
/** A codex address-system code — the subpath under `@mailwoman/codex/<system>`. */
|
|
24
|
-
export type SystemCode = "us" | "de" | "fr" | "ca" | "gb" | "jp";
|
|
24
|
+
export type SystemCode = "us" | "de" | "fr" | "ca" | "gb" | "jp" | "au" | "nz";
|
|
25
25
|
/**
|
|
26
26
|
* Every address system whose own postcode shape accepts `postcode`. Empty when no system recognizes
|
|
27
27
|
* the shape (e.g. a bare `27`, or a 7-digit run). O(number of systems) — a handful of cheap regex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcode-systems.d.ts","sourceRoot":"","sources":["../postcode-systems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"postcode-systems.d.ts","sourceRoot":"","sources":["../postcode-systems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAWH,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAmB9E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,EAAE,CAO1E"}
|
package/out/postcode-systems.js
CHANGED
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
* call; this function answers the coarser, model-free "which systems is this shape even eligible
|
|
21
21
|
* for".
|
|
22
22
|
*/
|
|
23
|
+
import { normalizeAuPostcode } from "./au/index.js";
|
|
23
24
|
import { normalizeCaPostalCode } from "./ca/index.js";
|
|
24
25
|
import { normalizePLZ } from "./de/index.js";
|
|
25
26
|
import { normalizeCodePostal } from "./fr/index.js";
|
|
26
27
|
import { normalizeUkPostcode } from "./gb/index.js";
|
|
27
28
|
import { normalizeJpPostalCode } from "./jp/index.js";
|
|
29
|
+
import { normalizeNzPostcode } from "./nz/index.js";
|
|
28
30
|
import { isZipCode } from "./us/index.js";
|
|
29
31
|
/**
|
|
30
32
|
* Per-system membership test: each entry returns true when the string is accepted by that system's
|
|
@@ -39,6 +41,8 @@ const SYSTEM_ACCEPTS = [
|
|
|
39
41
|
["ca", (s) => normalizeCaPostalCode(s) !== null],
|
|
40
42
|
["gb", (s) => normalizeUkPostcode(s) !== null],
|
|
41
43
|
["jp", (s) => normalizeJpPostalCode(s) !== null],
|
|
44
|
+
["au", (s) => normalizeAuPostcode(s) !== null],
|
|
45
|
+
["nz", (s) => normalizeNzPostcode(s) !== null],
|
|
42
46
|
];
|
|
43
47
|
/**
|
|
44
48
|
* Every address system whose own postcode shape accepts `postcode`. Empty when no system recognizes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcode-systems.js","sourceRoot":"","sources":["../postcode-systems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAKzC;;;;;GAKG;AACH,MAAM,cAAc,GAAiE;IACpF,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACvC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC9C,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChD,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC9C,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"postcode-systems.js","sourceRoot":"","sources":["../postcode-systems.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE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AAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACpE,MAAM,GAAG,GAAiB,EAAE,CAAA;IAC5B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,EAAE,CAAC;QAChD,IAAI,OAAO,CAAC,QAAQ,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* USPS Publication 28, Appendix C2 — Floor-class Secondary Unit Designators.
|
|
7
|
+
*
|
|
8
|
+
* The sibling of {@link ./unit-designator.ts}: where the unit table covers the full secondary-unit
|
|
9
|
+
* vocabulary (APT, STE, RM, …), this module extracts the floor-class subset — designators that
|
|
10
|
+
* name a FLOOR or LEVEL of the building rather than a specific addressable unit on that floor.
|
|
11
|
+
* USPS Pub 28 Appendix C2 identifies these designators as requiring a secondary number: "FL" (the
|
|
12
|
+
* approved abbreviation for FLOOR). The publication gives `FLOOR` as the canonical designator
|
|
13
|
+
* with approved abbreviation `FL` and variant `FLR`; `BASEMENT` (`BSMT`), `PENTHOUSE` (`PH`), and
|
|
14
|
+
* `LOBBY` (`LBBY`) are the standalone-or-numbered floor-adjacent types also listed in Appendix
|
|
15
|
+
* C2.
|
|
16
|
+
*
|
|
17
|
+
* Appendix C2 explicitly marks FLOOR, BASEMENT as requiring a secondary number (alongside APT,
|
|
18
|
+
* BLDG, etc.) while PENTHOUSE and LOBBY may stand alone. PH and LBBY are kept here (not just in
|
|
19
|
+
* {@link ./unit-designator.ts}) because the span proposer treats them as level-class hints —
|
|
20
|
+
* "LOBBY" and "PH" name a specific floor-analog, not a numbered unit, and the prior map routes
|
|
21
|
+
* `LEVEL_PHRASE` → `unit` (the schema carries no separate `level` tag).
|
|
22
|
+
*
|
|
23
|
+
* This table drives the `levelDesignators` set in the span-proposer lexicon. The full
|
|
24
|
+
* secondary-unit designators (APT, STE, RM, …) remain in {@link ./unit-designator.ts}.
|
|
25
|
+
*
|
|
26
|
+
* Data is verbatim USPS Pub 28 Appendix C2.
|
|
27
|
+
* @see {@link https://pe.usps.com/text/pub28/28apc_003.htm USPS Publication 28 — Appendix C2: Secondary Unit Designators}
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* One USPS Pub 28 C2 floor-class designator row.
|
|
31
|
+
*
|
|
32
|
+
* `requiresNumber` mirrors the Appendix C2 classification: FLOOR and BASEMENT must be followed by a
|
|
33
|
+
* secondary number; PENTHOUSE and LOBBY may stand alone.
|
|
34
|
+
*/
|
|
35
|
+
export interface UsFloorDesignator {
|
|
36
|
+
/** Full canonical designator (uppercase per the publication). */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Approved USPS abbreviation (what the post office prints on standardized mail). */
|
|
39
|
+
abbreviation: string;
|
|
40
|
+
/** Additional recognized surface variants from Appendix C2. */
|
|
41
|
+
variants: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* True when Appendix C2 marks this designator as "Requires a Secondary Number" (FLOOR, BASEMENT).
|
|
44
|
+
* False for standalone types (PENTHOUSE, LOBBY) that name a specific floor-analog without an
|
|
45
|
+
* identifier.
|
|
46
|
+
*/
|
|
47
|
+
requiresNumber: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* USPS Pub 28 C2 floor-class secondary unit designators. Verbatim from the publication; see the
|
|
51
|
+
* module header for the per-row provenance. Ordered with the most-common numbered form first.
|
|
52
|
+
*/
|
|
53
|
+
export declare const US_FLOOR_DESIGNATORS: readonly [{
|
|
54
|
+
readonly name: "FLOOR";
|
|
55
|
+
readonly abbreviation: "FL";
|
|
56
|
+
readonly variants: readonly ["FLR"];
|
|
57
|
+
readonly requiresNumber: true;
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "BASEMENT";
|
|
60
|
+
readonly abbreviation: "BSMT";
|
|
61
|
+
readonly variants: readonly [];
|
|
62
|
+
readonly requiresNumber: true;
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "PENTHOUSE";
|
|
65
|
+
readonly abbreviation: "PH";
|
|
66
|
+
readonly variants: readonly [];
|
|
67
|
+
readonly requiresNumber: false;
|
|
68
|
+
}, {
|
|
69
|
+
readonly name: "LOBBY";
|
|
70
|
+
readonly abbreviation: "LBBY";
|
|
71
|
+
readonly variants: readonly [];
|
|
72
|
+
readonly requiresNumber: false;
|
|
73
|
+
}];
|
|
74
|
+
/** A canonical USPS floor-class designator name. */
|
|
75
|
+
export type UsFloorDesignatorName = (typeof US_FLOOR_DESIGNATORS)[number]["name"];
|
|
76
|
+
/**
|
|
77
|
+
* Inverse lookup: every surface form (canonical name, approved abbreviation, or Appendix C2
|
|
78
|
+
* variant) → its canonical designator name. Lowercase-keyed for case-insensitive matching: `"fl"` →
|
|
79
|
+
* `"FLOOR"`, `"bsmt"` → `"BASEMENT"`, `"ph"` → `"PENTHOUSE"`.
|
|
80
|
+
*/
|
|
81
|
+
export declare const US_FLOOR_DESIGNATOR_LOOKUP: ReadonlyMap<string, UsFloorDesignatorName>;
|
|
82
|
+
/**
|
|
83
|
+
* All lowercase surface tokens for the floor-class designators — the set the span proposer
|
|
84
|
+
* populates `levelDesignators` with when wiring the US codex slice. Includes canonical names,
|
|
85
|
+
* approved abbreviations, and Appendix C2 variants.
|
|
86
|
+
*/
|
|
87
|
+
export declare const US_FLOOR_DESIGNATOR_TOKENS: ReadonlySet<string>;
|
|
88
|
+
/** Approved USPS abbreviation per canonical floor designator name. */
|
|
89
|
+
export declare const US_FLOOR_DESIGNATOR_PREFERRED_ABBR: Readonly<Record<UsFloorDesignatorName, string>>;
|
|
90
|
+
/**
|
|
91
|
+
* Look up a USPS floor-class designator (by canonical name, abbreviation, or any Appendix C2
|
|
92
|
+
* variant) and return the canonical name + approved abbreviation. Returns null if the token isn't a
|
|
93
|
+
* recognized floor-class designator.
|
|
94
|
+
*/
|
|
95
|
+
export declare function lookupFloorDesignator(input: string | null | undefined): {
|
|
96
|
+
designator: UsFloorDesignatorName;
|
|
97
|
+
abbreviation: string;
|
|
98
|
+
} | null;
|
|
99
|
+
/**
|
|
100
|
+
* True when a token is a recognized USPS floor-class secondary unit designator (case-insensitive) —
|
|
101
|
+
* `"Floor"`, `"FL"`, `"flr"`, `"bsmt"`, `"ph"`, `"lbby"`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function isFloorDesignatorToken(input: unknown): boolean;
|
|
104
|
+
//# sourceMappingURL=floor-designator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floor-designator.d.ts","sourceRoot":"","sources":["../../us/floor-designator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAA;IACZ,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;EAKgB,CAAA;AAEjD,oDAAoD;AACpD,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,MAAM,EAAE,qBAAqB,CAU9E,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,MAAM,CAA8C,CAAA;AAEzG,sEAAsE;AACtE,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAE3C,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IACxE,UAAU,EAAE,qBAAqB,CAAA;IACjC,YAAY,EAAE,MAAM,CAAA;CACpB,GAAG,IAAI,CAKP;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE9D"}
|