@mailwoman/codex 8.4.0 → 8.6.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/es/codigo-postal.ts +51 -0
- package/es/index.ts +9 -0
- package/it/cap.ts +39 -0
- package/it/index.ts +9 -0
- package/out/es/codigo-postal.d.ts +39 -0
- package/out/es/codigo-postal.d.ts.map +1 -0
- package/out/es/codigo-postal.js +35 -0
- package/out/es/codigo-postal.js.map +1 -0
- package/out/es/index.d.ts +9 -0
- package/out/es/index.d.ts.map +1 -0
- package/out/es/index.js +9 -0
- package/out/es/index.js.map +1 -0
- package/out/it/cap.d.ts +32 -0
- package/out/it/cap.d.ts.map +1 -0
- package/out/it/cap.js +25 -0
- package/out/it/cap.js.map +1 -0
- package/out/it/index.d.ts +9 -0
- package/out/it/index.d.ts.map +1 -0
- package/out/it/index.js +9 -0
- package/out/it/index.js.map +1 -0
- package/package.json +18 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Spanish postal codes (código postal): the branded type, the shape, and the province prior.
|
|
7
|
+
*
|
|
8
|
+
* The contrast with a German PLZ is the informative part. A PLZ's leading digit maps to a Leitzone
|
|
9
|
+
* that deliberately CROSSES state borders, so it cannot tell you the Bundesland. A Spanish código
|
|
10
|
+
* postal is the opposite: its first TWO digits are the province code, assigned alphabetically
|
|
11
|
+
* (01 Álava … 28 Madrid … 50 Zaragoza), so the province is derivable from the postcode exactly.
|
|
12
|
+
* Code that wants a Spanish region from an address can read it off the postcode; code that wants a
|
|
13
|
+
* German one cannot.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { Tagged } from "type-fest"
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A Spanish postal code: five digits, `PPNNN`, where `PP` is the province (`28001` is Madrid).
|
|
20
|
+
*
|
|
21
|
+
* @category Postal
|
|
22
|
+
* @type string
|
|
23
|
+
* @title CodigoPostal
|
|
24
|
+
* @pattern ^\d{5}$
|
|
25
|
+
*/
|
|
26
|
+
export type CodigoPostal = Tagged<string, "CodigoPostal">
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Shape of a Spanish código postal — five digits. Identical in shape to a French code postal, a German PLZ and a US
|
|
30
|
+
* ZIP; disambiguation is the parser's job, not the pattern's.
|
|
31
|
+
*/
|
|
32
|
+
export const CODIGO_POSTAL_PATTERN = /^\d{5}$/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Narrow a string to a {@link CodigoPostal}, or `null` when it is not one.
|
|
36
|
+
*/
|
|
37
|
+
export function parseCodigoPostal(input: string): CodigoPostal | null {
|
|
38
|
+
const s = input.trim()
|
|
39
|
+
|
|
40
|
+
return CODIGO_POSTAL_PATTERN.test(s) ? (s as CodigoPostal) : null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The two-digit province prefix (`"28001"` → `"28"`), or `null` for a non-postcode. Callers map it through their own
|
|
45
|
+
* province table; this module deliberately does not ship one, since the campaign that needed it only needs the shape.
|
|
46
|
+
*/
|
|
47
|
+
export function codigoPostalProvincePrefix(input: string): string | null {
|
|
48
|
+
const code = parseCodigoPostal(input)
|
|
49
|
+
|
|
50
|
+
return code ? code.slice(0, 2) : null
|
|
51
|
+
}
|
package/es/index.ts
ADDED
package/it/cap.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Italian postal codes (Codice di Avviamento Postale, CAP): the branded type and the shape.
|
|
7
|
+
*
|
|
8
|
+
* Five digits like the Spanish, French and German forms, but do NOT infer a province from the
|
|
9
|
+
* leading digits the way `es/codigo-postal.ts` documents for Spain. Italy's large cities are
|
|
10
|
+
* assigned RANGES rather than a single code (Rome spans 00118–00199, Milan 20121–20162), and
|
|
11
|
+
* several provinces share leading digits, so the CAP narrows geography without identifying a
|
|
12
|
+
* province. It is the same trap German PLZ Leitzonen set, in a different disguise.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { Tagged } from "type-fest"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* An Italian postal code: five digits (`00184` is Rome, Rione Monti).
|
|
19
|
+
*
|
|
20
|
+
* @category Postal
|
|
21
|
+
* @type string
|
|
22
|
+
* @title CAP
|
|
23
|
+
* @pattern ^\d{5}$
|
|
24
|
+
*/
|
|
25
|
+
export type CAP = Tagged<string, "CAP">
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Shape of an Italian CAP — five digits.
|
|
29
|
+
*/
|
|
30
|
+
export const CAP_PATTERN = /^\d{5}$/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Narrow a string to a {@link CAP}, or `null` when it is not one.
|
|
34
|
+
*/
|
|
35
|
+
export function parseCAP(input: string): CAP | null {
|
|
36
|
+
const s = input.trim()
|
|
37
|
+
|
|
38
|
+
return CAP_PATTERN.test(s) ? (s as CAP) : null
|
|
39
|
+
}
|
package/it/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Spanish postal codes (código postal): the branded type, the shape, and the province prior.
|
|
7
|
+
*
|
|
8
|
+
* The contrast with a German PLZ is the informative part. A PLZ's leading digit maps to a Leitzone
|
|
9
|
+
* that deliberately CROSSES state borders, so it cannot tell you the Bundesland. A Spanish código
|
|
10
|
+
* postal is the opposite: its first TWO digits are the province code, assigned alphabetically
|
|
11
|
+
* (01 Álava … 28 Madrid … 50 Zaragoza), so the province is derivable from the postcode exactly.
|
|
12
|
+
* Code that wants a Spanish region from an address can read it off the postcode; code that wants a
|
|
13
|
+
* German one cannot.
|
|
14
|
+
*/
|
|
15
|
+
import type { Tagged } from "type-fest";
|
|
16
|
+
/**
|
|
17
|
+
* A Spanish postal code: five digits, `PPNNN`, where `PP` is the province (`28001` is Madrid).
|
|
18
|
+
*
|
|
19
|
+
* @category Postal
|
|
20
|
+
* @type string
|
|
21
|
+
* @title CodigoPostal
|
|
22
|
+
* @pattern ^\d{5}$
|
|
23
|
+
*/
|
|
24
|
+
export type CodigoPostal = Tagged<string, "CodigoPostal">;
|
|
25
|
+
/**
|
|
26
|
+
* Shape of a Spanish código postal — five digits. Identical in shape to a French code postal, a German PLZ and a US
|
|
27
|
+
* ZIP; disambiguation is the parser's job, not the pattern's.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CODIGO_POSTAL_PATTERN: RegExp;
|
|
30
|
+
/**
|
|
31
|
+
* Narrow a string to a {@link CodigoPostal}, or `null` when it is not one.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseCodigoPostal(input: string): CodigoPostal | null;
|
|
34
|
+
/**
|
|
35
|
+
* The two-digit province prefix (`"28001"` → `"28"`), or `null` for a non-postcode. Callers map it through their own
|
|
36
|
+
* province table; this module deliberately does not ship one, since the campaign that needed it only needs the shape.
|
|
37
|
+
*/
|
|
38
|
+
export declare function codigoPostalProvincePrefix(input: string): string | null;
|
|
39
|
+
//# sourceMappingURL=codigo-postal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codigo-postal.d.ts","sourceRoot":"","sources":["../../es/codigo-postal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAY,CAAA;AAE9C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAIpE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIvE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Spanish postal codes (código postal): the branded type, the shape, and the province prior.
|
|
7
|
+
*
|
|
8
|
+
* The contrast with a German PLZ is the informative part. A PLZ's leading digit maps to a Leitzone
|
|
9
|
+
* that deliberately CROSSES state borders, so it cannot tell you the Bundesland. A Spanish código
|
|
10
|
+
* postal is the opposite: its first TWO digits are the province code, assigned alphabetically
|
|
11
|
+
* (01 Álava … 28 Madrid … 50 Zaragoza), so the province is derivable from the postcode exactly.
|
|
12
|
+
* Code that wants a Spanish region from an address can read it off the postcode; code that wants a
|
|
13
|
+
* German one cannot.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Shape of a Spanish código postal — five digits. Identical in shape to a French code postal, a German PLZ and a US
|
|
17
|
+
* ZIP; disambiguation is the parser's job, not the pattern's.
|
|
18
|
+
*/
|
|
19
|
+
export const CODIGO_POSTAL_PATTERN = /^\d{5}$/;
|
|
20
|
+
/**
|
|
21
|
+
* Narrow a string to a {@link CodigoPostal}, or `null` when it is not one.
|
|
22
|
+
*/
|
|
23
|
+
export function parseCodigoPostal(input) {
|
|
24
|
+
const s = input.trim();
|
|
25
|
+
return CODIGO_POSTAL_PATTERN.test(s) ? s : null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The two-digit province prefix (`"28001"` → `"28"`), or `null` for a non-postcode. Callers map it through their own
|
|
29
|
+
* province table; this module deliberately does not ship one, since the campaign that needed it only needs the shape.
|
|
30
|
+
*/
|
|
31
|
+
export function codigoPostalProvincePrefix(input) {
|
|
32
|
+
const code = parseCodigoPostal(input);
|
|
33
|
+
return code ? code.slice(0, 2) : null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=codigo-postal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codigo-postal.js","sourceRoot":"","sources":["../../es/codigo-postal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAA;AAE9C;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC9C,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAEtB,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAkB,CAAC,CAAC,CAAC,IAAI,CAAA;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACvD,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;IAErC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../es/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,oBAAoB,CAAA"}
|
package/out/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../es/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,oBAAoB,CAAA"}
|
package/out/it/cap.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Italian postal codes (Codice di Avviamento Postale, CAP): the branded type and the shape.
|
|
7
|
+
*
|
|
8
|
+
* Five digits like the Spanish, French and German forms, but do NOT infer a province from the
|
|
9
|
+
* leading digits the way `es/codigo-postal.ts` documents for Spain. Italy's large cities are
|
|
10
|
+
* assigned RANGES rather than a single code (Rome spans 00118–00199, Milan 20121–20162), and
|
|
11
|
+
* several provinces share leading digits, so the CAP narrows geography without identifying a
|
|
12
|
+
* province. It is the same trap German PLZ Leitzonen set, in a different disguise.
|
|
13
|
+
*/
|
|
14
|
+
import type { Tagged } from "type-fest";
|
|
15
|
+
/**
|
|
16
|
+
* An Italian postal code: five digits (`00184` is Rome, Rione Monti).
|
|
17
|
+
*
|
|
18
|
+
* @category Postal
|
|
19
|
+
* @type string
|
|
20
|
+
* @title CAP
|
|
21
|
+
* @pattern ^\d{5}$
|
|
22
|
+
*/
|
|
23
|
+
export type CAP = Tagged<string, "CAP">;
|
|
24
|
+
/**
|
|
25
|
+
* Shape of an Italian CAP — five digits.
|
|
26
|
+
*/
|
|
27
|
+
export declare const CAP_PATTERN: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* Narrow a string to a {@link CAP}, or `null` when it is not one.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseCAP(input: string): CAP | null;
|
|
32
|
+
//# sourceMappingURL=cap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cap.d.ts","sourceRoot":"","sources":["../../it/cap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,WAAW,QAAY,CAAA;AAEpC;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAIlD"}
|
package/out/it/cap.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Italian postal codes (Codice di Avviamento Postale, CAP): the branded type and the shape.
|
|
7
|
+
*
|
|
8
|
+
* Five digits like the Spanish, French and German forms, but do NOT infer a province from the
|
|
9
|
+
* leading digits the way `es/codigo-postal.ts` documents for Spain. Italy's large cities are
|
|
10
|
+
* assigned RANGES rather than a single code (Rome spans 00118–00199, Milan 20121–20162), and
|
|
11
|
+
* several provinces share leading digits, so the CAP narrows geography without identifying a
|
|
12
|
+
* province. It is the same trap German PLZ Leitzonen set, in a different disguise.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Shape of an Italian CAP — five digits.
|
|
16
|
+
*/
|
|
17
|
+
export const CAP_PATTERN = /^\d{5}$/;
|
|
18
|
+
/**
|
|
19
|
+
* Narrow a string to a {@link CAP}, or `null` when it is not one.
|
|
20
|
+
*/
|
|
21
|
+
export function parseCAP(input) {
|
|
22
|
+
const s = input.trim();
|
|
23
|
+
return CAP_PATTERN.test(s) ? s : null;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=cap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cap.js","sourceRoot":"","sources":["../../it/cap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAcH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAA;AAEpC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAEtB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAS,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../it/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAA"}
|
package/out/it/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../it/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/codex",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.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": {
|
|
@@ -68,6 +68,14 @@
|
|
|
68
68
|
"./tools": {
|
|
69
69
|
"types": "./out/tools/index.d.ts",
|
|
70
70
|
"default": "./out/tools/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./es": {
|
|
73
|
+
"types": "./out/es/index.d.ts",
|
|
74
|
+
"default": "./out/es/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./it": {
|
|
77
|
+
"types": "./out/it/index.d.ts",
|
|
78
|
+
"default": "./out/it/index.js"
|
|
71
79
|
}
|
|
72
80
|
},
|
|
73
81
|
"publishConfig": {
|
|
@@ -117,6 +125,14 @@
|
|
|
117
125
|
"./tools": {
|
|
118
126
|
"types": "./out/tools/index.d.ts",
|
|
119
127
|
"default": "./out/tools/index.js"
|
|
128
|
+
},
|
|
129
|
+
"./es": {
|
|
130
|
+
"types": "./out/es/index.d.ts",
|
|
131
|
+
"default": "./out/es/index.js"
|
|
132
|
+
},
|
|
133
|
+
"./it": {
|
|
134
|
+
"types": "./out/it/index.d.ts",
|
|
135
|
+
"default": "./out/it/index.js"
|
|
120
136
|
}
|
|
121
137
|
}
|
|
122
138
|
},
|
|
@@ -124,6 +140,6 @@
|
|
|
124
140
|
"type-fest": "^5.8.0"
|
|
125
141
|
},
|
|
126
142
|
"devDependencies": {
|
|
127
|
-
"@mailwoman/annotations": "8.
|
|
143
|
+
"@mailwoman/annotations": "8.6.0"
|
|
128
144
|
}
|
|
129
145
|
}
|