vet-data-utils-ts 0.3.0 → 0.4.1
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 +22 -0
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/dist/digital-twin.d.ts +17 -4
- package/dist/digital-twin.js +48 -11
- package/dist/financial.d.ts +26 -0
- package/dist/financial.js +162 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/iso-jurisdictions-data.d.ts +15 -0
- package/dist/iso-jurisdictions-data.js +32736 -0
- package/dist/iso-jurisdictions.d.ts +16 -0
- package/dist/iso-jurisdictions.js +28 -0
- package/package.json +46 -10
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Iso3166Country = Readonly<{
|
|
2
|
+
code: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}>;
|
|
5
|
+
export type Iso3166Subdivision = Readonly<{
|
|
6
|
+
code: string;
|
|
7
|
+
countryCode: string;
|
|
8
|
+
name: string;
|
|
9
|
+
parentCode?: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const Iso3166Countries: readonly Iso3166Country[];
|
|
13
|
+
export declare const Iso3166Subdivisions: readonly Iso3166Subdivision[];
|
|
14
|
+
export declare function isIso3166CountryCode(value: string): boolean;
|
|
15
|
+
export declare function iso3166SubdivisionsForCountry(countryCode: string): readonly Iso3166Subdivision[];
|
|
16
|
+
export declare function isIso3166SubdivisionForCountry(subdivisionCode: string, countryCode: string): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Iso3166CountryData, Iso3166SubdivisionData } from './iso-jurisdictions-data.js';
|
|
2
|
+
export const Iso3166Countries = Object.freeze(Iso3166CountryData.map(country => Object.freeze({ ...country })));
|
|
3
|
+
export const Iso3166Subdivisions = Object.freeze(Iso3166SubdivisionData.map(subdivision => Object.freeze({ ...subdivision })));
|
|
4
|
+
const countryCodes = new Set(Iso3166Countries.map(({ code }) => code));
|
|
5
|
+
const mutableSubdivisionsByCountry = new Map();
|
|
6
|
+
const subdivisionCodes = new Set();
|
|
7
|
+
for (const subdivision of Iso3166Subdivisions) {
|
|
8
|
+
subdivisionCodes.add(subdivision.code);
|
|
9
|
+
const current = mutableSubdivisionsByCountry.get(subdivision.countryCode) ?? [];
|
|
10
|
+
current.push(subdivision);
|
|
11
|
+
mutableSubdivisionsByCountry.set(subdivision.countryCode, current);
|
|
12
|
+
}
|
|
13
|
+
const subdivisionsByCountry = new Map([...mutableSubdivisionsByCountry].map(([countryCode, subdivisions]) => [
|
|
14
|
+
countryCode,
|
|
15
|
+
Object.freeze(subdivisions),
|
|
16
|
+
]));
|
|
17
|
+
export function isIso3166CountryCode(value) {
|
|
18
|
+
return countryCodes.has(value);
|
|
19
|
+
}
|
|
20
|
+
export function iso3166SubdivisionsForCountry(countryCode) {
|
|
21
|
+
if (!isIso3166CountryCode(countryCode))
|
|
22
|
+
return [];
|
|
23
|
+
return subdivisionsByCountry.get(countryCode) ?? [];
|
|
24
|
+
}
|
|
25
|
+
export function isIso3166SubdivisionForCountry(subdivisionCode, countryCode) {
|
|
26
|
+
return subdivisionCode.startsWith(`${countryCode}-`)
|
|
27
|
+
&& subdivisionCodes.has(subdivisionCode);
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vet-data-utils-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Browser-safe governed VetChain data contracts",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Connecting Solution & Applications Ltd",
|
|
@@ -8,22 +8,58 @@
|
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"./
|
|
16
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./animal-card": {
|
|
16
|
+
"types": "./dist/animal-card.d.ts",
|
|
17
|
+
"default": "./dist/animal-card.js"
|
|
18
|
+
},
|
|
19
|
+
"./digital-twin": {
|
|
20
|
+
"types": "./dist/digital-twin.d.ts",
|
|
21
|
+
"default": "./dist/digital-twin.js"
|
|
22
|
+
},
|
|
23
|
+
"./emergency": {
|
|
24
|
+
"types": "./dist/emergency.d.ts",
|
|
25
|
+
"default": "./dist/emergency.js"
|
|
26
|
+
},
|
|
27
|
+
"./financial": {
|
|
28
|
+
"types": "./dist/financial.d.ts",
|
|
29
|
+
"default": "./dist/financial.js"
|
|
30
|
+
},
|
|
31
|
+
"./iso-jurisdictions": {
|
|
32
|
+
"types": "./dist/iso-jurisdictions.d.ts",
|
|
33
|
+
"default": "./dist/iso-jurisdictions.js"
|
|
34
|
+
},
|
|
35
|
+
"./veterinary-sections": {
|
|
36
|
+
"types": "./dist/veterinary-sections.d.ts",
|
|
37
|
+
"default": "./dist/veterinary-sections.js"
|
|
38
|
+
},
|
|
39
|
+
"./assistant": {
|
|
40
|
+
"types": "./dist/assistant.d.ts",
|
|
41
|
+
"default": "./dist/assistant.js"
|
|
42
|
+
}
|
|
17
43
|
},
|
|
18
|
-
"files": [
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"THIRD_PARTY_NOTICES.md"
|
|
48
|
+
],
|
|
19
49
|
"scripts": {
|
|
20
50
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
21
51
|
"build": "npm run clean && tsc -p tsconfig.json",
|
|
22
52
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
53
|
"test": "npm run build && node --test tests/*.test.mjs",
|
|
54
|
+
"update:iso-jurisdictions": "node scripts/update-iso-jurisdictions.mjs",
|
|
24
55
|
"prepare": "npm run build",
|
|
25
56
|
"prepublishOnly": "npm run typecheck && npm test"
|
|
26
57
|
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^22.0.0",
|
|
60
|
+
"typescript": "^5.5.4"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=20"
|
|
64
|
+
}
|
|
29
65
|
}
|