hanzio 2.2.0 → 3.1.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 +133 -7
- package/dist/api-wrapper/connection-auth.d.ts +61 -0
- package/dist/cli/fields.d.ts +30 -0
- package/dist/cli/index.d.ts +122 -0
- package/dist/format/index.d.ts +91 -0
- package/dist/format/phone.d.ts +19 -0
- package/dist/http/index.d.ts +14 -0
- package/dist/i18n/catalog.d.ts +47 -0
- package/dist/i18n/check.d.ts +45 -0
- package/dist/i18n/cli.d.ts +2 -0
- package/dist/i18n/content-rules.d.ts +55 -0
- package/dist/i18n/i18next.d.ts +39 -0
- package/dist/i18n/index.d.ts +16 -1
- package/dist/i18n/locales.d.ts +62 -0
- package/dist/i18n/vite.d.ts +16 -0
- package/dist/i18n/vue.d.ts +93 -0
- package/dist/{index-kj1phgrx.js → index-29mmh343.js} +24 -1
- package/dist/{index-zbj9s3s3.js → index-2kz392vw.js} +1 -1
- package/dist/index-5n2e326q.js +409 -0
- package/dist/{index-hy7kbb99.js → index-5tzqfmnj.js} +1 -1
- package/dist/{index-0zvtcbzy.js → index-6f2w90pp.js} +69 -1
- package/dist/index-6ragggbs.js +473 -0
- package/dist/index-mq2qgc20.js +116 -0
- package/dist/index-najbyzpr.js +99 -0
- package/dist/index-ww09bm49.js +250 -0
- package/dist/iso/countries.d.ts +262 -0
- package/dist/iso/currencies.d.ts +165 -0
- package/dist/iso/index.d.ts +4 -0
- package/dist/iso/languages.d.ts +195 -0
- package/dist/iso/phone-language.d.ts +5 -0
- package/dist/promise/index.d.ts +31 -0
- package/dist/redis/client.d.ts +49 -0
- package/dist/redis/concurrency-limit.d.ts +63 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/lua-script.d.ts +13 -0
- package/dist/secrets/infisical-identity-file.d.ts +12 -0
- package/dist/src/api-wrapper/connection-auth.js +82 -0
- package/dist/src/api-wrapper/index.js +1 -1
- package/dist/src/cli/index.js +10 -0
- package/dist/src/format/index.js +79 -2
- package/dist/src/format/phone.js +21 -0
- package/dist/src/http/index.js +69 -0
- package/dist/src/i18n/check.js +15 -0
- package/dist/src/i18n/cli.js +71 -0
- package/dist/src/i18n/i18next.js +48 -0
- package/dist/src/i18n/index.js +16 -34
- package/dist/src/i18n/vite.js +25 -0
- package/dist/src/i18n/vue.js +51 -0
- package/dist/src/index.js +22 -6
- package/dist/src/iso/index.js +655 -0
- package/dist/src/redis/index.js +577 -0
- package/dist/src/secrets/index.js +78 -35
- package/dist/src/sitemap/index.js +1 -1
- package/dist/src/storage/index.js +8 -117
- package/dist/src/testing/index.js +348 -0
- package/dist/src/zod/index.js +20 -253
- package/dist/string/index.d.ts +21 -0
- package/dist/testing/connection-auth-contract.d.ts +43 -0
- package/dist/testing/helpers.d.ts +26 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/module-mocker.d.ts +30 -0
- package/dist/testing/prisma.d.ts +30 -0
- package/dist/testing/window.d.ts +18 -0
- package/dist/typedswitch/index.d.ts +55 -34
- package/dist/zod/index.d.ts +10 -0
- package/dist/zod/introspect.d.ts +2 -1
- package/package.json +97 -2
- package/src/api-wrapper/README.md +57 -2
- package/src/api-wrapper/SKILL.md +256 -0
- package/src/api-wrapper/connection-auth.ts +142 -0
- package/src/cli/README.md +220 -0
- package/src/cli/fields.ts +213 -0
- package/src/cli/index.ts +532 -0
- package/src/format/README.md +82 -2
- package/src/format/index.ts +148 -0
- package/src/format/phone.ts +43 -0
- package/src/http/README.md +25 -0
- package/src/http/index.ts +94 -0
- package/src/i18n/README.md +206 -3
- package/src/i18n/catalog.ts +139 -0
- package/src/i18n/check.ts +376 -0
- package/src/i18n/cli.ts +90 -0
- package/src/i18n/content-rules.ts +179 -0
- package/src/i18n/i18next.ts +89 -0
- package/src/i18n/index.ts +34 -0
- package/src/i18n/locales.ts +135 -0
- package/src/i18n/vite.ts +40 -0
- package/src/i18n/vue.ts +82 -0
- package/src/index.ts +1 -1
- package/src/iso/README.md +44 -0
- package/src/iso/countries.ts +272 -0
- package/src/iso/currencies.ts +172 -0
- package/src/iso/index.ts +8 -0
- package/src/iso/languages.ts +208 -0
- package/src/iso/phone-language.ts +46 -0
- package/src/promise/index.ts +100 -0
- package/src/redis/README.md +112 -0
- package/src/redis/client.ts +239 -0
- package/src/redis/concurrency-limit.ts +591 -0
- package/src/redis/index.ts +15 -0
- package/src/redis/lua-script.ts +43 -0
- package/src/secrets/README.md +5 -1
- package/src/secrets/infisical-identity-file.ts +69 -0
- package/src/secrets/infisical.ts +18 -3
- package/src/string/index.ts +59 -0
- package/src/testing/README.md +119 -0
- package/src/testing/connection-auth-contract.ts +303 -0
- package/src/testing/helpers.ts +41 -0
- package/src/testing/index.ts +12 -0
- package/src/testing/module-mocker.ts +50 -0
- package/src/testing/prisma.ts +78 -0
- package/src/testing/window.ts +119 -0
- package/src/typedswitch/README.md +55 -39
- package/src/typedswitch/index.ts +97 -83
- package/src/zod/index.ts +20 -0
- package/src/zod/introspect.ts +1 -1
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/** ISO 3166-1 alpha-2 codes with English short names. */
|
|
2
|
+
export const countryNames = {
|
|
3
|
+
AD: 'Andorra',
|
|
4
|
+
AE: 'United Arab Emirates',
|
|
5
|
+
AF: 'Afghanistan',
|
|
6
|
+
AG: 'Antigua and Barbuda',
|
|
7
|
+
AI: 'Anguilla',
|
|
8
|
+
AL: 'Albania',
|
|
9
|
+
AM: 'Armenia',
|
|
10
|
+
AO: 'Angola',
|
|
11
|
+
AQ: 'Antarctica',
|
|
12
|
+
AR: 'Argentina',
|
|
13
|
+
AS: 'American Samoa',
|
|
14
|
+
AT: 'Austria',
|
|
15
|
+
AU: 'Australia',
|
|
16
|
+
AW: 'Aruba',
|
|
17
|
+
AX: 'Aland Islands',
|
|
18
|
+
AZ: 'Azerbaijan',
|
|
19
|
+
BA: 'Bosnia and Herzegovina',
|
|
20
|
+
BB: 'Barbados',
|
|
21
|
+
BD: 'Bangladesh',
|
|
22
|
+
BE: 'Belgium',
|
|
23
|
+
BF: 'Burkina Faso',
|
|
24
|
+
BG: 'Bulgaria',
|
|
25
|
+
BH: 'Bahrain',
|
|
26
|
+
BI: 'Burundi',
|
|
27
|
+
BJ: 'Benin',
|
|
28
|
+
BL: 'Saint Barthelemy',
|
|
29
|
+
BM: 'Bermuda',
|
|
30
|
+
BN: 'Brunei Darussalam',
|
|
31
|
+
BO: 'Bolivia',
|
|
32
|
+
BQ: 'Bonaire, Sint Eustatius and Saba',
|
|
33
|
+
BR: 'Brazil',
|
|
34
|
+
BS: 'Bahamas',
|
|
35
|
+
BT: 'Bhutan',
|
|
36
|
+
BV: 'Bouvet Island',
|
|
37
|
+
BW: 'Botswana',
|
|
38
|
+
BY: 'Belarus',
|
|
39
|
+
BZ: 'Belize',
|
|
40
|
+
CA: 'Canada',
|
|
41
|
+
CC: 'Cocos (Keeling) Islands',
|
|
42
|
+
CD: 'Congo, (Kinshasa)',
|
|
43
|
+
CF: 'Central African Republic',
|
|
44
|
+
CG: 'Congo (Brazzaville)',
|
|
45
|
+
CH: 'Switzerland',
|
|
46
|
+
CI: 'Ivory Coast',
|
|
47
|
+
CK: 'Cook Islands',
|
|
48
|
+
CL: 'Chile',
|
|
49
|
+
CM: 'Cameroon',
|
|
50
|
+
CN: 'China',
|
|
51
|
+
CO: 'Colombia',
|
|
52
|
+
CR: 'Costa Rica',
|
|
53
|
+
CU: 'Cuba',
|
|
54
|
+
CV: 'Cape Verde',
|
|
55
|
+
CW: 'Curaçao',
|
|
56
|
+
CX: 'Christmas Island',
|
|
57
|
+
CY: 'Cyprus',
|
|
58
|
+
CZ: 'Czech Republic',
|
|
59
|
+
DE: 'Germany',
|
|
60
|
+
DJ: 'Djibouti',
|
|
61
|
+
DK: 'Denmark',
|
|
62
|
+
DM: 'Dominica',
|
|
63
|
+
DO: 'Dominican Republic',
|
|
64
|
+
DZ: 'Algeria',
|
|
65
|
+
EC: 'Ecuador',
|
|
66
|
+
EE: 'Estonia',
|
|
67
|
+
EG: 'Egypt',
|
|
68
|
+
EH: 'Western Sahara',
|
|
69
|
+
ER: 'Eritrea',
|
|
70
|
+
ES: 'Spain',
|
|
71
|
+
ET: 'Ethiopia',
|
|
72
|
+
FI: 'Finland',
|
|
73
|
+
FJ: 'Fiji',
|
|
74
|
+
FK: 'Falkland Islands (Malvinas)',
|
|
75
|
+
FM: 'Micronesia, Federated States of',
|
|
76
|
+
FO: 'Faroe Islands',
|
|
77
|
+
FR: 'France',
|
|
78
|
+
GA: 'Gabon',
|
|
79
|
+
GB: 'United Kingdom',
|
|
80
|
+
GD: 'Grenada',
|
|
81
|
+
GE: 'Georgia',
|
|
82
|
+
GF: 'French Guiana',
|
|
83
|
+
GG: 'Guernsey',
|
|
84
|
+
GH: 'Ghana',
|
|
85
|
+
GI: 'Gibraltar',
|
|
86
|
+
GL: 'Greenland',
|
|
87
|
+
GM: 'Gambia',
|
|
88
|
+
GN: 'Guinea',
|
|
89
|
+
GP: 'Guadeloupe',
|
|
90
|
+
GQ: 'Equatorial Guinea',
|
|
91
|
+
GR: 'Greece',
|
|
92
|
+
GS: 'South Georgia and the South Sandwich Islands',
|
|
93
|
+
GT: 'Guatemala',
|
|
94
|
+
GU: 'Guam',
|
|
95
|
+
GW: 'Guinea-Bissau',
|
|
96
|
+
GY: 'Guyana',
|
|
97
|
+
HK: 'Hong Kong, SAR China',
|
|
98
|
+
HM: 'Heard and Mcdonald Islands',
|
|
99
|
+
HN: 'Honduras',
|
|
100
|
+
HR: 'Croatia',
|
|
101
|
+
HT: 'Haiti',
|
|
102
|
+
HU: 'Hungary',
|
|
103
|
+
ID: 'Indonesia',
|
|
104
|
+
IE: 'Ireland',
|
|
105
|
+
IL: 'Israel',
|
|
106
|
+
IM: 'Isle of Man',
|
|
107
|
+
IN: 'India',
|
|
108
|
+
IO: 'British Indian Ocean Territory',
|
|
109
|
+
IQ: 'Iraq',
|
|
110
|
+
IR: 'Iran, Islamic Republic of',
|
|
111
|
+
IS: 'Iceland',
|
|
112
|
+
IT: 'Italy',
|
|
113
|
+
JE: 'Jersey',
|
|
114
|
+
JM: 'Jamaica',
|
|
115
|
+
JO: 'Jordan',
|
|
116
|
+
JP: 'Japan',
|
|
117
|
+
KE: 'Kenya',
|
|
118
|
+
KG: 'Kyrgyzstan',
|
|
119
|
+
KH: 'Cambodia',
|
|
120
|
+
KI: 'Kiribati',
|
|
121
|
+
KM: 'Comoros',
|
|
122
|
+
KN: 'Saint Kitts and Nevis',
|
|
123
|
+
KP: 'North Korea',
|
|
124
|
+
KR: 'South Korea',
|
|
125
|
+
KW: 'Kuwait',
|
|
126
|
+
KY: 'Cayman Islands',
|
|
127
|
+
KZ: 'Kazakhstan',
|
|
128
|
+
LA: 'Lao PDR',
|
|
129
|
+
LB: 'Lebanon',
|
|
130
|
+
LC: 'Saint Lucia',
|
|
131
|
+
LI: 'Liechtenstein',
|
|
132
|
+
LK: 'Sri Lanka',
|
|
133
|
+
LR: 'Liberia',
|
|
134
|
+
LS: 'Lesotho',
|
|
135
|
+
LT: 'Lithuania',
|
|
136
|
+
LU: 'Luxembourg',
|
|
137
|
+
LV: 'Latvia',
|
|
138
|
+
LY: 'Libya',
|
|
139
|
+
MA: 'Morocco',
|
|
140
|
+
MC: 'Monaco',
|
|
141
|
+
MD: 'Moldova',
|
|
142
|
+
ME: 'Montenegro',
|
|
143
|
+
MF: 'Saint-Martin (French part)',
|
|
144
|
+
MG: 'Madagascar',
|
|
145
|
+
MH: 'Marshall Islands',
|
|
146
|
+
MK: 'Macedonia, Republic of',
|
|
147
|
+
ML: 'Mali',
|
|
148
|
+
MM: 'Myanmar',
|
|
149
|
+
MN: 'Mongolia',
|
|
150
|
+
MO: 'Macao, SAR China',
|
|
151
|
+
MP: 'Northern Mariana Islands',
|
|
152
|
+
MQ: 'Martinique',
|
|
153
|
+
MR: 'Mauritania',
|
|
154
|
+
MS: 'Montserrat',
|
|
155
|
+
MT: 'Malta',
|
|
156
|
+
MU: 'Mauritius',
|
|
157
|
+
MV: 'Maldives',
|
|
158
|
+
MW: 'Malawi',
|
|
159
|
+
MX: 'Mexico',
|
|
160
|
+
MY: 'Malaysia',
|
|
161
|
+
MZ: 'Mozambique',
|
|
162
|
+
NA: 'Namibia',
|
|
163
|
+
NC: 'New Caledonia',
|
|
164
|
+
NE: 'Niger',
|
|
165
|
+
NF: 'Norfolk Island',
|
|
166
|
+
NG: 'Nigeria',
|
|
167
|
+
NI: 'Nicaragua',
|
|
168
|
+
NL: 'Netherlands',
|
|
169
|
+
NO: 'Norway',
|
|
170
|
+
NP: 'Nepal',
|
|
171
|
+
NR: 'Nauru',
|
|
172
|
+
NU: 'Niue',
|
|
173
|
+
NZ: 'New Zealand',
|
|
174
|
+
OM: 'Oman',
|
|
175
|
+
PA: 'Panama',
|
|
176
|
+
PE: 'Peru',
|
|
177
|
+
PF: 'French Polynesia',
|
|
178
|
+
PG: 'Papua New Guinea',
|
|
179
|
+
PH: 'Philippines',
|
|
180
|
+
PK: 'Pakistan',
|
|
181
|
+
PL: 'Poland',
|
|
182
|
+
PM: 'Saint Pierre and Miquelon',
|
|
183
|
+
PN: 'Pitcairn',
|
|
184
|
+
PR: 'Puerto Rico',
|
|
185
|
+
PS: 'Palestinian Territory',
|
|
186
|
+
PT: 'Portugal',
|
|
187
|
+
PW: 'Palau',
|
|
188
|
+
PY: 'Paraguay',
|
|
189
|
+
QA: 'Qatar',
|
|
190
|
+
RE: 'Reunion',
|
|
191
|
+
RO: 'Romania',
|
|
192
|
+
RS: 'Serbia',
|
|
193
|
+
RU: 'Russian Federation',
|
|
194
|
+
RW: 'Rwanda',
|
|
195
|
+
SA: 'Saudi Arabia',
|
|
196
|
+
SB: 'Solomon Islands',
|
|
197
|
+
SC: 'Seychelles',
|
|
198
|
+
SD: 'Sudan',
|
|
199
|
+
SE: 'Sweden',
|
|
200
|
+
SG: 'Singapore',
|
|
201
|
+
SH: 'Saint Helena',
|
|
202
|
+
SI: 'Slovenia',
|
|
203
|
+
SJ: 'Svalbard and Jan Mayen Islands',
|
|
204
|
+
SK: 'Slovakia',
|
|
205
|
+
SL: 'Sierra Leone',
|
|
206
|
+
SM: 'San Marino',
|
|
207
|
+
SN: 'Senegal',
|
|
208
|
+
SO: 'Somalia',
|
|
209
|
+
SR: 'Suriname',
|
|
210
|
+
SS: 'South Sudan',
|
|
211
|
+
ST: 'Sao Tome and Principe',
|
|
212
|
+
SV: 'El Salvador',
|
|
213
|
+
SX: 'Sint Maarten (Dutch part)',
|
|
214
|
+
SY: 'Syria',
|
|
215
|
+
SZ: 'Swaziland',
|
|
216
|
+
TC: 'Turks and Caicos Islands',
|
|
217
|
+
TD: 'Chad',
|
|
218
|
+
TF: 'French Southern Territories',
|
|
219
|
+
TG: 'Togo',
|
|
220
|
+
TH: 'Thailand',
|
|
221
|
+
TJ: 'Tajikistan',
|
|
222
|
+
TK: 'Tokelau',
|
|
223
|
+
TL: 'Timor-Leste',
|
|
224
|
+
TM: 'Turkmenistan',
|
|
225
|
+
TN: 'Tunisia',
|
|
226
|
+
TO: 'Tonga',
|
|
227
|
+
TR: 'Turkey',
|
|
228
|
+
TT: 'Trinidad and Tobago',
|
|
229
|
+
TV: 'Tuvalu',
|
|
230
|
+
TW: 'Taiwan, Republic of China',
|
|
231
|
+
TZ: 'Tanzania, United Republic of',
|
|
232
|
+
UA: 'Ukraine',
|
|
233
|
+
UG: 'Uganda',
|
|
234
|
+
UM: 'US Minor Outlying Islands',
|
|
235
|
+
US: 'United States of America',
|
|
236
|
+
UY: 'Uruguay',
|
|
237
|
+
UZ: 'Uzbekistan',
|
|
238
|
+
VA: 'Holy See (Vatican City State)',
|
|
239
|
+
VC: 'Saint Vincent and Grenadines',
|
|
240
|
+
VE: 'Venezuela',
|
|
241
|
+
VG: 'British Virgin Islands',
|
|
242
|
+
VI: 'Virgin Islands, US',
|
|
243
|
+
VN: 'Viet Nam',
|
|
244
|
+
VU: 'Vanuatu',
|
|
245
|
+
WF: 'Wallis and Futuna Islands',
|
|
246
|
+
WS: 'Samoa',
|
|
247
|
+
YE: 'Yemen',
|
|
248
|
+
YT: 'Mayotte',
|
|
249
|
+
ZA: 'South Africa',
|
|
250
|
+
ZM: 'Zambia',
|
|
251
|
+
ZW: 'Zimbabwe'
|
|
252
|
+
} as const
|
|
253
|
+
|
|
254
|
+
export type CountryCode = keyof typeof countryNames
|
|
255
|
+
|
|
256
|
+
/** All 249 ISO 3166-1 alpha-2 codes, sorted. */
|
|
257
|
+
export const countryCodes = Object.keys(countryNames) as readonly CountryCode[]
|
|
258
|
+
|
|
259
|
+
export function isCountryCode(value: unknown): value is CountryCode {
|
|
260
|
+
return typeof value === 'string' && Object.hasOwn(countryNames, value)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The flag emoji for a country code: `countryFlag('DK')` is `'🇩🇰'`. Built
|
|
265
|
+
* from regional-indicator letters, so platforms without a flag glyph show
|
|
266
|
+
* the two letters.
|
|
267
|
+
*/
|
|
268
|
+
export function countryFlag(code: CountryCode): string {
|
|
269
|
+
return String.fromCodePoint(
|
|
270
|
+
...[...code].map((letter) => 0x1f1a5 + letter.charCodeAt(0))
|
|
271
|
+
)
|
|
272
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISO 4217 codes of circulating currencies (plus the CFA and CFP francs and
|
|
3
|
+
* the East Caribbean dollars), with English names. Historic codes, funds and
|
|
4
|
+
* precious metals are left out.
|
|
5
|
+
*/
|
|
6
|
+
export const currencyNames = {
|
|
7
|
+
AED: 'United Arab Emirates Dirham',
|
|
8
|
+
AFN: 'Afghan Afghani',
|
|
9
|
+
ALL: 'Albanian Lek',
|
|
10
|
+
AMD: 'Armenian Dram',
|
|
11
|
+
AOA: 'Angolan Kwanza',
|
|
12
|
+
ARS: 'Argentine Peso',
|
|
13
|
+
AUD: 'Australian Dollar',
|
|
14
|
+
AWG: 'Aruban Florin',
|
|
15
|
+
AZN: 'Azerbaijani Manat',
|
|
16
|
+
BAM: 'Bosnia-Herzegovina Convertible Mark',
|
|
17
|
+
BBD: 'Barbadian Dollar',
|
|
18
|
+
BDT: 'Bangladeshi Taka',
|
|
19
|
+
BHD: 'Bahraini Dinar',
|
|
20
|
+
BIF: 'Burundian Franc',
|
|
21
|
+
BMD: 'Bermudan Dollar',
|
|
22
|
+
BND: 'Brunei Dollar',
|
|
23
|
+
BOB: 'Bolivian Boliviano',
|
|
24
|
+
BRL: 'Brazilian Real',
|
|
25
|
+
BSD: 'Bahamian Dollar',
|
|
26
|
+
BTN: 'Bhutanese Ngultrum',
|
|
27
|
+
BWP: 'Botswanan Pula',
|
|
28
|
+
BYN: 'Belarusian Ruble',
|
|
29
|
+
BZD: 'Belize Dollar',
|
|
30
|
+
CAD: 'Canadian Dollar',
|
|
31
|
+
CDF: 'Congolese Franc',
|
|
32
|
+
CHF: 'Swiss Franc',
|
|
33
|
+
CLP: 'Chilean Peso',
|
|
34
|
+
CNY: 'Chinese Yuan',
|
|
35
|
+
COP: 'Colombian Peso',
|
|
36
|
+
CRC: 'Costa Rican Colón',
|
|
37
|
+
CUP: 'Cuban Peso',
|
|
38
|
+
CVE: 'Cape Verdean Escudo',
|
|
39
|
+
CZK: 'Czech Koruna',
|
|
40
|
+
DJF: 'Djiboutian Franc',
|
|
41
|
+
DKK: 'Danish Krone',
|
|
42
|
+
DOP: 'Dominican Peso',
|
|
43
|
+
DZD: 'Algerian Dinar',
|
|
44
|
+
EGP: 'Egyptian Pound',
|
|
45
|
+
ERN: 'Eritrean Nakfa',
|
|
46
|
+
ETB: 'Ethiopian Birr',
|
|
47
|
+
EUR: 'Euro',
|
|
48
|
+
FJD: 'Fijian Dollar',
|
|
49
|
+
FKP: 'Falkland Islands Pound',
|
|
50
|
+
GBP: 'British Pound',
|
|
51
|
+
GEL: 'Georgian Lari',
|
|
52
|
+
GHS: 'Ghanaian Cedi',
|
|
53
|
+
GIP: 'Gibraltar Pound',
|
|
54
|
+
GMD: 'Gambian Dalasi',
|
|
55
|
+
GNF: 'Guinean Franc',
|
|
56
|
+
GTQ: 'Guatemalan Quetzal',
|
|
57
|
+
GYD: 'Guyanese Dollar',
|
|
58
|
+
HKD: 'Hong Kong Dollar',
|
|
59
|
+
HNL: 'Honduran Lempira',
|
|
60
|
+
HTG: 'Haitian Gourde',
|
|
61
|
+
HUF: 'Hungarian Forint',
|
|
62
|
+
IDR: 'Indonesian Rupiah',
|
|
63
|
+
ILS: 'Israeli New Shekel',
|
|
64
|
+
INR: 'Indian Rupee',
|
|
65
|
+
IQD: 'Iraqi Dinar',
|
|
66
|
+
IRR: 'Iranian Rial',
|
|
67
|
+
ISK: 'Icelandic Króna',
|
|
68
|
+
JMD: 'Jamaican Dollar',
|
|
69
|
+
JOD: 'Jordanian Dinar',
|
|
70
|
+
JPY: 'Japanese Yen',
|
|
71
|
+
KES: 'Kenyan Shilling',
|
|
72
|
+
KGS: 'Kyrgyz Som',
|
|
73
|
+
KHR: 'Cambodian Riel',
|
|
74
|
+
KMF: 'Comorian Franc',
|
|
75
|
+
KPW: 'North Korean Won',
|
|
76
|
+
KRW: 'South Korean Won',
|
|
77
|
+
KWD: 'Kuwaiti Dinar',
|
|
78
|
+
KYD: 'Cayman Islands Dollar',
|
|
79
|
+
KZT: 'Kazakhstani Tenge',
|
|
80
|
+
LAK: 'Laotian Kip',
|
|
81
|
+
LBP: 'Lebanese Pound',
|
|
82
|
+
LKR: 'Sri Lankan Rupee',
|
|
83
|
+
LRD: 'Liberian Dollar',
|
|
84
|
+
LSL: 'Lesotho Loti',
|
|
85
|
+
LYD: 'Libyan Dinar',
|
|
86
|
+
MAD: 'Moroccan Dirham',
|
|
87
|
+
MDL: 'Moldovan Leu',
|
|
88
|
+
MGA: 'Malagasy Ariary',
|
|
89
|
+
MKD: 'Macedonian Denar',
|
|
90
|
+
MMK: 'Myanmar Kyat',
|
|
91
|
+
MNT: 'Mongolian Tugrik',
|
|
92
|
+
MOP: 'Macanese Pataca',
|
|
93
|
+
MRU: 'Mauritanian Ouguiya',
|
|
94
|
+
MUR: 'Mauritian Rupee',
|
|
95
|
+
MVR: 'Maldivian Rufiyaa',
|
|
96
|
+
MWK: 'Malawian Kwacha',
|
|
97
|
+
MXN: 'Mexican Peso',
|
|
98
|
+
MYR: 'Malaysian Ringgit',
|
|
99
|
+
MZN: 'Mozambican Metical',
|
|
100
|
+
NAD: 'Namibian Dollar',
|
|
101
|
+
NGN: 'Nigerian Naira',
|
|
102
|
+
NIO: 'Nicaraguan Córdoba',
|
|
103
|
+
NOK: 'Norwegian Krone',
|
|
104
|
+
NPR: 'Nepalese Rupee',
|
|
105
|
+
NZD: 'New Zealand Dollar',
|
|
106
|
+
OMR: 'Omani Rial',
|
|
107
|
+
PAB: 'Panamanian Balboa',
|
|
108
|
+
PEN: 'Peruvian Sol',
|
|
109
|
+
PGK: 'Papua New Guinean Kina',
|
|
110
|
+
PHP: 'Philippine Peso',
|
|
111
|
+
PKR: 'Pakistani Rupee',
|
|
112
|
+
PLN: 'Polish Zloty',
|
|
113
|
+
PYG: 'Paraguayan Guarani',
|
|
114
|
+
QAR: 'Qatari Riyal',
|
|
115
|
+
RON: 'Romanian Leu',
|
|
116
|
+
RSD: 'Serbian Dinar',
|
|
117
|
+
RUB: 'Russian Ruble',
|
|
118
|
+
RWF: 'Rwandan Franc',
|
|
119
|
+
SAR: 'Saudi Riyal',
|
|
120
|
+
SBD: 'Solomon Islands Dollar',
|
|
121
|
+
SCR: 'Seychellois Rupee',
|
|
122
|
+
SDG: 'Sudanese Pound',
|
|
123
|
+
SEK: 'Swedish Krona',
|
|
124
|
+
SGD: 'Singapore Dollar',
|
|
125
|
+
SHP: 'St. Helena Pound',
|
|
126
|
+
SLE: 'Sierra Leonean Leone',
|
|
127
|
+
SOS: 'Somali Shilling',
|
|
128
|
+
SRD: 'Surinamese Dollar',
|
|
129
|
+
SSP: 'South Sudanese Pound',
|
|
130
|
+
STN: 'São Tomé & Príncipe Dobra',
|
|
131
|
+
SVC: 'Salvadoran Colón',
|
|
132
|
+
SYP: 'Syrian Pound',
|
|
133
|
+
SZL: 'Swazi Lilangeni',
|
|
134
|
+
THB: 'Thai Baht',
|
|
135
|
+
TJS: 'Tajikistani Somoni',
|
|
136
|
+
TMT: 'Turkmenistani Manat',
|
|
137
|
+
TND: 'Tunisian Dinar',
|
|
138
|
+
TOP: 'Tongan Paʻanga',
|
|
139
|
+
TRY: 'Turkish Lira',
|
|
140
|
+
TTD: 'Trinidad & Tobago Dollar',
|
|
141
|
+
TWD: 'New Taiwan Dollar',
|
|
142
|
+
TZS: 'Tanzanian Shilling',
|
|
143
|
+
UAH: 'Ukrainian Hryvnia',
|
|
144
|
+
UGX: 'Ugandan Shilling',
|
|
145
|
+
USD: 'US Dollar',
|
|
146
|
+
UYU: 'Uruguayan Peso',
|
|
147
|
+
UZS: 'Uzbekistani Som',
|
|
148
|
+
VED: 'Bolívar Soberano',
|
|
149
|
+
VES: 'Venezuelan Bolívar',
|
|
150
|
+
VND: 'Vietnamese Dong',
|
|
151
|
+
VUV: 'Vanuatu Vatu',
|
|
152
|
+
WST: 'Samoan Tala',
|
|
153
|
+
XAF: 'Central African CFA Franc',
|
|
154
|
+
XCD: 'East Caribbean Dollar',
|
|
155
|
+
XCG: 'Caribbean guilder',
|
|
156
|
+
XOF: 'West African CFA Franc',
|
|
157
|
+
XPF: 'CFP Franc',
|
|
158
|
+
YER: 'Yemeni Rial',
|
|
159
|
+
ZAR: 'South African Rand',
|
|
160
|
+
ZMW: 'Zambian Kwacha',
|
|
161
|
+
ZWG: 'Zimbabwean Gold'
|
|
162
|
+
} as const
|
|
163
|
+
|
|
164
|
+
export type CurrencyCode = keyof typeof currencyNames
|
|
165
|
+
|
|
166
|
+
export const currencyCodes = Object.keys(
|
|
167
|
+
currencyNames
|
|
168
|
+
) as readonly CurrencyCode[]
|
|
169
|
+
|
|
170
|
+
export function isCurrencyCode(value: unknown): value is CurrencyCode {
|
|
171
|
+
return typeof value === 'string' && Object.hasOwn(currencyNames, value)
|
|
172
|
+
}
|
package/src/iso/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ISO country, currency and language codes as literal unions, with English
|
|
2
|
+
// names. Static data with no dependencies; no `Intl.DisplayNames` needed (it is
|
|
3
|
+
// missing on Hermes). For names in other languages, use `Intl.DisplayNames`.
|
|
4
|
+
|
|
5
|
+
export * from './countries'
|
|
6
|
+
export * from './currencies'
|
|
7
|
+
export * from './languages'
|
|
8
|
+
export * from './phone-language'
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/** ISO 639-1 two-letter language codes (lowercase) with English names. */
|
|
2
|
+
export const languageNames = {
|
|
3
|
+
aa: 'Afar',
|
|
4
|
+
ab: 'Abkhazian',
|
|
5
|
+
ae: 'Avestan',
|
|
6
|
+
af: 'Afrikaans',
|
|
7
|
+
ak: 'Akan',
|
|
8
|
+
am: 'Amharic',
|
|
9
|
+
an: 'Aragonese',
|
|
10
|
+
ar: 'Arabic',
|
|
11
|
+
as: 'Assamese',
|
|
12
|
+
av: 'Avaric',
|
|
13
|
+
ay: 'Aymara',
|
|
14
|
+
az: 'Azerbaijani',
|
|
15
|
+
ba: 'Bashkir',
|
|
16
|
+
be: 'Belarusian',
|
|
17
|
+
bg: 'Bulgarian',
|
|
18
|
+
bi: 'Bislama',
|
|
19
|
+
bm: 'Bambara',
|
|
20
|
+
bn: 'Bangla',
|
|
21
|
+
bo: 'Tibetan',
|
|
22
|
+
br: 'Breton',
|
|
23
|
+
bs: 'Bosnian',
|
|
24
|
+
ca: 'Catalan',
|
|
25
|
+
ce: 'Chechen',
|
|
26
|
+
ch: 'Chamorro',
|
|
27
|
+
co: 'Corsican',
|
|
28
|
+
cr: 'Cree',
|
|
29
|
+
cs: 'Czech',
|
|
30
|
+
cu: 'Church Slavic',
|
|
31
|
+
cv: 'Chuvash',
|
|
32
|
+
cy: 'Welsh',
|
|
33
|
+
da: 'Danish',
|
|
34
|
+
de: 'German',
|
|
35
|
+
dv: 'Dhivehi',
|
|
36
|
+
dz: 'Dzongkha',
|
|
37
|
+
ee: 'Ewe',
|
|
38
|
+
el: 'Greek',
|
|
39
|
+
en: 'English',
|
|
40
|
+
eo: 'Esperanto',
|
|
41
|
+
es: 'Spanish',
|
|
42
|
+
et: 'Estonian',
|
|
43
|
+
eu: 'Basque',
|
|
44
|
+
fa: 'Persian',
|
|
45
|
+
ff: 'Fula',
|
|
46
|
+
fi: 'Finnish',
|
|
47
|
+
fj: 'Fijian',
|
|
48
|
+
fo: 'Faroese',
|
|
49
|
+
fr: 'French',
|
|
50
|
+
fy: 'Western Frisian',
|
|
51
|
+
ga: 'Irish',
|
|
52
|
+
gd: 'Scottish Gaelic',
|
|
53
|
+
gl: 'Galician',
|
|
54
|
+
gn: 'Guarani',
|
|
55
|
+
gu: 'Gujarati',
|
|
56
|
+
gv: 'Manx',
|
|
57
|
+
ha: 'Hausa',
|
|
58
|
+
he: 'Hebrew',
|
|
59
|
+
hi: 'Hindi',
|
|
60
|
+
ho: 'Hiri Motu',
|
|
61
|
+
hr: 'Croatian',
|
|
62
|
+
ht: 'Haitian Creole',
|
|
63
|
+
hu: 'Hungarian',
|
|
64
|
+
hy: 'Armenian',
|
|
65
|
+
hz: 'Herero',
|
|
66
|
+
ia: 'Interlingua',
|
|
67
|
+
id: 'Indonesian',
|
|
68
|
+
ie: 'Interlingue',
|
|
69
|
+
ig: 'Igbo',
|
|
70
|
+
ii: 'Liangshan Yi',
|
|
71
|
+
ik: 'Inupiaq',
|
|
72
|
+
io: 'Ido',
|
|
73
|
+
is: 'Icelandic',
|
|
74
|
+
it: 'Italian',
|
|
75
|
+
iu: 'Inuktitut',
|
|
76
|
+
ja: 'Japanese',
|
|
77
|
+
jv: 'Javanese',
|
|
78
|
+
ka: 'Georgian',
|
|
79
|
+
kg: 'Kongo',
|
|
80
|
+
ki: 'Kikuyu',
|
|
81
|
+
kj: 'Kuanyama',
|
|
82
|
+
kk: 'Kazakh',
|
|
83
|
+
kl: 'Kalaallisut',
|
|
84
|
+
km: 'Khmer',
|
|
85
|
+
kn: 'Kannada',
|
|
86
|
+
ko: 'Korean',
|
|
87
|
+
kr: 'Kanuri',
|
|
88
|
+
ks: 'Kashmiri',
|
|
89
|
+
ku: 'Kurdish',
|
|
90
|
+
kv: 'Komi',
|
|
91
|
+
kw: 'Cornish',
|
|
92
|
+
ky: 'Kyrgyz',
|
|
93
|
+
la: 'Latin',
|
|
94
|
+
lb: 'Luxembourgish',
|
|
95
|
+
lg: 'Ganda',
|
|
96
|
+
li: 'Limburgish',
|
|
97
|
+
ln: 'Lingala',
|
|
98
|
+
lo: 'Lao',
|
|
99
|
+
lt: 'Lithuanian',
|
|
100
|
+
lu: 'Luba-Katanga',
|
|
101
|
+
lv: 'Latvian',
|
|
102
|
+
mg: 'Malagasy',
|
|
103
|
+
mh: 'Marshallese',
|
|
104
|
+
mi: 'Māori',
|
|
105
|
+
mk: 'Macedonian',
|
|
106
|
+
ml: 'Malayalam',
|
|
107
|
+
mn: 'Mongolian',
|
|
108
|
+
mr: 'Marathi',
|
|
109
|
+
ms: 'Malay',
|
|
110
|
+
mt: 'Maltese',
|
|
111
|
+
my: 'Burmese',
|
|
112
|
+
na: 'Nauru',
|
|
113
|
+
nb: 'Norwegian Bokmål',
|
|
114
|
+
nd: 'North Ndebele',
|
|
115
|
+
ne: 'Nepali',
|
|
116
|
+
ng: 'Ndonga',
|
|
117
|
+
nl: 'Dutch',
|
|
118
|
+
nn: 'Norwegian Nynorsk',
|
|
119
|
+
no: 'Norwegian',
|
|
120
|
+
nr: 'South Ndebele',
|
|
121
|
+
nv: 'Navajo',
|
|
122
|
+
ny: 'Nyanja',
|
|
123
|
+
oc: 'Occitan',
|
|
124
|
+
oj: 'Ojibwa',
|
|
125
|
+
om: 'Oromo',
|
|
126
|
+
or: 'Odia',
|
|
127
|
+
os: 'Ossetic',
|
|
128
|
+
pa: 'Punjabi',
|
|
129
|
+
pi: 'Pali',
|
|
130
|
+
pl: 'Polish',
|
|
131
|
+
ps: 'Pashto',
|
|
132
|
+
pt: 'Portuguese',
|
|
133
|
+
qu: 'Quechua',
|
|
134
|
+
rm: 'Romansh',
|
|
135
|
+
rn: 'Rundi',
|
|
136
|
+
ro: 'Romanian',
|
|
137
|
+
ru: 'Russian',
|
|
138
|
+
rw: 'Kinyarwanda',
|
|
139
|
+
sa: 'Sanskrit',
|
|
140
|
+
sc: 'Sardinian',
|
|
141
|
+
sd: 'Sindhi',
|
|
142
|
+
se: 'North Sámi',
|
|
143
|
+
sg: 'Sango',
|
|
144
|
+
si: 'Sinhala',
|
|
145
|
+
sk: 'Slovak',
|
|
146
|
+
sl: 'Slovenian',
|
|
147
|
+
sm: 'Samoan',
|
|
148
|
+
sn: 'Shona',
|
|
149
|
+
so: 'Somali',
|
|
150
|
+
sq: 'Albanian',
|
|
151
|
+
sr: 'Serbian',
|
|
152
|
+
ss: 'Swati',
|
|
153
|
+
st: 'Southern Sotho',
|
|
154
|
+
su: 'Sundanese',
|
|
155
|
+
sv: 'Swedish',
|
|
156
|
+
sw: 'Swahili',
|
|
157
|
+
ta: 'Tamil',
|
|
158
|
+
te: 'Telugu',
|
|
159
|
+
tg: 'Tajik',
|
|
160
|
+
th: 'Thai',
|
|
161
|
+
ti: 'Tigrinya',
|
|
162
|
+
tk: 'Turkmen',
|
|
163
|
+
tl: 'Tagalog',
|
|
164
|
+
tn: 'Tswana',
|
|
165
|
+
to: 'Tongan',
|
|
166
|
+
tr: 'Turkish',
|
|
167
|
+
ts: 'Tsonga',
|
|
168
|
+
tt: 'Tatar',
|
|
169
|
+
tw: 'Twi',
|
|
170
|
+
ty: 'Tahitian',
|
|
171
|
+
ug: 'Uyghur',
|
|
172
|
+
uk: 'Ukrainian',
|
|
173
|
+
ur: 'Urdu',
|
|
174
|
+
uz: 'Uzbek',
|
|
175
|
+
ve: 'Venda',
|
|
176
|
+
vi: 'Vietnamese',
|
|
177
|
+
vo: 'Volapük',
|
|
178
|
+
wa: 'Walloon',
|
|
179
|
+
wo: 'Wolof',
|
|
180
|
+
xh: 'Xhosa',
|
|
181
|
+
yi: 'Yiddish',
|
|
182
|
+
yo: 'Yoruba',
|
|
183
|
+
za: 'Zhuang',
|
|
184
|
+
zh: 'Chinese',
|
|
185
|
+
zu: 'Zulu'
|
|
186
|
+
} as const
|
|
187
|
+
|
|
188
|
+
export type LanguageCode = keyof typeof languageNames
|
|
189
|
+
|
|
190
|
+
export const languageCodes = Object.keys(
|
|
191
|
+
languageNames
|
|
192
|
+
) as readonly LanguageCode[]
|
|
193
|
+
|
|
194
|
+
export function isLanguageCode(value: unknown): value is LanguageCode {
|
|
195
|
+
return typeof value === 'string' && Object.hasOwn(languageNames, value)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The ISO 639-1 language of a BCP-47-ish tag (`'en-GB'`, `'da_DK'`), or
|
|
200
|
+
* `null` when it has none. Map tags your app treats as one language (`'no'`
|
|
201
|
+
* and `'nn'` to `'nb'`, say) before or after.
|
|
202
|
+
*/
|
|
203
|
+
export function matchLanguageCode(
|
|
204
|
+
tag: string | null | undefined
|
|
205
|
+
): LanguageCode | null {
|
|
206
|
+
const language = tag?.trim().replaceAll('_', '-').split('-')[0]?.toLowerCase()
|
|
207
|
+
return isLanguageCode(language) ? language : null
|
|
208
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LanguageCode } from './languages'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Country calling code (digits, no `+`) → the language a support conversation
|
|
5
|
+
* with that number most likely wants. Only codes with one clear default are
|
|
6
|
+
* listed; multilingual countries get their most common language.
|
|
7
|
+
*/
|
|
8
|
+
const CALLING_CODE_LANGUAGE = {
|
|
9
|
+
'1': 'en', // NANP
|
|
10
|
+
'31': 'nl',
|
|
11
|
+
'32': 'nl', // Belgium: Dutch and French
|
|
12
|
+
'33': 'fr',
|
|
13
|
+
'34': 'es',
|
|
14
|
+
'39': 'it',
|
|
15
|
+
'41': 'de', // Switzerland: German, French and Italian
|
|
16
|
+
'43': 'de',
|
|
17
|
+
'44': 'en',
|
|
18
|
+
'45': 'da',
|
|
19
|
+
'46': 'sv',
|
|
20
|
+
'47': 'nb',
|
|
21
|
+
'49': 'de',
|
|
22
|
+
'351': 'pt',
|
|
23
|
+
'353': 'en'
|
|
24
|
+
} as const satisfies Record<string, LanguageCode>
|
|
25
|
+
|
|
26
|
+
type CallingCode = keyof typeof CALLING_CODE_LANGUAGE
|
|
27
|
+
|
|
28
|
+
// Longest first, so `351` wins over a shorter prefix.
|
|
29
|
+
const CALLING_CODES = (
|
|
30
|
+
Object.keys(CALLING_CODE_LANGUAGE) as CallingCode[]
|
|
31
|
+
).sort((a, b) => b.length - a.length)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A default language from an E.164 number's calling code (`+45…` → `'da'`),
|
|
35
|
+
* or `null` when the number is missing, too short, or its code is unmapped.
|
|
36
|
+
*/
|
|
37
|
+
export function languageFromE164PhoneNumber(
|
|
38
|
+
phoneNumber: string | null | undefined
|
|
39
|
+
) {
|
|
40
|
+
const digits = phoneNumber?.trim().replace(/^\+/, '').replace(/\D/g, '')
|
|
41
|
+
if (!digits) return null
|
|
42
|
+
const code = CALLING_CODES.find(
|
|
43
|
+
(code) => digits.startsWith(code) && digits.length > code.length
|
|
44
|
+
)
|
|
45
|
+
return code ? CALLING_CODE_LANGUAGE[code] : null
|
|
46
|
+
}
|