From 74ab30fea105e32ad6cc5f5b7c9f0c6b6d8aeb05 Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Tue, 19 Sep 2023 21:21:33 -0500 Subject: [PATCH] Fix credentials for CRA api call (#29) Signed-off-by: Sean Sundberg --- src/config/customer-risk-assessment.config.ts | 20 - src/config/index.ts | 2 - .../customer-risk-assessment.controller.ts | 4 +- .../kyc-summary/kyc-summary.controller.ts | 8 +- .../customer-risk-assessment.config.ts | 46 ++ .../customer-risk-assessment/index.ts | 1 + src/services/kyc-case-summary/index.ts | 2 +- .../kyc-case-summary}/kyc-summary.config.ts | 2 +- .../kyc-case/kyc-case-management.mock.ts | 18 +- .../menu-options/menu-options.mock.ts | 528 ++++++++++-------- 10 files changed, 345 insertions(+), 286 deletions(-) delete mode 100644 src/config/customer-risk-assessment.config.ts delete mode 100644 src/config/index.ts create mode 100644 src/services/customer-risk-assessment/customer-risk-assessment.config.ts rename src/{config => services/kyc-case-summary}/kyc-summary.config.ts (89%) diff --git a/src/config/customer-risk-assessment.config.ts b/src/config/customer-risk-assessment.config.ts deleted file mode 100644 index 998ea35..0000000 --- a/src/config/customer-risk-assessment.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {Configuration} from "../services/customer-risk-assessment"; - -let _instance: Configuration; -export const customerRiskAssessmentConfig = (): Configuration => { - if (_instance) { - return _instance; - } - - _instance = new Configuration({ - username: process.env.CRA_USERNAME, - password: process.env.CRA_PASSWORD, - basePath: process.env.CRA_BASE_PATH, - }); - - if (!_instance.username || !_instance.password) { - throw new Error('CRA_USERNAME or CRA_PASSWORD not set'); - } - - return _instance; -} diff --git a/src/config/index.ts b/src/config/index.ts deleted file mode 100644 index 4f2ec46..0000000 --- a/src/config/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './customer-risk-assessment.config'; -export * from './kyc-summary.config'; diff --git a/src/controllers/customer-risk-assessment/customer-risk-assessment.controller.ts b/src/controllers/customer-risk-assessment/customer-risk-assessment.controller.ts index 7474f00..c165fb2 100644 --- a/src/controllers/customer-risk-assessment/customer-risk-assessment.controller.ts +++ b/src/controllers/customer-risk-assessment/customer-risk-assessment.controller.ts @@ -1,11 +1,11 @@ import {Body, Controller, Get, Post} from "@nestjs/common"; +import {ApiPropertyOptional, ApiTags} from "@nestjs/swagger"; import { Cp4adminCustomerRiskAssessmentCustomerRiskAssessmentApiFactory, + customerRiskAssessmentConfig, CustomerRiskAssessmentRisk0020AssessmentInput } from "../../services/customer-risk-assessment"; -import {customerRiskAssessmentConfig} from "../../config"; -import {ApiPropertyOptional, ApiTags} from "@nestjs/swagger"; import {MenuOptionsApi} from "../../services"; class CustomerRiskAssessmentInput implements CustomerRiskAssessmentRisk0020AssessmentInput { diff --git a/src/controllers/kyc-summary/kyc-summary.controller.ts b/src/controllers/kyc-summary/kyc-summary.controller.ts index b5bd225..865c556 100644 --- a/src/controllers/kyc-summary/kyc-summary.controller.ts +++ b/src/controllers/kyc-summary/kyc-summary.controller.ts @@ -1,11 +1,9 @@ import {AxiosResponse} from "axios"; import {Body, Controller, Post, UploadedFile, UseInterceptors} from "@nestjs/common"; -import {ApiConsumes, ApiHeader, ApiParam, ApiProperty, ApiTags} from "@nestjs/swagger"; - -import {kycCaseSummaryConfig} from "../../config"; -import {DefaultApiFactory, Entity, IDefaultApi} from "../../services"; import {FileInterceptor} from "@nestjs/platform-express"; -import {SwaggerEnumType} from "@nestjs/swagger/dist/types/swagger-enum.type"; +import {ApiConsumes, ApiProperty, ApiTags} from "@nestjs/swagger"; + +import {DefaultApiFactory, Entity, IDefaultApi, kycCaseSummaryConfig} from "../../services"; class EntityData implements Entity { @ApiProperty() diff --git a/src/services/customer-risk-assessment/customer-risk-assessment.config.ts b/src/services/customer-risk-assessment/customer-risk-assessment.config.ts new file mode 100644 index 0000000..2f63c4c --- /dev/null +++ b/src/services/customer-risk-assessment/customer-risk-assessment.config.ts @@ -0,0 +1,46 @@ +import * as https from "https"; +import {Configuration} from "./configuration"; + +let _instance: Configuration; +export const customerRiskAssessmentConfig = (): Configuration => { + if (_instance) { + return _instance; + } + + const username = process.env.CRA_USERNAME; + const password = process.env.CRA_PASSWORD; + const apiKey = process.env.CRA_API_KEY; + + const buildAuthorization = () => { + if (username && apiKey) { + const token = Buffer.from(`${username}:${apiKey}`).toString('base64') + + return `ZenApiKey ${token}` + } + + const token = Buffer.from(`${username}:${password}`).toString('base64') + + return `Basic ${token}` + } + + _instance = new Configuration({ + username, + password, + apiKey, + basePath: process.env.CRA_BASE_PATH, + baseOptions: { + httpsAgent: new https.Agent({ + rejectUnauthorized: false + }), + headers: { + 'Authorization': buildAuthorization() + } + } + }); + + if (!(_instance.username && _instance.password) && !_instance.apiKey) { + throw new Error('CRA_USERNAME, CRA_PASSWORD, and/or CRA_API_KEY not set'); + } + + return _instance; +} diff --git a/src/services/customer-risk-assessment/index.ts b/src/services/customer-risk-assessment/index.ts index 5cd39fc..30b103e 100644 --- a/src/services/customer-risk-assessment/index.ts +++ b/src/services/customer-risk-assessment/index.ts @@ -14,4 +14,5 @@ export * from "./api"; export * from "./configuration"; export * from "./models"; +export * from './customer-risk-assessment.config'; diff --git a/src/services/kyc-case-summary/index.ts b/src/services/kyc-case-summary/index.ts index 46bb2ca..9426d06 100644 --- a/src/services/kyc-case-summary/index.ts +++ b/src/services/kyc-case-summary/index.ts @@ -14,4 +14,4 @@ export * from "./api"; export * from "./configuration"; export * from "./models"; - +export * from './kyc-summary.config'; diff --git a/src/config/kyc-summary.config.ts b/src/services/kyc-case-summary/kyc-summary.config.ts similarity index 89% rename from src/config/kyc-summary.config.ts rename to src/services/kyc-case-summary/kyc-summary.config.ts index 6b51f58..a1d7ab4 100644 --- a/src/config/kyc-summary.config.ts +++ b/src/services/kyc-case-summary/kyc-summary.config.ts @@ -1,4 +1,4 @@ -import {Configuration} from "../services/kyc-case-summary"; +import {Configuration} from "./configuration"; let _instance: Configuration; export const kycCaseSummaryConfig = (): Configuration => { diff --git a/src/services/kyc-case/kyc-case-management.mock.ts b/src/services/kyc-case/kyc-case-management.mock.ts index cba3f8f..2286259 100644 --- a/src/services/kyc-case/kyc-case-management.mock.ts +++ b/src/services/kyc-case/kyc-case-management.mock.ts @@ -22,10 +22,12 @@ import { ReviewCaseModel } from "../../models"; import {delay, first, streamToBuffer, urlToStream} from "../../utils"; -import {Cp4adminCustomerRiskAssessmentCustomerRiskAssessmentApiFactory} from "../customer-risk-assessment"; -import {customerRiskAssessmentConfig, kycCaseSummaryConfig} from "../../config"; +import { + Cp4adminCustomerRiskAssessmentCustomerRiskAssessmentApiFactory, + customerRiskAssessmentConfig +} from "../customer-risk-assessment"; import {NegativeNewsApi} from "../negative-news"; -import {DefaultApiFactory} from "../kyc-case-summary"; +import {DefaultApiFactory, kycCaseSummaryConfig} from "../kyc-case-summary"; import {NegativeNewsImpl} from "../negative-news/negative-news.impl"; const initialValue: KycCaseModel[] = [ @@ -33,10 +35,10 @@ const initialValue: KycCaseModel[] = [ id: '1', customer: { name: 'John Doe', - countryOfResidence: 'US', + countryOfResidence: 'United States', personalIdentificationNumber: '123458690', - entityType: '02', - industryType: '92.00', + entityType: 'Private Limited Company', + industryType: 'Growing of rice', }, status: 'New', documents: [], @@ -47,8 +49,8 @@ const initialValue: KycCaseModel[] = [ name: 'Jane Doe', countryOfResidence: 'CA', personalIdentificationNumber: 'AB1458690', - entityType: '03', - industryType: '10.82/2', + entityType: 'Sole Trader', + industryType: 'Extraction of crude petroleum', }, status: 'New', documents: [], diff --git a/src/services/menu-options/menu-options.mock.ts b/src/services/menu-options/menu-options.mock.ts index 27719fc..e707a54 100644 --- a/src/services/menu-options/menu-options.mock.ts +++ b/src/services/menu-options/menu-options.mock.ts @@ -2,6 +2,272 @@ import {MenuOptionsApi} from "./menu-options.api"; import {FormOptionModel} from "../../models"; import {parseCsv} from "../../utils"; +const countryTypesCsv = `Code,description,risk_weight, +XG,EU Organisations,LOW, +NULL,Missing Data,MEDIUM, +NOT_FOUND,Data Not Recognised,MEDIUM, +XH,Other International Org.,LOW, +QU,Unknown,MEDIUM, +XB,Abu Dhabi,HIGH, +AF,Afghanistan,REFER-SANCTIONS, +AX,Aland Islands,HIGH, +AL,Albania,AUTO-HIGH, +DZ,Algeria,HIGH, +AS,American Samoa,HIGH, +AD,Andorra,HIGH, +AO,Angola,HIGH, +AI,Anguilla,HIGH, +AQ,Antarctica,HIGH, +AG,Antigua And Barbuda,HIGH, +AR,Argentina,HIGH, +AM,Armenia,HIGH, +AW,Aruba,HIGH, +AU,Australia,MEDIUM, +AT,Austria,LOW, +AZ,Azerbaijan,HIGH, +BS,Bahamas,AUTO-HIGH, +BH,Bahrain,HIGH, +BD,Bangladesh,HIGH, +BB,Barbados,AUTO-HIGH, +BY,Belarus,REFER-SANCTIONS, +BE,Belgium,LOW, +BZ,Belize,HIGH, +BJ,Benin,HIGH, +BM,Bermuda,HIGH, +BT,Bhutan,MEDIUM, +BO,Bolivia,HIGH, +BQ,"Bonaire, Sint Eust And Saba",HIGH, +BA,Bosnia And Herzegovina,REFER-SANCTIONS, +BW,Botswana,AUTO-HIGH, +BV,Bouvet Island,HIGH, +BR,Brazil,HIGH, +XD,British Antarctic Territory,HIGH, +IO,British Indian Ocean Territory,HIGH, +VG,British Virgin Islands,HIGH, +BN,Brunei Darussalam,HIGH, +BG,Bulgaria,MEDIUM, +BF,Burkina Faso,AUTO-HIGH, +BI,Burundi,REFER-SANCTIONS, +KH,Cambodia,AUTO-HIGH, +CM,Cameroon,HIGH, +CA,Canada,LOW, +XE,Canton & Enderbury Islands,HIGH, +CV,Cape Verde,HIGH, +KY,Cayman Islands,AUTO-HIGH, +CF,Central African Republic,REFER-SANCTIONS, +TD,Chad,HIGH, +CL,Chile,LOW, +CN,China,REFER-SANCTIONS, +CX,Christmas Island,HIGH, +CC,Cocos Keeling Islands,HIGH, +CO,Colombia,HIGH, +KM,Comoros,HIGH, +CG,Congo (Republic Of),HIGH, +CK,Cook Islands,HIGH, +CR,Costa Rica,HIGH, +HR,Croatia,LOW, +CU,Cuba,REFER-SANCTIONS, +CW,Curacao,HIGH, +CY,Cyprus,HIGH, +CZ,Czech Republic,LOW, +CD,Democratic Republic Of Congo,REFER-SANCTIONS, +DK,Denmark,LOW, +DJ,Djibouti,HIGH, +DM,Dominica,HIGH, +DO,Dominican Republic,HIGH, +XC,Dubai,HIGH, +TL,East Timor,HIGH, +EC,Ecuador,HIGH, +EG,Egypt,REFER-SANCTIONS, +SV,El Salvador,HIGH, +GQ,Equatorial Guinea,HIGH, +ER,Eritrea,HIGH, +EE,Estonia,HIGH, +ET,Ethiopia,HIGH, +FK,Falkland Islands (Malvinas),HIGH, +FO,Faroe Islands,HIGH, +FJ,Fiji,HIGH, +FI,Finland,LOW, +FR,France,LOW, +GF,French Guiana,HIGH, +PF,French Polynesia,HIGH, +TF,French Southern Territories,HIGH, +GA,Gabon,HIGH, +GM,Gambia,HIGH, +GE,Georgia,HIGH, +DE,Germany,LOW, +GH,Ghana,AUTO-HIGH, +GI,Gibraltar,MEDIUM, +GR,Greece,LOW, +GL,Greenland,HIGH, +GD,Grenada,HIGH, +GP,Guadeloupe,HIGH, +GU,Guam,HIGH, +GT,Guatemala,HIGH, +GG,Guernsey,MEDIUM, +GN,Guinea,REFER-SANCTIONS, +GW,Guinea-Bissau,REFER-SANCTIONS, +GY,Guyana,HIGH, +HT,Haiti,HIGH, +HM,Heard & Macdonald Islands,HIGH, +HN,Honduras,HIGH, +HK,Hong Kong,HIGH, +HU,Hungary,MEDIUM, +IS,Iceland,LOW, +IN,India,HIGH, +ID,Indonesia,HIGH, +IR,"Iran, Islamic Republic Of",REFER-PROHIBITED, +IQ,Iraq,REFER-SANCTIONS, +IE,Ireland (Republic Of Ireland),LOW, +IM,Isle Of Man,MEDIUM, +IL,Israel,MEDIUM, +IT,Italy,LOW, +CI,Ivory Coast,HIGH, +JM,Jamaica,AUTO-HIGH, +JP,Japan,LOW, +JE,Jersey,MEDIUM, +JO,Jordan,HIGH, +KZ,Kazakhstan,HIGH, +KE,Kenya,HIGH, +KI,Kiribati,HIGH, +QZ,Kosovo,HIGH, +KW,Kuwait,HIGH, +KG,Kyrgyzstan,HIGH, +LA,Laos,HIGH, +LV,Latvia,HIGH, +LB,Lebanon,REFER-SANCTIONS, +LS,Lesotho,MEDIUM, +LR,Liberia,HIGH, +LY,Libya,REFER-SANCTIONS, +LI,Liechtenstein,HIGH, +LT,Lithuania,HIGH, +LU,Luxembourg,MEDIUM, +MO,Macao,HIGH, +MK,"Macedonia (Former Yugo Rep,)",HIGH, +MG,Madagascar ,HIGH, +MW,Malawi,HIGH, +MY,Malaysia,HIGH, +MV,Maldives,HIGH, +ML,Mali,REFER-SANCTIONS, +MT,Malta,MEDIUM, +MH,Marshall Islands,MEDIUM, +MQ,Martinique,HIGH, +MR,Mauritania,HIGH, +MU,Mauritius,AUTO-HIGH, +YT,Mayotte,HIGH, +MX,Mexico,HIGH, +FM,Micronesia,LOW, +MD,Moldova,HIGH, +MC,Monaco,HIGH, +MN,Mongolia,AUTO-HIGH, +ME,Montenegro,REFER-SANCTIONS, +MS,Montserrat,HIGH, +MA,Morocco,AUTO-HIGH, +MZ,Mozambique,HIGH, +MM,Myanmar (Burma),REFER-SANCTIONS, +NA,Namibia,MEDIUM, +NR,Nauru,HIGH, +NP,Nepal,HIGH, +NL,Netherlands,LOW, +AN,Netherlands Antilles,HIGH, +NC,New Caledonia,HIGH, +NZ,New Zealand,LOW, +NI,Nicaragua,REFER-SANCTIONS, +NE,Niger,HIGH, +NG,Nigeria,HIGH, +NU,Niue,HIGH, +NF,Norfolk Island,HIGH, +KP,North Korea (Dem Peop Rep Of),REFER-PROHIBITED, +MP,Northern Mariana Islands,HIGH, +NO,Norway,LOW, +OM,Oman,HIGH, +PK,Pakistan,AUTO-HIGH, +PW,Palau,HIGH, +PS,Palestine,HIGH, +PA,Panama,AUTO-HIGH, +PG,Papua New Guinea,HIGH, +PY,Paraguay,HIGH, +PE,Peru,HIGH, +PH,Philippines,HIGH, +PN,Pitcairn Islands,HIGH, +PL,Poland,LOW, +PT,Portugal,LOW, +PR,Puerto Rico,LOW, +QA,Qatar,HIGH, +RS,Republic Of Serbia,REFER-SANCTIONS, +RE,Reunion,HIGH, +RO,Romania,HIGH, +RU,Russian Federation,REFER-SANCTIONS, +RW,Rwanda,MEDIUM, +BL,Saint Barthelemy,HIGH, +SH,Saint Helena,HIGH, +KN,Saint Kitts & Nevis,HIGH, +LC,Saint Lucia,HIGH, +MF,Saint Martin French Part,HIGH, +PM,Saint Pierre & Miquelon,HIGH, +VC,Saint Vincent & The Grenadines,HIGH, +WS,Samoa,HIGH, +SM,San Marino,HIGH, +ST,Sao Tome & Principe,MEDIUM, +SA,Saudi Arabia,HIGH, +SN,Senegal,AUTO-HIGH, +CS,Serbia And Montenegro,REFER-SANCTIONS, +SC,Seychelles,HIGH, +SL,Sierra Leone,HIGH, +SG,Singapore ,LOW, +SX,Sint Maarten,HIGH, +SK,Slovakia,LOW, +SI,Slovenia,LOW, +SB,Solomon Islands,HIGH, +SO,Somalia,REFER-SANCTIONS, +ZA,South Africa,MEDIUM, +GS,South Georgia & South Sandwich Islands,HIGH, +KR,South Korea (Republic Of),LOW, +SS,South Sudan,REFER-SANCTIONS, +ES,Spain,LOW, +LK,Sri Lanka,HIGH, +SD,Sudan,REFER-SANCTIONS, +SR,Suriname,HIGH, +SJ,Svalbard,HIGH, +SZ,Eswatini (Swaziland),HIGH, +SE,Sweden,LOW, +CH,Switzerland,MEDIUM, +SY,Syria,REFER-PROHIBITED, +TW,Taiwan,MEDIUM, +TJ,Tajikistan,HIGH, +TZ,Tanzania,HIGH, +TH,Thailand,HIGH, +TG,Togo,HIGH, +TK,Tokelau,HIGH, +TO,Tonga,LOW, +TT,Trinidad And Tobago,AUTO-HIGH, +TN,Tunisia,HIGH, +TR,Turkey,REFER-SANCTIONS, +TM,Turkmenistan,HIGH, +TC,Turks And Caicos Islands,HIGH, +TV,Tuvalu,HIGH, +UG,Uganda,AUTO-HIGH, +UA,Ukraine,REFER-SANCTIONS, +AE,United Arab Emirates,HIGH, +XF,United Arab Emirates (Other),HIGH, +GB,United Kingdom,LOW, +US,United States,LOW, +UY,Uruguay,LOW, +UM,US Minor Outlying Islands,HIGH, +VI,US Virgin Islands,HIGH, +UZ,Uzbekistan,HIGH, +VU,Vanuatu,AUTO-HIGH, +VA,Vatican City State,HIGH, +VE,Venezuela,REFER-SANCTIONS, +VN,Vietnam,HIGH, +WF,Wallis & Futuna,HIGH, +EH,Western Sahara,HIGH, +YE,Yemen,REFER-SANCTIONS, +YU,"Macedonia (Former Yugo Rep,)",HIGH, +ZR,Zaire (Democratic Republic Of Congo),REFER-SANCTIONS, +ZM,Zambia,HIGH, +ZW,Zimbabwe,REFER-SANCTIONS,` + const industryTypesCsv = `Code,Division,Industry ,Strategic Rating, 01.11,Growing of non-perennial crops,"Growing of cereals (except rice), leguminous crops and oil seeds",MEDIUM, 01.12,Growing of non-perennial crops,Growing of rice,LOW, @@ -761,254 +1027,22 @@ code,description,risk_weight let entityTypes: FormOptionModel[]; let industryTypes: FormOptionModel[]; +let countryTypes: FormOptionModel[]; export class MenuOptionsMock implements MenuOptionsApi { async getCountryList(): Promise { - return [ - {text: 'Afghanistan', value: 'AF'}, - {text: 'Ă…land Islands', value: 'AX'}, - {text: 'Albania', value: 'AL'}, - {text: 'Algeria', value: 'DZ'}, - {text: 'American Samoa', value: 'AS'}, - {text: 'AndorrA', value: 'AD'}, - {text: 'Angola', value: 'AO'}, - {text: 'Anguilla', value: 'AI'}, - {text: 'Antarctica', value: 'AQ'}, - {text: 'Antigua and Barbuda', value: 'AG'}, - {text: 'Argentina', value: 'AR'}, - {text: 'Armenia', value: 'AM'}, - {text: 'Aruba', value: 'AW'}, - {text: 'Australia', value: 'AU'}, - {text: 'Austria', value: 'AT'}, - {text: 'Azerbaijan', value: 'AZ'}, - {text: 'Bahamas', value: 'BS'}, - {text: 'Bahrain', value: 'BH'}, - {text: 'Bangladesh', value: 'BD'}, - {text: 'Barbados', value: 'BB'}, - {text: 'Belarus', value: 'BY'}, - {text: 'Belgium', value: 'BE'}, - {text: 'Belize', value: 'BZ'}, - {text: 'Benin', value: 'BJ'}, - {text: 'Bermuda', value: 'BM'}, - {text: 'Bhutan', value: 'BT'}, - {text: 'Bolivia', value: 'BO'}, - {text: 'Bosnia and Herzegovina', value: 'BA'}, - {text: 'Botswana', value: 'BW'}, - {text: 'Bouvet Island', value: 'BV'}, - {text: 'Brazil', value: 'BR'}, - {text: 'British Indian Ocean Territory', value: 'IO'}, - {text: 'Brunei Darussalam', value: 'BN'}, - {text: 'Bulgaria', value: 'BG'}, - {text: 'Burkina Faso', value: 'BF'}, - {text: 'Burundi', value: 'BI'}, - {text: 'Cambodia', value: 'KH'}, - {text: 'Cameroon', value: 'CM'}, - {text: 'Canada', value: 'CA'}, - {text: 'Cape Verde', value: 'CV'}, - {text: 'Cayman Islands', value: 'KY'}, - {text: 'Central African Republic', value: 'CF'}, - {text: 'Chad', value: 'TD'}, - {text: 'Chile', value: 'CL'}, - {text: 'China', value: 'CN'}, - {text: 'Christmas Island', value: 'CX'}, - {text: 'Cocos (Keeling) Islands', value: 'CC'}, - {text: 'Colombia', value: 'CO'}, - {text: 'Comoros', value: 'KM'}, - {text: 'Congo', value: 'CG'}, - {text: 'Congo, The Democratic Republic of the', value: 'CD'}, - {text: 'Cook Islands', value: 'CK'}, - {text: 'Costa Rica', value: 'CR'}, - {text: 'Cote D\'Ivoire', value: 'CI'}, - {text: 'Croatia', value: 'HR'}, - {text: 'Cuba', value: 'CU'}, - {text: 'Cyprus', value: 'CY'}, - {text: 'Czech Republic', value: 'CZ'}, - {text: 'Denmark', value: 'DK'}, - {text: 'Djibouti', value: 'DJ'}, - {text: 'Dominica', value: 'DM'}, - {text: 'Dominican Republic', value: 'DO'}, - {text: 'Ecuador', value: 'EC'}, - {text: 'Egypt', value: 'EG'}, - {text: 'El Salvador', value: 'SV'}, - {text: 'Equatorial Guinea', value: 'GQ'}, - {text: 'Eritrea', value: 'ER'}, - {text: 'Estonia', value: 'EE'}, - {text: 'Ethiopia', value: 'ET'}, - {text: 'Falkland Islands (Malvinas)', value: 'FK'}, - {text: 'Faroe Islands', value: 'FO'}, - {text: 'Fiji', value: 'FJ'}, - {text: 'Finland', value: 'FI'}, - {text: 'France', value: 'FR'}, - {text: 'French Guiana', value: 'GF'}, - {text: 'French Polynesia', value: 'PF'}, - {text: 'French Southern Territories', value: 'TF'}, - {text: 'Gabon', value: 'GA'}, - {text: 'Gambia', value: 'GM'}, - {text: 'Georgia', value: 'GE'}, - {text: 'Germany', value: 'DE'}, - {text: 'Ghana', value: 'GH'}, - {text: 'Gibraltar', value: 'GI'}, - {text: 'Greece', value: 'GR'}, - {text: 'Greenland', value: 'GL'}, - {text: 'Grenada', value: 'GD'}, - {text: 'Guadeloupe', value: 'GP'}, - {text: 'Guam', value: 'GU'}, - {text: 'Guatemala', value: 'GT'}, - {text: 'Guernsey', value: 'GG'}, - {text: 'Guinea', value: 'GN'}, - {text: 'Guinea-Bissau', value: 'GW'}, - {text: 'Guyana', value: 'GY'}, - {text: 'Haiti', value: 'HT'}, - {text: 'Heard Island and Mcdonald Islands', value: 'HM'}, - {text: 'Holy See (Vatican City State)', value: 'VA'}, - {text: 'Honduras', value: 'HN'}, - {text: 'Hong Kong', value: 'HK'}, - {text: 'Hungary', value: 'HU'}, - {text: 'Iceland', value: 'IS'}, - {text: 'India', value: 'IN'}, - {text: 'Indonesia', value: 'ID'}, - {text: 'Iran, Islamic Republic Of', value: 'IR'}, - {text: 'Iraq', value: 'IQ'}, - {text: 'Ireland', value: 'IE'}, - {text: 'Isle of Man', value: 'IM'}, - {text: 'Israel', value: 'IL'}, - {text: 'Italy', value: 'IT'}, - {text: 'Jamaica', value: 'JM'}, - {text: 'Japan', value: 'JP'}, - {text: 'Jersey', value: 'JE'}, - {text: 'Jordan', value: 'JO'}, - {text: 'Kazakhstan', value: 'KZ'}, - {text: 'Kenya', value: 'KE'}, - {text: 'Kiribati', value: 'KI'}, - {text: 'Korea, Democratic People\'S Republic of', value: 'KP'}, - {text: 'Korea, Republic of', value: 'KR'}, - {text: 'Kuwait', value: 'KW'}, - {text: 'Kyrgyzstan', value: 'KG'}, - {text: 'Lao People\'S Democratic Republic', value: 'LA'}, - {text: 'Latvia', value: 'LV'}, - {text: 'Lebanon', value: 'LB'}, - {text: 'Lesotho', value: 'LS'}, - {text: 'Liberia', value: 'LR'}, - {text: 'Libyan Arab Jamahiriya', value: 'LY'}, - {text: 'Liechtenstein', value: 'LI'}, - {text: 'Lithuania', value: 'LT'}, - {text: 'Luxembourg', value: 'LU'}, - {text: 'Macao', value: 'MO'}, - {text: 'Macedonia, The Former Yugoslav Republic of', value: 'MK'}, - {text: 'Madagascar', value: 'MG'}, - {text: 'Malawi', value: 'MW'}, - {text: 'Malaysia', value: 'MY'}, - {text: 'Maldives', value: 'MV'}, - {text: 'Mali', value: 'ML'}, - {text: 'Malta', value: 'MT'}, - {text: 'Marshall Islands', value: 'MH'}, - {text: 'Martinique', value: 'MQ'}, - {text: 'Mauritania', value: 'MR'}, - {text: 'Mauritius', value: 'MU'}, - {text: 'Mayotte', value: 'YT'}, - {text: 'Mexico', value: 'MX'}, - {text: 'Micronesia, Federated States of', value: 'FM'}, - {text: 'Moldova, Republic of', value: 'MD'}, - {text: 'Monaco', value: 'MC'}, - {text: 'Mongolia', value: 'MN'}, - {text: 'Montserrat', value: 'MS'}, - {text: 'Morocco', value: 'MA'}, - {text: 'Mozambique', value: 'MZ'}, - {text: 'Myanmar', value: 'MM'}, - {text: 'Namibia', value: 'NA'}, - {text: 'Nauru', value: 'NR'}, - {text: 'Nepal', value: 'NP'}, - {text: 'Netherlands', value: 'NL'}, - {text: 'Netherlands Antilles', value: 'AN'}, - {text: 'New Caledonia', value: 'NC'}, - {text: 'New Zealand', value: 'NZ'}, - {text: 'Nicaragua', value: 'NI'}, - {text: 'Niger', value: 'NE'}, - {text: 'Nigeria', value: 'NG'}, - {text: 'Niue', value: 'NU'}, - {text: 'Norfolk Island', value: 'NF'}, - {text: 'Northern Mariana Islands', value: 'MP'}, - {text: 'Norway', value: 'NO'}, - {text: 'Oman', value: 'OM'}, - {text: 'Pakistan', value: 'PK'}, - {text: 'Palau', value: 'PW'}, - {text: 'Palestinian Territory, Occupied', value: 'PS'}, - {text: 'Panama', value: 'PA'}, - {text: 'Papua New Guinea', value: 'PG'}, - {text: 'Paraguay', value: 'PY'}, - {text: 'Peru', value: 'PE'}, - {text: 'Philippines', value: 'PH'}, - {text: 'Pitcairn', value: 'PN'}, - {text: 'Poland', value: 'PL'}, - {text: 'Portugal', value: 'PT'}, - {text: 'Puerto Rico', value: 'PR'}, - {text: 'Qatar', value: 'QA'}, - {text: 'Reunion', value: 'RE'}, - {text: 'Romania', value: 'RO'}, - {text: 'Russian Federation', value: 'RU'}, - {text: 'RWANDA', value: 'RW'}, - {text: 'Saint Helena', value: 'SH'}, - {text: 'Saint Kitts and Nevis', value: 'KN'}, - {text: 'Saint Lucia', value: 'LC'}, - {text: 'Saint Pierre and Miquelon', value: 'PM'}, - {text: 'Saint Vincent and the Grenadines', value: 'VC'}, - {text: 'Samoa', value: 'WS'}, - {text: 'San Marino', value: 'SM'}, - {text: 'Sao Tome and Principe', value: 'ST'}, - {text: 'Saudi Arabia', value: 'SA'}, - {text: 'Senegal', value: 'SN'}, - {text: 'Serbia and Montenegro', value: 'CS'}, - {text: 'Seychelles', value: 'SC'}, - {text: 'Sierra Leone', value: 'SL'}, - {text: 'Singapore', value: 'SG'}, - {text: 'Slovakia', value: 'SK'}, - {text: 'Slovenia', value: 'SI'}, - {text: 'Solomon Islands', value: 'SB'}, - {text: 'Somalia', value: 'SO'}, - {text: 'South Africa', value: 'ZA'}, - {text: 'South Georgia and the South Sandwich Islands', value: 'GS'}, - {text: 'Spain', value: 'ES'}, - {text: 'Sri Lanka', value: 'LK'}, - {text: 'Sudan', value: 'SD'}, - {text: 'Suritext', value: 'SR'}, - {text: 'Svalbard and Jan Mayen', value: 'SJ'}, - {text: 'Swaziland', value: 'SZ'}, - {text: 'Sweden', value: 'SE'}, - {text: 'Switzerland', value: 'CH'}, - {text: 'Syrian Arab Republic', value: 'SY'}, - {text: 'Taiwan, Province of China', value: 'TW'}, - {text: 'Tajikistan', value: 'TJ'}, - {text: 'Tanzania, United Republic of', value: 'TZ'}, - {text: 'Thailand', value: 'TH'}, - {text: 'Timor-Leste', value: 'TL'}, - {text: 'Togo', value: 'TG'}, - {text: 'Tokelau', value: 'TK'}, - {text: 'Tonga', value: 'TO'}, - {text: 'Trinidad and Tobago', value: 'TT'}, - {text: 'Tunisia', value: 'TN'}, - {text: 'Turkey', value: 'TR'}, - {text: 'Turkmenistan', value: 'TM'}, - {text: 'Turks and Caicos Islands', value: 'TC'}, - {text: 'Tuvalu', value: 'TV'}, - {text: 'Uganda', value: 'UG'}, - {text: 'Ukraine', value: 'UA'}, - {text: 'United Arab Emirates', value: 'AE'}, - {text: 'United Kingdom', value: 'GB'}, - {text: 'United States', value: 'US'}, - {text: 'United States Minor Outlying Islands', value: 'UM'}, - {text: 'Uruguay', value: 'UY'}, - {text: 'Uzbekistan', value: 'UZ'}, - {text: 'Vanuatu', value: 'VU'}, - {text: 'Venezuela', value: 'VE'}, - {text: 'Viet Nam', value: 'VN'}, - {text: 'Virgin Islands, British', value: 'VG'}, - {text: 'Virgin Islands, U.S.', value: 'VI'}, - {text: 'Wallis and Futuna', value: 'WF'}, - {text: 'Western Sahara', value: 'EH'}, - {text: 'Yemen', value: 'YE'}, - {text: 'Zambia', value: 'ZM'}, - {text: 'Zimbabwe', value: 'ZW'} - ] + if (countryTypes) { + return countryTypes; + } + + return entityTypes = countryTypesCsv + .split('\n') + .map(parseCsv) + .map(values => ({ + value: '' + values[1], + text: '' + values[1], + })) + .filter(val => val.value !== 'code'); } async getEntityTypes(): Promise { @@ -1020,7 +1054,7 @@ export class MenuOptionsMock implements MenuOptionsApi { .split('\n') .map(parseCsv) .map(values => ({ - value: '' + values[0], + value: '' + values[1], text: '' + values[1], })) .filter(val => val.value !== 'code'); @@ -1035,7 +1069,7 @@ export class MenuOptionsMock implements MenuOptionsApi { .split('\n') .map(parseCsv) .map(values => ({ - value: '' + values[0], + value: '' + values[2], text: '' + values[2], })) .filter(val => val.value !== 'Code');