@mailwoman/codex 6.4.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,7 +70,6 @@ import { ADDRESS_SYSTEM_CONVENTIONS, conventionsForSystem } from "@mailwoman/cod
70
70
  ## Related
71
71
 
72
72
  - [`@mailwoman/core`](../core) — `ComponentTag` schema, pipeline infrastructure
73
- - [`@mailwoman/classifiers`](../classifiers) — rule-based classifiers that consume codex data
74
73
  - [`@mailwoman/address-id`](../address-id) — uses codex for stable address primary keys
75
74
  - [Address system conventions](https://mailwoman.sister.software/articles/plan/reference/SCHEMA/)
76
75
 
@@ -32,7 +32,7 @@
32
32
  * `requiresNumber` mirrors the Appendix C2 classification: FLOOR and BASEMENT must be followed by a secondary number;
33
33
  * PENTHOUSE and LOBBY may stand alone.
34
34
  */
35
- export interface UsFloorDesignator {
35
+ export interface USFloorDesignator {
36
36
  /** Full canonical designator (uppercase per the publication). */
37
37
  name: string;
38
38
  /** Approved USPS abbreviation (what the post office prints on standardized mail). */
@@ -71,26 +71,26 @@ export declare const US_FLOOR_DESIGNATORS: readonly [{
71
71
  readonly requiresNumber: false;
72
72
  }];
73
73
  /** A canonical USPS floor-class designator name. */
74
- export type UsFloorDesignatorName = (typeof US_FLOOR_DESIGNATORS)[number]["name"];
74
+ export type USFloorDesignatorName = (typeof US_FLOOR_DESIGNATORS)[number]["name"];
75
75
  /**
76
76
  * Inverse lookup: every surface form (canonical name, approved abbreviation, or Appendix C2 variant) → its canonical
77
77
  * designator name. Lowercase-keyed for case-insensitive matching: `"fl"` → `"FLOOR"`, `"bsmt"` → `"BASEMENT"`, `"ph"` →
78
78
  * `"PENTHOUSE"`.
79
79
  */
80
- export declare const US_FLOOR_DESIGNATOR_LOOKUP: ReadonlyMap<string, UsFloorDesignatorName>;
80
+ export declare const US_FLOOR_DESIGNATOR_LOOKUP: ReadonlyMap<string, USFloorDesignatorName>;
81
81
  /**
82
82
  * All lowercase surface tokens for the floor-class designators — the set the span proposer populates `levelDesignators`
83
83
  * with when wiring the US codex slice. Includes canonical names, approved abbreviations, and Appendix C2 variants.
84
84
  */
85
85
  export declare const US_FLOOR_DESIGNATOR_TOKENS: ReadonlySet<string>;
86
86
  /** Approved USPS abbreviation per canonical floor designator name. */
87
- export declare const US_FLOOR_DESIGNATOR_PREFERRED_ABBR: Readonly<Record<UsFloorDesignatorName, string>>;
87
+ export declare const US_FLOOR_DESIGNATOR_PREFERRED_ABBR: Readonly<Record<USFloorDesignatorName, string>>;
88
88
  /**
89
89
  * Look up a USPS floor-class designator (by canonical name, abbreviation, or any Appendix C2 variant) and return the
90
90
  * canonical name + approved abbreviation. Returns null if the token isn't a recognized floor-class designator.
91
91
  */
92
92
  export declare function lookupFloorDesignator(input: string | null | undefined): {
93
- designator: UsFloorDesignatorName;
93
+ designator: USFloorDesignatorName;
94
94
  abbreviation: string;
95
95
  } | null;
96
96
  /**
@@ -46,7 +46,7 @@ export declare const US_MILITARY_POST_OFFICE_CODES: readonly [{
46
46
  readonly name: "Diplomatic Post Office";
47
47
  readonly armedForces: false;
48
48
  }];
49
- export type UsMilitaryPostOfficeCode = (typeof US_MILITARY_POST_OFFICE_CODES)[number]["code"];
49
+ export type USMilitaryPostOfficeCode = (typeof US_MILITARY_POST_OFFICE_CODES)[number]["code"];
50
50
  /**
51
51
  * USPS Armed Forces "state" codes used in place of state names on military/diplomatic addresses. These appear where a
52
52
  * US state abbreviation (NY, CA, …) would appear in a civilian address.
@@ -64,7 +64,7 @@ export declare const US_ARMED_FORCES_REGIONS: readonly [{
64
64
  readonly name: "Armed Forces Pacific";
65
65
  readonly description: "Pacific";
66
66
  }];
67
- export type UsArmedForcesRegionCode = (typeof US_ARMED_FORCES_REGIONS)[number]["code"];
67
+ export type USArmedForcesRegionCode = (typeof US_ARMED_FORCES_REGIONS)[number]["code"];
68
68
  /**
69
69
  * USPS Pub 28 Appendix B unit-line designators for military/diplomatic overseas addresses. Each designator introduces
70
70
  * an installation identifier and optionally a box number.
@@ -94,13 +94,13 @@ export declare const US_MILITARY_UNIT_DESIGNATORS: readonly [{
94
94
  readonly requiresBox: false;
95
95
  readonly description: "Numbered military unit (battalion/company); format: UNIT <id> [BOX <box>]";
96
96
  }];
97
- export type UsMilitaryUnitDesignatorCode = (typeof US_MILITARY_UNIT_DESIGNATORS)[number]["code"];
97
+ export type USMilitaryUnitDesignatorCode = (typeof US_MILITARY_UNIT_DESIGNATORS)[number]["code"];
98
98
  /** Result of a military address line parse (the unit line: PSC/CMR/UNIT). */
99
- export interface UsMilitaryUnitMatch {
99
+ export interface USMilitaryUnitMatch {
100
100
  /** The designator as it appeared ("PSC", "CMR", "Unit"). */
101
101
  matched: string;
102
102
  /** The canonical designator code ("PSC", "CMR", "UNIT"). */
103
- code: UsMilitaryUnitDesignatorCode;
103
+ code: USMilitaryUnitDesignatorCode;
104
104
  /** The installation identifier ("1520", "453"). */
105
105
  id: string;
106
106
  /** The box number when present ("4620", "1234A"). */
@@ -111,17 +111,17 @@ export interface UsMilitaryUnitMatch {
111
111
  * the canonical designator, installation id, and optional box. Null otherwise. Throws on a PSC or CMR line without a
112
112
  * BOX component (per Appendix B, BOX is required for PSC/CMR; a bare "PSC 1520" is malformed).
113
113
  */
114
- export declare function matchMilitaryUnitLine(input: unknown): UsMilitaryUnitMatch | null;
114
+ export declare function matchMilitaryUnitLine(input: unknown): USMilitaryUnitMatch | null;
115
115
  /** Type-predicate: does the input look like a USPS military unit line (PSC/CMR/UNIT)? */
116
116
  export declare function isMilitaryUnitLine(input: unknown): boolean;
117
117
  /** Result of a military city-line parse (APO/FPO/DPO + region code + ZIP). */
118
- export interface UsMilitaryCityMatch {
118
+ export interface USMilitaryCityMatch {
119
119
  /** The post-office code as it appeared ("APO", "FPO", "DPO"). */
120
120
  matched: string;
121
121
  /** The canonical post-office code. */
122
- code: UsMilitaryPostOfficeCode;
122
+ code: USMilitaryPostOfficeCode;
123
123
  /** The Armed Forces region code ("AA", "AE", "AP"). */
124
- region: UsArmedForcesRegionCode;
124
+ region: USArmedForcesRegionCode;
125
125
  /**
126
126
  * The 5-digit or 9-digit ZIP code. Typical ranges per Pub 28: 09xxx (AE), 34xxx (AA), 96xxx (AP) — range validation
127
127
  * per region is caller responsibility.
@@ -136,7 +136,7 @@ export interface UsMilitaryCityMatch {
136
136
  * validation per region is left to the caller; the matcher accepts any 5. or 9-digit ZIP paired with a valid region
137
137
  * code.
138
138
  */
139
- export declare function matchMilitaryCityLine(input: unknown): UsMilitaryCityMatch | null;
139
+ export declare function matchMilitaryCityLine(input: unknown): USMilitaryCityMatch | null;
140
140
  /** Type-predicate: does the input look like a USPS military city line (APO/FPO/DPO + region + ZIP)? */
141
141
  export declare function isMilitaryCityLine(input: unknown): boolean;
142
142
  //# sourceMappingURL=military-address.d.ts.map
@@ -17,7 +17,7 @@
17
17
  * punctuation/spacing.
18
18
  */
19
19
  export declare const US_PO_BOX_DESIGNATORS: readonly ["POST OFFICE BOX", "PO BOX", "P O BOX", "FIRM CALLER", "CALLER", "DRAWER", "LOCKBOX", "BOX"];
20
- export type UsPoBoxDesignator = (typeof US_PO_BOX_DESIGNATORS)[number];
20
+ export type USPoBoxDesignator = (typeof US_PO_BOX_DESIGNATORS)[number];
21
21
  /**
22
22
  * Type-predicate: does the input look like a standalone PO Box address? Case-insensitive and tolerant of "P.O. Box",
23
23
  * "Post Office Box", "Box 12", "PMB"-style ids. (Widens the original isp-nexus `/^PO BOX [\d-]+$/`, which only matched
package/out/us/state.d.ts CHANGED
@@ -17,12 +17,12 @@
17
17
  */
18
18
  export declare const US_STATE_ABBREVIATIONS: readonly ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY", "PR", "GU", "VI", "MP", "AS"];
19
19
  /** A USPS two-letter state-or-territory abbreviation. */
20
- export type UsStateAbbreviation = (typeof US_STATE_ABBREVIATIONS)[number];
20
+ export type USStateAbbreviation = (typeof US_STATE_ABBREVIATIONS)[number];
21
21
  /**
22
22
  * Type-predicate for a USPS state-or-territory abbreviation. Case-insensitive (`"ca"` and `"CA"` both pass), since the
23
23
  * abbreviation arrives from raw address text.
24
24
  */
25
- export declare function isUsStateAbbreviation(input: unknown): input is UsStateAbbreviation;
25
+ export declare function isUSStateAbbreviation(input: unknown): input is USStateAbbreviation;
26
26
  /**
27
27
  * Full names for the 50 states, DC, and the five primary territories, keyed by USPS abbreviation. The names half of the
28
28
  * closed region vocabulary — where the country/state homographs live ("Georgia", "Washington"), which the
package/out/us/state.js CHANGED
@@ -78,7 +78,7 @@ const STATE_ABBREVIATION_SET = new Set(US_STATE_ABBREVIATIONS);
78
78
  * Type-predicate for a USPS state-or-territory abbreviation. Case-insensitive (`"ca"` and `"CA"` both pass), since the
79
79
  * abbreviation arrives from raw address text.
80
80
  */
81
- export function isUsStateAbbreviation(input) {
81
+ export function isUSStateAbbreviation(input) {
82
82
  return typeof input === "string" && STATE_ABBREVIATION_SET.has(input.toUpperCase());
83
83
  }
84
84
  /**
@@ -227,14 +227,14 @@ export declare const US_STREET_SUFFIX_VARIANTS: {
227
227
  readonly WELLS: readonly ["WLS"];
228
228
  };
229
229
  /** Canonical USPS suffix (full word, uppercase per the publication). */
230
- export type UsStreetSuffix = keyof typeof US_STREET_SUFFIX_VARIANTS;
230
+ export type USStreetSuffix = keyof typeof US_STREET_SUFFIX_VARIANTS;
231
231
  /**
232
232
  * Inverse lookup: every variant abbreviation OR full canonical word → its canonical key. Built once at module load,
233
233
  * lowercase-keyed for case-insensitive matching (`street` → `"STREET"`, `st` → `"STREET"`, `strt` → `"STREET"`, …).
234
234
  */
235
- export declare const US_STREET_SUFFIX_LOOKUP: ReadonlyMap<string, UsStreetSuffix>;
235
+ export declare const US_STREET_SUFFIX_LOOKUP: ReadonlyMap<string, USStreetSuffix>;
236
236
  /** Preferred USPS abbreviation per canonical (`AVENUE → "AVE"`, `STREET → "ST"`). */
237
- export declare const US_STREET_SUFFIX_PREFERRED_ABBR: Readonly<Record<UsStreetSuffix, string>>;
237
+ export declare const US_STREET_SUFFIX_PREFERRED_ABBR: Readonly<Record<USStreetSuffix, string>>;
238
238
  /**
239
239
  * Apply `target`'s letters in the same case-pattern as `reference`. Three patterns covered:
240
240
  *
@@ -248,7 +248,7 @@ export declare function matchCase(target: string, reference: string): string;
248
248
  * matched word. Returns null if the trailing word isn't a known suffix.
249
249
  */
250
250
  export declare function matchTrailingSuffix(street: string): {
251
- canonical: UsStreetSuffix;
251
+ canonical: USStreetSuffix;
252
252
  matched: string;
253
253
  } | null;
254
254
  /**
@@ -463,9 +463,9 @@ export declare const StreetSuffixAbbreviationRecord: {
463
463
  };
464
464
  export type StreetSuffixAbbreviationRecord = typeof US_STREET_SUFFIX_VARIANTS;
465
465
  /**
466
- * A canonical USPS street suffix, i.e. "STREET", "AVENUE", "BOULEVARD". Aliases {@link UsStreetSuffix}.
466
+ * A canonical USPS street suffix, i.e. "STREET", "AVENUE", "BOULEVARD". Aliases {@link USStreetSuffix}.
467
467
  */
468
- export type StreetSuffix = UsStreetSuffix;
468
+ export type StreetSuffix = USStreetSuffix;
469
469
  /** A standardized USPS street suffix abbreviation (the preferred form), i.e. "ST", "AVE", "BLVD". */
470
470
  export type USPSStandardSuffixAbbreviation = StreetSuffixAbbreviationRecord[StreetSuffix][0];
471
471
  /** Any USPS-recognized suffix variant or abbreviation. */
@@ -61,34 +61,34 @@ export declare const US_UNIT_DESIGNATOR_VARIANTS: {
61
61
  readonly UPPER: readonly ["UPPR"];
62
62
  };
63
63
  /** Canonical USPS secondary unit designator (full word, uppercase per the publication). */
64
- export type UsUnitDesignator = keyof typeof US_UNIT_DESIGNATOR_VARIANTS;
64
+ export type USUnitDesignator = keyof typeof US_UNIT_DESIGNATOR_VARIANTS;
65
65
  /**
66
66
  * Inverse lookup: every variant abbreviation OR full canonical word → its canonical key, built once at module load,
67
67
  * lowercase-keyed for case-insensitive matching (`apt` → `"APARTMENT"`, `ste` → `"SUITE"`, `suite` → `"SUITE"`).
68
68
  */
69
- export declare const US_UNIT_DESIGNATOR_LOOKUP: ReadonlyMap<string, UsUnitDesignator>;
69
+ export declare const US_UNIT_DESIGNATOR_LOOKUP: ReadonlyMap<string, USUnitDesignator>;
70
70
  /** Approved USPS abbreviation per canonical (`APARTMENT → "APT"`, `SUITE → "STE"`). */
71
- export declare const US_UNIT_DESIGNATOR_PREFERRED_ABBR: Readonly<Record<UsUnitDesignator, string>>;
71
+ export declare const US_UNIT_DESIGNATOR_PREFERRED_ABBR: Readonly<Record<USUnitDesignator, string>>;
72
72
  /**
73
73
  * Canonical designators Appendix C2 marks as "Requires a Secondary Number" — the designator must be followed by an
74
74
  * identifier ("Apt 4B", "Rm 12"), never appearing bare. The remaining designators (BASEMENT, FRONT, LOBBY, LOWER,
75
75
  * OFFICE, PENTHOUSE, REAR, SIDE, UPPER) may stand alone with no trailing identifier. Verbatim from USPS Pub-28 C2; see
76
76
  * the module header for provenance (#1100).
77
77
  */
78
- export declare const US_UNIT_DESIGNATOR_REQUIRES_RANGE: Readonly<Record<UsUnitDesignator, boolean>>;
78
+ export declare const US_UNIT_DESIGNATOR_REQUIRES_RANGE: Readonly<Record<USUnitDesignator, boolean>>;
79
79
  /**
80
80
  * If the FIRST whitespace-separated word of `unit` is a known USPS designator variant, return the canonical key and the
81
81
  * matched word. Returns null if the leading word isn't a known designator (e.g. a bare `"4B"` or `"#210"`).
82
82
  * Leading-word-only — designators introduce the unit, unlike street suffixes which trail.
83
83
  */
84
84
  export declare function matchLeadingDesignator(unit: string): {
85
- canonical: UsUnitDesignator;
85
+ canonical: USUnitDesignator;
86
86
  matched: string;
87
87
  } | null;
88
88
  /** Result of {@link matchLeadingDesignatorWithRange}: the leading designator plus its optional secondary range. */
89
89
  export interface UnitDesignatorRangeMatch {
90
90
  /** The matched canonical designator, i.e. "APARTMENT", "SUITE". */
91
- canonical: UsUnitDesignator;
91
+ canonical: USUnitDesignator;
92
92
  /** The designator's own matched surface form, i.e. "Apt". */
93
93
  matched: string;
94
94
  /**
@@ -110,7 +110,7 @@ export interface UnitDesignatorRangeMatch {
110
110
  */
111
111
  export declare function matchLeadingDesignatorWithRange(unit: string): UnitDesignatorRangeMatch | null;
112
112
  /** Result of a successful USPS secondary-unit designator lookup. */
113
- export interface UnitDesignatorMatch<D extends UsUnitDesignator = UsUnitDesignator> {
113
+ export interface UnitDesignatorMatch<D extends USUnitDesignator = USUnitDesignator> {
114
114
  /** The matched canonical designator, i.e. "APARTMENT", "SUITE". */
115
115
  designator: D;
116
116
  /** The approved USPS abbreviation, i.e. "APT", "STE". */
@@ -120,7 +120,7 @@ export interface UnitDesignatorMatch<D extends UsUnitDesignator = UsUnitDesignat
120
120
  * Look up a USPS secondary unit designator (by canonical word, abbreviation, or any variant) and its approved
121
121
  * abbreviation.
122
122
  */
123
- export declare function lookupUnitDesignator<D extends UsUnitDesignator>(designator: D): UnitDesignatorMatch<D>;
123
+ export declare function lookupUnitDesignator<D extends USUnitDesignator>(designator: D): UnitDesignatorMatch<D>;
124
124
  export declare function lookupUnitDesignator(input: string | null | undefined): UnitDesignatorMatch | null;
125
125
  /**
126
126
  * True when a token is any USPS secondary unit designator or abbreviation (case-insensitive) — `"Apt"`, `"STE"`,
@@ -7,7 +7,7 @@
7
7
  * state geographic prior, and a state-plus-ZIP plucker.
8
8
  */
9
9
  import type { Tagged } from "type-fest";
10
- import { type UsStateAbbreviation } from "./state.ts";
10
+ import { type USStateAbbreviation } from "./state.ts";
11
11
  /**
12
12
  * USPS-recognized ZIP code digits.
13
13
  *
@@ -162,14 +162,14 @@ export declare const ZipCodePatterns: {
162
162
  */
163
163
  export declare function isZipCode(input: unknown): input is ZipCode | ZipCodePlusFour;
164
164
  export interface PluckedStateZIPCodeResult {
165
- stateAbbreviation: UsStateAbbreviation | null;
165
+ stateAbbreviation: USStateAbbreviation | null;
166
166
  zipCode: ZipCode | ZipCodePlusFour;
167
167
  }
168
168
  /**
169
169
  * Given an address string like `"NY"`, `"CA 94016"`, attempts to match the state abbreviation and postal code, if
170
170
  * applicable.
171
171
  *
172
- * @see {@linkcode isUsStateAbbreviation} to validate the state abbreviation.
172
+ * @see {@linkcode isUSStateAbbreviation} to validate the state abbreviation.
173
173
  */
174
174
  export declare function pluckStateZIPCode(input: unknown): PluckedStateZIPCodeResult | null;
175
175
  //# sourceMappingURL=zipcode.d.ts.map
package/out/us/zipcode.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * US ZIP (Zone Improvement Plan) codes: branded string types, the shape patterns, the first-digit →
7
7
  * state geographic prior, and a state-plus-ZIP plucker.
8
8
  */
9
- import { isUsStateAbbreviation } from "./state.js";
9
+ import { isUSStateAbbreviation } from "./state.js";
10
10
  /**
11
11
  * Record of US state abbreviations to their corresponding ZIP code prefix (the leading digit). A cheap geographic
12
12
  * prior: a 5-digit code's first digit narrows it to a band of states, which the parser can weigh against the
@@ -105,7 +105,7 @@ export function isZipCode(input) {
105
105
  * Given an address string like `"NY"`, `"CA 94016"`, attempts to match the state abbreviation and postal code, if
106
106
  * applicable.
107
107
  *
108
- * @see {@linkcode isUsStateAbbreviation} to validate the state abbreviation.
108
+ * @see {@linkcode isUSStateAbbreviation} to validate the state abbreviation.
109
109
  */
110
110
  export function pluckStateZIPCode(input) {
111
111
  if (!input || typeof input !== "string")
@@ -115,7 +115,7 @@ export function pluckStateZIPCode(input) {
115
115
  return null;
116
116
  const normalizedState = stateAbbreviation?.toUpperCase();
117
117
  return {
118
- stateAbbreviation: isUsStateAbbreviation(normalizedState) ? normalizedState : null,
118
+ stateAbbreviation: isUSStateAbbreviation(normalizedState) ? normalizedState : null,
119
119
  zipCode: zipCode,
120
120
  };
121
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/codex",
3
- "version": "6.4.0",
3
+ "version": "7.0.0",
4
4
  "description": "Per-address-system postal reference data + branded types (USPS street suffixes, US ZIP codes). Pure, zero-runtime-dep — the shared canonical home for postal-system primitives the parser, resolver, and synthesis layers all reach for.",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
@@ -116,6 +116,6 @@
116
116
  "type-fest": "^5.8.0"
117
117
  },
118
118
  "devDependencies": {
119
- "@mailwoman/annotations": "6.4.0"
119
+ "@mailwoman/annotations": "7.0.0"
120
120
  }
121
121
  }