national-metadata 0.1.1 → 0.1.3
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 +427 -1
- package/dist/cities/city-country-slugs.d.ts +2 -0
- package/dist/cities/city-country-slugs.d.ts.map +1 -0
- package/dist/cities/city-country-slugs.js +1346 -0
- package/dist/cities/city-country-slugs.js.map +1 -0
- package/dist/cities/city-slugs.d.ts +2 -0
- package/dist/cities/city-slugs.d.ts.map +1 -0
- package/dist/cities/city-slugs.js +1343 -0
- package/dist/cities/city-slugs.js.map +1 -0
- package/dist/code-to-country.js +1 -4
- package/dist/code-to-country.js.map +1 -1
- package/dist/country-name-strings.js +1 -4
- package/dist/country-name-strings.js.map +1 -1
- package/dist/country-to-code.d.ts.map +1 -1
- package/dist/country-to-code.js +3 -4
- package/dist/country-to-code.js.map +1 -1
- package/dist/flag-svg/AC.svg +1 -0
- package/dist/flag-svg/AD.svg +1 -0
- package/dist/flag-svg/AE.svg +1 -0
- package/dist/flag-svg/AF.svg +1 -0
- package/dist/flag-svg/AG.svg +1 -0
- package/dist/flag-svg/AI.svg +1 -0
- package/dist/flag-svg/AL.svg +1 -0
- package/dist/flag-svg/AM.svg +1 -0
- package/dist/flag-svg/AO.svg +1 -0
- package/dist/flag-svg/AQ.svg +1 -0
- package/dist/flag-svg/AR.svg +1 -0
- package/dist/flag-svg/AS.svg +1 -0
- package/dist/flag-svg/AT.svg +1 -0
- package/dist/flag-svg/AU.svg +1 -0
- package/dist/flag-svg/AW.svg +1 -0
- package/dist/flag-svg/AX.svg +1 -0
- package/dist/flag-svg/AZ.svg +1 -0
- package/dist/flag-svg/BA.svg +1 -0
- package/dist/flag-svg/BB.svg +1 -0
- package/dist/flag-svg/BD.svg +1 -0
- package/dist/flag-svg/BE.svg +1 -0
- package/dist/flag-svg/BF.svg +1 -0
- package/dist/flag-svg/BG.svg +1 -0
- package/dist/flag-svg/BH.svg +1 -0
- package/dist/flag-svg/BI.svg +1 -0
- package/dist/flag-svg/BJ.svg +1 -0
- package/dist/flag-svg/BL.svg +1 -0
- package/dist/flag-svg/BM.svg +1 -0
- package/dist/flag-svg/BN.svg +1 -0
- package/dist/flag-svg/BO.svg +1 -0
- package/dist/flag-svg/BQ.svg +1 -0
- package/dist/flag-svg/BR.svg +1 -0
- package/dist/flag-svg/BS.svg +1 -0
- package/dist/flag-svg/BT.svg +1 -0
- package/dist/flag-svg/BV.svg +1 -0
- package/dist/flag-svg/BW.svg +1 -0
- package/dist/flag-svg/BY.svg +1 -0
- package/dist/flag-svg/BZ.svg +1 -0
- package/dist/flag-svg/CA.svg +1 -0
- package/dist/flag-svg/CC.svg +1 -0
- package/dist/flag-svg/CD.svg +1 -0
- package/dist/flag-svg/CF.svg +1 -0
- package/dist/flag-svg/CG.svg +1 -0
- package/dist/flag-svg/CH.svg +1 -0
- package/dist/flag-svg/CI.svg +1 -0
- package/dist/flag-svg/CK.svg +1 -0
- package/dist/flag-svg/CL.svg +1 -0
- package/dist/flag-svg/CM.svg +1 -0
- package/dist/flag-svg/CN.svg +1 -0
- package/dist/flag-svg/CO.svg +1 -0
- package/dist/flag-svg/CR.svg +1 -0
- package/dist/flag-svg/CU.svg +1 -0
- package/dist/flag-svg/CV.svg +1 -0
- package/dist/flag-svg/CW.svg +1 -0
- package/dist/flag-svg/CX.svg +1 -0
- package/dist/flag-svg/CY.svg +1 -0
- package/dist/flag-svg/CZ.svg +1 -0
- package/dist/flag-svg/DE.svg +1 -0
- package/dist/flag-svg/DJ.svg +1 -0
- package/dist/flag-svg/DK.svg +1 -0
- package/dist/flag-svg/DM.svg +1 -0
- package/dist/flag-svg/DO.svg +1 -0
- package/dist/flag-svg/DZ.svg +1 -0
- package/dist/flag-svg/EC.svg +1 -0
- package/dist/flag-svg/EE.svg +1 -0
- package/dist/flag-svg/EG.svg +1 -0
- package/dist/flag-svg/EH.svg +1 -0
- package/dist/flag-svg/ER.svg +1 -0
- package/dist/flag-svg/ES.svg +1 -0
- package/dist/flag-svg/ET.svg +1 -0
- package/dist/flag-svg/EU.svg +1 -0
- package/dist/flag-svg/FI.svg +1 -0
- package/dist/flag-svg/FJ.svg +1 -0
- package/dist/flag-svg/FK.svg +1 -0
- package/dist/flag-svg/FM.svg +1 -0
- package/dist/flag-svg/FO.svg +1 -0
- package/dist/flag-svg/FR.svg +1 -0
- package/dist/flag-svg/GA.svg +1 -0
- package/dist/flag-svg/GB.svg +1 -0
- package/dist/flag-svg/GD.svg +1 -0
- package/dist/flag-svg/GE-AB.svg +1 -0
- package/dist/flag-svg/GE-OS.svg +1 -0
- package/dist/flag-svg/GE.svg +1 -0
- package/dist/flag-svg/GF.svg +1 -0
- package/dist/flag-svg/GG.svg +1 -0
- package/dist/flag-svg/GH.svg +1 -0
- package/dist/flag-svg/GI.svg +1 -0
- package/dist/flag-svg/GL.svg +1 -0
- package/dist/flag-svg/GM.svg +1 -0
- package/dist/flag-svg/GN.svg +1 -0
- package/dist/flag-svg/GP.svg +1 -0
- package/dist/flag-svg/GQ.svg +1 -0
- package/dist/flag-svg/GR.svg +1 -0
- package/dist/flag-svg/GS.svg +1 -0
- package/dist/flag-svg/GT.svg +1 -0
- package/dist/flag-svg/GU.svg +1 -0
- package/dist/flag-svg/GW.svg +1 -0
- package/dist/flag-svg/GY.svg +1 -0
- package/dist/flag-svg/HK.svg +1 -0
- package/dist/flag-svg/HM.svg +1 -0
- package/dist/flag-svg/HN.svg +1 -0
- package/dist/flag-svg/HR.svg +1 -0
- package/dist/flag-svg/HT.svg +1 -0
- package/dist/flag-svg/HU.svg +1 -0
- package/dist/flag-svg/IC.svg +1 -0
- package/dist/flag-svg/ID.svg +1 -0
- package/dist/flag-svg/IE.svg +1 -0
- package/dist/flag-svg/IL.svg +1 -0
- package/dist/flag-svg/IM.svg +1 -0
- package/dist/flag-svg/IN.svg +1 -0
- package/dist/flag-svg/IO.svg +1 -0
- package/dist/flag-svg/IQ.svg +1 -0
- package/dist/flag-svg/IR.svg +1 -0
- package/dist/flag-svg/IS.svg +1 -0
- package/dist/flag-svg/IT.svg +1 -0
- package/dist/flag-svg/JE.svg +1 -0
- package/dist/flag-svg/JM.svg +1 -0
- package/dist/flag-svg/JO.svg +1 -0
- package/dist/flag-svg/JP.svg +1 -0
- package/dist/flag-svg/KE.svg +1 -0
- package/dist/flag-svg/KG.svg +1 -0
- package/dist/flag-svg/KH.svg +1 -0
- package/dist/flag-svg/KI.svg +1 -0
- package/dist/flag-svg/KM.svg +1 -0
- package/dist/flag-svg/KN.svg +1 -0
- package/dist/flag-svg/KP.svg +1 -0
- package/dist/flag-svg/KR.svg +1 -0
- package/dist/flag-svg/KW.svg +1 -0
- package/dist/flag-svg/KY.svg +1 -0
- package/dist/flag-svg/KZ.svg +1 -0
- package/dist/flag-svg/LA.svg +1 -0
- package/dist/flag-svg/LB.svg +1 -0
- package/dist/flag-svg/LC.svg +1 -0
- package/dist/flag-svg/LI.svg +1 -0
- package/dist/flag-svg/LK.svg +1 -0
- package/dist/flag-svg/LR.svg +1 -0
- package/dist/flag-svg/LS.svg +1 -0
- package/dist/flag-svg/LT.svg +1 -0
- package/dist/flag-svg/LU.svg +1 -0
- package/dist/flag-svg/LV.svg +1 -0
- package/dist/flag-svg/LY.svg +1 -0
- package/dist/flag-svg/MA.svg +1 -0
- package/dist/flag-svg/MC.svg +1 -0
- package/dist/flag-svg/MD.svg +1 -0
- package/dist/flag-svg/ME.svg +1 -0
- package/dist/flag-svg/MF.svg +1 -0
- package/dist/flag-svg/MG.svg +1 -0
- package/dist/flag-svg/MH.svg +1 -0
- package/dist/flag-svg/MK.svg +1 -0
- package/dist/flag-svg/ML.svg +1 -0
- package/dist/flag-svg/MM.svg +1 -0
- package/dist/flag-svg/MN.svg +1 -0
- package/dist/flag-svg/MO.svg +1 -0
- package/dist/flag-svg/MP.svg +1 -0
- package/dist/flag-svg/MQ.svg +1 -0
- package/dist/flag-svg/MR.svg +1 -0
- package/dist/flag-svg/MS.svg +1 -0
- package/dist/flag-svg/MT.svg +1 -0
- package/dist/flag-svg/MU.svg +1 -0
- package/dist/flag-svg/MV.svg +1 -0
- package/dist/flag-svg/MW.svg +1 -0
- package/dist/flag-svg/MX.svg +1 -0
- package/dist/flag-svg/MY.svg +1 -0
- package/dist/flag-svg/MZ.svg +1 -0
- package/dist/flag-svg/NA.svg +1 -0
- package/dist/flag-svg/NC.svg +1 -0
- package/dist/flag-svg/NE.svg +1 -0
- package/dist/flag-svg/NF.svg +1 -0
- package/dist/flag-svg/NG.svg +1 -0
- package/dist/flag-svg/NI.svg +1 -0
- package/dist/flag-svg/NL.svg +1 -0
- package/dist/flag-svg/NO.svg +1 -0
- package/dist/flag-svg/NP.svg +1 -0
- package/dist/flag-svg/NR.svg +1 -0
- package/dist/flag-svg/NU.svg +1 -0
- package/dist/flag-svg/NZ.svg +1 -0
- package/dist/flag-svg/OM.svg +1 -0
- package/dist/flag-svg/PA.svg +1 -0
- package/dist/flag-svg/PE.svg +1 -0
- package/dist/flag-svg/PF.svg +1 -0
- package/dist/flag-svg/PG.svg +1 -0
- package/dist/flag-svg/PH.svg +1 -0
- package/dist/flag-svg/PK.svg +1 -0
- package/dist/flag-svg/PL.svg +1 -0
- package/dist/flag-svg/PM.svg +1 -0
- package/dist/flag-svg/PN.svg +1 -0
- package/dist/flag-svg/PR.svg +1 -0
- package/dist/flag-svg/PS.svg +1 -0
- package/dist/flag-svg/PT.svg +1 -0
- package/dist/flag-svg/PW.svg +1 -0
- package/dist/flag-svg/PY.svg +1 -0
- package/dist/flag-svg/QA.svg +1 -0
- package/dist/flag-svg/RE.svg +1 -0
- package/dist/flag-svg/RO.svg +1 -0
- package/dist/flag-svg/RS.svg +1 -0
- package/dist/flag-svg/RU.svg +1 -0
- package/dist/flag-svg/RW.svg +1 -0
- package/dist/flag-svg/SA.svg +1 -0
- package/dist/flag-svg/SB.svg +1 -0
- package/dist/flag-svg/SC.svg +1 -0
- package/dist/flag-svg/SD.svg +1 -0
- package/dist/flag-svg/SE.svg +1 -0
- package/dist/flag-svg/SG.svg +1 -0
- package/dist/flag-svg/SH.svg +1 -0
- package/dist/flag-svg/SI.svg +1 -0
- package/dist/flag-svg/SJ.svg +1 -0
- package/dist/flag-svg/SK.svg +1 -0
- package/dist/flag-svg/SL.svg +1 -0
- package/dist/flag-svg/SM.svg +1 -0
- package/dist/flag-svg/SN.svg +1 -0
- package/dist/flag-svg/SO.svg +1 -0
- package/dist/flag-svg/SR.svg +1 -0
- package/dist/flag-svg/SS.svg +1 -0
- package/dist/flag-svg/ST.svg +1 -0
- package/dist/flag-svg/SV.svg +1 -0
- package/dist/flag-svg/SX.svg +1 -0
- package/dist/flag-svg/SY.svg +1 -0
- package/dist/flag-svg/SZ.svg +1 -0
- package/dist/flag-svg/TA.svg +1 -0
- package/dist/flag-svg/TC.svg +1 -0
- package/dist/flag-svg/TD.svg +1 -0
- package/dist/flag-svg/TF.svg +1 -0
- package/dist/flag-svg/TG.svg +1 -0
- package/dist/flag-svg/TH.svg +1 -0
- package/dist/flag-svg/TJ.svg +1 -0
- package/dist/flag-svg/TK.svg +1 -0
- package/dist/flag-svg/TL.svg +1 -0
- package/dist/flag-svg/TM.svg +1 -0
- package/dist/flag-svg/TN.svg +1 -0
- package/dist/flag-svg/TO.svg +1 -0
- package/dist/flag-svg/TR.svg +1 -0
- package/dist/flag-svg/TT.svg +1 -0
- package/dist/flag-svg/TV.svg +1 -0
- package/dist/flag-svg/TW.svg +1 -0
- package/dist/flag-svg/TZ.svg +1 -0
- package/dist/flag-svg/UA.svg +1 -0
- package/dist/flag-svg/UG.svg +1 -0
- package/dist/flag-svg/UM.svg +1 -0
- package/dist/flag-svg/US.svg +1 -0
- package/dist/flag-svg/UY.svg +1 -0
- package/dist/flag-svg/UZ.svg +1 -0
- package/dist/flag-svg/VA.svg +1 -0
- package/dist/flag-svg/VC.svg +1 -0
- package/dist/flag-svg/VE.svg +1 -0
- package/dist/flag-svg/VG.svg +1 -0
- package/dist/flag-svg/VI.svg +1 -0
- package/dist/flag-svg/VN.svg +1 -0
- package/dist/flag-svg/VU.svg +1 -0
- package/dist/flag-svg/WF.svg +1 -0
- package/dist/flag-svg/WS.svg +1 -0
- package/dist/flag-svg/XK.svg +1 -0
- package/dist/flag-svg/YE.svg +1 -0
- package/dist/flag-svg/YT.svg +1 -0
- package/dist/flag-svg/ZA.svg +1 -0
- package/dist/flag-svg/ZM.svg +1 -0
- package/dist/flag-svg/ZW.svg +1 -0
- package/dist/flags.d.ts +27 -0
- package/dist/flags.d.ts.map +1 -0
- package/dist/flags.js +289 -0
- package/dist/flags.js.map +1 -0
- package/dist/immigration/visa-travel.d.ts +9 -0
- package/dist/immigration/visa-travel.d.ts.map +1 -0
- package/dist/immigration/visa-travel.js +36963 -0
- package/dist/immigration/visa-travel.js.map +1 -0
- package/dist/index.d.ts +31 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -43
- package/dist/index.js.map +1 -1
- package/dist/list-of-countries.js +2 -5
- package/dist/list-of-countries.js.map +1 -1
- package/dist/mercator-hash.js +2 -5
- package/dist/mercator-hash.js.map +1 -1
- package/dist/rankings/legatum_2023.d.ts +18 -0
- package/dist/rankings/legatum_2023.d.ts.map +1 -0
- package/dist/rankings/legatum_2023.js +2675 -0
- package/dist/rankings/legatum_2023.js.map +1 -0
- package/dist/three-to-two.js +1 -4
- package/dist/three-to-two.js.map +1 -1
- package/dist/two-to-three.js +1 -4
- package/dist/two-to-three.js.map +1 -1
- package/package.json +29 -6
package/README.md
CHANGED
|
@@ -173,6 +173,153 @@ Object mapping 3-digit ISO codes to size scale factors for visualization.
|
|
|
173
173
|
countrySizeScales["USA"]; // 300
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
+
## 🚩 Flag SVGs
|
|
177
|
+
|
|
178
|
+
National Metadata now includes high-quality SVG flags for all countries! The package exports flag utilities and includes all SVG files, optimized for web applications.
|
|
179
|
+
|
|
180
|
+
### Flag Functions
|
|
181
|
+
|
|
182
|
+
#### `getFlagPath(countryCode: string): string`
|
|
183
|
+
|
|
184
|
+
Returns the path to the flag SVG file for use in your bundler.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { getFlagPath } from "national-metadata";
|
|
188
|
+
|
|
189
|
+
getFlagPath("US"); // "national-metadata/dist/flag-svg/US.svg"
|
|
190
|
+
getFlagPath("fr"); // "national-metadata/dist/flag-svg/FR.svg" (case-insensitive)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### `getFlagFilename(countryCode: string): string`
|
|
194
|
+
|
|
195
|
+
Returns just the filename of the flag.
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import { getFlagFilename } from "national-metadata";
|
|
199
|
+
|
|
200
|
+
getFlagFilename("US"); // "US.svg"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### `hasFlagForCountry(countryCode: string): boolean`
|
|
204
|
+
|
|
205
|
+
Check if a flag exists for a given country code.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { hasFlagForCountry } from "national-metadata";
|
|
209
|
+
|
|
210
|
+
hasFlagForCountry("US"); // true
|
|
211
|
+
hasFlagForCountry("XX"); // false
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Flag Data Exports
|
|
215
|
+
|
|
216
|
+
#### `flagFilenames`
|
|
217
|
+
|
|
218
|
+
Object mapping country codes to flag filenames.
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import { flagFilenames } from "national-metadata";
|
|
222
|
+
|
|
223
|
+
flagFilenames["US"]; // "US.svg"
|
|
224
|
+
Object.keys(flagFilenames).length; // 260+ flags available
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### `availableFlagCodes`
|
|
228
|
+
|
|
229
|
+
Array of all country codes that have flags.
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import { availableFlagCodes } from "national-metadata";
|
|
233
|
+
|
|
234
|
+
availableFlagCodes; // ["AC", "AD", "AE", "AF", ...]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Using Flags in React/Next.js
|
|
238
|
+
|
|
239
|
+
For React and Next.js applications, you can import flag SVGs directly:
|
|
240
|
+
|
|
241
|
+
#### Option 1: Direct Import (Recommended for Modern Bundlers)
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { country_to_code } from "national-metadata";
|
|
245
|
+
|
|
246
|
+
// In your component
|
|
247
|
+
<img
|
|
248
|
+
src={
|
|
249
|
+
new URL(
|
|
250
|
+
`../node_modules/national-metadata/dist/flag-svg/${
|
|
251
|
+
country_to_code[city.country]
|
|
252
|
+
}.svg`,
|
|
253
|
+
import.meta.url
|
|
254
|
+
).href
|
|
255
|
+
}
|
|
256
|
+
alt={`${city.country} flag`}
|
|
257
|
+
className="w-12 h-12"
|
|
258
|
+
/>;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### Option 2: Next.js Public Folder (Copy to Public)
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Copy flags to your public folder
|
|
265
|
+
cp -r node_modules/national-metadata/dist/flag-svg public/flags
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Then use in your component:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { country_to_code } from "national-metadata";
|
|
272
|
+
|
|
273
|
+
<img
|
|
274
|
+
src={`/flags/${country_to_code[city.country]}.svg`}
|
|
275
|
+
alt={`${city.country} flag`}
|
|
276
|
+
className="w-12 h-12"
|
|
277
|
+
/>;
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Option 3: Webpack/Vite with Explicit Imports
|
|
281
|
+
|
|
282
|
+
For Vite or modern bundlers:
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
// Create a flag component
|
|
286
|
+
import { getFlagFilename } from "national-metadata";
|
|
287
|
+
|
|
288
|
+
interface FlagProps {
|
|
289
|
+
countryCode: string;
|
|
290
|
+
className?: string;
|
|
291
|
+
alt?: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function Flag({ countryCode, className, alt }: FlagProps) {
|
|
295
|
+
// Dynamic import for tree-shaking
|
|
296
|
+
const flagSrc = `/node_modules/national-metadata/dist/flag-svg/${countryCode.toUpperCase()}.svg`;
|
|
297
|
+
|
|
298
|
+
return (
|
|
299
|
+
<img
|
|
300
|
+
src={flagSrc}
|
|
301
|
+
alt={alt || `${countryCode} flag`}
|
|
302
|
+
className={className}
|
|
303
|
+
/>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Tree-Shaking Support
|
|
309
|
+
|
|
310
|
+
This package is fully optimized for tree-shaking. Only the functions and data you import will be included in your bundle:
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// This only bundles the flag utilities, not all country data
|
|
314
|
+
import { getFlagPath, hasFlagForCountry } from "national-metadata";
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
The package uses:
|
|
318
|
+
|
|
319
|
+
- `"sideEffects": false` for aggressive tree-shaking
|
|
320
|
+
- ES Modules for optimal bundler support
|
|
321
|
+
- Separate flag utilities to minimize bundle size
|
|
322
|
+
|
|
176
323
|
## TypeScript Support
|
|
177
324
|
|
|
178
325
|
Full TypeScript support with exported types:
|
|
@@ -186,6 +333,7 @@ import type {
|
|
|
186
333
|
CountryName,
|
|
187
334
|
ThreeDigitCode,
|
|
188
335
|
TwoDigitCode,
|
|
336
|
+
FlagCountryCode,
|
|
189
337
|
} from "national-metadata";
|
|
190
338
|
|
|
191
339
|
// Country interface
|
|
@@ -198,6 +346,7 @@ interface Country {
|
|
|
198
346
|
// Type-safe country codes
|
|
199
347
|
type CountryCode = keyof typeof code_to_country;
|
|
200
348
|
type CountryName = keyof typeof country_to_code;
|
|
349
|
+
type FlagCountryCode = keyof typeof flagFilenames; // All valid flag codes
|
|
201
350
|
```
|
|
202
351
|
|
|
203
352
|
## Use Cases
|
|
@@ -260,6 +409,262 @@ function normalizeCountryCode(code: string): string | null {
|
|
|
260
409
|
}
|
|
261
410
|
```
|
|
262
411
|
|
|
412
|
+
## 🏙️ City Data
|
|
413
|
+
|
|
414
|
+
National Metadata includes comprehensive city slug data for easy integration with city-based applications.
|
|
415
|
+
|
|
416
|
+
### City Functions
|
|
417
|
+
|
|
418
|
+
#### `getCitySlugs(): string[]`
|
|
419
|
+
|
|
420
|
+
Returns array of all city slugs (1300+ cities).
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
import { getCitySlugs } from "national-metadata";
|
|
424
|
+
|
|
425
|
+
const cities = getCitySlugs();
|
|
426
|
+
// ["lisbon", "berlin", "tokyo", "new-york-city-ny", ...]
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
#### `getCityCountrySlugs(): string[]`
|
|
430
|
+
|
|
431
|
+
Returns array of city slugs with country information (format: `city-country`).
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
import { getCityCountrySlugs } from "national-metadata";
|
|
435
|
+
|
|
436
|
+
const citiesWithCountries = getCityCountrySlugs();
|
|
437
|
+
// ["lisbon-portugal", "berlin-germany", "tokyo-japan", ...]
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
#### `isCitySlugValid(slug: string): boolean`
|
|
441
|
+
|
|
442
|
+
Validates if a city slug exists in the database.
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
import { isCitySlugValid } from "national-metadata";
|
|
446
|
+
|
|
447
|
+
isCitySlugValid("tokyo"); // true
|
|
448
|
+
isCitySlugValid("fake-city"); // false
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### `isCityCountrySlugValid(slug: string): boolean`
|
|
452
|
+
|
|
453
|
+
Validates if a city-country slug exists.
|
|
454
|
+
|
|
455
|
+
```typescript
|
|
456
|
+
import { isCityCountrySlugValid } from "national-metadata";
|
|
457
|
+
|
|
458
|
+
isCityCountrySlugValid("tokyo-japan"); // true
|
|
459
|
+
isCityCountrySlugValid("tokyo-china"); // false
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### City Data Exports
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
import { city_slugs, city_country_slugs } from "national-metadata";
|
|
466
|
+
|
|
467
|
+
// Array of 1300+ city slugs
|
|
468
|
+
city_slugs; // ["lisbon", "berlin", "tokyo", ...]
|
|
469
|
+
|
|
470
|
+
// Array of 1300+ city-country slugs
|
|
471
|
+
city_country_slugs; // ["lisbon-portugal", "berlin-germany", ...]
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## ✈️ Immigration & Visa Data
|
|
475
|
+
|
|
476
|
+
Comprehensive visa requirements data for all countries (updated Q3 2024).
|
|
477
|
+
|
|
478
|
+
### Visa Functions
|
|
479
|
+
|
|
480
|
+
#### `getVisaRequirements(countryCode: string): VisaTravel | undefined`
|
|
481
|
+
|
|
482
|
+
Gets all visa information for a country.
|
|
483
|
+
|
|
484
|
+
```typescript
|
|
485
|
+
import { getVisaRequirements } from "national-metadata";
|
|
486
|
+
|
|
487
|
+
const usVisa = getVisaRequirements("US");
|
|
488
|
+
// {
|
|
489
|
+
// country_code: "US",
|
|
490
|
+
// visa_free: ["Canada", "Mexico", ...],
|
|
491
|
+
// visa_on_arrival: [...],
|
|
492
|
+
// e_visa: [...],
|
|
493
|
+
// visa_required: [...]
|
|
494
|
+
// }
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
#### `getVisaFreeCountries(countryCode: string): string[] | undefined`
|
|
498
|
+
|
|
499
|
+
Gets list of countries that don't require visa.
|
|
500
|
+
|
|
501
|
+
```typescript
|
|
502
|
+
import { getVisaFreeCountries } from "national-metadata";
|
|
503
|
+
|
|
504
|
+
const visaFree = getVisaFreeCountries("US");
|
|
505
|
+
// ["Canada", "Mexico", "United Kingdom", ...]
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### `getVisaOnArrivalCountries(countryCode: string): string[] | undefined`
|
|
509
|
+
|
|
510
|
+
Gets list of countries offering visa on arrival.
|
|
511
|
+
|
|
512
|
+
```typescript
|
|
513
|
+
import { getVisaOnArrivalCountries } from "national-metadata";
|
|
514
|
+
|
|
515
|
+
const visaOnArrival = getVisaOnArrivalCountries("US");
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
#### `getEVisaCountries(countryCode: string): string[] | undefined`
|
|
519
|
+
|
|
520
|
+
Gets list of countries offering e-visa.
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
import { getEVisaCountries } from "national-metadata";
|
|
524
|
+
|
|
525
|
+
const eVisa = getEVisaCountries("US");
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
#### `getVisaRequiredCountries(countryCode: string): string[] | undefined`
|
|
529
|
+
|
|
530
|
+
Gets list of countries requiring visa.
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
import { getVisaRequiredCountries } from "national-metadata";
|
|
534
|
+
|
|
535
|
+
const visaRequired = getVisaRequiredCountries("US");
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### Visa Data Exports
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
import { visa_travel, type VisaTravel } from "national-metadata";
|
|
542
|
+
|
|
543
|
+
// Record mapping country codes to visa requirements
|
|
544
|
+
visa_travel["US"]; // Full visa data for United States
|
|
545
|
+
|
|
546
|
+
// TypeScript interface
|
|
547
|
+
interface VisaTravel {
|
|
548
|
+
country_code: string;
|
|
549
|
+
e_visa?: string[];
|
|
550
|
+
visa_on_arrival?: string[];
|
|
551
|
+
visa_required?: string[];
|
|
552
|
+
visa_free?: string[];
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
## 📊 Legatum Prosperity Index 2023
|
|
557
|
+
|
|
558
|
+
Access comprehensive prosperity rankings data from the Legatum Institute's 2023 Prosperity Index.
|
|
559
|
+
|
|
560
|
+
### Legatum Functions
|
|
561
|
+
|
|
562
|
+
#### `getLegatumData(): Legatum2023[]`
|
|
563
|
+
|
|
564
|
+
Returns complete Legatum prosperity rankings.
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
import { getLegatumData } from "national-metadata";
|
|
568
|
+
|
|
569
|
+
const allRankings = getLegatumData();
|
|
570
|
+
// Array of 167 countries with 12 prosperity pillars
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### `getLegatumRankingByCountry(countryName: string): Legatum2023 | undefined`
|
|
574
|
+
|
|
575
|
+
Gets prosperity ranking for a specific country.
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
import { getLegatumRankingByCountry } from "national-metadata";
|
|
579
|
+
|
|
580
|
+
const denmark = getLegatumRankingByCountry("Denmark");
|
|
581
|
+
// {
|
|
582
|
+
// country: "Denmark",
|
|
583
|
+
// overall: 1,
|
|
584
|
+
// safety_and_security: 6,
|
|
585
|
+
// personal_freedom: 2,
|
|
586
|
+
// governance: 3,
|
|
587
|
+
// social_capital: 1,
|
|
588
|
+
// investment_environment: 8,
|
|
589
|
+
// enterprise_conditions: 8,
|
|
590
|
+
// infrastructure_and_market_access: 9,
|
|
591
|
+
// economic_quality: 7,
|
|
592
|
+
// living_conditions: 2,
|
|
593
|
+
// health: 16,
|
|
594
|
+
// education: 5,
|
|
595
|
+
// natural_environment: 5
|
|
596
|
+
// }
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
#### `getLegatumTopCountries(limit?: number): Legatum2023[]`
|
|
600
|
+
|
|
601
|
+
Gets top N countries by prosperity ranking (default 10).
|
|
602
|
+
|
|
603
|
+
```typescript
|
|
604
|
+
import { getLegatumTopCountries } from "national-metadata";
|
|
605
|
+
|
|
606
|
+
const top10 = getLegatumTopCountries();
|
|
607
|
+
const top5 = getLegatumTopCountries(5);
|
|
608
|
+
// Returns top ranked countries
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
#### `getLegatumCountriesByOverallRank(minRank: number, maxRank: number): Legatum2023[]`
|
|
612
|
+
|
|
613
|
+
Gets countries within a rank range.
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
import { getLegatumCountriesByOverallRank } from "national-metadata";
|
|
617
|
+
|
|
618
|
+
const topTier = getLegatumCountriesByOverallRank(1, 20);
|
|
619
|
+
// Returns countries ranked 1-20
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### Legatum Data Exports
|
|
623
|
+
|
|
624
|
+
```typescript
|
|
625
|
+
import { legatum_2023, type Legatum2023 } from "national-metadata";
|
|
626
|
+
|
|
627
|
+
// Array of all country rankings
|
|
628
|
+
legatum_2023; // 167 countries
|
|
629
|
+
|
|
630
|
+
// TypeScript interface
|
|
631
|
+
interface Legatum2023 {
|
|
632
|
+
country: string;
|
|
633
|
+
overall: number;
|
|
634
|
+
safety_and_security: number;
|
|
635
|
+
personal_freedom: number;
|
|
636
|
+
governance: number;
|
|
637
|
+
social_capital: number;
|
|
638
|
+
investment_environment: number;
|
|
639
|
+
enterprise_conditions: number;
|
|
640
|
+
infrastructure_and_market_access: number;
|
|
641
|
+
economic_quality: number;
|
|
642
|
+
living_conditions: number;
|
|
643
|
+
health: number;
|
|
644
|
+
education: number;
|
|
645
|
+
natural_environment: number;
|
|
646
|
+
}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
### Legatum Index Pillars
|
|
650
|
+
|
|
651
|
+
The Legatum Prosperity Index measures prosperity across 12 pillars:
|
|
652
|
+
|
|
653
|
+
1. **Safety & Security**: Personal and national security
|
|
654
|
+
2. **Personal Freedom**: Individual liberties and rights
|
|
655
|
+
3. **Governance**: Effective and accountable governance
|
|
656
|
+
4. **Social Capital**: Social cohesion and engagement
|
|
657
|
+
5. **Investment Environment**: Protection of investors and financial infrastructure
|
|
658
|
+
6. **Enterprise Conditions**: Business environment and competition
|
|
659
|
+
7. **Infrastructure & Market Access**: Physical and digital infrastructure
|
|
660
|
+
8. **Economic Quality**: Economic growth and opportunity
|
|
661
|
+
9. **Living Conditions**: Material wellbeing and housing
|
|
662
|
+
10. **Health**: Physical and mental health outcomes
|
|
663
|
+
11. **Education**: Access to quality education
|
|
664
|
+
12. **Natural Environment**: Environmental quality and protection
|
|
665
|
+
|
|
666
|
+
Lower numbers indicate better rankings (1 = best).
|
|
667
|
+
|
|
263
668
|
## Contributing
|
|
264
669
|
|
|
265
670
|
We welcome contributions! Please see our contributing guidelines for more details.
|
|
@@ -270,7 +675,28 @@ MIT License - see LICENSE file for details.
|
|
|
270
675
|
|
|
271
676
|
## Changelog
|
|
272
677
|
|
|
273
|
-
###
|
|
678
|
+
### v0.1.2
|
|
679
|
+
|
|
680
|
+
- **NEW**: City data exports - 1300+ city slugs and city-country slugs
|
|
681
|
+
- **NEW**: City utility functions: `getCitySlugs`, `getCityCountrySlugs`, `isCitySlugValid`, `isCityCountrySlugValid`
|
|
682
|
+
- **NEW**: Immigration & Visa data - Comprehensive visa requirements for all countries (Q3 2024)
|
|
683
|
+
- **NEW**: Visa utility functions: `getVisaRequirements`, `getVisaFreeCountries`, `getVisaOnArrivalCountries`, `getEVisaCountries`, `getVisaRequiredCountries`
|
|
684
|
+
- **NEW**: Legatum Prosperity Index 2023 - Rankings for 167 countries across 12 prosperity pillars
|
|
685
|
+
- **NEW**: Legatum utility functions: `getLegatumData`, `getLegatumRankingByCountry`, `getLegatumTopCountries`, `getLegatumCountriesByOverallRank`
|
|
686
|
+
- **NEW**: TypeScript types: `VisaTravel`, `Legatum2023`
|
|
687
|
+
- **IMPROVED**: Expanded package capabilities for travel, immigration, and prosperity research
|
|
688
|
+
|
|
689
|
+
### v0.1.2
|
|
690
|
+
|
|
691
|
+
- **NEW**: Flag SVGs for 260+ countries included in package
|
|
692
|
+
- **NEW**: Flag utility functions: `getFlagPath`, `getFlagFilename`, `hasFlagForCountry`
|
|
693
|
+
- **NEW**: Flag data exports: `flagFilenames`, `availableFlagCodes`
|
|
694
|
+
- **NEW**: Full tree-shaking support with `sideEffects: false`
|
|
695
|
+
- **NEW**: ES Modules support for better bundler optimization
|
|
696
|
+
- **IMPROVED**: TypeScript types with new `FlagCountryCode` type
|
|
697
|
+
- **IMPROVED**: Package exports map for better module resolution
|
|
698
|
+
|
|
699
|
+
### v0.1.1
|
|
274
700
|
|
|
275
701
|
- Initial release with comprehensive country data
|
|
276
702
|
- ISO code conversion utilities
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"city-country-slugs.d.ts","sourceRoot":"","sources":["../../src/cities/city-country-slugs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAg0CtC,CAAC"}
|