national-metadata 0.1.3 → 0.1.4

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
@@ -15,6 +15,9 @@ import {
15
15
  helloWorld,
16
16
  getCountryNameFromCode,
17
17
  convertTwoToThree,
18
+ getCountryMetadata,
19
+ getTaxationData,
20
+ getZeroTaxCountries,
18
21
  } from "national-metadata";
19
22
 
20
23
  // Hello World function
@@ -23,6 +26,20 @@ console.log(helloWorld()); // "Mr World Wide is here"
23
26
  // Convert ISO codes
24
27
  console.log(getCountryNameFromCode("US")); // "United States"
25
28
  console.log(convertTwoToThree("US")); // "USA"
29
+
30
+ // Get detailed country metadata
31
+ const usData = getCountryMetadata("US");
32
+ console.log(usData?.name_chinese); // "美国"
33
+ console.log(usData?.region); // "North America"
34
+
35
+ // Get taxation information
36
+ const usTax = getTaxationData("US");
37
+ console.log(usTax?.personal_income_tax_limit); // 37
38
+ console.log(usTax?.residence_threshold); // 183 days
39
+
40
+ // Find tax-friendly countries
41
+ const zeroTaxCountries = getZeroTaxCountries();
42
+ console.log(zeroTaxCountries.length); // Countries with no income tax
26
43
  ```
27
44
 
28
45
  ## API Reference
@@ -334,13 +351,37 @@ import type {
334
351
  ThreeDigitCode,
335
352
  TwoDigitCode,
336
353
  FlagCountryCode,
354
+ TaxationData,
355
+ TaxCreditOrDeduction,
356
+ AdditionalTax,
357
+ TaxDataHash,
358
+ VisaTravel,
359
+ Legatum2023,
337
360
  } from "national-metadata";
338
361
 
339
- // Country interface
362
+ // Country metadata interface
340
363
  interface Country {
341
- iso_two: string;
364
+ cost_score: number;
365
+ country: string;
366
+ country_code: string;
367
+ long_slug: string;
342
368
  name: string;
343
- continent: string;
369
+ name_chinese: string;
370
+ overall_score: number;
371
+ region: string;
372
+ short_slug: string;
373
+ slug: string;
374
+ }
375
+
376
+ // Taxation data interface
377
+ interface TaxationData {
378
+ code: string;
379
+ slug: string;
380
+ zero_tax_system: boolean;
381
+ personal_income_tax_limit: number | undefined;
382
+ capital_percentage_limit: number | undefined;
383
+ residence_threshold?: number | null;
384
+ // ... many more fields
344
385
  }
345
386
 
346
387
  // Type-safe country codes
@@ -355,7 +396,12 @@ type FlagCountryCode = keyof typeof flagFilenames; // All valid flag codes
355
396
  - **Form Validation**: Validate country codes and names
356
397
  - **Data Normalization**: Convert between different ISO code formats
357
398
  - **Analytics**: Group data by continent using the country list
358
- - **Internationalization**: Display localized country names
399
+ - **Internationalization**: Display localized country names (including Chinese)
400
+ - **Tax Planning Tools**: Build calculators and comparison tools for international taxation
401
+ - **Digital Nomad Apps**: Help remote workers find tax-friendly destinations
402
+ - **Relocation Research**: Compare countries by cost scores, tax rates, and prosperity rankings
403
+ - **Immigration Platforms**: Integrate visa and tax information for comprehensive country profiles
404
+ - **Business Intelligence**: Analyze corporate tax rates and investment environments globally
359
405
 
360
406
  ## Examples
361
407
 
@@ -409,6 +455,95 @@ function normalizeCountryCode(code: string): string | null {
409
455
  }
410
456
  ```
411
457
 
