diff --git a/.eslintrc.js b/.eslintrc.js index da62299d..25a2bad1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,26 @@ -/* @flow */ - module.exports = { - extends: require.resolve( - "@krakenjs/grumbler-scripts/config/.eslintrc-browser" - ), + extends: + "./node_modules/@krakenjs/grumbler-scripts/config/.eslintrc-typescript.js", + + globals: { + __TEST__: true, + }, + + rules: { + "no-mixed-operators": "off", + // off for initial ts conversion + "@typescript-eslint/no-implicit-any-catch": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-base-to-string": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/prefer-for-of": "off", + + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + }, }; diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index fd4a46ef..00000000 --- a/.flowconfig +++ /dev/null @@ -1,15 +0,0 @@ -[ignore] -.*/node_modules/babel-plugin-flow-runtime -.*/node_modules/flow-runtime -.*/node_modules/npm -.*/node_modules/eslint-plugin-compat -.*/node_modules/resolve -.*/dist/module -[include] -node_modules/@krakenjs/grumbler-scripts/declarations.js -[libs] -flow-typed -[options] -module.name_mapper='^src\(.*\)$' -> '/src/\1' -experimental.const_params=false -esproposal.export_star_as=enable diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..9bf8100b --- /dev/null +++ b/babel.config.js @@ -0,0 +1,4 @@ +module.exports = { + extends: "@krakenjs/grumbler-scripts/config/.babelrc-browser", + presets: ["@krakenjs/grumbler-scripts/config/flow-ts-babel-preset"], +}; diff --git a/babel.config.json b/babel.config.json deleted file mode 100644 index c55c063b..00000000 --- a/babel.config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "@krakenjs/grumbler-scripts/config/.babelrc-browser" -} diff --git a/index.js b/index.ts similarity index 100% rename from index.js rename to index.ts diff --git a/package.json b/package.json index 3aaf8c2b..d98804ff 100644 --- a/package.json +++ b/package.json @@ -3,24 +3,26 @@ "version": "1.0.124", "description": "Utilities.", "main": "index.js", + "module": "dist/esm/index.js", + "types": "dist/types/index.d.ts", + "sideEffects": [ + "./src/styles/*.scss" + ], "scripts": { - "setup": "npm install && npm run flow-typed", - "lint": "eslint src/ *.js", - "flow-typed": "rm -rf ./flow-typed && flow-typed install", - "flow": "flow", - "karma": "cross-env NODE_ENV=test babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/karma start", - "babel": "babel src/ --out-dir dist/module", - "webpack": "babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress", + "build": "npm run babel && npm run webpack && npm run build:types", + "build:flow": "find ./dist -type f -not -path './node_modules/*' -name '*.d.ts' -exec sh -c 'flowgen --add-flow-header $1 -o ${1%.*.*}.js.flow' _ '{}' \\;", + "build:tsc": "tsc src/*.ts --outDir ./dist/esm --declaration --emitDeclarationOnly", + "build:types": "npm run build:tsc && npm run build:flow", + "webpack": "cross-env NODE_ENV=production babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress --output-path dist", + "babel": "cross-env NODE_ENV=production babel src/ --out-dir ./dist/esm/ --extensions .ts,.tsx", + "tsc": "tsc", "format": "prettier --write --ignore-unknown .", "format:check": "prettier --check .", - "test": "npm run format:check && npm run lint && npm run flow-typed && npm run flow", - "build": "npm run test && npm run babel && npm run webpack", - "release": "./publish.sh", - "release:patch": "./publish.sh patch", - "release:minor": "./publish.sh minor", - "release:major": "./publish.sh major", + "lint": "eslint --ext ts,tsx,js,jsx src/", "clean": "rimraf dist coverage", - "reinstall": "rimraf flow-typed && rimraf node_modules && npm install && flow-typed install", + "prerelease": "npm run clean && npm run build && git add dist && git commit -m 'ci: check in dist folder' || echo 'Nothing to distribute'", + "release": "standard-version", + "postrelease": "git push && git push --follow-tags && npm publish", "debug": "cross-env NODE_ENV=debug", "prepare": "husky install" }, @@ -45,11 +47,21 @@ "license": "Apache-2.0", "readmeFilename": "README.md", "devDependencies": { - "@krakenjs/grumbler-scripts": "^7.0.0", - "flow-bin": "0.129.0", + "@commitlint/cli": "^16.2.1", + "@commitlint/config-conventional": "^16.2.1", + "@krakenjs/grumbler-scripts": "^7.0.3", + "@types/webpack": "^5.28.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "c8": "^7.11.0", + "flowgen": "^1.16.0", + "happy-dom": "^2.55.0", "husky": "^8.0.1", "lint-staged": "^13.0.3", - "prettier": "2.7.1" + "prettier": "2.7.1", + "standard-version": "^9.3.2", + "ts-node": "^10.5.0", + "typescript": "4.8.4" }, "dependencies": { "hi-base32": "^0.5.0" diff --git a/src/apm.js b/src/apm.ts similarity index 96% rename from src/apm.js rename to src/apm.ts index d6a08618..ef21e9c6 100644 --- a/src/apm.js +++ b/src/apm.ts @@ -1,7 +1,4 @@ -/* @flow */ - import { FUNDING } from "./funding"; - export const APM_LIST = [ FUNDING.IDEAL, FUNDING.BANCONTACT, diff --git a/src/defaults.js b/src/defaults.ts similarity index 97% rename from src/defaults.js rename to src/defaults.ts index 25c8b4fe..55944fac 100644 --- a/src/defaults.js +++ b/src/defaults.ts @@ -1,9 +1,6 @@ -/* @flow */ - import { COUNTRY } from "./locale"; import { CURRENCY, INTENT, COMMIT, VAULT } from "./order"; import { COMPONENTS, DEBUG } from "./params"; - export const DEFAULT_COUNTRY = COUNTRY.US; export const DEFAULT_CURRENCY = CURRENCY.USD; export const DEFAULT_INTENT = INTENT.CAPTURE; diff --git a/src/env.js b/src/env.js deleted file mode 100644 index e1487774..00000000 --- a/src/env.js +++ /dev/null @@ -1,14 +0,0 @@ -/* @flow */ - -export const ENV = { - LOCAL: ("local": "local"), - STAGE: ("stage": "stage"), - SANDBOX: ("sandbox": "sandbox"), - PRODUCTION: ("production": "production"), - TEST: ("test": "test"), -}; - -export const MOBILE_ENV = { - ANDROID: ("android": "android"), - IOS: ("iOS": "iOS"), -}; diff --git a/src/env.ts b/src/env.ts new file mode 100644 index 00000000..1bf473b9 --- /dev/null +++ b/src/env.ts @@ -0,0 +1,11 @@ +export const ENV = { + LOCAL: "local" as const, + STAGE: "stage" as const, + SANDBOX: "sandbox" as const, + PRODUCTION: "production" as const, + TEST: "test" as const, +}; +export const MOBILE_ENV = { + ANDROID: "android" as const, + IOS: "iOS" as const, +}; diff --git a/src/error.js b/src/error.js deleted file mode 100644 index 05f37307..00000000 --- a/src/error.js +++ /dev/null @@ -1,5 +0,0 @@ -/* @flow */ - -export const ERROR_CODE = { - VALIDATION_ERROR: ("validation_error": "validation_error"), -}; diff --git a/src/error.ts b/src/error.ts new file mode 100644 index 00000000..c278b5ec --- /dev/null +++ b/src/error.ts @@ -0,0 +1,3 @@ +export const ERROR_CODE = { + VALIDATION_ERROR: "validation_error" as const, +}; diff --git a/src/fpti.js b/src/fpti.js deleted file mode 100644 index fcf5f875..00000000 --- a/src/fpti.js +++ /dev/null @@ -1,88 +0,0 @@ -/* @flow */ - -export const FPTI_KEY = { - FEED: ("feed_name": "feed_name"), - STATE: ("state_name": "state_name"), - EVENT_NAME: ("event_name": "event_name"), - TRANSITION: ("transition_name": "transition_name"), - PAGE: ("page_name": "page_name"), - BUTTON_TYPE: ("button_type": "button_type"), - SESSION_UID: ("page_session_id": "page_session_id"), - BUTTON_SESSION_UID: ("button_session_id": "button_session_id"), - TOKEN: ("token": "token"), - CONTEXT_ID: ("context_id": "context_id"), - CONTEXT_TYPE: ("context_type": "context_type"), - REFERER: ("referer_url": "referer_url"), - MERCHANT_DOMAIN: ("merchant_domain": "merchant_domain"), - PAY_ID: ("pay_id": "pay_id"), - SELLER_ID: ("seller_id": "seller_id"), - CLIENT_ID: ("client_id": "client_id"), - DATA_SOURCE: ("serverside_data_source": "serverside_data_source"), - BUTTON_SOURCE: ("button_source": "button_source"), - ERROR_CODE: ("ext_error_code": "ext_error_code"), - ERROR_DESC: ("ext_error_desc": "ext_error_desc"), - PAGE_LOAD_TIME: ("page_load_time": "page_load_time"), - EXPERIMENT_NAME: ("pxp_exp_id": "pxp_exp_id"), - TREATMENT_NAME: ("pxp_trtmnt_id": "pxp_trtmnt_id"), - TRANSITION_TIME: ("transition_time": "transition_time"), - FUNDING_LIST: ("eligible_payment_methods": "eligible_payment_methods"), - FUNDING_COUNT: ("eligible_payment_count": "eligible_payment_count"), - CHOSEN_FUNDING: ("selected_payment_method": "selected_payment_method"), - BUTTON_LAYOUT: ("button_layout": "button_layout"), - VERSION: ("checkoutjs_version": "checkoutjs_version"), - LOCALE: ("locale": "locale"), - BUYER_COUNTRY: ("buyer_cntry": "buyer_cntry"), - INTEGRATION_IDENTIFIER: ("integration_identifier": "integration_identifier"), - PARTNER_ATTRIBUTION_ID: ("bn_code": "bn_code"), - PAGE_TYPE: ("pp_placement": "pp_placement"), - SDK_NAME: ("sdk_name": "sdk_name"), - SDK_VERSION: ("sdk_version": "sdk_version"), - SDK_ENVIRONMENT: ("sdk_environment": "sdk_environment"), - MOBILE_APP_VERSION: ("mobile_app_version": "mobile_app_version"), - MOBILE_BUNDLE_IDENTIFIER: ("mapv": "mapv"), - USER_AGENT: ("user_agent": "user_agent"), - USER_ACTION: ("user_action": "user_action"), - CONTEXT_CORRID: ("context_correlation_id": "context_correlation_id"), - SDK_CACHE: ("sdk_cache": "sdk_cache"), - SDK_LOAD_TIME: ("sdk_load_time": "sdk_load_time"), - IS_VAULT: ("is_vault": "is_vault"), - DISABLE_FUNDING: ("disable_funding": "disable_funding"), - DISABLE_CARD: ("disable_card": "disable_card"), - RESPONSE_DURATION: ("response_duration": "response_duration"), - SDK_INTEGRATION_SOURCE: ("sdk_integration_source": "sdk_integration_source"), - PAYMENT_FLOW: ("payment_flow": "payment_flow"), - BUTTON_VERSION: ("button_version": "button_version"), - FI_LIST: ("fi_list": "fi_list"), - CHOSEN_FI_TYPE: ("chosen_fi_type": "chosen_fi_type"), - SELECTED_FI: - ("merchant_selected_funding_source": "merchant_selected_funding_source"), - POTENTIAL_PAYMENT_METHODS: - ("potential_payment_methods": "potential_payment_methods"), - PAY_NOW: ("pay_now": "pay_now"), - STICKINESS_ID: ("stickiness_id": "stickiness_id"), - TIMESTAMP: ("t": "t"), - OPTION_SELECTED: ("optsel": "optsel"), - USER_IDENTITY_METHOD: ("user_identity_method": "user_identity_method"), - FIELDS_COMPONENT_SESSION_ID: - ("fields_component_session_id": "fields_component_session_id"), - CPL_COMP_METRICS: ("cpl_comp_metrics": "cpl_comp_metrics"), - CPL_CHUNK_METRICS: ("cpl_chunk_metrics": "cpl_chunk_metrics"), - CPL_QUERY_METRICS: ("cpl_query_metrics": "cpl_query_metrics"), -}; - -export const FPTI_USER_ACTION = { - COMMIT: ("commit": "commit"), - CONTINUE: ("continue": "continue"), -}; - -export const FPTI_DATA_SOURCE = { - PAYMENTS_SDK: ("checkout": "checkout"), -}; - -export const FPTI_FEED = { - PAYMENTS_SDK: ("payments_sdk": "payments_sdk"), -}; - -export const FPTI_SDK_NAME = { - PAYMENTS_SDK: ("payments_sdk": "payments_sdk"), -}; diff --git a/src/fpti.ts b/src/fpti.ts new file mode 100644 index 00000000..65d70520 --- /dev/null +++ b/src/fpti.ts @@ -0,0 +1,79 @@ +export const FPTI_KEY = { + FEED: "feed_name" as const, + STATE: "state_name" as const, + EVENT_NAME: "event_name" as const, + TRANSITION: "transition_name" as const, + PAGE: "page_name" as const, + BUTTON_TYPE: "button_type" as const, + SESSION_UID: "page_session_id" as const, + BUTTON_SESSION_UID: "button_session_id" as const, + TOKEN: "token" as const, + CONTEXT_ID: "context_id" as const, + CONTEXT_TYPE: "context_type" as const, + REFERER: "referer_url" as const, + MERCHANT_DOMAIN: "merchant_domain" as const, + PAY_ID: "pay_id" as const, + SELLER_ID: "seller_id" as const, + CLIENT_ID: "client_id" as const, + DATA_SOURCE: "serverside_data_source" as const, + BUTTON_SOURCE: "button_source" as const, + ERROR_CODE: "ext_error_code" as const, + ERROR_DESC: "ext_error_desc" as const, + PAGE_LOAD_TIME: "page_load_time" as const, + EXPERIMENT_NAME: "pxp_exp_id" as const, + TREATMENT_NAME: "pxp_trtmnt_id" as const, + TRANSITION_TIME: "transition_time" as const, + FUNDING_LIST: "eligible_payment_methods" as const, + FUNDING_COUNT: "eligible_payment_count" as const, + CHOSEN_FUNDING: "selected_payment_method" as const, + BUTTON_LAYOUT: "button_layout" as const, + VERSION: "checkoutjs_version" as const, + LOCALE: "locale" as const, + BUYER_COUNTRY: "buyer_cntry" as const, + INTEGRATION_IDENTIFIER: "integration_identifier" as const, + PARTNER_ATTRIBUTION_ID: "bn_code" as const, + PAGE_TYPE: "pp_placement" as const, + SDK_NAME: "sdk_name" as const, + SDK_VERSION: "sdk_version" as const, + SDK_ENVIRONMENT: "sdk_environment" as const, + MOBILE_APP_VERSION: "mobile_app_version" as const, + MOBILE_BUNDLE_IDENTIFIER: "mapv" as const, + USER_AGENT: "user_agent" as const, + USER_ACTION: "user_action" as const, + CONTEXT_CORRID: "context_correlation_id" as const, + SDK_CACHE: "sdk_cache" as const, + SDK_LOAD_TIME: "sdk_load_time" as const, + IS_VAULT: "is_vault" as const, + DISABLE_FUNDING: "disable_funding" as const, + DISABLE_CARD: "disable_card" as const, + RESPONSE_DURATION: "response_duration" as const, + SDK_INTEGRATION_SOURCE: "sdk_integration_source" as const, + PAYMENT_FLOW: "payment_flow" as const, + BUTTON_VERSION: "button_version" as const, + FI_LIST: "fi_list" as const, + CHOSEN_FI_TYPE: "chosen_fi_type" as const, + SELECTED_FI: "merchant_selected_funding_source" as const, + POTENTIAL_PAYMENT_METHODS: "potential_payment_methods" as const, + PAY_NOW: "pay_now" as const, + STICKINESS_ID: "stickiness_id" as const, + TIMESTAMP: "t" as const, + OPTION_SELECTED: "optsel" as const, + USER_IDENTITY_METHOD: "user_identity_method" as const, + FIELDS_COMPONENT_SESSION_ID: "fields_component_session_id" as const, + CPL_COMP_METRICS: "cpl_comp_metrics" as const, + CPL_CHUNK_METRICS: "cpl_chunk_metrics" as const, + CPL_QUERY_METRICS: "cpl_query_metrics" as const, +}; +export const FPTI_USER_ACTION = { + COMMIT: "commit" as const, + CONTINUE: "continue" as const, +}; +export const FPTI_DATA_SOURCE = { + PAYMENTS_SDK: "checkout" as const, +}; +export const FPTI_FEED = { + PAYMENTS_SDK: "payments_sdk" as const, +}; +export const FPTI_SDK_NAME = { + PAYMENTS_SDK: "payments_sdk" as const, +}; diff --git a/src/funding.js b/src/funding.js deleted file mode 100644 index 8cc0ac47..00000000 --- a/src/funding.js +++ /dev/null @@ -1,61 +0,0 @@ -/* @flow */ - -export const FUNDING = { - PAYPAL: ("paypal": "paypal"), - VENMO: ("venmo": "venmo"), - APPLEPAY: ("applepay": "applepay"), - ITAU: ("itau": "itau"), - CREDIT: ("credit": "credit"), - PAYLATER: ("paylater": "paylater"), - CARD: ("card": "card"), - IDEAL: ("ideal": "ideal"), - SEPA: ("sepa": "sepa"), - BANCONTACT: ("bancontact": "bancontact"), - GIROPAY: ("giropay": "giropay"), - SOFORT: ("sofort": "sofort"), - EPS: ("eps": "eps"), - MYBANK: ("mybank": "mybank"), - P24: ("p24": "p24"), - VERKKOPANKKI: ("verkkopankki": "verkkopankki"), - PAYU: ("payu": "payu"), - BLIK: ("blik": "blik"), - TRUSTLY: ("trustly": "trustly"), - ZIMPLER: ("zimpler": "zimpler"), - MAXIMA: ("maxima": "maxima"), - OXXO: ("oxxo": "oxxo"), - BOLETO: ("boleto": "boleto"), - BOLETOBANCARIO: ("boletobancario": "boletobancario"), - WECHATPAY: ("wechatpay": "wechatpay"), - MERCADOPAGO: ("mercadopago": "mercadopago"), - MULTIBANCO: ("multibanco": "multibanco"), -}; - -export const FUNDING_BRAND_LABEL = { - PAYPAL: ("PayPal": "PayPal"), - CREDIT: ("PayPal Credit": "PayPal Credit"), -}; - -export const CARD = { - VISA: ("visa": "visa"), - MASTERCARD: ("mastercard": "mastercard"), - AMEX: ("amex": "amex"), - DISCOVER: ("discover": "discover"), - HIPER: ("hiper": "hiper"), - ELO: ("elo": "elo"), - JCB: ("jcb": "jcb"), - CUP: ("cup": "cup"), -}; - -export const WALLET_INSTRUMENT = { - BALANCE: ("balance": "balance"), - CARD: ("card": "card"), - BANK: ("bank": "bank"), - CREDIT: ("credit": "credit"), -}; - -export const FUNDING_PRODUCTS = { - PAY_IN_3: ("payIn3": "payIn3"), - PAY_IN_4: ("payIn4": "payIn4"), - PAYLATER: ("paylater": "paylater"), - CREDIT: ("credit": "credit"), -}; diff --git a/src/funding.ts b/src/funding.ts new file mode 100644 index 00000000..2d928212 --- /dev/null +++ b/src/funding.ts @@ -0,0 +1,55 @@ +export const FUNDING = { + PAYPAL: "paypal" as const, + VENMO: "venmo" as const, + APPLEPAY: "applepay" as const, + ITAU: "itau" as const, + CREDIT: "credit" as const, + PAYLATER: "paylater" as const, + CARD: "card" as const, + IDEAL: "ideal" as const, + SEPA: "sepa" as const, + BANCONTACT: "bancontact" as const, + GIROPAY: "giropay" as const, + SOFORT: "sofort" as const, + EPS: "eps" as const, + MYBANK: "mybank" as const, + P24: "p24" as const, + VERKKOPANKKI: "verkkopankki" as const, + PAYU: "payu" as const, + BLIK: "blik" as const, + TRUSTLY: "trustly" as const, + ZIMPLER: "zimpler" as const, + MAXIMA: "maxima" as const, + OXXO: "oxxo" as const, + BOLETO: "boleto" as const, + BOLETOBANCARIO: "boletobancario" as const, + WECHATPAY: "wechatpay" as const, + MERCADOPAGO: "mercadopago" as const, + MULTIBANCO: "multibanco" as const, +}; +export const FUNDING_BRAND_LABEL = { + PAYPAL: "PayPal" as const, + CREDIT: "PayPal Credit" as const, +}; +export const CARD = { + VISA: "visa" as const, + MASTERCARD: "mastercard" as const, + AMEX: "amex" as const, + DISCOVER: "discover" as const, + HIPER: "hiper" as const, + ELO: "elo" as const, + JCB: "jcb" as const, + CUP: "cup" as const, +}; +export const WALLET_INSTRUMENT = { + BALANCE: "balance" as const, + CARD: "card" as const, + BANK: "bank" as const, + CREDIT: "credit" as const, +}; +export const FUNDING_PRODUCTS = { + PAY_IN_3: "payIn3" as const, + PAY_IN_4: "payIn4" as const, + PAYLATER: "paylater" as const, + CREDIT: "credit" as const, +}; diff --git a/src/index.js b/src/index.ts similarity index 95% rename from src/index.js rename to src/index.ts index a8f31cef..4748a5f2 100644 --- a/src/index.js +++ b/src/index.ts @@ -1,5 +1,3 @@ -/* @flow */ - export * from "./defaults"; export * from "./env"; export * from "./error"; diff --git a/src/locale.js b/src/locale.js deleted file mode 100644 index 2fd44f31..00000000 --- a/src/locale.js +++ /dev/null @@ -1,669 +0,0 @@ -/* @flow */ -/* eslint max-lines: 0 */ - -export const COUNTRY = { - AD: ("AD": "AD"), - AE: ("AE": "AE"), - AG: ("AG": "AG"), - AI: ("AI": "AI"), - AL: ("AL": "AL"), - AM: ("AM": "AM"), - AN: ("AN": "AN"), - AO: ("AO": "AO"), - AR: ("AR": "AR"), - AT: ("AT": "AT"), - AU: ("AU": "AU"), - AW: ("AW": "AW"), - AZ: ("AZ": "AZ"), - BA: ("BA": "BA"), - BB: ("BB": "BB"), - BE: ("BE": "BE"), - BF: ("BF": "BF"), - BG: ("BG": "BG"), - BH: ("BH": "BH"), - BI: ("BI": "BI"), - BJ: ("BJ": "BJ"), - BM: ("BM": "BM"), - BN: ("BN": "BN"), - BO: ("BO": "BO"), - BR: ("BR": "BR"), - BS: ("BS": "BS"), - BT: ("BT": "BT"), - BW: ("BW": "BW"), - BY: ("BY": "BY"), - BZ: ("BZ": "BZ"), - CA: ("CA": "CA"), - CD: ("CD": "CD"), - CG: ("CG": "CG"), - CH: ("CH": "CH"), - CI: ("CI": "CI"), - CK: ("CK": "CK"), - CL: ("CL": "CL"), - CM: ("CM": "CM"), - CN: ("CN": "CN"), - CO: ("CO": "CO"), - CR: ("CR": "CR"), - CV: ("CV": "CV"), - CY: ("CY": "CY"), - CZ: ("CZ": "CZ"), - DE: ("DE": "DE"), - DJ: ("DJ": "DJ"), - DK: ("DK": "DK"), - DM: ("DM": "DM"), - DO: ("DO": "DO"), - DZ: ("DZ": "DZ"), - EC: ("EC": "EC"), - EE: ("EE": "EE"), - EG: ("EG": "EG"), - ER: ("ER": "ER"), - ES: ("ES": "ES"), - ET: ("ET": "ET"), - FI: ("FI": "FI"), - FJ: ("FJ": "FJ"), - FK: ("FK": "FK"), - FM: ("FM": "FM"), - FO: ("FO": "FO"), - FR: ("FR": "FR"), - GA: ("GA": "GA"), - GB: ("GB": "GB"), - GD: ("GD": "GD"), - GE: ("GE": "GE"), - GF: ("GF": "GF"), - GI: ("GI": "GI"), - GL: ("GL": "GL"), - GM: ("GM": "GM"), - GN: ("GN": "GN"), - GP: ("GP": "GP"), - GR: ("GR": "GR"), - GT: ("GT": "GT"), - GW: ("GW": "GW"), - GY: ("GY": "GY"), - HK: ("HK": "HK"), - HN: ("HN": "HN"), - HR: ("HR": "HR"), - HU: ("HU": "HU"), - ID: ("ID": "ID"), - IE: ("IE": "IE"), - IL: ("IL": "IL"), - IN: ("IN": "IN"), - IS: ("IS": "IS"), - IT: ("IT": "IT"), - JM: ("JM": "JM"), - JO: ("JO": "JO"), - JP: ("JP": "JP"), - KE: ("KE": "KE"), - KG: ("KG": "KG"), - KH: ("KH": "KH"), - KI: ("KI": "KI"), - KM: ("KM": "KM"), - KN: ("KN": "KN"), - KR: ("KR": "KR"), - KW: ("KW": "KW"), - KY: ("KY": "KY"), - KZ: ("KZ": "KZ"), - LA: ("LA": "LA"), - LC: ("LC": "LC"), - LI: ("LI": "LI"), - LK: ("LK": "LK"), - LS: ("LS": "LS"), - LT: ("LT": "LT"), - LU: ("LU": "LU"), - LV: ("LV": "LV"), - MA: ("MA": "MA"), - MC: ("MC": "MC"), - MD: ("MD": "MD"), - ME: ("ME": "ME"), - MG: ("MG": "MG"), - MH: ("MH": "MH"), - MK: ("MK": "MK"), - ML: ("ML": "ML"), - MN: ("MN": "MN"), - MQ: ("MQ": "MQ"), - MR: ("MR": "MR"), - MS: ("MS": "MS"), - MT: ("MT": "MT"), - MU: ("MU": "MU"), - MV: ("MV": "MV"), - MW: ("MW": "MW"), - MX: ("MX": "MX"), - MY: ("MY": "MY"), - MZ: ("MZ": "MZ"), - NA: ("NA": "NA"), - NC: ("NC": "NC"), - NE: ("NE": "NE"), - NF: ("NF": "NF"), - NG: ("NG": "NG"), - NI: ("NI": "NI"), - NL: ("NL": "NL"), - NO: ("NO": "NO"), - NP: ("NP": "NP"), - NR: ("NR": "NR"), - NU: ("NU": "NU"), - NZ: ("NZ": "NZ"), - OM: ("OM": "OM"), - PA: ("PA": "PA"), - PE: ("PE": "PE"), - PF: ("PF": "PF"), - PG: ("PG": "PG"), - PH: ("PH": "PH"), - PL: ("PL": "PL"), - PM: ("PM": "PM"), - PN: ("PN": "PN"), - PT: ("PT": "PT"), - PW: ("PW": "PW"), - PY: ("PY": "PY"), - QA: ("QA": "QA"), - RE: ("RE": "RE"), - RO: ("RO": "RO"), - RS: ("RS": "RS"), - RU: ("RU": "RU"), - RW: ("RW": "RW"), - SA: ("SA": "SA"), - SB: ("SB": "SB"), - SC: ("SC": "SC"), - SE: ("SE": "SE"), - SG: ("SG": "SG"), - SH: ("SH": "SH"), - SI: ("SI": "SI"), - SJ: ("SJ": "SJ"), - SK: ("SK": "SK"), - SL: ("SL": "SL"), - SM: ("SM": "SM"), - SN: ("SN": "SN"), - SO: ("SO": "SO"), - SR: ("SR": "SR"), - ST: ("ST": "ST"), - SV: ("SV": "SV"), - SZ: ("SZ": "SZ"), - TC: ("TC": "TC"), - TD: ("TD": "TD"), - TG: ("TG": "TG"), - TH: ("TH": "TH"), - TJ: ("TJ": "TJ"), - TM: ("TM": "TM"), - TN: ("TN": "TN"), - TO: ("TO": "TO"), - TR: ("TR": "TR"), - TT: ("TT": "TT"), - TV: ("TV": "TV"), - TW: ("TW": "TW"), - TZ: ("TZ": "TZ"), - UA: ("UA": "UA"), - UG: ("UG": "UG"), - US: ("US": "US"), - UY: ("UY": "UY"), - VA: ("VA": "VA"), - VC: ("VC": "VC"), - VE: ("VE": "VE"), - VG: ("VG": "VG"), - VN: ("VN": "VN"), - VU: ("VU": "VU"), - WF: ("WF": "WF"), - WS: ("WS": "WS"), - YE: ("YE": "YE"), - YT: ("YT": "YT"), - ZA: ("ZA": "ZA"), - ZM: ("ZM": "ZM"), - ZW: ("ZW": "ZW"), -}; - -export const LANG = { - AR: ("ar": "ar"), - BG: ("bg": "bg"), - CS: ("cs": "cs"), - DA: ("da": "da"), - DE: ("de": "de"), - EL: ("el": "el"), - EN: ("en": "en"), - ES: ("es": "es"), - ET: ("et": "et"), - FI: ("fi": "fi"), - FR: ("fr": "fr"), - HE: ("he": "he"), - HU: ("hu": "hu"), - ID: ("id": "id"), - IT: ("it": "it"), - JA: ("ja": "ja"), - KO: ("ko": "ko"), - LT: ("lt": "lt"), - LV: ("lv": "lv"), - MS: ("ms": "ms"), - NL: ("nl": "nl"), - NO: ("no": "no"), - PL: ("pl": "pl"), - PT: ("pt": "pt"), - RO: ("ro": "ro"), - RU: ("ru": "ru"), - SI: ("si": "si"), - SK: ("sk": "sk"), - SL: ("sl": "sl"), - SQ: ("sq": "sq"), - SV: ("sv": "sv"), - TH: ("th": "th"), - TL: ("tl": "tl"), - TR: ("tr": "tr"), - VI: ("vi": "vi"), - ZH: ("zh": "zh"), - ZH_HANT: ("zh_Hant": "zh_Hant"), -}; - -export type CountryLangs = {| - AD: "en" | "fr" | "es" | "zh", - AE: "en" | "fr" | "es" | "zh" | "ar", - AG: "en" | "fr" | "es" | "zh", - AI: "en" | "fr" | "es" | "zh", - AL: "sq" | "en", - AM: "en" | "fr" | "es" | "zh", - AN: "en" | "fr" | "es" | "zh", - AO: "en" | "fr" | "es" | "zh", - AR: "es" | "en", - AT: "de" | "en", - AU: "en", - AW: "en" | "fr" | "es" | "zh", - AZ: "en" | "fr" | "es" | "zh", - BA: "en", - BB: "en" | "fr" | "es" | "zh", - BE: "en" | "nl" | "fr", - BF: "fr" | "en" | "es" | "zh", - BG: "bg" | "en", - BH: "ar" | "en" | "fr" | "es" | "zh", - BI: "fr" | "en" | "es" | "zh", - BJ: "fr" | "en" | "es" | "zh", - BM: "en" | "fr" | "es" | "zh", - BN: "ms" | "en", - BO: "es" | "en" | "fr" | "zh", - BR: "pt" | "en", - BS: "en" | "fr" | "es" | "zh", - BT: "en", - BW: "en" | "fr" | "es" | "zh", - BY: "en", - BZ: "en" | "es" | "fr" | "zh", - CA: "en" | "fr", - CD: "fr" | "en" | "es" | "zh", - CG: "en" | "fr" | "es" | "zh", - CH: "de" | "fr" | "en", - CI: "fr" | "en", - CK: "en" | "fr" | "es" | "zh", - CL: "es" | "en" | "fr" | "zh", - CM: "fr" | "en", - CN: "zh", - CO: "es" | "en" | "fr" | "zh", - CR: "es" | "en" | "fr" | "zh", - CV: "en" | "fr" | "es" | "zh", - CY: "en", - CZ: "cs" | "en", - DE: "de" | "en", - DJ: "fr" | "en" | "es" | "zh", - DK: "da" | "en", - DM: "en" | "fr" | "es" | "zh", - DO: "es" | "en" | "fr" | "zh", - DZ: "ar" | "en" | "fr" | "es" | "zh", - EC: "es" | "en" | "fr" | "zh", - EE: "et" | "en" | "ru", - EG: "ar" | "en" | "fr" | "es" | "zh", - ER: "en" | "fr" | "es" | "zh", - ES: "es" | "en", - ET: "en" | "fr" | "es" | "zh", - FI: "fi" | "en", - FJ: "en" | "fr" | "es" | "zh", - FK: "en" | "fr" | "es" | "zh", - FM: "en", - FO: "da" | "en" | "fr" | "es" | "zh", - FR: "fr" | "en", - GA: "fr" | "en" | "es" | "zh", - GB: "en", - GD: "en" | "fr" | "es" | "zh", - GE: "en" | "fr" | "es" | "zh", - GF: "en" | "fr" | "es" | "zh", - GI: "en" | "fr" | "es" | "zh", - GL: "da" | "en" | "fr" | "es" | "zh", - GM: "en" | "fr" | "es" | "zh", - GN: "fr" | "en" | "es" | "zh", - GP: "en" | "fr" | "es" | "zh", - GR: "el" | "en", - GT: "es" | "en" | "fr" | "zh", - GW: "en" | "fr" | "es" | "zh", - GY: "en" | "fr" | "es" | "zh", - HK: "en" | "zh_Hant", - HN: "es" | "en" | "fr" | "zh", - HR: "en", - HU: "hu" | "en", - ID: "id" | "en", - IE: "en" | "fr" | "es" | "zh", - IL: "he" | "en", - IN: "en", - IS: "en", - IT: "it" | "en", - JM: "en" | "es" | "fr" | "zh", - JO: "ar" | "en" | "fr" | "es" | "zh", - JP: "ja" | "en", - KE: "en" | "fr" | "es" | "zh", - KG: "en" | "fr" | "es" | "zh", - KH: "en", - KI: "en" | "fr" | "es" | "zh", - KM: "fr" | "en" | "es" | "zh", - KN: "en" | "fr" | "es" | "zh", - KR: "ko" | "en", - KW: "ar" | "en" | "fr" | "es" | "zh", - KY: "en" | "fr" | "es" | "zh", - KZ: "en" | "fr" | "es" | "zh", - LA: "en", - LC: "en" | "fr" | "es" | "zh", - LI: "en" | "fr" | "es" | "zh", - LK: "si" | "en", - LS: "en" | "fr" | "es" | "zh", - LT: "lt" | "en" | "ru" | "zh", - LU: "en" | "de" | "fr" | "es" | "zh", - LV: "lv" | "en" | "ru", - MA: "ar" | "en" | "fr" | "es" | "zh", - MC: "fr" | "en", - MD: "en", - ME: "en", - MG: "en" | "fr" | "es" | "zh", - MH: "en" | "fr" | "es" | "zh", - MK: "en", - ML: "fr" | "en" | "es" | "zh", - MN: "en", - MQ: "en" | "fr" | "es" | "zh", - MR: "en" | "fr" | "es" | "zh", - MS: "en" | "fr" | "es" | "zh", - MT: "en", - MU: "en" | "fr" | "es" | "zh", - MV: "en", - MW: "en" | "fr" | "es" | "zh", - MX: "es" | "en", - MY: "ms" | "en", - MZ: "en" | "fr" | "es" | "zh", - NA: "en" | "fr" | "es" | "zh", - NC: "en" | "fr" | "es" | "zh", - NE: "fr" | "en" | "es" | "zh", - NF: "en" | "fr" | "es" | "zh", - NG: "en", - NI: "es" | "en" | "fr" | "zh", - NL: "nl" | "en", - NO: "no" | "en", - NP: "en", - NR: "en" | "fr" | "es" | "zh", - NU: "en" | "fr" | "es" | "zh", - NZ: "en" | "fr" | "es" | "zh", - OM: "ar" | "en" | "fr" | "es" | "zh", - PA: "es" | "en" | "fr" | "zh", - PE: "es" | "en" | "fr" | "zh", - PF: "en" | "fr" | "es" | "zh", - PG: "en" | "fr" | "es" | "zh", - PH: "tl" | "en", - PL: "pl" | "en", - PM: "en" | "fr" | "es" | "zh", - PN: "en" | "fr" | "es" | "zh", - PT: "pt" | "en", - PW: "en" | "fr" | "es" | "zh", - PY: "es" | "en", - QA: "en" | "fr" | "es" | "zh" | "ar", - RE: "en" | "fr" | "es" | "zh", - RO: "ro" | "en", - RS: "en" | "fr" | "es" | "zh", - RU: "ru" | "en", - RW: "fr" | "en" | "es" | "zh", - SA: "ar" | "en" | "fr" | "es" | "zh", - SB: "en" | "fr" | "es" | "zh", - SC: "fr" | "en" | "es" | "zh", - SE: "sv" | "en", - SG: "en", - SH: "en" | "fr" | "es" | "zh", - SI: "sl" | "en", - SJ: "en" | "fr" | "es" | "zh", - SK: "sk" | "en", - SL: "en" | "fr" | "es" | "zh", - SM: "en" | "fr" | "es" | "zh", - SN: "fr" | "en" | "es" | "zh", - SO: "en" | "fr" | "es" | "zh", - SR: "en" | "fr" | "es" | "zh", - ST: "en" | "fr" | "es" | "zh", - SV: "es" | "en" | "fr" | "zh", - SZ: "en" | "fr" | "es" | "zh", - TC: "en" | "fr" | "es" | "zh", - TD: "fr" | "en" | "es" | "zh", - TG: "fr" | "en" | "es" | "zh", - TH: "th" | "en", - TJ: "en" | "fr" | "es" | "zh", - TM: "en" | "fr" | "es" | "zh", - TN: "ar" | "en" | "fr" | "es" | "zh", - TO: "en", - TR: "tr" | "en", - TT: "en" | "fr" | "es" | "zh", - TV: "en" | "fr" | "es" | "zh", - TW: "zh_Hant" | "en", - TZ: "en" | "fr" | "es" | "zh", - UA: "en" | "ru" | "fr" | "es" | "zh", - UG: "en" | "fr" | "es" | "zh", - US: "en" | "fr" | "es" | "zh", - UY: "es" | "en" | "fr" | "zh", - VA: "en" | "fr" | "es" | "zh", - VC: "en" | "fr" | "es" | "zh", - VE: "es" | "en" | "fr" | "zh", - VG: "en" | "fr" | "es" | "zh", - VN: "vi" | "en", - VU: "en" | "fr" | "es" | "zh", - WF: "en" | "fr" | "es" | "zh", - WS: "en", - YE: "ar" | "en" | "fr" | "es" | "zh", - YT: "en" | "fr" | "es" | "zh", - ZA: "en" | "fr" | "es" | "zh", - ZM: "en" | "fr" | "es" | "zh", - ZW: "en", -|}; - -type CountryMap = { - [$Values]: $ReadOnlyArray<$Values>, -}; - -export const COUNTRY_LANGS: CountryMap = { - AD: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH, LANG.AR], - AG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AL: [LANG.SQ, LANG.EN], - AM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AN: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AO: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AR: [LANG.ES, LANG.EN], - AT: [LANG.DE, LANG.EN], - AU: [LANG.EN], - AW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - AZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - BA: [LANG.EN], - BB: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - BE: [LANG.EN, LANG.NL, LANG.FR], - BF: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - BG: [LANG.BG, LANG.EN], - BH: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - BI: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - BJ: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - BM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - BN: [LANG.MS, LANG.EN], - BO: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - BR: [LANG.PT, LANG.EN], - BS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - BT: [LANG.EN], - BW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - BY: [LANG.EN], - BZ: [LANG.EN, LANG.ES, LANG.FR, LANG.ZH], - CA: [LANG.EN, LANG.FR], - CD: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - CG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - CH: [LANG.DE, LANG.FR, LANG.EN], - CI: [LANG.FR, LANG.EN], - CK: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - CL: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - CM: [LANG.FR, LANG.EN], - CN: [LANG.ZH], - CO: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - CR: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - CV: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - CY: [LANG.EN], - CZ: [LANG.CS, LANG.EN], - DE: [LANG.DE, LANG.EN], - DJ: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - DK: [LANG.DA, LANG.EN], - DM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - DO: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - DZ: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - EC: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - EE: [LANG.ET, LANG.EN, LANG.RU], - EG: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - ER: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - ES: [LANG.ES, LANG.EN], - ET: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - FI: [LANG.FI, LANG.EN], - FJ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - FK: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - FM: [LANG.EN], - FO: [LANG.DA, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - FR: [LANG.FR, LANG.EN], - GA: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - GB: [LANG.EN], - GD: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GL: [LANG.DA, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GN: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - GP: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GR: [LANG.EL, LANG.EN], - GT: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - GW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - GY: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - HK: [LANG.EN, LANG.ZH_HANT, LANG.ZH], - HN: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - HR: [LANG.EN], - HU: [LANG.HU, LANG.EN], - ID: [LANG.ID, LANG.EN], - IE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - IL: [LANG.HE, LANG.EN], - IN: [LANG.EN], - IS: [LANG.EN], - IT: [LANG.IT, LANG.EN], - JM: [LANG.EN, LANG.ES, LANG.FR, LANG.ZH], - JO: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - JP: [LANG.JA, LANG.EN], - KE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - KG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - KH: [LANG.EN], - KI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - KM: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - KN: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - KR: [LANG.KO, LANG.EN], - KW: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - KY: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - KZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - LA: [LANG.EN], - LC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - LI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - LK: [LANG.SI, LANG.EN], - LS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - LT: [LANG.LT, LANG.EN, LANG.RU, LANG.ZH], - LU: [LANG.EN, LANG.DE, LANG.FR, LANG.ES, LANG.ZH], - LV: [LANG.LV, LANG.EN, LANG.RU], - MA: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MC: [LANG.FR, LANG.EN], - MD: [LANG.EN], - ME: [LANG.EN], - MG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MH: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MK: [LANG.EN], - ML: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - MN: [LANG.EN], - MQ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MR: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MT: [LANG.EN], - MU: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MV: [LANG.EN], - MW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - MX: [LANG.ES, LANG.EN], - MY: [LANG.MS, LANG.EN], - MZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - NA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - NC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - NE: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - NF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - NG: [LANG.EN], - NI: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - NL: [LANG.NL, LANG.EN], - NO: [LANG.NO, LANG.EN], - NP: [LANG.EN], - NR: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - NU: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - NZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - OM: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - PA: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - PE: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - PF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - PG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - PH: [LANG.TL, LANG.EN], - PL: [LANG.PL, LANG.EN], - PM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - PN: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - PT: [LANG.PT, LANG.EN], - PW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - PY: [LANG.ES, LANG.EN], - QA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH, LANG.AR], - RE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - RO: [LANG.RO, LANG.EN], - RS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - RU: [LANG.RU, LANG.EN], - RW: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - SA: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SB: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SC: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - SE: [LANG.SV, LANG.EN], - SG: [LANG.EN], - SH: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SI: [LANG.SL, LANG.EN], - SJ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SK: [LANG.SK, LANG.EN], - SL: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SN: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - SO: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SR: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - ST: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - SV: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - SZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TD: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - TG: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], - TH: [LANG.TH, LANG.EN], - TJ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TN: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TO: [LANG.EN], - TR: [LANG.TR, LANG.EN], - TT: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TV: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - TW: [LANG.ZH_HANT, LANG.ZH, LANG.EN], - TZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - UA: [LANG.EN, LANG.RU, LANG.FR, LANG.ES, LANG.ZH], - UG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - US: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - UY: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - VA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - VC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - VE: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], - VG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - VN: [LANG.VI, LANG.EN], - VU: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - WF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - WS: [LANG.EN], - YE: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - YT: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - ZA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - ZM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], - ZW: [LANG.EN], -}; - -export type LocaleType = {| - country: $Values, - lang: $Values, -|}; diff --git a/src/locale.ts b/src/locale.ts new file mode 100644 index 00000000..01803478 --- /dev/null +++ b/src/locale.ts @@ -0,0 +1,663 @@ +/* eslint max-lines: 0 */ +export const COUNTRY = { + AD: "AD" as const, + AE: "AE" as const, + AG: "AG" as const, + AI: "AI" as const, + AL: "AL" as const, + AM: "AM" as const, + AN: "AN" as const, + AO: "AO" as const, + AR: "AR" as const, + AT: "AT" as const, + AU: "AU" as const, + AW: "AW" as const, + AZ: "AZ" as const, + BA: "BA" as const, + BB: "BB" as const, + BE: "BE" as const, + BF: "BF" as const, + BG: "BG" as const, + BH: "BH" as const, + BI: "BI" as const, + BJ: "BJ" as const, + BM: "BM" as const, + BN: "BN" as const, + BO: "BO" as const, + BR: "BR" as const, + BS: "BS" as const, + BT: "BT" as const, + BW: "BW" as const, + BY: "BY" as const, + BZ: "BZ" as const, + CA: "CA" as const, + CD: "CD" as const, + CG: "CG" as const, + CH: "CH" as const, + CI: "CI" as const, + CK: "CK" as const, + CL: "CL" as const, + CM: "CM" as const, + CN: "CN" as const, + CO: "CO" as const, + CR: "CR" as const, + CV: "CV" as const, + CY: "CY" as const, + CZ: "CZ" as const, + DE: "DE" as const, + DJ: "DJ" as const, + DK: "DK" as const, + DM: "DM" as const, + DO: "DO" as const, + DZ: "DZ" as const, + EC: "EC" as const, + EE: "EE" as const, + EG: "EG" as const, + ER: "ER" as const, + ES: "ES" as const, + ET: "ET" as const, + FI: "FI" as const, + FJ: "FJ" as const, + FK: "FK" as const, + FM: "FM" as const, + FO: "FO" as const, + FR: "FR" as const, + GA: "GA" as const, + GB: "GB" as const, + GD: "GD" as const, + GE: "GE" as const, + GF: "GF" as const, + GI: "GI" as const, + GL: "GL" as const, + GM: "GM" as const, + GN: "GN" as const, + GP: "GP" as const, + GR: "GR" as const, + GT: "GT" as const, + GW: "GW" as const, + GY: "GY" as const, + HK: "HK" as const, + HN: "HN" as const, + HR: "HR" as const, + HU: "HU" as const, + ID: "ID" as const, + IE: "IE" as const, + IL: "IL" as const, + IN: "IN" as const, + IS: "IS" as const, + IT: "IT" as const, + JM: "JM" as const, + JO: "JO" as const, + JP: "JP" as const, + KE: "KE" as const, + KG: "KG" as const, + KH: "KH" as const, + KI: "KI" as const, + KM: "KM" as const, + KN: "KN" as const, + KR: "KR" as const, + KW: "KW" as const, + KY: "KY" as const, + KZ: "KZ" as const, + LA: "LA" as const, + LC: "LC" as const, + LI: "LI" as const, + LK: "LK" as const, + LS: "LS" as const, + LT: "LT" as const, + LU: "LU" as const, + LV: "LV" as const, + MA: "MA" as const, + MC: "MC" as const, + MD: "MD" as const, + ME: "ME" as const, + MG: "MG" as const, + MH: "MH" as const, + MK: "MK" as const, + ML: "ML" as const, + MN: "MN" as const, + MQ: "MQ" as const, + MR: "MR" as const, + MS: "MS" as const, + MT: "MT" as const, + MU: "MU" as const, + MV: "MV" as const, + MW: "MW" as const, + MX: "MX" as const, + MY: "MY" as const, + MZ: "MZ" as const, + NA: "NA" as const, + NC: "NC" as const, + NE: "NE" as const, + NF: "NF" as const, + NG: "NG" as const, + NI: "NI" as const, + NL: "NL" as const, + NO: "NO" as const, + NP: "NP" as const, + NR: "NR" as const, + NU: "NU" as const, + NZ: "NZ" as const, + OM: "OM" as const, + PA: "PA" as const, + PE: "PE" as const, + PF: "PF" as const, + PG: "PG" as const, + PH: "PH" as const, + PL: "PL" as const, + PM: "PM" as const, + PN: "PN" as const, + PT: "PT" as const, + PW: "PW" as const, + PY: "PY" as const, + QA: "QA" as const, + RE: "RE" as const, + RO: "RO" as const, + RS: "RS" as const, + RU: "RU" as const, + RW: "RW" as const, + SA: "SA" as const, + SB: "SB" as const, + SC: "SC" as const, + SE: "SE" as const, + SG: "SG" as const, + SH: "SH" as const, + SI: "SI" as const, + SJ: "SJ" as const, + SK: "SK" as const, + SL: "SL" as const, + SM: "SM" as const, + SN: "SN" as const, + SO: "SO" as const, + SR: "SR" as const, + ST: "ST" as const, + SV: "SV" as const, + SZ: "SZ" as const, + TC: "TC" as const, + TD: "TD" as const, + TG: "TG" as const, + TH: "TH" as const, + TJ: "TJ" as const, + TM: "TM" as const, + TN: "TN" as const, + TO: "TO" as const, + TR: "TR" as const, + TT: "TT" as const, + TV: "TV" as const, + TW: "TW" as const, + TZ: "TZ" as const, + UA: "UA" as const, + UG: "UG" as const, + US: "US" as const, + UY: "UY" as const, + VA: "VA" as const, + VC: "VC" as const, + VE: "VE" as const, + VG: "VG" as const, + VN: "VN" as const, + VU: "VU" as const, + WF: "WF" as const, + WS: "WS" as const, + YE: "YE" as const, + YT: "YT" as const, + ZA: "ZA" as const, + ZM: "ZM" as const, + ZW: "ZW" as const, +}; +export const LANG = { + AR: "ar" as const, + BG: "bg" as const, + CS: "cs" as const, + DA: "da" as const, + DE: "de" as const, + EL: "el" as const, + EN: "en" as const, + ES: "es" as const, + ET: "et" as const, + FI: "fi" as const, + FR: "fr" as const, + HE: "he" as const, + HU: "hu" as const, + ID: "id" as const, + IT: "it" as const, + JA: "ja" as const, + KO: "ko" as const, + LT: "lt" as const, + LV: "lv" as const, + MS: "ms" as const, + NL: "nl" as const, + NO: "no" as const, + PL: "pl" as const, + PT: "pt" as const, + RO: "ro" as const, + RU: "ru" as const, + SI: "si" as const, + SK: "sk" as const, + SL: "sl" as const, + SQ: "sq" as const, + SV: "sv" as const, + TH: "th" as const, + TL: "tl" as const, + TR: "tr" as const, + VI: "vi" as const, + ZH: "zh" as const, + ZH_HANT: "zh_Hant" as const, +}; +export type CountryLangs = { + AD: "en" | "fr" | "es" | "zh"; + AE: "en" | "fr" | "es" | "zh" | "ar"; + AG: "en" | "fr" | "es" | "zh"; + AI: "en" | "fr" | "es" | "zh"; + AL: "sq" | "en"; + AM: "en" | "fr" | "es" | "zh"; + AN: "en" | "fr" | "es" | "zh"; + AO: "en" | "fr" | "es" | "zh"; + AR: "es" | "en"; + AT: "de" | "en"; + AU: "en"; + AW: "en" | "fr" | "es" | "zh"; + AZ: "en" | "fr" | "es" | "zh"; + BA: "en"; + BB: "en" | "fr" | "es" | "zh"; + BE: "en" | "nl" | "fr"; + BF: "fr" | "en" | "es" | "zh"; + BG: "bg" | "en"; + BH: "ar" | "en" | "fr" | "es" | "zh"; + BI: "fr" | "en" | "es" | "zh"; + BJ: "fr" | "en" | "es" | "zh"; + BM: "en" | "fr" | "es" | "zh"; + BN: "ms" | "en"; + BO: "es" | "en" | "fr" | "zh"; + BR: "pt" | "en"; + BS: "en" | "fr" | "es" | "zh"; + BT: "en"; + BW: "en" | "fr" | "es" | "zh"; + BY: "en"; + BZ: "en" | "es" | "fr" | "zh"; + CA: "en" | "fr"; + CD: "fr" | "en" | "es" | "zh"; + CG: "en" | "fr" | "es" | "zh"; + CH: "de" | "fr" | "en"; + CI: "fr" | "en"; + CK: "en" | "fr" | "es" | "zh"; + CL: "es" | "en" | "fr" | "zh"; + CM: "fr" | "en"; + CN: "zh"; + CO: "es" | "en" | "fr" | "zh"; + CR: "es" | "en" | "fr" | "zh"; + CV: "en" | "fr" | "es" | "zh"; + CY: "en"; + CZ: "cs" | "en"; + DE: "de" | "en"; + DJ: "fr" | "en" | "es" | "zh"; + DK: "da" | "en"; + DM: "en" | "fr" | "es" | "zh"; + DO: "es" | "en" | "fr" | "zh"; + DZ: "ar" | "en" | "fr" | "es" | "zh"; + EC: "es" | "en" | "fr" | "zh"; + EE: "et" | "en" | "ru"; + EG: "ar" | "en" | "fr" | "es" | "zh"; + ER: "en" | "fr" | "es" | "zh"; + ES: "es" | "en"; + ET: "en" | "fr" | "es" | "zh"; + FI: "fi" | "en"; + FJ: "en" | "fr" | "es" | "zh"; + FK: "en" | "fr" | "es" | "zh"; + FM: "en"; + FO: "da" | "en" | "fr" | "es" | "zh"; + FR: "fr" | "en"; + GA: "fr" | "en" | "es" | "zh"; + GB: "en"; + GD: "en" | "fr" | "es" | "zh"; + GE: "en" | "fr" | "es" | "zh"; + GF: "en" | "fr" | "es" | "zh"; + GI: "en" | "fr" | "es" | "zh"; + GL: "da" | "en" | "fr" | "es" | "zh"; + GM: "en" | "fr" | "es" | "zh"; + GN: "fr" | "en" | "es" | "zh"; + GP: "en" | "fr" | "es" | "zh"; + GR: "el" | "en"; + GT: "es" | "en" | "fr" | "zh"; + GW: "en" | "fr" | "es" | "zh"; + GY: "en" | "fr" | "es" | "zh"; + HK: "en" | "zh_Hant"; + HN: "es" | "en" | "fr" | "zh"; + HR: "en"; + HU: "hu" | "en"; + ID: "id" | "en"; + IE: "en" | "fr" | "es" | "zh"; + IL: "he" | "en"; + IN: "en"; + IS: "en"; + IT: "it" | "en"; + JM: "en" | "es" | "fr" | "zh"; + JO: "ar" | "en" | "fr" | "es" | "zh"; + JP: "ja" | "en"; + KE: "en" | "fr" | "es" | "zh"; + KG: "en" | "fr" | "es" | "zh"; + KH: "en"; + KI: "en" | "fr" | "es" | "zh"; + KM: "fr" | "en" | "es" | "zh"; + KN: "en" | "fr" | "es" | "zh"; + KR: "ko" | "en"; + KW: "ar" | "en" | "fr" | "es" | "zh"; + KY: "en" | "fr" | "es" | "zh"; + KZ: "en" | "fr" | "es" | "zh"; + LA: "en"; + LC: "en" | "fr" | "es" | "zh"; + LI: "en" | "fr" | "es" | "zh"; + LK: "si" | "en"; + LS: "en" | "fr" | "es" | "zh"; + LT: "lt" | "en" | "ru" | "zh"; + LU: "en" | "de" | "fr" | "es" | "zh"; + LV: "lv" | "en" | "ru"; + MA: "ar" | "en" | "fr" | "es" | "zh"; + MC: "fr" | "en"; + MD: "en"; + ME: "en"; + MG: "en" | "fr" | "es" | "zh"; + MH: "en" | "fr" | "es" | "zh"; + MK: "en"; + ML: "fr" | "en" | "es" | "zh"; + MN: "en"; + MQ: "en" | "fr" | "es" | "zh"; + MR: "en" | "fr" | "es" | "zh"; + MS: "en" | "fr" | "es" | "zh"; + MT: "en"; + MU: "en" | "fr" | "es" | "zh"; + MV: "en"; + MW: "en" | "fr" | "es" | "zh"; + MX: "es" | "en"; + MY: "ms" | "en"; + MZ: "en" | "fr" | "es" | "zh"; + NA: "en" | "fr" | "es" | "zh"; + NC: "en" | "fr" | "es" | "zh"; + NE: "fr" | "en" | "es" | "zh"; + NF: "en" | "fr" | "es" | "zh"; + NG: "en"; + NI: "es" | "en" | "fr" | "zh"; + NL: "nl" | "en"; + NO: "no" | "en"; + NP: "en"; + NR: "en" | "fr" | "es" | "zh"; + NU: "en" | "fr" | "es" | "zh"; + NZ: "en" | "fr" | "es" | "zh"; + OM: "ar" | "en" | "fr" | "es" | "zh"; + PA: "es" | "en" | "fr" | "zh"; + PE: "es" | "en" | "fr" | "zh"; + PF: "en" | "fr" | "es" | "zh"; + PG: "en" | "fr" | "es" | "zh"; + PH: "tl" | "en"; + PL: "pl" | "en"; + PM: "en" | "fr" | "es" | "zh"; + PN: "en" | "fr" | "es" | "zh"; + PT: "pt" | "en"; + PW: "en" | "fr" | "es" | "zh"; + PY: "es" | "en"; + QA: "en" | "fr" | "es" | "zh" | "ar"; + RE: "en" | "fr" | "es" | "zh"; + RO: "ro" | "en"; + RS: "en" | "fr" | "es" | "zh"; + RU: "ru" | "en"; + RW: "fr" | "en" | "es" | "zh"; + SA: "ar" | "en" | "fr" | "es" | "zh"; + SB: "en" | "fr" | "es" | "zh"; + SC: "fr" | "en" | "es" | "zh"; + SE: "sv" | "en"; + SG: "en"; + SH: "en" | "fr" | "es" | "zh"; + SI: "sl" | "en"; + SJ: "en" | "fr" | "es" | "zh"; + SK: "sk" | "en"; + SL: "en" | "fr" | "es" | "zh"; + SM: "en" | "fr" | "es" | "zh"; + SN: "fr" | "en" | "es" | "zh"; + SO: "en" | "fr" | "es" | "zh"; + SR: "en" | "fr" | "es" | "zh"; + ST: "en" | "fr" | "es" | "zh"; + SV: "es" | "en" | "fr" | "zh"; + SZ: "en" | "fr" | "es" | "zh"; + TC: "en" | "fr" | "es" | "zh"; + TD: "fr" | "en" | "es" | "zh"; + TG: "fr" | "en" | "es" | "zh"; + TH: "th" | "en"; + TJ: "en" | "fr" | "es" | "zh"; + TM: "en" | "fr" | "es" | "zh"; + TN: "ar" | "en" | "fr" | "es" | "zh"; + TO: "en"; + TR: "tr" | "en"; + TT: "en" | "fr" | "es" | "zh"; + TV: "en" | "fr" | "es" | "zh"; + TW: "zh_Hant" | "en"; + TZ: "en" | "fr" | "es" | "zh"; + UA: "en" | "ru" | "fr" | "es" | "zh"; + UG: "en" | "fr" | "es" | "zh"; + US: "en" | "fr" | "es" | "zh"; + UY: "es" | "en" | "fr" | "zh"; + VA: "en" | "fr" | "es" | "zh"; + VC: "en" | "fr" | "es" | "zh"; + VE: "es" | "en" | "fr" | "zh"; + VG: "en" | "fr" | "es" | "zh"; + VN: "vi" | "en"; + VU: "en" | "fr" | "es" | "zh"; + WF: "en" | "fr" | "es" | "zh"; + WS: "en"; + YE: "ar" | "en" | "fr" | "es" | "zh"; + YT: "en" | "fr" | "es" | "zh"; + ZA: "en" | "fr" | "es" | "zh"; + ZM: "en" | "fr" | "es" | "zh"; + ZW: "en"; +}; +type CountryMap = Record< + keyof typeof COUNTRY, + ReadonlyArray +>; +export const COUNTRY_LANGS: CountryMap = { + AD: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH, LANG.AR], + AG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AL: [LANG.SQ, LANG.EN], + AM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AN: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AO: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AR: [LANG.ES, LANG.EN], + AT: [LANG.DE, LANG.EN], + AU: [LANG.EN], + AW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + AZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + BA: [LANG.EN], + BB: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + BE: [LANG.EN, LANG.NL, LANG.FR], + BF: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + BG: [LANG.BG, LANG.EN], + BH: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + BI: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + BJ: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + BM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + BN: [LANG.MS, LANG.EN], + BO: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + BR: [LANG.PT, LANG.EN], + BS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + BT: [LANG.EN], + BW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + BY: [LANG.EN], + BZ: [LANG.EN, LANG.ES, LANG.FR, LANG.ZH], + CA: [LANG.EN, LANG.FR], + CD: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + CG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + CH: [LANG.DE, LANG.FR, LANG.EN], + CI: [LANG.FR, LANG.EN], + CK: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + CL: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + CM: [LANG.FR, LANG.EN], + CN: [LANG.ZH], + CO: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + CR: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + CV: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + CY: [LANG.EN], + CZ: [LANG.CS, LANG.EN], + DE: [LANG.DE, LANG.EN], + DJ: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + DK: [LANG.DA, LANG.EN], + DM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + DO: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + DZ: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + EC: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + EE: [LANG.ET, LANG.EN, LANG.RU], + EG: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + ER: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + ES: [LANG.ES, LANG.EN], + ET: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + FI: [LANG.FI, LANG.EN], + FJ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + FK: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + FM: [LANG.EN], + FO: [LANG.DA, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + FR: [LANG.FR, LANG.EN], + GA: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + GB: [LANG.EN], + GD: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GL: [LANG.DA, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GN: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + GP: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GR: [LANG.EL, LANG.EN], + GT: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + GW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + GY: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + HK: [LANG.EN, LANG.ZH_HANT, LANG.ZH], + HN: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + HR: [LANG.EN], + HU: [LANG.HU, LANG.EN], + ID: [LANG.ID, LANG.EN], + IE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + IL: [LANG.HE, LANG.EN], + IN: [LANG.EN], + IS: [LANG.EN], + IT: [LANG.IT, LANG.EN], + JM: [LANG.EN, LANG.ES, LANG.FR, LANG.ZH], + JO: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + JP: [LANG.JA, LANG.EN], + KE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + KG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + KH: [LANG.EN], + KI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + KM: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + KN: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + KR: [LANG.KO, LANG.EN], + KW: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + KY: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + KZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + LA: [LANG.EN], + LC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + LI: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + LK: [LANG.SI, LANG.EN], + LS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + LT: [LANG.LT, LANG.EN, LANG.RU, LANG.ZH], + LU: [LANG.EN, LANG.DE, LANG.FR, LANG.ES, LANG.ZH], + LV: [LANG.LV, LANG.EN, LANG.RU], + MA: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MC: [LANG.FR, LANG.EN], + MD: [LANG.EN], + ME: [LANG.EN], + MG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MH: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MK: [LANG.EN], + ML: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + MN: [LANG.EN], + MQ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MR: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MT: [LANG.EN], + MU: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MV: [LANG.EN], + MW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + MX: [LANG.ES, LANG.EN], + MY: [LANG.MS, LANG.EN], + MZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + NA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + NC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + NE: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + NF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + NG: [LANG.EN], + NI: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + NL: [LANG.NL, LANG.EN], + NO: [LANG.NO, LANG.EN], + NP: [LANG.EN], + NR: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + NU: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + NZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + OM: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + PA: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + PE: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + PF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + PG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + PH: [LANG.TL, LANG.EN], + PL: [LANG.PL, LANG.EN], + PM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + PN: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + PT: [LANG.PT, LANG.EN], + PW: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + PY: [LANG.ES, LANG.EN], + QA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH, LANG.AR], + RE: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + RO: [LANG.RO, LANG.EN], + RS: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + RU: [LANG.RU, LANG.EN], + RW: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + SA: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SB: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SC: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + SE: [LANG.SV, LANG.EN], + SG: [LANG.EN], + SH: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SI: [LANG.SL, LANG.EN], + SJ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SK: [LANG.SK, LANG.EN], + SL: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SN: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + SO: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SR: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + ST: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + SV: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + SZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TD: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + TG: [LANG.FR, LANG.EN, LANG.ES, LANG.ZH], + TH: [LANG.TH, LANG.EN], + TJ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TN: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TO: [LANG.EN], + TR: [LANG.TR, LANG.EN], + TT: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TV: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + TW: [LANG.ZH_HANT, LANG.ZH, LANG.EN], + TZ: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + UA: [LANG.EN, LANG.RU, LANG.FR, LANG.ES, LANG.ZH], + UG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + US: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + UY: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + VA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + VC: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + VE: [LANG.ES, LANG.EN, LANG.FR, LANG.ZH], + VG: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + VN: [LANG.VI, LANG.EN], + VU: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + WF: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + WS: [LANG.EN], + YE: [LANG.AR, LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + YT: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + ZA: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + ZM: [LANG.EN, LANG.FR, LANG.ES, LANG.ZH], + ZW: [LANG.EN], +}; +export type LocaleType = { + country: typeof COUNTRY[keyof typeof COUNTRY]; + lang: typeof LANG[keyof typeof LANG]; +}; diff --git a/src/order.js b/src/order.js deleted file mode 100644 index 7d03173c..00000000 --- a/src/order.js +++ /dev/null @@ -1,124 +0,0 @@ -/* @flow */ - -export const INTENT = { - CAPTURE: ("capture": "capture"), - AUTHORIZE: ("authorize": "authorize"), - ORDER: ("order": "order"), - TOKENIZE: ("tokenize": "tokenize"), - SUBSCRIPTION: ("subscription": "subscription"), -}; - -export const COMMIT = { - TRUE: (true: true), - FALSE: (false: false), -}; - -export const VAULT = { - TRUE: (true: true), - FALSE: (false: false), -}; - -export const CURRENCY = { - AED: ("AED": "AED"), - ALL: ("ALL": "ALL"), - ANG: ("ANG": "ANG"), - AOA: ("AOA": "AOA"), - AUD: ("AUD": "AUD"), - AWG: ("AWG": "AWG"), - BAM: ("BAM": "BAM"), - BBD: ("BBD": "BBD"), - BGN: ("BGN": "BGN"), - BIF: ("BIF": "BIF"), - BMD: ("BMD": "BMD"), - BND: ("BND": "BND"), - BOB: ("BOB": "BOB"), - BRL: ("BRL": "BRL"), - BSD: ("BSD": "BSD"), - BTN: ("BTN": "BTN"), - CAD: ("CAD": "CAD"), - CDF: ("CDF": "CDF"), - CHF: ("CHF": "CHF"), - CLP: ("CLP": "CLP"), - COP: ("COP": "COP"), - CRC: ("CRC": "CRC"), - CVE: ("CVE": "CVE"), - CZK: ("CZK": "CZK"), - DJF: ("DJF": "DJF"), - DKK: ("DKK": "DKK"), - DOP: ("DOP": "DOP"), - DZD: ("DZD": "DZD"), - EGP: ("EGP": "EGP"), - ETB: ("ETB": "ETB"), - EUR: ("EUR": "EUR"), - FJD: ("FJD": "FJD"), - FKP: ("FKP": "FKP"), - GBP: ("GBP": "GBP"), - GIP: ("GIP": "GIP"), - GMD: ("GMD": "GMD"), - GNF: ("GNF": "GNF"), - GTQ: ("GTQ": "GTQ"), - GYD: ("GYD": "GYD"), - HKD: ("HKD": "HKD"), - HNL: ("HNL": "HNL"), - HRK: ("HRK": "HRK"), - HUF: ("HUF": "HUF"), - IDR: ("IDR": "IDR"), - ILS: ("ILS": "ILS"), - INR: ("INR": "INR"), - ISK: ("ISK": "ISK"), - JMD: ("JMD": "JMD"), - JPY: ("JPY": "JPY"), - KES: ("KES": "KES"), - KMF: ("KMF": "KMF"), - KRW: ("KRW": "KRW"), - KYD: ("KYD": "KYD"), - LAK: ("LAK": "LAK"), - LKR: ("LKR": "LKR"), - MDL: ("MDL": "MDL"), - MGA: ("MGA": "MGA"), - MKD: ("MKD": "MKD"), - MNT: ("MNT": "MNT"), - MRO: ("MRO": "MRO"), - MUR: ("MUR": "MUR"), - MVR: ("MVR": "MVR"), - MXN: ("MXN": "MXN"), - MYR: ("MYR": "MYR"), - NAD: ("NAD": "NAD"), - NIO: ("NIO": "NIO"), - NOK: ("NOK": "NOK"), - NPR: ("NPR": "NPR"), - NZD: ("NZD": "NZD"), - PEN: ("PEN": "PEN"), - PGK: ("PGK": "PGK"), - PHP: ("PHP": "PHP"), - PLN: ("PLN": "PLN"), - PYG: ("PYG": "PYG"), - QAR: ("QAR": "QAR"), - RON: ("RON": "RON"), - RSD: ("RSD": "RSD"), - RUB: ("RUB": "RUB"), - SAR: ("SAR": "SAR"), - SBD: ("SBD": "SBD"), - SCR: ("SCR": "SCR"), - SEK: ("SEK": "SEK"), - SGD: ("SGD": "SGD"), - SHP: ("SHP": "SHP"), - SLL: ("SLL": "SLL"), - SOS: ("SOS": "SOS"), - SRD: ("SRD": "SRD"), - SZL: ("SZL": "SZL"), - THB: ("THB": "THB"), - TJS: ("TJS": "TJS"), - TOP: ("TOP": "TOP"), - TTD: ("TTD": "TTD"), - TWD: ("TWD": "TWD"), - TZS: ("TZS": "TZS"), - USD: ("USD": "USD"), - UYU: ("UYU": "UYU"), - VND: ("VND": "VND"), - VUV: ("VUV": "VUV"), - WST: ("WST": "WST"), - XAF: ("XAF": "XAF"), - XCD: ("XCD": "XCD"), - YER: ("YER": "YER"), -}; diff --git a/src/order.ts b/src/order.ts new file mode 100644 index 00000000..1bc9c80b --- /dev/null +++ b/src/order.ts @@ -0,0 +1,119 @@ +export const INTENT = { + CAPTURE: "capture" as const, + AUTHORIZE: "authorize" as const, + ORDER: "order" as const, + TOKENIZE: "tokenize" as const, + SUBSCRIPTION: "subscription" as const, +}; +export const COMMIT = { + TRUE: true as const, + FALSE: false as const, +}; +export const VAULT = { + TRUE: true as const, + FALSE: false as const, +}; +export const CURRENCY = { + AED: "AED" as const, + ALL: "ALL" as const, + ANG: "ANG" as const, + AOA: "AOA" as const, + AUD: "AUD" as const, + AWG: "AWG" as const, + BAM: "BAM" as const, + BBD: "BBD" as const, + BGN: "BGN" as const, + BIF: "BIF" as const, + BMD: "BMD" as const, + BND: "BND" as const, + BOB: "BOB" as const, + BRL: "BRL" as const, + BSD: "BSD" as const, + BTN: "BTN" as const, + CAD: "CAD" as const, + CDF: "CDF" as const, + CHF: "CHF" as const, + CLP: "CLP" as const, + COP: "COP" as const, + CRC: "CRC" as const, + CVE: "CVE" as const, + CZK: "CZK" as const, + DJF: "DJF" as const, + DKK: "DKK" as const, + DOP: "DOP" as const, + DZD: "DZD" as const, + EGP: "EGP" as const, + ETB: "ETB" as const, + EUR: "EUR" as const, + FJD: "FJD" as const, + FKP: "FKP" as const, + GBP: "GBP" as const, + GIP: "GIP" as const, + GMD: "GMD" as const, + GNF: "GNF" as const, + GTQ: "GTQ" as const, + GYD: "GYD" as const, + HKD: "HKD" as const, + HNL: "HNL" as const, + HRK: "HRK" as const, + HUF: "HUF" as const, + IDR: "IDR" as const, + ILS: "ILS" as const, + INR: "INR" as const, + ISK: "ISK" as const, + JMD: "JMD" as const, + JPY: "JPY" as const, + KES: "KES" as const, + KMF: "KMF" as const, + KRW: "KRW" as const, + KYD: "KYD" as const, + LAK: "LAK" as const, + LKR: "LKR" as const, + MDL: "MDL" as const, + MGA: "MGA" as const, + MKD: "MKD" as const, + MNT: "MNT" as const, + MRO: "MRO" as const, + MUR: "MUR" as const, + MVR: "MVR" as const, + MXN: "MXN" as const, + MYR: "MYR" as const, + NAD: "NAD" as const, + NIO: "NIO" as const, + NOK: "NOK" as const, + NPR: "NPR" as const, + NZD: "NZD" as const, + PEN: "PEN" as const, + PGK: "PGK" as const, + PHP: "PHP" as const, + PLN: "PLN" as const, + PYG: "PYG" as const, + QAR: "QAR" as const, + RON: "RON" as const, + RSD: "RSD" as const, + RUB: "RUB" as const, + SAR: "SAR" as const, + SBD: "SBD" as const, + SCR: "SCR" as const, + SEK: "SEK" as const, + SGD: "SGD" as const, + SHP: "SHP" as const, + SLL: "SLL" as const, + SOS: "SOS" as const, + SRD: "SRD" as const, + SZL: "SZL" as const, + THB: "THB" as const, + TJS: "TJS" as const, + TOP: "TOP" as const, + TTD: "TTD" as const, + TWD: "TWD" as const, + TZS: "TZS" as const, + USD: "USD" as const, + UYU: "UYU" as const, + VND: "VND" as const, + VUV: "VUV" as const, + WST: "WST" as const, + XAF: "XAF" as const, + XCD: "XCD" as const, + YER: "YER" as const, +}; diff --git a/src/params.js b/src/params.js deleted file mode 100644 index 9bca49f8..00000000 --- a/src/params.js +++ /dev/null @@ -1,89 +0,0 @@ -/* @flow */ - -export const SDK_PATH = "/sdk/js"; - -export const SDK_SETTINGS = { - NAMESPACE: ("data-namespace": "data-namespace"), - CLIENT_TOKEN: ("data-client-token": "data-client-token"), - MERCHANT_ID: ("data-merchant-id": "data-merchant-id"), - PARTNER_ATTRIBUTION_ID: - ("data-partner-attribution-id": "data-partner-attribution-id"), - STAGE_HOST: ("data-stage-host": "data-stage-host"), - API_STAGE_HOST: ("data-api-stage-host": "data-api-stage-host"), - CSP_NONCE: ("data-csp-nonce": "data-csp-nonce"), - ENABLE_3DS: ("data-enable-3ds": "data-enable-3ds"), - SDK_INTEGRATION_SOURCE: - ("data-sdk-integration-source": "data-sdk-integration-source"), - USER_ID_TOKEN: ("data-user-id-token": "data-user-id-token"), - AMOUNT: ("data-amount": "data-amount"), - CLIENT_METADATA_ID: ("data-client-metadata-id": "data-client-metadata-id"), - PAGE_TYPE: ("data-page-type": "data-page-type"), - USER_EXPERIENCE_FLOW: - ("data-user-experience-flow": "data-user-experience-flow"), - POPUPS_DISABLED: ("data-popups-disabled": "data-popups-disabled"), -}; - -export const SDK_QUERY_KEYS = { - COMPONENTS: ("components": "components"), - - ENV: ("env": "env"), - DEBUG: ("debug": "debug"), - CACHEBUST: ("cachebust": "cachebust"), - - CLIENT_ID: ("client-id": "client-id"), - MERCHANT_ID: ("merchant-id": "merchant-id"), - - LOCALE: ("locale": "locale"), - - CURRENCY: ("currency": "currency"), - INTENT: ("intent": "intent"), - COMMIT: ("commit": "commit"), - VAULT: ("vault": "vault"), - - BUYER_COUNTRY: ("buyer-country": "buyer-country"), - - ENABLE_FUNDING: ("enable-funding": "enable-funding"), - DISABLE_FUNDING: ("disable-funding": "disable-funding"), - DISABLE_CARD: ("disable-card": "disable-card"), - - INTEGRATION_DATE: ("integration-date": "integration-date"), - STAGE_HOST: ("stage-host": "stage-host"), - STAGE_ALIAS: ("stage-alias": "stage-alias"), - CDN_REGISTRY: ("cdn-registry": "cdn-registry"), - VERSION: ("version": "version"), -}; - -export const COMPONENTS = { - BUTTONS: ("buttons": "buttons"), - HOSTED_FIELDS: ("hosted-fields": "hosted-fields"), -}; - -export const DEBUG = { - TRUE: (true: true), - FALSE: (false: false), -}; - -export const QUERY_BOOL = { - TRUE: ("true": "true"), - FALSE: ("false": "false"), -}; - -export const UNKNOWN = ("unknown": "unknown"); - -export const PROTOCOL = { - HTTP: ("http": "http"), - HTTPS: ("https": "https"), -}; - -export const PAGE_TYPES = { - HOME: ("home": "home"), - PRODUCT: ("product": "product"), - CART: ("cart": "cart"), - CHECKOUT: ("checkout": "checkout"), - PRODUCT_LISTING: ("product-listing": "product-listing"), - SEARCH_RESULTS: ("search-results": "search-results"), - PRODUCT_DETAILS: ("product-details": "product-details"), - MINI_CART: ("mini-cart": "mini-cart"), -}; - -export const MERCHANT_ID_MAX = 10; diff --git a/src/params.ts b/src/params.ts new file mode 100644 index 00000000..24a4b48b --- /dev/null +++ b/src/params.ts @@ -0,0 +1,68 @@ +export const SDK_PATH = "/sdk/js"; +export const SDK_SETTINGS = { + NAMESPACE: "data-namespace" as const, + CLIENT_TOKEN: "data-client-token" as const, + MERCHANT_ID: "data-merchant-id" as const, + PARTNER_ATTRIBUTION_ID: "data-partner-attribution-id" as const, + STAGE_HOST: "data-stage-host" as const, + API_STAGE_HOST: "data-api-stage-host" as const, + CSP_NONCE: "data-csp-nonce" as const, + ENABLE_3DS: "data-enable-3ds" as const, + SDK_INTEGRATION_SOURCE: "data-sdk-integration-source" as const, + USER_ID_TOKEN: "data-user-id-token" as const, + AMOUNT: "data-amount" as const, + CLIENT_METADATA_ID: "data-client-metadata-id" as const, + PAGE_TYPE: "data-page-type" as const, + USER_EXPERIENCE_FLOW: "data-user-experience-flow" as const, + POPUPS_DISABLED: "data-popups-disabled" as const, +}; +export const SDK_QUERY_KEYS = { + COMPONENTS: "components" as const, + ENV: "env" as const, + DEBUG: "debug" as const, + CACHEBUST: "cachebust" as const, + CLIENT_ID: "client-id" as const, + MERCHANT_ID: "merchant-id" as const, + LOCALE: "locale" as const, + CURRENCY: "currency" as const, + INTENT: "intent" as const, + COMMIT: "commit" as const, + VAULT: "vault" as const, + BUYER_COUNTRY: "buyer-country" as const, + ENABLE_FUNDING: "enable-funding" as const, + DISABLE_FUNDING: "disable-funding" as const, + DISABLE_CARD: "disable-card" as const, + INTEGRATION_DATE: "integration-date" as const, + STAGE_HOST: "stage-host" as const, + STAGE_ALIAS: "stage-alias" as const, + CDN_REGISTRY: "cdn-registry" as const, + VERSION: "version" as const, +}; +export const COMPONENTS = { + BUTTONS: "buttons" as const, + HOSTED_FIELDS: "hosted-fields" as const, +}; +export const DEBUG = { + TRUE: true as const, + FALSE: false as const, +}; +export const QUERY_BOOL = { + TRUE: "true" as const, + FALSE: "false" as const, +}; +export const UNKNOWN = "unknown" as const; +export const PROTOCOL = { + HTTP: "http" as const, + HTTPS: "https" as const, +}; +export const PAGE_TYPES = { + HOME: "home" as const, + PRODUCT: "product" as const, + CART: "cart" as const, + CHECKOUT: "checkout" as const, + PRODUCT_LISTING: "product-listing" as const, + SEARCH_RESULTS: "search-results" as const, + PRODUCT_DETAILS: "product-details" as const, + MINI_CART: "mini-cart" as const, +}; +export const MERCHANT_ID_MAX = 10; diff --git a/src/platform.js b/src/platform.js deleted file mode 100644 index ee00e996..00000000 --- a/src/platform.js +++ /dev/null @@ -1,6 +0,0 @@ -/* @flow */ - -export const PLATFORM = { - DESKTOP: ("desktop": "desktop"), - MOBILE: ("mobile": "mobile"), -}; diff --git a/src/platform.ts b/src/platform.ts new file mode 100644 index 00000000..4f88139d --- /dev/null +++ b/src/platform.ts @@ -0,0 +1,4 @@ +export const PLATFORM = { + DESKTOP: "desktop" as const, + MOBILE: "mobile" as const, +}; diff --git a/src/types.js b/src/types.js deleted file mode 100644 index 84570a65..00000000 --- a/src/types.js +++ /dev/null @@ -1,94 +0,0 @@ -/* @flow */ - -export const TYPES = true; - -export type VaultedInstrument = {| - id: string, - label: {| - description: string, - |}, -|}; - -export type BasicEligibility = {| - eligible: ?boolean, - branded: ?boolean, - recommended?: ?boolean, -|}; - -export type PayPalEligibility = {| - eligible: ?boolean, - branded: ?boolean, - recommended?: ?boolean, - vaultable?: ?boolean, - vaultedInstruments?: $ReadOnlyArray, -|}; - -export type FundingProductEligibility = {| - eligible?: boolean, - variant?: ?string, -|}; - -export type PayLaterEligibility = {| - eligible: ?boolean, - recommended?: ?boolean, - products?: {| - payIn3: FundingProductEligibility, - payIn4: FundingProductEligibility, - paylater: FundingProductEligibility, - |}, -|}; - -export type CardVendorEligibility = {| - eligible: ?boolean, - vaultable?: ?boolean, - vaultedInstruments?: $ReadOnlyArray, -|}; - -export type CardVendorsEligibility = {| - visa?: CardVendorEligibility, - mastercard?: CardVendorEligibility, - amex?: CardVendorEligibility, - discover?: CardVendorEligibility, - hiper?: CardVendorEligibility, - elo?: CardVendorEligibility, - jcb?: CardVendorEligibility, - cup?: CardVendorEligibility, -|}; - -export type CardEligibility = {| - eligible: ?boolean, - branded: ?boolean, - recommended?: ?boolean, - installments?: ?boolean, - vendors: CardVendorsEligibility, -|}; - -export type FundingEligibilityType = {| - paypal?: PayPalEligibility, - card?: CardEligibility, - venmo?: BasicEligibility, - applepay?: BasicEligibility, - credit?: BasicEligibility, - paylater?: PayLaterEligibility, - sepa?: BasicEligibility, - bancontact?: BasicEligibility, - eps?: BasicEligibility, - giropay?: BasicEligibility, - ideal?: BasicEligibility, - mybank?: BasicEligibility, - p24?: BasicEligibility, - sofort?: BasicEligibility, - wechatpay?: BasicEligibility, - zimpler?: BasicEligibility, - itau?: BasicEligibility, - payu?: BasicEligibility, - verkkopankki?: BasicEligibility, - blik?: BasicEligibility, - boleto?: BasicEligibility, - boletobancario?: BasicEligibility, - maxima?: BasicEligibility, - oxxo?: BasicEligibility, - trustly?: BasicEligibility, - mercadopago?: BasicEligibility, - multibanco?: BasicEligibility, -|}; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 00000000..4b73ca06 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,83 @@ +export const TYPES = true; +export type VaultedInstrument = { + id: string; + label: { + description: string; + }; +}; +export type BasicEligibility = { + eligible: boolean | null | undefined; + branded: boolean | null | undefined; + recommended?: boolean | null | undefined; +}; +export type PayPalEligibility = { + eligible: boolean | null | undefined; + branded: boolean | null | undefined; + recommended?: boolean | null | undefined; + vaultable?: boolean | null | undefined; + vaultedInstruments?: ReadonlyArray; +}; +export type FundingProductEligibility = { + eligible?: boolean; + variant?: string | null | undefined; +}; +export type PayLaterEligibility = { + eligible: boolean | null | undefined; + recommended?: boolean | null | undefined; + products?: { + payIn3: FundingProductEligibility; + payIn4: FundingProductEligibility; + paylater: FundingProductEligibility; + }; +}; +export type CardVendorEligibility = { + eligible: boolean | null | undefined; + vaultable?: boolean | null | undefined; + vaultedInstruments?: ReadonlyArray; +}; +export type CardVendorsEligibility = { + visa?: CardVendorEligibility; + mastercard?: CardVendorEligibility; + amex?: CardVendorEligibility; + discover?: CardVendorEligibility; + hiper?: CardVendorEligibility; + elo?: CardVendorEligibility; + jcb?: CardVendorEligibility; + cup?: CardVendorEligibility; +}; +export type CardEligibility = { + eligible: boolean | null | undefined; + branded: boolean | null | undefined; + recommended?: boolean | null | undefined; + installments?: boolean | null | undefined; + vendors: CardVendorsEligibility; +}; +export type FundingEligibilityType = { + paypal?: PayPalEligibility; + card?: CardEligibility; + venmo?: BasicEligibility; + applepay?: BasicEligibility; + credit?: BasicEligibility; + paylater?: PayLaterEligibility; + sepa?: BasicEligibility; + bancontact?: BasicEligibility; + eps?: BasicEligibility; + giropay?: BasicEligibility; + ideal?: BasicEligibility; + mybank?: BasicEligibility; + p24?: BasicEligibility; + sofort?: BasicEligibility; + wechatpay?: BasicEligibility; + zimpler?: BasicEligibility; + itau?: BasicEligibility; + payu?: BasicEligibility; + verkkopankki?: BasicEligibility; + blik?: BasicEligibility; + boleto?: BasicEligibility; + boletobancario?: BasicEligibility; + maxima?: BasicEligibility; + oxxo?: BasicEligibility; + trustly?: BasicEligibility; + mercadopago?: BasicEligibility; + multibanco?: BasicEligibility; +}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..a0710938 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@krakenjs/grumbler-scripts/config/tsconfig.json" +} diff --git a/webpack.config.js b/webpack.config.ts similarity index 90% rename from webpack.config.js rename to webpack.config.ts index 103fc4c8..aba1302f 100644 --- a/webpack.config.js +++ b/webpack.config.ts @@ -1,17 +1,19 @@ /* @flow */ /* eslint import/no-nodejs-modules: off */ - +// @ts-ignore import { getWebpackConfig } from "@krakenjs/grumbler-scripts/config/webpack.config"; const FILE_NAME = "paypal-sdk-constants"; const MODULE_NAME = "ppsdkconstants"; export const WEBPACK_CONFIG = getWebpackConfig({ + entry: "./index.ts", filename: `${FILE_NAME}.js`, modulename: MODULE_NAME, }); export const WEBPACK_CONFIG_MIN = getWebpackConfig({ + entry: "./index.ts", filename: `${FILE_NAME}.min.js`, modulename: MODULE_NAME, minify: true, @@ -21,6 +23,7 @@ export const WEBPACK_CONFIG_MIN = getWebpackConfig({ }); export const WEBPACK_CONFIG_TEST = getWebpackConfig({ + entry: "./index.ts", filename: `${FILE_NAME}.js`, modulename: MODULE_NAME, options: {