458
+ ### Tax-Friendly Country Finder
459
+
460
+ ```typescript
461
+ import {
462
+ getZeroTaxCountries,
463
+ getTerritorialTaxCountries,
464
+ getCountryMetadata,
465
+ getVisaFreeCountries,
466
+ } from "national-metadata";
467
+
468
+ // Find tax-friendly countries with high quality of life
469
+ function findBestTaxDestinations(fromCountryCode: string) {
470
+ // Get countries with favorable tax systems
471
+ const zeroTax = getZeroTaxCountries();
472
+ const territorial = getTerritorialTaxCountries();
473
+ const allFavorable = [...zeroTax, ...territorial];
474
+
475
+ // Get visa-free destinations
476
+ const visaFree = getVisaFreeCountries(fromCountryCode) || [];
477
+
478
+ // Combine tax and metadata
479
+ return allFavorable
480
+ .map((taxData) => {
481
+ const metadata = getCountryMetadata(taxData.code);
482
+ return {
483
+ name: metadata?.name || taxData.code,
484
+ code: taxData.code,
485
+ region: metadata?.region,
486
+ overallScore: metadata?.overall_score,
487
+ costScore: metadata?.cost_score,
488
+ taxSystem: taxData.zero_tax_system ? "Zero Tax" : "Territorial",
489
+ personalTaxRate: taxData.personal_income_tax_limit || 0,
490
+ visaFree: visaFree.includes(metadata?.name || ""),
491
+ };
492
+ })
493
+ .filter((country) => country.overallScore && country.overallScore > 3)
494
+ .sort((a, b) => (b.overallScore || 0) - (a.overallScore || 0));
495
+ }
496
+
497
+ // Usage
498
+ const destinations = findBestTaxDestinations("US");
499
+ console.log("Best tax destinations:", destinations);
500
+ ```
501
+
502
+ ### Country Comparison Tool
503
+
504
+ ```typescript
505
+ import {
506
+ getCountryMetadata,
507
+ getTaxationData,
508
+ getLegatumRankingByCountry,
509
+ } from "national-metadata";
510
+
511
+ function compareCountries(codes: string[]) {
512
+ return codes.map((code) => {
513
+ const metadata = getCountryMetadata(code);
514
+ const taxData = getTaxationData(code);
515
+ const prosperity = getLegatumRankingByCountry(metadata?.name || "");
516
+
517
+ return {
518
+ country: metadata?.name,
519
+ region: metadata?.region,
520
+ scores: {
521
+ cost: metadata?.cost_score,
522
+ overall: metadata?.overall_score,
523
+ prosperity: prosperity?.overall,
524
+ },
525
+ taxation: {
526
+ personalIncomeTax: taxData?.personal_income_tax_limit,
527
+ capitalGainsTax: taxData?.capital_percentage_limit,
528
+ corporateTax: taxData?.corporate_tax_rate,
529
+ residenceThreshold: taxData?.residence_threshold,
530
+ zeroTaxSystem: taxData?.zero_tax_system,
531
+ },
532
+ quality: {
533
+ safety: prosperity?.safety_and_security,
534
+ personalFreedom: prosperity?.personal_freedom,
535
+ education: prosperity?.education,
536
+ health: prosperity?.health,
537
+ },
538
+ };
539
+ });
540
+ }
541
+
542
+ // Usage
543
+ const comparison = compareCountries(["US", "SG", "PT", "AE"]);
544
+ console.log("Country comparison:", comparison);
545
+ ```
546
+
412
547
  ## 🏙️ City Data
413
548
 
414
549
  National Metadata includes comprehensive city slug data for easy integration with city-based applications.
@@ -665,6 +800,227 @@ The Legatum Prosperity Index measures prosperity across 12 pillars:
665
800
 
666
801
  Lower numbers indicate better rankings (1 = best).
667
802
 
803
+ ## 🌐 Country Metadata
804
+
805
+ Detailed country information including scores, regions, and Chinese translations.
806
+
807
+ ### Country Metadata Functions
808
+
809
+ #### `getCountryMetadata(countryCode: string): Country | undefined`
810
+
811
+ Gets comprehensive metadata for a country by its 2-digit ISO code.
812
+
813
+ ```typescript
814
+ import { getCountryMetadata } from "national-metadata";
815
+
816
+ const usData = getCountryMetadata("US");
817
+ // {
818
+ // cost_score: 3.02,
819
+ // country: "United States",
820
+ // country_code: "US",
821
+ // long_slug: "united-states",
822
+ // name: "United States",
823
+ // name_chinese: "美国",
824
+ // overall_score: 3.33,
825
+ // region: "North America",
826
+ // short_slug: "united-states",
827
+ // slug: "united-states"
828
+ // }
829
+ ```
830
+
831
+ #### `getAllCountryMetadata(): { [key: string]: Country }`
832
+
833
+ Returns all country metadata as an object keyed by country code.
834
+
835
+ ```typescript
836
+ import { getAllCountryMetadata } from "national-metadata";
837
+
838
+ const allCountries = getAllCountryMetadata();
839
+ // { "US": {...}, "GB": {...}, ... }
840
+ ```
841
+
842
+ #### `getCountryBySlug(slug: string): Country | undefined`
843
+
844
+ Finds a country by any of its slug variants.
845
+
846
+ ```typescript
847
+ import { getCountryBySlug } from "national-metadata";
848
+
849
+ const usa = getCountryBySlug("united-states");
850
+ const uk = getCountryBySlug("united-kingdom");
851
+ ```
852
+
853
+ #### `getCountriesByRegion(region: string): Country[]`
854
+
855
+ Gets all countries in a specific region.
856
+
857
+ ```typescript
858
+ import { getCountriesByRegion } from "national-metadata";
859
+
860
+ const europeanCountries = getCountriesByRegion("Europe");
861
+ const asianCountries = getCountriesByRegion("Asia");
862
+ // Returns array of Country objects
863
+ ```
864
+
865
+ ### Country Metadata Exports
866
+
867
+ ```typescript
868
+ import { countries, type Country } from "national-metadata";
869
+
870
+ // Object mapping country codes to detailed metadata
871
+ countries["JP"]; // Japan's full metadata
872
+
873
+ // TypeScript interface
874
+ interface Country {
875
+ cost_score: number;
876
+ country: string;
877
+ country_code: string;
878
+ long_slug: string;
879
+ name: string;
880
+ name_chinese: string;
881
+ overall_score: number;
882
+ region: string;
883
+ short_slug: string;
884
+ slug: string;
885
+ }
886
+ ```
887
+
888
+ Available regions: `"Africa"`, `"Asia"`, `"Europe"`, `"North America"`, `"Latin America"`, `"Oceania"`, `"Antarctica"`, `"Caribbean"`
889
+
890
+ ## 💰 Taxation Data
891
+
892
+ Comprehensive tax information for countries worldwide, including personal income tax, capital gains, wealth tax, and more.
893
+
894
+ ### Taxation Functions
895
+
896
+ #### `getTaxationData(countryCode: string): TaxationData | undefined`
897
+
898
+ Gets complete taxation information for a country.
899
+
900
+ ```typescript
901
+ import { getTaxationData } from "national-metadata";
902
+
903
+ const usTax = getTaxationData("US");
904
+ // {
905
+ // code: "US",
906
+ // slug: "united-states",
907
+ // zero_tax_system: false,
908
+ // personal_income_tax_limit: 37,
909
+ // capital_percentage_limit: 20,
910
+ // residence_threshold: 183,
911
+ // corporate_tax_rate: 21,
912
+ // notes: [...],
913
+ // ...
914
+ // }
915
+ ```
916
+
917
+ #### `getAllTaxationData(): { [key: string]: TaxationData }`
918
+
919
+ Returns all taxation data as an object keyed by country code.
920
+
921
+ ```typescript
922
+ import { getAllTaxationData } from "national-metadata";
923
+
924
+ const allTaxData = getAllTaxationData();
925
+ ```
926
+
927
+ #### `getTaxationDataBySlug(slug: string): TaxationData | undefined`
928
+
929
+ Finds taxation data by country slug.
930
+
931
+ ```typescript
932
+ import { getTaxationDataBySlug } from "national-metadata";
933
+
934
+ const singaporeTax = getTaxationDataBySlug("singapore");
935
+ ```
936
+
937
+ #### `getZeroTaxCountries(): TaxationData[]`
938
+
939
+ Gets all countries with zero income tax systems.
940
+
941
+ ```typescript
942
+ import { getZeroTaxCountries } from "national-metadata";
943
+
944
+ const taxHavens = getZeroTaxCountries();
945
+ // Returns countries like Monaco, UAE, Bahamas, etc.
946
+ ```
947
+
948
+ #### `getTerritorialTaxCountries(): TaxationData[]`
949
+
950
+ Gets all countries with territorial tax systems (only tax local income).
951
+
952
+ ```typescript
953
+ import { getTerritorialTaxCountries } from "national-metadata";
954
+
955
+ const territorialCountries = getTerritorialTaxCountries();
956
+ // Returns countries with territorial taxation
957
+ ```
958
+
959
+ ### Taxation Data Exports
960
+
961
+ ```typescript
962
+ import {
963
+ taxation_data,
964
+ type TaxationData,
965
+ type TaxCreditOrDeduction,
966
+ type AdditionalTax,
967
+ } from "national-metadata";
968
+
969
+ // Object mapping country codes to taxation data
970
+ taxation_data["SG"]; // Singapore's tax data
971
+
972
+ // TypeScript interfaces
973
+ interface TaxationData {
974
+ code: string;
975
+ slug: string;
976
+ zero_tax_system: boolean;
977
+ personal_income_tax_limit: number | undefined;
978
+ capital_percentage_limit: number | undefined;
979
+ residence_threshold?: number | null;
980
+ corporate_tax_rate?: number;
981
+ wealth_tax?: boolean;
982
+ inheritance_tax?: boolean;
983
+ value_added_tax_rate?: number;
984
+ government_tax_agency?: string;
985
+ notes: string[];
986
+ // ... and many more fields
987
+ }
988
+
989
+ interface TaxCreditOrDeduction {
990
+ title: string;
991
+ description: string;
992
+ url: string;
993
+ type: "rate" | "flat_amount" | "per_transaction";
994
+ class: "credit" | "deduction";
995
+ amount: number;
996
+ }
997
+
998
+ interface AdditionalTax {
999
+ threshold: string;
1000
+ name: string;
1001
+ rate: number;
1002
+ title: string;
1003
+ description: string;
1004
+ url: string;
1005
+ }
1006
+ ```
1007
+
1008
+ ### Tax Data Fields
1009
+
1010
+ The taxation data includes:
1011
+
1012
+ - **Personal Income Tax**: Maximum rates and system type
1013
+ - **Capital Gains Tax**: Rates and exemptions
1014
+ - **Corporate Tax**: Business taxation rates
1015
+ - **Wealth Tax**: Thresholds and percentages
1016
+ - **Inheritance Tax**: Estate and gift tax information
1017
+ - **VAT/Sales Tax**: Value-added tax rates
1018
+ - **Residence Threshold**: Days required for tax residency
1019
+ - **Withholding Tax**: Rates for residents and non-residents
1020
+ - **Tax System Type**: Worldwide, territorial, or citizenship-based
1021
+ - **Government Links**: Official tax agency websites
1022
+ - **Notes**: Important tax information and special cases
1023
+
668
1024
  ## Contributing
669
1025
 
670
1026
  We welcome contributions! Please see our contributing guidelines for more details.
@@ -675,6 +1031,16 @@ MIT License - see LICENSE file for details.
675
1031
 
676
1032
  ## Changelog
677
1033
 
1034
+ ### v0.1.3
1035
+
1036
+ - **NEW**: Country metadata - Comprehensive country information with scores, slugs, and Chinese translations
1037
+ - **NEW**: Country metadata functions: `getCountryMetadata`, `getAllCountryMetadata`, `getCountryBySlug`, `getCountriesByRegion`
1038
+ - **NEW**: Taxation data - Complete tax information for countries worldwide
1039
+ - **NEW**: Taxation functions: `getTaxationData`, `getAllTaxationData`, `getTaxationDataBySlug`, `getZeroTaxCountries`, `getTerritorialTaxCountries`
1040
+ - **NEW**: TypeScript types: `Country`, `TaxationData`, `TaxCreditOrDeduction`, `AdditionalTax`, `TaxDataHash`
1041
+ - **IMPROVED**: Enhanced Quick Start examples showing new metadata and taxation APIs
1042
+ - **IMPROVED**: Expanded package capabilities for tax planning, relocation research, and country comparison
1043
+
678
1044
  ### v0.1.2
679
1045
 
680
1046
  - **NEW**: City data exports - 1300+ city slugs and city-country slugs
@@ -0,0 +1,18 @@
1
+ export interface Country {
2
+ cost_score: number;
3
+ country: string;
4
+ country_code: string;
5
+ long_slug: string;
6
+ name: string;
7
+ name_chinese: string;
8
+ overall_score: number;
9
+ region: string;
10
+ short_slug: string;
11
+ slug: string;
12
+ }
13
+ interface CountryHash {
14
+ [key: string]: Country;
15
+ }
16
+ export declare const countries: CountryHash;
17
+ export {};
18
+ //# sourceMappingURL=countries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countries.d.ts","sourceRoot":"","sources":["../src/countries.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,WAAW;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,EAAE,WAqnFvB,CAAC"}