From 1d99c30c697fad71a530127a5aefe02113aa6958 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Thu, 19 Dec 2024 11:18:08 +0000 Subject: [PATCH 01/12] chore(EMS-4066): application eligibility - rename exit page (#3417) * chore(EMS-4066): application eligibility - rename contract too short exit page * chore(EMS-4066): application eligibility - rename contract too short exit page * chore(EMS-4066): fix typo --- .github/workflows/test.yml | 2 +- e2e-tests/constants/routes/insurance/index.js | 2 +- .../pages/insurance/eligibility/index.js | 2 +- .../buyer-country-no-short-term-cover.spec.js | 10 +++++----- .../talk-to-an-export-finance-manager.spec.js} | 12 ++++++------ src/ui/server/constants/routes/insurance/index.ts | 2 +- .../templates/insurance/eligibility/index.ts | 2 +- .../pages/insurance/eligibility/index.ts | 4 ++-- .../buyer-country/country-redirects.test.ts | 6 +++--- .../insurance/eligibility/buyer-country/index.ts | 6 +++--- .../index.test.ts | 6 +++--- .../index.ts | 8 ++++---- .../insurance/eligibility/index.test.ts | 6 +++--- .../insurance/eligibility/index.ts | 4 ++-- .../routes/insurance/eligibility/index.test.ts | 4 ++-- src/ui/server/routes/insurance/eligibility/index.ts | 4 ++-- ...ort.njk => talk-to-an-export-finance-manager.njk} | 0 17 files changed, 40 insertions(+), 40 deletions(-) rename e2e-tests/insurance/cypress/e2e/journeys/eligibility/{contract-too-short/contract-too-short.spec.js => talk-to-an-export-finance-manager/talk-to-an-export-finance-manager.spec.js} (75%) rename src/ui/server/controllers/insurance/eligibility/{contract-too-short => talk-to-an-export-finance-manager}/index.test.ts (77%) rename src/ui/server/controllers/insurance/eligibility/{contract-too-short => talk-to-an-export-finance-manager}/index.ts (65%) rename src/ui/templates/insurance/eligibility/{contract-too-short.njk => talk-to-an-export-finance-manager.njk} (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ac603a2f2..6778ceee90 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -521,7 +521,6 @@ jobs: 'eligibility/cannot-apply/**/*.spec.js', 'eligibility/cannot-apply-multiple-risks/**/*.spec.js', 'eligibility/cannot-skip-flow/**/*.spec.js', - 'eligibility/contract-too-short/**/*.spec.js', 'eligibility/change-your-answers/**/*.spec.js', 'eligibility/check-your-answers/**/*.spec.js', 'eligibility/companies-house/**/*.spec.js', @@ -535,6 +534,7 @@ jobs: 'eligibility/member-of-a-group/**/*.spec.js', 'eligibility/no-companies-house-number/**/*.spec.js', 'eligibility/party-to-consortium/**/*.spec.js', + 'eligibility/talk-to-an-export-finance-manager/**/*.spec.js', 'eligibility/total-value-insured/**/*.spec.js', 'eligibility/uk-goods-or-services/**/*.spec.js', ] diff --git a/e2e-tests/constants/routes/insurance/index.js b/e2e-tests/constants/routes/insurance/index.js index 95a915f5e0..3700cc1aa8 100644 --- a/e2e-tests/constants/routes/insurance/index.js +++ b/e2e-tests/constants/routes/insurance/index.js @@ -48,7 +48,7 @@ export const INSURANCE_ROUTES = { ELIGIBLE_TO_APPLY_ONLINE: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/eligible-to-apply-online`, HAVE_AN_ACCOUNT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/do-you-have-an-account`, NEED_TO_START_AGAIN: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/need-to-start-again`, - CONTRACT_TOO_SHORT_EXIT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`, + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`, PARTY_TO_CONSORTIUM: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/party-to-any-consortium`, PARTY_TO_CONSORTIUM_CHANGE: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/party-to-any-consortium/change`, MEMBER_OF_A_GROUP: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/member-of-a-group`, diff --git a/e2e-tests/content-strings/pages/insurance/eligibility/index.js b/e2e-tests/content-strings/pages/insurance/eligibility/index.js index aa81837374..ecafb7d40a 100644 --- a/e2e-tests/content-strings/pages/insurance/eligibility/index.js +++ b/e2e-tests/content-strings/pages/insurance/eligibility/index.js @@ -168,7 +168,7 @@ export const HAVE_AN_ACCOUNT = { PAGE_TITLE: 'Do you have an account with us?', }; -export const CONTRACT_TOO_SHORT_EXIT = { +export const TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT = { PAGE_TITLE: 'Talk to an export finance manager', INTRO: "We do not normally offer short term cover for the country you've selected.", CONTACT_EFM: { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js index 46b31d399e..d4c0485ff7 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js @@ -2,7 +2,7 @@ import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries'; const { - ELIGIBILITY: { CONTRACT_TOO_SHORT_EXIT }, + ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, } = INSURANCE_ROUTES; const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NO_SHORT_TERM_COVER_1.NAME; @@ -18,14 +18,14 @@ context( }); describe(COUNTRY_NAME_1, () => { - it(`redirects to ${CONTRACT_TOO_SHORT_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, CONTRACT_TOO_SHORT_EXIT); + it(`redirects to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); describe(COUNTRY_NAME_2, () => { - it(`redirects to ${CONTRACT_TOO_SHORT_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, CONTRACT_TOO_SHORT_EXIT); + it(`redirects to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); }, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/contract-too-short/contract-too-short.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/talk-to-an-export-finance-manager/talk-to-an-export-finance-manager.spec.js similarity index 75% rename from e2e-tests/insurance/cypress/e2e/journeys/eligibility/contract-too-short/contract-too-short.spec.js rename to e2e-tests/insurance/cypress/e2e/journeys/eligibility/talk-to-an-export-finance-manager/talk-to-an-export-finance-manager.spec.js index 735116f20b..6337e043db 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/contract-too-short/contract-too-short.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/talk-to-an-export-finance-manager/talk-to-an-export-finance-manager.spec.js @@ -2,18 +2,18 @@ import { actions } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; -const CONTENT_STRINGS = PAGES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT; +const CONTENT_STRINGS = PAGES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT; const { CONTACT_EFM } = CONTENT_STRINGS; const { - ELIGIBILITY: { CONTRACT_TOO_SHORT_EXIT }, + ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, } = INSURANCE_ROUTES; const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Contract too short page', () => { - const url = `${baseUrl}${CONTRACT_TOO_SHORT_EXIT}`; +context('Insurance - Eligibility - Talk to an export finance manager page', () => { + const url = `${baseUrl}${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT}`; before(() => { cy.navigateToUrl(url); @@ -28,8 +28,8 @@ context('Insurance - Eligibility - Contract too short page', () => { it('renders core page elements', () => { cy.corePageChecks({ pageTitle: CONTENT_STRINGS.PAGE_TITLE, - backLink: `${CONTRACT_TOO_SHORT_EXIT}#`, - currentHref: CONTRACT_TOO_SHORT_EXIT, + backLink: `${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT}#`, + currentHref: TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, assertAuthenticatedHeader: false, assertSaveAndBackButtonDoesNotExist: true, hasAForm: false, diff --git a/src/ui/server/constants/routes/insurance/index.ts b/src/ui/server/constants/routes/insurance/index.ts index 1b91d3fa12..f6629fa80a 100644 --- a/src/ui/server/constants/routes/insurance/index.ts +++ b/src/ui/server/constants/routes/insurance/index.ts @@ -48,7 +48,7 @@ export const INSURANCE_ROUTES = { ELIGIBLE_TO_APPLY_ONLINE: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/eligible-to-apply-online`, HAVE_AN_ACCOUNT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/do-you-have-an-account`, NEED_TO_START_AGAIN: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/need-to-start-again`, - CONTRACT_TOO_SHORT_EXIT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`, + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`, PARTY_TO_CONSORTIUM: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/party-to-any-consortium`, PARTY_TO_CONSORTIUM_CHANGE: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/party-to-any-consortium/change`, MEMBER_OF_A_GROUP: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/member-of-a-group`, diff --git a/src/ui/server/constants/templates/insurance/eligibility/index.ts b/src/ui/server/constants/templates/insurance/eligibility/index.ts index e20a7c99f1..5f6ac216d7 100644 --- a/src/ui/server/constants/templates/insurance/eligibility/index.ts +++ b/src/ui/server/constants/templates/insurance/eligibility/index.ts @@ -13,5 +13,5 @@ export const ELIGIBILITY_TEMPLATES = { CANNOT_APPLY_MULTIPLE_RISKS_EXIT: 'insurance/eligibility/cannot-apply-multiple-risks.njk', CHECK_YOUR_ANSWERS: 'insurance/eligibility/check-your-answers.njk', ELIGIBLE_TO_APPLY_ONLINE: 'insurance/eligibility/eligible-to-apply-online.njk', - CONTRACT_TOO_SHORT_EXIT: 'insurance/eligibility/contract-too-short.njk', + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT: 'insurance/eligibility/talk-to-an-export-finance-manager.njk', }; diff --git a/src/ui/server/content-strings/pages/insurance/eligibility/index.ts b/src/ui/server/content-strings/pages/insurance/eligibility/index.ts index 102b44920b..1519dedd2b 100644 --- a/src/ui/server/content-strings/pages/insurance/eligibility/index.ts +++ b/src/ui/server/content-strings/pages/insurance/eligibility/index.ts @@ -168,7 +168,7 @@ const HAVE_AN_ACCOUNT = { PAGE_TITLE: 'Do you have an account with us?', }; -const CONTRACT_TOO_SHORT_EXIT = { +const TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT = { PAGE_TITLE: 'Talk to an export finance manager', INTRO: "We do not normally offer short term cover for the country you've selected.", CONTACT_EFM: { @@ -206,7 +206,7 @@ export default { CHECK_YOUR_ANSWERS, ELIGIBLE_TO_APPLY_ONLINE, HAVE_AN_ACCOUNT, - CONTRACT_TOO_SHORT_EXIT, + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, PARTY_TO_CONSORTIUM, MEMBER_OF_A_GROUP, MEMBER_OF_A_GROUP_EXIT, diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts index 132098e347..686ab8d790 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts @@ -10,7 +10,7 @@ import { Request, Response } from '../../../../../types'; import { mockReq, mockRes, mockCountries } from '../../../../test-mocks'; const { - ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, BUYER_COUNTRY_CHANGE, CHECK_YOUR_ANSWERS, CONTRACT_TOO_SHORT_EXIT }, + ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, BUYER_COUNTRY_CHANGE, CHECK_YOUR_ANSWERS, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, } = INSURANCE_ROUTES; describe('controllers/insurance/eligibility/buyer-country - redirects', () => { @@ -130,10 +130,10 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { expect(req.session.submittedData).toEqual(expected); }); - it(`should redirect to ${CONTRACT_TOO_SHORT_EXIT}`, async () => { + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT}`, async () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(CONTRACT_TOO_SHORT_EXIT); + expect(res.redirect).toHaveBeenCalledWith(TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts index 6f7751d311..ba66e5eb56 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts @@ -25,7 +25,7 @@ export const TEMPLATE = TEMPLATES.SHARED_PAGES.BUYER_COUNTRY; const { PROBLEM_WITH_SERVICE, - ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, CHECK_YOUR_ANSWERS, CONTRACT_TOO_SHORT_EXIT }, + ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, CHECK_YOUR_ANSWERS, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, } = INSURANCE_ROUTES; export const get = async (req: Request, res: Response) => { @@ -92,7 +92,7 @@ export const post = async (req: Request, res: Response) => { /** * If a country has no insurance support and no short term cover, - * redirect to CONTRACT_TOO_SHORT_EXIT. + * redirect to TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT. */ const noShortTermCover = !country.noInsuranceSupport && !country.shortTermCover; @@ -104,7 +104,7 @@ export const post = async (req: Request, res: Response) => { insuranceEligibility: updateSubmittedData(populatedData, req.session.submittedData.insuranceEligibility), }; - return res.redirect(CONTRACT_TOO_SHORT_EXIT); + return res.redirect(TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); } if (country.canApplyForInsuranceOnline) { diff --git a/src/ui/server/controllers/insurance/eligibility/contract-too-short/index.test.ts b/src/ui/server/controllers/insurance/eligibility/talk-to-an-export-finance-manager/index.test.ts similarity index 77% rename from src/ui/server/controllers/insurance/eligibility/contract-too-short/index.test.ts rename to src/ui/server/controllers/insurance/eligibility/talk-to-an-export-finance-manager/index.test.ts index 1fd6403b19..c73433ec0e 100644 --- a/src/ui/server/controllers/insurance/eligibility/contract-too-short/index.test.ts +++ b/src/ui/server/controllers/insurance/eligibility/talk-to-an-export-finance-manager/index.test.ts @@ -6,7 +6,7 @@ import getUserNameFromSession from '../../../../helpers/get-user-name-from-sessi import { mockReq, mockRes } from '../../../../test-mocks'; import { Request, Response } from '../../../../../types'; -describe('controllers/insurance/eligibility/contract-too-short', () => { +describe('controllers/insurance/eligibility/talk-to-an-export-finance-manager', () => { let req: Request; let res: Response; @@ -17,7 +17,7 @@ describe('controllers/insurance/eligibility/contract-too-short', () => { describe('TEMPLATE', () => { it('should have the correct template defined', () => { - expect(TEMPLATE).toEqual(TEMPLATES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT); + expect(TEMPLATE).toEqual(TEMPLATES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); @@ -27,7 +27,7 @@ describe('controllers/insurance/eligibility/contract-too-short', () => { const expectedVariables = { ...corePageVariables({ - PAGE_CONTENT_STRINGS: PAGES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT, + PAGE_CONTENT_STRINGS: PAGES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, BACK_LINK: req.headers.referer, }), userName: getUserNameFromSession(req.session.user), diff --git a/src/ui/server/controllers/insurance/eligibility/contract-too-short/index.ts b/src/ui/server/controllers/insurance/eligibility/talk-to-an-export-finance-manager/index.ts similarity index 65% rename from src/ui/server/controllers/insurance/eligibility/contract-too-short/index.ts rename to src/ui/server/controllers/insurance/eligibility/talk-to-an-export-finance-manager/index.ts index d60848344b..510a07c1db 100644 --- a/src/ui/server/controllers/insurance/eligibility/contract-too-short/index.ts +++ b/src/ui/server/controllers/insurance/eligibility/talk-to-an-export-finance-manager/index.ts @@ -4,19 +4,19 @@ import { Request, Response } from '../../../../../types'; import corePageVariables from '../../../../helpers/page-variables/core/insurance'; import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; -export const TEMPLATE = TEMPLATES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT; +export const TEMPLATE = TEMPLATES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT; /** * get - * Render the "Talk to EFM - contract too short" exit page + * Render the "Talk to an export finance manager" exit page * @param {Express.Request} Express request * @param {Express.Response} Express response - * @returns {Express.Response.render} "Talk to EFM - contract too short" exit page + * @returns {Express.Response.render} "Talk to an export finance manager" exit page */ export const get = (req: Request, res: Response) => res.render(TEMPLATE, { ...corePageVariables({ - PAGE_CONTENT_STRINGS: PAGES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT, + PAGE_CONTENT_STRINGS: PAGES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, BACK_LINK: req.headers.referer, }), userName: getUserNameFromSession(req.session.user), diff --git a/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.test.ts b/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.test.ts index ec191007b1..40348c82ac 100644 --- a/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.test.ts +++ b/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.test.ts @@ -36,7 +36,7 @@ const { COMPANY_DETAILS_CHANGE, CANNOT_APPLY_MULTIPLE_RISKS_EXIT, ELIGIBLE_TO_APPLY_ONLINE, - CONTRACT_TOO_SHORT_EXIT, + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, PARTY_TO_CONSORTIUM, PARTY_TO_CONSORTIUM_CHANGE, MEMBER_OF_A_GROUP, @@ -156,9 +156,9 @@ describe('middleware/required-data-provided/insurance/eligibility', () => { }); }); - describe(`when req.originalUrl is ${CONTRACT_TOO_SHORT_EXIT}`, () => { + describe(`when req.originalUrl is ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT}`, () => { it('should call req.next', () => { - req.originalUrl = CONTRACT_TOO_SHORT_EXIT; + req.originalUrl = TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT; requiredInsuranceEligibilityDataProvided(req, res, nextSpy); expect(nextSpy).toHaveBeenCalled(); diff --git a/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.ts b/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.ts index d6ad878b34..74c267689f 100644 --- a/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.ts +++ b/src/ui/server/middleware/required-data-provided/insurance/eligibility/index.ts @@ -35,7 +35,7 @@ const { COMPANY_DETAILS_CHANGE, CANNOT_APPLY_MULTIPLE_RISKS_EXIT, ELIGIBLE_TO_APPLY_ONLINE, - CONTRACT_TOO_SHORT_EXIT, + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, PARTY_TO_CONSORTIUM, PARTY_TO_CONSORTIUM_CHANGE, MEMBER_OF_A_GROUP, @@ -137,7 +137,7 @@ export const requiredInsuranceEligibilityDataProvided = (req: Request, res: Resp HAVE_AN_ACCOUNT, ACCOUNT.CREATE.YOUR_DETAILS, ACCOUNT.SIGN_IN.ROOT, - CONTRACT_TOO_SHORT_EXIT, + TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, MEMBER_OF_A_GROUP_EXIT, PARTY_TO_CONSORTIUM_EXIT, ]; diff --git a/src/ui/server/routes/insurance/eligibility/index.test.ts b/src/ui/server/routes/insurance/eligibility/index.test.ts index 6b7bab8284..ab4f93c4fd 100644 --- a/src/ui/server/routes/insurance/eligibility/index.test.ts +++ b/src/ui/server/routes/insurance/eligibility/index.test.ts @@ -22,7 +22,7 @@ import { get as eligibleToApplyOnlineGet, post as eligibleToApplyOnlinePost } fr import { get as haveAnAccountGet, post as haveAnAccountPost } from '../../../controllers/insurance/eligibility/do-you-have-an-account'; import { get as cannotApplyGet } from '../../../controllers/insurance/eligibility/cannot-apply'; import { get as needToStartAgainGet, post as needToStartAgainPost } from '../../../controllers/insurance/eligibility/need-to-start-again'; -import { get as contractTooShortGet } from '../../../controllers/insurance/eligibility/contract-too-short'; +import { get as contractTooShortGet } from '../../../controllers/insurance/eligibility/talk-to-an-export-finance-manager'; import { get as partyToConsortiumExitGet } from '../../../controllers/insurance/eligibility/party-to-consortium-exit'; import { get as memberOfAGroupExitGet } from '../../../controllers/insurance/eligibility/member-of-a-group-exit'; @@ -102,7 +102,7 @@ describe('routes/insurance/eligibility', () => { expect(get).toHaveBeenCalledWith(ROUTES.INSURANCE.ELIGIBILITY.NEED_TO_START_AGAIN, needToStartAgainGet); expect(post).toHaveBeenCalledWith(ROUTES.INSURANCE.ELIGIBILITY.NEED_TO_START_AGAIN, needToStartAgainPost); - expect(get).toHaveBeenCalledWith(ROUTES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT, contractTooShortGet); + expect(get).toHaveBeenCalledWith(ROUTES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, contractTooShortGet); expect(get).toHaveBeenCalledWith(ROUTES.INSURANCE.ELIGIBILITY.PARTY_TO_CONSORTIUM_EXIT, partyToConsortiumExitGet); diff --git a/src/ui/server/routes/insurance/eligibility/index.ts b/src/ui/server/routes/insurance/eligibility/index.ts index 91c53d5447..7865b47103 100644 --- a/src/ui/server/routes/insurance/eligibility/index.ts +++ b/src/ui/server/routes/insurance/eligibility/index.ts @@ -22,7 +22,7 @@ import { get as eligibleToApplyOnlineGet, post as eligibleToApplyOnlinePost } fr import { get as haveAnAccountGet, post as haveAnAccountPost } from '../../../controllers/insurance/eligibility/do-you-have-an-account'; import { get as cannotApplyGet } from '../../../controllers/insurance/eligibility/cannot-apply'; import { get as needToStartAgainGet, post as needToStartAgainPost } from '../../../controllers/insurance/eligibility/need-to-start-again'; -import { get as talkToEfmTooShortGet } from '../../../controllers/insurance/eligibility/contract-too-short'; +import { get as talkToEfmTooShortGet } from '../../../controllers/insurance/eligibility/talk-to-an-export-finance-manager'; import { get as partyToConsortiumExitGet } from '../../../controllers/insurance/eligibility/party-to-consortium-exit'; import { get as memberOfAGroupExitGet } from '../../../controllers/insurance/eligibility/member-of-a-group-exit'; @@ -111,7 +111,7 @@ insuranceEligibilityRouter.get(ROUTES.INSURANCE.ELIGIBILITY.CANNOT_APPLY_EXIT, c insuranceEligibilityRouter.get(ROUTES.INSURANCE.ELIGIBILITY.NEED_TO_START_AGAIN, needToStartAgainGet); insuranceEligibilityRouter.post(ROUTES.INSURANCE.ELIGIBILITY.NEED_TO_START_AGAIN, needToStartAgainPost); -insuranceEligibilityRouter.get(ROUTES.INSURANCE.ELIGIBILITY.CONTRACT_TOO_SHORT_EXIT, talkToEfmTooShortGet); +insuranceEligibilityRouter.get(ROUTES.INSURANCE.ELIGIBILITY.TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT, talkToEfmTooShortGet); insuranceEligibilityRouter.get(ROUTES.INSURANCE.ELIGIBILITY.PARTY_TO_CONSORTIUM_EXIT, partyToConsortiumExitGet); diff --git a/src/ui/templates/insurance/eligibility/contract-too-short.njk b/src/ui/templates/insurance/eligibility/talk-to-an-export-finance-manager.njk similarity index 100% rename from src/ui/templates/insurance/eligibility/contract-too-short.njk rename to src/ui/templates/insurance/eligibility/talk-to-an-export-finance-manager.njk From 77ed6759ab821c2a85e8d5537e0edb2dc7a3727b Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Thu, 19 Dec 2024 14:30:11 +0000 Subject: [PATCH 02/12] feat(EMS-3842): country risk logic - application - country rating, online support (#3416) * feat(EMS-3842): country risk logic - application - country rating * feat(EMS-3842): add country support logs to ui buyer country controllers * chore(EMS-3842): rename function * chore(EMS-3842): rename function * feat(EMS-3842): country risk logic - application - a/b rating conditions * feat(EMS-3842): country risk logic - application - c/d rating conditions * feat(EMS-3842): exit page condition - temporary comment out * feat(EMS-3842): rename country support flag * feat(EMS-3842): fix/update ui redirection logic * chore(EMS-3842): rename constant * feat(EMS-3842): update todo comment * feat(EMS-3842): address todo comments * feat(EMS-3842): address todo comment * feat(EMS-3842): fix typo * chore(EMS-3842): remove todo comment * feat(EMS-3842): fix/update tests * feat(EMS-3842): improve unit test coverage * feat(EMS-3842): fix quote generation * feat(EMS-3842): replace all instances of riskCategory * feat(EMS-3842): various code improvements/fixes * feat(EMS-3842): code improvements/fixes * feat(EMS-3842): fix/update querying issue * feat(EMS-3842): fix/update e2e tests * feat(EMS-3842): fix/update new console logs --- e2e-tests/constants/api.js | 2 +- e2e-tests/constants/external-apis.js | 21 +- ...uyer-country-unsupported-countries.spec.js | 18 +- .../eligibility/cannot-apply-page.spec.js | 3 +- .../cannot-apply/cannot-apply-page.spec.js | 3 +- .../about-goods-or-services.spec.js | 5 +- .../agent-charges/agent-charges.spec.js | 5 +- .../agent-details/agent-details.spec.js | 5 +- .../other-company-details.spec.js | 5 +- .../country-autocomplete-input/index.js | 11 +- generate-exip-pricing-grid/index.js | 16 +- src/api/.keystone/config.js | 268 ++++++++++++++---- src/api/constants/external-apis.ts | 11 +- src/api/custom-schema/type-defs.ts | 3 +- .../index.test.ts | 50 ++++ .../has-valid-esra-classification/index.ts | 31 ++ .../has-valid-short-term-cover/index.test.ts | 30 ++ .../has-valid-short-term-cover/index.ts | 31 ++ .../index.test.ts | 56 +--- .../can-apply-for-insurance-online/index.ts | 27 +- .../index.test.ts | 10 +- .../index.ts | 6 +- .../can-get-a-quote-by-email/index.test.ts | 50 ++-- .../can-get-a-quote-by-email/index.ts | 11 +- .../can-get-a-quote-online/index.test.ts | 50 ++-- .../can-get-a-quote-online/index.ts | 11 +- .../cannot-get-a-quote/index.test.ts | 49 +--- .../cannot-get-a-quote/index.ts | 11 +- .../country-rating-is-a-or-b/index.test.ts | 40 +++ .../country-rating-is-a-or-b/index.ts | 25 ++ .../country-rating-is-c-or-d/index.test.ts | 40 +++ .../country-rating-is-c-or-d/index.ts | 25 ++ .../map-CIS-country/index.test.ts | 60 ++-- .../map-CIS-country/index.ts | 50 ++-- .../map-esra-classification/index.test.ts | 46 +++ .../map-esra-classification/index.ts | 29 ++ .../map-risk-category/index.test.ts | 46 --- .../map-risk-category/index.ts | 26 -- .../map-short-term-cover-available/index.ts | 2 +- .../no-insurance-support/index.test.ts | 24 -- .../no-insurance-support/index.ts | 13 - .../index-rating-a.test.ts | 115 ++++++++ .../index-rating-b.test.ts | 115 ++++++++ .../index-rating-c-and-d.test.ts | 36 +++ .../index-rating-none.test.ts | 36 +++ .../a-and-b-rating-conditions/index.ts | 47 +++ .../index-rating-a-and-b.test.ts | 36 +++ .../index-rating-c.test.ts | 196 +++++++++++++ .../index-rating-d.test.ts | 196 +++++++++++++ .../index-rating-none.test.ts | 36 +++ .../c-and-d-rating-conditions/index.ts | 59 ++++ .../no-online-insurance-support/index.test.ts | 100 +++++++ .../no-online-insurance-support/index.ts | 31 ++ src/api/schema.graphql | 3 +- src/api/test-mocks/index.ts | 7 + src/api/test-mocks/mock-CIS-countries.ts | 21 +- src/api/types/country/index.ts | 22 +- src/api/types/helpers/index.ts | 12 + .../buyer-country/country-redirects.test.ts | 22 +- .../eligibility/buyer-country/index.ts | 24 +- .../controllers/quote/buyer-country/index.ts | 18 ++ ...remium-rate-multi-policy-high-risk.test.ts | 8 +- ...um-rate-multi-policy-standard-risk.test.ts | 8 +- ...m-rate-multi-policy-very-high-risk.test.ts | 8 +- ...emium-rate-single-policy-high-risk.test.ts | 20 +- ...m-rate-single-policy-standard-risk.test.ts | 20 +- ...emium-rate-single-policy-very-high.test.ts | 20 +- .../get-premium-rate/index.test.ts | 14 +- .../generate-quote/get-premium-rate/index.ts | 6 +- src/ui/server/generate-quote/index.test.ts | 2 +- src/ui/server/generate-quote/index.ts | 2 +- .../graphql/queries/APIM/CIS-countries.ts | 3 +- .../index.test.ts | 4 +- .../index.ts | 4 +- src/ui/server/test-mocks/mock-countries.ts | 14 +- src/ui/types/country.d.ts | 3 +- 76 files changed, 1975 insertions(+), 518 deletions(-) create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts rename src/api/helpers/map-CIS-countries/map-CIS-country/{can-apply-offline => can-apply-for-quote-offline}/index.test.ts (79%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{can-apply-offline => can-apply-for-quote-offline}/index.ts (79%) create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts diff --git a/e2e-tests/constants/api.js b/e2e-tests/constants/api.js index 2896a4f4da..3d0b369911 100644 --- a/e2e-tests/constants/api.js +++ b/e2e-tests/constants/api.js @@ -2,7 +2,7 @@ export const API = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard Risk', diff --git a/e2e-tests/constants/external-apis.js b/e2e-tests/constants/external-apis.js index 70797251ec..93aaa1bb58 100644 --- a/e2e-tests/constants/external-apis.js +++ b/e2e-tests/constants/external-apis.js @@ -2,10 +2,11 @@ export const EXTERNAL_API_DEFINITIONS = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard Risk', + NONE: 'None', }, SHORT_TERM_COVER_AVAILABLE: { YES: 'Yes', @@ -20,8 +21,22 @@ export const EXTERNAL_API_DEFINITIONS = { NO: 'N', }, NO_COVER: 'Off cover', - INVALID_COUNTRIES: ['EC Market n/k', 'Non EC Market n/k', 'Non UK', 'Third Country', 'Eastern and Southern African Trade and Development Bank'], + INVALID_COUNTRIES: [ + 'CABEI', + 'Cor Andino Fom', + 'Eastern and Southern African Trade and Development Bank', + 'EC Market n/k', + 'Non EC Market n/k', + 'Non UK', + 'Third Country', + ], INVALID_CURRENCIES: ['Gold'], + COUNTRY_RATINGS: { + A: ['AAA', 'AA+', 'AA', 'AA-', 'A+', 'A', 'A-'], + B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], + C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], + D: ['D'], + }, }, COMPANIES_HOUSE: { COMPANY_STATUS: { @@ -32,7 +47,7 @@ export const EXTERNAL_API_DEFINITIONS = { export const EXTERNAL_API_MAPPINGS = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard', diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js index 0f3f5e2684..a7b8a94107 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js @@ -2,7 +2,7 @@ import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries'; const { - ELIGIBILITY: { CANNOT_APPLY_EXIT }, + ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, } = INSURANCE_ROUTES; const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME; @@ -21,26 +21,26 @@ context(`Insurance - Buyer country page - ${contextString} - Unsupported countri }); describe(COUNTRY_NAME_1, () => { - it(`redirects to ${CANNOT_APPLY_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, CANNOT_APPLY_EXIT); + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); describe(COUNTRY_NAME_2, () => { - it(`redirects to ${CANNOT_APPLY_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, CANNOT_APPLY_EXIT); + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); describe(COUNTRY_NAME_3, () => { - it(`redirects to ${CANNOT_APPLY_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_3, CANNOT_APPLY_EXIT); + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_3, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); describe(COUNTRY_NAME_4, () => { - it(`redirects to ${CANNOT_APPLY_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, CANNOT_APPLY_EXIT); + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js index 0de7e240a5..b010cba1aa 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js @@ -16,7 +16,8 @@ const COUNTRY_NAME_UNSUPPORTED = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME; const baseUrl = Cypress.config('baseUrl'); -context('Insurance Eligibility - Cannot apply exit page', () => { +// TODO: EMS-4065 +context.skip('Insurance Eligibility - Cannot apply exit page', () => { beforeEach(() => { cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js index 68c0d22dd4..9229353dc3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js @@ -17,7 +17,8 @@ const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME; const baseUrl = Cypress.config('baseUrl'); -context( +// TODO: EMS-4065 +context.skip( 'Insurance - Cannot apply page - as an exporter, I want to check if UKEF offer credit insurance policy for where my buyer is based - Unsupported country', () => { beforeEach(() => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js index 9e4b6076a6..e5fe43121c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js @@ -135,7 +135,10 @@ context( cy.clickYesRadioInput(); }); - assertCountryAutocompleteInput({ fieldId }); + assertCountryAutocompleteInput({ + fieldId, + assertFilteredCisCountries: false, + }); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js index 734436cf5f..097b41bb44 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js @@ -104,7 +104,10 @@ context( }); describe(`searchable autocomplete input (${PAYABLE_COUNTRY_CODE})`, () => { - assertCountryAutocompleteInput({ fieldId: PAYABLE_COUNTRY_CODE }); + assertCountryAutocompleteInput({ + fieldId: PAYABLE_COUNTRY_CODE, + assertFilteredCisCountries: false, + }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js index d00ffdcbed..3af6495d96 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js @@ -86,7 +86,10 @@ context( }); describe(`searchable autocomplete input (${COUNTRY_CODE})`, () => { - assertCountryAutocompleteInput({ fieldId: COUNTRY_CODE }); + assertCountryAutocompleteInput({ + fieldId: COUNTRY_CODE, + assertFilteredCisCountries: false, + }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js index 0f971b3382..0956aadcad 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js @@ -77,7 +77,10 @@ context(`Insurance - Policy - Other company details page - ${story}`, () => { }); describe(`searchable autocomplete input (${COUNTRY_CODE})`, () => { - assertCountryAutocompleteInput({ fieldId: COUNTRY_CODE }); + assertCountryAutocompleteInput({ + fieldId: COUNTRY_CODE, + assertFilteredCisCountries: false, + }); }); it(`renders ${COMPANY_NUMBER} label and input`, () => { diff --git a/e2e-tests/shared-test-assertions/country-autocomplete-input/index.js b/e2e-tests/shared-test-assertions/country-autocomplete-input/index.js index ea87c44a2c..d4b3ec9052 100644 --- a/e2e-tests/shared-test-assertions/country-autocomplete-input/index.js +++ b/e2e-tests/shared-test-assertions/country-autocomplete-input/index.js @@ -9,8 +9,9 @@ const { NAME: ALGERIA } = DZA; * assertCountryAutocompleteInput * Assert a country autocomplete field * @param {String} fieldId: Country field ID + * @param {Boolean} assertFilteredCisCountries: Whether to check for filtered CIS countries. */ -export const assertCountryAutocompleteInput = ({ fieldId }) => { +export const assertCountryAutocompleteInput = ({ fieldId, assertFilteredCisCountries }) => { const field = autoCompleteField(fieldId); it('has working client side JS', () => { @@ -25,9 +26,11 @@ export const assertCountryAutocompleteInput = ({ fieldId }) => { assertions.rendersNoResultsMessage(field, 'test'); }); - it('renders `no results` message for invalid/filtered out CIS countries', () => { - assertions.doesNotRenderFilteredCisCountries(field); - }); + if (assertFilteredCisCountries) { + it('renders `no results` message for invalid/filtered out CIS countries', () => { + assertions.doesNotRenderFilteredCisCountries(field); + }); + } it('renders a single country result after searching', () => { assertions.rendersSingleResult(field, 'Alg'); diff --git a/generate-exip-pricing-grid/index.js b/generate-exip-pricing-grid/index.js index 8c51b0602b..13326c40cf 100644 --- a/generate-exip-pricing-grid/index.js +++ b/generate-exip-pricing-grid/index.js @@ -140,16 +140,16 @@ const mapRowRates = (row) => { * @param {String} Risk category from spreadsheet, e.g "Standard Risk" * @returns {String} Risk category in the grid, e.g "STANDARD" */ -const mapRiskCategory = (riskCategory) => { - if (riskCategory === RISK.STANDARD) { +const mapRiskCategory = (esraClassification) => { + if (esraClassification === RISK.STANDARD) { return RISK_FIELDS.STANDARD; } - if (riskCategory === RISK.HIGH) { + if (esraClassification === RISK.HIGH) { return RISK_FIELDS.HIGH; } - if (riskCategory === RISK.VERY_HIGH) { + if (esraClassification === RISK.VERY_HIGH) { return RISK_FIELDS.VERY_HIGH; } @@ -166,8 +166,8 @@ const mapRiskCategory = (riskCategory) => { * @param {String} Risk category * @returns {Object} Updated pricing grid */ -const addRowToGrid = (grid, months, rates, policyType, riskCategory) => { - grid[policyType][riskCategory].push({ +const addRowToGrid = (grid, months, rates, policyType, esraClassification) => { + grid[policyType][esraClassification].push({ months, rates, }); @@ -193,9 +193,9 @@ const addPolicyToGrid = (grid, policyType, rows) => { const months = Number(row[1]); const rates = mapRowRates(row); - const riskCategory = mapRiskCategory(row[0]); + const esraClassification = mapRiskCategory(row[0]); - updatedGrid = addRowToGrid(grid, months, rates, policyType, riskCategory); + updatedGrid = addRowToGrid(grid, months, rates, policyType, esraClassification); } }); diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 468d6376a8..dbae4e93c1 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -822,10 +822,11 @@ var EXPORT_CONTRACT_AWARD_METHOD = { // constants/external-apis.ts var EXTERNAL_API_DEFINITIONS = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard Risk', + NONE: 'None', }, SHORT_TERM_COVER_AVAILABLE: { YES: 'Yes', @@ -850,6 +851,12 @@ var EXTERNAL_API_DEFINITIONS = { 'Third Country', ], INVALID_CURRENCIES: ['Gold'], + COUNTRY_RATINGS: { + A: ['AAA', 'AA+', 'AA', 'AA-', 'A+', 'A', 'A-'], + B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], + C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], + D: ['D'], + }, }, COMPANIES_HOUSE: { COMPANY_STATUS: { @@ -859,7 +866,7 @@ var EXTERNAL_API_DEFINITIONS = { }; var EXTERNAL_API_MAPPINGS = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard', @@ -2813,7 +2820,7 @@ var typeDefs = ` isoCode: String! name: String shortTermCover: Boolean - riskCategory: String + esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean canGetAQuoteOffline: Boolean @@ -2821,6 +2828,7 @@ var typeDefs = ` cannotGetAQuote: Boolean cannotApply: Boolean canApplyForInsuranceOnline: Boolean + noOnlineInsuranceSupport: Boolean noInsuranceSupport: Boolean } @@ -8962,21 +8970,23 @@ var filterCisEntries = (arr, invalidEntries, entityPropertyName) => { }; var filter_cis_entries_default = filterCisEntries; -// helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts -var { CIS } = EXTERNAL_API_DEFINITIONS; -var mapRiskCategory = (str) => { - if (str === CIS.RISK.STANDARD) { - return EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; +// helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts +var { + CIS: { ESRA_CLASSIFICATION }, +} = EXTERNAL_API_DEFINITIONS; +var mapEsraClassification = (str) => { + if (str === ESRA_CLASSIFICATION.STANDARD) { + return EXTERNAL_API_MAPPINGS.CIS.ESRA_CLASSIFICATION.STANDARD; } - if (str === CIS.RISK.HIGH) { + if (str === ESRA_CLASSIFICATION.HIGH) { return str; } - if (str === CIS.RISK.VERY_HIGH) { + if (str === ESRA_CLASSIFICATION.VERY_HIGH) { return str; } return null; }; -var map_risk_category_default = mapRiskCategory; +var map_esra_classification_default = mapEsraClassification; // helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts var { @@ -8999,9 +9009,9 @@ var mapShortTermCoverAvailable = (str) => { var map_short_term_cover_available_default = mapShortTermCoverAvailable; // helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts -var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; +var { CIS } = EXTERNAL_API_DEFINITIONS; var mapNbiIssueAvailable = (str) => { - if (str === CIS2.NBI_ISSUE_AVAILABLE.YES) { + if (str === CIS.NBI_ISSUE_AVAILABLE.YES) { return true; } return false; @@ -9009,8 +9019,8 @@ var mapNbiIssueAvailable = (str) => { var map_NBI_issue_available_default = mapNbiIssueAvailable; // helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts -var canGetAQuoteOnline = (country) => { - if (country.riskCategory && country.shortTermCover && country.nbiIssueAvailable) { +var canGetAQuoteOnline = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (esraClassification && shortTermCover && nbiIssueAvailable) { return true; } return false; @@ -9018,8 +9028,8 @@ var canGetAQuoteOnline = (country) => { var can_get_a_quote_online_default = canGetAQuoteOnline; // helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts -var canGetAQuoteByEmail = (country) => { - if (country.riskCategory && country.shortTermCover && !country.nbiIssueAvailable) { +var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (shortTermCover && !nbiIssueAvailable && esraClassification) { return true; } return false; @@ -9027,59 +9037,219 @@ var canGetAQuoteByEmail = (country) => { var can_get_a_quote_by_email_default = canGetAQuoteByEmail; // helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts -var cannotGetAQuote = (country) => { - if (!country.riskCategory || (!country.shortTermCover && !country.nbiIssueAvailable)) { +var cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (!esraClassification || (!shortTermCover && !nbiIssueAvailable)) { return true; } return false; }; var cannot_get_a_quote_default = cannotGetAQuote; -// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts -var canApplyForInsuranceOnline = (shortTermCover, riskCategory) => { - if (riskCategory && shortTermCover) { +// helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts +var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; +var canApplyForAQuoteOffline = (originalShortTermCover) => { + if (originalShortTermCover === CIS2.SHORT_TERM_COVER_AVAILABLE.ILC) { + return true; + } + if (originalShortTermCover === CIS2.SHORT_TERM_COVER_AVAILABLE.CILC) { + return true; + } + if (originalShortTermCover === CIS2.SHORT_TERM_COVER_AVAILABLE.REFER) { return true; } return false; }; +var can_apply_for_quote_offline_default = canApplyForAQuoteOffline; + +// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts +var { + CIS: { + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + }, +} = EXTERNAL_API_DEFINITIONS; +var hasValidEsraClassification = (esraClassification) => { + switch (esraClassification) { + case STANDARD: + return true; + case HIGH: + return true; + case VERY_HIGH: + return true; + default: + return false; + } +}; +var has_valid_esra_classification_default = hasValidEsraClassification; + +// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts +var { + CIS: { + SHORT_TERM_COVER_AVAILABLE: { YES: YES2, REFER, UNLISTED }, + }, +} = EXTERNAL_API_DEFINITIONS; +var hasValidShortTermCover = (shortTermCover) => { + switch (shortTermCover) { + case YES2: + return true; + case REFER: + return true; + case UNLISTED: + return true; + default: + return false; + } +}; +var has_valid_short_term_cover_default = hasValidShortTermCover; + +// helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts +var { + CIS: { COUNTRY_RATINGS }, +} = EXTERNAL_API_DEFINITIONS; +var countryRatingIsAorB = (rating) => { + if (COUNTRY_RATINGS.A.includes(rating)) { + return true; + } + if (COUNTRY_RATINGS.B.includes(rating)) { + return true; + } + return false; +}; +var country_rating_is_a_or_b_default = countryRatingIsAorB; + +// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts +var canApplyForInsuranceOnline = (cisCountry) => { + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; + const conditions = + has_valid_esra_classification_default(ESRAClassificationDesc) && + has_valid_short_term_cover_default(shortTermCoverAvailabilityDesc) && + country_rating_is_a_or_b_default(countryRatingDesc); + return conditions; +}; var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; -// helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.ts -var { CIS: CIS3 } = EXTERNAL_API_DEFINITIONS; -var canApplyOffline = (originalShortTermCover) => { - if (originalShortTermCover === CIS3.SHORT_TERM_COVER_AVAILABLE.ILC) { +// helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts +var { + CIS: { + ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE }, + SHORT_TERM_COVER_AVAILABLE: { NO: NO2, ILC, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; +var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { + if (!country_rating_is_a_or_b_default(countryRating)) { + return false; + } + if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { + if (shortTermCover === ILC) { + return true; + } + if (shortTermCover === CILC) { + return true; + } + if (shortTermCover === NO2) { + return true; + } + } + if (esraClassification === NONE && shortTermCover === NO2) { return true; } - if (originalShortTermCover === CIS3.SHORT_TERM_COVER_AVAILABLE.CILC) { + return false; +}; +var a_and_b_rating_conditions_default = aAndBRatingConditions; + +// helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts +var { + CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 }, +} = EXTERNAL_API_DEFINITIONS; +var countryRatingIsCorD = (rating) => { + if (COUNTRY_RATINGS2.C.includes(rating)) { return true; } - if (originalShortTermCover === CIS3.SHORT_TERM_COVER_AVAILABLE.REFER) { + if (COUNTRY_RATINGS2.D.includes(rating)) { return true; } return false; }; -var can_apply_offline_default = canApplyOffline; +var country_rating_is_c_or_d_default = countryRatingIsCorD; -// helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts -var { NO_COVER } = EXTERNAL_API_DEFINITIONS.CIS; -var noInsuranceSupportAvailable = (marketRiskAppetitePublicDesc) => marketRiskAppetitePublicDesc === NO_COVER; -var no_insurance_support_default = noInsuranceSupportAvailable; +// helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts +var { + CIS: { + ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE2 }, + SHORT_TERM_COVER_AVAILABLE: { YES: YES3, NO: NO3, ILC: ILC2, CILC: CILC2, REFER: REFER2, UNLISTED: UNLISTED2 }, + }, +} = EXTERNAL_API_DEFINITIONS; +var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { + if (!country_rating_is_c_or_d_default(countryRating)) { + return false; + } + if (esraClassification === STANDARD3 || esraClassification === HIGH3 || esraClassification === VERY_HIGH3) { + if (shortTermCover === YES3) { + return true; + } + if (shortTermCover === ILC2) { + return true; + } + if (shortTermCover === CILC2) { + return true; + } + if (shortTermCover === REFER2) { + return true; + } + if (shortTermCover === UNLISTED2) { + return true; + } + if (shortTermCover === NO3) { + return true; + } + } + if (esraClassification === NONE2 && shortTermCover === NO3) { + return true; + } + return false; +}; +var c_and_d_rating_conditions_default = cAndDRatingConditions; + +// helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts +var noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }) => { + const aAndBConditions = a_and_b_rating_conditions_default({ + countryRating, + esraClassification, + shortTermCover, + }); + const cAndDConditions = c_and_d_rating_conditions_default({ + countryRating, + esraClassification, + shortTermCover, + }); + const conditions = aAndBConditions || cAndDConditions; + return conditions; +}; +var no_online_insurance_support_default = noOnlineInsuranceSupport; // helpers/map-CIS-countries/map-CIS-country/index.ts -var mapCisCountry = (country) => { +var mapCisCountry = (cisCountry) => { + const { countryRatingDesc, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc } = cisCountry; + const esraClassification = map_esra_classification_default(cisCountry.ESRAClassificationDesc); + const nbiIssueAvailable = map_NBI_issue_available_default(cisCountry.NBIIssue); + const shortTermCover = map_short_term_cover_available_default(cisCountry.shortTermCoverAvailabilityDesc); const mapped = { - name: country.marketName, - isoCode: country.isoCode, - riskCategory: map_risk_category_default(country.ESRAClassificationDesc), - shortTermCover: map_short_term_cover_available_default(country.shortTermCoverAvailabilityDesc), - nbiIssueAvailable: map_NBI_issue_available_default(country.NBIIssue), + countryRating: countryRatingDesc, + esraClassification, + isoCode, + name: marketName, + nbiIssueAvailable, + shortTermCover, + canGetAQuoteOnline: can_get_a_quote_online_default({ shortTermCover, nbiIssueAvailable, esraClassification }), + canGetAQuoteOffline: can_apply_for_quote_offline_default(cisCountry.shortTermCoverAvailabilityDesc), + canGetAQuoteByEmail: can_get_a_quote_by_email_default({ shortTermCover, nbiIssueAvailable, esraClassification }), + cannotGetAQuote: cannot_get_a_quote_default({ shortTermCover, nbiIssueAvailable, esraClassification }), + canApplyForInsuranceOnline: can_apply_for_insurance_online_default(cisCountry), + noOnlineInsuranceSupport: no_online_insurance_support_default({ + countryRating: countryRatingDesc, + esraClassification: ESRAClassificationDesc, + shortTermCover: shortTermCoverAvailabilityDesc, + }), }; - mapped.canGetAQuoteOnline = can_get_a_quote_online_default(mapped); - mapped.canGetAQuoteOffline = can_apply_offline_default(country.shortTermCoverAvailabilityDesc); - mapped.canGetAQuoteByEmail = can_get_a_quote_by_email_default(mapped); - mapped.cannotGetAQuote = cannot_get_a_quote_default(mapped); - mapped.canApplyForInsuranceOnline = can_apply_for_insurance_online_default(mapped.shortTermCover, mapped.riskCategory); - mapped.noInsuranceSupport = no_insurance_support_default(country.marketRiskAppetitePublicDesc); return mapped; }; var map_CIS_country_default = mapCisCountry; @@ -9092,9 +9262,9 @@ var sortArrayAlphabetically = (arr, field) => { var sort_array_alphabetically_default = sortArrayAlphabetically; // helpers/map-CIS-countries/index.ts -var { CIS: CIS4 } = EXTERNAL_API_DEFINITIONS; +var { CIS: CIS3 } = EXTERNAL_API_DEFINITIONS; var mapCisCountries = (countries) => { - const filteredCountries = filter_cis_entries_default(countries, CIS4.INVALID_COUNTRIES, 'marketName'); + const filteredCountries = filter_cis_entries_default(countries, CIS3.INVALID_COUNTRIES, 'marketName'); const mapped = filteredCountries.map((country) => map_CIS_country_default(country)); const sorted = sort_array_alphabetically_default(mapped, 'name'); return sorted; @@ -9119,7 +9289,7 @@ var getApimCisCountries = async () => { var get_APIM_CIS_countries_default = getApimCisCountries; // helpers/map-currencies/index.ts -var { CIS: CIS5 } = EXTERNAL_API_DEFINITIONS; +var { CIS: CIS4 } = EXTERNAL_API_DEFINITIONS; var getSupportedCurrencies = (currencies) => { const supported = currencies.filter((currency) => SUPPORTED_CURRENCIES.find((currencyCode) => currency.isoCode === currencyCode)); return supported; @@ -9129,7 +9299,7 @@ var getAlternativeCurrencies = (currencies) => { return alternate; }; var mapCurrencies = (currencies, alternativeCurrencies) => { - let currenciesArray = filter_cis_entries_default(currencies, CIS5.INVALID_CURRENCIES, 'name'); + let currenciesArray = filter_cis_entries_default(currencies, CIS4.INVALID_CURRENCIES, 'name'); if (!alternativeCurrencies) { currenciesArray = getSupportedCurrencies(currenciesArray); } else { diff --git a/src/api/constants/external-apis.ts b/src/api/constants/external-apis.ts index 005f719c96..93aaa1bb58 100644 --- a/src/api/constants/external-apis.ts +++ b/src/api/constants/external-apis.ts @@ -2,10 +2,11 @@ export const EXTERNAL_API_DEFINITIONS = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard Risk', + NONE: 'None', }, SHORT_TERM_COVER_AVAILABLE: { YES: 'Yes', @@ -30,6 +31,12 @@ export const EXTERNAL_API_DEFINITIONS = { 'Third Country', ], INVALID_CURRENCIES: ['Gold'], + COUNTRY_RATINGS: { + A: ['AAA', 'AA+', 'AA', 'AA-', 'A+', 'A', 'A-'], + B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], + C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], + D: ['D'], + }, }, COMPANIES_HOUSE: { COMPANY_STATUS: { @@ -40,7 +47,7 @@ export const EXTERNAL_API_DEFINITIONS = { export const EXTERNAL_API_MAPPINGS = { CIS: { - RISK: { + ESRA_CLASSIFICATION: { VERY_HIGH: 'Very High', HIGH: 'High', STANDARD: 'Standard', diff --git a/src/api/custom-schema/type-defs.ts b/src/api/custom-schema/type-defs.ts index 96c8ec8fb8..74c78c075b 100644 --- a/src/api/custom-schema/type-defs.ts +++ b/src/api/custom-schema/type-defs.ts @@ -228,7 +228,7 @@ const typeDefs = ` isoCode: String! name: String shortTermCover: Boolean - riskCategory: String + esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean canGetAQuoteOffline: Boolean @@ -236,6 +236,7 @@ const typeDefs = ` cannotGetAQuote: Boolean cannotApply: Boolean canApplyForInsuranceOnline: Boolean + noOnlineInsuranceSupport: Boolean noInsuranceSupport: Boolean } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts new file mode 100644 index 0000000000..abb87f9607 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts @@ -0,0 +1,50 @@ +import hasValidEsraClassification from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, + }, +} = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification', () => { + describe(`when the classification is ${STANDARD}`, () => { + it('should return true', () => { + const result = hasValidEsraClassification(STANDARD); + + expect(result).toEqual(true); + }); + }); + + describe(`when the classification is ${HIGH}`, () => { + it('should return true', () => { + const result = hasValidEsraClassification(HIGH); + + expect(result).toEqual(true); + }); + }); + + describe(`when the classification is ${VERY_HIGH}`, () => { + it('should return true', () => { + const result = hasValidEsraClassification(VERY_HIGH); + + expect(result).toEqual(true); + }); + }); + + describe(`when the classification is ${NONE}`, () => { + it('should return false', () => { + const result = hasValidEsraClassification(NONE); + + expect(result).toEqual(false); + }); + }); + + describe('when the classification is unrecognised', () => { + it('should return false', () => { + const result = hasValidEsraClassification('Some other classification'); + + expect(result).toEqual(false); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts new file mode 100644 index 0000000000..6f890c8a54 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts @@ -0,0 +1,31 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * hasValidEsraClassification + * Check if a country's "ESRA classification" can apply for insurance online. + * @param {String} esraClassification: ESRA classification + * @returns {Boolean} + */ +const hasValidEsraClassification = (esraClassification: string): boolean => { + switch (esraClassification) { + case STANDARD: + return true; + + case HIGH: + return true; + + case VERY_HIGH: + return true; + + default: + return false; + } +}; + +export default hasValidEsraClassification; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts new file mode 100644 index 0000000000..261f607787 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts @@ -0,0 +1,30 @@ +import hasValidShortTermCover from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + SHORT_TERM_COVER_AVAILABLE: { YES, REFER, UNLISTED, NO, ILC, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover', () => { + const validShortTermCovers = [YES, REFER, UNLISTED]; + + const invalidShortTermCovers = [NO, ILC, CILC, 'Some other shortTermCover value']; + + describe.each(validShortTermCovers)('valid short term covers', (shortTermCover) => { + it(`should return true for ${shortTermCover}`, () => { + const result = hasValidShortTermCover(shortTermCover); + + expect(result).toEqual(true); + }); + }); + + describe.each(invalidShortTermCovers)('invalid short term covers', (shortTermCover) => { + it(`should return false for ${shortTermCover}`, () => { + const result = hasValidShortTermCover(shortTermCover); + + expect(result).toEqual(false); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts new file mode 100644 index 0000000000..bfcae7b00d --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts @@ -0,0 +1,31 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + SHORT_TERM_COVER_AVAILABLE: { YES, REFER, UNLISTED }, + }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * hasValidShortTermCover + * Check if a country's "short term cover" flag can apply for insurance online. + * @param {String} shortTermCover: Short term cover + * @returns {Boolean} + */ +const hasValidShortTermCover = (shortTermCover: string): boolean => { + switch (shortTermCover) { + case YES: + return true; + + case REFER: + return true; + + case UNLISTED: + return true; + + default: + return false; + } +}; + +export default hasValidShortTermCover; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts index bfa53a4be2..3d02327bf5 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts @@ -1,52 +1,20 @@ import canApplyForInsuranceOnline from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { - CIS: { - RISK: { VERY_HIGH }, - }, -} = EXTERNAL_API_DEFINITIONS; - -const mockRiskCategory = VERY_HIGH; +import hasValidEsraClassification from './has-valid-esra-classification'; +import hasValidShortTermCover from './has-valid-short-term-cover'; +import countryRatingIsAorB from '../country-rating-is-a-or-b'; +import { mockCisCountry } from '../../../../test-mocks'; describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online', () => { - describe('when a country has a riskCategory and shortTermCover of true', () => { - it('should return true', () => { - const shortTermCover = true; - - const result = canApplyForInsuranceOnline(shortTermCover, mockRiskCategory); - - expect(result).toEqual(true); - }); - }); - - describe('when a country has a riskCategory and shortTermCover is false', () => { - it('should return false', () => { - const shortTermCover = false; - - const result = canApplyForInsuranceOnline(shortTermCover, mockRiskCategory); - - expect(result).toEqual(false); - }); - }); - - describe('when a country does not have a riskCategory and shortTermCover of true', () => { - it('should return false', () => { - const shortTermCover = true; - - const result = canApplyForInsuranceOnline(shortTermCover); - - expect(result).toEqual(false); - }); - }); + it('should return the result of 3x conditions', () => { + const result = canApplyForInsuranceOnline(mockCisCountry); - describe('when a country does not have a riskCategory and shortTermCover is false', () => { - it('should return false', () => { - const shortTermCover = false; + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, marketRiskAppetitePublicDesc } = mockCisCountry; - const result = canApplyForInsuranceOnline(shortTermCover); + const expected = + hasValidEsraClassification(ESRAClassificationDesc) && + hasValidShortTermCover(shortTermCoverAvailabilityDesc) && + countryRatingIsAorB(marketRiskAppetitePublicDesc); - expect(result).toEqual(false); - }); + expect(result).toEqual(expected); }); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts index ce27d98dd0..9aeeaee65f 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts @@ -1,24 +1,21 @@ +import hasValidEsraClassification from './has-valid-esra-classification'; +import hasValidShortTermCover from './has-valid-short-term-cover'; +import countryRatingIsAorB from '../country-rating-is-a-or-b'; +import { CisCountry } from '../../../../types'; + /** * canApplyForInsuranceOnline * Check if a country can apply for insurance online. - * A country can apply if - * 1) The country has a risk category, - * 2) The country has a short term cover definition with one of the following values: - * - Yes - * - ILC - * - CILC - * - Refer - * - Unlisted - * @param {Boolean} shortTermCover: Boolean value of shortTermCover. - * @param {String} riskCategory: Country risk category. + * @param {CisCountry} cisCountry: CIS country * @returns {Boolean} */ -export const canApplyForInsuranceOnline = (shortTermCover: boolean, riskCategory?: string) => { - if (riskCategory && shortTermCover) { - return true; - } +const canApplyForInsuranceOnline = (cisCountry: CisCountry): boolean => { + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; + + const conditions = + hasValidEsraClassification(ESRAClassificationDesc) && hasValidShortTermCover(shortTermCoverAvailabilityDesc) && countryRatingIsAorB(countryRatingDesc); - return false; + return conditions; }; export default canApplyForInsuranceOnline; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts similarity index 79% rename from src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts index 86b0c94356..1915c7cc4d 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts @@ -1,4 +1,4 @@ -import canApplyOffline from '.'; +import canApplyForAQuoteOffline from '.'; import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; import mockCountries from '../../../../test-mocks/mock-countries'; @@ -14,7 +14,7 @@ describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.ILC, }; - const result = canApplyOffline(mockCountry.shortTermCoverAvailabilityDesc); + const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); expect(result).toEqual(true); }); @@ -27,7 +27,7 @@ describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.CILC, }; - const result = canApplyOffline(mockCountry.shortTermCoverAvailabilityDesc); + const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); expect(result).toEqual(true); }); @@ -40,7 +40,7 @@ describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.REFER, }; - const result = canApplyOffline(mockCountry.shortTermCoverAvailabilityDesc); + const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); expect(result).toEqual(true); }); @@ -53,7 +53,7 @@ describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { shortTermCoverAvailabilityDesc: 'Something else', }; - const result = canApplyOffline(mockCountry.shortTermCoverAvailabilityDesc); + const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts similarity index 79% rename from src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts index 70ccd04333..b51cd75797 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-offline/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts @@ -3,12 +3,12 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { CIS } = EXTERNAL_API_DEFINITIONS; /** - * canApplyOffline + * canApplyForAQuoteOffline * Check if a country can get a quote offline * @param {String} Country original short term cover definition from CIS API. * @returns {Boolean} */ -export const canApplyOffline = (originalShortTermCover: string) => { +export const canApplyForAQuoteOffline = (originalShortTermCover: string) => { if (originalShortTermCover === CIS.SHORT_TERM_COVER_AVAILABLE.ILC) { return true; } @@ -24,4 +24,4 @@ export const canApplyOffline = (originalShortTermCover: string) => { return false; }; -export default canApplyOffline; +export default canApplyForAQuoteOffline; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts index ff57cb7bf4..9ce54f4337 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts @@ -1,62 +1,48 @@ import canGetAQuoteByEmail from '.'; import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; -import mockCountries from '../../../../test-mocks/mock-countries'; -import { MappedCisCountry } from '../../../../types'; const { - CIS: { RISK }, + CIS: { + ESRA_CLASSIFICATION: { STANDARD }, + }, } = EXTERNAL_API_MAPPINGS; -const validMockCountry = { - ...mockCountries[0], - riskCategory: RISK.STANDARD, - shortTermCover: true, - nbiIssueAvailable: false, -} as MappedCisCountry; - describe('helpers/map-cis-countries/map-cis-country/can-get-a-quote-by-email', () => { - describe('when a country has true riskCategory, shortTermCover and no nbiIssueAvailable', () => { + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is provided', () => { it('should return true', () => { - const result = canGetAQuoteByEmail(validMockCountry); + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: STANDARD }); expect(result).toEqual(true); }); }); - describe('when a country does not have riskCategory', () => { + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is null', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - riskCategory: undefined, - } as MappedCisCountry; - - const result = canGetAQuoteByEmail(mockCountry); + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: null }); expect(result).toEqual(false); }); }); - describe('when a country does not have shortTermCover', () => { + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is an empty string', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - shortTermCover: false, - } as MappedCisCountry; - - const result = canGetAQuoteByEmail(mockCountry); + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: '' }); expect(result).toEqual(false); }); }); - describe('when a country has nbiIssueAvailable', () => { + describe('when shortTermCover=false, nbiIssueAvailable=false, esraClassification is provided', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - nbiIssueAvailable: true, - } as MappedCisCountry; + const result = canGetAQuoteByEmail({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: STANDARD }); + + expect(result).toEqual(false); + }); + }); - const result = canGetAQuoteByEmail(mockCountry); + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is provided', () => { + it('should return false', () => { + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: STANDARD }); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts index a856b562aa..77d3366588 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts @@ -1,13 +1,16 @@ -import { MappedCisCountry } from '../../../../types'; +import { MapCisCountryParams } from '../../../../types'; /** * canGetAQuoteByEmail * Check if a country is able to get a quote by email - * @param {MappedCisCountry} Mapped CIS Country + * @param {MapCisCountryParams} + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {Boolean} nbiIssueAvailable: NBI flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const canGetAQuoteByEmail = (country: MappedCisCountry) => { - if (country.riskCategory && country.shortTermCover && !country.nbiIssueAvailable) { +const canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { + if (shortTermCover && !nbiIssueAvailable && esraClassification) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts index 2d01411acc..5c841c38dc 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts @@ -1,62 +1,48 @@ import canGetAQuoteOnline from '.'; import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; -import mockCountries from '../../../../test-mocks/mock-countries'; -import { MappedCisCountry } from '../../../../types'; const { - CIS: { RISK }, + CIS: { + ESRA_CLASSIFICATION: { STANDARD }, + }, } = EXTERNAL_API_MAPPINGS; -const validMockCountry = { - ...mockCountries[0], - riskCategory: RISK.STANDARD, - shortTermCover: true, - nbiIssueAvailable: true, -} as MappedCisCountry; - describe('helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online', () => { - describe('when a country has true riskCategory, shortTermCover and nbiIssueAvailable', () => { + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is provided', () => { it('should return true', () => { - const result = canGetAQuoteOnline(validMockCountry); + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: STANDARD }); expect(result).toEqual(true); }); }); - describe('when a country does not have riskCategory', () => { + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is null', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - riskCategory: undefined, - } as MappedCisCountry; - - const result = canGetAQuoteOnline(mockCountry); + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: null }); expect(result).toEqual(false); }); }); - describe('when a country does not have shortTermCover', () => { + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is an empty string', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - shortTermCover: false, - } as MappedCisCountry; - - const result = canGetAQuoteOnline(mockCountry); + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: '' }); expect(result).toEqual(false); }); }); - describe('when a country does not have nbiIssueAvailable', () => { + describe('when shortTermCover=false, nbiIssueAvailable=true, esraClassification is provided', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - nbiIssueAvailable: false, - } as MappedCisCountry; + const result = canGetAQuoteOnline({ shortTermCover: false, nbiIssueAvailable: true, esraClassification: STANDARD }); + + expect(result).toEqual(false); + }); + }); - const result = canGetAQuoteOnline(mockCountry); + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is provided', () => { + it('should return false', () => { + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: STANDARD }); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts index 82f540bcc8..1bc5e7d721 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts @@ -1,13 +1,16 @@ -import { MappedCisCountry } from '../../../../types'; +import { MapCisCountryParams } from '../../../../types'; /** * canGetAQuoteOnline * Check if a country is able to get a quote online - * @param {MappedCisCountry} Mapped CIS Country + * @param {MapCisCountryParams} + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {Boolean} nbiIssueAvailable: NBI flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const canGetAQuoteOnline = (country: MappedCisCountry) => { - if (country.riskCategory && country.shortTermCover && country.nbiIssueAvailable) { +const canGetAQuoteOnline = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { + if (esraClassification && shortTermCover && nbiIssueAvailable) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts index dd592d9d1e..1a8d6622ca 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts @@ -1,57 +1,32 @@ import cannotGetAQuote from '.'; -import mockCountries from '../../../../test-mocks/mock-countries'; -import { MappedCisCountry } from '../../../../types'; +import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; -const mockCountryCannotGetAQuote = { - ...mockCountries[0], - shortTermCover: false, - nbiIssueAvailable: false, -} as MappedCisCountry; +const { + CIS: { + ESRA_CLASSIFICATION: { STANDARD }, + }, +} = EXTERNAL_API_MAPPINGS; describe('helpers/map-cis-countries/map-cis-country/cannot-get-a-quote', () => { - describe('when country does not have riskCategory, shortTermCover and nbiIssueAvailable', () => { + describe('when country has shortTermCover=false, nbiIssueAvailable=false and no esraClassification', () => { it('should return true', () => { - const result = cannotGetAQuote(mockCountryCannotGetAQuote); + const result = cannotGetAQuote({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: null }); expect(result).toEqual(true); }); }); - describe('when country does not have riskCategory, but has shortTermCover and nbiIssueAvailable', () => { + describe('when country has shortTermCover=false, nbiIssueAvailable=false and has a esraClassification', () => { it('should return true', () => { - const mockCountry = { - ...mockCountryCannotGetAQuote, - shortTermCover: true, - nbiIssueAvailable: true, - }; - const result = cannotGetAQuote(mockCountry); + const result = cannotGetAQuote({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: STANDARD }); expect(result).toEqual(true); }); }); - describe('when country has riskCategory, but not shortTermCover and nbiIssueAvailable', () => { - it('should return true', () => { - const mockCountry = { - ...mockCountryCannotGetAQuote, - riskCategory: 'Mock', - }; - const result = cannotGetAQuote(mockCountry); - - expect(result).toEqual(true); - }); - }); - - describe('when country has riskCategory, shortTermCover and nbiIssueAvailable', () => { + describe('when country has shortTermCover=true, nbiIssueAvailable=true and has a esraClassification', () => { it('should return false', () => { - const mockCountry = { - ...mockCountryCannotGetAQuote, - riskCategory: 'Mock', - shortTermCover: true, - nbiIssueAvailable: true, - }; - - const result = cannotGetAQuote(mockCountry); + const result = cannotGetAQuote({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: STANDARD }); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts index 175898f568..d2b37edd89 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts @@ -1,13 +1,16 @@ -import { MappedCisCountry } from '../../../../types'; +import { MapCisCountryParams } from '../../../../types'; /** * cannotGetAQuote * Check if a country cannot get a quote online or offline - * @param {MappedCisCountry} Country from CIS API + * @param {MapCisCountryParams} + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {Boolean} nbiIssueAvailable: NBI flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const cannotGetAQuote = (country: MappedCisCountry) => { - if (!country.riskCategory || (!country.shortTermCover && !country.nbiIssueAvailable)) { +const cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { + if (!esraClassification || (!shortTermCover && !nbiIssueAvailable)) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.test.ts new file mode 100644 index 0000000000..e10f308313 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.test.ts @@ -0,0 +1,40 @@ +import countryRatingIsAorB from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; + +const { + CIS: { COUNTRY_RATINGS }, +} = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b', () => { + describe.each(COUNTRY_RATINGS.A)('COUNTRY_RATINGS.A', (rating) => { + it(`should return true for ${rating}`, () => { + const result = countryRatingIsAorB(rating); + + expect(result).toEqual(true); + }); + }); + + describe.each(COUNTRY_RATINGS.B)('COUNTRY_RATINGS.B', (rating) => { + it(`should return true for ${rating}`, () => { + const result = countryRatingIsAorB(rating); + + expect(result).toEqual(true); + }); + }); + + describe.each(COUNTRY_RATINGS.C)('COUNTRY_RATINGS.C', (rating) => { + it(`should return false for ${rating}`, () => { + const result = countryRatingIsAorB(rating); + + expect(result).toEqual(false); + }); + }); + + describe.each(COUNTRY_RATINGS.D)('COUNTRY_RATINGS.D', (rating) => { + it(`should return false for ${rating}`, () => { + const result = countryRatingIsAorB(rating); + + expect(result).toEqual(false); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts new file mode 100644 index 0000000000..27ab3a51ea --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts @@ -0,0 +1,25 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; + +const { + CIS: { COUNTRY_RATINGS }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * countryRatingIsAorB + * Check if a country's "country rating" is A or B. + * @param {String} rating: Country rating + * @returns {Boolean} + */ +const countryRatingIsAorB = (rating: string): boolean => { + if (COUNTRY_RATINGS.A.includes(rating)) { + return true; + } + + if (COUNTRY_RATINGS.B.includes(rating)) { + return true; + } + + return false; +}; + +export default countryRatingIsAorB; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.test.ts new file mode 100644 index 0000000000..6c52964795 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.test.ts @@ -0,0 +1,40 @@ +import countryRatingIsCorD from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; + +const { + CIS: { COUNTRY_RATINGS }, +} = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d', () => { + describe.each(COUNTRY_RATINGS.C)('COUNTRY_RATINGS.C', (rating) => { + it(`should return true for ${rating}`, () => { + const result = countryRatingIsCorD(rating); + + expect(result).toEqual(true); + }); + }); + + describe.each(COUNTRY_RATINGS.D)('COUNTRY_RATINGS.D', (rating) => { + it(`should return true for ${rating}`, () => { + const result = countryRatingIsCorD(rating); + + expect(result).toEqual(true); + }); + }); + + describe.each(COUNTRY_RATINGS.A)('COUNTRY_RATINGS.A', (rating) => { + it(`should return false for ${rating}`, () => { + const result = countryRatingIsCorD(rating); + + expect(result).toEqual(false); + }); + }); + + describe.each(COUNTRY_RATINGS.B)('COUNTRY_RATINGS.B', (rating) => { + it(`should return false for ${rating}`, () => { + const result = countryRatingIsCorD(rating); + + expect(result).toEqual(false); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts new file mode 100644 index 0000000000..0cd1944a5e --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts @@ -0,0 +1,25 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; + +const { + CIS: { COUNTRY_RATINGS }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * countryRatingIsCorD + * Check if a country's "country rating" is C or D. + * @param {String} rating: Country rating + * @returns {Boolean} + */ +const countryRatingIsCorD = (rating: string): boolean => { + if (COUNTRY_RATINGS.C.includes(rating)) { + return true; + } + + if (COUNTRY_RATINGS.D.includes(rating)) { + return true; + } + + return false; +}; + +export default countryRatingIsCorD; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index 7b8c318ebd..21786db1e6 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -1,27 +1,25 @@ import mapCisCountry from '.'; -import mapRiskCategory from './map-risk-category'; +import mapEsraClassification from './map-esra-classification'; import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import cannotGetAQuote from './cannot-get-a-quote'; -import applyForInsuranceOnline from './can-apply-for-insurance-online'; -import canApplyOffline from './can-apply-offline'; -import noInsuranceSupportAvailable from './no-insurance-support'; +import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; +import canApplyOffline from './can-apply-for-quote-offline'; +import noOnlineInsuranceSupport from './no-online-insurance-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; import { MappedCisCountry } from '../../../types'; -import { mockCisCountries } from '../../../test-mocks'; +import { mockCisCountry } from '../../../test-mocks'; const { CIS } = EXTERNAL_API_DEFINITIONS; describe('helpers/map-CIS-countries/map-CIS-country', () => { - const { 1: initialMockCountry } = mockCisCountries; - const mockCountryBase = { - ...initialMockCountry, - marketName: initialMockCountry.marketName, - riskCategory: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, - isoCode: initialMockCountry.isoCode, + ...mockCisCountry, + marketName: mockCisCountry.marketName, + esraClassification: EXTERNAL_API_MAPPINGS.CIS.ESRA_CLASSIFICATION.STANDARD, + isoCode: mockCisCountry.isoCode, shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.ILC, marketRiskAppetitePublicDesc: CIS.NO_COVER, }; @@ -29,28 +27,34 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { it('should return an object', () => { const result = mapCisCountry(mockCountryBase); + const esraClassification = mapEsraClassification(mockCountryBase.ESRAClassificationDesc); + const shortTermCover = mapShortTermCoverAvailable(mockCountryBase.shortTermCoverAvailabilityDesc); + const nbiIssueAvailable = mapNbiIssueAvailable(mockCountryBase.NBIIssue); + const mapped = { - name: mockCountryBase.marketName, + countryRating: mockCisCountry.countryRatingDesc, + esraClassification, isoCode: mockCountryBase.isoCode, - riskCategory: mapRiskCategory(mockCountryBase.ESRAClassificationDesc), - shortTermCover: mapShortTermCoverAvailable(mockCountryBase.shortTermCoverAvailabilityDesc), - nbiIssueAvailable: mapNbiIssueAvailable(mockCountryBase.NBIIssue), - canGetAQuoteOnline: false, - canGetAQuoteOffline: false, - canGetAQuoteByEmail: false, - cannotGetAQuote: false, - canApplyForInsuranceOnline: false, - noInsuranceSupport: false, - } as MappedCisCountry; + name: mockCountryBase.marketName, + nbiIssueAvailable, + shortTermCover, - mapped.canGetAQuoteOnline = canGetAQuoteOnline(mapped); - mapped.canGetAQuoteOffline = canApplyOffline(mockCountryBase.shortTermCoverAvailabilityDesc); - mapped.canGetAQuoteByEmail = canGetAQuoteByEmail(mapped); - mapped.cannotGetAQuote = cannotGetAQuote(mapped); + canGetAQuoteOnline: canGetAQuoteOnline({ shortTermCover, nbiIssueAvailable, esraClassification }), - mapped.canApplyForInsuranceOnline = applyForInsuranceOnline(mapped.shortTermCover); + canGetAQuoteOffline: canApplyOffline(mockCountryBase.shortTermCoverAvailabilityDesc), - mapped.noInsuranceSupport = noInsuranceSupportAvailable(mockCountryBase.marketRiskAppetitePublicDesc); + canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), + + cannotGetAQuote: cannotGetAQuote({ shortTermCover, nbiIssueAvailable, esraClassification }), + + canApplyForInsuranceOnline: canApplyForInsuranceOnline(mockCisCountry), + + noOnlineInsuranceSupport: noOnlineInsuranceSupport({ + countryRating: mockCisCountry.countryRatingDesc, + esraClassification: mockCisCountry.ESRAClassificationDesc, + shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, + }), + } as MappedCisCountry; expect(result).toEqual(mapped); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index 55fbe71033..ff34e59662 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -1,12 +1,12 @@ -import mapRiskCategory from './map-risk-category'; +import mapEsraClassification from './map-esra-classification'; import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import cannotGetAQuote from './cannot-get-a-quote'; -import applyForInsuranceOnline from './can-apply-for-insurance-online'; -import canApplyOffline from './can-apply-offline'; -import noInsuranceSupportAvailable from './no-insurance-support'; +import canApplyForAQuoteOffline from './can-apply-for-quote-offline'; +import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; +import noOnlineInsuranceSupport from './no-online-insurance-support'; import { CisCountry, MappedCisCountry } from '../../../types'; /** @@ -15,23 +15,39 @@ import { CisCountry, MappedCisCountry } from '../../../types'; * @param {CisCountry} CIS Country * @returns {MappedCisCountry} Mapped country */ -export const mapCisCountry = (country: CisCountry): MappedCisCountry => { +export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { + const { countryRatingDesc, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc } = cisCountry; + + const esraClassification = mapEsraClassification(cisCountry.ESRAClassificationDesc); + const nbiIssueAvailable = mapNbiIssueAvailable(cisCountry.NBIIssue); + const shortTermCover = mapShortTermCoverAvailable(cisCountry.shortTermCoverAvailabilityDesc); + const mapped = { - name: country.marketName, - isoCode: country.isoCode, - riskCategory: mapRiskCategory(country.ESRAClassificationDesc), - shortTermCover: mapShortTermCoverAvailable(country.shortTermCoverAvailabilityDesc), - nbiIssueAvailable: mapNbiIssueAvailable(country.NBIIssue), - } as MappedCisCountry; + countryRating: countryRatingDesc, + esraClassification, + isoCode, + name: marketName, + nbiIssueAvailable, + shortTermCover, + + canGetAQuoteOnline: canGetAQuoteOnline({ shortTermCover, nbiIssueAvailable, esraClassification }), - mapped.canGetAQuoteOnline = canGetAQuoteOnline(mapped); - mapped.canGetAQuoteOffline = canApplyOffline(country.shortTermCoverAvailabilityDesc); - mapped.canGetAQuoteByEmail = canGetAQuoteByEmail(mapped); - mapped.cannotGetAQuote = cannotGetAQuote(mapped); + canGetAQuoteOffline: canApplyForAQuoteOffline(cisCountry.shortTermCoverAvailabilityDesc), - mapped.canApplyForInsuranceOnline = applyForInsuranceOnline(mapped.shortTermCover, mapped.riskCategory); + canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), + + cannotGetAQuote: cannotGetAQuote({ shortTermCover, nbiIssueAvailable, esraClassification }), + + canApplyForInsuranceOnline: canApplyForInsuranceOnline(cisCountry), + + noOnlineInsuranceSupport: noOnlineInsuranceSupport({ + countryRating: countryRatingDesc, + esraClassification: ESRAClassificationDesc, + shortTermCover: shortTermCoverAvailabilityDesc, + }), + } as MappedCisCountry; - mapped.noInsuranceSupport = noInsuranceSupportAvailable(country.marketRiskAppetitePublicDesc); + // TODO: EMS-4065 - noInsuranceSupport. return mapped; }; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts new file mode 100644 index 0000000000..fcab33ed61 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts @@ -0,0 +1,46 @@ +import mapEsraClassification from '.'; +import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../../constants'; + +const { CIS } = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-cis-countries/map-cis-country/map-esra-classification', () => { + describe(`when the risk is '${CIS.ESRA_CLASSIFICATION.STANDARD}'`, () => { + it('should return simplified string', () => { + const str = CIS.ESRA_CLASSIFICATION.STANDARD; + + const result = mapEsraClassification(str); + + const expected = EXTERNAL_API_MAPPINGS.CIS.ESRA_CLASSIFICATION.STANDARD; + + expect(result).toEqual(expected); + }); + }); + + describe(`when the risk is '${CIS.ESRA_CLASSIFICATION.HIGH}'`, () => { + it('should return the string', () => { + const str = CIS.ESRA_CLASSIFICATION.HIGH; + + const result = mapEsraClassification(str); + + expect(result).toEqual(str); + }); + }); + + describe(`when the risk is '${CIS.ESRA_CLASSIFICATION.VERY_HIGH}'`, () => { + it('should return the string', () => { + const str = CIS.ESRA_CLASSIFICATION.VERY_HIGH; + + const result = mapEsraClassification(str); + + expect(result).toEqual(str); + }); + }); + + it('should return null', () => { + const str = 'None'; + + const result = mapEsraClassification(str); + + expect(result).toBeNull(); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts new file mode 100644 index 0000000000..339782fdcc --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts @@ -0,0 +1,29 @@ +import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../../constants'; + +const { + CIS: { ESRA_CLASSIFICATION }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * mapEsraClassification + * Transform a country's ESRAClassificationDesc field into a consistent string + * @param {String} Risk category + * @returns {String} Consistent ESRA classification + */ +const mapEsraClassification = (str: string): string | null => { + if (str === ESRA_CLASSIFICATION.STANDARD) { + return EXTERNAL_API_MAPPINGS.CIS.ESRA_CLASSIFICATION.STANDARD; + } + + if (str === ESRA_CLASSIFICATION.HIGH) { + return str; + } + + if (str === ESRA_CLASSIFICATION.VERY_HIGH) { + return str; + } + + return null; +}; + +export default mapEsraClassification; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts deleted file mode 100644 index 812a1919e1..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import mapRiskCategory from '.'; -import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../../constants'; - -const { CIS } = EXTERNAL_API_DEFINITIONS; - -describe('helpers/map-cis-countries/map-cis-country/map-risk-category', () => { - describe(`when the risk is '${CIS.RISK.STANDARD}'`, () => { - it('should return simplified string', () => { - const str = CIS.RISK.STANDARD; - - const result = mapRiskCategory(str); - - const expected = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; - - expect(result).toEqual(expected); - }); - }); - - describe(`when the risk is '${CIS.RISK.HIGH}'`, () => { - it('should return the string', () => { - const str = CIS.RISK.HIGH; - - const result = mapRiskCategory(str); - - expect(result).toEqual(str); - }); - }); - - describe(`when the risk is '${CIS.RISK.VERY_HIGH}'`, () => { - it('should return the string', () => { - const str = CIS.RISK.VERY_HIGH; - - const result = mapRiskCategory(str); - - expect(result).toEqual(str); - }); - }); - - it('should return null', () => { - const str = 'None'; - - const result = mapRiskCategory(str); - - expect(result).toBeNull(); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts deleted file mode 100644 index a6da4db6e7..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../../constants'; - -const { CIS } = EXTERNAL_API_DEFINITIONS; -/** - * mapRiskCategory - * Transform a countries risk category to a consistent string - * @param {String} Risk category - * @returns {String} Consistent risk category - */ -export const mapRiskCategory = (str: string) => { - if (str === CIS.RISK.STANDARD) { - return EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; - } - - if (str === CIS.RISK.HIGH) { - return str; - } - - if (str === CIS.RISK.VERY_HIGH) { - return str; - } - - return null; -}; - -export default mapRiskCategory; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts index 44e565531d..c4aa5dd5d7 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts @@ -10,7 +10,7 @@ const { * @param {String} Risk category * @returns {Boolean} */ -export const mapShortTermCoverAvailable = (str: string): boolean => { +const mapShortTermCoverAvailable = (str: string): boolean => { switch (str) { case SHORT_TERM_COVER_AVAILABLE.YES: return true; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts deleted file mode 100644 index 77d869090f..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import noInsuranceSupportAvailable from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { - CIS: { NO_COVER }, -} = EXTERNAL_API_DEFINITIONS; - -describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support', () => { - describe(`when marketRiskAppetitePublicDesc is ${NO_COVER}`, () => { - it('should return true', () => { - const result = noInsuranceSupportAvailable(NO_COVER); - - expect(result).toEqual(true); - }); - }); - - describe(`when originalShortTermCover is NOT '${NO_COVER}'`, () => { - it('should return false', () => { - const result = noInsuranceSupportAvailable(''); - - expect(result).toEqual(false); - }); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts deleted file mode 100644 index 30a6376333..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { NO_COVER } = EXTERNAL_API_DEFINITIONS.CIS; - -/** - * noInsuranceSupportAvailable - * Check if a country cannot apply for insurance - * @param {String} marketRiskAppetitePublicDesc market risk appetite definition from CIS API. - * @returns {Boolean} - */ -export const noInsuranceSupportAvailable = (marketRiskAppetitePublicDesc: string) => marketRiskAppetitePublicDesc === NO_COVER; - -export default noInsuranceSupportAvailable; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts new file mode 100644 index 0000000000..1e95b0abf4 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts @@ -0,0 +1,115 @@ +import aAndBRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + SHORT_TERM_COVER_AVAILABLE: { NO, ILC, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +const createMockParams = (esraClassification: string, shortTermCover: string) => + COUNTRY_RATINGS.A.map((rating: string) => ({ + countryRating: rating, + esraClassification, + shortTermCover, + })); + +const params = { + STANDARD: { + [ILC]: createMockParams(STANDARD, ILC), + [CILC]: createMockParams(STANDARD, CILC), + [NO]: createMockParams(STANDARD, NO), + }, + HIGH: { + [ILC]: createMockParams(HIGH, ILC), + [CILC]: createMockParams(HIGH, CILC), + [NO]: createMockParams(HIGH, NO), + }, + VERY_HIGH: { + [ILC]: createMockParams(VERY_HIGH, ILC), + [CILC]: createMockParams(VERY_HIGH, CILC), + [NO]: createMockParams(VERY_HIGH, NO), + }, +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - rating as A', () => { + describe(`when the ESRA classification is ${STANDARD}`, () => { + describe.each(params.STANDARD[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${HIGH}`, () => { + describe.each(params.HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${VERY_HIGH}`, () => { + describe.each(params.VERY_HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts new file mode 100644 index 0000000000..20a1fd1fb1 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts @@ -0,0 +1,115 @@ +import aAndBRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + SHORT_TERM_COVER_AVAILABLE: { NO, ILC, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +const createMockParams = (esraClassification: string, shortTermCover: string) => + COUNTRY_RATINGS.B.map((rating: string) => ({ + countryRating: rating, + esraClassification, + shortTermCover, + })); + +const params = { + STANDARD: { + [ILC]: createMockParams(STANDARD, ILC), + [CILC]: createMockParams(STANDARD, CILC), + [NO]: createMockParams(STANDARD, NO), + }, + HIGH: { + [ILC]: createMockParams(HIGH, ILC), + [CILC]: createMockParams(HIGH, CILC), + [NO]: createMockParams(HIGH, NO), + }, + VERY_HIGH: { + [ILC]: createMockParams(VERY_HIGH, ILC), + [CILC]: createMockParams(VERY_HIGH, CILC), + [NO]: createMockParams(VERY_HIGH, NO), + }, +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - rating as B', () => { + describe(`when the ESRA classification is ${STANDARD}`, () => { + describe.each(params.STANDARD[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${HIGH}`, () => { + describe.each(params.HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${VERY_HIGH}`, () => { + describe.each(params.VERY_HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts new file mode 100644 index 0000000000..07fb8e1aee --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts @@ -0,0 +1,36 @@ +import aAndBRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION, SHORT_TERM_COVER_AVAILABLE }, +} = EXTERNAL_API_DEFINITIONS; + +const countryRatingsCParams = COUNTRY_RATINGS.C.map((rating: string) => ({ + countryRating: rating, + esraClassification: ESRA_CLASSIFICATION.STANDARD, + shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, +})); + +const countryRatingsDParams = COUNTRY_RATINGS.D.map((rating: string) => ({ + countryRating: rating, + esraClassification: ESRA_CLASSIFICATION.STANDARD, + shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, +})); + +describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - ratings as C and D', () => { + describe.each(countryRatingsCParams)('when the country rating is `C`', (countryObj) => { + it(`should return false for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(false); + }); + }); + + describe.each(countryRatingsDParams)('when the country rating is `D`', (countryObj) => { + it(`should return false for ${countryObj.countryRating}`, () => { + const result = aAndBRatingConditions(countryObj); + + expect(result).toEqual(false); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts new file mode 100644 index 0000000000..7529467111 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts @@ -0,0 +1,36 @@ +import aAndBRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { NONE }, + SHORT_TERM_COVER_AVAILABLE: { NO }, + }, +} = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - ESRA classification=NONE, short term cover=NO', () => { + describe('when the country rating is `A`', () => { + it('should return true', () => { + const result = aAndBRatingConditions({ + countryRating: COUNTRY_RATINGS.A[0], + esraClassification: NONE, + shortTermCover: NO, + }); + + expect(result).toEqual(true); + }); + }); + + describe('when the country rating is `B`', () => { + it('should return true', () => { + const result = aAndBRatingConditions({ + countryRating: COUNTRY_RATINGS.B[0], + esraClassification: NONE, + shortTermCover: NO, + }); + + expect(result).toEqual(true); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts new file mode 100644 index 0000000000..057ab3b3a9 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts @@ -0,0 +1,47 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; +import countryRatingIsAorB from '../../country-rating-is-a-or-b'; +import { noOnlineInsuranceSupportParams } from '../../../../../types'; + +const { + CIS: { + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, + SHORT_TERM_COVER_AVAILABLE: { NO, ILC, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * aAndBRatingConditions + * Country conditions for "A and B country ratings", + * to determine if a country does NOT have insurance support available. + * @param {String} countryRating: Country rating + * @param {String} esraClassification: ESRA classification + * @param {String} shortTermCover: Short term cover + * @returns {Boolean} + */ +const aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }: noOnlineInsuranceSupportParams): boolean => { + if (!countryRatingIsAorB(countryRating)) { + return false; + } + + if (esraClassification === STANDARD || esraClassification === HIGH || esraClassification === VERY_HIGH) { + if (shortTermCover === ILC) { + return true; + } + + if (shortTermCover === CILC) { + return true; + } + + if (shortTermCover === NO) { + return true; + } + } + + if (esraClassification === NONE && shortTermCover === NO) { + return true; + } + + return false; +}; + +export default aAndBRatingConditions; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts new file mode 100644 index 0000000000..bfdf1cf754 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts @@ -0,0 +1,36 @@ +import cAndDRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION, SHORT_TERM_COVER_AVAILABLE }, +} = EXTERNAL_API_DEFINITIONS; + +const countryRatingsAParams = COUNTRY_RATINGS.A.map((rating: string) => ({ + countryRating: rating, + esraClassification: ESRA_CLASSIFICATION.STANDARD, + shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, +})); + +const countryRatingsBParams = COUNTRY_RATINGS.B.map((rating: string) => ({ + countryRating: rating, + esraClassification: ESRA_CLASSIFICATION.STANDARD, + shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, +})); + +describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/a-and-b-rating-conditions - rating as A and B', () => { + describe.each(countryRatingsAParams)('when the country rating is `A`', (countryObj) => { + it(`should return false for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(false); + }); + }); + + describe.each(countryRatingsBParams)('when the country rating is `B`', (countryObj) => { + it(`should return false for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(false); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts new file mode 100644 index 0000000000..3fdf1df724 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts @@ -0,0 +1,196 @@ +import cAndDRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + SHORT_TERM_COVER_AVAILABLE: { YES, NO, ILC, CILC, REFER, UNLISTED }, + }, +} = EXTERNAL_API_DEFINITIONS; + +const createMockParams = (esraClassification: string, shortTermCover: string) => + COUNTRY_RATINGS.C.map((rating: string) => ({ + countryRating: rating, + esraClassification, + shortTermCover, + })); + +const params = { + STANDARD: { + [YES]: createMockParams(STANDARD, YES), + [ILC]: createMockParams(STANDARD, ILC), + [CILC]: createMockParams(STANDARD, CILC), + [REFER]: createMockParams(STANDARD, REFER), + [UNLISTED]: createMockParams(STANDARD, UNLISTED), + [NO]: createMockParams(STANDARD, NO), + }, + HIGH: { + [YES]: createMockParams(HIGH, YES), + [ILC]: createMockParams(HIGH, ILC), + [CILC]: createMockParams(HIGH, CILC), + [REFER]: createMockParams(HIGH, REFER), + [UNLISTED]: createMockParams(HIGH, UNLISTED), + [NO]: createMockParams(HIGH, NO), + }, + VERY_HIGH: { + [YES]: createMockParams(VERY_HIGH, YES), + [ILC]: createMockParams(VERY_HIGH, ILC), + [CILC]: createMockParams(VERY_HIGH, CILC), + [REFER]: createMockParams(VERY_HIGH, REFER), + [UNLISTED]: createMockParams(VERY_HIGH, UNLISTED), + [NO]: createMockParams(VERY_HIGH, NO), + }, +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/c-and-d-rating-conditions - rating as C', () => { + describe(`when the ESRA classification is ${STANDARD}`, () => { + describe.each(params.STANDARD[YES])(`when the short term cover is ${YES}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[REFER])(`when the short term cover is ${REFER}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[UNLISTED])(`when the short term cover is ${UNLISTED}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${HIGH}`, () => { + describe.each(params.HIGH[YES])(`when the short term cover is ${YES}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[REFER])(`when the short term cover is ${REFER}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[UNLISTED])(`when the short term cover is ${UNLISTED}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${VERY_HIGH}`, () => { + describe.each(params.VERY_HIGH[YES])(`when the short term cover is ${YES}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[REFER])(`when the short term cover is ${REFER}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[UNLISTED])(`when the short term cover is ${UNLISTED}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts new file mode 100644 index 0000000000..b69ca9ea6a --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts @@ -0,0 +1,196 @@ +import cAndDRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + SHORT_TERM_COVER_AVAILABLE: { YES, NO, ILC, CILC, REFER, UNLISTED }, + }, +} = EXTERNAL_API_DEFINITIONS; + +const createMockParams = (esraClassification: string, shortTermCover: string) => + COUNTRY_RATINGS.D.map((rating: string) => ({ + countryRating: rating, + esraClassification, + shortTermCover, + })); + +const params = { + STANDARD: { + [YES]: createMockParams(STANDARD, YES), + [ILC]: createMockParams(STANDARD, ILC), + [CILC]: createMockParams(STANDARD, CILC), + [REFER]: createMockParams(STANDARD, REFER), + [UNLISTED]: createMockParams(STANDARD, UNLISTED), + [NO]: createMockParams(STANDARD, NO), + }, + HIGH: { + [YES]: createMockParams(HIGH, YES), + [ILC]: createMockParams(HIGH, ILC), + [CILC]: createMockParams(HIGH, CILC), + [REFER]: createMockParams(HIGH, REFER), + [UNLISTED]: createMockParams(HIGH, UNLISTED), + [NO]: createMockParams(HIGH, NO), + }, + VERY_HIGH: { + [YES]: createMockParams(VERY_HIGH, YES), + [ILC]: createMockParams(VERY_HIGH, ILC), + [CILC]: createMockParams(VERY_HIGH, CILC), + [REFER]: createMockParams(VERY_HIGH, REFER), + [UNLISTED]: createMockParams(VERY_HIGH, UNLISTED), + [NO]: createMockParams(VERY_HIGH, NO), + }, +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/c-and-d-rating-conditions - rating as D', () => { + describe(`when the ESRA classification is ${STANDARD}`, () => { + describe.each(params.STANDARD[YES])(`when the short term cover is ${YES}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[REFER])(`when the short term cover is ${REFER}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[UNLISTED])(`when the short term cover is ${UNLISTED}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${HIGH}`, () => { + describe.each(params.HIGH[YES])(`when the short term cover is ${YES}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[REFER])(`when the short term cover is ${REFER}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[UNLISTED])(`when the short term cover is ${UNLISTED}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); + + describe(`when the ESRA classification is ${VERY_HIGH}`, () => { + describe.each(params.VERY_HIGH[YES])(`when the short term cover is ${YES}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[CILC])(`when the short term cover is ${CILC}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[REFER])(`when the short term cover is ${REFER}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[UNLISTED])(`when the short term cover is ${UNLISTED}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + + describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => { + it(`should return true for ${countryObj.countryRating}`, () => { + const result = cAndDRatingConditions(countryObj); + + expect(result).toEqual(true); + }); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts new file mode 100644 index 0000000000..d82092c6a4 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts @@ -0,0 +1,36 @@ +import cAndDRatingConditions from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { NONE }, + SHORT_TERM_COVER_AVAILABLE: { NO }, + }, +} = EXTERNAL_API_DEFINITIONS; + +describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/c-and-d-rating-conditions - ESRA classification=NONE, short term cover=NO', () => { + describe('when the country rating is `C`', () => { + it('should return true', () => { + const result = cAndDRatingConditions({ + countryRating: COUNTRY_RATINGS.C[0], + esraClassification: NONE, + shortTermCover: NO, + }); + + expect(result).toEqual(true); + }); + }); + + describe('when the country rating is `D`', () => { + it('should return true', () => { + const result = cAndDRatingConditions({ + countryRating: COUNTRY_RATINGS.D[0], + esraClassification: NONE, + shortTermCover: NO, + }); + + expect(result).toEqual(true); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts new file mode 100644 index 0000000000..85a134559b --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts @@ -0,0 +1,59 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; +import countryRatingIsCorD from '../../country-rating-is-c-or-d'; +import { noOnlineInsuranceSupportParams } from '../../../../../types'; + +const { + CIS: { + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, + SHORT_TERM_COVER_AVAILABLE: { YES, NO, ILC, CILC, REFER, UNLISTED }, + }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * cAndDRatingConditions + * Country conditions for "C and D country ratings", + * to determine if a country does NOT have insurance support available. + * @param {String} countryRating: Country rating + * @param {String} esraClassification: ESRA classification + * @param {String} shortTermCover: Short term cover + * @returns {Boolean} + */ +const cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }: noOnlineInsuranceSupportParams): boolean => { + if (!countryRatingIsCorD(countryRating)) { + return false; + } + + if (esraClassification === STANDARD || esraClassification === HIGH || esraClassification === VERY_HIGH) { + if (shortTermCover === YES) { + return true; + } + + if (shortTermCover === ILC) { + return true; + } + + if (shortTermCover === CILC) { + return true; + } + + if (shortTermCover === REFER) { + return true; + } + + if (shortTermCover === UNLISTED) { + return true; + } + + if (shortTermCover === NO) { + return true; + } + } + + if (esraClassification === NONE && shortTermCover === NO) { + return true; + } + + return false; +}; + +export default cAndDRatingConditions; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts new file mode 100644 index 0000000000..208d83ab56 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts @@ -0,0 +1,100 @@ +import noOnlineInsuranceSupport from '.'; +import aAndBRatingConditions from './a-and-b-rating-conditions'; +import cAndDRatingConditions from './c-and-d-rating-conditions'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; +import { mockCisCountry } from '../../../../test-mocks'; + +const { + CIS: { COUNTRY_RATINGS }, +} = EXTERNAL_API_DEFINITIONS; + +const mockInitCountry = { + esraClassification: mockCisCountry.ESRAClassificationDesc, + shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support', () => { + describe('when a country rating is `A`', () => { + it('should return the result of aAndBRatingConditions', () => { + const [mockRating] = COUNTRY_RATINGS.A; + + const mockCountry = { + ...mockInitCountry, + countryRating: mockRating, + }; + + const result = noOnlineInsuranceSupport(mockCountry); + + const expected = aAndBRatingConditions({ + countryRating: mockRating, + esraClassification: mockInitCountry.esraClassification, + shortTermCover: mockInitCountry.shortTermCover, + }); + + expect(result).toEqual(expected); + }); + }); + + describe('when a country rating is `B`', () => { + it('should return the result of aAndBRatingConditions', () => { + const [mockRating] = COUNTRY_RATINGS.B; + + const mockCountry = { + ...mockInitCountry, + countryRating: mockRating, + }; + + const result = noOnlineInsuranceSupport(mockCountry); + + const expected = aAndBRatingConditions({ + countryRating: mockRating, + esraClassification: mockInitCountry.esraClassification, + shortTermCover: mockInitCountry.shortTermCover, + }); + + expect(result).toEqual(expected); + }); + }); + + describe('when a country rating is `C`', () => { + it('should return the result of cAndDRatingConditions', () => { + const [mockRating] = COUNTRY_RATINGS.C; + + const mockCountry = { + ...mockInitCountry, + countryRating: mockRating, + }; + + const result = noOnlineInsuranceSupport(mockCountry); + + const expected = cAndDRatingConditions({ + countryRating: mockRating, + esraClassification: mockInitCountry.esraClassification, + shortTermCover: mockInitCountry.shortTermCover, + }); + + expect(result).toEqual(expected); + }); + }); + + describe('when a country rating is `D`', () => { + it('should return the result of cAndDRatingConditions', () => { + const [mockRating] = COUNTRY_RATINGS.D; + + const mockCountry = { + ...mockInitCountry, + countryRating: mockRating, + }; + + const result = noOnlineInsuranceSupport(mockCountry); + + const expected = cAndDRatingConditions({ + countryRating: mockRating, + esraClassification: mockInitCountry.esraClassification, + shortTermCover: mockInitCountry.shortTermCover, + }); + + expect(result).toEqual(expected); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts new file mode 100644 index 0000000000..64041b04f6 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts @@ -0,0 +1,31 @@ +import aAndBRatingConditions from './a-and-b-rating-conditions'; +import cAndDRatingConditions from './c-and-d-rating-conditions'; +import { noOnlineInsuranceSupportParams } from '../../../../types'; + +/** + * noOnlineInsuranceSupport + * Check if a country has no online insurance support + * @param {String} countryRating: Country rating + * @param {String} esraClassification: ESRA classification + * @param {String} shortTermCover: Short term cover + * @returns {Boolean} + */ +const noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }: noOnlineInsuranceSupportParams): boolean => { + const aAndBConditions = aAndBRatingConditions({ + countryRating, + esraClassification, + shortTermCover, + }); + + const cAndDConditions = cAndDRatingConditions({ + countryRating, + esraClassification, + shortTermCover, + }); + + const conditions = aAndBConditions || cAndDConditions; + + return conditions; +}; + +export default noOnlineInsuranceSupport; diff --git a/src/api/schema.graphql b/src/api/schema.graphql index 789bcf660c..8f8273a09c 100644 --- a/src/api/schema.graphql +++ b/src/api/schema.graphql @@ -3742,7 +3742,7 @@ type MappedCisCountry { isoCode: String! name: String shortTermCover: Boolean - riskCategory: String + esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean canGetAQuoteOffline: Boolean @@ -3750,6 +3750,7 @@ type MappedCisCountry { cannotGetAQuote: Boolean cannotApply: Boolean canApplyForInsuranceOnline: Boolean + noOnlineInsuranceSupport: Boolean noInsuranceSupport: Boolean } diff --git a/src/api/test-mocks/index.ts b/src/api/test-mocks/index.ts index e9b7fbe8a9..4a39e58aa0 100644 --- a/src/api/test-mocks/index.ts +++ b/src/api/test-mocks/index.ts @@ -8,6 +8,7 @@ import currencies from './mock-currencies'; import company, { companyScenarios } from './mock-company'; import companySicCode from './mock-company-sic-code'; import nominatedLossPayee from './mock-nominated-loss-payee'; +import mapCisCountries from '../helpers/map-CIS-countries'; import { Account } from '../types'; const { @@ -114,6 +115,12 @@ export const mockApplicationMultiplePolicyTotalContractValueOverThreshold = { export const mockCisCountries = cisCountries; +const [firstCisCountry] = mockCisCountries; + +export const mockCisCountry = firstCisCountry; + +export const mockMappedCisCountries = mapCisCountries(mockCisCountries); + export const mockCompany = company; export const mockCompanySicCode = companySicCode; export const mockCompanyScenarios = companyScenarios; diff --git a/src/api/test-mocks/mock-CIS-countries.ts b/src/api/test-mocks/mock-CIS-countries.ts index eb392aa123..ebaa45f172 100644 --- a/src/api/test-mocks/mock-CIS-countries.ts +++ b/src/api/test-mocks/mock-CIS-countries.ts @@ -4,25 +4,28 @@ const mockDescription = 'Mock description'; const mockCisCountries = [ { - marketName: 'Abu Dhabi', - isoCode: 'XAD', - shortTermCoverAvailabilityDesc: mockDescription, + countryRatingDesc: 'A', ESRAClassificationDesc: mockDescription, + isoCode: 'XAD', + marketName: 'Abu Dhabi', NBIIssue: '', + shortTermCoverAvailabilityDesc: mockDescription, }, { - marketName: 'Algeria', - isoCode: 'DZA', - shortTermCoverAvailabilityDesc: mockDescription, + countryRatingDesc: 'B+', ESRAClassificationDesc: mockDescription, + isoCode: 'DZA', + marketName: 'Algeria', NBIIssue: '', + shortTermCoverAvailabilityDesc: mockDescription, }, { - marketName: 'Greenland', - isoCode: 'GRL', - shortTermCoverAvailabilityDesc: mockDescription, + countryRatingDesc: 'CCC-', ESRAClassificationDesc: mockDescription, + isoCode: 'GRL', + marketName: 'Greenland', NBIIssue: '', + shortTermCoverAvailabilityDesc: mockDescription, }, ] as Array; diff --git a/src/api/types/country/index.ts b/src/api/types/country/index.ts index 06f84eb260..9fd8241497 100644 --- a/src/api/types/country/index.ts +++ b/src/api/types/country/index.ts @@ -2,19 +2,20 @@ import { Currency } from '../currency'; import { Relationship } from '../relationship'; export interface CisCountry { - marketName: string; - isoCode: string; - shortTermCoverAvailabilityDesc: string; + countryRatingDesc: string; ESRAClassificationDesc: string; - NBIIssue: string; + isoCode: string; + marketName: string; marketRiskAppetitePublicDesc: string; - riskCategory?: string; + NBIIssue: string; + esraClassification?: string; + shortTermCoverAvailabilityDesc: string; } export interface Country extends Relationship { name: string; isoCode: string; - riskCategory?: string; + esraClassification?: string; shortTermCover?: boolean; nbiIssueAvailable?: boolean; canGetAQuoteOnline?: boolean; @@ -36,15 +37,18 @@ export interface GetApimCurrenciesResponse { } export interface MappedCisCountry { - name: string; + countryRating: string; + esraClassification?: string; isoCode: string; - shortTermCover: boolean; - riskCategory?: string; nbiIssueAvailable: boolean; + name: string; + esraClassification?: string; + shortTermCover: boolean; canGetAQuoteOnline: boolean; canGetAQuoteOffline: boolean; canGetAQuoteByEmail: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; + noOnlineInsuranceSupport: boolean; noInsuranceSupport: boolean; } diff --git a/src/api/types/helpers/index.ts b/src/api/types/helpers/index.ts index a586b8321a..9ccde13b31 100644 --- a/src/api/types/helpers/index.ts +++ b/src/api/types/helpers/index.ts @@ -2,3 +2,15 @@ export interface MapYesNoFieldParams { answer?: boolean | null; defaultValue?: string; } + +export interface MapCisCountryParams { + shortTermCover: boolean; + nbiIssueAvailable: boolean; + esraClassification?: string | null; +} + +export interface noOnlineInsuranceSupportParams { + countryRating: string; + esraClassification: string; + shortTermCover: string; +} diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts index 686ab8d790..57ea413688 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts @@ -19,7 +19,7 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { let mockCountriesResponse = mockCountries; - const { 1: countryApplyOnline, 4: countryCannotApply, 5: countryNoShortTermCover } = mockCountriesResponse; + const { 1: countryApplyOnline, 4: countryNoInsuranceSupport, 5: countryNoOnlineInsuranceSupport } = mockCountriesResponse; const mockFlash = jest.fn(); beforeEach(() => { @@ -40,7 +40,7 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { api.keystone.APIM.getCisCountries = getCisCountriesSpy; }); - describe('when the submitted country is not found', () => { + describe('when the country is not found', () => { beforeEach(() => { req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = 'Country not in the mock response'; }); @@ -52,7 +52,7 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); }); - describe('when the country can apply for an application online', () => { + describe('when the country has a canApplyForInsuranceOnline flag', () => { const selectedCountryIsoCode = countryApplyOnline.isoCode; const validBody = { @@ -102,13 +102,13 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); }); - describe('when the submitted country does not have short term cover', () => { - const selectedCountryName = countryNoShortTermCover.isoCode; + describe('when the country has a noOnlineInsuranceSupport flag', () => { + const selectedCountryName = countryNoOnlineInsuranceSupport.isoCode; beforeEach(() => { req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryName; - mockCountriesResponse = [countryNoShortTermCover]; + mockCountriesResponse = [countryNoOnlineInsuranceSupport]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); @@ -118,7 +118,7 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { it('should update the session with populated country object', async () => { await post(req, res); - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, countryNoShortTermCover.isoCode); + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, countryNoOnlineInsuranceSupport.isoCode); const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); @@ -137,14 +137,14 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); }); - describe('when the submitted country cannot apply for an application', () => { - const selectedCountryName = countryCannotApply.name; - const selectedCountryIsoCode = countryCannotApply.isoCode; + describe('when the country has a noInsuranceSupport flag', () => { + const selectedCountryName = countryNoInsuranceSupport.name; + const selectedCountryIsoCode = countryNoInsuranceSupport.isoCode; beforeEach(() => { req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryIsoCode; - mockCountriesResponse = [countryCannotApply]; + mockCountriesResponse = [countryNoInsuranceSupport]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts index ba66e5eb56..34498e8605 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts @@ -91,12 +91,12 @@ export const post = async (req: Request, res: Response) => { } /** - * If a country has no insurance support and no short term cover, - * redirect to TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT. + * If a country does not have online insurance support, + * redirect to a specific exit page. */ - const noShortTermCover = !country.noInsuranceSupport && !country.shortTermCover; + if (country.noOnlineInsuranceSupport) { + console.info('Country support - %s - no online insurance support available', country.name); - if (noShortTermCover) { const populatedData = mapSubmittedEligibilityCountry(country); req.session.submittedData = { @@ -107,7 +107,13 @@ export const post = async (req: Request, res: Response) => { return res.redirect(TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); } + /** + * If a country cannot apply for insurance online, + * redirect to a specific exit page. + */ if (country.canApplyForInsuranceOnline) { + console.info('Country support - %s - can apply for insurance online', country.name); + const populatedData = mapSubmittedEligibilityCountry(country); req.session.submittedData = { @@ -122,7 +128,13 @@ export const post = async (req: Request, res: Response) => { return res.redirect(TOTAL_VALUE_INSURED); } + /** + * If a country has no insurance support (online or offline) + * redirect to a specific exit page. + */ if (country.noInsuranceSupport) { + console.info('Country support - %s - no insurance support', country.name); + const populatedData = mapSubmittedEligibilityCountry(country); req.session.submittedData = { @@ -139,6 +151,10 @@ export const post = async (req: Request, res: Response) => { return res.redirect(CANNOT_APPLY_ROUTE); } + + console.info('Country support - %s - unable to determine country support', country.name); + + return res.redirect(PROBLEM_WITH_SERVICE); } catch (error) { console.error('Error posting insurance - eligibility - buyer-country %o', error); diff --git a/src/ui/server/controllers/quote/buyer-country/index.ts b/src/ui/server/controllers/quote/buyer-country/index.ts index dedee1355a..e8894dc693 100644 --- a/src/ui/server/controllers/quote/buyer-country/index.ts +++ b/src/ui/server/controllers/quote/buyer-country/index.ts @@ -121,7 +121,13 @@ export const post = async (req: Request, res: Response) => { return res.redirect(ROUTES.QUOTE.CANNOT_APPLY_EXIT); } + /** + * If a country cannot get a quote online, + * redirect to a specific exit page. + */ if (country.canGetAQuoteOnline) { + console.info('Country support - %s - can get a quote online', country.name); + const populatedData = mapSubmittedEligibilityCountry(country); req.session.submittedData.quoteEligibility = updateSubmittedData(populatedData, req.session.submittedData.quoteEligibility); @@ -133,7 +139,13 @@ export const post = async (req: Request, res: Response) => { return res.redirect(ROUTES.QUOTE.BUYER_BODY); } + /** + * If a country can get a quote by email, + * redirect to a specific exit page. + */ if (country.canGetAQuoteByEmail) { + console.info('Country support - %s - can get a quote by email', country.name); + const populatedData = mapSubmittedEligibilityCountry(country); req.session.submittedData.quoteEligibility = updateSubmittedData(populatedData, req.session.submittedData.quoteEligibility); @@ -149,7 +161,13 @@ export const post = async (req: Request, res: Response) => { return res.redirect(ROUTES.QUOTE.GET_A_QUOTE_BY_EMAIL); } + /** + * If a country cannot get a quote, + * redirect to a specific exit page. + */ if (country.cannotGetAQuote) { + console.info('Country support - %s - cannot a quote', country.name); + const populatedData = mapSubmittedEligibilityCountry(country); req.session.submittedData.quoteEligibility = updateSubmittedData(populatedData, req.session.submittedData.quoteEligibility); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts index 46f5eca1f6..7598a85b83 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts @@ -11,10 +11,10 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('multiple policy - high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; const mock = { ...mockBase, - riskCategory, + esraClassification, creditPeriodInMonths: 1, }; @@ -24,7 +24,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); @@ -40,7 +40,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts index 6326a3cd0e..dd63ea1980 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts @@ -11,10 +11,10 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('multiple policy - standard risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; const mock = { ...mockBase, - riskCategory, + esraClassification, creditPeriodInMonths: 1, }; @@ -24,7 +24,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); @@ -40,7 +40,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts index e9de048325..cb775c6273 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts @@ -11,10 +11,10 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('multiple policy - very high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; const mock = { ...mockBase, - riskCategory, + esraClassification, creditPeriodInMonths: 1, }; @@ -24,7 +24,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); @@ -40,7 +40,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts index 741accb185..f86887a003 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts @@ -17,10 +17,10 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('single policy - high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; const mock = { ...mockBase, - riskCategory, + esraClassification, policyLengthInMonths: 2, }; @@ -30,7 +30,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -46,7 +46,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -62,7 +62,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -78,7 +78,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -94,7 +94,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -110,7 +110,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -126,7 +126,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -142,7 +142,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts index 4dec48ad30..5ae8327bc5 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts @@ -17,10 +17,10 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('single policy - standard risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; const mock = { ...mockBase, - riskCategory, + esraClassification, policyLengthInMonths: 2, }; @@ -30,7 +30,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -46,7 +46,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -62,7 +62,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -78,7 +78,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -94,7 +94,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -110,7 +110,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -126,7 +126,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -142,7 +142,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts index 83680211e9..b0be0d849b 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts @@ -17,10 +17,10 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('single policy - very high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; const mock = { ...mockBase, - riskCategory, + esraClassification, policyLengthInMonths: 2, }; @@ -30,7 +30,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -46,7 +46,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -62,7 +62,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -78,7 +78,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -94,7 +94,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -110,7 +110,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -126,7 +126,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -142,7 +142,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/index.test.ts b/src/ui/server/generate-quote/get-premium-rate/index.test.ts index e9e654bea3..88ffee4146 100644 --- a/src/ui/server/generate-quote/get-premium-rate/index.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/index.test.ts @@ -3,9 +3,9 @@ import { EXTERNAL_API_MAPPINGS, FIELD_VALUES } from '../../constants'; import PRICING_GRID from '../pricing-grid.json'; import { PricingGridMonth, PricingGridRate } from '../../../types'; -const expectedPremiumRate = (policyType: string, riskCategory: string, totalMonths: number, insuredFor: number) => { +const expectedPremiumRate = (policyType: string, esraClassification: string, totalMonths: number, insuredFor: number) => { const mappedPolicyType = PRICING_GRID_MAP.POLICY_TYPE[policyType]; - const mappedRiskCategory = PRICING_GRID_MAP.RISK_CATEGORY[riskCategory]; + const mappedRiskCategory = PRICING_GRID_MAP.RISK_CATEGORY[esraClassification]; const risk = PRICING_GRID[mappedPolicyType][mappedRiskCategory]; @@ -18,10 +18,10 @@ const expectedPremiumRate = (policyType: string, riskCategory: string, totalMont return expected; }; -const getResultAndExpected = (policyType: string, riskCategory: string, totalMonths: number, insuredFor: number) => { - const result = getPremiumRate(policyType, riskCategory, totalMonths, insuredFor); +const getResultAndExpected = (policyType: string, esraClassification: string, totalMonths: number, insuredFor: number) => { + const result = getPremiumRate(policyType, esraClassification, totalMonths, insuredFor); - const expected = expectedPremiumRate(policyType, riskCategory, totalMonths, insuredFor); + const expected = expectedPremiumRate(policyType, esraClassification, totalMonths, insuredFor); return { result, @@ -37,11 +37,11 @@ describe('server/generate-quote/get-premium-rate', () => { const mock = { policyType: FIELD_VALUES.POLICY_TYPE.MULTIPLE, insuredFor: 80, - riskCategory: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, + esraClassification: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, totalMonths: 2, }; - const result = getPremiumRate(mock.policyType, mock.riskCategory, mock.totalMonths, mock.insuredFor); + const result = getPremiumRate(mock.policyType, mock.esraClassification, mock.totalMonths, mock.insuredFor); expect(typeof result).toEqual('number'); }); diff --git a/src/ui/server/generate-quote/get-premium-rate/index.ts b/src/ui/server/generate-quote/get-premium-rate/index.ts index 676c86a487..3c333ae4de 100644 --- a/src/ui/server/generate-quote/get-premium-rate/index.ts +++ b/src/ui/server/generate-quote/get-premium-rate/index.ts @@ -22,14 +22,14 @@ const PRICING_GRID_MAP = { * @param {Number} Percentage of the export that will be insured * @returns {Number} Premium rate percentage */ -const getPremiumRate = (policyType: string, riskCategory: string, totalMonths: number, insuredFor: number): number => { +const getPremiumRate = (policyType: string, esraClassification: string, totalMonths: number, insuredFor: number): number => { const policyTypeKey = PRICING_GRID_MAP.POLICY_TYPE[policyType]; - const riskCategoryKey = PRICING_GRID_MAP.RISK_CATEGORY[riskCategory]; + const esraClassificationKey = PRICING_GRID_MAP.RISK_CATEGORY[esraClassification]; const pricingGrid: any = PRICING_GRID as PricingGrid; - const risk = pricingGrid[policyTypeKey][riskCategoryKey]; + const risk = pricingGrid[policyTypeKey][esraClassificationKey]; const pricingGridMonth = risk.find((month: PricingGridMonth) => month.months === totalMonths); diff --git a/src/ui/server/generate-quote/index.test.ts b/src/ui/server/generate-quote/index.test.ts index 391c1efe57..e5a594681f 100644 --- a/src/ui/server/generate-quote/index.test.ts +++ b/src/ui/server/generate-quote/index.test.ts @@ -161,7 +161,7 @@ describe('server/generate-quote/index', () => { const expectedPremiumRate = getPremiumRate( mockSubmittedData.quoteEligibility[POLICY_TYPE], - mockSubmittedData.quoteEligibility[BUYER_COUNTRY].riskCategory, + mockSubmittedData.quoteEligibility[BUYER_COUNTRY].esraClassification, expectedTotalMonths, mockPercentageOfCover, ); diff --git a/src/ui/server/generate-quote/index.ts b/src/ui/server/generate-quote/index.ts index 65aaa2e6bd..ab3b601500 100644 --- a/src/ui/server/generate-quote/index.ts +++ b/src/ui/server/generate-quote/index.ts @@ -114,7 +114,7 @@ const generateQuote = (submittedData: SubmittedData): Quote => { const totalMonths = getTotalMonths(mapped[POLICY_TYPE], mapped[POLICY_LENGTH], mapped[CREDIT_PERIOD]); - const premiumRate = getPremiumRate(mapped[POLICY_TYPE], mapped[BUYER_COUNTRY].riskCategory, totalMonths, mapped[PERCENTAGE_OF_COVER]); + const premiumRate = getPremiumRate(mapped[POLICY_TYPE], mapped[BUYER_COUNTRY].esraClassification, totalMonths, mapped[PERCENTAGE_OF_COVER]); const [contractValueAmount] = Object.values(contractValue); diff --git a/src/ui/server/graphql/queries/APIM/CIS-countries.ts b/src/ui/server/graphql/queries/APIM/CIS-countries.ts index f0e8506ca8..cb528c1fa7 100644 --- a/src/ui/server/graphql/queries/APIM/CIS-countries.ts +++ b/src/ui/server/graphql/queries/APIM/CIS-countries.ts @@ -5,13 +5,14 @@ const getApimCisCountries = gql` getApimCisCountries { isoCode name - riskCategory + esraClassification canGetAQuoteOnline canGetAQuoteOffline canGetAQuoteByEmail cannotGetAQuote cannotApply canApplyForInsuranceOnline + noOnlineInsuranceSupport noInsuranceSupport shortTermCover } diff --git a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts index bbee7391f2..2f8eb6bce1 100644 --- a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts +++ b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts @@ -25,7 +25,7 @@ describe('server/helpers/mappings/map-submitted-eligibility-country', () => { [BUYER_COUNTRY]: { name: mappedCountry.name, isoCode: mappedCountry.isoCode, - riskCategory: mappedCountry.riskCategory, + esraClassification: mappedCountry.esraClassification, canApplyOnline: countryCanGetAQuoteOnline.canGetAQuoteOnline, }, }; @@ -51,7 +51,7 @@ describe('server/helpers/mappings/map-submitted-eligibility-country', () => { [BUYER_COUNTRY]: { name: mappedCountry.name, isoCode: mappedCountry.isoCode, - riskCategory: mappedCountry.riskCategory, + esraClassification: mappedCountry.esraClassification, canApplyOnline: countryCanApplyForInsuranceOnline.canApplyForInsuranceOnline, }, }; diff --git a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts index f7cf2ecfc5..a89a0848c4 100644 --- a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts +++ b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts @@ -12,13 +12,13 @@ const { * @returns {Object} Object with BUYER_COUNTRY object, country fields and canApplyOnline flag */ const mapSubmittedEligibilityCountry = (country: Country) => { - const { name, isoCode, riskCategory } = country; + const { name, isoCode, esraClassification } = country; const mapped = { [BUYER_COUNTRY]: { name, isoCode, - riskCategory, + esraClassification, canApplyOnline: country.canGetAQuoteOnline || country.canApplyForInsuranceOnline, }, }; diff --git a/src/ui/server/test-mocks/mock-countries.ts b/src/ui/server/test-mocks/mock-countries.ts index 980366f7e5..b133b07593 100644 --- a/src/ui/server/test-mocks/mock-countries.ts +++ b/src/ui/server/test-mocks/mock-countries.ts @@ -26,7 +26,7 @@ const mockCountries = [ name: 'Abu Dhabi', ...baseCountry, isoCode: 'XAD', - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, shortTermCover: false, canGetAQuoteOnline: false, canApplyForInsuranceOnline: false, @@ -35,7 +35,7 @@ const mockCountries = [ { name: 'Algeria', isoCode: 'DZA', - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, ...baseCountry, }, /** @@ -46,7 +46,7 @@ const mockCountries = [ { name: 'Egypt', isoCode: 'EGY', - riskCategory: RISK.VERY_HIGH, + esraClassification: RISK.VERY_HIGH, ...baseCountry, canGetAQuoteOnline: false, canGetAQuoteByEmail: true, @@ -58,7 +58,7 @@ const mockCountries = [ { name: 'Gabon', isoCode: 'GAB', - riskCategory: RISK.VERY_HIGH, + esraClassification: RISK.VERY_HIGH, ...baseCountry, canGetAQuoteOnline: false, canApplyForInsuranceOnline: false, @@ -72,10 +72,11 @@ const mockCountries = [ name: 'Gibraltar', isoCode: 'GIB', ...baseCountry, - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, canGetAQuoteOnline: false, canGetAQuoteOffline: false, canApplyForInsuranceOnline: false, + noOnlineInsuranceSupport: false, noInsuranceSupport: true, }, /** @@ -88,13 +89,14 @@ const mockCountries = [ name: 'France', isoCode: 'FRA', ...baseCountry, - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, canGetAQuoteOnline: true, canGetAQuoteOffline: true, canApplyForInsuranceOnline: true, canApplyForInsuranceOffline: false, noInsuranceSupport: false, shortTermCover: false, + noOnlineInsuranceSupport: true, }, ] as Array; diff --git a/src/ui/types/country.d.ts b/src/ui/types/country.d.ts index 12cb54e958..be851aef75 100644 --- a/src/ui/types/country.d.ts +++ b/src/ui/types/country.d.ts @@ -2,7 +2,7 @@ interface Country { id?: string; name: string; isoCode: string; - riskCategory: string; + esraClassification: string; selected?: boolean; value: string; canGetAQuoteOnline: boolean; @@ -10,6 +10,7 @@ interface Country { canGetAQuoteByEmail: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; + noOnlineInsuranceSupport: boolean; noInsuranceSupport: boolean; shortTermCover: boolean; } From 82964a85fb790425cd50df1256d0cf103f75aa6e Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Fri, 20 Dec 2024 11:16:57 +0000 Subject: [PATCH 03/12] feat(EMS-4065): country risk logic - application - no support (#3419) * feat(EMS-4065): country risk logic - application - no support * feat(EMS-4065): fix/update e2e tests * chore(EMS-4065): remove commented code * feat(EMS-4065): rename SHORT_TERM_COVER_AVAILABLE to SHORT_TERM_COVER * feat(EMS-4065): fix typo * feat(EMS-4065): minor code improvement * feat(EMS-4065): code improvement * feat(EMS-4065): fix/update e2e tests --- e2e-tests/constants/api.js | 2 +- e2e-tests/constants/external-apis.js | 2 +- e2e-tests/fixtures/countries.js | 2 + .../eligibility/cannot-apply-page.spec.js | 5 +- .../cannot-apply/cannot-apply-page.spec.js | 5 +- src/api/.keystone/config.js | 94 +++++++++----- src/api/constants/external-apis.ts | 3 +- .../has-valid-short-term-cover/index.test.ts | 2 +- .../has-valid-short-term-cover/index.ts | 2 +- .../index.test.ts | 4 +- .../can-apply-for-insurance-online/index.ts | 6 +- .../can-apply-for-quote-offline/index.test.ts | 18 +-- .../can-apply-for-quote-offline/index.ts | 12 +- .../index.test.ts | 14 +-- .../index.ts | 10 +- .../map-CIS-country/index.test.ts | 19 ++- .../map-CIS-country/index.ts | 17 ++- .../index.test.ts | 18 +-- .../map-short-term-cover-available/index.ts | 10 +- .../no-insurance-support/index.test.ts | 116 ++++++++++++++++++ .../no-insurance-support/index.ts | 43 +++++++ .../index-rating-a.test.ts | 2 +- .../index-rating-b.test.ts | 2 +- .../index-rating-c-and-d.test.ts | 6 +- .../index-rating-none.test.ts | 2 +- .../a-and-b-rating-conditions/index.ts | 6 +- .../index-rating-a-and-b.test.ts | 6 +- .../index-rating-c.test.ts | 2 +- .../index-rating-d.test.ts | 2 +- .../index-rating-none.test.ts | 2 +- .../c-and-d-rating-conditions/index.ts | 6 +- .../no-online-insurance-support/index.ts | 4 +- src/api/types/country/index.ts | 3 +- src/api/types/helpers/index.ts | 2 +- 34 files changed, 335 insertions(+), 114 deletions(-) rename src/api/helpers/map-CIS-countries/map-CIS-country/{can-apply-for-insurance-online/has-valid-esra-classification => esra-classification-is-standard-high-or-very-high}/index.test.ts (65%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{can-apply-for-insurance-online/has-valid-esra-classification => esra-classification-is-standard-high-or-very-high}/index.ts (53%) create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts diff --git a/e2e-tests/constants/api.js b/e2e-tests/constants/api.js index 3d0b369911..4f45b2e43d 100644 --- a/e2e-tests/constants/api.js +++ b/e2e-tests/constants/api.js @@ -7,7 +7,7 @@ export const API = { HIGH: 'High', STANDARD: 'Standard Risk', }, - SHORT_TERM_COVER_AVAILABLE: { + SHORT_TERM_COVER: { YES: 'Yes', ILC: 'ILC Only', CILC: 'CILC Only', diff --git a/e2e-tests/constants/external-apis.js b/e2e-tests/constants/external-apis.js index 93aaa1bb58..84d8166d22 100644 --- a/e2e-tests/constants/external-apis.js +++ b/e2e-tests/constants/external-apis.js @@ -8,7 +8,7 @@ export const EXTERNAL_API_DEFINITIONS = { STANDARD: 'Standard Risk', NONE: 'None', }, - SHORT_TERM_COVER_AVAILABLE: { + SHORT_TERM_COVER: { YES: 'Yes', NO: 'No', ILC: 'ILC Only', diff --git a/e2e-tests/fixtures/countries.js b/e2e-tests/fixtures/countries.js index 4f471d53c7..78b26b4b6e 100644 --- a/e2e-tests/fixtures/countries.js +++ b/e2e-tests/fixtures/countries.js @@ -80,6 +80,7 @@ const { 5: APPLICATION_UNSUPPORTED_2, 7: APPLICATION_UNSUPPORTED_3, 9: APPLICATION_UNSUPPORTED_4, + 10: APPLICATION_CANNOT_APPLY_1, } = mockCountries; export const COUNTRY_APPLICATION_SUPPORT = { @@ -89,6 +90,7 @@ export const COUNTRY_APPLICATION_SUPPORT = { UNSUPPORTED_2: APPLICATION_UNSUPPORTED_2, UNSUPPORTED_3: APPLICATION_UNSUPPORTED_3, UNSUPPORTED_4: APPLICATION_UNSUPPORTED_4, + CANNOT_APPLY_1: APPLICATION_CANNOT_APPLY_1, NO_SHORT_TERM_COVER_1: APPLICATION_NO_SHORT_TERM_COVER_1, NO_SHORT_TERM_COVER_2: APPLICATION_NO_SHORT_TERM_COVER_2, }; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js index b010cba1aa..f8c95a6adb 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js @@ -12,12 +12,11 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME_UNSUPPORTED = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME; +const COUNTRY_NAME_UNSUPPORTED = COUNTRY_APPLICATION_SUPPORT.CANNOT_APPLY_1.NAME; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-4065 -context.skip('Insurance Eligibility - Cannot apply exit page', () => { +context('Insurance Eligibility - Cannot apply exit page', () => { beforeEach(() => { cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js index 9229353dc3..5dff77af05 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js @@ -13,12 +13,11 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME; +const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.CANNOT_APPLY_1.NAME; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-4065 -context.skip( +context( 'Insurance - Cannot apply page - as an exporter, I want to check if UKEF offer credit insurance policy for where my buyer is based - Unsupported country', () => { beforeEach(() => { diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index dbae4e93c1..bcb8c5d64e 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -828,7 +828,7 @@ var EXTERNAL_API_DEFINITIONS = { STANDARD: 'Standard Risk', NONE: 'None', }, - SHORT_TERM_COVER_AVAILABLE: { + SHORT_TERM_COVER: { YES: 'Yes', NO: 'No', ILC: 'ILC Only', @@ -856,6 +856,7 @@ var EXTERNAL_API_DEFINITIONS = { B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], D: ['D'], + NOT_APPLICABLE: 'N/A', }, }, COMPANIES_HOUSE: { @@ -8990,17 +8991,17 @@ var map_esra_classification_default = mapEsraClassification; // helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts var { - CIS: { SHORT_TERM_COVER_AVAILABLE }, + CIS: { SHORT_TERM_COVER }, } = EXTERNAL_API_DEFINITIONS; var mapShortTermCoverAvailable = (str) => { switch (str) { - case SHORT_TERM_COVER_AVAILABLE.YES: + case SHORT_TERM_COVER.YES: return true; - case SHORT_TERM_COVER_AVAILABLE.ILC: + case SHORT_TERM_COVER.ILC: return true; - case SHORT_TERM_COVER_AVAILABLE.CILC: + case SHORT_TERM_COVER.CILC: return true; - case SHORT_TERM_COVER_AVAILABLE.REFER: + case SHORT_TERM_COVER.REFER: return true; default: return false; @@ -9046,28 +9047,32 @@ var cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification } var cannot_get_a_quote_default = cannotGetAQuote; // helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts -var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; +var { + CIS: { + SHORT_TERM_COVER: { ILC, CILC, REFER }, + }, +} = EXTERNAL_API_DEFINITIONS; var canApplyForAQuoteOffline = (originalShortTermCover) => { - if (originalShortTermCover === CIS2.SHORT_TERM_COVER_AVAILABLE.ILC) { + if (originalShortTermCover === ILC) { return true; } - if (originalShortTermCover === CIS2.SHORT_TERM_COVER_AVAILABLE.CILC) { + if (originalShortTermCover === CILC) { return true; } - if (originalShortTermCover === CIS2.SHORT_TERM_COVER_AVAILABLE.REFER) { + if (originalShortTermCover === REFER) { return true; } return false; }; var can_apply_for_quote_offline_default = canApplyForAQuoteOffline; -// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts +// helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts var { CIS: { ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, }, } = EXTERNAL_API_DEFINITIONS; -var hasValidEsraClassification = (esraClassification) => { +var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { switch (esraClassification) { case STANDARD: return true; @@ -9079,19 +9084,19 @@ var hasValidEsraClassification = (esraClassification) => { return false; } }; -var has_valid_esra_classification_default = hasValidEsraClassification; +var esra_classification_is_standard_high_or_very_high_default = esraClassificationIsStandardHighOrVeryHigh; // helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts var { CIS: { - SHORT_TERM_COVER_AVAILABLE: { YES: YES2, REFER, UNLISTED }, + SHORT_TERM_COVER: { YES: YES2, REFER: REFER2, UNLISTED }, }, } = EXTERNAL_API_DEFINITIONS; var hasValidShortTermCover = (shortTermCover) => { switch (shortTermCover) { case YES2: return true; - case REFER: + case REFER2: return true; case UNLISTED: return true; @@ -9120,7 +9125,7 @@ var country_rating_is_a_or_b_default = countryRatingIsAorB; var canApplyForInsuranceOnline = (cisCountry) => { const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; const conditions = - has_valid_esra_classification_default(ESRAClassificationDesc) && + esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && has_valid_short_term_cover_default(shortTermCoverAvailabilityDesc) && country_rating_is_a_or_b_default(countryRatingDesc); return conditions; @@ -9131,7 +9136,7 @@ var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE }, - SHORT_TERM_COVER_AVAILABLE: { NO: NO2, ILC, CILC }, + SHORT_TERM_COVER: { NO: NO2, ILC: ILC2, CILC: CILC2 }, }, } = EXTERNAL_API_DEFINITIONS; var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { @@ -9139,10 +9144,10 @@ var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover return false; } if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { - if (shortTermCover === ILC) { + if (shortTermCover === ILC2) { return true; } - if (shortTermCover === CILC) { + if (shortTermCover === CILC2) { return true; } if (shortTermCover === NO2) { @@ -9175,7 +9180,7 @@ var country_rating_is_c_or_d_default = countryRatingIsCorD; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE2 }, - SHORT_TERM_COVER_AVAILABLE: { YES: YES3, NO: NO3, ILC: ILC2, CILC: CILC2, REFER: REFER2, UNLISTED: UNLISTED2 }, + SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC3, CILC: CILC3, REFER: REFER3, UNLISTED: UNLISTED2 }, }, } = EXTERNAL_API_DEFINITIONS; var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { @@ -9186,13 +9191,13 @@ var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover if (shortTermCover === YES3) { return true; } - if (shortTermCover === ILC2) { + if (shortTermCover === ILC3) { return true; } - if (shortTermCover === CILC2) { + if (shortTermCover === CILC3) { return true; } - if (shortTermCover === REFER2) { + if (shortTermCover === REFER3) { return true; } if (shortTermCover === UNLISTED2) { @@ -9226,14 +9231,40 @@ var noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCo }; var no_online_insurance_support_default = noOnlineInsuranceSupport; +// helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts +var { + CIS: { + COUNTRY_RATINGS: { NOT_APPLICABLE }, + ESRA_CLASSIFICATION: { NONE: NONE3 }, + SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC4 }, + }, +} = EXTERNAL_API_DEFINITIONS; +var noInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }) => { + const shortTermCoverIsUnlisted = shortTermCover === UNLISTED3; + const esraClassificationIsNone = esraClassification === NONE3; + const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; + const countryRatingConditions = + country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; + if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { + return true; + } + const esraClassificationConditions = esra_classification_is_standard_high_or_very_high_default(esraClassification) || esraClassificationIsNone; + if (shortTermCover === CILC4 && countryRatingIsNotApplicable && esraClassificationConditions) { + return true; + } + return false; +}; +var no_insurance_support_default = noInsuranceSupport; + // helpers/map-CIS-countries/map-CIS-country/index.ts var mapCisCountry = (cisCountry) => { const { countryRatingDesc, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc } = cisCountry; const esraClassification = map_esra_classification_default(cisCountry.ESRAClassificationDesc); const nbiIssueAvailable = map_NBI_issue_available_default(cisCountry.NBIIssue); const shortTermCover = map_short_term_cover_available_default(cisCountry.shortTermCoverAvailabilityDesc); + const countryRating = countryRatingDesc; const mapped = { - countryRating: countryRatingDesc, + countryRating, esraClassification, isoCode, name: marketName, @@ -9245,7 +9276,12 @@ var mapCisCountry = (cisCountry) => { cannotGetAQuote: cannot_get_a_quote_default({ shortTermCover, nbiIssueAvailable, esraClassification }), canApplyForInsuranceOnline: can_apply_for_insurance_online_default(cisCountry), noOnlineInsuranceSupport: no_online_insurance_support_default({ - countryRating: countryRatingDesc, + countryRating, + esraClassification: ESRAClassificationDesc, + shortTermCover: shortTermCoverAvailabilityDesc, + }), + noInsuranceSupport: no_insurance_support_default({ + countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, }), @@ -9262,9 +9298,9 @@ var sortArrayAlphabetically = (arr, field) => { var sort_array_alphabetically_default = sortArrayAlphabetically; // helpers/map-CIS-countries/index.ts -var { CIS: CIS3 } = EXTERNAL_API_DEFINITIONS; +var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; var mapCisCountries = (countries) => { - const filteredCountries = filter_cis_entries_default(countries, CIS3.INVALID_COUNTRIES, 'marketName'); + const filteredCountries = filter_cis_entries_default(countries, CIS2.INVALID_COUNTRIES, 'marketName'); const mapped = filteredCountries.map((country) => map_CIS_country_default(country)); const sorted = sort_array_alphabetically_default(mapped, 'name'); return sorted; @@ -9289,7 +9325,7 @@ var getApimCisCountries = async () => { var get_APIM_CIS_countries_default = getApimCisCountries; // helpers/map-currencies/index.ts -var { CIS: CIS4 } = EXTERNAL_API_DEFINITIONS; +var { CIS: CIS3 } = EXTERNAL_API_DEFINITIONS; var getSupportedCurrencies = (currencies) => { const supported = currencies.filter((currency) => SUPPORTED_CURRENCIES.find((currencyCode) => currency.isoCode === currencyCode)); return supported; @@ -9299,7 +9335,7 @@ var getAlternativeCurrencies = (currencies) => { return alternate; }; var mapCurrencies = (currencies, alternativeCurrencies) => { - let currenciesArray = filter_cis_entries_default(currencies, CIS4.INVALID_CURRENCIES, 'name'); + let currenciesArray = filter_cis_entries_default(currencies, CIS3.INVALID_CURRENCIES, 'name'); if (!alternativeCurrencies) { currenciesArray = getSupportedCurrencies(currenciesArray); } else { diff --git a/src/api/constants/external-apis.ts b/src/api/constants/external-apis.ts index 93aaa1bb58..1f52118ae8 100644 --- a/src/api/constants/external-apis.ts +++ b/src/api/constants/external-apis.ts @@ -8,7 +8,7 @@ export const EXTERNAL_API_DEFINITIONS = { STANDARD: 'Standard Risk', NONE: 'None', }, - SHORT_TERM_COVER_AVAILABLE: { + SHORT_TERM_COVER: { YES: 'Yes', NO: 'No', ILC: 'ILC Only', @@ -36,6 +36,7 @@ export const EXTERNAL_API_DEFINITIONS = { B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], D: ['D'], + NOT_APPLICABLE: 'N/A', }, }, COMPANIES_HOUSE: { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts index 261f607787..2b9b8a0fe4 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts @@ -3,7 +3,7 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; const { CIS: { - SHORT_TERM_COVER_AVAILABLE: { YES, REFER, UNLISTED, NO, ILC, CILC }, + SHORT_TERM_COVER: { YES, REFER, UNLISTED, NO, ILC, CILC }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts index bfcae7b00d..32c1e267cf 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts @@ -2,7 +2,7 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; const { CIS: { - SHORT_TERM_COVER_AVAILABLE: { YES, REFER, UNLISTED }, + SHORT_TERM_COVER: { YES, REFER, UNLISTED }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts index 3d02327bf5..b163837507 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts @@ -1,5 +1,5 @@ import canApplyForInsuranceOnline from '.'; -import hasValidEsraClassification from './has-valid-esra-classification'; +import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; import hasValidShortTermCover from './has-valid-short-term-cover'; import countryRatingIsAorB from '../country-rating-is-a-or-b'; import { mockCisCountry } from '../../../../test-mocks'; @@ -11,7 +11,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, marketRiskAppetitePublicDesc } = mockCisCountry; const expected = - hasValidEsraClassification(ESRAClassificationDesc) && + esraClassificationIsStandardHighOrVeryHigh(ESRAClassificationDesc) && hasValidShortTermCover(shortTermCoverAvailabilityDesc) && countryRatingIsAorB(marketRiskAppetitePublicDesc); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts index 9aeeaee65f..a212117e8d 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts @@ -1,4 +1,4 @@ -import hasValidEsraClassification from './has-valid-esra-classification'; +import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; import hasValidShortTermCover from './has-valid-short-term-cover'; import countryRatingIsAorB from '../country-rating-is-a-or-b'; import { CisCountry } from '../../../../types'; @@ -13,7 +13,9 @@ const canApplyForInsuranceOnline = (cisCountry: CisCountry): boolean => { const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; const conditions = - hasValidEsraClassification(ESRAClassificationDesc) && hasValidShortTermCover(shortTermCoverAvailabilityDesc) && countryRatingIsAorB(countryRatingDesc); + esraClassificationIsStandardHighOrVeryHigh(ESRAClassificationDesc) && + hasValidShortTermCover(shortTermCoverAvailabilityDesc) && + countryRatingIsAorB(countryRatingDesc); return conditions; }; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts index 1915c7cc4d..d7fd522c00 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts @@ -2,16 +2,20 @@ import canApplyForAQuoteOffline from '.'; import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; import mockCountries from '../../../../test-mocks/mock-countries'; -const { CIS } = EXTERNAL_API_DEFINITIONS; +const { + CIS: { + SHORT_TERM_COVER: { ILC, CILC, REFER }, + }, +} = EXTERNAL_API_DEFINITIONS; const { 1: mockCountryBase } = mockCountries; describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { - describe(`when shortTermCoverAvailabilityDesc is ${CIS.SHORT_TERM_COVER_AVAILABLE.ILC}`, () => { + describe(`when shortTermCoverAvailabilityDesc is ${ILC}`, () => { it('should return true', () => { const mockCountry = { ...mockCountryBase, - shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.ILC, + shortTermCoverAvailabilityDesc: ILC, }; const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); @@ -20,11 +24,11 @@ describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { }); }); - describe(`when shortTermCoverAvailabilityDesc is ${CIS.SHORT_TERM_COVER_AVAILABLE.CILC}`, () => { + describe(`when shortTermCoverAvailabilityDesc is ${CILC}`, () => { it('should return true', () => { const mockCountry = { ...mockCountryBase, - shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.CILC, + shortTermCoverAvailabilityDesc: CILC, }; const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); @@ -33,11 +37,11 @@ describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { }); }); - describe(`when shortTermCoverAvailabilityDesc is ${CIS.SHORT_TERM_COVER_AVAILABLE.REFER}`, () => { + describe(`when shortTermCoverAvailabilityDesc is ${REFER}`, () => { it('should return true', () => { const mockCountry = { ...mockCountryBase, - shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.REFER, + shortTermCoverAvailabilityDesc: REFER, }; const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts index b51cd75797..496656dbd6 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts @@ -1,6 +1,10 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; -const { CIS } = EXTERNAL_API_DEFINITIONS; +const { + CIS: { + SHORT_TERM_COVER: { ILC, CILC, REFER }, + }, +} = EXTERNAL_API_DEFINITIONS; /** * canApplyForAQuoteOffline @@ -9,15 +13,15 @@ const { CIS } = EXTERNAL_API_DEFINITIONS; * @returns {Boolean} */ export const canApplyForAQuoteOffline = (originalShortTermCover: string) => { - if (originalShortTermCover === CIS.SHORT_TERM_COVER_AVAILABLE.ILC) { + if (originalShortTermCover === ILC) { return true; } - if (originalShortTermCover === CIS.SHORT_TERM_COVER_AVAILABLE.CILC) { + if (originalShortTermCover === CILC) { return true; } - if (originalShortTermCover === CIS.SHORT_TERM_COVER_AVAILABLE.REFER) { + if (originalShortTermCover === REFER) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.test.ts similarity index 65% rename from src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.test.ts index abb87f9607..79d169f8b7 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.test.ts @@ -1,5 +1,5 @@ -import hasValidEsraClassification from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; +import esraClassificationIsStandardHighOrVeryHigh from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { CIS: { @@ -10,7 +10,7 @@ const { describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification', () => { describe(`when the classification is ${STANDARD}`, () => { it('should return true', () => { - const result = hasValidEsraClassification(STANDARD); + const result = esraClassificationIsStandardHighOrVeryHigh(STANDARD); expect(result).toEqual(true); }); @@ -18,7 +18,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli describe(`when the classification is ${HIGH}`, () => { it('should return true', () => { - const result = hasValidEsraClassification(HIGH); + const result = esraClassificationIsStandardHighOrVeryHigh(HIGH); expect(result).toEqual(true); }); @@ -26,7 +26,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli describe(`when the classification is ${VERY_HIGH}`, () => { it('should return true', () => { - const result = hasValidEsraClassification(VERY_HIGH); + const result = esraClassificationIsStandardHighOrVeryHigh(VERY_HIGH); expect(result).toEqual(true); }); @@ -34,7 +34,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli describe(`when the classification is ${NONE}`, () => { it('should return false', () => { - const result = hasValidEsraClassification(NONE); + const result = esraClassificationIsStandardHighOrVeryHigh(NONE); expect(result).toEqual(false); }); @@ -42,7 +42,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli describe('when the classification is unrecognised', () => { it('should return false', () => { - const result = hasValidEsraClassification('Some other classification'); + const result = esraClassificationIsStandardHighOrVeryHigh('Some other classification'); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts similarity index 53% rename from src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts index 6f890c8a54..957ab4dabe 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-esra-classification/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts @@ -1,4 +1,4 @@ -import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { CIS: { @@ -7,12 +7,12 @@ const { } = EXTERNAL_API_DEFINITIONS; /** - * hasValidEsraClassification - * Check if a country's "ESRA classification" can apply for insurance online. + * esraClassificationIsStandardHighOrVeryHigh + * Check if a country's "ESRA classification" is STANDARD, HIGH or VERY_HIGH * @param {String} esraClassification: ESRA classification * @returns {Boolean} */ -const hasValidEsraClassification = (esraClassification: string): boolean => { +const esraClassificationIsStandardHighOrVeryHigh = (esraClassification: string): boolean => { switch (esraClassification) { case STANDARD: return true; @@ -28,4 +28,4 @@ const hasValidEsraClassification = (esraClassification: string): boolean => { } }; -export default hasValidEsraClassification; +export default esraClassificationIsStandardHighOrVeryHigh; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index 21786db1e6..df12047f19 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -8,6 +8,7 @@ import cannotGetAQuote from './cannot-get-a-quote'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import canApplyOffline from './can-apply-for-quote-offline'; import noOnlineInsuranceSupport from './no-online-insurance-support'; +import noInsuranceSupport from './no-insurance-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; import { MappedCisCountry } from '../../../types'; import { mockCisCountry } from '../../../test-mocks'; @@ -20,7 +21,7 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { marketName: mockCisCountry.marketName, esraClassification: EXTERNAL_API_MAPPINGS.CIS.ESRA_CLASSIFICATION.STANDARD, isoCode: mockCisCountry.isoCode, - shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.ILC, + shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER.ILC, marketRiskAppetitePublicDesc: CIS.NO_COVER, }; @@ -31,8 +32,10 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { const shortTermCover = mapShortTermCoverAvailable(mockCountryBase.shortTermCoverAvailabilityDesc); const nbiIssueAvailable = mapNbiIssueAvailable(mockCountryBase.NBIIssue); - const mapped = { - countryRating: mockCisCountry.countryRatingDesc, + const countryRating = mockCisCountry.countryRatingDesc; + + const mapped: MappedCisCountry = { + countryRating, esraClassification, isoCode: mockCountryBase.isoCode, name: mockCountryBase.marketName, @@ -50,11 +53,17 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { canApplyForInsuranceOnline: canApplyForInsuranceOnline(mockCisCountry), noOnlineInsuranceSupport: noOnlineInsuranceSupport({ - countryRating: mockCisCountry.countryRatingDesc, + countryRating, + esraClassification: mockCisCountry.ESRAClassificationDesc, + shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, + }), + + noInsuranceSupport: noInsuranceSupport({ + countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, }), - } as MappedCisCountry; + }; expect(result).toEqual(mapped); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index ff34e59662..963b4c0c9f 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -7,6 +7,7 @@ import cannotGetAQuote from './cannot-get-a-quote'; import canApplyForAQuoteOffline from './can-apply-for-quote-offline'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import noOnlineInsuranceSupport from './no-online-insurance-support'; +import noInsuranceSupport from './no-insurance-support'; import { CisCountry, MappedCisCountry } from '../../../types'; /** @@ -22,8 +23,10 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { const nbiIssueAvailable = mapNbiIssueAvailable(cisCountry.NBIIssue); const shortTermCover = mapShortTermCoverAvailable(cisCountry.shortTermCoverAvailabilityDesc); - const mapped = { - countryRating: countryRatingDesc, + const countryRating = countryRatingDesc; + + const mapped: MappedCisCountry = { + countryRating, esraClassification, isoCode, name: marketName, @@ -41,13 +44,17 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { canApplyForInsuranceOnline: canApplyForInsuranceOnline(cisCountry), noOnlineInsuranceSupport: noOnlineInsuranceSupport({ - countryRating: countryRatingDesc, + countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, }), - } as MappedCisCountry; - // TODO: EMS-4065 - noInsuranceSupport. + noInsuranceSupport: noInsuranceSupport({ + countryRating, + esraClassification: ESRAClassificationDesc, + shortTermCover: shortTermCoverAvailabilityDesc, + }), + }; return mapped; }; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts index e33ec29302..353eeacb2d 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts @@ -2,37 +2,37 @@ import mapShortTermCoverAvailable from '.'; import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { - CIS: { SHORT_TERM_COVER_AVAILABLE }, + CIS: { SHORT_TERM_COVER }, } = EXTERNAL_API_DEFINITIONS; describe('helpers/map-cis-countries/map-cis-country/map-short-term-cover-available', () => { - describe(`when the short term cover is ${SHORT_TERM_COVER_AVAILABLE.YES}`, () => { + describe(`when the short term cover is ${SHORT_TERM_COVER.YES}`, () => { it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER_AVAILABLE.YES); + const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.YES); expect(result).toEqual(true); }); }); - describe(`when the short term cover is ${SHORT_TERM_COVER_AVAILABLE.ILC}`, () => { + describe(`when the short term cover is ${SHORT_TERM_COVER.ILC}`, () => { it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER_AVAILABLE.ILC); + const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.ILC); expect(result).toEqual(true); }); }); - describe(`when the short term cover is ${SHORT_TERM_COVER_AVAILABLE.CILC}`, () => { + describe(`when the short term cover is ${SHORT_TERM_COVER.CILC}`, () => { it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER_AVAILABLE.CILC); + const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.CILC); expect(result).toEqual(true); }); }); - describe(`when the short term cover is ${SHORT_TERM_COVER_AVAILABLE.REFER}`, () => { + describe(`when the short term cover is ${SHORT_TERM_COVER.REFER}`, () => { it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER_AVAILABLE.REFER); + const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.REFER); expect(result).toEqual(true); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts index c4aa5dd5d7..44c2c9e2a0 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts @@ -1,7 +1,7 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { - CIS: { SHORT_TERM_COVER_AVAILABLE }, + CIS: { SHORT_TERM_COVER }, } = EXTERNAL_API_DEFINITIONS; /** @@ -12,16 +12,16 @@ const { */ const mapShortTermCoverAvailable = (str: string): boolean => { switch (str) { - case SHORT_TERM_COVER_AVAILABLE.YES: + case SHORT_TERM_COVER.YES: return true; - case SHORT_TERM_COVER_AVAILABLE.ILC: + case SHORT_TERM_COVER.ILC: return true; - case SHORT_TERM_COVER_AVAILABLE.CILC: + case SHORT_TERM_COVER.CILC: return true; - case SHORT_TERM_COVER_AVAILABLE.REFER: + case SHORT_TERM_COVER.REFER: return true; default: diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts new file mode 100644 index 0000000000..84985ad459 --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.test.ts @@ -0,0 +1,116 @@ +import noInsuranceSupport from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { VERY_HIGH, HIGH, STANDARD, NONE }, + SHORT_TERM_COVER: { UNLISTED, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +const mockInitCountry = { + esraClassification: NONE, + shortTermCover: UNLISTED, +}; + +const createMockParams = (countryRating: string, esraClassification?: string, shortTermCover?: string) => { + const params = { + ...mockInitCountry, + countryRating, + }; + + if (esraClassification) { + params.esraClassification = esraClassification; + } + + if (shortTermCover) { + params.shortTermCover = shortTermCover; + } + + return params; +}; + +const params = { + firstConditions: [ + { + country: createMockParams(COUNTRY_RATINGS.A[0]), + description: 'A', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.B[0]), + description: 'B', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.C[0]), + description: 'C', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.D[0]), + description: 'D', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE), + description: 'NOT_APPLICABLE', + expectation: true, + }, + { + country: createMockParams('not recognised'), + description: 'not recognised', + expectation: false, + }, + ], + secondConditions: [ + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, STANDARD, CILC), + description: 'STANDARD', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, HIGH, CILC), + description: 'HIGH', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, VERY_HIGH, CILC), + description: 'VERY_HIGH', + expectation: true, + }, + + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, NONE, CILC), + description: 'NONE', + expectation: true, + }, + ], +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support', () => { + describe(`when shortTermCover is ${UNLISTED} and esraClassification is ${NONE}`, () => { + describe.each(params.firstConditions)('', ({ country, description, expectation }) => { + describe(`when the countryRating is ${description}`, () => { + it(`should return ${expectation}`, () => { + const result = noInsuranceSupport(country); + + expect(result).toEqual(expectation); + }); + }); + }); + }); + + describe(`when shortTermCover is ${CILC} and countryRating is ${COUNTRY_RATINGS.NOT_APPLICABLE}`, () => { + describe.each(params.secondConditions)('', ({ country, description, expectation }) => { + describe(`when the esraClassification is ${description}`, () => { + it(`should return ${expectation}`, () => { + const result = noInsuranceSupport(country); + + expect(result).toEqual(expectation); + }); + }); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts new file mode 100644 index 0000000000..9b7cb2290d --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts @@ -0,0 +1,43 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; +import countryRatingIsAorB from '../country-rating-is-a-or-b'; +import countryRatingIsCorD from '../country-rating-is-c-or-d'; +import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; +import { NoInsuranceSupportParams } from '../../../../types'; + +const { + CIS: { + COUNTRY_RATINGS: { NOT_APPLICABLE }, + ESRA_CLASSIFICATION: { NONE }, + SHORT_TERM_COVER: { UNLISTED, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * noInsuranceSupport + * Check if a country has no insurance support (online or offline) + * @param {String} countryRating: Country rating + * @param {String} esraClassification: ESRA classification + * @param {String} shortTermCover: Short term cover + * @returns {Boolean} + */ +const noInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { + const shortTermCoverIsUnlisted = shortTermCover === UNLISTED; + const esraClassificationIsNone = esraClassification === NONE; + const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; + + const countryRatingConditions = countryRatingIsAorB(countryRating) || countryRatingIsCorD(countryRating) || countryRatingIsNotApplicable; + + if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { + return true; + } + + const esraClassificationConditions = esraClassificationIsStandardHighOrVeryHigh(esraClassification) || esraClassificationIsNone; + + if (shortTermCover === CILC && countryRatingIsNotApplicable && esraClassificationConditions) { + return true; + } + + return false; +}; + +export default noInsuranceSupport; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts index 1e95b0abf4..b3dc1ed7af 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts @@ -5,7 +5,7 @@ const { CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, - SHORT_TERM_COVER_AVAILABLE: { NO, ILC, CILC }, + SHORT_TERM_COVER: { NO, ILC, CILC }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts index 20a1fd1fb1..4e618ba2dc 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts @@ -5,7 +5,7 @@ const { CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, - SHORT_TERM_COVER_AVAILABLE: { NO, ILC, CILC }, + SHORT_TERM_COVER: { NO, ILC, CILC }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts index 07fb8e1aee..f69ca445e0 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts @@ -2,19 +2,19 @@ import aAndBRatingConditions from '.'; import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; const { - CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION, SHORT_TERM_COVER_AVAILABLE }, + CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION, SHORT_TERM_COVER }, } = EXTERNAL_API_DEFINITIONS; const countryRatingsCParams = COUNTRY_RATINGS.C.map((rating: string) => ({ countryRating: rating, esraClassification: ESRA_CLASSIFICATION.STANDARD, - shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, + shortTermCover: SHORT_TERM_COVER.YES, })); const countryRatingsDParams = COUNTRY_RATINGS.D.map((rating: string) => ({ countryRating: rating, esraClassification: ESRA_CLASSIFICATION.STANDARD, - shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, + shortTermCover: SHORT_TERM_COVER.YES, })); describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - ratings as C and D', () => { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts index 7529467111..84140f061e 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts @@ -5,7 +5,7 @@ const { CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION: { NONE }, - SHORT_TERM_COVER_AVAILABLE: { NO }, + SHORT_TERM_COVER: { NO }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts index 057ab3b3a9..cc661b67d4 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts @@ -1,11 +1,11 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; import countryRatingIsAorB from '../../country-rating-is-a-or-b'; -import { noOnlineInsuranceSupportParams } from '../../../../../types'; +import { NoInsuranceSupportParams } from '../../../../../types'; const { CIS: { ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, - SHORT_TERM_COVER_AVAILABLE: { NO, ILC, CILC }, + SHORT_TERM_COVER: { NO, ILC, CILC }, }, } = EXTERNAL_API_DEFINITIONS; @@ -18,7 +18,7 @@ const { * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }: noOnlineInsuranceSupportParams): boolean => { +const aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { if (!countryRatingIsAorB(countryRating)) { return false; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts index bfdf1cf754..872991a0be 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts @@ -2,19 +2,19 @@ import cAndDRatingConditions from '.'; import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; const { - CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION, SHORT_TERM_COVER_AVAILABLE }, + CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION, SHORT_TERM_COVER }, } = EXTERNAL_API_DEFINITIONS; const countryRatingsAParams = COUNTRY_RATINGS.A.map((rating: string) => ({ countryRating: rating, esraClassification: ESRA_CLASSIFICATION.STANDARD, - shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, + shortTermCover: SHORT_TERM_COVER.YES, })); const countryRatingsBParams = COUNTRY_RATINGS.B.map((rating: string) => ({ countryRating: rating, esraClassification: ESRA_CLASSIFICATION.STANDARD, - shortTermCover: SHORT_TERM_COVER_AVAILABLE.YES, + shortTermCover: SHORT_TERM_COVER.YES, })); describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/a-and-b-rating-conditions - rating as A and B', () => { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts index 3fdf1df724..c6b7dd6cd8 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts @@ -5,7 +5,7 @@ const { CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, - SHORT_TERM_COVER_AVAILABLE: { YES, NO, ILC, CILC, REFER, UNLISTED }, + SHORT_TERM_COVER: { YES, NO, ILC, CILC, REFER, UNLISTED }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts index b69ca9ea6a..afc5aa1c8e 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts @@ -5,7 +5,7 @@ const { CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, - SHORT_TERM_COVER_AVAILABLE: { YES, NO, ILC, CILC, REFER, UNLISTED }, + SHORT_TERM_COVER: { YES, NO, ILC, CILC, REFER, UNLISTED }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts index d82092c6a4..b2965918dc 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts @@ -5,7 +5,7 @@ const { CIS: { COUNTRY_RATINGS, ESRA_CLASSIFICATION: { NONE }, - SHORT_TERM_COVER_AVAILABLE: { NO }, + SHORT_TERM_COVER: { NO }, }, } = EXTERNAL_API_DEFINITIONS; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts index 85a134559b..43d315ef9c 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts @@ -1,11 +1,11 @@ import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; import countryRatingIsCorD from '../../country-rating-is-c-or-d'; -import { noOnlineInsuranceSupportParams } from '../../../../../types'; +import { NoInsuranceSupportParams } from '../../../../../types'; const { CIS: { ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, - SHORT_TERM_COVER_AVAILABLE: { YES, NO, ILC, CILC, REFER, UNLISTED }, + SHORT_TERM_COVER: { YES, NO, ILC, CILC, REFER, UNLISTED }, }, } = EXTERNAL_API_DEFINITIONS; @@ -18,7 +18,7 @@ const { * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }: noOnlineInsuranceSupportParams): boolean => { +const cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { if (!countryRatingIsCorD(countryRating)) { return false; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts index 64041b04f6..a853396e34 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts @@ -1,6 +1,6 @@ import aAndBRatingConditions from './a-and-b-rating-conditions'; import cAndDRatingConditions from './c-and-d-rating-conditions'; -import { noOnlineInsuranceSupportParams } from '../../../../types'; +import { NoInsuranceSupportParams } from '../../../../types'; /** * noOnlineInsuranceSupport @@ -10,7 +10,7 @@ import { noOnlineInsuranceSupportParams } from '../../../../types'; * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }: noOnlineInsuranceSupportParams): boolean => { +const noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { const aAndBConditions = aAndBRatingConditions({ countryRating, esraClassification, diff --git a/src/api/types/country/index.ts b/src/api/types/country/index.ts index 9fd8241497..ae67ad0632 100644 --- a/src/api/types/country/index.ts +++ b/src/api/types/country/index.ts @@ -38,11 +38,10 @@ export interface GetApimCurrenciesResponse { export interface MappedCisCountry { countryRating: string; - esraClassification?: string; + esraClassification?: string | null; isoCode: string; nbiIssueAvailable: boolean; name: string; - esraClassification?: string; shortTermCover: boolean; canGetAQuoteOnline: boolean; canGetAQuoteOffline: boolean; diff --git a/src/api/types/helpers/index.ts b/src/api/types/helpers/index.ts index 9ccde13b31..ead4c81e5c 100644 --- a/src/api/types/helpers/index.ts +++ b/src/api/types/helpers/index.ts @@ -9,7 +9,7 @@ export interface MapCisCountryParams { esraClassification?: string | null; } -export interface noOnlineInsuranceSupportParams { +export interface NoInsuranceSupportParams { countryRating: string; esraClassification: string; shortTermCover: string; From 40e7b2a5cf1b70c9fc4f3498062f146a93cb6975 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Fri, 20 Dec 2024 11:52:02 +0000 Subject: [PATCH 04/12] feat(EMS-4071): country risk logic - get a quote online (#3421) * feat(EMS-4065): country risk logic - application - no support * feat(EMS-4065): fix/update e2e tests * chore(EMS-4065): remove commented code * feat(EMS-4065): rename SHORT_TERM_COVER_AVAILABLE to SHORT_TERM_COVER * feat(EMS-4065): fix typo * feat(EMS-4065): minor code improvement * feat(EMS-4065): code improvement * feat(EMS-4065): fix/update e2e tests * feat(EMS-4071): country risk logic - get a quote online * feat(EMS-4071): country risk logic - get a quote online --- src/api/.keystone/config.js | 4979 ++++++++--------- .../index.test.ts | 4 +- .../can-apply-for-insurance-online/index.ts | 4 +- .../can-get-a-quote-online/index.test.ts | 54 +- .../can-get-a-quote-online/index.ts | 25 +- .../map-CIS-country/index.test.ts | 2 +- .../map-CIS-country/index.ts | 2 +- .../index.test.ts | 10 +- .../index.ts | 8 +- 9 files changed, 2482 insertions(+), 2606 deletions(-) rename src/api/helpers/map-CIS-countries/map-CIS-country/{can-apply-for-insurance-online/has-valid-short-term-cover => short-term-cover-is-yes-refer-or-unlisted}/index.test.ts (64%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{can-apply-for-insurance-online/has-valid-short-term-cover => short-term-cover-is-yes-refer-or-unlisted}/index.ts (65%) diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index bcb8c5d64e..3143993d2d 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; @@ -6,91 +6,89 @@ var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { - for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { - if ((from && typeof from === 'object') || typeof from === 'function') { + if (from && typeof from === "object" || typeof from === "function") { for (let key2 of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key2) && key2 !== except) __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable }); } return to; }; -var __toESM = (mod, isNodeMode, target) => ( - (target = mod != null ? __create(__getProtoOf(mod)) : {}), - __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, 'default', { value: mod, enumerable: true }) : target, - mod, - ) -); -var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod); +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // keystone.ts var keystone_exports = {}; __export(keystone_exports, { - default: () => keystone_default, + default: () => keystone_default }); module.exports = __toCommonJS(keystone_exports); -var import_config7 = require('dotenv/config'); -var import_core3 = require('@keystone-6/core'); -var import_overload_protection = __toESM(require('overload-protection')); +var import_config7 = require("dotenv/config"); +var import_core3 = require("@keystone-6/core"); +var import_overload_protection = __toESM(require("overload-protection")); // middleware/headers/security/index.ts var security = (req, res, next) => { - res.setHeader('Strict-Transport-Security', 'max-age=15552000; includeSubDomains; preload'); - res.setHeader('X-Frame-Options', 'deny'); - res.setHeader('X-Content-Type-Options', 'nosniff'); + res.setHeader("Strict-Transport-Security", "max-age=15552000; includeSubDomains; preload"); + res.setHeader("X-Frame-Options", "deny"); + res.setHeader("X-Content-Type-Options", "nosniff"); res.setHeader( - 'Content-Security-Policy', - "default-src 'none';connect-src 'self';base-uri 'self';font-src 'self' data:;form-action 'self';frame-ancestors 'self';img-src 'self';object-src 'none';script-src 'self';script-src-attr 'self';style-src 'self';upgrade-insecure-requests", + "Content-Security-Policy", + "default-src 'none';connect-src 'self';base-uri 'self';font-src 'self' data:;form-action 'self';frame-ancestors 'self';img-src 'self';object-src 'none';script-src 'self';script-src-attr 'self';style-src 'self';upgrade-insecure-requests" ); - res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate, max-age=604800'); - res.setHeader('Referrer-Policy', 'same-origin'); - res.setHeader('X-Download-Options', 'noopen'); - res.setHeader('X-DNS-Prefetch-Control', 'on'); - res.setHeader('Expect-CT', 'max-age=0,enforce'); - res.setHeader('Cross-Origin-Opener-Policy', 'same-origin'); - res.setHeader('Cross-Origin-Resource-Policy', 'same-origin'); - res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp'); + res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=604800"); + res.setHeader("Referrer-Policy", "same-origin"); + res.setHeader("X-Download-Options", "noopen"); + res.setHeader("X-DNS-Prefetch-Control", "on"); + res.setHeader("Expect-CT", "max-age=0,enforce"); + res.setHeader("Cross-Origin-Opener-Policy", "same-origin"); + res.setHeader("Cross-Origin-Resource-Policy", "same-origin"); + res.setHeader("Cross-Origin-Embedder-Policy", "require-corp"); res.setHeader( - 'Permissions-Policy', - 'fullscreen=(self),microphone=(),camera=(),payment=(),geolocation=(),display-capture=(),battery=(),autoplay=(),gyroscope=(),accelerometer=(),web-share=(),usb=(),gamepad=(),magnetometer=(),midi=(),picture-in-picture=(),xr-spatial-tracking=()', + "Permissions-Policy", + "fullscreen=(self),microphone=(),camera=(),payment=(),geolocation=(),display-capture=(),battery=(),autoplay=(),gyroscope=(),accelerometer=(),web-share=(),usb=(),gamepad=(),magnetometer=(),midi=(),picture-in-picture=(),xr-spatial-tracking=()" ); - res.removeHeader('X-Powered-By'); + res.removeHeader("X-Powered-By"); next(); }; var security_default = security; // middleware/headers/check-api-key/index.ts -var import_config = require('dotenv/config'); +var import_config = require("dotenv/config"); var { API_KEY } = process.env; var checkApiKey = (req, res, next) => { - const { 'x-api-key': xApiKey } = req.headers; + const { "x-api-key": xApiKey } = req.headers; if (!xApiKey || xApiKey !== API_KEY) { - return res.status(401).json({ message: 'Unauthorised' }); + return res.status(401).json({ message: "Unauthorised" }); } next(); }; var check_api_key_default = checkApiKey; // middleware/rate-limiter/index.js -var import_express_rate_limit = __toESM(require('express-rate-limit')); +var import_express_rate_limit = __toESM(require("express-rate-limit")); var rateLimiter = (0, import_express_rate_limit.default)({ windowMs: 1 * 60 * 1e3, // 1 minute max: 1e3, // 1K requests / 1 window standardHeaders: false, - legacyHeaders: false, + legacyHeaders: false }); var rate_limiter_default = rateLimiter; // cron/cron-job-scheduler.ts -var cron = __toESM(require('node-cron')); +var cron = __toESM(require("node-cron")); // helpers/cron/scheduler.ts var asyncTaskToSyncTask = (task, context) => (now2) => { @@ -116,31 +114,28 @@ var cronJobScheduler = (jobs, context) => { return; } console.info("Adding scheduled job '%s' on schedule '%s'", description, cronExpression); - cron - .schedule(cronExpression, asyncTaskToSyncTask(taskWithErrorLogging(description, task, context), context)) - .on('error', (error) => console.error("An error occurred scheduling job '%s' %o", description, error)); + cron.schedule(cronExpression, asyncTaskToSyncTask(taskWithErrorLogging(description, task, context), context)).on("error", (error) => console.error("An error occurred scheduling job '%s' %o", description, error)); }); }; var cron_job_scheduler_default = cronJobScheduler; // cron/account/unverified-account-cron-job.ts -var import_dotenv2 = __toESM(require('dotenv')); +var import_dotenv2 = __toESM(require("dotenv")); // helpers/get-unverified-accounts/index.ts var now = /* @__PURE__ */ new Date(); var getUnverifiedAccounts = async (context) => { try { - console.info('Getting unverified accounts - getUnverifiedAccounts (helper)'); + console.info("Getting unverified accounts - getUnverifiedAccounts (helper)"); const accounts = await context.query.Account.findMany({ where: { - AND: [{ verificationExpiry: { lt: now } }, { status: { isVerified: { equals: false } } }, { status: { isInactive: { equals: false } } }], + AND: [{ verificationExpiry: { lt: now } }, { status: { isVerified: { equals: false } } }, { status: { isInactive: { equals: false } } }] }, - query: - 'id firstName lastName email otpSalt otpHash otpExpiry salt hash passwordResetHash passwordResetExpiry verificationHash verificationExpiry reactivationHash reactivationExpiry updatedAt status { id isBlocked isVerified isInactive updatedAt }', + query: "id firstName lastName email otpSalt otpHash otpExpiry salt hash passwordResetHash passwordResetExpiry verificationHash verificationExpiry reactivationHash reactivationExpiry updatedAt status { id isBlocked isVerified isInactive updatedAt }" }); return accounts; } catch (error) { - console.error('Error getting unverified accounts (getUnverifiedAccounts helper) %o', error); + console.error("Error getting unverified accounts (getUnverifiedAccounts helper) %o", error); throw new Error(`Error getting unverified accounts (getUnverifiedAccounts helper) ${error}`); } }; @@ -153,8 +148,8 @@ var mapUnverifiedAccounts = (accounts) => { where: { id: account2.status.id }, data: { isInactive: true, - updatedAt: /* @__PURE__ */ new Date(), - }, + updatedAt: /* @__PURE__ */ new Date() + } }; return mapped; }); @@ -163,15 +158,15 @@ var mapUnverifiedAccounts = (accounts) => { where: { id: account2.id }, data: { updatedAt: /* @__PURE__ */ new Date(), - verificationHash: '', - verificationExpiry: null, - }, + verificationHash: "", + verificationExpiry: null + } }; return mapped; }); return { accountStatus: mappedAccountStatusArray, - account: mappedAccountArray, + account: mappedAccountArray }; }; var map_unverified_accounts_default = mapUnverifiedAccounts; @@ -179,16 +174,16 @@ var map_unverified_accounts_default = mapUnverifiedAccounts; // helpers/map-and-update-unverified-accounts/index.ts var mapAndUpdateUnverifiedAccounts = async (accounts, context) => { try { - console.info('Mapping and updating unverified accounts - mapAndUpdateUnverifiedAccounts'); + console.info("Mapping and updating unverified accounts - mapAndUpdateUnverifiedAccounts"); const { account: account2, accountStatus: accountStatus2 } = map_unverified_accounts_default(accounts); await context.db.Account.updateMany({ - data: account2, + data: account2 }); await context.db.AccountStatus.updateMany({ - data: accountStatus2, + data: accountStatus2 }); } catch (error) { - console.error('Error mapping and updating unverified accounts %o', error); + console.error("Error mapping and updating unverified accounts %o", error); throw new Error(`Error mapping and updating unverified accounts ${error}`); } }; @@ -197,110 +192,110 @@ var map_and_update_unverified_accounts_default = mapAndUpdateUnverifiedAccounts; // helpers/update-unverified-accounts/index.ts var updateUnverifiedAccounts = async (context) => { try { - console.info('Getting and updating unverified accounts'); + console.info("Getting and updating unverified accounts"); const accounts = await get_unverified_accounts_default(context); if (accounts.length) { await map_and_update_unverified_accounts_default(accounts, context); return { - success: true, + success: true }; } - console.info('No unverified accounts found - updateUnverifiedAccounts'); + console.info("No unverified accounts found - updateUnverifiedAccounts"); return { - success: true, + success: true }; } catch (error) { - console.error('Error getting and updating unverified accounts %o', error); + console.error("Error getting and updating unverified accounts %o", error); throw new Error(`Error getting and updating unverified accounts ${error}`); } }; var update_unverified_accounts_default = updateUnverifiedAccounts; // constants/index.ts -var import_dotenv = __toESM(require('dotenv')); +var import_dotenv = __toESM(require("dotenv")); // constants/field-ids/shared/index.ts var SHARED = { - POLICY_TYPE: 'policyType', - SINGLE_POLICY_TYPE: 'singlePolicyType', - MULTIPLE_POLICY_TYPE: 'multiplePolicyType', - POLICY_LENGTH: 'policyLength', - NAME: 'name', - EMAIL: 'email', + POLICY_TYPE: "policyType", + SINGLE_POLICY_TYPE: "singlePolicyType", + MULTIPLE_POLICY_TYPE: "multiplePolicyType", + POLICY_LENGTH: "policyLength", + NAME: "name", + EMAIL: "email" }; var shared_default = SHARED; // constants/field-ids/shared-eligibility/index.ts var SHARED_ELIGIBILITY = { - BUYER_COUNTRY: 'buyerCountry', - BUYER_COUNTRY_ISO_CODE: 'buyerCountryIsoCode', - HAS_MINIMUM_UK_GOODS_OR_SERVICES: 'hasMinimumUkGoodsOrServices', - VALID_EXPORTER_LOCATION: 'validExporterLocation', + BUYER_COUNTRY: "buyerCountry", + BUYER_COUNTRY_ISO_CODE: "buyerCountryIsoCode", + HAS_MINIMUM_UK_GOODS_OR_SERVICES: "hasMinimumUkGoodsOrServices", + VALID_EXPORTER_LOCATION: "validExporterLocation" }; var shared_eligibility_default = SHARED_ELIGIBILITY; // constants/field-ids/insurance/shared/index.ts var SHARED_FIELD_IDS = { - COMPANY: 'company', + COMPANY: "company", COMPANIES_HOUSE: { - COMPANY_NAME: 'companyName', - COMPANY_ADDRESS: 'registeredOfficeAddress', - COMPANY_NUMBER: 'companyNumber', - COMPANY_INCORPORATED: 'dateOfCreation', - SIC_CODE: 'sicCode', - COMPANY_SIC: 'sicCodes', - INDUSTRY_SECTOR_NAME: 'industrySectorName', - INDUSTRY_SECTOR_NAMES: 'industrySectorNames', - FINANCIAL_YEAR_END_DATE: 'financialYearEndDate', + COMPANY_NAME: "companyName", + COMPANY_ADDRESS: "registeredOfficeAddress", + COMPANY_NUMBER: "companyNumber", + COMPANY_INCORPORATED: "dateOfCreation", + SIC_CODE: "sicCode", + COMPANY_SIC: "sicCodes", + INDUSTRY_SECTOR_NAME: "industrySectorName", + INDUSTRY_SECTOR_NAMES: "industrySectorNames", + FINANCIAL_YEAR_END_DATE: "financialYearEndDate", REGISTED_OFFICE_ADDRESS: { - ADDRESS_LINE_1: 'addressLine1', - ADDRESS_LINE_2: 'addressLine2', - CARE_OF: 'careOf', - LOCALITY: 'locality', - REGION: 'region', - POSTAL_CODE: 'postalCode', - COUNTRY: 'country', - PREMISES: 'premises', - }, - }, + ADDRESS_LINE_1: "addressLine1", + ADDRESS_LINE_2: "addressLine2", + CARE_OF: "careOf", + LOCALITY: "locality", + REGION: "region", + POSTAL_CODE: "postalCode", + COUNTRY: "country", + PREMISES: "premises" + } + } }; var shared_default2 = SHARED_FIELD_IDS; // constants/field-ids/insurance/account/index.ts var ACCOUNT = { - ID: 'id', - FIRST_NAME: 'firstName', - LAST_NAME: 'lastName', - EMAIL: 'email', - PASSWORD: 'password', - SALT: 'salt', - HASH: 'hash', - ACCESS_CODE: 'securityCode', - IS_VERIFIED: 'isVerified', - IS_BLOCKED: 'isBlocked', - PASSWORD_RESET_HASH: 'passwordResetHash', - PASSWORD_RESET_EXPIRY: 'passwordResetExpiry', - REACTIVATION_HASH: 'reactivationHash', - REACTIVATION_EXPIRY: 'reactivationExpiry', - VERIFICATION_HASH: 'verificationHash', - VERIFICATION_EXPIRY: 'verificationExpiry', + ID: "id", + FIRST_NAME: "firstName", + LAST_NAME: "lastName", + EMAIL: "email", + PASSWORD: "password", + SALT: "salt", + HASH: "hash", + ACCESS_CODE: "securityCode", + IS_VERIFIED: "isVerified", + IS_BLOCKED: "isBlocked", + PASSWORD_RESET_HASH: "passwordResetHash", + PASSWORD_RESET_EXPIRY: "passwordResetExpiry", + REACTIVATION_HASH: "reactivationHash", + REACTIVATION_EXPIRY: "reactivationExpiry", + VERIFICATION_HASH: "verificationHash", + VERIFICATION_EXPIRY: "verificationExpiry" }; var account_default = ACCOUNT; // constants/field-ids/insurance/policy/index.ts -var REQUESTED_START_DATE = 'requestedStartDate'; -var CONTRACT_COMPLETION_DATE = 'contractCompletionDate'; +var REQUESTED_START_DATE = "requestedStartDate"; +var CONTRACT_COMPLETION_DATE = "contractCompletionDate"; var SHARED_CONTRACT_POLICY = { REQUESTED_START_DATE, REQUESTED_START_DATE_DAY: `${REQUESTED_START_DATE}-day`, REQUESTED_START_DATE_MONTH: `${REQUESTED_START_DATE}-month`, REQUESTED_START_DATE_YEAR: `${REQUESTED_START_DATE}-year`, - POLICY_CURRENCY_CODE: 'policyCurrencyCode', + POLICY_CURRENCY_CODE: "policyCurrencyCode" }; var POLICY = { ...shared_default, TYPE_OF_POLICY: { - POLICY_TYPE: shared_default.POLICY_TYPE, + POLICY_TYPE: shared_default.POLICY_TYPE }, CONTRACT_POLICY: { ...SHARED_CONTRACT_POLICY, @@ -309,114 +304,114 @@ var POLICY = { CONTRACT_COMPLETION_DATE_DAY: `${CONTRACT_COMPLETION_DATE}-day`, CONTRACT_COMPLETION_DATE_MONTH: `${CONTRACT_COMPLETION_DATE}-month`, CONTRACT_COMPLETION_DATE_YEAR: `${CONTRACT_COMPLETION_DATE}-year`, - TOTAL_CONTRACT_VALUE: 'totalValueOfContract', - REQUESTED_CREDIT_LIMIT: 'requestedCreditLimit', + TOTAL_CONTRACT_VALUE: "totalValueOfContract", + REQUESTED_CREDIT_LIMIT: "requestedCreditLimit" }, MULTIPLE: { - TOTAL_MONTHS_OF_COVER: 'totalMonthsOfCover', - }, + TOTAL_MONTHS_OF_COVER: "totalMonthsOfCover" + } }, EXPORT_VALUE: { MULTIPLE: { - TOTAL_SALES_TO_BUYER: 'totalSalesToBuyer', - MAXIMUM_BUYER_WILL_OWE: 'maximumBuyerWillOwe', - }, + TOTAL_SALES_TO_BUYER: "totalSalesToBuyer", + MAXIMUM_BUYER_WILL_OWE: "maximumBuyerWillOwe" + } }, NAME_ON_POLICY: { - NAME: 'nameOnPolicy', - IS_SAME_AS_OWNER: 'isSameAsOwner', - SAME_NAME: 'sameName', - OTHER_NAME: 'otherName', - POSITION: 'position', - POLICY_CONTACT_EMAIL: 'policyContact.email', + NAME: "nameOnPolicy", + IS_SAME_AS_OWNER: "isSameAsOwner", + SAME_NAME: "sameName", + OTHER_NAME: "otherName", + POSITION: "position", + POLICY_CONTACT_EMAIL: "policyContact.email" }, DIFFERENT_NAME_ON_POLICY: { - POLICY_CONTACT_DETAIL: 'policyContactDetail', - POSITION: 'position', + POLICY_CONTACT_DETAIL: "policyContactDetail", + POSITION: "position" }, - NEED_PRE_CREDIT_PERIOD: 'needPreCreditPeriodCover', - CREDIT_PERIOD_WITH_BUYER: 'creditPeriodWithBuyer', + NEED_PRE_CREDIT_PERIOD: "needPreCreditPeriodCover", + CREDIT_PERIOD_WITH_BUYER: "creditPeriodWithBuyer", REQUESTED_JOINTLY_INSURED_PARTY: { - REQUESTED: 'requested', - COMPANY_NAME: 'companyName', - COMPANY_NUMBER: 'companyNumber', - COUNTRY_CODE: 'countryCode', + REQUESTED: "requested", + COMPANY_NAME: "companyName", + COMPANY_NUMBER: "companyNumber", + COUNTRY_CODE: "countryCode" }, - USING_BROKER: 'isUsingBroker', + USING_BROKER: "isUsingBroker", BROKER_DETAILS: { - NAME: 'name', + NAME: "name", EMAIL: shared_default.EMAIL, - BROKER_EMAIL: 'broker.email', - FULL_ADDRESS: 'fullAddress', + BROKER_EMAIL: "broker.email", + FULL_ADDRESS: "fullAddress" }, LOSS_PAYEE: { - IS_APPOINTED: 'isAppointed', + IS_APPOINTED: "isAppointed" }, LOSS_PAYEE_DETAILS: { - NAME: 'name', - LOSS_PAYEE_NAME: 'lossPayee.name', - LOCATION: 'location', - IS_LOCATED_IN_UK: 'isLocatedInUk', - IS_LOCATED_INTERNATIONALLY: 'isLocatedInternationally', + NAME: "name", + LOSS_PAYEE_NAME: "lossPayee.name", + LOCATION: "location", + IS_LOCATED_IN_UK: "isLocatedInUk", + IS_LOCATED_INTERNATIONALLY: "isLocatedInternationally" }, LOSS_PAYEE_FINANCIAL_UK: { - SORT_CODE: 'sortCode', - ACCOUNT_NUMBER: 'accountNumber', + SORT_CODE: "sortCode", + ACCOUNT_NUMBER: "accountNumber" }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { - BIC_SWIFT_CODE: 'bicSwiftCode', - IBAN: 'iban', + BIC_SWIFT_CODE: "bicSwiftCode", + IBAN: "iban" }, - FINANCIAL_ADDRESS: 'bankAddress', - LOSS_PAYEE_FINANCIAL_ADDRESS: 'lossPayee.bankAddress', + FINANCIAL_ADDRESS: "bankAddress", + LOSS_PAYEE_FINANCIAL_ADDRESS: "lossPayee.bankAddress" }; var policy_default = POLICY; // constants/field-ids/insurance/business/index.ts var EXPORTER_BUSINESS = { COMPANIES_HOUSE: { - INPUT: 'companiesHouseNumber', - COMPANY_NAME: 'companyName', - COMPANY_ADDRESS: 'registeredOfficeAddress', - COMPANY_NUMBER: 'companyNumber', - COMPANY_INCORPORATED: 'dateOfCreation', - COMPANY_SIC: 'sicCodes', - FINANCIAL_YEAR_END_DATE: 'financialYearEndDate', + INPUT: "companiesHouseNumber", + COMPANY_NAME: "companyName", + COMPANY_ADDRESS: "registeredOfficeAddress", + COMPANY_NUMBER: "companyNumber", + COMPANY_INCORPORATED: "dateOfCreation", + COMPANY_SIC: "sicCodes", + FINANCIAL_YEAR_END_DATE: "financialYearEndDate", REGISTED_OFFICE_ADDRESS: { - ADDRESS_LINE_1: 'addressLine1', - ADDRESS_LINE_2: 'addressLine2', - CARE_OF: 'careOf', - LOCALITY: 'locality', - REGION: 'region', - POSTAL_CODE: 'postalCode', - COUNTRY: 'country', - PREMISES: 'premises', - }, + ADDRESS_LINE_1: "addressLine1", + ADDRESS_LINE_2: "addressLine2", + CARE_OF: "careOf", + LOCALITY: "locality", + REGION: "region", + POSTAL_CODE: "postalCode", + COUNTRY: "country", + PREMISES: "premises" + } }, YOUR_COMPANY: { - YOUR_BUSINESS: 'yourBusiness', - HAS_DIFFERENT_TRADING_ADDRESS: 'hasDifferentTradingAddress', - HAS_DIFFERENT_TRADING_NAME: 'hasDifferentTradingName', - DIFFERENT_TRADING_NAME: 'differentTradingName', - WEBSITE: 'companyWebsite', - PHONE_NUMBER: 'phoneNumber', + YOUR_BUSINESS: "yourBusiness", + HAS_DIFFERENT_TRADING_ADDRESS: "hasDifferentTradingAddress", + HAS_DIFFERENT_TRADING_NAME: "hasDifferentTradingName", + DIFFERENT_TRADING_NAME: "differentTradingName", + WEBSITE: "companyWebsite", + PHONE_NUMBER: "phoneNumber" }, ALTERNATIVE_TRADING_ADDRESS: { - FULL_ADDRESS: 'fullAddress', - FULL_ADDRESS_DOT_NOTATION: 'alternativeTrading.fullAddress', + FULL_ADDRESS: "fullAddress", + FULL_ADDRESS_DOT_NOTATION: "alternativeTrading.fullAddress" }, NATURE_OF_YOUR_BUSINESS: { - GOODS_OR_SERVICES: 'goodsOrServicesSupplied', - YEARS_EXPORTING: 'totalYearsExporting', - EMPLOYEES_UK: 'totalEmployeesUK', + GOODS_OR_SERVICES: "goodsOrServicesSupplied", + YEARS_EXPORTING: "totalYearsExporting", + EMPLOYEES_UK: "totalEmployeesUK" }, TURNOVER: { - FINANCIAL_YEAR_END_DATE: 'financialYearEndDate', - ESTIMATED_ANNUAL_TURNOVER: 'estimatedAnnualTurnover', - PERCENTAGE_TURNOVER: 'exportsTurnoverPercentage', - TURNOVER_CURRENCY_CODE: 'turnoverCurrencyCode', + FINANCIAL_YEAR_END_DATE: "financialYearEndDate", + ESTIMATED_ANNUAL_TURNOVER: "estimatedAnnualTurnover", + PERCENTAGE_TURNOVER: "exportsTurnoverPercentage", + TURNOVER_CURRENCY_CODE: "turnoverCurrencyCode" }, - HAS_CREDIT_CONTROL: 'hasCreditControlProcess', + HAS_CREDIT_CONTROL: "hasCreditControlProcess" }; var business_default = EXPORTER_BUSINESS; @@ -424,85 +419,85 @@ var business_default = EXPORTER_BUSINESS; var EXPORT_CONTRACT = { ...shared_default, HOW_WAS_THE_CONTRACT_AWARDED: { - AWARD_METHOD: 'awardMethod', - OTHER_AWARD_METHOD: 'otherAwardMethod', + AWARD_METHOD: "awardMethod", + OTHER_AWARD_METHOD: "otherAwardMethod" }, ABOUT_GOODS_OR_SERVICES: { - DESCRIPTION: 'goodsOrServicesDescription', - FINAL_DESTINATION_KNOWN: 'finalDestinationKnown', - FINAL_DESTINATION: 'finalDestinationCountryCode', + DESCRIPTION: "goodsOrServicesDescription", + FINAL_DESTINATION_KNOWN: "finalDestinationKnown", + FINAL_DESTINATION: "finalDestinationCountryCode" }, HOW_WILL_YOU_GET_PAID: { - PAYMENT_TERMS_DESCRIPTION: 'paymentTermsDescription', + PAYMENT_TERMS_DESCRIPTION: "paymentTermsDescription" }, PRIVATE_MARKET: { - ATTEMPTED: 'attempted', - DECLINED_DESCRIPTION: 'declinedDescription', + ATTEMPTED: "attempted", + DECLINED_DESCRIPTION: "declinedDescription" }, - USING_AGENT: 'isUsingAgent', + USING_AGENT: "isUsingAgent", AGENT_DETAILS: { - NAME: 'name', - AGENT_NAME: 'agent.name', - FULL_ADDRESS: 'fullAddress', - AGENT_FULL_ADDRESS: 'agent.fullAddress', - COUNTRY_CODE: 'countryCode', - AGENT_COUNTRY_CODE: 'agent.countryCode', + NAME: "name", + AGENT_NAME: "agent.name", + FULL_ADDRESS: "fullAddress", + AGENT_FULL_ADDRESS: "agent.fullAddress", + COUNTRY_CODE: "countryCode", + AGENT_COUNTRY_CODE: "agent.countryCode" }, AGENT_SERVICE: { - IS_CHARGING: 'agentIsCharging', - SERVICE_DESCRIPTION: 'serviceDescription', + IS_CHARGING: "agentIsCharging", + SERVICE_DESCRIPTION: "serviceDescription" }, AGENT_CHARGES: { - METHOD: 'method', - PAYABLE_COUNTRY_CODE: 'payableCountryCode', - FIXED_SUM: 'fixedSum', - FIXED_SUM_AMOUNT: 'fixedSumAmount', - FIXED_SUM_CURRENCY_CODE: 'fixedSumCurrencyCode', - PERCENTAGE: 'percentage', - PERCENTAGE_CHARGE: 'percentageCharge', - }, + METHOD: "method", + PAYABLE_COUNTRY_CODE: "payableCountryCode", + FIXED_SUM: "fixedSum", + FIXED_SUM_AMOUNT: "fixedSumAmount", + FIXED_SUM_CURRENCY_CODE: "fixedSumCurrencyCode", + PERCENTAGE: "percentage", + PERCENTAGE_CHARGE: "percentageCharge" + } }; var export_contract_default = EXPORT_CONTRACT; // constants/field-ids/insurance/your-buyer/index.ts var YOUR_BUYER = { COMPANY_OR_ORGANISATION: { - NAME: 'companyOrOrganisationName', - ADDRESS: 'address', - COUNTRY: 'country', - REGISTRATION_NUMBER: 'registrationNumber', - WEBSITE: 'website', - }, - CONNECTION_WITH_BUYER: 'exporterIsConnectedWithBuyer', - CONNECTION_WITH_BUYER_DESCRIPTION: 'connectionWithBuyerDescription', - TRADED_WITH_BUYER: 'exporterHasTradedWithBuyer', - OUTSTANDING_PAYMENTS: 'outstandingPayments', - TOTAL_OUTSTANDING_PAYMENTS: 'totalOutstandingPayments', - TOTAL_AMOUNT_OVERDUE: 'totalOverduePayments', - FAILED_PAYMENTS: 'failedPayments', - HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: 'exporterHasPreviousCreditInsuranceWithBuyer', - PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: 'previousCreditInsuranceWithBuyerDescription', - HAS_BUYER_FINANCIAL_ACCOUNTS: 'exporterHasBuyerFinancialAccounts', + NAME: "companyOrOrganisationName", + ADDRESS: "address", + COUNTRY: "country", + REGISTRATION_NUMBER: "registrationNumber", + WEBSITE: "website" + }, + CONNECTION_WITH_BUYER: "exporterIsConnectedWithBuyer", + CONNECTION_WITH_BUYER_DESCRIPTION: "connectionWithBuyerDescription", + TRADED_WITH_BUYER: "exporterHasTradedWithBuyer", + OUTSTANDING_PAYMENTS: "outstandingPayments", + TOTAL_OUTSTANDING_PAYMENTS: "totalOutstandingPayments", + TOTAL_AMOUNT_OVERDUE: "totalOverduePayments", + FAILED_PAYMENTS: "failedPayments", + HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: "exporterHasPreviousCreditInsuranceWithBuyer", + PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: "previousCreditInsuranceWithBuyerDescription", + HAS_BUYER_FINANCIAL_ACCOUNTS: "exporterHasBuyerFinancialAccounts" }; var your_buyer_default = YOUR_BUYER; // constants/field-ids/insurance/declarations/index.ts var DECLARATIONS = { - AGREE_CONFIDENTIALITY: 'agreeToConfidentiality', - AGREE_ANTI_BRIBERY: 'agreeToAntiBribery', - HAS_ANTI_BRIBERY_CODE_OF_CONDUCT: 'hasAntiBriberyCodeOfConduct', - WILL_EXPORT_WITH_CODE_OF_CONDUCT: 'willExportWithAntiBriberyCodeOfConduct', - AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: 'agreeToConfirmationAndAcknowledgements', + AGREE_CONFIDENTIALITY: "agreeToConfidentiality", + AGREE_ANTI_BRIBERY: "agreeToAntiBribery", + HAS_ANTI_BRIBERY_CODE_OF_CONDUCT: "hasAntiBriberyCodeOfConduct", + WILL_EXPORT_WITH_CODE_OF_CONDUCT: "willExportWithAntiBriberyCodeOfConduct", + AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: "agreeToConfirmationAndAcknowledgements" }; var declarations_default = DECLARATIONS; // constants/field-ids/insurance/check-your-answers/index.ts var CHECK_YOUR_ANSWERS = { - ELIGIBILITY: 'eligibility', - EXPORTER_BUSINESS: 'business', - BUYER: 'buyer', - POLICY: 'policy', - EXPORT_CONTRACT: 'exportContract', + ELIGIBILITY: "eligibility", + EXPORTER_BUSINESS: "business", + BUYER: "buyer", + POLICY: "policy", + EXPORT_CONTRACT: "exportContract" }; var check_your_answers_default = CHECK_YOUR_ANSWERS; @@ -511,31 +506,31 @@ var INSURANCE_FIELD_IDS = { ELIGIBILITY: { ...shared_eligibility_default, ...shared_default2, - HAS_COMPANIES_HOUSE_NUMBER: 'hasCompaniesHouseNumber', - COMPANIES_HOUSE_NUMBER: 'companyNumber', - TOTAL_CONTRACT_VALUE: 'totalContractValue', - TOTAL_CONTRACT_VALUE_ID: 'totalContractValueId', - COVER_PERIOD: 'coverPeriod', - COVER_PERIOD_ID: 'coverPeriodId', - HAS_END_BUYER: 'hasEndBuyer', - HAVE_AN_ACCOUNT: 'haveAnAccount', - HAS_REVIEWED_ELIGIBILITY: 'hasReviewedEligibility', - IS_PARTY_TO_CONSORTIUM: 'isPartyToConsortium', - IS_MEMBER_OF_A_GROUP: 'isMemberOfAGroup', + HAS_COMPANIES_HOUSE_NUMBER: "hasCompaniesHouseNumber", + COMPANIES_HOUSE_NUMBER: "companyNumber", + TOTAL_CONTRACT_VALUE: "totalContractValue", + TOTAL_CONTRACT_VALUE_ID: "totalContractValueId", + COVER_PERIOD: "coverPeriod", + COVER_PERIOD_ID: "coverPeriodId", + HAS_END_BUYER: "hasEndBuyer", + HAVE_AN_ACCOUNT: "haveAnAccount", + HAS_REVIEWED_ELIGIBILITY: "hasReviewedEligibility", + IS_PARTY_TO_CONSORTIUM: "isPartyToConsortium", + IS_MEMBER_OF_A_GROUP: "isMemberOfAGroup" }, ...shared_default2, CURRENCY: { - CURRENCY_CODE: 'currencyCode', - ALTERNATIVE_CURRENCY_CODE: 'alternativeCurrencyCode', + CURRENCY_CODE: "currencyCode", + ALTERNATIVE_CURRENCY_CODE: "alternativeCurrencyCode" }, - SUBMISSION_DEADLINE: 'submissionDeadline', + SUBMISSION_DEADLINE: "submissionDeadline", ACCOUNT: account_default, POLICY: policy_default, EXPORTER_BUSINESS: business_default, EXPORT_CONTRACT: export_contract_default, YOUR_BUYER: your_buyer_default, DECLARATIONS: declarations_default, - CHECK_YOUR_ANSWERS: check_your_answers_default, + CHECK_YOUR_ANSWERS: check_your_answers_default }; var insurance_default = INSURANCE_FIELD_IDS; @@ -543,114 +538,114 @@ var insurance_default = INSURANCE_FIELD_IDS; var FIELD_IDS = { ...shared_default, ...shared_eligibility_default, - INSURANCE: insurance_default, + INSURANCE: insurance_default }; // constants/allowed-graphql-resolvers/index.ts -var import_config2 = require('dotenv/config'); +var import_config2 = require("dotenv/config"); var { NODE_ENV } = process.env; -var isDevEnvironment = NODE_ENV === 'development'; +var isDevEnvironment = NODE_ENV === "development"; var DEFAULT_RESOLVERS = [ // application - 'updateBroker', - 'updateBusiness', - 'updateBuyer', - 'updateBuyerRelationship', - 'updateBuyerTradingHistory', - 'updateCompany', - 'updateDeclaration', - 'updateNominatedLossPayee', - 'updateJointlyInsuredParty', - 'updatePolicy', - 'updatePolicyContact', - 'updateExportContract', - 'updateExportContractAgent', - 'updateExportContractAgentService', - 'updateExportContractAgentServiceCharge', - 'updatePrivateMarket', - 'updateSectionReview', - 'updateEligibility', - 'updateCompanyDifferentTradingAddress', - 'referenceNumber', - 'applications', + "updateBroker", + "updateBusiness", + "updateBuyer", + "updateBuyerRelationship", + "updateBuyerTradingHistory", + "updateCompany", + "updateDeclaration", + "updateNominatedLossPayee", + "updateJointlyInsuredParty", + "updatePolicy", + "updatePolicyContact", + "updateExportContract", + "updateExportContractAgent", + "updateExportContractAgentService", + "updateExportContractAgentServiceCharge", + "updatePrivateMarket", + "updateSectionReview", + "updateEligibility", + "updateCompanyDifferentTradingAddress", + "referenceNumber", + "applications", // account - 'account', - 'updateAccount', + "account", + "updateAccount", // misc - 'countries', - 'page', + "countries", + "page" ]; var CUSTOM_RESOLVERS = [ // account - 'accountPasswordReset', - 'accountSignIn', - 'accountSignInSendNewCode', - 'createAnAccount', - 'sendEmailConfirmEmailAddress', - 'sendEmailPasswordResetLink', - 'sendEmailReactivateAccountLink', - 'updateLossPayeeFinancialDetailsUk', - 'updateLossPayeeFinancialDetailsInternational', - 'verifyAccountEmailAddress', - 'verifyAccountPasswordResetToken', - 'verifyAccountReactivationToken', - 'verifyAccountSignInCode', + "accountPasswordReset", + "accountSignIn", + "accountSignInSendNewCode", + "createAnAccount", + "sendEmailConfirmEmailAddress", + "sendEmailPasswordResetLink", + "sendEmailReactivateAccountLink", + "updateLossPayeeFinancialDetailsUk", + "updateLossPayeeFinancialDetailsInternational", + "verifyAccountEmailAddress", + "verifyAccountPasswordResetToken", + "verifyAccountReactivationToken", + "verifyAccountSignInCode", // application - 'createAnApplication', - 'declarationAntiBriberies', - 'declarationConfirmationAndAcknowledgements', - 'declarationHowDataWillBeUseds', - 'deleteApplicationByReferenceNumber', - 'getCompaniesHouseInformation', - 'getApplicationByReferenceNumber', - 'submitApplication', + "createAnApplication", + "declarationAntiBriberies", + "declarationConfirmationAndAcknowledgements", + "declarationHowDataWillBeUseds", + "deleteApplicationByReferenceNumber", + "getCompaniesHouseInformation", + "getApplicationByReferenceNumber", + "submitApplication", // feedback - 'createFeedbackAndSendEmail', - 'getApimCisCountries', - 'getApimCurrencies', + "createFeedbackAndSendEmail", + "getApimCisCountries", + "getApimCurrencies" ]; if (isDevEnvironment) { CUSTOM_RESOLVERS.push( - 'accounts', - 'addAndGetOTP', - 'createApplications', - 'createAnAbandonedApplication', - 'createManyApplications', - 'createBuyer', - 'deleteAnAccount', - 'deleteApplications', - 'getAccountPasswordResetToken', - 'updateAccountStatus', + "accounts", + "addAndGetOTP", + "createApplications", + "createAnAbandonedApplication", + "createManyApplications", + "createBuyer", + "deleteAnAccount", + "deleteApplications", + "getAccountPasswordResetToken", + "updateAccountStatus" ); } var ALLOWED_GRAPHQL_RESOLVERS = [...DEFAULT_RESOLVERS, ...CUSTOM_RESOLVERS]; // constants/supported-currencies/index.ts -var SUPPORTED_CURRENCIES = ['EUR', 'GBP', 'JPY', 'USD']; -var GBP = 'GBP'; +var SUPPORTED_CURRENCIES = ["EUR", "GBP", "JPY", "USD"]; +var GBP = "GBP"; // constants/application/versions/index.ts var VERSION_1 = { - VERSION_NUMBER: '1', + VERSION_NUMBER: "1", OVER_500K_SUPPORT: false, MAXIMUM_BUYER_CAN_OWE: 5e5, TOTAL_VALUE_OF_CONTRACT: 5e5, DEFAULT_FINAL_DESTINATION_KNOWN: true, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: false, - BROKER_ADDRESS_AS_MULTIPLE_FIELDS: true, + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: true }; var VERSION_2 = { - VERSION_NUMBER: '2', + VERSION_NUMBER: "2", OVER_500K_SUPPORT: true, DEFAULT_FINAL_DESTINATION_KNOWN: null, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: null, DEFAULT_CURRENCY: GBP, - BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false, + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false }; var VERSION_3 = { ...VERSION_2, - VERSION_NUMBER: '3', - REQUESTED_CREDIT_LIMIT_REQUIRED: true, + VERSION_NUMBER: "3", + REQUESTED_CREDIT_LIMIT_REQUIRED: true }; var VERSIONS = [VERSION_1, VERSION_2, VERSION_3]; var versions_default = VERSIONS; @@ -661,8 +656,8 @@ var getApplicationDefinition = (versionNumber) => { if (applicationDefinition) { return applicationDefinition; } - console.error('Unable to find latest application version'); - throw new Error('Unable to find latest application version'); + console.error("Unable to find latest application version"); + throw new Error("Unable to find latest application version"); }; var get_application_definition_default = getApplicationDefinition; @@ -675,11 +670,11 @@ var LATEST_VERSION = get_application_definition_default(latest_default); var APPLICATION = { LATEST_VERSION, LATEST_VERSION_NUMBER: latest_default, - DEAL_TYPE: 'EXIP', + DEAL_TYPE: "EXIP", SUBMISSION_COUNT_DEFAULT: 0, SUBMISSION_DEADLINE_IN_MONTHS: 1, SUBMISSION_DEADLINE_IN_DAYS: 30, - ALL_SECTIONS_ROUTE: '/all-sections', + ALL_SECTIONS_ROUTE: "/all-sections", SUBMISSION_DEADLINE_EMAIL: { REMINDER_DAYS: 2, START_TIME_LIMIT_HOURS: 0, @@ -689,34 +684,34 @@ var APPLICATION = { END_TIME_LIMIT_HOURS: 23, END_TIME_LIMIT_MINUTES: 59, END_TIME_LIMIT_SECONDS: 59, - END_TIME_LIMIT_MS: 999, + END_TIME_LIMIT_MS: 999 }, SUBMISSION_TYPE: { - MIA: 'Manual Inclusion Application', + MIA: "Manual Inclusion Application" }, POLICY_TYPE: { - SINGLE: 'Single contract policy', - MULTIPLE: 'Multiple contract policy', + SINGLE: "Single contract policy", + MULTIPLE: "Multiple contract policy", ABBREVIATED: { - SINGLE: 'Single', - MULTIPLE: 'Multiple', - }, + SINGLE: "Single", + MULTIPLE: "Multiple" + } }, POLICY: { TOTAL_VALUE_OF_CONTRACT: { MINIMUM: 1, - MAXIMUM: LATEST_VERSION.TOTAL_VALUE_OF_CONTRACT, + MAXIMUM: LATEST_VERSION.TOTAL_VALUE_OF_CONTRACT }, TOTAL_MONTHS_OF_COVER: { MINIMUM: 1, - MAXIMUM: 12, + MAXIMUM: 12 }, - MAXIMUM_BUYER_CAN_OWE: LATEST_VERSION.MAXIMUM_BUYER_CAN_OWE, + MAXIMUM_BUYER_CAN_OWE: LATEST_VERSION.MAXIMUM_BUYER_CAN_OWE }, STATUS: { - IN_PROGRESS: 'In progress', - SUBMITTED: 'Submitted to UKEF', - ABANDONED: 'Abandoned', + IN_PROGRESS: "In progress", + SUBMITTED: "Submitted to UKEF", + ABANDONED: "Abandoned" }, DEFAULT_FINAL_DESTINATION_KNOWN: LATEST_VERSION.DEFAULT_FINAL_DESTINATION_KNOWN, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: LATEST_VERSION.DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER, @@ -724,14 +719,13 @@ var APPLICATION = { EXPORT_CONTRACT: { AGENT_SERVICE_CHARGE: { METHOD: { - FIXED_SUM: 'Fixed sum', - PERCENTAGE: 'Percentage', - }, - }, + FIXED_SUM: "Fixed sum", + PERCENTAGE: "Percentage" + } + } }, - GET_QUERY: - 'id eligibility { id } buyer { id companyOrOrganisationName } company { id } declaration { id } exportContract { id } nominatedLossPayee { id } policy { id } sectionReview { id } owner { id email firstName lastName } referenceNumber submissionDeadline status ', - VERSIONS: versions_default, + GET_QUERY: "id eligibility { id } buyer { id companyOrOrganisationName } company { id } declaration { id } exportContract { id } nominatedLossPayee { id } policy { id } sectionReview { id } owner { id email firstName lastName } referenceNumber submissionDeadline status ", + VERSIONS: versions_default }; var application_default = APPLICATION; @@ -739,44 +733,44 @@ var application_default = APPLICATION; var COVER_PERIOD = { LESS_THAN_2_YEARS: { DB_ID: 1, - VALUE: '1 to 24 months', + VALUE: "1 to 24 months" }, MORE_THAN_2_YEARS: { DB_ID: 2, - VALUE: 'More than 2 years', - }, + VALUE: "More than 2 years" + } }; // constants/cron/index.ts -var CRON_DESCRIPTION_ACCOUNT_UPDATE_UNVERIFIED = 'Update unverified accounts (over 24hrs) to isInactive'; +var CRON_DESCRIPTION_ACCOUNT_UPDATE_UNVERIFIED = "Update unverified accounts (over 24hrs) to isInactive"; var CRON_DESCRIPTION_APPLICATION_UPDATE_INACTIVE = `Update inactive applications (over ${APPLICATION.SUBMISSION_DEADLINE_IN_DAYS}) to Abandoned`; -var CRON_DESCRIPTION_APPLICATION_SUBMISSION_DEADLINE_EMAIL = 'Email application submission deadline reminder'; +var CRON_DESCRIPTION_APPLICATION_SUBMISSION_DEADLINE_EMAIL = "Email application submission deadline reminder"; // constants/date-format.ts var DATE_FORMAT = { - DEFAULT: 'd MMMM yyyy', - HOURS_AND_MINUTES: 'HH:mm', - SHORT_MONTH: 'd MMM yyyy', - XLSX: 'dd-MMM-yy', + DEFAULT: "d MMMM yyyy", + HOURS_AND_MINUTES: "HH:mm", + SHORT_MONTH: "d MMM yyyy", + XLSX: "dd-MMM-yy" }; // constants/declarations/versions/index.ts var DECLARATION_VERSIONS = [ { - ANTI_BRIBERY: '1', - ANTI_BRIBERY_CODE_OF_CONDUCT: '1', - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', - CONFIDENTIALITY: '1', - CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', - HOW_YOUR_DATA_WILL_BE_USED: '1', + ANTI_BRIBERY: "1", + ANTI_BRIBERY_CODE_OF_CONDUCT: "1", + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: "1", + CONFIDENTIALITY: "1", + CONFIRMATION_AND_ACKNOWLEDGEMENTS: "1", + HOW_YOUR_DATA_WILL_BE_USED: "1" }, { - ANTI_BRIBERY: '2', - ANTI_BRIBERY_CODE_OF_CONDUCT: '2', - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', - CONFIDENTIALITY: '1', - CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', - }, + ANTI_BRIBERY: "2", + ANTI_BRIBERY_CODE_OF_CONDUCT: "2", + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: "1", + CONFIDENTIALITY: "1", + CONFIRMATION_AND_ACKNOWLEDGEMENTS: "1" + } ]; var versions_default2 = DECLARATION_VERSIONS; @@ -784,7 +778,7 @@ var versions_default2 = DECLARATION_VERSIONS; var DECLARATIONS2 = { VERSIONS: versions_default2, V1_DECLARATIONS: versions_default2[0], - LATEST_DECLARATIONS: versions_default2[versions_default2.length - 1], + LATEST_DECLARATIONS: versions_default2[versions_default2.length - 1] }; var declarations_default2 = DECLARATIONS2; @@ -792,149 +786,149 @@ var declarations_default2 = DECLARATIONS2; var ELIGIBILITY = { MAX_COVER_AMOUNT_IN_GBP: 5e5, MAX_COVER_PERIOD_MONTHS: 24, - MAX_COVER_PERIOD_YEARS: 2, + MAX_COVER_PERIOD_YEARS: 2 }; // constants/export-contract-award-method/index.ts var EXPORT_CONTRACT_AWARD_METHOD = { OPEN_TENDER: { - DB_ID: 'eg9qxlqw4edxa8b5mwbybsrfp', - VALUE: 'Open tender', + DB_ID: "eg9qxlqw4edxa8b5mwbybsrfp", + VALUE: "Open tender" }, NEGOTIATED_CONTRACT: { - DB_ID: 'mzwp337piamg1mei7fqh1o73s', - VALUE: 'Negotiated contract', + DB_ID: "mzwp337piamg1mei7fqh1o73s", + VALUE: "Negotiated contract" }, DIRECT_AWARD: { - DB_ID: 'qnqrle4xwsj5go8pchj31sat4', - VALUE: 'Direct award', + DB_ID: "qnqrle4xwsj5go8pchj31sat4", + VALUE: "Direct award" }, COMPETITIVE_BIDDING: { - DB_ID: 'qw2hp8khykctdic2z58z70ru8', - VALUE: 'Competitive bidding', + DB_ID: "qw2hp8khykctdic2z58z70ru8", + VALUE: "Competitive bidding" }, OTHER: { - DB_ID: 'tn8k8lot1bvirmztmmgq2u8hn', - VALUE: 'Other', - }, + DB_ID: "tn8k8lot1bvirmztmmgq2u8hn", + VALUE: "Other" + } }; // constants/external-apis.ts var EXTERNAL_API_DEFINITIONS = { CIS: { ESRA_CLASSIFICATION: { - VERY_HIGH: 'Very High', - HIGH: 'High', - STANDARD: 'Standard Risk', - NONE: 'None', + VERY_HIGH: "Very High", + HIGH: "High", + STANDARD: "Standard Risk", + NONE: "None" }, SHORT_TERM_COVER: { - YES: 'Yes', - NO: 'No', - ILC: 'ILC Only', - CILC: 'CILC Only', - REFER: 'Refer', - UNLISTED: 'Unlisted', + YES: "Yes", + NO: "No", + ILC: "ILC Only", + CILC: "CILC Only", + REFER: "Refer", + UNLISTED: "Unlisted" }, NBI_ISSUE_AVAILABLE: { - YES: 'Y', - NO: 'N', + YES: "Y", + NO: "N" }, - NO_COVER: 'Off cover', + NO_COVER: "Off cover", INVALID_COUNTRIES: [ - 'CABEI', - 'Cor Andino Fom', - 'Eastern and Southern African Trade and Development Bank', - 'EC Market n/k', - 'Non EC Market n/k', - 'Non UK', - 'Third Country', + "CABEI", + "Cor Andino Fom", + "Eastern and Southern African Trade and Development Bank", + "EC Market n/k", + "Non EC Market n/k", + "Non UK", + "Third Country" ], - INVALID_CURRENCIES: ['Gold'], + INVALID_CURRENCIES: ["Gold"], COUNTRY_RATINGS: { - A: ['AAA', 'AA+', 'AA', 'AA-', 'A+', 'A', 'A-'], - B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], - C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], - D: ['D'], - NOT_APPLICABLE: 'N/A', - }, + A: ["AAA", "AA+", "AA", "AA-", "A+", "A", "A-"], + B: ["BBB+", "BBB", "BBB-", "BB+", "BB", "BB-", "B+", "B", "B-"], + C: ["CCC+", "CCC", "CCC-", "CC", "C"], + D: ["D"], + NOT_APPLICABLE: "N/A" + } }, COMPANIES_HOUSE: { COMPANY_STATUS: { - ACTIVE: 'active', - }, - }, + ACTIVE: "active" + } + } }; var EXTERNAL_API_MAPPINGS = { CIS: { ESRA_CLASSIFICATION: { - VERY_HIGH: 'Very High', - HIGH: 'High', - STANDARD: 'Standard', - }, - }, + VERY_HIGH: "Very High", + HIGH: "High", + STANDARD: "Standard" + } + } }; var EXTERNAL_API_ENDPOINTS = { APIM_MDM: { - CURRENCY: '/currencies', - INDUSTRY_SECTORS: '/sector-industries', - MARKETS: '/markets', - }, + CURRENCY: "/currencies", + INDUSTRY_SECTORS: "/sector-industries", + MARKETS: "/markets" + } }; // constants/field-values/index.ts var { POLICY_TYPE, POLICY: POLICY2 } = application_default; var FIELD_VALUES = { OPTIONAL_COOKIES: { - ACCEPT: 'accept', - REJECT: 'reject', + ACCEPT: "accept", + REJECT: "reject" }, POLICY_TYPE: { SINGLE: POLICY_TYPE.SINGLE, - MULTIPLE: POLICY_TYPE.MULTIPLE, + MULTIPLE: POLICY_TYPE.MULTIPLE }, POLICY_LENGTH: { // default multiple policy length in months - MULTIPLE: 12, + MULTIPLE: 12 }, TOTAL_MONTHS_OF_COVER: Array.from(Array(POLICY2.TOTAL_MONTHS_OF_COVER.MAXIMUM).keys()), - YES: 'Yes', - NO: 'No', + YES: "Yes", + NO: "No" }; // constants/total-contract-value/index.ts var TOTAL_CONTRACT_VALUE = { LESS_THAN_500K: { DB_ID: 1, - VALUE: 'Less than 500k', + VALUE: "Less than 500k" }, MORE_THAN_500K: { DB_ID: 2, - VALUE: 'More than 500k', + VALUE: "More than 500k" }, LESS_THAN_250K: { DB_ID: 3, - VALUE: 'Less than 250k', + VALUE: "Less than 250k" }, MORE_THAN_250K: { DB_ID: 4, - VALUE: 'More than 250k', + VALUE: "More than 250k" }, - AMOUNT_250K: 25e4, + AMOUNT_250K: 25e4 }; // constants/XLSX-CONFIG/index.ts var XLSX_CONFIG = { - KEY: 'field', - VALUE: 'answer', + KEY: "field", + VALUE: "answer", COLUMN_WIDTH: 85, ADDITIONAL_TITLE_COLUMN_HEIGHT: 25, ADDITIONAL_COLUMN_HEIGHT: 50, LARGE_ADDITIONAL_COLUMN_HEIGHT: 50 * 2, FONT_SIZE: { DEFAULT: 11, - TITLE: 14, - }, + TITLE: 14 + } }; // constants/validation.ts @@ -942,19 +936,19 @@ var MAXIMUM_CHARACTERS = { ABOUT_GOODS_OR_SERVICES_DESCRIPTION: 1e3, ACCOUNT_NUMBER: 8, ACCOUNT: { - NAME: 400, + NAME: 400 }, AGENT_NAME: 800, AGENT_SERVICE_DESCRIPTION: 1e3, BIC_SWIFT_CODE: 11, BROKER_NAME: 800, BUSINESS: { - GOODS_OR_SERVICES_DESCRIPTION: 1e3, + GOODS_OR_SERVICES_DESCRIPTION: 1e3 }, BUYER: { COMPANY_OR_ORGANISATION: 200, REGISTRATION_NUMBER: 200, - PREVIOUS_CREDIT_INSURANCE_COVER: 1e3, + PREVIOUS_CREDIT_INSURANCE_COVER: 1e3 }, COMPANY_DIFFERENT_TRADING_NAME: 200, CONNECTION_WITH_BUYER_DESCRIPTION: 1e3, @@ -964,11 +958,11 @@ var MAXIMUM_CHARACTERS = { DIFFERENT_NAME_ON_POLICY: 50, EMAIL: 300, EXPORT_CONTRACT: { - OTHER_AWARD_METHOD: 200, + OTHER_AWARD_METHOD: 200 }, FEEDBACK: { IMPROVEMENT: 1200, - OTHER_COMMENTS: 1200, + OTHER_COMMENTS: 1200 }, FULL_ADDRESS: 500, IBAN: 34, @@ -978,18 +972,18 @@ var MAXIMUM_CHARACTERS = { PERCENTAGE: 100, POLICY_CONTACT_NAME: 400, QUOTE: { - CREDIT_PERIOD: 2, + CREDIT_PERIOD: 2 }, REQUESTED_JOINTLY_INSURED_PARTY: { COMPANY_NAME: 200, - COMPANY_NUMBER: 100, + COMPANY_NUMBER: 100 }, - SORT_CODE: 6, + SORT_CODE: 6 }; // constants/index.ts import_dotenv.default.config(); -var GBP_CURRENCY_CODE = 'GBP'; +var GBP_CURRENCY_CODE = "GBP"; var DATE_24_HOURS_FROM_NOW = () => { const now2 = /* @__PURE__ */ new Date(); const day = now2.getDate(); @@ -1011,43 +1005,43 @@ var DATE_30_MINUTES_FROM_NOW = () => { }; var ACCOUNT2 = { EMAIL: { - VERIFICATION_EXPIRY: DATE_24_HOURS_FROM_NOW, + VERIFICATION_EXPIRY: DATE_24_HOURS_FROM_NOW }, ENCRYPTION: { RANDOM_BYTES_SIZE: 32, - STRING_TYPE: 'hex', + STRING_TYPE: "hex", PBKDF2: { ITERATIONS: 1e4, - DIGEST_ALGORITHM: 'sha512', + DIGEST_ALGORITHM: "sha512" }, PASSWORD: { PBKDF2: { - KEY_LENGTH: 64, - }, + KEY_LENGTH: 64 + } }, OTP: { PBKDF2: { - KEY_LENGTH: 128, - }, - }, + KEY_LENGTH: 128 + } + } }, PASSWORD_RESET_EXPIRY: DATE_30_MINUTES_FROM_NOW, // One time password OTP: { DIGITS: 6, - VERIFICATION_EXPIRY: DATE_30_MINUTES_FROM_NOW, + VERIFICATION_EXPIRY: DATE_30_MINUTES_FROM_NOW }, REACTIVATION_EXPIRY: DATE_24_HOURS_FROM_NOW, // JSON web token JWT: { KEY: { SIGNATURE: String(process.env.JWT_SIGNING_KEY), - ENCODING: 'base64', - STRING_ENCODING: 'ascii', + ENCODING: "base64", + STRING_ENCODING: "ascii" }, TOKEN: { - EXPIRY: '12h', - ALGORITHM: 'RS256', + EXPIRY: "12h", + ALGORITHM: "RS256" }, SESSION_EXPIRY: () => { const now2 = /* @__PURE__ */ new Date(); @@ -1055,7 +1049,7 @@ var ACCOUNT2 = { const seconds = 60 * 60 * 1e3; const future = new Date(now2.getTime() + hours * seconds); return future; - }, + } }, MAX_AUTH_RETRIES: 6, /** @@ -1063,80 +1057,80 @@ var ACCOUNT2 = { * Generate a date that is 24 hours ago from now * To be safe, we use time rather than subtracting a day. */ - MAX_AUTH_RETRIES_TIMEFRAME: DATE_24_HOURS_IN_THE_PAST(), + MAX_AUTH_RETRIES_TIMEFRAME: DATE_24_HOURS_IN_THE_PAST() }; var DEFAULT_ENCRYPTION_SAVE_OBJECT = { - value: '', - iv: '', + value: "", + iv: "" }; var FINANCIAL_DETAILS = { ENCRYPTION: { CIPHER: { - ENCODING: 'hex', - STRING_ENCODING: 'base64', - ENCRYPTION_METHOD: 'aes-256-cbc', - OUTPUT_ENCODING: 'utf-8', + ENCODING: "hex", + STRING_ENCODING: "base64", + ENCRYPTION_METHOD: "aes-256-cbc", + OUTPUT_ENCODING: "utf-8" }, KEY: { - ALGORITHM: 'sha512', + ALGORITHM: "sha512", SIGNATURE: String(process.env.LOSS_PAYEE_ENCRYPTION_KEY), SUBSTRING_INDEX_START: 0, - SUBSTRING_INDEX_END: 32, + SUBSTRING_INDEX_END: 32 }, IV: { BYTES_SIZE: 16, - ENCODING: 'base64', + ENCODING: "base64", SLICE_INDEX_START: 0, - SLICE_INDEX_END: 16, - }, - }, + SLICE_INDEX_END: 16 + } + } }; var EMAIL_TEMPLATE_IDS = { ACCOUNT: { - CONFIRM_EMAIL: '24022e94-171c-4044-b0ee-d22418116575', - ACCESS_CODE: 'b92650d1-9187-4510-ace2-5eec7ca7e626', - PASSWORD_RESET: '86d5f582-e1d3-4b55-b103-50141401fd13', - REACTIVATE_ACCOUNT_CONFIRM_EMAIL: '2abf173a-52fc-4ec8-b28c-d7a862b8cf37', + CONFIRM_EMAIL: "24022e94-171c-4044-b0ee-d22418116575", + ACCESS_CODE: "b92650d1-9187-4510-ace2-5eec7ca7e626", + PASSWORD_RESET: "86d5f582-e1d3-4b55-b103-50141401fd13", + REACTIVATE_ACCOUNT_CONFIRM_EMAIL: "2abf173a-52fc-4ec8-b28c-d7a862b8cf37" }, APPLICATION: { SUBMISSION: { EXPORTER: { - CONFIRMATION: '2e9084e2-d871-4be7-85d0-0ccc1961b148', + CONFIRMATION: "2e9084e2-d871-4be7-85d0-0ccc1961b148", SEND_DOCUMENTS: { - TRADING_HISTORY: '1ae4d77e-58d6-460e-99c0-b62bf08d8c52', - ANTI_BRIBERY: '002e43e3-ca78-4b9c-932f-6833014bb1e4', - ANTI_BRIBERY_AND_TRADING_HISTORY: '49753c34-24b5-4cad-a7c5-1ab32d711dfe', - }, + TRADING_HISTORY: "1ae4d77e-58d6-460e-99c0-b62bf08d8c52", + ANTI_BRIBERY: "002e43e3-ca78-4b9c-932f-6833014bb1e4", + ANTI_BRIBERY_AND_TRADING_HISTORY: "49753c34-24b5-4cad-a7c5-1ab32d711dfe" + } }, UNDERWRITING_TEAM: { - NOTIFICATION_TRADING_HISTORY: '34457439-bf9c-46e3-bd05-b8732ed682fb', - NOTIFICATION_ANTI_BRIBERY: '8be12c98-b2c7-4992-8920-925aa37b6391', - NOTIFICATION_ANTI_BRIBERY_AND_TRADING_HISTORY: '7f0541dd-1dae-4d51-9ebc-87d2a624f8d2', - NO_DOCUMENTS: '65b517c6-ae86-470b-9448-194ae5ac44bb', + NOTIFICATION_TRADING_HISTORY: "34457439-bf9c-46e3-bd05-b8732ed682fb", + NOTIFICATION_ANTI_BRIBERY: "8be12c98-b2c7-4992-8920-925aa37b6391", + NOTIFICATION_ANTI_BRIBERY_AND_TRADING_HISTORY: "7f0541dd-1dae-4d51-9ebc-87d2a624f8d2", + NO_DOCUMENTS: "65b517c6-ae86-470b-9448-194ae5ac44bb" }, - DEADLINE_REMINDER: 'e8e5ba73-96da-46f1-b96e-2b1909be6f3d', - }, + DEADLINE_REMINDER: "e8e5ba73-96da-46f1-b96e-2b1909be6f3d" + } }, FEEDBACK: { - INSURANCE: '4d3d7944-e894-4527-aee6-692038c84107', - }, + INSURANCE: "4d3d7944-e894-4527-aee6-692038c84107" + } }; var FEEDBACK = { - VERY_SATISFIED: 'verySatisfied', - SATISFIED: 'satisfied', - NEITHER: 'neither', - DISSATISFIED: 'dissatisfied', - VERY_DISSATISIFED: 'veryDissatisfied', + VERY_SATISFIED: "verySatisfied", + SATISFIED: "satisfied", + NEITHER: "neither", + DISSATISFIED: "dissatisfied", + VERY_DISSATISIFED: "veryDissatisfied", EMAIL_TEXT: { - verySatisfied: 'Very satisfied', - satisfied: 'Satisfied', - neither: 'Neither satisfied or dissatisfied', - dissatisfied: 'Dissatisfied', - veryDissatisfied: 'Very dissatisfied', - }, + verySatisfied: "Very satisfied", + satisfied: "Satisfied", + neither: "Neither satisfied or dissatisfied", + dissatisfied: "Dissatisfied", + veryDissatisfied: "Very dissatisfied" + } }; -var ACCEPTED_FILE_TYPES = ['.xlsx']; -var ORDNANCE_SURVEY_QUERY_URL = '/search/places/v1/postcode?postcode='; +var ACCEPTED_FILE_TYPES = [".xlsx"]; +var ORDNANCE_SURVEY_QUERY_URL = "/search/places/v1/postcode?postcode="; // cron/account/unverified-account-cron-job.ts import_dotenv2.default.config(); @@ -1144,7 +1138,7 @@ var { CRON_SCHEDULE_UNVERIFIED_ACCOUNT } = process.env; var updateUnverifiedAccountsJob = { cronExpression: String(CRON_SCHEDULE_UNVERIFIED_ACCOUNT), description: CRON_DESCRIPTION_ACCOUNT_UPDATE_UNVERIFIED, - task: update_unverified_accounts_default, + task: update_unverified_accounts_default }; var unverified_account_cron_job_default = updateUnverifiedAccountsJob; @@ -1153,22 +1147,22 @@ var accountCronSchedulerJobs = [unverified_account_cron_job_default]; var account_default2 = accountCronSchedulerJobs; // cron/application/inactive-application-cron-job.ts -var import_dotenv3 = __toESM(require('dotenv')); +var import_dotenv3 = __toESM(require("dotenv")); // helpers/get-inactive-applications/index.ts var { IN_PROGRESS } = APPLICATION.STATUS; var getInactiveApplications = async (context) => { try { - console.info('Getting inactive applications - getInactiveApplications helper'); + console.info("Getting inactive applications - getInactiveApplications helper"); const applications = await context.query.Application.findMany({ where: { - AND: [{ status: { in: [IN_PROGRESS] } }, { submissionDeadline: { lt: /* @__PURE__ */ new Date() } }], + AND: [{ status: { in: [IN_PROGRESS] } }, { submissionDeadline: { lt: /* @__PURE__ */ new Date() } }] }, - query: 'id status', + query: "id status" }); return applications; } catch (error) { - console.error('Error getting inactive applications (getInactiveApplications helper) %o', error); + console.error("Error getting inactive applications (getInactiveApplications helper) %o", error); throw new Error(`Error getting inactive applications (getInactiveApplications helper) ${error}`); } }; @@ -1182,8 +1176,8 @@ var mapInactiveApplications = (applications) => { data: { status: APPLICATION.STATUS.ABANDONED, previousStatus: application2.status, - updatedAt: /* @__PURE__ */ new Date(), - }, + updatedAt: /* @__PURE__ */ new Date() + } }; return mapped; }); @@ -1194,13 +1188,13 @@ var map_inactive_applications_default = mapInactiveApplications; // helpers/map-and-update-inactive-applications/index.ts var mapAndUpdateInactiveApplications = async (applications, context) => { try { - console.info('Mapping and updating inactive applications - mapAndUpdateInactiveApplications'); + console.info("Mapping and updating inactive applications - mapAndUpdateInactiveApplications"); const updateData = map_inactive_applications_default(applications); await context.db.Application.updateMany({ - data: updateData, + data: updateData }); } catch (error) { - console.error('Error mapping and updating inactive applications %o', error); + console.error("Error mapping and updating inactive applications %o", error); throw new Error(`Error mapping and updating inactive applications ${error}`); } }; @@ -1209,16 +1203,16 @@ var map_and_update_inactive_applications_default = mapAndUpdateInactiveApplicati // helpers/update-inactive-applications/index.ts var updateInactiveApplications = async (context) => { try { - console.info('Getting and updating inactive applications'); + console.info("Getting and updating inactive applications"); const applications = await get_inactive_applications_default(context); if (applications.length) { await map_and_update_inactive_applications_default(applications, context); } return { - success: true, + success: true }; } catch (error) { - console.error('Error getting and updating inactive applications %o', error); + console.error("Error getting and updating inactive applications %o", error); throw new Error(`Error getting and updating inactive applications ${error}`); } }; @@ -1230,12 +1224,12 @@ var { CRON_SCHEDULE_INACTIVE_APPLICATION } = process.env; var updateInactiveApplicationsJob = { cronExpression: String(CRON_SCHEDULE_INACTIVE_APPLICATION), description: CRON_DESCRIPTION_APPLICATION_UPDATE_INACTIVE, - task: update_inactive_applications_default, + task: update_inactive_applications_default }; var inactive_application_cron_job_default = updateInactiveApplicationsJob; // cron/application/email-submission-deadline-reminder-cron-job.ts -var import_dotenv8 = __toESM(require('dotenv')); +var import_dotenv8 = __toESM(require("dotenv")); // helpers/get-start-and-end-time-of-date/index.ts var { @@ -1246,20 +1240,20 @@ var { END_TIME_LIMIT_HOURS, END_TIME_LIMIT_MINUTES, END_TIME_LIMIT_MS, - END_TIME_LIMIT_SECONDS, + END_TIME_LIMIT_SECONDS } = APPLICATION.SUBMISSION_DEADLINE_EMAIL; var getStartAndEndTimeOfDate = (date) => { const startSet = date.setHours(START_TIME_LIMIT_HOURS, START_TIME_LIMIT_MINUTES, START_TIME_LIMIT_SECONDS, START_TIME_LIMIT_MS); const endSet = date.setHours(END_TIME_LIMIT_HOURS, END_TIME_LIMIT_MINUTES, END_TIME_LIMIT_SECONDS, END_TIME_LIMIT_MS); return { startTime: new Date(startSet), - endTime: new Date(endSet), + endTime: new Date(endSet) }; }; var get_start_and_end_time_of_date_default = getStartAndEndTimeOfDate; // helpers/date/index.ts -var import_date_fns = require('date-fns'); +var import_date_fns = require("date-fns"); var dateIsInThePast = (targetDate) => { const now2 = /* @__PURE__ */ new Date(); return (0, import_date_fns.isAfter)(now2, targetDate); @@ -1271,31 +1265,31 @@ var { IN_PROGRESS: IN_PROGRESS2 } = APPLICATION.STATUS; var { REMINDER_DAYS } = APPLICATION.SUBMISSION_DEADLINE_EMAIL; var getExpiringApplications = async (context) => { try { - console.info('Getting expiring applications - getExpiringApplications helper'); + console.info("Getting expiring applications - getExpiringApplications helper"); const today = /* @__PURE__ */ new Date(); const reminderDays = dateInTheFutureByDays(today, REMINDER_DAYS); const { startTime, endTime } = get_start_and_end_time_of_date_default(reminderDays); const applications = await context.query.Application.findMany({ where: { - AND: [{ status: { in: [IN_PROGRESS2] } }, { submissionDeadline: { gte: startTime, lte: endTime } }], + AND: [{ status: { in: [IN_PROGRESS2] } }, { submissionDeadline: { gte: startTime, lte: endTime } }] }, - query: APPLICATION.GET_QUERY, + query: APPLICATION.GET_QUERY }); return applications; } catch (error) { - console.error('Error getting expiring applications (getExpiringApplications helper) %o', error); + console.error("Error getting expiring applications (getExpiringApplications helper) %o", error); throw new Error(`Error getting expiring applications (getExpiringApplications helper) ${error}`); } }; var get_expiring_applications_default = getExpiringApplications; // helpers/format-date/index.ts -var import_date_fns2 = require('date-fns'); +var import_date_fns2 = require("date-fns"); var formatDate = (timestamp3, dateFormat = DATE_FORMAT.DEFAULT) => (0, import_date_fns2.format)(new Date(timestamp3), dateFormat); var format_date_default = formatDate; // helpers/generate-application-url/index.ts -var import_dotenv4 = __toESM(require('dotenv')); +var import_dotenv4 = __toESM(require("dotenv")); import_dotenv4.default.config(); var baseUrl = String(process.env.APPLICATION_URL); var generateApplicationUrl = (referenceNumber) => `${baseUrl}/${referenceNumber}${APPLICATION.ALL_SECTIONS_ROUTE}`; @@ -1311,18 +1305,18 @@ var mapApplicationSubmissionDeadlineVariables = (application2) => { name: `${firstName} ${lastName}`, referenceNumber: String(referenceNumber), applicationUrl: generate_application_url_default(referenceNumber), - buyerName: application2.buyer.companyOrOrganisationName ? String(companyOrOrganisationName) : '', - submissionDeadline: format_date_default(new Date(submissionDeadline)), + buyerName: application2.buyer.companyOrOrganisationName ? String(companyOrOrganisationName) : "", + submissionDeadline: format_date_default(new Date(submissionDeadline)) }; }; var map_application_submission_deadline_variables_default = mapApplicationSubmissionDeadlineVariables; // emails/index.ts -var import_dotenv7 = __toESM(require('dotenv')); +var import_dotenv7 = __toESM(require("dotenv")); // integrations/notify/index.ts -var import_dotenv5 = __toESM(require('dotenv')); -var import_notifications_node_client = require('notifications-node-client'); +var import_dotenv5 = __toESM(require("dotenv")); +var import_notifications_node_client = require("notifications-node-client"); import_dotenv5.default.config(); var notifyKey = process.env.GOV_NOTIFY_API_KEY; var notifyClient = new import_notifications_node_client.NotifyClient(notifyKey); @@ -1338,24 +1332,24 @@ var notify = { */ sendEmail: async (templateId, sendToEmailAddress, variables, file) => { try { - console.info('Calling Notify API. templateId: %s', templateId); + console.info("Calling Notify API. templateId: %s", templateId); const personalisation = variables; if (file) { personalisation.linkToFile = await notifyClient.prepareUpload(file, { confirmEmailBeforeDownload: true }); } await notifyClient.sendEmail(templateId, sendToEmailAddress, { personalisation, - reference: null, + reference: null }); return { success: true, - emailRecipient: sendToEmailAddress, + emailRecipient: sendToEmailAddress }; } catch (error) { - console.error('Error calling Notify API. Unable to send email %o', error); + console.error("Error calling Notify API. Unable to send email %o", error); throw new Error(`Calling Notify API. Unable to send email ${error}`); } - }, + } }; var notify_default = notify; @@ -1373,7 +1367,7 @@ var callNotify = async (templateId, emailAddress, variables, file) => { } throw new Error(`Sending email ${emailResponse}`); } catch (error) { - console.error('Error sending email %o', error); + console.error("Error sending email %o", error); throw new Error(`Sending email ${error}`); } }; @@ -1381,13 +1375,13 @@ var callNotify = async (templateId, emailAddress, variables, file) => { // emails/confirm-email-address/index.ts var confirmEmailAddress = async (emailAddress, urlOrigin, name, verificationHash, id) => { try { - console.info('Sending confirm email address email'); + console.info("Sending confirm email address email"); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.CONFIRM_EMAIL; const variables = { urlOrigin, name, confirmToken: verificationHash, id }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error('Error sending confirm email address email %o', error); + console.error("Error sending confirm email address email %o", error); throw new Error(`Sending confirm email address email ${error}`); } }; @@ -1395,13 +1389,13 @@ var confirmEmailAddress = async (emailAddress, urlOrigin, name, verificationHash // emails/access-code-email/index.ts var accessCodeEmail = async (emailAddress, name, securityCode) => { try { - console.info('Sending access code email for account sign in'); + console.info("Sending access code email for account sign in"); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.ACCESS_CODE; const variables = { name, securityCode }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error('Error sending access code email for account sign in %o', error); + console.error("Error sending access code email for account sign in %o", error); throw new Error(`Sending access code email for account sign in ${error}`); } }; @@ -1409,13 +1403,13 @@ var accessCodeEmail = async (emailAddress, name, securityCode) => { // emails/password-reset-link/index.ts var passwordResetLink = async (urlOrigin, emailAddress, name, passwordResetHash) => { try { - console.info('Sending email for account password reset'); + console.info("Sending email for account password reset"); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.PASSWORD_RESET; const variables = { urlOrigin, name, passwordResetToken: passwordResetHash }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error('Error sending email for account password reset %o', error); + console.error("Error sending email for account password reset %o", error); throw new Error(`Sending email for account password reset ${error}`); } }; @@ -1423,20 +1417,20 @@ var passwordResetLink = async (urlOrigin, emailAddress, name, passwordResetHash) // emails/reactivate-account-link/index.ts var reactivateAccountLink = async (urlOrigin, emailAddress, name, reactivationHash) => { try { - console.info('Sending email for account reactivation'); + console.info("Sending email for account reactivation"); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.REACTIVATE_ACCOUNT_CONFIRM_EMAIL; const variables = { urlOrigin, name, reactivationToken: reactivationHash }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error('Error sending email for account reactivation %o', error); + console.error("Error sending email for account reactivation %o", error); throw new Error(`Sending email for account reactivation ${error}`); } }; // file-system/index.ts -var import_fs = require('fs'); -var import_path = __toESM(require('path')); +var import_fs = require("fs"); +var import_path = __toESM(require("path")); var fileExists = (filePath) => { const fileBuffer = Buffer.from(filePath); if (fileBuffer.length) { @@ -1453,27 +1447,27 @@ var isAcceptedFileType = (filePath) => { }; var readFile = async (filePath) => { try { - console.info('Reading file %s', filePath); + console.info("Reading file %s", filePath); const file = await import_fs.promises.readFile(filePath); if (fileExists(file) && isAcceptedFileType(filePath)) { return file; } - throw new Error('Reading file - does not exist or is unaccepted file type'); + throw new Error("Reading file - does not exist or is unaccepted file type"); } catch (error) { - console.error('Error reading file %o', error); + console.error("Error reading file %o", error); throw new Error(`Reading file ${error}`); } }; var unlink = async (filePath) => { try { - console.info('Deleting file %s', filePath); + console.info("Deleting file %s", filePath); const file = await readFile(filePath); if (file) { await import_fs.promises.unlink(filePath); } return false; } catch (error) { - console.error('Error deleting file %o', error); + console.error("Error deleting file %o", error); throw new Error(`Deleting file ${error}`); } }; @@ -1481,7 +1475,7 @@ var fileSystem = { fileExists, isAcceptedFileType, readFile, - unlink, + unlink }; var file_system_default = fileSystem; @@ -1495,13 +1489,13 @@ var application = { */ submittedEmail: async (variables) => { try { - console.info('Sending application submitted email to application owner or provided business contact'); + console.info("Sending application submitted email to application owner or provided business contact"); const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.EXPORTER.CONFIRMATION; const { emailAddress } = variables; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error('Error sending application submitted email to to application owner or provided business contact %o', error); + console.error("Error sending application submitted email to to application owner or provided business contact %o", error); throw new Error(`Sending application submitted email to to application owner or provided business contact ${error}`); } }, @@ -1515,7 +1509,7 @@ var application = { */ underwritingTeam: async (variables, filePath, templateId) => { try { - console.info('Sending application submitted email to underwriting team'); + console.info("Sending application submitted email to underwriting team"); const emailAddress = String(process.env.UNDERWRITING_TEAM_EMAIL); const file = await file_system_default.readFile(filePath); if (file) { @@ -1524,30 +1518,30 @@ var application = { await file_system_default.unlink(filePath); return response; } - throw new Error('Sending application submitted email to underwriting team - invalid file / file not found'); + throw new Error("Sending application submitted email to underwriting team - invalid file / file not found"); } catch (error) { - console.error('Error sending application submitted email to underwriting team %o', error); + console.error("Error sending application submitted email to underwriting team %o", error); throw new Error(`Sending application submitted email to underwriting team ${error}`); } - }, + } }; var application_default2 = application; // emails/documents/index.ts var documentsEmail = async (variables, templateId) => { try { - console.info('Sending documents email'); + console.info("Sending documents email"); const { emailAddress } = variables; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error('Error sending documents email %o', error); + console.error("Error sending documents email %o", error); throw new Error(`Sending documents email ${error}`); } }; // emails/insurance-feedback-email/index.ts -var import_dotenv6 = __toESM(require('dotenv')); +var import_dotenv6 = __toESM(require("dotenv")); // helpers/map-feedback-satisfaction/index.ts var mapFeedbackSatisfaction = (satisfaction) => FEEDBACK.EMAIL_TEXT[satisfaction]; @@ -1557,15 +1551,15 @@ var map_feedback_satisfaction_default = mapFeedbackSatisfaction; import_dotenv6.default.config(); var insuranceFeedbackEmail = async (variables) => { try { - console.info('Sending insurance feedback email'); + console.info("Sending insurance feedback email"); const templateId = EMAIL_TEMPLATE_IDS.FEEDBACK.INSURANCE; const emailAddress = process.env.FEEDBACK_EMAIL_RECIPIENT; const emailVariables = variables; - emailVariables.time = ''; - emailVariables.date = ''; + emailVariables.time = ""; + emailVariables.date = ""; if (variables.createdAt) { emailVariables.date = format_date_default(variables.createdAt); - emailVariables.time = format_date_default(variables.createdAt, 'HH:mm:ss'); + emailVariables.time = format_date_default(variables.createdAt, "HH:mm:ss"); } if (variables.satisfaction) { emailVariables.satisfaction = map_feedback_satisfaction_default(variables.satisfaction); @@ -1573,7 +1567,7 @@ var insuranceFeedbackEmail = async (variables) => { const response = await callNotify(templateId, emailAddress, emailVariables); return response; } catch (error) { - console.error('Error sending insurance feedback email %o', error); + console.error("Error sending insurance feedback email %o", error); throw new Error(`Sending insurance feedback email ${error}`); } }; @@ -1581,12 +1575,12 @@ var insuranceFeedbackEmail = async (variables) => { // emails/submission-deadline/index.ts var submissionDeadlineEmail = async (emailAddress, submissionDeadlineEmailVariables) => { try { - console.info('Sending submission deadline reminder email for %s', submissionDeadlineEmailVariables.referenceNumber); + console.info("Sending submission deadline reminder email for %s", submissionDeadlineEmailVariables.referenceNumber); const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.DEADLINE_REMINDER; const response = await callNotify(templateId, emailAddress, submissionDeadlineEmailVariables); return response; } catch (error) { - console.error('Error sending submission deadline email for applicationId %s - %o', submissionDeadlineEmailVariables.referenceNumber, error); + console.error("Error sending submission deadline email for applicationId %s - %o", submissionDeadlineEmailVariables.referenceNumber, error); throw new Error(`Sending submission deadline email for ${submissionDeadlineEmailVariables.referenceNumber} - ${error}`); } }; @@ -1601,14 +1595,14 @@ var sendEmail = { application: application_default2, documentsEmail, insuranceFeedbackEmail, - submissionDeadlineEmail, + submissionDeadlineEmail }; var emails_default = sendEmail; // helpers/send-email-application-submission-deadline/send-email/index.ts var send = async (applications) => { try { - console.info('Sending application submission deadline emails - send helper'); + console.info("Sending application submission deadline emails - send helper"); const mapped = applications.map(async (application2) => { const variables = map_application_submission_deadline_variables_default(application2); const response = await emails_default.submissionDeadlineEmail(variables.email, variables); @@ -1617,36 +1611,36 @@ var send = async (applications) => { const promises = await Promise.all(mapped); return promises; } catch (error) { - console.error('Error sending application submission deadline email (send helper) %o', error); + console.error("Error sending application submission deadline email (send helper) %o", error); throw new Error(`Sending application submission deadline email (send helper) ${error}`); } }; var applicationSubmissionDeadineEmail = { - send, + send }; var send_email_default = applicationSubmissionDeadineEmail; // helpers/send-email-application-submission-deadline/index.ts var applicationSubmissionDeadlineEmail = async (context) => { try { - console.info('Sending application submission deadline email'); + console.info("Sending application submission deadline email"); const applications = await get_expiring_applications_default(context); if (applications.length) { const sentEmails = await send_email_default.send(applications); if (sentEmails.length === applications.length) { return { - success: true, + success: true }; } return { - success: false, + success: false }; } return { - success: true, + success: true }; } catch (error) { - console.error('Error sending application submission deadline email (emailApplicationSubmissionDeadlineEmail helper) %o', error); + console.error("Error sending application submission deadline email (emailApplicationSubmissionDeadlineEmail helper) %o", error); throw new Error(`Sending application submission deadline email (emailApplicationSubmissionDeadlineEmail helper) ${error}`); } }; @@ -1658,7 +1652,7 @@ var { CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL } = process.env; var sendEmailApplicationSubmissionDeadlineJob = { cronExpression: String(CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL), description: CRON_DESCRIPTION_APPLICATION_SUBMISSION_DEADLINE_EMAIL, - task: send_email_application_submission_deadline_default, + task: send_email_application_submission_deadline_default }; var email_submission_deadline_reminder_cron_job_default = sendEmailApplicationSubmissionDeadlineJob; @@ -1668,54 +1662,54 @@ var application_default3 = applicationCronSchedulerJobs; // cron/index.ts var cronJobs = (context) => { - console.info('Running cron jobs'); + console.info("Running cron jobs"); cron_job_scheduler_default(account_default2, context); cron_job_scheduler_default(application_default3, context); }; var cron_default = cronJobs; // schema.ts -var import_core2 = require('@keystone-6/core'); -var import_access = require('@keystone-6/core/access'); -var import_fields = require('@keystone-6/core/fields'); -var import_fields_document = require('@keystone-6/fields-document'); +var import_core2 = require("@keystone-6/core"); +var import_access = require("@keystone-6/core/access"); +var import_fields = require("@keystone-6/core/fields"); +var import_fields_document = require("@keystone-6/fields-document"); // helpers/update-application/index.ts var timestamp = async (context, applicationId) => { try { - console.info('Updating application updatedAt timestamp'); + console.info("Updating application updatedAt timestamp"); const now2 = /* @__PURE__ */ new Date(); const application2 = await context.db.Application.updateOne({ where: { - id: applicationId, + id: applicationId }, data: { - updatedAt: now2, - }, + updatedAt: now2 + } }); return application2; } catch (error) { - console.error('Error updating application updatedAt timestamp %o', error); + console.error("Error updating application updatedAt timestamp %o", error); throw new Error(`Updating application updatedAt timestamp ${error}`); } }; var updateApplication = { - timestamp, + timestamp }; var update_application_default = updateApplication; // nullable-checkbox/index.ts -var import_types = require('@keystone-6/core/types'); -var import_core = require('@keystone-6/core'); -var nullableCheckboxConfig = (defaultValue) => +var import_types = require("@keystone-6/core/types"); +var import_core = require("@keystone-6/core"); +var nullableCheckboxConfig = (defaultValue) => ( /** * Database/GraphQL config. * This defines the field as an optional boolean with a default value of null. */ (0, import_types.fieldType)({ - kind: 'scalar', - mode: 'optional', - scalar: 'Boolean', + kind: "scalar", + mode: "optional", + scalar: "Boolean" })({ /** * Input/output config. @@ -1732,30 +1726,31 @@ var nullableCheckboxConfig = (defaultValue) => return value; } return null; - }, + } }, update: { arg: import_core.graphql.arg({ type: import_core.graphql.Boolean }), resolve(value) { return value; - }, - }, + } + } }, output: import_core.graphql.field({ type: import_core.graphql.Boolean, resolve({ value }) { return value; - }, + } }), /** * Keystone admin UI/CMS config for this field. * Since we do not use the UI/CMS, this can be empty. */ - views: './nullable-checkbox/views', + views: "./nullable-checkbox/views", getAdminMeta() { return {}; - }, - }); + } + }) +); var nullableCheckbox = (defaultValue) => () => nullableCheckboxConfig(defaultValue); var nullable_checkbox_default = nullableCheckbox; @@ -1766,311 +1761,311 @@ var { EXPORT_CONTRACT: { AGENT_SERVICE_CHARGE }, POLICY: POLICY3, POLICY_TYPE: POLICY_TYPE2, - SUBMISSION_TYPE, + SUBMISSION_TYPE } = APPLICATION; var lists = { ReferenceNumber: { db: { - idField: { kind: 'autoincrement' }, + idField: { kind: "autoincrement" } }, fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), + application: (0, import_fields.relationship)({ ref: "Application" }) }, - access: import_access.allowAll, + access: import_access.allowAll }, Application: { fields: { createdAt: (0, import_fields.timestamp)(), updatedAt: (0, import_fields.timestamp)(), - eligibility: (0, import_fields.relationship)({ ref: 'Eligibility' }), + eligibility: (0, import_fields.relationship)({ ref: "Eligibility" }), referenceNumber: (0, import_fields.integer)({ - isIndexed: true, + isIndexed: true }), submissionCount: (0, import_fields.integer)({ - validation: { isRequired: true }, + validation: { isRequired: true } }), submissionDate: (0, import_fields.timestamp)(), submissionDeadline: (0, import_fields.timestamp)(), submissionType: (0, import_fields.select)({ - options: [{ label: SUBMISSION_TYPE.MIA, value: SUBMISSION_TYPE.MIA }], + options: [{ label: SUBMISSION_TYPE.MIA, value: SUBMISSION_TYPE.MIA }] }), status: (0, import_fields.text)({ - validation: { isRequired: true }, + validation: { isRequired: true } }), previousStatus: (0, import_fields.text)(), - policy: (0, import_fields.relationship)({ ref: 'Policy' }), - exportContract: (0, import_fields.relationship)({ ref: 'ExportContract' }), + policy: (0, import_fields.relationship)({ ref: "Policy" }), + exportContract: (0, import_fields.relationship)({ ref: "ExportContract" }), owner: (0, import_fields.relationship)({ - ref: 'Account', - many: false, + ref: "Account", + many: false }), - business: (0, import_fields.relationship)({ ref: 'Business' }), - broker: (0, import_fields.relationship)({ ref: 'Broker' }), - buyer: (0, import_fields.relationship)({ ref: 'Buyer' }), - company: (0, import_fields.relationship)({ ref: 'Company' }), - declaration: (0, import_fields.relationship)({ ref: 'Declaration' }), - nominatedLossPayee: (0, import_fields.relationship)({ ref: 'NominatedLossPayee' }), - policyContact: (0, import_fields.relationship)({ ref: 'PolicyContact' }), - sectionReview: (0, import_fields.relationship)({ ref: 'SectionReview' }), + business: (0, import_fields.relationship)({ ref: "Business" }), + broker: (0, import_fields.relationship)({ ref: "Broker" }), + buyer: (0, import_fields.relationship)({ ref: "Buyer" }), + company: (0, import_fields.relationship)({ ref: "Company" }), + declaration: (0, import_fields.relationship)({ ref: "Declaration" }), + nominatedLossPayee: (0, import_fields.relationship)({ ref: "NominatedLossPayee" }), + policyContact: (0, import_fields.relationship)({ ref: "PolicyContact" }), + sectionReview: (0, import_fields.relationship)({ ref: "SectionReview" }), version: (0, import_fields.text)({ - validation: { isRequired: true }, + validation: { isRequired: true } }), dealType: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: 'VarChar(4)' }, + db: { nativeType: "VarChar(4)" } }), - migratedV2toV3: nullable_checkbox_default(), + migratedV2toV3: nullable_checkbox_default() }, - access: import_access.allowAll, + access: import_access.allowAll }, TotalContractValue: (0, import_core2.list)({ fields: { valueId: (0, import_fields.integer)(), value: (0, import_fields.text)({ - db: { nativeType: 'VarChar(70)' }, - }), + db: { nativeType: "VarChar(70)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), CoverPeriod: (0, import_core2.list)({ fields: { valueId: (0, import_fields.integer)(), value: (0, import_fields.text)({ - db: { nativeType: 'VarChar(70)' }, - }), + db: { nativeType: "VarChar(70)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), LossPayeeFinancialInternational: { fields: { - lossPayee: (0, import_fields.relationship)({ ref: 'NominatedLossPayee.financialInternational' }), - vector: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialInternationalVector.financialInternational' }), + lossPayee: (0, import_fields.relationship)({ ref: "NominatedLossPayee.financialInternational" }), + vector: (0, import_fields.relationship)({ ref: "LossPayeeFinancialInternationalVector.financialInternational" }), bankAddress: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, + db: { nativeType: "VarChar(500)" } }), bicSwiftCode: (0, import_fields.text)(), - iban: (0, import_fields.text)(), + iban: (0, import_fields.text)() }, - access: import_access.allowAll, + access: import_access.allowAll }, LossPayeeFinancialInternationalVector: { fields: { - financialInternational: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialInternational.vector' }), + financialInternational: (0, import_fields.relationship)({ ref: "LossPayeeFinancialInternational.vector" }), bicSwiftCodeVector: (0, import_fields.text)(), - ibanVector: (0, import_fields.text)(), + ibanVector: (0, import_fields.text)() }, - access: import_access.allowAll, + access: import_access.allowAll }, LossPayeeFinancialUk: { fields: { - lossPayee: (0, import_fields.relationship)({ ref: 'NominatedLossPayee.financialUk' }), - vector: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialUkVector.financialUk' }), + lossPayee: (0, import_fields.relationship)({ ref: "NominatedLossPayee.financialUk" }), + vector: (0, import_fields.relationship)({ ref: "LossPayeeFinancialUkVector.financialUk" }), accountNumber: (0, import_fields.text)(), bankAddress: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, + db: { nativeType: "VarChar(500)" } }), - sortCode: (0, import_fields.text)(), + sortCode: (0, import_fields.text)() }, - access: import_access.allowAll, + access: import_access.allowAll }, LossPayeeFinancialUkVector: { fields: { - financialUk: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialUk.vector' }), + financialUk: (0, import_fields.relationship)({ ref: "LossPayeeFinancialUk.vector" }), accountNumberVector: (0, import_fields.text)(), - sortCodeVector: (0, import_fields.text)(), + sortCodeVector: (0, import_fields.text)() }, - access: import_access.allowAll, + access: import_access.allowAll }, NominatedLossPayee: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - financialUk: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialUk.lossPayee' }), - financialInternational: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialInternational.lossPayee' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + financialUk: (0, import_fields.relationship)({ ref: "LossPayeeFinancialUk.lossPayee" }), + financialInternational: (0, import_fields.relationship)({ ref: "LossPayeeFinancialInternational.lossPayee" }), isAppointed: nullable_checkbox_default(), isLocatedInUk: nullable_checkbox_default(), isLocatedInternationally: nullable_checkbox_default(), name: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, - }), + db: { nativeType: "VarChar(200)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), Policy: { fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - jointlyInsuredParty: (0, import_fields.relationship)({ ref: 'JointlyInsuredParty.policy' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + jointlyInsuredParty: (0, import_fields.relationship)({ ref: "JointlyInsuredParty.policy" }), needPreCreditPeriodCover: nullable_checkbox_default(DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER), policyType: (0, import_fields.select)({ options: [ { label: POLICY_TYPE2.SINGLE, value: POLICY_TYPE2.SINGLE }, - { label: POLICY_TYPE2.MULTIPLE, value: POLICY_TYPE2.MULTIPLE }, - ], + { label: POLICY_TYPE2.MULTIPLE, value: POLICY_TYPE2.MULTIPLE } + ] }), requestedStartDate: (0, import_fields.timestamp)(), contractCompletionDate: (0, import_fields.timestamp)(), totalValueOfContract: (0, import_fields.integer)({ validation: { min: POLICY3.TOTAL_VALUE_OF_CONTRACT.MINIMUM, - max: POLICY3.TOTAL_VALUE_OF_CONTRACT.MAXIMUM, - }, + max: POLICY3.TOTAL_VALUE_OF_CONTRACT.MAXIMUM + } }), creditPeriodWithBuyer: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, + db: { nativeType: "VarChar(1000)" } }), policyCurrencyCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), totalMonthsOfCover: (0, import_fields.integer)(), totalSalesToBuyer: (0, import_fields.integer)(), maximumBuyerWillOwe: (0, import_fields.integer)(), - requestedCreditLimit: (0, import_fields.integer)(), + requestedCreditLimit: (0, import_fields.integer)() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }, PolicyContact: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), + application: (0, import_fields.relationship)({ ref: "Application" }), firstName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(400)' }, + db: { nativeType: "VarChar(400)" } }), lastName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(400)' }, + db: { nativeType: "VarChar(400)" } }), email: (0, import_fields.text)({ - db: { nativeType: 'VarChar(300)' }, + db: { nativeType: "VarChar(300)" } }), position: (0, import_fields.text)({ - db: { nativeType: 'VarChar(50)' }, + db: { nativeType: "VarChar(50)" } }), - isSameAsOwner: nullable_checkbox_default(), + isSameAsOwner: nullable_checkbox_default() }, - access: import_access.allowAll, + access: import_access.allowAll }), JointlyInsuredParty: (0, import_core2.list)({ fields: { - policy: (0, import_fields.relationship)({ ref: 'Policy.jointlyInsuredParty' }), + policy: (0, import_fields.relationship)({ ref: "Policy.jointlyInsuredParty" }), requested: nullable_checkbox_default(), companyName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), companyNumber: (0, import_fields.text)({ - db: { nativeType: 'VarChar(100)' }, + db: { nativeType: "VarChar(100)" } }), countryCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, - }), + db: { nativeType: "VarChar(3)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), ExportContract: { fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - agent: (0, import_fields.relationship)({ ref: 'ExportContractAgent.exportContract' }), - privateMarket: (0, import_fields.relationship)({ ref: 'PrivateMarket.exportContract' }), - awardMethod: (0, import_fields.relationship)({ ref: 'ExportContractAwardMethod' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + agent: (0, import_fields.relationship)({ ref: "ExportContractAgent.exportContract" }), + privateMarket: (0, import_fields.relationship)({ ref: "PrivateMarket.exportContract" }), + awardMethod: (0, import_fields.relationship)({ ref: "ExportContractAwardMethod" }), otherAwardMethod: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), finalDestinationKnown: nullable_checkbox_default(), finalDestinationCountryCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), goodsOrServicesDescription: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, + db: { nativeType: "VarChar(1000)" } }), paymentTermsDescription: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, - }), + db: { nativeType: "VarChar(1000)" } + }) }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }, ExportContractAgent: (0, import_core2.list)({ fields: { - exportContract: (0, import_fields.relationship)({ ref: 'ExportContract.agent' }), - service: (0, import_fields.relationship)({ ref: 'ExportContractAgentService.agent' }), + exportContract: (0, import_fields.relationship)({ ref: "ExportContract.agent" }), + service: (0, import_fields.relationship)({ ref: "ExportContractAgentService.agent" }), countryCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), fullAddress: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, + db: { nativeType: "VarChar(500)" } }), isUsingAgent: nullable_checkbox_default(), name: (0, import_fields.text)({ - db: { nativeType: 'VarChar(800)' }, - }), + db: { nativeType: "VarChar(800)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), ExportContractAgentService: { fields: { - agent: (0, import_fields.relationship)({ ref: 'ExportContractAgent.service' }), - charge: (0, import_fields.relationship)({ ref: 'ExportContractAgentServiceCharge.service' }), + agent: (0, import_fields.relationship)({ ref: "ExportContractAgent.service" }), + charge: (0, import_fields.relationship)({ ref: "ExportContractAgentServiceCharge.service" }), agentIsCharging: nullable_checkbox_default(), serviceDescription: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, - }), + db: { nativeType: "VarChar(1000)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }, ExportContractAgentServiceCharge: { fields: { - service: (0, import_fields.relationship)({ ref: 'ExportContractAgentService.charge' }), + service: (0, import_fields.relationship)({ ref: "ExportContractAgentService.charge" }), percentageCharge: (0, import_fields.integer)(), fixedSumAmount: (0, import_fields.decimal)({ scale: 2 }), fixedSumCurrencyCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, - defaultValue: DEFAULT_CURRENCY, + db: { nativeType: "VarChar(3)" }, + defaultValue: DEFAULT_CURRENCY }), method: (0, import_fields.select)({ options: [ { label: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM, value: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM }, - { label: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE, value: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE }, - ], + { label: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE, value: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE } + ] }), payableCountryCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, - }), + db: { nativeType: "VarChar(3)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }, ExportContractAwardMethod: (0, import_core2.list)({ fields: { value: (0, import_fields.text)({ - db: { nativeType: 'VarChar(50)' }, - }), + db: { nativeType: "VarChar(50)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), PrivateMarket: (0, import_core2.list)({ fields: { - exportContract: (0, import_fields.relationship)({ ref: 'ExportContract.privateMarket' }), + exportContract: (0, import_fields.relationship)({ ref: "ExportContract.privateMarket" }), attempted: nullable_checkbox_default(), declinedDescription: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, - }), + db: { nativeType: "VarChar(1000)" } + }) }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), Account: (0, import_core2.list)({ fields: { @@ -2078,15 +2073,15 @@ var lists = { updatedAt: (0, import_fields.timestamp)(), firstName: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: 'VarChar(400)' }, + db: { nativeType: "VarChar(400)" } }), lastName: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: 'VarChar(400)' }, + db: { nativeType: "VarChar(400)" } }), email: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: 'VarChar(300)' }, + db: { nativeType: "VarChar(300)" } }), salt: (0, import_fields.text)({ validation: { isRequired: true } }), hash: (0, import_fields.text)({ validation: { isRequired: true } }), @@ -2095,7 +2090,7 @@ var lists = { verificationExpiry: (0, import_fields.timestamp)(), otpSalt: (0, import_fields.text)(), otpHash: (0, import_fields.text)({ - db: { nativeType: 'VarChar(256)' }, + db: { nativeType: "VarChar(256)" } }), otpExpiry: (0, import_fields.timestamp)(), sessionExpiry: (0, import_fields.timestamp)(), @@ -2103,24 +2098,24 @@ var lists = { passwordResetHash: (0, import_fields.text)({ validation: { isRequired: false } }), passwordResetExpiry: (0, import_fields.timestamp)({ validation: { isRequired: false } }), authentication: (0, import_fields.relationship)({ - ref: 'Authentication', + ref: "Authentication" }), authenticationRetry: (0, import_fields.relationship)({ - ref: 'AuthenticationRetry', + ref: "AuthenticationRetry" }), reactivationHash: (0, import_fields.text)({ validation: { isRequired: false } }), reactivationExpiry: (0, import_fields.timestamp)({ validation: { isRequired: false } }), applications: (0, import_fields.relationship)({ - ref: 'Application', - many: true, + ref: "Application", + many: true }), - status: (0, import_fields.relationship)({ ref: 'AccountStatus.account' }), + status: (0, import_fields.relationship)({ ref: "AccountStatus.account" }) }, - access: import_access.allowAll, + access: import_access.allowAll }), AccountStatus: { fields: { - account: (0, import_fields.relationship)({ ref: 'Account.status' }), + account: (0, import_fields.relationship)({ ref: "Account.status" }), isVerified: (0, import_fields.checkbox)({ defaultValue: false }), /** * isBlocked flag will only be true if the account has: @@ -2129,37 +2124,37 @@ var lists = { */ isBlocked: (0, import_fields.checkbox)({ defaultValue: false }), isInactive: (0, import_fields.checkbox)({ defaultValue: false }), - updatedAt: (0, import_fields.timestamp)(), + updatedAt: (0, import_fields.timestamp)() }, - access: import_access.allowAll, + access: import_access.allowAll }, AuthenticationRetry: (0, import_core2.list)({ fields: { account: (0, import_fields.relationship)({ - ref: 'Account', - many: true, + ref: "Account", + many: true }), - createdAt: (0, import_fields.timestamp)({ validation: { isRequired: true } }), + createdAt: (0, import_fields.timestamp)({ validation: { isRequired: true } }) }, - access: import_access.allowAll, + access: import_access.allowAll }), Authentication: (0, import_core2.list)({ fields: { account: (0, import_fields.relationship)({ - ref: 'Account', - many: true, + ref: "Account", + many: true }), createdAt: (0, import_fields.timestamp)(), salt: (0, import_fields.text)({ validation: { isRequired: true } }), - hash: (0, import_fields.text)({ validation: { isRequired: true } }), + hash: (0, import_fields.text)({ validation: { isRequired: true } }) }, - access: import_access.allowAll, + access: import_access.allowAll }), Business: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), + application: (0, import_fields.relationship)({ ref: "Application" }), goodsOrServicesSupplied: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, + db: { nativeType: "VarChar(1000)" } }), totalYearsExporting: (0, import_fields.integer)(), totalEmployeesUK: (0, import_fields.integer)(), @@ -2167,26 +2162,26 @@ var lists = { estimatedAnnualTurnover: (0, import_fields.integer)(), exportsTurnoverPercentage: (0, import_fields.integer)(), turnoverCurrencyCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, - defaultValue: DEFAULT_CURRENCY, + db: { nativeType: "VarChar(3)" }, + defaultValue: DEFAULT_CURRENCY }), - hasCreditControlProcess: nullable_checkbox_default(), + hasCreditControlProcess: nullable_checkbox_default() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), Broker: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), + application: (0, import_fields.relationship)({ ref: "Application" }), isUsingBroker: nullable_checkbox_default(), name: (0, import_fields.text)({ - db: { nativeType: 'VarChar(800)' }, + db: { nativeType: "VarChar(800)" } }), addressLine1: (0, import_fields.text)(), addressLine2: (0, import_fields.text)(), @@ -2194,24 +2189,24 @@ var lists = { county: (0, import_fields.text)(), postcode: (0, import_fields.text)(), fullAddress: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, + db: { nativeType: "VarChar(500)" } }), email: (0, import_fields.text)({ - db: { nativeType: 'VarChar(300)' }, - }), + db: { nativeType: "VarChar(300)" } + }) }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), CompanyAddress: (0, import_core2.list)({ fields: { - company: (0, import_fields.relationship)({ ref: 'Company.registeredOfficeAddress' }), + company: (0, import_fields.relationship)({ ref: "Company.registeredOfficeAddress" }), addressLine1: (0, import_fields.text)(), addressLine2: (0, import_fields.text)(), careOf: (0, import_fields.text)(), @@ -2219,282 +2214,282 @@ var lists = { region: (0, import_fields.text)(), postalCode: (0, import_fields.text)(), country: (0, import_fields.text)(), - premises: (0, import_fields.text)(), + premises: (0, import_fields.text)() }, - access: import_access.allowAll, + access: import_access.allowAll }), Company: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - registeredOfficeAddress: (0, import_fields.relationship)({ ref: 'CompanyAddress.company' }), - differentTradingAddress: (0, import_fields.relationship)({ ref: 'CompanyDifferentTradingAddress.company' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + registeredOfficeAddress: (0, import_fields.relationship)({ ref: "CompanyAddress.company" }), + differentTradingAddress: (0, import_fields.relationship)({ ref: "CompanyDifferentTradingAddress.company" }), sicCodes: (0, import_fields.relationship)({ - ref: 'CompanySicCode.company', - many: true, + ref: "CompanySicCode.company", + many: true }), companyName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), companyNumber: (0, import_fields.text)(), dateOfCreation: (0, import_fields.timestamp)(), hasDifferentTradingAddress: nullable_checkbox_default(), differentTradingName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), hasDifferentTradingName: nullable_checkbox_default(), companyWebsite: (0, import_fields.text)(), phoneNumber: (0, import_fields.text)(), - financialYearEndDate: (0, import_fields.timestamp)(), + financialYearEndDate: (0, import_fields.timestamp)() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), CompanyDifferentTradingAddress: (0, import_core2.list)({ fields: { - company: (0, import_fields.relationship)({ ref: 'Company.differentTradingAddress' }), + company: (0, import_fields.relationship)({ ref: "Company.differentTradingAddress" }), fullAddress: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, - }), + db: { nativeType: "VarChar(500)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), CompanySicCode: (0, import_core2.list)({ fields: { - company: (0, import_fields.relationship)({ ref: 'Company.sicCodes' }), + company: (0, import_fields.relationship)({ ref: "Company.sicCodes" }), sicCode: (0, import_fields.text)(), - industrySectorName: (0, import_fields.text)(), + industrySectorName: (0, import_fields.text)() }, - access: import_access.allowAll, + access: import_access.allowAll }), Buyer: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), + application: (0, import_fields.relationship)({ ref: "Application" }), companyOrOrganisationName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), address: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, + db: { nativeType: "VarChar(500)" } }), - country: (0, import_fields.relationship)({ ref: 'Country' }), + country: (0, import_fields.relationship)({ ref: "Country" }), registrationNumber: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), website: (0, import_fields.text)(), - buyerTradingHistory: (0, import_fields.relationship)({ ref: 'BuyerTradingHistory.buyer' }), - contact: (0, import_fields.relationship)({ ref: 'BuyerContact.buyer' }), - relationship: (0, import_fields.relationship)({ ref: 'BuyerRelationship.buyer' }), + buyerTradingHistory: (0, import_fields.relationship)({ ref: "BuyerTradingHistory.buyer" }), + contact: (0, import_fields.relationship)({ ref: "BuyerContact.buyer" }), + relationship: (0, import_fields.relationship)({ ref: "BuyerRelationship.buyer" }) }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), BuyerContact: { fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - buyer: (0, import_fields.relationship)({ ref: 'Buyer.contact' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + buyer: (0, import_fields.relationship)({ ref: "Buyer.contact" }), contactFirstName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), contactLastName: (0, import_fields.text)({ - db: { nativeType: 'VarChar(200)' }, + db: { nativeType: "VarChar(200)" } }), contactPosition: (0, import_fields.text)(), contactEmail: (0, import_fields.text)({ - db: { nativeType: 'VarChar(300)' }, + db: { nativeType: "VarChar(300)" } }), - canContactBuyer: nullable_checkbox_default(), + canContactBuyer: nullable_checkbox_default() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }, BuyerRelationship: { fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - buyer: (0, import_fields.relationship)({ ref: 'Buyer.relationship' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + buyer: (0, import_fields.relationship)({ ref: "Buyer.relationship" }), exporterIsConnectedWithBuyer: nullable_checkbox_default(), connectionWithBuyerDescription: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, + db: { nativeType: "VarChar(1000)" } }), exporterHasPreviousCreditInsuranceWithBuyer: nullable_checkbox_default(), exporterHasBuyerFinancialAccounts: nullable_checkbox_default(), previousCreditInsuranceWithBuyerDescription: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1000)' }, - }), + db: { nativeType: "VarChar(1000)" } + }) }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }, BuyerTradingHistory: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - buyer: (0, import_fields.relationship)({ ref: 'Buyer.buyerTradingHistory' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + buyer: (0, import_fields.relationship)({ ref: "Buyer.buyerTradingHistory" }), currencyCode: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), outstandingPayments: nullable_checkbox_default(), failedPayments: nullable_checkbox_default(), exporterHasTradedWithBuyer: nullable_checkbox_default(), totalOutstandingPayments: (0, import_fields.integer)(), - totalOverduePayments: (0, import_fields.integer)(), + totalOverduePayments: (0, import_fields.integer)() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), Country: (0, import_core2.list)({ fields: { isoCode: (0, import_fields.text)({ - validation: { isRequired: true }, + validation: { isRequired: true } }), name: (0, import_fields.text)({ - validation: { isRequired: true }, - }), + validation: { isRequired: true } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), Eligibility: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - buyerCountry: (0, import_fields.relationship)({ ref: 'Country' }), - coverPeriod: (0, import_fields.relationship)({ ref: 'CoverPeriod' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + buyerCountry: (0, import_fields.relationship)({ ref: "Country" }), + coverPeriod: (0, import_fields.relationship)({ ref: "CoverPeriod" }), hasEndBuyer: (0, import_fields.checkbox)(), hasMinimumUkGoodsOrServices: (0, import_fields.checkbox)(), hasCompaniesHouseNumber: (0, import_fields.checkbox)(), otherPartiesInvolved: (0, import_fields.checkbox)(), paidByLetterOfCredit: (0, import_fields.checkbox)(), - totalContractValue: (0, import_fields.relationship)({ ref: 'TotalContractValue' }), + totalContractValue: (0, import_fields.relationship)({ ref: "TotalContractValue" }), validExporterLocation: (0, import_fields.checkbox)(), isPartyToConsortium: (0, import_fields.checkbox)(), - isMemberOfAGroup: (0, import_fields.checkbox)(), + isMemberOfAGroup: (0, import_fields.checkbox)() }, - access: import_access.allowAll, + access: import_access.allowAll }), SectionReview: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), + application: (0, import_fields.relationship)({ ref: "Application" }), eligibility: nullable_checkbox_default(), business: nullable_checkbox_default(), buyer: nullable_checkbox_default(), exportContract: nullable_checkbox_default(), - policy: nullable_checkbox_default(), + policy: nullable_checkbox_default() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), Declaration: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: 'Application' }), - version: (0, import_fields.relationship)({ ref: 'DeclarationVersion' }), + application: (0, import_fields.relationship)({ ref: "Application" }), + version: (0, import_fields.relationship)({ ref: "DeclarationVersion" }), agreeHowDataWillBeUsed: nullable_checkbox_default(), agreeToAntiBribery: nullable_checkbox_default(), agreeToConfidentiality: nullable_checkbox_default(), agreeToConfirmationAndAcknowledgements: nullable_checkbox_default(), hasAntiBriberyCodeOfConduct: nullable_checkbox_default(), - willExportWithAntiBriberyCodeOfConduct: nullable_checkbox_default(), + willExportWithAntiBriberyCodeOfConduct: nullable_checkbox_default() }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - }, + } }, - access: import_access.allowAll, + access: import_access.allowAll }), DeclarationVersion: (0, import_core2.list)({ fields: { - declaration: (0, import_fields.relationship)({ ref: 'Declaration' }), + declaration: (0, import_fields.relationship)({ ref: "Declaration" }), agreeToConfidentiality: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), agreeToAntiBribery: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), hasAntiBriberyCodeOfConduct: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), willExportWithAntiBriberyCodeOfConduct: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), agreeToConfirmationAndAcknowledgements: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, + db: { nativeType: "VarChar(3)" } }), agreeHowDataWillBeUsed: (0, import_fields.text)({ - db: { nativeType: 'VarChar(3)' }, - }), + db: { nativeType: "VarChar(3)" } + }) }, - access: import_access.allowAll, + access: import_access.allowAll }), Page: (0, import_core2.list)({ fields: { heading: (0, import_fields.text)({ - label: 'Page heading', + label: "Page heading" }), metaTitle: (0, import_fields.text)({ - label: 'Meta title', + label: "Meta title" }), content: (0, import_fields_document.document)({ formatting: true, dividers: true, - links: true, - }), + links: true + }) }, ui: { listView: { - initialColumns: ['heading', 'id'], - }, + initialColumns: ["heading", "id"] + } }, - access: import_access.allowAll, + access: import_access.allowAll }), User: (0, import_core2.list)({ fields: { name: (0, import_fields.text)({ validation: { isRequired: true } }), email: (0, import_fields.text)({ validation: { isRequired: true }, - isIndexed: 'unique', + isIndexed: "unique" }), - password: (0, import_fields.password)({ validation: { isRequired: true } }), + password: (0, import_fields.password)({ validation: { isRequired: true } }) }, ui: { listView: { - initialColumns: ['name', 'email'], - }, + initialColumns: ["name", "email"] + } }, - access: import_access.allowAll, + access: import_access.allowAll }), Feedback: (0, import_core2.list)({ fields: { @@ -2506,54 +2501,54 @@ var lists = { { label: FEEDBACK.NEITHER, value: FEEDBACK.NEITHER }, { label: FEEDBACK.DISSATISFIED, value: FEEDBACK.DISSATISFIED }, { label: FEEDBACK.VERY_DISSATISIFED, value: FEEDBACK.VERY_DISSATISIFED }, - { label: '', value: '' }, + { label: "", value: "" } ], - db: { isNullable: true }, + db: { isNullable: true } }), improvement: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1200)' }, + db: { nativeType: "VarChar(1200)" } }), otherComments: (0, import_fields.text)({ - db: { nativeType: 'VarChar(1200)' }, + db: { nativeType: "VarChar(1200)" } }), referralUrl: (0, import_fields.text)({ - db: { nativeType: 'VarChar(500)' }, + db: { nativeType: "VarChar(500)" } }), product: (0, import_fields.text)(), - createdAt: (0, import_fields.timestamp)(), + createdAt: (0, import_fields.timestamp)() }, - access: import_access.allowAll, - }), + access: import_access.allowAll + }) }; // auth.ts -var import_config3 = require('dotenv/config'); -var import_auth = require('@keystone-6/auth'); -var import_session = require('@keystone-6/core/session'); +var import_config3 = require("dotenv/config"); +var import_auth = require("@keystone-6/auth"); +var import_session = require("@keystone-6/core/session"); var sessionSecret = String(process.env.SESSION_SECRET); if (!sessionSecret) { - if (process.env.NODE_ENV === 'production') { - throw new Error('SESSION_SECRET environment variable must be set in production'); + if (process.env.NODE_ENV === "production") { + throw new Error("SESSION_SECRET environment variable must be set in production"); } } var { withAuth } = (0, import_auth.createAuth)({ - listKey: 'User', - identityField: 'email', - sessionData: 'name', - secretField: 'password', + listKey: "User", + identityField: "email", + sessionData: "name", + secretField: "password", initFirstItem: { /** * Ensure that if there are no items in the database, * keystone admin UI will ask you to create * a new user, with the following fields. */ - fields: ['name', 'email', 'password'], - }, + fields: ["name", "email", "password"] + } }); var sessionMaxAge = 60 * 60 * 24 * 30; var session = (0, import_session.statelessSessions)({ maxAge: sessionMaxAge, - secret: sessionSecret, + secret: sessionSecret }); // apollo/plugins/index.ts @@ -2569,21 +2564,21 @@ var requestDidStart = () => ({ * via an explicit list of allowed resolvers. */ didResolveOperation({ request }) { - if (!request.operationName || (request.operationName && !ALLOWED_GRAPHQL_RESOLVERS.includes(request.operationName))) { - throw new Error('Operation not permitted'); + if (!request.operationName || request.operationName && !ALLOWED_GRAPHQL_RESOLVERS.includes(request.operationName)) { + throw new Error("Operation not permitted"); } - }, + } }); var apolloPlugins = [{ requestDidStart }]; var plugins_default = apolloPlugins; // apollo/format-graphql-error/index.ts -var import_config4 = require('dotenv/config'); -var import_apollo_server_express = require('apollo-server-express'); +var import_config4 = require("dotenv/config"); +var import_apollo_server_express = require("apollo-server-express"); var formatGraphQlError = (error) => { - const isDevEnvironment3 = process.env.NODE_ENV === 'development'; + const isDevEnvironment3 = process.env.NODE_ENV === "development"; if (!isDevEnvironment3) { - return new import_apollo_server_express.ValidationError('Invalid request'); + return new import_apollo_server_express.ValidationError("Invalid request"); } return error; }; @@ -2594,7 +2589,7 @@ var apolloPlugins2 = plugins_default; var formatGraphQlError2 = format_graphql_error_default; // custom-schema/index.ts -var import_schema = require('@graphql-tools/schema'); +var import_schema = require("@graphql-tools/schema"); // custom-schema/type-defs.ts var typeDefs = ` @@ -3087,19 +3082,19 @@ var typeDefs = ` var type_defs_default = typeDefs; // custom-resolvers/mutations/create-an-account/index.ts -var import_config5 = require('dotenv/config'); +var import_config5 = require("dotenv/config"); // helpers/get-account-status-by-id/index.ts var getAccountStatusById = async (context, id) => { try { - console.info('Getting account status by ID %s', id); + console.info("Getting account status by ID %s", id); const accountStatus2 = await context.query.AccountStatus.findOne({ where: { id }, - query: 'id isVerified isBlocked isInactive', + query: "id isVerified isBlocked isInactive" }); return accountStatus2; } catch (error) { - console.error('Error getting account status by ID %o', error); + console.error("Error getting account status by ID %o", error); throw new Error(`Getting account status by ID ${error}`); } }; @@ -3108,40 +3103,40 @@ var get_account_status_by_id_default = getAccountStatusById; // helpers/get-account-by-field/index.ts var getAccountByField = async (context, field, value) => { try { - console.info('Getting account by field/value $s', `${field}, ${value}`); + console.info("Getting account by field/value $s", `${field}, ${value}`); const accountsArray = await context.db.Account.findMany({ where: { - [field]: { equals: value }, + [field]: { equals: value } }, - take: 1, + take: 1 }); if (!accountsArray?.length || !accountsArray[0]) { - console.info('Getting account by field - no account exists with the provided field/value'); + console.info("Getting account by field - no account exists with the provided field/value"); return false; } const account2 = accountsArray[0]; const accountStatus2 = await get_account_status_by_id_default(context, account2.statusId); const populatedAccount = { ...account2, - status: accountStatus2, + status: accountStatus2 }; return populatedAccount; } catch (error) { - console.error('Error getting account by field/value %o', error); + console.error("Error getting account by field/value %o", error); throw new Error(`Getting account by field/value ${error}`); } }; var get_account_by_field_default = getAccountByField; // helpers/get-password-hash/index.ts -var import_crypto = __toESM(require('crypto')); +var import_crypto = __toESM(require("crypto")); var { ENCRYPTION } = ACCOUNT2; var { STRING_TYPE, PBKDF2: { ITERATIONS, DIGEST_ALGORITHM }, PASSWORD: { - PBKDF2: { KEY_LENGTH }, - }, + PBKDF2: { KEY_LENGTH } + } } = ENCRYPTION; var getPasswordHash = (password2, salt) => { const hash = import_crypto.default.pbkdf2Sync(password2, salt, ITERATIONS, KEY_LENGTH, DIGEST_ALGORITHM).toString(STRING_TYPE); @@ -3151,54 +3146,54 @@ var get_password_hash_default = getPasswordHash; // helpers/is-valid-account-password/index.ts var isValidAccountPassword = (password2, salt, hash) => { - console.info('Validating account password'); + console.info("Validating account password"); const hashVerify = get_password_hash_default(password2, salt); if (hash === hashVerify) { - console.info('Valid account password'); + console.info("Valid account password"); return true; } - console.info('Invalid account password'); + console.info("Invalid account password"); return false; }; var is_valid_account_password_default = isValidAccountPassword; // helpers/encrypt-password/index.ts -var import_crypto2 = __toESM(require('crypto')); +var import_crypto2 = __toESM(require("crypto")); var { ENCRYPTION: ENCRYPTION2 } = ACCOUNT2; var { RANDOM_BYTES_SIZE, STRING_TYPE: STRING_TYPE2, PBKDF2: { ITERATIONS: ITERATIONS2, DIGEST_ALGORITHM: DIGEST_ALGORITHM2 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH2 }, - }, + PBKDF2: { KEY_LENGTH: KEY_LENGTH2 } + } } = ENCRYPTION2; var encryptPassword = (password2) => { const salt = import_crypto2.default.randomBytes(RANDOM_BYTES_SIZE).toString(STRING_TYPE2); const hash = import_crypto2.default.pbkdf2Sync(password2, salt, ITERATIONS2, KEY_LENGTH2, DIGEST_ALGORITHM2).toString(STRING_TYPE2); return { salt, - hash, + hash }; }; var encrypt_password_default = encryptPassword; // helpers/get-account-verification-hash/index.ts -var import_crypto3 = __toESM(require('crypto')); +var import_crypto3 = __toESM(require("crypto")); var { EMAIL, ENCRYPTION: ENCRYPTION3 } = ACCOUNT2; var { STRING_TYPE: STRING_TYPE3, PBKDF2: { ITERATIONS: ITERATIONS3, DIGEST_ALGORITHM: DIGEST_ALGORITHM3 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH3 }, - }, + PBKDF2: { KEY_LENGTH: KEY_LENGTH3 } + } } = ENCRYPTION3; var generateAccountVerificationHash = (email, salt) => { const verificationHash = import_crypto3.default.pbkdf2Sync(email, salt, ITERATIONS3, KEY_LENGTH3, DIGEST_ALGORITHM3).toString(STRING_TYPE3); const verificationExpiry = EMAIL.VERIFICATION_EXPIRY(); return { verificationHash, - verificationExpiry, + verificationExpiry }; }; var get_account_verification_hash_default = generateAccountVerificationHash; @@ -3214,15 +3209,15 @@ var get_full_name_string_default = getFullNameString; // helpers/get-account-by-id/index.ts var getAccountById = async (context, accountId) => { try { - console.info('Getting account by ID'); + console.info("Getting account by ID"); const account2 = await context.db.Account.findOne({ where: { - id: accountId, - }, + id: accountId + } }); return account2; } catch (error) { - console.error('Error getting account by ID %o', error); + console.error("Error getting account by ID %o", error); throw new Error(`Getting account by ID ${error}`); } }; @@ -3231,55 +3226,55 @@ var get_account_by_id_default = getAccountById; // helpers/update-account/index.ts var account = async (context, accountId, updateData) => { try { - console.info('Updating account'); + console.info("Updating account"); const updatedAccount = await context.db.Account.updateOne({ where: { - id: accountId, + id: accountId }, - data: updateData, + data: updateData }); return updatedAccount; } catch (error) { - console.error('Error updating account %o', error); + console.error("Error updating account %o", error); throw new Error(`Updating account ${error}`); } }; var accountStatus = async (context, accountStatusId, updateData) => { try { - console.info('Updating account'); + console.info("Updating account"); const updatedAccountStatus = await context.db.AccountStatus.updateOne({ where: { - id: accountStatusId, + id: accountStatusId }, data: { ...updateData, - updatedAt: /* @__PURE__ */ new Date(), - }, + updatedAt: /* @__PURE__ */ new Date() + } }); return updatedAccountStatus; } catch (error) { - console.error('Error updating account status %o', error); + console.error("Error updating account status %o", error); throw new Error(`Updating account status ${error}`); } }; var update = { account, - accountStatus, + accountStatus }; var update_account_default = update; // helpers/send-email-confirm-email-address/index.ts var send2 = async (context, urlOrigin, accountId) => { try { - console.info('Sending email verification %s %s', urlOrigin, accountId); + console.info("Sending email verification %s %s", urlOrigin, accountId); const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info('Sending email verification - no account exists with the provided account ID'); + console.info("Sending email verification - no account exists with the provided account ID"); return { - success: false, + success: false }; } - let latestVerificationHash = ''; + let latestVerificationHash = ""; let verificationHasExpired = false; if (account2.verificationExpiry) { verificationHasExpired = dateIsInThePast(account2.verificationExpiry); @@ -3301,85 +3296,85 @@ var send2 = async (context, urlOrigin, accountId) => { } throw new Error(`Sending email verification (sendEmailConfirmEmailAddress helper) ${emailResponse}`); } catch (error) { - console.error('Error sending email verification (sendEmailConfirmEmailAddress helper) %o', error); + console.error("Error sending email verification (sendEmailConfirmEmailAddress helper) %o", error); throw new Error(`Sending email verification (sendEmailConfirmEmailAddress helper) ${error}`); } }; var confirmEmailAddressEmail = { - send: send2, + send: send2 }; var send_email_confirm_email_address_default = confirmEmailAddressEmail; // helpers/send-email-reactivate-account-link/index.ts -var import_crypto4 = __toESM(require('crypto')); +var import_crypto4 = __toESM(require("crypto")); var { ENCRYPTION: { STRING_TYPE: STRING_TYPE4, PBKDF2: { ITERATIONS: ITERATIONS4, DIGEST_ALGORITHM: DIGEST_ALGORITHM4 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH4 }, - }, - }, + PBKDF2: { KEY_LENGTH: KEY_LENGTH4 } + } + } } = ACCOUNT2; var send3 = async (variables, context) => { try { - console.info('Received a request to send reactivate account email/link - checking account - sendEmailReactivateAccountLinkHelper'); + console.info("Received a request to send reactivate account email/link - checking account - sendEmailReactivateAccountLinkHelper"); const { urlOrigin, accountId } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info('Unable to check account and send reactivate account email/link - no account found'); + console.info("Unable to check account and send reactivate account email/link - no account found"); return { success: false }; } const { email } = account2; - console.info('Generating hash for account reactivation'); + console.info("Generating hash for account reactivation"); const reactivationHash = import_crypto4.default.pbkdf2Sync(email, account2.salt, ITERATIONS4, KEY_LENGTH4, DIGEST_ALGORITHM4).toString(STRING_TYPE4); const accountUpdate = { reactivationHash, - reactivationExpiry: ACCOUNT2.REACTIVATION_EXPIRY(), + reactivationExpiry: ACCOUNT2.REACTIVATION_EXPIRY() }; - console.info('Updating account for reactivation'); + console.info("Updating account for reactivation"); await update_account_default.account(context, accountId, accountUpdate); - console.info('Sending reactivate account email/link'); + console.info("Sending reactivate account email/link"); const name = get_full_name_string_default(account2); const emailResponse = await emails_default.reactivateAccountLink(urlOrigin, email, name, reactivationHash); if (emailResponse.success) { return { ...emailResponse, email, - accountId, + accountId }; } return { accountId, email, success: false }; } catch (error) { - console.error('Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink helper) %o', error); + console.error("Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink helper) %o", error); throw new Error(`Checking account and sending reactivate account email/link (sendEmailReactivateAccountLink helper) ${error}`); } }; var sendEmailReactivateAccountLinkHelper = { - send: send3, + send: send3 }; var send_email_reactivate_account_link_default = sendEmailReactivateAccountLinkHelper; // custom-resolvers/mutations/create-an-account/index.ts var createAnAccount = async (root, variables, context) => { - console.info('Account creation - %s', variables.email); + console.info("Account creation - %s", variables.email); const { NODE_ENV: NODE_ENV3 } = process.env; - const isDevEnvironment3 = NODE_ENV3 === 'development'; + const isDevEnvironment3 = NODE_ENV3 === "development"; try { const { urlOrigin, firstName, lastName, email, password: password2 } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (account2) { - console.info('Account creation - account already exists %s', email); + console.info("Account creation - account already exists %s", email); if (is_valid_account_password_default(password2, account2.salt, account2.hash)) { - console.info('Account creation - account already exists - valid credentials provided %s', email); + console.info("Account creation - account already exists - valid credentials provided %s", email); if (account2.status.isBlocked) { - console.info('Account creation - unable to create a new account - account already exists and is blocked %s', email); + console.info("Account creation - unable to create a new account - account already exists and is blocked %s", email); const { id: accountId2 } = account2; const reactivateAccountVariables = { accountId: accountId2, - urlOrigin, + urlOrigin }; - console.info('Account creation - resending an email for reactivation %s', email); + console.info("Account creation - resending an email for reactivation %s", email); const emailResponse2 = await send_email_reactivate_account_link_default.send(reactivateAccountVariables, context); if (emailResponse2.success) { return { @@ -3387,43 +3382,43 @@ var createAnAccount = async (root, variables, context) => { success: true, alreadyExists: true, isVerified: false, - isBlocked: true, + isBlocked: true }; } return { success: false, - alreadyExists: true, + alreadyExists: true }; } if (!account2.status.isVerified) { - console.info('Account creation - unable to create a new account - account already exists and is not verified %s', email); + console.info("Account creation - unable to create a new account - account already exists and is not verified %s", email); const { id: accountId2 } = account2; - console.info('Account creation - resending an email verification for %s', email); + console.info("Account creation - resending an email verification for %s", email); const emailResponse2 = await send_email_confirm_email_address_default.send(context, urlOrigin, accountId2); if (emailResponse2.success) { return { id: accountId2, success: true, alreadyExists: true, - isVerified: false, + isVerified: false }; } } - console.info('Account creation - unable to create a new account - account already exists and is verified %s', email); + console.info("Account creation - unable to create a new account - account already exists and is verified %s", email); return { success: false, alreadyExists: true, - isVerified: true, + isVerified: true }; } - console.info('Account creation - account already exists - invalid credentials provided %s', email); + console.info("Account creation - account already exists - invalid credentials provided %s", email); return { success: false }; } - console.info('Account creation - no existing account found. Generating an encrypted password %s', email); + console.info("Account creation - no existing account found. Generating an encrypted password %s", email); const { salt, hash } = encrypt_password_default(password2); const now2 = /* @__PURE__ */ new Date(); const { verificationHash, verificationExpiry } = get_account_verification_hash_default(email, salt); - console.info('Account creation - constructing account data %s', email); + console.info("Account creation - constructing account data %s", email); const accountData = { firstName, lastName, @@ -3433,32 +3428,32 @@ var createAnAccount = async (root, variables, context) => { verificationHash, verificationExpiry, createdAt: now2, - updatedAt: now2, + updatedAt: now2 }; - console.info('Account creation - creating account %s', email); + console.info("Account creation - creating account %s", email); const creationResponse = await context.db.Account.createOne({ - data: accountData, + data: accountData }); - console.info('Account creation - creating account status relationship %s', email); + console.info("Account creation - creating account status relationship %s", email); const accountId = creationResponse.id; await context.db.AccountStatus.createOne({ data: { account: { connect: { - id: accountId, - }, - }, - }, + id: accountId + } + } + } }); - console.info('Account creation - sending an email verification for %s', email); + console.info("Account creation - sending an email verification for %s", email); const name = get_full_name_string_default(creationResponse); if (isDevEnvironment3) { const verificationUrl = `${variables.urlOrigin}/apply/create-account/verify-email?token=${verificationHash}&id=${accountId}`; - console.info('\u2705 Account creation (dev environment only) - mimicking sending verification link via email \n%s', verificationUrl); + console.info("\u2705 Account creation (dev environment only) - mimicking sending verification link via email \n%s", verificationUrl); return { id: accountId, verificationHash, - success: true, + success: true }; } const emailResponse = await emails_default.confirmEmailAddress(email, urlOrigin, name, verificationHash, accountId); @@ -3466,12 +3461,12 @@ var createAnAccount = async (root, variables, context) => { return { id: accountId, verificationHash, - success: true, + success: true }; } throw new Error(`Account creation - sending email verification for account creation ${emailResponse}`); } catch (error) { - console.error('Error Account creation - creating account %o', error); + console.error("Error Account creation - creating account %o", error); throw new Error(`Account creation - creating account ${error}`); } }; @@ -3479,20 +3474,20 @@ var create_an_account_default = createAnAccount; // helpers/get-authentication-retries-by-account-id/index.ts var getAuthenticationRetriesByAccountId = async (context, accountId) => { - console.info('Getting authentication retries by account ID'); + console.info("Getting authentication retries by account ID"); try { const retries = await context.db.AuthenticationRetry.findMany({ where: { account: { every: { - id: { equals: accountId }, - }, - }, - }, + id: { equals: accountId } + } + } + } }); return retries; } catch (error) { - console.error('Error getting authentication retries by account ID %o', error); + console.error("Error getting authentication retries by account ID %o", error); throw new Error(`Getting authentication retries by account ID ${error}`); } }; @@ -3500,67 +3495,67 @@ var get_authentication_retries_by_account_id_default = getAuthenticationRetriesB // custom-resolvers/mutations/delete-an-account/index.ts var deleteAnAccount = async (root, variables, context) => { - console.info('Deleting account ', variables.email); + console.info("Deleting account ", variables.email); try { const { email } = variables; - const account2 = await get_account_by_field_default(context, 'email', email); + const account2 = await get_account_by_field_default(context, "email", email); if (!account2) { console.info(`Unable to delete account - account not found`); return { success: false }; } const { id: accountId } = account2; - console.info('Checking authentication retry entries'); + console.info("Checking authentication retry entries"); const retries = await get_authentication_retries_by_account_id_default(context, accountId); if (retries.length) { - console.info('Deleting authentication retry entries'); + console.info("Deleting authentication retry entries"); const retriesArray = retries.map((retry) => ({ - id: retry.id, + id: retry.id })); await context.db.AuthenticationRetry.deleteMany({ - where: retriesArray, + where: retriesArray }); } - console.info('Deleting account %s', accountId); + console.info("Deleting account %s", accountId); await context.db.Account.deleteOne({ where: { - id: accountId, - }, + id: accountId + } }); return { - success: true, + success: true }; } catch (error) { - console.error('Error deleting account %o', error); + console.error("Error deleting account %o", error); throw new Error(`Deleting account ${error}`); } }; var delete_an_account_default = deleteAnAccount; // custom-resolvers/mutations/verify-account-email-address/index.ts -var import_date_fns3 = require('date-fns'); +var import_date_fns3 = require("date-fns"); var { ID, EMAIL: EMAIL2, VERIFICATION_EXPIRY } = account_default; var verifyAccountEmailAddress = async (root, variables, context) => { try { - console.info('Verifying account email address'); + console.info("Verifying account email address"); const account2 = await get_account_by_field_default(context, ID, variables.id); if (!account2) { - console.info('Unable to verify account email address - account does not exist'); + console.info("Unable to verify account email address - account does not exist"); return { success: false, - invalid: true, + invalid: true }; } if (account2.verificationHash !== variables.token) { - console.info('Unable to verify account email address - token does not match hash'); + console.info("Unable to verify account email address - token does not match hash"); return { success: false, - invalid: true, + invalid: true }; } if (account2.status.isVerified) { - console.info('Account email address is already verified'); + console.info("Account email address is already verified"); return { - success: true, + success: true }; } const { id } = account2; @@ -3568,30 +3563,30 @@ var verifyAccountEmailAddress = async (root, variables, context) => { const now2 = /* @__PURE__ */ new Date(); const canActivateAccount = (0, import_date_fns3.isBefore)(now2, account2[VERIFICATION_EXPIRY]); if (!canActivateAccount) { - console.info('Unable to verify account email address - verification period has expired'); + console.info("Unable to verify account email address - verification period has expired"); return { expired: true, success: false, - accountId: id, + accountId: id }; } - console.info('Verified account email address - updating account to be verified'); + console.info("Verified account email address - updating account to be verified"); const accountUpdate = { - verificationHash: '', - verificationExpiry: null, + verificationHash: "", + verificationExpiry: null }; const statusUpdate = { - isVerified: true, + isVerified: true }; await update_account_default.account(context, id, accountUpdate); await update_account_default.accountStatus(context, statusId, statusUpdate); return { success: true, accountId: id, - emailRecipient: account2[EMAIL2], + emailRecipient: account2[EMAIL2] }; } catch (error) { - console.error('Error verifying account email address %o', error); + console.error("Error verifying account email address %o", error); throw new Error(`Verifying account email address ${error}`); } }; @@ -3600,14 +3595,14 @@ var verify_account_email_address_default = verifyAccountEmailAddress; // custom-resolvers/mutations/send-email-confirm-email-address/index.ts var sendEmailConfirmEmailAddressMutation = async (root, variables, context) => { try { - console.info('Sending email verification for account creation'); + console.info("Sending email verification for account creation"); const emailResponse = await send_email_confirm_email_address_default.send(context, variables.urlOrigin, variables.accountId); if (emailResponse.success) { return emailResponse; } throw new Error(`Sending email verification for account creation (sendEmailConfirmEmailAddress mutation) ${emailResponse}`); } catch (error) { - console.error('Error sending email verification for account creation (sendEmailConfirmEmailAddress mutation) %o', error); + console.error("Error sending email verification for account creation (sendEmailConfirmEmailAddress mutation) %o", error); throw new Error(`Sending email verification for account creation (sendEmailConfirmEmailAddress mutation) ${error}`); } }; @@ -3616,38 +3611,38 @@ var send_email_confirm_email_address_default2 = sendEmailConfirmEmailAddressMuta // helpers/create-authentication-retry-entry/index.ts var createAuthenticationRetryEntry = async (context, accountId) => { try { - console.info('Creating account authentication retry entry'); + console.info("Creating account authentication retry entry"); const now2 = /* @__PURE__ */ new Date(); const response = await context.db.AuthenticationRetry.createOne({ data: { account: { connect: { - id: accountId, - }, + id: accountId + } }, - createdAt: now2, - }, + createdAt: now2 + } }); if (response.id) { return { - success: true, + success: true }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error creating account authentication retry entry %o', error); + console.error("Error creating account authentication retry entry %o", error); throw new Error(`${error}`); } }; var create_authentication_retry_entry_default = createAuthenticationRetryEntry; // helpers/should-block-account/index.ts -var import_date_fns4 = require('date-fns'); +var import_date_fns4 = require("date-fns"); var { MAX_AUTH_RETRIES, MAX_AUTH_RETRIES_TIMEFRAME } = ACCOUNT2; var shouldBlockAccount = async (context, accountId) => { - console.info('Checking account authentication retries %s', accountId); + console.info("Checking account authentication retries %s", accountId); try { const retries = await get_authentication_retries_by_account_id_default(context, accountId); const now2 = /* @__PURE__ */ new Date(); @@ -3660,12 +3655,12 @@ var shouldBlockAccount = async (context, accountId) => { } }); if (retriesInTimeframe.length >= MAX_AUTH_RETRIES) { - console.info('Account authentication retries exceeds the threshold %s', accountId); + console.info("Account authentication retries exceeds the threshold %s", accountId); return true; } return false; } catch (error) { - console.error('Error checking account authentication retries %o', error); + console.error("Error checking account authentication retries %o", error); throw new Error(`Checking account authentication retries ${error}`); } }; @@ -3673,7 +3668,7 @@ var should_block_account_default = shouldBlockAccount; // helpers/block-account/index.ts var blockAccount = async (context, statusId) => { - console.info('Blocking account %s', statusId); + console.info("Blocking account %s", statusId); try { const statusUpdate = { isBlocked: true }; const result = await update_account_default.accountStatus(context, statusId, statusUpdate); @@ -3682,30 +3677,30 @@ var blockAccount = async (context, statusId) => { } return false; } catch (error) { - console.error('Error blocking account %o', error); + console.error("Error blocking account %o", error); throw new Error(`Blocking account ${error}`); } }; var block_account_default = blockAccount; // custom-resolvers/mutations/account-sign-in/account-sign-in-checks/index.ts -var import_config6 = require('dotenv/config'); +var import_config6 = require("dotenv/config"); // helpers/generate-otp/index.ts -var import_crypto5 = __toESM(require('crypto')); -var import_otplib = require('otplib'); +var import_crypto5 = __toESM(require("crypto")); +var import_otplib = require("otplib"); var { ENCRYPTION: ENCRYPTION4, OTP } = ACCOUNT2; var { RANDOM_BYTES_SIZE: RANDOM_BYTES_SIZE2, STRING_TYPE: STRING_TYPE5, PBKDF2: { ITERATIONS: ITERATIONS5, DIGEST_ALGORITHM: DIGEST_ALGORITHM5 }, OTP: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH5 }, - }, + PBKDF2: { KEY_LENGTH: KEY_LENGTH5 } + } } = ENCRYPTION4; var generateOtp = () => { try { - console.info('Generating OTP'); + console.info("Generating OTP"); const salt = import_crypto5.default.randomBytes(RANDOM_BYTES_SIZE2).toString(STRING_TYPE5); import_otplib.authenticator.options = { digits: OTP.DIGITS }; const securityCode = import_otplib.authenticator.generate(salt); @@ -3715,38 +3710,38 @@ var generateOtp = () => { securityCode, salt, hash, - expiry, + expiry }; } catch (error) { - console.error('Error generating OTP %o', error); + console.error("Error generating OTP %o", error); throw new Error(`Error generating OTP ${error}`); } }; var generate = { - otp: generateOtp, + otp: generateOtp }; var generate_otp_default = generate; // helpers/generate-otp-and-update-account/index.ts var generateOTPAndUpdateAccount = async (context, accountId) => { try { - console.info('Adding OTP to an account'); + console.info("Adding OTP to an account"); const otp = generate_otp_default.otp(); const { securityCode, salt, hash, expiry } = otp; const accountUpdate = { otpSalt: salt, otpHash: hash, - otpExpiry: expiry, + otpExpiry: expiry }; const updatedAccount = await update_account_default.account(context, accountId, accountUpdate); const accountStatusUpdate = { isInactive: false }; await update_account_default.accountStatus(context, String(updatedAccount.statusId), accountStatusUpdate); return { success: true, - securityCode, + securityCode }; } catch (error) { - console.error('Error adding OTP to an account %o', error); + console.error("Error adding OTP to an account %o", error); throw new Error(`Adding OTP to an account ${error}`); } }; @@ -3755,44 +3750,44 @@ var generate_otp_and_update_account_default = generateOTPAndUpdateAccount; // custom-resolvers/mutations/account-sign-in/account-sign-in-checks/index.ts var accountSignInChecks = async (context, account2, urlOrigin) => { try { - console.info('Signing in account - checking account'); + console.info("Signing in account - checking account"); const { NODE_ENV: NODE_ENV3 } = process.env; - const isDevEnvironment3 = NODE_ENV3 === 'development'; + const isDevEnvironment3 = NODE_ENV3 === "development"; const { id: accountId, email } = account2; if (!account2.status.isVerified) { - console.info('Unable to sign in account - account has not been verified yet. Sending a new email verification'); + console.info("Unable to sign in account - account has not been verified yet. Sending a new email verification"); const emailResponse2 = await send_email_confirm_email_address_default.send(context, urlOrigin, accountId); if (emailResponse2?.success) { return { success: false, resentVerificationEmail: true, - accountId, + accountId }; } return { success: false, accountId }; } - console.info('Signing in account - account is verified. Generating and sending an OTP'); + console.info("Signing in account - account is verified. Generating and sending an OTP"); const { securityCode } = await generate_otp_and_update_account_default(context, accountId); const name = get_full_name_string_default(account2); if (isDevEnvironment3) { - console.info('\u2705 Signing in account (dev environment only) - mimicking sending OTP via email %s', securityCode); + console.info("\u2705 Signing in account (dev environment only) - mimicking sending OTP via email %s", securityCode); return { accountId, - success: true, + success: true }; } const emailResponse = await emails_default.accessCodeEmail(email, name, securityCode); if (emailResponse?.success) { return { ...emailResponse, - accountId, + accountId }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error validating password or sending email(s) for account sign in (accountSignIn mutation - account checks) %o', error); + console.error("Error validating password or sending email(s) for account sign in (accountSignIn mutation - account checks) %o", error); throw new Error(`Validating password or sending email(s) for account sign in (accountSignIn mutation - account checks) ${error}`); } }; @@ -3801,26 +3796,26 @@ var account_sign_in_checks_default = accountSignInChecks; // custom-resolvers/mutations/account-sign-in/index.ts var accountSignIn = async (root, variables, context) => { try { - console.info('Signing in account'); + console.info("Signing in account"); const { urlOrigin, email, password: password2 } = variables; const accountData = await get_account_by_field_default(context, account_default.EMAIL, email); if (!accountData) { - console.info('Unable to validate account - no account found'); + console.info("Unable to validate account - no account found"); return { success: false }; } const account2 = accountData; const { id: accountId } = account2; - console.info('Signing in account - account found %s', accountId); + console.info("Signing in account - account found %s", accountId); const { isBlocked } = account2.status; if (isBlocked) { - console.info('Unable to sign in account - account is blocked'); + console.info("Unable to sign in account - account is blocked"); return { success: false, isBlocked: true, accountId }; } if (is_valid_account_password_default(password2, account2.salt, account2.hash)) { - console.info('Signing in account - valid credentials provided'); + console.info("Signing in account - valid credentials provided"); return account_sign_in_checks_default(context, account2, urlOrigin); } - console.info('Signing in account - invalid credentials provided'); + console.info("Signing in account - invalid credentials provided"); const newRetriesEntry = await create_authentication_retry_entry_default(context, accountId); if (!newRetriesEntry.success) { return { success: false }; @@ -3832,14 +3827,14 @@ var accountSignIn = async (root, variables, context) => { return { success: false, isBlocked: true, - accountId, + accountId }; } return { success: false }; } return { success: false }; } catch (error) { - console.error('Error signing into account %o', error); + console.error("Error signing into account %o", error); throw new Error(`Signing in account (accountSignIn mutation) ${error}`); } }; @@ -3848,11 +3843,11 @@ var account_sign_in_default = accountSignIn; // custom-resolvers/mutations/account-sign-in-new-code/index.ts var accountSignInSendNewCode = async (root, variables, context) => { try { - console.info('Generating and sending new sign in code for account'); + console.info("Generating and sending new sign in code for account"); const { accountId } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info('Unable to validate account - no account found'); + console.info("Unable to validate account - no account found"); return { success: false }; } const { securityCode } = await generate_otp_and_update_account_default(context, account2.id); @@ -3862,39 +3857,39 @@ var accountSignInSendNewCode = async (root, variables, context) => { if (emailResponse?.success) { return { ...emailResponse, - accountId: account2.id, + accountId: account2.id }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error generating and sending new sign in code for account (accountSignInSendNewCode mutation) %o', error); + console.error("Error generating and sending new sign in code for account (accountSignInSendNewCode mutation) %o", error); throw new Error(`Generating and sending new sign in code for account (accountSignInSendNewCode mutation) ${error}`); } }; var account_sign_in_new_code_default = accountSignInSendNewCode; // helpers/is-valid-otp/index.ts -var import_crypto6 = __toESM(require('crypto')); +var import_crypto6 = __toESM(require("crypto")); var { ENCRYPTION: ENCRYPTION5 } = ACCOUNT2; var { STRING_TYPE: STRING_TYPE6, PBKDF2: { ITERATIONS: ITERATIONS6, DIGEST_ALGORITHM: DIGEST_ALGORITHM6 }, OTP: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH6 }, - }, + PBKDF2: { KEY_LENGTH: KEY_LENGTH6 } + } } = ENCRYPTION5; var isValidOTP = (securityCode, otpSalt, otpHash) => { try { - console.info('Validating OTP'); + console.info("Validating OTP"); const hashVerify = import_crypto6.default.pbkdf2Sync(securityCode, otpSalt, ITERATIONS6, KEY_LENGTH6, DIGEST_ALGORITHM6).toString(STRING_TYPE6); if (otpHash === hashVerify) { return true; } return false; } catch (error) { - console.error('Error validating OTP %o', error); + console.error("Error validating OTP %o", error); throw new Error(`Error validating OTP ${error}`); } }; @@ -3902,32 +3897,32 @@ var is_valid_otp_default = isValidOTP; // helpers/delete-authentication-retries/index.ts var deleteAuthenticationRetries = async (context, accountId) => { - console.info('Deleting authentication retries for account %s', accountId); + console.info("Deleting authentication retries for account %s", accountId); try { const retries = await get_authentication_retries_by_account_id_default(context, accountId); const retryIds = retries.map((obj) => ({ - id: obj.id, + id: obj.id })); const result = await context.db.AuthenticationRetry.deleteMany({ - where: retryIds, + where: retryIds }); return result; } catch (error) { - console.error('Error deleting authentication retries %o', error); + console.error("Error deleting authentication retries %o", error); throw new Error(`Deleting authentication retries ${error}`); } }; var delete_authentication_retries_default = deleteAuthenticationRetries; // helpers/create-jwt/index.ts -var import_crypto7 = __toESM(require('crypto')); -var import_jsonwebtoken = __toESM(require('jsonwebtoken')); +var import_crypto7 = __toESM(require("crypto")); +var import_jsonwebtoken = __toESM(require("jsonwebtoken")); var { ENCRYPTION: { RANDOM_BYTES_SIZE: RANDOM_BYTES_SIZE3, STRING_TYPE: STRING_TYPE7 }, JWT: { KEY: { SIGNATURE, ENCODING, STRING_ENCODING }, - TOKEN: { EXPIRY, ALGORITHM }, - }, + TOKEN: { EXPIRY, ALGORITHM } + } } = ACCOUNT2; var PRIV_KEY = Buffer.from(SIGNATURE, ENCODING).toString(STRING_ENCODING); var createJWT = (accountId) => { @@ -3935,62 +3930,62 @@ var createJWT = (accountId) => { const expiresIn = EXPIRY; const payload = { sub: accountId, - sessionIdentifier, + sessionIdentifier }; const signedToken = import_jsonwebtoken.default.sign(payload, PRIV_KEY, { expiresIn, algorithm: ALGORITHM }); return { token: `Bearer ${signedToken}`, expires: expiresIn, - sessionIdentifier, + sessionIdentifier }; }; var create = { - JWT: createJWT, + JWT: createJWT }; var create_jwt_default = create; // custom-resolvers/mutations/verify-account-sign-in-code/index.ts var { - JWT: { SESSION_EXPIRY }, + JWT: { SESSION_EXPIRY } } = ACCOUNT2; var verifyAccountSignInCode = async (root, variables, context) => { try { - console.info('Verifying account sign in code'); + console.info("Verifying account sign in code"); const { accountId, securityCode } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info('Unable to verify account sign in code - no account exists with the provided ID'); + console.info("Unable to verify account sign in code - no account exists with the provided ID"); return { - success: false, + success: false }; } if (!account2.otpSalt || !account2.otpHash || !account2.otpExpiry) { - console.info('Unable to verify account sign in code - no OTP available for this account'); + console.info("Unable to verify account sign in code - no OTP available for this account"); return { - success: false, + success: false }; } const { otpSalt, otpHash, otpExpiry } = account2; const hasExpired = dateIsInThePast(otpExpiry); if (hasExpired) { - console.info('Unable to verify account sign in code - verification period has expired'); + console.info("Unable to verify account sign in code - verification period has expired"); return { success: false, - expired: true, + expired: true }; } const isValid = otpSalt && otpHash && is_valid_otp_default(securityCode, otpSalt, otpHash); if (isValid) { - console.info('Verified account sign in code - creating JWT and updating account'); + console.info("Verified account sign in code - creating JWT and updating account"); await delete_authentication_retries_default(context, accountId); const jwt = create_jwt_default.JWT(accountId); const { sessionIdentifier } = jwt; const accountUpdate = { sessionIdentifier, sessionExpiry: SESSION_EXPIRY(), - otpSalt: '', - otpHash: '', - otpExpiry: null, + otpSalt: "", + otpHash: "", + otpExpiry: null }; await update_account_default.account(context, accountId, accountUpdate); return { @@ -4000,14 +3995,14 @@ var verifyAccountSignInCode = async (root, variables, context) => { firstName: account2.firstName, email: account2.email, ...jwt, - expires: accountUpdate.sessionExpiry, + expires: accountUpdate.sessionExpiry }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error verifying account sign in code and generating JWT (verifyAccountSignInCode mutation) %o', error); + console.error("Error verifying account sign in code and generating JWT (verifyAccountSignInCode mutation) %o", error); throw new Error(`Verifying account sign in code and generating JWT (verifyAccountSignInCode mutation) ${error}`); } }; @@ -4016,43 +4011,43 @@ var verify_account_sign_in_code_default = verifyAccountSignInCode; // custom-resolvers/mutations/add-and-get-OTP/index.ts var addAndGetOTP = async (root, variables, context) => { try { - console.info('Adding OTP to an account'); + console.info("Adding OTP to an account"); const { email } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (!account2) { - console.info('Unable to generate and add OTP to an account - no account found'); + console.info("Unable to generate and add OTP to an account - no account found"); return { success: false }; } const { securityCode } = await generate_otp_and_update_account_default(context, account2.id); return { success: true, - securityCode, + securityCode }; } catch (error) { - console.error('Error adding OTP to an account (addAndGetOTP mutation) %o', error); + console.error("Error adding OTP to an account (addAndGetOTP mutation) %o", error); throw new Error(`Adding OTP to an account (addAndGetOTP mutation) ${error}`); } }; var add_and_get_OTP_default = addAndGetOTP; // custom-resolvers/mutations/send-email-password-reset-link/index.ts -var import_crypto8 = __toESM(require('crypto')); +var import_crypto8 = __toESM(require("crypto")); var { ENCRYPTION: { STRING_TYPE: STRING_TYPE8, PBKDF2: { ITERATIONS: ITERATIONS7, DIGEST_ALGORITHM: DIGEST_ALGORITHM7 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH7 }, - }, - }, + PBKDF2: { KEY_LENGTH: KEY_LENGTH7 } + } + } } = ACCOUNT2; var sendEmailPasswordResetLink = async (root, variables, context) => { try { - console.info('Received a password reset request - checking account'); + console.info("Received a password reset request - checking account"); const { urlOrigin, email } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (!account2) { - console.info('Unable to check account and send password reset email - no account found'); + console.info("Unable to check account and send password reset email - no account found"); return { success: false }; } const { id: accountId } = account2; @@ -4069,23 +4064,23 @@ var sendEmailPasswordResetLink = async (root, variables, context) => { return { success: false, isBlocked: true, - accountId, + accountId }; } } catch (error) { - console.error('Error blocking account $O', error); + console.error("Error blocking account $O", error); return { success: false }; } } - console.info('Generating password reset hash'); + console.info("Generating password reset hash"); const passwordResetHash = import_crypto8.default.pbkdf2Sync(email, account2.salt, ITERATIONS7, KEY_LENGTH7, DIGEST_ALGORITHM7).toString(STRING_TYPE8); const accountUpdate = { passwordResetHash, - passwordResetExpiry: ACCOUNT2.PASSWORD_RESET_EXPIRY(), + passwordResetExpiry: ACCOUNT2.PASSWORD_RESET_EXPIRY() }; - console.info('Updating account for password reset'); + console.info("Updating account for password reset"); await update_account_default.account(context, accountId, accountUpdate); - console.info('Sending password reset email'); + console.info("Sending password reset email"); const name = get_full_name_string_default(account2); const emailResponse = await emails_default.passwordResetLink(urlOrigin, email, name, passwordResetHash); if (emailResponse?.success) { @@ -4093,7 +4088,7 @@ var sendEmailPasswordResetLink = async (root, variables, context) => { } return { success: false }; } catch (error) { - console.error('Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) $O', error); + console.error("Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) $O", error); throw new Error(`Checking account and sending password reset email (sendEmailPasswordResetLink mutation) ${error}`); } }; @@ -4101,17 +4096,17 @@ var send_email_password_reset_link_default = sendEmailPasswordResetLink; // helpers/account-has-used-password-before/index.ts var hasAccountUsedPasswordBefore = async (context, accountId, newPassword) => { - console.info('Checking if an account has used a password before'); + console.info("Checking if an account has used a password before"); try { let usedBefore = false; const previousHashes = await context.db.Authentication.findMany({ where: { account: { every: { - id: { equals: accountId }, - }, - }, - }, + id: { equals: accountId } + } + } + } }); if (previousHashes.length) { previousHashes.forEach((previous) => { @@ -4123,7 +4118,7 @@ var hasAccountUsedPasswordBefore = async (context, accountId, newPassword) => { } return usedBefore; } catch (error) { - console.error('Error checking if an account has used a password before %o', error); + console.error("Error checking if an account has used a password before %o", error); throw new Error(`Checking if an account has used a password before ${error}`); } }; @@ -4131,17 +4126,17 @@ var account_has_used_password_before_default = hasAccountUsedPasswordBefore; // helpers/create-authentication-entry/index.ts var createAuthenticationEntry = async (context, entry) => { - console.info('Creating authentication entry'); + console.info("Creating authentication entry"); try { const result = await context.db.Authentication.createOne({ data: { ...entry, - createdAt: /* @__PURE__ */ new Date(), - }, + createdAt: /* @__PURE__ */ new Date() + } }); return result; } catch (error) { - console.error('Error creating authentication entry %o', error); + console.error("Error creating authentication entry %o", error); throw new Error(`Creating authentication entry ${error}`); } }; @@ -4149,75 +4144,75 @@ var create_authentication_entry_default = createAuthenticationEntry; // custom-resolvers/mutations/account-password-reset/index.ts var accountPasswordReset = async (root, variables, context) => { - console.info('Resetting account password'); + console.info("Resetting account password"); try { const { token, password: newPassword } = variables; const account2 = await get_account_by_field_default(context, account_default.PASSWORD_RESET_HASH, token); if (!account2) { - console.info('Unable to reset account password - account does not exist'); + console.info("Unable to reset account password - account does not exist"); return { success: false }; } const { - status: { isBlocked }, + status: { isBlocked } } = account2; if (isBlocked) { - console.info('Unable to reset account password - account is blocked'); + console.info("Unable to reset account password - account is blocked"); return { success: false }; } const { id: accountId, passwordResetHash, passwordResetExpiry, salt: currentSalt, hash: currentHash } = account2; if (!passwordResetHash || !passwordResetExpiry) { - console.info('Unable to reset account password - reset hash or expiry does not exist'); + console.info("Unable to reset account password - reset hash or expiry does not exist"); return { success: false }; } const hasExpired = dateIsInThePast(passwordResetExpiry); if (hasExpired) { - console.info('Unable to reset account password - verification period has expired'); + console.info("Unable to reset account password - verification period has expired"); return { success: false, - expired: true, + expired: true }; } const newHashCurrentSalt = get_password_hash_default(newPassword, currentSalt); const passwordIsTheSame = newHashCurrentSalt === currentHash; if (passwordIsTheSame) { - console.info('Unable to reset account password - provided password is the same'); + console.info("Unable to reset account password - provided password is the same"); return { success: false, - hasBeenUsedBefore: true, + hasBeenUsedBefore: true }; } const usedPasswordBefore = await account_has_used_password_before_default(context, accountId, newPassword); if (usedPasswordBefore) { - console.info('Unable to reset account password - provided password has been used before'); + console.info("Unable to reset account password - provided password has been used before"); return { success: false, - hasBeenUsedBefore: true, + hasBeenUsedBefore: true }; } await delete_authentication_retries_default(context, accountId); const authEntry = { account: { connect: { - id: accountId, - }, + id: accountId + } }, salt: currentSalt, - hash: currentHash, + hash: currentHash }; await create_authentication_entry_default(context, authEntry); const { salt: newSalt, hash: newHash } = encrypt_password_default(newPassword); const accountUpdate = { salt: newSalt, hash: newHash, - passwordResetHash: '', - passwordResetExpiry: null, + passwordResetHash: "", + passwordResetExpiry: null }; await update_account_default.account(context, accountId, accountUpdate); return { - success: true, + success: true }; } catch (error) { - console.error('Error resetting account password %o', error); + console.error("Error resetting account password %o", error); throw new Error(`Resetting account password ${error}`); } }; @@ -4226,18 +4221,18 @@ var account_password_reset_default = accountPasswordReset; // custom-resolvers/mutations/send-email-reactivate-account-link/index.ts var sendEmailReactivateAccountLink = async (root, variables, context) => { try { - console.info('Received a request to send reactivate account email/link - checking account'); + console.info("Received a request to send reactivate account email/link - checking account"); const reactiveAccountResponse = await send_email_reactivate_account_link_default.send(variables, context); return reactiveAccountResponse; } catch (error) { - console.error('Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink mutation) %o', error); + console.error("Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink mutation) %o", error); throw new Error(`Checking account and sending reactivate account email/link (sendEmailReactivateAccountLink mutation) ${error}`); } }; var send_email_reactivate_account_link_default2 = sendEmailReactivateAccountLink; // helpers/create-an-application/create-initial-application/index.ts -var import_date_fns5 = require('date-fns'); +var import_date_fns5 = require("date-fns"); // constants/application/initial-application-data/index.ts var { STATUS, LATEST_VERSION_NUMBER: LATEST_VERSION_NUMBER2, DEAL_TYPE, SUBMISSION_COUNT_DEFAULT } = APPLICATION; @@ -4245,7 +4240,7 @@ var INITIAL_APPLICATION_DATA = { status: STATUS.IN_PROGRESS, version: LATEST_VERSION_NUMBER2, dealType: DEAL_TYPE, - submissionCount: SUBMISSION_COUNT_DEFAULT, + submissionCount: SUBMISSION_COUNT_DEFAULT }; var initial_application_data_default = INITIAL_APPLICATION_DATA; @@ -4254,50 +4249,50 @@ var { STATUS: STATUS2, SUBMISSION_DEADLINE_IN_MONTHS, SUBMISSION_TYPE: SUBMISSIO var { status: inititalStatus, ...APPLICATION_FIELDS } = initial_application_data_default; var createInitialApplication = async ({ context, accountId, status = STATUS2.IN_PROGRESS }) => { try { - console.info('Creating initial application (createInitialApplication helper) for user %s', accountId); + console.info("Creating initial application (createInitialApplication helper) for user %s", accountId); const now2 = /* @__PURE__ */ new Date(); const application2 = await context.db.Application.createOne({ data: { owner: { - connect: { id: accountId }, + connect: { id: accountId } }, createdAt: now2, status, submissionDeadline: (0, import_date_fns5.addMonths)(new Date(now2), SUBMISSION_DEADLINE_IN_MONTHS), submissionType: SUBMISSION_TYPE2.MIA, updatedAt: now2, - ...APPLICATION_FIELDS, - }, + ...APPLICATION_FIELDS + } }); return application2; } catch (error) { - console.error('Error creating initial application (createInitialApplication helper) for user %s %o', accountId, error); + console.error("Error creating initial application (createInitialApplication helper) for user %s %o", accountId, error); throw new Error(`Creating initial application (createInitialApplication helper) for user ${accountId} ${error}`); } }; var initialApplication = { - create: createInitialApplication, + create: createInitialApplication }; var create_initial_application_default = initialApplication; // helpers/get-country-by-field/index.ts var getCountryByField = async (context, field, value) => { try { - console.info('Getting country by field/value'); + console.info("Getting country by field/value"); const countriesArray = await context.db.Country.findMany({ where: { - [field]: { equals: value }, + [field]: { equals: value } }, - take: 1, + take: 1 }); if (!countriesArray?.length || !countriesArray[0]) { - console.info('Getting country by field - no country exists with the provided field/value'); + console.info("Getting country by field - no country exists with the provided field/value"); return false; } const country = countriesArray[0]; return country; } catch (error) { - console.error('Error getting country by field/value %o', error); + console.error("Error getting country by field/value %o", error); throw new Error(`Getting country by field/value ${error}`); } }; @@ -4306,21 +4301,21 @@ var get_country_by_field_default = getCountryByField; // helpers/get-cover-period-value-by-field/index.ts var getCoverPeriodValueByField = async (context, field, value) => { try { - console.info('Getting coverPeriod by field/value $s %s %d', field, value); + console.info("Getting coverPeriod by field/value $s %s %d", field, value); const coverPeriodsArray = await context.db.CoverPeriod.findMany({ where: { - [field]: { equals: value }, + [field]: { equals: value } }, - take: 1, + take: 1 }); if (!coverPeriodsArray?.length || !coverPeriodsArray[0]) { - console.info('Getting coverPeriod by field - no coverPeriod exists with the provided field/value'); + console.info("Getting coverPeriod by field - no coverPeriod exists with the provided field/value"); return false; } const [coverPeriod] = coverPeriodsArray; return coverPeriod; } catch (error) { - console.error('Error getting coverPeriod by field/value %o', error); + console.error("Error getting coverPeriod by field/value %o", error); throw new Error(`Getting coverPeriod by field/value ${error}`); } }; @@ -4329,21 +4324,21 @@ var get_cover_period_value_by_field_default = getCoverPeriodValueByField; // helpers/get-total-contract-value-by-field/index.ts var getTotalContractValueByField = async (context, field, value) => { try { - console.info('Getting totalContractValue by field/value $s %s, %s', field, value); + console.info("Getting totalContractValue by field/value $s %s, %s", field, value); const totalContractValuesArray = await context.db.TotalContractValue.findMany({ where: { - [field]: { equals: value }, + [field]: { equals: value } }, - take: 1, + take: 1 }); if (!totalContractValuesArray?.length || !totalContractValuesArray[0]) { - console.info('Getting totalContractValue by field - no totalContractValue exists with the provided field/value'); + console.info("Getting totalContractValue by field - no totalContractValue exists with the provided field/value"); return false; } const [totalContractValue] = totalContractValuesArray; return totalContractValue; } catch (error) { - console.error('Error getting totalContractValue by field/value %o', error); + console.error("Error getting totalContractValue by field/value %o", error); throw new Error(`Getting totalContractValue by field/value ${error}`); } }; @@ -4351,20 +4346,20 @@ var get_total_contract_value_by_field_default = getTotalContractValueByField; // helpers/create-a-reference-number/index.ts var createAReferenceNumber = async (context, applicationId) => { - console.info('Creating a reference number for %s', applicationId); + console.info("Creating a reference number for %s", applicationId); try { const created = await context.db.ReferenceNumber.createOne({ data: { application: { connect: { - id: applicationId, - }, - }, - }, + id: applicationId + } + } + } }); return created.id; } catch (error) { - console.error('Error creating a reference number %o', error); + console.error("Error creating a reference number %o", error); throw new Error(`Creating a reference number ${error}`); } }; @@ -4372,18 +4367,18 @@ var create_a_reference_number_default = createAReferenceNumber; // helpers/create-a-broker/index.ts var createABroker = async (context, applicationId) => { - console.info('Creating a broker for %s', applicationId); + console.info("Creating a broker for %s", applicationId); try { const broker = await context.db.Broker.createOne({ data: { application: { - connect: { id: applicationId }, - }, - }, + connect: { id: applicationId } + } + } }); return broker; } catch (error) { - console.error('Error creating a broker %o', error); + console.error("Error creating a broker %o", error); throw new Error(`Creating a broker ${error}`); } }; @@ -4391,18 +4386,18 @@ var create_a_broker_default = createABroker; // helpers/create-a-business/index.ts var createABusiness = async (context, applicationId) => { - console.info('Creating a business for %s', applicationId); + console.info("Creating a business for %s", applicationId); try { const business = await context.db.Business.createOne({ data: { application: { - connect: { id: applicationId }, - }, - }, + connect: { id: applicationId } + } + } }); return business; } catch (error) { - console.error('Error creating a business %o', error); + console.error("Error creating a business %o", error); throw new Error(`Creating a business ${error}`); } }; @@ -4410,26 +4405,26 @@ var create_a_business_default = createABusiness; // helpers/create-a-buyer-trading-history/index.ts var createABuyerTradingHistory = async (context, buyerId, applicationId) => { - console.info('Creating a buyer trading history for %s', buyerId); + console.info("Creating a buyer trading history for %s", buyerId); try { const buyerTradingHistory = await context.db.BuyerTradingHistory.createOne({ data: { buyer: { connect: { - id: buyerId, - }, + id: buyerId + } }, application: { connect: { - id: applicationId, - }, + id: applicationId + } }, - currencyCode: APPLICATION.DEFAULT_CURRENCY, - }, + currencyCode: APPLICATION.DEFAULT_CURRENCY + } }); return buyerTradingHistory; } catch (error) { - console.error('Error creating a buyer trading history %o', error); + console.error("Error creating a buyer trading history %o", error); throw new Error(`Creating a buyer trading history ${error}`); } }; @@ -4437,25 +4432,25 @@ var create_a_buyer_trading_history_default = createABuyerTradingHistory; // helpers/create-a-buyer-contact/index.ts var createABuyerContact = async (context, buyerId, applicationId) => { - console.info('Creating a buyer contact for %s', buyerId); + console.info("Creating a buyer contact for %s", buyerId); try { const buyerContact = await context.db.BuyerContact.createOne({ data: { buyer: { connect: { - id: buyerId, - }, + id: buyerId + } }, application: { connect: { - id: applicationId, - }, - }, - }, + id: applicationId + } + } + } }); return buyerContact; } catch (error) { - console.error('Error creating a buyer contact %o', error); + console.error("Error creating a buyer contact %o", error); throw new Error(`Creating a buyer contact ${error}`); } }; @@ -4463,25 +4458,25 @@ var create_a_buyer_contact_default = createABuyerContact; // helpers/create-a-buyer-relationship/index.ts var createABuyerRelationship = async (context, buyerId, applicationId) => { - console.info('Creating a buyer relationship for %s', buyerId); + console.info("Creating a buyer relationship for %s", buyerId); try { const buyerRelationship = await context.db.BuyerRelationship.createOne({ data: { buyer: { connect: { - id: buyerId, - }, + id: buyerId + } }, application: { connect: { - id: applicationId, - }, - }, - }, + id: applicationId + } + } + } }); return buyerRelationship; } catch (error) { - console.error('Error creating a buyer relationship %o', error); + console.error("Error creating a buyer relationship %o", error); throw new Error(`Creating a buyer relationship ${error}`); } }; @@ -4489,17 +4484,17 @@ var create_a_buyer_relationship_default = createABuyerRelationship; // helpers/create-a-populated-buyer/index.ts var createAPopulatedBuyer = async (context, countryId, applicationId) => { - console.info('Creating a buyer for %s', applicationId); + console.info("Creating a buyer for %s", applicationId); try { const buyer = await context.db.Buyer.createOne({ data: { country: { - connect: { id: countryId }, + connect: { id: countryId } }, application: { - connect: { id: applicationId }, - }, - }, + connect: { id: applicationId } + } + } }); const buyerTradingHistory = await create_a_buyer_trading_history_default(context, buyer.id, applicationId); const buyerRelationship = await create_a_buyer_relationship_default(context, buyer.id, applicationId); @@ -4508,36 +4503,35 @@ var createAPopulatedBuyer = async (context, countryId, applicationId) => { ...buyer, buyerTradingHistory, relationship: buyerRelationship, - buyerContact, + buyerContact }; } catch (error) { - console.error('Error creating a populated buyer %o', error); + console.error("Error creating a populated buyer %o", error); throw new Error(`Creating a populated buyer ${error}`); } }; var create_a_populated_buyer_default = createAPopulatedBuyer; // helpers/create-a-declaration-version/index.ts -var { ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, CONFIDENTIALITY, CONFIRMATION_AND_ACKNOWLEDGEMENTS } = - declarations_default2.LATEST_DECLARATIONS; +var { ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, CONFIDENTIALITY, CONFIRMATION_AND_ACKNOWLEDGEMENTS } = declarations_default2.LATEST_DECLARATIONS; var createADeclarationVersion = async (context, declarationId) => { - console.info('Creating an application declaration version for %s', declarationId); + console.info("Creating an application declaration version for %s", declarationId); try { const declaration = await context.db.DeclarationVersion.createOne({ data: { declaration: { - connect: { id: declarationId }, + connect: { id: declarationId } }, agreeToAntiBribery: ANTI_BRIBERY, agreeToConfidentiality: CONFIDENTIALITY, agreeToConfirmationAndAcknowledgements: CONFIRMATION_AND_ACKNOWLEDGEMENTS, hasAntiBriberyCodeOfConduct: ANTI_BRIBERY_CODE_OF_CONDUCT, - willExportWithAntiBriberyCodeOfConduct: ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, - }, + willExportWithAntiBriberyCodeOfConduct: ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT + } }); return declaration; } catch (error) { - console.error('Error creating an application declaration version %o', error); + console.error("Error creating an application declaration version %o", error); throw new Error(`Creating an application declaration version ${error}`); } }; @@ -4545,22 +4539,22 @@ var create_a_declaration_version_default = createADeclarationVersion; // helpers/create-a-declaration/index.ts var createADeclaration = async (context, applicationId) => { - console.info('Creating an application declaration for %s', applicationId); + console.info("Creating an application declaration for %s", applicationId); try { const declaration = await context.db.Declaration.createOne({ data: { application: { - connect: { id: applicationId }, - }, - }, + connect: { id: applicationId } + } + } }); const declarationVersion = await create_a_declaration_version_default(context, declaration.id); return { ...declaration, - declarationVersion, + declarationVersion }; } catch (error) { - console.error('Error creating an application declaration %o', error); + console.error("Error creating an application declaration %o", error); throw new Error(`Creating an application declaration ${error}`); } }; @@ -4568,28 +4562,28 @@ var create_a_declaration_default = createADeclaration; // helpers/create-an-eligibility/index.ts var createAnEligibility = async (context, countryId, applicationId, coverPeriodId, totalContractValueId, eligibilityData) => { - console.info('Creating an eligibility for %s', applicationId); + console.info("Creating an eligibility for %s", applicationId); try { const eligibility = await context.db.Eligibility.createOne({ data: { buyerCountry: { - connect: { id: countryId }, + connect: { id: countryId } }, application: { - connect: { id: applicationId }, + connect: { id: applicationId } }, coverPeriod: { - connect: { id: coverPeriodId }, + connect: { id: coverPeriodId } }, totalContractValue: { - connect: { id: totalContractValueId }, + connect: { id: totalContractValueId } }, - ...eligibilityData, - }, + ...eligibilityData + } }); return eligibility; } catch (error) { - console.error('Error creating an eligibility %o', error); + console.error("Error creating an eligibility %o", error); throw new Error(`Creating an eligibility ${error}`); } }; @@ -4597,18 +4591,18 @@ var create_an_eligibility_default = createAnEligibility; // helpers/create-a-jointly-insured-party/index.ts var createAJointlyInsuredParty = async (context, policyId) => { - console.info('Creating a jointly insured party for %s', policyId); + console.info("Creating a jointly insured party for %s", policyId); try { const jointlyInsuredParty = await context.db.JointlyInsuredParty.createOne({ data: { policy: { - connect: { id: policyId }, - }, - }, + connect: { id: policyId } + } + } }); return jointlyInsuredParty; } catch (error) { - console.error('Error creating a jointly insured party %o', error); + console.error("Error creating a jointly insured party %o", error); throw new Error(`Creating a jointly insured party ${error}`); } }; @@ -4616,23 +4610,23 @@ var create_a_jointly_insured_party_default = createAJointlyInsuredParty; // helpers/create-a-policy/index.ts var createAPolicy = async (context, applicationId) => { - console.info('Creating a policy for %s', applicationId); + console.info("Creating a policy for %s", applicationId); try { const policy = await context.db.Policy.createOne({ data: { application: { - connect: { id: applicationId }, + connect: { id: applicationId } }, - needPreCreditPeriodCover: APPLICATION.DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER, - }, + needPreCreditPeriodCover: APPLICATION.DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER + } }); const jointlyInsuredParty = await create_a_jointly_insured_party_default(context, policy.id); return { ...policy, - jointlyInsuredParty, + jointlyInsuredParty }; } catch (error) { - console.error('Error creating a policy %o', error); + console.error("Error creating a policy %o", error); throw new Error(`Creating a policy ${error}`); } }; @@ -4640,18 +4634,18 @@ var create_a_policy_default = createAPolicy; // helpers/create-a-policy-contact/index.ts var createAPolicyContact = async (context, applicationId) => { - console.info('Creating a policy contact for %s', applicationId); + console.info("Creating a policy contact for %s", applicationId); try { const policyContact = await context.db.PolicyContact.createOne({ data: { application: { - connect: { id: applicationId }, - }, - }, + connect: { id: applicationId } + } + } }); return policyContact; } catch (error) { - console.error('Error creating a policy contact %o', error); + console.error("Error creating a policy contact %o", error); throw new Error(`Creating a policy contact ${error}`); } }; @@ -4659,28 +4653,28 @@ var create_a_policy_contact_default = createAPolicyContact; // helpers/create-a-loss-payee-financial-international/index.ts var createALossPayeeFinancialInternational = async (context, lossPayeeId) => { - console.info('Creating a loss payee financial (international) for %s', lossPayeeId); + console.info("Creating a loss payee financial (international) for %s", lossPayeeId); try { const lossPayeeFinancialInternational = await context.db.LossPayeeFinancialInternational.createOne({ data: { lossPayee: { - connect: { id: lossPayeeId }, - }, - }, + connect: { id: lossPayeeId } + } + } }); const vector = await context.db.LossPayeeFinancialInternationalVector.createOne({ data: { financialInternational: { - connect: { id: lossPayeeFinancialInternational.id }, - }, - }, + connect: { id: lossPayeeFinancialInternational.id } + } + } }); return { ...lossPayeeFinancialInternational, - vector, + vector }; } catch (error) { - console.error('Error creating a loss payee financial (international) for %o', error); + console.error("Error creating a loss payee financial (international) for %o", error); throw new Error(`Creating a loss payee financial (international) for ${error}`); } }; @@ -4688,28 +4682,28 @@ var create_a_loss_payee_financial_international_default = createALossPayeeFinanc // helpers/create-a-loss-payee-financial-uk/index.ts var createALossPayeeFinancialUk = async (context, lossPayeeId) => { - console.info('Creating a loss payee financial (UK) for %s', lossPayeeId); + console.info("Creating a loss payee financial (UK) for %s", lossPayeeId); try { const lossPayeeFinancialUk = await context.db.LossPayeeFinancialUk.createOne({ data: { lossPayee: { - connect: { id: lossPayeeId }, - }, - }, + connect: { id: lossPayeeId } + } + } }); const vector = await context.db.LossPayeeFinancialUkVector.createOne({ data: { financialUk: { - connect: { id: lossPayeeFinancialUk.id }, - }, - }, + connect: { id: lossPayeeFinancialUk.id } + } + } }); return { ...lossPayeeFinancialUk, - vector, + vector }; } catch (error) { - console.error('Error creating a loss payee financial (UK) for %o', error); + console.error("Error creating a loss payee financial (UK) for %o", error); throw new Error(`Creating a loss payee financial (UK) for ${error}`); } }; @@ -4717,20 +4711,20 @@ var create_a_loss_payee_financial_uk_default = createALossPayeeFinancialUk; // helpers/create-a-nominated-loss-payee/index.ts var createANominatedLossPayee = async (context, applicationId) => { - console.info('Creating a nominated loss payee for %s', applicationId); + console.info("Creating a nominated loss payee for %s", applicationId); try { const nominatedLossPayee = await context.db.NominatedLossPayee.createOne({ data: { application: { - connect: { id: applicationId }, - }, - }, + connect: { id: applicationId } + } + } }); await create_a_loss_payee_financial_international_default(context, nominatedLossPayee.id); await create_a_loss_payee_financial_uk_default(context, nominatedLossPayee.id); return nominatedLossPayee; } catch (error) { - console.error('Error creating a nominated loss payee for %o', error); + console.error("Error creating a nominated loss payee for %o", error); throw new Error(`Creating a nominated loss payee for ${error}`); } }; @@ -4738,21 +4732,21 @@ var create_a_nominated_loss_payee_default = createANominatedLossPayee; // helpers/create-a-company-address/index.ts var createACompanyAddress = async (context, addressData, companyId) => { - console.info('Creating a company address for %s', companyId); + console.info("Creating a company address for %s", companyId); try { const companyAddress = await context.db.CompanyAddress.createOne({ data: { company: { connect: { - id: companyId, - }, + id: companyId + } }, - ...addressData, - }, + ...addressData + } }); return companyAddress; } catch (error) { - console.error('Error creating a company address %o', error); + console.error("Error creating a company address %o", error); throw new Error(`Creating a company address ${error}`); } }; @@ -4765,7 +4759,7 @@ var mapSicCodes = (sicCodes, industrySectorNames2, companyId) => { return mapped; } sicCodes.forEach((code, index) => { - let industrySectorName = ''; + let industrySectorName = ""; if (industrySectorNames2?.[index]) { industrySectorName = industrySectorNames2[index]; } @@ -4774,9 +4768,9 @@ var mapSicCodes = (sicCodes, industrySectorNames2, companyId) => { industrySectorName, company: { connect: { - id: companyId, - }, - }, + id: companyId + } + } }; mapped.push(mappedCode); }); @@ -4786,18 +4780,18 @@ var map_sic_codes_default = mapSicCodes; // helpers/create-company-sic-codes/index.ts var createCompanySicCodes = async (context, companyId, sicCodes, industrySectorNames2) => { - console.info('Creating company SIC codes for %s', companyId); + console.info("Creating company SIC codes for %s", companyId); try { if (sicCodes?.length) { const mappedSicCodes = map_sic_codes_default(sicCodes, industrySectorNames2, companyId); const createdSicCodes = await context.db.CompanySicCode.createMany({ - data: mappedSicCodes, + data: mappedSicCodes }); return createdSicCodes; } return []; } catch (error) { - console.error('Error creating company SIC codes for %s %o', companyId, error); + console.error("Error creating company SIC codes for %s %o", companyId, error); throw new Error(`Creating company SIC codes for ${companyId} ${error}`); } }; @@ -4805,20 +4799,20 @@ var create_company_sic_codes_default = createCompanySicCodes; // helpers/create-a-company-different-trading-address/index.ts var createACompanyDifferentTradingAddress = async (context, companyId) => { - console.info('Creating a different trading address for %s', companyId); + console.info("Creating a different trading address for %s", companyId); try { const differentTradingAddress = await context.db.CompanyDifferentTradingAddress.createOne({ data: { company: { connect: { - id: companyId, - }, - }, - }, + id: companyId + } + } + } }); return differentTradingAddress; } catch (error) { - console.error('Error creating a company different trading address %o', error); + console.error("Error creating a company different trading address %o", error); throw new Error(`Creating a company different trading address ${error}`); } }; @@ -4826,16 +4820,16 @@ var create_a_company_different_trading_address_default = createACompanyDifferent // helpers/create-a-company/index.ts var createACompany = async (context, applicationId, companyData) => { - console.info('Creating a company, address and SIC codes for %s', applicationId); + console.info("Creating a company, address and SIC codes for %s", applicationId); try { const { registeredOfficeAddress, sicCodes, industrySectorNames: industrySectorNames2, ...companyFields } = companyData; const company = await context.db.Company.createOne({ data: { application: { - connect: { id: applicationId }, + connect: { id: applicationId } }, - ...companyFields, - }, + ...companyFields + } }); const companyAddress = await create_a_company_address_default(context, registeredOfficeAddress, company.id); const createdSicCodes = await create_company_sic_codes_default(context, company.id, sicCodes, industrySectorNames2); @@ -4844,10 +4838,10 @@ var createACompany = async (context, applicationId, companyData) => { ...company, registeredOfficeAddress: companyAddress, sicCodes: createdSicCodes, - differentTradingAddress: createdDifferentTradingAddress, + differentTradingAddress: createdDifferentTradingAddress }; } catch (error) { - console.error('Error creating a company, address, SIC codes and company different trading address %o', error); + console.error("Error creating a company, address, SIC codes and company different trading address %o", error); throw new Error(`Creating a company, address, SIC codes and company different trading address ${error}`); } }; @@ -4855,18 +4849,18 @@ var create_a_company_default = createACompany; // helpers/create-a-private-market/index.ts var createAPrivateMarket = async (context, exportContractId) => { - console.info('Creating a private market for %s', exportContractId); + console.info("Creating a private market for %s", exportContractId); try { const privateMarket = await context.db.PrivateMarket.createOne({ data: { exportContract: { - connect: { id: exportContractId }, - }, - }, + connect: { id: exportContractId } + } + } }); return privateMarket; } catch (error) { - console.error('Error creating a private market %o', error); + console.error("Error creating a private market %o", error); throw new Error(`Creating a private market ${error}`); } }; @@ -4874,18 +4868,18 @@ var create_a_private_market_default = createAPrivateMarket; // helpers/create-an-export-contract-agent-service/index.ts var createAnExportContractAgentService = async (context, agentId) => { - console.info('Creating an export contract agent service for %s', agentId); + console.info("Creating an export contract agent service for %s", agentId); try { const agentService = await context.db.ExportContractAgentService.createOne({ data: { agent: { - connect: { id: agentId }, - }, - }, + connect: { id: agentId } + } + } }); return agentService; } catch (error) { - console.error('Error creating an export contract agent service %o', error); + console.error("Error creating an export contract agent service %o", error); throw new Error(`Creating an export contract agent service ${error}`); } }; @@ -4893,18 +4887,18 @@ var create_an_export_contract_agent_service_default = createAnExportContractAgen // helpers/create-an-export-contract-agent-service-charge/index.ts var createAnExportContractAgentServiceCharge = async (context, agentServiceId) => { - console.info('Creating an export contract agent service charge for %s', agentServiceId); + console.info("Creating an export contract agent service charge for %s", agentServiceId); try { const agentService = await context.db.ExportContractAgentServiceCharge.createOne({ data: { service: { - connect: { id: agentServiceId }, - }, - }, + connect: { id: agentServiceId } + } + } }); return agentService; } catch (error) { - console.error('Error creating an export contract agent service charge %o', error); + console.error("Error creating an export contract agent service charge %o", error); throw new Error(`Creating an export contract agent service charge ${error}`); } }; @@ -4912,24 +4906,24 @@ var create_an_export_contract_agent_service_charge_default = createAnExportContr // helpers/create-an-export-contract-agent/index.ts var createAnExportContractAgent = async (context, exportContractId) => { - console.info('Creating an export contract agent for %s', exportContractId); + console.info("Creating an export contract agent for %s", exportContractId); try { const agent = await context.db.ExportContractAgent.createOne({ data: { exportContract: { - connect: { id: exportContractId }, - }, - }, + connect: { id: exportContractId } + } + } }); const agentService = await create_an_export_contract_agent_service_default(context, agent.id); const agentServiceCharge = await create_an_export_contract_agent_service_charge_default(context, agentService.id); return { agent, agentService, - agentServiceCharge, + agentServiceCharge }; } catch (error) { - console.error('Error creating an export contract agent %o', error); + console.error("Error creating an export contract agent %o", error); throw new Error(`Creating an export contract agent ${error}`); } }; @@ -4937,15 +4931,15 @@ var create_an_export_contract_agent_default = createAnExportContractAgent; // helpers/create-an-export-contract/index.ts var createAnExportContract = async (context, applicationId) => { - console.info('Creating an export contract for %s', applicationId); + console.info("Creating an export contract for %s", applicationId); try { const exportContract = await context.db.ExportContract.createOne({ data: { application: { - connect: { id: applicationId }, + connect: { id: applicationId } }, - finalDestinationKnown: APPLICATION.DEFAULT_FINAL_DESTINATION_KNOWN, - }, + finalDestinationKnown: APPLICATION.DEFAULT_FINAL_DESTINATION_KNOWN + } }); const privateMarket = await create_a_private_market_default(context, exportContract.id); const { agent, agentService } = await create_an_export_contract_agent_default(context, exportContract.id); @@ -4953,10 +4947,10 @@ var createAnExportContract = async (context, applicationId) => { ...exportContract, privateMarket, agent, - agentService, + agentService }; } catch (error) { - console.error('Error creating an export contract %o', error); + console.error("Error creating an export contract %o", error); throw new Error(`Creating an export contract ${error}`); } }; @@ -4964,41 +4958,47 @@ var create_an_export_contract_default = createAnExportContract; // helpers/create-a-section-review/index.ts var createASectionReview = async (context, applicationId, sectionReviewData) => { - console.info('Creating a section review for %s', applicationId); + console.info("Creating a section review for %s", applicationId); try { const sectionReview = await context.db.SectionReview.createOne({ data: { application: { - connect: { id: applicationId }, + connect: { id: applicationId } }, - ...sectionReviewData, - }, + ...sectionReviewData + } }); return sectionReview; } catch (error) { - console.error('Error creating a section review %o', error); + console.error("Error creating a section review %o", error); throw new Error(`Creating a section review ${error}`); } }; var create_a_section_review_default = createASectionReview; // helpers/create-an-application/create-application-relationships/index.ts -var createApplicationRelationships = async ({ context, applicationId, companyData, eligibilityAnswers, sectionReviewData }) => { +var createApplicationRelationships = async ({ + context, + applicationId, + companyData, + eligibilityAnswers, + sectionReviewData +}) => { try { - console.info('Creating application relationships (createApplicationRelationships helper) for application %s', applicationId); + console.info("Creating application relationships (createApplicationRelationships helper) for application %s", applicationId); const { buyerCountryIsoCode, totalContractValueId, coverPeriodId, ...otherEligibilityAnswers } = eligibilityAnswers; - const country = await get_country_by_field_default(context, 'isoCode', buyerCountryIsoCode); + const country = await get_country_by_field_default(context, "isoCode", buyerCountryIsoCode); if (!country) { console.error( - 'Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application %s', - applicationId, + "Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application %s", + applicationId ); throw new Error( - `Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application ${applicationId}`, + `Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application ${applicationId}` ); } - const coverPeriod = await get_cover_period_value_by_field_default(context, 'valueId', coverPeriodId); - const totalContractValue = await get_total_contract_value_by_field_default(context, 'valueId', totalContractValueId); + const coverPeriod = await get_cover_period_value_by_field_default(context, "valueId", coverPeriodId); + const totalContractValue = await get_total_contract_value_by_field_default(context, "valueId", totalContractValueId); const referenceNumber = await create_a_reference_number_default(context, applicationId); const createdRelationships = await Promise.all([ create_a_broker_default(context, applicationId), @@ -5011,10 +5011,9 @@ var createApplicationRelationships = async ({ context, applicationId, companyDat create_a_policy_contact_default(context, applicationId), create_a_nominated_loss_payee_default(context, applicationId), create_a_company_default(context, applicationId, companyData), - create_a_section_review_default(context, applicationId, sectionReviewData), + create_a_section_review_default(context, applicationId, sectionReviewData) ]); - const [broker, business, buyer, declaration, eligibility, exportContract, policy, policyContact, nominatedLossPayee, company, sectionReview] = - createdRelationships; + const [broker, business, buyer, declaration, eligibility, exportContract, policy, policyContact, nominatedLossPayee, company, sectionReview] = createdRelationships; const relationshipIds = { brokerId: broker.id, businessId: business.id, @@ -5027,16 +5026,16 @@ var createApplicationRelationships = async ({ context, applicationId, companyDat policyId: policy.id, policyContactId: policyContact.id, referenceNumber, - sectionReviewId: sectionReview.id, + sectionReviewId: sectionReview.id }; return relationshipIds; } catch (error) { - console.error('Error creating application relationships (createApplicationRelationships helper) for application %s %o', applicationId, error); + console.error("Error creating application relationships (createApplicationRelationships helper) for application %s %o", applicationId, error); throw new Error(`Creating application relationships (createApplicationRelationships helper) for application ${applicationId} ${error}`); } }; var applicationRelationships = { - create: createApplicationRelationships, + create: createApplicationRelationships }; var create_application_relationships_default = applicationRelationships; @@ -5055,76 +5054,76 @@ var updateApplicationColumns = async ({ policyId, policyContactId, referenceNumber, - sectionReviewId, + sectionReviewId }) => { try { - console.info('Updating application relationship columns (updateApplicationColumns helper) for application %s', applicationId); + console.info("Updating application relationship columns (updateApplicationColumns helper) for application %s", applicationId); const updatedApplication = await context.db.Application.updateOne({ where: { - id: applicationId, + id: applicationId }, data: { broker: { - connect: { id: brokerId }, + connect: { id: brokerId } }, business: { - connect: { id: businessId }, + connect: { id: businessId } }, buyer: { - connect: { id: buyerId }, + connect: { id: buyerId } }, company: { - connect: { id: companyId }, + connect: { id: companyId } }, declaration: { - connect: { id: declarationId }, + connect: { id: declarationId } }, eligibility: { - connect: { id: eligibilityId }, + connect: { id: eligibilityId } }, exportContract: { - connect: { id: exportContractId }, + connect: { id: exportContractId } }, nominatedLossPayee: { - connect: { id: nominatedLossPayeeId }, + connect: { id: nominatedLossPayeeId } }, policy: { - connect: { id: policyId }, + connect: { id: policyId } }, policyContact: { - connect: { id: policyContactId }, + connect: { id: policyContactId } }, referenceNumber, sectionReview: { - connect: { id: sectionReviewId }, - }, - }, + connect: { id: sectionReviewId } + } + } }); return updatedApplication; } catch (error) { - console.error('Error updating application relationship columns (updateApplicationColumns helper) for application %s %o', applicationId, error); + console.error("Error updating application relationship columns (updateApplicationColumns helper) for application %s %o", applicationId, error); throw new Error(`Updating application relationship columns (updateApplicationColumns helper) for application ${applicationId} ${error}`); } }; var applicationColumns = { - update: updateApplicationColumns, + update: updateApplicationColumns }; var update_application_columns_default = applicationColumns; // helpers/create-an-application/index.ts var createAnApplicationHelper = async (variables, context) => { - console.info('Creating an application (createAnApplication helper) for user %s', variables.accountId); + console.info("Creating an application (createAnApplication helper) for user %s", variables.accountId); try { const { accountId, eligibilityAnswers, company: companyData, sectionReview: sectionReviewData, status } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info('Rejecting application creation - no account found (createAnApplication helper)'); + console.info("Rejecting application creation - no account found (createAnApplication helper)"); return null; } const application2 = await create_initial_application_default.create({ context, accountId, - status, + status }); const { id: applicationId } = application2; const { @@ -5139,13 +5138,13 @@ var createAnApplicationHelper = async (variables, context) => { policyId, policyContactId, referenceNumber, - sectionReviewId, + sectionReviewId } = await create_application_relationships_default.create({ context, applicationId, companyData, eligibilityAnswers, - sectionReviewData, + sectionReviewData }); const updatedApplication = await update_application_columns_default.update({ context, @@ -5161,11 +5160,11 @@ var createAnApplicationHelper = async (variables, context) => { policyId, policyContactId, referenceNumber, - sectionReviewId, + sectionReviewId }); return updatedApplication; } catch (error) { - console.error('Error creating an application (createAnApplication helper) for user %s %o', variables.accountId, error); + console.error("Error creating an application (createAnApplication helper) for user %s %o", variables.accountId, error); throw new Error(`Creating an application (createAnApplication helper) for user ${variables.accountId} ${error}`); } }; @@ -5173,20 +5172,20 @@ var create_an_application_default = createAnApplicationHelper; // custom-resolvers/mutations/create-an-application/index.ts var createAnApplication = async (root, variables, context) => { - console.info('Creating application for user %s', variables.accountId); + console.info("Creating application for user %s", variables.accountId); try { const application2 = await create_an_application_default(variables, context); if (application2) { return { ...application2, - success: true, + success: true }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error creating application for user %s %o', variables.accountId, error); + console.error("Error creating application for user %s %o", variables.accountId, error); throw new Error(`Creating application for user ${variables.accountId} ${error}`); } }; @@ -5194,12 +5193,12 @@ var create_an_application_default2 = createAnApplication; // helpers/get-countries/index.ts var getCountries = async (context) => { - console.info('Getting countries'); + console.info("Getting countries"); try { const countries = await context.db.Country.findMany(); return countries; } catch (error) { - console.error('Error getting countries %o', error); + console.error("Error getting countries %o", error); throw new Error(`Getting countries ${error}`); } }; @@ -5207,20 +5206,20 @@ var get_countries_default = getCountries; // helpers/create-a-buyer/index.ts var createABuyer = async (context, countryId) => { - console.info('Creating a buyer'); + console.info("Creating a buyer"); try { const buyer = await context.db.Buyer.createOne({ data: { country: { connect: { - id: countryId, - }, - }, - }, + id: countryId + } + } + } }); return buyer; } catch (error) { - console.error('Error creating a buyer %o', error); + console.error("Error creating a buyer %o", error); throw new Error(`Creating a buyer ${error}`); } }; @@ -5228,25 +5227,25 @@ var create_a_buyer_default = createABuyer; // helpers/create-many-applications-and-reference-numbers/index.ts var createManyApplicationsAndReferenceNumbers = async (context, applicationData) => { - console.info('Creating many applications and reference numbers'); + console.info("Creating many applications and reference numbers"); try { const applications = await context.db.Application.createMany({ - data: applicationData, + data: applicationData }); const referenceNumbersData = applications.map((application2) => ({ application: { connect: { - id: application2.id, - }, - }, + id: application2.id + } + } })); const referenceNumbers = await context.db.ReferenceNumber.createMany({ data: referenceNumbersData }); return { applications, - referenceNumbers, + referenceNumbers }; } catch (error) { - console.error('Error creating many applications and reference numbers - helper %o', error); + console.error("Error creating many applications and reference numbers - helper %o", error); throw new Error(`Creating many applications and reference numbers - helper ${error}`); } }; @@ -5254,14 +5253,14 @@ var create_many_applications_and_reference_numbers_default = createManyApplicati // helpers/update-applications-data/index.ts var updateApplicationsData = async (context, updateData) => { - console.info('Updating many applications'); + console.info("Updating many applications"); try { const updatedApplications = await context.db.Application.updateMany({ - data: updateData, + data: updateData }); return updatedApplications; } catch (error) { - console.error('Error updating many applications - helper %o', error); + console.error("Error updating many applications - helper %o", error); throw new Error(`Updating many applications - helper ${error}`); } }; @@ -5269,7 +5268,7 @@ var update_applications_data_default = updateApplicationsData; // custom-resolvers/mutations/create-many-applications/index.ts var createManyApplications = async (root, variables, context) => { - console.info('Creating many applications'); + console.info("Creating many applications"); try { const emptyArray = new Array(variables.count).fill({}); const countries = await get_countries_default(context); @@ -5277,36 +5276,36 @@ var createManyApplications = async (root, variables, context) => { const mockApplicationsData = emptyArray.map(() => ({ owner: { connect: { - id: variables.accountId, - }, + id: variables.accountId + } }, buyer: { connect: { - id: buyer.id, - }, + id: buyer.id + } }, - ...initial_application_data_default, + ...initial_application_data_default })); const { referenceNumbers } = await create_many_applications_and_reference_numbers_default(context, mockApplicationsData); const updateApplicationReferenceNumbers = referenceNumbers.map((referenceNumber) => ({ where: { id: referenceNumber.applicationId }, - data: { referenceNumber: referenceNumber.id }, + data: { referenceNumber: referenceNumber.id } })); await update_applications_data_default(context, updateApplicationReferenceNumbers); const allApplications = await context.query.Application.findMany({ - query: 'id referenceNumber', + query: "id referenceNumber" }); if (allApplications.length) { return { applications: allApplications, - success: true, + success: true }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error creating many applications %o', error); + console.error("Error creating many applications %o", error); throw new Error(`Creating many applications ${error}`); } }; @@ -5315,7 +5314,7 @@ var create_many_applications_default = createManyApplications; // custom-resolvers/mutations/create-an-abandoned-application/index.ts var { STATUS: STATUS3 } = APPLICATION; var createAnAbandonedApplication = async (root, variables, context) => { - console.info('Creating an abandoned application for %s', variables.accountId); + console.info("Creating an abandoned application for %s", variables.accountId); const abandonedApplicationVariables = variables; abandonedApplicationVariables.status = STATUS3.ABANDONED; try { @@ -5323,14 +5322,14 @@ var createAnAbandonedApplication = async (root, variables, context) => { if (createdApplication) { return { ...createdApplication, - success: true, + success: true }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error creating an abandoned application %o', error); + console.error("Error creating an abandoned application %o", error); throw new Error(`Creating an abandoned application ${error}`); } }; @@ -5339,11 +5338,11 @@ var create_an_abandoned_application_default = createAnAbandonedApplication; // helpers/get-application-by-reference-number/index.ts var getApplicationByReferenceNumber = async (referenceNumber, context) => { try { - console.info('Getting application by reference number - getApplicationByReferenceNumber helper %s', referenceNumber); + console.info("Getting application by reference number - getApplicationByReferenceNumber helper %s", referenceNumber); const applications = await context.db.Application.findMany({ where: { - referenceNumber: { equals: referenceNumber }, - }, + referenceNumber: { equals: referenceNumber } + } }); if (applications?.length) { const [application2] = applications; @@ -5351,7 +5350,7 @@ var getApplicationByReferenceNumber = async (referenceNumber, context) => { } return null; } catch (error) { - console.error('Error getting application by reference number %o', error); + console.error("Error getting application by reference number %o", error); throw new Error(`Error getting application by reference number ${error}`); } }; @@ -5360,45 +5359,45 @@ var get_application_by_reference_number_default = getApplicationByReferenceNumbe // custom-resolvers/mutations/delete-application-by-reference-number/index.ts var deleteApplicationByReferenceNumber = async (root, variables, context) => { try { - console.info('Deleting application by reference number'); + console.info("Deleting application by reference number"); const { referenceNumber } = variables; const application2 = await get_application_by_reference_number_default(referenceNumber, context); if (application2) { const { id } = application2; const deleteResponse = await context.db.Application.deleteOne({ where: { - id, - }, + id + } }); if (deleteResponse?.id) { return { - success: true, + success: true }; } } return { - success: false, + success: false }; } catch (error) { - console.error('Error deleting application by reference number (DeleteApplicationByReferenceNumber mutation) %o', error); + console.error("Error deleting application by reference number (DeleteApplicationByReferenceNumber mutation) %o", error); throw new Error(`Deleting application by reference number (DeleteApplicationByReferenceNumber mutation) ${error}`); } }; var delete_application_by_reference_number_default = deleteApplicationByReferenceNumber; // custom-resolvers/mutations/submit-application/index.ts -var import_date_fns6 = require('date-fns'); +var import_date_fns6 = require("date-fns"); // helpers/get-eligibility-by-id/index.ts var getEligibilityById = async (context, id) => { try { - console.info('Getting eligibility by ID %s', id); + console.info("Getting eligibility by ID %s", id); const eligibility = await context.db.Eligibility.findOne({ - where: { id }, + where: { id } }); return eligibility; } catch (error) { - console.error('Getting eligibility by ID %s %o', id, error); + console.error("Getting eligibility by ID %s %o", id, error); throw new Error(`Error Getting eligibility by ID ${id} ${error}`); } }; @@ -5407,13 +5406,13 @@ var get_eligibility_by_id_default = getEligibilityById; // helpers/get-cover-period-by-id/index.ts var getCoverPeriodById = async (context, id) => { try { - console.info('Getting coverPeriod by ID %s', id); + console.info("Getting coverPeriod by ID %s", id); const coverPeriod = await context.db.CoverPeriod.findOne({ - where: { id }, + where: { id } }); return coverPeriod; } catch (error) { - console.error('Getting coverPeriod by ID %s %o', id, error); + console.error("Getting coverPeriod by ID %s %o", id, error); throw new Error(`Error Getting coverPeriod by ID ${id} ${error}`); } }; @@ -5422,13 +5421,13 @@ var get_cover_period_by_id_default = getCoverPeriodById; // helpers/get-total-contract-value-by-id/index.ts var getTotalContractValueById = async (context, id) => { try { - console.info('Getting totalContractValue by ID %s', id); + console.info("Getting totalContractValue by ID %s", id); const totalContractValue = await context.db.TotalContractValue.findOne({ - where: { id }, + where: { id } }); return totalContractValue; } catch (error) { - console.error('Getting totalContractValue by ID %s %o', id, error); + console.error("Getting totalContractValue by ID %s %o", id, error); throw new Error(`Error Getting totalContractValue by ID ${id} ${error}`); } }; @@ -5437,7 +5436,7 @@ var get_total_contract_value_by_id_default = getTotalContractValueById; // helpers/get-populated-eligibility/index.ts var getPopulatedEligibility = async (context, id, buyerCountry) => { try { - console.info('Getting populated eligibility %s', id); + console.info("Getting populated eligibility %s", id); const eligibility = await get_eligibility_by_id_default(context, id); const coverPeriod = await get_cover_period_by_id_default(context, eligibility.coverPeriodId); const totalContractValue = await get_total_contract_value_by_id_default(context, eligibility.totalContractValueId); @@ -5445,11 +5444,11 @@ var getPopulatedEligibility = async (context, id, buyerCountry) => { ...eligibility, buyerCountry, coverPeriod, - totalContractValue, + totalContractValue }; return populatedEligibility; } catch (error) { - console.error('Getting populated eligibility %s %o', id, error); + console.error("Getting populated eligibility %s %o", id, error); throw new Error(`Error Getting populated eligibility ${id} ${error}`); } }; @@ -5458,15 +5457,14 @@ var get_populated_eligibility_default = getPopulatedEligibility; // helpers/get-policy-by-id/index.ts var getPolicyById = async (context, id) => { try { - console.info('Getting policy by ID %s', id); + console.info("Getting policy by ID %s", id); const policy = await context.query.Policy.findOne({ where: { id }, - query: - 'id policyType requestedStartDate contractCompletionDate requestedCreditLimit totalValueOfContract creditPeriodWithBuyer policyCurrencyCode totalMonthsOfCover totalSalesToBuyer maximumBuyerWillOwe needPreCreditPeriodCover jointlyInsuredParty { id companyName companyNumber countryCode requested }', + query: "id policyType requestedStartDate contractCompletionDate requestedCreditLimit totalValueOfContract creditPeriodWithBuyer policyCurrencyCode totalMonthsOfCover totalSalesToBuyer maximumBuyerWillOwe needPreCreditPeriodCover jointlyInsuredParty { id companyName companyNumber countryCode requested }" }); return policy; } catch (error) { - console.error('Getting policy by ID %s %o', id, error); + console.error("Getting policy by ID %s %o", id, error); throw new Error(`Error Getting policy by ID ${id} ${error}`); } }; @@ -5475,32 +5473,32 @@ var get_policy_by_id_default = getPolicyById; // helpers/get-policy-contact-by-id/index.ts var getPolicyContactById = async (context, id) => { try { - console.info('Getting policyContact by ID %s', id); + console.info("Getting policyContact by ID %s", id); const policyContact = await context.db.PolicyContact.findOne({ - where: { id }, + where: { id } }); return policyContact; } catch (error) { - console.error('Getting policyContact by ID %s %o', id, error); + console.error("Getting policyContact by ID %s %o", id, error); throw new Error(`Error Getting policyContact by ID ${id} ${error}`); } }; var get_policy_contact_by_id_default = getPolicyContactById; // helpers/encrypt/generate-key/index.ts -var import_crypto9 = __toESM(require('crypto')); +var import_crypto9 = __toESM(require("crypto")); var { ALGORITHM: ALGORITHM2, SIGNATURE: SIGNATURE2, SUBSTRING_INDEX_START, SUBSTRING_INDEX_END } = FINANCIAL_DETAILS.ENCRYPTION.KEY; -var generateKey = () => import_crypto9.default.createHash(ALGORITHM2).update(SIGNATURE2).digest('hex').substring(SUBSTRING_INDEX_START, SUBSTRING_INDEX_END); +var generateKey = () => import_crypto9.default.createHash(ALGORITHM2).update(SIGNATURE2).digest("hex").substring(SUBSTRING_INDEX_START, SUBSTRING_INDEX_END); var generate_key_default = generateKey; // helpers/decrypt/generate-decipher/index.ts -var import_crypto10 = __toESM(require('crypto')); +var import_crypto10 = __toESM(require("crypto")); var { ENCRYPTION_METHOD } = FINANCIAL_DETAILS.ENCRYPTION.CIPHER; var generateDecipher = (key2, iv) => { try { return import_crypto10.default.createDecipheriv(ENCRYPTION_METHOD, key2, iv); } catch (error) { - console.error('Error generating decipher %o', error); + console.error("Error generating decipher %o", error); throw new Error(`Error generating decipher ${error}`); } }; @@ -5512,7 +5510,7 @@ var generateBufferInStringFormat = (value) => { try { return Buffer.from(value, STRING_ENCODING2).toString(OUTPUT_ENCODING); } catch (error) { - console.error('Error generating buffer %o', error); + console.error("Error generating buffer %o", error); throw new Error(`Error generating buffer ${error}`); } }; @@ -5523,7 +5521,7 @@ var { ENCODING: ENCODING2, OUTPUT_ENCODING: OUTPUT_ENCODING2 } = FINANCIAL_DETAI var key = generate_key_default(); var decryptData = (dataToDecrypt) => { try { - console.info('Decrypting data'); + console.info("Decrypting data"); const { value, iv } = dataToDecrypt; const buffer = generate_buffer_default(value); const decipher = generate_decipher_default(key, iv); @@ -5531,27 +5529,27 @@ var decryptData = (dataToDecrypt) => { const decipherFinal = decipher.final(OUTPUT_ENCODING2); return decipherUpdate.concat(decipherFinal); } catch (error) { - console.error('Error decrypting data %o', error); + console.error("Error decrypting data %o", error); throw new Error(`Error decrypting data ${error}`); } }; var decrypt = { - decrypt: decryptData, + decrypt: decryptData }; var decrypt_default = decrypt; // helpers/decrypt-financial-uk/index.ts var decryptFinancialUk = (applicationFinancialUk) => { try { - console.info('Decrypting financial uk'); + console.info("Decrypting financial uk"); const mapped = applicationFinancialUk; const { accountNumber, sortCode, - vector: { accountNumberVector, sortCodeVector }, + vector: { accountNumberVector, sortCodeVector } } = applicationFinancialUk; - let decryptedAccountNumber = ''; - let decryptedSortCode = ''; + let decryptedAccountNumber = ""; + let decryptedSortCode = ""; if (accountNumber && accountNumberVector) { decryptedAccountNumber = decrypt_default.decrypt({ value: accountNumber, iv: accountNumberVector }); } @@ -5562,7 +5560,7 @@ var decryptFinancialUk = (applicationFinancialUk) => { mapped.sortCode = decryptedSortCode; return mapped; } catch (error) { - console.error('Error decrypting financial uk %o', error); + console.error("Error decrypting financial uk %o", error); throw new Error(`Error decrypting financial uk ${error}`); } }; @@ -5571,15 +5569,15 @@ var decrypt_financial_uk_default = decryptFinancialUk; // helpers/decrypt-financial-international/index.ts var decryptFinancialInternational = (applicationFinancialInternational) => { try { - console.info('Decrypting financial international'); + console.info("Decrypting financial international"); const mapped = applicationFinancialInternational; const { bicSwiftCode, iban, - vector: { bicSwiftCodeVector, ibanVector }, + vector: { bicSwiftCodeVector, ibanVector } } = applicationFinancialInternational; - let decryptedIban = ''; - let decryptedBicSwiftCode = ''; + let decryptedIban = ""; + let decryptedBicSwiftCode = ""; if (bicSwiftCode && bicSwiftCodeVector) { decryptedBicSwiftCode = decrypt_default.decrypt({ value: bicSwiftCode, iv: bicSwiftCodeVector }); } @@ -5590,7 +5588,7 @@ var decryptFinancialInternational = (applicationFinancialInternational) => { mapped.iban = decryptedIban; return mapped; } catch (error) { - console.error('Error decrypting international uk %o', error); + console.error("Error decrypting international uk %o", error); throw new Error(`Error decrypting international uk ${error}`); } }; @@ -5599,26 +5597,26 @@ var decrypt_financial_international_default = decryptFinancialInternational; // helpers/decrypt-nominated-loss-payee/index.ts var decryptNominatedLossPayee = (nominatedLossPayee, decryptFinancialUk2, decryptFinancialInternational2) => { try { - console.info('Decrypting nominated loss payee %s', nominatedLossPayee.id); + console.info("Decrypting nominated loss payee %s", nominatedLossPayee.id); const mapped = { ...nominatedLossPayee, financialUk: {}, - financialInternational: {}, + financialInternational: {} }; const { financialUk, financialInternational } = nominatedLossPayee; if (decryptFinancialUk2) { - console.info('Decrypting nominated loss payee - financial - UK data %s', nominatedLossPayee.id); + console.info("Decrypting nominated loss payee - financial - UK data %s", nominatedLossPayee.id); const mappedFinancialUk = decrypt_financial_uk_default(financialUk); mapped.financialUk = mappedFinancialUk; } if (decryptFinancialInternational2) { - console.info('Decrypting nominated loss payee - financial - international data %s', nominatedLossPayee.id); + console.info("Decrypting nominated loss payee - financial - international data %s", nominatedLossPayee.id); const mappedFinancialInternational = decrypt_financial_international_default(financialInternational); mapped.financialInternational = mappedFinancialInternational; } return mapped; } catch (error) { - console.error('Error decrypting nominated loss payee %o', error); + console.error("Error decrypting nominated loss payee %o", error); throw new Error(`Error decrypting nominated loss payee ${error}`); } }; @@ -5627,11 +5625,10 @@ var decrypt_nominated_loss_payee_default = decryptNominatedLossPayee; // helpers/get-populated-application/nominated-loss-payee/index.ts var getNominatedLossPayee = async (context, lossPayeeId, decryptFinancialUk2, decryptFinancialInternational2) => { try { - console.info('Getting nominated loss payee %s', lossPayeeId); + console.info("Getting nominated loss payee %s", lossPayeeId); const nominatedLossPayee = await context.query.NominatedLossPayee.findOne({ where: { id: lossPayeeId }, - query: - 'id isAppointed isLocatedInUk isLocatedInternationally name financialUk { id accountNumber sortCode bankAddress vector { accountNumberVector sortCodeVector } } financialInternational { id iban bicSwiftCode bankAddress vector { bicSwiftCodeVector ibanVector } }', + query: "id isAppointed isLocatedInUk isLocatedInternationally name financialUk { id accountNumber sortCode bankAddress vector { accountNumberVector sortCodeVector } } financialInternational { id iban bicSwiftCode bankAddress vector { bicSwiftCodeVector ibanVector } }" }); if (decryptFinancialUk2 || decryptFinancialInternational2) { const decryptedNominatedLossPayee = decrypt_nominated_loss_payee_default(nominatedLossPayee, decryptFinancialUk2, decryptFinancialInternational2); @@ -5639,7 +5636,7 @@ var getNominatedLossPayee = async (context, lossPayeeId, decryptFinancialUk2, de } return nominatedLossPayee; } catch (error) { - console.error('Error getting nominated loss payee (getNominatedLossPayee helper) %o', error); + console.error("Error getting nominated loss payee (getNominatedLossPayee helper) %o", error); throw new Error(`Error getting nominated loss payee (getNominatedLossPayee helper) ${error}`); } }; @@ -5648,13 +5645,13 @@ var nominated_loss_payee_default = getNominatedLossPayee; // helpers/get-export-contract-by-id/index.ts var getExportContractById = async (context, id) => { try { - console.info('Getting exportContract by ID %s', id); + console.info("Getting exportContract by ID %s", id); const exportContract = await context.db.ExportContract.findOne({ - where: { id }, + where: { id } }); return exportContract; } catch (error) { - console.error('Getting exportContract by ID %s %o', id, error); + console.error("Getting exportContract by ID %s %o", id, error); throw new Error(`Error Getting exportContract by ID ${id} ${error}`); } }; @@ -5663,13 +5660,13 @@ var get_export_contract_by_id_default = getExportContractById; // helpers/get-export-contract-agent-by-id/index.ts var getExportContractAgentById = async (context, id) => { try { - console.info('Getting exportContractAgent by ID %s', id); + console.info("Getting exportContractAgent by ID %s", id); const exportContractAgent = await context.db.ExportContractAgent.findOne({ - where: { id }, + where: { id } }); return exportContractAgent; } catch (error) { - console.error('Getting exportContractAgent by ID %s %o', id, error); + console.error("Getting exportContractAgent by ID %s %o", id, error); throw new Error(`Error Getting exportContractAgent by ID ${id} ${error}`); } }; @@ -5678,13 +5675,13 @@ var get_export_contract_agent_by_id_default = getExportContractAgentById; // helpers/get-export-contract-agent-service-by-id/index.ts var getExportContractAgentServiceById = async (context, id) => { try { - console.info('Getting exportContractAgentService by ID %s', id); + console.info("Getting exportContractAgentService by ID %s", id); const exportContractAgentService = await context.db.ExportContractAgentService.findOne({ - where: { id }, + where: { id } }); return exportContractAgentService; } catch (error) { - console.error('Getting exportContractAgentService by ID %s %o', id, error); + console.error("Getting exportContractAgentService by ID %s %o", id, error); throw new Error(`Error Getting exportContractAgentService by ID ${id} ${error}`); } }; @@ -5693,13 +5690,13 @@ var get_export_contract_agent_service_by_id_default = getExportContractAgentServ // helpers/get-export-contract-agent-service-charge-by-id/index.ts var getExportContractAgentServiceChargeById = async (context, id) => { try { - console.info('Getting exportContractAgentServiceCharge by ID %s', id); + console.info("Getting exportContractAgentServiceCharge by ID %s", id); const exportContractAgentServiceCharge = await context.db.ExportContractAgentServiceCharge.findOne({ - where: { id }, + where: { id } }); return exportContractAgentServiceCharge; } catch (error) { - console.error('Getting exportContractAgentServiceCharge by ID %s %o', id, error); + console.error("Getting exportContractAgentServiceCharge by ID %s %o", id, error); throw new Error(`Error Getting exportContractAgentServiceCharge by ID ${id} ${error}`); } }; @@ -5708,7 +5705,7 @@ var get_export_contract_agent_service_charge_by_id_default = getExportContractAg // helpers/get-populated-export-contract/get-populated-agent/index.ts var getPopulatedAgent = async (context, id) => { try { - console.info('Getting populated exportContract agent %s', id); + console.info("Getting populated exportContract agent %s", id); const exportContractAgent = await get_export_contract_agent_by_id_default(context, id); const exportContractAgentService = await get_export_contract_agent_service_by_id_default(context, exportContractAgent.serviceId); const exportContractAgentServiceCharge = await get_export_contract_agent_service_charge_by_id_default(context, exportContractAgentService.chargeId); @@ -5716,12 +5713,12 @@ var getPopulatedAgent = async (context, id) => { ...exportContractAgent, service: { ...exportContractAgentService, - charge: exportContractAgentServiceCharge, - }, + charge: exportContractAgentServiceCharge + } }; return populatedAgent; } catch (error) { - console.error('Getting populated exportContract agent %s %o', id, error); + console.error("Getting populated exportContract agent %s %o", id, error); throw new Error(`Error Getting populated exportContract agent ${id} ${error}`); } }; @@ -5730,13 +5727,13 @@ var get_populated_agent_default = getPopulatedAgent; // helpers/get-private-market-by-id/index.ts var getPrivateMarketById = async (context, id) => { try { - console.info('Getting privateMarket by ID %s', id); + console.info("Getting privateMarket by ID %s", id); const privateMarket = await context.db.PrivateMarket.findOne({ - where: { id }, + where: { id } }); return privateMarket; } catch (error) { - console.error('Getting privateMarket by ID %s %o', id, error); + console.error("Getting privateMarket by ID %s %o", id, error); throw new Error(`Error Getting privateMarket by ID ${id} ${error}`); } }; @@ -5745,20 +5742,20 @@ var get_private_market_by_id_default = getPrivateMarketById; // helpers/get-populated-export-contract/index.ts var getPopulatedExportContract = async (context, id) => { try { - console.info('Getting populated exportContract %s', id); + console.info("Getting populated exportContract %s", id); const exportContract = await get_export_contract_by_id_default(context, id); const exportContractAgent = await get_populated_agent_default(context, exportContract.agentId); const privateMarket = await get_private_market_by_id_default(context, exportContract.privateMarketId); - const finalDestinationCountry = await get_country_by_field_default(context, 'isoCode', exportContract.finalDestinationCountryCode); + const finalDestinationCountry = await get_country_by_field_default(context, "isoCode", exportContract.finalDestinationCountryCode); const populatedExportContract = { ...exportContract, agent: exportContractAgent, finalDestinationCountry, - privateMarket, + privateMarket }; return populatedExportContract; } catch (error) { - console.error('Getting populated exportContract %s %o', id, error); + console.error("Getting populated exportContract %s %o", id, error); throw new Error(`Error Getting populated exportContract ${id} ${error}`); } }; @@ -5767,13 +5764,13 @@ var get_populated_export_contract_default = getPopulatedExportContract; // helpers/get-company-by-id/index.ts var getCompanyById = async (context, id) => { try { - console.info('Getting company by ID %s', id); + console.info("Getting company by ID %s", id); const company = await context.db.Company.findOne({ - where: { id }, + where: { id } }); return company; } catch (error) { - console.error('Getting company by ID %s %o', id, error); + console.error("Getting company by ID %s %o", id, error); throw new Error(`Error Getting company by ID ${id} ${error}`); } }; @@ -5782,13 +5779,13 @@ var get_company_by_id_default = getCompanyById; // helpers/get-company-address-by-id/index.ts var getCompanyAddressById = async (context, id) => { try { - console.info('Getting company address by ID %s', id); + console.info("Getting company address by ID %s", id); const companyAddress = await context.db.CompanyAddress.findOne({ - where: { id }, + where: { id } }); return companyAddress; } catch (error) { - console.error('Getting company address by ID %s %o', id, error); + console.error("Getting company address by ID %s %o", id, error); throw new Error(`Error Getting company address by ID ${id} ${error}`); } }; @@ -5797,17 +5794,17 @@ var get_company_address_by_id_default = getCompanyAddressById; // helpers/get-company-sic-codes-by-company-id/index.ts var getCompanySicCodesByCompanyId = async (context, id) => { try { - console.info('Getting company SIC codes by company ID %s', id); + console.info("Getting company SIC codes by company ID %s", id); const companySicCodes = await context.db.CompanySicCode.findMany({ where: { company: { - id: { equals: id }, - }, - }, + id: { equals: id } + } + } }); return companySicCodes; } catch (error) { - console.error('Getting company SIC codes by company ID %s %o', id, error); + console.error("Getting company SIC codes by company ID %s %o", id, error); throw new Error(`Error Getting company SIC codes by company ID ${id} ${error}`); } }; @@ -5816,13 +5813,13 @@ var get_company_sic_codes_by_company_id_default = getCompanySicCodesByCompanyId; // helpers/get-company-different-trading-address-by-id/index.ts var getCompanyDifferentTradingAddressById = async (context, id) => { try { - console.info('Getting company different trading address by ID %s', id); + console.info("Getting company different trading address by ID %s", id); const differentTradingAddress = await context.db.CompanyDifferentTradingAddress.findOne({ - where: { id }, + where: { id } }); return differentTradingAddress; } catch (error) { - console.error('Getting company different trading address by ID %s %o', id, error); + console.error("Getting company different trading address by ID %s %o", id, error); throw new Error(`Error Getting company different trading address by ID ${id} ${error}`); } }; @@ -5831,7 +5828,7 @@ var get_company_different_trading_address_by_id_default = getCompanyDifferentTra // helpers/get-populated-company/index.ts var getPopulatedCompany = async (context, id) => { try { - console.info('Getting populated company %s', id); + console.info("Getting populated company %s", id); const company = await get_company_by_id_default(context, id); const companyAddress = await get_company_address_by_id_default(context, company.registeredOfficeAddressId); const companySicCodes = await get_company_sic_codes_by_company_id_default(context, company.id); @@ -5840,11 +5837,11 @@ var getPopulatedCompany = async (context, id) => { ...company, companySicCodes, registeredOfficeAddress: companyAddress, - differentTradingAddress, + differentTradingAddress }; return populatedCompany; } catch (error) { - console.error('Getting populated company %s %o', id, error); + console.error("Getting populated company %s %o", id, error); throw new Error(`Error Getting populated company ${id} ${error}`); } }; @@ -5853,13 +5850,13 @@ var get_populated_company_default = getPopulatedCompany; // helpers/get-business-by-id/index.ts var getBusinessById = async (context, id) => { try { - console.info('Getting business by ID %s', id); + console.info("Getting business by ID %s", id); const business = await context.db.Business.findOne({ - where: { id }, + where: { id } }); return business; } catch (error) { - console.error('Getting business by ID %s %o', id, error); + console.error("Getting business by ID %s %o", id, error); throw new Error(`Error Getting business by ID ${id} ${error}`); } }; @@ -5868,13 +5865,13 @@ var get_business_by_id_default = getBusinessById; // helpers/get-broker-by-id/index.ts var getBrokerById = async (context, id) => { try { - console.info('Getting broker by ID %s', id); + console.info("Getting broker by ID %s", id); const broker = await context.db.Broker.findOne({ - where: { id }, + where: { id } }); return broker; } catch (error) { - console.error('Getting broker by ID %s %o', id, error); + console.error("Getting broker by ID %s %o", id, error); throw new Error(`Error Getting broker by ID ${id} ${error}`); } }; @@ -5883,13 +5880,13 @@ var get_broker_by_id_default = getBrokerById; // helpers/get-buyer-by-id/index.ts var getBuyerById = async (context, id) => { try { - console.info('Getting buyer by ID %s', id); + console.info("Getting buyer by ID %s", id); const buyer = await context.db.Buyer.findOne({ - where: { id }, + where: { id } }); return buyer; } catch (error) { - console.error('Getting buyer by ID %s %o', id, error); + console.error("Getting buyer by ID %s %o", id, error); throw new Error(`Error Getting buyer by ID ${id} ${error}`); } }; @@ -5898,13 +5895,13 @@ var get_buyer_by_id_default = getBuyerById; // helpers/get-country-by-id/index.ts var getCountryById = async (context, id) => { try { - console.info('Getting country by ID %s', id); + console.info("Getting country by ID %s", id); const country = await context.db.Country.findOne({ - where: { id }, + where: { id } }); return country; } catch (error) { - console.error('Getting country by ID %s %o', id, error); + console.error("Getting country by ID %s %o", id, error); throw new Error(`Error Getting country by ID ${id} ${error}`); } }; @@ -5913,13 +5910,13 @@ var get_country_by_id_default = getCountryById; // helpers/get-buyer-relationship-by-id/index.ts var getBuyerRelationshipById = async (context, id) => { try { - console.info('Getting buyer relationship by ID %s', id); + console.info("Getting buyer relationship by ID %s", id); const buyerRelationship = await context.db.BuyerRelationship.findOne({ - where: { id }, + where: { id } }); return buyerRelationship; } catch (error) { - console.error('Getting buyer relationship by ID %s %o', id, error); + console.error("Getting buyer relationship by ID %s %o", id, error); throw new Error(`Error Getting buyer relationship by ID ${id} ${error}`); } }; @@ -5928,13 +5925,13 @@ var get_buyer_relationship_by_id_default = getBuyerRelationshipById; // helpers/get-buyer-trading-history-by-id/index.ts var getBuyerTradingHistoryById = async (context, id) => { try { - console.info('Getting buyer trading history by ID %s', id); + console.info("Getting buyer trading history by ID %s", id); const buyerTradingHistory = await context.db.BuyerTradingHistory.findOne({ - where: { id }, + where: { id } }); return buyerTradingHistory; } catch (error) { - console.error('Getting buyer trading history by ID %s %o', id, error); + console.error("Getting buyer trading history by ID %s %o", id, error); throw new Error(`Error Getting buyer trading history by ID ${id} ${error}`); } }; @@ -5943,7 +5940,7 @@ var get_buyer_trading_history_by_id_default = getBuyerTradingHistoryById; // helpers/get-populated-buyer/index.ts var getPopulatedBuyer = async (context, id) => { try { - console.info('Getting populated buyer %s', id); + console.info("Getting populated buyer %s", id); const buyer = await get_buyer_by_id_default(context, id); const buyerCountry = await get_country_by_id_default(context, buyer.countryId); const buyerRelationship = await get_buyer_relationship_by_id_default(context, buyer.relationshipId); @@ -5952,11 +5949,11 @@ var getPopulatedBuyer = async (context, id) => { ...buyer, country: buyerCountry, relationship: buyerRelationship, - buyerTradingHistory, + buyerTradingHistory }; return populatedBuyer; } catch (error) { - console.error('Getting populated buyer %s %o', id, error); + console.error("Getting populated buyer %s %o", id, error); throw new Error(`Error Getting populated buyer ${id} ${error}`); } }; @@ -5965,13 +5962,13 @@ var get_populated_buyer_default = getPopulatedBuyer; // helpers/get-declaration-by-id/index.ts var getDeclarationById = async (context, id) => { try { - console.info('Getting declaration by ID %s', id); + console.info("Getting declaration by ID %s", id); const declaration = await context.db.Declaration.findOne({ - where: { id }, + where: { id } }); return declaration; } catch (error) { - console.error('Getting declaration by ID %s %o', id, error); + console.error("Getting declaration by ID %s %o", id, error); throw new Error(`Error Getting declaration by ID ${id} ${error}`); } }; @@ -5980,13 +5977,13 @@ var get_declaration_by_id_default = getDeclarationById; // helpers/get-section-review-by-id/index.ts var getSectionReviewById = async (context, id) => { try { - console.info('Getting sectionReview by ID %s', id); + console.info("Getting sectionReview by ID %s", id); const sectionReview = await context.db.SectionReview.findOne({ - where: { id }, + where: { id } }); return sectionReview; } catch (error) { - console.error('Getting sectionReview by ID %s %o', id, error); + console.error("Getting sectionReview by ID %s %o", id, error); throw new Error(`Error Getting sectionReview by ID ${id} ${error}`); } }; @@ -6002,7 +5999,7 @@ var mapPolicy = (policy) => { const mappedPolicy = { ...policy, requestedStartDate: requestedStartDate ? new Date(requestedStartDate) : null, - contractCompletionDate: contractCompletionDate ? new Date(contractCompletionDate) : null, + contractCompletionDate: contractCompletionDate ? new Date(contractCompletionDate) : null }; return mappedPolicy; }; @@ -6013,10 +6010,10 @@ var getPopulatedApplication = async ({ context, application: application2, decryptFinancialUk: decryptFinancialUk2 = false, - decryptFinancialInternational: decryptFinancialInternational2 = false, + decryptFinancialInternational: decryptFinancialInternational2 = false }) => { try { - console.info('Getting populated application (helper) %s', application2.id); + console.info("Getting populated application (helper) %s", application2.id); const { eligibilityId, ownerId, @@ -6029,7 +6026,7 @@ var getPopulatedApplication = async ({ buyerId, declarationId, nominatedLossPayeeId, - sectionReviewId, + sectionReviewId } = application2; const populatedBuyer = await get_populated_buyer_default(context, buyerId); const populatedEligibility = await get_populated_eligibility_default(context, eligibilityId, populatedBuyer.country); @@ -6059,46 +6056,38 @@ var getPopulatedApplication = async ({ policyContact, nominatedLossPayee, sectionReview, - totalContractValueOverThreshold, + totalContractValueOverThreshold }; return populatedApplication2; } catch (error) { - console.error('Getting populated application (helper) %s %o', application2.id, error); + console.error("Getting populated application (helper) %s %o", application2.id, error); throw new Error(`Error Getting populated application (helper) ${application2.id} ${error}`); } }; var populatedApplication = { - get: getPopulatedApplication, + get: getPopulatedApplication }; var get_populated_application_default = populatedApplication; // helpers/replace-character-codes-with-characters/index.ts -var replaceCharacterCodesWithCharacters = (str) => - str - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/"/g, '"') - .replace(/'/g, "'") - .replace(///g, '/') - .replace(/*/g, '*') - .replace(/&/g, '&'); +var replaceCharacterCodesWithCharacters = (str) => str.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(///g, "/").replace(/*/g, "*").replace(/&/g, "&"); var replace_character_codes_with_characters_default = replaceCharacterCodesWithCharacters; // helpers/get-application-submitted-email-template-ids/index.ts var { APPLICATION: { - SUBMISSION: { EXPORTER, UNDERWRITING_TEAM }, - }, + SUBMISSION: { EXPORTER, UNDERWRITING_TEAM } + } } = EMAIL_TEMPLATE_IDS; var getApplicationSubmittedEmailTemplateIds = (application2) => { const { buyer, declaration } = application2; const templateIds = { - underwritingTeam: '', - account: '', + underwritingTeam: "", + account: "" }; const { hasAntiBriberyCodeOfConduct } = declaration; const { - buyerTradingHistory: { exporterHasTradedWithBuyer }, + buyerTradingHistory: { exporterHasTradedWithBuyer } } = buyer; if (!hasAntiBriberyCodeOfConduct && !exporterHasTradedWithBuyer) { templateIds.underwritingTeam = UNDERWRITING_TEAM.NO_DOCUMENTS; @@ -6130,45 +6119,45 @@ var send4 = async (application2, xlsxPath) => { buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), buyerLocation: buyer.country?.name, companyName: replace_character_codes_with_characters_default(company.companyName), - requestedStartDate: format_date_default(policy.requestedStartDate), + requestedStartDate: format_date_default(policy.requestedStartDate) }; const sendOwnerEmailVars = { ...sharedEmailVars, buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), name: replace_character_codes_with_characters_default(get_full_name_string_default(owner)), - emailAddress: email, + emailAddress: email }; const sendContactEmailVars = { ...sharedEmailVars, buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), name: replace_character_codes_with_characters_default(get_full_name_string_default(policyContact)), - emailAddress: policyContact.email, + emailAddress: policyContact.email }; - console.info('Sending application submitted email to application account owner: %s', sendOwnerEmailVars.emailAddress); + console.info("Sending application submitted email to application account owner: %s", sendOwnerEmailVars.emailAddress); const accountSubmittedResponse = await emails_default.application.submittedEmail(sendOwnerEmailVars); if (!accountSubmittedResponse?.success) { - throw new Error('Sending application submitted email to owner/account'); + throw new Error("Sending application submitted email to owner/account"); } if (!policyContact.isSameAsOwner) { - console.info('Sending application submitted email to policy contact email: %s', sendContactEmailVars.emailAddress); + console.info("Sending application submitted email to policy contact email: %s", sendContactEmailVars.emailAddress); const contactSubmittedResponse = await emails_default.application.submittedEmail(sendContactEmailVars); if (!contactSubmittedResponse?.success) { - throw new Error('Sending application submitted email to contact'); + throw new Error("Sending application submitted email to contact"); } } const templateIds = get_application_submitted_email_template_ids_default(application2); const underwritingTeamSubmittedResponse = await emails_default.application.underwritingTeam(sendOwnerEmailVars, xlsxPath, templateIds.underwritingTeam); if (!underwritingTeamSubmittedResponse.success) { - throw new Error('Sending application submitted email to underwriting team'); + throw new Error("Sending application submitted email to underwriting team"); } if (templateIds.account) { - console.info('Sending documents email to application owner: %s', sendOwnerEmailVars.emailAddress); + console.info("Sending documents email to application owner: %s", sendOwnerEmailVars.emailAddress); const documentsResponse = await emails_default.documentsEmail(sendOwnerEmailVars, templateIds.account); if (!documentsResponse.success) { throw new Error(`Sending application documents emails ${documentsResponse}`); } if (!policyContact.isSameAsOwner) { - console.info('Sending documents email to policy contact: %s', sendContactEmailVars.emailAddress); + console.info("Sending documents email to policy contact: %s", sendContactEmailVars.emailAddress); const contactDocumentsResponse = await emails_default.documentsEmail(sendContactEmailVars, templateIds.account); if (!contactDocumentsResponse.success) { throw new Error(`Sending application documents emails to contact ${documentsResponse}`); @@ -6176,31 +6165,31 @@ var send4 = async (application2, xlsxPath) => { } } return { - success: true, + success: true }; } catch (error) { - console.error('Error sending application submitted emails %o', error); + console.error("Error sending application submitted emails %o", error); throw new Error(`Sending application submitted emails ${error}`); } }; var applicationSubmittedEmails = { - send: send4, + send: send4 }; var send_application_submitted_emails_default = applicationSubmittedEmails; // generate-xlsx/index.ts -var import_dotenv9 = __toESM(require('dotenv')); -var import_exceljs = __toESM(require('exceljs')); +var import_dotenv9 = __toESM(require("dotenv")); +var import_exceljs = __toESM(require("exceljs")); // constants/XLSX-CONFIG/SECTION_NAMES/index.ts var SECTION_NAMES = { - APPLICATION_INFORMATION: 'Application Information', - ELIGIBILITY: 'Eligibility', - EXPORTER_BUSINESS: 'The Business', - BUYER: 'The Buyer', - POLICY: 'Insurance Policy', - EXPORT_CONTRACT: 'Export Contract', - DECLARATIONS: 'Declarations', + APPLICATION_INFORMATION: "Application Information", + ELIGIBILITY: "Eligibility", + EXPORTER_BUSINESS: "The Business", + BUYER: "The Buyer", + POLICY: "Insurance Policy", + EXPORT_CONTRACT: "Export Contract", + DECLARATIONS: "Declarations" }; var SECTION_NAMES_default = SECTION_NAMES; @@ -6211,69 +6200,66 @@ var { AGREE_ANTI_BRIBERY, HAS_ANTI_BRIBERY_CODE_OF_CONDUCT, AGREE_CONFIRMATION_ACKNOWLEDGEMENTS, - WILL_EXPORT_WITH_CODE_OF_CONDUCT, - }, + WILL_EXPORT_WITH_CODE_OF_CONDUCT + } } = insurance_default; var DECLARATIONS_FIELDS = { [AGREE_CONFIDENTIALITY]: { SUMMARY: { - TITLE: 'Confidentiality', - }, + TITLE: "Confidentiality" + } }, [AGREE_ANTI_BRIBERY]: { SUMMARY: { - TITLE: 'Anti-bribery and corruption', - }, + TITLE: "Anti-bribery and corruption" + } }, [HAS_ANTI_BRIBERY_CODE_OF_CONDUCT]: { SUMMARY: { - TITLE: 'Do you have a code of conduct?', - }, + TITLE: "Do you have a code of conduct?" + } }, [WILL_EXPORT_WITH_CODE_OF_CONDUCT]: { SUMMARY: { - TITLE: 'Will you export using your code of conduct?', - }, + TITLE: "Will you export using your code of conduct?" + } }, [AGREE_CONFIRMATION_ACKNOWLEDGEMENTS]: { SUMMARY: { - TITLE: 'Confirmation and acknowledgements', - }, - }, + TITLE: "Confirmation and acknowledgements" + } + } }; // content-strings/links.ts var LINKS = { EXTERNAL: { - GUIDANCE: 'https://www.gov.uk/guidance/credit-insurance-policy#eligibility', - BEFORE_YOU_START: 'https://www.gov.uk/guidance/get-a-quote-for-ukef-credit-insurance', - PRIVACY: 'https://www.gov.uk/government/publications/ukef-privacy-notice/ukef-privacy-notice--2', - FEEDBACK: 'https://forms.office.com/r/TacytrRCgJ', - RESEARCH: 'https://forms.office.com/pages/responsepage.aspx?id=jhOEgACUnkCm2ka1KB4LCkj8OKxLpCpDmTbrMyQ3j2JUOUFHNUc0QUhUOFdLNkJXWkRUS0wyMUZFNiQlQCN0PWcu', - EXPORT_FINANCE_MANAGERS: 'https://www.gov.uk/government/publications/find-an-export-finance-manager', - APPROVED_BROKER_LIST: 'https://www.gov.uk/government/publications/uk-export-finance-insurance-list-of-approved-brokers/export-insurance-approved-brokers', - PROPOSAL_FORM: - 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1075267/10489_UKEF_Export_Insurance_Proposal_Form_20220513-fillable.pdf', - NBI_FORM: - 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1041659/export-insurance-non-binding-indication-request-form_20170609.pdf', - FULL_APPLICATION: 'https://www.gov.uk/guidance/apply-for-ukef-credit-insurance', - ABILITY_NET: 'https://mcmw.abilityNet.org.uk', - EQUALITY_ADVISORY_SERVICE: 'https://www.equalityadvisoryservice.com', - ACCESSIBILITY_GUIDLINES: 'https://www.w3.org/TR/WCAG21', - BRIBERY_ACT_2010_GUIDANCE: 'https://www.justice.gov.uk/downloads/legislation/bribery-act-2010-guidance.pdf', - ICO_MAKE_A_COMPLAINT: 'https://ico.org.uk/make-a-complaint', - COMPANIES_HOUSE: 'https://find-and-update.company-information.service.gov.uk', - }, + GUIDANCE: "https://www.gov.uk/guidance/credit-insurance-policy#eligibility", + BEFORE_YOU_START: "https://www.gov.uk/guidance/get-a-quote-for-ukef-credit-insurance", + PRIVACY: "https://www.gov.uk/government/publications/ukef-privacy-notice/ukef-privacy-notice--2", + FEEDBACK: "https://forms.office.com/r/TacytrRCgJ", + RESEARCH: "https://forms.office.com/pages/responsepage.aspx?id=jhOEgACUnkCm2ka1KB4LCkj8OKxLpCpDmTbrMyQ3j2JUOUFHNUc0QUhUOFdLNkJXWkRUS0wyMUZFNiQlQCN0PWcu", + EXPORT_FINANCE_MANAGERS: "https://www.gov.uk/government/publications/find-an-export-finance-manager", + APPROVED_BROKER_LIST: "https://www.gov.uk/government/publications/uk-export-finance-insurance-list-of-approved-brokers/export-insurance-approved-brokers", + PROPOSAL_FORM: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1075267/10489_UKEF_Export_Insurance_Proposal_Form_20220513-fillable.pdf", + NBI_FORM: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1041659/export-insurance-non-binding-indication-request-form_20170609.pdf", + FULL_APPLICATION: "https://www.gov.uk/guidance/apply-for-ukef-credit-insurance", + ABILITY_NET: "https://mcmw.abilityNet.org.uk", + EQUALITY_ADVISORY_SERVICE: "https://www.equalityadvisoryservice.com", + ACCESSIBILITY_GUIDLINES: "https://www.w3.org/TR/WCAG21", + BRIBERY_ACT_2010_GUIDANCE: "https://www.justice.gov.uk/downloads/legislation/bribery-act-2010-guidance.pdf", + ICO_MAKE_A_COMPLAINT: "https://ico.org.uk/make-a-complaint", + COMPANIES_HOUSE: "https://find-and-update.company-information.service.gov.uk" + } }; // helpers/format-currency/index.ts -var formatCurrency = (number, currencyCode, decimalPlaces) => - number.toLocaleString('en', { - style: 'currency', - currency: currencyCode, - minimumFractionDigits: decimalPlaces ?? 0, - maximumFractionDigits: decimalPlaces ?? 0, - }); +var formatCurrency = (number, currencyCode, decimalPlaces) => number.toLocaleString("en", { + style: "currency", + currency: currencyCode, + minimumFractionDigits: decimalPlaces ?? 0, + maximumFractionDigits: decimalPlaces ?? 0 +}); var format_currency_default = formatCurrency; // content-strings/fields/insurance/eligibility/index.ts @@ -6285,91 +6271,91 @@ var { COMPANIES_HOUSE_NUMBER, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE_FIELD_ID, HAS_END_BUYER, - HAS_COMPANIES_HOUSE_NUMBER, + HAS_COMPANIES_HOUSE_NUMBER } = insurance_default.ELIGIBILITY; var { COMPANY_NAME } = insurance_default.COMPANIES_HOUSE; var THRESHOLD = format_currency_default(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); var ELIGIBILITY_FIELDS = { [BUYER_COUNTRY]: { SUMMARY: { - TITLE: 'Buyer location', - }, + TITLE: "Buyer location" + } }, [VALID_EXPORTER_LOCATION]: { SUMMARY: { - TITLE: 'In UK, Channel Islands or Isle of Man', - }, + TITLE: "In UK, Channel Islands or Isle of Man" + } }, [HAS_MINIMUM_UK_GOODS_OR_SERVICES]: { SUMMARY: { - TITLE: 'UK goods or services', + TITLE: "UK goods or services" }, - ANSWER: 'At least 20%', + ANSWER: "At least 20%" }, [HAS_END_BUYER]: { HINT: "Sometimes, exporters supply goods to a client in an overseas market who will then sell them on. The exporter will not get paid by the buyer until they have been paid by this third party. We call this third party an 'end buyer'.", SUMMARY: { - TITLE: 'End buyer', - }, + TITLE: "End buyer" + } }, [COVER_PERIOD_FIELD_ID]: { OPTIONS: { BELOW: { ID: COVER_PERIOD.LESS_THAN_2_YEARS.DB_ID, VALUE: COVER_PERIOD.LESS_THAN_2_YEARS.DB_ID, - TEXT: COVER_PERIOD.LESS_THAN_2_YEARS.VALUE, + TEXT: COVER_PERIOD.LESS_THAN_2_YEARS.VALUE }, ABOVE: { ID: COVER_PERIOD.MORE_THAN_2_YEARS.DB_ID, VALUE: COVER_PERIOD.MORE_THAN_2_YEARS.DB_ID, - TEXT: COVER_PERIOD.MORE_THAN_2_YEARS.VALUE, - }, + TEXT: COVER_PERIOD.MORE_THAN_2_YEARS.VALUE + } }, SUMMARY: { - TITLE: 'Length of policy', - }, + TITLE: "Length of policy" + } }, [COMPANIES_HOUSE_NUMBER]: { HINT: { INTRO: "For example, 8989898 or SC907816. You'll find it on your incorporation certificate or on the", LINK: { - TEXT: 'Companies House website', - HREF: LINKS.EXTERNAL.COMPANIES_HOUSE, - }, + TEXT: "Companies House website", + HREF: LINKS.EXTERNAL.COMPANIES_HOUSE + } }, SUMMARY: { - TITLE: 'UK Companies House number', - }, + TITLE: "UK Companies House number" + } }, [HAS_COMPANIES_HOUSE_NUMBER]: { SUMMARY: { - TITLE: 'UK Companies House registration number and actively trading', - }, + TITLE: "UK Companies House registration number and actively trading" + } }, [COMPANY_NAME]: { SUMMARY: { - TITLE: 'Company name', - }, + TITLE: "Company name" + } }, [TOTAL_CONTRACT_VALUE_FIELD_ID]: { OPTIONS: { ABOVE: { ID: TOTAL_CONTRACT_VALUE.MORE_THAN_250K.DB_ID, VALUE: TOTAL_CONTRACT_VALUE.MORE_THAN_250K.DB_ID, - TEXT: `${THRESHOLD} and above`, + TEXT: `${THRESHOLD} and above` }, BELOW: { ID: TOTAL_CONTRACT_VALUE.LESS_THAN_250K.DB_ID, VALUE: TOTAL_CONTRACT_VALUE.LESS_THAN_250K.DB_ID, - TEXT: `Less than ${THRESHOLD}`, - }, + TEXT: `Less than ${THRESHOLD}` + } }, SUMMARY: { - TITLE: 'Total value to insure', + TITLE: "Total value to insure", ABOVE: `Above ${THRESHOLD}`, - BELOW: `Below ${THRESHOLD}`, - }, - }, + BELOW: `Below ${THRESHOLD}` + } + } }; // content-strings/fields/insurance/export-contract/index.ts @@ -6378,114 +6364,114 @@ var { HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD }, ABOUT_GOODS_OR_SERVICES: { DESCRIPTION, FINAL_DESTINATION_KNOWN, FINAL_DESTINATION }, HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION }, - PRIVATE_MARKET: { DECLINED_DESCRIPTION }, + PRIVATE_MARKET: { DECLINED_DESCRIPTION } } = export_contract_default; var EXPORT_CONTRACT_FIELDS = { HOW_WAS_THE_CONTRACT_AWARDED: { [AWARD_METHOD]: { - LEGEND: 'How was the contract awarded?', + LEGEND: "How was the contract awarded?", OPTIONS: { OPEN_TENDER: { ID: OPEN_TENDER.DB_ID, VALUE: OPEN_TENDER.DB_ID, - TEXT: OPEN_TENDER.VALUE, + TEXT: OPEN_TENDER.VALUE }, NEGOTIATED_CONTRACT: { ID: NEGOTIATED_CONTRACT.DB_ID, VALUE: NEGOTIATED_CONTRACT.DB_ID, - TEXT: NEGOTIATED_CONTRACT.VALUE, + TEXT: NEGOTIATED_CONTRACT.VALUE }, DIRECT_AWARD: { ID: DIRECT_AWARD.DB_ID, VALUE: DIRECT_AWARD.DB_ID, - TEXT: DIRECT_AWARD.VALUE, + TEXT: DIRECT_AWARD.VALUE }, COMPETITIVE_BIDDING: { ID: COMPETITIVE_BIDDING.DB_ID, VALUE: COMPETITIVE_BIDDING.DB_ID, - TEXT: COMPETITIVE_BIDDING.VALUE, + TEXT: COMPETITIVE_BIDDING.VALUE }, OTHER: { ID: OTHER.DB_ID, VALUE: OTHER.DB_ID, - TEXT: OTHER.VALUE, - }, + TEXT: OTHER.VALUE + } }, SUMMARY: { - TITLE: 'How was the contract awarded', - }, - }, + TITLE: "How was the contract awarded" + } + } }, ABOUT_GOODS_OR_SERVICES: { [DESCRIPTION]: { LABEL: "Describe the goods or services you're exporting and explain how they'll be used by the buyer", HINT: { - INTRO: 'For example:', + INTRO: "For example:", LIST: [ - 'fast moving consumer goods, like vegan protein bars', - 'construction materials to build commercial property', - 'educational services such as teacher training', + "fast moving consumer goods, like vegan protein bars", + "construction materials to build commercial property", + "educational services such as teacher training" ], - OUTRO: "We may contact you to get more information if you're exporting goods or services that might have an impact on the environment.", + OUTRO: "We may contact you to get more information if you're exporting goods or services that might have an impact on the environment." }, MAXIMUM: 1e3, SUMMARY: { - TITLE: "Goods or services you're exporting", - }, + TITLE: "Goods or services you're exporting" + } }, [FINAL_DESTINATION_KNOWN]: { - LABEL: 'Do you know the final destination of the goods or services?', + LABEL: "Do you know the final destination of the goods or services?" }, [FINAL_DESTINATION]: { LABEL: "What's the final destination of the goods or services?", SUMMARY: { - TITLE: 'Final destination of goods or services', - }, - }, + TITLE: "Final destination of goods or services" + } + } }, HOW_WILL_YOU_GET_PAID: { [PAYMENT_TERMS_DESCRIPTION]: { HINT: { - INTRO: 'Types of payment terms include:', - LIST: ['payments that are due within 60 days from date of invoice', 'payments collected by a letter of credit', 'staged payments'], - OUTRO: "If you use staged payments, explain their structure and whether they're monthly, in advance or something else.", - }, - }, + INTRO: "Types of payment terms include:", + LIST: ["payments that are due within 60 days from date of invoice", "payments collected by a letter of credit", "staged payments"], + OUTRO: "If you use staged payments, explain their structure and whether they're monthly, in advance or something else." + } + } }, PRIVATE_MARKET: { [DECLINED_DESCRIPTION]: { - HINT: "Tell us about the best quote you received and why you were unable to use it. For example, your current policy might not cover the country you're exporting to.", - }, - }, + HINT: "Tell us about the best quote you received and why you were unable to use it. For example, your current policy might not cover the country you're exporting to." + } + } }; // content-strings/form-titles.ts var FORM_TITLES = { YOUR_BUSINESS: { - COMPANY_DETAILS: 'Company details', - NATURE_OF_BUSINESS: 'Nature of your business', - TURNOVER: 'Turnover', - CREDIT_CONTROL: 'Credit control', + COMPANY_DETAILS: "Company details", + NATURE_OF_BUSINESS: "Nature of your business", + TURNOVER: "Turnover", + CREDIT_CONTROL: "Credit control" }, YOUR_BUYER: { - COMPANY_DETAILS: 'Company details', - CONNECTION_TO_BUYER: 'Connection to the buyer', - TRADING_HISTORY: 'Trading history', - CREDIT_INSURANCE_HISTORY: 'Credit insurance history', - FINANCIAL_ACCOUNTS: 'Financial accounts', + COMPANY_DETAILS: "Company details", + CONNECTION_TO_BUYER: "Connection to the buyer", + TRADING_HISTORY: "Trading history", + CREDIT_INSURANCE_HISTORY: "Credit insurance history", + FINANCIAL_ACCOUNTS: "Financial accounts" }, POLICY: { - CONTRACT_POLICY: 'Requested insurance policy', - NAME_ON_POLICY: 'Named person on the policy', - BROKER: 'Broker', - OTHER_COMPANY: 'Other company to be insured', - LOSS_PAYEE: 'Loss payee', + CONTRACT_POLICY: "Requested insurance policy", + NAME_ON_POLICY: "Named person on the policy", + BROKER: "Broker", + OTHER_COMPANY: "Other company to be insured", + LOSS_PAYEE: "Loss payee" }, EXPORT_CONTRACT: { - ABOUT_THE_EXPORT: 'About the export', - PRIVATE_MARKET: 'Private insurance market', - AGENT: 'Agent', - }, + ABOUT_THE_EXPORT: "About the export", + PRIVATE_MARKET: "Private insurance market", + AGENT: "Agent" + } }; // content-strings/fields/insurance/policy/index.ts @@ -6509,12 +6495,12 @@ var { LOSS_PAYEE_DETAILS: { NAME: LOSS_PAYEE_NAME, LOCATION, IS_LOCATED_IN_UK, IS_LOCATED_INTERNATIONALLY }, LOSS_PAYEE_FINANCIAL_UK: { SORT_CODE, ACCOUNT_NUMBER }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { BIC_SWIFT_CODE, IBAN }, - FINANCIAL_ADDRESS, - }, + FINANCIAL_ADDRESS + } } = insurance_default; var { MAX_COVER_PERIOD_MONTHS } = ELIGIBILITY; var { - POLICY: { TOTAL_MONTHS_OF_COVER }, + POLICY: { TOTAL_MONTHS_OF_COVER } } = APPLICATION; var { POLICY: POLICY_FORM_TITLES } = FORM_TITLES; var POLICY_FIELDS = { @@ -6524,432 +6510,424 @@ var POLICY_FIELDS = { SINGLE: { ID: SINGLE_POLICY_TYPE, VALUE: FIELD_VALUES.POLICY_TYPE.SINGLE, - TEXT: 'Single contract policy', + TEXT: "Single contract policy", HINT_LIST: [ - 'Covers a single contract with a buyer, for one or more shipments', + "Covers a single contract with a buyer, for one or more shipments", `Cover for up to ${MAX_COVER_PERIOD_MONTHS} months`, - 'Best for a one off- project, when you know the exact value of your export contract now', - 'You pay for the insurance before the policy starts', - ], + "Best for a one off- project, when you know the exact value of your export contract now", + "You pay for the insurance before the policy starts" + ] }, MULTIPLE: { ID: MULTIPLE_POLICY_TYPE, VALUE: FIELD_VALUES.POLICY_TYPE.MULTIPLE, - TEXT: 'Multiple contract policy (Revolving credit)', + TEXT: "Multiple contract policy (Revolving credit)", HINT_LIST: [ `Covers multiple contracts with the same buyer, usually for ${TOTAL_MONTHS_OF_COVER.MAXIMUM} months`, "Best if you'll have an ongoing relationship with the buyer but you're not sure yet how many contracts or sales you'll have", - 'You only pay for your insurance each time you declare a new contract or sale - no need to pay before the policy starts', - ], - }, + "You only pay for your insurance each time you declare a new contract or sale - no need to pay before the policy starts" + ] + } }, SUMMARY: { - TITLE: 'Policy type', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, + TITLE: "Policy type", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } }, CONTRACT_POLICY: { [CONTRACT_POLICY.REQUESTED_START_DATE]: { - LABEL: 'When do you want your policy to start?', - HINT: 'For example, 06 11 2023', + LABEL: "When do you want your policy to start?", + HINT: "For example, 06 11 2023", SUMMARY: { - TITLE: 'Policy start date', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, + TITLE: "Policy start date", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } }, [CURRENCY_CODE]: { LEGEND: "Select currency you'd like your policy to be issued in", - HINT: 'This is the currency your policy will be issued in', + HINT: "This is the currency your policy will be issued in", SUMMARY: { - TITLE: 'Policy currency', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + TITLE: "Policy currency", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY }, [ALTERNATIVE_CURRENCY_CODE]: { ID: ALTERNATIVE_CURRENCY_CODE, - VALUE: ALTERNATIVE_CURRENCY_CODE, - }, + VALUE: ALTERNATIVE_CURRENCY_CODE + } }, SINGLE: { [CONTRACT_POLICY.SINGLE.CONTRACT_COMPLETION_DATE]: { - LABEL: 'When do you expect to complete the export contract?', - HINT: 'For example, 06 11 2024', + LABEL: "When do you expect to complete the export contract?", + HINT: "For example, 06 11 2024", SUMMARY: { - TITLE: 'Date you expect it to complete', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, + TITLE: "Date you expect it to complete", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } }, [CONTRACT_POLICY.SINGLE.TOTAL_CONTRACT_VALUE]: { LABEL: "What's the total value of the contract you want to insure?", - HINT: 'Enter a whole number. Do not enter decimals.', + HINT: "Enter a whole number. Do not enter decimals.", SUMMARY: { - TITLE: 'Contract value', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, + TITLE: "Contract value", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } }, [CONTRACT_POLICY.SINGLE.REQUESTED_CREDIT_LIMIT]: { - LABEL: 'What credit limit do you require?', + LABEL: "What credit limit do you require?", HINT: { - INTRO: 'For example, your total contract maybe \xA3250,000 but the amount you want to insure is \xA3100,000.', - OUTRO: 'Enter a whole number. Do not enter decimals.', + INTRO: "For example, your total contract maybe \xA3250,000 but the amount you want to insure is \xA3100,000.", + OUTRO: "Enter a whole number. Do not enter decimals." }, SUMMARY: { - TITLE: 'Credit limit', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, - }, + TITLE: "Credit limit", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } + } }, MULTIPLE: { [CONTRACT_POLICY.MULTIPLE.TOTAL_MONTHS_OF_COVER]: { - LABEL: 'How many months do you want to be insured for?', + LABEL: "How many months do you want to be insured for?", HINT: `The maximum is ${TOTAL_MONTHS_OF_COVER.MAXIMUM} months.`, OPTIONS: FIELD_VALUES.TOTAL_MONTHS_OF_COVER, SUMMARY: { - TITLE: 'How many months you want to be insured for', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, - }, - }, + TITLE: "How many months you want to be insured for", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } + } + } }, EXPORT_VALUE: { MULTIPLE: { [EXPORT_VALUE.MULTIPLE.TOTAL_SALES_TO_BUYER]: { - LABEL: 'Estimate total sales to your buyer during this time', - HINT: 'Enter a whole number. Do not enter decimals.', + LABEL: "Estimate total sales to your buyer during this time", + HINT: "Enter a whole number. Do not enter decimals.", SUMMARY: { - TITLE: 'Estimated total sales to the buyer', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, + TITLE: "Estimated total sales to the buyer", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } }, [EXPORT_VALUE.MULTIPLE.MAXIMUM_BUYER_WILL_OWE]: { - LABEL: 'Estimate the maximum amount your buyer will owe you at any single point during this time', + LABEL: "Estimate the maximum amount your buyer will owe you at any single point during this time", HINT: { - FOR_EXAMPLE: 'For example, your total sales might be \xA3250,000 but the maximum the buyer will owe you at any single point is \xA3100,000.', - NO_DECIMALS: 'Enter a whole number. Do not enter decimals.', + FOR_EXAMPLE: "For example, your total sales might be \xA3250,000 but the maximum the buyer will owe you at any single point is \xA3100,000.", + NO_DECIMALS: "Enter a whole number. Do not enter decimals." }, SUMMARY: { - TITLE: 'Estimated maximum amount owed by the buyer', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, - }, - }, + TITLE: "Estimated maximum amount owed by the buyer", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } + } + } }, NAME_ON_POLICY: { OPTIONS: { SAME_NAME: { ID: NAME_ON_POLICY.SAME_NAME, - VALUE: NAME_ON_POLICY.SAME_NAME, + VALUE: NAME_ON_POLICY.SAME_NAME }, OTHER_NAME: { ID: NAME_ON_POLICY.OTHER_NAME, VALUE: NAME_ON_POLICY.OTHER_NAME, - TEXT: 'Someone else', - }, + TEXT: "Someone else" + } }, [NAME_ON_POLICY.POSITION]: { LABEL: "What's your position at the company?", MAXIMUM: MAXIMUM_CHARACTERS.NAME_ON_POLICY_POSITION, SUMMARY: { - TITLE: 'Position at company', - FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY, - }, + TITLE: "Position at company", + FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY + } }, [NAME_ON_POLICY.NAME]: { SUMMARY: { - TITLE: 'Contact name', - FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY, - }, - }, + TITLE: "Contact name", + FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY + } + } }, DIFFERENT_NAME_ON_POLICY: { [DIFFERENT_NAME_ON_POLICY.POSITION]: { - LABEL: 'Position at company', - MAXIMUM: MAXIMUM_CHARACTERS.DIFFERENT_NAME_ON_POLICY, + LABEL: "Position at company", + MAXIMUM: MAXIMUM_CHARACTERS.DIFFERENT_NAME_ON_POLICY }, [EMAIL3]: { SUMMARY: { - TITLE: 'Contact email', - FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY, - }, - }, + TITLE: "Contact email", + FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY + } + } }, [NEED_PRE_CREDIT_PERIOD]: { - HINT: 'This is known as the pre-credit period', + HINT: "This is known as the pre-credit period", SUMMARY: { - TITLE: 'Pre-credit period', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, - }, + TITLE: "Pre-credit period", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + } }, [CREDIT_PERIOD_WITH_BUYER]: { - LABEL: 'How long do you need pre-credit cover for?', + LABEL: "How long do you need pre-credit cover for?", SUMMARY: { - TITLE: 'Period of pre-credit cover', - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + TITLE: "Period of pre-credit cover", + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY }, - MAXIMUM: MAXIMUM_CHARACTERS.CREDIT_PERIOD_WITH_BUYER, + MAXIMUM: MAXIMUM_CHARACTERS.CREDIT_PERIOD_WITH_BUYER }, REQUESTED_JOINTLY_INSURED_PARTY: { [REQUESTED]: { - HINT: 'This could be a parent company, subsidiary or a subcontractor.', + HINT: "This could be a parent company, subsidiary or a subcontractor.", SUMMARY: { - TITLE: 'Another company to be insured', - }, + TITLE: "Another company to be insured" + } }, [COMPANY_NAME2]: { - LABEL: 'Name of the other company', + LABEL: "Name of the other company", MAXIMUM: MAXIMUM_CHARACTERS.REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NAME, SUMMARY: { - TITLE: 'Name of the other company', - }, + TITLE: "Name of the other company" + } }, [COMPANY_NUMBER]: { - LABEL: 'Registration number of the other company (optional)', + LABEL: "Registration number of the other company (optional)", MAXIMUM: MAXIMUM_CHARACTERS.REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NUMBER, SUMMARY: { - TITLE: 'Registration number of the other company', - }, + TITLE: "Registration number of the other company" + } }, [COUNTRY_CODE]: { - LABEL: 'What country is the other company based in?', + LABEL: "What country is the other company based in?", SUMMARY: { - TITLE: 'Country of the company', - }, - }, + TITLE: "Country of the company" + } + } }, BROKER: { [USING_BROKER]: { - LABEL: 'Are you using a broker to get this insurance?', + LABEL: "Are you using a broker to get this insurance?", SUMMARY: { - TITLE: 'Using a broker', - FORM_TITLE: POLICY_FORM_TITLES.BROKER, - }, - }, + TITLE: "Using a broker", + FORM_TITLE: POLICY_FORM_TITLES.BROKER + } + } }, BROKER_DETAILS: { [NAME]: { - LABEL: 'Name of broker or company', + LABEL: "Name of broker or company", MAXIMUM: MAXIMUM_CHARACTERS.BROKER_NAME, SUMMARY: { TITLE: "Broker's name or company", - FORM_TITLE: POLICY_FORM_TITLES.BROKER, - }, + FORM_TITLE: POLICY_FORM_TITLES.BROKER + } }, [EMAIL3]: { - LABEL: 'Email address', + LABEL: "Email address", SUMMARY: { TITLE: "Broker's email", - FORM_TITLE: POLICY_FORM_TITLES.BROKER, - }, + FORM_TITLE: POLICY_FORM_TITLES.BROKER + } }, [FULL_ADDRESS]: { LABEL: "Broker's address", SUMMARY: { TITLE: "Broker's address", - FORM_TITLE: POLICY_FORM_TITLES.BROKER, + FORM_TITLE: POLICY_FORM_TITLES.BROKER }, - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, - }, + MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS + } }, LOSS_PAYEE: { [IS_APPOINTED]: { HINT: { - INTRO: - 'A loss payee is a financial organisation, like a bank or a lender, who will be paid in the event of a valid claim. A loss payee could also be a parent company or subsidiary of your business.', - OUTRO: "Not every policy has a loss payee. If you don't, select 'No' and you will be listed as the default claimant.", + INTRO: "A loss payee is a financial organisation, like a bank or a lender, who will be paid in the event of a valid claim. A loss payee could also be a parent company or subsidiary of your business.", + OUTRO: "Not every policy has a loss payee. If you don't, select 'No' and you will be listed as the default claimant." }, SUMMARY: { - TITLE: 'Appointed a loss payee', - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, - }, + TITLE: "Appointed a loss payee", + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } + } }, LOSS_PAYEE_DETAILS: { [LOSS_PAYEE_NAME]: { - LABEL: 'Name of the loss payee', + LABEL: "Name of the loss payee", MAXIMUM: MAXIMUM_CHARACTERS.LOSS_PAYEE_NAME, SUMMARY: { - TITLE: 'Name of the loss payee', - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, + TITLE: "Name of the loss payee", + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } }, [LOCATION]: { - LABEL: 'Where is the loss payee located?', + LABEL: "Where is the loss payee located?", OPTIONS: { UK: { ID: IS_LOCATED_IN_UK, VALUE: IS_LOCATED_IN_UK, - TEXT: 'United Kingdom', + TEXT: "United Kingdom" }, INTERNATIONALLY: { ID: IS_LOCATED_INTERNATIONALLY, VALUE: IS_LOCATED_INTERNATIONALLY, - TEXT: 'International', - }, - }, - }, + TEXT: "International" + } + } + } }, LOSS_PAYEE_FINANCIAL_UK: { [SORT_CODE]: { - LABEL: 'Sort code', - HINT: 'Must be 6 digits long', + LABEL: "Sort code", + HINT: "Must be 6 digits long", SUMMARY: { - TITLE: 'Sort code', - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, + TITLE: "Sort code", + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } }, [ACCOUNT_NUMBER]: { - LABEL: 'Account number', - HINT: 'Must be between 6 and 8 digits long', + LABEL: "Account number", + HINT: "Must be between 6 and 8 digits long", SUMMARY: { - TITLE: 'Account number', - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, + TITLE: "Account number", + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } }, [FINANCIAL_ADDRESS]: { SUMMARY: { TITLE: "Loss payee's bank based in the UK", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, - }, + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } + } }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { [BIC_SWIFT_CODE]: { - LABEL: 'BIC or SWIFT code', - HINT: 'Must be between 8 and 11 characters long', + LABEL: "BIC or SWIFT code", + HINT: "Must be between 8 and 11 characters long", SUMMARY: { - TITLE: 'BIC or SWIFT code', - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, + TITLE: "BIC or SWIFT code", + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } }, [IBAN]: { - LABEL: 'IBAN', - HINT: 'Must be between 16 and 34 characters long', + LABEL: "IBAN", + HINT: "Must be between 16 and 34 characters long", SUMMARY: { - TITLE: 'IBAN', - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, + TITLE: "IBAN", + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } }, [FINANCIAL_ADDRESS]: { SUMMARY: { TITLE: "Loss payee's bank based internationally", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, - }, - }, + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE + } + } }, FINANCIAL_ADDRESS: { - LABEL: 'Bank address', - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, - }, + LABEL: "Bank address", + MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS + } }; // content-strings/fields/insurance/your-business/index.ts var { - COMPANIES_HOUSE: { - COMPANY_NAME: COMPANY_NAME3, - COMPANY_NUMBER: COMPANY_NUMBER2, - COMPANY_INCORPORATED, - COMPANY_SIC, - COMPANY_ADDRESS, - FINANCIAL_YEAR_END_DATE, - }, - EXPORTER_BUSINESS: EXPORTER_BUSINESS2, + COMPANIES_HOUSE: { COMPANY_NAME: COMPANY_NAME3, COMPANY_NUMBER: COMPANY_NUMBER2, COMPANY_INCORPORATED, COMPANY_SIC, COMPANY_ADDRESS, FINANCIAL_YEAR_END_DATE }, + EXPORTER_BUSINESS: EXPORTER_BUSINESS2 } = insurance_default; var { YOUR_COMPANY: { HAS_DIFFERENT_TRADING_ADDRESS, HAS_DIFFERENT_TRADING_NAME, PHONE_NUMBER, WEBSITE }, ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: FULL_ADDRESS2 }, NATURE_OF_YOUR_BUSINESS: { GOODS_OR_SERVICES, YEARS_EXPORTING, EMPLOYEES_UK }, TURNOVER: { ESTIMATED_ANNUAL_TURNOVER, PERCENTAGE_TURNOVER }, - HAS_CREDIT_CONTROL, + HAS_CREDIT_CONTROL } = EXPORTER_BUSINESS2; var EXPORTER_BUSINESS_FIELDS = { COMPANY_DETAILS: { [COMPANY_NUMBER2]: { SUMMARY: { - TITLE: 'Companies House registration number', - }, + TITLE: "Companies House registration number" + } }, [COMPANY_NAME3]: { SUMMARY: { - TITLE: 'Company name', - }, + TITLE: "Company name" + } }, [COMPANY_ADDRESS]: { SUMMARY: { - TITLE: 'Registered office address', - }, + TITLE: "Registered office address" + } }, [COMPANY_INCORPORATED]: { SUMMARY: { - TITLE: 'Date incorporated', - }, + TITLE: "Date incorporated" + } }, [COMPANY_SIC]: { SUMMARY: { - TITLE: 'Standard industry classification (SIC) codes and nature of business', - }, + TITLE: "Standard industry classification (SIC) codes and nature of business" + } }, [FINANCIAL_YEAR_END_DATE]: { SUMMARY: { - TITLE: 'Financial year end date', - }, + TITLE: "Financial year end date" + } }, [HAS_DIFFERENT_TRADING_NAME]: { SUMMARY: { - TITLE: 'Different trading name', - }, + TITLE: "Different trading name" + } }, [HAS_DIFFERENT_TRADING_ADDRESS]: { SUMMARY: { - TITLE: 'Different trading address', - }, + TITLE: "Different trading address" + } }, [WEBSITE]: { SUMMARY: { - TITLE: 'Company website (optional)', - }, + TITLE: "Company website (optional)" + } }, [PHONE_NUMBER]: { SUMMARY: { - TITLE: 'UK telephone number (optional)', - }, - }, + TITLE: "UK telephone number (optional)" + } + } }, [FULL_ADDRESS2]: { - LABEL: "What's your alternative trading address?", + LABEL: "What's your alternative trading address?" }, NATURE_OF_YOUR_BUSINESS: { [GOODS_OR_SERVICES]: { SUMMARY: { - TITLE: 'Goods or services your business supplies', - }, + TITLE: "Goods or services your business supplies" + } }, [YEARS_EXPORTING]: { SUMMARY: { - TITLE: 'Years exporting', - }, + TITLE: "Years exporting" + } }, [EMPLOYEES_UK]: { SUMMARY: { - TITLE: 'Number of UK employees', - }, - }, + TITLE: "Number of UK employees" + } + } }, TURNOVER: { [ESTIMATED_ANNUAL_TURNOVER]: { SUMMARY: { - TITLE: 'Estimated turnover this current financial year', - }, + TITLE: "Estimated turnover this current financial year" + } }, [PERCENTAGE_TURNOVER]: { SUMMARY: { - TITLE: 'Percentage of turnover from exports', - }, - }, + TITLE: "Percentage of turnover from exports" + } + } }, [HAS_CREDIT_CONTROL]: { SUMMARY: { - TITLE: 'Process for managing late payments', - }, - }, + TITLE: "Process for managing late payments" + } + } }; // content-strings/fields/insurance/your-buyer/index.ts @@ -6965,163 +6943,163 @@ var { PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER, TOTAL_OUTSTANDING_PAYMENTS, TOTAL_AMOUNT_OVERDUE, - HAS_BUYER_FINANCIAL_ACCOUNTS, + HAS_BUYER_FINANCIAL_ACCOUNTS }, - CURRENCY: { CURRENCY_CODE: CURRENCY_CODE2 }, + CURRENCY: { CURRENCY_CODE: CURRENCY_CODE2 } } = FIELD_IDS.INSURANCE; var { - YOUR_BUYER: { COMPANY_DETAILS, TRADING_HISTORY, CONNECTION_TO_BUYER, CREDIT_INSURANCE_HISTORY, FINANCIAL_ACCOUNTS }, + YOUR_BUYER: { COMPANY_DETAILS, TRADING_HISTORY, CONNECTION_TO_BUYER, CREDIT_INSURANCE_HISTORY, FINANCIAL_ACCOUNTS } } = FORM_TITLES; var YOUR_BUYER_FIELDS = { COMPANY_OR_ORGANISATION: { [COMPANY_OR_ORGANISATION.NAME]: { LABEL: "Buyer's company or organisation name", SUMMARY: { - TITLE: 'Company or organisation name', - FORM_TITLE: COMPANY_DETAILS, - }, + TITLE: "Company or organisation name", + FORM_TITLE: COMPANY_DETAILS + } }, [COMPANY_OR_ORGANISATION.ADDRESS]: { - LABEL: 'Company address', + LABEL: "Company address", SUMMARY: { - TITLE: 'Buyer address', - FORM_TITLE: COMPANY_DETAILS, + TITLE: "Buyer address", + FORM_TITLE: COMPANY_DETAILS }, - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, + MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS }, [COMPANY_OR_ORGANISATION.COUNTRY]: { - LABEL: 'Buyer country', + LABEL: "Buyer country", SUMMARY: { - TITLE: 'Buyer country', - }, + TITLE: "Buyer country" + } }, [COMPANY_OR_ORGANISATION.REGISTRATION_NUMBER]: { - LABEL: 'Company registration number (optional)', + LABEL: "Company registration number (optional)", SUMMARY: { - TITLE: 'Registration number (optional)', - FORM_TITLE: COMPANY_DETAILS, + TITLE: "Registration number (optional)", + FORM_TITLE: COMPANY_DETAILS }, - MAXIMUM: MAXIMUM_CHARACTERS.BUYER.REGISTRATION_NUMBER, + MAXIMUM: MAXIMUM_CHARACTERS.BUYER.REGISTRATION_NUMBER }, [COMPANY_OR_ORGANISATION.WEBSITE]: { - LABEL: 'Enter their website (optional)', + LABEL: "Enter their website (optional)", SUMMARY: { - TITLE: 'Buyer website (optional)', - FORM_TITLE: COMPANY_DETAILS, - }, - }, + TITLE: "Buyer website (optional)", + FORM_TITLE: COMPANY_DETAILS + } + } }, [CONNECTION_WITH_BUYER]: { - LABEL: 'Are you connected with the buyer in any way?', + LABEL: "Are you connected with the buyer in any way?", HINT: { - INTRO: 'For example:', + INTRO: "For example:", LIST: [ "someone in your company is a shareholder or director of the buyer's company", - "someone in the buyer's company is a shareholder or director of your company", - ], + "someone in the buyer's company is a shareholder or director of your company" + ] }, SUMMARY: { - TITLE: 'Connected with the buyer', - FORM_TITLE: CONNECTION_TO_BUYER, - }, + TITLE: "Connected with the buyer", + FORM_TITLE: CONNECTION_TO_BUYER + } }, [CONNECTION_WITH_BUYER_DESCRIPTION]: { - LABEL: 'Describe the connection with the buyer', + LABEL: "Describe the connection with the buyer", MAXIMUM: MAXIMUM_CHARACTERS.CONNECTION_WITH_BUYER_DESCRIPTION, SUMMARY: { - TITLE: 'Details of connection', - FORM_TITLE: CONNECTION_TO_BUYER, - }, + TITLE: "Details of connection", + FORM_TITLE: CONNECTION_TO_BUYER + } }, [TRADED_WITH_BUYER]: { - LABEL: 'Have you traded with this buyer before?', - HINT: 'If yes, we will request a copy of your trading history once the application has been submitted.', + LABEL: "Have you traded with this buyer before?", + HINT: "If yes, we will request a copy of your trading history once the application has been submitted.", SUMMARY: { - TITLE: 'Trading history', - FORM_TITLE: TRADING_HISTORY, - }, + TITLE: "Trading history", + FORM_TITLE: TRADING_HISTORY + } }, [OUTSTANDING_PAYMENTS]: { - LABEL: 'Do you currently have any outstanding or overdue payments from the buyer?', + LABEL: "Do you currently have any outstanding or overdue payments from the buyer?", SUMMARY: { - TITLE: 'Outstanding or overdue payments', - FORM_TITLE: TRADING_HISTORY, - }, + TITLE: "Outstanding or overdue payments", + FORM_TITLE: TRADING_HISTORY + } }, [FAILED_PAYMENTS]: { - HINT: 'This is when an invoice has still not been paid 30 days or more after the agreed payment date.', + HINT: "This is when an invoice has still not been paid 30 days or more after the agreed payment date.", SUMMARY: { - TITLE: 'Buyer failed to pay on time?', - FORM_TITLE: TRADING_HISTORY, - }, + TITLE: "Buyer failed to pay on time?", + FORM_TITLE: TRADING_HISTORY + } }, [CURRENCY_CODE2]: { - LEGEND: 'What is the currency the outstanding or overdue payments are in?', + LEGEND: "What is the currency the outstanding or overdue payments are in?", SUMMARY: { - TITLE: 'Outstanding payments currency', - FORM_TITLE: TRADING_HISTORY, - }, + TITLE: "Outstanding payments currency", + FORM_TITLE: TRADING_HISTORY + } }, [HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER]: { - LABEL: 'Have you in the past held credit insurance cover on the buyer?', + LABEL: "Have you in the past held credit insurance cover on the buyer?", SUMMARY: { - TITLE: 'Credit insurance previously held for the buyer', - FORM_TITLE: CREDIT_INSURANCE_HISTORY, - }, + TITLE: "Credit insurance previously held for the buyer", + FORM_TITLE: CREDIT_INSURANCE_HISTORY + } }, [PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER]: { - LABEL: 'Tell us about the credit insurance cover you had on the buyer', - HINT: 'Include the name of the insurer(s) and the credit limit.', + LABEL: "Tell us about the credit insurance cover you had on the buyer", + HINT: "Include the name of the insurer(s) and the credit limit.", SUMMARY: { - TITLE: 'Details of credit insurance', - FORM_TITLE: CREDIT_INSURANCE_HISTORY, + TITLE: "Details of credit insurance", + FORM_TITLE: CREDIT_INSURANCE_HISTORY }, - MAXIMUM: MAXIMUM_CHARACTERS.BUYER.PREVIOUS_CREDIT_INSURANCE_COVER, + MAXIMUM: MAXIMUM_CHARACTERS.BUYER.PREVIOUS_CREDIT_INSURANCE_COVER }, [TOTAL_OUTSTANDING_PAYMENTS]: { - LABEL: 'Total outstanding, including overdue in', - HINT: 'Enter a whole number. Do not enter decimals.', + LABEL: "Total outstanding, including overdue in", + HINT: "Enter a whole number. Do not enter decimals.", SUMMARY: { - TITLE: 'Total outstanding including overdue', - FORM_TITLE: TRADING_HISTORY, - }, + TITLE: "Total outstanding including overdue", + FORM_TITLE: TRADING_HISTORY + } }, [TOTAL_AMOUNT_OVERDUE]: { - LABEL: 'Amount overdue in', - HINT: 'Enter a whole number. Do not enter decimals.', + LABEL: "Amount overdue in", + HINT: "Enter a whole number. Do not enter decimals.", SUMMARY: { - TITLE: 'Amount overdue', - FORM_TITLE: TRADING_HISTORY, - }, + TITLE: "Amount overdue", + FORM_TITLE: TRADING_HISTORY + } }, [HAS_BUYER_FINANCIAL_ACCOUNTS]: { SUMMARY: { - TITLE: 'Financial accounts relating to the buyer', - FORM_TITLE: FINANCIAL_ACCOUNTS, - }, - }, + TITLE: "Financial accounts relating to the buyer", + FORM_TITLE: FINANCIAL_ACCOUNTS + } + } }; // content-strings/fields/insurance/index.ts var REFERENCE_NUMBER = { SUMMARY: { - TITLE: 'Application reference number', - }, + TITLE: "Application reference number" + } }; var DATE_SUBMITTED = { SUMMARY: { - TITLE: 'Date submitted', - }, + TITLE: "Date submitted" + } }; var TIME_SUBMITTED = { SUMMARY: { - TITLE: 'Time submitted', - }, + TITLE: "Time submitted" + } }; // content-strings/default.ts var DEFAULT = { - EMPTY: '-', + EMPTY: "-" }; // content-strings/XLSX.ts @@ -7136,7 +7114,7 @@ var { HAS_END_BUYER: HAS_END_BUYER2, HAS_MINIMUM_UK_GOODS_OR_SERVICES: HAS_MINIMUM_UK_GOODS_OR_SERVICES2, IS_MEMBER_OF_A_GROUP, - IS_PARTY_TO_CONSORTIUM, + IS_PARTY_TO_CONSORTIUM }, EXPORT_CONTRACT: { ABOUT_GOODS_OR_SERVICES: { DESCRIPTION: DESCRIPTION2, FINAL_DESTINATION_KNOWN: FINAL_DESTINATION_KNOWN2 }, @@ -7145,7 +7123,7 @@ var { AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION }, HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION: PAYMENT_TERMS_DESCRIPTION2 }, PRIVATE_MARKET: { ATTEMPTED: ATTEMPTED_PRIVATE_MARKET, DECLINED_DESCRIPTION: DECLINED_DESCRIPTION2 }, - USING_AGENT, + USING_AGENT }, EXPORTER_BUSINESS: { ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS_DOT_NOTATION }, @@ -7153,23 +7131,17 @@ var { HAS_CREDIT_CONTROL: HAS_CREDIT_CONTROL2, NATURE_OF_YOUR_BUSINESS: { GOODS_OR_SERVICES: GOODS_OR_SERVICES2, YEARS_EXPORTING: YEARS_EXPORTING2, EMPLOYEES_UK: EMPLOYEES_UK2 }, TURNOVER: { ESTIMATED_ANNUAL_TURNOVER: ESTIMATED_ANNUAL_TURNOVER2 }, - YOUR_COMPANY: { - HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME2, - DIFFERENT_TRADING_NAME, - PHONE_NUMBER: PHONE_NUMBER2, - HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS2, - WEBSITE: WEBSITE2, - }, + YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME2, DIFFERENT_TRADING_NAME, PHONE_NUMBER: PHONE_NUMBER2, HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS2, WEBSITE: WEBSITE2 } }, POLICY: { BROKER_DETAILS: { NAME: BROKER_NAME, EMAIL: BROKER_EMAIL, FULL_ADDRESS: BROKER_ADDRESS }, CONTRACT_POLICY: { REQUESTED_START_DATE: REQUESTED_START_DATE2, SINGLE: { CONTRACT_COMPLETION_DATE: CONTRACT_COMPLETION_DATE2, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE_ID }, - MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER2 }, + MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER2 } }, EXPORT_VALUE: { - MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE }, + MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE } }, FINANCIAL_ADDRESS: FINANCIAL_ADDRESS2, LOSS_PAYEE: { IS_APPOINTED: IS_APPOINTED2 }, @@ -7180,7 +7152,7 @@ var { CREDIT_PERIOD_WITH_BUYER: CREDIT_PERIOD_WITH_BUYER2, REQUESTED_JOINTLY_INSURED_PARTY, TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE4 }, - USING_BROKER: USING_BROKER2, + USING_BROKER: USING_BROKER2 }, YOUR_BUYER: { COMPANY_OR_ORGANISATION: { COUNTRY, NAME: BUYER_COMPANY_NAME, REGISTRATION_NUMBER: BUYER_REGISTRATION_NUMBER }, @@ -7192,126 +7164,126 @@ var { OUTSTANDING_PAYMENTS: OUTSTANDING_PAYMENTS2, PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2, TOTAL_OUTSTANDING_PAYMENTS: TOTAL_OUTSTANDING_PAYMENTS2, - TRADED_WITH_BUYER: TRADED_WITH_BUYER2, - }, + TRADED_WITH_BUYER: TRADED_WITH_BUYER2 + } } = insurance_default; var XLSX = { - AGREED: 'Agreed', + AGREED: "Agreed", FIELDS: { - [ACCOUNT_NUMBER2]: 'Loss payee account number', + [ACCOUNT_NUMBER2]: "Loss payee account number", AGENT: { - [AGENT_NAME]: 'Name of the agent', - [AGENT_ADDRESS]: 'Address of the agent', - [AGENT_COUNTRY_CODE]: 'Country the agent is based in', + [AGENT_NAME]: "Name of the agent", + [AGENT_ADDRESS]: "Address of the agent", + [AGENT_COUNTRY_CODE]: "Country the agent is based in" }, AGENT_CHARGES: { - [FIXED_SUM_AMOUNT]: 'How much is the agent charging?', - [PAYABLE_COUNTRY_CODE]: 'Country where the charges are payable', - [PERCENTAGE_CHARGE]: 'How much is the agent charging?', + [FIXED_SUM_AMOUNT]: "How much is the agent charging?", + [PAYABLE_COUNTRY_CODE]: "Country where the charges are payable", + [PERCENTAGE_CHARGE]: "How much is the agent charging?" }, AGENT_SERVICE: { - [IS_CHARGING]: 'Is the agent charging for their support in the export contract?', - [SERVICE_DESCRIPTION]: 'Service the agent is providing', + [IS_CHARGING]: "Is the agent charging for their support in the export contract?", + [SERVICE_DESCRIPTION]: "Service the agent is providing" }, - APPLICANT_EMAIL_ADDRESS: 'Applicant email address', - [BIC_SWIFT_CODE2]: 'Loss payee BIC or SWIFT code', - [BROKER_NAME]: 'Name of broker or company', - [BROKER_ADDRESS]: 'Broker address', + APPLICANT_EMAIL_ADDRESS: "Applicant email address", + [BIC_SWIFT_CODE2]: "Loss payee BIC or SWIFT code", + [BROKER_NAME]: "Name of broker or company", + [BROKER_ADDRESS]: "Broker address", [BROKER_EMAIL]: "Broker's email address", - [BUYER_COMPANY_NAME]: 'Buyer company name or organisation', - BUYER_CONTACT_DETAILS: 'Buyer contact details', - [BUYER_COUNTRY2]: 'Where is your buyer based?', - [BUYER_REGISTRATION_NUMBER]: 'Buyer registration number (optional)', - [COMPANIES_HOUSE_NUMBER2]: 'Companies house number', - [CONNECTION_WITH_BUYER2]: 'Is the exporter connected with the buyer in any way?', - [CONNECTION_WITH_BUYER_DESCRIPTION2]: 'Describe connection to the buyer', - [CONTRACT_COMPLETION_DATE2]: 'Expected contract completion date', - [COUNTRY]: 'Buyer location', - [COVER_PERIOD2]: 'Length of cover', - [DIFFERENT_TRADING_NAME]: 'Alternative trading name', - [EMPLOYEES_UK2]: 'Number of UK Employees', - [ESTIMATED_ANNUAL_TURNOVER2]: 'Exporter estimated turnover this current financial year', - [EXPORTER_COMPANY_ADDRESS]: 'Exporter registered office address', - [EXPORTER_COMPANY_NAME]: 'Exporter company name', - [EXPORTER_COMPANY_SIC]: 'Exporter standard industry classification (SIC) code(s)', + [BUYER_COMPANY_NAME]: "Buyer company name or organisation", + BUYER_CONTACT_DETAILS: "Buyer contact details", + [BUYER_COUNTRY2]: "Where is your buyer based?", + [BUYER_REGISTRATION_NUMBER]: "Buyer registration number (optional)", + [COMPANIES_HOUSE_NUMBER2]: "Companies house number", + [CONNECTION_WITH_BUYER2]: "Is the exporter connected with the buyer in any way?", + [CONNECTION_WITH_BUYER_DESCRIPTION2]: "Describe connection to the buyer", + [CONTRACT_COMPLETION_DATE2]: "Expected contract completion date", + [COUNTRY]: "Buyer location", + [COVER_PERIOD2]: "Length of cover", + [DIFFERENT_TRADING_NAME]: "Alternative trading name", + [EMPLOYEES_UK2]: "Number of UK Employees", + [ESTIMATED_ANNUAL_TURNOVER2]: "Exporter estimated turnover this current financial year", + [EXPORTER_COMPANY_ADDRESS]: "Exporter registered office address", + [EXPORTER_COMPANY_NAME]: "Exporter company name", + [EXPORTER_COMPANY_SIC]: "Exporter standard industry classification (SIC) code(s)", EXPORTER_CONTACT: { - TITLE: 'Exporter contact details', - [FIRST_NAME]: 'Exporter first name', - [LAST_NAME]: 'Exporter last name', - EXPORTER_CONTACT_EMAIL: 'Exporter email address', - EXPORTER_CONTACT_POSITION: "Exporter's role", + TITLE: "Exporter contact details", + [FIRST_NAME]: "Exporter first name", + [LAST_NAME]: "Exporter last name", + EXPORTER_CONTACT_EMAIL: "Exporter email address", + EXPORTER_CONTACT_POSITION: "Exporter's role" }, EXPORT_CONTRACT: { [DESCRIPTION2]: "About the exporter's goods or services", - [FINAL_DESTINATION_KNOWN2]: 'Does the exporter know the final destination of the goods or services?', - [PAYMENT_TERMS_DESCRIPTION2]: 'How the exporter will be paid for their export', - [ATTEMPTED_PRIVATE_MARKET]: 'Did the exporter try to insure through the private market?', - [DECLINED_DESCRIPTION2]: 'Why could they not get insurance through the private market? ', - [USING_AGENT]: 'Did the exporter use an agent?', - }, - [FAILED_PAYMENTS2]: 'Has the buyer ever failed to pay the exporter on time?', - [FINANCIAL_ADDRESS2]: 'Bank address of the loss payee', - [FIRST_NAME]: 'Applicant first name', - [FULL_ADDRESS_DOT_NOTATION]: 'Alternative trading address', - [GOODS_OR_SERVICES2]: 'Goods or services the business supplies', - [HAS_ANTI_BRIBERY_CODE_OF_CONDUCT2]: 'Does the exporter have a code of conduct?', - [HAS_BUYER_FINANCIAL_ACCOUNTS2]: 'Does the exporter hold any financial accounts in relation to the buyer?', - [HAS_CREDIT_CONTROL2]: 'Do you have a process for dealing with late payments?', - [HAS_DIFFERENT_TRADING_NAME2]: 'Different trading name?', - [HAS_END_BUYER2]: 'Is there an end buyer?', - [HAS_MINIMUM_UK_GOODS_OR_SERVICES2]: 'Is at least 20% of the contract value made up from UK goods or services?', - [HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: 'Has the exporter previously held credit insurance cover on the buyer?', - [IBAN2]: 'Loss payee IBAN number', - [IS_APPOINTED2]: 'Using a loss payee?', + [FINAL_DESTINATION_KNOWN2]: "Does the exporter know the final destination of the goods or services?", + [PAYMENT_TERMS_DESCRIPTION2]: "How the exporter will be paid for their export", + [ATTEMPTED_PRIVATE_MARKET]: "Did the exporter try to insure through the private market?", + [DECLINED_DESCRIPTION2]: "Why could they not get insurance through the private market? ", + [USING_AGENT]: "Did the exporter use an agent?" + }, + [FAILED_PAYMENTS2]: "Has the buyer ever failed to pay the exporter on time?", + [FINANCIAL_ADDRESS2]: "Bank address of the loss payee", + [FIRST_NAME]: "Applicant first name", + [FULL_ADDRESS_DOT_NOTATION]: "Alternative trading address", + [GOODS_OR_SERVICES2]: "Goods or services the business supplies", + [HAS_ANTI_BRIBERY_CODE_OF_CONDUCT2]: "Does the exporter have a code of conduct?", + [HAS_BUYER_FINANCIAL_ACCOUNTS2]: "Does the exporter hold any financial accounts in relation to the buyer?", + [HAS_CREDIT_CONTROL2]: "Do you have a process for dealing with late payments?", + [HAS_DIFFERENT_TRADING_NAME2]: "Different trading name?", + [HAS_END_BUYER2]: "Is there an end buyer?", + [HAS_MINIMUM_UK_GOODS_OR_SERVICES2]: "Is at least 20% of the contract value made up from UK goods or services?", + [HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: "Has the exporter previously held credit insurance cover on the buyer?", + [IBAN2]: "Loss payee IBAN number", + [IS_APPOINTED2]: "Using a loss payee?", JOINTLY_INSURED_PARTY: { - [REQUESTED_JOINTLY_INSURED_PARTY.REQUESTED]: 'Is there another company that needs to be insured on the policy?', - [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NAME]: 'Name of the company', - [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NUMBER]: 'Registration number of the other company (optional)', - [REQUESTED_JOINTLY_INSURED_PARTY.COUNTRY_CODE]: 'The country the other company is based in', - }, - KEY_INFORMATION_TITLE: 'Key information', - [LAST_NAME]: 'Applicant last name', - [MAXIMUM_BUYER_WILL_OWE]: 'Maximum buyer will owe exporter', + [REQUESTED_JOINTLY_INSURED_PARTY.REQUESTED]: "Is there another company that needs to be insured on the policy?", + [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NAME]: "Name of the company", + [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NUMBER]: "Registration number of the other company (optional)", + [REQUESTED_JOINTLY_INSURED_PARTY.COUNTRY_CODE]: "The country the other company is based in" + }, + KEY_INFORMATION_TITLE: "Key information", + [LAST_NAME]: "Applicant last name", + [MAXIMUM_BUYER_WILL_OWE]: "Maximum buyer will owe exporter", [MORE_THAN_250K.VALUE]: `Contract value of ${format_currency_default(AMOUNT_250K, GBP_CURRENCY_CODE)} or more?`, NAME_ON_POLICY: { - [NAME_ON_POLICY2.NAME]: 'Name on the policy', - [NAME_ON_POLICY2.POSITION]: 'Position at the company', - }, - [NEED_PRE_CREDIT_PERIOD2]: 'Is there a pre-credit period?', - [CREDIT_PERIOD_WITH_BUYER2]: 'The period of pre-credit cover required', - NO_FINANCIAL_YEAR_END_DATE: 'No data from Companies House', - [OUTSTANDING_PAYMENTS2]: 'Does the exporter currently have any outstanding or overdue payments from the buyer?', - [PHONE_NUMBER2]: 'Exporter UK telephone number (optional)', - [POLICY_TYPE4]: 'Type of policy', - [PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: 'Details of credit insurance cover held on the buyer', - [REQUESTED_START_DATE2]: 'Requested policy start date', - SOMEONE_ELSE: 'Someone else', - [SORT_CODE2]: 'Loss payee sort code', - [TOTAL_CONTRACT_VALUE_ID]: 'Total value of the contract', - [TOTAL_MONTHS_OF_COVER2]: 'Requested length of insurance', - [TOTAL_OUTSTANDING_PAYMENTS2]: 'Total outstanding payments', - [TOTAL_SALES_TO_BUYER]: 'Total sales estimate', - [HAS_DIFFERENT_TRADING_ADDRESS2]: 'Different trading address?', - [TRADED_WITH_BUYER2]: 'Has the exporter traded with this buyer before?', - [USING_BROKER2]: 'Using a broker for this insurance?', - [WEBSITE2]: 'Exporter Company website (optional)', - [WILL_EXPORT_WITH_CODE_OF_CONDUCT2]: 'Will the exporter export using their code of conduct?', - [YEARS_EXPORTING2]: 'How long the business has been exporting for', - [IS_PARTY_TO_CONSORTIUM]: 'Party to any consortium in connection with the export contract(s)?', - [IS_MEMBER_OF_A_GROUP]: 'Member of a group which may have a part in negotiating the contract(s)?', - }, + [NAME_ON_POLICY2.NAME]: "Name on the policy", + [NAME_ON_POLICY2.POSITION]: "Position at the company" + }, + [NEED_PRE_CREDIT_PERIOD2]: "Is there a pre-credit period?", + [CREDIT_PERIOD_WITH_BUYER2]: "The period of pre-credit cover required", + NO_FINANCIAL_YEAR_END_DATE: "No data from Companies House", + [OUTSTANDING_PAYMENTS2]: "Does the exporter currently have any outstanding or overdue payments from the buyer?", + [PHONE_NUMBER2]: "Exporter UK telephone number (optional)", + [POLICY_TYPE4]: "Type of policy", + [PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: "Details of credit insurance cover held on the buyer", + [REQUESTED_START_DATE2]: "Requested policy start date", + SOMEONE_ELSE: "Someone else", + [SORT_CODE2]: "Loss payee sort code", + [TOTAL_CONTRACT_VALUE_ID]: "Total value of the contract", + [TOTAL_MONTHS_OF_COVER2]: "Requested length of insurance", + [TOTAL_OUTSTANDING_PAYMENTS2]: "Total outstanding payments", + [TOTAL_SALES_TO_BUYER]: "Total sales estimate", + [HAS_DIFFERENT_TRADING_ADDRESS2]: "Different trading address?", + [TRADED_WITH_BUYER2]: "Has the exporter traded with this buyer before?", + [USING_BROKER2]: "Using a broker for this insurance?", + [WEBSITE2]: "Exporter Company website (optional)", + [WILL_EXPORT_WITH_CODE_OF_CONDUCT2]: "Will the exporter export using their code of conduct?", + [YEARS_EXPORTING2]: "How long the business has been exporting for", + [IS_PARTY_TO_CONSORTIUM]: "Party to any consortium in connection with the export contract(s)?", + [IS_MEMBER_OF_A_GROUP]: "Member of a group which may have a part in negotiating the contract(s)?" + } }; // generate-xlsx/map-application-to-XLSX/helpers/xlsx-row/index.ts var { KEY, VALUE } = XLSX_CONFIG; var xlsxRow = (fieldName, answer) => { if (fieldName) { - console.info('Mapping XLSX row %s', fieldName); - const value = answer || answer === 0 ? answer : ''; + console.info("Mapping XLSX row %s", fieldName); + const value = answer || answer === 0 ? answer : ""; const cleanValue = replace_character_codes_with_characters_default(String(value)); const row = { [KEY]: fieldName, - [VALUE]: cleanValue, + [VALUE]: cleanValue }; return row; } @@ -7332,7 +7304,7 @@ var mapIntroduction = (application2) => { xlsx_row_default(TIME_SUBMITTED.SUMMARY.TITLE, format_time_of_day_default(application2.submissionDate)), xlsx_row_default(String(FIELDS[FIRST_NAME2]), application2.owner[FIRST_NAME2]), xlsx_row_default(String(FIELDS[LAST_NAME2]), application2.owner[LAST_NAME2]), - xlsx_row_default(FIELDS.APPLICANT_EMAIL_ADDRESS, application2.owner[EMAIL4]), + xlsx_row_default(FIELDS.APPLICANT_EMAIL_ADDRESS, application2.owner[EMAIL4]) ]; return mapped; }; @@ -7342,8 +7314,8 @@ var map_introduction_default = mapIntroduction; var { ACCOUNT: { FIRST_NAME: FIRST_NAME3, LAST_NAME: LAST_NAME3, EMAIL: EMAIL5 }, POLICY: { - NAME_ON_POLICY: { POSITION }, - }, + NAME_ON_POLICY: { POSITION } + } } = insurance_default; var { FIELDS: FIELDS2 } = XLSX; var mapExporterContactDetails = (application2) => { @@ -7353,7 +7325,7 @@ var mapExporterContactDetails = (application2) => { xlsx_row_default(FIELDS2.EXPORTER_CONTACT[FIRST_NAME3], policyContact[FIRST_NAME3]), xlsx_row_default(FIELDS2.EXPORTER_CONTACT[LAST_NAME3], policyContact[LAST_NAME3]), xlsx_row_default(FIELDS2.EXPORTER_CONTACT.EXPORTER_CONTACT_EMAIL, policyContact[EMAIL5]), - xlsx_row_default(FIELDS2.EXPORTER_CONTACT.EXPORTER_CONTACT_POSITION, policyContact[POSITION]), + xlsx_row_default(FIELDS2.EXPORTER_CONTACT.EXPORTER_CONTACT_POSITION, policyContact[POSITION]) ]; return mapped; }; @@ -7387,19 +7359,16 @@ var { COMPANIES_HOUSE_NUMBER: COMPANIES_HOUSE_NUMBER3, HAS_END_BUYER: HAS_END_BUYER3, IS_PARTY_TO_CONSORTIUM: IS_PARTY_TO_CONSORTIUM2, - IS_MEMBER_OF_A_GROUP: IS_MEMBER_OF_A_GROUP2, - }, + IS_MEMBER_OF_A_GROUP: IS_MEMBER_OF_A_GROUP2 + } } = insurance_default; var mapEligibility = (application2) => { const { company, eligibility } = application2; let mapped = [ xlsx_row_default(ELIGIBILITY_FIELDS[VALID_EXPORTER_LOCATION2].SUMMARY?.TITLE, map_yes_no_field_default({ answer: eligibility[VALID_EXPORTER_LOCATION2] })), - xlsx_row_default( - ELIGIBILITY_FIELDS[HAS_COMPANIES_HOUSE_NUMBER2].SUMMARY?.TITLE, - map_yes_no_field_default({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER2] }), - ), + xlsx_row_default(ELIGIBILITY_FIELDS[HAS_COMPANIES_HOUSE_NUMBER2].SUMMARY?.TITLE, map_yes_no_field_default({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER2] })), xlsx_row_default(String(FIELDS3[COMPANIES_HOUSE_NUMBER3]), company[COMPANIES_HOUSE_NUMBER3]), - xlsx_row_default(String(FIELDS3[BUYER_COUNTRY3]), eligibility[BUYER_COUNTRY3].name), + xlsx_row_default(String(FIELDS3[BUYER_COUNTRY3]), eligibility[BUYER_COUNTRY3].name) ]; const totalContractValueAnswer = eligibility[TOTAL_CONTRACT_VALUE_FIELD_ID2].valueId === MORE_THAN_250K2.DB_ID; mapped = [ @@ -7409,7 +7378,7 @@ var mapEligibility = (application2) => { xlsx_row_default(String(FIELDS3[HAS_MINIMUM_UK_GOODS_OR_SERVICES3]), map_yes_no_field_default({ answer: eligibility[HAS_MINIMUM_UK_GOODS_OR_SERVICES3] })), xlsx_row_default(String(FIELDS3[HAS_END_BUYER3]), map_yes_no_field_default({ answer: eligibility[HAS_END_BUYER3] })), xlsx_row_default(String(FIELDS3[IS_PARTY_TO_CONSORTIUM2]), map_yes_no_field_default({ answer: eligibility[IS_PARTY_TO_CONSORTIUM2] })), - xlsx_row_default(String(FIELDS3[IS_MEMBER_OF_A_GROUP2]), map_yes_no_field_default({ answer: eligibility[IS_PARTY_TO_CONSORTIUM2] })), + xlsx_row_default(String(FIELDS3[IS_MEMBER_OF_A_GROUP2]), map_yes_no_field_default({ answer: eligibility[IS_PARTY_TO_CONSORTIUM2] })) ]; return mapped; }; @@ -7418,18 +7387,18 @@ var map_eligibility_default = mapEligibility; // generate-xlsx/map-application-to-XLSX/map-key-information/index.ts var { FIELDS: FIELDS4 } = XLSX; var CONTENT_STRINGS = { - ...POLICY_FIELDS, + ...POLICY_FIELDS }; var { EXPORTER_BUSINESS: { - COMPANIES_HOUSE: { COMPANY_NAME: EXPORTER_COMPANY_NAME2 }, + COMPANIES_HOUSE: { COMPANY_NAME: EXPORTER_COMPANY_NAME2 } }, YOUR_BUYER: { - COMPANY_OR_ORGANISATION: { COUNTRY: COUNTRY2, NAME: BUYER_COMPANY_NAME2 }, + COMPANY_OR_ORGANISATION: { COUNTRY: COUNTRY2, NAME: BUYER_COMPANY_NAME2 } }, POLICY: { - TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE5 }, - }, + TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE5 } + } } = insurance_default; var mapKeyInformation = (application2) => { const { policy } = application2; @@ -7438,7 +7407,7 @@ var mapKeyInformation = (application2) => { xlsx_row_default(String(FIELDS4[EXPORTER_COMPANY_NAME2]), replace_character_codes_with_characters_default(application2.company[EXPORTER_COMPANY_NAME2])), xlsx_row_default(String(FIELDS4[COUNTRY2]), application2.buyer[COUNTRY2].name), xlsx_row_default(String(FIELDS4[BUYER_COMPANY_NAME2]), replace_character_codes_with_characters_default(application2.buyer[BUYER_COMPANY_NAME2])), - xlsx_row_default(String(CONTENT_STRINGS[POLICY_TYPE5].SUMMARY?.TITLE), policy[POLICY_TYPE5]), + xlsx_row_default(String(CONTENT_STRINGS[POLICY_TYPE5].SUMMARY?.TITLE), policy[POLICY_TYPE5]) ]; return mapped; }; @@ -7450,7 +7419,7 @@ var isMultiplePolicyType = (policyType) => policyType === FIELD_VALUES.POLICY_TY // generate-xlsx/map-application-to-XLSX/map-policy/map-intro/map-policy-type/index.ts var { - POLICY_TYPE: { ABBREVIATED }, + POLICY_TYPE: { ABBREVIATED } } = APPLICATION; var mapPolicyType = (policyType) => { if (isSinglePolicyType(policyType)) { @@ -7466,12 +7435,12 @@ var map_policy_type_default = mapPolicyType; var { FIELDS: FIELDS5 } = XLSX; var { POLICY_TYPE: POLICY_TYPE6, - CONTRACT_POLICY: { REQUESTED_START_DATE: REQUESTED_START_DATE3 }, + CONTRACT_POLICY: { REQUESTED_START_DATE: REQUESTED_START_DATE3 } } = policy_default; var mapIntro = (policy) => { const mapped = [ xlsx_row_default(String(FIELDS5[POLICY_TYPE6]), map_policy_type_default(policy[POLICY_TYPE6])), - xlsx_row_default(String(FIELDS5[REQUESTED_START_DATE3]), format_date_default(policy[REQUESTED_START_DATE3], DATE_FORMAT.XLSX)), + xlsx_row_default(String(FIELDS5[REQUESTED_START_DATE3]), format_date_default(policy[REQUESTED_START_DATE3], DATE_FORMAT.XLSX)) ]; return mapped; }; @@ -7481,64 +7450,64 @@ var map_intro_default = mapIntro; var { ACCOUNT: ACCOUNT3 } = FIELD_IDS.INSURANCE; var { FIRST_NAME: FIRST_NAME4, LAST_NAME: LAST_NAME4, EMAIL: EMAIL6, PASSWORD, ACCESS_CODE } = ACCOUNT3; var PASSWORD_HINT = { - INTRO: 'Your password must contain at least 14 characters and have:', - RULES: ['an uppercase letter', 'a lowercase letter', 'a number', 'a special character (for example @%!?*)'], + INTRO: "Your password must contain at least 14 characters and have:", + RULES: ["an uppercase letter", "a lowercase letter", "a number", "a special character (for example @%!?*)"] }; var ACCOUNT_FIELDS = { MAXIMUM: { NAME: { - CHARACTERS: 100, - }, + CHARACTERS: 100 + } }, [FIRST_NAME4]: { - LABEL: 'First name', + LABEL: "First name" }, [LAST_NAME4]: { - LABEL: 'Last name', + LABEL: "Last name" }, [EMAIL6]: { - LABEL: 'Email address', + LABEL: "Email address" }, [PASSWORD]: { REVEAL: { - SHOW: 'Show', - HIDE: 'Hide', - }, + SHOW: "Show", + HIDE: "Hide" + } }, [ACCESS_CODE]: { - LABEL: 'Access code', + LABEL: "Access code" }, CREATE: { YOUR_DETAILS: { [FIRST_NAME4]: { - LABEL: 'First name', + LABEL: "First name" }, [LAST_NAME4]: { - LABEL: 'Last name', + LABEL: "Last name" }, [PASSWORD]: { - LABEL: 'Create a password', - HINT: PASSWORD_HINT, - }, - }, + LABEL: "Create a password", + HINT: PASSWORD_HINT + } + } }, SIGN_IN: { [PASSWORD]: { - LABEL: 'Password', - }, + LABEL: "Password" + } }, PASSWORD_RESET: { [EMAIL6]: { - LABEL: 'Email address', - HINT: 'Enter the email address associated with your credit insurance application(s).', - }, + LABEL: "Email address", + HINT: "Enter the email address associated with your credit insurance application(s)." + } }, NEW_PASSWORD: { [PASSWORD]: { - LABEL: 'Create a password', - HINT: PASSWORD_HINT, - }, - }, + LABEL: "Create a password", + HINT: PASSWORD_HINT + } + } }; // generate-xlsx/map-application-to-XLSX/map-policy/map-name-on-policy/index.ts @@ -7546,17 +7515,14 @@ var { FIELDS: FIELDS6 } = XLSX; var { ACCOUNT: { FIRST_NAME: FIRST_NAME5, LAST_NAME: LAST_NAME5, EMAIL: EMAIL7 }, POLICY: { - NAME_ON_POLICY: { IS_SAME_AS_OWNER, NAME: NAME2, POSITION: POSITION2 }, - }, + NAME_ON_POLICY: { IS_SAME_AS_OWNER, NAME: NAME2, POSITION: POSITION2 } + } } = insurance_default; var mapNameOnPolicy = (policyContact) => { let mapped = []; if (policyContact[IS_SAME_AS_OWNER]) { const nameOnPolicy = `${policyContact[FIRST_NAME5]} ${policyContact[LAST_NAME5]} (${policyContact[EMAIL7]})`; - mapped = [ - xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[NAME2]), nameOnPolicy), - xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2]), - ]; + mapped = [xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[NAME2]), nameOnPolicy), xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2])]; return mapped; } mapped = [ @@ -7564,20 +7530,19 @@ var mapNameOnPolicy = (policyContact) => { xlsx_row_default(String(ACCOUNT_FIELDS[FIRST_NAME5].LABEL), policyContact[FIRST_NAME5]), xlsx_row_default(String(ACCOUNT_FIELDS[LAST_NAME5].LABEL), policyContact[LAST_NAME5]), xlsx_row_default(String(ACCOUNT_FIELDS[EMAIL7].LABEL), policyContact[EMAIL7]), - xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2]), + xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2]) ]; return mapped; }; var map_name_on_policy_default = mapNameOnPolicy; // generate-xlsx/map-application-to-XLSX/helpers/format-currency/index.ts -var formatCurrency2 = (number, currencyCode, decimalPlaces) => - number.toLocaleString('en', { - style: 'currency', - currency: currencyCode, - minimumFractionDigits: decimalPlaces ?? 0, - maximumFractionDigits: decimalPlaces ?? 0, - }); +var formatCurrency2 = (number, currencyCode, decimalPlaces) => number.toLocaleString("en", { + style: "currency", + currency: currencyCode, + minimumFractionDigits: decimalPlaces ?? 0, + maximumFractionDigits: decimalPlaces ?? 0 +}); var format_currency_default2 = formatCurrency2; // generate-xlsx/map-application-to-XLSX/map-policy/map-single-contract-policy/index.ts @@ -7585,7 +7550,7 @@ var { FIELDS: FIELDS7 } = XLSX; var CONTENT_STRINGS2 = { ...POLICY_FIELDS, ...POLICY_FIELDS.CONTRACT_POLICY, - ...POLICY_FIELDS.CONTRACT_POLICY.SINGLE, + ...POLICY_FIELDS.CONTRACT_POLICY.SINGLE }; var { CURRENCY: { CURRENCY_CODE: CURRENCY_CODE3 }, @@ -7593,26 +7558,23 @@ var { CONTRACT_POLICY: { SINGLE: { CONTRACT_COMPLETION_DATE: CONTRACT_COMPLETION_DATE3 }, POLICY_CURRENCY_CODE, - SINGLE: { REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE2 }, - }, - }, + SINGLE: { REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE2 } + } + } } = insurance_default; var mapSingleContractPolicy = (policy) => { const mapped = [ xlsx_row_default(String(FIELDS7[CONTRACT_COMPLETION_DATE3]), format_date_default(policy[CONTRACT_COMPLETION_DATE3], DATE_FORMAT.XLSX)), xlsx_row_default(String(CONTENT_STRINGS2[CURRENCY_CODE3].SUMMARY?.TITLE), policy[POLICY_CURRENCY_CODE]), xlsx_row_default(String(FIELDS7[TOTAL_CONTRACT_VALUE2]), format_currency_default2(policy[TOTAL_CONTRACT_VALUE2], policy[POLICY_CURRENCY_CODE])), - xlsx_row_default( - String(CONTENT_STRINGS2[REQUESTED_CREDIT_LIMIT].SUMMARY?.TITLE), - format_currency_default2(policy[REQUESTED_CREDIT_LIMIT], policy[POLICY_CURRENCY_CODE]), - ), + xlsx_row_default(String(CONTENT_STRINGS2[REQUESTED_CREDIT_LIMIT].SUMMARY?.TITLE), format_currency_default2(policy[REQUESTED_CREDIT_LIMIT], policy[POLICY_CURRENCY_CODE])) ]; return mapped; }; var map_single_contract_policy_default = mapSingleContractPolicy; // generate-xlsx/map-application-to-XLSX/helpers/map-month-string/index.ts -var mapMonthString = (answer) => (answer === 1 ? `${answer} month` : `${answer} months`); +var mapMonthString = (answer) => answer === 1 ? `${answer} month` : `${answer} months`; var map_month_string_default = mapMonthString; // generate-xlsx/map-application-to-XLSX/map-policy/map-multiple-contract-policy/index.ts @@ -7621,25 +7583,25 @@ var CONTENT_STRINGS3 = { ...POLICY_FIELDS, ...POLICY_FIELDS.CONTRACT_POLICY, ...POLICY_FIELDS.CONTRACT_POLICY.MULTIPLE, - ...POLICY_FIELDS.EXPORT_VALUE.MULTIPLE, + ...POLICY_FIELDS.EXPORT_VALUE.MULTIPLE }; var { CURRENCY: { CURRENCY_CODE: CURRENCY_CODE4 }, POLICY: { CONTRACT_POLICY: { POLICY_CURRENCY_CODE: POLICY_CURRENCY_CODE2, - MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER3 }, + MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER3 } }, EXPORT_VALUE: { - MULTIPLE: { TOTAL_SALES_TO_BUYER: TOTAL_SALES_TO_BUYER2, MAXIMUM_BUYER_WILL_OWE: MAXIMUM_BUYER_WILL_OWE2 }, - }, - }, + MULTIPLE: { TOTAL_SALES_TO_BUYER: TOTAL_SALES_TO_BUYER2, MAXIMUM_BUYER_WILL_OWE: MAXIMUM_BUYER_WILL_OWE2 } + } + } } = insurance_default; var mapMultipleContractPolicy = (policy) => [ xlsx_row_default(String(FIELDS8[TOTAL_MONTHS_OF_COVER3]), map_month_string_default(policy[TOTAL_MONTHS_OF_COVER3])), xlsx_row_default(String(CONTENT_STRINGS3[CURRENCY_CODE4].SUMMARY?.TITLE), policy[POLICY_CURRENCY_CODE2]), xlsx_row_default(String(FIELDS8[TOTAL_SALES_TO_BUYER2]), format_currency_default2(policy[TOTAL_SALES_TO_BUYER2], policy[POLICY_CURRENCY_CODE2])), - xlsx_row_default(String(FIELDS8[MAXIMUM_BUYER_WILL_OWE2]), format_currency_default2(policy[MAXIMUM_BUYER_WILL_OWE2], policy[POLICY_CURRENCY_CODE2])), + xlsx_row_default(String(FIELDS8[MAXIMUM_BUYER_WILL_OWE2]), format_currency_default2(policy[MAXIMUM_BUYER_WILL_OWE2], policy[POLICY_CURRENCY_CODE2])) ]; var map_multiple_contract_policy_default = mapMultipleContractPolicy; @@ -7666,7 +7628,7 @@ var get_country_by_iso_code_default = getCountryByIsoCode; // generate-xlsx/map-application-to-XLSX/map-policy/map-jointly-insured-party/index.ts var { FIELDS: FIELDS10 } = XLSX; var { - REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED: REQUESTED2, COMPANY_NAME: COMPANY_NAME4, COMPANY_NUMBER: COMPANY_NUMBER3, COUNTRY_CODE: COUNTRY_CODE2 }, + REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED: REQUESTED2, COMPANY_NAME: COMPANY_NAME4, COMPANY_NUMBER: COMPANY_NUMBER3, COUNTRY_CODE: COUNTRY_CODE2 } } = policy_default; var mapJointlyInsuredParty = (party, countries) => { const requestedParty = party[REQUESTED2]; @@ -7677,7 +7639,7 @@ var mapJointlyInsuredParty = (party, countries) => { ...mapped, xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COMPANY_NAME4]), party[COMPANY_NAME4]), xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COUNTRY_CODE2]), country.name), - xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COMPANY_NUMBER3]), party[COMPANY_NUMBER3]), + xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COMPANY_NUMBER3]), party[COMPANY_NUMBER3]) ]; } return mapped; @@ -7687,7 +7649,7 @@ var map_jointly_insured_party_default = mapJointlyInsuredParty; // generate-xlsx/map-application-to-XLSX/map-policy/map-broker/index.ts var { USING_BROKER: USING_BROKER3, - BROKER_DETAILS: { NAME: BROKER_NAME2, EMAIL: EMAIL8, FULL_ADDRESS: FULL_ADDRESS3 }, + BROKER_DETAILS: { NAME: BROKER_NAME2, EMAIL: EMAIL8, FULL_ADDRESS: FULL_ADDRESS3 } } = POLICY; var { FIELDS: FIELDS11 } = XLSX; var mapBroker = (application2) => { @@ -7698,7 +7660,7 @@ var mapBroker = (application2) => { ...mapped, xlsx_row_default(String(FIELDS11[BROKER_NAME2]), broker[BROKER_NAME2]), xlsx_row_default(String(FIELDS11[EMAIL8]), broker[EMAIL8]), - xlsx_row_default(String(FIELDS11[FULL_ADDRESS3]), broker[FULL_ADDRESS3]), + xlsx_row_default(String(FIELDS11[FULL_ADDRESS3]), broker[FULL_ADDRESS3]) ]; } return mapped; @@ -7707,7 +7669,7 @@ var map_broker_default = mapBroker; // generate-xlsx/map-application-to-XLSX/map-policy/map-loss-payee/map-appointed-loss-payee/map-location/index.ts var { - LOSS_PAYEE_DETAILS: { IS_LOCATED_INTERNATIONALLY: IS_LOCATED_INTERNATIONALLY2, IS_LOCATED_IN_UK: IS_LOCATED_IN_UK2, LOCATION: LOCATION2 }, + LOSS_PAYEE_DETAILS: { IS_LOCATED_INTERNATIONALLY: IS_LOCATED_INTERNATIONALLY2, IS_LOCATED_IN_UK: IS_LOCATED_IN_UK2, LOCATION: LOCATION2 } } = policy_default; var CONTENT_STRINGS4 = POLICY_FIELDS.LOSS_PAYEE_DETAILS[LOCATION2].OPTIONS; var mapLossPayeeLocation = (lossPayee) => { @@ -7725,7 +7687,7 @@ var { FIELDS: FIELDS12 } = XLSX; var CONTENT_STRINGS5 = POLICY_FIELDS.LOSS_PAYEE_DETAILS; var { LOSS_PAYEE: { IS_APPOINTED: IS_APPOINTED3 }, - LOSS_PAYEE_DETAILS: { LOCATION: LOCATION3, NAME: LOSS_PAYEE_NAME2 }, + LOSS_PAYEE_DETAILS: { LOCATION: LOCATION3, NAME: LOSS_PAYEE_NAME2 } } = policy_default; var mapAppointedLossPayee = (lossPayee) => { let mapped = [xlsx_row_default(String(FIELDS12[IS_APPOINTED3]), map_yes_no_field_default({ answer: lossPayee[IS_APPOINTED3] }))]; @@ -7733,7 +7695,7 @@ var mapAppointedLossPayee = (lossPayee) => { mapped = [ ...mapped, xlsx_row_default(String(CONTENT_STRINGS5[LOSS_PAYEE_NAME2].SUMMARY?.TITLE), lossPayee[LOSS_PAYEE_NAME2]), - xlsx_row_default(String(CONTENT_STRINGS5[LOCATION3].LABEL), map_location_default(lossPayee)), + xlsx_row_default(String(CONTENT_STRINGS5[LOCATION3].LABEL), map_location_default(lossPayee)) ]; } return mapped; @@ -7745,14 +7707,14 @@ var { FIELDS: FIELDS13 } = XLSX; var { LOSS_PAYEE_DETAILS: { IS_LOCATED_INTERNATIONALLY: IS_LOCATED_INTERNATIONALLY3 }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { BIC_SWIFT_CODE: BIC_SWIFT_CODE3, IBAN: IBAN3 }, - FINANCIAL_ADDRESS: FINANCIAL_ADDRESS3, + FINANCIAL_ADDRESS: FINANCIAL_ADDRESS3 } = policy_default; var mapLossPayeeFinancialDetailsInternational = (lossPayee) => { if (lossPayee[IS_LOCATED_INTERNATIONALLY3]) { const mapped = [ xlsx_row_default(String(FIELDS13[BIC_SWIFT_CODE3]), lossPayee.financialInternational[BIC_SWIFT_CODE3]), xlsx_row_default(String(FIELDS13[IBAN3]), lossPayee.financialInternational[IBAN3]), - xlsx_row_default(String(FIELDS13[FINANCIAL_ADDRESS3]), lossPayee.financialInternational[FINANCIAL_ADDRESS3]), + xlsx_row_default(String(FIELDS13[FINANCIAL_ADDRESS3]), lossPayee.financialInternational[FINANCIAL_ADDRESS3]) ]; return mapped; } @@ -7765,14 +7727,14 @@ var { FIELDS: FIELDS14 } = XLSX; var { LOSS_PAYEE_DETAILS: { IS_LOCATED_IN_UK: IS_LOCATED_IN_UK3 }, LOSS_PAYEE_FINANCIAL_UK: { SORT_CODE: SORT_CODE3, ACCOUNT_NUMBER: ACCOUNT_NUMBER3 }, - FINANCIAL_ADDRESS: FINANCIAL_ADDRESS4, + FINANCIAL_ADDRESS: FINANCIAL_ADDRESS4 } = policy_default; var mapLossPayeeFinancialDetailsUk = (lossPayee) => { if (lossPayee[IS_LOCATED_IN_UK3]) { const mapped = [ xlsx_row_default(String(FIELDS14[SORT_CODE3]), lossPayee.financialUk[SORT_CODE3]), xlsx_row_default(String(FIELDS14[ACCOUNT_NUMBER3]), lossPayee.financialUk[ACCOUNT_NUMBER3]), - xlsx_row_default(String(FIELDS14[FINANCIAL_ADDRESS4]), lossPayee.financialUk[FINANCIAL_ADDRESS4]), + xlsx_row_default(String(FIELDS14[FINANCIAL_ADDRESS4]), lossPayee.financialUk[FINANCIAL_ADDRESS4]) ]; return mapped; } @@ -7782,18 +7744,14 @@ var map_financial_details_uk_default = mapLossPayeeFinancialDetailsUk; // generate-xlsx/map-application-to-XLSX/map-policy/map-loss-payee/index.ts var mapLossPayee = (lossPayee) => { - const mapped = [ - ...map_appointed_loss_payee_default(lossPayee), - ...map_financial_details_uk_default(lossPayee), - ...map_financial_details_international_default(lossPayee), - ]; + const mapped = [...map_appointed_loss_payee_default(lossPayee), ...map_financial_details_uk_default(lossPayee), ...map_financial_details_international_default(lossPayee)]; return mapped; }; var map_loss_payee_default = mapLossPayee; // generate-xlsx/map-application-to-XLSX/map-policy/index.ts var { - TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE7 }, + TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE7 } } = policy_default; var mapPolicy2 = (application2, countries) => { const { nominatedLossPayee, policy, policyContact } = application2; @@ -7811,7 +7769,7 @@ var mapPolicy2 = (application2, countries) => { ...map_credit_period_default(policy), ...map_jointly_insured_party_default(policy.jointlyInsuredParty, countries), ...map_broker_default(application2), - ...map_loss_payee_default(nominatedLossPayee), + ...map_loss_payee_default(nominatedLossPayee) ]; return mapped; }; @@ -7819,7 +7777,7 @@ var map_policy_default2 = mapPolicy2; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-different-trading-name/index.ts var { - YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME3, DIFFERENT_TRADING_NAME: DIFFERENT_TRADING_NAME2 }, + YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME3, DIFFERENT_TRADING_NAME: DIFFERENT_TRADING_NAME2 } } = business_default; var { FIELDS: FIELDS15 } = XLSX; var mapDifferentTradingName = (company) => { @@ -7831,7 +7789,7 @@ var map_different_trading_name_default = mapDifferentTradingName; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-different-trading-address/index.ts var { - ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: FULL_ADDRESS4, FULL_ADDRESS_DOT_NOTATION: FULL_ADDRESS_DOT_NOTATION2 }, + ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: FULL_ADDRESS4, FULL_ADDRESS_DOT_NOTATION: FULL_ADDRESS_DOT_NOTATION2 } } = business_default; var { FIELDS: FIELDS16 } = XLSX; var mapDifferentTradingAddress = (company) => { @@ -7844,14 +7802,14 @@ var mapDifferentTradingAddress = (company) => { var map_different_trading_address_default = mapDifferentTradingAddress; // generate-xlsx/map-application-to-XLSX/helpers/xlsx-new-line/index.ts -var NEW_LINE = '\r\n'; +var NEW_LINE = "\r\n"; var xlsx_new_line_default = NEW_LINE; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-exporter-address/index.ts var mapExporterAddress = (address) => { - let addressString = ''; + let addressString = ""; Object.keys(address).forEach((field) => { - if (address[field] && field !== 'id' && field !== '__typename') { + if (address[field] && field !== "id" && field !== "__typename") { addressString += `${address[field]}${xlsx_new_line_default}`; } }); @@ -7861,7 +7819,7 @@ var map_exporter_address_default = mapExporterAddress; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-financial-year-end-date/index.ts var { - COMPANIES_HOUSE: { FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE2 }, + COMPANIES_HOUSE: { FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE2 } } = business_default; var { FIELDS: FIELDS17 } = XLSX; var mapFinancialYearEndDate = (company) => { @@ -7874,7 +7832,7 @@ var map_financial_year_end_date_default = mapFinancialYearEndDate; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-sic-codes/index.ts var mapSicCodes2 = (sicCodes) => { - let mapped = ''; + let mapped = ""; sicCodes.forEach((sicCodeObj) => { const { sicCode, industrySectorName } = sicCodeObj; mapped += `${sicCode} - ${industrySectorName}${xlsx_new_line_default}`; @@ -7889,24 +7847,14 @@ var CONTENT_STRINGS6 = { ...EXPORTER_BUSINESS_FIELDS.COMPANY_DETAILS, ...EXPORTER_BUSINESS_FIELDS.NATURE_OF_YOUR_BUSINESS, ...EXPORTER_BUSINESS_FIELDS.TURNOVER, - ...EXPORTER_BUSINESS_FIELDS.BROKER, + ...EXPORTER_BUSINESS_FIELDS.BROKER }; var { - COMPANIES_HOUSE: { - COMPANY_ADDRESS: COMPANY_ADDRESS2, - COMPANY_INCORPORATED: COMPANY_INCORPORATED2, - COMPANY_SIC: COMPANY_SIC2, - FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE3, - }, - YOUR_COMPANY: { - HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME4, - HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS3, - PHONE_NUMBER: PHONE_NUMBER3, - WEBSITE: WEBSITE3, - }, + COMPANIES_HOUSE: { COMPANY_ADDRESS: COMPANY_ADDRESS2, COMPANY_INCORPORATED: COMPANY_INCORPORATED2, COMPANY_SIC: COMPANY_SIC2, FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE3 }, + YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME4, HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS3, PHONE_NUMBER: PHONE_NUMBER3, WEBSITE: WEBSITE3 }, NATURE_OF_YOUR_BUSINESS: { GOODS_OR_SERVICES: GOODS_OR_SERVICES3, YEARS_EXPORTING: YEARS_EXPORTING3, EMPLOYEES_UK: EMPLOYEES_UK3 }, TURNOVER: { ESTIMATED_ANNUAL_TURNOVER: ESTIMATED_ANNUAL_TURNOVER3, PERCENTAGE_TURNOVER: PERCENTAGE_TURNOVER2, TURNOVER_CURRENCY_CODE }, - HAS_CREDIT_CONTROL: HAS_CREDIT_CONTROL3, + HAS_CREDIT_CONTROL: HAS_CREDIT_CONTROL3 } = business_default; var mapExporterBusiness = (application2) => { const { business, company, companySicCodes } = application2; @@ -7924,12 +7872,9 @@ var mapExporterBusiness = (application2) => { xlsx_row_default(String(FIELDS18[YEARS_EXPORTING3]), business[YEARS_EXPORTING3]), xlsx_row_default(String(FIELDS18[EMPLOYEES_UK3]), business[EMPLOYEES_UK3]), xlsx_row_default(CONTENT_STRINGS6[FINANCIAL_YEAR_END_DATE3].SUMMARY?.TITLE, map_financial_year_end_date_default(company)), - xlsx_row_default( - String(FIELDS18[ESTIMATED_ANNUAL_TURNOVER3]), - format_currency_default2(business[ESTIMATED_ANNUAL_TURNOVER3], business[TURNOVER_CURRENCY_CODE]), - ), + xlsx_row_default(String(FIELDS18[ESTIMATED_ANNUAL_TURNOVER3]), format_currency_default2(business[ESTIMATED_ANNUAL_TURNOVER3], business[TURNOVER_CURRENCY_CODE])), xlsx_row_default(CONTENT_STRINGS6[PERCENTAGE_TURNOVER2].SUMMARY?.TITLE, `${business[PERCENTAGE_TURNOVER2]}%`), - xlsx_row_default(String(FIELDS18[HAS_CREDIT_CONTROL3]), map_yes_no_field_default({ answer: business[HAS_CREDIT_CONTROL3] })), + xlsx_row_default(String(FIELDS18[HAS_CREDIT_CONTROL3]), map_yes_no_field_default({ answer: business[HAS_CREDIT_CONTROL3] })) ]; return mapped; }; @@ -7948,11 +7893,7 @@ var map_connection_with_buyer_default = mapConnectionWithBuyer; // generate-xlsx/map-application-to-XLSX/map-buyer/map-outstanding-payments/index.ts var { CURRENCY: { CURRENCY_CODE: CURRENCY_CODE5 }, - YOUR_BUYER: { - OUTSTANDING_PAYMENTS: OUTSTANDING_PAYMENTS3, - TOTAL_OUTSTANDING_PAYMENTS: TOTAL_OUTSTANDING_PAYMENTS3, - TOTAL_AMOUNT_OVERDUE: TOTAL_AMOUNT_OVERDUE2, - }, + YOUR_BUYER: { OUTSTANDING_PAYMENTS: OUTSTANDING_PAYMENTS3, TOTAL_OUTSTANDING_PAYMENTS: TOTAL_OUTSTANDING_PAYMENTS3, TOTAL_AMOUNT_OVERDUE: TOTAL_AMOUNT_OVERDUE2 } } = insurance_default; var { FIELDS: FIELDS20 } = XLSX; var mapOutstandingPayments = (tradingHistory) => { @@ -7960,12 +7901,12 @@ var mapOutstandingPayments = (tradingHistory) => { const values = { currency: tradingHistory[CURRENCY_CODE5], totalOutstanding: format_currency_default(tradingHistory[TOTAL_OUTSTANDING_PAYMENTS3], tradingHistory[CURRENCY_CODE5]), - totalAmountOverdue: format_currency_default(tradingHistory[TOTAL_AMOUNT_OVERDUE2], tradingHistory[CURRENCY_CODE5]), + totalAmountOverdue: format_currency_default(tradingHistory[TOTAL_AMOUNT_OVERDUE2], tradingHistory[CURRENCY_CODE5]) }; const mapped = [ xlsx_row_default(String(FIELDS20[TOTAL_OUTSTANDING_PAYMENTS3]), values.totalOutstanding), xlsx_row_default(String(YOUR_BUYER_FIELDS[CURRENCY_CODE5].SUMMARY?.TITLE), values.currency), - xlsx_row_default(String(YOUR_BUYER_FIELDS[TOTAL_AMOUNT_OVERDUE2].SUMMARY?.TITLE), values.totalAmountOverdue), + xlsx_row_default(String(YOUR_BUYER_FIELDS[TOTAL_AMOUNT_OVERDUE2].SUMMARY?.TITLE), values.totalAmountOverdue) ]; return mapped; } @@ -7981,7 +7922,7 @@ var mapBuyerTradingHistory = (tradingHistory) => { const mapped = [ xlsx_row_default(String(FIELDS21[OUTSTANDING_PAYMENTS4]), map_yes_no_field_default({ answer: tradingHistory[OUTSTANDING_PAYMENTS4] })), ...map_outstanding_payments_default(tradingHistory), - xlsx_row_default(String(FIELDS21[FAILED_PAYMENTS3]), map_yes_no_field_default({ answer: tradingHistory[FAILED_PAYMENTS3] })), + xlsx_row_default(String(FIELDS21[FAILED_PAYMENTS3]), map_yes_no_field_default({ answer: tradingHistory[FAILED_PAYMENTS3] })) ]; return mapped; } @@ -7990,15 +7931,12 @@ var mapBuyerTradingHistory = (tradingHistory) => { var map_buyer_trading_history_default = mapBuyerTradingHistory; // generate-xlsx/map-application-to-XLSX/map-buyer/map-previous-cover-with-buyer/index.ts -var { - HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3, - PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3, -} = your_buyer_default; +var { HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3, PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3 } = your_buyer_default; var { FIELDS: FIELDS22 } = XLSX; var mapPreviousCoverWithBuyer = (application2) => { const { buyer: { relationship: relationship2 }, - totalContractValueOverThreshold, + totalContractValueOverThreshold } = application2; if (totalContractValueOverThreshold) { const answer = relationship2[HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3]; @@ -8015,13 +7953,13 @@ var map_previous_cover_with_buyer_default = mapPreviousCoverWithBuyer; // generate-xlsx/map-application-to-XLSX/map-buyer/index.ts var CONTENT_STRINGS7 = { ...YOUR_BUYER_FIELDS.COMPANY_OR_ORGANISATION, - ...YOUR_BUYER_FIELDS, + ...YOUR_BUYER_FIELDS }; var { COMPANY_OR_ORGANISATION: { NAME: NAME3, ADDRESS, COUNTRY: COUNTRY3, REGISTRATION_NUMBER, WEBSITE: WEBSITE4 }, CONNECTION_WITH_BUYER: CONNECTION_WITH_BUYER4, HAS_BUYER_FINANCIAL_ACCOUNTS: HAS_BUYER_FINANCIAL_ACCOUNTS3, - TRADED_WITH_BUYER: TRADED_WITH_BUYER4, + TRADED_WITH_BUYER: TRADED_WITH_BUYER4 } = your_buyer_default; var { FIELDS: FIELDS23 } = XLSX; var mapBuyer = (application2) => { @@ -8037,7 +7975,7 @@ var mapBuyer = (application2) => { xlsx_row_default(String(FIELDS23[TRADED_WITH_BUYER4]), map_yes_no_field_default({ answer: buyerTradingHistory[TRADED_WITH_BUYER4] })), ...map_buyer_trading_history_default(buyerTradingHistory), ...map_previous_cover_with_buyer_default(application2), - xlsx_row_default(String(FIELDS23[HAS_BUYER_FINANCIAL_ACCOUNTS3]), map_yes_no_field_default({ answer: relationship2[HAS_BUYER_FINANCIAL_ACCOUNTS3] })), + xlsx_row_default(String(FIELDS23[HAS_BUYER_FINANCIAL_ACCOUNTS3]), map_yes_no_field_default({ answer: relationship2[HAS_BUYER_FINANCIAL_ACCOUNTS3] })) ]; return mapped; }; @@ -8047,7 +7985,7 @@ var map_buyer_default = mapBuyer; var { OTHER: OTHER2 } = EXPORT_CONTRACT_AWARD_METHOD; var CONTENT_STRINGS8 = EXPORT_CONTRACT_FIELDS.HOW_WAS_THE_CONTRACT_AWARDED; var { - HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD: AWARD_METHOD2, OTHER_AWARD_METHOD }, + HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD: AWARD_METHOD2, OTHER_AWARD_METHOD } } = export_contract_default; var mapHowWasTheContractAwarded = (exportContract) => { const submittedMethodId = exportContract.awardMethodId; @@ -8070,13 +8008,11 @@ var map_how_was_the_contract_awarded_default = mapHowWasTheContractAwarded; var CONTENT_STRINGS9 = EXPORT_CONTRACT_FIELDS.ABOUT_GOODS_OR_SERVICES; var { FIELDS: FIELDS24 } = XLSX; var { - ABOUT_GOODS_OR_SERVICES: { FINAL_DESTINATION: FINAL_DESTINATION2, FINAL_DESTINATION_KNOWN: FINAL_DESTINATION_KNOWN3 }, + ABOUT_GOODS_OR_SERVICES: { FINAL_DESTINATION: FINAL_DESTINATION2, FINAL_DESTINATION_KNOWN: FINAL_DESTINATION_KNOWN3 } } = export_contract_default; var mapFinalDestination = (exportContract, countries) => { const finalDestinationKnownAnswer = exportContract[FINAL_DESTINATION_KNOWN3]; - const mapped = [ - xlsx_row_default(String(FIELDS24.EXPORT_CONTRACT[FINAL_DESTINATION_KNOWN3]), map_yes_no_field_default({ answer: finalDestinationKnownAnswer })), - ]; + const mapped = [xlsx_row_default(String(FIELDS24.EXPORT_CONTRACT[FINAL_DESTINATION_KNOWN3]), map_yes_no_field_default({ answer: finalDestinationKnownAnswer }))]; if (finalDestinationKnownAnswer) { const country = get_country_by_iso_code_default(countries, exportContract[FINAL_DESTINATION2]); mapped.push(xlsx_row_default(String(CONTENT_STRINGS9[FINAL_DESTINATION2].SUMMARY?.TITLE), country.name)); @@ -8088,12 +8024,12 @@ var map_final_destination_default = mapFinalDestination; // generate-xlsx/map-application-to-XLSX/map-export-contract/map-private-market/index.ts var { FIELDS: FIELDS25 } = XLSX; var { - PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION: DECLINED_DESCRIPTION3 }, + PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION: DECLINED_DESCRIPTION3 } } = export_contract_default; var mapPrivateMarket = (application2) => { const { exportContract: { privateMarket }, - totalContractValueOverThreshold, + totalContractValueOverThreshold } = application2; if (totalContractValueOverThreshold) { const attempedPrivateMarketAnswer = privateMarket[ATTEMPTED]; @@ -8110,12 +8046,7 @@ var map_private_market_default = mapPrivateMarket; // generate-xlsx/map-application-to-XLSX/map-export-contract/map-agent/map-agent-charge/map-agent-charge-amount/index.ts var { FIELDS: FIELDS26 } = XLSX; var { - AGENT_CHARGES: { - FIXED_SUM_AMOUNT: FIXED_SUM_AMOUNT2, - FIXED_SUM_CURRENCY_CODE, - PAYABLE_COUNTRY_CODE: PAYABLE_COUNTRY_CODE2, - PERCENTAGE_CHARGE: PERCENTAGE_CHARGE2, - }, + AGENT_CHARGES: { FIXED_SUM_AMOUNT: FIXED_SUM_AMOUNT2, FIXED_SUM_CURRENCY_CODE, PAYABLE_COUNTRY_CODE: PAYABLE_COUNTRY_CODE2, PERCENTAGE_CHARGE: PERCENTAGE_CHARGE2 } } = export_contract_default; var mapAgentChargeAmount = (charge, countries) => { const country = get_country_by_iso_code_default(countries, charge[PAYABLE_COUNTRY_CODE2]); @@ -8136,7 +8067,7 @@ var map_agent_charge_amount_default = mapAgentChargeAmount; // generate-xlsx/map-application-to-XLSX/map-export-contract/map-agent/map-agent-charge/index.ts var { FIELDS: FIELDS27 } = XLSX; var { - AGENT_SERVICE: { IS_CHARGING: IS_CHARGING2 }, + AGENT_SERVICE: { IS_CHARGING: IS_CHARGING2 } } = export_contract_default; var mapAgentCharge = (service, countries) => { const { charge } = service; @@ -8154,7 +8085,7 @@ var { FIELDS: FIELDS28 } = XLSX; var { AGENT_DETAILS: { NAME: NAME4, FULL_ADDRESS: FULL_ADDRESS5, COUNTRY_CODE: COUNTRY_CODE3 }, AGENT_SERVICE: { SERVICE_DESCRIPTION: SERVICE_DESCRIPTION2 }, - USING_AGENT: USING_AGENT2, + USING_AGENT: USING_AGENT2 } = export_contract_default; var mapAgent = (agent, countries) => { const usingAgentAnswer = agent[USING_AGENT2]; @@ -8168,7 +8099,7 @@ var mapAgent = (agent, countries) => { xlsx_row_default(String(FIELDS28.AGENT[FULL_ADDRESS5]), agent[FULL_ADDRESS5]), xlsx_row_default(String(FIELDS28.AGENT[COUNTRY_CODE3]), country.name), xlsx_row_default(String(FIELDS28.AGENT_SERVICE[SERVICE_DESCRIPTION2]), service[SERVICE_DESCRIPTION2]), - ...map_agent_charge_default(service, countries), + ...map_agent_charge_default(service, countries) ]; } return mapped; @@ -8179,7 +8110,7 @@ var map_agent_default = mapAgent; var { FIELDS: FIELDS29 } = XLSX; var { ABOUT_GOODS_OR_SERVICES: { DESCRIPTION: DESCRIPTION3 }, - HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION: PAYMENT_TERMS_DESCRIPTION3 }, + HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION: PAYMENT_TERMS_DESCRIPTION3 } } = export_contract_default; var mapExportContract = (application2, countries) => { const { exportContract } = application2; @@ -8190,7 +8121,7 @@ var mapExportContract = (application2, countries) => { ...map_final_destination_default(exportContract, countries), xlsx_row_default(String(FIELDS29.EXPORT_CONTRACT[PAYMENT_TERMS_DESCRIPTION3]), exportContract[PAYMENT_TERMS_DESCRIPTION3]), ...map_private_market_default(application2), - ...map_agent_default(agent, countries), + ...map_agent_default(agent, countries) ]; return mapped; }; @@ -8213,8 +8144,8 @@ var { AGREE_ANTI_BRIBERY: AGREE_ANTI_BRIBERY2, HAS_ANTI_BRIBERY_CODE_OF_CONDUCT: HAS_ANTI_BRIBERY_CODE_OF_CONDUCT3, WILL_EXPORT_WITH_CODE_OF_CONDUCT: WILL_EXPORT_WITH_CODE_OF_CONDUCT3, - AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2, - }, + AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2 + } } = insurance_default; var mapDeclarations = (application2) => { const { declaration } = application2; @@ -8223,43 +8154,28 @@ var mapDeclarations = (application2) => { xlsx_row_default(DECLARATIONS_FIELDS[AGREE_ANTI_BRIBERY2].SUMMARY.TITLE, map_agreed_field_default(declaration[AGREE_ANTI_BRIBERY2])), xlsx_row_default(String(FIELDS30[HAS_ANTI_BRIBERY_CODE_OF_CONDUCT3]), map_yes_no_field_default({ answer: declaration[HAS_ANTI_BRIBERY_CODE_OF_CONDUCT3] })), xlsx_row_default(String(FIELDS30[WILL_EXPORT_WITH_CODE_OF_CONDUCT3]), map_yes_no_field_default({ answer: declaration[WILL_EXPORT_WITH_CODE_OF_CONDUCT3] })), - xlsx_row_default( - DECLARATIONS_FIELDS[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2].SUMMARY.TITLE, - map_agreed_field_default(declaration[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2]), - ), + xlsx_row_default(DECLARATIONS_FIELDS[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2].SUMMARY.TITLE, map_agreed_field_default(declaration[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2])) ]; return mapped; }; var map_declarations_default = mapDeclarations; // generate-xlsx/map-application-to-XLSX/index.ts -var { - APPLICATION_INFORMATION, - ELIGIBILITY: ELIGIBILITY2, - EXPORTER_BUSINESS: EXPORTER_BUSINESS3, - POLICY: POLICY4, - BUYER, - EXPORT_CONTRACT: EXPORT_CONTRACT2, - DECLARATIONS: DECLARATIONS3, -} = SECTION_NAMES_default; +var { APPLICATION_INFORMATION, ELIGIBILITY: ELIGIBILITY2, EXPORTER_BUSINESS: EXPORTER_BUSINESS3, POLICY: POLICY4, BUYER, EXPORT_CONTRACT: EXPORT_CONTRACT2, DECLARATIONS: DECLARATIONS3 } = SECTION_NAMES_default; var mapApplicationToXLSX = (application2, countries) => { try { const mapped = { - [APPLICATION_INFORMATION]: [ - ...map_introduction_default(application2), - ...map_exporter_contact_details_default(application2), - ...map_key_information_default(application2), - ], + [APPLICATION_INFORMATION]: [...map_introduction_default(application2), ...map_exporter_contact_details_default(application2), ...map_key_information_default(application2)], [ELIGIBILITY2]: map_eligibility_default(application2), [EXPORTER_BUSINESS3]: map_exporter_business_default(application2), [POLICY4]: map_policy_default2(application2, countries), [BUYER]: map_buyer_default(application2), [EXPORT_CONTRACT2]: map_export_contract_default(application2, countries), - [DECLARATIONS3]: map_declarations_default(application2), + [DECLARATIONS3]: map_declarations_default(application2) }; return mapped; } catch (error) { - console.error('Error mapping application to XLSX %o', error); + console.error("Error mapping application to XLSX %o", error); throw new Error(`Mapping application to XLSX ${error}`); } }; @@ -8269,7 +8185,7 @@ var map_application_to_XLSX_default = mapApplicationToXLSX; var { KEY: KEY2, VALUE: VALUE2, COLUMN_WIDTH } = XLSX_CONFIG; var XLSX_HEADER_COLUMNS = (sheetName) => [ { key: KEY2, header: sheetName, width: COLUMN_WIDTH }, - { key: VALUE2, width: COLUMN_WIDTH }, + { key: VALUE2, width: COLUMN_WIDTH } ]; var header_columns_default = XLSX_HEADER_COLUMNS; @@ -8277,14 +8193,14 @@ var header_columns_default = XLSX_HEADER_COLUMNS; var DEFAULT_INDEXES = () => ({ REGISTERED_OFFICE_ADDRESS: 3, COMPANY_SIC_CODES: 4, - ALTERNATIVE_TRADING_ADDRESS: 0, + ALTERNATIVE_TRADING_ADDRESS: 0 }); var EXPORTER_BUSINESS_INDEXES = (application2) => { const { company: { differentTradingAddress: { fullAddress: hasDifferentTradingAddress }, - hasDifferentTradingName, - }, + hasDifferentTradingName + } } = application2; const INDEXES = DEFAULT_INDEXES(); if (hasDifferentTradingAddress) { @@ -8304,9 +8220,9 @@ var BROKER_CONDITIONS = (application2, INDEXES) => { broker, policy: { jointlyInsuredParty: { requested: requestedJointlyInsuredParty }, - needPreCreditPeriodCover, + needPreCreditPeriodCover }, - policyContact: { isSameAsOwner: policyContactIsSameAsOwner }, + policyContact: { isSameAsOwner: policyContactIsSameAsOwner } } = application2; const MODIFIED_INDEXES = INDEXES; if (broker[USING_BROKER4]) { @@ -8332,9 +8248,9 @@ var LOSS_PAYEE_CONDITIONS = (application2, INDEXES) => { nominatedLossPayee: { isAppointed: nominatedLossPayeeAppointed }, policy: { jointlyInsuredParty: { requested: requestedJointlyInsuredParty }, - needPreCreditPeriodCover, + needPreCreditPeriodCover }, - policyContact: { isSameAsOwner: policyContactIsSameAsOwner }, + policyContact: { isSameAsOwner: policyContactIsSameAsOwner } } = application2; const MODIFIED_INDEXES = INDEXES; if (nominatedLossPayeeAppointed) { @@ -8359,18 +8275,18 @@ var LOSS_PAYEE_CONDITIONS_default = LOSS_PAYEE_CONDITIONS; var { TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE8 }, USING_BROKER: USING_BROKER6, - NAME_ON_POLICY: { IS_SAME_AS_OWNER: IS_SAME_AS_OWNER2 }, + NAME_ON_POLICY: { IS_SAME_AS_OWNER: IS_SAME_AS_OWNER2 } } = policy_default; var DEFAULT_INDEXES2 = { BROKER_ADDRESS: 0, - LOSS_PAYEE_ADDRESS: 0, + LOSS_PAYEE_ADDRESS: 0 }; var POLICY_INDEXES = (application2) => { const { broker, nominatedLossPayee: { isAppointed: nominatedLossPayeeAppointed }, policy, - policyContact, + policyContact } = application2; const isMultiplePolicy = isMultiplePolicyType(policy[POLICY_TYPE8]); let INDEXES = DEFAULT_INDEXES2; @@ -8393,7 +8309,7 @@ var POLICY_INDEXES = (application2) => { INDEXES = { ...INDEXES, ...BROKER_CONDITIONS_default(application2, INDEXES), - ...LOSS_PAYEE_CONDITIONS_default(application2, INDEXES), + ...LOSS_PAYEE_CONDITIONS_default(application2, INDEXES) }; return INDEXES; }; @@ -8401,13 +8317,13 @@ var POLICY_default = POLICY_INDEXES; // constants/XLSX-CONFIG/INDEXES/BUYER/index.ts var BUYER_INDEXES = () => ({ - BUYER_ADDRESS: 3, + BUYER_ADDRESS: 3 }); var BUYER_default = BUYER_INDEXES; // constants/XLSX-CONFIG/INDEXES/EXPORT_CONTRACT/index.ts var DEFAULT_INDEXES3 = () => ({ - AGENT_ADDRESS: 0, + AGENT_ADDRESS: 0 }); var EXPORT_CONTRACT_INDEXES = (application2) => { const { exportContract } = application2; @@ -8432,7 +8348,7 @@ var XLSX_ROW_INDEXES = { [EXPORTER_BUSINESS4]: (application2) => EXPORTER_BUSINESS_default(application2), [POLICY5]: (application2) => POLICY_default(application2), [BUYER2]: () => BUYER_default(), - [EXPORT_CONTRACT3]: (application2) => EXPORT_CONTRACT_default(application2), + [EXPORT_CONTRACT3]: (application2) => EXPORT_CONTRACT_default(application2) }; var INDEXES_default = XLSX_ROW_INDEXES; @@ -8458,8 +8374,8 @@ var styledColumns = (application2, worksheet, sheetName) => { row.eachCell((cell, colNumber) => { const modifiedRow = row; modifiedRow.getCell(colNumber).alignment = { - vertical: 'top', - wrapText: true, + vertical: "top", + wrapText: true }; const isInformationSheet = sheetName === APPLICATION_INFORMATION2; const isInformationTitleOne = isInformationSheet && rowNumber === 8; @@ -8468,7 +8384,7 @@ var styledColumns = (application2, worksheet, sheetName) => { const isTitleRow = rowNumber === 1 || isInformationTitle; modifiedRow.getCell(colNumber).font = { bold: Boolean(isTitleRow), - size: isTitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT, + size: isTitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT }; }); }); @@ -8487,51 +8403,51 @@ import_dotenv9.default.config(); var { EXCELJS_PROTECTION_PASSWORD } = process.env; var XLSX2 = (application2, countries) => { try { - console.info('Generating XLSX file for application %s', application2.id); + console.info("Generating XLSX file for application %s", application2.id); const { referenceNumber } = application2; const refNumber = String(referenceNumber); return new Promise((resolve) => { const filePath = `XLSX/${refNumber}.xlsx`; const xlsxData = map_application_to_XLSX_default(application2, countries); - console.info('Generating XLSX file - creating a new workbook'); + console.info("Generating XLSX file - creating a new workbook"); const workbook = new import_exceljs.default.Workbook(); - console.info('Generating XLSX file - adding worksheets to workbook'); + console.info("Generating XLSX file - adding worksheets to workbook"); const sheetNames = Object.values(SECTION_NAMES_default); sheetNames.forEach((sheetName) => { - console.info('Generating XLSX file - adding %s worksheet', sheetName); + console.info("Generating XLSX file - adding %s worksheet", sheetName); let worksheet = workbook.addWorksheet(sheetName); - console.info('Generating XLSX file - protecting %s worksheet from modification', sheetName); + console.info("Generating XLSX file - protecting %s worksheet from modification", sheetName); worksheet.protect(String(EXCELJS_PROTECTION_PASSWORD), {}); - console.info('Generating XLSX file - adding %s worksheet header columns', sheetName); + console.info("Generating XLSX file - adding %s worksheet header columns", sheetName); worksheet.columns = header_columns_default(sheetName); xlsxData[sheetName].forEach((row) => { - console.info('Generating XLSX file - adding rows to %s worksheeet', sheetName); + console.info("Generating XLSX file - adding rows to %s worksheeet", sheetName); if (row) { worksheet.addRow(row); } }); - console.info('Generating XLSX file - adding custom styles to %s worksheet', sheetName); + console.info("Generating XLSX file - adding custom styles to %s worksheet", sheetName); worksheet = styled_columns_default(application2, worksheet, sheetName); }); - console.info('Generating XLSX file - writing file'); + console.info("Generating XLSX file - writing file"); workbook.xlsx.writeFile(filePath).then(() => resolve(filePath)); }); } catch (error) { - console.error('Error generating XLSX file %o', error); + console.error("Error generating XLSX file %o", error); throw new Error(`Generating XLSX file ${error}`); } }; var generate2 = { - XLSX: XLSX2, + XLSX: XLSX2 }; var generate_xlsx_default = generate2; // custom-resolvers/mutations/submit-application/index.ts var submitApplication = async (root, variables, context) => { try { - console.info('Submitting application %s', variables.applicationId); + console.info("Submitting application %s", variables.applicationId); const application2 = await context.db.Application.findOne({ - where: { id: variables.applicationId }, + where: { id: variables.applicationId } }); if (application2) { const { status, submissionDeadline, submissionCount } = application2; @@ -8541,39 +8457,39 @@ var submitApplication = async (root, variables, context) => { const isFirstSubmission = submissionCount === 0; const canSubmit = isInProgress && validSubmissionDate && isFirstSubmission; if (canSubmit) { - console.info('Submitting application - updating status, submission date and count %s', variables.applicationId); + console.info("Submitting application - updating status, submission date and count %s", variables.applicationId); const update2 = { status: APPLICATION.STATUS.SUBMITTED, previousStatus: APPLICATION.STATUS.IN_PROGRESS, submissionDate: now2, - submissionCount: submissionCount + 1, + submissionCount: submissionCount + 1 }; const updatedApplication = await context.db.Application.updateOne({ where: { id: application2.id }, - data: update2, + data: update2 }); - console.info('Submitting application - getting populated application %s', variables.applicationId); + console.info("Submitting application - getting populated application %s", variables.applicationId); const populatedApplication2 = await get_populated_application_default.get({ context, application: updatedApplication, decryptFinancialUk: true, - decryptFinancialInternational: true, + decryptFinancialInternational: true }); const countries = await get_countries_default(context); const xlsxPath = await generate_xlsx_default.XLSX(populatedApplication2, countries); await send_application_submitted_emails_default.send(populatedApplication2, xlsxPath); return { - success: true, + success: true }; } - console.error('Unable to submit application - application already submitted'); + console.error("Unable to submit application - application already submitted"); } - console.error('Unable to submit application - no application found'); + console.error("Unable to submit application - no application found"); return { - success: false, + success: false }; } catch (error) { - console.error('Error submitting application %o', error); + console.error("Error submitting application %o", error); throw new Error(`Submitting application ${error}`); } }; @@ -8581,110 +8497,105 @@ var submit_application_default = submitApplication; // custom-resolvers/mutations/create-feedback/index.ts var createFeedback = async (root, variables, context) => { - console.info('Creating feedback'); + console.info("Creating feedback"); try { const feedback = { ...variables, - createdAt: /* @__PURE__ */ new Date(), + createdAt: /* @__PURE__ */ new Date() }; const response = await context.db.Feedback.createOne({ - data: feedback, + data: feedback }); const emailResponse = await emails_default.insuranceFeedbackEmail(feedback); if (response && emailResponse?.success) { return { ...response, - success: true, + success: true }; } return { success: false }; } catch (error) { - console.error('Error creating feedback %o', error); + console.error("Error creating feedback %o", error); throw new Error(`Creating feedback: ${error}`); } }; var create_feedback_default = createFeedback; // custom-resolvers/mutations/verify-account-reactivation-token/index.ts -var import_date_fns7 = require('date-fns'); +var import_date_fns7 = require("date-fns"); var { INSURANCE: { - ACCOUNT: { REACTIVATION_HASH, REACTIVATION_EXPIRY }, - }, + ACCOUNT: { REACTIVATION_HASH, REACTIVATION_EXPIRY } + } } = FIELD_IDS; var verifyAccountReactivationToken = async (root, variables, context) => { try { - console.info('Received a request to reactivate account - checking account'); + console.info("Received a request to reactivate account - checking account"); const account2 = await get_account_by_field_default(context, REACTIVATION_HASH, variables.token); if (account2) { - console.info('Received a request to reactivate account - found account %s', account2.id); + console.info("Received a request to reactivate account - found account %s", account2.id); const now2 = /* @__PURE__ */ new Date(); const canReactivateAccount = (0, import_date_fns7.isBefore)(now2, account2[REACTIVATION_EXPIRY]); if (!canReactivateAccount) { - console.info('Unable to reactivate account - reactivation period has expired'); + console.info("Unable to reactivate account - reactivation period has expired"); return { expired: true, success: false, - accountId: account2.id, + accountId: account2.id }; } - console.info('Reactivating account %s', account2.id); + console.info("Reactivating account %s", account2.id); const accountUpdate = { - reactivationHash: '', - reactivationExpiry: null, + reactivationHash: "", + reactivationExpiry: null }; const statusUpdate = { isBlocked: false, - isVerified: true, + isVerified: true }; await update_account_default.account(context, account2.id, accountUpdate); await update_account_default.accountStatus(context, account2.status.id, statusUpdate); await delete_authentication_retries_default(context, account2.id); return { - success: true, + success: true }; } - console.info('Unable to reactivate account - no account found from the provided %s', REACTIVATION_HASH); + console.info("Unable to reactivate account - no account found from the provided %s", REACTIVATION_HASH); return { success: false, - invalid: true, + invalid: true }; } catch (error) { - console.error('Error checking account and reactivating account(verifyAccountReactivationToken mutation) %o', error); + console.error("Error checking account and reactivating account(verifyAccountReactivationToken mutation) %o", error); throw new Error(`Checking account and reactivating account(verifyAccountReactivationToken mutation) ${error}`); } }; var verify_account_reactivation_token_default = verifyAccountReactivationToken; // helpers/encrypt/index.ts -var import_crypto12 = __toESM(require('crypto')); +var import_crypto12 = __toESM(require("crypto")); // helpers/encrypt/generate-initialisation-vector/index.ts -var import_crypto11 = __toESM(require('crypto')); +var import_crypto11 = __toESM(require("crypto")); var { BYTES_SIZE, ENCODING: ENCODING3, SLICE_INDEX_START, SLICE_INDEX_END } = FINANCIAL_DETAILS.ENCRYPTION.IV; var generateInitialisationVector = () => import_crypto11.default.randomBytes(BYTES_SIZE).toString(ENCODING3).slice(SLICE_INDEX_START, SLICE_INDEX_END); var generate_initialisation_vector_default = generateInitialisationVector; // helpers/encrypt/index.ts -var { - ENCRYPTION_METHOD: ENCRYPTION_METHOD2, - ENCODING: ENCODING4, - STRING_ENCODING: STRING_ENCODING3, - OUTPUT_ENCODING: OUTPUT_ENCODING3, -} = FINANCIAL_DETAILS.ENCRYPTION.CIPHER; +var { ENCRYPTION_METHOD: ENCRYPTION_METHOD2, ENCODING: ENCODING4, STRING_ENCODING: STRING_ENCODING3, OUTPUT_ENCODING: OUTPUT_ENCODING3 } = FINANCIAL_DETAILS.ENCRYPTION.CIPHER; var encrypt = (dataToEncrypt) => { try { - console.info('Encrypting data'); + console.info("Encrypting data"); const key2 = generate_key_default(); const iv = generate_initialisation_vector_default(); const cipher = import_crypto12.default.createCipheriv(ENCRYPTION_METHOD2, key2, iv); const value = Buffer.from(cipher.update(dataToEncrypt, OUTPUT_ENCODING3, ENCODING4).concat(cipher.final(ENCODING4))).toString(STRING_ENCODING3); return { value, - iv, + iv }; } catch (error) { - console.error('Error encrypting data %o', error); + console.error("Error encrypting data %o", error); throw new Error(`Error encrypting data ${error}`); } }; @@ -8693,7 +8604,7 @@ var encrypt_default = encrypt; // helpers/map-loss-payee-financial-details-uk/index.ts var mapLossPayeeFinancialDetailsUk2 = (variables) => { try { - console.info('Mapping loss payee financial UK'); + console.info("Mapping loss payee financial UK"); const { accountNumber, sortCode, bankAddress } = variables; let accountNumberData = DEFAULT_ENCRYPTION_SAVE_OBJECT; let sortCodeData = DEFAULT_ENCRYPTION_SAVE_OBJECT; @@ -8707,16 +8618,16 @@ var mapLossPayeeFinancialDetailsUk2 = (variables) => { uk: { accountNumber: accountNumberData.value, sortCode: sortCodeData.value, - bankAddress, + bankAddress }, vectors: { accountNumberVector: accountNumberData.iv, - sortCodeVector: sortCodeData.iv, - }, + sortCodeVector: sortCodeData.iv + } }; return updateData; } catch (error) { - console.error('Error mapping loss payee financial UK %o', error); + console.error("Error mapping loss payee financial UK %o", error); throw new Error(`Error mapping loss payee financial UK ${error}`); } }; @@ -8725,16 +8636,16 @@ var map_loss_payee_financial_details_uk_default = mapLossPayeeFinancialDetailsUk // helpers/update-loss-payee-financial-uk/index.ts var updateLossPayeeFinancialInternationalUk = async (context, id, data) => { try { - console.info('Updating loss payee financial uk (helper) %s', id); + console.info("Updating loss payee financial uk (helper) %s", id); const updated = await context.db.LossPayeeFinancialUk.updateOne({ where: { - id, + id }, - data, + data }); return updated; } catch (error) { - console.error('Error updating loss payee financial uk (helper) %o', error); + console.error("Error updating loss payee financial uk (helper) %o", error); throw new Error(`Updating loss payee financial uk (helper) ${error}`); } }; @@ -8743,16 +8654,16 @@ var update_loss_payee_financial_uk_default = updateLossPayeeFinancialInternation // helpers/update-loss-payee-financial-uk-vector/index.ts var updateLossPayeeFinancialUkVector = async (context, id, data) => { try { - console.info('Updating loss payee financial uk vector (helper) %s', id); + console.info("Updating loss payee financial uk vector (helper) %s", id); const updated = await context.db.LossPayeeFinancialUkVector.updateOne({ where: { - id, + id }, - data, + data }); return updated; } catch (error) { - console.error('Error updating loss payee financial uk vector (helper) %o', error); + console.error("Error updating loss payee financial uk vector (helper) %o", error); throw new Error(`Updating loss payee financial uk vector (helper) ${error}`); } }; @@ -8761,21 +8672,21 @@ var update_loss_payee_financial_uk_vector_default = updateLossPayeeFinancialUkVe // custom-resolvers/mutations/update-loss-payee-financial-details-uk/index.ts var updateLossPayeeFinancialDetailsUk = async (root, variables, context) => { try { - console.info('Updating loss payee financial UK %s', variables.id); + console.info("Updating loss payee financial UK %s", variables.id); const { id } = variables; const mappedData = map_loss_payee_financial_details_uk_default(variables); const uk = await update_loss_payee_financial_uk_default(context, id, mappedData.uk); const vector = await update_loss_payee_financial_uk_vector_default(context, String(uk.vectorId), mappedData.vectors); if (uk && vector) { return { - success: true, + success: true }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error updating loss payee financial UK %o', error); + console.error("Error updating loss payee financial UK %o", error); throw new Error(`Updating loss payee financial UK ${error}`); } }; @@ -8797,16 +8708,16 @@ var mapLossPayeeFinancialDetailsInternational2 = (variables) => { international: { iban: ibanData.value, bicSwiftCode: bicSwiftCodeData.value, - bankAddress, + bankAddress }, vectors: { ibanVector: ibanData.iv, - bicSwiftCodeVector: bicSwiftCodeData.iv, - }, + bicSwiftCodeVector: bicSwiftCodeData.iv + } }; return updateData; } catch (error) { - console.error('Error mapping loss payee financial international %o', error); + console.error("Error mapping loss payee financial international %o", error); throw new Error(`Error mapping loss payee financial international ${error}`); } }; @@ -8815,16 +8726,16 @@ var map_loss_payee_financial_details_international_default = mapLossPayeeFinanci // helpers/update-loss-payee-financial-international/index.ts var updateLossPayeeFinancialInternational = async (context, id, data) => { try { - console.info('Updating loss payee financial international (helper) %s', id); + console.info("Updating loss payee financial international (helper) %s", id); const updated = await context.db.LossPayeeFinancialInternational.updateOne({ where: { - id, + id }, - data, + data }); return updated; } catch (error) { - console.error('Error updating loss payee financial international (helper) %o', error); + console.error("Error updating loss payee financial international (helper) %o", error); throw new Error(`Updating loss payee financial international (helper) ${error}`); } }; @@ -8833,16 +8744,16 @@ var update_loss_payee_financial_international_default = updateLossPayeeFinancial // helpers/update-loss-payee-financial-international-vector/index.ts var updateLossPayeeFinancialInternationalVector = async (context, id, data) => { try { - console.info('Updating loss payee financial international vector (helper) %s', id); + console.info("Updating loss payee financial international vector (helper) %s", id); const updated = await context.db.LossPayeeFinancialInternationalVector.updateOne({ where: { - id, + id }, - data, + data }); return updated; } catch (error) { - console.error('Error updating loss payee financial international vector (helper) %o', error); + console.error("Error updating loss payee financial international vector (helper) %o", error); throw new Error(`Updating loss payee financial international vector (helper) ${error}`); } }; @@ -8851,21 +8762,21 @@ var update_loss_payee_financial_international_vector_default = updateLossPayeeFi // custom-resolvers/mutations/update-loss-payee-financial-details-international/index.ts var updateLossPayeeFinancialDetailsInternational = async (root, variables, context) => { try { - console.info('Updating loss payee financial international %s', variables.id); + console.info("Updating loss payee financial international %s", variables.id); const { id } = variables; const mappedData = map_loss_payee_financial_details_international_default(variables); const international = await update_loss_payee_financial_international_default(context, id, mappedData.international); const vector = await update_loss_payee_financial_international_vector_default(context, String(international.vectorId), mappedData.vectors); if (international && vector) { return { - success: true, + success: true }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error updating loss payee financial international %o', error); + console.error("Error updating loss payee financial international %o", error); throw new Error(`Updating loss payee financial international ${error}`); } }; @@ -8873,94 +8784,94 @@ var update_loss_payee_financial_details_international_default = updateLossPayeeF // custom-resolvers/queries/get-account-password-reset-token/index.ts var getAccountPasswordResetToken = async (root, variables, context) => { - console.info('Getting account password reset token'); + console.info("Getting account password reset token"); try { const { email } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (!account2) { - console.info('Unable to get account password reset token - account does not exist'); + console.info("Unable to get account password reset token - account does not exist"); return { success: false }; } if (account2.passwordResetHash) { return { success: true, - token: account2.passwordResetHash, + token: account2.passwordResetHash }; } - console.info('Unable to get account password reset token - reset hash does not exist'); + console.info("Unable to get account password reset token - reset hash does not exist"); return { success: false }; } catch (error) { - console.error('Error getting account password reset token %o', error); + console.error("Error getting account password reset token %o", error); throw new Error(`Getting account password reset token ${error}`); } }; var get_account_password_reset_token_default = getAccountPasswordResetToken; // integrations/APIM/index.ts -var import_axios = __toESM(require('axios')); -var import_dotenv10 = __toESM(require('dotenv')); +var import_axios = __toESM(require("axios")); +var import_dotenv10 = __toESM(require("dotenv")); import_dotenv10.default.config(); var { APIM_MDM_URL, APIM_MDM_KEY, APIM_MDM_VALUE } = process.env; var { APIM_MDM } = EXTERNAL_API_ENDPOINTS; var APIM = { getCisCountries: async () => { try { - console.info('Calling APIM - CIS countries'); + console.info("Calling APIM - CIS countries"); const response = await (0, import_axios.default)({ - method: 'get', + method: "get", url: `${APIM_MDM_URL}${APIM_MDM.MARKETS}`, headers: { - 'Content-Type': 'application/json', - [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, + "Content-Type": "application/json", + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE }, validateStatus(status) { const acceptableStatus = [200]; return acceptableStatus.includes(status); - }, + } }); if (response.data && response.status === 200) { return { success: true, - data: response.data, + data: response.data }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error calling APIM - CIS countries %o', error); + console.error("Error calling APIM - CIS countries %o", error); throw new Error(`Calling APIM - CIS countries ${error}`); } }, getCurrencies: async () => { try { - console.info('Calling APIM - currencies'); + console.info("Calling APIM - currencies"); const response = await (0, import_axios.default)({ - method: 'get', + method: "get", url: `${APIM_MDM_URL}${APIM_MDM.CURRENCY}`, headers: { - 'Content-Type': 'application/json', - [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, + "Content-Type": "application/json", + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE }, validateStatus(status) { const acceptableStatus = [200]; return acceptableStatus.includes(status); - }, + } }); if (response.data && response.status === 200) { return { success: true, - data: response.data, + data: response.data }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error calling APIM - currencies %o', error); + console.error("Error calling APIM - currencies %o", error); throw new Error(`Calling APIM - currencies ${error}`); } - }, + } }; var APIM_default = APIM; @@ -8973,7 +8884,7 @@ var filter_cis_entries_default = filterCisEntries; // helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts var { - CIS: { ESRA_CLASSIFICATION }, + CIS: { ESRA_CLASSIFICATION } } = EXTERNAL_API_DEFINITIONS; var mapEsraClassification = (str) => { if (str === ESRA_CLASSIFICATION.STANDARD) { @@ -8991,7 +8902,7 @@ var map_esra_classification_default = mapEsraClassification; // helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts var { - CIS: { SHORT_TERM_COVER }, + CIS: { SHORT_TERM_COVER } } = EXTERNAL_API_DEFINITIONS; var mapShortTermCoverAvailable = (str) => { switch (str) { @@ -9019,58 +8930,11 @@ var mapNbiIssueAvailable = (str) => { }; var map_NBI_issue_available_default = mapNbiIssueAvailable; -// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts -var canGetAQuoteOnline = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { - if (esraClassification && shortTermCover && nbiIssueAvailable) { - return true; - } - return false; -}; -var can_get_a_quote_online_default = canGetAQuoteOnline; - -// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts -var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { - if (shortTermCover && !nbiIssueAvailable && esraClassification) { - return true; - } - return false; -}; -var can_get_a_quote_by_email_default = canGetAQuoteByEmail; - -// helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts -var cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { - if (!esraClassification || (!shortTermCover && !nbiIssueAvailable)) { - return true; - } - return false; -}; -var cannot_get_a_quote_default = cannotGetAQuote; - -// helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts -var { - CIS: { - SHORT_TERM_COVER: { ILC, CILC, REFER }, - }, -} = EXTERNAL_API_DEFINITIONS; -var canApplyForAQuoteOffline = (originalShortTermCover) => { - if (originalShortTermCover === ILC) { - return true; - } - if (originalShortTermCover === CILC) { - return true; - } - if (originalShortTermCover === REFER) { - return true; - } - return false; -}; -var can_apply_for_quote_offline_default = canApplyForAQuoteOffline; - // helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts var { CIS: { - ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, - }, + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH } + } } = EXTERNAL_API_DEFINITIONS; var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { switch (esraClassification) { @@ -9086,17 +8950,17 @@ var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { }; var esra_classification_is_standard_high_or_very_high_default = esraClassificationIsStandardHighOrVeryHigh; -// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts +// helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts var { CIS: { - SHORT_TERM_COVER: { YES: YES2, REFER: REFER2, UNLISTED }, - }, + SHORT_TERM_COVER: { YES: YES2, REFER, UNLISTED } + } } = EXTERNAL_API_DEFINITIONS; -var hasValidShortTermCover = (shortTermCover) => { +var shortTermCoverIsYesReferOrUnlisted = (shortTermCover) => { switch (shortTermCover) { case YES2: return true; - case REFER2: + case REFER: return true; case UNLISTED: return true; @@ -9104,11 +8968,11 @@ var hasValidShortTermCover = (shortTermCover) => { return false; } }; -var has_valid_short_term_cover_default = hasValidShortTermCover; +var short_term_cover_is_yes_refer_or_unlisted_default = shortTermCoverIsYesReferOrUnlisted; // helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts var { - CIS: { COUNTRY_RATINGS }, + CIS: { COUNTRY_RATINGS } } = EXTERNAL_API_DEFINITIONS; var countryRatingIsAorB = (rating) => { if (COUNTRY_RATINGS.A.includes(rating)) { @@ -9121,13 +8985,56 @@ var countryRatingIsAorB = (rating) => { }; var country_rating_is_a_or_b_default = countryRatingIsAorB; +// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts +var canGetAQuoteOnline = (cisCountry) => { + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; + const conditions = esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && country_rating_is_a_or_b_default(countryRatingDesc); + return conditions; +}; +var can_get_a_quote_online_default = canGetAQuoteOnline; + +// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts +var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (shortTermCover && !nbiIssueAvailable && esraClassification) { + return true; + } + return false; +}; +var can_get_a_quote_by_email_default = canGetAQuoteByEmail; + +// helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts +var cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (!esraClassification || !shortTermCover && !nbiIssueAvailable) { + return true; + } + return false; +}; +var cannot_get_a_quote_default = cannotGetAQuote; + +// helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts +var { + CIS: { + SHORT_TERM_COVER: { ILC, CILC, REFER: REFER2 } + } +} = EXTERNAL_API_DEFINITIONS; +var canApplyForAQuoteOffline = (originalShortTermCover) => { + if (originalShortTermCover === ILC) { + return true; + } + if (originalShortTermCover === CILC) { + return true; + } + if (originalShortTermCover === REFER2) { + return true; + } + return false; +}; +var can_apply_for_quote_offline_default = canApplyForAQuoteOffline; + // helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts var canApplyForInsuranceOnline = (cisCountry) => { const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; - const conditions = - esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && - has_valid_short_term_cover_default(shortTermCoverAvailabilityDesc) && - country_rating_is_a_or_b_default(countryRatingDesc); + const conditions = esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && country_rating_is_a_or_b_default(countryRatingDesc); return conditions; }; var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; @@ -9136,8 +9043,8 @@ var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE }, - SHORT_TERM_COVER: { NO: NO2, ILC: ILC2, CILC: CILC2 }, - }, + SHORT_TERM_COVER: { NO: NO2, ILC: ILC2, CILC: CILC2 } + } } = EXTERNAL_API_DEFINITIONS; var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_a_or_b_default(countryRating)) { @@ -9163,7 +9070,7 @@ var a_and_b_rating_conditions_default = aAndBRatingConditions; // helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts var { - CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 }, + CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 } } = EXTERNAL_API_DEFINITIONS; var countryRatingIsCorD = (rating) => { if (COUNTRY_RATINGS2.C.includes(rating)) { @@ -9180,8 +9087,8 @@ var country_rating_is_c_or_d_default = countryRatingIsCorD; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE2 }, - SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC3, CILC: CILC3, REFER: REFER3, UNLISTED: UNLISTED2 }, - }, + SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC3, CILC: CILC3, REFER: REFER3, UNLISTED: UNLISTED2 } + } } = EXTERNAL_API_DEFINITIONS; var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_c_or_d_default(countryRating)) { @@ -9219,12 +9126,12 @@ var noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCo const aAndBConditions = a_and_b_rating_conditions_default({ countryRating, esraClassification, - shortTermCover, + shortTermCover }); const cAndDConditions = c_and_d_rating_conditions_default({ countryRating, esraClassification, - shortTermCover, + shortTermCover }); const conditions = aAndBConditions || cAndDConditions; return conditions; @@ -9236,15 +9143,14 @@ var { CIS: { COUNTRY_RATINGS: { NOT_APPLICABLE }, ESRA_CLASSIFICATION: { NONE: NONE3 }, - SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC4 }, - }, + SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC4 } + } } = EXTERNAL_API_DEFINITIONS; var noInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }) => { const shortTermCoverIsUnlisted = shortTermCover === UNLISTED3; const esraClassificationIsNone = esraClassification === NONE3; const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; - const countryRatingConditions = - country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; + const countryRatingConditions = country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { return true; } @@ -9270,7 +9176,7 @@ var mapCisCountry = (cisCountry) => { name: marketName, nbiIssueAvailable, shortTermCover, - canGetAQuoteOnline: can_get_a_quote_online_default({ shortTermCover, nbiIssueAvailable, esraClassification }), + canGetAQuoteOnline: can_get_a_quote_online_default(cisCountry), canGetAQuoteOffline: can_apply_for_quote_offline_default(cisCountry.shortTermCoverAvailabilityDesc), canGetAQuoteByEmail: can_get_a_quote_by_email_default({ shortTermCover, nbiIssueAvailable, esraClassification }), cannotGetAQuote: cannot_get_a_quote_default({ shortTermCover, nbiIssueAvailable, esraClassification }), @@ -9278,13 +9184,13 @@ var mapCisCountry = (cisCountry) => { noOnlineInsuranceSupport: no_online_insurance_support_default({ countryRating, esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, + shortTermCover: shortTermCoverAvailabilityDesc }), noInsuranceSupport: no_insurance_support_default({ countryRating, esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, - }), + shortTermCover: shortTermCoverAvailabilityDesc + }) }; return mapped; }; @@ -9300,9 +9206,9 @@ var sort_array_alphabetically_default = sortArrayAlphabetically; // helpers/map-CIS-countries/index.ts var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; var mapCisCountries = (countries) => { - const filteredCountries = filter_cis_entries_default(countries, CIS2.INVALID_COUNTRIES, 'marketName'); + const filteredCountries = filter_cis_entries_default(countries, CIS2.INVALID_COUNTRIES, "marketName"); const mapped = filteredCountries.map((country) => map_CIS_country_default(country)); - const sorted = sort_array_alphabetically_default(mapped, 'name'); + const sorted = sort_array_alphabetically_default(mapped, "name"); return sorted; }; var map_CIS_countries_default = mapCisCountries; @@ -9310,7 +9216,7 @@ var map_CIS_countries_default = mapCisCountries; // custom-resolvers/queries/get-APIM-CIS-countries/index.ts var getApimCisCountries = async () => { try { - console.info('Getting and mapping CIS countries from APIM'); + console.info("Getting and mapping CIS countries from APIM"); const response = await APIM_default.getCisCountries(); if (response.data) { const mapped = map_CIS_countries_default(response.data); @@ -9318,7 +9224,7 @@ var getApimCisCountries = async () => { } return { success: false }; } catch (error) { - console.error('Error Getting and mapping CIS countries from APIM %o', error); + console.error("Error Getting and mapping CIS countries from APIM %o", error); throw new Error(`Getting and mapping CIS countries from APIM ${error}`); } }; @@ -9335,7 +9241,7 @@ var getAlternativeCurrencies = (currencies) => { return alternate; }; var mapCurrencies = (currencies, alternativeCurrencies) => { - let currenciesArray = filter_cis_entries_default(currencies, CIS3.INVALID_CURRENCIES, 'name'); + let currenciesArray = filter_cis_entries_default(currencies, CIS3.INVALID_CURRENCIES, "name"); if (!alternativeCurrencies) { currenciesArray = getSupportedCurrencies(currenciesArray); } else { @@ -9349,7 +9255,7 @@ var map_currencies_default = mapCurrencies; // custom-resolvers/queries/get-APIM-currencies/index.ts var getApimCurrencies = async () => { try { - console.info('Getting and mapping currencies from APIM'); + console.info("Getting and mapping currencies from APIM"); const response = await APIM_default.getCurrencies(); if (response.data) { const supportedCurrencies = map_currencies_default(response.data, false); @@ -9358,28 +9264,28 @@ var getApimCurrencies = async () => { return { supportedCurrencies, alternativeCurrencies, - allCurrencies, + allCurrencies }; } return { success: false }; } catch (error) { - console.error('Error Getting and mapping currencies from APIM %o', error); + console.error("Error Getting and mapping currencies from APIM %o", error); throw new Error(`Getting and mapping currencies from APIM ${error}`); } }; var get_APIM_currencies_default = getApimCurrencies; // helpers/remove-white-space/index.ts -var removeWhiteSpace = (string) => string.replace(' ', ''); +var removeWhiteSpace = (string) => string.replace(" ", ""); var remove_white_space_default = removeWhiteSpace; // helpers/sanitise-companies-house-number/index.ts -var sanitiseCompaniesHouseNumber = (companyNumber) => remove_white_space_default(companyNumber).toUpperCase().padStart(8, '0'); +var sanitiseCompaniesHouseNumber = (companyNumber) => remove_white_space_default(companyNumber).toUpperCase().padStart(8, "0"); var sanitise_companies_house_number_default = sanitiseCompaniesHouseNumber; // integrations/companies-house/index.ts -var import_axios2 = __toESM(require('axios')); -var import_dotenv11 = __toESM(require('dotenv')); +var import_axios2 = __toESM(require("axios")); +var import_dotenv11 = __toESM(require("dotenv")); import_dotenv11.default.config(); var username = String(process.env.COMPANIES_HOUSE_API_KEY); var companiesHouseURL = String(process.env.COMPANIES_HOUSE_API_URL); @@ -9387,84 +9293,84 @@ var companiesHouse = { get: async (companyNumber) => { try { const response = await (0, import_axios2.default)({ - method: 'get', + method: "get", url: `${companiesHouseURL}/company/${companyNumber}`, - auth: { username, password: '' }, + auth: { username, password: "" }, validateStatus(status) { const acceptableStatus = [200, 404]; return acceptableStatus.includes(status); - }, + } }); if (response.status === 404) { return { success: false, - notFound: true, + notFound: true }; } if (!response.data || response.status !== 200) { return { - success: false, + success: false }; } return { success: true, - data: response.data, + data: response.data }; } catch (error) { - console.error('Error calling Companies House API %o', error); + console.error("Error calling Companies House API %o", error); throw new Error(`Calling Companies House API. Unable to search for company ${error}`); } - }, + } }; var companies_house_default = companiesHouse; // integrations/industry-sector/index.ts -var import_axios3 = __toESM(require('axios')); -var import_dotenv12 = __toESM(require('dotenv')); +var import_axios3 = __toESM(require("axios")); +var import_dotenv12 = __toESM(require("dotenv")); import_dotenv12.default.config(); var { APIM_MDM_URL: APIM_MDM_URL2, APIM_MDM_KEY: APIM_MDM_KEY2, APIM_MDM_VALUE: APIM_MDM_VALUE2 } = process.env; var { APIM_MDM: APIM_MDM2 } = EXTERNAL_API_ENDPOINTS; var headers = { - 'Content-Type': 'application/json', - [String(APIM_MDM_KEY2)]: APIM_MDM_VALUE2, + "Content-Type": "application/json", + [String(APIM_MDM_KEY2)]: APIM_MDM_VALUE2 }; var industrySectorNames = { get: async () => { try { - console.info('Calling industry sector API'); + console.info("Calling industry sector API"); const response = await (0, import_axios3.default)({ - method: 'get', + method: "get", url: `${APIM_MDM_URL2}${APIM_MDM2.INDUSTRY_SECTORS}`, headers, validateStatus(status) { const acceptableStatus = [200, 404]; return acceptableStatus.includes(status); - }, + } }); if (!response.data || response.status !== 200) { return { - success: false, + success: false }; } return { success: true, - data: response.data, + data: response.data }; } catch (error) { - console.error('Error calling industry sector API %o', error); + console.error("Error calling industry sector API %o", error); return { success: false, - apiError: true, + apiError: true }; } - }, + } }; var industry_sector_default = industrySectorNames; // helpers/create-full-timestamp-from-day-month/index.ts var createFullTimestampFromDayAndMonth = (day, month) => { if (day && month) { - return /* @__PURE__ */ new Date(`${/* @__PURE__ */ new Date().getFullYear()}-${month}-${day}`); + return /* @__PURE__ */ new Date(`${(/* @__PURE__ */ new Date()).getFullYear()}-${month}-${day}`); } return null; }; @@ -9486,7 +9392,7 @@ var map_sic_code_descriptions_default = mapSicCodeDescriptions; // helpers/map-companies-house-fields/index.ts var { - COMPANIES_HOUSE: { COMPANY_STATUS }, + COMPANIES_HOUSE: { COMPANY_STATUS } } = EXTERNAL_API_DEFINITIONS; var mapCompaniesHouseFields = (companiesHouseResponse, sectors) => ({ companyName: companiesHouseResponse.company_name, @@ -9498,7 +9404,7 @@ var mapCompaniesHouseFields = (companiesHouseResponse, sectors) => ({ locality: companiesHouseResponse.registered_office_address.locality, region: companiesHouseResponse.registered_office_address.region, postalCode: companiesHouseResponse.registered_office_address.postal_code, - country: companiesHouseResponse.registered_office_address.country, + country: companiesHouseResponse.registered_office_address.country }, companyNumber: companiesHouseResponse.company_number, dateOfCreation: companiesHouseResponse.date_of_creation, @@ -9510,41 +9416,41 @@ var mapCompaniesHouseFields = (companiesHouseResponse, sectors) => ({ */ financialYearEndDate: create_full_timestamp_from_day_month_default( companiesHouseResponse.accounts?.accounting_reference_date?.day, - companiesHouseResponse.accounts?.accounting_reference_date?.month, + companiesHouseResponse.accounts?.accounting_reference_date?.month ), - isActive: companiesHouseResponse.company_status === COMPANY_STATUS.ACTIVE, + isActive: companiesHouseResponse.company_status === COMPANY_STATUS.ACTIVE }); // custom-resolvers/queries/get-companies-house-information/index.ts var getCompaniesHouseInformation = async (root, variables) => { try { const { companiesHouseNumber } = variables; - console.info('Getting Companies House information for %s', companiesHouseNumber); + console.info("Getting Companies House information for %s", companiesHouseNumber); const sanitisedNumber = sanitise_companies_house_number_default(companiesHouseNumber); const response = await companies_house_default.get(sanitisedNumber); if (!response.success || !response.data) { return { success: false, - notFound: response.notFound, + notFound: response.notFound }; } const industrySectors = await industry_sector_default.get(); if (!industrySectors.success || industrySectors.apiError) { return { apiError: true, - success: false, + success: false }; } const mappedResponse = mapCompaniesHouseFields(response.data, industrySectors.data); return { ...mappedResponse, - success: true, + success: true }; } catch (error) { - console.error('Error getting companies house information %o', error); + console.error("Error getting companies house information %o", error); return { apiError: true, - success: false, + success: false }; } }; @@ -9553,7 +9459,7 @@ var get_companies_house_information_default = getCompaniesHouseInformation; // custom-resolvers/queries/get-application-by-reference-number/index.ts var getApplicationByReferenceNumberQuery = async (root, variables, context) => { try { - console.info('Getting application by reference number %s', variables.referenceNumber); + console.info("Getting application by reference number %s", variables.referenceNumber); const { referenceNumber, decryptFinancialUk: decryptFinancialUk2, decryptFinancialInternational: decryptFinancialInternational2 } = variables; const application2 = await get_application_by_reference_number_default(referenceNumber, context); if (application2) { @@ -9561,75 +9467,73 @@ var getApplicationByReferenceNumberQuery = async (root, variables, context) => { context, application: application2, decryptFinancialUk: decryptFinancialUk2, - decryptFinancialInternational: decryptFinancialInternational2, + decryptFinancialInternational: decryptFinancialInternational2 }); return { success: true, - application: populatedApplication2, + application: populatedApplication2 }; } return { - success: false, + success: false }; } catch (error) { - console.error('Error getting application by reference number (GetApplicationByReferenceNumber query) %o', error); + console.error("Error getting application by reference number (GetApplicationByReferenceNumber query) %o", error); throw new Error(`Get application by reference number (GetApplicationByReferenceNumber query) ${error}`); } }; var get_application_by_reference_number_default2 = getApplicationByReferenceNumberQuery; // integrations/ordnance-survey/index.ts -var import_axios4 = __toESM(require('axios')); -var import_dotenv13 = __toESM(require('dotenv')); +var import_axios4 = __toESM(require("axios")); +var import_dotenv13 = __toESM(require("dotenv")); import_dotenv13.default.config(); var { ORDNANCE_SURVEY_API_KEY, ORDNANCE_SURVEY_API_URL } = process.env; var ordnanceSurvey = { get: async (postcode) => { try { const response = await (0, import_axios4.default)({ - method: 'get', + method: "get", url: `${ORDNANCE_SURVEY_API_URL}${ORDNANCE_SURVEY_QUERY_URL}${postcode}&key=${ORDNANCE_SURVEY_API_KEY}`, validateStatus(status) { const acceptableStatus = [200, 404]; return acceptableStatus.includes(status); - }, + } }); if (!response?.data?.results || response.status !== 200) { return { - success: false, + success: false }; } return { success: true, - data: response.data.results, + data: response.data.results }; } catch (error) { - console.error('Error calling Ordnance Survey API %o', error); + console.error("Error calling Ordnance Survey API %o", error); throw new Error(`Calling Ordnance Survey API. Unable to search for address ${error}`); } - }, + } }; var ordnance_survey_default = ordnanceSurvey; // helpers/is-valid-postcode/index.ts -var import_postcode_validator = require('postcode-validator'); -var isValidPostcode = (postcode) => (0, import_postcode_validator.postcodeValidator)(postcode, 'GB'); +var import_postcode_validator = require("postcode-validator"); +var isValidPostcode = (postcode) => (0, import_postcode_validator.postcodeValidator)(postcode, "GB"); // helpers/map-address/index.ts var mapAddress = (address) => ({ - addressLine1: `${address.DPA.ORGANISATION_NAME ?? ''} ${address.DPA.BUILDING_NAME ?? ''} ${address.DPA.BUILDING_NUMBER ?? ''} ${ - address.DPA.THOROUGHFARE_NAME ?? '' - }`.trim(), + addressLine1: `${address.DPA.ORGANISATION_NAME ?? ""} ${address.DPA.BUILDING_NAME ?? ""} ${address.DPA.BUILDING_NUMBER ?? ""} ${address.DPA.THOROUGHFARE_NAME ?? ""}`.trim(), addressLine2: address.DPA.DEPENDENT_LOCALITY, town: address.DPA.POST_TOWN, - postalCode: address.DPA.POSTCODE, + postalCode: address.DPA.POSTCODE }); var map_address_default = mapAddress; // helpers/map-and-filter-address/index.ts var mapAndFilterAddress = (houseNameOrNumber, ordnanceSurveyResponse) => { const filtered = ordnanceSurveyResponse.filter( - (eachAddress) => eachAddress.DPA.BUILDING_NUMBER === houseNameOrNumber || eachAddress.DPA.BUILDING_NAME === houseNameOrNumber, + (eachAddress) => eachAddress.DPA.BUILDING_NUMBER === houseNameOrNumber || eachAddress.DPA.BUILDING_NAME === houseNameOrNumber ); if (!filtered.length) { return []; @@ -9646,37 +9550,37 @@ var map_and_filter_address_default = mapAndFilterAddress; var getOrdnanceSurveyAddress = async (root, variables) => { try { const { postcode, houseNameOrNumber } = variables; - console.info('Getting Ordnance Survey address for postcode: %s, houseNameOrNumber: %s', postcode, houseNameOrNumber); + console.info("Getting Ordnance Survey address for postcode: %s, houseNameOrNumber: %s", postcode, houseNameOrNumber); const noWhitespacePostcode = remove_white_space_default(postcode); if (!isValidPostcode(noWhitespacePostcode)) { - console.error('Invalid postcode: %s', postcode); + console.error("Invalid postcode: %s", postcode); return { success: false, - invalidPostcode: true, + invalidPostcode: true }; } const response = await ordnance_survey_default.get(postcode); if (!response.success || !response.data) { return { - success: false, + success: false }; } const mappedAddresses = map_and_filter_address_default(houseNameOrNumber, response.data); if (!mappedAddresses.length) { return { success: false, - noAddressesFound: true, + noAddressesFound: true }; } return { addresses: mappedAddresses, - success: true, + success: true }; } catch (error) { - console.error('Error getting Ordnance Survey address results %o', error); + console.error("Error getting Ordnance Survey address results %o", error); return { apiError: true, - success: false, + success: false }; } }; @@ -9685,32 +9589,32 @@ var get_ordnance_survey_address_default = getOrdnanceSurveyAddress; // custom-resolvers/queries/verify-account-password-reset-token/index.ts var { PASSWORD_RESET_HASH, PASSWORD_RESET_EXPIRY } = account_default; var verifyAccountPasswordResetToken = async (root, variables, context) => { - console.info('Verifying account password reset token'); + console.info("Verifying account password reset token"); try { const { token } = variables; const account2 = await get_account_by_field_default(context, PASSWORD_RESET_HASH, token); if (account2) { const hasExpired = dateIsInThePast(account2[PASSWORD_RESET_EXPIRY]); if (hasExpired) { - console.info('Unable to verify account password reset token - token has expired'); + console.info("Unable to verify account password reset token - token has expired"); return { success: false, expired: true, - accountId: account2.id, + accountId: account2.id }; } - console.info('Successfully verified account password reset token'); + console.info("Successfully verified account password reset token"); return { - success: true, + success: true }; } - console.info('Unable to verify account password reset token - no account found from the provided %s', PASSWORD_RESET_HASH); + console.info("Unable to verify account password reset token - no account found from the provided %s", PASSWORD_RESET_HASH); return { success: false, - invalid: true, + invalid: true }; } catch (error) { - console.error('Error verifying account password reset token %o', error); + console.error("Error verifying account password reset token %o", error); throw new Error(`Verifying account password reset token ${error}`); } }; @@ -9738,7 +9642,7 @@ var customResolvers = { createFeedbackAndSendEmail: create_feedback_default, verifyAccountReactivationToken: verify_account_reactivation_token_default, updateLossPayeeFinancialDetailsUk: update_loss_payee_financial_details_uk_default, - updateLossPayeeFinancialDetailsInternational: update_loss_payee_financial_details_international_default, + updateLossPayeeFinancialDetailsInternational: update_loss_payee_financial_details_international_default }, Query: { getAccountPasswordResetToken: get_account_password_reset_token_default, @@ -9747,29 +9651,28 @@ var customResolvers = { getCompaniesHouseInformation: get_companies_house_information_default, getApplicationByReferenceNumber: get_application_by_reference_number_default2, getOrdnanceSurveyAddress: get_ordnance_survey_address_default, - verifyAccountPasswordResetToken: verify_account_password_reset_token_default, - }, + verifyAccountPasswordResetToken: verify_account_password_reset_token_default + } }; var custom_resolvers_default = customResolvers; // custom-schema/index.ts -var extendGraphqlSchema = (schema) => - (0, import_schema.mergeSchemas)({ - schemas: [schema], - typeDefs: type_defs_default, - resolvers: custom_resolvers_default, - }); +var extendGraphqlSchema = (schema) => (0, import_schema.mergeSchemas)({ + schemas: [schema], + typeDefs: type_defs_default, + resolvers: custom_resolvers_default +}); // keystone.ts var { NODE_ENV: NODE_ENV2, PORT, DATABASE_URL } = process.env; -var isDevEnvironment2 = NODE_ENV2 === 'development'; -var isProdEnvironment = NODE_ENV2 === 'production'; +var isDevEnvironment2 = NODE_ENV2 === "development"; +var isProdEnvironment = NODE_ENV2 === "production"; var keystone_default = withAuth( (0, import_core3.config)({ server: { port: Number(PORT), extendExpressApp: (app) => { - app.use((0, import_overload_protection.default)('express')); + app.use((0, import_overload_protection.default)("express")); app.use(security_default); app.use(check_api_key_default); if (isProdEnvironment) { @@ -9778,25 +9681,25 @@ var keystone_default = withAuth( }, extendHttpServer: (httpServer, context) => { cron_default(context); - }, + } }, db: { - provider: 'mysql', + provider: "mysql", url: String(DATABASE_URL), - enableLogging: isDevEnvironment2, + enableLogging: isDevEnvironment2 }, graphql: { playground: isDevEnvironment2, apolloConfig: { introspection: isDevEnvironment2, plugins: apolloPlugins2, - formatError: formatGraphQlError2, - }, + formatError: formatGraphQlError2 + } }, lists, session, extendGraphqlSchema, - telemetry: false, - }), + telemetry: false + }) ); //# sourceMappingURL=config.js.map diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts index b163837507..a2f212d569 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts @@ -1,6 +1,6 @@ import canApplyForInsuranceOnline from '.'; import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; -import hasValidShortTermCover from './has-valid-short-term-cover'; +import shortTermCoverIsYesReferOrUnlisted from '../short-term-cover-is-yes-refer-or-unlisted'; import countryRatingIsAorB from '../country-rating-is-a-or-b'; import { mockCisCountry } from '../../../../test-mocks'; @@ -12,7 +12,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli const expected = esraClassificationIsStandardHighOrVeryHigh(ESRAClassificationDesc) && - hasValidShortTermCover(shortTermCoverAvailabilityDesc) && + shortTermCoverIsYesReferOrUnlisted(shortTermCoverAvailabilityDesc) && countryRatingIsAorB(marketRiskAppetitePublicDesc); expect(result).toEqual(expected); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts index a212117e8d..6474a2aac3 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts @@ -1,5 +1,5 @@ import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; -import hasValidShortTermCover from './has-valid-short-term-cover'; +import shortTermCoverIsYesReferOrUnlisted from '../short-term-cover-is-yes-refer-or-unlisted'; import countryRatingIsAorB from '../country-rating-is-a-or-b'; import { CisCountry } from '../../../../types'; @@ -14,7 +14,7 @@ const canApplyForInsuranceOnline = (cisCountry: CisCountry): boolean => { const conditions = esraClassificationIsStandardHighOrVeryHigh(ESRAClassificationDesc) && - hasValidShortTermCover(shortTermCoverAvailabilityDesc) && + shortTermCoverIsYesReferOrUnlisted(shortTermCoverAvailabilityDesc) && countryRatingIsAorB(countryRatingDesc); return conditions; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts index 5c841c38dc..c909591fd7 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts @@ -1,50 +1,20 @@ import canGetAQuoteOnline from '.'; -import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; - -const { - CIS: { - ESRA_CLASSIFICATION: { STANDARD }, - }, -} = EXTERNAL_API_MAPPINGS; +import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; +import shortTermCoverIsYesReferOrUnlisted from '../short-term-cover-is-yes-refer-or-unlisted'; +import countryRatingIsAorB from '../country-rating-is-a-or-b'; +import { mockCisCountry } from '../../../../test-mocks'; describe('helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online', () => { - describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is provided', () => { - it('should return true', () => { - const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: STANDARD }); - - expect(result).toEqual(true); - }); - }); - - describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is null', () => { - it('should return false', () => { - const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: null }); - - expect(result).toEqual(false); - }); - }); + it('should return the result of 3x conditions', () => { + const result = canGetAQuoteOnline(mockCisCountry); - describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is an empty string', () => { - it('should return false', () => { - const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: '' }); - - expect(result).toEqual(false); - }); - }); - - describe('when shortTermCover=false, nbiIssueAvailable=true, esraClassification is provided', () => { - it('should return false', () => { - const result = canGetAQuoteOnline({ shortTermCover: false, nbiIssueAvailable: true, esraClassification: STANDARD }); - - expect(result).toEqual(false); - }); - }); + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, marketRiskAppetitePublicDesc } = mockCisCountry; - describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is provided', () => { - it('should return false', () => { - const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: STANDARD }); + const expected = + esraClassificationIsStandardHighOrVeryHigh(ESRAClassificationDesc) && + shortTermCoverIsYesReferOrUnlisted(shortTermCoverAvailabilityDesc) && + countryRatingIsAorB(marketRiskAppetitePublicDesc); - expect(result).toEqual(false); - }); + expect(result).toEqual(expected); }); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts index 1bc5e7d721..e9d23198ec 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts @@ -1,20 +1,23 @@ -import { MapCisCountryParams } from '../../../../types'; +import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; +import shortTermCoverIsYesReferOrUnlisted from '../short-term-cover-is-yes-refer-or-unlisted'; +import countryRatingIsAorB from '../country-rating-is-a-or-b'; +import { CisCountry } from '../../../../types'; /** * canGetAQuoteOnline - * Check if a country is able to get a quote online - * @param {MapCisCountryParams} - * @param {Boolean} shortTermCover: Short term cover flag. - * @param {Boolean} nbiIssueAvailable: NBI flag. - * @param {String} esraClassification: ESRA classification. + * Check if a country can apply for a quote online. + * @param {CisCountry} CIS Country * @returns {Boolean} */ -const canGetAQuoteOnline = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { - if (esraClassification && shortTermCover && nbiIssueAvailable) { - return true; - } +const canGetAQuoteOnline = (cisCountry: CisCountry) => { + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; - return false; + const conditions = + esraClassificationIsStandardHighOrVeryHigh(ESRAClassificationDesc) && + shortTermCoverIsYesReferOrUnlisted(shortTermCoverAvailabilityDesc) && + countryRatingIsAorB(countryRatingDesc); + + return conditions; }; export default canGetAQuoteOnline; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index df12047f19..e40851377d 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -42,7 +42,7 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { nbiIssueAvailable, shortTermCover, - canGetAQuoteOnline: canGetAQuoteOnline({ shortTermCover, nbiIssueAvailable, esraClassification }), + canGetAQuoteOnline: canGetAQuoteOnline(mockCisCountry), canGetAQuoteOffline: canApplyOffline(mockCountryBase.shortTermCoverAvailabilityDesc), diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index 963b4c0c9f..2a867e16f8 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -33,7 +33,7 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { nbiIssueAvailable, shortTermCover, - canGetAQuoteOnline: canGetAQuoteOnline({ shortTermCover, nbiIssueAvailable, esraClassification }), + canGetAQuoteOnline: canGetAQuoteOnline(cisCountry), canGetAQuoteOffline: canApplyForAQuoteOffline(cisCountry.shortTermCoverAvailabilityDesc), diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.test.ts similarity index 64% rename from src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.test.ts index 2b9b8a0fe4..bbef254a76 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.test.ts @@ -1,5 +1,5 @@ -import hasValidShortTermCover from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; +import shortTermCoverIsYesReferOrUnlisted from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { CIS: { @@ -7,14 +7,14 @@ const { }, } = EXTERNAL_API_DEFINITIONS; -describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover', () => { +describe('helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted', () => { const validShortTermCovers = [YES, REFER, UNLISTED]; const invalidShortTermCovers = [NO, ILC, CILC, 'Some other shortTermCover value']; describe.each(validShortTermCovers)('valid short term covers', (shortTermCover) => { it(`should return true for ${shortTermCover}`, () => { - const result = hasValidShortTermCover(shortTermCover); + const result = shortTermCoverIsYesReferOrUnlisted(shortTermCover); expect(result).toEqual(true); }); @@ -22,7 +22,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-onli describe.each(invalidShortTermCovers)('invalid short term covers', (shortTermCover) => { it(`should return false for ${shortTermCover}`, () => { - const result = hasValidShortTermCover(shortTermCover); + const result = shortTermCoverIsYesReferOrUnlisted(shortTermCover); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts similarity index 65% rename from src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts index 32c1e267cf..f1634ba038 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/has-valid-short-term-cover/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts @@ -1,4 +1,4 @@ -import { EXTERNAL_API_DEFINITIONS } from '../../../../../constants'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { CIS: { @@ -7,12 +7,12 @@ const { } = EXTERNAL_API_DEFINITIONS; /** - * hasValidShortTermCover + * shortTermCoverIsYesReferOrUnlisted * Check if a country's "short term cover" flag can apply for insurance online. * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const hasValidShortTermCover = (shortTermCover: string): boolean => { +const shortTermCoverIsYesReferOrUnlisted = (shortTermCover: string): boolean => { switch (shortTermCover) { case YES: return true; @@ -28,4 +28,4 @@ const hasValidShortTermCover = (shortTermCover: string): boolean => { } }; -export default hasValidShortTermCover; +export default shortTermCoverIsYesReferOrUnlisted; From 14c97c0aa0ba4dd807a134bd893e960192674009 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Fri, 20 Dec 2024 13:15:32 +0000 Subject: [PATCH 05/12] feat(EMS-4074): country risk logic - cannot get a quote (#3422) * feat(EMS-4065): country risk logic - application - no support * feat(EMS-4065): fix/update e2e tests * chore(EMS-4065): remove commented code * feat(EMS-4065): rename SHORT_TERM_COVER_AVAILABLE to SHORT_TERM_COVER * feat(EMS-4065): fix typo * feat(EMS-4065): minor code improvement * feat(EMS-4065): code improvement * feat(EMS-4065): fix/update e2e tests * feat(EMS-4074): country risk logic - cannot get a quote * feat(EMS-4074): fix tests --- e2e-tests/fixtures/countries.js | 2 +- .../buyer-country-unsupported-country.spec.js | 6 +- .../quote/get-a-quote-via-email.spec.js | 3 +- src/api/.keystone/config.js | 4908 +++++++++-------- .../cannot-get-a-quote/index.test.ts | 34 - .../cannot-get-a-quote/index.ts | 20 - .../map-CIS-country/index.test.ts | 11 +- .../map-CIS-country/index.ts | 11 +- .../map-CIS-country/no-support/index.test.ts | 116 + .../map-CIS-country/no-support/index.ts | 43 + .../buyer-country/country-redirects.test.ts | 26 + .../quote/buyer-country/index.test.ts | 25 + .../controllers/quote/buyer-country/index.ts | 4 + 13 files changed, 2735 insertions(+), 2474 deletions(-) delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts create mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts diff --git a/e2e-tests/fixtures/countries.js b/e2e-tests/fixtures/countries.js index 78b26b4b6e..aaf03e325b 100644 --- a/e2e-tests/fixtures/countries.js +++ b/e2e-tests/fixtures/countries.js @@ -59,7 +59,7 @@ const mockCountries = [XAD, AFG, DZA, AGO, AUS, BLR, BRA, MMR, FRA, RUS, GBR]; * COUNTRY_QUOTE_SUPPORT * Different types of country support for a quote. */ -const { 2: QUOTE_ONLINE, 3: QUOTE_BY_EMAIL, 8: QUOTE_UNSUPPORTED } = mockCountries; +const { 2: QUOTE_ONLINE, 3: QUOTE_BY_EMAIL, 10: QUOTE_UNSUPPORTED } = mockCountries; export const COUNTRY_QUOTE_SUPPORT = { ONLINE: QUOTE_ONLINE, diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js index e355a54aee..bfd2b74af0 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js @@ -38,17 +38,17 @@ context( cy.clickSubmitButton(); }); - it('redirects to `cannot obtain cover` exit page', () => { + it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => { const expectedUrl = `${baseUrl}${CANNOT_APPLY_EXIT}`; cy.assertUrl(expectedUrl); }); - it('renders a back link with correct url', () => { + it('should render a back link with correct url', () => { cy.checkLink(backLink(), BUYER_COUNTRY, LINKS.BACK); }); - it('renders a specific reason', () => { + it('should render a specific reason', () => { const { REASON } = CONTENT_STRINGS; const expected = `${REASON.INTRO} ${REASON.UNSUPPORTED_BUYER_COUNTRY_1} ${NEW_COUNTRY_INPUT}, ${REASON.UNSUPPORTED_BUYER_COUNTRY_2}`; cy.checkText(cannotApplyPage.reason(), expected); diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js index 8170f63a7e..520e5c7ee0 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js @@ -2,12 +2,13 @@ import { autoCompleteField } from '../../../../../pages/shared'; import { getAQuoteByEmailPage } from '../../../../../pages/quote'; import { PAGES } from '../../../../../content-strings'; import { ROUTES, FIELD_IDS } from '../../../../../constants'; +import { COUNTRY_QUOTE_SUPPORT } from '../../../../../fixtures/countries'; const CONTENT_STRINGS = PAGES.QUOTE.GET_A_QUOTE_BY_EMAIL; const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME_QUOTE_BY_EMAIL_ONLY = 'Egypt'; +const COUNTRY_NAME_QUOTE_BY_EMAIL_ONLY = COUNTRY_QUOTE_SUPPORT.BY_EMAIL.NAME; const baseUrl = Cypress.config('baseUrl'); diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 3143993d2d..4c081d6077 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; @@ -6,89 +6,91 @@ var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); + for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { + if ((from && typeof from === 'object') || typeof from === 'function') { for (let key2 of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key2) && key2 !== except) __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable }); } return to; }; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var __toESM = (mod, isNodeMode, target) => ( + (target = mod != null ? __create(__getProtoOf(mod)) : {}), + __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, 'default', { value: mod, enumerable: true }) : target, + mod, + ) +); +var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod); // keystone.ts var keystone_exports = {}; __export(keystone_exports, { - default: () => keystone_default + default: () => keystone_default, }); module.exports = __toCommonJS(keystone_exports); -var import_config7 = require("dotenv/config"); -var import_core3 = require("@keystone-6/core"); -var import_overload_protection = __toESM(require("overload-protection")); +var import_config7 = require('dotenv/config'); +var import_core3 = require('@keystone-6/core'); +var import_overload_protection = __toESM(require('overload-protection')); // middleware/headers/security/index.ts var security = (req, res, next) => { - res.setHeader("Strict-Transport-Security", "max-age=15552000; includeSubDomains; preload"); - res.setHeader("X-Frame-Options", "deny"); - res.setHeader("X-Content-Type-Options", "nosniff"); + res.setHeader('Strict-Transport-Security', 'max-age=15552000; includeSubDomains; preload'); + res.setHeader('X-Frame-Options', 'deny'); + res.setHeader('X-Content-Type-Options', 'nosniff'); res.setHeader( - "Content-Security-Policy", - "default-src 'none';connect-src 'self';base-uri 'self';font-src 'self' data:;form-action 'self';frame-ancestors 'self';img-src 'self';object-src 'none';script-src 'self';script-src-attr 'self';style-src 'self';upgrade-insecure-requests" + 'Content-Security-Policy', + "default-src 'none';connect-src 'self';base-uri 'self';font-src 'self' data:;form-action 'self';frame-ancestors 'self';img-src 'self';object-src 'none';script-src 'self';script-src-attr 'self';style-src 'self';upgrade-insecure-requests", ); - res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=604800"); - res.setHeader("Referrer-Policy", "same-origin"); - res.setHeader("X-Download-Options", "noopen"); - res.setHeader("X-DNS-Prefetch-Control", "on"); - res.setHeader("Expect-CT", "max-age=0,enforce"); - res.setHeader("Cross-Origin-Opener-Policy", "same-origin"); - res.setHeader("Cross-Origin-Resource-Policy", "same-origin"); - res.setHeader("Cross-Origin-Embedder-Policy", "require-corp"); + res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate, max-age=604800'); + res.setHeader('Referrer-Policy', 'same-origin'); + res.setHeader('X-Download-Options', 'noopen'); + res.setHeader('X-DNS-Prefetch-Control', 'on'); + res.setHeader('Expect-CT', 'max-age=0,enforce'); + res.setHeader('Cross-Origin-Opener-Policy', 'same-origin'); + res.setHeader('Cross-Origin-Resource-Policy', 'same-origin'); + res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp'); res.setHeader( - "Permissions-Policy", - "fullscreen=(self),microphone=(),camera=(),payment=(),geolocation=(),display-capture=(),battery=(),autoplay=(),gyroscope=(),accelerometer=(),web-share=(),usb=(),gamepad=(),magnetometer=(),midi=(),picture-in-picture=(),xr-spatial-tracking=()" + 'Permissions-Policy', + 'fullscreen=(self),microphone=(),camera=(),payment=(),geolocation=(),display-capture=(),battery=(),autoplay=(),gyroscope=(),accelerometer=(),web-share=(),usb=(),gamepad=(),magnetometer=(),midi=(),picture-in-picture=(),xr-spatial-tracking=()', ); - res.removeHeader("X-Powered-By"); + res.removeHeader('X-Powered-By'); next(); }; var security_default = security; // middleware/headers/check-api-key/index.ts -var import_config = require("dotenv/config"); +var import_config = require('dotenv/config'); var { API_KEY } = process.env; var checkApiKey = (req, res, next) => { - const { "x-api-key": xApiKey } = req.headers; + const { 'x-api-key': xApiKey } = req.headers; if (!xApiKey || xApiKey !== API_KEY) { - return res.status(401).json({ message: "Unauthorised" }); + return res.status(401).json({ message: 'Unauthorised' }); } next(); }; var check_api_key_default = checkApiKey; // middleware/rate-limiter/index.js -var import_express_rate_limit = __toESM(require("express-rate-limit")); +var import_express_rate_limit = __toESM(require('express-rate-limit')); var rateLimiter = (0, import_express_rate_limit.default)({ windowMs: 1 * 60 * 1e3, // 1 minute max: 1e3, // 1K requests / 1 window standardHeaders: false, - legacyHeaders: false + legacyHeaders: false, }); var rate_limiter_default = rateLimiter; // cron/cron-job-scheduler.ts -var cron = __toESM(require("node-cron")); +var cron = __toESM(require('node-cron')); // helpers/cron/scheduler.ts var asyncTaskToSyncTask = (task, context) => (now2) => { @@ -114,28 +116,31 @@ var cronJobScheduler = (jobs, context) => { return; } console.info("Adding scheduled job '%s' on schedule '%s'", description, cronExpression); - cron.schedule(cronExpression, asyncTaskToSyncTask(taskWithErrorLogging(description, task, context), context)).on("error", (error) => console.error("An error occurred scheduling job '%s' %o", description, error)); + cron + .schedule(cronExpression, asyncTaskToSyncTask(taskWithErrorLogging(description, task, context), context)) + .on('error', (error) => console.error("An error occurred scheduling job '%s' %o", description, error)); }); }; var cron_job_scheduler_default = cronJobScheduler; // cron/account/unverified-account-cron-job.ts -var import_dotenv2 = __toESM(require("dotenv")); +var import_dotenv2 = __toESM(require('dotenv')); // helpers/get-unverified-accounts/index.ts var now = /* @__PURE__ */ new Date(); var getUnverifiedAccounts = async (context) => { try { - console.info("Getting unverified accounts - getUnverifiedAccounts (helper)"); + console.info('Getting unverified accounts - getUnverifiedAccounts (helper)'); const accounts = await context.query.Account.findMany({ where: { - AND: [{ verificationExpiry: { lt: now } }, { status: { isVerified: { equals: false } } }, { status: { isInactive: { equals: false } } }] + AND: [{ verificationExpiry: { lt: now } }, { status: { isVerified: { equals: false } } }, { status: { isInactive: { equals: false } } }], }, - query: "id firstName lastName email otpSalt otpHash otpExpiry salt hash passwordResetHash passwordResetExpiry verificationHash verificationExpiry reactivationHash reactivationExpiry updatedAt status { id isBlocked isVerified isInactive updatedAt }" + query: + 'id firstName lastName email otpSalt otpHash otpExpiry salt hash passwordResetHash passwordResetExpiry verificationHash verificationExpiry reactivationHash reactivationExpiry updatedAt status { id isBlocked isVerified isInactive updatedAt }', }); return accounts; } catch (error) { - console.error("Error getting unverified accounts (getUnverifiedAccounts helper) %o", error); + console.error('Error getting unverified accounts (getUnverifiedAccounts helper) %o', error); throw new Error(`Error getting unverified accounts (getUnverifiedAccounts helper) ${error}`); } }; @@ -148,8 +153,8 @@ var mapUnverifiedAccounts = (accounts) => { where: { id: account2.status.id }, data: { isInactive: true, - updatedAt: /* @__PURE__ */ new Date() - } + updatedAt: /* @__PURE__ */ new Date(), + }, }; return mapped; }); @@ -158,15 +163,15 @@ var mapUnverifiedAccounts = (accounts) => { where: { id: account2.id }, data: { updatedAt: /* @__PURE__ */ new Date(), - verificationHash: "", - verificationExpiry: null - } + verificationHash: '', + verificationExpiry: null, + }, }; return mapped; }); return { accountStatus: mappedAccountStatusArray, - account: mappedAccountArray + account: mappedAccountArray, }; }; var map_unverified_accounts_default = mapUnverifiedAccounts; @@ -174,16 +179,16 @@ var map_unverified_accounts_default = mapUnverifiedAccounts; // helpers/map-and-update-unverified-accounts/index.ts var mapAndUpdateUnverifiedAccounts = async (accounts, context) => { try { - console.info("Mapping and updating unverified accounts - mapAndUpdateUnverifiedAccounts"); + console.info('Mapping and updating unverified accounts - mapAndUpdateUnverifiedAccounts'); const { account: account2, accountStatus: accountStatus2 } = map_unverified_accounts_default(accounts); await context.db.Account.updateMany({ - data: account2 + data: account2, }); await context.db.AccountStatus.updateMany({ - data: accountStatus2 + data: accountStatus2, }); } catch (error) { - console.error("Error mapping and updating unverified accounts %o", error); + console.error('Error mapping and updating unverified accounts %o', error); throw new Error(`Error mapping and updating unverified accounts ${error}`); } }; @@ -192,110 +197,110 @@ var map_and_update_unverified_accounts_default = mapAndUpdateUnverifiedAccounts; // helpers/update-unverified-accounts/index.ts var updateUnverifiedAccounts = async (context) => { try { - console.info("Getting and updating unverified accounts"); + console.info('Getting and updating unverified accounts'); const accounts = await get_unverified_accounts_default(context); if (accounts.length) { await map_and_update_unverified_accounts_default(accounts, context); return { - success: true + success: true, }; } - console.info("No unverified accounts found - updateUnverifiedAccounts"); + console.info('No unverified accounts found - updateUnverifiedAccounts'); return { - success: true + success: true, }; } catch (error) { - console.error("Error getting and updating unverified accounts %o", error); + console.error('Error getting and updating unverified accounts %o', error); throw new Error(`Error getting and updating unverified accounts ${error}`); } }; var update_unverified_accounts_default = updateUnverifiedAccounts; // constants/index.ts -var import_dotenv = __toESM(require("dotenv")); +var import_dotenv = __toESM(require('dotenv')); // constants/field-ids/shared/index.ts var SHARED = { - POLICY_TYPE: "policyType", - SINGLE_POLICY_TYPE: "singlePolicyType", - MULTIPLE_POLICY_TYPE: "multiplePolicyType", - POLICY_LENGTH: "policyLength", - NAME: "name", - EMAIL: "email" + POLICY_TYPE: 'policyType', + SINGLE_POLICY_TYPE: 'singlePolicyType', + MULTIPLE_POLICY_TYPE: 'multiplePolicyType', + POLICY_LENGTH: 'policyLength', + NAME: 'name', + EMAIL: 'email', }; var shared_default = SHARED; // constants/field-ids/shared-eligibility/index.ts var SHARED_ELIGIBILITY = { - BUYER_COUNTRY: "buyerCountry", - BUYER_COUNTRY_ISO_CODE: "buyerCountryIsoCode", - HAS_MINIMUM_UK_GOODS_OR_SERVICES: "hasMinimumUkGoodsOrServices", - VALID_EXPORTER_LOCATION: "validExporterLocation" + BUYER_COUNTRY: 'buyerCountry', + BUYER_COUNTRY_ISO_CODE: 'buyerCountryIsoCode', + HAS_MINIMUM_UK_GOODS_OR_SERVICES: 'hasMinimumUkGoodsOrServices', + VALID_EXPORTER_LOCATION: 'validExporterLocation', }; var shared_eligibility_default = SHARED_ELIGIBILITY; // constants/field-ids/insurance/shared/index.ts var SHARED_FIELD_IDS = { - COMPANY: "company", + COMPANY: 'company', COMPANIES_HOUSE: { - COMPANY_NAME: "companyName", - COMPANY_ADDRESS: "registeredOfficeAddress", - COMPANY_NUMBER: "companyNumber", - COMPANY_INCORPORATED: "dateOfCreation", - SIC_CODE: "sicCode", - COMPANY_SIC: "sicCodes", - INDUSTRY_SECTOR_NAME: "industrySectorName", - INDUSTRY_SECTOR_NAMES: "industrySectorNames", - FINANCIAL_YEAR_END_DATE: "financialYearEndDate", + COMPANY_NAME: 'companyName', + COMPANY_ADDRESS: 'registeredOfficeAddress', + COMPANY_NUMBER: 'companyNumber', + COMPANY_INCORPORATED: 'dateOfCreation', + SIC_CODE: 'sicCode', + COMPANY_SIC: 'sicCodes', + INDUSTRY_SECTOR_NAME: 'industrySectorName', + INDUSTRY_SECTOR_NAMES: 'industrySectorNames', + FINANCIAL_YEAR_END_DATE: 'financialYearEndDate', REGISTED_OFFICE_ADDRESS: { - ADDRESS_LINE_1: "addressLine1", - ADDRESS_LINE_2: "addressLine2", - CARE_OF: "careOf", - LOCALITY: "locality", - REGION: "region", - POSTAL_CODE: "postalCode", - COUNTRY: "country", - PREMISES: "premises" - } - } + ADDRESS_LINE_1: 'addressLine1', + ADDRESS_LINE_2: 'addressLine2', + CARE_OF: 'careOf', + LOCALITY: 'locality', + REGION: 'region', + POSTAL_CODE: 'postalCode', + COUNTRY: 'country', + PREMISES: 'premises', + }, + }, }; var shared_default2 = SHARED_FIELD_IDS; // constants/field-ids/insurance/account/index.ts var ACCOUNT = { - ID: "id", - FIRST_NAME: "firstName", - LAST_NAME: "lastName", - EMAIL: "email", - PASSWORD: "password", - SALT: "salt", - HASH: "hash", - ACCESS_CODE: "securityCode", - IS_VERIFIED: "isVerified", - IS_BLOCKED: "isBlocked", - PASSWORD_RESET_HASH: "passwordResetHash", - PASSWORD_RESET_EXPIRY: "passwordResetExpiry", - REACTIVATION_HASH: "reactivationHash", - REACTIVATION_EXPIRY: "reactivationExpiry", - VERIFICATION_HASH: "verificationHash", - VERIFICATION_EXPIRY: "verificationExpiry" + ID: 'id', + FIRST_NAME: 'firstName', + LAST_NAME: 'lastName', + EMAIL: 'email', + PASSWORD: 'password', + SALT: 'salt', + HASH: 'hash', + ACCESS_CODE: 'securityCode', + IS_VERIFIED: 'isVerified', + IS_BLOCKED: 'isBlocked', + PASSWORD_RESET_HASH: 'passwordResetHash', + PASSWORD_RESET_EXPIRY: 'passwordResetExpiry', + REACTIVATION_HASH: 'reactivationHash', + REACTIVATION_EXPIRY: 'reactivationExpiry', + VERIFICATION_HASH: 'verificationHash', + VERIFICATION_EXPIRY: 'verificationExpiry', }; var account_default = ACCOUNT; // constants/field-ids/insurance/policy/index.ts -var REQUESTED_START_DATE = "requestedStartDate"; -var CONTRACT_COMPLETION_DATE = "contractCompletionDate"; +var REQUESTED_START_DATE = 'requestedStartDate'; +var CONTRACT_COMPLETION_DATE = 'contractCompletionDate'; var SHARED_CONTRACT_POLICY = { REQUESTED_START_DATE, REQUESTED_START_DATE_DAY: `${REQUESTED_START_DATE}-day`, REQUESTED_START_DATE_MONTH: `${REQUESTED_START_DATE}-month`, REQUESTED_START_DATE_YEAR: `${REQUESTED_START_DATE}-year`, - POLICY_CURRENCY_CODE: "policyCurrencyCode" + POLICY_CURRENCY_CODE: 'policyCurrencyCode', }; var POLICY = { ...shared_default, TYPE_OF_POLICY: { - POLICY_TYPE: shared_default.POLICY_TYPE + POLICY_TYPE: shared_default.POLICY_TYPE, }, CONTRACT_POLICY: { ...SHARED_CONTRACT_POLICY, @@ -304,114 +309,114 @@ var POLICY = { CONTRACT_COMPLETION_DATE_DAY: `${CONTRACT_COMPLETION_DATE}-day`, CONTRACT_COMPLETION_DATE_MONTH: `${CONTRACT_COMPLETION_DATE}-month`, CONTRACT_COMPLETION_DATE_YEAR: `${CONTRACT_COMPLETION_DATE}-year`, - TOTAL_CONTRACT_VALUE: "totalValueOfContract", - REQUESTED_CREDIT_LIMIT: "requestedCreditLimit" + TOTAL_CONTRACT_VALUE: 'totalValueOfContract', + REQUESTED_CREDIT_LIMIT: 'requestedCreditLimit', }, MULTIPLE: { - TOTAL_MONTHS_OF_COVER: "totalMonthsOfCover" - } + TOTAL_MONTHS_OF_COVER: 'totalMonthsOfCover', + }, }, EXPORT_VALUE: { MULTIPLE: { - TOTAL_SALES_TO_BUYER: "totalSalesToBuyer", - MAXIMUM_BUYER_WILL_OWE: "maximumBuyerWillOwe" - } + TOTAL_SALES_TO_BUYER: 'totalSalesToBuyer', + MAXIMUM_BUYER_WILL_OWE: 'maximumBuyerWillOwe', + }, }, NAME_ON_POLICY: { - NAME: "nameOnPolicy", - IS_SAME_AS_OWNER: "isSameAsOwner", - SAME_NAME: "sameName", - OTHER_NAME: "otherName", - POSITION: "position", - POLICY_CONTACT_EMAIL: "policyContact.email" + NAME: 'nameOnPolicy', + IS_SAME_AS_OWNER: 'isSameAsOwner', + SAME_NAME: 'sameName', + OTHER_NAME: 'otherName', + POSITION: 'position', + POLICY_CONTACT_EMAIL: 'policyContact.email', }, DIFFERENT_NAME_ON_POLICY: { - POLICY_CONTACT_DETAIL: "policyContactDetail", - POSITION: "position" + POLICY_CONTACT_DETAIL: 'policyContactDetail', + POSITION: 'position', }, - NEED_PRE_CREDIT_PERIOD: "needPreCreditPeriodCover", - CREDIT_PERIOD_WITH_BUYER: "creditPeriodWithBuyer", + NEED_PRE_CREDIT_PERIOD: 'needPreCreditPeriodCover', + CREDIT_PERIOD_WITH_BUYER: 'creditPeriodWithBuyer', REQUESTED_JOINTLY_INSURED_PARTY: { - REQUESTED: "requested", - COMPANY_NAME: "companyName", - COMPANY_NUMBER: "companyNumber", - COUNTRY_CODE: "countryCode" + REQUESTED: 'requested', + COMPANY_NAME: 'companyName', + COMPANY_NUMBER: 'companyNumber', + COUNTRY_CODE: 'countryCode', }, - USING_BROKER: "isUsingBroker", + USING_BROKER: 'isUsingBroker', BROKER_DETAILS: { - NAME: "name", + NAME: 'name', EMAIL: shared_default.EMAIL, - BROKER_EMAIL: "broker.email", - FULL_ADDRESS: "fullAddress" + BROKER_EMAIL: 'broker.email', + FULL_ADDRESS: 'fullAddress', }, LOSS_PAYEE: { - IS_APPOINTED: "isAppointed" + IS_APPOINTED: 'isAppointed', }, LOSS_PAYEE_DETAILS: { - NAME: "name", - LOSS_PAYEE_NAME: "lossPayee.name", - LOCATION: "location", - IS_LOCATED_IN_UK: "isLocatedInUk", - IS_LOCATED_INTERNATIONALLY: "isLocatedInternationally" + NAME: 'name', + LOSS_PAYEE_NAME: 'lossPayee.name', + LOCATION: 'location', + IS_LOCATED_IN_UK: 'isLocatedInUk', + IS_LOCATED_INTERNATIONALLY: 'isLocatedInternationally', }, LOSS_PAYEE_FINANCIAL_UK: { - SORT_CODE: "sortCode", - ACCOUNT_NUMBER: "accountNumber" + SORT_CODE: 'sortCode', + ACCOUNT_NUMBER: 'accountNumber', }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { - BIC_SWIFT_CODE: "bicSwiftCode", - IBAN: "iban" + BIC_SWIFT_CODE: 'bicSwiftCode', + IBAN: 'iban', }, - FINANCIAL_ADDRESS: "bankAddress", - LOSS_PAYEE_FINANCIAL_ADDRESS: "lossPayee.bankAddress" + FINANCIAL_ADDRESS: 'bankAddress', + LOSS_PAYEE_FINANCIAL_ADDRESS: 'lossPayee.bankAddress', }; var policy_default = POLICY; // constants/field-ids/insurance/business/index.ts var EXPORTER_BUSINESS = { COMPANIES_HOUSE: { - INPUT: "companiesHouseNumber", - COMPANY_NAME: "companyName", - COMPANY_ADDRESS: "registeredOfficeAddress", - COMPANY_NUMBER: "companyNumber", - COMPANY_INCORPORATED: "dateOfCreation", - COMPANY_SIC: "sicCodes", - FINANCIAL_YEAR_END_DATE: "financialYearEndDate", + INPUT: 'companiesHouseNumber', + COMPANY_NAME: 'companyName', + COMPANY_ADDRESS: 'registeredOfficeAddress', + COMPANY_NUMBER: 'companyNumber', + COMPANY_INCORPORATED: 'dateOfCreation', + COMPANY_SIC: 'sicCodes', + FINANCIAL_YEAR_END_DATE: 'financialYearEndDate', REGISTED_OFFICE_ADDRESS: { - ADDRESS_LINE_1: "addressLine1", - ADDRESS_LINE_2: "addressLine2", - CARE_OF: "careOf", - LOCALITY: "locality", - REGION: "region", - POSTAL_CODE: "postalCode", - COUNTRY: "country", - PREMISES: "premises" - } + ADDRESS_LINE_1: 'addressLine1', + ADDRESS_LINE_2: 'addressLine2', + CARE_OF: 'careOf', + LOCALITY: 'locality', + REGION: 'region', + POSTAL_CODE: 'postalCode', + COUNTRY: 'country', + PREMISES: 'premises', + }, }, YOUR_COMPANY: { - YOUR_BUSINESS: "yourBusiness", - HAS_DIFFERENT_TRADING_ADDRESS: "hasDifferentTradingAddress", - HAS_DIFFERENT_TRADING_NAME: "hasDifferentTradingName", - DIFFERENT_TRADING_NAME: "differentTradingName", - WEBSITE: "companyWebsite", - PHONE_NUMBER: "phoneNumber" + YOUR_BUSINESS: 'yourBusiness', + HAS_DIFFERENT_TRADING_ADDRESS: 'hasDifferentTradingAddress', + HAS_DIFFERENT_TRADING_NAME: 'hasDifferentTradingName', + DIFFERENT_TRADING_NAME: 'differentTradingName', + WEBSITE: 'companyWebsite', + PHONE_NUMBER: 'phoneNumber', }, ALTERNATIVE_TRADING_ADDRESS: { - FULL_ADDRESS: "fullAddress", - FULL_ADDRESS_DOT_NOTATION: "alternativeTrading.fullAddress" + FULL_ADDRESS: 'fullAddress', + FULL_ADDRESS_DOT_NOTATION: 'alternativeTrading.fullAddress', }, NATURE_OF_YOUR_BUSINESS: { - GOODS_OR_SERVICES: "goodsOrServicesSupplied", - YEARS_EXPORTING: "totalYearsExporting", - EMPLOYEES_UK: "totalEmployeesUK" + GOODS_OR_SERVICES: 'goodsOrServicesSupplied', + YEARS_EXPORTING: 'totalYearsExporting', + EMPLOYEES_UK: 'totalEmployeesUK', }, TURNOVER: { - FINANCIAL_YEAR_END_DATE: "financialYearEndDate", - ESTIMATED_ANNUAL_TURNOVER: "estimatedAnnualTurnover", - PERCENTAGE_TURNOVER: "exportsTurnoverPercentage", - TURNOVER_CURRENCY_CODE: "turnoverCurrencyCode" + FINANCIAL_YEAR_END_DATE: 'financialYearEndDate', + ESTIMATED_ANNUAL_TURNOVER: 'estimatedAnnualTurnover', + PERCENTAGE_TURNOVER: 'exportsTurnoverPercentage', + TURNOVER_CURRENCY_CODE: 'turnoverCurrencyCode', }, - HAS_CREDIT_CONTROL: "hasCreditControlProcess" + HAS_CREDIT_CONTROL: 'hasCreditControlProcess', }; var business_default = EXPORTER_BUSINESS; @@ -419,85 +424,85 @@ var business_default = EXPORTER_BUSINESS; var EXPORT_CONTRACT = { ...shared_default, HOW_WAS_THE_CONTRACT_AWARDED: { - AWARD_METHOD: "awardMethod", - OTHER_AWARD_METHOD: "otherAwardMethod" + AWARD_METHOD: 'awardMethod', + OTHER_AWARD_METHOD: 'otherAwardMethod', }, ABOUT_GOODS_OR_SERVICES: { - DESCRIPTION: "goodsOrServicesDescription", - FINAL_DESTINATION_KNOWN: "finalDestinationKnown", - FINAL_DESTINATION: "finalDestinationCountryCode" + DESCRIPTION: 'goodsOrServicesDescription', + FINAL_DESTINATION_KNOWN: 'finalDestinationKnown', + FINAL_DESTINATION: 'finalDestinationCountryCode', }, HOW_WILL_YOU_GET_PAID: { - PAYMENT_TERMS_DESCRIPTION: "paymentTermsDescription" + PAYMENT_TERMS_DESCRIPTION: 'paymentTermsDescription', }, PRIVATE_MARKET: { - ATTEMPTED: "attempted", - DECLINED_DESCRIPTION: "declinedDescription" + ATTEMPTED: 'attempted', + DECLINED_DESCRIPTION: 'declinedDescription', }, - USING_AGENT: "isUsingAgent", + USING_AGENT: 'isUsingAgent', AGENT_DETAILS: { - NAME: "name", - AGENT_NAME: "agent.name", - FULL_ADDRESS: "fullAddress", - AGENT_FULL_ADDRESS: "agent.fullAddress", - COUNTRY_CODE: "countryCode", - AGENT_COUNTRY_CODE: "agent.countryCode" + NAME: 'name', + AGENT_NAME: 'agent.name', + FULL_ADDRESS: 'fullAddress', + AGENT_FULL_ADDRESS: 'agent.fullAddress', + COUNTRY_CODE: 'countryCode', + AGENT_COUNTRY_CODE: 'agent.countryCode', }, AGENT_SERVICE: { - IS_CHARGING: "agentIsCharging", - SERVICE_DESCRIPTION: "serviceDescription" + IS_CHARGING: 'agentIsCharging', + SERVICE_DESCRIPTION: 'serviceDescription', }, AGENT_CHARGES: { - METHOD: "method", - PAYABLE_COUNTRY_CODE: "payableCountryCode", - FIXED_SUM: "fixedSum", - FIXED_SUM_AMOUNT: "fixedSumAmount", - FIXED_SUM_CURRENCY_CODE: "fixedSumCurrencyCode", - PERCENTAGE: "percentage", - PERCENTAGE_CHARGE: "percentageCharge" - } + METHOD: 'method', + PAYABLE_COUNTRY_CODE: 'payableCountryCode', + FIXED_SUM: 'fixedSum', + FIXED_SUM_AMOUNT: 'fixedSumAmount', + FIXED_SUM_CURRENCY_CODE: 'fixedSumCurrencyCode', + PERCENTAGE: 'percentage', + PERCENTAGE_CHARGE: 'percentageCharge', + }, }; var export_contract_default = EXPORT_CONTRACT; // constants/field-ids/insurance/your-buyer/index.ts var YOUR_BUYER = { COMPANY_OR_ORGANISATION: { - NAME: "companyOrOrganisationName", - ADDRESS: "address", - COUNTRY: "country", - REGISTRATION_NUMBER: "registrationNumber", - WEBSITE: "website" - }, - CONNECTION_WITH_BUYER: "exporterIsConnectedWithBuyer", - CONNECTION_WITH_BUYER_DESCRIPTION: "connectionWithBuyerDescription", - TRADED_WITH_BUYER: "exporterHasTradedWithBuyer", - OUTSTANDING_PAYMENTS: "outstandingPayments", - TOTAL_OUTSTANDING_PAYMENTS: "totalOutstandingPayments", - TOTAL_AMOUNT_OVERDUE: "totalOverduePayments", - FAILED_PAYMENTS: "failedPayments", - HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: "exporterHasPreviousCreditInsuranceWithBuyer", - PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: "previousCreditInsuranceWithBuyerDescription", - HAS_BUYER_FINANCIAL_ACCOUNTS: "exporterHasBuyerFinancialAccounts" + NAME: 'companyOrOrganisationName', + ADDRESS: 'address', + COUNTRY: 'country', + REGISTRATION_NUMBER: 'registrationNumber', + WEBSITE: 'website', + }, + CONNECTION_WITH_BUYER: 'exporterIsConnectedWithBuyer', + CONNECTION_WITH_BUYER_DESCRIPTION: 'connectionWithBuyerDescription', + TRADED_WITH_BUYER: 'exporterHasTradedWithBuyer', + OUTSTANDING_PAYMENTS: 'outstandingPayments', + TOTAL_OUTSTANDING_PAYMENTS: 'totalOutstandingPayments', + TOTAL_AMOUNT_OVERDUE: 'totalOverduePayments', + FAILED_PAYMENTS: 'failedPayments', + HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: 'exporterHasPreviousCreditInsuranceWithBuyer', + PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: 'previousCreditInsuranceWithBuyerDescription', + HAS_BUYER_FINANCIAL_ACCOUNTS: 'exporterHasBuyerFinancialAccounts', }; var your_buyer_default = YOUR_BUYER; // constants/field-ids/insurance/declarations/index.ts var DECLARATIONS = { - AGREE_CONFIDENTIALITY: "agreeToConfidentiality", - AGREE_ANTI_BRIBERY: "agreeToAntiBribery", - HAS_ANTI_BRIBERY_CODE_OF_CONDUCT: "hasAntiBriberyCodeOfConduct", - WILL_EXPORT_WITH_CODE_OF_CONDUCT: "willExportWithAntiBriberyCodeOfConduct", - AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: "agreeToConfirmationAndAcknowledgements" + AGREE_CONFIDENTIALITY: 'agreeToConfidentiality', + AGREE_ANTI_BRIBERY: 'agreeToAntiBribery', + HAS_ANTI_BRIBERY_CODE_OF_CONDUCT: 'hasAntiBriberyCodeOfConduct', + WILL_EXPORT_WITH_CODE_OF_CONDUCT: 'willExportWithAntiBriberyCodeOfConduct', + AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: 'agreeToConfirmationAndAcknowledgements', }; var declarations_default = DECLARATIONS; // constants/field-ids/insurance/check-your-answers/index.ts var CHECK_YOUR_ANSWERS = { - ELIGIBILITY: "eligibility", - EXPORTER_BUSINESS: "business", - BUYER: "buyer", - POLICY: "policy", - EXPORT_CONTRACT: "exportContract" + ELIGIBILITY: 'eligibility', + EXPORTER_BUSINESS: 'business', + BUYER: 'buyer', + POLICY: 'policy', + EXPORT_CONTRACT: 'exportContract', }; var check_your_answers_default = CHECK_YOUR_ANSWERS; @@ -506,31 +511,31 @@ var INSURANCE_FIELD_IDS = { ELIGIBILITY: { ...shared_eligibility_default, ...shared_default2, - HAS_COMPANIES_HOUSE_NUMBER: "hasCompaniesHouseNumber", - COMPANIES_HOUSE_NUMBER: "companyNumber", - TOTAL_CONTRACT_VALUE: "totalContractValue", - TOTAL_CONTRACT_VALUE_ID: "totalContractValueId", - COVER_PERIOD: "coverPeriod", - COVER_PERIOD_ID: "coverPeriodId", - HAS_END_BUYER: "hasEndBuyer", - HAVE_AN_ACCOUNT: "haveAnAccount", - HAS_REVIEWED_ELIGIBILITY: "hasReviewedEligibility", - IS_PARTY_TO_CONSORTIUM: "isPartyToConsortium", - IS_MEMBER_OF_A_GROUP: "isMemberOfAGroup" + HAS_COMPANIES_HOUSE_NUMBER: 'hasCompaniesHouseNumber', + COMPANIES_HOUSE_NUMBER: 'companyNumber', + TOTAL_CONTRACT_VALUE: 'totalContractValue', + TOTAL_CONTRACT_VALUE_ID: 'totalContractValueId', + COVER_PERIOD: 'coverPeriod', + COVER_PERIOD_ID: 'coverPeriodId', + HAS_END_BUYER: 'hasEndBuyer', + HAVE_AN_ACCOUNT: 'haveAnAccount', + HAS_REVIEWED_ELIGIBILITY: 'hasReviewedEligibility', + IS_PARTY_TO_CONSORTIUM: 'isPartyToConsortium', + IS_MEMBER_OF_A_GROUP: 'isMemberOfAGroup', }, ...shared_default2, CURRENCY: { - CURRENCY_CODE: "currencyCode", - ALTERNATIVE_CURRENCY_CODE: "alternativeCurrencyCode" + CURRENCY_CODE: 'currencyCode', + ALTERNATIVE_CURRENCY_CODE: 'alternativeCurrencyCode', }, - SUBMISSION_DEADLINE: "submissionDeadline", + SUBMISSION_DEADLINE: 'submissionDeadline', ACCOUNT: account_default, POLICY: policy_default, EXPORTER_BUSINESS: business_default, EXPORT_CONTRACT: export_contract_default, YOUR_BUYER: your_buyer_default, DECLARATIONS: declarations_default, - CHECK_YOUR_ANSWERS: check_your_answers_default + CHECK_YOUR_ANSWERS: check_your_answers_default, }; var insurance_default = INSURANCE_FIELD_IDS; @@ -538,114 +543,114 @@ var insurance_default = INSURANCE_FIELD_IDS; var FIELD_IDS = { ...shared_default, ...shared_eligibility_default, - INSURANCE: insurance_default + INSURANCE: insurance_default, }; // constants/allowed-graphql-resolvers/index.ts -var import_config2 = require("dotenv/config"); +var import_config2 = require('dotenv/config'); var { NODE_ENV } = process.env; -var isDevEnvironment = NODE_ENV === "development"; +var isDevEnvironment = NODE_ENV === 'development'; var DEFAULT_RESOLVERS = [ // application - "updateBroker", - "updateBusiness", - "updateBuyer", - "updateBuyerRelationship", - "updateBuyerTradingHistory", - "updateCompany", - "updateDeclaration", - "updateNominatedLossPayee", - "updateJointlyInsuredParty", - "updatePolicy", - "updatePolicyContact", - "updateExportContract", - "updateExportContractAgent", - "updateExportContractAgentService", - "updateExportContractAgentServiceCharge", - "updatePrivateMarket", - "updateSectionReview", - "updateEligibility", - "updateCompanyDifferentTradingAddress", - "referenceNumber", - "applications", + 'updateBroker', + 'updateBusiness', + 'updateBuyer', + 'updateBuyerRelationship', + 'updateBuyerTradingHistory', + 'updateCompany', + 'updateDeclaration', + 'updateNominatedLossPayee', + 'updateJointlyInsuredParty', + 'updatePolicy', + 'updatePolicyContact', + 'updateExportContract', + 'updateExportContractAgent', + 'updateExportContractAgentService', + 'updateExportContractAgentServiceCharge', + 'updatePrivateMarket', + 'updateSectionReview', + 'updateEligibility', + 'updateCompanyDifferentTradingAddress', + 'referenceNumber', + 'applications', // account - "account", - "updateAccount", + 'account', + 'updateAccount', // misc - "countries", - "page" + 'countries', + 'page', ]; var CUSTOM_RESOLVERS = [ // account - "accountPasswordReset", - "accountSignIn", - "accountSignInSendNewCode", - "createAnAccount", - "sendEmailConfirmEmailAddress", - "sendEmailPasswordResetLink", - "sendEmailReactivateAccountLink", - "updateLossPayeeFinancialDetailsUk", - "updateLossPayeeFinancialDetailsInternational", - "verifyAccountEmailAddress", - "verifyAccountPasswordResetToken", - "verifyAccountReactivationToken", - "verifyAccountSignInCode", + 'accountPasswordReset', + 'accountSignIn', + 'accountSignInSendNewCode', + 'createAnAccount', + 'sendEmailConfirmEmailAddress', + 'sendEmailPasswordResetLink', + 'sendEmailReactivateAccountLink', + 'updateLossPayeeFinancialDetailsUk', + 'updateLossPayeeFinancialDetailsInternational', + 'verifyAccountEmailAddress', + 'verifyAccountPasswordResetToken', + 'verifyAccountReactivationToken', + 'verifyAccountSignInCode', // application - "createAnApplication", - "declarationAntiBriberies", - "declarationConfirmationAndAcknowledgements", - "declarationHowDataWillBeUseds", - "deleteApplicationByReferenceNumber", - "getCompaniesHouseInformation", - "getApplicationByReferenceNumber", - "submitApplication", + 'createAnApplication', + 'declarationAntiBriberies', + 'declarationConfirmationAndAcknowledgements', + 'declarationHowDataWillBeUseds', + 'deleteApplicationByReferenceNumber', + 'getCompaniesHouseInformation', + 'getApplicationByReferenceNumber', + 'submitApplication', // feedback - "createFeedbackAndSendEmail", - "getApimCisCountries", - "getApimCurrencies" + 'createFeedbackAndSendEmail', + 'getApimCisCountries', + 'getApimCurrencies', ]; if (isDevEnvironment) { CUSTOM_RESOLVERS.push( - "accounts", - "addAndGetOTP", - "createApplications", - "createAnAbandonedApplication", - "createManyApplications", - "createBuyer", - "deleteAnAccount", - "deleteApplications", - "getAccountPasswordResetToken", - "updateAccountStatus" + 'accounts', + 'addAndGetOTP', + 'createApplications', + 'createAnAbandonedApplication', + 'createManyApplications', + 'createBuyer', + 'deleteAnAccount', + 'deleteApplications', + 'getAccountPasswordResetToken', + 'updateAccountStatus', ); } var ALLOWED_GRAPHQL_RESOLVERS = [...DEFAULT_RESOLVERS, ...CUSTOM_RESOLVERS]; // constants/supported-currencies/index.ts -var SUPPORTED_CURRENCIES = ["EUR", "GBP", "JPY", "USD"]; -var GBP = "GBP"; +var SUPPORTED_CURRENCIES = ['EUR', 'GBP', 'JPY', 'USD']; +var GBP = 'GBP'; // constants/application/versions/index.ts var VERSION_1 = { - VERSION_NUMBER: "1", + VERSION_NUMBER: '1', OVER_500K_SUPPORT: false, MAXIMUM_BUYER_CAN_OWE: 5e5, TOTAL_VALUE_OF_CONTRACT: 5e5, DEFAULT_FINAL_DESTINATION_KNOWN: true, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: false, - BROKER_ADDRESS_AS_MULTIPLE_FIELDS: true + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: true, }; var VERSION_2 = { - VERSION_NUMBER: "2", + VERSION_NUMBER: '2', OVER_500K_SUPPORT: true, DEFAULT_FINAL_DESTINATION_KNOWN: null, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: null, DEFAULT_CURRENCY: GBP, - BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false, }; var VERSION_3 = { ...VERSION_2, - VERSION_NUMBER: "3", - REQUESTED_CREDIT_LIMIT_REQUIRED: true + VERSION_NUMBER: '3', + REQUESTED_CREDIT_LIMIT_REQUIRED: true, }; var VERSIONS = [VERSION_1, VERSION_2, VERSION_3]; var versions_default = VERSIONS; @@ -656,8 +661,8 @@ var getApplicationDefinition = (versionNumber) => { if (applicationDefinition) { return applicationDefinition; } - console.error("Unable to find latest application version"); - throw new Error("Unable to find latest application version"); + console.error('Unable to find latest application version'); + throw new Error('Unable to find latest application version'); }; var get_application_definition_default = getApplicationDefinition; @@ -670,11 +675,11 @@ var LATEST_VERSION = get_application_definition_default(latest_default); var APPLICATION = { LATEST_VERSION, LATEST_VERSION_NUMBER: latest_default, - DEAL_TYPE: "EXIP", + DEAL_TYPE: 'EXIP', SUBMISSION_COUNT_DEFAULT: 0, SUBMISSION_DEADLINE_IN_MONTHS: 1, SUBMISSION_DEADLINE_IN_DAYS: 30, - ALL_SECTIONS_ROUTE: "/all-sections", + ALL_SECTIONS_ROUTE: '/all-sections', SUBMISSION_DEADLINE_EMAIL: { REMINDER_DAYS: 2, START_TIME_LIMIT_HOURS: 0, @@ -684,34 +689,34 @@ var APPLICATION = { END_TIME_LIMIT_HOURS: 23, END_TIME_LIMIT_MINUTES: 59, END_TIME_LIMIT_SECONDS: 59, - END_TIME_LIMIT_MS: 999 + END_TIME_LIMIT_MS: 999, }, SUBMISSION_TYPE: { - MIA: "Manual Inclusion Application" + MIA: 'Manual Inclusion Application', }, POLICY_TYPE: { - SINGLE: "Single contract policy", - MULTIPLE: "Multiple contract policy", + SINGLE: 'Single contract policy', + MULTIPLE: 'Multiple contract policy', ABBREVIATED: { - SINGLE: "Single", - MULTIPLE: "Multiple" - } + SINGLE: 'Single', + MULTIPLE: 'Multiple', + }, }, POLICY: { TOTAL_VALUE_OF_CONTRACT: { MINIMUM: 1, - MAXIMUM: LATEST_VERSION.TOTAL_VALUE_OF_CONTRACT + MAXIMUM: LATEST_VERSION.TOTAL_VALUE_OF_CONTRACT, }, TOTAL_MONTHS_OF_COVER: { MINIMUM: 1, - MAXIMUM: 12 + MAXIMUM: 12, }, - MAXIMUM_BUYER_CAN_OWE: LATEST_VERSION.MAXIMUM_BUYER_CAN_OWE + MAXIMUM_BUYER_CAN_OWE: LATEST_VERSION.MAXIMUM_BUYER_CAN_OWE, }, STATUS: { - IN_PROGRESS: "In progress", - SUBMITTED: "Submitted to UKEF", - ABANDONED: "Abandoned" + IN_PROGRESS: 'In progress', + SUBMITTED: 'Submitted to UKEF', + ABANDONED: 'Abandoned', }, DEFAULT_FINAL_DESTINATION_KNOWN: LATEST_VERSION.DEFAULT_FINAL_DESTINATION_KNOWN, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: LATEST_VERSION.DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER, @@ -719,13 +724,14 @@ var APPLICATION = { EXPORT_CONTRACT: { AGENT_SERVICE_CHARGE: { METHOD: { - FIXED_SUM: "Fixed sum", - PERCENTAGE: "Percentage" - } - } + FIXED_SUM: 'Fixed sum', + PERCENTAGE: 'Percentage', + }, + }, }, - GET_QUERY: "id eligibility { id } buyer { id companyOrOrganisationName } company { id } declaration { id } exportContract { id } nominatedLossPayee { id } policy { id } sectionReview { id } owner { id email firstName lastName } referenceNumber submissionDeadline status ", - VERSIONS: versions_default + GET_QUERY: + 'id eligibility { id } buyer { id companyOrOrganisationName } company { id } declaration { id } exportContract { id } nominatedLossPayee { id } policy { id } sectionReview { id } owner { id email firstName lastName } referenceNumber submissionDeadline status ', + VERSIONS: versions_default, }; var application_default = APPLICATION; @@ -733,44 +739,44 @@ var application_default = APPLICATION; var COVER_PERIOD = { LESS_THAN_2_YEARS: { DB_ID: 1, - VALUE: "1 to 24 months" + VALUE: '1 to 24 months', }, MORE_THAN_2_YEARS: { DB_ID: 2, - VALUE: "More than 2 years" - } + VALUE: 'More than 2 years', + }, }; // constants/cron/index.ts -var CRON_DESCRIPTION_ACCOUNT_UPDATE_UNVERIFIED = "Update unverified accounts (over 24hrs) to isInactive"; +var CRON_DESCRIPTION_ACCOUNT_UPDATE_UNVERIFIED = 'Update unverified accounts (over 24hrs) to isInactive'; var CRON_DESCRIPTION_APPLICATION_UPDATE_INACTIVE = `Update inactive applications (over ${APPLICATION.SUBMISSION_DEADLINE_IN_DAYS}) to Abandoned`; -var CRON_DESCRIPTION_APPLICATION_SUBMISSION_DEADLINE_EMAIL = "Email application submission deadline reminder"; +var CRON_DESCRIPTION_APPLICATION_SUBMISSION_DEADLINE_EMAIL = 'Email application submission deadline reminder'; // constants/date-format.ts var DATE_FORMAT = { - DEFAULT: "d MMMM yyyy", - HOURS_AND_MINUTES: "HH:mm", - SHORT_MONTH: "d MMM yyyy", - XLSX: "dd-MMM-yy" + DEFAULT: 'd MMMM yyyy', + HOURS_AND_MINUTES: 'HH:mm', + SHORT_MONTH: 'd MMM yyyy', + XLSX: 'dd-MMM-yy', }; // constants/declarations/versions/index.ts var DECLARATION_VERSIONS = [ { - ANTI_BRIBERY: "1", - ANTI_BRIBERY_CODE_OF_CONDUCT: "1", - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: "1", - CONFIDENTIALITY: "1", - CONFIRMATION_AND_ACKNOWLEDGEMENTS: "1", - HOW_YOUR_DATA_WILL_BE_USED: "1" + ANTI_BRIBERY: '1', + ANTI_BRIBERY_CODE_OF_CONDUCT: '1', + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', + CONFIDENTIALITY: '1', + CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', + HOW_YOUR_DATA_WILL_BE_USED: '1', }, { - ANTI_BRIBERY: "2", - ANTI_BRIBERY_CODE_OF_CONDUCT: "2", - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: "1", - CONFIDENTIALITY: "1", - CONFIRMATION_AND_ACKNOWLEDGEMENTS: "1" - } + ANTI_BRIBERY: '2', + ANTI_BRIBERY_CODE_OF_CONDUCT: '2', + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', + CONFIDENTIALITY: '1', + CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', + }, ]; var versions_default2 = DECLARATION_VERSIONS; @@ -778,7 +784,7 @@ var versions_default2 = DECLARATION_VERSIONS; var DECLARATIONS2 = { VERSIONS: versions_default2, V1_DECLARATIONS: versions_default2[0], - LATEST_DECLARATIONS: versions_default2[versions_default2.length - 1] + LATEST_DECLARATIONS: versions_default2[versions_default2.length - 1], }; var declarations_default2 = DECLARATIONS2; @@ -786,149 +792,149 @@ var declarations_default2 = DECLARATIONS2; var ELIGIBILITY = { MAX_COVER_AMOUNT_IN_GBP: 5e5, MAX_COVER_PERIOD_MONTHS: 24, - MAX_COVER_PERIOD_YEARS: 2 + MAX_COVER_PERIOD_YEARS: 2, }; // constants/export-contract-award-method/index.ts var EXPORT_CONTRACT_AWARD_METHOD = { OPEN_TENDER: { - DB_ID: "eg9qxlqw4edxa8b5mwbybsrfp", - VALUE: "Open tender" + DB_ID: 'eg9qxlqw4edxa8b5mwbybsrfp', + VALUE: 'Open tender', }, NEGOTIATED_CONTRACT: { - DB_ID: "mzwp337piamg1mei7fqh1o73s", - VALUE: "Negotiated contract" + DB_ID: 'mzwp337piamg1mei7fqh1o73s', + VALUE: 'Negotiated contract', }, DIRECT_AWARD: { - DB_ID: "qnqrle4xwsj5go8pchj31sat4", - VALUE: "Direct award" + DB_ID: 'qnqrle4xwsj5go8pchj31sat4', + VALUE: 'Direct award', }, COMPETITIVE_BIDDING: { - DB_ID: "qw2hp8khykctdic2z58z70ru8", - VALUE: "Competitive bidding" + DB_ID: 'qw2hp8khykctdic2z58z70ru8', + VALUE: 'Competitive bidding', }, OTHER: { - DB_ID: "tn8k8lot1bvirmztmmgq2u8hn", - VALUE: "Other" - } + DB_ID: 'tn8k8lot1bvirmztmmgq2u8hn', + VALUE: 'Other', + }, }; // constants/external-apis.ts var EXTERNAL_API_DEFINITIONS = { CIS: { ESRA_CLASSIFICATION: { - VERY_HIGH: "Very High", - HIGH: "High", - STANDARD: "Standard Risk", - NONE: "None" + VERY_HIGH: 'Very High', + HIGH: 'High', + STANDARD: 'Standard Risk', + NONE: 'None', }, SHORT_TERM_COVER: { - YES: "Yes", - NO: "No", - ILC: "ILC Only", - CILC: "CILC Only", - REFER: "Refer", - UNLISTED: "Unlisted" + YES: 'Yes', + NO: 'No', + ILC: 'ILC Only', + CILC: 'CILC Only', + REFER: 'Refer', + UNLISTED: 'Unlisted', }, NBI_ISSUE_AVAILABLE: { - YES: "Y", - NO: "N" + YES: 'Y', + NO: 'N', }, - NO_COVER: "Off cover", + NO_COVER: 'Off cover', INVALID_COUNTRIES: [ - "CABEI", - "Cor Andino Fom", - "Eastern and Southern African Trade and Development Bank", - "EC Market n/k", - "Non EC Market n/k", - "Non UK", - "Third Country" + 'CABEI', + 'Cor Andino Fom', + 'Eastern and Southern African Trade and Development Bank', + 'EC Market n/k', + 'Non EC Market n/k', + 'Non UK', + 'Third Country', ], - INVALID_CURRENCIES: ["Gold"], + INVALID_CURRENCIES: ['Gold'], COUNTRY_RATINGS: { - A: ["AAA", "AA+", "AA", "AA-", "A+", "A", "A-"], - B: ["BBB+", "BBB", "BBB-", "BB+", "BB", "BB-", "B+", "B", "B-"], - C: ["CCC+", "CCC", "CCC-", "CC", "C"], - D: ["D"], - NOT_APPLICABLE: "N/A" - } + A: ['AAA', 'AA+', 'AA', 'AA-', 'A+', 'A', 'A-'], + B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'], + C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'], + D: ['D'], + NOT_APPLICABLE: 'N/A', + }, }, COMPANIES_HOUSE: { COMPANY_STATUS: { - ACTIVE: "active" - } - } + ACTIVE: 'active', + }, + }, }; var EXTERNAL_API_MAPPINGS = { CIS: { ESRA_CLASSIFICATION: { - VERY_HIGH: "Very High", - HIGH: "High", - STANDARD: "Standard" - } - } + VERY_HIGH: 'Very High', + HIGH: 'High', + STANDARD: 'Standard', + }, + }, }; var EXTERNAL_API_ENDPOINTS = { APIM_MDM: { - CURRENCY: "/currencies", - INDUSTRY_SECTORS: "/sector-industries", - MARKETS: "/markets" - } + CURRENCY: '/currencies', + INDUSTRY_SECTORS: '/sector-industries', + MARKETS: '/markets', + }, }; // constants/field-values/index.ts var { POLICY_TYPE, POLICY: POLICY2 } = application_default; var FIELD_VALUES = { OPTIONAL_COOKIES: { - ACCEPT: "accept", - REJECT: "reject" + ACCEPT: 'accept', + REJECT: 'reject', }, POLICY_TYPE: { SINGLE: POLICY_TYPE.SINGLE, - MULTIPLE: POLICY_TYPE.MULTIPLE + MULTIPLE: POLICY_TYPE.MULTIPLE, }, POLICY_LENGTH: { // default multiple policy length in months - MULTIPLE: 12 + MULTIPLE: 12, }, TOTAL_MONTHS_OF_COVER: Array.from(Array(POLICY2.TOTAL_MONTHS_OF_COVER.MAXIMUM).keys()), - YES: "Yes", - NO: "No" + YES: 'Yes', + NO: 'No', }; // constants/total-contract-value/index.ts var TOTAL_CONTRACT_VALUE = { LESS_THAN_500K: { DB_ID: 1, - VALUE: "Less than 500k" + VALUE: 'Less than 500k', }, MORE_THAN_500K: { DB_ID: 2, - VALUE: "More than 500k" + VALUE: 'More than 500k', }, LESS_THAN_250K: { DB_ID: 3, - VALUE: "Less than 250k" + VALUE: 'Less than 250k', }, MORE_THAN_250K: { DB_ID: 4, - VALUE: "More than 250k" + VALUE: 'More than 250k', }, - AMOUNT_250K: 25e4 + AMOUNT_250K: 25e4, }; // constants/XLSX-CONFIG/index.ts var XLSX_CONFIG = { - KEY: "field", - VALUE: "answer", + KEY: 'field', + VALUE: 'answer', COLUMN_WIDTH: 85, ADDITIONAL_TITLE_COLUMN_HEIGHT: 25, ADDITIONAL_COLUMN_HEIGHT: 50, LARGE_ADDITIONAL_COLUMN_HEIGHT: 50 * 2, FONT_SIZE: { DEFAULT: 11, - TITLE: 14 - } + TITLE: 14, + }, }; // constants/validation.ts @@ -936,19 +942,19 @@ var MAXIMUM_CHARACTERS = { ABOUT_GOODS_OR_SERVICES_DESCRIPTION: 1e3, ACCOUNT_NUMBER: 8, ACCOUNT: { - NAME: 400 + NAME: 400, }, AGENT_NAME: 800, AGENT_SERVICE_DESCRIPTION: 1e3, BIC_SWIFT_CODE: 11, BROKER_NAME: 800, BUSINESS: { - GOODS_OR_SERVICES_DESCRIPTION: 1e3 + GOODS_OR_SERVICES_DESCRIPTION: 1e3, }, BUYER: { COMPANY_OR_ORGANISATION: 200, REGISTRATION_NUMBER: 200, - PREVIOUS_CREDIT_INSURANCE_COVER: 1e3 + PREVIOUS_CREDIT_INSURANCE_COVER: 1e3, }, COMPANY_DIFFERENT_TRADING_NAME: 200, CONNECTION_WITH_BUYER_DESCRIPTION: 1e3, @@ -958,11 +964,11 @@ var MAXIMUM_CHARACTERS = { DIFFERENT_NAME_ON_POLICY: 50, EMAIL: 300, EXPORT_CONTRACT: { - OTHER_AWARD_METHOD: 200 + OTHER_AWARD_METHOD: 200, }, FEEDBACK: { IMPROVEMENT: 1200, - OTHER_COMMENTS: 1200 + OTHER_COMMENTS: 1200, }, FULL_ADDRESS: 500, IBAN: 34, @@ -972,18 +978,18 @@ var MAXIMUM_CHARACTERS = { PERCENTAGE: 100, POLICY_CONTACT_NAME: 400, QUOTE: { - CREDIT_PERIOD: 2 + CREDIT_PERIOD: 2, }, REQUESTED_JOINTLY_INSURED_PARTY: { COMPANY_NAME: 200, - COMPANY_NUMBER: 100 + COMPANY_NUMBER: 100, }, - SORT_CODE: 6 + SORT_CODE: 6, }; // constants/index.ts import_dotenv.default.config(); -var GBP_CURRENCY_CODE = "GBP"; +var GBP_CURRENCY_CODE = 'GBP'; var DATE_24_HOURS_FROM_NOW = () => { const now2 = /* @__PURE__ */ new Date(); const day = now2.getDate(); @@ -1005,43 +1011,43 @@ var DATE_30_MINUTES_FROM_NOW = () => { }; var ACCOUNT2 = { EMAIL: { - VERIFICATION_EXPIRY: DATE_24_HOURS_FROM_NOW + VERIFICATION_EXPIRY: DATE_24_HOURS_FROM_NOW, }, ENCRYPTION: { RANDOM_BYTES_SIZE: 32, - STRING_TYPE: "hex", + STRING_TYPE: 'hex', PBKDF2: { ITERATIONS: 1e4, - DIGEST_ALGORITHM: "sha512" + DIGEST_ALGORITHM: 'sha512', }, PASSWORD: { PBKDF2: { - KEY_LENGTH: 64 - } + KEY_LENGTH: 64, + }, }, OTP: { PBKDF2: { - KEY_LENGTH: 128 - } - } + KEY_LENGTH: 128, + }, + }, }, PASSWORD_RESET_EXPIRY: DATE_30_MINUTES_FROM_NOW, // One time password OTP: { DIGITS: 6, - VERIFICATION_EXPIRY: DATE_30_MINUTES_FROM_NOW + VERIFICATION_EXPIRY: DATE_30_MINUTES_FROM_NOW, }, REACTIVATION_EXPIRY: DATE_24_HOURS_FROM_NOW, // JSON web token JWT: { KEY: { SIGNATURE: String(process.env.JWT_SIGNING_KEY), - ENCODING: "base64", - STRING_ENCODING: "ascii" + ENCODING: 'base64', + STRING_ENCODING: 'ascii', }, TOKEN: { - EXPIRY: "12h", - ALGORITHM: "RS256" + EXPIRY: '12h', + ALGORITHM: 'RS256', }, SESSION_EXPIRY: () => { const now2 = /* @__PURE__ */ new Date(); @@ -1049,7 +1055,7 @@ var ACCOUNT2 = { const seconds = 60 * 60 * 1e3; const future = new Date(now2.getTime() + hours * seconds); return future; - } + }, }, MAX_AUTH_RETRIES: 6, /** @@ -1057,80 +1063,80 @@ var ACCOUNT2 = { * Generate a date that is 24 hours ago from now * To be safe, we use time rather than subtracting a day. */ - MAX_AUTH_RETRIES_TIMEFRAME: DATE_24_HOURS_IN_THE_PAST() + MAX_AUTH_RETRIES_TIMEFRAME: DATE_24_HOURS_IN_THE_PAST(), }; var DEFAULT_ENCRYPTION_SAVE_OBJECT = { - value: "", - iv: "" + value: '', + iv: '', }; var FINANCIAL_DETAILS = { ENCRYPTION: { CIPHER: { - ENCODING: "hex", - STRING_ENCODING: "base64", - ENCRYPTION_METHOD: "aes-256-cbc", - OUTPUT_ENCODING: "utf-8" + ENCODING: 'hex', + STRING_ENCODING: 'base64', + ENCRYPTION_METHOD: 'aes-256-cbc', + OUTPUT_ENCODING: 'utf-8', }, KEY: { - ALGORITHM: "sha512", + ALGORITHM: 'sha512', SIGNATURE: String(process.env.LOSS_PAYEE_ENCRYPTION_KEY), SUBSTRING_INDEX_START: 0, - SUBSTRING_INDEX_END: 32 + SUBSTRING_INDEX_END: 32, }, IV: { BYTES_SIZE: 16, - ENCODING: "base64", + ENCODING: 'base64', SLICE_INDEX_START: 0, - SLICE_INDEX_END: 16 - } - } + SLICE_INDEX_END: 16, + }, + }, }; var EMAIL_TEMPLATE_IDS = { ACCOUNT: { - CONFIRM_EMAIL: "24022e94-171c-4044-b0ee-d22418116575", - ACCESS_CODE: "b92650d1-9187-4510-ace2-5eec7ca7e626", - PASSWORD_RESET: "86d5f582-e1d3-4b55-b103-50141401fd13", - REACTIVATE_ACCOUNT_CONFIRM_EMAIL: "2abf173a-52fc-4ec8-b28c-d7a862b8cf37" + CONFIRM_EMAIL: '24022e94-171c-4044-b0ee-d22418116575', + ACCESS_CODE: 'b92650d1-9187-4510-ace2-5eec7ca7e626', + PASSWORD_RESET: '86d5f582-e1d3-4b55-b103-50141401fd13', + REACTIVATE_ACCOUNT_CONFIRM_EMAIL: '2abf173a-52fc-4ec8-b28c-d7a862b8cf37', }, APPLICATION: { SUBMISSION: { EXPORTER: { - CONFIRMATION: "2e9084e2-d871-4be7-85d0-0ccc1961b148", + CONFIRMATION: '2e9084e2-d871-4be7-85d0-0ccc1961b148', SEND_DOCUMENTS: { - TRADING_HISTORY: "1ae4d77e-58d6-460e-99c0-b62bf08d8c52", - ANTI_BRIBERY: "002e43e3-ca78-4b9c-932f-6833014bb1e4", - ANTI_BRIBERY_AND_TRADING_HISTORY: "49753c34-24b5-4cad-a7c5-1ab32d711dfe" - } + TRADING_HISTORY: '1ae4d77e-58d6-460e-99c0-b62bf08d8c52', + ANTI_BRIBERY: '002e43e3-ca78-4b9c-932f-6833014bb1e4', + ANTI_BRIBERY_AND_TRADING_HISTORY: '49753c34-24b5-4cad-a7c5-1ab32d711dfe', + }, }, UNDERWRITING_TEAM: { - NOTIFICATION_TRADING_HISTORY: "34457439-bf9c-46e3-bd05-b8732ed682fb", - NOTIFICATION_ANTI_BRIBERY: "8be12c98-b2c7-4992-8920-925aa37b6391", - NOTIFICATION_ANTI_BRIBERY_AND_TRADING_HISTORY: "7f0541dd-1dae-4d51-9ebc-87d2a624f8d2", - NO_DOCUMENTS: "65b517c6-ae86-470b-9448-194ae5ac44bb" + NOTIFICATION_TRADING_HISTORY: '34457439-bf9c-46e3-bd05-b8732ed682fb', + NOTIFICATION_ANTI_BRIBERY: '8be12c98-b2c7-4992-8920-925aa37b6391', + NOTIFICATION_ANTI_BRIBERY_AND_TRADING_HISTORY: '7f0541dd-1dae-4d51-9ebc-87d2a624f8d2', + NO_DOCUMENTS: '65b517c6-ae86-470b-9448-194ae5ac44bb', }, - DEADLINE_REMINDER: "e8e5ba73-96da-46f1-b96e-2b1909be6f3d" - } + DEADLINE_REMINDER: 'e8e5ba73-96da-46f1-b96e-2b1909be6f3d', + }, }, FEEDBACK: { - INSURANCE: "4d3d7944-e894-4527-aee6-692038c84107" - } + INSURANCE: '4d3d7944-e894-4527-aee6-692038c84107', + }, }; var FEEDBACK = { - VERY_SATISFIED: "verySatisfied", - SATISFIED: "satisfied", - NEITHER: "neither", - DISSATISFIED: "dissatisfied", - VERY_DISSATISIFED: "veryDissatisfied", + VERY_SATISFIED: 'verySatisfied', + SATISFIED: 'satisfied', + NEITHER: 'neither', + DISSATISFIED: 'dissatisfied', + VERY_DISSATISIFED: 'veryDissatisfied', EMAIL_TEXT: { - verySatisfied: "Very satisfied", - satisfied: "Satisfied", - neither: "Neither satisfied or dissatisfied", - dissatisfied: "Dissatisfied", - veryDissatisfied: "Very dissatisfied" - } + verySatisfied: 'Very satisfied', + satisfied: 'Satisfied', + neither: 'Neither satisfied or dissatisfied', + dissatisfied: 'Dissatisfied', + veryDissatisfied: 'Very dissatisfied', + }, }; -var ACCEPTED_FILE_TYPES = [".xlsx"]; -var ORDNANCE_SURVEY_QUERY_URL = "/search/places/v1/postcode?postcode="; +var ACCEPTED_FILE_TYPES = ['.xlsx']; +var ORDNANCE_SURVEY_QUERY_URL = '/search/places/v1/postcode?postcode='; // cron/account/unverified-account-cron-job.ts import_dotenv2.default.config(); @@ -1138,7 +1144,7 @@ var { CRON_SCHEDULE_UNVERIFIED_ACCOUNT } = process.env; var updateUnverifiedAccountsJob = { cronExpression: String(CRON_SCHEDULE_UNVERIFIED_ACCOUNT), description: CRON_DESCRIPTION_ACCOUNT_UPDATE_UNVERIFIED, - task: update_unverified_accounts_default + task: update_unverified_accounts_default, }; var unverified_account_cron_job_default = updateUnverifiedAccountsJob; @@ -1147,22 +1153,22 @@ var accountCronSchedulerJobs = [unverified_account_cron_job_default]; var account_default2 = accountCronSchedulerJobs; // cron/application/inactive-application-cron-job.ts -var import_dotenv3 = __toESM(require("dotenv")); +var import_dotenv3 = __toESM(require('dotenv')); // helpers/get-inactive-applications/index.ts var { IN_PROGRESS } = APPLICATION.STATUS; var getInactiveApplications = async (context) => { try { - console.info("Getting inactive applications - getInactiveApplications helper"); + console.info('Getting inactive applications - getInactiveApplications helper'); const applications = await context.query.Application.findMany({ where: { - AND: [{ status: { in: [IN_PROGRESS] } }, { submissionDeadline: { lt: /* @__PURE__ */ new Date() } }] + AND: [{ status: { in: [IN_PROGRESS] } }, { submissionDeadline: { lt: /* @__PURE__ */ new Date() } }], }, - query: "id status" + query: 'id status', }); return applications; } catch (error) { - console.error("Error getting inactive applications (getInactiveApplications helper) %o", error); + console.error('Error getting inactive applications (getInactiveApplications helper) %o', error); throw new Error(`Error getting inactive applications (getInactiveApplications helper) ${error}`); } }; @@ -1176,8 +1182,8 @@ var mapInactiveApplications = (applications) => { data: { status: APPLICATION.STATUS.ABANDONED, previousStatus: application2.status, - updatedAt: /* @__PURE__ */ new Date() - } + updatedAt: /* @__PURE__ */ new Date(), + }, }; return mapped; }); @@ -1188,13 +1194,13 @@ var map_inactive_applications_default = mapInactiveApplications; // helpers/map-and-update-inactive-applications/index.ts var mapAndUpdateInactiveApplications = async (applications, context) => { try { - console.info("Mapping and updating inactive applications - mapAndUpdateInactiveApplications"); + console.info('Mapping and updating inactive applications - mapAndUpdateInactiveApplications'); const updateData = map_inactive_applications_default(applications); await context.db.Application.updateMany({ - data: updateData + data: updateData, }); } catch (error) { - console.error("Error mapping and updating inactive applications %o", error); + console.error('Error mapping and updating inactive applications %o', error); throw new Error(`Error mapping and updating inactive applications ${error}`); } }; @@ -1203,16 +1209,16 @@ var map_and_update_inactive_applications_default = mapAndUpdateInactiveApplicati // helpers/update-inactive-applications/index.ts var updateInactiveApplications = async (context) => { try { - console.info("Getting and updating inactive applications"); + console.info('Getting and updating inactive applications'); const applications = await get_inactive_applications_default(context); if (applications.length) { await map_and_update_inactive_applications_default(applications, context); } return { - success: true + success: true, }; } catch (error) { - console.error("Error getting and updating inactive applications %o", error); + console.error('Error getting and updating inactive applications %o', error); throw new Error(`Error getting and updating inactive applications ${error}`); } }; @@ -1224,12 +1230,12 @@ var { CRON_SCHEDULE_INACTIVE_APPLICATION } = process.env; var updateInactiveApplicationsJob = { cronExpression: String(CRON_SCHEDULE_INACTIVE_APPLICATION), description: CRON_DESCRIPTION_APPLICATION_UPDATE_INACTIVE, - task: update_inactive_applications_default + task: update_inactive_applications_default, }; var inactive_application_cron_job_default = updateInactiveApplicationsJob; // cron/application/email-submission-deadline-reminder-cron-job.ts -var import_dotenv8 = __toESM(require("dotenv")); +var import_dotenv8 = __toESM(require('dotenv')); // helpers/get-start-and-end-time-of-date/index.ts var { @@ -1240,20 +1246,20 @@ var { END_TIME_LIMIT_HOURS, END_TIME_LIMIT_MINUTES, END_TIME_LIMIT_MS, - END_TIME_LIMIT_SECONDS + END_TIME_LIMIT_SECONDS, } = APPLICATION.SUBMISSION_DEADLINE_EMAIL; var getStartAndEndTimeOfDate = (date) => { const startSet = date.setHours(START_TIME_LIMIT_HOURS, START_TIME_LIMIT_MINUTES, START_TIME_LIMIT_SECONDS, START_TIME_LIMIT_MS); const endSet = date.setHours(END_TIME_LIMIT_HOURS, END_TIME_LIMIT_MINUTES, END_TIME_LIMIT_SECONDS, END_TIME_LIMIT_MS); return { startTime: new Date(startSet), - endTime: new Date(endSet) + endTime: new Date(endSet), }; }; var get_start_and_end_time_of_date_default = getStartAndEndTimeOfDate; // helpers/date/index.ts -var import_date_fns = require("date-fns"); +var import_date_fns = require('date-fns'); var dateIsInThePast = (targetDate) => { const now2 = /* @__PURE__ */ new Date(); return (0, import_date_fns.isAfter)(now2, targetDate); @@ -1265,31 +1271,31 @@ var { IN_PROGRESS: IN_PROGRESS2 } = APPLICATION.STATUS; var { REMINDER_DAYS } = APPLICATION.SUBMISSION_DEADLINE_EMAIL; var getExpiringApplications = async (context) => { try { - console.info("Getting expiring applications - getExpiringApplications helper"); + console.info('Getting expiring applications - getExpiringApplications helper'); const today = /* @__PURE__ */ new Date(); const reminderDays = dateInTheFutureByDays(today, REMINDER_DAYS); const { startTime, endTime } = get_start_and_end_time_of_date_default(reminderDays); const applications = await context.query.Application.findMany({ where: { - AND: [{ status: { in: [IN_PROGRESS2] } }, { submissionDeadline: { gte: startTime, lte: endTime } }] + AND: [{ status: { in: [IN_PROGRESS2] } }, { submissionDeadline: { gte: startTime, lte: endTime } }], }, - query: APPLICATION.GET_QUERY + query: APPLICATION.GET_QUERY, }); return applications; } catch (error) { - console.error("Error getting expiring applications (getExpiringApplications helper) %o", error); + console.error('Error getting expiring applications (getExpiringApplications helper) %o', error); throw new Error(`Error getting expiring applications (getExpiringApplications helper) ${error}`); } }; var get_expiring_applications_default = getExpiringApplications; // helpers/format-date/index.ts -var import_date_fns2 = require("date-fns"); +var import_date_fns2 = require('date-fns'); var formatDate = (timestamp3, dateFormat = DATE_FORMAT.DEFAULT) => (0, import_date_fns2.format)(new Date(timestamp3), dateFormat); var format_date_default = formatDate; // helpers/generate-application-url/index.ts -var import_dotenv4 = __toESM(require("dotenv")); +var import_dotenv4 = __toESM(require('dotenv')); import_dotenv4.default.config(); var baseUrl = String(process.env.APPLICATION_URL); var generateApplicationUrl = (referenceNumber) => `${baseUrl}/${referenceNumber}${APPLICATION.ALL_SECTIONS_ROUTE}`; @@ -1305,18 +1311,18 @@ var mapApplicationSubmissionDeadlineVariables = (application2) => { name: `${firstName} ${lastName}`, referenceNumber: String(referenceNumber), applicationUrl: generate_application_url_default(referenceNumber), - buyerName: application2.buyer.companyOrOrganisationName ? String(companyOrOrganisationName) : "", - submissionDeadline: format_date_default(new Date(submissionDeadline)) + buyerName: application2.buyer.companyOrOrganisationName ? String(companyOrOrganisationName) : '', + submissionDeadline: format_date_default(new Date(submissionDeadline)), }; }; var map_application_submission_deadline_variables_default = mapApplicationSubmissionDeadlineVariables; // emails/index.ts -var import_dotenv7 = __toESM(require("dotenv")); +var import_dotenv7 = __toESM(require('dotenv')); // integrations/notify/index.ts -var import_dotenv5 = __toESM(require("dotenv")); -var import_notifications_node_client = require("notifications-node-client"); +var import_dotenv5 = __toESM(require('dotenv')); +var import_notifications_node_client = require('notifications-node-client'); import_dotenv5.default.config(); var notifyKey = process.env.GOV_NOTIFY_API_KEY; var notifyClient = new import_notifications_node_client.NotifyClient(notifyKey); @@ -1332,24 +1338,24 @@ var notify = { */ sendEmail: async (templateId, sendToEmailAddress, variables, file) => { try { - console.info("Calling Notify API. templateId: %s", templateId); + console.info('Calling Notify API. templateId: %s', templateId); const personalisation = variables; if (file) { personalisation.linkToFile = await notifyClient.prepareUpload(file, { confirmEmailBeforeDownload: true }); } await notifyClient.sendEmail(templateId, sendToEmailAddress, { personalisation, - reference: null + reference: null, }); return { success: true, - emailRecipient: sendToEmailAddress + emailRecipient: sendToEmailAddress, }; } catch (error) { - console.error("Error calling Notify API. Unable to send email %o", error); + console.error('Error calling Notify API. Unable to send email %o', error); throw new Error(`Calling Notify API. Unable to send email ${error}`); } - } + }, }; var notify_default = notify; @@ -1367,7 +1373,7 @@ var callNotify = async (templateId, emailAddress, variables, file) => { } throw new Error(`Sending email ${emailResponse}`); } catch (error) { - console.error("Error sending email %o", error); + console.error('Error sending email %o', error); throw new Error(`Sending email ${error}`); } }; @@ -1375,13 +1381,13 @@ var callNotify = async (templateId, emailAddress, variables, file) => { // emails/confirm-email-address/index.ts var confirmEmailAddress = async (emailAddress, urlOrigin, name, verificationHash, id) => { try { - console.info("Sending confirm email address email"); + console.info('Sending confirm email address email'); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.CONFIRM_EMAIL; const variables = { urlOrigin, name, confirmToken: verificationHash, id }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error("Error sending confirm email address email %o", error); + console.error('Error sending confirm email address email %o', error); throw new Error(`Sending confirm email address email ${error}`); } }; @@ -1389,13 +1395,13 @@ var confirmEmailAddress = async (emailAddress, urlOrigin, name, verificationHash // emails/access-code-email/index.ts var accessCodeEmail = async (emailAddress, name, securityCode) => { try { - console.info("Sending access code email for account sign in"); + console.info('Sending access code email for account sign in'); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.ACCESS_CODE; const variables = { name, securityCode }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error("Error sending access code email for account sign in %o", error); + console.error('Error sending access code email for account sign in %o', error); throw new Error(`Sending access code email for account sign in ${error}`); } }; @@ -1403,13 +1409,13 @@ var accessCodeEmail = async (emailAddress, name, securityCode) => { // emails/password-reset-link/index.ts var passwordResetLink = async (urlOrigin, emailAddress, name, passwordResetHash) => { try { - console.info("Sending email for account password reset"); + console.info('Sending email for account password reset'); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.PASSWORD_RESET; const variables = { urlOrigin, name, passwordResetToken: passwordResetHash }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error("Error sending email for account password reset %o", error); + console.error('Error sending email for account password reset %o', error); throw new Error(`Sending email for account password reset ${error}`); } }; @@ -1417,20 +1423,20 @@ var passwordResetLink = async (urlOrigin, emailAddress, name, passwordResetHash) // emails/reactivate-account-link/index.ts var reactivateAccountLink = async (urlOrigin, emailAddress, name, reactivationHash) => { try { - console.info("Sending email for account reactivation"); + console.info('Sending email for account reactivation'); const templateId = EMAIL_TEMPLATE_IDS.ACCOUNT.REACTIVATE_ACCOUNT_CONFIRM_EMAIL; const variables = { urlOrigin, name, reactivationToken: reactivationHash }; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error("Error sending email for account reactivation %o", error); + console.error('Error sending email for account reactivation %o', error); throw new Error(`Sending email for account reactivation ${error}`); } }; // file-system/index.ts -var import_fs = require("fs"); -var import_path = __toESM(require("path")); +var import_fs = require('fs'); +var import_path = __toESM(require('path')); var fileExists = (filePath) => { const fileBuffer = Buffer.from(filePath); if (fileBuffer.length) { @@ -1447,27 +1453,27 @@ var isAcceptedFileType = (filePath) => { }; var readFile = async (filePath) => { try { - console.info("Reading file %s", filePath); + console.info('Reading file %s', filePath); const file = await import_fs.promises.readFile(filePath); if (fileExists(file) && isAcceptedFileType(filePath)) { return file; } - throw new Error("Reading file - does not exist or is unaccepted file type"); + throw new Error('Reading file - does not exist or is unaccepted file type'); } catch (error) { - console.error("Error reading file %o", error); + console.error('Error reading file %o', error); throw new Error(`Reading file ${error}`); } }; var unlink = async (filePath) => { try { - console.info("Deleting file %s", filePath); + console.info('Deleting file %s', filePath); const file = await readFile(filePath); if (file) { await import_fs.promises.unlink(filePath); } return false; } catch (error) { - console.error("Error deleting file %o", error); + console.error('Error deleting file %o', error); throw new Error(`Deleting file ${error}`); } }; @@ -1475,7 +1481,7 @@ var fileSystem = { fileExists, isAcceptedFileType, readFile, - unlink + unlink, }; var file_system_default = fileSystem; @@ -1489,13 +1495,13 @@ var application = { */ submittedEmail: async (variables) => { try { - console.info("Sending application submitted email to application owner or provided business contact"); + console.info('Sending application submitted email to application owner or provided business contact'); const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.EXPORTER.CONFIRMATION; const { emailAddress } = variables; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error("Error sending application submitted email to to application owner or provided business contact %o", error); + console.error('Error sending application submitted email to to application owner or provided business contact %o', error); throw new Error(`Sending application submitted email to to application owner or provided business contact ${error}`); } }, @@ -1509,7 +1515,7 @@ var application = { */ underwritingTeam: async (variables, filePath, templateId) => { try { - console.info("Sending application submitted email to underwriting team"); + console.info('Sending application submitted email to underwriting team'); const emailAddress = String(process.env.UNDERWRITING_TEAM_EMAIL); const file = await file_system_default.readFile(filePath); if (file) { @@ -1518,30 +1524,30 @@ var application = { await file_system_default.unlink(filePath); return response; } - throw new Error("Sending application submitted email to underwriting team - invalid file / file not found"); + throw new Error('Sending application submitted email to underwriting team - invalid file / file not found'); } catch (error) { - console.error("Error sending application submitted email to underwriting team %o", error); + console.error('Error sending application submitted email to underwriting team %o', error); throw new Error(`Sending application submitted email to underwriting team ${error}`); } - } + }, }; var application_default2 = application; // emails/documents/index.ts var documentsEmail = async (variables, templateId) => { try { - console.info("Sending documents email"); + console.info('Sending documents email'); const { emailAddress } = variables; const response = await callNotify(templateId, emailAddress, variables); return response; } catch (error) { - console.error("Error sending documents email %o", error); + console.error('Error sending documents email %o', error); throw new Error(`Sending documents email ${error}`); } }; // emails/insurance-feedback-email/index.ts -var import_dotenv6 = __toESM(require("dotenv")); +var import_dotenv6 = __toESM(require('dotenv')); // helpers/map-feedback-satisfaction/index.ts var mapFeedbackSatisfaction = (satisfaction) => FEEDBACK.EMAIL_TEXT[satisfaction]; @@ -1551,15 +1557,15 @@ var map_feedback_satisfaction_default = mapFeedbackSatisfaction; import_dotenv6.default.config(); var insuranceFeedbackEmail = async (variables) => { try { - console.info("Sending insurance feedback email"); + console.info('Sending insurance feedback email'); const templateId = EMAIL_TEMPLATE_IDS.FEEDBACK.INSURANCE; const emailAddress = process.env.FEEDBACK_EMAIL_RECIPIENT; const emailVariables = variables; - emailVariables.time = ""; - emailVariables.date = ""; + emailVariables.time = ''; + emailVariables.date = ''; if (variables.createdAt) { emailVariables.date = format_date_default(variables.createdAt); - emailVariables.time = format_date_default(variables.createdAt, "HH:mm:ss"); + emailVariables.time = format_date_default(variables.createdAt, 'HH:mm:ss'); } if (variables.satisfaction) { emailVariables.satisfaction = map_feedback_satisfaction_default(variables.satisfaction); @@ -1567,7 +1573,7 @@ var insuranceFeedbackEmail = async (variables) => { const response = await callNotify(templateId, emailAddress, emailVariables); return response; } catch (error) { - console.error("Error sending insurance feedback email %o", error); + console.error('Error sending insurance feedback email %o', error); throw new Error(`Sending insurance feedback email ${error}`); } }; @@ -1575,12 +1581,12 @@ var insuranceFeedbackEmail = async (variables) => { // emails/submission-deadline/index.ts var submissionDeadlineEmail = async (emailAddress, submissionDeadlineEmailVariables) => { try { - console.info("Sending submission deadline reminder email for %s", submissionDeadlineEmailVariables.referenceNumber); + console.info('Sending submission deadline reminder email for %s', submissionDeadlineEmailVariables.referenceNumber); const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.DEADLINE_REMINDER; const response = await callNotify(templateId, emailAddress, submissionDeadlineEmailVariables); return response; } catch (error) { - console.error("Error sending submission deadline email for applicationId %s - %o", submissionDeadlineEmailVariables.referenceNumber, error); + console.error('Error sending submission deadline email for applicationId %s - %o', submissionDeadlineEmailVariables.referenceNumber, error); throw new Error(`Sending submission deadline email for ${submissionDeadlineEmailVariables.referenceNumber} - ${error}`); } }; @@ -1595,14 +1601,14 @@ var sendEmail = { application: application_default2, documentsEmail, insuranceFeedbackEmail, - submissionDeadlineEmail + submissionDeadlineEmail, }; var emails_default = sendEmail; // helpers/send-email-application-submission-deadline/send-email/index.ts var send = async (applications) => { try { - console.info("Sending application submission deadline emails - send helper"); + console.info('Sending application submission deadline emails - send helper'); const mapped = applications.map(async (application2) => { const variables = map_application_submission_deadline_variables_default(application2); const response = await emails_default.submissionDeadlineEmail(variables.email, variables); @@ -1611,36 +1617,36 @@ var send = async (applications) => { const promises = await Promise.all(mapped); return promises; } catch (error) { - console.error("Error sending application submission deadline email (send helper) %o", error); + console.error('Error sending application submission deadline email (send helper) %o', error); throw new Error(`Sending application submission deadline email (send helper) ${error}`); } }; var applicationSubmissionDeadineEmail = { - send + send, }; var send_email_default = applicationSubmissionDeadineEmail; // helpers/send-email-application-submission-deadline/index.ts var applicationSubmissionDeadlineEmail = async (context) => { try { - console.info("Sending application submission deadline email"); + console.info('Sending application submission deadline email'); const applications = await get_expiring_applications_default(context); if (applications.length) { const sentEmails = await send_email_default.send(applications); if (sentEmails.length === applications.length) { return { - success: true + success: true, }; } return { - success: false + success: false, }; } return { - success: true + success: true, }; } catch (error) { - console.error("Error sending application submission deadline email (emailApplicationSubmissionDeadlineEmail helper) %o", error); + console.error('Error sending application submission deadline email (emailApplicationSubmissionDeadlineEmail helper) %o', error); throw new Error(`Sending application submission deadline email (emailApplicationSubmissionDeadlineEmail helper) ${error}`); } }; @@ -1652,7 +1658,7 @@ var { CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL } = process.env; var sendEmailApplicationSubmissionDeadlineJob = { cronExpression: String(CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL), description: CRON_DESCRIPTION_APPLICATION_SUBMISSION_DEADLINE_EMAIL, - task: send_email_application_submission_deadline_default + task: send_email_application_submission_deadline_default, }; var email_submission_deadline_reminder_cron_job_default = sendEmailApplicationSubmissionDeadlineJob; @@ -1662,54 +1668,54 @@ var application_default3 = applicationCronSchedulerJobs; // cron/index.ts var cronJobs = (context) => { - console.info("Running cron jobs"); + console.info('Running cron jobs'); cron_job_scheduler_default(account_default2, context); cron_job_scheduler_default(application_default3, context); }; var cron_default = cronJobs; // schema.ts -var import_core2 = require("@keystone-6/core"); -var import_access = require("@keystone-6/core/access"); -var import_fields = require("@keystone-6/core/fields"); -var import_fields_document = require("@keystone-6/fields-document"); +var import_core2 = require('@keystone-6/core'); +var import_access = require('@keystone-6/core/access'); +var import_fields = require('@keystone-6/core/fields'); +var import_fields_document = require('@keystone-6/fields-document'); // helpers/update-application/index.ts var timestamp = async (context, applicationId) => { try { - console.info("Updating application updatedAt timestamp"); + console.info('Updating application updatedAt timestamp'); const now2 = /* @__PURE__ */ new Date(); const application2 = await context.db.Application.updateOne({ where: { - id: applicationId + id: applicationId, }, data: { - updatedAt: now2 - } + updatedAt: now2, + }, }); return application2; } catch (error) { - console.error("Error updating application updatedAt timestamp %o", error); + console.error('Error updating application updatedAt timestamp %o', error); throw new Error(`Updating application updatedAt timestamp ${error}`); } }; var updateApplication = { - timestamp + timestamp, }; var update_application_default = updateApplication; // nullable-checkbox/index.ts -var import_types = require("@keystone-6/core/types"); -var import_core = require("@keystone-6/core"); -var nullableCheckboxConfig = (defaultValue) => ( +var import_types = require('@keystone-6/core/types'); +var import_core = require('@keystone-6/core'); +var nullableCheckboxConfig = (defaultValue) => /** * Database/GraphQL config. * This defines the field as an optional boolean with a default value of null. */ (0, import_types.fieldType)({ - kind: "scalar", - mode: "optional", - scalar: "Boolean" + kind: 'scalar', + mode: 'optional', + scalar: 'Boolean', })({ /** * Input/output config. @@ -1726,31 +1732,30 @@ var nullableCheckboxConfig = (defaultValue) => ( return value; } return null; - } + }, }, update: { arg: import_core.graphql.arg({ type: import_core.graphql.Boolean }), resolve(value) { return value; - } - } + }, + }, }, output: import_core.graphql.field({ type: import_core.graphql.Boolean, resolve({ value }) { return value; - } + }, }), /** * Keystone admin UI/CMS config for this field. * Since we do not use the UI/CMS, this can be empty. */ - views: "./nullable-checkbox/views", + views: './nullable-checkbox/views', getAdminMeta() { return {}; - } - }) -); + }, + }); var nullableCheckbox = (defaultValue) => () => nullableCheckboxConfig(defaultValue); var nullable_checkbox_default = nullableCheckbox; @@ -1761,311 +1766,311 @@ var { EXPORT_CONTRACT: { AGENT_SERVICE_CHARGE }, POLICY: POLICY3, POLICY_TYPE: POLICY_TYPE2, - SUBMISSION_TYPE + SUBMISSION_TYPE, } = APPLICATION; var lists = { ReferenceNumber: { db: { - idField: { kind: "autoincrement" } + idField: { kind: 'autoincrement' }, }, fields: { - application: (0, import_fields.relationship)({ ref: "Application" }) + application: (0, import_fields.relationship)({ ref: 'Application' }), }, - access: import_access.allowAll + access: import_access.allowAll, }, Application: { fields: { createdAt: (0, import_fields.timestamp)(), updatedAt: (0, import_fields.timestamp)(), - eligibility: (0, import_fields.relationship)({ ref: "Eligibility" }), + eligibility: (0, import_fields.relationship)({ ref: 'Eligibility' }), referenceNumber: (0, import_fields.integer)({ - isIndexed: true + isIndexed: true, }), submissionCount: (0, import_fields.integer)({ - validation: { isRequired: true } + validation: { isRequired: true }, }), submissionDate: (0, import_fields.timestamp)(), submissionDeadline: (0, import_fields.timestamp)(), submissionType: (0, import_fields.select)({ - options: [{ label: SUBMISSION_TYPE.MIA, value: SUBMISSION_TYPE.MIA }] + options: [{ label: SUBMISSION_TYPE.MIA, value: SUBMISSION_TYPE.MIA }], }), status: (0, import_fields.text)({ - validation: { isRequired: true } + validation: { isRequired: true }, }), previousStatus: (0, import_fields.text)(), - policy: (0, import_fields.relationship)({ ref: "Policy" }), - exportContract: (0, import_fields.relationship)({ ref: "ExportContract" }), + policy: (0, import_fields.relationship)({ ref: 'Policy' }), + exportContract: (0, import_fields.relationship)({ ref: 'ExportContract' }), owner: (0, import_fields.relationship)({ - ref: "Account", - many: false + ref: 'Account', + many: false, }), - business: (0, import_fields.relationship)({ ref: "Business" }), - broker: (0, import_fields.relationship)({ ref: "Broker" }), - buyer: (0, import_fields.relationship)({ ref: "Buyer" }), - company: (0, import_fields.relationship)({ ref: "Company" }), - declaration: (0, import_fields.relationship)({ ref: "Declaration" }), - nominatedLossPayee: (0, import_fields.relationship)({ ref: "NominatedLossPayee" }), - policyContact: (0, import_fields.relationship)({ ref: "PolicyContact" }), - sectionReview: (0, import_fields.relationship)({ ref: "SectionReview" }), + business: (0, import_fields.relationship)({ ref: 'Business' }), + broker: (0, import_fields.relationship)({ ref: 'Broker' }), + buyer: (0, import_fields.relationship)({ ref: 'Buyer' }), + company: (0, import_fields.relationship)({ ref: 'Company' }), + declaration: (0, import_fields.relationship)({ ref: 'Declaration' }), + nominatedLossPayee: (0, import_fields.relationship)({ ref: 'NominatedLossPayee' }), + policyContact: (0, import_fields.relationship)({ ref: 'PolicyContact' }), + sectionReview: (0, import_fields.relationship)({ ref: 'SectionReview' }), version: (0, import_fields.text)({ - validation: { isRequired: true } + validation: { isRequired: true }, }), dealType: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: "VarChar(4)" } + db: { nativeType: 'VarChar(4)' }, }), - migratedV2toV3: nullable_checkbox_default() + migratedV2toV3: nullable_checkbox_default(), }, - access: import_access.allowAll + access: import_access.allowAll, }, TotalContractValue: (0, import_core2.list)({ fields: { valueId: (0, import_fields.integer)(), value: (0, import_fields.text)({ - db: { nativeType: "VarChar(70)" } - }) + db: { nativeType: 'VarChar(70)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), CoverPeriod: (0, import_core2.list)({ fields: { valueId: (0, import_fields.integer)(), value: (0, import_fields.text)({ - db: { nativeType: "VarChar(70)" } - }) + db: { nativeType: 'VarChar(70)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), LossPayeeFinancialInternational: { fields: { - lossPayee: (0, import_fields.relationship)({ ref: "NominatedLossPayee.financialInternational" }), - vector: (0, import_fields.relationship)({ ref: "LossPayeeFinancialInternationalVector.financialInternational" }), + lossPayee: (0, import_fields.relationship)({ ref: 'NominatedLossPayee.financialInternational' }), + vector: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialInternationalVector.financialInternational' }), bankAddress: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } + db: { nativeType: 'VarChar(500)' }, }), bicSwiftCode: (0, import_fields.text)(), - iban: (0, import_fields.text)() + iban: (0, import_fields.text)(), }, - access: import_access.allowAll + access: import_access.allowAll, }, LossPayeeFinancialInternationalVector: { fields: { - financialInternational: (0, import_fields.relationship)({ ref: "LossPayeeFinancialInternational.vector" }), + financialInternational: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialInternational.vector' }), bicSwiftCodeVector: (0, import_fields.text)(), - ibanVector: (0, import_fields.text)() + ibanVector: (0, import_fields.text)(), }, - access: import_access.allowAll + access: import_access.allowAll, }, LossPayeeFinancialUk: { fields: { - lossPayee: (0, import_fields.relationship)({ ref: "NominatedLossPayee.financialUk" }), - vector: (0, import_fields.relationship)({ ref: "LossPayeeFinancialUkVector.financialUk" }), + lossPayee: (0, import_fields.relationship)({ ref: 'NominatedLossPayee.financialUk' }), + vector: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialUkVector.financialUk' }), accountNumber: (0, import_fields.text)(), bankAddress: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } + db: { nativeType: 'VarChar(500)' }, }), - sortCode: (0, import_fields.text)() + sortCode: (0, import_fields.text)(), }, - access: import_access.allowAll + access: import_access.allowAll, }, LossPayeeFinancialUkVector: { fields: { - financialUk: (0, import_fields.relationship)({ ref: "LossPayeeFinancialUk.vector" }), + financialUk: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialUk.vector' }), accountNumberVector: (0, import_fields.text)(), - sortCodeVector: (0, import_fields.text)() + sortCodeVector: (0, import_fields.text)(), }, - access: import_access.allowAll + access: import_access.allowAll, }, NominatedLossPayee: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - financialUk: (0, import_fields.relationship)({ ref: "LossPayeeFinancialUk.lossPayee" }), - financialInternational: (0, import_fields.relationship)({ ref: "LossPayeeFinancialInternational.lossPayee" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + financialUk: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialUk.lossPayee' }), + financialInternational: (0, import_fields.relationship)({ ref: 'LossPayeeFinancialInternational.lossPayee' }), isAppointed: nullable_checkbox_default(), isLocatedInUk: nullable_checkbox_default(), isLocatedInternationally: nullable_checkbox_default(), name: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } - }) + db: { nativeType: 'VarChar(200)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), Policy: { fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - jointlyInsuredParty: (0, import_fields.relationship)({ ref: "JointlyInsuredParty.policy" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + jointlyInsuredParty: (0, import_fields.relationship)({ ref: 'JointlyInsuredParty.policy' }), needPreCreditPeriodCover: nullable_checkbox_default(DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER), policyType: (0, import_fields.select)({ options: [ { label: POLICY_TYPE2.SINGLE, value: POLICY_TYPE2.SINGLE }, - { label: POLICY_TYPE2.MULTIPLE, value: POLICY_TYPE2.MULTIPLE } - ] + { label: POLICY_TYPE2.MULTIPLE, value: POLICY_TYPE2.MULTIPLE }, + ], }), requestedStartDate: (0, import_fields.timestamp)(), contractCompletionDate: (0, import_fields.timestamp)(), totalValueOfContract: (0, import_fields.integer)({ validation: { min: POLICY3.TOTAL_VALUE_OF_CONTRACT.MINIMUM, - max: POLICY3.TOTAL_VALUE_OF_CONTRACT.MAXIMUM - } + max: POLICY3.TOTAL_VALUE_OF_CONTRACT.MAXIMUM, + }, }), creditPeriodWithBuyer: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } + db: { nativeType: 'VarChar(1000)' }, }), policyCurrencyCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), totalMonthsOfCover: (0, import_fields.integer)(), totalSalesToBuyer: (0, import_fields.integer)(), maximumBuyerWillOwe: (0, import_fields.integer)(), - requestedCreditLimit: (0, import_fields.integer)() + requestedCreditLimit: (0, import_fields.integer)(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }, PolicyContact: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), firstName: (0, import_fields.text)({ - db: { nativeType: "VarChar(400)" } + db: { nativeType: 'VarChar(400)' }, }), lastName: (0, import_fields.text)({ - db: { nativeType: "VarChar(400)" } + db: { nativeType: 'VarChar(400)' }, }), email: (0, import_fields.text)({ - db: { nativeType: "VarChar(300)" } + db: { nativeType: 'VarChar(300)' }, }), position: (0, import_fields.text)({ - db: { nativeType: "VarChar(50)" } + db: { nativeType: 'VarChar(50)' }, }), - isSameAsOwner: nullable_checkbox_default() + isSameAsOwner: nullable_checkbox_default(), }, - access: import_access.allowAll + access: import_access.allowAll, }), JointlyInsuredParty: (0, import_core2.list)({ fields: { - policy: (0, import_fields.relationship)({ ref: "Policy.jointlyInsuredParty" }), + policy: (0, import_fields.relationship)({ ref: 'Policy.jointlyInsuredParty' }), requested: nullable_checkbox_default(), companyName: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), companyNumber: (0, import_fields.text)({ - db: { nativeType: "VarChar(100)" } + db: { nativeType: 'VarChar(100)' }, }), countryCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } - }) + db: { nativeType: 'VarChar(3)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), ExportContract: { fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - agent: (0, import_fields.relationship)({ ref: "ExportContractAgent.exportContract" }), - privateMarket: (0, import_fields.relationship)({ ref: "PrivateMarket.exportContract" }), - awardMethod: (0, import_fields.relationship)({ ref: "ExportContractAwardMethod" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + agent: (0, import_fields.relationship)({ ref: 'ExportContractAgent.exportContract' }), + privateMarket: (0, import_fields.relationship)({ ref: 'PrivateMarket.exportContract' }), + awardMethod: (0, import_fields.relationship)({ ref: 'ExportContractAwardMethod' }), otherAwardMethod: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), finalDestinationKnown: nullable_checkbox_default(), finalDestinationCountryCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), goodsOrServicesDescription: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } + db: { nativeType: 'VarChar(1000)' }, }), paymentTermsDescription: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } - }) + db: { nativeType: 'VarChar(1000)' }, + }), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }, ExportContractAgent: (0, import_core2.list)({ fields: { - exportContract: (0, import_fields.relationship)({ ref: "ExportContract.agent" }), - service: (0, import_fields.relationship)({ ref: "ExportContractAgentService.agent" }), + exportContract: (0, import_fields.relationship)({ ref: 'ExportContract.agent' }), + service: (0, import_fields.relationship)({ ref: 'ExportContractAgentService.agent' }), countryCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), fullAddress: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } + db: { nativeType: 'VarChar(500)' }, }), isUsingAgent: nullable_checkbox_default(), name: (0, import_fields.text)({ - db: { nativeType: "VarChar(800)" } - }) + db: { nativeType: 'VarChar(800)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), ExportContractAgentService: { fields: { - agent: (0, import_fields.relationship)({ ref: "ExportContractAgent.service" }), - charge: (0, import_fields.relationship)({ ref: "ExportContractAgentServiceCharge.service" }), + agent: (0, import_fields.relationship)({ ref: 'ExportContractAgent.service' }), + charge: (0, import_fields.relationship)({ ref: 'ExportContractAgentServiceCharge.service' }), agentIsCharging: nullable_checkbox_default(), serviceDescription: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } - }) + db: { nativeType: 'VarChar(1000)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }, ExportContractAgentServiceCharge: { fields: { - service: (0, import_fields.relationship)({ ref: "ExportContractAgentService.charge" }), + service: (0, import_fields.relationship)({ ref: 'ExportContractAgentService.charge' }), percentageCharge: (0, import_fields.integer)(), fixedSumAmount: (0, import_fields.decimal)({ scale: 2 }), fixedSumCurrencyCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" }, - defaultValue: DEFAULT_CURRENCY + db: { nativeType: 'VarChar(3)' }, + defaultValue: DEFAULT_CURRENCY, }), method: (0, import_fields.select)({ options: [ { label: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM, value: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM }, - { label: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE, value: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE } - ] + { label: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE, value: AGENT_SERVICE_CHARGE.METHOD.PERCENTAGE }, + ], }), payableCountryCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } - }) + db: { nativeType: 'VarChar(3)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }, ExportContractAwardMethod: (0, import_core2.list)({ fields: { value: (0, import_fields.text)({ - db: { nativeType: "VarChar(50)" } - }) + db: { nativeType: 'VarChar(50)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), PrivateMarket: (0, import_core2.list)({ fields: { - exportContract: (0, import_fields.relationship)({ ref: "ExportContract.privateMarket" }), + exportContract: (0, import_fields.relationship)({ ref: 'ExportContract.privateMarket' }), attempted: nullable_checkbox_default(), declinedDescription: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } - }) + db: { nativeType: 'VarChar(1000)' }, + }), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), Account: (0, import_core2.list)({ fields: { @@ -2073,15 +2078,15 @@ var lists = { updatedAt: (0, import_fields.timestamp)(), firstName: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: "VarChar(400)" } + db: { nativeType: 'VarChar(400)' }, }), lastName: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: "VarChar(400)" } + db: { nativeType: 'VarChar(400)' }, }), email: (0, import_fields.text)({ validation: { isRequired: true }, - db: { nativeType: "VarChar(300)" } + db: { nativeType: 'VarChar(300)' }, }), salt: (0, import_fields.text)({ validation: { isRequired: true } }), hash: (0, import_fields.text)({ validation: { isRequired: true } }), @@ -2090,7 +2095,7 @@ var lists = { verificationExpiry: (0, import_fields.timestamp)(), otpSalt: (0, import_fields.text)(), otpHash: (0, import_fields.text)({ - db: { nativeType: "VarChar(256)" } + db: { nativeType: 'VarChar(256)' }, }), otpExpiry: (0, import_fields.timestamp)(), sessionExpiry: (0, import_fields.timestamp)(), @@ -2098,24 +2103,24 @@ var lists = { passwordResetHash: (0, import_fields.text)({ validation: { isRequired: false } }), passwordResetExpiry: (0, import_fields.timestamp)({ validation: { isRequired: false } }), authentication: (0, import_fields.relationship)({ - ref: "Authentication" + ref: 'Authentication', }), authenticationRetry: (0, import_fields.relationship)({ - ref: "AuthenticationRetry" + ref: 'AuthenticationRetry', }), reactivationHash: (0, import_fields.text)({ validation: { isRequired: false } }), reactivationExpiry: (0, import_fields.timestamp)({ validation: { isRequired: false } }), applications: (0, import_fields.relationship)({ - ref: "Application", - many: true + ref: 'Application', + many: true, }), - status: (0, import_fields.relationship)({ ref: "AccountStatus.account" }) + status: (0, import_fields.relationship)({ ref: 'AccountStatus.account' }), }, - access: import_access.allowAll + access: import_access.allowAll, }), AccountStatus: { fields: { - account: (0, import_fields.relationship)({ ref: "Account.status" }), + account: (0, import_fields.relationship)({ ref: 'Account.status' }), isVerified: (0, import_fields.checkbox)({ defaultValue: false }), /** * isBlocked flag will only be true if the account has: @@ -2124,37 +2129,37 @@ var lists = { */ isBlocked: (0, import_fields.checkbox)({ defaultValue: false }), isInactive: (0, import_fields.checkbox)({ defaultValue: false }), - updatedAt: (0, import_fields.timestamp)() + updatedAt: (0, import_fields.timestamp)(), }, - access: import_access.allowAll + access: import_access.allowAll, }, AuthenticationRetry: (0, import_core2.list)({ fields: { account: (0, import_fields.relationship)({ - ref: "Account", - many: true + ref: 'Account', + many: true, }), - createdAt: (0, import_fields.timestamp)({ validation: { isRequired: true } }) + createdAt: (0, import_fields.timestamp)({ validation: { isRequired: true } }), }, - access: import_access.allowAll + access: import_access.allowAll, }), Authentication: (0, import_core2.list)({ fields: { account: (0, import_fields.relationship)({ - ref: "Account", - many: true + ref: 'Account', + many: true, }), createdAt: (0, import_fields.timestamp)(), salt: (0, import_fields.text)({ validation: { isRequired: true } }), - hash: (0, import_fields.text)({ validation: { isRequired: true } }) + hash: (0, import_fields.text)({ validation: { isRequired: true } }), }, - access: import_access.allowAll + access: import_access.allowAll, }), Business: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), goodsOrServicesSupplied: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } + db: { nativeType: 'VarChar(1000)' }, }), totalYearsExporting: (0, import_fields.integer)(), totalEmployeesUK: (0, import_fields.integer)(), @@ -2162,26 +2167,26 @@ var lists = { estimatedAnnualTurnover: (0, import_fields.integer)(), exportsTurnoverPercentage: (0, import_fields.integer)(), turnoverCurrencyCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" }, - defaultValue: DEFAULT_CURRENCY + db: { nativeType: 'VarChar(3)' }, + defaultValue: DEFAULT_CURRENCY, }), - hasCreditControlProcess: nullable_checkbox_default() + hasCreditControlProcess: nullable_checkbox_default(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), Broker: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), isUsingBroker: nullable_checkbox_default(), name: (0, import_fields.text)({ - db: { nativeType: "VarChar(800)" } + db: { nativeType: 'VarChar(800)' }, }), addressLine1: (0, import_fields.text)(), addressLine2: (0, import_fields.text)(), @@ -2189,24 +2194,24 @@ var lists = { county: (0, import_fields.text)(), postcode: (0, import_fields.text)(), fullAddress: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } + db: { nativeType: 'VarChar(500)' }, }), email: (0, import_fields.text)({ - db: { nativeType: "VarChar(300)" } - }) + db: { nativeType: 'VarChar(300)' }, + }), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), CompanyAddress: (0, import_core2.list)({ fields: { - company: (0, import_fields.relationship)({ ref: "Company.registeredOfficeAddress" }), + company: (0, import_fields.relationship)({ ref: 'Company.registeredOfficeAddress' }), addressLine1: (0, import_fields.text)(), addressLine2: (0, import_fields.text)(), careOf: (0, import_fields.text)(), @@ -2214,282 +2219,282 @@ var lists = { region: (0, import_fields.text)(), postalCode: (0, import_fields.text)(), country: (0, import_fields.text)(), - premises: (0, import_fields.text)() + premises: (0, import_fields.text)(), }, - access: import_access.allowAll + access: import_access.allowAll, }), Company: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - registeredOfficeAddress: (0, import_fields.relationship)({ ref: "CompanyAddress.company" }), - differentTradingAddress: (0, import_fields.relationship)({ ref: "CompanyDifferentTradingAddress.company" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + registeredOfficeAddress: (0, import_fields.relationship)({ ref: 'CompanyAddress.company' }), + differentTradingAddress: (0, import_fields.relationship)({ ref: 'CompanyDifferentTradingAddress.company' }), sicCodes: (0, import_fields.relationship)({ - ref: "CompanySicCode.company", - many: true + ref: 'CompanySicCode.company', + many: true, }), companyName: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), companyNumber: (0, import_fields.text)(), dateOfCreation: (0, import_fields.timestamp)(), hasDifferentTradingAddress: nullable_checkbox_default(), differentTradingName: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), hasDifferentTradingName: nullable_checkbox_default(), companyWebsite: (0, import_fields.text)(), phoneNumber: (0, import_fields.text)(), - financialYearEndDate: (0, import_fields.timestamp)() + financialYearEndDate: (0, import_fields.timestamp)(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), CompanyDifferentTradingAddress: (0, import_core2.list)({ fields: { - company: (0, import_fields.relationship)({ ref: "Company.differentTradingAddress" }), + company: (0, import_fields.relationship)({ ref: 'Company.differentTradingAddress' }), fullAddress: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } - }) + db: { nativeType: 'VarChar(500)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), CompanySicCode: (0, import_core2.list)({ fields: { - company: (0, import_fields.relationship)({ ref: "Company.sicCodes" }), + company: (0, import_fields.relationship)({ ref: 'Company.sicCodes' }), sicCode: (0, import_fields.text)(), - industrySectorName: (0, import_fields.text)() + industrySectorName: (0, import_fields.text)(), }, - access: import_access.allowAll + access: import_access.allowAll, }), Buyer: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), companyOrOrganisationName: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), address: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } + db: { nativeType: 'VarChar(500)' }, }), - country: (0, import_fields.relationship)({ ref: "Country" }), + country: (0, import_fields.relationship)({ ref: 'Country' }), registrationNumber: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), website: (0, import_fields.text)(), - buyerTradingHistory: (0, import_fields.relationship)({ ref: "BuyerTradingHistory.buyer" }), - contact: (0, import_fields.relationship)({ ref: "BuyerContact.buyer" }), - relationship: (0, import_fields.relationship)({ ref: "BuyerRelationship.buyer" }) + buyerTradingHistory: (0, import_fields.relationship)({ ref: 'BuyerTradingHistory.buyer' }), + contact: (0, import_fields.relationship)({ ref: 'BuyerContact.buyer' }), + relationship: (0, import_fields.relationship)({ ref: 'BuyerRelationship.buyer' }), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), BuyerContact: { fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - buyer: (0, import_fields.relationship)({ ref: "Buyer.contact" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + buyer: (0, import_fields.relationship)({ ref: 'Buyer.contact' }), contactFirstName: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), contactLastName: (0, import_fields.text)({ - db: { nativeType: "VarChar(200)" } + db: { nativeType: 'VarChar(200)' }, }), contactPosition: (0, import_fields.text)(), contactEmail: (0, import_fields.text)({ - db: { nativeType: "VarChar(300)" } + db: { nativeType: 'VarChar(300)' }, }), - canContactBuyer: nullable_checkbox_default() + canContactBuyer: nullable_checkbox_default(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }, BuyerRelationship: { fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - buyer: (0, import_fields.relationship)({ ref: "Buyer.relationship" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + buyer: (0, import_fields.relationship)({ ref: 'Buyer.relationship' }), exporterIsConnectedWithBuyer: nullable_checkbox_default(), connectionWithBuyerDescription: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } + db: { nativeType: 'VarChar(1000)' }, }), exporterHasPreviousCreditInsuranceWithBuyer: nullable_checkbox_default(), exporterHasBuyerFinancialAccounts: nullable_checkbox_default(), previousCreditInsuranceWithBuyerDescription: (0, import_fields.text)({ - db: { nativeType: "VarChar(1000)" } - }) + db: { nativeType: 'VarChar(1000)' }, + }), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }, BuyerTradingHistory: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - buyer: (0, import_fields.relationship)({ ref: "Buyer.buyerTradingHistory" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + buyer: (0, import_fields.relationship)({ ref: 'Buyer.buyerTradingHistory' }), currencyCode: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), outstandingPayments: nullable_checkbox_default(), failedPayments: nullable_checkbox_default(), exporterHasTradedWithBuyer: nullable_checkbox_default(), totalOutstandingPayments: (0, import_fields.integer)(), - totalOverduePayments: (0, import_fields.integer)() + totalOverduePayments: (0, import_fields.integer)(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), Country: (0, import_core2.list)({ fields: { isoCode: (0, import_fields.text)({ - validation: { isRequired: true } + validation: { isRequired: true }, }), name: (0, import_fields.text)({ - validation: { isRequired: true } - }) + validation: { isRequired: true }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), Eligibility: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - buyerCountry: (0, import_fields.relationship)({ ref: "Country" }), - coverPeriod: (0, import_fields.relationship)({ ref: "CoverPeriod" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + buyerCountry: (0, import_fields.relationship)({ ref: 'Country' }), + coverPeriod: (0, import_fields.relationship)({ ref: 'CoverPeriod' }), hasEndBuyer: (0, import_fields.checkbox)(), hasMinimumUkGoodsOrServices: (0, import_fields.checkbox)(), hasCompaniesHouseNumber: (0, import_fields.checkbox)(), otherPartiesInvolved: (0, import_fields.checkbox)(), paidByLetterOfCredit: (0, import_fields.checkbox)(), - totalContractValue: (0, import_fields.relationship)({ ref: "TotalContractValue" }), + totalContractValue: (0, import_fields.relationship)({ ref: 'TotalContractValue' }), validExporterLocation: (0, import_fields.checkbox)(), isPartyToConsortium: (0, import_fields.checkbox)(), - isMemberOfAGroup: (0, import_fields.checkbox)() + isMemberOfAGroup: (0, import_fields.checkbox)(), }, - access: import_access.allowAll + access: import_access.allowAll, }), SectionReview: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), eligibility: nullable_checkbox_default(), business: nullable_checkbox_default(), buyer: nullable_checkbox_default(), exportContract: nullable_checkbox_default(), - policy: nullable_checkbox_default() + policy: nullable_checkbox_default(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), Declaration: (0, import_core2.list)({ fields: { - application: (0, import_fields.relationship)({ ref: "Application" }), - version: (0, import_fields.relationship)({ ref: "DeclarationVersion" }), + application: (0, import_fields.relationship)({ ref: 'Application' }), + version: (0, import_fields.relationship)({ ref: 'DeclarationVersion' }), agreeHowDataWillBeUsed: nullable_checkbox_default(), agreeToAntiBribery: nullable_checkbox_default(), agreeToConfidentiality: nullable_checkbox_default(), agreeToConfirmationAndAcknowledgements: nullable_checkbox_default(), hasAntiBriberyCodeOfConduct: nullable_checkbox_default(), - willExportWithAntiBriberyCodeOfConduct: nullable_checkbox_default() + willExportWithAntiBriberyCodeOfConduct: nullable_checkbox_default(), }, hooks: { afterOperation: async ({ item, context }) => { if (item?.applicationId) { await update_application_default.timestamp(context, item.applicationId); } - } + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), DeclarationVersion: (0, import_core2.list)({ fields: { - declaration: (0, import_fields.relationship)({ ref: "Declaration" }), + declaration: (0, import_fields.relationship)({ ref: 'Declaration' }), agreeToConfidentiality: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), agreeToAntiBribery: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), hasAntiBriberyCodeOfConduct: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), willExportWithAntiBriberyCodeOfConduct: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), agreeToConfirmationAndAcknowledgements: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } + db: { nativeType: 'VarChar(3)' }, }), agreeHowDataWillBeUsed: (0, import_fields.text)({ - db: { nativeType: "VarChar(3)" } - }) + db: { nativeType: 'VarChar(3)' }, + }), }, - access: import_access.allowAll + access: import_access.allowAll, }), Page: (0, import_core2.list)({ fields: { heading: (0, import_fields.text)({ - label: "Page heading" + label: 'Page heading', }), metaTitle: (0, import_fields.text)({ - label: "Meta title" + label: 'Meta title', }), content: (0, import_fields_document.document)({ formatting: true, dividers: true, - links: true - }) + links: true, + }), }, ui: { listView: { - initialColumns: ["heading", "id"] - } + initialColumns: ['heading', 'id'], + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), User: (0, import_core2.list)({ fields: { name: (0, import_fields.text)({ validation: { isRequired: true } }), email: (0, import_fields.text)({ validation: { isRequired: true }, - isIndexed: "unique" + isIndexed: 'unique', }), - password: (0, import_fields.password)({ validation: { isRequired: true } }) + password: (0, import_fields.password)({ validation: { isRequired: true } }), }, ui: { listView: { - initialColumns: ["name", "email"] - } + initialColumns: ['name', 'email'], + }, }, - access: import_access.allowAll + access: import_access.allowAll, }), Feedback: (0, import_core2.list)({ fields: { @@ -2501,54 +2506,54 @@ var lists = { { label: FEEDBACK.NEITHER, value: FEEDBACK.NEITHER }, { label: FEEDBACK.DISSATISFIED, value: FEEDBACK.DISSATISFIED }, { label: FEEDBACK.VERY_DISSATISIFED, value: FEEDBACK.VERY_DISSATISIFED }, - { label: "", value: "" } + { label: '', value: '' }, ], - db: { isNullable: true } + db: { isNullable: true }, }), improvement: (0, import_fields.text)({ - db: { nativeType: "VarChar(1200)" } + db: { nativeType: 'VarChar(1200)' }, }), otherComments: (0, import_fields.text)({ - db: { nativeType: "VarChar(1200)" } + db: { nativeType: 'VarChar(1200)' }, }), referralUrl: (0, import_fields.text)({ - db: { nativeType: "VarChar(500)" } + db: { nativeType: 'VarChar(500)' }, }), product: (0, import_fields.text)(), - createdAt: (0, import_fields.timestamp)() + createdAt: (0, import_fields.timestamp)(), }, - access: import_access.allowAll - }) + access: import_access.allowAll, + }), }; // auth.ts -var import_config3 = require("dotenv/config"); -var import_auth = require("@keystone-6/auth"); -var import_session = require("@keystone-6/core/session"); +var import_config3 = require('dotenv/config'); +var import_auth = require('@keystone-6/auth'); +var import_session = require('@keystone-6/core/session'); var sessionSecret = String(process.env.SESSION_SECRET); if (!sessionSecret) { - if (process.env.NODE_ENV === "production") { - throw new Error("SESSION_SECRET environment variable must be set in production"); + if (process.env.NODE_ENV === 'production') { + throw new Error('SESSION_SECRET environment variable must be set in production'); } } var { withAuth } = (0, import_auth.createAuth)({ - listKey: "User", - identityField: "email", - sessionData: "name", - secretField: "password", + listKey: 'User', + identityField: 'email', + sessionData: 'name', + secretField: 'password', initFirstItem: { /** * Ensure that if there are no items in the database, * keystone admin UI will ask you to create * a new user, with the following fields. */ - fields: ["name", "email", "password"] - } + fields: ['name', 'email', 'password'], + }, }); var sessionMaxAge = 60 * 60 * 24 * 30; var session = (0, import_session.statelessSessions)({ maxAge: sessionMaxAge, - secret: sessionSecret + secret: sessionSecret, }); // apollo/plugins/index.ts @@ -2564,21 +2569,21 @@ var requestDidStart = () => ({ * via an explicit list of allowed resolvers. */ didResolveOperation({ request }) { - if (!request.operationName || request.operationName && !ALLOWED_GRAPHQL_RESOLVERS.includes(request.operationName)) { - throw new Error("Operation not permitted"); + if (!request.operationName || (request.operationName && !ALLOWED_GRAPHQL_RESOLVERS.includes(request.operationName))) { + throw new Error('Operation not permitted'); } - } + }, }); var apolloPlugins = [{ requestDidStart }]; var plugins_default = apolloPlugins; // apollo/format-graphql-error/index.ts -var import_config4 = require("dotenv/config"); -var import_apollo_server_express = require("apollo-server-express"); +var import_config4 = require('dotenv/config'); +var import_apollo_server_express = require('apollo-server-express'); var formatGraphQlError = (error) => { - const isDevEnvironment3 = process.env.NODE_ENV === "development"; + const isDevEnvironment3 = process.env.NODE_ENV === 'development'; if (!isDevEnvironment3) { - return new import_apollo_server_express.ValidationError("Invalid request"); + return new import_apollo_server_express.ValidationError('Invalid request'); } return error; }; @@ -2589,7 +2594,7 @@ var apolloPlugins2 = plugins_default; var formatGraphQlError2 = format_graphql_error_default; // custom-schema/index.ts -var import_schema = require("@graphql-tools/schema"); +var import_schema = require('@graphql-tools/schema'); // custom-schema/type-defs.ts var typeDefs = ` @@ -3082,19 +3087,19 @@ var typeDefs = ` var type_defs_default = typeDefs; // custom-resolvers/mutations/create-an-account/index.ts -var import_config5 = require("dotenv/config"); +var import_config5 = require('dotenv/config'); // helpers/get-account-status-by-id/index.ts var getAccountStatusById = async (context, id) => { try { - console.info("Getting account status by ID %s", id); + console.info('Getting account status by ID %s', id); const accountStatus2 = await context.query.AccountStatus.findOne({ where: { id }, - query: "id isVerified isBlocked isInactive" + query: 'id isVerified isBlocked isInactive', }); return accountStatus2; } catch (error) { - console.error("Error getting account status by ID %o", error); + console.error('Error getting account status by ID %o', error); throw new Error(`Getting account status by ID ${error}`); } }; @@ -3103,40 +3108,40 @@ var get_account_status_by_id_default = getAccountStatusById; // helpers/get-account-by-field/index.ts var getAccountByField = async (context, field, value) => { try { - console.info("Getting account by field/value $s", `${field}, ${value}`); + console.info('Getting account by field/value $s', `${field}, ${value}`); const accountsArray = await context.db.Account.findMany({ where: { - [field]: { equals: value } + [field]: { equals: value }, }, - take: 1 + take: 1, }); if (!accountsArray?.length || !accountsArray[0]) { - console.info("Getting account by field - no account exists with the provided field/value"); + console.info('Getting account by field - no account exists with the provided field/value'); return false; } const account2 = accountsArray[0]; const accountStatus2 = await get_account_status_by_id_default(context, account2.statusId); const populatedAccount = { ...account2, - status: accountStatus2 + status: accountStatus2, }; return populatedAccount; } catch (error) { - console.error("Error getting account by field/value %o", error); + console.error('Error getting account by field/value %o', error); throw new Error(`Getting account by field/value ${error}`); } }; var get_account_by_field_default = getAccountByField; // helpers/get-password-hash/index.ts -var import_crypto = __toESM(require("crypto")); +var import_crypto = __toESM(require('crypto')); var { ENCRYPTION } = ACCOUNT2; var { STRING_TYPE, PBKDF2: { ITERATIONS, DIGEST_ALGORITHM }, PASSWORD: { - PBKDF2: { KEY_LENGTH } - } + PBKDF2: { KEY_LENGTH }, + }, } = ENCRYPTION; var getPasswordHash = (password2, salt) => { const hash = import_crypto.default.pbkdf2Sync(password2, salt, ITERATIONS, KEY_LENGTH, DIGEST_ALGORITHM).toString(STRING_TYPE); @@ -3146,54 +3151,54 @@ var get_password_hash_default = getPasswordHash; // helpers/is-valid-account-password/index.ts var isValidAccountPassword = (password2, salt, hash) => { - console.info("Validating account password"); + console.info('Validating account password'); const hashVerify = get_password_hash_default(password2, salt); if (hash === hashVerify) { - console.info("Valid account password"); + console.info('Valid account password'); return true; } - console.info("Invalid account password"); + console.info('Invalid account password'); return false; }; var is_valid_account_password_default = isValidAccountPassword; // helpers/encrypt-password/index.ts -var import_crypto2 = __toESM(require("crypto")); +var import_crypto2 = __toESM(require('crypto')); var { ENCRYPTION: ENCRYPTION2 } = ACCOUNT2; var { RANDOM_BYTES_SIZE, STRING_TYPE: STRING_TYPE2, PBKDF2: { ITERATIONS: ITERATIONS2, DIGEST_ALGORITHM: DIGEST_ALGORITHM2 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH2 } - } + PBKDF2: { KEY_LENGTH: KEY_LENGTH2 }, + }, } = ENCRYPTION2; var encryptPassword = (password2) => { const salt = import_crypto2.default.randomBytes(RANDOM_BYTES_SIZE).toString(STRING_TYPE2); const hash = import_crypto2.default.pbkdf2Sync(password2, salt, ITERATIONS2, KEY_LENGTH2, DIGEST_ALGORITHM2).toString(STRING_TYPE2); return { salt, - hash + hash, }; }; var encrypt_password_default = encryptPassword; // helpers/get-account-verification-hash/index.ts -var import_crypto3 = __toESM(require("crypto")); +var import_crypto3 = __toESM(require('crypto')); var { EMAIL, ENCRYPTION: ENCRYPTION3 } = ACCOUNT2; var { STRING_TYPE: STRING_TYPE3, PBKDF2: { ITERATIONS: ITERATIONS3, DIGEST_ALGORITHM: DIGEST_ALGORITHM3 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH3 } - } + PBKDF2: { KEY_LENGTH: KEY_LENGTH3 }, + }, } = ENCRYPTION3; var generateAccountVerificationHash = (email, salt) => { const verificationHash = import_crypto3.default.pbkdf2Sync(email, salt, ITERATIONS3, KEY_LENGTH3, DIGEST_ALGORITHM3).toString(STRING_TYPE3); const verificationExpiry = EMAIL.VERIFICATION_EXPIRY(); return { verificationHash, - verificationExpiry + verificationExpiry, }; }; var get_account_verification_hash_default = generateAccountVerificationHash; @@ -3209,15 +3214,15 @@ var get_full_name_string_default = getFullNameString; // helpers/get-account-by-id/index.ts var getAccountById = async (context, accountId) => { try { - console.info("Getting account by ID"); + console.info('Getting account by ID'); const account2 = await context.db.Account.findOne({ where: { - id: accountId - } + id: accountId, + }, }); return account2; } catch (error) { - console.error("Error getting account by ID %o", error); + console.error('Error getting account by ID %o', error); throw new Error(`Getting account by ID ${error}`); } }; @@ -3226,55 +3231,55 @@ var get_account_by_id_default = getAccountById; // helpers/update-account/index.ts var account = async (context, accountId, updateData) => { try { - console.info("Updating account"); + console.info('Updating account'); const updatedAccount = await context.db.Account.updateOne({ where: { - id: accountId + id: accountId, }, - data: updateData + data: updateData, }); return updatedAccount; } catch (error) { - console.error("Error updating account %o", error); + console.error('Error updating account %o', error); throw new Error(`Updating account ${error}`); } }; var accountStatus = async (context, accountStatusId, updateData) => { try { - console.info("Updating account"); + console.info('Updating account'); const updatedAccountStatus = await context.db.AccountStatus.updateOne({ where: { - id: accountStatusId + id: accountStatusId, }, data: { ...updateData, - updatedAt: /* @__PURE__ */ new Date() - } + updatedAt: /* @__PURE__ */ new Date(), + }, }); return updatedAccountStatus; } catch (error) { - console.error("Error updating account status %o", error); + console.error('Error updating account status %o', error); throw new Error(`Updating account status ${error}`); } }; var update = { account, - accountStatus + accountStatus, }; var update_account_default = update; // helpers/send-email-confirm-email-address/index.ts var send2 = async (context, urlOrigin, accountId) => { try { - console.info("Sending email verification %s %s", urlOrigin, accountId); + console.info('Sending email verification %s %s', urlOrigin, accountId); const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info("Sending email verification - no account exists with the provided account ID"); + console.info('Sending email verification - no account exists with the provided account ID'); return { - success: false + success: false, }; } - let latestVerificationHash = ""; + let latestVerificationHash = ''; let verificationHasExpired = false; if (account2.verificationExpiry) { verificationHasExpired = dateIsInThePast(account2.verificationExpiry); @@ -3296,85 +3301,85 @@ var send2 = async (context, urlOrigin, accountId) => { } throw new Error(`Sending email verification (sendEmailConfirmEmailAddress helper) ${emailResponse}`); } catch (error) { - console.error("Error sending email verification (sendEmailConfirmEmailAddress helper) %o", error); + console.error('Error sending email verification (sendEmailConfirmEmailAddress helper) %o', error); throw new Error(`Sending email verification (sendEmailConfirmEmailAddress helper) ${error}`); } }; var confirmEmailAddressEmail = { - send: send2 + send: send2, }; var send_email_confirm_email_address_default = confirmEmailAddressEmail; // helpers/send-email-reactivate-account-link/index.ts -var import_crypto4 = __toESM(require("crypto")); +var import_crypto4 = __toESM(require('crypto')); var { ENCRYPTION: { STRING_TYPE: STRING_TYPE4, PBKDF2: { ITERATIONS: ITERATIONS4, DIGEST_ALGORITHM: DIGEST_ALGORITHM4 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH4 } - } - } + PBKDF2: { KEY_LENGTH: KEY_LENGTH4 }, + }, + }, } = ACCOUNT2; var send3 = async (variables, context) => { try { - console.info("Received a request to send reactivate account email/link - checking account - sendEmailReactivateAccountLinkHelper"); + console.info('Received a request to send reactivate account email/link - checking account - sendEmailReactivateAccountLinkHelper'); const { urlOrigin, accountId } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info("Unable to check account and send reactivate account email/link - no account found"); + console.info('Unable to check account and send reactivate account email/link - no account found'); return { success: false }; } const { email } = account2; - console.info("Generating hash for account reactivation"); + console.info('Generating hash for account reactivation'); const reactivationHash = import_crypto4.default.pbkdf2Sync(email, account2.salt, ITERATIONS4, KEY_LENGTH4, DIGEST_ALGORITHM4).toString(STRING_TYPE4); const accountUpdate = { reactivationHash, - reactivationExpiry: ACCOUNT2.REACTIVATION_EXPIRY() + reactivationExpiry: ACCOUNT2.REACTIVATION_EXPIRY(), }; - console.info("Updating account for reactivation"); + console.info('Updating account for reactivation'); await update_account_default.account(context, accountId, accountUpdate); - console.info("Sending reactivate account email/link"); + console.info('Sending reactivate account email/link'); const name = get_full_name_string_default(account2); const emailResponse = await emails_default.reactivateAccountLink(urlOrigin, email, name, reactivationHash); if (emailResponse.success) { return { ...emailResponse, email, - accountId + accountId, }; } return { accountId, email, success: false }; } catch (error) { - console.error("Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink helper) %o", error); + console.error('Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink helper) %o', error); throw new Error(`Checking account and sending reactivate account email/link (sendEmailReactivateAccountLink helper) ${error}`); } }; var sendEmailReactivateAccountLinkHelper = { - send: send3 + send: send3, }; var send_email_reactivate_account_link_default = sendEmailReactivateAccountLinkHelper; // custom-resolvers/mutations/create-an-account/index.ts var createAnAccount = async (root, variables, context) => { - console.info("Account creation - %s", variables.email); + console.info('Account creation - %s', variables.email); const { NODE_ENV: NODE_ENV3 } = process.env; - const isDevEnvironment3 = NODE_ENV3 === "development"; + const isDevEnvironment3 = NODE_ENV3 === 'development'; try { const { urlOrigin, firstName, lastName, email, password: password2 } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (account2) { - console.info("Account creation - account already exists %s", email); + console.info('Account creation - account already exists %s', email); if (is_valid_account_password_default(password2, account2.salt, account2.hash)) { - console.info("Account creation - account already exists - valid credentials provided %s", email); + console.info('Account creation - account already exists - valid credentials provided %s', email); if (account2.status.isBlocked) { - console.info("Account creation - unable to create a new account - account already exists and is blocked %s", email); + console.info('Account creation - unable to create a new account - account already exists and is blocked %s', email); const { id: accountId2 } = account2; const reactivateAccountVariables = { accountId: accountId2, - urlOrigin + urlOrigin, }; - console.info("Account creation - resending an email for reactivation %s", email); + console.info('Account creation - resending an email for reactivation %s', email); const emailResponse2 = await send_email_reactivate_account_link_default.send(reactivateAccountVariables, context); if (emailResponse2.success) { return { @@ -3382,43 +3387,43 @@ var createAnAccount = async (root, variables, context) => { success: true, alreadyExists: true, isVerified: false, - isBlocked: true + isBlocked: true, }; } return { success: false, - alreadyExists: true + alreadyExists: true, }; } if (!account2.status.isVerified) { - console.info("Account creation - unable to create a new account - account already exists and is not verified %s", email); + console.info('Account creation - unable to create a new account - account already exists and is not verified %s', email); const { id: accountId2 } = account2; - console.info("Account creation - resending an email verification for %s", email); + console.info('Account creation - resending an email verification for %s', email); const emailResponse2 = await send_email_confirm_email_address_default.send(context, urlOrigin, accountId2); if (emailResponse2.success) { return { id: accountId2, success: true, alreadyExists: true, - isVerified: false + isVerified: false, }; } } - console.info("Account creation - unable to create a new account - account already exists and is verified %s", email); + console.info('Account creation - unable to create a new account - account already exists and is verified %s', email); return { success: false, alreadyExists: true, - isVerified: true + isVerified: true, }; } - console.info("Account creation - account already exists - invalid credentials provided %s", email); + console.info('Account creation - account already exists - invalid credentials provided %s', email); return { success: false }; } - console.info("Account creation - no existing account found. Generating an encrypted password %s", email); + console.info('Account creation - no existing account found. Generating an encrypted password %s', email); const { salt, hash } = encrypt_password_default(password2); const now2 = /* @__PURE__ */ new Date(); const { verificationHash, verificationExpiry } = get_account_verification_hash_default(email, salt); - console.info("Account creation - constructing account data %s", email); + console.info('Account creation - constructing account data %s', email); const accountData = { firstName, lastName, @@ -3428,32 +3433,32 @@ var createAnAccount = async (root, variables, context) => { verificationHash, verificationExpiry, createdAt: now2, - updatedAt: now2 + updatedAt: now2, }; - console.info("Account creation - creating account %s", email); + console.info('Account creation - creating account %s', email); const creationResponse = await context.db.Account.createOne({ - data: accountData + data: accountData, }); - console.info("Account creation - creating account status relationship %s", email); + console.info('Account creation - creating account status relationship %s', email); const accountId = creationResponse.id; await context.db.AccountStatus.createOne({ data: { account: { connect: { - id: accountId - } - } - } + id: accountId, + }, + }, + }, }); - console.info("Account creation - sending an email verification for %s", email); + console.info('Account creation - sending an email verification for %s', email); const name = get_full_name_string_default(creationResponse); if (isDevEnvironment3) { const verificationUrl = `${variables.urlOrigin}/apply/create-account/verify-email?token=${verificationHash}&id=${accountId}`; - console.info("\u2705 Account creation (dev environment only) - mimicking sending verification link via email \n%s", verificationUrl); + console.info('\u2705 Account creation (dev environment only) - mimicking sending verification link via email \n%s', verificationUrl); return { id: accountId, verificationHash, - success: true + success: true, }; } const emailResponse = await emails_default.confirmEmailAddress(email, urlOrigin, name, verificationHash, accountId); @@ -3461,12 +3466,12 @@ var createAnAccount = async (root, variables, context) => { return { id: accountId, verificationHash, - success: true + success: true, }; } throw new Error(`Account creation - sending email verification for account creation ${emailResponse}`); } catch (error) { - console.error("Error Account creation - creating account %o", error); + console.error('Error Account creation - creating account %o', error); throw new Error(`Account creation - creating account ${error}`); } }; @@ -3474,20 +3479,20 @@ var create_an_account_default = createAnAccount; // helpers/get-authentication-retries-by-account-id/index.ts var getAuthenticationRetriesByAccountId = async (context, accountId) => { - console.info("Getting authentication retries by account ID"); + console.info('Getting authentication retries by account ID'); try { const retries = await context.db.AuthenticationRetry.findMany({ where: { account: { every: { - id: { equals: accountId } - } - } - } + id: { equals: accountId }, + }, + }, + }, }); return retries; } catch (error) { - console.error("Error getting authentication retries by account ID %o", error); + console.error('Error getting authentication retries by account ID %o', error); throw new Error(`Getting authentication retries by account ID ${error}`); } }; @@ -3495,67 +3500,67 @@ var get_authentication_retries_by_account_id_default = getAuthenticationRetriesB // custom-resolvers/mutations/delete-an-account/index.ts var deleteAnAccount = async (root, variables, context) => { - console.info("Deleting account ", variables.email); + console.info('Deleting account ', variables.email); try { const { email } = variables; - const account2 = await get_account_by_field_default(context, "email", email); + const account2 = await get_account_by_field_default(context, 'email', email); if (!account2) { console.info(`Unable to delete account - account not found`); return { success: false }; } const { id: accountId } = account2; - console.info("Checking authentication retry entries"); + console.info('Checking authentication retry entries'); const retries = await get_authentication_retries_by_account_id_default(context, accountId); if (retries.length) { - console.info("Deleting authentication retry entries"); + console.info('Deleting authentication retry entries'); const retriesArray = retries.map((retry) => ({ - id: retry.id + id: retry.id, })); await context.db.AuthenticationRetry.deleteMany({ - where: retriesArray + where: retriesArray, }); } - console.info("Deleting account %s", accountId); + console.info('Deleting account %s', accountId); await context.db.Account.deleteOne({ where: { - id: accountId - } + id: accountId, + }, }); return { - success: true + success: true, }; } catch (error) { - console.error("Error deleting account %o", error); + console.error('Error deleting account %o', error); throw new Error(`Deleting account ${error}`); } }; var delete_an_account_default = deleteAnAccount; // custom-resolvers/mutations/verify-account-email-address/index.ts -var import_date_fns3 = require("date-fns"); +var import_date_fns3 = require('date-fns'); var { ID, EMAIL: EMAIL2, VERIFICATION_EXPIRY } = account_default; var verifyAccountEmailAddress = async (root, variables, context) => { try { - console.info("Verifying account email address"); + console.info('Verifying account email address'); const account2 = await get_account_by_field_default(context, ID, variables.id); if (!account2) { - console.info("Unable to verify account email address - account does not exist"); + console.info('Unable to verify account email address - account does not exist'); return { success: false, - invalid: true + invalid: true, }; } if (account2.verificationHash !== variables.token) { - console.info("Unable to verify account email address - token does not match hash"); + console.info('Unable to verify account email address - token does not match hash'); return { success: false, - invalid: true + invalid: true, }; } if (account2.status.isVerified) { - console.info("Account email address is already verified"); + console.info('Account email address is already verified'); return { - success: true + success: true, }; } const { id } = account2; @@ -3563,30 +3568,30 @@ var verifyAccountEmailAddress = async (root, variables, context) => { const now2 = /* @__PURE__ */ new Date(); const canActivateAccount = (0, import_date_fns3.isBefore)(now2, account2[VERIFICATION_EXPIRY]); if (!canActivateAccount) { - console.info("Unable to verify account email address - verification period has expired"); + console.info('Unable to verify account email address - verification period has expired'); return { expired: true, success: false, - accountId: id + accountId: id, }; } - console.info("Verified account email address - updating account to be verified"); + console.info('Verified account email address - updating account to be verified'); const accountUpdate = { - verificationHash: "", - verificationExpiry: null + verificationHash: '', + verificationExpiry: null, }; const statusUpdate = { - isVerified: true + isVerified: true, }; await update_account_default.account(context, id, accountUpdate); await update_account_default.accountStatus(context, statusId, statusUpdate); return { success: true, accountId: id, - emailRecipient: account2[EMAIL2] + emailRecipient: account2[EMAIL2], }; } catch (error) { - console.error("Error verifying account email address %o", error); + console.error('Error verifying account email address %o', error); throw new Error(`Verifying account email address ${error}`); } }; @@ -3595,14 +3600,14 @@ var verify_account_email_address_default = verifyAccountEmailAddress; // custom-resolvers/mutations/send-email-confirm-email-address/index.ts var sendEmailConfirmEmailAddressMutation = async (root, variables, context) => { try { - console.info("Sending email verification for account creation"); + console.info('Sending email verification for account creation'); const emailResponse = await send_email_confirm_email_address_default.send(context, variables.urlOrigin, variables.accountId); if (emailResponse.success) { return emailResponse; } throw new Error(`Sending email verification for account creation (sendEmailConfirmEmailAddress mutation) ${emailResponse}`); } catch (error) { - console.error("Error sending email verification for account creation (sendEmailConfirmEmailAddress mutation) %o", error); + console.error('Error sending email verification for account creation (sendEmailConfirmEmailAddress mutation) %o', error); throw new Error(`Sending email verification for account creation (sendEmailConfirmEmailAddress mutation) ${error}`); } }; @@ -3611,38 +3616,38 @@ var send_email_confirm_email_address_default2 = sendEmailConfirmEmailAddressMuta // helpers/create-authentication-retry-entry/index.ts var createAuthenticationRetryEntry = async (context, accountId) => { try { - console.info("Creating account authentication retry entry"); + console.info('Creating account authentication retry entry'); const now2 = /* @__PURE__ */ new Date(); const response = await context.db.AuthenticationRetry.createOne({ data: { account: { connect: { - id: accountId - } + id: accountId, + }, }, - createdAt: now2 - } + createdAt: now2, + }, }); if (response.id) { return { - success: true + success: true, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error creating account authentication retry entry %o", error); + console.error('Error creating account authentication retry entry %o', error); throw new Error(`${error}`); } }; var create_authentication_retry_entry_default = createAuthenticationRetryEntry; // helpers/should-block-account/index.ts -var import_date_fns4 = require("date-fns"); +var import_date_fns4 = require('date-fns'); var { MAX_AUTH_RETRIES, MAX_AUTH_RETRIES_TIMEFRAME } = ACCOUNT2; var shouldBlockAccount = async (context, accountId) => { - console.info("Checking account authentication retries %s", accountId); + console.info('Checking account authentication retries %s', accountId); try { const retries = await get_authentication_retries_by_account_id_default(context, accountId); const now2 = /* @__PURE__ */ new Date(); @@ -3655,12 +3660,12 @@ var shouldBlockAccount = async (context, accountId) => { } }); if (retriesInTimeframe.length >= MAX_AUTH_RETRIES) { - console.info("Account authentication retries exceeds the threshold %s", accountId); + console.info('Account authentication retries exceeds the threshold %s', accountId); return true; } return false; } catch (error) { - console.error("Error checking account authentication retries %o", error); + console.error('Error checking account authentication retries %o', error); throw new Error(`Checking account authentication retries ${error}`); } }; @@ -3668,7 +3673,7 @@ var should_block_account_default = shouldBlockAccount; // helpers/block-account/index.ts var blockAccount = async (context, statusId) => { - console.info("Blocking account %s", statusId); + console.info('Blocking account %s', statusId); try { const statusUpdate = { isBlocked: true }; const result = await update_account_default.accountStatus(context, statusId, statusUpdate); @@ -3677,30 +3682,30 @@ var blockAccount = async (context, statusId) => { } return false; } catch (error) { - console.error("Error blocking account %o", error); + console.error('Error blocking account %o', error); throw new Error(`Blocking account ${error}`); } }; var block_account_default = blockAccount; // custom-resolvers/mutations/account-sign-in/account-sign-in-checks/index.ts -var import_config6 = require("dotenv/config"); +var import_config6 = require('dotenv/config'); // helpers/generate-otp/index.ts -var import_crypto5 = __toESM(require("crypto")); -var import_otplib = require("otplib"); +var import_crypto5 = __toESM(require('crypto')); +var import_otplib = require('otplib'); var { ENCRYPTION: ENCRYPTION4, OTP } = ACCOUNT2; var { RANDOM_BYTES_SIZE: RANDOM_BYTES_SIZE2, STRING_TYPE: STRING_TYPE5, PBKDF2: { ITERATIONS: ITERATIONS5, DIGEST_ALGORITHM: DIGEST_ALGORITHM5 }, OTP: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH5 } - } + PBKDF2: { KEY_LENGTH: KEY_LENGTH5 }, + }, } = ENCRYPTION4; var generateOtp = () => { try { - console.info("Generating OTP"); + console.info('Generating OTP'); const salt = import_crypto5.default.randomBytes(RANDOM_BYTES_SIZE2).toString(STRING_TYPE5); import_otplib.authenticator.options = { digits: OTP.DIGITS }; const securityCode = import_otplib.authenticator.generate(salt); @@ -3710,38 +3715,38 @@ var generateOtp = () => { securityCode, salt, hash, - expiry + expiry, }; } catch (error) { - console.error("Error generating OTP %o", error); + console.error('Error generating OTP %o', error); throw new Error(`Error generating OTP ${error}`); } }; var generate = { - otp: generateOtp + otp: generateOtp, }; var generate_otp_default = generate; // helpers/generate-otp-and-update-account/index.ts var generateOTPAndUpdateAccount = async (context, accountId) => { try { - console.info("Adding OTP to an account"); + console.info('Adding OTP to an account'); const otp = generate_otp_default.otp(); const { securityCode, salt, hash, expiry } = otp; const accountUpdate = { otpSalt: salt, otpHash: hash, - otpExpiry: expiry + otpExpiry: expiry, }; const updatedAccount = await update_account_default.account(context, accountId, accountUpdate); const accountStatusUpdate = { isInactive: false }; await update_account_default.accountStatus(context, String(updatedAccount.statusId), accountStatusUpdate); return { success: true, - securityCode + securityCode, }; } catch (error) { - console.error("Error adding OTP to an account %o", error); + console.error('Error adding OTP to an account %o', error); throw new Error(`Adding OTP to an account ${error}`); } }; @@ -3750,44 +3755,44 @@ var generate_otp_and_update_account_default = generateOTPAndUpdateAccount; // custom-resolvers/mutations/account-sign-in/account-sign-in-checks/index.ts var accountSignInChecks = async (context, account2, urlOrigin) => { try { - console.info("Signing in account - checking account"); + console.info('Signing in account - checking account'); const { NODE_ENV: NODE_ENV3 } = process.env; - const isDevEnvironment3 = NODE_ENV3 === "development"; + const isDevEnvironment3 = NODE_ENV3 === 'development'; const { id: accountId, email } = account2; if (!account2.status.isVerified) { - console.info("Unable to sign in account - account has not been verified yet. Sending a new email verification"); + console.info('Unable to sign in account - account has not been verified yet. Sending a new email verification'); const emailResponse2 = await send_email_confirm_email_address_default.send(context, urlOrigin, accountId); if (emailResponse2?.success) { return { success: false, resentVerificationEmail: true, - accountId + accountId, }; } return { success: false, accountId }; } - console.info("Signing in account - account is verified. Generating and sending an OTP"); + console.info('Signing in account - account is verified. Generating and sending an OTP'); const { securityCode } = await generate_otp_and_update_account_default(context, accountId); const name = get_full_name_string_default(account2); if (isDevEnvironment3) { - console.info("\u2705 Signing in account (dev environment only) - mimicking sending OTP via email %s", securityCode); + console.info('\u2705 Signing in account (dev environment only) - mimicking sending OTP via email %s', securityCode); return { accountId, - success: true + success: true, }; } const emailResponse = await emails_default.accessCodeEmail(email, name, securityCode); if (emailResponse?.success) { return { ...emailResponse, - accountId + accountId, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error validating password or sending email(s) for account sign in (accountSignIn mutation - account checks) %o", error); + console.error('Error validating password or sending email(s) for account sign in (accountSignIn mutation - account checks) %o', error); throw new Error(`Validating password or sending email(s) for account sign in (accountSignIn mutation - account checks) ${error}`); } }; @@ -3796,26 +3801,26 @@ var account_sign_in_checks_default = accountSignInChecks; // custom-resolvers/mutations/account-sign-in/index.ts var accountSignIn = async (root, variables, context) => { try { - console.info("Signing in account"); + console.info('Signing in account'); const { urlOrigin, email, password: password2 } = variables; const accountData = await get_account_by_field_default(context, account_default.EMAIL, email); if (!accountData) { - console.info("Unable to validate account - no account found"); + console.info('Unable to validate account - no account found'); return { success: false }; } const account2 = accountData; const { id: accountId } = account2; - console.info("Signing in account - account found %s", accountId); + console.info('Signing in account - account found %s', accountId); const { isBlocked } = account2.status; if (isBlocked) { - console.info("Unable to sign in account - account is blocked"); + console.info('Unable to sign in account - account is blocked'); return { success: false, isBlocked: true, accountId }; } if (is_valid_account_password_default(password2, account2.salt, account2.hash)) { - console.info("Signing in account - valid credentials provided"); + console.info('Signing in account - valid credentials provided'); return account_sign_in_checks_default(context, account2, urlOrigin); } - console.info("Signing in account - invalid credentials provided"); + console.info('Signing in account - invalid credentials provided'); const newRetriesEntry = await create_authentication_retry_entry_default(context, accountId); if (!newRetriesEntry.success) { return { success: false }; @@ -3827,14 +3832,14 @@ var accountSignIn = async (root, variables, context) => { return { success: false, isBlocked: true, - accountId + accountId, }; } return { success: false }; } return { success: false }; } catch (error) { - console.error("Error signing into account %o", error); + console.error('Error signing into account %o', error); throw new Error(`Signing in account (accountSignIn mutation) ${error}`); } }; @@ -3843,11 +3848,11 @@ var account_sign_in_default = accountSignIn; // custom-resolvers/mutations/account-sign-in-new-code/index.ts var accountSignInSendNewCode = async (root, variables, context) => { try { - console.info("Generating and sending new sign in code for account"); + console.info('Generating and sending new sign in code for account'); const { accountId } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info("Unable to validate account - no account found"); + console.info('Unable to validate account - no account found'); return { success: false }; } const { securityCode } = await generate_otp_and_update_account_default(context, account2.id); @@ -3857,39 +3862,39 @@ var accountSignInSendNewCode = async (root, variables, context) => { if (emailResponse?.success) { return { ...emailResponse, - accountId: account2.id + accountId: account2.id, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error generating and sending new sign in code for account (accountSignInSendNewCode mutation) %o", error); + console.error('Error generating and sending new sign in code for account (accountSignInSendNewCode mutation) %o', error); throw new Error(`Generating and sending new sign in code for account (accountSignInSendNewCode mutation) ${error}`); } }; var account_sign_in_new_code_default = accountSignInSendNewCode; // helpers/is-valid-otp/index.ts -var import_crypto6 = __toESM(require("crypto")); +var import_crypto6 = __toESM(require('crypto')); var { ENCRYPTION: ENCRYPTION5 } = ACCOUNT2; var { STRING_TYPE: STRING_TYPE6, PBKDF2: { ITERATIONS: ITERATIONS6, DIGEST_ALGORITHM: DIGEST_ALGORITHM6 }, OTP: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH6 } - } + PBKDF2: { KEY_LENGTH: KEY_LENGTH6 }, + }, } = ENCRYPTION5; var isValidOTP = (securityCode, otpSalt, otpHash) => { try { - console.info("Validating OTP"); + console.info('Validating OTP'); const hashVerify = import_crypto6.default.pbkdf2Sync(securityCode, otpSalt, ITERATIONS6, KEY_LENGTH6, DIGEST_ALGORITHM6).toString(STRING_TYPE6); if (otpHash === hashVerify) { return true; } return false; } catch (error) { - console.error("Error validating OTP %o", error); + console.error('Error validating OTP %o', error); throw new Error(`Error validating OTP ${error}`); } }; @@ -3897,32 +3902,32 @@ var is_valid_otp_default = isValidOTP; // helpers/delete-authentication-retries/index.ts var deleteAuthenticationRetries = async (context, accountId) => { - console.info("Deleting authentication retries for account %s", accountId); + console.info('Deleting authentication retries for account %s', accountId); try { const retries = await get_authentication_retries_by_account_id_default(context, accountId); const retryIds = retries.map((obj) => ({ - id: obj.id + id: obj.id, })); const result = await context.db.AuthenticationRetry.deleteMany({ - where: retryIds + where: retryIds, }); return result; } catch (error) { - console.error("Error deleting authentication retries %o", error); + console.error('Error deleting authentication retries %o', error); throw new Error(`Deleting authentication retries ${error}`); } }; var delete_authentication_retries_default = deleteAuthenticationRetries; // helpers/create-jwt/index.ts -var import_crypto7 = __toESM(require("crypto")); -var import_jsonwebtoken = __toESM(require("jsonwebtoken")); +var import_crypto7 = __toESM(require('crypto')); +var import_jsonwebtoken = __toESM(require('jsonwebtoken')); var { ENCRYPTION: { RANDOM_BYTES_SIZE: RANDOM_BYTES_SIZE3, STRING_TYPE: STRING_TYPE7 }, JWT: { KEY: { SIGNATURE, ENCODING, STRING_ENCODING }, - TOKEN: { EXPIRY, ALGORITHM } - } + TOKEN: { EXPIRY, ALGORITHM }, + }, } = ACCOUNT2; var PRIV_KEY = Buffer.from(SIGNATURE, ENCODING).toString(STRING_ENCODING); var createJWT = (accountId) => { @@ -3930,62 +3935,62 @@ var createJWT = (accountId) => { const expiresIn = EXPIRY; const payload = { sub: accountId, - sessionIdentifier + sessionIdentifier, }; const signedToken = import_jsonwebtoken.default.sign(payload, PRIV_KEY, { expiresIn, algorithm: ALGORITHM }); return { token: `Bearer ${signedToken}`, expires: expiresIn, - sessionIdentifier + sessionIdentifier, }; }; var create = { - JWT: createJWT + JWT: createJWT, }; var create_jwt_default = create; // custom-resolvers/mutations/verify-account-sign-in-code/index.ts var { - JWT: { SESSION_EXPIRY } + JWT: { SESSION_EXPIRY }, } = ACCOUNT2; var verifyAccountSignInCode = async (root, variables, context) => { try { - console.info("Verifying account sign in code"); + console.info('Verifying account sign in code'); const { accountId, securityCode } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info("Unable to verify account sign in code - no account exists with the provided ID"); + console.info('Unable to verify account sign in code - no account exists with the provided ID'); return { - success: false + success: false, }; } if (!account2.otpSalt || !account2.otpHash || !account2.otpExpiry) { - console.info("Unable to verify account sign in code - no OTP available for this account"); + console.info('Unable to verify account sign in code - no OTP available for this account'); return { - success: false + success: false, }; } const { otpSalt, otpHash, otpExpiry } = account2; const hasExpired = dateIsInThePast(otpExpiry); if (hasExpired) { - console.info("Unable to verify account sign in code - verification period has expired"); + console.info('Unable to verify account sign in code - verification period has expired'); return { success: false, - expired: true + expired: true, }; } const isValid = otpSalt && otpHash && is_valid_otp_default(securityCode, otpSalt, otpHash); if (isValid) { - console.info("Verified account sign in code - creating JWT and updating account"); + console.info('Verified account sign in code - creating JWT and updating account'); await delete_authentication_retries_default(context, accountId); const jwt = create_jwt_default.JWT(accountId); const { sessionIdentifier } = jwt; const accountUpdate = { sessionIdentifier, sessionExpiry: SESSION_EXPIRY(), - otpSalt: "", - otpHash: "", - otpExpiry: null + otpSalt: '', + otpHash: '', + otpExpiry: null, }; await update_account_default.account(context, accountId, accountUpdate); return { @@ -3995,14 +4000,14 @@ var verifyAccountSignInCode = async (root, variables, context) => { firstName: account2.firstName, email: account2.email, ...jwt, - expires: accountUpdate.sessionExpiry + expires: accountUpdate.sessionExpiry, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error verifying account sign in code and generating JWT (verifyAccountSignInCode mutation) %o", error); + console.error('Error verifying account sign in code and generating JWT (verifyAccountSignInCode mutation) %o', error); throw new Error(`Verifying account sign in code and generating JWT (verifyAccountSignInCode mutation) ${error}`); } }; @@ -4011,43 +4016,43 @@ var verify_account_sign_in_code_default = verifyAccountSignInCode; // custom-resolvers/mutations/add-and-get-OTP/index.ts var addAndGetOTP = async (root, variables, context) => { try { - console.info("Adding OTP to an account"); + console.info('Adding OTP to an account'); const { email } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (!account2) { - console.info("Unable to generate and add OTP to an account - no account found"); + console.info('Unable to generate and add OTP to an account - no account found'); return { success: false }; } const { securityCode } = await generate_otp_and_update_account_default(context, account2.id); return { success: true, - securityCode + securityCode, }; } catch (error) { - console.error("Error adding OTP to an account (addAndGetOTP mutation) %o", error); + console.error('Error adding OTP to an account (addAndGetOTP mutation) %o', error); throw new Error(`Adding OTP to an account (addAndGetOTP mutation) ${error}`); } }; var add_and_get_OTP_default = addAndGetOTP; // custom-resolvers/mutations/send-email-password-reset-link/index.ts -var import_crypto8 = __toESM(require("crypto")); +var import_crypto8 = __toESM(require('crypto')); var { ENCRYPTION: { STRING_TYPE: STRING_TYPE8, PBKDF2: { ITERATIONS: ITERATIONS7, DIGEST_ALGORITHM: DIGEST_ALGORITHM7 }, PASSWORD: { - PBKDF2: { KEY_LENGTH: KEY_LENGTH7 } - } - } + PBKDF2: { KEY_LENGTH: KEY_LENGTH7 }, + }, + }, } = ACCOUNT2; var sendEmailPasswordResetLink = async (root, variables, context) => { try { - console.info("Received a password reset request - checking account"); + console.info('Received a password reset request - checking account'); const { urlOrigin, email } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (!account2) { - console.info("Unable to check account and send password reset email - no account found"); + console.info('Unable to check account and send password reset email - no account found'); return { success: false }; } const { id: accountId } = account2; @@ -4064,23 +4069,23 @@ var sendEmailPasswordResetLink = async (root, variables, context) => { return { success: false, isBlocked: true, - accountId + accountId, }; } } catch (error) { - console.error("Error blocking account $O", error); + console.error('Error blocking account $O', error); return { success: false }; } } - console.info("Generating password reset hash"); + console.info('Generating password reset hash'); const passwordResetHash = import_crypto8.default.pbkdf2Sync(email, account2.salt, ITERATIONS7, KEY_LENGTH7, DIGEST_ALGORITHM7).toString(STRING_TYPE8); const accountUpdate = { passwordResetHash, - passwordResetExpiry: ACCOUNT2.PASSWORD_RESET_EXPIRY() + passwordResetExpiry: ACCOUNT2.PASSWORD_RESET_EXPIRY(), }; - console.info("Updating account for password reset"); + console.info('Updating account for password reset'); await update_account_default.account(context, accountId, accountUpdate); - console.info("Sending password reset email"); + console.info('Sending password reset email'); const name = get_full_name_string_default(account2); const emailResponse = await emails_default.passwordResetLink(urlOrigin, email, name, passwordResetHash); if (emailResponse?.success) { @@ -4088,7 +4093,7 @@ var sendEmailPasswordResetLink = async (root, variables, context) => { } return { success: false }; } catch (error) { - console.error("Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) $O", error); + console.error('Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) $O', error); throw new Error(`Checking account and sending password reset email (sendEmailPasswordResetLink mutation) ${error}`); } }; @@ -4096,17 +4101,17 @@ var send_email_password_reset_link_default = sendEmailPasswordResetLink; // helpers/account-has-used-password-before/index.ts var hasAccountUsedPasswordBefore = async (context, accountId, newPassword) => { - console.info("Checking if an account has used a password before"); + console.info('Checking if an account has used a password before'); try { let usedBefore = false; const previousHashes = await context.db.Authentication.findMany({ where: { account: { every: { - id: { equals: accountId } - } - } - } + id: { equals: accountId }, + }, + }, + }, }); if (previousHashes.length) { previousHashes.forEach((previous) => { @@ -4118,7 +4123,7 @@ var hasAccountUsedPasswordBefore = async (context, accountId, newPassword) => { } return usedBefore; } catch (error) { - console.error("Error checking if an account has used a password before %o", error); + console.error('Error checking if an account has used a password before %o', error); throw new Error(`Checking if an account has used a password before ${error}`); } }; @@ -4126,17 +4131,17 @@ var account_has_used_password_before_default = hasAccountUsedPasswordBefore; // helpers/create-authentication-entry/index.ts var createAuthenticationEntry = async (context, entry) => { - console.info("Creating authentication entry"); + console.info('Creating authentication entry'); try { const result = await context.db.Authentication.createOne({ data: { ...entry, - createdAt: /* @__PURE__ */ new Date() - } + createdAt: /* @__PURE__ */ new Date(), + }, }); return result; } catch (error) { - console.error("Error creating authentication entry %o", error); + console.error('Error creating authentication entry %o', error); throw new Error(`Creating authentication entry ${error}`); } }; @@ -4144,75 +4149,75 @@ var create_authentication_entry_default = createAuthenticationEntry; // custom-resolvers/mutations/account-password-reset/index.ts var accountPasswordReset = async (root, variables, context) => { - console.info("Resetting account password"); + console.info('Resetting account password'); try { const { token, password: newPassword } = variables; const account2 = await get_account_by_field_default(context, account_default.PASSWORD_RESET_HASH, token); if (!account2) { - console.info("Unable to reset account password - account does not exist"); + console.info('Unable to reset account password - account does not exist'); return { success: false }; } const { - status: { isBlocked } + status: { isBlocked }, } = account2; if (isBlocked) { - console.info("Unable to reset account password - account is blocked"); + console.info('Unable to reset account password - account is blocked'); return { success: false }; } const { id: accountId, passwordResetHash, passwordResetExpiry, salt: currentSalt, hash: currentHash } = account2; if (!passwordResetHash || !passwordResetExpiry) { - console.info("Unable to reset account password - reset hash or expiry does not exist"); + console.info('Unable to reset account password - reset hash or expiry does not exist'); return { success: false }; } const hasExpired = dateIsInThePast(passwordResetExpiry); if (hasExpired) { - console.info("Unable to reset account password - verification period has expired"); + console.info('Unable to reset account password - verification period has expired'); return { success: false, - expired: true + expired: true, }; } const newHashCurrentSalt = get_password_hash_default(newPassword, currentSalt); const passwordIsTheSame = newHashCurrentSalt === currentHash; if (passwordIsTheSame) { - console.info("Unable to reset account password - provided password is the same"); + console.info('Unable to reset account password - provided password is the same'); return { success: false, - hasBeenUsedBefore: true + hasBeenUsedBefore: true, }; } const usedPasswordBefore = await account_has_used_password_before_default(context, accountId, newPassword); if (usedPasswordBefore) { - console.info("Unable to reset account password - provided password has been used before"); + console.info('Unable to reset account password - provided password has been used before'); return { success: false, - hasBeenUsedBefore: true + hasBeenUsedBefore: true, }; } await delete_authentication_retries_default(context, accountId); const authEntry = { account: { connect: { - id: accountId - } + id: accountId, + }, }, salt: currentSalt, - hash: currentHash + hash: currentHash, }; await create_authentication_entry_default(context, authEntry); const { salt: newSalt, hash: newHash } = encrypt_password_default(newPassword); const accountUpdate = { salt: newSalt, hash: newHash, - passwordResetHash: "", - passwordResetExpiry: null + passwordResetHash: '', + passwordResetExpiry: null, }; await update_account_default.account(context, accountId, accountUpdate); return { - success: true + success: true, }; } catch (error) { - console.error("Error resetting account password %o", error); + console.error('Error resetting account password %o', error); throw new Error(`Resetting account password ${error}`); } }; @@ -4221,18 +4226,18 @@ var account_password_reset_default = accountPasswordReset; // custom-resolvers/mutations/send-email-reactivate-account-link/index.ts var sendEmailReactivateAccountLink = async (root, variables, context) => { try { - console.info("Received a request to send reactivate account email/link - checking account"); + console.info('Received a request to send reactivate account email/link - checking account'); const reactiveAccountResponse = await send_email_reactivate_account_link_default.send(variables, context); return reactiveAccountResponse; } catch (error) { - console.error("Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink mutation) %o", error); + console.error('Error checking account and sending reactivate account email/link (sendEmailReactivateAccountLink mutation) %o', error); throw new Error(`Checking account and sending reactivate account email/link (sendEmailReactivateAccountLink mutation) ${error}`); } }; var send_email_reactivate_account_link_default2 = sendEmailReactivateAccountLink; // helpers/create-an-application/create-initial-application/index.ts -var import_date_fns5 = require("date-fns"); +var import_date_fns5 = require('date-fns'); // constants/application/initial-application-data/index.ts var { STATUS, LATEST_VERSION_NUMBER: LATEST_VERSION_NUMBER2, DEAL_TYPE, SUBMISSION_COUNT_DEFAULT } = APPLICATION; @@ -4240,7 +4245,7 @@ var INITIAL_APPLICATION_DATA = { status: STATUS.IN_PROGRESS, version: LATEST_VERSION_NUMBER2, dealType: DEAL_TYPE, - submissionCount: SUBMISSION_COUNT_DEFAULT + submissionCount: SUBMISSION_COUNT_DEFAULT, }; var initial_application_data_default = INITIAL_APPLICATION_DATA; @@ -4249,50 +4254,50 @@ var { STATUS: STATUS2, SUBMISSION_DEADLINE_IN_MONTHS, SUBMISSION_TYPE: SUBMISSIO var { status: inititalStatus, ...APPLICATION_FIELDS } = initial_application_data_default; var createInitialApplication = async ({ context, accountId, status = STATUS2.IN_PROGRESS }) => { try { - console.info("Creating initial application (createInitialApplication helper) for user %s", accountId); + console.info('Creating initial application (createInitialApplication helper) for user %s', accountId); const now2 = /* @__PURE__ */ new Date(); const application2 = await context.db.Application.createOne({ data: { owner: { - connect: { id: accountId } + connect: { id: accountId }, }, createdAt: now2, status, submissionDeadline: (0, import_date_fns5.addMonths)(new Date(now2), SUBMISSION_DEADLINE_IN_MONTHS), submissionType: SUBMISSION_TYPE2.MIA, updatedAt: now2, - ...APPLICATION_FIELDS - } + ...APPLICATION_FIELDS, + }, }); return application2; } catch (error) { - console.error("Error creating initial application (createInitialApplication helper) for user %s %o", accountId, error); + console.error('Error creating initial application (createInitialApplication helper) for user %s %o', accountId, error); throw new Error(`Creating initial application (createInitialApplication helper) for user ${accountId} ${error}`); } }; var initialApplication = { - create: createInitialApplication + create: createInitialApplication, }; var create_initial_application_default = initialApplication; // helpers/get-country-by-field/index.ts var getCountryByField = async (context, field, value) => { try { - console.info("Getting country by field/value"); + console.info('Getting country by field/value'); const countriesArray = await context.db.Country.findMany({ where: { - [field]: { equals: value } + [field]: { equals: value }, }, - take: 1 + take: 1, }); if (!countriesArray?.length || !countriesArray[0]) { - console.info("Getting country by field - no country exists with the provided field/value"); + console.info('Getting country by field - no country exists with the provided field/value'); return false; } const country = countriesArray[0]; return country; } catch (error) { - console.error("Error getting country by field/value %o", error); + console.error('Error getting country by field/value %o', error); throw new Error(`Getting country by field/value ${error}`); } }; @@ -4301,21 +4306,21 @@ var get_country_by_field_default = getCountryByField; // helpers/get-cover-period-value-by-field/index.ts var getCoverPeriodValueByField = async (context, field, value) => { try { - console.info("Getting coverPeriod by field/value $s %s %d", field, value); + console.info('Getting coverPeriod by field/value $s %s %d', field, value); const coverPeriodsArray = await context.db.CoverPeriod.findMany({ where: { - [field]: { equals: value } + [field]: { equals: value }, }, - take: 1 + take: 1, }); if (!coverPeriodsArray?.length || !coverPeriodsArray[0]) { - console.info("Getting coverPeriod by field - no coverPeriod exists with the provided field/value"); + console.info('Getting coverPeriod by field - no coverPeriod exists with the provided field/value'); return false; } const [coverPeriod] = coverPeriodsArray; return coverPeriod; } catch (error) { - console.error("Error getting coverPeriod by field/value %o", error); + console.error('Error getting coverPeriod by field/value %o', error); throw new Error(`Getting coverPeriod by field/value ${error}`); } }; @@ -4324,21 +4329,21 @@ var get_cover_period_value_by_field_default = getCoverPeriodValueByField; // helpers/get-total-contract-value-by-field/index.ts var getTotalContractValueByField = async (context, field, value) => { try { - console.info("Getting totalContractValue by field/value $s %s, %s", field, value); + console.info('Getting totalContractValue by field/value $s %s, %s', field, value); const totalContractValuesArray = await context.db.TotalContractValue.findMany({ where: { - [field]: { equals: value } + [field]: { equals: value }, }, - take: 1 + take: 1, }); if (!totalContractValuesArray?.length || !totalContractValuesArray[0]) { - console.info("Getting totalContractValue by field - no totalContractValue exists with the provided field/value"); + console.info('Getting totalContractValue by field - no totalContractValue exists with the provided field/value'); return false; } const [totalContractValue] = totalContractValuesArray; return totalContractValue; } catch (error) { - console.error("Error getting totalContractValue by field/value %o", error); + console.error('Error getting totalContractValue by field/value %o', error); throw new Error(`Getting totalContractValue by field/value ${error}`); } }; @@ -4346,20 +4351,20 @@ var get_total_contract_value_by_field_default = getTotalContractValueByField; // helpers/create-a-reference-number/index.ts var createAReferenceNumber = async (context, applicationId) => { - console.info("Creating a reference number for %s", applicationId); + console.info('Creating a reference number for %s', applicationId); try { const created = await context.db.ReferenceNumber.createOne({ data: { application: { connect: { - id: applicationId - } - } - } + id: applicationId, + }, + }, + }, }); return created.id; } catch (error) { - console.error("Error creating a reference number %o", error); + console.error('Error creating a reference number %o', error); throw new Error(`Creating a reference number ${error}`); } }; @@ -4367,18 +4372,18 @@ var create_a_reference_number_default = createAReferenceNumber; // helpers/create-a-broker/index.ts var createABroker = async (context, applicationId) => { - console.info("Creating a broker for %s", applicationId); + console.info('Creating a broker for %s', applicationId); try { const broker = await context.db.Broker.createOne({ data: { application: { - connect: { id: applicationId } - } - } + connect: { id: applicationId }, + }, + }, }); return broker; } catch (error) { - console.error("Error creating a broker %o", error); + console.error('Error creating a broker %o', error); throw new Error(`Creating a broker ${error}`); } }; @@ -4386,18 +4391,18 @@ var create_a_broker_default = createABroker; // helpers/create-a-business/index.ts var createABusiness = async (context, applicationId) => { - console.info("Creating a business for %s", applicationId); + console.info('Creating a business for %s', applicationId); try { const business = await context.db.Business.createOne({ data: { application: { - connect: { id: applicationId } - } - } + connect: { id: applicationId }, + }, + }, }); return business; } catch (error) { - console.error("Error creating a business %o", error); + console.error('Error creating a business %o', error); throw new Error(`Creating a business ${error}`); } }; @@ -4405,26 +4410,26 @@ var create_a_business_default = createABusiness; // helpers/create-a-buyer-trading-history/index.ts var createABuyerTradingHistory = async (context, buyerId, applicationId) => { - console.info("Creating a buyer trading history for %s", buyerId); + console.info('Creating a buyer trading history for %s', buyerId); try { const buyerTradingHistory = await context.db.BuyerTradingHistory.createOne({ data: { buyer: { connect: { - id: buyerId - } + id: buyerId, + }, }, application: { connect: { - id: applicationId - } + id: applicationId, + }, }, - currencyCode: APPLICATION.DEFAULT_CURRENCY - } + currencyCode: APPLICATION.DEFAULT_CURRENCY, + }, }); return buyerTradingHistory; } catch (error) { - console.error("Error creating a buyer trading history %o", error); + console.error('Error creating a buyer trading history %o', error); throw new Error(`Creating a buyer trading history ${error}`); } }; @@ -4432,25 +4437,25 @@ var create_a_buyer_trading_history_default = createABuyerTradingHistory; // helpers/create-a-buyer-contact/index.ts var createABuyerContact = async (context, buyerId, applicationId) => { - console.info("Creating a buyer contact for %s", buyerId); + console.info('Creating a buyer contact for %s', buyerId); try { const buyerContact = await context.db.BuyerContact.createOne({ data: { buyer: { connect: { - id: buyerId - } + id: buyerId, + }, }, application: { connect: { - id: applicationId - } - } - } + id: applicationId, + }, + }, + }, }); return buyerContact; } catch (error) { - console.error("Error creating a buyer contact %o", error); + console.error('Error creating a buyer contact %o', error); throw new Error(`Creating a buyer contact ${error}`); } }; @@ -4458,25 +4463,25 @@ var create_a_buyer_contact_default = createABuyerContact; // helpers/create-a-buyer-relationship/index.ts var createABuyerRelationship = async (context, buyerId, applicationId) => { - console.info("Creating a buyer relationship for %s", buyerId); + console.info('Creating a buyer relationship for %s', buyerId); try { const buyerRelationship = await context.db.BuyerRelationship.createOne({ data: { buyer: { connect: { - id: buyerId - } + id: buyerId, + }, }, application: { connect: { - id: applicationId - } - } - } + id: applicationId, + }, + }, + }, }); return buyerRelationship; } catch (error) { - console.error("Error creating a buyer relationship %o", error); + console.error('Error creating a buyer relationship %o', error); throw new Error(`Creating a buyer relationship ${error}`); } }; @@ -4484,17 +4489,17 @@ var create_a_buyer_relationship_default = createABuyerRelationship; // helpers/create-a-populated-buyer/index.ts var createAPopulatedBuyer = async (context, countryId, applicationId) => { - console.info("Creating a buyer for %s", applicationId); + console.info('Creating a buyer for %s', applicationId); try { const buyer = await context.db.Buyer.createOne({ data: { country: { - connect: { id: countryId } + connect: { id: countryId }, }, application: { - connect: { id: applicationId } - } - } + connect: { id: applicationId }, + }, + }, }); const buyerTradingHistory = await create_a_buyer_trading_history_default(context, buyer.id, applicationId); const buyerRelationship = await create_a_buyer_relationship_default(context, buyer.id, applicationId); @@ -4503,35 +4508,36 @@ var createAPopulatedBuyer = async (context, countryId, applicationId) => { ...buyer, buyerTradingHistory, relationship: buyerRelationship, - buyerContact + buyerContact, }; } catch (error) { - console.error("Error creating a populated buyer %o", error); + console.error('Error creating a populated buyer %o', error); throw new Error(`Creating a populated buyer ${error}`); } }; var create_a_populated_buyer_default = createAPopulatedBuyer; // helpers/create-a-declaration-version/index.ts -var { ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, CONFIDENTIALITY, CONFIRMATION_AND_ACKNOWLEDGEMENTS } = declarations_default2.LATEST_DECLARATIONS; +var { ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, CONFIDENTIALITY, CONFIRMATION_AND_ACKNOWLEDGEMENTS } = + declarations_default2.LATEST_DECLARATIONS; var createADeclarationVersion = async (context, declarationId) => { - console.info("Creating an application declaration version for %s", declarationId); + console.info('Creating an application declaration version for %s', declarationId); try { const declaration = await context.db.DeclarationVersion.createOne({ data: { declaration: { - connect: { id: declarationId } + connect: { id: declarationId }, }, agreeToAntiBribery: ANTI_BRIBERY, agreeToConfidentiality: CONFIDENTIALITY, agreeToConfirmationAndAcknowledgements: CONFIRMATION_AND_ACKNOWLEDGEMENTS, hasAntiBriberyCodeOfConduct: ANTI_BRIBERY_CODE_OF_CONDUCT, - willExportWithAntiBriberyCodeOfConduct: ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT - } + willExportWithAntiBriberyCodeOfConduct: ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, + }, }); return declaration; } catch (error) { - console.error("Error creating an application declaration version %o", error); + console.error('Error creating an application declaration version %o', error); throw new Error(`Creating an application declaration version ${error}`); } }; @@ -4539,22 +4545,22 @@ var create_a_declaration_version_default = createADeclarationVersion; // helpers/create-a-declaration/index.ts var createADeclaration = async (context, applicationId) => { - console.info("Creating an application declaration for %s", applicationId); + console.info('Creating an application declaration for %s', applicationId); try { const declaration = await context.db.Declaration.createOne({ data: { application: { - connect: { id: applicationId } - } - } + connect: { id: applicationId }, + }, + }, }); const declarationVersion = await create_a_declaration_version_default(context, declaration.id); return { ...declaration, - declarationVersion + declarationVersion, }; } catch (error) { - console.error("Error creating an application declaration %o", error); + console.error('Error creating an application declaration %o', error); throw new Error(`Creating an application declaration ${error}`); } }; @@ -4562,28 +4568,28 @@ var create_a_declaration_default = createADeclaration; // helpers/create-an-eligibility/index.ts var createAnEligibility = async (context, countryId, applicationId, coverPeriodId, totalContractValueId, eligibilityData) => { - console.info("Creating an eligibility for %s", applicationId); + console.info('Creating an eligibility for %s', applicationId); try { const eligibility = await context.db.Eligibility.createOne({ data: { buyerCountry: { - connect: { id: countryId } + connect: { id: countryId }, }, application: { - connect: { id: applicationId } + connect: { id: applicationId }, }, coverPeriod: { - connect: { id: coverPeriodId } + connect: { id: coverPeriodId }, }, totalContractValue: { - connect: { id: totalContractValueId } + connect: { id: totalContractValueId }, }, - ...eligibilityData - } + ...eligibilityData, + }, }); return eligibility; } catch (error) { - console.error("Error creating an eligibility %o", error); + console.error('Error creating an eligibility %o', error); throw new Error(`Creating an eligibility ${error}`); } }; @@ -4591,18 +4597,18 @@ var create_an_eligibility_default = createAnEligibility; // helpers/create-a-jointly-insured-party/index.ts var createAJointlyInsuredParty = async (context, policyId) => { - console.info("Creating a jointly insured party for %s", policyId); + console.info('Creating a jointly insured party for %s', policyId); try { const jointlyInsuredParty = await context.db.JointlyInsuredParty.createOne({ data: { policy: { - connect: { id: policyId } - } - } + connect: { id: policyId }, + }, + }, }); return jointlyInsuredParty; } catch (error) { - console.error("Error creating a jointly insured party %o", error); + console.error('Error creating a jointly insured party %o', error); throw new Error(`Creating a jointly insured party ${error}`); } }; @@ -4610,23 +4616,23 @@ var create_a_jointly_insured_party_default = createAJointlyInsuredParty; // helpers/create-a-policy/index.ts var createAPolicy = async (context, applicationId) => { - console.info("Creating a policy for %s", applicationId); + console.info('Creating a policy for %s', applicationId); try { const policy = await context.db.Policy.createOne({ data: { application: { - connect: { id: applicationId } + connect: { id: applicationId }, }, - needPreCreditPeriodCover: APPLICATION.DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER - } + needPreCreditPeriodCover: APPLICATION.DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER, + }, }); const jointlyInsuredParty = await create_a_jointly_insured_party_default(context, policy.id); return { ...policy, - jointlyInsuredParty + jointlyInsuredParty, }; } catch (error) { - console.error("Error creating a policy %o", error); + console.error('Error creating a policy %o', error); throw new Error(`Creating a policy ${error}`); } }; @@ -4634,18 +4640,18 @@ var create_a_policy_default = createAPolicy; // helpers/create-a-policy-contact/index.ts var createAPolicyContact = async (context, applicationId) => { - console.info("Creating a policy contact for %s", applicationId); + console.info('Creating a policy contact for %s', applicationId); try { const policyContact = await context.db.PolicyContact.createOne({ data: { application: { - connect: { id: applicationId } - } - } + connect: { id: applicationId }, + }, + }, }); return policyContact; } catch (error) { - console.error("Error creating a policy contact %o", error); + console.error('Error creating a policy contact %o', error); throw new Error(`Creating a policy contact ${error}`); } }; @@ -4653,28 +4659,28 @@ var create_a_policy_contact_default = createAPolicyContact; // helpers/create-a-loss-payee-financial-international/index.ts var createALossPayeeFinancialInternational = async (context, lossPayeeId) => { - console.info("Creating a loss payee financial (international) for %s", lossPayeeId); + console.info('Creating a loss payee financial (international) for %s', lossPayeeId); try { const lossPayeeFinancialInternational = await context.db.LossPayeeFinancialInternational.createOne({ data: { lossPayee: { - connect: { id: lossPayeeId } - } - } + connect: { id: lossPayeeId }, + }, + }, }); const vector = await context.db.LossPayeeFinancialInternationalVector.createOne({ data: { financialInternational: { - connect: { id: lossPayeeFinancialInternational.id } - } - } + connect: { id: lossPayeeFinancialInternational.id }, + }, + }, }); return { ...lossPayeeFinancialInternational, - vector + vector, }; } catch (error) { - console.error("Error creating a loss payee financial (international) for %o", error); + console.error('Error creating a loss payee financial (international) for %o', error); throw new Error(`Creating a loss payee financial (international) for ${error}`); } }; @@ -4682,28 +4688,28 @@ var create_a_loss_payee_financial_international_default = createALossPayeeFinanc // helpers/create-a-loss-payee-financial-uk/index.ts var createALossPayeeFinancialUk = async (context, lossPayeeId) => { - console.info("Creating a loss payee financial (UK) for %s", lossPayeeId); + console.info('Creating a loss payee financial (UK) for %s', lossPayeeId); try { const lossPayeeFinancialUk = await context.db.LossPayeeFinancialUk.createOne({ data: { lossPayee: { - connect: { id: lossPayeeId } - } - } + connect: { id: lossPayeeId }, + }, + }, }); const vector = await context.db.LossPayeeFinancialUkVector.createOne({ data: { financialUk: { - connect: { id: lossPayeeFinancialUk.id } - } - } + connect: { id: lossPayeeFinancialUk.id }, + }, + }, }); return { ...lossPayeeFinancialUk, - vector + vector, }; } catch (error) { - console.error("Error creating a loss payee financial (UK) for %o", error); + console.error('Error creating a loss payee financial (UK) for %o', error); throw new Error(`Creating a loss payee financial (UK) for ${error}`); } }; @@ -4711,20 +4717,20 @@ var create_a_loss_payee_financial_uk_default = createALossPayeeFinancialUk; // helpers/create-a-nominated-loss-payee/index.ts var createANominatedLossPayee = async (context, applicationId) => { - console.info("Creating a nominated loss payee for %s", applicationId); + console.info('Creating a nominated loss payee for %s', applicationId); try { const nominatedLossPayee = await context.db.NominatedLossPayee.createOne({ data: { application: { - connect: { id: applicationId } - } - } + connect: { id: applicationId }, + }, + }, }); await create_a_loss_payee_financial_international_default(context, nominatedLossPayee.id); await create_a_loss_payee_financial_uk_default(context, nominatedLossPayee.id); return nominatedLossPayee; } catch (error) { - console.error("Error creating a nominated loss payee for %o", error); + console.error('Error creating a nominated loss payee for %o', error); throw new Error(`Creating a nominated loss payee for ${error}`); } }; @@ -4732,21 +4738,21 @@ var create_a_nominated_loss_payee_default = createANominatedLossPayee; // helpers/create-a-company-address/index.ts var createACompanyAddress = async (context, addressData, companyId) => { - console.info("Creating a company address for %s", companyId); + console.info('Creating a company address for %s', companyId); try { const companyAddress = await context.db.CompanyAddress.createOne({ data: { company: { connect: { - id: companyId - } + id: companyId, + }, }, - ...addressData - } + ...addressData, + }, }); return companyAddress; } catch (error) { - console.error("Error creating a company address %o", error); + console.error('Error creating a company address %o', error); throw new Error(`Creating a company address ${error}`); } }; @@ -4759,7 +4765,7 @@ var mapSicCodes = (sicCodes, industrySectorNames2, companyId) => { return mapped; } sicCodes.forEach((code, index) => { - let industrySectorName = ""; + let industrySectorName = ''; if (industrySectorNames2?.[index]) { industrySectorName = industrySectorNames2[index]; } @@ -4768,9 +4774,9 @@ var mapSicCodes = (sicCodes, industrySectorNames2, companyId) => { industrySectorName, company: { connect: { - id: companyId - } - } + id: companyId, + }, + }, }; mapped.push(mappedCode); }); @@ -4780,18 +4786,18 @@ var map_sic_codes_default = mapSicCodes; // helpers/create-company-sic-codes/index.ts var createCompanySicCodes = async (context, companyId, sicCodes, industrySectorNames2) => { - console.info("Creating company SIC codes for %s", companyId); + console.info('Creating company SIC codes for %s', companyId); try { if (sicCodes?.length) { const mappedSicCodes = map_sic_codes_default(sicCodes, industrySectorNames2, companyId); const createdSicCodes = await context.db.CompanySicCode.createMany({ - data: mappedSicCodes + data: mappedSicCodes, }); return createdSicCodes; } return []; } catch (error) { - console.error("Error creating company SIC codes for %s %o", companyId, error); + console.error('Error creating company SIC codes for %s %o', companyId, error); throw new Error(`Creating company SIC codes for ${companyId} ${error}`); } }; @@ -4799,20 +4805,20 @@ var create_company_sic_codes_default = createCompanySicCodes; // helpers/create-a-company-different-trading-address/index.ts var createACompanyDifferentTradingAddress = async (context, companyId) => { - console.info("Creating a different trading address for %s", companyId); + console.info('Creating a different trading address for %s', companyId); try { const differentTradingAddress = await context.db.CompanyDifferentTradingAddress.createOne({ data: { company: { connect: { - id: companyId - } - } - } + id: companyId, + }, + }, + }, }); return differentTradingAddress; } catch (error) { - console.error("Error creating a company different trading address %o", error); + console.error('Error creating a company different trading address %o', error); throw new Error(`Creating a company different trading address ${error}`); } }; @@ -4820,16 +4826,16 @@ var create_a_company_different_trading_address_default = createACompanyDifferent // helpers/create-a-company/index.ts var createACompany = async (context, applicationId, companyData) => { - console.info("Creating a company, address and SIC codes for %s", applicationId); + console.info('Creating a company, address and SIC codes for %s', applicationId); try { const { registeredOfficeAddress, sicCodes, industrySectorNames: industrySectorNames2, ...companyFields } = companyData; const company = await context.db.Company.createOne({ data: { application: { - connect: { id: applicationId } + connect: { id: applicationId }, }, - ...companyFields - } + ...companyFields, + }, }); const companyAddress = await create_a_company_address_default(context, registeredOfficeAddress, company.id); const createdSicCodes = await create_company_sic_codes_default(context, company.id, sicCodes, industrySectorNames2); @@ -4838,10 +4844,10 @@ var createACompany = async (context, applicationId, companyData) => { ...company, registeredOfficeAddress: companyAddress, sicCodes: createdSicCodes, - differentTradingAddress: createdDifferentTradingAddress + differentTradingAddress: createdDifferentTradingAddress, }; } catch (error) { - console.error("Error creating a company, address, SIC codes and company different trading address %o", error); + console.error('Error creating a company, address, SIC codes and company different trading address %o', error); throw new Error(`Creating a company, address, SIC codes and company different trading address ${error}`); } }; @@ -4849,18 +4855,18 @@ var create_a_company_default = createACompany; // helpers/create-a-private-market/index.ts var createAPrivateMarket = async (context, exportContractId) => { - console.info("Creating a private market for %s", exportContractId); + console.info('Creating a private market for %s', exportContractId); try { const privateMarket = await context.db.PrivateMarket.createOne({ data: { exportContract: { - connect: { id: exportContractId } - } - } + connect: { id: exportContractId }, + }, + }, }); return privateMarket; } catch (error) { - console.error("Error creating a private market %o", error); + console.error('Error creating a private market %o', error); throw new Error(`Creating a private market ${error}`); } }; @@ -4868,18 +4874,18 @@ var create_a_private_market_default = createAPrivateMarket; // helpers/create-an-export-contract-agent-service/index.ts var createAnExportContractAgentService = async (context, agentId) => { - console.info("Creating an export contract agent service for %s", agentId); + console.info('Creating an export contract agent service for %s', agentId); try { const agentService = await context.db.ExportContractAgentService.createOne({ data: { agent: { - connect: { id: agentId } - } - } + connect: { id: agentId }, + }, + }, }); return agentService; } catch (error) { - console.error("Error creating an export contract agent service %o", error); + console.error('Error creating an export contract agent service %o', error); throw new Error(`Creating an export contract agent service ${error}`); } }; @@ -4887,18 +4893,18 @@ var create_an_export_contract_agent_service_default = createAnExportContractAgen // helpers/create-an-export-contract-agent-service-charge/index.ts var createAnExportContractAgentServiceCharge = async (context, agentServiceId) => { - console.info("Creating an export contract agent service charge for %s", agentServiceId); + console.info('Creating an export contract agent service charge for %s', agentServiceId); try { const agentService = await context.db.ExportContractAgentServiceCharge.createOne({ data: { service: { - connect: { id: agentServiceId } - } - } + connect: { id: agentServiceId }, + }, + }, }); return agentService; } catch (error) { - console.error("Error creating an export contract agent service charge %o", error); + console.error('Error creating an export contract agent service charge %o', error); throw new Error(`Creating an export contract agent service charge ${error}`); } }; @@ -4906,24 +4912,24 @@ var create_an_export_contract_agent_service_charge_default = createAnExportContr // helpers/create-an-export-contract-agent/index.ts var createAnExportContractAgent = async (context, exportContractId) => { - console.info("Creating an export contract agent for %s", exportContractId); + console.info('Creating an export contract agent for %s', exportContractId); try { const agent = await context.db.ExportContractAgent.createOne({ data: { exportContract: { - connect: { id: exportContractId } - } - } + connect: { id: exportContractId }, + }, + }, }); const agentService = await create_an_export_contract_agent_service_default(context, agent.id); const agentServiceCharge = await create_an_export_contract_agent_service_charge_default(context, agentService.id); return { agent, agentService, - agentServiceCharge + agentServiceCharge, }; } catch (error) { - console.error("Error creating an export contract agent %o", error); + console.error('Error creating an export contract agent %o', error); throw new Error(`Creating an export contract agent ${error}`); } }; @@ -4931,15 +4937,15 @@ var create_an_export_contract_agent_default = createAnExportContractAgent; // helpers/create-an-export-contract/index.ts var createAnExportContract = async (context, applicationId) => { - console.info("Creating an export contract for %s", applicationId); + console.info('Creating an export contract for %s', applicationId); try { const exportContract = await context.db.ExportContract.createOne({ data: { application: { - connect: { id: applicationId } + connect: { id: applicationId }, }, - finalDestinationKnown: APPLICATION.DEFAULT_FINAL_DESTINATION_KNOWN - } + finalDestinationKnown: APPLICATION.DEFAULT_FINAL_DESTINATION_KNOWN, + }, }); const privateMarket = await create_a_private_market_default(context, exportContract.id); const { agent, agentService } = await create_an_export_contract_agent_default(context, exportContract.id); @@ -4947,10 +4953,10 @@ var createAnExportContract = async (context, applicationId) => { ...exportContract, privateMarket, agent, - agentService + agentService, }; } catch (error) { - console.error("Error creating an export contract %o", error); + console.error('Error creating an export contract %o', error); throw new Error(`Creating an export contract ${error}`); } }; @@ -4958,47 +4964,41 @@ var create_an_export_contract_default = createAnExportContract; // helpers/create-a-section-review/index.ts var createASectionReview = async (context, applicationId, sectionReviewData) => { - console.info("Creating a section review for %s", applicationId); + console.info('Creating a section review for %s', applicationId); try { const sectionReview = await context.db.SectionReview.createOne({ data: { application: { - connect: { id: applicationId } + connect: { id: applicationId }, }, - ...sectionReviewData - } + ...sectionReviewData, + }, }); return sectionReview; } catch (error) { - console.error("Error creating a section review %o", error); + console.error('Error creating a section review %o', error); throw new Error(`Creating a section review ${error}`); } }; var create_a_section_review_default = createASectionReview; // helpers/create-an-application/create-application-relationships/index.ts -var createApplicationRelationships = async ({ - context, - applicationId, - companyData, - eligibilityAnswers, - sectionReviewData -}) => { +var createApplicationRelationships = async ({ context, applicationId, companyData, eligibilityAnswers, sectionReviewData }) => { try { - console.info("Creating application relationships (createApplicationRelationships helper) for application %s", applicationId); + console.info('Creating application relationships (createApplicationRelationships helper) for application %s', applicationId); const { buyerCountryIsoCode, totalContractValueId, coverPeriodId, ...otherEligibilityAnswers } = eligibilityAnswers; - const country = await get_country_by_field_default(context, "isoCode", buyerCountryIsoCode); + const country = await get_country_by_field_default(context, 'isoCode', buyerCountryIsoCode); if (!country) { console.error( - "Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application %s", - applicationId + 'Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application %s', + applicationId, ); throw new Error( - `Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application ${applicationId}` + `Unable to create application relationships - buyer country not found (createApplicationRelationships helper) for application ${applicationId}`, ); } - const coverPeriod = await get_cover_period_value_by_field_default(context, "valueId", coverPeriodId); - const totalContractValue = await get_total_contract_value_by_field_default(context, "valueId", totalContractValueId); + const coverPeriod = await get_cover_period_value_by_field_default(context, 'valueId', coverPeriodId); + const totalContractValue = await get_total_contract_value_by_field_default(context, 'valueId', totalContractValueId); const referenceNumber = await create_a_reference_number_default(context, applicationId); const createdRelationships = await Promise.all([ create_a_broker_default(context, applicationId), @@ -5011,9 +5011,10 @@ var createApplicationRelationships = async ({ create_a_policy_contact_default(context, applicationId), create_a_nominated_loss_payee_default(context, applicationId), create_a_company_default(context, applicationId, companyData), - create_a_section_review_default(context, applicationId, sectionReviewData) + create_a_section_review_default(context, applicationId, sectionReviewData), ]); - const [broker, business, buyer, declaration, eligibility, exportContract, policy, policyContact, nominatedLossPayee, company, sectionReview] = createdRelationships; + const [broker, business, buyer, declaration, eligibility, exportContract, policy, policyContact, nominatedLossPayee, company, sectionReview] = + createdRelationships; const relationshipIds = { brokerId: broker.id, businessId: business.id, @@ -5026,16 +5027,16 @@ var createApplicationRelationships = async ({ policyId: policy.id, policyContactId: policyContact.id, referenceNumber, - sectionReviewId: sectionReview.id + sectionReviewId: sectionReview.id, }; return relationshipIds; } catch (error) { - console.error("Error creating application relationships (createApplicationRelationships helper) for application %s %o", applicationId, error); + console.error('Error creating application relationships (createApplicationRelationships helper) for application %s %o', applicationId, error); throw new Error(`Creating application relationships (createApplicationRelationships helper) for application ${applicationId} ${error}`); } }; var applicationRelationships = { - create: createApplicationRelationships + create: createApplicationRelationships, }; var create_application_relationships_default = applicationRelationships; @@ -5054,76 +5055,76 @@ var updateApplicationColumns = async ({ policyId, policyContactId, referenceNumber, - sectionReviewId + sectionReviewId, }) => { try { - console.info("Updating application relationship columns (updateApplicationColumns helper) for application %s", applicationId); + console.info('Updating application relationship columns (updateApplicationColumns helper) for application %s', applicationId); const updatedApplication = await context.db.Application.updateOne({ where: { - id: applicationId + id: applicationId, }, data: { broker: { - connect: { id: brokerId } + connect: { id: brokerId }, }, business: { - connect: { id: businessId } + connect: { id: businessId }, }, buyer: { - connect: { id: buyerId } + connect: { id: buyerId }, }, company: { - connect: { id: companyId } + connect: { id: companyId }, }, declaration: { - connect: { id: declarationId } + connect: { id: declarationId }, }, eligibility: { - connect: { id: eligibilityId } + connect: { id: eligibilityId }, }, exportContract: { - connect: { id: exportContractId } + connect: { id: exportContractId }, }, nominatedLossPayee: { - connect: { id: nominatedLossPayeeId } + connect: { id: nominatedLossPayeeId }, }, policy: { - connect: { id: policyId } + connect: { id: policyId }, }, policyContact: { - connect: { id: policyContactId } + connect: { id: policyContactId }, }, referenceNumber, sectionReview: { - connect: { id: sectionReviewId } - } - } + connect: { id: sectionReviewId }, + }, + }, }); return updatedApplication; } catch (error) { - console.error("Error updating application relationship columns (updateApplicationColumns helper) for application %s %o", applicationId, error); + console.error('Error updating application relationship columns (updateApplicationColumns helper) for application %s %o', applicationId, error); throw new Error(`Updating application relationship columns (updateApplicationColumns helper) for application ${applicationId} ${error}`); } }; var applicationColumns = { - update: updateApplicationColumns + update: updateApplicationColumns, }; var update_application_columns_default = applicationColumns; // helpers/create-an-application/index.ts var createAnApplicationHelper = async (variables, context) => { - console.info("Creating an application (createAnApplication helper) for user %s", variables.accountId); + console.info('Creating an application (createAnApplication helper) for user %s', variables.accountId); try { const { accountId, eligibilityAnswers, company: companyData, sectionReview: sectionReviewData, status } = variables; const account2 = await get_account_by_id_default(context, accountId); if (!account2) { - console.info("Rejecting application creation - no account found (createAnApplication helper)"); + console.info('Rejecting application creation - no account found (createAnApplication helper)'); return null; } const application2 = await create_initial_application_default.create({ context, accountId, - status + status, }); const { id: applicationId } = application2; const { @@ -5138,13 +5139,13 @@ var createAnApplicationHelper = async (variables, context) => { policyId, policyContactId, referenceNumber, - sectionReviewId + sectionReviewId, } = await create_application_relationships_default.create({ context, applicationId, companyData, eligibilityAnswers, - sectionReviewData + sectionReviewData, }); const updatedApplication = await update_application_columns_default.update({ context, @@ -5160,11 +5161,11 @@ var createAnApplicationHelper = async (variables, context) => { policyId, policyContactId, referenceNumber, - sectionReviewId + sectionReviewId, }); return updatedApplication; } catch (error) { - console.error("Error creating an application (createAnApplication helper) for user %s %o", variables.accountId, error); + console.error('Error creating an application (createAnApplication helper) for user %s %o', variables.accountId, error); throw new Error(`Creating an application (createAnApplication helper) for user ${variables.accountId} ${error}`); } }; @@ -5172,20 +5173,20 @@ var create_an_application_default = createAnApplicationHelper; // custom-resolvers/mutations/create-an-application/index.ts var createAnApplication = async (root, variables, context) => { - console.info("Creating application for user %s", variables.accountId); + console.info('Creating application for user %s', variables.accountId); try { const application2 = await create_an_application_default(variables, context); if (application2) { return { ...application2, - success: true + success: true, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error creating application for user %s %o", variables.accountId, error); + console.error('Error creating application for user %s %o', variables.accountId, error); throw new Error(`Creating application for user ${variables.accountId} ${error}`); } }; @@ -5193,12 +5194,12 @@ var create_an_application_default2 = createAnApplication; // helpers/get-countries/index.ts var getCountries = async (context) => { - console.info("Getting countries"); + console.info('Getting countries'); try { const countries = await context.db.Country.findMany(); return countries; } catch (error) { - console.error("Error getting countries %o", error); + console.error('Error getting countries %o', error); throw new Error(`Getting countries ${error}`); } }; @@ -5206,20 +5207,20 @@ var get_countries_default = getCountries; // helpers/create-a-buyer/index.ts var createABuyer = async (context, countryId) => { - console.info("Creating a buyer"); + console.info('Creating a buyer'); try { const buyer = await context.db.Buyer.createOne({ data: { country: { connect: { - id: countryId - } - } - } + id: countryId, + }, + }, + }, }); return buyer; } catch (error) { - console.error("Error creating a buyer %o", error); + console.error('Error creating a buyer %o', error); throw new Error(`Creating a buyer ${error}`); } }; @@ -5227,25 +5228,25 @@ var create_a_buyer_default = createABuyer; // helpers/create-many-applications-and-reference-numbers/index.ts var createManyApplicationsAndReferenceNumbers = async (context, applicationData) => { - console.info("Creating many applications and reference numbers"); + console.info('Creating many applications and reference numbers'); try { const applications = await context.db.Application.createMany({ - data: applicationData + data: applicationData, }); const referenceNumbersData = applications.map((application2) => ({ application: { connect: { - id: application2.id - } - } + id: application2.id, + }, + }, })); const referenceNumbers = await context.db.ReferenceNumber.createMany({ data: referenceNumbersData }); return { applications, - referenceNumbers + referenceNumbers, }; } catch (error) { - console.error("Error creating many applications and reference numbers - helper %o", error); + console.error('Error creating many applications and reference numbers - helper %o', error); throw new Error(`Creating many applications and reference numbers - helper ${error}`); } }; @@ -5253,14 +5254,14 @@ var create_many_applications_and_reference_numbers_default = createManyApplicati // helpers/update-applications-data/index.ts var updateApplicationsData = async (context, updateData) => { - console.info("Updating many applications"); + console.info('Updating many applications'); try { const updatedApplications = await context.db.Application.updateMany({ - data: updateData + data: updateData, }); return updatedApplications; } catch (error) { - console.error("Error updating many applications - helper %o", error); + console.error('Error updating many applications - helper %o', error); throw new Error(`Updating many applications - helper ${error}`); } }; @@ -5268,7 +5269,7 @@ var update_applications_data_default = updateApplicationsData; // custom-resolvers/mutations/create-many-applications/index.ts var createManyApplications = async (root, variables, context) => { - console.info("Creating many applications"); + console.info('Creating many applications'); try { const emptyArray = new Array(variables.count).fill({}); const countries = await get_countries_default(context); @@ -5276,36 +5277,36 @@ var createManyApplications = async (root, variables, context) => { const mockApplicationsData = emptyArray.map(() => ({ owner: { connect: { - id: variables.accountId - } + id: variables.accountId, + }, }, buyer: { connect: { - id: buyer.id - } + id: buyer.id, + }, }, - ...initial_application_data_default + ...initial_application_data_default, })); const { referenceNumbers } = await create_many_applications_and_reference_numbers_default(context, mockApplicationsData); const updateApplicationReferenceNumbers = referenceNumbers.map((referenceNumber) => ({ where: { id: referenceNumber.applicationId }, - data: { referenceNumber: referenceNumber.id } + data: { referenceNumber: referenceNumber.id }, })); await update_applications_data_default(context, updateApplicationReferenceNumbers); const allApplications = await context.query.Application.findMany({ - query: "id referenceNumber" + query: 'id referenceNumber', }); if (allApplications.length) { return { applications: allApplications, - success: true + success: true, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error creating many applications %o", error); + console.error('Error creating many applications %o', error); throw new Error(`Creating many applications ${error}`); } }; @@ -5314,7 +5315,7 @@ var create_many_applications_default = createManyApplications; // custom-resolvers/mutations/create-an-abandoned-application/index.ts var { STATUS: STATUS3 } = APPLICATION; var createAnAbandonedApplication = async (root, variables, context) => { - console.info("Creating an abandoned application for %s", variables.accountId); + console.info('Creating an abandoned application for %s', variables.accountId); const abandonedApplicationVariables = variables; abandonedApplicationVariables.status = STATUS3.ABANDONED; try { @@ -5322,14 +5323,14 @@ var createAnAbandonedApplication = async (root, variables, context) => { if (createdApplication) { return { ...createdApplication, - success: true + success: true, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error creating an abandoned application %o", error); + console.error('Error creating an abandoned application %o', error); throw new Error(`Creating an abandoned application ${error}`); } }; @@ -5338,11 +5339,11 @@ var create_an_abandoned_application_default = createAnAbandonedApplication; // helpers/get-application-by-reference-number/index.ts var getApplicationByReferenceNumber = async (referenceNumber, context) => { try { - console.info("Getting application by reference number - getApplicationByReferenceNumber helper %s", referenceNumber); + console.info('Getting application by reference number - getApplicationByReferenceNumber helper %s', referenceNumber); const applications = await context.db.Application.findMany({ where: { - referenceNumber: { equals: referenceNumber } - } + referenceNumber: { equals: referenceNumber }, + }, }); if (applications?.length) { const [application2] = applications; @@ -5350,7 +5351,7 @@ var getApplicationByReferenceNumber = async (referenceNumber, context) => { } return null; } catch (error) { - console.error("Error getting application by reference number %o", error); + console.error('Error getting application by reference number %o', error); throw new Error(`Error getting application by reference number ${error}`); } }; @@ -5359,45 +5360,45 @@ var get_application_by_reference_number_default = getApplicationByReferenceNumbe // custom-resolvers/mutations/delete-application-by-reference-number/index.ts var deleteApplicationByReferenceNumber = async (root, variables, context) => { try { - console.info("Deleting application by reference number"); + console.info('Deleting application by reference number'); const { referenceNumber } = variables; const application2 = await get_application_by_reference_number_default(referenceNumber, context); if (application2) { const { id } = application2; const deleteResponse = await context.db.Application.deleteOne({ where: { - id - } + id, + }, }); if (deleteResponse?.id) { return { - success: true + success: true, }; } } return { - success: false + success: false, }; } catch (error) { - console.error("Error deleting application by reference number (DeleteApplicationByReferenceNumber mutation) %o", error); + console.error('Error deleting application by reference number (DeleteApplicationByReferenceNumber mutation) %o', error); throw new Error(`Deleting application by reference number (DeleteApplicationByReferenceNumber mutation) ${error}`); } }; var delete_application_by_reference_number_default = deleteApplicationByReferenceNumber; // custom-resolvers/mutations/submit-application/index.ts -var import_date_fns6 = require("date-fns"); +var import_date_fns6 = require('date-fns'); // helpers/get-eligibility-by-id/index.ts var getEligibilityById = async (context, id) => { try { - console.info("Getting eligibility by ID %s", id); + console.info('Getting eligibility by ID %s', id); const eligibility = await context.db.Eligibility.findOne({ - where: { id } + where: { id }, }); return eligibility; } catch (error) { - console.error("Getting eligibility by ID %s %o", id, error); + console.error('Getting eligibility by ID %s %o', id, error); throw new Error(`Error Getting eligibility by ID ${id} ${error}`); } }; @@ -5406,13 +5407,13 @@ var get_eligibility_by_id_default = getEligibilityById; // helpers/get-cover-period-by-id/index.ts var getCoverPeriodById = async (context, id) => { try { - console.info("Getting coverPeriod by ID %s", id); + console.info('Getting coverPeriod by ID %s', id); const coverPeriod = await context.db.CoverPeriod.findOne({ - where: { id } + where: { id }, }); return coverPeriod; } catch (error) { - console.error("Getting coverPeriod by ID %s %o", id, error); + console.error('Getting coverPeriod by ID %s %o', id, error); throw new Error(`Error Getting coverPeriod by ID ${id} ${error}`); } }; @@ -5421,13 +5422,13 @@ var get_cover_period_by_id_default = getCoverPeriodById; // helpers/get-total-contract-value-by-id/index.ts var getTotalContractValueById = async (context, id) => { try { - console.info("Getting totalContractValue by ID %s", id); + console.info('Getting totalContractValue by ID %s', id); const totalContractValue = await context.db.TotalContractValue.findOne({ - where: { id } + where: { id }, }); return totalContractValue; } catch (error) { - console.error("Getting totalContractValue by ID %s %o", id, error); + console.error('Getting totalContractValue by ID %s %o', id, error); throw new Error(`Error Getting totalContractValue by ID ${id} ${error}`); } }; @@ -5436,7 +5437,7 @@ var get_total_contract_value_by_id_default = getTotalContractValueById; // helpers/get-populated-eligibility/index.ts var getPopulatedEligibility = async (context, id, buyerCountry) => { try { - console.info("Getting populated eligibility %s", id); + console.info('Getting populated eligibility %s', id); const eligibility = await get_eligibility_by_id_default(context, id); const coverPeriod = await get_cover_period_by_id_default(context, eligibility.coverPeriodId); const totalContractValue = await get_total_contract_value_by_id_default(context, eligibility.totalContractValueId); @@ -5444,11 +5445,11 @@ var getPopulatedEligibility = async (context, id, buyerCountry) => { ...eligibility, buyerCountry, coverPeriod, - totalContractValue + totalContractValue, }; return populatedEligibility; } catch (error) { - console.error("Getting populated eligibility %s %o", id, error); + console.error('Getting populated eligibility %s %o', id, error); throw new Error(`Error Getting populated eligibility ${id} ${error}`); } }; @@ -5457,14 +5458,15 @@ var get_populated_eligibility_default = getPopulatedEligibility; // helpers/get-policy-by-id/index.ts var getPolicyById = async (context, id) => { try { - console.info("Getting policy by ID %s", id); + console.info('Getting policy by ID %s', id); const policy = await context.query.Policy.findOne({ where: { id }, - query: "id policyType requestedStartDate contractCompletionDate requestedCreditLimit totalValueOfContract creditPeriodWithBuyer policyCurrencyCode totalMonthsOfCover totalSalesToBuyer maximumBuyerWillOwe needPreCreditPeriodCover jointlyInsuredParty { id companyName companyNumber countryCode requested }" + query: + 'id policyType requestedStartDate contractCompletionDate requestedCreditLimit totalValueOfContract creditPeriodWithBuyer policyCurrencyCode totalMonthsOfCover totalSalesToBuyer maximumBuyerWillOwe needPreCreditPeriodCover jointlyInsuredParty { id companyName companyNumber countryCode requested }', }); return policy; } catch (error) { - console.error("Getting policy by ID %s %o", id, error); + console.error('Getting policy by ID %s %o', id, error); throw new Error(`Error Getting policy by ID ${id} ${error}`); } }; @@ -5473,32 +5475,32 @@ var get_policy_by_id_default = getPolicyById; // helpers/get-policy-contact-by-id/index.ts var getPolicyContactById = async (context, id) => { try { - console.info("Getting policyContact by ID %s", id); + console.info('Getting policyContact by ID %s', id); const policyContact = await context.db.PolicyContact.findOne({ - where: { id } + where: { id }, }); return policyContact; } catch (error) { - console.error("Getting policyContact by ID %s %o", id, error); + console.error('Getting policyContact by ID %s %o', id, error); throw new Error(`Error Getting policyContact by ID ${id} ${error}`); } }; var get_policy_contact_by_id_default = getPolicyContactById; // helpers/encrypt/generate-key/index.ts -var import_crypto9 = __toESM(require("crypto")); +var import_crypto9 = __toESM(require('crypto')); var { ALGORITHM: ALGORITHM2, SIGNATURE: SIGNATURE2, SUBSTRING_INDEX_START, SUBSTRING_INDEX_END } = FINANCIAL_DETAILS.ENCRYPTION.KEY; -var generateKey = () => import_crypto9.default.createHash(ALGORITHM2).update(SIGNATURE2).digest("hex").substring(SUBSTRING_INDEX_START, SUBSTRING_INDEX_END); +var generateKey = () => import_crypto9.default.createHash(ALGORITHM2).update(SIGNATURE2).digest('hex').substring(SUBSTRING_INDEX_START, SUBSTRING_INDEX_END); var generate_key_default = generateKey; // helpers/decrypt/generate-decipher/index.ts -var import_crypto10 = __toESM(require("crypto")); +var import_crypto10 = __toESM(require('crypto')); var { ENCRYPTION_METHOD } = FINANCIAL_DETAILS.ENCRYPTION.CIPHER; var generateDecipher = (key2, iv) => { try { return import_crypto10.default.createDecipheriv(ENCRYPTION_METHOD, key2, iv); } catch (error) { - console.error("Error generating decipher %o", error); + console.error('Error generating decipher %o', error); throw new Error(`Error generating decipher ${error}`); } }; @@ -5510,7 +5512,7 @@ var generateBufferInStringFormat = (value) => { try { return Buffer.from(value, STRING_ENCODING2).toString(OUTPUT_ENCODING); } catch (error) { - console.error("Error generating buffer %o", error); + console.error('Error generating buffer %o', error); throw new Error(`Error generating buffer ${error}`); } }; @@ -5521,7 +5523,7 @@ var { ENCODING: ENCODING2, OUTPUT_ENCODING: OUTPUT_ENCODING2 } = FINANCIAL_DETAI var key = generate_key_default(); var decryptData = (dataToDecrypt) => { try { - console.info("Decrypting data"); + console.info('Decrypting data'); const { value, iv } = dataToDecrypt; const buffer = generate_buffer_default(value); const decipher = generate_decipher_default(key, iv); @@ -5529,27 +5531,27 @@ var decryptData = (dataToDecrypt) => { const decipherFinal = decipher.final(OUTPUT_ENCODING2); return decipherUpdate.concat(decipherFinal); } catch (error) { - console.error("Error decrypting data %o", error); + console.error('Error decrypting data %o', error); throw new Error(`Error decrypting data ${error}`); } }; var decrypt = { - decrypt: decryptData + decrypt: decryptData, }; var decrypt_default = decrypt; // helpers/decrypt-financial-uk/index.ts var decryptFinancialUk = (applicationFinancialUk) => { try { - console.info("Decrypting financial uk"); + console.info('Decrypting financial uk'); const mapped = applicationFinancialUk; const { accountNumber, sortCode, - vector: { accountNumberVector, sortCodeVector } + vector: { accountNumberVector, sortCodeVector }, } = applicationFinancialUk; - let decryptedAccountNumber = ""; - let decryptedSortCode = ""; + let decryptedAccountNumber = ''; + let decryptedSortCode = ''; if (accountNumber && accountNumberVector) { decryptedAccountNumber = decrypt_default.decrypt({ value: accountNumber, iv: accountNumberVector }); } @@ -5560,7 +5562,7 @@ var decryptFinancialUk = (applicationFinancialUk) => { mapped.sortCode = decryptedSortCode; return mapped; } catch (error) { - console.error("Error decrypting financial uk %o", error); + console.error('Error decrypting financial uk %o', error); throw new Error(`Error decrypting financial uk ${error}`); } }; @@ -5569,15 +5571,15 @@ var decrypt_financial_uk_default = decryptFinancialUk; // helpers/decrypt-financial-international/index.ts var decryptFinancialInternational = (applicationFinancialInternational) => { try { - console.info("Decrypting financial international"); + console.info('Decrypting financial international'); const mapped = applicationFinancialInternational; const { bicSwiftCode, iban, - vector: { bicSwiftCodeVector, ibanVector } + vector: { bicSwiftCodeVector, ibanVector }, } = applicationFinancialInternational; - let decryptedIban = ""; - let decryptedBicSwiftCode = ""; + let decryptedIban = ''; + let decryptedBicSwiftCode = ''; if (bicSwiftCode && bicSwiftCodeVector) { decryptedBicSwiftCode = decrypt_default.decrypt({ value: bicSwiftCode, iv: bicSwiftCodeVector }); } @@ -5588,7 +5590,7 @@ var decryptFinancialInternational = (applicationFinancialInternational) => { mapped.iban = decryptedIban; return mapped; } catch (error) { - console.error("Error decrypting international uk %o", error); + console.error('Error decrypting international uk %o', error); throw new Error(`Error decrypting international uk ${error}`); } }; @@ -5597,26 +5599,26 @@ var decrypt_financial_international_default = decryptFinancialInternational; // helpers/decrypt-nominated-loss-payee/index.ts var decryptNominatedLossPayee = (nominatedLossPayee, decryptFinancialUk2, decryptFinancialInternational2) => { try { - console.info("Decrypting nominated loss payee %s", nominatedLossPayee.id); + console.info('Decrypting nominated loss payee %s', nominatedLossPayee.id); const mapped = { ...nominatedLossPayee, financialUk: {}, - financialInternational: {} + financialInternational: {}, }; const { financialUk, financialInternational } = nominatedLossPayee; if (decryptFinancialUk2) { - console.info("Decrypting nominated loss payee - financial - UK data %s", nominatedLossPayee.id); + console.info('Decrypting nominated loss payee - financial - UK data %s', nominatedLossPayee.id); const mappedFinancialUk = decrypt_financial_uk_default(financialUk); mapped.financialUk = mappedFinancialUk; } if (decryptFinancialInternational2) { - console.info("Decrypting nominated loss payee - financial - international data %s", nominatedLossPayee.id); + console.info('Decrypting nominated loss payee - financial - international data %s', nominatedLossPayee.id); const mappedFinancialInternational = decrypt_financial_international_default(financialInternational); mapped.financialInternational = mappedFinancialInternational; } return mapped; } catch (error) { - console.error("Error decrypting nominated loss payee %o", error); + console.error('Error decrypting nominated loss payee %o', error); throw new Error(`Error decrypting nominated loss payee ${error}`); } }; @@ -5625,10 +5627,11 @@ var decrypt_nominated_loss_payee_default = decryptNominatedLossPayee; // helpers/get-populated-application/nominated-loss-payee/index.ts var getNominatedLossPayee = async (context, lossPayeeId, decryptFinancialUk2, decryptFinancialInternational2) => { try { - console.info("Getting nominated loss payee %s", lossPayeeId); + console.info('Getting nominated loss payee %s', lossPayeeId); const nominatedLossPayee = await context.query.NominatedLossPayee.findOne({ where: { id: lossPayeeId }, - query: "id isAppointed isLocatedInUk isLocatedInternationally name financialUk { id accountNumber sortCode bankAddress vector { accountNumberVector sortCodeVector } } financialInternational { id iban bicSwiftCode bankAddress vector { bicSwiftCodeVector ibanVector } }" + query: + 'id isAppointed isLocatedInUk isLocatedInternationally name financialUk { id accountNumber sortCode bankAddress vector { accountNumberVector sortCodeVector } } financialInternational { id iban bicSwiftCode bankAddress vector { bicSwiftCodeVector ibanVector } }', }); if (decryptFinancialUk2 || decryptFinancialInternational2) { const decryptedNominatedLossPayee = decrypt_nominated_loss_payee_default(nominatedLossPayee, decryptFinancialUk2, decryptFinancialInternational2); @@ -5636,7 +5639,7 @@ var getNominatedLossPayee = async (context, lossPayeeId, decryptFinancialUk2, de } return nominatedLossPayee; } catch (error) { - console.error("Error getting nominated loss payee (getNominatedLossPayee helper) %o", error); + console.error('Error getting nominated loss payee (getNominatedLossPayee helper) %o', error); throw new Error(`Error getting nominated loss payee (getNominatedLossPayee helper) ${error}`); } }; @@ -5645,13 +5648,13 @@ var nominated_loss_payee_default = getNominatedLossPayee; // helpers/get-export-contract-by-id/index.ts var getExportContractById = async (context, id) => { try { - console.info("Getting exportContract by ID %s", id); + console.info('Getting exportContract by ID %s', id); const exportContract = await context.db.ExportContract.findOne({ - where: { id } + where: { id }, }); return exportContract; } catch (error) { - console.error("Getting exportContract by ID %s %o", id, error); + console.error('Getting exportContract by ID %s %o', id, error); throw new Error(`Error Getting exportContract by ID ${id} ${error}`); } }; @@ -5660,13 +5663,13 @@ var get_export_contract_by_id_default = getExportContractById; // helpers/get-export-contract-agent-by-id/index.ts var getExportContractAgentById = async (context, id) => { try { - console.info("Getting exportContractAgent by ID %s", id); + console.info('Getting exportContractAgent by ID %s', id); const exportContractAgent = await context.db.ExportContractAgent.findOne({ - where: { id } + where: { id }, }); return exportContractAgent; } catch (error) { - console.error("Getting exportContractAgent by ID %s %o", id, error); + console.error('Getting exportContractAgent by ID %s %o', id, error); throw new Error(`Error Getting exportContractAgent by ID ${id} ${error}`); } }; @@ -5675,13 +5678,13 @@ var get_export_contract_agent_by_id_default = getExportContractAgentById; // helpers/get-export-contract-agent-service-by-id/index.ts var getExportContractAgentServiceById = async (context, id) => { try { - console.info("Getting exportContractAgentService by ID %s", id); + console.info('Getting exportContractAgentService by ID %s', id); const exportContractAgentService = await context.db.ExportContractAgentService.findOne({ - where: { id } + where: { id }, }); return exportContractAgentService; } catch (error) { - console.error("Getting exportContractAgentService by ID %s %o", id, error); + console.error('Getting exportContractAgentService by ID %s %o', id, error); throw new Error(`Error Getting exportContractAgentService by ID ${id} ${error}`); } }; @@ -5690,13 +5693,13 @@ var get_export_contract_agent_service_by_id_default = getExportContractAgentServ // helpers/get-export-contract-agent-service-charge-by-id/index.ts var getExportContractAgentServiceChargeById = async (context, id) => { try { - console.info("Getting exportContractAgentServiceCharge by ID %s", id); + console.info('Getting exportContractAgentServiceCharge by ID %s', id); const exportContractAgentServiceCharge = await context.db.ExportContractAgentServiceCharge.findOne({ - where: { id } + where: { id }, }); return exportContractAgentServiceCharge; } catch (error) { - console.error("Getting exportContractAgentServiceCharge by ID %s %o", id, error); + console.error('Getting exportContractAgentServiceCharge by ID %s %o', id, error); throw new Error(`Error Getting exportContractAgentServiceCharge by ID ${id} ${error}`); } }; @@ -5705,7 +5708,7 @@ var get_export_contract_agent_service_charge_by_id_default = getExportContractAg // helpers/get-populated-export-contract/get-populated-agent/index.ts var getPopulatedAgent = async (context, id) => { try { - console.info("Getting populated exportContract agent %s", id); + console.info('Getting populated exportContract agent %s', id); const exportContractAgent = await get_export_contract_agent_by_id_default(context, id); const exportContractAgentService = await get_export_contract_agent_service_by_id_default(context, exportContractAgent.serviceId); const exportContractAgentServiceCharge = await get_export_contract_agent_service_charge_by_id_default(context, exportContractAgentService.chargeId); @@ -5713,12 +5716,12 @@ var getPopulatedAgent = async (context, id) => { ...exportContractAgent, service: { ...exportContractAgentService, - charge: exportContractAgentServiceCharge - } + charge: exportContractAgentServiceCharge, + }, }; return populatedAgent; } catch (error) { - console.error("Getting populated exportContract agent %s %o", id, error); + console.error('Getting populated exportContract agent %s %o', id, error); throw new Error(`Error Getting populated exportContract agent ${id} ${error}`); } }; @@ -5727,13 +5730,13 @@ var get_populated_agent_default = getPopulatedAgent; // helpers/get-private-market-by-id/index.ts var getPrivateMarketById = async (context, id) => { try { - console.info("Getting privateMarket by ID %s", id); + console.info('Getting privateMarket by ID %s', id); const privateMarket = await context.db.PrivateMarket.findOne({ - where: { id } + where: { id }, }); return privateMarket; } catch (error) { - console.error("Getting privateMarket by ID %s %o", id, error); + console.error('Getting privateMarket by ID %s %o', id, error); throw new Error(`Error Getting privateMarket by ID ${id} ${error}`); } }; @@ -5742,20 +5745,20 @@ var get_private_market_by_id_default = getPrivateMarketById; // helpers/get-populated-export-contract/index.ts var getPopulatedExportContract = async (context, id) => { try { - console.info("Getting populated exportContract %s", id); + console.info('Getting populated exportContract %s', id); const exportContract = await get_export_contract_by_id_default(context, id); const exportContractAgent = await get_populated_agent_default(context, exportContract.agentId); const privateMarket = await get_private_market_by_id_default(context, exportContract.privateMarketId); - const finalDestinationCountry = await get_country_by_field_default(context, "isoCode", exportContract.finalDestinationCountryCode); + const finalDestinationCountry = await get_country_by_field_default(context, 'isoCode', exportContract.finalDestinationCountryCode); const populatedExportContract = { ...exportContract, agent: exportContractAgent, finalDestinationCountry, - privateMarket + privateMarket, }; return populatedExportContract; } catch (error) { - console.error("Getting populated exportContract %s %o", id, error); + console.error('Getting populated exportContract %s %o', id, error); throw new Error(`Error Getting populated exportContract ${id} ${error}`); } }; @@ -5764,13 +5767,13 @@ var get_populated_export_contract_default = getPopulatedExportContract; // helpers/get-company-by-id/index.ts var getCompanyById = async (context, id) => { try { - console.info("Getting company by ID %s", id); + console.info('Getting company by ID %s', id); const company = await context.db.Company.findOne({ - where: { id } + where: { id }, }); return company; } catch (error) { - console.error("Getting company by ID %s %o", id, error); + console.error('Getting company by ID %s %o', id, error); throw new Error(`Error Getting company by ID ${id} ${error}`); } }; @@ -5779,13 +5782,13 @@ var get_company_by_id_default = getCompanyById; // helpers/get-company-address-by-id/index.ts var getCompanyAddressById = async (context, id) => { try { - console.info("Getting company address by ID %s", id); + console.info('Getting company address by ID %s', id); const companyAddress = await context.db.CompanyAddress.findOne({ - where: { id } + where: { id }, }); return companyAddress; } catch (error) { - console.error("Getting company address by ID %s %o", id, error); + console.error('Getting company address by ID %s %o', id, error); throw new Error(`Error Getting company address by ID ${id} ${error}`); } }; @@ -5794,17 +5797,17 @@ var get_company_address_by_id_default = getCompanyAddressById; // helpers/get-company-sic-codes-by-company-id/index.ts var getCompanySicCodesByCompanyId = async (context, id) => { try { - console.info("Getting company SIC codes by company ID %s", id); + console.info('Getting company SIC codes by company ID %s', id); const companySicCodes = await context.db.CompanySicCode.findMany({ where: { company: { - id: { equals: id } - } - } + id: { equals: id }, + }, + }, }); return companySicCodes; } catch (error) { - console.error("Getting company SIC codes by company ID %s %o", id, error); + console.error('Getting company SIC codes by company ID %s %o', id, error); throw new Error(`Error Getting company SIC codes by company ID ${id} ${error}`); } }; @@ -5813,13 +5816,13 @@ var get_company_sic_codes_by_company_id_default = getCompanySicCodesByCompanyId; // helpers/get-company-different-trading-address-by-id/index.ts var getCompanyDifferentTradingAddressById = async (context, id) => { try { - console.info("Getting company different trading address by ID %s", id); + console.info('Getting company different trading address by ID %s', id); const differentTradingAddress = await context.db.CompanyDifferentTradingAddress.findOne({ - where: { id } + where: { id }, }); return differentTradingAddress; } catch (error) { - console.error("Getting company different trading address by ID %s %o", id, error); + console.error('Getting company different trading address by ID %s %o', id, error); throw new Error(`Error Getting company different trading address by ID ${id} ${error}`); } }; @@ -5828,7 +5831,7 @@ var get_company_different_trading_address_by_id_default = getCompanyDifferentTra // helpers/get-populated-company/index.ts var getPopulatedCompany = async (context, id) => { try { - console.info("Getting populated company %s", id); + console.info('Getting populated company %s', id); const company = await get_company_by_id_default(context, id); const companyAddress = await get_company_address_by_id_default(context, company.registeredOfficeAddressId); const companySicCodes = await get_company_sic_codes_by_company_id_default(context, company.id); @@ -5837,11 +5840,11 @@ var getPopulatedCompany = async (context, id) => { ...company, companySicCodes, registeredOfficeAddress: companyAddress, - differentTradingAddress + differentTradingAddress, }; return populatedCompany; } catch (error) { - console.error("Getting populated company %s %o", id, error); + console.error('Getting populated company %s %o', id, error); throw new Error(`Error Getting populated company ${id} ${error}`); } }; @@ -5850,13 +5853,13 @@ var get_populated_company_default = getPopulatedCompany; // helpers/get-business-by-id/index.ts var getBusinessById = async (context, id) => { try { - console.info("Getting business by ID %s", id); + console.info('Getting business by ID %s', id); const business = await context.db.Business.findOne({ - where: { id } + where: { id }, }); return business; } catch (error) { - console.error("Getting business by ID %s %o", id, error); + console.error('Getting business by ID %s %o', id, error); throw new Error(`Error Getting business by ID ${id} ${error}`); } }; @@ -5865,13 +5868,13 @@ var get_business_by_id_default = getBusinessById; // helpers/get-broker-by-id/index.ts var getBrokerById = async (context, id) => { try { - console.info("Getting broker by ID %s", id); + console.info('Getting broker by ID %s', id); const broker = await context.db.Broker.findOne({ - where: { id } + where: { id }, }); return broker; } catch (error) { - console.error("Getting broker by ID %s %o", id, error); + console.error('Getting broker by ID %s %o', id, error); throw new Error(`Error Getting broker by ID ${id} ${error}`); } }; @@ -5880,13 +5883,13 @@ var get_broker_by_id_default = getBrokerById; // helpers/get-buyer-by-id/index.ts var getBuyerById = async (context, id) => { try { - console.info("Getting buyer by ID %s", id); + console.info('Getting buyer by ID %s', id); const buyer = await context.db.Buyer.findOne({ - where: { id } + where: { id }, }); return buyer; } catch (error) { - console.error("Getting buyer by ID %s %o", id, error); + console.error('Getting buyer by ID %s %o', id, error); throw new Error(`Error Getting buyer by ID ${id} ${error}`); } }; @@ -5895,13 +5898,13 @@ var get_buyer_by_id_default = getBuyerById; // helpers/get-country-by-id/index.ts var getCountryById = async (context, id) => { try { - console.info("Getting country by ID %s", id); + console.info('Getting country by ID %s', id); const country = await context.db.Country.findOne({ - where: { id } + where: { id }, }); return country; } catch (error) { - console.error("Getting country by ID %s %o", id, error); + console.error('Getting country by ID %s %o', id, error); throw new Error(`Error Getting country by ID ${id} ${error}`); } }; @@ -5910,13 +5913,13 @@ var get_country_by_id_default = getCountryById; // helpers/get-buyer-relationship-by-id/index.ts var getBuyerRelationshipById = async (context, id) => { try { - console.info("Getting buyer relationship by ID %s", id); + console.info('Getting buyer relationship by ID %s', id); const buyerRelationship = await context.db.BuyerRelationship.findOne({ - where: { id } + where: { id }, }); return buyerRelationship; } catch (error) { - console.error("Getting buyer relationship by ID %s %o", id, error); + console.error('Getting buyer relationship by ID %s %o', id, error); throw new Error(`Error Getting buyer relationship by ID ${id} ${error}`); } }; @@ -5925,13 +5928,13 @@ var get_buyer_relationship_by_id_default = getBuyerRelationshipById; // helpers/get-buyer-trading-history-by-id/index.ts var getBuyerTradingHistoryById = async (context, id) => { try { - console.info("Getting buyer trading history by ID %s", id); + console.info('Getting buyer trading history by ID %s', id); const buyerTradingHistory = await context.db.BuyerTradingHistory.findOne({ - where: { id } + where: { id }, }); return buyerTradingHistory; } catch (error) { - console.error("Getting buyer trading history by ID %s %o", id, error); + console.error('Getting buyer trading history by ID %s %o', id, error); throw new Error(`Error Getting buyer trading history by ID ${id} ${error}`); } }; @@ -5940,7 +5943,7 @@ var get_buyer_trading_history_by_id_default = getBuyerTradingHistoryById; // helpers/get-populated-buyer/index.ts var getPopulatedBuyer = async (context, id) => { try { - console.info("Getting populated buyer %s", id); + console.info('Getting populated buyer %s', id); const buyer = await get_buyer_by_id_default(context, id); const buyerCountry = await get_country_by_id_default(context, buyer.countryId); const buyerRelationship = await get_buyer_relationship_by_id_default(context, buyer.relationshipId); @@ -5949,11 +5952,11 @@ var getPopulatedBuyer = async (context, id) => { ...buyer, country: buyerCountry, relationship: buyerRelationship, - buyerTradingHistory + buyerTradingHistory, }; return populatedBuyer; } catch (error) { - console.error("Getting populated buyer %s %o", id, error); + console.error('Getting populated buyer %s %o', id, error); throw new Error(`Error Getting populated buyer ${id} ${error}`); } }; @@ -5962,13 +5965,13 @@ var get_populated_buyer_default = getPopulatedBuyer; // helpers/get-declaration-by-id/index.ts var getDeclarationById = async (context, id) => { try { - console.info("Getting declaration by ID %s", id); + console.info('Getting declaration by ID %s', id); const declaration = await context.db.Declaration.findOne({ - where: { id } + where: { id }, }); return declaration; } catch (error) { - console.error("Getting declaration by ID %s %o", id, error); + console.error('Getting declaration by ID %s %o', id, error); throw new Error(`Error Getting declaration by ID ${id} ${error}`); } }; @@ -5977,13 +5980,13 @@ var get_declaration_by_id_default = getDeclarationById; // helpers/get-section-review-by-id/index.ts var getSectionReviewById = async (context, id) => { try { - console.info("Getting sectionReview by ID %s", id); + console.info('Getting sectionReview by ID %s', id); const sectionReview = await context.db.SectionReview.findOne({ - where: { id } + where: { id }, }); return sectionReview; } catch (error) { - console.error("Getting sectionReview by ID %s %o", id, error); + console.error('Getting sectionReview by ID %s %o', id, error); throw new Error(`Error Getting sectionReview by ID ${id} ${error}`); } }; @@ -5999,7 +6002,7 @@ var mapPolicy = (policy) => { const mappedPolicy = { ...policy, requestedStartDate: requestedStartDate ? new Date(requestedStartDate) : null, - contractCompletionDate: contractCompletionDate ? new Date(contractCompletionDate) : null + contractCompletionDate: contractCompletionDate ? new Date(contractCompletionDate) : null, }; return mappedPolicy; }; @@ -6010,10 +6013,10 @@ var getPopulatedApplication = async ({ context, application: application2, decryptFinancialUk: decryptFinancialUk2 = false, - decryptFinancialInternational: decryptFinancialInternational2 = false + decryptFinancialInternational: decryptFinancialInternational2 = false, }) => { try { - console.info("Getting populated application (helper) %s", application2.id); + console.info('Getting populated application (helper) %s', application2.id); const { eligibilityId, ownerId, @@ -6026,7 +6029,7 @@ var getPopulatedApplication = async ({ buyerId, declarationId, nominatedLossPayeeId, - sectionReviewId + sectionReviewId, } = application2; const populatedBuyer = await get_populated_buyer_default(context, buyerId); const populatedEligibility = await get_populated_eligibility_default(context, eligibilityId, populatedBuyer.country); @@ -6056,38 +6059,46 @@ var getPopulatedApplication = async ({ policyContact, nominatedLossPayee, sectionReview, - totalContractValueOverThreshold + totalContractValueOverThreshold, }; return populatedApplication2; } catch (error) { - console.error("Getting populated application (helper) %s %o", application2.id, error); + console.error('Getting populated application (helper) %s %o', application2.id, error); throw new Error(`Error Getting populated application (helper) ${application2.id} ${error}`); } }; var populatedApplication = { - get: getPopulatedApplication + get: getPopulatedApplication, }; var get_populated_application_default = populatedApplication; // helpers/replace-character-codes-with-characters/index.ts -var replaceCharacterCodesWithCharacters = (str) => str.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(///g, "/").replace(/*/g, "*").replace(/&/g, "&"); +var replaceCharacterCodesWithCharacters = (str) => + str + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"') + .replace(/'/g, "'") + .replace(///g, '/') + .replace(/*/g, '*') + .replace(/&/g, '&'); var replace_character_codes_with_characters_default = replaceCharacterCodesWithCharacters; // helpers/get-application-submitted-email-template-ids/index.ts var { APPLICATION: { - SUBMISSION: { EXPORTER, UNDERWRITING_TEAM } - } + SUBMISSION: { EXPORTER, UNDERWRITING_TEAM }, + }, } = EMAIL_TEMPLATE_IDS; var getApplicationSubmittedEmailTemplateIds = (application2) => { const { buyer, declaration } = application2; const templateIds = { - underwritingTeam: "", - account: "" + underwritingTeam: '', + account: '', }; const { hasAntiBriberyCodeOfConduct } = declaration; const { - buyerTradingHistory: { exporterHasTradedWithBuyer } + buyerTradingHistory: { exporterHasTradedWithBuyer }, } = buyer; if (!hasAntiBriberyCodeOfConduct && !exporterHasTradedWithBuyer) { templateIds.underwritingTeam = UNDERWRITING_TEAM.NO_DOCUMENTS; @@ -6119,45 +6130,45 @@ var send4 = async (application2, xlsxPath) => { buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), buyerLocation: buyer.country?.name, companyName: replace_character_codes_with_characters_default(company.companyName), - requestedStartDate: format_date_default(policy.requestedStartDate) + requestedStartDate: format_date_default(policy.requestedStartDate), }; const sendOwnerEmailVars = { ...sharedEmailVars, buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), name: replace_character_codes_with_characters_default(get_full_name_string_default(owner)), - emailAddress: email + emailAddress: email, }; const sendContactEmailVars = { ...sharedEmailVars, buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), name: replace_character_codes_with_characters_default(get_full_name_string_default(policyContact)), - emailAddress: policyContact.email + emailAddress: policyContact.email, }; - console.info("Sending application submitted email to application account owner: %s", sendOwnerEmailVars.emailAddress); + console.info('Sending application submitted email to application account owner: %s', sendOwnerEmailVars.emailAddress); const accountSubmittedResponse = await emails_default.application.submittedEmail(sendOwnerEmailVars); if (!accountSubmittedResponse?.success) { - throw new Error("Sending application submitted email to owner/account"); + throw new Error('Sending application submitted email to owner/account'); } if (!policyContact.isSameAsOwner) { - console.info("Sending application submitted email to policy contact email: %s", sendContactEmailVars.emailAddress); + console.info('Sending application submitted email to policy contact email: %s', sendContactEmailVars.emailAddress); const contactSubmittedResponse = await emails_default.application.submittedEmail(sendContactEmailVars); if (!contactSubmittedResponse?.success) { - throw new Error("Sending application submitted email to contact"); + throw new Error('Sending application submitted email to contact'); } } const templateIds = get_application_submitted_email_template_ids_default(application2); const underwritingTeamSubmittedResponse = await emails_default.application.underwritingTeam(sendOwnerEmailVars, xlsxPath, templateIds.underwritingTeam); if (!underwritingTeamSubmittedResponse.success) { - throw new Error("Sending application submitted email to underwriting team"); + throw new Error('Sending application submitted email to underwriting team'); } if (templateIds.account) { - console.info("Sending documents email to application owner: %s", sendOwnerEmailVars.emailAddress); + console.info('Sending documents email to application owner: %s', sendOwnerEmailVars.emailAddress); const documentsResponse = await emails_default.documentsEmail(sendOwnerEmailVars, templateIds.account); if (!documentsResponse.success) { throw new Error(`Sending application documents emails ${documentsResponse}`); } if (!policyContact.isSameAsOwner) { - console.info("Sending documents email to policy contact: %s", sendContactEmailVars.emailAddress); + console.info('Sending documents email to policy contact: %s', sendContactEmailVars.emailAddress); const contactDocumentsResponse = await emails_default.documentsEmail(sendContactEmailVars, templateIds.account); if (!contactDocumentsResponse.success) { throw new Error(`Sending application documents emails to contact ${documentsResponse}`); @@ -6165,31 +6176,31 @@ var send4 = async (application2, xlsxPath) => { } } return { - success: true + success: true, }; } catch (error) { - console.error("Error sending application submitted emails %o", error); + console.error('Error sending application submitted emails %o', error); throw new Error(`Sending application submitted emails ${error}`); } }; var applicationSubmittedEmails = { - send: send4 + send: send4, }; var send_application_submitted_emails_default = applicationSubmittedEmails; // generate-xlsx/index.ts -var import_dotenv9 = __toESM(require("dotenv")); -var import_exceljs = __toESM(require("exceljs")); +var import_dotenv9 = __toESM(require('dotenv')); +var import_exceljs = __toESM(require('exceljs')); // constants/XLSX-CONFIG/SECTION_NAMES/index.ts var SECTION_NAMES = { - APPLICATION_INFORMATION: "Application Information", - ELIGIBILITY: "Eligibility", - EXPORTER_BUSINESS: "The Business", - BUYER: "The Buyer", - POLICY: "Insurance Policy", - EXPORT_CONTRACT: "Export Contract", - DECLARATIONS: "Declarations" + APPLICATION_INFORMATION: 'Application Information', + ELIGIBILITY: 'Eligibility', + EXPORTER_BUSINESS: 'The Business', + BUYER: 'The Buyer', + POLICY: 'Insurance Policy', + EXPORT_CONTRACT: 'Export Contract', + DECLARATIONS: 'Declarations', }; var SECTION_NAMES_default = SECTION_NAMES; @@ -6200,66 +6211,69 @@ var { AGREE_ANTI_BRIBERY, HAS_ANTI_BRIBERY_CODE_OF_CONDUCT, AGREE_CONFIRMATION_ACKNOWLEDGEMENTS, - WILL_EXPORT_WITH_CODE_OF_CONDUCT - } + WILL_EXPORT_WITH_CODE_OF_CONDUCT, + }, } = insurance_default; var DECLARATIONS_FIELDS = { [AGREE_CONFIDENTIALITY]: { SUMMARY: { - TITLE: "Confidentiality" - } + TITLE: 'Confidentiality', + }, }, [AGREE_ANTI_BRIBERY]: { SUMMARY: { - TITLE: "Anti-bribery and corruption" - } + TITLE: 'Anti-bribery and corruption', + }, }, [HAS_ANTI_BRIBERY_CODE_OF_CONDUCT]: { SUMMARY: { - TITLE: "Do you have a code of conduct?" - } + TITLE: 'Do you have a code of conduct?', + }, }, [WILL_EXPORT_WITH_CODE_OF_CONDUCT]: { SUMMARY: { - TITLE: "Will you export using your code of conduct?" - } + TITLE: 'Will you export using your code of conduct?', + }, }, [AGREE_CONFIRMATION_ACKNOWLEDGEMENTS]: { SUMMARY: { - TITLE: "Confirmation and acknowledgements" - } - } + TITLE: 'Confirmation and acknowledgements', + }, + }, }; // content-strings/links.ts var LINKS = { EXTERNAL: { - GUIDANCE: "https://www.gov.uk/guidance/credit-insurance-policy#eligibility", - BEFORE_YOU_START: "https://www.gov.uk/guidance/get-a-quote-for-ukef-credit-insurance", - PRIVACY: "https://www.gov.uk/government/publications/ukef-privacy-notice/ukef-privacy-notice--2", - FEEDBACK: "https://forms.office.com/r/TacytrRCgJ", - RESEARCH: "https://forms.office.com/pages/responsepage.aspx?id=jhOEgACUnkCm2ka1KB4LCkj8OKxLpCpDmTbrMyQ3j2JUOUFHNUc0QUhUOFdLNkJXWkRUS0wyMUZFNiQlQCN0PWcu", - EXPORT_FINANCE_MANAGERS: "https://www.gov.uk/government/publications/find-an-export-finance-manager", - APPROVED_BROKER_LIST: "https://www.gov.uk/government/publications/uk-export-finance-insurance-list-of-approved-brokers/export-insurance-approved-brokers", - PROPOSAL_FORM: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1075267/10489_UKEF_Export_Insurance_Proposal_Form_20220513-fillable.pdf", - NBI_FORM: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1041659/export-insurance-non-binding-indication-request-form_20170609.pdf", - FULL_APPLICATION: "https://www.gov.uk/guidance/apply-for-ukef-credit-insurance", - ABILITY_NET: "https://mcmw.abilityNet.org.uk", - EQUALITY_ADVISORY_SERVICE: "https://www.equalityadvisoryservice.com", - ACCESSIBILITY_GUIDLINES: "https://www.w3.org/TR/WCAG21", - BRIBERY_ACT_2010_GUIDANCE: "https://www.justice.gov.uk/downloads/legislation/bribery-act-2010-guidance.pdf", - ICO_MAKE_A_COMPLAINT: "https://ico.org.uk/make-a-complaint", - COMPANIES_HOUSE: "https://find-and-update.company-information.service.gov.uk" - } + GUIDANCE: 'https://www.gov.uk/guidance/credit-insurance-policy#eligibility', + BEFORE_YOU_START: 'https://www.gov.uk/guidance/get-a-quote-for-ukef-credit-insurance', + PRIVACY: 'https://www.gov.uk/government/publications/ukef-privacy-notice/ukef-privacy-notice--2', + FEEDBACK: 'https://forms.office.com/r/TacytrRCgJ', + RESEARCH: 'https://forms.office.com/pages/responsepage.aspx?id=jhOEgACUnkCm2ka1KB4LCkj8OKxLpCpDmTbrMyQ3j2JUOUFHNUc0QUhUOFdLNkJXWkRUS0wyMUZFNiQlQCN0PWcu', + EXPORT_FINANCE_MANAGERS: 'https://www.gov.uk/government/publications/find-an-export-finance-manager', + APPROVED_BROKER_LIST: 'https://www.gov.uk/government/publications/uk-export-finance-insurance-list-of-approved-brokers/export-insurance-approved-brokers', + PROPOSAL_FORM: + 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1075267/10489_UKEF_Export_Insurance_Proposal_Form_20220513-fillable.pdf', + NBI_FORM: + 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1041659/export-insurance-non-binding-indication-request-form_20170609.pdf', + FULL_APPLICATION: 'https://www.gov.uk/guidance/apply-for-ukef-credit-insurance', + ABILITY_NET: 'https://mcmw.abilityNet.org.uk', + EQUALITY_ADVISORY_SERVICE: 'https://www.equalityadvisoryservice.com', + ACCESSIBILITY_GUIDLINES: 'https://www.w3.org/TR/WCAG21', + BRIBERY_ACT_2010_GUIDANCE: 'https://www.justice.gov.uk/downloads/legislation/bribery-act-2010-guidance.pdf', + ICO_MAKE_A_COMPLAINT: 'https://ico.org.uk/make-a-complaint', + COMPANIES_HOUSE: 'https://find-and-update.company-information.service.gov.uk', + }, }; // helpers/format-currency/index.ts -var formatCurrency = (number, currencyCode, decimalPlaces) => number.toLocaleString("en", { - style: "currency", - currency: currencyCode, - minimumFractionDigits: decimalPlaces ?? 0, - maximumFractionDigits: decimalPlaces ?? 0 -}); +var formatCurrency = (number, currencyCode, decimalPlaces) => + number.toLocaleString('en', { + style: 'currency', + currency: currencyCode, + minimumFractionDigits: decimalPlaces ?? 0, + maximumFractionDigits: decimalPlaces ?? 0, + }); var format_currency_default = formatCurrency; // content-strings/fields/insurance/eligibility/index.ts @@ -6271,91 +6285,91 @@ var { COMPANIES_HOUSE_NUMBER, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE_FIELD_ID, HAS_END_BUYER, - HAS_COMPANIES_HOUSE_NUMBER + HAS_COMPANIES_HOUSE_NUMBER, } = insurance_default.ELIGIBILITY; var { COMPANY_NAME } = insurance_default.COMPANIES_HOUSE; var THRESHOLD = format_currency_default(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); var ELIGIBILITY_FIELDS = { [BUYER_COUNTRY]: { SUMMARY: { - TITLE: "Buyer location" - } + TITLE: 'Buyer location', + }, }, [VALID_EXPORTER_LOCATION]: { SUMMARY: { - TITLE: "In UK, Channel Islands or Isle of Man" - } + TITLE: 'In UK, Channel Islands or Isle of Man', + }, }, [HAS_MINIMUM_UK_GOODS_OR_SERVICES]: { SUMMARY: { - TITLE: "UK goods or services" + TITLE: 'UK goods or services', }, - ANSWER: "At least 20%" + ANSWER: 'At least 20%', }, [HAS_END_BUYER]: { HINT: "Sometimes, exporters supply goods to a client in an overseas market who will then sell them on. The exporter will not get paid by the buyer until they have been paid by this third party. We call this third party an 'end buyer'.", SUMMARY: { - TITLE: "End buyer" - } + TITLE: 'End buyer', + }, }, [COVER_PERIOD_FIELD_ID]: { OPTIONS: { BELOW: { ID: COVER_PERIOD.LESS_THAN_2_YEARS.DB_ID, VALUE: COVER_PERIOD.LESS_THAN_2_YEARS.DB_ID, - TEXT: COVER_PERIOD.LESS_THAN_2_YEARS.VALUE + TEXT: COVER_PERIOD.LESS_THAN_2_YEARS.VALUE, }, ABOVE: { ID: COVER_PERIOD.MORE_THAN_2_YEARS.DB_ID, VALUE: COVER_PERIOD.MORE_THAN_2_YEARS.DB_ID, - TEXT: COVER_PERIOD.MORE_THAN_2_YEARS.VALUE - } + TEXT: COVER_PERIOD.MORE_THAN_2_YEARS.VALUE, + }, }, SUMMARY: { - TITLE: "Length of policy" - } + TITLE: 'Length of policy', + }, }, [COMPANIES_HOUSE_NUMBER]: { HINT: { INTRO: "For example, 8989898 or SC907816. You'll find it on your incorporation certificate or on the", LINK: { - TEXT: "Companies House website", - HREF: LINKS.EXTERNAL.COMPANIES_HOUSE - } + TEXT: 'Companies House website', + HREF: LINKS.EXTERNAL.COMPANIES_HOUSE, + }, }, SUMMARY: { - TITLE: "UK Companies House number" - } + TITLE: 'UK Companies House number', + }, }, [HAS_COMPANIES_HOUSE_NUMBER]: { SUMMARY: { - TITLE: "UK Companies House registration number and actively trading" - } + TITLE: 'UK Companies House registration number and actively trading', + }, }, [COMPANY_NAME]: { SUMMARY: { - TITLE: "Company name" - } + TITLE: 'Company name', + }, }, [TOTAL_CONTRACT_VALUE_FIELD_ID]: { OPTIONS: { ABOVE: { ID: TOTAL_CONTRACT_VALUE.MORE_THAN_250K.DB_ID, VALUE: TOTAL_CONTRACT_VALUE.MORE_THAN_250K.DB_ID, - TEXT: `${THRESHOLD} and above` + TEXT: `${THRESHOLD} and above`, }, BELOW: { ID: TOTAL_CONTRACT_VALUE.LESS_THAN_250K.DB_ID, VALUE: TOTAL_CONTRACT_VALUE.LESS_THAN_250K.DB_ID, - TEXT: `Less than ${THRESHOLD}` - } + TEXT: `Less than ${THRESHOLD}`, + }, }, SUMMARY: { - TITLE: "Total value to insure", + TITLE: 'Total value to insure', ABOVE: `Above ${THRESHOLD}`, - BELOW: `Below ${THRESHOLD}` - } - } + BELOW: `Below ${THRESHOLD}`, + }, + }, }; // content-strings/fields/insurance/export-contract/index.ts @@ -6364,114 +6378,114 @@ var { HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD }, ABOUT_GOODS_OR_SERVICES: { DESCRIPTION, FINAL_DESTINATION_KNOWN, FINAL_DESTINATION }, HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION }, - PRIVATE_MARKET: { DECLINED_DESCRIPTION } + PRIVATE_MARKET: { DECLINED_DESCRIPTION }, } = export_contract_default; var EXPORT_CONTRACT_FIELDS = { HOW_WAS_THE_CONTRACT_AWARDED: { [AWARD_METHOD]: { - LEGEND: "How was the contract awarded?", + LEGEND: 'How was the contract awarded?', OPTIONS: { OPEN_TENDER: { ID: OPEN_TENDER.DB_ID, VALUE: OPEN_TENDER.DB_ID, - TEXT: OPEN_TENDER.VALUE + TEXT: OPEN_TENDER.VALUE, }, NEGOTIATED_CONTRACT: { ID: NEGOTIATED_CONTRACT.DB_ID, VALUE: NEGOTIATED_CONTRACT.DB_ID, - TEXT: NEGOTIATED_CONTRACT.VALUE + TEXT: NEGOTIATED_CONTRACT.VALUE, }, DIRECT_AWARD: { ID: DIRECT_AWARD.DB_ID, VALUE: DIRECT_AWARD.DB_ID, - TEXT: DIRECT_AWARD.VALUE + TEXT: DIRECT_AWARD.VALUE, }, COMPETITIVE_BIDDING: { ID: COMPETITIVE_BIDDING.DB_ID, VALUE: COMPETITIVE_BIDDING.DB_ID, - TEXT: COMPETITIVE_BIDDING.VALUE + TEXT: COMPETITIVE_BIDDING.VALUE, }, OTHER: { ID: OTHER.DB_ID, VALUE: OTHER.DB_ID, - TEXT: OTHER.VALUE - } + TEXT: OTHER.VALUE, + }, }, SUMMARY: { - TITLE: "How was the contract awarded" - } - } + TITLE: 'How was the contract awarded', + }, + }, }, ABOUT_GOODS_OR_SERVICES: { [DESCRIPTION]: { LABEL: "Describe the goods or services you're exporting and explain how they'll be used by the buyer", HINT: { - INTRO: "For example:", + INTRO: 'For example:', LIST: [ - "fast moving consumer goods, like vegan protein bars", - "construction materials to build commercial property", - "educational services such as teacher training" + 'fast moving consumer goods, like vegan protein bars', + 'construction materials to build commercial property', + 'educational services such as teacher training', ], - OUTRO: "We may contact you to get more information if you're exporting goods or services that might have an impact on the environment." + OUTRO: "We may contact you to get more information if you're exporting goods or services that might have an impact on the environment.", }, MAXIMUM: 1e3, SUMMARY: { - TITLE: "Goods or services you're exporting" - } + TITLE: "Goods or services you're exporting", + }, }, [FINAL_DESTINATION_KNOWN]: { - LABEL: "Do you know the final destination of the goods or services?" + LABEL: 'Do you know the final destination of the goods or services?', }, [FINAL_DESTINATION]: { LABEL: "What's the final destination of the goods or services?", SUMMARY: { - TITLE: "Final destination of goods or services" - } - } + TITLE: 'Final destination of goods or services', + }, + }, }, HOW_WILL_YOU_GET_PAID: { [PAYMENT_TERMS_DESCRIPTION]: { HINT: { - INTRO: "Types of payment terms include:", - LIST: ["payments that are due within 60 days from date of invoice", "payments collected by a letter of credit", "staged payments"], - OUTRO: "If you use staged payments, explain their structure and whether they're monthly, in advance or something else." - } - } + INTRO: 'Types of payment terms include:', + LIST: ['payments that are due within 60 days from date of invoice', 'payments collected by a letter of credit', 'staged payments'], + OUTRO: "If you use staged payments, explain their structure and whether they're monthly, in advance or something else.", + }, + }, }, PRIVATE_MARKET: { [DECLINED_DESCRIPTION]: { - HINT: "Tell us about the best quote you received and why you were unable to use it. For example, your current policy might not cover the country you're exporting to." - } - } + HINT: "Tell us about the best quote you received and why you were unable to use it. For example, your current policy might not cover the country you're exporting to.", + }, + }, }; // content-strings/form-titles.ts var FORM_TITLES = { YOUR_BUSINESS: { - COMPANY_DETAILS: "Company details", - NATURE_OF_BUSINESS: "Nature of your business", - TURNOVER: "Turnover", - CREDIT_CONTROL: "Credit control" + COMPANY_DETAILS: 'Company details', + NATURE_OF_BUSINESS: 'Nature of your business', + TURNOVER: 'Turnover', + CREDIT_CONTROL: 'Credit control', }, YOUR_BUYER: { - COMPANY_DETAILS: "Company details", - CONNECTION_TO_BUYER: "Connection to the buyer", - TRADING_HISTORY: "Trading history", - CREDIT_INSURANCE_HISTORY: "Credit insurance history", - FINANCIAL_ACCOUNTS: "Financial accounts" + COMPANY_DETAILS: 'Company details', + CONNECTION_TO_BUYER: 'Connection to the buyer', + TRADING_HISTORY: 'Trading history', + CREDIT_INSURANCE_HISTORY: 'Credit insurance history', + FINANCIAL_ACCOUNTS: 'Financial accounts', }, POLICY: { - CONTRACT_POLICY: "Requested insurance policy", - NAME_ON_POLICY: "Named person on the policy", - BROKER: "Broker", - OTHER_COMPANY: "Other company to be insured", - LOSS_PAYEE: "Loss payee" + CONTRACT_POLICY: 'Requested insurance policy', + NAME_ON_POLICY: 'Named person on the policy', + BROKER: 'Broker', + OTHER_COMPANY: 'Other company to be insured', + LOSS_PAYEE: 'Loss payee', }, EXPORT_CONTRACT: { - ABOUT_THE_EXPORT: "About the export", - PRIVATE_MARKET: "Private insurance market", - AGENT: "Agent" - } + ABOUT_THE_EXPORT: 'About the export', + PRIVATE_MARKET: 'Private insurance market', + AGENT: 'Agent', + }, }; // content-strings/fields/insurance/policy/index.ts @@ -6495,12 +6509,12 @@ var { LOSS_PAYEE_DETAILS: { NAME: LOSS_PAYEE_NAME, LOCATION, IS_LOCATED_IN_UK, IS_LOCATED_INTERNATIONALLY }, LOSS_PAYEE_FINANCIAL_UK: { SORT_CODE, ACCOUNT_NUMBER }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { BIC_SWIFT_CODE, IBAN }, - FINANCIAL_ADDRESS - } + FINANCIAL_ADDRESS, + }, } = insurance_default; var { MAX_COVER_PERIOD_MONTHS } = ELIGIBILITY; var { - POLICY: { TOTAL_MONTHS_OF_COVER } + POLICY: { TOTAL_MONTHS_OF_COVER }, } = APPLICATION; var { POLICY: POLICY_FORM_TITLES } = FORM_TITLES; var POLICY_FIELDS = { @@ -6510,424 +6524,432 @@ var POLICY_FIELDS = { SINGLE: { ID: SINGLE_POLICY_TYPE, VALUE: FIELD_VALUES.POLICY_TYPE.SINGLE, - TEXT: "Single contract policy", + TEXT: 'Single contract policy', HINT_LIST: [ - "Covers a single contract with a buyer, for one or more shipments", + 'Covers a single contract with a buyer, for one or more shipments', `Cover for up to ${MAX_COVER_PERIOD_MONTHS} months`, - "Best for a one off- project, when you know the exact value of your export contract now", - "You pay for the insurance before the policy starts" - ] + 'Best for a one off- project, when you know the exact value of your export contract now', + 'You pay for the insurance before the policy starts', + ], }, MULTIPLE: { ID: MULTIPLE_POLICY_TYPE, VALUE: FIELD_VALUES.POLICY_TYPE.MULTIPLE, - TEXT: "Multiple contract policy (Revolving credit)", + TEXT: 'Multiple contract policy (Revolving credit)', HINT_LIST: [ `Covers multiple contracts with the same buyer, usually for ${TOTAL_MONTHS_OF_COVER.MAXIMUM} months`, "Best if you'll have an ongoing relationship with the buyer but you're not sure yet how many contracts or sales you'll have", - "You only pay for your insurance each time you declare a new contract or sale - no need to pay before the policy starts" - ] - } + 'You only pay for your insurance each time you declare a new contract or sale - no need to pay before the policy starts', + ], + }, }, SUMMARY: { - TITLE: "Policy type", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } + TITLE: 'Policy type', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, }, CONTRACT_POLICY: { [CONTRACT_POLICY.REQUESTED_START_DATE]: { - LABEL: "When do you want your policy to start?", - HINT: "For example, 06 11 2023", + LABEL: 'When do you want your policy to start?', + HINT: 'For example, 06 11 2023', SUMMARY: { - TITLE: "Policy start date", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } + TITLE: 'Policy start date', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, }, [CURRENCY_CODE]: { LEGEND: "Select currency you'd like your policy to be issued in", - HINT: "This is the currency your policy will be issued in", + HINT: 'This is the currency your policy will be issued in', SUMMARY: { - TITLE: "Policy currency", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + TITLE: 'Policy currency', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, }, [ALTERNATIVE_CURRENCY_CODE]: { ID: ALTERNATIVE_CURRENCY_CODE, - VALUE: ALTERNATIVE_CURRENCY_CODE - } + VALUE: ALTERNATIVE_CURRENCY_CODE, + }, }, SINGLE: { [CONTRACT_POLICY.SINGLE.CONTRACT_COMPLETION_DATE]: { - LABEL: "When do you expect to complete the export contract?", - HINT: "For example, 06 11 2024", + LABEL: 'When do you expect to complete the export contract?', + HINT: 'For example, 06 11 2024', SUMMARY: { - TITLE: "Date you expect it to complete", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } + TITLE: 'Date you expect it to complete', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, }, [CONTRACT_POLICY.SINGLE.TOTAL_CONTRACT_VALUE]: { LABEL: "What's the total value of the contract you want to insure?", - HINT: "Enter a whole number. Do not enter decimals.", + HINT: 'Enter a whole number. Do not enter decimals.', SUMMARY: { - TITLE: "Contract value", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } + TITLE: 'Contract value', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, }, [CONTRACT_POLICY.SINGLE.REQUESTED_CREDIT_LIMIT]: { - LABEL: "What credit limit do you require?", + LABEL: 'What credit limit do you require?', HINT: { - INTRO: "For example, your total contract maybe \xA3250,000 but the amount you want to insure is \xA3100,000.", - OUTRO: "Enter a whole number. Do not enter decimals." + INTRO: 'For example, your total contract maybe \xA3250,000 but the amount you want to insure is \xA3100,000.', + OUTRO: 'Enter a whole number. Do not enter decimals.', }, SUMMARY: { - TITLE: "Credit limit", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } - } + TITLE: 'Credit limit', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, + }, }, MULTIPLE: { [CONTRACT_POLICY.MULTIPLE.TOTAL_MONTHS_OF_COVER]: { - LABEL: "How many months do you want to be insured for?", + LABEL: 'How many months do you want to be insured for?', HINT: `The maximum is ${TOTAL_MONTHS_OF_COVER.MAXIMUM} months.`, OPTIONS: FIELD_VALUES.TOTAL_MONTHS_OF_COVER, SUMMARY: { - TITLE: "How many months you want to be insured for", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } - } - } + TITLE: 'How many months you want to be insured for', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, + }, + }, }, EXPORT_VALUE: { MULTIPLE: { [EXPORT_VALUE.MULTIPLE.TOTAL_SALES_TO_BUYER]: { - LABEL: "Estimate total sales to your buyer during this time", - HINT: "Enter a whole number. Do not enter decimals.", + LABEL: 'Estimate total sales to your buyer during this time', + HINT: 'Enter a whole number. Do not enter decimals.', SUMMARY: { - TITLE: "Estimated total sales to the buyer", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } + TITLE: 'Estimated total sales to the buyer', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, }, [EXPORT_VALUE.MULTIPLE.MAXIMUM_BUYER_WILL_OWE]: { - LABEL: "Estimate the maximum amount your buyer will owe you at any single point during this time", + LABEL: 'Estimate the maximum amount your buyer will owe you at any single point during this time', HINT: { - FOR_EXAMPLE: "For example, your total sales might be \xA3250,000 but the maximum the buyer will owe you at any single point is \xA3100,000.", - NO_DECIMALS: "Enter a whole number. Do not enter decimals." + FOR_EXAMPLE: 'For example, your total sales might be \xA3250,000 but the maximum the buyer will owe you at any single point is \xA3100,000.', + NO_DECIMALS: 'Enter a whole number. Do not enter decimals.', }, SUMMARY: { - TITLE: "Estimated maximum amount owed by the buyer", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } - } - } + TITLE: 'Estimated maximum amount owed by the buyer', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, + }, + }, }, NAME_ON_POLICY: { OPTIONS: { SAME_NAME: { ID: NAME_ON_POLICY.SAME_NAME, - VALUE: NAME_ON_POLICY.SAME_NAME + VALUE: NAME_ON_POLICY.SAME_NAME, }, OTHER_NAME: { ID: NAME_ON_POLICY.OTHER_NAME, VALUE: NAME_ON_POLICY.OTHER_NAME, - TEXT: "Someone else" - } + TEXT: 'Someone else', + }, }, [NAME_ON_POLICY.POSITION]: { LABEL: "What's your position at the company?", MAXIMUM: MAXIMUM_CHARACTERS.NAME_ON_POLICY_POSITION, SUMMARY: { - TITLE: "Position at company", - FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY - } + TITLE: 'Position at company', + FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY, + }, }, [NAME_ON_POLICY.NAME]: { SUMMARY: { - TITLE: "Contact name", - FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY - } - } + TITLE: 'Contact name', + FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY, + }, + }, }, DIFFERENT_NAME_ON_POLICY: { [DIFFERENT_NAME_ON_POLICY.POSITION]: { - LABEL: "Position at company", - MAXIMUM: MAXIMUM_CHARACTERS.DIFFERENT_NAME_ON_POLICY + LABEL: 'Position at company', + MAXIMUM: MAXIMUM_CHARACTERS.DIFFERENT_NAME_ON_POLICY, }, [EMAIL3]: { SUMMARY: { - TITLE: "Contact email", - FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY - } - } + TITLE: 'Contact email', + FORM_TITLE: POLICY_FORM_TITLES.NAME_ON_POLICY, + }, + }, }, [NEED_PRE_CREDIT_PERIOD]: { - HINT: "This is known as the pre-credit period", + HINT: 'This is known as the pre-credit period', SUMMARY: { - TITLE: "Pre-credit period", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY - } + TITLE: 'Pre-credit period', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, + }, }, [CREDIT_PERIOD_WITH_BUYER]: { - LABEL: "How long do you need pre-credit cover for?", + LABEL: 'How long do you need pre-credit cover for?', SUMMARY: { - TITLE: "Period of pre-credit cover", - FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY + TITLE: 'Period of pre-credit cover', + FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY, }, - MAXIMUM: MAXIMUM_CHARACTERS.CREDIT_PERIOD_WITH_BUYER + MAXIMUM: MAXIMUM_CHARACTERS.CREDIT_PERIOD_WITH_BUYER, }, REQUESTED_JOINTLY_INSURED_PARTY: { [REQUESTED]: { - HINT: "This could be a parent company, subsidiary or a subcontractor.", + HINT: 'This could be a parent company, subsidiary or a subcontractor.', SUMMARY: { - TITLE: "Another company to be insured" - } + TITLE: 'Another company to be insured', + }, }, [COMPANY_NAME2]: { - LABEL: "Name of the other company", + LABEL: 'Name of the other company', MAXIMUM: MAXIMUM_CHARACTERS.REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NAME, SUMMARY: { - TITLE: "Name of the other company" - } + TITLE: 'Name of the other company', + }, }, [COMPANY_NUMBER]: { - LABEL: "Registration number of the other company (optional)", + LABEL: 'Registration number of the other company (optional)', MAXIMUM: MAXIMUM_CHARACTERS.REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NUMBER, SUMMARY: { - TITLE: "Registration number of the other company" - } + TITLE: 'Registration number of the other company', + }, }, [COUNTRY_CODE]: { - LABEL: "What country is the other company based in?", + LABEL: 'What country is the other company based in?', SUMMARY: { - TITLE: "Country of the company" - } - } + TITLE: 'Country of the company', + }, + }, }, BROKER: { [USING_BROKER]: { - LABEL: "Are you using a broker to get this insurance?", + LABEL: 'Are you using a broker to get this insurance?', SUMMARY: { - TITLE: "Using a broker", - FORM_TITLE: POLICY_FORM_TITLES.BROKER - } - } + TITLE: 'Using a broker', + FORM_TITLE: POLICY_FORM_TITLES.BROKER, + }, + }, }, BROKER_DETAILS: { [NAME]: { - LABEL: "Name of broker or company", + LABEL: 'Name of broker or company', MAXIMUM: MAXIMUM_CHARACTERS.BROKER_NAME, SUMMARY: { TITLE: "Broker's name or company", - FORM_TITLE: POLICY_FORM_TITLES.BROKER - } + FORM_TITLE: POLICY_FORM_TITLES.BROKER, + }, }, [EMAIL3]: { - LABEL: "Email address", + LABEL: 'Email address', SUMMARY: { TITLE: "Broker's email", - FORM_TITLE: POLICY_FORM_TITLES.BROKER - } + FORM_TITLE: POLICY_FORM_TITLES.BROKER, + }, }, [FULL_ADDRESS]: { LABEL: "Broker's address", SUMMARY: { TITLE: "Broker's address", - FORM_TITLE: POLICY_FORM_TITLES.BROKER + FORM_TITLE: POLICY_FORM_TITLES.BROKER, }, - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS - } + MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, + }, }, LOSS_PAYEE: { [IS_APPOINTED]: { HINT: { - INTRO: "A loss payee is a financial organisation, like a bank or a lender, who will be paid in the event of a valid claim. A loss payee could also be a parent company or subsidiary of your business.", - OUTRO: "Not every policy has a loss payee. If you don't, select 'No' and you will be listed as the default claimant." + INTRO: + 'A loss payee is a financial organisation, like a bank or a lender, who will be paid in the event of a valid claim. A loss payee could also be a parent company or subsidiary of your business.', + OUTRO: "Not every policy has a loss payee. If you don't, select 'No' and you will be listed as the default claimant.", }, SUMMARY: { - TITLE: "Appointed a loss payee", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } - } + TITLE: 'Appointed a loss payee', + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, + }, }, LOSS_PAYEE_DETAILS: { [LOSS_PAYEE_NAME]: { - LABEL: "Name of the loss payee", + LABEL: 'Name of the loss payee', MAXIMUM: MAXIMUM_CHARACTERS.LOSS_PAYEE_NAME, SUMMARY: { - TITLE: "Name of the loss payee", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } + TITLE: 'Name of the loss payee', + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, }, [LOCATION]: { - LABEL: "Where is the loss payee located?", + LABEL: 'Where is the loss payee located?', OPTIONS: { UK: { ID: IS_LOCATED_IN_UK, VALUE: IS_LOCATED_IN_UK, - TEXT: "United Kingdom" + TEXT: 'United Kingdom', }, INTERNATIONALLY: { ID: IS_LOCATED_INTERNATIONALLY, VALUE: IS_LOCATED_INTERNATIONALLY, - TEXT: "International" - } - } - } + TEXT: 'International', + }, + }, + }, }, LOSS_PAYEE_FINANCIAL_UK: { [SORT_CODE]: { - LABEL: "Sort code", - HINT: "Must be 6 digits long", + LABEL: 'Sort code', + HINT: 'Must be 6 digits long', SUMMARY: { - TITLE: "Sort code", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } + TITLE: 'Sort code', + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, }, [ACCOUNT_NUMBER]: { - LABEL: "Account number", - HINT: "Must be between 6 and 8 digits long", + LABEL: 'Account number', + HINT: 'Must be between 6 and 8 digits long', SUMMARY: { - TITLE: "Account number", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } + TITLE: 'Account number', + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, }, [FINANCIAL_ADDRESS]: { SUMMARY: { TITLE: "Loss payee's bank based in the UK", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } - } + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, + }, }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { [BIC_SWIFT_CODE]: { - LABEL: "BIC or SWIFT code", - HINT: "Must be between 8 and 11 characters long", + LABEL: 'BIC or SWIFT code', + HINT: 'Must be between 8 and 11 characters long', SUMMARY: { - TITLE: "BIC or SWIFT code", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } + TITLE: 'BIC or SWIFT code', + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, }, [IBAN]: { - LABEL: "IBAN", - HINT: "Must be between 16 and 34 characters long", + LABEL: 'IBAN', + HINT: 'Must be between 16 and 34 characters long', SUMMARY: { - TITLE: "IBAN", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } + TITLE: 'IBAN', + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, }, [FINANCIAL_ADDRESS]: { SUMMARY: { TITLE: "Loss payee's bank based internationally", - FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE - } - } + FORM_TITLE: POLICY_FORM_TITLES.LOSS_PAYEE, + }, + }, }, FINANCIAL_ADDRESS: { - LABEL: "Bank address", - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS - } + LABEL: 'Bank address', + MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, + }, }; // content-strings/fields/insurance/your-business/index.ts var { - COMPANIES_HOUSE: { COMPANY_NAME: COMPANY_NAME3, COMPANY_NUMBER: COMPANY_NUMBER2, COMPANY_INCORPORATED, COMPANY_SIC, COMPANY_ADDRESS, FINANCIAL_YEAR_END_DATE }, - EXPORTER_BUSINESS: EXPORTER_BUSINESS2 + COMPANIES_HOUSE: { + COMPANY_NAME: COMPANY_NAME3, + COMPANY_NUMBER: COMPANY_NUMBER2, + COMPANY_INCORPORATED, + COMPANY_SIC, + COMPANY_ADDRESS, + FINANCIAL_YEAR_END_DATE, + }, + EXPORTER_BUSINESS: EXPORTER_BUSINESS2, } = insurance_default; var { YOUR_COMPANY: { HAS_DIFFERENT_TRADING_ADDRESS, HAS_DIFFERENT_TRADING_NAME, PHONE_NUMBER, WEBSITE }, ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: FULL_ADDRESS2 }, NATURE_OF_YOUR_BUSINESS: { GOODS_OR_SERVICES, YEARS_EXPORTING, EMPLOYEES_UK }, TURNOVER: { ESTIMATED_ANNUAL_TURNOVER, PERCENTAGE_TURNOVER }, - HAS_CREDIT_CONTROL + HAS_CREDIT_CONTROL, } = EXPORTER_BUSINESS2; var EXPORTER_BUSINESS_FIELDS = { COMPANY_DETAILS: { [COMPANY_NUMBER2]: { SUMMARY: { - TITLE: "Companies House registration number" - } + TITLE: 'Companies House registration number', + }, }, [COMPANY_NAME3]: { SUMMARY: { - TITLE: "Company name" - } + TITLE: 'Company name', + }, }, [COMPANY_ADDRESS]: { SUMMARY: { - TITLE: "Registered office address" - } + TITLE: 'Registered office address', + }, }, [COMPANY_INCORPORATED]: { SUMMARY: { - TITLE: "Date incorporated" - } + TITLE: 'Date incorporated', + }, }, [COMPANY_SIC]: { SUMMARY: { - TITLE: "Standard industry classification (SIC) codes and nature of business" - } + TITLE: 'Standard industry classification (SIC) codes and nature of business', + }, }, [FINANCIAL_YEAR_END_DATE]: { SUMMARY: { - TITLE: "Financial year end date" - } + TITLE: 'Financial year end date', + }, }, [HAS_DIFFERENT_TRADING_NAME]: { SUMMARY: { - TITLE: "Different trading name" - } + TITLE: 'Different trading name', + }, }, [HAS_DIFFERENT_TRADING_ADDRESS]: { SUMMARY: { - TITLE: "Different trading address" - } + TITLE: 'Different trading address', + }, }, [WEBSITE]: { SUMMARY: { - TITLE: "Company website (optional)" - } + TITLE: 'Company website (optional)', + }, }, [PHONE_NUMBER]: { SUMMARY: { - TITLE: "UK telephone number (optional)" - } - } + TITLE: 'UK telephone number (optional)', + }, + }, }, [FULL_ADDRESS2]: { - LABEL: "What's your alternative trading address?" + LABEL: "What's your alternative trading address?", }, NATURE_OF_YOUR_BUSINESS: { [GOODS_OR_SERVICES]: { SUMMARY: { - TITLE: "Goods or services your business supplies" - } + TITLE: 'Goods or services your business supplies', + }, }, [YEARS_EXPORTING]: { SUMMARY: { - TITLE: "Years exporting" - } + TITLE: 'Years exporting', + }, }, [EMPLOYEES_UK]: { SUMMARY: { - TITLE: "Number of UK employees" - } - } + TITLE: 'Number of UK employees', + }, + }, }, TURNOVER: { [ESTIMATED_ANNUAL_TURNOVER]: { SUMMARY: { - TITLE: "Estimated turnover this current financial year" - } + TITLE: 'Estimated turnover this current financial year', + }, }, [PERCENTAGE_TURNOVER]: { SUMMARY: { - TITLE: "Percentage of turnover from exports" - } - } + TITLE: 'Percentage of turnover from exports', + }, + }, }, [HAS_CREDIT_CONTROL]: { SUMMARY: { - TITLE: "Process for managing late payments" - } - } + TITLE: 'Process for managing late payments', + }, + }, }; // content-strings/fields/insurance/your-buyer/index.ts @@ -6943,163 +6965,163 @@ var { PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER, TOTAL_OUTSTANDING_PAYMENTS, TOTAL_AMOUNT_OVERDUE, - HAS_BUYER_FINANCIAL_ACCOUNTS + HAS_BUYER_FINANCIAL_ACCOUNTS, }, - CURRENCY: { CURRENCY_CODE: CURRENCY_CODE2 } + CURRENCY: { CURRENCY_CODE: CURRENCY_CODE2 }, } = FIELD_IDS.INSURANCE; var { - YOUR_BUYER: { COMPANY_DETAILS, TRADING_HISTORY, CONNECTION_TO_BUYER, CREDIT_INSURANCE_HISTORY, FINANCIAL_ACCOUNTS } + YOUR_BUYER: { COMPANY_DETAILS, TRADING_HISTORY, CONNECTION_TO_BUYER, CREDIT_INSURANCE_HISTORY, FINANCIAL_ACCOUNTS }, } = FORM_TITLES; var YOUR_BUYER_FIELDS = { COMPANY_OR_ORGANISATION: { [COMPANY_OR_ORGANISATION.NAME]: { LABEL: "Buyer's company or organisation name", SUMMARY: { - TITLE: "Company or organisation name", - FORM_TITLE: COMPANY_DETAILS - } + TITLE: 'Company or organisation name', + FORM_TITLE: COMPANY_DETAILS, + }, }, [COMPANY_OR_ORGANISATION.ADDRESS]: { - LABEL: "Company address", + LABEL: 'Company address', SUMMARY: { - TITLE: "Buyer address", - FORM_TITLE: COMPANY_DETAILS + TITLE: 'Buyer address', + FORM_TITLE: COMPANY_DETAILS, }, - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS + MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, }, [COMPANY_OR_ORGANISATION.COUNTRY]: { - LABEL: "Buyer country", + LABEL: 'Buyer country', SUMMARY: { - TITLE: "Buyer country" - } + TITLE: 'Buyer country', + }, }, [COMPANY_OR_ORGANISATION.REGISTRATION_NUMBER]: { - LABEL: "Company registration number (optional)", + LABEL: 'Company registration number (optional)', SUMMARY: { - TITLE: "Registration number (optional)", - FORM_TITLE: COMPANY_DETAILS + TITLE: 'Registration number (optional)', + FORM_TITLE: COMPANY_DETAILS, }, - MAXIMUM: MAXIMUM_CHARACTERS.BUYER.REGISTRATION_NUMBER + MAXIMUM: MAXIMUM_CHARACTERS.BUYER.REGISTRATION_NUMBER, }, [COMPANY_OR_ORGANISATION.WEBSITE]: { - LABEL: "Enter their website (optional)", + LABEL: 'Enter their website (optional)', SUMMARY: { - TITLE: "Buyer website (optional)", - FORM_TITLE: COMPANY_DETAILS - } - } + TITLE: 'Buyer website (optional)', + FORM_TITLE: COMPANY_DETAILS, + }, + }, }, [CONNECTION_WITH_BUYER]: { - LABEL: "Are you connected with the buyer in any way?", + LABEL: 'Are you connected with the buyer in any way?', HINT: { - INTRO: "For example:", + INTRO: 'For example:', LIST: [ "someone in your company is a shareholder or director of the buyer's company", - "someone in the buyer's company is a shareholder or director of your company" - ] + "someone in the buyer's company is a shareholder or director of your company", + ], }, SUMMARY: { - TITLE: "Connected with the buyer", - FORM_TITLE: CONNECTION_TO_BUYER - } + TITLE: 'Connected with the buyer', + FORM_TITLE: CONNECTION_TO_BUYER, + }, }, [CONNECTION_WITH_BUYER_DESCRIPTION]: { - LABEL: "Describe the connection with the buyer", + LABEL: 'Describe the connection with the buyer', MAXIMUM: MAXIMUM_CHARACTERS.CONNECTION_WITH_BUYER_DESCRIPTION, SUMMARY: { - TITLE: "Details of connection", - FORM_TITLE: CONNECTION_TO_BUYER - } + TITLE: 'Details of connection', + FORM_TITLE: CONNECTION_TO_BUYER, + }, }, [TRADED_WITH_BUYER]: { - LABEL: "Have you traded with this buyer before?", - HINT: "If yes, we will request a copy of your trading history once the application has been submitted.", + LABEL: 'Have you traded with this buyer before?', + HINT: 'If yes, we will request a copy of your trading history once the application has been submitted.', SUMMARY: { - TITLE: "Trading history", - FORM_TITLE: TRADING_HISTORY - } + TITLE: 'Trading history', + FORM_TITLE: TRADING_HISTORY, + }, }, [OUTSTANDING_PAYMENTS]: { - LABEL: "Do you currently have any outstanding or overdue payments from the buyer?", + LABEL: 'Do you currently have any outstanding or overdue payments from the buyer?', SUMMARY: { - TITLE: "Outstanding or overdue payments", - FORM_TITLE: TRADING_HISTORY - } + TITLE: 'Outstanding or overdue payments', + FORM_TITLE: TRADING_HISTORY, + }, }, [FAILED_PAYMENTS]: { - HINT: "This is when an invoice has still not been paid 30 days or more after the agreed payment date.", + HINT: 'This is when an invoice has still not been paid 30 days or more after the agreed payment date.', SUMMARY: { - TITLE: "Buyer failed to pay on time?", - FORM_TITLE: TRADING_HISTORY - } + TITLE: 'Buyer failed to pay on time?', + FORM_TITLE: TRADING_HISTORY, + }, }, [CURRENCY_CODE2]: { - LEGEND: "What is the currency the outstanding or overdue payments are in?", + LEGEND: 'What is the currency the outstanding or overdue payments are in?', SUMMARY: { - TITLE: "Outstanding payments currency", - FORM_TITLE: TRADING_HISTORY - } + TITLE: 'Outstanding payments currency', + FORM_TITLE: TRADING_HISTORY, + }, }, [HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER]: { - LABEL: "Have you in the past held credit insurance cover on the buyer?", + LABEL: 'Have you in the past held credit insurance cover on the buyer?', SUMMARY: { - TITLE: "Credit insurance previously held for the buyer", - FORM_TITLE: CREDIT_INSURANCE_HISTORY - } + TITLE: 'Credit insurance previously held for the buyer', + FORM_TITLE: CREDIT_INSURANCE_HISTORY, + }, }, [PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER]: { - LABEL: "Tell us about the credit insurance cover you had on the buyer", - HINT: "Include the name of the insurer(s) and the credit limit.", + LABEL: 'Tell us about the credit insurance cover you had on the buyer', + HINT: 'Include the name of the insurer(s) and the credit limit.', SUMMARY: { - TITLE: "Details of credit insurance", - FORM_TITLE: CREDIT_INSURANCE_HISTORY + TITLE: 'Details of credit insurance', + FORM_TITLE: CREDIT_INSURANCE_HISTORY, }, - MAXIMUM: MAXIMUM_CHARACTERS.BUYER.PREVIOUS_CREDIT_INSURANCE_COVER + MAXIMUM: MAXIMUM_CHARACTERS.BUYER.PREVIOUS_CREDIT_INSURANCE_COVER, }, [TOTAL_OUTSTANDING_PAYMENTS]: { - LABEL: "Total outstanding, including overdue in", - HINT: "Enter a whole number. Do not enter decimals.", + LABEL: 'Total outstanding, including overdue in', + HINT: 'Enter a whole number. Do not enter decimals.', SUMMARY: { - TITLE: "Total outstanding including overdue", - FORM_TITLE: TRADING_HISTORY - } + TITLE: 'Total outstanding including overdue', + FORM_TITLE: TRADING_HISTORY, + }, }, [TOTAL_AMOUNT_OVERDUE]: { - LABEL: "Amount overdue in", - HINT: "Enter a whole number. Do not enter decimals.", + LABEL: 'Amount overdue in', + HINT: 'Enter a whole number. Do not enter decimals.', SUMMARY: { - TITLE: "Amount overdue", - FORM_TITLE: TRADING_HISTORY - } + TITLE: 'Amount overdue', + FORM_TITLE: TRADING_HISTORY, + }, }, [HAS_BUYER_FINANCIAL_ACCOUNTS]: { SUMMARY: { - TITLE: "Financial accounts relating to the buyer", - FORM_TITLE: FINANCIAL_ACCOUNTS - } - } + TITLE: 'Financial accounts relating to the buyer', + FORM_TITLE: FINANCIAL_ACCOUNTS, + }, + }, }; // content-strings/fields/insurance/index.ts var REFERENCE_NUMBER = { SUMMARY: { - TITLE: "Application reference number" - } + TITLE: 'Application reference number', + }, }; var DATE_SUBMITTED = { SUMMARY: { - TITLE: "Date submitted" - } + TITLE: 'Date submitted', + }, }; var TIME_SUBMITTED = { SUMMARY: { - TITLE: "Time submitted" - } + TITLE: 'Time submitted', + }, }; // content-strings/default.ts var DEFAULT = { - EMPTY: "-" + EMPTY: '-', }; // content-strings/XLSX.ts @@ -7114,7 +7136,7 @@ var { HAS_END_BUYER: HAS_END_BUYER2, HAS_MINIMUM_UK_GOODS_OR_SERVICES: HAS_MINIMUM_UK_GOODS_OR_SERVICES2, IS_MEMBER_OF_A_GROUP, - IS_PARTY_TO_CONSORTIUM + IS_PARTY_TO_CONSORTIUM, }, EXPORT_CONTRACT: { ABOUT_GOODS_OR_SERVICES: { DESCRIPTION: DESCRIPTION2, FINAL_DESTINATION_KNOWN: FINAL_DESTINATION_KNOWN2 }, @@ -7123,7 +7145,7 @@ var { AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION }, HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION: PAYMENT_TERMS_DESCRIPTION2 }, PRIVATE_MARKET: { ATTEMPTED: ATTEMPTED_PRIVATE_MARKET, DECLINED_DESCRIPTION: DECLINED_DESCRIPTION2 }, - USING_AGENT + USING_AGENT, }, EXPORTER_BUSINESS: { ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS_DOT_NOTATION }, @@ -7131,17 +7153,23 @@ var { HAS_CREDIT_CONTROL: HAS_CREDIT_CONTROL2, NATURE_OF_YOUR_BUSINESS: { GOODS_OR_SERVICES: GOODS_OR_SERVICES2, YEARS_EXPORTING: YEARS_EXPORTING2, EMPLOYEES_UK: EMPLOYEES_UK2 }, TURNOVER: { ESTIMATED_ANNUAL_TURNOVER: ESTIMATED_ANNUAL_TURNOVER2 }, - YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME2, DIFFERENT_TRADING_NAME, PHONE_NUMBER: PHONE_NUMBER2, HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS2, WEBSITE: WEBSITE2 } + YOUR_COMPANY: { + HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME2, + DIFFERENT_TRADING_NAME, + PHONE_NUMBER: PHONE_NUMBER2, + HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS2, + WEBSITE: WEBSITE2, + }, }, POLICY: { BROKER_DETAILS: { NAME: BROKER_NAME, EMAIL: BROKER_EMAIL, FULL_ADDRESS: BROKER_ADDRESS }, CONTRACT_POLICY: { REQUESTED_START_DATE: REQUESTED_START_DATE2, SINGLE: { CONTRACT_COMPLETION_DATE: CONTRACT_COMPLETION_DATE2, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE_ID }, - MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER2 } + MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER2 }, }, EXPORT_VALUE: { - MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE } + MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE }, }, FINANCIAL_ADDRESS: FINANCIAL_ADDRESS2, LOSS_PAYEE: { IS_APPOINTED: IS_APPOINTED2 }, @@ -7152,7 +7180,7 @@ var { CREDIT_PERIOD_WITH_BUYER: CREDIT_PERIOD_WITH_BUYER2, REQUESTED_JOINTLY_INSURED_PARTY, TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE4 }, - USING_BROKER: USING_BROKER2 + USING_BROKER: USING_BROKER2, }, YOUR_BUYER: { COMPANY_OR_ORGANISATION: { COUNTRY, NAME: BUYER_COMPANY_NAME, REGISTRATION_NUMBER: BUYER_REGISTRATION_NUMBER }, @@ -7164,126 +7192,126 @@ var { OUTSTANDING_PAYMENTS: OUTSTANDING_PAYMENTS2, PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2, TOTAL_OUTSTANDING_PAYMENTS: TOTAL_OUTSTANDING_PAYMENTS2, - TRADED_WITH_BUYER: TRADED_WITH_BUYER2 - } + TRADED_WITH_BUYER: TRADED_WITH_BUYER2, + }, } = insurance_default; var XLSX = { - AGREED: "Agreed", + AGREED: 'Agreed', FIELDS: { - [ACCOUNT_NUMBER2]: "Loss payee account number", + [ACCOUNT_NUMBER2]: 'Loss payee account number', AGENT: { - [AGENT_NAME]: "Name of the agent", - [AGENT_ADDRESS]: "Address of the agent", - [AGENT_COUNTRY_CODE]: "Country the agent is based in" + [AGENT_NAME]: 'Name of the agent', + [AGENT_ADDRESS]: 'Address of the agent', + [AGENT_COUNTRY_CODE]: 'Country the agent is based in', }, AGENT_CHARGES: { - [FIXED_SUM_AMOUNT]: "How much is the agent charging?", - [PAYABLE_COUNTRY_CODE]: "Country where the charges are payable", - [PERCENTAGE_CHARGE]: "How much is the agent charging?" + [FIXED_SUM_AMOUNT]: 'How much is the agent charging?', + [PAYABLE_COUNTRY_CODE]: 'Country where the charges are payable', + [PERCENTAGE_CHARGE]: 'How much is the agent charging?', }, AGENT_SERVICE: { - [IS_CHARGING]: "Is the agent charging for their support in the export contract?", - [SERVICE_DESCRIPTION]: "Service the agent is providing" + [IS_CHARGING]: 'Is the agent charging for their support in the export contract?', + [SERVICE_DESCRIPTION]: 'Service the agent is providing', }, - APPLICANT_EMAIL_ADDRESS: "Applicant email address", - [BIC_SWIFT_CODE2]: "Loss payee BIC or SWIFT code", - [BROKER_NAME]: "Name of broker or company", - [BROKER_ADDRESS]: "Broker address", + APPLICANT_EMAIL_ADDRESS: 'Applicant email address', + [BIC_SWIFT_CODE2]: 'Loss payee BIC or SWIFT code', + [BROKER_NAME]: 'Name of broker or company', + [BROKER_ADDRESS]: 'Broker address', [BROKER_EMAIL]: "Broker's email address", - [BUYER_COMPANY_NAME]: "Buyer company name or organisation", - BUYER_CONTACT_DETAILS: "Buyer contact details", - [BUYER_COUNTRY2]: "Where is your buyer based?", - [BUYER_REGISTRATION_NUMBER]: "Buyer registration number (optional)", - [COMPANIES_HOUSE_NUMBER2]: "Companies house number", - [CONNECTION_WITH_BUYER2]: "Is the exporter connected with the buyer in any way?", - [CONNECTION_WITH_BUYER_DESCRIPTION2]: "Describe connection to the buyer", - [CONTRACT_COMPLETION_DATE2]: "Expected contract completion date", - [COUNTRY]: "Buyer location", - [COVER_PERIOD2]: "Length of cover", - [DIFFERENT_TRADING_NAME]: "Alternative trading name", - [EMPLOYEES_UK2]: "Number of UK Employees", - [ESTIMATED_ANNUAL_TURNOVER2]: "Exporter estimated turnover this current financial year", - [EXPORTER_COMPANY_ADDRESS]: "Exporter registered office address", - [EXPORTER_COMPANY_NAME]: "Exporter company name", - [EXPORTER_COMPANY_SIC]: "Exporter standard industry classification (SIC) code(s)", + [BUYER_COMPANY_NAME]: 'Buyer company name or organisation', + BUYER_CONTACT_DETAILS: 'Buyer contact details', + [BUYER_COUNTRY2]: 'Where is your buyer based?', + [BUYER_REGISTRATION_NUMBER]: 'Buyer registration number (optional)', + [COMPANIES_HOUSE_NUMBER2]: 'Companies house number', + [CONNECTION_WITH_BUYER2]: 'Is the exporter connected with the buyer in any way?', + [CONNECTION_WITH_BUYER_DESCRIPTION2]: 'Describe connection to the buyer', + [CONTRACT_COMPLETION_DATE2]: 'Expected contract completion date', + [COUNTRY]: 'Buyer location', + [COVER_PERIOD2]: 'Length of cover', + [DIFFERENT_TRADING_NAME]: 'Alternative trading name', + [EMPLOYEES_UK2]: 'Number of UK Employees', + [ESTIMATED_ANNUAL_TURNOVER2]: 'Exporter estimated turnover this current financial year', + [EXPORTER_COMPANY_ADDRESS]: 'Exporter registered office address', + [EXPORTER_COMPANY_NAME]: 'Exporter company name', + [EXPORTER_COMPANY_SIC]: 'Exporter standard industry classification (SIC) code(s)', EXPORTER_CONTACT: { - TITLE: "Exporter contact details", - [FIRST_NAME]: "Exporter first name", - [LAST_NAME]: "Exporter last name", - EXPORTER_CONTACT_EMAIL: "Exporter email address", - EXPORTER_CONTACT_POSITION: "Exporter's role" + TITLE: 'Exporter contact details', + [FIRST_NAME]: 'Exporter first name', + [LAST_NAME]: 'Exporter last name', + EXPORTER_CONTACT_EMAIL: 'Exporter email address', + EXPORTER_CONTACT_POSITION: "Exporter's role", }, EXPORT_CONTRACT: { [DESCRIPTION2]: "About the exporter's goods or services", - [FINAL_DESTINATION_KNOWN2]: "Does the exporter know the final destination of the goods or services?", - [PAYMENT_TERMS_DESCRIPTION2]: "How the exporter will be paid for their export", - [ATTEMPTED_PRIVATE_MARKET]: "Did the exporter try to insure through the private market?", - [DECLINED_DESCRIPTION2]: "Why could they not get insurance through the private market? ", - [USING_AGENT]: "Did the exporter use an agent?" - }, - [FAILED_PAYMENTS2]: "Has the buyer ever failed to pay the exporter on time?", - [FINANCIAL_ADDRESS2]: "Bank address of the loss payee", - [FIRST_NAME]: "Applicant first name", - [FULL_ADDRESS_DOT_NOTATION]: "Alternative trading address", - [GOODS_OR_SERVICES2]: "Goods or services the business supplies", - [HAS_ANTI_BRIBERY_CODE_OF_CONDUCT2]: "Does the exporter have a code of conduct?", - [HAS_BUYER_FINANCIAL_ACCOUNTS2]: "Does the exporter hold any financial accounts in relation to the buyer?", - [HAS_CREDIT_CONTROL2]: "Do you have a process for dealing with late payments?", - [HAS_DIFFERENT_TRADING_NAME2]: "Different trading name?", - [HAS_END_BUYER2]: "Is there an end buyer?", - [HAS_MINIMUM_UK_GOODS_OR_SERVICES2]: "Is at least 20% of the contract value made up from UK goods or services?", - [HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: "Has the exporter previously held credit insurance cover on the buyer?", - [IBAN2]: "Loss payee IBAN number", - [IS_APPOINTED2]: "Using a loss payee?", + [FINAL_DESTINATION_KNOWN2]: 'Does the exporter know the final destination of the goods or services?', + [PAYMENT_TERMS_DESCRIPTION2]: 'How the exporter will be paid for their export', + [ATTEMPTED_PRIVATE_MARKET]: 'Did the exporter try to insure through the private market?', + [DECLINED_DESCRIPTION2]: 'Why could they not get insurance through the private market? ', + [USING_AGENT]: 'Did the exporter use an agent?', + }, + [FAILED_PAYMENTS2]: 'Has the buyer ever failed to pay the exporter on time?', + [FINANCIAL_ADDRESS2]: 'Bank address of the loss payee', + [FIRST_NAME]: 'Applicant first name', + [FULL_ADDRESS_DOT_NOTATION]: 'Alternative trading address', + [GOODS_OR_SERVICES2]: 'Goods or services the business supplies', + [HAS_ANTI_BRIBERY_CODE_OF_CONDUCT2]: 'Does the exporter have a code of conduct?', + [HAS_BUYER_FINANCIAL_ACCOUNTS2]: 'Does the exporter hold any financial accounts in relation to the buyer?', + [HAS_CREDIT_CONTROL2]: 'Do you have a process for dealing with late payments?', + [HAS_DIFFERENT_TRADING_NAME2]: 'Different trading name?', + [HAS_END_BUYER2]: 'Is there an end buyer?', + [HAS_MINIMUM_UK_GOODS_OR_SERVICES2]: 'Is at least 20% of the contract value made up from UK goods or services?', + [HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: 'Has the exporter previously held credit insurance cover on the buyer?', + [IBAN2]: 'Loss payee IBAN number', + [IS_APPOINTED2]: 'Using a loss payee?', JOINTLY_INSURED_PARTY: { - [REQUESTED_JOINTLY_INSURED_PARTY.REQUESTED]: "Is there another company that needs to be insured on the policy?", - [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NAME]: "Name of the company", - [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NUMBER]: "Registration number of the other company (optional)", - [REQUESTED_JOINTLY_INSURED_PARTY.COUNTRY_CODE]: "The country the other company is based in" - }, - KEY_INFORMATION_TITLE: "Key information", - [LAST_NAME]: "Applicant last name", - [MAXIMUM_BUYER_WILL_OWE]: "Maximum buyer will owe exporter", + [REQUESTED_JOINTLY_INSURED_PARTY.REQUESTED]: 'Is there another company that needs to be insured on the policy?', + [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NAME]: 'Name of the company', + [REQUESTED_JOINTLY_INSURED_PARTY.COMPANY_NUMBER]: 'Registration number of the other company (optional)', + [REQUESTED_JOINTLY_INSURED_PARTY.COUNTRY_CODE]: 'The country the other company is based in', + }, + KEY_INFORMATION_TITLE: 'Key information', + [LAST_NAME]: 'Applicant last name', + [MAXIMUM_BUYER_WILL_OWE]: 'Maximum buyer will owe exporter', [MORE_THAN_250K.VALUE]: `Contract value of ${format_currency_default(AMOUNT_250K, GBP_CURRENCY_CODE)} or more?`, NAME_ON_POLICY: { - [NAME_ON_POLICY2.NAME]: "Name on the policy", - [NAME_ON_POLICY2.POSITION]: "Position at the company" - }, - [NEED_PRE_CREDIT_PERIOD2]: "Is there a pre-credit period?", - [CREDIT_PERIOD_WITH_BUYER2]: "The period of pre-credit cover required", - NO_FINANCIAL_YEAR_END_DATE: "No data from Companies House", - [OUTSTANDING_PAYMENTS2]: "Does the exporter currently have any outstanding or overdue payments from the buyer?", - [PHONE_NUMBER2]: "Exporter UK telephone number (optional)", - [POLICY_TYPE4]: "Type of policy", - [PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: "Details of credit insurance cover held on the buyer", - [REQUESTED_START_DATE2]: "Requested policy start date", - SOMEONE_ELSE: "Someone else", - [SORT_CODE2]: "Loss payee sort code", - [TOTAL_CONTRACT_VALUE_ID]: "Total value of the contract", - [TOTAL_MONTHS_OF_COVER2]: "Requested length of insurance", - [TOTAL_OUTSTANDING_PAYMENTS2]: "Total outstanding payments", - [TOTAL_SALES_TO_BUYER]: "Total sales estimate", - [HAS_DIFFERENT_TRADING_ADDRESS2]: "Different trading address?", - [TRADED_WITH_BUYER2]: "Has the exporter traded with this buyer before?", - [USING_BROKER2]: "Using a broker for this insurance?", - [WEBSITE2]: "Exporter Company website (optional)", - [WILL_EXPORT_WITH_CODE_OF_CONDUCT2]: "Will the exporter export using their code of conduct?", - [YEARS_EXPORTING2]: "How long the business has been exporting for", - [IS_PARTY_TO_CONSORTIUM]: "Party to any consortium in connection with the export contract(s)?", - [IS_MEMBER_OF_A_GROUP]: "Member of a group which may have a part in negotiating the contract(s)?" - } + [NAME_ON_POLICY2.NAME]: 'Name on the policy', + [NAME_ON_POLICY2.POSITION]: 'Position at the company', + }, + [NEED_PRE_CREDIT_PERIOD2]: 'Is there a pre-credit period?', + [CREDIT_PERIOD_WITH_BUYER2]: 'The period of pre-credit cover required', + NO_FINANCIAL_YEAR_END_DATE: 'No data from Companies House', + [OUTSTANDING_PAYMENTS2]: 'Does the exporter currently have any outstanding or overdue payments from the buyer?', + [PHONE_NUMBER2]: 'Exporter UK telephone number (optional)', + [POLICY_TYPE4]: 'Type of policy', + [PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER2]: 'Details of credit insurance cover held on the buyer', + [REQUESTED_START_DATE2]: 'Requested policy start date', + SOMEONE_ELSE: 'Someone else', + [SORT_CODE2]: 'Loss payee sort code', + [TOTAL_CONTRACT_VALUE_ID]: 'Total value of the contract', + [TOTAL_MONTHS_OF_COVER2]: 'Requested length of insurance', + [TOTAL_OUTSTANDING_PAYMENTS2]: 'Total outstanding payments', + [TOTAL_SALES_TO_BUYER]: 'Total sales estimate', + [HAS_DIFFERENT_TRADING_ADDRESS2]: 'Different trading address?', + [TRADED_WITH_BUYER2]: 'Has the exporter traded with this buyer before?', + [USING_BROKER2]: 'Using a broker for this insurance?', + [WEBSITE2]: 'Exporter Company website (optional)', + [WILL_EXPORT_WITH_CODE_OF_CONDUCT2]: 'Will the exporter export using their code of conduct?', + [YEARS_EXPORTING2]: 'How long the business has been exporting for', + [IS_PARTY_TO_CONSORTIUM]: 'Party to any consortium in connection with the export contract(s)?', + [IS_MEMBER_OF_A_GROUP]: 'Member of a group which may have a part in negotiating the contract(s)?', + }, }; // generate-xlsx/map-application-to-XLSX/helpers/xlsx-row/index.ts var { KEY, VALUE } = XLSX_CONFIG; var xlsxRow = (fieldName, answer) => { if (fieldName) { - console.info("Mapping XLSX row %s", fieldName); - const value = answer || answer === 0 ? answer : ""; + console.info('Mapping XLSX row %s', fieldName); + const value = answer || answer === 0 ? answer : ''; const cleanValue = replace_character_codes_with_characters_default(String(value)); const row = { [KEY]: fieldName, - [VALUE]: cleanValue + [VALUE]: cleanValue, }; return row; } @@ -7304,7 +7332,7 @@ var mapIntroduction = (application2) => { xlsx_row_default(TIME_SUBMITTED.SUMMARY.TITLE, format_time_of_day_default(application2.submissionDate)), xlsx_row_default(String(FIELDS[FIRST_NAME2]), application2.owner[FIRST_NAME2]), xlsx_row_default(String(FIELDS[LAST_NAME2]), application2.owner[LAST_NAME2]), - xlsx_row_default(FIELDS.APPLICANT_EMAIL_ADDRESS, application2.owner[EMAIL4]) + xlsx_row_default(FIELDS.APPLICANT_EMAIL_ADDRESS, application2.owner[EMAIL4]), ]; return mapped; }; @@ -7314,8 +7342,8 @@ var map_introduction_default = mapIntroduction; var { ACCOUNT: { FIRST_NAME: FIRST_NAME3, LAST_NAME: LAST_NAME3, EMAIL: EMAIL5 }, POLICY: { - NAME_ON_POLICY: { POSITION } - } + NAME_ON_POLICY: { POSITION }, + }, } = insurance_default; var { FIELDS: FIELDS2 } = XLSX; var mapExporterContactDetails = (application2) => { @@ -7325,7 +7353,7 @@ var mapExporterContactDetails = (application2) => { xlsx_row_default(FIELDS2.EXPORTER_CONTACT[FIRST_NAME3], policyContact[FIRST_NAME3]), xlsx_row_default(FIELDS2.EXPORTER_CONTACT[LAST_NAME3], policyContact[LAST_NAME3]), xlsx_row_default(FIELDS2.EXPORTER_CONTACT.EXPORTER_CONTACT_EMAIL, policyContact[EMAIL5]), - xlsx_row_default(FIELDS2.EXPORTER_CONTACT.EXPORTER_CONTACT_POSITION, policyContact[POSITION]) + xlsx_row_default(FIELDS2.EXPORTER_CONTACT.EXPORTER_CONTACT_POSITION, policyContact[POSITION]), ]; return mapped; }; @@ -7359,16 +7387,19 @@ var { COMPANIES_HOUSE_NUMBER: COMPANIES_HOUSE_NUMBER3, HAS_END_BUYER: HAS_END_BUYER3, IS_PARTY_TO_CONSORTIUM: IS_PARTY_TO_CONSORTIUM2, - IS_MEMBER_OF_A_GROUP: IS_MEMBER_OF_A_GROUP2 - } + IS_MEMBER_OF_A_GROUP: IS_MEMBER_OF_A_GROUP2, + }, } = insurance_default; var mapEligibility = (application2) => { const { company, eligibility } = application2; let mapped = [ xlsx_row_default(ELIGIBILITY_FIELDS[VALID_EXPORTER_LOCATION2].SUMMARY?.TITLE, map_yes_no_field_default({ answer: eligibility[VALID_EXPORTER_LOCATION2] })), - xlsx_row_default(ELIGIBILITY_FIELDS[HAS_COMPANIES_HOUSE_NUMBER2].SUMMARY?.TITLE, map_yes_no_field_default({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER2] })), + xlsx_row_default( + ELIGIBILITY_FIELDS[HAS_COMPANIES_HOUSE_NUMBER2].SUMMARY?.TITLE, + map_yes_no_field_default({ answer: eligibility[HAS_COMPANIES_HOUSE_NUMBER2] }), + ), xlsx_row_default(String(FIELDS3[COMPANIES_HOUSE_NUMBER3]), company[COMPANIES_HOUSE_NUMBER3]), - xlsx_row_default(String(FIELDS3[BUYER_COUNTRY3]), eligibility[BUYER_COUNTRY3].name) + xlsx_row_default(String(FIELDS3[BUYER_COUNTRY3]), eligibility[BUYER_COUNTRY3].name), ]; const totalContractValueAnswer = eligibility[TOTAL_CONTRACT_VALUE_FIELD_ID2].valueId === MORE_THAN_250K2.DB_ID; mapped = [ @@ -7378,7 +7409,7 @@ var mapEligibility = (application2) => { xlsx_row_default(String(FIELDS3[HAS_MINIMUM_UK_GOODS_OR_SERVICES3]), map_yes_no_field_default({ answer: eligibility[HAS_MINIMUM_UK_GOODS_OR_SERVICES3] })), xlsx_row_default(String(FIELDS3[HAS_END_BUYER3]), map_yes_no_field_default({ answer: eligibility[HAS_END_BUYER3] })), xlsx_row_default(String(FIELDS3[IS_PARTY_TO_CONSORTIUM2]), map_yes_no_field_default({ answer: eligibility[IS_PARTY_TO_CONSORTIUM2] })), - xlsx_row_default(String(FIELDS3[IS_MEMBER_OF_A_GROUP2]), map_yes_no_field_default({ answer: eligibility[IS_PARTY_TO_CONSORTIUM2] })) + xlsx_row_default(String(FIELDS3[IS_MEMBER_OF_A_GROUP2]), map_yes_no_field_default({ answer: eligibility[IS_PARTY_TO_CONSORTIUM2] })), ]; return mapped; }; @@ -7387,18 +7418,18 @@ var map_eligibility_default = mapEligibility; // generate-xlsx/map-application-to-XLSX/map-key-information/index.ts var { FIELDS: FIELDS4 } = XLSX; var CONTENT_STRINGS = { - ...POLICY_FIELDS + ...POLICY_FIELDS, }; var { EXPORTER_BUSINESS: { - COMPANIES_HOUSE: { COMPANY_NAME: EXPORTER_COMPANY_NAME2 } + COMPANIES_HOUSE: { COMPANY_NAME: EXPORTER_COMPANY_NAME2 }, }, YOUR_BUYER: { - COMPANY_OR_ORGANISATION: { COUNTRY: COUNTRY2, NAME: BUYER_COMPANY_NAME2 } + COMPANY_OR_ORGANISATION: { COUNTRY: COUNTRY2, NAME: BUYER_COMPANY_NAME2 }, }, POLICY: { - TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE5 } - } + TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE5 }, + }, } = insurance_default; var mapKeyInformation = (application2) => { const { policy } = application2; @@ -7407,7 +7438,7 @@ var mapKeyInformation = (application2) => { xlsx_row_default(String(FIELDS4[EXPORTER_COMPANY_NAME2]), replace_character_codes_with_characters_default(application2.company[EXPORTER_COMPANY_NAME2])), xlsx_row_default(String(FIELDS4[COUNTRY2]), application2.buyer[COUNTRY2].name), xlsx_row_default(String(FIELDS4[BUYER_COMPANY_NAME2]), replace_character_codes_with_characters_default(application2.buyer[BUYER_COMPANY_NAME2])), - xlsx_row_default(String(CONTENT_STRINGS[POLICY_TYPE5].SUMMARY?.TITLE), policy[POLICY_TYPE5]) + xlsx_row_default(String(CONTENT_STRINGS[POLICY_TYPE5].SUMMARY?.TITLE), policy[POLICY_TYPE5]), ]; return mapped; }; @@ -7419,7 +7450,7 @@ var isMultiplePolicyType = (policyType) => policyType === FIELD_VALUES.POLICY_TY // generate-xlsx/map-application-to-XLSX/map-policy/map-intro/map-policy-type/index.ts var { - POLICY_TYPE: { ABBREVIATED } + POLICY_TYPE: { ABBREVIATED }, } = APPLICATION; var mapPolicyType = (policyType) => { if (isSinglePolicyType(policyType)) { @@ -7435,12 +7466,12 @@ var map_policy_type_default = mapPolicyType; var { FIELDS: FIELDS5 } = XLSX; var { POLICY_TYPE: POLICY_TYPE6, - CONTRACT_POLICY: { REQUESTED_START_DATE: REQUESTED_START_DATE3 } + CONTRACT_POLICY: { REQUESTED_START_DATE: REQUESTED_START_DATE3 }, } = policy_default; var mapIntro = (policy) => { const mapped = [ xlsx_row_default(String(FIELDS5[POLICY_TYPE6]), map_policy_type_default(policy[POLICY_TYPE6])), - xlsx_row_default(String(FIELDS5[REQUESTED_START_DATE3]), format_date_default(policy[REQUESTED_START_DATE3], DATE_FORMAT.XLSX)) + xlsx_row_default(String(FIELDS5[REQUESTED_START_DATE3]), format_date_default(policy[REQUESTED_START_DATE3], DATE_FORMAT.XLSX)), ]; return mapped; }; @@ -7450,64 +7481,64 @@ var map_intro_default = mapIntro; var { ACCOUNT: ACCOUNT3 } = FIELD_IDS.INSURANCE; var { FIRST_NAME: FIRST_NAME4, LAST_NAME: LAST_NAME4, EMAIL: EMAIL6, PASSWORD, ACCESS_CODE } = ACCOUNT3; var PASSWORD_HINT = { - INTRO: "Your password must contain at least 14 characters and have:", - RULES: ["an uppercase letter", "a lowercase letter", "a number", "a special character (for example @%!?*)"] + INTRO: 'Your password must contain at least 14 characters and have:', + RULES: ['an uppercase letter', 'a lowercase letter', 'a number', 'a special character (for example @%!?*)'], }; var ACCOUNT_FIELDS = { MAXIMUM: { NAME: { - CHARACTERS: 100 - } + CHARACTERS: 100, + }, }, [FIRST_NAME4]: { - LABEL: "First name" + LABEL: 'First name', }, [LAST_NAME4]: { - LABEL: "Last name" + LABEL: 'Last name', }, [EMAIL6]: { - LABEL: "Email address" + LABEL: 'Email address', }, [PASSWORD]: { REVEAL: { - SHOW: "Show", - HIDE: "Hide" - } + SHOW: 'Show', + HIDE: 'Hide', + }, }, [ACCESS_CODE]: { - LABEL: "Access code" + LABEL: 'Access code', }, CREATE: { YOUR_DETAILS: { [FIRST_NAME4]: { - LABEL: "First name" + LABEL: 'First name', }, [LAST_NAME4]: { - LABEL: "Last name" + LABEL: 'Last name', }, [PASSWORD]: { - LABEL: "Create a password", - HINT: PASSWORD_HINT - } - } + LABEL: 'Create a password', + HINT: PASSWORD_HINT, + }, + }, }, SIGN_IN: { [PASSWORD]: { - LABEL: "Password" - } + LABEL: 'Password', + }, }, PASSWORD_RESET: { [EMAIL6]: { - LABEL: "Email address", - HINT: "Enter the email address associated with your credit insurance application(s)." - } + LABEL: 'Email address', + HINT: 'Enter the email address associated with your credit insurance application(s).', + }, }, NEW_PASSWORD: { [PASSWORD]: { - LABEL: "Create a password", - HINT: PASSWORD_HINT - } - } + LABEL: 'Create a password', + HINT: PASSWORD_HINT, + }, + }, }; // generate-xlsx/map-application-to-XLSX/map-policy/map-name-on-policy/index.ts @@ -7515,14 +7546,17 @@ var { FIELDS: FIELDS6 } = XLSX; var { ACCOUNT: { FIRST_NAME: FIRST_NAME5, LAST_NAME: LAST_NAME5, EMAIL: EMAIL7 }, POLICY: { - NAME_ON_POLICY: { IS_SAME_AS_OWNER, NAME: NAME2, POSITION: POSITION2 } - } + NAME_ON_POLICY: { IS_SAME_AS_OWNER, NAME: NAME2, POSITION: POSITION2 }, + }, } = insurance_default; var mapNameOnPolicy = (policyContact) => { let mapped = []; if (policyContact[IS_SAME_AS_OWNER]) { const nameOnPolicy = `${policyContact[FIRST_NAME5]} ${policyContact[LAST_NAME5]} (${policyContact[EMAIL7]})`; - mapped = [xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[NAME2]), nameOnPolicy), xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2])]; + mapped = [ + xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[NAME2]), nameOnPolicy), + xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2]), + ]; return mapped; } mapped = [ @@ -7530,19 +7564,20 @@ var mapNameOnPolicy = (policyContact) => { xlsx_row_default(String(ACCOUNT_FIELDS[FIRST_NAME5].LABEL), policyContact[FIRST_NAME5]), xlsx_row_default(String(ACCOUNT_FIELDS[LAST_NAME5].LABEL), policyContact[LAST_NAME5]), xlsx_row_default(String(ACCOUNT_FIELDS[EMAIL7].LABEL), policyContact[EMAIL7]), - xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2]) + xlsx_row_default(String(FIELDS6.NAME_ON_POLICY[POSITION2]), policyContact[POSITION2]), ]; return mapped; }; var map_name_on_policy_default = mapNameOnPolicy; // generate-xlsx/map-application-to-XLSX/helpers/format-currency/index.ts -var formatCurrency2 = (number, currencyCode, decimalPlaces) => number.toLocaleString("en", { - style: "currency", - currency: currencyCode, - minimumFractionDigits: decimalPlaces ?? 0, - maximumFractionDigits: decimalPlaces ?? 0 -}); +var formatCurrency2 = (number, currencyCode, decimalPlaces) => + number.toLocaleString('en', { + style: 'currency', + currency: currencyCode, + minimumFractionDigits: decimalPlaces ?? 0, + maximumFractionDigits: decimalPlaces ?? 0, + }); var format_currency_default2 = formatCurrency2; // generate-xlsx/map-application-to-XLSX/map-policy/map-single-contract-policy/index.ts @@ -7550,7 +7585,7 @@ var { FIELDS: FIELDS7 } = XLSX; var CONTENT_STRINGS2 = { ...POLICY_FIELDS, ...POLICY_FIELDS.CONTRACT_POLICY, - ...POLICY_FIELDS.CONTRACT_POLICY.SINGLE + ...POLICY_FIELDS.CONTRACT_POLICY.SINGLE, }; var { CURRENCY: { CURRENCY_CODE: CURRENCY_CODE3 }, @@ -7558,23 +7593,26 @@ var { CONTRACT_POLICY: { SINGLE: { CONTRACT_COMPLETION_DATE: CONTRACT_COMPLETION_DATE3 }, POLICY_CURRENCY_CODE, - SINGLE: { REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE2 } - } - } + SINGLE: { REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE: TOTAL_CONTRACT_VALUE2 }, + }, + }, } = insurance_default; var mapSingleContractPolicy = (policy) => { const mapped = [ xlsx_row_default(String(FIELDS7[CONTRACT_COMPLETION_DATE3]), format_date_default(policy[CONTRACT_COMPLETION_DATE3], DATE_FORMAT.XLSX)), xlsx_row_default(String(CONTENT_STRINGS2[CURRENCY_CODE3].SUMMARY?.TITLE), policy[POLICY_CURRENCY_CODE]), xlsx_row_default(String(FIELDS7[TOTAL_CONTRACT_VALUE2]), format_currency_default2(policy[TOTAL_CONTRACT_VALUE2], policy[POLICY_CURRENCY_CODE])), - xlsx_row_default(String(CONTENT_STRINGS2[REQUESTED_CREDIT_LIMIT].SUMMARY?.TITLE), format_currency_default2(policy[REQUESTED_CREDIT_LIMIT], policy[POLICY_CURRENCY_CODE])) + xlsx_row_default( + String(CONTENT_STRINGS2[REQUESTED_CREDIT_LIMIT].SUMMARY?.TITLE), + format_currency_default2(policy[REQUESTED_CREDIT_LIMIT], policy[POLICY_CURRENCY_CODE]), + ), ]; return mapped; }; var map_single_contract_policy_default = mapSingleContractPolicy; // generate-xlsx/map-application-to-XLSX/helpers/map-month-string/index.ts -var mapMonthString = (answer) => answer === 1 ? `${answer} month` : `${answer} months`; +var mapMonthString = (answer) => (answer === 1 ? `${answer} month` : `${answer} months`); var map_month_string_default = mapMonthString; // generate-xlsx/map-application-to-XLSX/map-policy/map-multiple-contract-policy/index.ts @@ -7583,25 +7621,25 @@ var CONTENT_STRINGS3 = { ...POLICY_FIELDS, ...POLICY_FIELDS.CONTRACT_POLICY, ...POLICY_FIELDS.CONTRACT_POLICY.MULTIPLE, - ...POLICY_FIELDS.EXPORT_VALUE.MULTIPLE + ...POLICY_FIELDS.EXPORT_VALUE.MULTIPLE, }; var { CURRENCY: { CURRENCY_CODE: CURRENCY_CODE4 }, POLICY: { CONTRACT_POLICY: { POLICY_CURRENCY_CODE: POLICY_CURRENCY_CODE2, - MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER3 } + MULTIPLE: { TOTAL_MONTHS_OF_COVER: TOTAL_MONTHS_OF_COVER3 }, }, EXPORT_VALUE: { - MULTIPLE: { TOTAL_SALES_TO_BUYER: TOTAL_SALES_TO_BUYER2, MAXIMUM_BUYER_WILL_OWE: MAXIMUM_BUYER_WILL_OWE2 } - } - } + MULTIPLE: { TOTAL_SALES_TO_BUYER: TOTAL_SALES_TO_BUYER2, MAXIMUM_BUYER_WILL_OWE: MAXIMUM_BUYER_WILL_OWE2 }, + }, + }, } = insurance_default; var mapMultipleContractPolicy = (policy) => [ xlsx_row_default(String(FIELDS8[TOTAL_MONTHS_OF_COVER3]), map_month_string_default(policy[TOTAL_MONTHS_OF_COVER3])), xlsx_row_default(String(CONTENT_STRINGS3[CURRENCY_CODE4].SUMMARY?.TITLE), policy[POLICY_CURRENCY_CODE2]), xlsx_row_default(String(FIELDS8[TOTAL_SALES_TO_BUYER2]), format_currency_default2(policy[TOTAL_SALES_TO_BUYER2], policy[POLICY_CURRENCY_CODE2])), - xlsx_row_default(String(FIELDS8[MAXIMUM_BUYER_WILL_OWE2]), format_currency_default2(policy[MAXIMUM_BUYER_WILL_OWE2], policy[POLICY_CURRENCY_CODE2])) + xlsx_row_default(String(FIELDS8[MAXIMUM_BUYER_WILL_OWE2]), format_currency_default2(policy[MAXIMUM_BUYER_WILL_OWE2], policy[POLICY_CURRENCY_CODE2])), ]; var map_multiple_contract_policy_default = mapMultipleContractPolicy; @@ -7628,7 +7666,7 @@ var get_country_by_iso_code_default = getCountryByIsoCode; // generate-xlsx/map-application-to-XLSX/map-policy/map-jointly-insured-party/index.ts var { FIELDS: FIELDS10 } = XLSX; var { - REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED: REQUESTED2, COMPANY_NAME: COMPANY_NAME4, COMPANY_NUMBER: COMPANY_NUMBER3, COUNTRY_CODE: COUNTRY_CODE2 } + REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED: REQUESTED2, COMPANY_NAME: COMPANY_NAME4, COMPANY_NUMBER: COMPANY_NUMBER3, COUNTRY_CODE: COUNTRY_CODE2 }, } = policy_default; var mapJointlyInsuredParty = (party, countries) => { const requestedParty = party[REQUESTED2]; @@ -7639,7 +7677,7 @@ var mapJointlyInsuredParty = (party, countries) => { ...mapped, xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COMPANY_NAME4]), party[COMPANY_NAME4]), xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COUNTRY_CODE2]), country.name), - xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COMPANY_NUMBER3]), party[COMPANY_NUMBER3]) + xlsx_row_default(String(FIELDS10.JOINTLY_INSURED_PARTY[COMPANY_NUMBER3]), party[COMPANY_NUMBER3]), ]; } return mapped; @@ -7649,7 +7687,7 @@ var map_jointly_insured_party_default = mapJointlyInsuredParty; // generate-xlsx/map-application-to-XLSX/map-policy/map-broker/index.ts var { USING_BROKER: USING_BROKER3, - BROKER_DETAILS: { NAME: BROKER_NAME2, EMAIL: EMAIL8, FULL_ADDRESS: FULL_ADDRESS3 } + BROKER_DETAILS: { NAME: BROKER_NAME2, EMAIL: EMAIL8, FULL_ADDRESS: FULL_ADDRESS3 }, } = POLICY; var { FIELDS: FIELDS11 } = XLSX; var mapBroker = (application2) => { @@ -7660,7 +7698,7 @@ var mapBroker = (application2) => { ...mapped, xlsx_row_default(String(FIELDS11[BROKER_NAME2]), broker[BROKER_NAME2]), xlsx_row_default(String(FIELDS11[EMAIL8]), broker[EMAIL8]), - xlsx_row_default(String(FIELDS11[FULL_ADDRESS3]), broker[FULL_ADDRESS3]) + xlsx_row_default(String(FIELDS11[FULL_ADDRESS3]), broker[FULL_ADDRESS3]), ]; } return mapped; @@ -7669,7 +7707,7 @@ var map_broker_default = mapBroker; // generate-xlsx/map-application-to-XLSX/map-policy/map-loss-payee/map-appointed-loss-payee/map-location/index.ts var { - LOSS_PAYEE_DETAILS: { IS_LOCATED_INTERNATIONALLY: IS_LOCATED_INTERNATIONALLY2, IS_LOCATED_IN_UK: IS_LOCATED_IN_UK2, LOCATION: LOCATION2 } + LOSS_PAYEE_DETAILS: { IS_LOCATED_INTERNATIONALLY: IS_LOCATED_INTERNATIONALLY2, IS_LOCATED_IN_UK: IS_LOCATED_IN_UK2, LOCATION: LOCATION2 }, } = policy_default; var CONTENT_STRINGS4 = POLICY_FIELDS.LOSS_PAYEE_DETAILS[LOCATION2].OPTIONS; var mapLossPayeeLocation = (lossPayee) => { @@ -7687,7 +7725,7 @@ var { FIELDS: FIELDS12 } = XLSX; var CONTENT_STRINGS5 = POLICY_FIELDS.LOSS_PAYEE_DETAILS; var { LOSS_PAYEE: { IS_APPOINTED: IS_APPOINTED3 }, - LOSS_PAYEE_DETAILS: { LOCATION: LOCATION3, NAME: LOSS_PAYEE_NAME2 } + LOSS_PAYEE_DETAILS: { LOCATION: LOCATION3, NAME: LOSS_PAYEE_NAME2 }, } = policy_default; var mapAppointedLossPayee = (lossPayee) => { let mapped = [xlsx_row_default(String(FIELDS12[IS_APPOINTED3]), map_yes_no_field_default({ answer: lossPayee[IS_APPOINTED3] }))]; @@ -7695,7 +7733,7 @@ var mapAppointedLossPayee = (lossPayee) => { mapped = [ ...mapped, xlsx_row_default(String(CONTENT_STRINGS5[LOSS_PAYEE_NAME2].SUMMARY?.TITLE), lossPayee[LOSS_PAYEE_NAME2]), - xlsx_row_default(String(CONTENT_STRINGS5[LOCATION3].LABEL), map_location_default(lossPayee)) + xlsx_row_default(String(CONTENT_STRINGS5[LOCATION3].LABEL), map_location_default(lossPayee)), ]; } return mapped; @@ -7707,14 +7745,14 @@ var { FIELDS: FIELDS13 } = XLSX; var { LOSS_PAYEE_DETAILS: { IS_LOCATED_INTERNATIONALLY: IS_LOCATED_INTERNATIONALLY3 }, LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { BIC_SWIFT_CODE: BIC_SWIFT_CODE3, IBAN: IBAN3 }, - FINANCIAL_ADDRESS: FINANCIAL_ADDRESS3 + FINANCIAL_ADDRESS: FINANCIAL_ADDRESS3, } = policy_default; var mapLossPayeeFinancialDetailsInternational = (lossPayee) => { if (lossPayee[IS_LOCATED_INTERNATIONALLY3]) { const mapped = [ xlsx_row_default(String(FIELDS13[BIC_SWIFT_CODE3]), lossPayee.financialInternational[BIC_SWIFT_CODE3]), xlsx_row_default(String(FIELDS13[IBAN3]), lossPayee.financialInternational[IBAN3]), - xlsx_row_default(String(FIELDS13[FINANCIAL_ADDRESS3]), lossPayee.financialInternational[FINANCIAL_ADDRESS3]) + xlsx_row_default(String(FIELDS13[FINANCIAL_ADDRESS3]), lossPayee.financialInternational[FINANCIAL_ADDRESS3]), ]; return mapped; } @@ -7727,14 +7765,14 @@ var { FIELDS: FIELDS14 } = XLSX; var { LOSS_PAYEE_DETAILS: { IS_LOCATED_IN_UK: IS_LOCATED_IN_UK3 }, LOSS_PAYEE_FINANCIAL_UK: { SORT_CODE: SORT_CODE3, ACCOUNT_NUMBER: ACCOUNT_NUMBER3 }, - FINANCIAL_ADDRESS: FINANCIAL_ADDRESS4 + FINANCIAL_ADDRESS: FINANCIAL_ADDRESS4, } = policy_default; var mapLossPayeeFinancialDetailsUk = (lossPayee) => { if (lossPayee[IS_LOCATED_IN_UK3]) { const mapped = [ xlsx_row_default(String(FIELDS14[SORT_CODE3]), lossPayee.financialUk[SORT_CODE3]), xlsx_row_default(String(FIELDS14[ACCOUNT_NUMBER3]), lossPayee.financialUk[ACCOUNT_NUMBER3]), - xlsx_row_default(String(FIELDS14[FINANCIAL_ADDRESS4]), lossPayee.financialUk[FINANCIAL_ADDRESS4]) + xlsx_row_default(String(FIELDS14[FINANCIAL_ADDRESS4]), lossPayee.financialUk[FINANCIAL_ADDRESS4]), ]; return mapped; } @@ -7744,14 +7782,18 @@ var map_financial_details_uk_default = mapLossPayeeFinancialDetailsUk; // generate-xlsx/map-application-to-XLSX/map-policy/map-loss-payee/index.ts var mapLossPayee = (lossPayee) => { - const mapped = [...map_appointed_loss_payee_default(lossPayee), ...map_financial_details_uk_default(lossPayee), ...map_financial_details_international_default(lossPayee)]; + const mapped = [ + ...map_appointed_loss_payee_default(lossPayee), + ...map_financial_details_uk_default(lossPayee), + ...map_financial_details_international_default(lossPayee), + ]; return mapped; }; var map_loss_payee_default = mapLossPayee; // generate-xlsx/map-application-to-XLSX/map-policy/index.ts var { - TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE7 } + TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE7 }, } = policy_default; var mapPolicy2 = (application2, countries) => { const { nominatedLossPayee, policy, policyContact } = application2; @@ -7769,7 +7811,7 @@ var mapPolicy2 = (application2, countries) => { ...map_credit_period_default(policy), ...map_jointly_insured_party_default(policy.jointlyInsuredParty, countries), ...map_broker_default(application2), - ...map_loss_payee_default(nominatedLossPayee) + ...map_loss_payee_default(nominatedLossPayee), ]; return mapped; }; @@ -7777,7 +7819,7 @@ var map_policy_default2 = mapPolicy2; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-different-trading-name/index.ts var { - YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME3, DIFFERENT_TRADING_NAME: DIFFERENT_TRADING_NAME2 } + YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME3, DIFFERENT_TRADING_NAME: DIFFERENT_TRADING_NAME2 }, } = business_default; var { FIELDS: FIELDS15 } = XLSX; var mapDifferentTradingName = (company) => { @@ -7789,7 +7831,7 @@ var map_different_trading_name_default = mapDifferentTradingName; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-different-trading-address/index.ts var { - ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: FULL_ADDRESS4, FULL_ADDRESS_DOT_NOTATION: FULL_ADDRESS_DOT_NOTATION2 } + ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: FULL_ADDRESS4, FULL_ADDRESS_DOT_NOTATION: FULL_ADDRESS_DOT_NOTATION2 }, } = business_default; var { FIELDS: FIELDS16 } = XLSX; var mapDifferentTradingAddress = (company) => { @@ -7802,14 +7844,14 @@ var mapDifferentTradingAddress = (company) => { var map_different_trading_address_default = mapDifferentTradingAddress; // generate-xlsx/map-application-to-XLSX/helpers/xlsx-new-line/index.ts -var NEW_LINE = "\r\n"; +var NEW_LINE = '\r\n'; var xlsx_new_line_default = NEW_LINE; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-exporter-address/index.ts var mapExporterAddress = (address) => { - let addressString = ""; + let addressString = ''; Object.keys(address).forEach((field) => { - if (address[field] && field !== "id" && field !== "__typename") { + if (address[field] && field !== 'id' && field !== '__typename') { addressString += `${address[field]}${xlsx_new_line_default}`; } }); @@ -7819,7 +7861,7 @@ var map_exporter_address_default = mapExporterAddress; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-financial-year-end-date/index.ts var { - COMPANIES_HOUSE: { FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE2 } + COMPANIES_HOUSE: { FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE2 }, } = business_default; var { FIELDS: FIELDS17 } = XLSX; var mapFinancialYearEndDate = (company) => { @@ -7832,7 +7874,7 @@ var map_financial_year_end_date_default = mapFinancialYearEndDate; // generate-xlsx/map-application-to-XLSX/map-exporter-business/map-sic-codes/index.ts var mapSicCodes2 = (sicCodes) => { - let mapped = ""; + let mapped = ''; sicCodes.forEach((sicCodeObj) => { const { sicCode, industrySectorName } = sicCodeObj; mapped += `${sicCode} - ${industrySectorName}${xlsx_new_line_default}`; @@ -7847,14 +7889,24 @@ var CONTENT_STRINGS6 = { ...EXPORTER_BUSINESS_FIELDS.COMPANY_DETAILS, ...EXPORTER_BUSINESS_FIELDS.NATURE_OF_YOUR_BUSINESS, ...EXPORTER_BUSINESS_FIELDS.TURNOVER, - ...EXPORTER_BUSINESS_FIELDS.BROKER + ...EXPORTER_BUSINESS_FIELDS.BROKER, }; var { - COMPANIES_HOUSE: { COMPANY_ADDRESS: COMPANY_ADDRESS2, COMPANY_INCORPORATED: COMPANY_INCORPORATED2, COMPANY_SIC: COMPANY_SIC2, FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE3 }, - YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME4, HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS3, PHONE_NUMBER: PHONE_NUMBER3, WEBSITE: WEBSITE3 }, + COMPANIES_HOUSE: { + COMPANY_ADDRESS: COMPANY_ADDRESS2, + COMPANY_INCORPORATED: COMPANY_INCORPORATED2, + COMPANY_SIC: COMPANY_SIC2, + FINANCIAL_YEAR_END_DATE: FINANCIAL_YEAR_END_DATE3, + }, + YOUR_COMPANY: { + HAS_DIFFERENT_TRADING_NAME: HAS_DIFFERENT_TRADING_NAME4, + HAS_DIFFERENT_TRADING_ADDRESS: HAS_DIFFERENT_TRADING_ADDRESS3, + PHONE_NUMBER: PHONE_NUMBER3, + WEBSITE: WEBSITE3, + }, NATURE_OF_YOUR_BUSINESS: { GOODS_OR_SERVICES: GOODS_OR_SERVICES3, YEARS_EXPORTING: YEARS_EXPORTING3, EMPLOYEES_UK: EMPLOYEES_UK3 }, TURNOVER: { ESTIMATED_ANNUAL_TURNOVER: ESTIMATED_ANNUAL_TURNOVER3, PERCENTAGE_TURNOVER: PERCENTAGE_TURNOVER2, TURNOVER_CURRENCY_CODE }, - HAS_CREDIT_CONTROL: HAS_CREDIT_CONTROL3 + HAS_CREDIT_CONTROL: HAS_CREDIT_CONTROL3, } = business_default; var mapExporterBusiness = (application2) => { const { business, company, companySicCodes } = application2; @@ -7872,9 +7924,12 @@ var mapExporterBusiness = (application2) => { xlsx_row_default(String(FIELDS18[YEARS_EXPORTING3]), business[YEARS_EXPORTING3]), xlsx_row_default(String(FIELDS18[EMPLOYEES_UK3]), business[EMPLOYEES_UK3]), xlsx_row_default(CONTENT_STRINGS6[FINANCIAL_YEAR_END_DATE3].SUMMARY?.TITLE, map_financial_year_end_date_default(company)), - xlsx_row_default(String(FIELDS18[ESTIMATED_ANNUAL_TURNOVER3]), format_currency_default2(business[ESTIMATED_ANNUAL_TURNOVER3], business[TURNOVER_CURRENCY_CODE])), + xlsx_row_default( + String(FIELDS18[ESTIMATED_ANNUAL_TURNOVER3]), + format_currency_default2(business[ESTIMATED_ANNUAL_TURNOVER3], business[TURNOVER_CURRENCY_CODE]), + ), xlsx_row_default(CONTENT_STRINGS6[PERCENTAGE_TURNOVER2].SUMMARY?.TITLE, `${business[PERCENTAGE_TURNOVER2]}%`), - xlsx_row_default(String(FIELDS18[HAS_CREDIT_CONTROL3]), map_yes_no_field_default({ answer: business[HAS_CREDIT_CONTROL3] })) + xlsx_row_default(String(FIELDS18[HAS_CREDIT_CONTROL3]), map_yes_no_field_default({ answer: business[HAS_CREDIT_CONTROL3] })), ]; return mapped; }; @@ -7893,7 +7948,11 @@ var map_connection_with_buyer_default = mapConnectionWithBuyer; // generate-xlsx/map-application-to-XLSX/map-buyer/map-outstanding-payments/index.ts var { CURRENCY: { CURRENCY_CODE: CURRENCY_CODE5 }, - YOUR_BUYER: { OUTSTANDING_PAYMENTS: OUTSTANDING_PAYMENTS3, TOTAL_OUTSTANDING_PAYMENTS: TOTAL_OUTSTANDING_PAYMENTS3, TOTAL_AMOUNT_OVERDUE: TOTAL_AMOUNT_OVERDUE2 } + YOUR_BUYER: { + OUTSTANDING_PAYMENTS: OUTSTANDING_PAYMENTS3, + TOTAL_OUTSTANDING_PAYMENTS: TOTAL_OUTSTANDING_PAYMENTS3, + TOTAL_AMOUNT_OVERDUE: TOTAL_AMOUNT_OVERDUE2, + }, } = insurance_default; var { FIELDS: FIELDS20 } = XLSX; var mapOutstandingPayments = (tradingHistory) => { @@ -7901,12 +7960,12 @@ var mapOutstandingPayments = (tradingHistory) => { const values = { currency: tradingHistory[CURRENCY_CODE5], totalOutstanding: format_currency_default(tradingHistory[TOTAL_OUTSTANDING_PAYMENTS3], tradingHistory[CURRENCY_CODE5]), - totalAmountOverdue: format_currency_default(tradingHistory[TOTAL_AMOUNT_OVERDUE2], tradingHistory[CURRENCY_CODE5]) + totalAmountOverdue: format_currency_default(tradingHistory[TOTAL_AMOUNT_OVERDUE2], tradingHistory[CURRENCY_CODE5]), }; const mapped = [ xlsx_row_default(String(FIELDS20[TOTAL_OUTSTANDING_PAYMENTS3]), values.totalOutstanding), xlsx_row_default(String(YOUR_BUYER_FIELDS[CURRENCY_CODE5].SUMMARY?.TITLE), values.currency), - xlsx_row_default(String(YOUR_BUYER_FIELDS[TOTAL_AMOUNT_OVERDUE2].SUMMARY?.TITLE), values.totalAmountOverdue) + xlsx_row_default(String(YOUR_BUYER_FIELDS[TOTAL_AMOUNT_OVERDUE2].SUMMARY?.TITLE), values.totalAmountOverdue), ]; return mapped; } @@ -7922,7 +7981,7 @@ var mapBuyerTradingHistory = (tradingHistory) => { const mapped = [ xlsx_row_default(String(FIELDS21[OUTSTANDING_PAYMENTS4]), map_yes_no_field_default({ answer: tradingHistory[OUTSTANDING_PAYMENTS4] })), ...map_outstanding_payments_default(tradingHistory), - xlsx_row_default(String(FIELDS21[FAILED_PAYMENTS3]), map_yes_no_field_default({ answer: tradingHistory[FAILED_PAYMENTS3] })) + xlsx_row_default(String(FIELDS21[FAILED_PAYMENTS3]), map_yes_no_field_default({ answer: tradingHistory[FAILED_PAYMENTS3] })), ]; return mapped; } @@ -7931,12 +7990,15 @@ var mapBuyerTradingHistory = (tradingHistory) => { var map_buyer_trading_history_default = mapBuyerTradingHistory; // generate-xlsx/map-application-to-XLSX/map-buyer/map-previous-cover-with-buyer/index.ts -var { HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3, PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3 } = your_buyer_default; +var { + HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3, + PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER: PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3, +} = your_buyer_default; var { FIELDS: FIELDS22 } = XLSX; var mapPreviousCoverWithBuyer = (application2) => { const { buyer: { relationship: relationship2 }, - totalContractValueOverThreshold + totalContractValueOverThreshold, } = application2; if (totalContractValueOverThreshold) { const answer = relationship2[HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER3]; @@ -7953,13 +8015,13 @@ var map_previous_cover_with_buyer_default = mapPreviousCoverWithBuyer; // generate-xlsx/map-application-to-XLSX/map-buyer/index.ts var CONTENT_STRINGS7 = { ...YOUR_BUYER_FIELDS.COMPANY_OR_ORGANISATION, - ...YOUR_BUYER_FIELDS + ...YOUR_BUYER_FIELDS, }; var { COMPANY_OR_ORGANISATION: { NAME: NAME3, ADDRESS, COUNTRY: COUNTRY3, REGISTRATION_NUMBER, WEBSITE: WEBSITE4 }, CONNECTION_WITH_BUYER: CONNECTION_WITH_BUYER4, HAS_BUYER_FINANCIAL_ACCOUNTS: HAS_BUYER_FINANCIAL_ACCOUNTS3, - TRADED_WITH_BUYER: TRADED_WITH_BUYER4 + TRADED_WITH_BUYER: TRADED_WITH_BUYER4, } = your_buyer_default; var { FIELDS: FIELDS23 } = XLSX; var mapBuyer = (application2) => { @@ -7975,7 +8037,7 @@ var mapBuyer = (application2) => { xlsx_row_default(String(FIELDS23[TRADED_WITH_BUYER4]), map_yes_no_field_default({ answer: buyerTradingHistory[TRADED_WITH_BUYER4] })), ...map_buyer_trading_history_default(buyerTradingHistory), ...map_previous_cover_with_buyer_default(application2), - xlsx_row_default(String(FIELDS23[HAS_BUYER_FINANCIAL_ACCOUNTS3]), map_yes_no_field_default({ answer: relationship2[HAS_BUYER_FINANCIAL_ACCOUNTS3] })) + xlsx_row_default(String(FIELDS23[HAS_BUYER_FINANCIAL_ACCOUNTS3]), map_yes_no_field_default({ answer: relationship2[HAS_BUYER_FINANCIAL_ACCOUNTS3] })), ]; return mapped; }; @@ -7985,7 +8047,7 @@ var map_buyer_default = mapBuyer; var { OTHER: OTHER2 } = EXPORT_CONTRACT_AWARD_METHOD; var CONTENT_STRINGS8 = EXPORT_CONTRACT_FIELDS.HOW_WAS_THE_CONTRACT_AWARDED; var { - HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD: AWARD_METHOD2, OTHER_AWARD_METHOD } + HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD: AWARD_METHOD2, OTHER_AWARD_METHOD }, } = export_contract_default; var mapHowWasTheContractAwarded = (exportContract) => { const submittedMethodId = exportContract.awardMethodId; @@ -8008,11 +8070,13 @@ var map_how_was_the_contract_awarded_default = mapHowWasTheContractAwarded; var CONTENT_STRINGS9 = EXPORT_CONTRACT_FIELDS.ABOUT_GOODS_OR_SERVICES; var { FIELDS: FIELDS24 } = XLSX; var { - ABOUT_GOODS_OR_SERVICES: { FINAL_DESTINATION: FINAL_DESTINATION2, FINAL_DESTINATION_KNOWN: FINAL_DESTINATION_KNOWN3 } + ABOUT_GOODS_OR_SERVICES: { FINAL_DESTINATION: FINAL_DESTINATION2, FINAL_DESTINATION_KNOWN: FINAL_DESTINATION_KNOWN3 }, } = export_contract_default; var mapFinalDestination = (exportContract, countries) => { const finalDestinationKnownAnswer = exportContract[FINAL_DESTINATION_KNOWN3]; - const mapped = [xlsx_row_default(String(FIELDS24.EXPORT_CONTRACT[FINAL_DESTINATION_KNOWN3]), map_yes_no_field_default({ answer: finalDestinationKnownAnswer }))]; + const mapped = [ + xlsx_row_default(String(FIELDS24.EXPORT_CONTRACT[FINAL_DESTINATION_KNOWN3]), map_yes_no_field_default({ answer: finalDestinationKnownAnswer })), + ]; if (finalDestinationKnownAnswer) { const country = get_country_by_iso_code_default(countries, exportContract[FINAL_DESTINATION2]); mapped.push(xlsx_row_default(String(CONTENT_STRINGS9[FINAL_DESTINATION2].SUMMARY?.TITLE), country.name)); @@ -8024,12 +8088,12 @@ var map_final_destination_default = mapFinalDestination; // generate-xlsx/map-application-to-XLSX/map-export-contract/map-private-market/index.ts var { FIELDS: FIELDS25 } = XLSX; var { - PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION: DECLINED_DESCRIPTION3 } + PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION: DECLINED_DESCRIPTION3 }, } = export_contract_default; var mapPrivateMarket = (application2) => { const { exportContract: { privateMarket }, - totalContractValueOverThreshold + totalContractValueOverThreshold, } = application2; if (totalContractValueOverThreshold) { const attempedPrivateMarketAnswer = privateMarket[ATTEMPTED]; @@ -8046,7 +8110,12 @@ var map_private_market_default = mapPrivateMarket; // generate-xlsx/map-application-to-XLSX/map-export-contract/map-agent/map-agent-charge/map-agent-charge-amount/index.ts var { FIELDS: FIELDS26 } = XLSX; var { - AGENT_CHARGES: { FIXED_SUM_AMOUNT: FIXED_SUM_AMOUNT2, FIXED_SUM_CURRENCY_CODE, PAYABLE_COUNTRY_CODE: PAYABLE_COUNTRY_CODE2, PERCENTAGE_CHARGE: PERCENTAGE_CHARGE2 } + AGENT_CHARGES: { + FIXED_SUM_AMOUNT: FIXED_SUM_AMOUNT2, + FIXED_SUM_CURRENCY_CODE, + PAYABLE_COUNTRY_CODE: PAYABLE_COUNTRY_CODE2, + PERCENTAGE_CHARGE: PERCENTAGE_CHARGE2, + }, } = export_contract_default; var mapAgentChargeAmount = (charge, countries) => { const country = get_country_by_iso_code_default(countries, charge[PAYABLE_COUNTRY_CODE2]); @@ -8067,7 +8136,7 @@ var map_agent_charge_amount_default = mapAgentChargeAmount; // generate-xlsx/map-application-to-XLSX/map-export-contract/map-agent/map-agent-charge/index.ts var { FIELDS: FIELDS27 } = XLSX; var { - AGENT_SERVICE: { IS_CHARGING: IS_CHARGING2 } + AGENT_SERVICE: { IS_CHARGING: IS_CHARGING2 }, } = export_contract_default; var mapAgentCharge = (service, countries) => { const { charge } = service; @@ -8085,7 +8154,7 @@ var { FIELDS: FIELDS28 } = XLSX; var { AGENT_DETAILS: { NAME: NAME4, FULL_ADDRESS: FULL_ADDRESS5, COUNTRY_CODE: COUNTRY_CODE3 }, AGENT_SERVICE: { SERVICE_DESCRIPTION: SERVICE_DESCRIPTION2 }, - USING_AGENT: USING_AGENT2 + USING_AGENT: USING_AGENT2, } = export_contract_default; var mapAgent = (agent, countries) => { const usingAgentAnswer = agent[USING_AGENT2]; @@ -8099,7 +8168,7 @@ var mapAgent = (agent, countries) => { xlsx_row_default(String(FIELDS28.AGENT[FULL_ADDRESS5]), agent[FULL_ADDRESS5]), xlsx_row_default(String(FIELDS28.AGENT[COUNTRY_CODE3]), country.name), xlsx_row_default(String(FIELDS28.AGENT_SERVICE[SERVICE_DESCRIPTION2]), service[SERVICE_DESCRIPTION2]), - ...map_agent_charge_default(service, countries) + ...map_agent_charge_default(service, countries), ]; } return mapped; @@ -8110,7 +8179,7 @@ var map_agent_default = mapAgent; var { FIELDS: FIELDS29 } = XLSX; var { ABOUT_GOODS_OR_SERVICES: { DESCRIPTION: DESCRIPTION3 }, - HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION: PAYMENT_TERMS_DESCRIPTION3 } + HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION: PAYMENT_TERMS_DESCRIPTION3 }, } = export_contract_default; var mapExportContract = (application2, countries) => { const { exportContract } = application2; @@ -8121,7 +8190,7 @@ var mapExportContract = (application2, countries) => { ...map_final_destination_default(exportContract, countries), xlsx_row_default(String(FIELDS29.EXPORT_CONTRACT[PAYMENT_TERMS_DESCRIPTION3]), exportContract[PAYMENT_TERMS_DESCRIPTION3]), ...map_private_market_default(application2), - ...map_agent_default(agent, countries) + ...map_agent_default(agent, countries), ]; return mapped; }; @@ -8144,8 +8213,8 @@ var { AGREE_ANTI_BRIBERY: AGREE_ANTI_BRIBERY2, HAS_ANTI_BRIBERY_CODE_OF_CONDUCT: HAS_ANTI_BRIBERY_CODE_OF_CONDUCT3, WILL_EXPORT_WITH_CODE_OF_CONDUCT: WILL_EXPORT_WITH_CODE_OF_CONDUCT3, - AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2 - } + AGREE_CONFIRMATION_ACKNOWLEDGEMENTS: AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2, + }, } = insurance_default; var mapDeclarations = (application2) => { const { declaration } = application2; @@ -8154,28 +8223,43 @@ var mapDeclarations = (application2) => { xlsx_row_default(DECLARATIONS_FIELDS[AGREE_ANTI_BRIBERY2].SUMMARY.TITLE, map_agreed_field_default(declaration[AGREE_ANTI_BRIBERY2])), xlsx_row_default(String(FIELDS30[HAS_ANTI_BRIBERY_CODE_OF_CONDUCT3]), map_yes_no_field_default({ answer: declaration[HAS_ANTI_BRIBERY_CODE_OF_CONDUCT3] })), xlsx_row_default(String(FIELDS30[WILL_EXPORT_WITH_CODE_OF_CONDUCT3]), map_yes_no_field_default({ answer: declaration[WILL_EXPORT_WITH_CODE_OF_CONDUCT3] })), - xlsx_row_default(DECLARATIONS_FIELDS[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2].SUMMARY.TITLE, map_agreed_field_default(declaration[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2])) + xlsx_row_default( + DECLARATIONS_FIELDS[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2].SUMMARY.TITLE, + map_agreed_field_default(declaration[AGREE_CONFIRMATION_ACKNOWLEDGEMENTS2]), + ), ]; return mapped; }; var map_declarations_default = mapDeclarations; // generate-xlsx/map-application-to-XLSX/index.ts -var { APPLICATION_INFORMATION, ELIGIBILITY: ELIGIBILITY2, EXPORTER_BUSINESS: EXPORTER_BUSINESS3, POLICY: POLICY4, BUYER, EXPORT_CONTRACT: EXPORT_CONTRACT2, DECLARATIONS: DECLARATIONS3 } = SECTION_NAMES_default; +var { + APPLICATION_INFORMATION, + ELIGIBILITY: ELIGIBILITY2, + EXPORTER_BUSINESS: EXPORTER_BUSINESS3, + POLICY: POLICY4, + BUYER, + EXPORT_CONTRACT: EXPORT_CONTRACT2, + DECLARATIONS: DECLARATIONS3, +} = SECTION_NAMES_default; var mapApplicationToXLSX = (application2, countries) => { try { const mapped = { - [APPLICATION_INFORMATION]: [...map_introduction_default(application2), ...map_exporter_contact_details_default(application2), ...map_key_information_default(application2)], + [APPLICATION_INFORMATION]: [ + ...map_introduction_default(application2), + ...map_exporter_contact_details_default(application2), + ...map_key_information_default(application2), + ], [ELIGIBILITY2]: map_eligibility_default(application2), [EXPORTER_BUSINESS3]: map_exporter_business_default(application2), [POLICY4]: map_policy_default2(application2, countries), [BUYER]: map_buyer_default(application2), [EXPORT_CONTRACT2]: map_export_contract_default(application2, countries), - [DECLARATIONS3]: map_declarations_default(application2) + [DECLARATIONS3]: map_declarations_default(application2), }; return mapped; } catch (error) { - console.error("Error mapping application to XLSX %o", error); + console.error('Error mapping application to XLSX %o', error); throw new Error(`Mapping application to XLSX ${error}`); } }; @@ -8185,7 +8269,7 @@ var map_application_to_XLSX_default = mapApplicationToXLSX; var { KEY: KEY2, VALUE: VALUE2, COLUMN_WIDTH } = XLSX_CONFIG; var XLSX_HEADER_COLUMNS = (sheetName) => [ { key: KEY2, header: sheetName, width: COLUMN_WIDTH }, - { key: VALUE2, width: COLUMN_WIDTH } + { key: VALUE2, width: COLUMN_WIDTH }, ]; var header_columns_default = XLSX_HEADER_COLUMNS; @@ -8193,14 +8277,14 @@ var header_columns_default = XLSX_HEADER_COLUMNS; var DEFAULT_INDEXES = () => ({ REGISTERED_OFFICE_ADDRESS: 3, COMPANY_SIC_CODES: 4, - ALTERNATIVE_TRADING_ADDRESS: 0 + ALTERNATIVE_TRADING_ADDRESS: 0, }); var EXPORTER_BUSINESS_INDEXES = (application2) => { const { company: { differentTradingAddress: { fullAddress: hasDifferentTradingAddress }, - hasDifferentTradingName - } + hasDifferentTradingName, + }, } = application2; const INDEXES = DEFAULT_INDEXES(); if (hasDifferentTradingAddress) { @@ -8220,9 +8304,9 @@ var BROKER_CONDITIONS = (application2, INDEXES) => { broker, policy: { jointlyInsuredParty: { requested: requestedJointlyInsuredParty }, - needPreCreditPeriodCover + needPreCreditPeriodCover, }, - policyContact: { isSameAsOwner: policyContactIsSameAsOwner } + policyContact: { isSameAsOwner: policyContactIsSameAsOwner }, } = application2; const MODIFIED_INDEXES = INDEXES; if (broker[USING_BROKER4]) { @@ -8248,9 +8332,9 @@ var LOSS_PAYEE_CONDITIONS = (application2, INDEXES) => { nominatedLossPayee: { isAppointed: nominatedLossPayeeAppointed }, policy: { jointlyInsuredParty: { requested: requestedJointlyInsuredParty }, - needPreCreditPeriodCover + needPreCreditPeriodCover, }, - policyContact: { isSameAsOwner: policyContactIsSameAsOwner } + policyContact: { isSameAsOwner: policyContactIsSameAsOwner }, } = application2; const MODIFIED_INDEXES = INDEXES; if (nominatedLossPayeeAppointed) { @@ -8275,18 +8359,18 @@ var LOSS_PAYEE_CONDITIONS_default = LOSS_PAYEE_CONDITIONS; var { TYPE_OF_POLICY: { POLICY_TYPE: POLICY_TYPE8 }, USING_BROKER: USING_BROKER6, - NAME_ON_POLICY: { IS_SAME_AS_OWNER: IS_SAME_AS_OWNER2 } + NAME_ON_POLICY: { IS_SAME_AS_OWNER: IS_SAME_AS_OWNER2 }, } = policy_default; var DEFAULT_INDEXES2 = { BROKER_ADDRESS: 0, - LOSS_PAYEE_ADDRESS: 0 + LOSS_PAYEE_ADDRESS: 0, }; var POLICY_INDEXES = (application2) => { const { broker, nominatedLossPayee: { isAppointed: nominatedLossPayeeAppointed }, policy, - policyContact + policyContact, } = application2; const isMultiplePolicy = isMultiplePolicyType(policy[POLICY_TYPE8]); let INDEXES = DEFAULT_INDEXES2; @@ -8309,7 +8393,7 @@ var POLICY_INDEXES = (application2) => { INDEXES = { ...INDEXES, ...BROKER_CONDITIONS_default(application2, INDEXES), - ...LOSS_PAYEE_CONDITIONS_default(application2, INDEXES) + ...LOSS_PAYEE_CONDITIONS_default(application2, INDEXES), }; return INDEXES; }; @@ -8317,13 +8401,13 @@ var POLICY_default = POLICY_INDEXES; // constants/XLSX-CONFIG/INDEXES/BUYER/index.ts var BUYER_INDEXES = () => ({ - BUYER_ADDRESS: 3 + BUYER_ADDRESS: 3, }); var BUYER_default = BUYER_INDEXES; // constants/XLSX-CONFIG/INDEXES/EXPORT_CONTRACT/index.ts var DEFAULT_INDEXES3 = () => ({ - AGENT_ADDRESS: 0 + AGENT_ADDRESS: 0, }); var EXPORT_CONTRACT_INDEXES = (application2) => { const { exportContract } = application2; @@ -8348,7 +8432,7 @@ var XLSX_ROW_INDEXES = { [EXPORTER_BUSINESS4]: (application2) => EXPORTER_BUSINESS_default(application2), [POLICY5]: (application2) => POLICY_default(application2), [BUYER2]: () => BUYER_default(), - [EXPORT_CONTRACT3]: (application2) => EXPORT_CONTRACT_default(application2) + [EXPORT_CONTRACT3]: (application2) => EXPORT_CONTRACT_default(application2), }; var INDEXES_default = XLSX_ROW_INDEXES; @@ -8374,8 +8458,8 @@ var styledColumns = (application2, worksheet, sheetName) => { row.eachCell((cell, colNumber) => { const modifiedRow = row; modifiedRow.getCell(colNumber).alignment = { - vertical: "top", - wrapText: true + vertical: 'top', + wrapText: true, }; const isInformationSheet = sheetName === APPLICATION_INFORMATION2; const isInformationTitleOne = isInformationSheet && rowNumber === 8; @@ -8384,7 +8468,7 @@ var styledColumns = (application2, worksheet, sheetName) => { const isTitleRow = rowNumber === 1 || isInformationTitle; modifiedRow.getCell(colNumber).font = { bold: Boolean(isTitleRow), - size: isTitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT + size: isTitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT, }; }); }); @@ -8403,51 +8487,51 @@ import_dotenv9.default.config(); var { EXCELJS_PROTECTION_PASSWORD } = process.env; var XLSX2 = (application2, countries) => { try { - console.info("Generating XLSX file for application %s", application2.id); + console.info('Generating XLSX file for application %s', application2.id); const { referenceNumber } = application2; const refNumber = String(referenceNumber); return new Promise((resolve) => { const filePath = `XLSX/${refNumber}.xlsx`; const xlsxData = map_application_to_XLSX_default(application2, countries); - console.info("Generating XLSX file - creating a new workbook"); + console.info('Generating XLSX file - creating a new workbook'); const workbook = new import_exceljs.default.Workbook(); - console.info("Generating XLSX file - adding worksheets to workbook"); + console.info('Generating XLSX file - adding worksheets to workbook'); const sheetNames = Object.values(SECTION_NAMES_default); sheetNames.forEach((sheetName) => { - console.info("Generating XLSX file - adding %s worksheet", sheetName); + console.info('Generating XLSX file - adding %s worksheet', sheetName); let worksheet = workbook.addWorksheet(sheetName); - console.info("Generating XLSX file - protecting %s worksheet from modification", sheetName); + console.info('Generating XLSX file - protecting %s worksheet from modification', sheetName); worksheet.protect(String(EXCELJS_PROTECTION_PASSWORD), {}); - console.info("Generating XLSX file - adding %s worksheet header columns", sheetName); + console.info('Generating XLSX file - adding %s worksheet header columns', sheetName); worksheet.columns = header_columns_default(sheetName); xlsxData[sheetName].forEach((row) => { - console.info("Generating XLSX file - adding rows to %s worksheeet", sheetName); + console.info('Generating XLSX file - adding rows to %s worksheeet', sheetName); if (row) { worksheet.addRow(row); } }); - console.info("Generating XLSX file - adding custom styles to %s worksheet", sheetName); + console.info('Generating XLSX file - adding custom styles to %s worksheet', sheetName); worksheet = styled_columns_default(application2, worksheet, sheetName); }); - console.info("Generating XLSX file - writing file"); + console.info('Generating XLSX file - writing file'); workbook.xlsx.writeFile(filePath).then(() => resolve(filePath)); }); } catch (error) { - console.error("Error generating XLSX file %o", error); + console.error('Error generating XLSX file %o', error); throw new Error(`Generating XLSX file ${error}`); } }; var generate2 = { - XLSX: XLSX2 + XLSX: XLSX2, }; var generate_xlsx_default = generate2; // custom-resolvers/mutations/submit-application/index.ts var submitApplication = async (root, variables, context) => { try { - console.info("Submitting application %s", variables.applicationId); + console.info('Submitting application %s', variables.applicationId); const application2 = await context.db.Application.findOne({ - where: { id: variables.applicationId } + where: { id: variables.applicationId }, }); if (application2) { const { status, submissionDeadline, submissionCount } = application2; @@ -8457,39 +8541,39 @@ var submitApplication = async (root, variables, context) => { const isFirstSubmission = submissionCount === 0; const canSubmit = isInProgress && validSubmissionDate && isFirstSubmission; if (canSubmit) { - console.info("Submitting application - updating status, submission date and count %s", variables.applicationId); + console.info('Submitting application - updating status, submission date and count %s', variables.applicationId); const update2 = { status: APPLICATION.STATUS.SUBMITTED, previousStatus: APPLICATION.STATUS.IN_PROGRESS, submissionDate: now2, - submissionCount: submissionCount + 1 + submissionCount: submissionCount + 1, }; const updatedApplication = await context.db.Application.updateOne({ where: { id: application2.id }, - data: update2 + data: update2, }); - console.info("Submitting application - getting populated application %s", variables.applicationId); + console.info('Submitting application - getting populated application %s', variables.applicationId); const populatedApplication2 = await get_populated_application_default.get({ context, application: updatedApplication, decryptFinancialUk: true, - decryptFinancialInternational: true + decryptFinancialInternational: true, }); const countries = await get_countries_default(context); const xlsxPath = await generate_xlsx_default.XLSX(populatedApplication2, countries); await send_application_submitted_emails_default.send(populatedApplication2, xlsxPath); return { - success: true + success: true, }; } - console.error("Unable to submit application - application already submitted"); + console.error('Unable to submit application - application already submitted'); } - console.error("Unable to submit application - no application found"); + console.error('Unable to submit application - no application found'); return { - success: false + success: false, }; } catch (error) { - console.error("Error submitting application %o", error); + console.error('Error submitting application %o', error); throw new Error(`Submitting application ${error}`); } }; @@ -8497,105 +8581,110 @@ var submit_application_default = submitApplication; // custom-resolvers/mutations/create-feedback/index.ts var createFeedback = async (root, variables, context) => { - console.info("Creating feedback"); + console.info('Creating feedback'); try { const feedback = { ...variables, - createdAt: /* @__PURE__ */ new Date() + createdAt: /* @__PURE__ */ new Date(), }; const response = await context.db.Feedback.createOne({ - data: feedback + data: feedback, }); const emailResponse = await emails_default.insuranceFeedbackEmail(feedback); if (response && emailResponse?.success) { return { ...response, - success: true + success: true, }; } return { success: false }; } catch (error) { - console.error("Error creating feedback %o", error); + console.error('Error creating feedback %o', error); throw new Error(`Creating feedback: ${error}`); } }; var create_feedback_default = createFeedback; // custom-resolvers/mutations/verify-account-reactivation-token/index.ts -var import_date_fns7 = require("date-fns"); +var import_date_fns7 = require('date-fns'); var { INSURANCE: { - ACCOUNT: { REACTIVATION_HASH, REACTIVATION_EXPIRY } - } + ACCOUNT: { REACTIVATION_HASH, REACTIVATION_EXPIRY }, + }, } = FIELD_IDS; var verifyAccountReactivationToken = async (root, variables, context) => { try { - console.info("Received a request to reactivate account - checking account"); + console.info('Received a request to reactivate account - checking account'); const account2 = await get_account_by_field_default(context, REACTIVATION_HASH, variables.token); if (account2) { - console.info("Received a request to reactivate account - found account %s", account2.id); + console.info('Received a request to reactivate account - found account %s', account2.id); const now2 = /* @__PURE__ */ new Date(); const canReactivateAccount = (0, import_date_fns7.isBefore)(now2, account2[REACTIVATION_EXPIRY]); if (!canReactivateAccount) { - console.info("Unable to reactivate account - reactivation period has expired"); + console.info('Unable to reactivate account - reactivation period has expired'); return { expired: true, success: false, - accountId: account2.id + accountId: account2.id, }; } - console.info("Reactivating account %s", account2.id); + console.info('Reactivating account %s', account2.id); const accountUpdate = { - reactivationHash: "", - reactivationExpiry: null + reactivationHash: '', + reactivationExpiry: null, }; const statusUpdate = { isBlocked: false, - isVerified: true + isVerified: true, }; await update_account_default.account(context, account2.id, accountUpdate); await update_account_default.accountStatus(context, account2.status.id, statusUpdate); await delete_authentication_retries_default(context, account2.id); return { - success: true + success: true, }; } - console.info("Unable to reactivate account - no account found from the provided %s", REACTIVATION_HASH); + console.info('Unable to reactivate account - no account found from the provided %s', REACTIVATION_HASH); return { success: false, - invalid: true + invalid: true, }; } catch (error) { - console.error("Error checking account and reactivating account(verifyAccountReactivationToken mutation) %o", error); + console.error('Error checking account and reactivating account(verifyAccountReactivationToken mutation) %o', error); throw new Error(`Checking account and reactivating account(verifyAccountReactivationToken mutation) ${error}`); } }; var verify_account_reactivation_token_default = verifyAccountReactivationToken; // helpers/encrypt/index.ts -var import_crypto12 = __toESM(require("crypto")); +var import_crypto12 = __toESM(require('crypto')); // helpers/encrypt/generate-initialisation-vector/index.ts -var import_crypto11 = __toESM(require("crypto")); +var import_crypto11 = __toESM(require('crypto')); var { BYTES_SIZE, ENCODING: ENCODING3, SLICE_INDEX_START, SLICE_INDEX_END } = FINANCIAL_DETAILS.ENCRYPTION.IV; var generateInitialisationVector = () => import_crypto11.default.randomBytes(BYTES_SIZE).toString(ENCODING3).slice(SLICE_INDEX_START, SLICE_INDEX_END); var generate_initialisation_vector_default = generateInitialisationVector; // helpers/encrypt/index.ts -var { ENCRYPTION_METHOD: ENCRYPTION_METHOD2, ENCODING: ENCODING4, STRING_ENCODING: STRING_ENCODING3, OUTPUT_ENCODING: OUTPUT_ENCODING3 } = FINANCIAL_DETAILS.ENCRYPTION.CIPHER; +var { + ENCRYPTION_METHOD: ENCRYPTION_METHOD2, + ENCODING: ENCODING4, + STRING_ENCODING: STRING_ENCODING3, + OUTPUT_ENCODING: OUTPUT_ENCODING3, +} = FINANCIAL_DETAILS.ENCRYPTION.CIPHER; var encrypt = (dataToEncrypt) => { try { - console.info("Encrypting data"); + console.info('Encrypting data'); const key2 = generate_key_default(); const iv = generate_initialisation_vector_default(); const cipher = import_crypto12.default.createCipheriv(ENCRYPTION_METHOD2, key2, iv); const value = Buffer.from(cipher.update(dataToEncrypt, OUTPUT_ENCODING3, ENCODING4).concat(cipher.final(ENCODING4))).toString(STRING_ENCODING3); return { value, - iv + iv, }; } catch (error) { - console.error("Error encrypting data %o", error); + console.error('Error encrypting data %o', error); throw new Error(`Error encrypting data ${error}`); } }; @@ -8604,7 +8693,7 @@ var encrypt_default = encrypt; // helpers/map-loss-payee-financial-details-uk/index.ts var mapLossPayeeFinancialDetailsUk2 = (variables) => { try { - console.info("Mapping loss payee financial UK"); + console.info('Mapping loss payee financial UK'); const { accountNumber, sortCode, bankAddress } = variables; let accountNumberData = DEFAULT_ENCRYPTION_SAVE_OBJECT; let sortCodeData = DEFAULT_ENCRYPTION_SAVE_OBJECT; @@ -8618,16 +8707,16 @@ var mapLossPayeeFinancialDetailsUk2 = (variables) => { uk: { accountNumber: accountNumberData.value, sortCode: sortCodeData.value, - bankAddress + bankAddress, }, vectors: { accountNumberVector: accountNumberData.iv, - sortCodeVector: sortCodeData.iv - } + sortCodeVector: sortCodeData.iv, + }, }; return updateData; } catch (error) { - console.error("Error mapping loss payee financial UK %o", error); + console.error('Error mapping loss payee financial UK %o', error); throw new Error(`Error mapping loss payee financial UK ${error}`); } }; @@ -8636,16 +8725,16 @@ var map_loss_payee_financial_details_uk_default = mapLossPayeeFinancialDetailsUk // helpers/update-loss-payee-financial-uk/index.ts var updateLossPayeeFinancialInternationalUk = async (context, id, data) => { try { - console.info("Updating loss payee financial uk (helper) %s", id); + console.info('Updating loss payee financial uk (helper) %s', id); const updated = await context.db.LossPayeeFinancialUk.updateOne({ where: { - id + id, }, - data + data, }); return updated; } catch (error) { - console.error("Error updating loss payee financial uk (helper) %o", error); + console.error('Error updating loss payee financial uk (helper) %o', error); throw new Error(`Updating loss payee financial uk (helper) ${error}`); } }; @@ -8654,16 +8743,16 @@ var update_loss_payee_financial_uk_default = updateLossPayeeFinancialInternation // helpers/update-loss-payee-financial-uk-vector/index.ts var updateLossPayeeFinancialUkVector = async (context, id, data) => { try { - console.info("Updating loss payee financial uk vector (helper) %s", id); + console.info('Updating loss payee financial uk vector (helper) %s', id); const updated = await context.db.LossPayeeFinancialUkVector.updateOne({ where: { - id + id, }, - data + data, }); return updated; } catch (error) { - console.error("Error updating loss payee financial uk vector (helper) %o", error); + console.error('Error updating loss payee financial uk vector (helper) %o', error); throw new Error(`Updating loss payee financial uk vector (helper) ${error}`); } }; @@ -8672,21 +8761,21 @@ var update_loss_payee_financial_uk_vector_default = updateLossPayeeFinancialUkVe // custom-resolvers/mutations/update-loss-payee-financial-details-uk/index.ts var updateLossPayeeFinancialDetailsUk = async (root, variables, context) => { try { - console.info("Updating loss payee financial UK %s", variables.id); + console.info('Updating loss payee financial UK %s', variables.id); const { id } = variables; const mappedData = map_loss_payee_financial_details_uk_default(variables); const uk = await update_loss_payee_financial_uk_default(context, id, mappedData.uk); const vector = await update_loss_payee_financial_uk_vector_default(context, String(uk.vectorId), mappedData.vectors); if (uk && vector) { return { - success: true + success: true, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error updating loss payee financial UK %o", error); + console.error('Error updating loss payee financial UK %o', error); throw new Error(`Updating loss payee financial UK ${error}`); } }; @@ -8708,16 +8797,16 @@ var mapLossPayeeFinancialDetailsInternational2 = (variables) => { international: { iban: ibanData.value, bicSwiftCode: bicSwiftCodeData.value, - bankAddress + bankAddress, }, vectors: { ibanVector: ibanData.iv, - bicSwiftCodeVector: bicSwiftCodeData.iv - } + bicSwiftCodeVector: bicSwiftCodeData.iv, + }, }; return updateData; } catch (error) { - console.error("Error mapping loss payee financial international %o", error); + console.error('Error mapping loss payee financial international %o', error); throw new Error(`Error mapping loss payee financial international ${error}`); } }; @@ -8726,16 +8815,16 @@ var map_loss_payee_financial_details_international_default = mapLossPayeeFinanci // helpers/update-loss-payee-financial-international/index.ts var updateLossPayeeFinancialInternational = async (context, id, data) => { try { - console.info("Updating loss payee financial international (helper) %s", id); + console.info('Updating loss payee financial international (helper) %s', id); const updated = await context.db.LossPayeeFinancialInternational.updateOne({ where: { - id + id, }, - data + data, }); return updated; } catch (error) { - console.error("Error updating loss payee financial international (helper) %o", error); + console.error('Error updating loss payee financial international (helper) %o', error); throw new Error(`Updating loss payee financial international (helper) ${error}`); } }; @@ -8744,16 +8833,16 @@ var update_loss_payee_financial_international_default = updateLossPayeeFinancial // helpers/update-loss-payee-financial-international-vector/index.ts var updateLossPayeeFinancialInternationalVector = async (context, id, data) => { try { - console.info("Updating loss payee financial international vector (helper) %s", id); + console.info('Updating loss payee financial international vector (helper) %s', id); const updated = await context.db.LossPayeeFinancialInternationalVector.updateOne({ where: { - id + id, }, - data + data, }); return updated; } catch (error) { - console.error("Error updating loss payee financial international vector (helper) %o", error); + console.error('Error updating loss payee financial international vector (helper) %o', error); throw new Error(`Updating loss payee financial international vector (helper) ${error}`); } }; @@ -8762,21 +8851,21 @@ var update_loss_payee_financial_international_vector_default = updateLossPayeeFi // custom-resolvers/mutations/update-loss-payee-financial-details-international/index.ts var updateLossPayeeFinancialDetailsInternational = async (root, variables, context) => { try { - console.info("Updating loss payee financial international %s", variables.id); + console.info('Updating loss payee financial international %s', variables.id); const { id } = variables; const mappedData = map_loss_payee_financial_details_international_default(variables); const international = await update_loss_payee_financial_international_default(context, id, mappedData.international); const vector = await update_loss_payee_financial_international_vector_default(context, String(international.vectorId), mappedData.vectors); if (international && vector) { return { - success: true + success: true, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error updating loss payee financial international %o", error); + console.error('Error updating loss payee financial international %o', error); throw new Error(`Updating loss payee financial international ${error}`); } }; @@ -8784,94 +8873,94 @@ var update_loss_payee_financial_details_international_default = updateLossPayeeF // custom-resolvers/queries/get-account-password-reset-token/index.ts var getAccountPasswordResetToken = async (root, variables, context) => { - console.info("Getting account password reset token"); + console.info('Getting account password reset token'); try { const { email } = variables; const account2 = await get_account_by_field_default(context, account_default.EMAIL, email); if (!account2) { - console.info("Unable to get account password reset token - account does not exist"); + console.info('Unable to get account password reset token - account does not exist'); return { success: false }; } if (account2.passwordResetHash) { return { success: true, - token: account2.passwordResetHash + token: account2.passwordResetHash, }; } - console.info("Unable to get account password reset token - reset hash does not exist"); + console.info('Unable to get account password reset token - reset hash does not exist'); return { success: false }; } catch (error) { - console.error("Error getting account password reset token %o", error); + console.error('Error getting account password reset token %o', error); throw new Error(`Getting account password reset token ${error}`); } }; var get_account_password_reset_token_default = getAccountPasswordResetToken; // integrations/APIM/index.ts -var import_axios = __toESM(require("axios")); -var import_dotenv10 = __toESM(require("dotenv")); +var import_axios = __toESM(require('axios')); +var import_dotenv10 = __toESM(require('dotenv')); import_dotenv10.default.config(); var { APIM_MDM_URL, APIM_MDM_KEY, APIM_MDM_VALUE } = process.env; var { APIM_MDM } = EXTERNAL_API_ENDPOINTS; var APIM = { getCisCountries: async () => { try { - console.info("Calling APIM - CIS countries"); + console.info('Calling APIM - CIS countries'); const response = await (0, import_axios.default)({ - method: "get", + method: 'get', url: `${APIM_MDM_URL}${APIM_MDM.MARKETS}`, headers: { - "Content-Type": "application/json", - [String(APIM_MDM_KEY)]: APIM_MDM_VALUE + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, }, validateStatus(status) { const acceptableStatus = [200]; return acceptableStatus.includes(status); - } + }, }); if (response.data && response.status === 200) { return { success: true, - data: response.data + data: response.data, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error calling APIM - CIS countries %o", error); + console.error('Error calling APIM - CIS countries %o', error); throw new Error(`Calling APIM - CIS countries ${error}`); } }, getCurrencies: async () => { try { - console.info("Calling APIM - currencies"); + console.info('Calling APIM - currencies'); const response = await (0, import_axios.default)({ - method: "get", + method: 'get', url: `${APIM_MDM_URL}${APIM_MDM.CURRENCY}`, headers: { - "Content-Type": "application/json", - [String(APIM_MDM_KEY)]: APIM_MDM_VALUE + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, }, validateStatus(status) { const acceptableStatus = [200]; return acceptableStatus.includes(status); - } + }, }); if (response.data && response.status === 200) { return { success: true, - data: response.data + data: response.data, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error calling APIM - currencies %o", error); + console.error('Error calling APIM - currencies %o', error); throw new Error(`Calling APIM - currencies ${error}`); } - } + }, }; var APIM_default = APIM; @@ -8884,7 +8973,7 @@ var filter_cis_entries_default = filterCisEntries; // helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts var { - CIS: { ESRA_CLASSIFICATION } + CIS: { ESRA_CLASSIFICATION }, } = EXTERNAL_API_DEFINITIONS; var mapEsraClassification = (str) => { if (str === ESRA_CLASSIFICATION.STANDARD) { @@ -8902,7 +8991,7 @@ var map_esra_classification_default = mapEsraClassification; // helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts var { - CIS: { SHORT_TERM_COVER } + CIS: { SHORT_TERM_COVER }, } = EXTERNAL_API_DEFINITIONS; var mapShortTermCoverAvailable = (str) => { switch (str) { @@ -8933,8 +9022,8 @@ var map_NBI_issue_available_default = mapNbiIssueAvailable; // helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts var { CIS: { - ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH } - } + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + }, } = EXTERNAL_API_DEFINITIONS; var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { switch (esraClassification) { @@ -8953,8 +9042,8 @@ var esra_classification_is_standard_high_or_very_high_default = esraClassificati // helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts var { CIS: { - SHORT_TERM_COVER: { YES: YES2, REFER, UNLISTED } - } + SHORT_TERM_COVER: { YES: YES2, REFER, UNLISTED }, + }, } = EXTERNAL_API_DEFINITIONS; var shortTermCoverIsYesReferOrUnlisted = (shortTermCover) => { switch (shortTermCover) { @@ -8972,7 +9061,7 @@ var short_term_cover_is_yes_refer_or_unlisted_default = shortTermCoverIsYesRefer // helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts var { - CIS: { COUNTRY_RATINGS } + CIS: { COUNTRY_RATINGS }, } = EXTERNAL_API_DEFINITIONS; var countryRatingIsAorB = (rating) => { if (COUNTRY_RATINGS.A.includes(rating)) { @@ -8988,7 +9077,10 @@ var country_rating_is_a_or_b_default = countryRatingIsAorB; // helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts var canGetAQuoteOnline = (cisCountry) => { const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; - const conditions = esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && country_rating_is_a_or_b_default(countryRatingDesc); + const conditions = + esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && + short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && + country_rating_is_a_or_b_default(countryRatingDesc); return conditions; }; var can_get_a_quote_online_default = canGetAQuoteOnline; @@ -9002,20 +9094,11 @@ var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassificati }; var can_get_a_quote_by_email_default = canGetAQuoteByEmail; -// helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts -var cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { - if (!esraClassification || !shortTermCover && !nbiIssueAvailable) { - return true; - } - return false; -}; -var cannot_get_a_quote_default = cannotGetAQuote; - // helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts var { CIS: { - SHORT_TERM_COVER: { ILC, CILC, REFER: REFER2 } - } + SHORT_TERM_COVER: { ILC, CILC, REFER: REFER2 }, + }, } = EXTERNAL_API_DEFINITIONS; var canApplyForAQuoteOffline = (originalShortTermCover) => { if (originalShortTermCover === ILC) { @@ -9034,7 +9117,10 @@ var can_apply_for_quote_offline_default = canApplyForAQuoteOffline; // helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts var canApplyForInsuranceOnline = (cisCountry) => { const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; - const conditions = esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && country_rating_is_a_or_b_default(countryRatingDesc); + const conditions = + esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && + short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && + country_rating_is_a_or_b_default(countryRatingDesc); return conditions; }; var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; @@ -9043,8 +9129,8 @@ var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE }, - SHORT_TERM_COVER: { NO: NO2, ILC: ILC2, CILC: CILC2 } - } + SHORT_TERM_COVER: { NO: NO2, ILC: ILC2, CILC: CILC2 }, + }, } = EXTERNAL_API_DEFINITIONS; var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_a_or_b_default(countryRating)) { @@ -9070,7 +9156,7 @@ var a_and_b_rating_conditions_default = aAndBRatingConditions; // helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts var { - CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 } + CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 }, } = EXTERNAL_API_DEFINITIONS; var countryRatingIsCorD = (rating) => { if (COUNTRY_RATINGS2.C.includes(rating)) { @@ -9087,8 +9173,8 @@ var country_rating_is_c_or_d_default = countryRatingIsCorD; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE2 }, - SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC3, CILC: CILC3, REFER: REFER3, UNLISTED: UNLISTED2 } - } + SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC3, CILC: CILC3, REFER: REFER3, UNLISTED: UNLISTED2 }, + }, } = EXTERNAL_API_DEFINITIONS; var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_c_or_d_default(countryRating)) { @@ -9126,31 +9212,32 @@ var noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCo const aAndBConditions = a_and_b_rating_conditions_default({ countryRating, esraClassification, - shortTermCover + shortTermCover, }); const cAndDConditions = c_and_d_rating_conditions_default({ countryRating, esraClassification, - shortTermCover + shortTermCover, }); const conditions = aAndBConditions || cAndDConditions; return conditions; }; var no_online_insurance_support_default = noOnlineInsuranceSupport; -// helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts +// helpers/map-CIS-countries/map-CIS-country/no-support/index.ts var { CIS: { COUNTRY_RATINGS: { NOT_APPLICABLE }, ESRA_CLASSIFICATION: { NONE: NONE3 }, - SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC4 } - } + SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC4 }, + }, } = EXTERNAL_API_DEFINITIONS; -var noInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }) => { +var noSupport = ({ countryRating, esraClassification, shortTermCover }) => { const shortTermCoverIsUnlisted = shortTermCover === UNLISTED3; const esraClassificationIsNone = esraClassification === NONE3; const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; - const countryRatingConditions = country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; + const countryRatingConditions = + country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { return true; } @@ -9160,7 +9247,7 @@ var noInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }) } return false; }; -var no_insurance_support_default = noInsuranceSupport; +var no_support_default = noSupport; // helpers/map-CIS-countries/map-CIS-country/index.ts var mapCisCountry = (cisCountry) => { @@ -9179,18 +9266,22 @@ var mapCisCountry = (cisCountry) => { canGetAQuoteOnline: can_get_a_quote_online_default(cisCountry), canGetAQuoteOffline: can_apply_for_quote_offline_default(cisCountry.shortTermCoverAvailabilityDesc), canGetAQuoteByEmail: can_get_a_quote_by_email_default({ shortTermCover, nbiIssueAvailable, esraClassification }), - cannotGetAQuote: cannot_get_a_quote_default({ shortTermCover, nbiIssueAvailable, esraClassification }), + cannotGetAQuote: no_support_default({ + countryRating, + esraClassification: ESRAClassificationDesc, + shortTermCover: shortTermCoverAvailabilityDesc, + }), canApplyForInsuranceOnline: can_apply_for_insurance_online_default(cisCountry), noOnlineInsuranceSupport: no_online_insurance_support_default({ countryRating, esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc + shortTermCover: shortTermCoverAvailabilityDesc, }), - noInsuranceSupport: no_insurance_support_default({ + noInsuranceSupport: no_support_default({ countryRating, esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc - }) + shortTermCover: shortTermCoverAvailabilityDesc, + }), }; return mapped; }; @@ -9206,9 +9297,9 @@ var sort_array_alphabetically_default = sortArrayAlphabetically; // helpers/map-CIS-countries/index.ts var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; var mapCisCountries = (countries) => { - const filteredCountries = filter_cis_entries_default(countries, CIS2.INVALID_COUNTRIES, "marketName"); + const filteredCountries = filter_cis_entries_default(countries, CIS2.INVALID_COUNTRIES, 'marketName'); const mapped = filteredCountries.map((country) => map_CIS_country_default(country)); - const sorted = sort_array_alphabetically_default(mapped, "name"); + const sorted = sort_array_alphabetically_default(mapped, 'name'); return sorted; }; var map_CIS_countries_default = mapCisCountries; @@ -9216,7 +9307,7 @@ var map_CIS_countries_default = mapCisCountries; // custom-resolvers/queries/get-APIM-CIS-countries/index.ts var getApimCisCountries = async () => { try { - console.info("Getting and mapping CIS countries from APIM"); + console.info('Getting and mapping CIS countries from APIM'); const response = await APIM_default.getCisCountries(); if (response.data) { const mapped = map_CIS_countries_default(response.data); @@ -9224,7 +9315,7 @@ var getApimCisCountries = async () => { } return { success: false }; } catch (error) { - console.error("Error Getting and mapping CIS countries from APIM %o", error); + console.error('Error Getting and mapping CIS countries from APIM %o', error); throw new Error(`Getting and mapping CIS countries from APIM ${error}`); } }; @@ -9241,7 +9332,7 @@ var getAlternativeCurrencies = (currencies) => { return alternate; }; var mapCurrencies = (currencies, alternativeCurrencies) => { - let currenciesArray = filter_cis_entries_default(currencies, CIS3.INVALID_CURRENCIES, "name"); + let currenciesArray = filter_cis_entries_default(currencies, CIS3.INVALID_CURRENCIES, 'name'); if (!alternativeCurrencies) { currenciesArray = getSupportedCurrencies(currenciesArray); } else { @@ -9255,7 +9346,7 @@ var map_currencies_default = mapCurrencies; // custom-resolvers/queries/get-APIM-currencies/index.ts var getApimCurrencies = async () => { try { - console.info("Getting and mapping currencies from APIM"); + console.info('Getting and mapping currencies from APIM'); const response = await APIM_default.getCurrencies(); if (response.data) { const supportedCurrencies = map_currencies_default(response.data, false); @@ -9264,28 +9355,28 @@ var getApimCurrencies = async () => { return { supportedCurrencies, alternativeCurrencies, - allCurrencies + allCurrencies, }; } return { success: false }; } catch (error) { - console.error("Error Getting and mapping currencies from APIM %o", error); + console.error('Error Getting and mapping currencies from APIM %o', error); throw new Error(`Getting and mapping currencies from APIM ${error}`); } }; var get_APIM_currencies_default = getApimCurrencies; // helpers/remove-white-space/index.ts -var removeWhiteSpace = (string) => string.replace(" ", ""); +var removeWhiteSpace = (string) => string.replace(' ', ''); var remove_white_space_default = removeWhiteSpace; // helpers/sanitise-companies-house-number/index.ts -var sanitiseCompaniesHouseNumber = (companyNumber) => remove_white_space_default(companyNumber).toUpperCase().padStart(8, "0"); +var sanitiseCompaniesHouseNumber = (companyNumber) => remove_white_space_default(companyNumber).toUpperCase().padStart(8, '0'); var sanitise_companies_house_number_default = sanitiseCompaniesHouseNumber; // integrations/companies-house/index.ts -var import_axios2 = __toESM(require("axios")); -var import_dotenv11 = __toESM(require("dotenv")); +var import_axios2 = __toESM(require('axios')); +var import_dotenv11 = __toESM(require('dotenv')); import_dotenv11.default.config(); var username = String(process.env.COMPANIES_HOUSE_API_KEY); var companiesHouseURL = String(process.env.COMPANIES_HOUSE_API_URL); @@ -9293,84 +9384,84 @@ var companiesHouse = { get: async (companyNumber) => { try { const response = await (0, import_axios2.default)({ - method: "get", + method: 'get', url: `${companiesHouseURL}/company/${companyNumber}`, - auth: { username, password: "" }, + auth: { username, password: '' }, validateStatus(status) { const acceptableStatus = [200, 404]; return acceptableStatus.includes(status); - } + }, }); if (response.status === 404) { return { success: false, - notFound: true + notFound: true, }; } if (!response.data || response.status !== 200) { return { - success: false + success: false, }; } return { success: true, - data: response.data + data: response.data, }; } catch (error) { - console.error("Error calling Companies House API %o", error); + console.error('Error calling Companies House API %o', error); throw new Error(`Calling Companies House API. Unable to search for company ${error}`); } - } + }, }; var companies_house_default = companiesHouse; // integrations/industry-sector/index.ts -var import_axios3 = __toESM(require("axios")); -var import_dotenv12 = __toESM(require("dotenv")); +var import_axios3 = __toESM(require('axios')); +var import_dotenv12 = __toESM(require('dotenv')); import_dotenv12.default.config(); var { APIM_MDM_URL: APIM_MDM_URL2, APIM_MDM_KEY: APIM_MDM_KEY2, APIM_MDM_VALUE: APIM_MDM_VALUE2 } = process.env; var { APIM_MDM: APIM_MDM2 } = EXTERNAL_API_ENDPOINTS; var headers = { - "Content-Type": "application/json", - [String(APIM_MDM_KEY2)]: APIM_MDM_VALUE2 + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY2)]: APIM_MDM_VALUE2, }; var industrySectorNames = { get: async () => { try { - console.info("Calling industry sector API"); + console.info('Calling industry sector API'); const response = await (0, import_axios3.default)({ - method: "get", + method: 'get', url: `${APIM_MDM_URL2}${APIM_MDM2.INDUSTRY_SECTORS}`, headers, validateStatus(status) { const acceptableStatus = [200, 404]; return acceptableStatus.includes(status); - } + }, }); if (!response.data || response.status !== 200) { return { - success: false + success: false, }; } return { success: true, - data: response.data + data: response.data, }; } catch (error) { - console.error("Error calling industry sector API %o", error); + console.error('Error calling industry sector API %o', error); return { success: false, - apiError: true + apiError: true, }; } - } + }, }; var industry_sector_default = industrySectorNames; // helpers/create-full-timestamp-from-day-month/index.ts var createFullTimestampFromDayAndMonth = (day, month) => { if (day && month) { - return /* @__PURE__ */ new Date(`${(/* @__PURE__ */ new Date()).getFullYear()}-${month}-${day}`); + return /* @__PURE__ */ new Date(`${/* @__PURE__ */ new Date().getFullYear()}-${month}-${day}`); } return null; }; @@ -9392,7 +9483,7 @@ var map_sic_code_descriptions_default = mapSicCodeDescriptions; // helpers/map-companies-house-fields/index.ts var { - COMPANIES_HOUSE: { COMPANY_STATUS } + COMPANIES_HOUSE: { COMPANY_STATUS }, } = EXTERNAL_API_DEFINITIONS; var mapCompaniesHouseFields = (companiesHouseResponse, sectors) => ({ companyName: companiesHouseResponse.company_name, @@ -9404,7 +9495,7 @@ var mapCompaniesHouseFields = (companiesHouseResponse, sectors) => ({ locality: companiesHouseResponse.registered_office_address.locality, region: companiesHouseResponse.registered_office_address.region, postalCode: companiesHouseResponse.registered_office_address.postal_code, - country: companiesHouseResponse.registered_office_address.country + country: companiesHouseResponse.registered_office_address.country, }, companyNumber: companiesHouseResponse.company_number, dateOfCreation: companiesHouseResponse.date_of_creation, @@ -9416,41 +9507,41 @@ var mapCompaniesHouseFields = (companiesHouseResponse, sectors) => ({ */ financialYearEndDate: create_full_timestamp_from_day_month_default( companiesHouseResponse.accounts?.accounting_reference_date?.day, - companiesHouseResponse.accounts?.accounting_reference_date?.month + companiesHouseResponse.accounts?.accounting_reference_date?.month, ), - isActive: companiesHouseResponse.company_status === COMPANY_STATUS.ACTIVE + isActive: companiesHouseResponse.company_status === COMPANY_STATUS.ACTIVE, }); // custom-resolvers/queries/get-companies-house-information/index.ts var getCompaniesHouseInformation = async (root, variables) => { try { const { companiesHouseNumber } = variables; - console.info("Getting Companies House information for %s", companiesHouseNumber); + console.info('Getting Companies House information for %s', companiesHouseNumber); const sanitisedNumber = sanitise_companies_house_number_default(companiesHouseNumber); const response = await companies_house_default.get(sanitisedNumber); if (!response.success || !response.data) { return { success: false, - notFound: response.notFound + notFound: response.notFound, }; } const industrySectors = await industry_sector_default.get(); if (!industrySectors.success || industrySectors.apiError) { return { apiError: true, - success: false + success: false, }; } const mappedResponse = mapCompaniesHouseFields(response.data, industrySectors.data); return { ...mappedResponse, - success: true + success: true, }; } catch (error) { - console.error("Error getting companies house information %o", error); + console.error('Error getting companies house information %o', error); return { apiError: true, - success: false + success: false, }; } }; @@ -9459,7 +9550,7 @@ var get_companies_house_information_default = getCompaniesHouseInformation; // custom-resolvers/queries/get-application-by-reference-number/index.ts var getApplicationByReferenceNumberQuery = async (root, variables, context) => { try { - console.info("Getting application by reference number %s", variables.referenceNumber); + console.info('Getting application by reference number %s', variables.referenceNumber); const { referenceNumber, decryptFinancialUk: decryptFinancialUk2, decryptFinancialInternational: decryptFinancialInternational2 } = variables; const application2 = await get_application_by_reference_number_default(referenceNumber, context); if (application2) { @@ -9467,73 +9558,75 @@ var getApplicationByReferenceNumberQuery = async (root, variables, context) => { context, application: application2, decryptFinancialUk: decryptFinancialUk2, - decryptFinancialInternational: decryptFinancialInternational2 + decryptFinancialInternational: decryptFinancialInternational2, }); return { success: true, - application: populatedApplication2 + application: populatedApplication2, }; } return { - success: false + success: false, }; } catch (error) { - console.error("Error getting application by reference number (GetApplicationByReferenceNumber query) %o", error); + console.error('Error getting application by reference number (GetApplicationByReferenceNumber query) %o', error); throw new Error(`Get application by reference number (GetApplicationByReferenceNumber query) ${error}`); } }; var get_application_by_reference_number_default2 = getApplicationByReferenceNumberQuery; // integrations/ordnance-survey/index.ts -var import_axios4 = __toESM(require("axios")); -var import_dotenv13 = __toESM(require("dotenv")); +var import_axios4 = __toESM(require('axios')); +var import_dotenv13 = __toESM(require('dotenv')); import_dotenv13.default.config(); var { ORDNANCE_SURVEY_API_KEY, ORDNANCE_SURVEY_API_URL } = process.env; var ordnanceSurvey = { get: async (postcode) => { try { const response = await (0, import_axios4.default)({ - method: "get", + method: 'get', url: `${ORDNANCE_SURVEY_API_URL}${ORDNANCE_SURVEY_QUERY_URL}${postcode}&key=${ORDNANCE_SURVEY_API_KEY}`, validateStatus(status) { const acceptableStatus = [200, 404]; return acceptableStatus.includes(status); - } + }, }); if (!response?.data?.results || response.status !== 200) { return { - success: false + success: false, }; } return { success: true, - data: response.data.results + data: response.data.results, }; } catch (error) { - console.error("Error calling Ordnance Survey API %o", error); + console.error('Error calling Ordnance Survey API %o', error); throw new Error(`Calling Ordnance Survey API. Unable to search for address ${error}`); } - } + }, }; var ordnance_survey_default = ordnanceSurvey; // helpers/is-valid-postcode/index.ts -var import_postcode_validator = require("postcode-validator"); -var isValidPostcode = (postcode) => (0, import_postcode_validator.postcodeValidator)(postcode, "GB"); +var import_postcode_validator = require('postcode-validator'); +var isValidPostcode = (postcode) => (0, import_postcode_validator.postcodeValidator)(postcode, 'GB'); // helpers/map-address/index.ts var mapAddress = (address) => ({ - addressLine1: `${address.DPA.ORGANISATION_NAME ?? ""} ${address.DPA.BUILDING_NAME ?? ""} ${address.DPA.BUILDING_NUMBER ?? ""} ${address.DPA.THOROUGHFARE_NAME ?? ""}`.trim(), + addressLine1: `${address.DPA.ORGANISATION_NAME ?? ''} ${address.DPA.BUILDING_NAME ?? ''} ${address.DPA.BUILDING_NUMBER ?? ''} ${ + address.DPA.THOROUGHFARE_NAME ?? '' + }`.trim(), addressLine2: address.DPA.DEPENDENT_LOCALITY, town: address.DPA.POST_TOWN, - postalCode: address.DPA.POSTCODE + postalCode: address.DPA.POSTCODE, }); var map_address_default = mapAddress; // helpers/map-and-filter-address/index.ts var mapAndFilterAddress = (houseNameOrNumber, ordnanceSurveyResponse) => { const filtered = ordnanceSurveyResponse.filter( - (eachAddress) => eachAddress.DPA.BUILDING_NUMBER === houseNameOrNumber || eachAddress.DPA.BUILDING_NAME === houseNameOrNumber + (eachAddress) => eachAddress.DPA.BUILDING_NUMBER === houseNameOrNumber || eachAddress.DPA.BUILDING_NAME === houseNameOrNumber, ); if (!filtered.length) { return []; @@ -9550,37 +9643,37 @@ var map_and_filter_address_default = mapAndFilterAddress; var getOrdnanceSurveyAddress = async (root, variables) => { try { const { postcode, houseNameOrNumber } = variables; - console.info("Getting Ordnance Survey address for postcode: %s, houseNameOrNumber: %s", postcode, houseNameOrNumber); + console.info('Getting Ordnance Survey address for postcode: %s, houseNameOrNumber: %s', postcode, houseNameOrNumber); const noWhitespacePostcode = remove_white_space_default(postcode); if (!isValidPostcode(noWhitespacePostcode)) { - console.error("Invalid postcode: %s", postcode); + console.error('Invalid postcode: %s', postcode); return { success: false, - invalidPostcode: true + invalidPostcode: true, }; } const response = await ordnance_survey_default.get(postcode); if (!response.success || !response.data) { return { - success: false + success: false, }; } const mappedAddresses = map_and_filter_address_default(houseNameOrNumber, response.data); if (!mappedAddresses.length) { return { success: false, - noAddressesFound: true + noAddressesFound: true, }; } return { addresses: mappedAddresses, - success: true + success: true, }; } catch (error) { - console.error("Error getting Ordnance Survey address results %o", error); + console.error('Error getting Ordnance Survey address results %o', error); return { apiError: true, - success: false + success: false, }; } }; @@ -9589,32 +9682,32 @@ var get_ordnance_survey_address_default = getOrdnanceSurveyAddress; // custom-resolvers/queries/verify-account-password-reset-token/index.ts var { PASSWORD_RESET_HASH, PASSWORD_RESET_EXPIRY } = account_default; var verifyAccountPasswordResetToken = async (root, variables, context) => { - console.info("Verifying account password reset token"); + console.info('Verifying account password reset token'); try { const { token } = variables; const account2 = await get_account_by_field_default(context, PASSWORD_RESET_HASH, token); if (account2) { const hasExpired = dateIsInThePast(account2[PASSWORD_RESET_EXPIRY]); if (hasExpired) { - console.info("Unable to verify account password reset token - token has expired"); + console.info('Unable to verify account password reset token - token has expired'); return { success: false, expired: true, - accountId: account2.id + accountId: account2.id, }; } - console.info("Successfully verified account password reset token"); + console.info('Successfully verified account password reset token'); return { - success: true + success: true, }; } - console.info("Unable to verify account password reset token - no account found from the provided %s", PASSWORD_RESET_HASH); + console.info('Unable to verify account password reset token - no account found from the provided %s', PASSWORD_RESET_HASH); return { success: false, - invalid: true + invalid: true, }; } catch (error) { - console.error("Error verifying account password reset token %o", error); + console.error('Error verifying account password reset token %o', error); throw new Error(`Verifying account password reset token ${error}`); } }; @@ -9642,7 +9735,7 @@ var customResolvers = { createFeedbackAndSendEmail: create_feedback_default, verifyAccountReactivationToken: verify_account_reactivation_token_default, updateLossPayeeFinancialDetailsUk: update_loss_payee_financial_details_uk_default, - updateLossPayeeFinancialDetailsInternational: update_loss_payee_financial_details_international_default + updateLossPayeeFinancialDetailsInternational: update_loss_payee_financial_details_international_default, }, Query: { getAccountPasswordResetToken: get_account_password_reset_token_default, @@ -9651,28 +9744,29 @@ var customResolvers = { getCompaniesHouseInformation: get_companies_house_information_default, getApplicationByReferenceNumber: get_application_by_reference_number_default2, getOrdnanceSurveyAddress: get_ordnance_survey_address_default, - verifyAccountPasswordResetToken: verify_account_password_reset_token_default - } + verifyAccountPasswordResetToken: verify_account_password_reset_token_default, + }, }; var custom_resolvers_default = customResolvers; // custom-schema/index.ts -var extendGraphqlSchema = (schema) => (0, import_schema.mergeSchemas)({ - schemas: [schema], - typeDefs: type_defs_default, - resolvers: custom_resolvers_default -}); +var extendGraphqlSchema = (schema) => + (0, import_schema.mergeSchemas)({ + schemas: [schema], + typeDefs: type_defs_default, + resolvers: custom_resolvers_default, + }); // keystone.ts var { NODE_ENV: NODE_ENV2, PORT, DATABASE_URL } = process.env; -var isDevEnvironment2 = NODE_ENV2 === "development"; -var isProdEnvironment = NODE_ENV2 === "production"; +var isDevEnvironment2 = NODE_ENV2 === 'development'; +var isProdEnvironment = NODE_ENV2 === 'production'; var keystone_default = withAuth( (0, import_core3.config)({ server: { port: Number(PORT), extendExpressApp: (app) => { - app.use((0, import_overload_protection.default)("express")); + app.use((0, import_overload_protection.default)('express')); app.use(security_default); app.use(check_api_key_default); if (isProdEnvironment) { @@ -9681,25 +9775,25 @@ var keystone_default = withAuth( }, extendHttpServer: (httpServer, context) => { cron_default(context); - } + }, }, db: { - provider: "mysql", + provider: 'mysql', url: String(DATABASE_URL), - enableLogging: isDevEnvironment2 + enableLogging: isDevEnvironment2, }, graphql: { playground: isDevEnvironment2, apolloConfig: { introspection: isDevEnvironment2, plugins: apolloPlugins2, - formatError: formatGraphQlError2 - } + formatError: formatGraphQlError2, + }, }, lists, session, extendGraphqlSchema, - telemetry: false - }) + telemetry: false, + }), ); //# sourceMappingURL=config.js.map diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts deleted file mode 100644 index 1a8d6622ca..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import cannotGetAQuote from '.'; -import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; - -const { - CIS: { - ESRA_CLASSIFICATION: { STANDARD }, - }, -} = EXTERNAL_API_MAPPINGS; - -describe('helpers/map-cis-countries/map-cis-country/cannot-get-a-quote', () => { - describe('when country has shortTermCover=false, nbiIssueAvailable=false and no esraClassification', () => { - it('should return true', () => { - const result = cannotGetAQuote({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: null }); - - expect(result).toEqual(true); - }); - }); - - describe('when country has shortTermCover=false, nbiIssueAvailable=false and has a esraClassification', () => { - it('should return true', () => { - const result = cannotGetAQuote({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: STANDARD }); - - expect(result).toEqual(true); - }); - }); - - describe('when country has shortTermCover=true, nbiIssueAvailable=true and has a esraClassification', () => { - it('should return false', () => { - const result = cannotGetAQuote({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: STANDARD }); - - expect(result).toEqual(false); - }); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts deleted file mode 100644 index d2b37edd89..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MapCisCountryParams } from '../../../../types'; - -/** - * cannotGetAQuote - * Check if a country cannot get a quote online or offline - * @param {MapCisCountryParams} - * @param {Boolean} shortTermCover: Short term cover flag. - * @param {Boolean} nbiIssueAvailable: NBI flag. - * @param {String} esraClassification: ESRA classification. - * @returns {Boolean} - */ -const cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { - if (!esraClassification || (!shortTermCover && !nbiIssueAvailable)) { - return true; - } - - return false; -}; - -export default cannotGetAQuote; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index e40851377d..02e0bb6d08 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -4,11 +4,10 @@ import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; -import cannotGetAQuote from './cannot-get-a-quote'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import canApplyOffline from './can-apply-for-quote-offline'; import noOnlineInsuranceSupport from './no-online-insurance-support'; -import noInsuranceSupport from './no-insurance-support'; +import noSupport from './no-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; import { MappedCisCountry } from '../../../types'; import { mockCisCountry } from '../../../test-mocks'; @@ -48,7 +47,11 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), - cannotGetAQuote: cannotGetAQuote({ shortTermCover, nbiIssueAvailable, esraClassification }), + cannotGetAQuote: noSupport({ + countryRating, + esraClassification: mockCisCountry.ESRAClassificationDesc, + shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, + }), canApplyForInsuranceOnline: canApplyForInsuranceOnline(mockCisCountry), @@ -58,7 +61,7 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, }), - noInsuranceSupport: noInsuranceSupport({ + noInsuranceSupport: noSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index 2a867e16f8..18a6bbf44e 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -3,11 +3,10 @@ import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; -import cannotGetAQuote from './cannot-get-a-quote'; import canApplyForAQuoteOffline from './can-apply-for-quote-offline'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import noOnlineInsuranceSupport from './no-online-insurance-support'; -import noInsuranceSupport from './no-insurance-support'; +import noSupport from './no-support'; import { CisCountry, MappedCisCountry } from '../../../types'; /** @@ -39,7 +38,11 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), - cannotGetAQuote: cannotGetAQuote({ shortTermCover, nbiIssueAvailable, esraClassification }), + cannotGetAQuote: noSupport({ + countryRating, + esraClassification: ESRAClassificationDesc, + shortTermCover: shortTermCoverAvailabilityDesc, + }), canApplyForInsuranceOnline: canApplyForInsuranceOnline(cisCountry), @@ -49,7 +52,7 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { shortTermCover: shortTermCoverAvailabilityDesc, }), - noInsuranceSupport: noInsuranceSupport({ + noInsuranceSupport: noSupport({ countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts new file mode 100644 index 0000000000..4ccd4a8a2b --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts @@ -0,0 +1,116 @@ +import noSupport from '.'; +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; + +const { + CIS: { + COUNTRY_RATINGS, + ESRA_CLASSIFICATION: { VERY_HIGH, HIGH, STANDARD, NONE }, + SHORT_TERM_COVER: { UNLISTED, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +const mockInitCountry = { + esraClassification: NONE, + shortTermCover: UNLISTED, +}; + +const createMockParams = (countryRating: string, esraClassification?: string, shortTermCover?: string) => { + const params = { + ...mockInitCountry, + countryRating, + }; + + if (esraClassification) { + params.esraClassification = esraClassification; + } + + if (shortTermCover) { + params.shortTermCover = shortTermCover; + } + + return params; +}; + +const params = { + firstConditions: [ + { + country: createMockParams(COUNTRY_RATINGS.A[0]), + description: 'A', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.B[0]), + description: 'B', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.C[0]), + description: 'C', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.D[0]), + description: 'D', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE), + description: 'NOT_APPLICABLE', + expectation: true, + }, + { + country: createMockParams('not recognised'), + description: 'not recognised', + expectation: false, + }, + ], + secondConditions: [ + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, STANDARD, CILC), + description: 'STANDARD', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, HIGH, CILC), + description: 'HIGH', + expectation: true, + }, + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, VERY_HIGH, CILC), + description: 'VERY_HIGH', + expectation: true, + }, + + { + country: createMockParams(COUNTRY_RATINGS.NOT_APPLICABLE, NONE, CILC), + description: 'NONE', + expectation: true, + }, + ], +}; + +describe('helpers/map-CIS-countries/map-CIS-country/no-support', () => { + describe(`when shortTermCover is ${UNLISTED} and esraClassification is ${NONE}`, () => { + describe.each(params.firstConditions)('', ({ country, description, expectation }) => { + describe(`when the countryRating is ${description}`, () => { + it(`should return ${expectation}`, () => { + const result = noSupport(country); + + expect(result).toEqual(expectation); + }); + }); + }); + }); + + describe(`when shortTermCover is ${CILC} and countryRating is ${COUNTRY_RATINGS.NOT_APPLICABLE}`, () => { + describe.each(params.secondConditions)('', ({ country, description, expectation }) => { + describe(`when the esraClassification is ${description}`, () => { + it(`should return ${expectation}`, () => { + const result = noSupport(country); + + expect(result).toEqual(expectation); + }); + }); + }); + }); +}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts new file mode 100644 index 0000000000..64e15c900e --- /dev/null +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts @@ -0,0 +1,43 @@ +import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; +import countryRatingIsAorB from '../country-rating-is-a-or-b'; +import countryRatingIsCorD from '../country-rating-is-c-or-d'; +import esraClassificationIsStandardHighOrVeryHigh from '../esra-classification-is-standard-high-or-very-high'; +import { NoInsuranceSupportParams } from '../../../../types'; + +const { + CIS: { + COUNTRY_RATINGS: { NOT_APPLICABLE }, + ESRA_CLASSIFICATION: { NONE }, + SHORT_TERM_COVER: { UNLISTED, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; + +/** + * noSupport + * Check if a country has no quote or insurance support (online or offline) + * @param {String} countryRating: Country rating + * @param {String} esraClassification: ESRA classification + * @param {String} shortTermCover: Short term cover + * @returns {Boolean} + */ +const noSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { + const shortTermCoverIsUnlisted = shortTermCover === UNLISTED; + const esraClassificationIsNone = esraClassification === NONE; + const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; + + const countryRatingConditions = countryRatingIsAorB(countryRating) || countryRatingIsCorD(countryRating) || countryRatingIsNotApplicable; + + if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { + return true; + } + + const esraClassificationConditions = esraClassificationIsStandardHighOrVeryHigh(esraClassification) || esraClassificationIsNone; + + if (shortTermCover === CILC && countryRatingIsNotApplicable && esraClassificationConditions) { + return true; + } + + return false; +}; + +export default noSupport; diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts index 57ea413688..7eba63c9a5 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts @@ -11,6 +11,7 @@ import { mockReq, mockRes, mockCountries } from '../../../../test-mocks'; const { ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, BUYER_COUNTRY_CHANGE, CHECK_YOUR_ANSWERS, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, + PROBLEM_WITH_SERVICE, } = INSURANCE_ROUTES; describe('controllers/insurance/eligibility/buyer-country - redirects', () => { @@ -183,5 +184,30 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { expect(res.redirect).toHaveBeenCalledWith(CANNOT_APPLY_ROUTE); }); }); + + describe('when the country does not have any recognised flags with a value of true', () => { + beforeEach(() => { + req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = countryNoInsuranceSupport.isoCode; + + mockCountriesResponse = [ + { + ...countryNoInsuranceSupport, + noOnlineInsuranceSupport: false, + canApplyForInsuranceOnline: false, + noInsuranceSupport: false, + }, + ]; + + getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + + api.keystone.APIM.getCisCountries = getCisCountriesSpy; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); }); }); diff --git a/src/ui/server/controllers/quote/buyer-country/index.test.ts b/src/ui/server/controllers/quote/buyer-country/index.test.ts index 04f7a7f02b..6bc72dae20 100644 --- a/src/ui/server/controllers/quote/buyer-country/index.test.ts +++ b/src/ui/server/controllers/quote/buyer-country/index.test.ts @@ -369,6 +369,31 @@ describe('controllers/quote/buyer-country', () => { }); }); + describe('when the country does not have any recognised flags with a value of true', () => { + beforeEach(() => { + req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = countryQuoteOnline.isoCode; + + mockCountriesResponse = [ + { + ...countryQuoteOnline, + canGetAQuoteOnline: false, + canGetAQuoteByEmail: false, + cannotGetAQuote: false, + }, + ]; + + getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + + api.keystone.APIM.getCisCountries = getCisCountriesSpy; + }); + + it(`should redirect to ${ROUTES.PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(ROUTES.PROBLEM_WITH_SERVICE); + }); + }); + describe('api error handling', () => { describe('when the get CIS countries API call fails', () => { beforeEach(() => { diff --git a/src/ui/server/controllers/quote/buyer-country/index.ts b/src/ui/server/controllers/quote/buyer-country/index.ts index e8894dc693..81e14cc2a0 100644 --- a/src/ui/server/controllers/quote/buyer-country/index.ts +++ b/src/ui/server/controllers/quote/buyer-country/index.ts @@ -183,6 +183,10 @@ export const post = async (req: Request, res: Response) => { return res.redirect(ROUTES.QUOTE.CANNOT_APPLY_EXIT); } + + console.info('Country support - %s - unable to determine country support', country.name); + + return res.redirect(ROUTES.PROBLEM_WITH_SERVICE); } catch (error) { console.error('Error getting CIS countries %o', error); From 7e7da8b1160366cfb6f98087fb45171cade91f7b Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Fri, 20 Dec 2024 14:11:36 +0000 Subject: [PATCH 06/12] chore(EMS-4075): country risk logic - remove canGetAQuoteOffline flag (#3423) * feat(EMS-4065): country risk logic - application - no support * feat(EMS-4065): fix/update e2e tests * chore(EMS-4065): remove commented code * feat(EMS-4065): rename SHORT_TERM_COVER_AVAILABLE to SHORT_TERM_COVER * feat(EMS-4065): fix typo * feat(EMS-4065): minor code improvement * feat(EMS-4065): code improvement * feat(EMS-4065): fix/update e2e tests * chore(EMS-4075): country risk logic - remove canGetAQuoteOffline flag --- src/api/.keystone/config.js | 40 +++--------- src/api/custom-schema/type-defs.ts | 1 - .../can-apply-for-quote-offline/index.test.ts | 65 ------------------- .../can-apply-for-quote-offline/index.ts | 31 --------- .../map-CIS-country/index.test.ts | 3 - .../map-CIS-country/index.ts | 3 - src/api/schema.graphql | 1 - .../test-mocks/mock-mapped-CIS-countries.ts | 1 - src/api/types/country/index.ts | 2 - .../graphql/queries/APIM/CIS-countries.ts | 1 - src/ui/server/test-mocks/mock-countries.ts | 3 - src/ui/types/country.d.ts | 1 - 12 files changed, 9 insertions(+), 143 deletions(-) delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 4c081d6077..6c0bbba29d 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -2824,7 +2824,6 @@ var typeDefs = ` esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean - canGetAQuoteOffline: Boolean canGetAQuoteByEmail: Boolean cannotGetAQuote: Boolean cannotApply: Boolean @@ -9094,26 +9093,6 @@ var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassificati }; var can_get_a_quote_by_email_default = canGetAQuoteByEmail; -// helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts -var { - CIS: { - SHORT_TERM_COVER: { ILC, CILC, REFER: REFER2 }, - }, -} = EXTERNAL_API_DEFINITIONS; -var canApplyForAQuoteOffline = (originalShortTermCover) => { - if (originalShortTermCover === ILC) { - return true; - } - if (originalShortTermCover === CILC) { - return true; - } - if (originalShortTermCover === REFER2) { - return true; - } - return false; -}; -var can_apply_for_quote_offline_default = canApplyForAQuoteOffline; - // helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts var canApplyForInsuranceOnline = (cisCountry) => { const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; @@ -9129,7 +9108,7 @@ var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE }, - SHORT_TERM_COVER: { NO: NO2, ILC: ILC2, CILC: CILC2 }, + SHORT_TERM_COVER: { NO: NO2, ILC, CILC }, }, } = EXTERNAL_API_DEFINITIONS; var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { @@ -9137,10 +9116,10 @@ var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover return false; } if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { - if (shortTermCover === ILC2) { + if (shortTermCover === ILC) { return true; } - if (shortTermCover === CILC2) { + if (shortTermCover === CILC) { return true; } if (shortTermCover === NO2) { @@ -9173,7 +9152,7 @@ var country_rating_is_c_or_d_default = countryRatingIsCorD; var { CIS: { ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE2 }, - SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC3, CILC: CILC3, REFER: REFER3, UNLISTED: UNLISTED2 }, + SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC2, CILC: CILC2, REFER: REFER2, UNLISTED: UNLISTED2 }, }, } = EXTERNAL_API_DEFINITIONS; var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { @@ -9184,13 +9163,13 @@ var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover if (shortTermCover === YES3) { return true; } - if (shortTermCover === ILC3) { + if (shortTermCover === ILC2) { return true; } - if (shortTermCover === CILC3) { + if (shortTermCover === CILC2) { return true; } - if (shortTermCover === REFER3) { + if (shortTermCover === REFER2) { return true; } if (shortTermCover === UNLISTED2) { @@ -9229,7 +9208,7 @@ var { CIS: { COUNTRY_RATINGS: { NOT_APPLICABLE }, ESRA_CLASSIFICATION: { NONE: NONE3 }, - SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC4 }, + SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC3 }, }, } = EXTERNAL_API_DEFINITIONS; var noSupport = ({ countryRating, esraClassification, shortTermCover }) => { @@ -9242,7 +9221,7 @@ var noSupport = ({ countryRating, esraClassification, shortTermCover }) => { return true; } const esraClassificationConditions = esra_classification_is_standard_high_or_very_high_default(esraClassification) || esraClassificationIsNone; - if (shortTermCover === CILC4 && countryRatingIsNotApplicable && esraClassificationConditions) { + if (shortTermCover === CILC3 && countryRatingIsNotApplicable && esraClassificationConditions) { return true; } return false; @@ -9264,7 +9243,6 @@ var mapCisCountry = (cisCountry) => { nbiIssueAvailable, shortTermCover, canGetAQuoteOnline: can_get_a_quote_online_default(cisCountry), - canGetAQuoteOffline: can_apply_for_quote_offline_default(cisCountry.shortTermCoverAvailabilityDesc), canGetAQuoteByEmail: can_get_a_quote_by_email_default({ shortTermCover, nbiIssueAvailable, esraClassification }), cannotGetAQuote: no_support_default({ countryRating, diff --git a/src/api/custom-schema/type-defs.ts b/src/api/custom-schema/type-defs.ts index 74c78c075b..17c6c2ed00 100644 --- a/src/api/custom-schema/type-defs.ts +++ b/src/api/custom-schema/type-defs.ts @@ -231,7 +231,6 @@ const typeDefs = ` esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean - canGetAQuoteOffline: Boolean canGetAQuoteByEmail: Boolean cannotGetAQuote: Boolean cannotApply: Boolean diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts deleted file mode 100644 index d7fd522c00..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import canApplyForAQuoteOffline from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; -import mockCountries from '../../../../test-mocks/mock-countries'; - -const { - CIS: { - SHORT_TERM_COVER: { ILC, CILC, REFER }, - }, -} = EXTERNAL_API_DEFINITIONS; - -const { 1: mockCountryBase } = mockCountries; - -describe('helpers/map-cis-countries/map-cis-country/can-apply-offline', () => { - describe(`when shortTermCoverAvailabilityDesc is ${ILC}`, () => { - it('should return true', () => { - const mockCountry = { - ...mockCountryBase, - shortTermCoverAvailabilityDesc: ILC, - }; - - const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); - - expect(result).toEqual(true); - }); - }); - - describe(`when shortTermCoverAvailabilityDesc is ${CILC}`, () => { - it('should return true', () => { - const mockCountry = { - ...mockCountryBase, - shortTermCoverAvailabilityDesc: CILC, - }; - - const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); - - expect(result).toEqual(true); - }); - }); - - describe(`when shortTermCoverAvailabilityDesc is ${REFER}`, () => { - it('should return true', () => { - const mockCountry = { - ...mockCountryBase, - shortTermCoverAvailabilityDesc: REFER, - }; - - const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); - - expect(result).toEqual(true); - }); - }); - - describe('when shortTermCoverAvailabilityDesc does not match anything', () => { - it('should return false', () => { - const mockCountry = { - ...mockCountryBase, - shortTermCoverAvailabilityDesc: 'Something else', - }; - - const result = canApplyForAQuoteOffline(mockCountry.shortTermCoverAvailabilityDesc); - - expect(result).toEqual(false); - }); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts deleted file mode 100644 index 496656dbd6..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-quote-offline/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { - CIS: { - SHORT_TERM_COVER: { ILC, CILC, REFER }, - }, -} = EXTERNAL_API_DEFINITIONS; - -/** - * canApplyForAQuoteOffline - * Check if a country can get a quote offline - * @param {String} Country original short term cover definition from CIS API. - * @returns {Boolean} - */ -export const canApplyForAQuoteOffline = (originalShortTermCover: string) => { - if (originalShortTermCover === ILC) { - return true; - } - - if (originalShortTermCover === CILC) { - return true; - } - - if (originalShortTermCover === REFER) { - return true; - } - - return false; -}; - -export default canApplyForAQuoteOffline; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index 02e0bb6d08..545b34ae96 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -5,7 +5,6 @@ import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; -import canApplyOffline from './can-apply-for-quote-offline'; import noOnlineInsuranceSupport from './no-online-insurance-support'; import noSupport from './no-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; @@ -43,8 +42,6 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { canGetAQuoteOnline: canGetAQuoteOnline(mockCisCountry), - canGetAQuoteOffline: canApplyOffline(mockCountryBase.shortTermCoverAvailabilityDesc), - canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), cannotGetAQuote: noSupport({ diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index 18a6bbf44e..d82525eee2 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -3,7 +3,6 @@ import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; -import canApplyForAQuoteOffline from './can-apply-for-quote-offline'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import noOnlineInsuranceSupport from './no-online-insurance-support'; import noSupport from './no-support'; @@ -34,8 +33,6 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { canGetAQuoteOnline: canGetAQuoteOnline(cisCountry), - canGetAQuoteOffline: canApplyForAQuoteOffline(cisCountry.shortTermCoverAvailabilityDesc), - canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), cannotGetAQuote: noSupport({ diff --git a/src/api/schema.graphql b/src/api/schema.graphql index 8f8273a09c..0662169c26 100644 --- a/src/api/schema.graphql +++ b/src/api/schema.graphql @@ -3745,7 +3745,6 @@ type MappedCisCountry { esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean - canGetAQuoteOffline: Boolean canGetAQuoteByEmail: Boolean cannotGetAQuote: Boolean cannotApply: Boolean diff --git a/src/api/test-mocks/mock-mapped-CIS-countries.ts b/src/api/test-mocks/mock-mapped-CIS-countries.ts index bae522e31d..f30c0d231a 100644 --- a/src/api/test-mocks/mock-mapped-CIS-countries.ts +++ b/src/api/test-mocks/mock-mapped-CIS-countries.ts @@ -3,7 +3,6 @@ import { MappedCisCountry } from '../types'; // mock base country that can get a quote and apply online. const baseCountry = { canGetAQuoteOnline: true, - canGetAQuoteOffline: true, canGetAQuoteByEmail: true, cannotGetAQuote: false, canApplyForInsuranceOnline: true, diff --git a/src/api/types/country/index.ts b/src/api/types/country/index.ts index ae67ad0632..29c0275927 100644 --- a/src/api/types/country/index.ts +++ b/src/api/types/country/index.ts @@ -19,7 +19,6 @@ export interface Country extends Relationship { shortTermCover?: boolean; nbiIssueAvailable?: boolean; canGetAQuoteOnline?: boolean; - canGetAQuoteOffline?: boolean; canGetAQuoteByEmail?: boolean; cannotGetAQuote?: boolean; canApplyForInsuranceOnline?: boolean; @@ -44,7 +43,6 @@ export interface MappedCisCountry { name: string; shortTermCover: boolean; canGetAQuoteOnline: boolean; - canGetAQuoteOffline: boolean; canGetAQuoteByEmail: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; diff --git a/src/ui/server/graphql/queries/APIM/CIS-countries.ts b/src/ui/server/graphql/queries/APIM/CIS-countries.ts index cb528c1fa7..31323efc88 100644 --- a/src/ui/server/graphql/queries/APIM/CIS-countries.ts +++ b/src/ui/server/graphql/queries/APIM/CIS-countries.ts @@ -7,7 +7,6 @@ const getApimCisCountries = gql` name esraClassification canGetAQuoteOnline - canGetAQuoteOffline canGetAQuoteByEmail cannotGetAQuote cannotApply diff --git a/src/ui/server/test-mocks/mock-countries.ts b/src/ui/server/test-mocks/mock-countries.ts index b133b07593..46de4d3913 100644 --- a/src/ui/server/test-mocks/mock-countries.ts +++ b/src/ui/server/test-mocks/mock-countries.ts @@ -8,7 +8,6 @@ const { // mock base country that can get a quote and apply online. const baseCountry = { canGetAQuoteOnline: true, - canGetAQuoteOffline: false, canGetAQuoteByEmail: false, cannotGetAQuote: false, canApplyForInsuranceOnline: true, @@ -74,7 +73,6 @@ const mockCountries = [ ...baseCountry, esraClassification: RISK.STANDARD, canGetAQuoteOnline: false, - canGetAQuoteOffline: false, canApplyForInsuranceOnline: false, noOnlineInsuranceSupport: false, noInsuranceSupport: true, @@ -91,7 +89,6 @@ const mockCountries = [ ...baseCountry, esraClassification: RISK.STANDARD, canGetAQuoteOnline: true, - canGetAQuoteOffline: true, canApplyForInsuranceOnline: true, canApplyForInsuranceOffline: false, noInsuranceSupport: false, diff --git a/src/ui/types/country.d.ts b/src/ui/types/country.d.ts index be851aef75..5ae27afb9c 100644 --- a/src/ui/types/country.d.ts +++ b/src/ui/types/country.d.ts @@ -6,7 +6,6 @@ interface Country { selected?: boolean; value: string; canGetAQuoteOnline: boolean; - canGetAQuoteOffline: boolean; canGetAQuoteByEmail: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; From 4308d18c86eec9ee2918bf939ddaa4bbdd85dc77 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Fri, 20 Dec 2024 16:43:16 +0000 Subject: [PATCH 07/12] feat(EMS-4073): country risk logic - remove canGetAQuoteByEmail flag (#3424) * feat(EMS-4065): country risk logic - application - no support * feat(EMS-4065): fix/update e2e tests * chore(EMS-4065): remove commented code * feat(EMS-4065): rename SHORT_TERM_COVER_AVAILABLE to SHORT_TERM_COVER * feat(EMS-4065): fix typo * feat(EMS-4065): minor code improvement * feat(EMS-4065): code improvement * feat(EMS-4065): fix/update e2e tests * feat(EMS-4073): country risk logic - remove canGetAQuoteByEmail flag * feat(EMS-4073): fix typo * feat(EMS-4073): fix merge issue --- src/api/.keystone/config.js | 171 ++++++++---------- src/api/custom-schema/type-defs.ts | 3 +- .../can-get-a-quote-by-email/index.test.ts | 50 ----- .../can-get-a-quote-by-email/index.ts | 20 -- .../map-CIS-country/index.test.ts | 15 +- .../map-CIS-country/index.ts | 15 +- .../index-rating-a.test.ts | 2 +- .../index-rating-b.test.ts | 2 +- .../index-rating-c-and-d.test.ts | 2 +- .../index-rating-none.test.ts | 2 +- .../a-and-b-rating-conditions/index.ts | 0 .../index-rating-a-and-b.test.ts | 2 +- .../index-rating-c.test.ts | 2 +- .../index-rating-d.test.ts | 2 +- .../index-rating-none.test.ts | 2 +- .../c-and-d-rating-conditions/index.ts | 0 .../index.test.ts | 12 +- .../index.ts | 8 +- src/api/schema.graphql | 3 +- .../test-mocks/mock-mapped-CIS-countries.ts | 2 - src/api/types/country/index.ts | 5 +- .../buyer-country/country-redirects.test.ts | 98 ++++------ .../eligibility/buyer-country/index.ts | 8 +- .../quote/buyer-country/index.test.ts | 1 - .../controllers/quote/buyer-country/index.ts | 4 +- .../graphql/queries/APIM/CIS-countries.ts | 3 +- src/ui/server/test-mocks/mock-countries.ts | 8 +- src/ui/types/country.d.ts | 3 +- 28 files changed, 159 insertions(+), 286 deletions(-) delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/a-and-b-rating-conditions/index-rating-a.test.ts (96%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/a-and-b-rating-conditions/index-rating-b.test.ts (96%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/a-and-b-rating-conditions/index-rating-c-and-d.test.ts (89%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/a-and-b-rating-conditions/index-rating-none.test.ts (83%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/a-and-b-rating-conditions/index.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/c-and-d-rating-conditions/index-rating-a-and-b.test.ts (89%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/c-and-d-rating-conditions/index-rating-c.test.ts (98%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/c-and-d-rating-conditions/index-rating-d.test.ts (98%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/c-and-d-rating-conditions/index-rating-none.test.ts (84%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/c-and-d-rating-conditions/index.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/index.test.ts (87%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-insurance-support => no-online-support}/index.ts (73%) diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 6c0bbba29d..00658d9c2d 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -2824,11 +2824,10 @@ var typeDefs = ` esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean - canGetAQuoteByEmail: Boolean cannotGetAQuote: Boolean cannotApply: Boolean canApplyForInsuranceOnline: Boolean - noOnlineInsuranceSupport: Boolean + noOnlineSupport: Boolean noInsuranceSupport: Boolean } @@ -9018,46 +9017,6 @@ var mapNbiIssueAvailable = (str) => { }; var map_NBI_issue_available_default = mapNbiIssueAvailable; -// helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts -var { - CIS: { - ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, - }, -} = EXTERNAL_API_DEFINITIONS; -var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { - switch (esraClassification) { - case STANDARD: - return true; - case HIGH: - return true; - case VERY_HIGH: - return true; - default: - return false; - } -}; -var esra_classification_is_standard_high_or_very_high_default = esraClassificationIsStandardHighOrVeryHigh; - -// helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts -var { - CIS: { - SHORT_TERM_COVER: { YES: YES2, REFER, UNLISTED }, - }, -} = EXTERNAL_API_DEFINITIONS; -var shortTermCoverIsYesReferOrUnlisted = (shortTermCover) => { - switch (shortTermCover) { - case YES2: - return true; - case REFER: - return true; - case UNLISTED: - return true; - default: - return false; - } -}; -var short_term_cover_is_yes_refer_or_unlisted_default = shortTermCoverIsYesReferOrUnlisted; - // helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts var { CIS: { COUNTRY_RATINGS }, @@ -9073,41 +9032,10 @@ var countryRatingIsAorB = (rating) => { }; var country_rating_is_a_or_b_default = countryRatingIsAorB; -// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts -var canGetAQuoteOnline = (cisCountry) => { - const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; - const conditions = - esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && - short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && - country_rating_is_a_or_b_default(countryRatingDesc); - return conditions; -}; -var can_get_a_quote_online_default = canGetAQuoteOnline; - -// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts -var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { - if (shortTermCover && !nbiIssueAvailable && esraClassification) { - return true; - } - return false; -}; -var can_get_a_quote_by_email_default = canGetAQuoteByEmail; - -// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts -var canApplyForInsuranceOnline = (cisCountry) => { - const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; - const conditions = - esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && - short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && - country_rating_is_a_or_b_default(countryRatingDesc); - return conditions; -}; -var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; - -// helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts +// helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index.ts var { CIS: { - ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE }, + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, SHORT_TERM_COVER: { NO: NO2, ILC, CILC }, }, } = EXTERNAL_API_DEFINITIONS; @@ -9115,7 +9043,7 @@ var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover if (!country_rating_is_a_or_b_default(countryRating)) { return false; } - if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { + if (esraClassification === STANDARD || esraClassification === HIGH || esraClassification === VERY_HIGH) { if (shortTermCover === ILC) { return true; } @@ -9148,19 +9076,19 @@ var countryRatingIsCorD = (rating) => { }; var country_rating_is_c_or_d_default = countryRatingIsCorD; -// helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts +// helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index.ts var { CIS: { - ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE2 }, - SHORT_TERM_COVER: { YES: YES3, NO: NO3, ILC: ILC2, CILC: CILC2, REFER: REFER2, UNLISTED: UNLISTED2 }, + ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE: NONE2 }, + SHORT_TERM_COVER: { YES: YES2, NO: NO3, ILC: ILC2, CILC: CILC2, REFER, UNLISTED }, }, } = EXTERNAL_API_DEFINITIONS; var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_c_or_d_default(countryRating)) { return false; } - if (esraClassification === STANDARD3 || esraClassification === HIGH3 || esraClassification === VERY_HIGH3) { - if (shortTermCover === YES3) { + if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { + if (shortTermCover === YES2) { return true; } if (shortTermCover === ILC2) { @@ -9169,10 +9097,10 @@ var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover if (shortTermCover === CILC2) { return true; } - if (shortTermCover === REFER2) { + if (shortTermCover === REFER) { return true; } - if (shortTermCover === UNLISTED2) { + if (shortTermCover === UNLISTED) { return true; } if (shortTermCover === NO3) { @@ -9186,8 +9114,8 @@ var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }; var c_and_d_rating_conditions_default = cAndDRatingConditions; -// helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts -var noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }) => { +// helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts +var noOnlineSupport = ({ countryRating, esraClassification, shortTermCover }) => { const aAndBConditions = a_and_b_rating_conditions_default({ countryRating, esraClassification, @@ -9201,7 +9129,69 @@ var noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCo const conditions = aAndBConditions || cAndDConditions; return conditions; }; -var no_online_insurance_support_default = noOnlineInsuranceSupport; +var no_online_support_default = noOnlineSupport; + +// helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts +var { + CIS: { + ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3 }, + }, +} = EXTERNAL_API_DEFINITIONS; +var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { + switch (esraClassification) { + case STANDARD3: + return true; + case HIGH3: + return true; + case VERY_HIGH3: + return true; + default: + return false; + } +}; +var esra_classification_is_standard_high_or_very_high_default = esraClassificationIsStandardHighOrVeryHigh; + +// helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts +var { + CIS: { + SHORT_TERM_COVER: { YES: YES3, REFER: REFER2, UNLISTED: UNLISTED2 }, + }, +} = EXTERNAL_API_DEFINITIONS; +var shortTermCoverIsYesReferOrUnlisted = (shortTermCover) => { + switch (shortTermCover) { + case YES3: + return true; + case REFER2: + return true; + case UNLISTED2: + return true; + default: + return false; + } +}; +var short_term_cover_is_yes_refer_or_unlisted_default = shortTermCoverIsYesReferOrUnlisted; + +// helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts +var canGetAQuoteOnline = (cisCountry) => { + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; + const conditions = + esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && + short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && + country_rating_is_a_or_b_default(countryRatingDesc); + return conditions; +}; +var can_get_a_quote_online_default = canGetAQuoteOnline; + +// helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts +var canApplyForInsuranceOnline = (cisCountry) => { + const { ESRAClassificationDesc, shortTermCoverAvailabilityDesc, countryRatingDesc } = cisCountry; + const conditions = + esra_classification_is_standard_high_or_very_high_default(ESRAClassificationDesc) && + short_term_cover_is_yes_refer_or_unlisted_default(shortTermCoverAvailabilityDesc) && + country_rating_is_a_or_b_default(countryRatingDesc); + return conditions; +}; +var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; // helpers/map-CIS-countries/map-CIS-country/no-support/index.ts var { @@ -9242,19 +9232,18 @@ var mapCisCountry = (cisCountry) => { name: marketName, nbiIssueAvailable, shortTermCover, - canGetAQuoteOnline: can_get_a_quote_online_default(cisCountry), - canGetAQuoteByEmail: can_get_a_quote_by_email_default({ shortTermCover, nbiIssueAvailable, esraClassification }), - cannotGetAQuote: no_support_default({ + noOnlineSupport: no_online_support_default({ countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, }), - canApplyForInsuranceOnline: can_apply_for_insurance_online_default(cisCountry), - noOnlineInsuranceSupport: no_online_insurance_support_default({ + canGetAQuoteOnline: can_get_a_quote_online_default(cisCountry), + cannotGetAQuote: no_support_default({ countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, }), + canApplyForInsuranceOnline: can_apply_for_insurance_online_default(cisCountry), noInsuranceSupport: no_support_default({ countryRating, esraClassification: ESRAClassificationDesc, diff --git a/src/api/custom-schema/type-defs.ts b/src/api/custom-schema/type-defs.ts index 17c6c2ed00..059ce6611c 100644 --- a/src/api/custom-schema/type-defs.ts +++ b/src/api/custom-schema/type-defs.ts @@ -231,11 +231,10 @@ const typeDefs = ` esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean - canGetAQuoteByEmail: Boolean cannotGetAQuote: Boolean cannotApply: Boolean canApplyForInsuranceOnline: Boolean - noOnlineInsuranceSupport: Boolean + noOnlineSupport: Boolean noInsuranceSupport: Boolean } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts deleted file mode 100644 index 9ce54f4337..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -import canGetAQuoteByEmail from '.'; -import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; - -const { - CIS: { - ESRA_CLASSIFICATION: { STANDARD }, - }, -} = EXTERNAL_API_MAPPINGS; - -describe('helpers/map-cis-countries/map-cis-country/can-get-a-quote-by-email', () => { - describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is provided', () => { - it('should return true', () => { - const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: STANDARD }); - - expect(result).toEqual(true); - }); - }); - - describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is null', () => { - it('should return false', () => { - const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: null }); - - expect(result).toEqual(false); - }); - }); - - describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is an empty string', () => { - it('should return false', () => { - const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: '' }); - - expect(result).toEqual(false); - }); - }); - - describe('when shortTermCover=false, nbiIssueAvailable=false, esraClassification is provided', () => { - it('should return false', () => { - const result = canGetAQuoteByEmail({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: STANDARD }); - - expect(result).toEqual(false); - }); - }); - - describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is provided', () => { - it('should return false', () => { - const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: STANDARD }); - - expect(result).toEqual(false); - }); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts deleted file mode 100644 index 77d3366588..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MapCisCountryParams } from '../../../../types'; - -/** - * canGetAQuoteByEmail - * Check if a country is able to get a quote by email - * @param {MapCisCountryParams} - * @param {Boolean} shortTermCover: Short term cover flag. - * @param {Boolean} nbiIssueAvailable: NBI flag. - * @param {String} esraClassification: ESRA classification. - * @returns {Boolean} - */ -const canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { - if (shortTermCover && !nbiIssueAvailable && esraClassification) { - return true; - } - - return false; -}; - -export default canGetAQuoteByEmail; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index 545b34ae96..191830c438 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -2,10 +2,9 @@ import mapCisCountry from '.'; import mapEsraClassification from './map-esra-classification'; import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; +import noOnlineSupport from './no-online-support'; import canGetAQuoteOnline from './can-get-a-quote-online'; -import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; -import noOnlineInsuranceSupport from './no-online-insurance-support'; import noSupport from './no-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; import { MappedCisCountry } from '../../../types'; @@ -40,24 +39,22 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { nbiIssueAvailable, shortTermCover, - canGetAQuoteOnline: canGetAQuoteOnline(mockCisCountry), - - canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), - - cannotGetAQuote: noSupport({ + noOnlineSupport: noOnlineSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, }), - canApplyForInsuranceOnline: canApplyForInsuranceOnline(mockCisCountry), + canGetAQuoteOnline: canGetAQuoteOnline(mockCisCountry), - noOnlineInsuranceSupport: noOnlineInsuranceSupport({ + cannotGetAQuote: noSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, }), + canApplyForInsuranceOnline: canApplyForInsuranceOnline(mockCisCountry), + noInsuranceSupport: noSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index d82525eee2..6efb281114 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -1,10 +1,9 @@ import mapEsraClassification from './map-esra-classification'; import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; +import noOnlineSupport from './no-online-support'; import canGetAQuoteOnline from './can-get-a-quote-online'; -import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; -import noOnlineInsuranceSupport from './no-online-insurance-support'; import noSupport from './no-support'; import { CisCountry, MappedCisCountry } from '../../../types'; @@ -31,24 +30,22 @@ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { nbiIssueAvailable, shortTermCover, - canGetAQuoteOnline: canGetAQuoteOnline(cisCountry), - - canGetAQuoteByEmail: canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }), - - cannotGetAQuote: noSupport({ + noOnlineSupport: noOnlineSupport({ countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, }), - canApplyForInsuranceOnline: canApplyForInsuranceOnline(cisCountry), + canGetAQuoteOnline: canGetAQuoteOnline(cisCountry), - noOnlineInsuranceSupport: noOnlineInsuranceSupport({ + cannotGetAQuote: noSupport({ countryRating, esraClassification: ESRAClassificationDesc, shortTermCover: shortTermCoverAvailabilityDesc, }), + canApplyForInsuranceOnline: canApplyForInsuranceOnline(cisCountry), + noInsuranceSupport: noSupport({ countryRating, esraClassification: ESRAClassificationDesc, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts similarity index 96% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts index b3dc1ed7af..33feec8e75 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-a.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts @@ -34,7 +34,7 @@ const params = { }, }; -describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - rating as A', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions - rating as A', () => { describe(`when the ESRA classification is ${STANDARD}`, () => { describe.each(params.STANDARD[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { it(`should return true for ${countryObj.countryRating}`, () => { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts similarity index 96% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts index 4e618ba2dc..bf902d6757 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-b.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts @@ -34,7 +34,7 @@ const params = { }, }; -describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - rating as B', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions - rating as B', () => { describe(`when the ESRA classification is ${STANDARD}`, () => { describe.each(params.STANDARD[ILC])(`when the short term cover is ${ILC}`, (countryObj) => { it(`should return true for ${countryObj.countryRating}`, () => { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts similarity index 89% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts index f69ca445e0..b1cbbad41d 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts @@ -17,7 +17,7 @@ const countryRatingsDParams = COUNTRY_RATINGS.D.map((rating: string) => ({ shortTermCover: SHORT_TERM_COVER.YES, })); -describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - ratings as C and D', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions - ratings as C and D', () => { describe.each(countryRatingsCParams)('when the country rating is `C`', (countryObj) => { it(`should return false for ${countryObj.countryRating}`, () => { const result = aAndBRatingConditions(countryObj); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts similarity index 83% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts index 84140f061e..9dd2486c78 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index-rating-none.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts @@ -9,7 +9,7 @@ const { }, } = EXTERNAL_API_DEFINITIONS; -describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions - ESRA classification=NONE, short term cover=NO', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions - ESRA classification=NONE, short term cover=NO', () => { describe('when the country rating is `A`', () => { it('should return true', () => { const result = aAndBRatingConditions({ diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/a-and-b-rating-conditions/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts similarity index 89% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts index 872991a0be..43732b868d 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts @@ -17,7 +17,7 @@ const countryRatingsBParams = COUNTRY_RATINGS.B.map((rating: string) => ({ shortTermCover: SHORT_TERM_COVER.YES, })); -describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/a-and-b-rating-conditions - rating as A and B', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions - rating as A and B', () => { describe.each(countryRatingsAParams)('when the country rating is `A`', (countryObj) => { it(`should return false for ${countryObj.countryRating}`, () => { const result = cAndDRatingConditions(countryObj); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts similarity index 98% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts index c6b7dd6cd8..15298d932a 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-c.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts @@ -43,7 +43,7 @@ const params = { }, }; -describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/c-and-d-rating-conditions - rating as C', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions - rating as C', () => { describe(`when the ESRA classification is ${STANDARD}`, () => { describe.each(params.STANDARD[YES])(`when the short term cover is ${YES}`, (countryObj) => { it(`should return true for ${countryObj.countryRating}`, () => { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts similarity index 98% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts index afc5aa1c8e..950e5ffd62 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-d.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts @@ -43,7 +43,7 @@ const params = { }, }; -describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/c-and-d-rating-conditions - rating as D', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions - rating as D', () => { describe(`when the ESRA classification is ${STANDARD}`, () => { describe.each(params.STANDARD[YES])(`when the short term cover is ${YES}`, (countryObj) => { it(`should return true for ${countryObj.countryRating}`, () => { diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts similarity index 84% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts index b2965918dc..4e9520edd6 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index-rating-none.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts @@ -9,7 +9,7 @@ const { }, } = EXTERNAL_API_DEFINITIONS; -describe('helpers/map-CIS-countries/map-CIS-country/no-insurance-support/c-and-d-rating-conditions - ESRA classification=NONE, short term cover=NO', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions - ESRA classification=NONE, short term cover=NO', () => { describe('when the country rating is `C`', () => { it('should return true', () => { const result = cAndDRatingConditions({ diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/c-and-d-rating-conditions/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.test.ts similarity index 87% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.test.ts index 208d83ab56..f27b485c7a 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.test.ts @@ -1,4 +1,4 @@ -import noOnlineInsuranceSupport from '.'; +import noOnlineSupport from '.'; import aAndBRatingConditions from './a-and-b-rating-conditions'; import cAndDRatingConditions from './c-and-d-rating-conditions'; import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; @@ -13,7 +13,7 @@ const mockInitCountry = { shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, }; -describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support', () => { +describe('helpers/map-CIS-countries/map-CIS-country/no-online-support', () => { describe('when a country rating is `A`', () => { it('should return the result of aAndBRatingConditions', () => { const [mockRating] = COUNTRY_RATINGS.A; @@ -23,7 +23,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support' countryRating: mockRating, }; - const result = noOnlineInsuranceSupport(mockCountry); + const result = noOnlineSupport(mockCountry); const expected = aAndBRatingConditions({ countryRating: mockRating, @@ -44,7 +44,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support' countryRating: mockRating, }; - const result = noOnlineInsuranceSupport(mockCountry); + const result = noOnlineSupport(mockCountry); const expected = aAndBRatingConditions({ countryRating: mockRating, @@ -65,7 +65,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support' countryRating: mockRating, }; - const result = noOnlineInsuranceSupport(mockCountry); + const result = noOnlineSupport(mockCountry); const expected = cAndDRatingConditions({ countryRating: mockRating, @@ -86,7 +86,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support' countryRating: mockRating, }; - const result = noOnlineInsuranceSupport(mockCountry); + const result = noOnlineSupport(mockCountry); const expected = cAndDRatingConditions({ countryRating: mockRating, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts similarity index 73% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts index a853396e34..d73fc143df 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-insurance-support/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts @@ -3,14 +3,14 @@ import cAndDRatingConditions from './c-and-d-rating-conditions'; import { NoInsuranceSupportParams } from '../../../../types'; /** - * noOnlineInsuranceSupport - * Check if a country has no online insurance support + * noOnlineSupport + * Check if a country has no quote or insurance support (online) * @param {String} countryRating: Country rating * @param {String} esraClassification: ESRA classification * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { +const noOnlineSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { const aAndBConditions = aAndBRatingConditions({ countryRating, esraClassification, @@ -28,4 +28,4 @@ const noOnlineInsuranceSupport = ({ countryRating, esraClassification, shortTerm return conditions; }; -export default noOnlineInsuranceSupport; +export default noOnlineSupport; diff --git a/src/api/schema.graphql b/src/api/schema.graphql index 0662169c26..966beaa723 100644 --- a/src/api/schema.graphql +++ b/src/api/schema.graphql @@ -3745,11 +3745,10 @@ type MappedCisCountry { esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean - canGetAQuoteByEmail: Boolean cannotGetAQuote: Boolean cannotApply: Boolean canApplyForInsuranceOnline: Boolean - noOnlineInsuranceSupport: Boolean + noOnlineSupport: Boolean noInsuranceSupport: Boolean } diff --git a/src/api/test-mocks/mock-mapped-CIS-countries.ts b/src/api/test-mocks/mock-mapped-CIS-countries.ts index f30c0d231a..4d7019e89e 100644 --- a/src/api/test-mocks/mock-mapped-CIS-countries.ts +++ b/src/api/test-mocks/mock-mapped-CIS-countries.ts @@ -3,10 +3,8 @@ import { MappedCisCountry } from '../types'; // mock base country that can get a quote and apply online. const baseCountry = { canGetAQuoteOnline: true, - canGetAQuoteByEmail: true, cannotGetAQuote: false, canApplyForInsuranceOnline: true, - noInsuranceSupport: false, }; const mockCountries = [ diff --git a/src/api/types/country/index.ts b/src/api/types/country/index.ts index 29c0275927..825a6b284b 100644 --- a/src/api/types/country/index.ts +++ b/src/api/types/country/index.ts @@ -19,10 +19,8 @@ export interface Country extends Relationship { shortTermCover?: boolean; nbiIssueAvailable?: boolean; canGetAQuoteOnline?: boolean; - canGetAQuoteByEmail?: boolean; cannotGetAQuote?: boolean; canApplyForInsuranceOnline?: boolean; - noInsuranceSupport?: boolean; } export interface GetApimCisCountriesResponse { @@ -42,10 +40,9 @@ export interface MappedCisCountry { nbiIssueAvailable: boolean; name: string; shortTermCover: boolean; + noOnlineSupport: boolean; canGetAQuoteOnline: boolean; - canGetAQuoteByEmail: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; - noOnlineInsuranceSupport: boolean; noInsuranceSupport: boolean; } diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts index 7eba63c9a5..f7c7dcf9d8 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts @@ -11,7 +11,6 @@ import { mockReq, mockRes, mockCountries } from '../../../../test-mocks'; const { ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, BUYER_COUNTRY_CHANGE, CHECK_YOUR_ANSWERS, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, - PROBLEM_WITH_SERVICE, } = INSURANCE_ROUTES; describe('controllers/insurance/eligibility/buyer-country - redirects', () => { @@ -20,7 +19,7 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { let mockCountriesResponse = mockCountries; - const { 1: countryApplyOnline, 4: countryNoInsuranceSupport, 5: countryNoOnlineInsuranceSupport } = mockCountriesResponse; + const { 1: canApplyForInsuranceOnline, 4: noInsuranceSupport, 5: noOnlineInsuranceSupport } = mockCountriesResponse; const mockFlash = jest.fn(); beforeEach(() => { @@ -53,27 +52,23 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); }); - describe('when the country has a canApplyForInsuranceOnline flag', () => { - const selectedCountryIsoCode = countryApplyOnline.isoCode; - - const validBody = { - [FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY]: selectedCountryIsoCode, - }; + describe('when the API returns a noOnlineInsuranceSupport flag for the submitted country', () => { + const selectedCountryName = noOnlineInsuranceSupport.isoCode; beforeEach(() => { - req.body = validBody; + req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryName; - mockCountriesResponse = [countryApplyOnline]; + mockCountriesResponse = [noOnlineInsuranceSupport]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); api.keystone.APIM.getCisCountries = getCisCountriesSpy; }); - it('should update the session with populated with country object', async () => { + it('should update the session with populated country object', async () => { await post(req, res); - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, noOnlineInsuranceSupport.isoCode); const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); @@ -85,41 +80,34 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { expect(req.session.submittedData).toEqual(expected); }); - it(`should redirect to ${TOTAL_VALUE_INSURED}`, async () => { + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT}`, async () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(TOTAL_VALUE_INSURED); - }); - - describe("when the url's last substring is `change`", () => { - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, async () => { - req.originalUrl = BUYER_COUNTRY_CHANGE; - - await post(req, res); - - const expected = CHECK_YOUR_ANSWERS; - expect(res.redirect).toHaveBeenCalledWith(expected); - }); + expect(res.redirect).toHaveBeenCalledWith(TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); }); }); - describe('when the country has a noOnlineInsuranceSupport flag', () => { - const selectedCountryName = countryNoOnlineInsuranceSupport.isoCode; + describe('when the API returns a canApplyForInsuranceOnline flag for the submitted country', () => { + const selectedCountryIsoCode = canApplyForInsuranceOnline.isoCode; + + const validBody = { + [FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY]: selectedCountryIsoCode, + }; beforeEach(() => { - req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryName; + req.body = validBody; - mockCountriesResponse = [countryNoOnlineInsuranceSupport]; + mockCountriesResponse = [canApplyForInsuranceOnline]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); api.keystone.APIM.getCisCountries = getCisCountriesSpy; }); - it('should update the session with populated country object', async () => { + it('should update the session with populated with country object', async () => { await post(req, res); - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, countryNoOnlineInsuranceSupport.isoCode); + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); @@ -131,21 +119,32 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { expect(req.session.submittedData).toEqual(expected); }); - it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT}`, async () => { + it(`should redirect to ${TOTAL_VALUE_INSURED}`, async () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + expect(res.redirect).toHaveBeenCalledWith(TOTAL_VALUE_INSURED); + }); + + describe("when the url's last substring is `change`", () => { + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, async () => { + req.originalUrl = BUYER_COUNTRY_CHANGE; + + await post(req, res); + + const expected = CHECK_YOUR_ANSWERS; + expect(res.redirect).toHaveBeenCalledWith(expected); + }); }); }); - describe('when the country has a noInsuranceSupport flag', () => { - const selectedCountryName = countryNoInsuranceSupport.name; - const selectedCountryIsoCode = countryNoInsuranceSupport.isoCode; + describe('when the API returns a noInsuranceSupport flag for the submitted country', () => { + const selectedCountryName = noInsuranceSupport.name; + const selectedCountryIsoCode = noInsuranceSupport.isoCode; beforeEach(() => { req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryIsoCode; - mockCountriesResponse = [countryNoInsuranceSupport]; + mockCountriesResponse = [noInsuranceSupport]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); @@ -184,30 +183,5 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { expect(res.redirect).toHaveBeenCalledWith(CANNOT_APPLY_ROUTE); }); }); - - describe('when the country does not have any recognised flags with a value of true', () => { - beforeEach(() => { - req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = countryNoInsuranceSupport.isoCode; - - mockCountriesResponse = [ - { - ...countryNoInsuranceSupport, - noOnlineInsuranceSupport: false, - canApplyForInsuranceOnline: false, - noInsuranceSupport: false, - }, - ]; - - getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); - - api.keystone.APIM.getCisCountries = getCisCountriesSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); }); }); diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts index 34498e8605..dab547192e 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/index.ts @@ -94,7 +94,7 @@ export const post = async (req: Request, res: Response) => { * If a country does not have online insurance support, * redirect to a specific exit page. */ - if (country.noOnlineInsuranceSupport) { + if (country.noOnlineSupport) { console.info('Country support - %s - no online insurance support available', country.name); const populatedData = mapSubmittedEligibilityCountry(country); @@ -108,8 +108,8 @@ export const post = async (req: Request, res: Response) => { } /** - * If a country cannot apply for insurance online, - * redirect to a specific exit page. + * If a country can apply for insurance online, + * redirect to the next page. */ if (country.canApplyForInsuranceOnline) { console.info('Country support - %s - can apply for insurance online', country.name); @@ -129,7 +129,7 @@ export const post = async (req: Request, res: Response) => { } /** - * If a country has no insurance support (online or offline) + * If a country has no online support * redirect to a specific exit page. */ if (country.noInsuranceSupport) { diff --git a/src/ui/server/controllers/quote/buyer-country/index.test.ts b/src/ui/server/controllers/quote/buyer-country/index.test.ts index 6bc72dae20..eda546361c 100644 --- a/src/ui/server/controllers/quote/buyer-country/index.test.ts +++ b/src/ui/server/controllers/quote/buyer-country/index.test.ts @@ -377,7 +377,6 @@ describe('controllers/quote/buyer-country', () => { { ...countryQuoteOnline, canGetAQuoteOnline: false, - canGetAQuoteByEmail: false, cannotGetAQuote: false, }, ]; diff --git a/src/ui/server/controllers/quote/buyer-country/index.ts b/src/ui/server/controllers/quote/buyer-country/index.ts index 81e14cc2a0..5b19832c9b 100644 --- a/src/ui/server/controllers/quote/buyer-country/index.ts +++ b/src/ui/server/controllers/quote/buyer-country/index.ts @@ -140,10 +140,10 @@ export const post = async (req: Request, res: Response) => { } /** - * If a country can get a quote by email, + * If a country has no online support, * redirect to a specific exit page. */ - if (country.canGetAQuoteByEmail) { + if (country.noOnlineSupport) { console.info('Country support - %s - can get a quote by email', country.name); const populatedData = mapSubmittedEligibilityCountry(country); diff --git a/src/ui/server/graphql/queries/APIM/CIS-countries.ts b/src/ui/server/graphql/queries/APIM/CIS-countries.ts index 31323efc88..a6ecbcc115 100644 --- a/src/ui/server/graphql/queries/APIM/CIS-countries.ts +++ b/src/ui/server/graphql/queries/APIM/CIS-countries.ts @@ -7,11 +7,10 @@ const getApimCisCountries = gql` name esraClassification canGetAQuoteOnline - canGetAQuoteByEmail cannotGetAQuote cannotApply canApplyForInsuranceOnline - noOnlineInsuranceSupport + noOnlineSupport noInsuranceSupport shortTermCover } diff --git a/src/ui/server/test-mocks/mock-countries.ts b/src/ui/server/test-mocks/mock-countries.ts index 46de4d3913..16169df6c5 100644 --- a/src/ui/server/test-mocks/mock-countries.ts +++ b/src/ui/server/test-mocks/mock-countries.ts @@ -8,10 +8,8 @@ const { // mock base country that can get a quote and apply online. const baseCountry = { canGetAQuoteOnline: true, - canGetAQuoteByEmail: false, cannotGetAQuote: false, canApplyForInsuranceOnline: true, - noInsuranceSupport: false, shortTermCover: true, }; @@ -48,7 +46,7 @@ const mockCountries = [ esraClassification: RISK.VERY_HIGH, ...baseCountry, canGetAQuoteOnline: false, - canGetAQuoteByEmail: true, + noOnlineSupport: true, }, /** * mock country that: @@ -74,7 +72,6 @@ const mockCountries = [ esraClassification: RISK.STANDARD, canGetAQuoteOnline: false, canApplyForInsuranceOnline: false, - noOnlineInsuranceSupport: false, noInsuranceSupport: true, }, /** @@ -91,9 +88,8 @@ const mockCountries = [ canGetAQuoteOnline: true, canApplyForInsuranceOnline: true, canApplyForInsuranceOffline: false, - noInsuranceSupport: false, shortTermCover: false, - noOnlineInsuranceSupport: true, + noOnlineSupport: true, }, ] as Array; diff --git a/src/ui/types/country.d.ts b/src/ui/types/country.d.ts index 5ae27afb9c..b0b1d99890 100644 --- a/src/ui/types/country.d.ts +++ b/src/ui/types/country.d.ts @@ -6,10 +6,9 @@ interface Country { selected?: boolean; value: string; canGetAQuoteOnline: boolean; - canGetAQuoteByEmail: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; - noOnlineInsuranceSupport: boolean; + noOnlineSupport: boolean; noInsuranceSupport: boolean; shortTermCover: boolean; } From 9520f485f40163810a888998bbc7c2bd9957ade9 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Mon, 23 Dec 2024 10:09:55 +0000 Subject: [PATCH 08/12] chore(EMS-4076-4077): improve buyer country unit tests (#3433) * chore(EMS-4076): improve buyer country unit tests * chore(EMS-4076): improve ui country mocks --- .../buyer-country/country-redirects.test.ts | 44 ++-- .../buyer-country/country-redirects.test.ts | 198 ++++++++++++++++++ .../quote/buyer-country/index.test.ts | 191 +---------------- src/ui/server/test-mocks/index.ts | 3 +- src/ui/server/test-mocks/mock-countries.ts | 130 +++++------- src/ui/types/country.d.ts | 2 +- 6 files changed, 279 insertions(+), 289 deletions(-) create mode 100644 src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts diff --git a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts index f7c7dcf9d8..2021d57338 100644 --- a/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts +++ b/src/ui/server/controllers/insurance/eligibility/buyer-country/country-redirects.test.ts @@ -7,19 +7,25 @@ import getCountryByIsoCode from '../../../../helpers/get-country-by-iso-code'; import mapSubmittedEligibilityCountry from '../../../../helpers/mappings/map-submitted-eligibility-country'; import { updateSubmittedData } from '../../../../helpers/update-submitted-data/insurance'; import { Request, Response } from '../../../../../types'; -import { mockReq, mockRes, mockCountries } from '../../../../test-mocks'; +import { + mockReq, + mockRes, + mockCountries, + mockCountryCanApplyForInsuranceOnline, + mockCountryNoInsuranceSupport, + mockCountryNoOnlineSupport, +} from '../../../../test-mocks'; const { ELIGIBILITY: { CANNOT_APPLY_EXIT: CANNOT_APPLY_ROUTE, TOTAL_VALUE_INSURED, BUYER_COUNTRY_CHANGE, CHECK_YOUR_ANSWERS, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, } = INSURANCE_ROUTES; +let mockCountriesResponse = mockCountries; + describe('controllers/insurance/eligibility/buyer-country - redirects', () => { let req: Request; let res: Response; - let mockCountriesResponse = mockCountries; - - const { 1: canApplyForInsuranceOnline, 4: noInsuranceSupport, 5: noOnlineInsuranceSupport } = mockCountriesResponse; const mockFlash = jest.fn(); beforeEach(() => { @@ -52,23 +58,23 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); }); - describe('when the API returns a noOnlineInsuranceSupport flag for the submitted country', () => { - const selectedCountryName = noOnlineInsuranceSupport.isoCode; + describe('when the API returns a noOnlineSupport flag for the submitted country', () => { + const selectedCountryName = mockCountryNoOnlineSupport.isoCode; beforeEach(() => { - req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryName; - - mockCountriesResponse = [noOnlineInsuranceSupport]; + mockCountriesResponse = [mockCountryNoOnlineSupport]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); api.keystone.APIM.getCisCountries = getCisCountriesSpy; + + req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryName; }); it('should update the session with populated country object', async () => { await post(req, res); - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, noOnlineInsuranceSupport.isoCode); + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, mockCountryNoOnlineSupport.isoCode); const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); @@ -88,20 +94,20 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); describe('when the API returns a canApplyForInsuranceOnline flag for the submitted country', () => { - const selectedCountryIsoCode = canApplyForInsuranceOnline.isoCode; + const selectedCountryIsoCode = mockCountryCanApplyForInsuranceOnline.isoCode; const validBody = { [FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY]: selectedCountryIsoCode, }; beforeEach(() => { - req.body = validBody; - - mockCountriesResponse = [canApplyForInsuranceOnline]; + mockCountriesResponse = [mockCountryCanApplyForInsuranceOnline]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); api.keystone.APIM.getCisCountries = getCisCountriesSpy; + + req.body = validBody; }); it('should update the session with populated with country object', async () => { @@ -138,17 +144,17 @@ describe('controllers/insurance/eligibility/buyer-country - redirects', () => { }); describe('when the API returns a noInsuranceSupport flag for the submitted country', () => { - const selectedCountryName = noInsuranceSupport.name; - const selectedCountryIsoCode = noInsuranceSupport.isoCode; + const selectedCountryName = mockCountryNoInsuranceSupport.name; + const selectedCountryIsoCode = mockCountryNoInsuranceSupport.isoCode; beforeEach(() => { - req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryIsoCode; - - mockCountriesResponse = [noInsuranceSupport]; + mockCountriesResponse = [mockCountryNoInsuranceSupport]; getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); api.keystone.APIM.getCisCountries = getCisCountriesSpy; + + req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = selectedCountryIsoCode; }); it('should update the session with populated with country object', async () => { diff --git a/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts new file mode 100644 index 0000000000..98c2eab24e --- /dev/null +++ b/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts @@ -0,0 +1,198 @@ +import { FIELD_ID, post } from '.'; +import { PAGES } from '../../../content-strings'; +import { ROUTES } from '../../../constants'; +import getCountryByIsoCode from '../../../helpers/get-country-by-iso-code'; +import mapSubmittedEligibilityCountry from '../../../helpers/mappings/map-submitted-eligibility-country'; +import api from '../../../api'; +import { updateSubmittedData } from '../../../helpers/update-submitted-data/quote'; +import { + mockReq, + mockRes, + mockCountries, + mockCountryCannotGetAQuote, + mockCountryCanGetAQuoteOnline, + mockCountryCanGetAQuoteByEmail, +} from '../../../test-mocks'; +import { Request, Response } from '../../../../types'; + +let mockCountriesResponse = mockCountries; + +describe('controllers/quote/buyer-country - redirects', () => { + let req: Request; + let res: Response; + + const mockFlash = jest.fn(); + + beforeEach(() => { + req = mockReq(); + req.flash = mockFlash; + + res = mockRes(); + }); + + afterAll(() => { + jest.resetAllMocks(); + }); + + describe('post', () => { + let getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + + beforeEach(() => { + api.keystone.APIM.getCisCountries = getCisCountriesSpy; + }); + + describe('when the submitted country is not found', () => { + beforeEach(() => { + req.body[FIELD_ID] = 'Country not in the mock response'; + }); + + it(`should redirect to ${ROUTES.QUOTE.CANNOT_APPLY_EXIT}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.CANNOT_APPLY_EXIT); + }); + }); + + describe('when the API returns a canGetAQuoteOnline flag for the submitted country', () => { + const selectedCountryIsoCode = mockCountryCanGetAQuoteOnline.isoCode; + + beforeEach(() => { + jest.resetAllMocks(); + + mockCountriesResponse = [mockCountryCanGetAQuoteOnline]; + + getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + + api.keystone.APIM.getCisCountries = getCisCountriesSpy; + + req.body[FIELD_ID] = selectedCountryIsoCode; + }); + + it('should update the session with submitted data, populated with country object', async () => { + await post(req, res); + + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); + + const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); + + const expected = updateSubmittedData(expectedPopulatedData, req.session.submittedData.quoteEligibility); + + expect(req.session.submittedData.quoteEligibility).toEqual(expected); + }); + + it(`should redirect to ${ROUTES.QUOTE.BUYER_BODY}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.BUYER_BODY); + }); + + describe("when the url's last substring is `change`", () => { + it(`should redirect to ${ROUTES.QUOTE.CHECK_YOUR_ANSWERS}`, async () => { + req.originalUrl = 'mock/change'; + + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.CHECK_YOUR_ANSWERS); + }); + }); + }); + + describe('when the API returns a canGetAQuoteByEmail flag for the submitted country', () => { + const selectedCountryIsoCode = mockCountryCanGetAQuoteByEmail.isoCode; + + beforeEach(() => { + jest.resetAllMocks(); + + mockCountriesResponse = [mockCountryCanGetAQuoteByEmail]; + + getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + + api.keystone.APIM.getCisCountries = getCisCountriesSpy; + + req.body[FIELD_ID] = mockCountryCanGetAQuoteByEmail.isoCode; + }); + + it('should update the session with submitted data, populated with country object', async () => { + await post(req, res); + + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); + + const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); + + const expected = updateSubmittedData(expectedPopulatedData, req.session.submittedData.quoteEligibility); + + expect(req.session.submittedData.quoteEligibility).toEqual(expected); + }); + + it('should add previousRoute, exitReason and exitDescription to req.flash', async () => { + await post(req, res); + + expect(mockFlash).toHaveBeenCalledTimes(3); + + expect(mockFlash.mock.calls[0]).toEqual(['previousRoute', ROUTES.QUOTE.BUYER_COUNTRY]); + + const { GET_A_QUOTE_BY_EMAIL } = PAGES.QUOTE; + const { REASON } = GET_A_QUOTE_BY_EMAIL; + + expect(mockFlash.mock.calls[1]).toEqual(['exitReason', REASON.BUYER_COUNTRY]); + expect(mockFlash.mock.calls[2]).toEqual(['exitDescription', REASON.BUYER_COUNTRY_DESCRIPTION]); + }); + + it(`should redirect to ${ROUTES.QUOTE.GET_A_QUOTE_BY_EMAIL}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.GET_A_QUOTE_BY_EMAIL); + }); + }); + + describe('when the API returns a cannotGetAQuote flag for the submitted country', () => { + const selectedCountryName = mockCountryCannotGetAQuote.name; + const selectedCountryIsoCode = mockCountryCannotGetAQuote.isoCode; + + beforeEach(() => { + jest.resetAllMocks(); + + mockCountriesResponse = [mockCountryCannotGetAQuote]; + + getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + + api.keystone.APIM.getCisCountries = getCisCountriesSpy; + + req.body[FIELD_ID] = selectedCountryIsoCode; + }); + + it('should update the session with submitted data, populated with country object', async () => { + await post(req, res); + + const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); + + const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); + + const expected = updateSubmittedData(expectedPopulatedData, req.session.submittedData.quoteEligibility); + + expect(req.session.submittedData.quoteEligibility).toEqual(expected); + }); + + it('should add previousRoute and exitReason to req.flash', async () => { + await post(req, res); + + expect(req.flash).toHaveBeenCalledWith('previousRoute', ROUTES.QUOTE.BUYER_COUNTRY); + + const countryName = selectedCountryName; + + const { CANNOT_APPLY_EXIT } = PAGES; + const { REASON } = CANNOT_APPLY_EXIT; + + const expectedReason = `${REASON.UNSUPPORTED_BUYER_COUNTRY_1} ${countryName}, ${REASON.UNSUPPORTED_BUYER_COUNTRY_2}`; + + expect(req.flash).toHaveBeenCalledWith('exitReason', expectedReason); + }); + + it(`should redirect to ${ROUTES.QUOTE.CANNOT_APPLY_EXIT}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.CANNOT_APPLY_EXIT); + }); + }); + }); +}); diff --git a/src/ui/server/controllers/quote/buyer-country/index.test.ts b/src/ui/server/controllers/quote/buyer-country/index.test.ts index eda546361c..b2eaca2808 100644 --- a/src/ui/server/controllers/quote/buyer-country/index.test.ts +++ b/src/ui/server/controllers/quote/buyer-country/index.test.ts @@ -6,11 +6,8 @@ import getUserNameFromSession from '../../../helpers/get-user-name-from-session' import constructPayload from '../../../helpers/construct-payload'; import { validation as generateValidationErrors } from '../../../shared-validation/buyer-country'; import isChangeRoute from '../../../helpers/is-change-route'; -import getCountryByIsoCode from '../../../helpers/get-country-by-iso-code'; -import mapSubmittedEligibilityCountry from '../../../helpers/mappings/map-submitted-eligibility-country'; import api from '../../../api'; import mapCountries from '../../../helpers/mappings/map-countries'; -import { updateSubmittedData } from '../../../helpers/update-submitted-data/quote'; import { mockReq, mockRes, mockCountries, mockSpyPromiseRejection } from '../../../test-mocks'; import { Request, Response } from '../../../../types'; @@ -18,10 +15,6 @@ describe('controllers/quote/buyer-country', () => { let req: Request; let res: Response; - let mockCountriesResponse = mockCountries; - - const { 0: countryUnsupported, 1: countryQuoteOnline, 2: countryQuoteByEmail } = mockCountriesResponse; - const mockFlash = jest.fn(); beforeEach(() => { @@ -106,7 +99,7 @@ describe('controllers/quote/buyer-country', () => { }); describe('get', () => { - let getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + let getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); beforeEach(() => { api.keystone.APIM.getCisCountries = getCisCountriesSpy; @@ -124,7 +117,7 @@ describe('controllers/quote/buyer-country', () => { const expectedVariables = { ...singleInputPageVariables({ ...PAGE_VARIABLES, BACK_LINK: getBackLink(req.headers.referer), ORIGINAL_URL: req.originalUrl }), userName: getUserNameFromSession(req.session.user), - countries: mapCountries(mockCountriesResponse, req.session.submittedData.quoteEligibility[FIELD_ID]?.isoCode), + countries: mapCountries(mockCountries, req.session.submittedData.quoteEligibility[FIELD_ID]?.isoCode), submittedValues: req.session.submittedData.quoteEligibility, isChangeRoute: isChangeRoute(req.originalUrl), }; @@ -197,7 +190,7 @@ describe('controllers/quote/buyer-country', () => { }); describe('post', () => { - let getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); + let getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); beforeEach(() => { api.keystone.APIM.getCisCountries = getCisCountriesSpy; @@ -212,191 +205,18 @@ describe('controllers/quote/buyer-country', () => { expect(res.render).toHaveBeenCalledWith(TEMPLATES.SHARED_PAGES.BUYER_COUNTRY, { ...singleInputPageVariables({ ...PAGE_VARIABLES, BACK_LINK: getBackLink(req.headers.referer), ORIGINAL_URL: req.originalUrl }), userName: getUserNameFromSession(req.session.user), - countries: mapCountries(mockCountriesResponse), + countries: mapCountries(mockCountries), validationErrors: generateValidationErrors(payload), isChangeRoute: isChangeRoute(req.originalUrl), }); }); }); - describe('when the submitted country can only get a quote via email', () => { - const selectedCountryisoCode = countryQuoteByEmail.isoCode; - - mockCountriesResponse = [countryQuoteByEmail]; - - getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); - - beforeEach(() => { - req.body[FIELD_ID] = countryQuoteByEmail.isoCode; - }); - - it('should update the session with submitted data, populated with country object', async () => { - await post(req, res); - - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryisoCode); - - const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); - - const expected = updateSubmittedData(expectedPopulatedData, req.session.submittedData.quoteEligibility); - - expect(req.session.submittedData.quoteEligibility).toEqual(expected); - }); - - it('should add previousRoute, exitReason and exitDescription to req.flash', async () => { - await post(req, res); - - expect(mockFlash).toHaveBeenCalledTimes(3); - - expect(mockFlash.mock.calls[0]).toEqual(['previousRoute', ROUTES.QUOTE.BUYER_COUNTRY]); - - const { GET_A_QUOTE_BY_EMAIL } = PAGES.QUOTE; - const { REASON } = GET_A_QUOTE_BY_EMAIL; - - expect(mockFlash.mock.calls[1]).toEqual(['exitReason', REASON.BUYER_COUNTRY]); - expect(mockFlash.mock.calls[2]).toEqual(['exitDescription', REASON.BUYER_COUNTRY_DESCRIPTION]); - }); - - it(`should redirect to ${ROUTES.QUOTE.GET_A_QUOTE_BY_EMAIL}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.GET_A_QUOTE_BY_EMAIL); - }); - }); - - describe('when the submitted country is not found', () => { - beforeEach(() => { - req.body[FIELD_ID] = 'Country not in the mock response'; - }); - - it(`should redirect to ${ROUTES.QUOTE.CANNOT_APPLY_EXIT}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.CANNOT_APPLY_EXIT); - }); - }); - - describe('when the submitted country is not supported', () => { - const selectedCountryName = countryUnsupported.name; - const selectedCountryIsoCode = countryUnsupported.isoCode; - - beforeEach(() => { - req.body[FIELD_ID] = selectedCountryIsoCode; - - mockCountriesResponse = [countryUnsupported]; - - getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); - - api.keystone.APIM.getCisCountries = getCisCountriesSpy; - }); - - it('should update the session with submitted data, populated with country object', async () => { - await post(req, res); - - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); - - const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); - - const expected = updateSubmittedData(expectedPopulatedData, req.session.submittedData.quoteEligibility); - - expect(req.session.submittedData.quoteEligibility).toEqual(expected); - }); - - it('should add previousRoute and exitReason to req.flash', async () => { - await post(req, res); - - expect(req.flash).toHaveBeenCalledWith('previousRoute', ROUTES.QUOTE.BUYER_COUNTRY); - - const countryName = selectedCountryName; - - const { CANNOT_APPLY_EXIT } = PAGES; - const { REASON } = CANNOT_APPLY_EXIT; - - const expectedReason = `${REASON.UNSUPPORTED_BUYER_COUNTRY_1} ${countryName}, ${REASON.UNSUPPORTED_BUYER_COUNTRY_2}`; - - expect(req.flash).toHaveBeenCalledWith('exitReason', expectedReason); - }); - - it(`should redirect to ${ROUTES.QUOTE.CANNOT_APPLY_EXIT}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.CANNOT_APPLY_EXIT); - }); - }); - - describe('when the country is supported for an online quote and there are no validation errors', () => { - const selectedCountryIsoCode = countryQuoteOnline.isoCode; - - const validBody = { - [FIELD_ID]: selectedCountryIsoCode, - }; - - beforeEach(() => { - req.body = validBody; - - mockCountriesResponse = [countryQuoteOnline]; - - getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); - - api.keystone.APIM.getCisCountries = getCisCountriesSpy; - }); - - it('should update the session with submitted data, populated with country object', async () => { - await post(req, res); - - const selectedCountry = getCountryByIsoCode(mockCountriesResponse, selectedCountryIsoCode); - - const expectedPopulatedData = mapSubmittedEligibilityCountry(selectedCountry); - - const expected = updateSubmittedData(expectedPopulatedData, req.session.submittedData.quoteEligibility); - - expect(req.session.submittedData.quoteEligibility).toEqual(expected); - }); - - it(`should redirect to ${ROUTES.QUOTE.BUYER_BODY}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.BUYER_BODY); - }); - - describe("when the url's last substring is `change`", () => { - it(`should redirect to ${ROUTES.QUOTE.CHECK_YOUR_ANSWERS}`, async () => { - req.originalUrl = 'mock/change'; - - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(ROUTES.QUOTE.CHECK_YOUR_ANSWERS); - }); - }); - }); - - describe('when the country does not have any recognised flags with a value of true', () => { - beforeEach(() => { - req.body[FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY] = countryQuoteOnline.isoCode; - - mockCountriesResponse = [ - { - ...countryQuoteOnline, - canGetAQuoteOnline: false, - cannotGetAQuote: false, - }, - ]; - - getCisCountriesSpy = jest.fn(() => Promise.resolve(mockCountriesResponse)); - - api.keystone.APIM.getCisCountries = getCisCountriesSpy; - }); - - it(`should redirect to ${ROUTES.PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(ROUTES.PROBLEM_WITH_SERVICE); - }); - }); - describe('api error handling', () => { describe('when the get CIS countries API call fails', () => { beforeEach(() => { getCisCountriesSpy = mockSpyPromiseRejection; + api.keystone.APIM.getCisCountries = getCisCountriesSpy; }); @@ -410,6 +230,7 @@ describe('controllers/quote/buyer-country', () => { describe('when the get CIS countries API call does not return a populated array', () => { beforeEach(() => { getCisCountriesSpy = jest.fn(() => Promise.resolve([])); + api.keystone.APIM.getCisCountries = getCisCountriesSpy; }); diff --git a/src/ui/server/test-mocks/index.ts b/src/ui/server/test-mocks/index.ts index 8cb499fbc7..c23cc8e666 100644 --- a/src/ui/server/test-mocks/index.ts +++ b/src/ui/server/test-mocks/index.ts @@ -5,7 +5,7 @@ import mockAccount from './mock-account'; import mockAnswers from './mock-answers'; import mockSession from './mock-session'; import mockQuote from './mock-quote'; -import mockCountries from './mock-countries'; +export * from './mock-countries'; import mockCurrencies, { EUR, HKD, JPY, GBP, USD, mockCurrenciesResponse, mockCurrenciesEmptyResponse } from './mock-currencies'; import mockCompaniesHouseResponse from './mock-companies-house-response'; import mockCompany from './mock-company'; @@ -155,7 +155,6 @@ export { mockBuyerOutstandingOrOverduePayments, mockBuyerRelationship, mockBuyerTradingHistory, - mockCountries, mockCompaniesHouseResponse, mockCompany, mockCreateApplicationResponse, diff --git a/src/ui/server/test-mocks/mock-countries.ts b/src/ui/server/test-mocks/mock-countries.ts index 16169df6c5..cbed3e6a78 100644 --- a/src/ui/server/test-mocks/mock-countries.ts +++ b/src/ui/server/test-mocks/mock-countries.ts @@ -5,92 +5,58 @@ const { CIS: { RISK }, } = EXTERNAL_API_MAPPINGS; -// mock base country that can get a quote and apply online. const baseCountry = { - canGetAQuoteOnline: true, + noOnlineSupport: false, + canGetAQuoteOnline: false, cannotGetAQuote: false, + canApplyForInsuranceOnline: false, + noInsuranceSupport: false, + shortTermCover: false, + esraClassification: RISK.STANDARD, +}; + +export const mockCountryCannotGetAQuote: Country = { + ...baseCountry, + name: 'Abu Dhabi', + isoCode: 'XAD', + cannotGetAQuote: true, +}; + +export const mockCountryCanGetAQuoteOnline: Country = { + ...baseCountry, + name: 'Algeria', + isoCode: 'DZA', + canGetAQuoteOnline: true, +}; + +export const mockCountryCanApplyForInsuranceOnline: Country = { + ...baseCountry, + name: 'Algeria', + isoCode: 'DZA', canApplyForInsuranceOnline: true, - shortTermCover: true, }; -const mockCountries = [ - /** - * mock country that: - * - cannot get a quote online - * - cannot apply for insurance - */ - { - name: 'Abu Dhabi', - ...baseCountry, - isoCode: 'XAD', - esraClassification: RISK.STANDARD, - shortTermCover: false, - canGetAQuoteOnline: false, - canApplyForInsuranceOnline: false, - cannotGetAQuote: true, - }, - { - name: 'Algeria', - isoCode: 'DZA', - esraClassification: RISK.STANDARD, - ...baseCountry, - }, - /** - * mock country that: - * - cannot get a quote online - * - can get a quote by email - */ - { - name: 'Egypt', - isoCode: 'EGY', - esraClassification: RISK.VERY_HIGH, - ...baseCountry, - canGetAQuoteOnline: false, - noOnlineSupport: true, - }, - /** - * mock country that: - * - can only apply for insurance offline - */ - { - name: 'Gabon', - isoCode: 'GAB', - esraClassification: RISK.VERY_HIGH, - ...baseCountry, - canGetAQuoteOnline: false, - canApplyForInsuranceOnline: false, - }, - /** - * mock country that: - * - cannot get a quote, online or offline - * - cannot apply for insurance, online or offline - */ - { - name: 'Gibraltar', - isoCode: 'GIB', - ...baseCountry, - esraClassification: RISK.STANDARD, - canGetAQuoteOnline: false, - canApplyForInsuranceOnline: false, - noInsuranceSupport: true, - }, - /** - * mock country that: - * - can get a quote, online or offline - * - can apply for insurance, online - * - cannot get short term cover - */ - { - name: 'France', - isoCode: 'FRA', - ...baseCountry, - esraClassification: RISK.STANDARD, - canGetAQuoteOnline: true, - canApplyForInsuranceOnline: true, - canApplyForInsuranceOffline: false, - shortTermCover: false, - noOnlineSupport: true, - }, -] as Array; +export const mockCountryNoInsuranceSupport: Country = { + ...baseCountry, + name: 'Algeria', + isoCode: 'DZA', + noInsuranceSupport: true, +}; + +export const mockCountryNoOnlineSupport: Country = { + ...baseCountry, + name: 'Algeria', + isoCode: 'DZA', + noOnlineSupport: true, +}; + +export const mockCountryCanGetAQuoteByEmail: Country = { + ...baseCountry, + name: 'Egypt', + isoCode: 'EGY', + noOnlineSupport: true, +}; + +export const mockCountries = [mockCountryCannotGetAQuote, mockCountryCanGetAQuoteOnline, mockCountryCanGetAQuoteByEmail] as Array; export default mockCountries; diff --git a/src/ui/types/country.d.ts b/src/ui/types/country.d.ts index b0b1d99890..53024a8b3a 100644 --- a/src/ui/types/country.d.ts +++ b/src/ui/types/country.d.ts @@ -4,7 +4,7 @@ interface Country { isoCode: string; esraClassification: string; selected?: boolean; - value: string; + value?: string; canGetAQuoteOnline: boolean; cannotGetAQuote: boolean; canApplyForInsuranceOnline: boolean; From 4684dbc6af81d9a6b0c54252fdf9f7062803f0d5 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Mon, 23 Dec 2024 10:48:41 +0000 Subject: [PATCH 09/12] chore(EMS-4079): country risk logic - simplify/improve mapping function (#3436) --- src/api/.keystone/config.js | 215 +++++++----------- src/api/custom-schema/type-defs.ts | 1 - .../index-rating-a.test.ts | 0 .../index-rating-b.test.ts | 0 .../index-rating-c-and-d.test.ts | 0 .../index-rating-none.test.ts | 0 .../a-and-b-rating-conditions/index.ts | 0 .../index-rating-a-and-b.test.ts | 0 .../index-rating-c.test.ts | 0 .../index-rating-d.test.ts | 0 .../index-rating-none.test.ts | 0 .../c-and-d-rating-conditions/index.ts | 0 .../index.test.ts | 12 +- .../index.ts | 6 +- .../index.test.ts | 8 +- .../{no-support => has-no-support}/index.ts | 6 +- .../map-CIS-country/index.test.ts | 16 +- .../map-CIS-country/index.ts | 39 ++-- .../map-NBI-issue-available/index.test.ts | 20 -- .../map-NBI-issue-available/index.ts | 19 -- .../index.test.ts | 48 ---- .../map-short-term-cover-available/index.ts | 32 --- src/api/schema.graphql | 1 - src/api/types/country/index.ts | 4 - src/api/types/helpers/index.ts | 1 - .../graphql/queries/APIM/CIS-countries.ts | 1 - src/ui/types/country.d.ts | 1 - 27 files changed, 126 insertions(+), 304 deletions(-) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/a-and-b-rating-conditions/index-rating-a.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/a-and-b-rating-conditions/index-rating-b.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/a-and-b-rating-conditions/index-rating-c-and-d.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/a-and-b-rating-conditions/index-rating-none.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/a-and-b-rating-conditions/index.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/c-and-d-rating-conditions/index-rating-a-and-b.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/c-and-d-rating-conditions/index-rating-c.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/c-and-d-rating-conditions/index-rating-d.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/c-and-d-rating-conditions/index-rating-none.test.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/c-and-d-rating-conditions/index.ts (100%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/index.test.ts (88%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-online-support => has-no-online-support}/index.ts (81%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-support => has-no-support}/index.test.ts (93%) rename src/api/helpers/map-CIS-countries/map-CIS-country/{no-support => has-no-support}/index.ts (90%) delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts delete mode 100644 src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 00658d9c2d..a9cb2e1d16 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -2822,7 +2822,6 @@ var typeDefs = ` name: String shortTermCover: Boolean esraClassification: String - nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean cannotGetAQuote: Boolean cannotApply: Boolean @@ -8987,135 +8986,150 @@ var mapEsraClassification = (str) => { }; var map_esra_classification_default = mapEsraClassification; -// helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts +// helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts var { - CIS: { SHORT_TERM_COVER }, + CIS: { COUNTRY_RATINGS }, } = EXTERNAL_API_DEFINITIONS; -var mapShortTermCoverAvailable = (str) => { - switch (str) { - case SHORT_TERM_COVER.YES: - return true; - case SHORT_TERM_COVER.ILC: - return true; - case SHORT_TERM_COVER.CILC: - return true; - case SHORT_TERM_COVER.REFER: - return true; - default: - return false; +var countryRatingIsAorB = (rating) => { + if (COUNTRY_RATINGS.A.includes(rating)) { + return true; + } + if (COUNTRY_RATINGS.B.includes(rating)) { + return true; } + return false; }; -var map_short_term_cover_available_default = mapShortTermCoverAvailable; +var country_rating_is_a_or_b_default = countryRatingIsAorB; -// helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts -var { CIS } = EXTERNAL_API_DEFINITIONS; -var mapNbiIssueAvailable = (str) => { - if (str === CIS.NBI_ISSUE_AVAILABLE.YES) { +// helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts +var { + CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 }, +} = EXTERNAL_API_DEFINITIONS; +var countryRatingIsCorD = (rating) => { + if (COUNTRY_RATINGS2.C.includes(rating)) { + return true; + } + if (COUNTRY_RATINGS2.D.includes(rating)) { return true; } return false; }; -var map_NBI_issue_available_default = mapNbiIssueAvailable; +var country_rating_is_c_or_d_default = countryRatingIsCorD; -// helpers/map-CIS-countries/map-CIS-country/country-rating-is-a-or-b/index.ts +// helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts var { - CIS: { COUNTRY_RATINGS }, + CIS: { + ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH }, + }, } = EXTERNAL_API_DEFINITIONS; -var countryRatingIsAorB = (rating) => { - if (COUNTRY_RATINGS.A.includes(rating)) { +var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { + switch (esraClassification) { + case STANDARD: + return true; + case HIGH: + return true; + case VERY_HIGH: + return true; + default: + return false; + } +}; +var esra_classification_is_standard_high_or_very_high_default = esraClassificationIsStandardHighOrVeryHigh; + +// helpers/map-CIS-countries/map-CIS-country/has-no-support/index.ts +var { + CIS: { + COUNTRY_RATINGS: { NOT_APPLICABLE }, + ESRA_CLASSIFICATION: { NONE }, + SHORT_TERM_COVER: { UNLISTED, CILC }, + }, +} = EXTERNAL_API_DEFINITIONS; +var hasNoSupport = ({ countryRating, esraClassification, shortTermCover }) => { + const shortTermCoverIsUnlisted = shortTermCover === UNLISTED; + const esraClassificationIsNone = esraClassification === NONE; + const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; + const countryRatingConditions = + country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; + if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { return true; } - if (COUNTRY_RATINGS.B.includes(rating)) { + const esraClassificationConditions = esra_classification_is_standard_high_or_very_high_default(esraClassification) || esraClassificationIsNone; + if (shortTermCover === CILC && countryRatingIsNotApplicable && esraClassificationConditions) { return true; } return false; }; -var country_rating_is_a_or_b_default = countryRatingIsAorB; +var has_no_support_default = hasNoSupport; -// helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index.ts +// helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index.ts var { CIS: { - ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH, NONE }, - SHORT_TERM_COVER: { NO: NO2, ILC, CILC }, + ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE: NONE2 }, + SHORT_TERM_COVER: { NO: NO2, ILC, CILC: CILC2 }, }, } = EXTERNAL_API_DEFINITIONS; var aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_a_or_b_default(countryRating)) { return false; } - if (esraClassification === STANDARD || esraClassification === HIGH || esraClassification === VERY_HIGH) { + if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { if (shortTermCover === ILC) { return true; } - if (shortTermCover === CILC) { + if (shortTermCover === CILC2) { return true; } if (shortTermCover === NO2) { return true; } } - if (esraClassification === NONE && shortTermCover === NO2) { + if (esraClassification === NONE2 && shortTermCover === NO2) { return true; } return false; }; var a_and_b_rating_conditions_default = aAndBRatingConditions; -// helpers/map-CIS-countries/map-CIS-country/country-rating-is-c-or-d/index.ts -var { - CIS: { COUNTRY_RATINGS: COUNTRY_RATINGS2 }, -} = EXTERNAL_API_DEFINITIONS; -var countryRatingIsCorD = (rating) => { - if (COUNTRY_RATINGS2.C.includes(rating)) { - return true; - } - if (COUNTRY_RATINGS2.D.includes(rating)) { - return true; - } - return false; -}; -var country_rating_is_c_or_d_default = countryRatingIsCorD; - -// helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index.ts +// helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index.ts var { CIS: { - ESRA_CLASSIFICATION: { STANDARD: STANDARD2, HIGH: HIGH2, VERY_HIGH: VERY_HIGH2, NONE: NONE2 }, - SHORT_TERM_COVER: { YES: YES2, NO: NO3, ILC: ILC2, CILC: CILC2, REFER, UNLISTED }, + ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3, NONE: NONE3 }, + SHORT_TERM_COVER: { YES: YES2, NO: NO3, ILC: ILC2, CILC: CILC3, REFER, UNLISTED: UNLISTED2 }, }, } = EXTERNAL_API_DEFINITIONS; var cAndDRatingConditions = ({ countryRating, esraClassification, shortTermCover }) => { if (!country_rating_is_c_or_d_default(countryRating)) { return false; } - if (esraClassification === STANDARD2 || esraClassification === HIGH2 || esraClassification === VERY_HIGH2) { + if (esraClassification === STANDARD3 || esraClassification === HIGH3 || esraClassification === VERY_HIGH3) { if (shortTermCover === YES2) { return true; } if (shortTermCover === ILC2) { return true; } - if (shortTermCover === CILC2) { + if (shortTermCover === CILC3) { return true; } if (shortTermCover === REFER) { return true; } - if (shortTermCover === UNLISTED) { + if (shortTermCover === UNLISTED2) { return true; } if (shortTermCover === NO3) { return true; } } - if (esraClassification === NONE2 && shortTermCover === NO3) { + if (esraClassification === NONE3 && shortTermCover === NO3) { return true; } return false; }; var c_and_d_rating_conditions_default = cAndDRatingConditions; -// helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts -var noOnlineSupport = ({ countryRating, esraClassification, shortTermCover }) => { +// helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.ts +var hasNoOnlineSupport = ({ countryRating, esraClassification, shortTermCover }) => { const aAndBConditions = a_and_b_rating_conditions_default({ countryRating, esraClassification, @@ -9129,32 +9143,12 @@ var noOnlineSupport = ({ countryRating, esraClassification, shortTermCover }) => const conditions = aAndBConditions || cAndDConditions; return conditions; }; -var no_online_support_default = noOnlineSupport; - -// helpers/map-CIS-countries/map-CIS-country/esra-classification-is-standard-high-or-very-high/index.ts -var { - CIS: { - ESRA_CLASSIFICATION: { STANDARD: STANDARD3, HIGH: HIGH3, VERY_HIGH: VERY_HIGH3 }, - }, -} = EXTERNAL_API_DEFINITIONS; -var esraClassificationIsStandardHighOrVeryHigh = (esraClassification) => { - switch (esraClassification) { - case STANDARD3: - return true; - case HIGH3: - return true; - case VERY_HIGH3: - return true; - default: - return false; - } -}; -var esra_classification_is_standard_high_or_very_high_default = esraClassificationIsStandardHighOrVeryHigh; +var has_no_online_support_default = hasNoOnlineSupport; // helpers/map-CIS-countries/map-CIS-country/short-term-cover-is-yes-refer-or-unlisted/index.ts var { CIS: { - SHORT_TERM_COVER: { YES: YES3, REFER: REFER2, UNLISTED: UNLISTED2 }, + SHORT_TERM_COVER: { YES: YES3, REFER: REFER2, UNLISTED: UNLISTED3 }, }, } = EXTERNAL_API_DEFINITIONS; var shortTermCoverIsYesReferOrUnlisted = (shortTermCover) => { @@ -9163,7 +9157,7 @@ var shortTermCoverIsYesReferOrUnlisted = (shortTermCover) => { return true; case REFER2: return true; - case UNLISTED2: + case UNLISTED3: return true; default: return false; @@ -9193,62 +9187,29 @@ var canApplyForInsuranceOnline = (cisCountry) => { }; var can_apply_for_insurance_online_default = canApplyForInsuranceOnline; -// helpers/map-CIS-countries/map-CIS-country/no-support/index.ts -var { - CIS: { - COUNTRY_RATINGS: { NOT_APPLICABLE }, - ESRA_CLASSIFICATION: { NONE: NONE3 }, - SHORT_TERM_COVER: { UNLISTED: UNLISTED3, CILC: CILC3 }, - }, -} = EXTERNAL_API_DEFINITIONS; -var noSupport = ({ countryRating, esraClassification, shortTermCover }) => { - const shortTermCoverIsUnlisted = shortTermCover === UNLISTED3; - const esraClassificationIsNone = esraClassification === NONE3; - const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; - const countryRatingConditions = - country_rating_is_a_or_b_default(countryRating) || country_rating_is_c_or_d_default(countryRating) || countryRatingIsNotApplicable; - if (shortTermCoverIsUnlisted && esraClassificationIsNone && countryRatingConditions) { - return true; - } - const esraClassificationConditions = esra_classification_is_standard_high_or_very_high_default(esraClassification) || esraClassificationIsNone; - if (shortTermCover === CILC3 && countryRatingIsNotApplicable && esraClassificationConditions) { - return true; - } - return false; -}; -var no_support_default = noSupport; - // helpers/map-CIS-countries/map-CIS-country/index.ts var mapCisCountry = (cisCountry) => { - const { countryRatingDesc, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc } = cisCountry; + const { countryRatingDesc: countryRating, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc: shortTermCover } = cisCountry; const esraClassification = map_esra_classification_default(cisCountry.ESRAClassificationDesc); - const nbiIssueAvailable = map_NBI_issue_available_default(cisCountry.NBIIssue); - const shortTermCover = map_short_term_cover_available_default(cisCountry.shortTermCoverAvailabilityDesc); - const countryRating = countryRatingDesc; + const noSupport = has_no_support_default({ + countryRating, + esraClassification: ESRAClassificationDesc, + shortTermCover, + }); const mapped = { countryRating, esraClassification, isoCode, name: marketName, - nbiIssueAvailable, - shortTermCover, - noOnlineSupport: no_online_support_default({ + noOnlineSupport: has_no_online_support_default({ countryRating, esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, + shortTermCover, }), canGetAQuoteOnline: can_get_a_quote_online_default(cisCountry), - cannotGetAQuote: no_support_default({ - countryRating, - esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, - }), + cannotGetAQuote: noSupport, canApplyForInsuranceOnline: can_apply_for_insurance_online_default(cisCountry), - noInsuranceSupport: no_support_default({ - countryRating, - esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, - }), + noInsuranceSupport: noSupport, }; return mapped; }; @@ -9262,9 +9223,9 @@ var sortArrayAlphabetically = (arr, field) => { var sort_array_alphabetically_default = sortArrayAlphabetically; // helpers/map-CIS-countries/index.ts -var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; +var { CIS } = EXTERNAL_API_DEFINITIONS; var mapCisCountries = (countries) => { - const filteredCountries = filter_cis_entries_default(countries, CIS2.INVALID_COUNTRIES, 'marketName'); + const filteredCountries = filter_cis_entries_default(countries, CIS.INVALID_COUNTRIES, 'marketName'); const mapped = filteredCountries.map((country) => map_CIS_country_default(country)); const sorted = sort_array_alphabetically_default(mapped, 'name'); return sorted; @@ -9289,7 +9250,7 @@ var getApimCisCountries = async () => { var get_APIM_CIS_countries_default = getApimCisCountries; // helpers/map-currencies/index.ts -var { CIS: CIS3 } = EXTERNAL_API_DEFINITIONS; +var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; var getSupportedCurrencies = (currencies) => { const supported = currencies.filter((currency) => SUPPORTED_CURRENCIES.find((currencyCode) => currency.isoCode === currencyCode)); return supported; @@ -9299,7 +9260,7 @@ var getAlternativeCurrencies = (currencies) => { return alternate; }; var mapCurrencies = (currencies, alternativeCurrencies) => { - let currenciesArray = filter_cis_entries_default(currencies, CIS3.INVALID_CURRENCIES, 'name'); + let currenciesArray = filter_cis_entries_default(currencies, CIS2.INVALID_CURRENCIES, 'name'); if (!alternativeCurrencies) { currenciesArray = getSupportedCurrencies(currenciesArray); } else { diff --git a/src/api/custom-schema/type-defs.ts b/src/api/custom-schema/type-defs.ts index 059ce6611c..08f0ee4caf 100644 --- a/src/api/custom-schema/type-defs.ts +++ b/src/api/custom-schema/type-defs.ts @@ -229,7 +229,6 @@ const typeDefs = ` name: String shortTermCover: Boolean esraClassification: String - nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean cannotGetAQuote: Boolean cannotApply: Boolean diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-a.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-b.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-c-and-d.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index-rating-none.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-rating-conditions/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/a-and-b-rating-conditions/index.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-a-and-b.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-c.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-d.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index-rating-none.test.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index.ts similarity index 100% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-rating-conditions/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/c-and-d-rating-conditions/index.ts diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.test.ts similarity index 88% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.test.ts index f27b485c7a..0ea8c89afb 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.test.ts @@ -1,4 +1,4 @@ -import noOnlineSupport from '.'; +import hasNoOnlineSupport from '.'; import aAndBRatingConditions from './a-and-b-rating-conditions'; import cAndDRatingConditions from './c-and-d-rating-conditions'; import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; @@ -13,7 +13,7 @@ const mockInitCountry = { shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, }; -describe('helpers/map-CIS-countries/map-CIS-country/no-online-support', () => { +describe('helpers/map-CIS-countries/map-CIS-country/has-no-online-support', () => { describe('when a country rating is `A`', () => { it('should return the result of aAndBRatingConditions', () => { const [mockRating] = COUNTRY_RATINGS.A; @@ -23,7 +23,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support', () => { countryRating: mockRating, }; - const result = noOnlineSupport(mockCountry); + const result = hasNoOnlineSupport(mockCountry); const expected = aAndBRatingConditions({ countryRating: mockRating, @@ -44,7 +44,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support', () => { countryRating: mockRating, }; - const result = noOnlineSupport(mockCountry); + const result = hasNoOnlineSupport(mockCountry); const expected = aAndBRatingConditions({ countryRating: mockRating, @@ -65,7 +65,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support', () => { countryRating: mockRating, }; - const result = noOnlineSupport(mockCountry); + const result = hasNoOnlineSupport(mockCountry); const expected = cAndDRatingConditions({ countryRating: mockRating, @@ -86,7 +86,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support', () => { countryRating: mockRating, }; - const result = noOnlineSupport(mockCountry); + const result = hasNoOnlineSupport(mockCountry); const expected = cAndDRatingConditions({ countryRating: mockRating, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.ts similarity index 81% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.ts index d73fc143df..89f36df849 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-online-support/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-online-support/index.ts @@ -3,14 +3,14 @@ import cAndDRatingConditions from './c-and-d-rating-conditions'; import { NoInsuranceSupportParams } from '../../../../types'; /** - * noOnlineSupport + * hasNoOnlineSupport * Check if a country has no quote or insurance support (online) * @param {String} countryRating: Country rating * @param {String} esraClassification: ESRA classification * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const noOnlineSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { +const hasNoOnlineSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { const aAndBConditions = aAndBRatingConditions({ countryRating, esraClassification, @@ -28,4 +28,4 @@ const noOnlineSupport = ({ countryRating, esraClassification, shortTermCover }: return conditions; }; -export default noOnlineSupport; +export default hasNoOnlineSupport; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-support/index.test.ts similarity index 93% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-support/index.test.ts index 4ccd4a8a2b..d0d05442b2 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-support/index.test.ts @@ -1,4 +1,4 @@ -import noSupport from '.'; +import hasNoSupport from '.'; import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; const { @@ -89,12 +89,12 @@ const params = { ], }; -describe('helpers/map-CIS-countries/map-CIS-country/no-support', () => { +describe('helpers/map-CIS-countries/map-CIS-country/has-no-support', () => { describe(`when shortTermCover is ${UNLISTED} and esraClassification is ${NONE}`, () => { describe.each(params.firstConditions)('', ({ country, description, expectation }) => { describe(`when the countryRating is ${description}`, () => { it(`should return ${expectation}`, () => { - const result = noSupport(country); + const result = hasNoSupport(country); expect(result).toEqual(expectation); }); @@ -106,7 +106,7 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-support', () => { describe.each(params.secondConditions)('', ({ country, description, expectation }) => { describe(`when the esraClassification is ${description}`, () => { it(`should return ${expectation}`, () => { - const result = noSupport(country); + const result = hasNoSupport(country); expect(result).toEqual(expectation); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-support/index.ts similarity index 90% rename from src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/has-no-support/index.ts index 64e15c900e..0e8b266cc9 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-support/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/has-no-support/index.ts @@ -13,14 +13,14 @@ const { } = EXTERNAL_API_DEFINITIONS; /** - * noSupport + * hasNoSupport * Check if a country has no quote or insurance support (online or offline) * @param {String} countryRating: Country rating * @param {String} esraClassification: ESRA classification * @param {String} shortTermCover: Short term cover * @returns {Boolean} */ -const noSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { +const hasNoSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsuranceSupportParams): boolean => { const shortTermCoverIsUnlisted = shortTermCover === UNLISTED; const esraClassificationIsNone = esraClassification === NONE; const countryRatingIsNotApplicable = countryRating === NOT_APPLICABLE; @@ -40,4 +40,4 @@ const noSupport = ({ countryRating, esraClassification, shortTermCover }: NoInsu return false; }; -export default noSupport; +export default hasNoSupport; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index 191830c438..1a590e87f3 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -1,11 +1,9 @@ import mapCisCountry from '.'; import mapEsraClassification from './map-esra-classification'; -import mapShortTermCoverAvailable from './map-short-term-cover-available'; -import mapNbiIssueAvailable from './map-NBI-issue-available'; -import noOnlineSupport from './no-online-support'; +import hasNoOnlineSupport from './has-no-online-support'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; -import noSupport from './no-support'; +import hasNoSupport from './has-no-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; import { MappedCisCountry } from '../../../types'; import { mockCisCountry } from '../../../test-mocks'; @@ -26,8 +24,6 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { const result = mapCisCountry(mockCountryBase); const esraClassification = mapEsraClassification(mockCountryBase.ESRAClassificationDesc); - const shortTermCover = mapShortTermCoverAvailable(mockCountryBase.shortTermCoverAvailabilityDesc); - const nbiIssueAvailable = mapNbiIssueAvailable(mockCountryBase.NBIIssue); const countryRating = mockCisCountry.countryRatingDesc; @@ -36,10 +32,8 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { esraClassification, isoCode: mockCountryBase.isoCode, name: mockCountryBase.marketName, - nbiIssueAvailable, - shortTermCover, - noOnlineSupport: noOnlineSupport({ + noOnlineSupport: hasNoOnlineSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, @@ -47,7 +41,7 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { canGetAQuoteOnline: canGetAQuoteOnline(mockCisCountry), - cannotGetAQuote: noSupport({ + cannotGetAQuote: hasNoSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, @@ -55,7 +49,7 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { canApplyForInsuranceOnline: canApplyForInsuranceOnline(mockCisCountry), - noInsuranceSupport: noSupport({ + noInsuranceSupport: hasNoSupport({ countryRating, esraClassification: mockCisCountry.ESRAClassificationDesc, shortTermCover: mockCisCountry.shortTermCoverAvailabilityDesc, diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index 6efb281114..ef24aaca12 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -1,10 +1,8 @@ import mapEsraClassification from './map-esra-classification'; -import mapShortTermCoverAvailable from './map-short-term-cover-available'; -import mapNbiIssueAvailable from './map-NBI-issue-available'; -import noOnlineSupport from './no-online-support'; +import hasNoSupport from './has-no-support'; +import hasNoOnlineSupport from './has-no-online-support'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; -import noSupport from './no-support'; import { CisCountry, MappedCisCountry } from '../../../types'; /** @@ -14,43 +12,40 @@ import { CisCountry, MappedCisCountry } from '../../../types'; * @returns {MappedCisCountry} Mapped country */ export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { - const { countryRatingDesc, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc } = cisCountry; + const { countryRatingDesc: countryRating, ESRAClassificationDesc, isoCode, marketName, shortTermCoverAvailabilityDesc: shortTermCover } = cisCountry; const esraClassification = mapEsraClassification(cisCountry.ESRAClassificationDesc); - const nbiIssueAvailable = mapNbiIssueAvailable(cisCountry.NBIIssue); - const shortTermCover = mapShortTermCoverAvailable(cisCountry.shortTermCoverAvailabilityDesc); - const countryRating = countryRatingDesc; + /** + * Current business logic for "no support" (online or offline) + * Is exactly the same for "get a quote" and "insurance application". + * Therefore we can use hasNoSupport for both. + */ + const noSupport = hasNoSupport({ + countryRating, + esraClassification: ESRAClassificationDesc, + shortTermCover, + }); const mapped: MappedCisCountry = { countryRating, esraClassification, isoCode, name: marketName, - nbiIssueAvailable, - shortTermCover, - noOnlineSupport: noOnlineSupport({ + noOnlineSupport: hasNoOnlineSupport({ countryRating, esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, + shortTermCover, }), canGetAQuoteOnline: canGetAQuoteOnline(cisCountry), - cannotGetAQuote: noSupport({ - countryRating, - esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, - }), + cannotGetAQuote: noSupport, canApplyForInsuranceOnline: canApplyForInsuranceOnline(cisCountry), - noInsuranceSupport: noSupport({ - countryRating, - esraClassification: ESRAClassificationDesc, - shortTermCover: shortTermCoverAvailabilityDesc, - }), + noInsuranceSupport: noSupport, }; return mapped; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.test.ts deleted file mode 100644 index acf131e5af..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import mapNbiIssueAvailable from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { CIS } = EXTERNAL_API_DEFINITIONS; - -describe('helpers/map-cis-countries/map-cis-country/map-NBI-issue-available', () => { - describe(`when the NBI issue field is ${CIS.NBI_ISSUE_AVAILABLE.YES}`, () => { - it('should return true', () => { - const result = mapNbiIssueAvailable(CIS.NBI_ISSUE_AVAILABLE.YES); - - expect(result).toEqual(true); - }); - }); - - it('should return false', () => { - const result = mapNbiIssueAvailable(CIS.NBI_ISSUE_AVAILABLE.NO); - - expect(result).toEqual(false); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts deleted file mode 100644 index f8be363855..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { CIS } = EXTERNAL_API_DEFINITIONS; - -/** - * mapNbiIssueAvailable - * Transform a countries 'NBI issue available' string to a boolean - * @param {String} NBI flag - * @returns {Boolean} - */ -export const mapNbiIssueAvailable = (str: string): boolean => { - if (str === CIS.NBI_ISSUE_AVAILABLE.YES) { - return true; - } - - return false; -}; - -export default mapNbiIssueAvailable; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts deleted file mode 100644 index 353eeacb2d..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import mapShortTermCoverAvailable from '.'; -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { - CIS: { SHORT_TERM_COVER }, -} = EXTERNAL_API_DEFINITIONS; - -describe('helpers/map-cis-countries/map-cis-country/map-short-term-cover-available', () => { - describe(`when the short term cover is ${SHORT_TERM_COVER.YES}`, () => { - it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.YES); - - expect(result).toEqual(true); - }); - }); - - describe(`when the short term cover is ${SHORT_TERM_COVER.ILC}`, () => { - it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.ILC); - - expect(result).toEqual(true); - }); - }); - - describe(`when the short term cover is ${SHORT_TERM_COVER.CILC}`, () => { - it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.CILC); - - expect(result).toEqual(true); - }); - }); - - describe(`when the short term cover is ${SHORT_TERM_COVER.REFER}`, () => { - it('should return true', () => { - const result = mapShortTermCoverAvailable(SHORT_TERM_COVER.REFER); - - expect(result).toEqual(true); - }); - }); - - describe('when the short term cover is not recognised', () => { - it('should return false', () => { - const result = mapShortTermCoverAvailable('Not recognised'); - - expect(result).toEqual(false); - }); - }); -}); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts deleted file mode 100644 index 44c2c9e2a0..0000000000 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { EXTERNAL_API_DEFINITIONS } from '../../../../constants'; - -const { - CIS: { SHORT_TERM_COVER }, -} = EXTERNAL_API_DEFINITIONS; - -/** - * mapShortTermCoverAvailable - * Transform a countries 'short term cover available' string to a boolean - * @param {String} Risk category - * @returns {Boolean} - */ -const mapShortTermCoverAvailable = (str: string): boolean => { - switch (str) { - case SHORT_TERM_COVER.YES: - return true; - - case SHORT_TERM_COVER.ILC: - return true; - - case SHORT_TERM_COVER.CILC: - return true; - - case SHORT_TERM_COVER.REFER: - return true; - - default: - return false; - } -}; - -export default mapShortTermCoverAvailable; diff --git a/src/api/schema.graphql b/src/api/schema.graphql index 966beaa723..0d2431a695 100644 --- a/src/api/schema.graphql +++ b/src/api/schema.graphql @@ -3743,7 +3743,6 @@ type MappedCisCountry { name: String shortTermCover: Boolean esraClassification: String - nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean cannotGetAQuote: Boolean cannotApply: Boolean diff --git a/src/api/types/country/index.ts b/src/api/types/country/index.ts index 825a6b284b..2670446d6a 100644 --- a/src/api/types/country/index.ts +++ b/src/api/types/country/index.ts @@ -16,8 +16,6 @@ export interface Country extends Relationship { name: string; isoCode: string; esraClassification?: string; - shortTermCover?: boolean; - nbiIssueAvailable?: boolean; canGetAQuoteOnline?: boolean; cannotGetAQuote?: boolean; canApplyForInsuranceOnline?: boolean; @@ -37,9 +35,7 @@ export interface MappedCisCountry { countryRating: string; esraClassification?: string | null; isoCode: string; - nbiIssueAvailable: boolean; name: string; - shortTermCover: boolean; noOnlineSupport: boolean; canGetAQuoteOnline: boolean; cannotGetAQuote: boolean; diff --git a/src/api/types/helpers/index.ts b/src/api/types/helpers/index.ts index ead4c81e5c..8062f28eb4 100644 --- a/src/api/types/helpers/index.ts +++ b/src/api/types/helpers/index.ts @@ -5,7 +5,6 @@ export interface MapYesNoFieldParams { export interface MapCisCountryParams { shortTermCover: boolean; - nbiIssueAvailable: boolean; esraClassification?: string | null; } diff --git a/src/ui/server/graphql/queries/APIM/CIS-countries.ts b/src/ui/server/graphql/queries/APIM/CIS-countries.ts index a6ecbcc115..dac20373cb 100644 --- a/src/ui/server/graphql/queries/APIM/CIS-countries.ts +++ b/src/ui/server/graphql/queries/APIM/CIS-countries.ts @@ -12,7 +12,6 @@ const getApimCisCountries = gql` canApplyForInsuranceOnline noOnlineSupport noInsuranceSupport - shortTermCover } } `; diff --git a/src/ui/types/country.d.ts b/src/ui/types/country.d.ts index 53024a8b3a..f54c0c5658 100644 --- a/src/ui/types/country.d.ts +++ b/src/ui/types/country.d.ts @@ -10,7 +10,6 @@ interface Country { canApplyForInsuranceOnline: boolean; noOnlineSupport: boolean; noInsuranceSupport: boolean; - shortTermCover: boolean; } export { Country }; From e0e5618413e9c35f02641d4ae57b5cfa77a77b96 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Mon, 23 Dec 2024 11:38:07 +0000 Subject: [PATCH 10/12] chore(EMS-4067-4070): country risk logic - e2e improvements (#3435) * chore(gql): remove unused field * chore(EMS-4067-4070): e2e fixture improvements * chore(EMS-4067-4070): buyer country e2e improvements * chore(EMS-4067-4070): e2e improvements * chore(EMS-4067): fix typo * chore(EMS-4067): fix typo * chore(EMS-4067-4070): fix/update e2e tests * feat(EMS-4067): fix/update e2e tests * chore(EMS-4067-4070): fix/update e2e tests * chore(EMS-4067-4070): fix/update e2e tests * chore(EMS-4067-4070): fix/update e2e tests --- .../complete-about-goods-or-services-form.js | 2 +- .../complete-and-submit-buyer-country-form.js | 7 +- e2e-tests/fixtures/application.js | 16 +-- e2e-tests/fixtures/countries.js | 110 +++++++++--------- .../buyer-country-no-online-support.spec.js | 46 ++++++++ .../buyer-country-no-short-term-cover.spec.js | 32 ----- ...uyer-country-unsupported-countries.spec.js | 28 ++--- .../buyer-country/buyer-country.spec.js | 2 +- .../eligibility/cannot-apply-page.spec.js | 2 +- .../cannot-apply/cannot-apply-page.spec.js | 4 +- ...about-goods-or-services-validation.spec.js | 2 +- ...-country-only-get-a-quote-offline.spec.js} | 8 +- .../buyer-country-unsupported-country.spec.js | 10 +- .../quote/buyer-country/buyer-country.spec.js | 4 +- .../quote/get-a-quote-via-email.spec.js | 2 +- src/api/.keystone/config.js | 1 - src/api/custom-schema/type-defs.ts | 1 - src/api/schema.graphql | 1 - .../graphql/queries/APIM/CIS-countries.ts | 1 - 19 files changed, 144 insertions(+), 135 deletions(-) create mode 100644 e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js delete mode 100644 e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js rename e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/{buyer-country-country-only-get-a-quote-by-email.spec.js => buyer-country-country-only-get-a-quote-offline.spec.js} (85%) diff --git a/e2e-tests/commands/insurance/complete-about-goods-or-services-form.js b/e2e-tests/commands/insurance/complete-about-goods-or-services-form.js index d6a2faea93..5481398576 100644 --- a/e2e-tests/commands/insurance/complete-about-goods-or-services-form.js +++ b/e2e-tests/commands/insurance/complete-about-goods-or-services-form.js @@ -26,7 +26,7 @@ const completeAboutGoodsOrServicesForm = ({ cy.clickYesRadioInput(); if (includeFinalDestination) { - cy.keyboardInput(autoCompleteField(FINAL_DESTINATION).input(), COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME); + cy.keyboardInput(autoCompleteField(FINAL_DESTINATION).input(), COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME); } } else { cy.clickNoRadioInput(); diff --git a/e2e-tests/commands/shared-commands/eligibility/complete-and-submit-buyer-country-form.js b/e2e-tests/commands/shared-commands/eligibility/complete-and-submit-buyer-country-form.js index 27c8402e4b..13a9b44a9f 100644 --- a/e2e-tests/commands/shared-commands/eligibility/complete-and-submit-buyer-country-form.js +++ b/e2e-tests/commands/shared-commands/eligibility/complete-and-submit-buyer-country-form.js @@ -1,15 +1,16 @@ import { autoCompleteField } from '../../../pages/shared'; import { FIELD_IDS } from '../../../constants'; -import { DZA } from '../../../fixtures/countries'; +import { COUNTRY_QUOTE_SUPPORT } from '../../../fixtures/countries'; const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; +const { ONLINE_SUPPORT_1 } = COUNTRY_QUOTE_SUPPORT; /** * completeAndSubmitBuyerCountryForm * Complete and submit a buyer country form. - * @param {String} countryName to input - defaults to Algeria mock country + * @param {String} countryName to input - defaults to ONLINE_SUPPORT_1 mock country */ -export const completeAndSubmitBuyerCountryForm = ({ countryName = DZA.NAME }) => { +export const completeAndSubmitBuyerCountryForm = ({ countryName = ONLINE_SUPPORT_1.NAME }) => { cy.keyboardInput(autoCompleteField(FIELD_ID).input(), countryName); const results = autoCompleteField(FIELD_ID).results(); results.first().click(); diff --git a/e2e-tests/fixtures/application.js b/e2e-tests/fixtures/application.js index e630acb1a5..7150f6562b 100644 --- a/e2e-tests/fixtures/application.js +++ b/e2e-tests/fixtures/application.js @@ -101,7 +101,7 @@ export const endDate = new Date(date.setMonth(date.getMonth() + 6)); // Add 6 mo const application = { ELIGIBILITY: { - buyerCountryIsoCode: COUNTRY_APPLICATION_SUPPORT.ONLINE.ISO_CODE, + buyerCountryIsoCode: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.ISO_CODE, [COVER_PERIOD_ID]: COVER_PERIOD_CONSTANTS.LESS_THAN_2_YEARS.DB_ID, [HAS_COMPANIES_HOUSE_NUMBER]: true, [HAS_END_BUYER]: false, @@ -111,7 +111,7 @@ const application = { [IS_PARTY_TO_CONSORTIUM]: false, [IS_MEMBER_OF_A_GROUP]: false, }, - [BUYER_COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME, + [BUYER_COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME, COMPANY: mockCompanies[COMPANIES_HOUSE_NUMBER], YOUR_COMPANY: { [DIFFERENT_TRADING_NAME]: 'Mock different trading name', @@ -149,14 +149,14 @@ const application = { }, REQUESTED_JOINTLY_INSURED_PARTY: { [COMPANY_NAME]: 'Mock jointly insured company name', - [COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME, + [COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME, [COMPANY_NUMBER]: 'Mock jointly insured company number', }, EXPORT_CONTRACT: { [AWARD_METHOD]: EXPORT_CONTRACT_AWARD_METHOD.OTHER.DB_ID, [OTHER_AWARD_METHOD]: 'Mock other award method description', [DESCRIPTION]: 'Mock description', - [FINAL_DESTINATION]: COUNTRY_APPLICATION_SUPPORT.ONLINE.ISO_CODE, + [FINAL_DESTINATION]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.ISO_CODE, HOW_WILL_YOU_GET_PAID: { [PAYMENT_TERMS_DESCRIPTION]: mockAddress0, }, @@ -166,7 +166,7 @@ const application = { }, AGENT_DETAILS: { [AGENT_NAME]: "Mock export contract agent name O'Neill", - [AGENT_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME, + [AGENT_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME, [AGENT_FULL_ADDRESS]: mockAddress0, }, AGENT_SERVICE: { @@ -178,7 +178,7 @@ const application = { [FIXED_SUM_AMOUNT]: '1500', [FIXED_SUM_CURRENCY_CODE]: GBP_CURRENCY_CODE, [METHOD]: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM, - [PAYABLE_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME, + [PAYABLE_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME, }, }, EXPORTER_BUSINESS: { @@ -199,7 +199,7 @@ const application = { BUYER: { [COMPANY_OR_ORGANISATION_NAME]: 'Test name', [ADDRESS]: 'Test address', - [COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME, + [COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME, [REGISTRATION_NUMBER]: '12345', [WEBSITE]: WEBSITE_EXAMPLES.VALID, [CONNECTION_WITH_BUYER]: FIELD_VALUES.NO, @@ -223,6 +223,6 @@ const application = { }, }; -export const country = COUNTRY_APPLICATION_SUPPORT.ONLINE; +export const country = COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1; export default application; diff --git a/e2e-tests/fixtures/countries.js b/e2e-tests/fixtures/countries.js index aaf03e325b..83358a500a 100644 --- a/e2e-tests/fixtures/countries.js +++ b/e2e-tests/fixtures/countries.js @@ -1,6 +1,16 @@ -export const XAD = { - NAME: 'Abu Dhabi', - ISO_CODE: 'XAD', +export const AGO = { + NAME: 'Angola', + ISO_CODE: 'AGO', +}; + +export const ARG = { + NAME: 'Argentina', + ISO_CODE: 'AGO', +}; + +export const BRA = { + NAME: 'Brazil', + ISO_CODE: 'BRA', }; export const DZA = { @@ -8,9 +18,9 @@ export const DZA = { ISO_CODE: 'DZA', }; -export const AGO = { - NAME: 'Angola', - ISO_CODE: 'AGO', +export const ERI = { + NAME: 'Eritrea', + ISO_CODE: 'ERI', }; export const FRA = { @@ -18,81 +28,69 @@ export const FRA = { ISO_CODE: 'FRA', }; -export const BRA = { - NAME: 'Brazil', - ISO_CODE: 'BRA', +export const GBR = { + NAME: 'United Kingdom', + ISO_CODE: 'GBR', }; -export const AFG = { - NAME: 'Afghanistan', - ISO_CODE: 'AFG', +export const IOT = { + NAME: 'British Indian Ocean Territory', + ISO_CODE: 'IOT', }; -export const AUS = { - NAME: 'Australia', - ISO_CODE: 'AUS', +export const NCL = { + NAME: 'New Caledonia', + ISO_CODE: 'NCL', }; -export const BLR = { - NAME: 'Belarus', - ISO_CODE: 'BLR', +export const TN = { + NAME: 'Tunisia', + ISO_CODE: 'TN', }; -export const RUS = { - NAME: 'Russia', - ISO_CODE: 'RUS', +export const XAD = { + NAME: 'Abu Dhabi', + ISO_CODE: 'XAD', }; -export const MMR = { - NAME: 'Burma', - ISO_CODE: 'MMR', -}; +const mockCountries = [DZA, FRA, AGO, GBR, XAD, BRA]; -export const GBR = { - NAME: 'United Kingdom', - ISO_CODE: 'GBR', -}; +const ONLINE_SUPPORT_1 = DZA; + +const NO_ONLINE_SUPPORT_1 = FRA; +const NO_ONLINE_SUPPORT_2 = AGO; +const NO_ONLINE_SUPPORT_3 = ARG; +const NO_ONLINE_SUPPORT_4 = TN; -const mockCountries = [XAD, AFG, DZA, AGO, AUS, BLR, BRA, MMR, FRA, RUS, GBR]; +const NOT_SUPPORTED_1 = GBR; +const NOT_SUPPORTED_2 = ERI; +const NOT_SUPPORTED_3 = IOT; +const NOT_SUPPORTED_4 = NCL; /** * COUNTRY_QUOTE_SUPPORT * Different types of country support for a quote. */ -const { 2: QUOTE_ONLINE, 3: QUOTE_BY_EMAIL, 10: QUOTE_UNSUPPORTED } = mockCountries; - export const COUNTRY_QUOTE_SUPPORT = { - ONLINE: QUOTE_ONLINE, - BY_EMAIL: QUOTE_BY_EMAIL, - UNSUPPORTED: QUOTE_UNSUPPORTED, + ONLINE_SUPPORT_1, + NO_ONLINE_SUPPORT_1, + NOT_SUPPORTED_1, }; /** * COUNTRY_APPLICATION_SUPPORT * Different types of country support for an application */ -const { - 2: APPLICATION_ONLINE, - 3: APPLICATION_BY_EMAIL, - 8: APPLICATION_NO_SHORT_TERM_COVER_1, - 4: APPLICATION_NO_SHORT_TERM_COVER_2, - 1: APPLICATION_UNSUPPORTED_1, - 5: APPLICATION_UNSUPPORTED_2, - 7: APPLICATION_UNSUPPORTED_3, - 9: APPLICATION_UNSUPPORTED_4, - 10: APPLICATION_CANNOT_APPLY_1, -} = mockCountries; - export const COUNTRY_APPLICATION_SUPPORT = { - ONLINE: APPLICATION_ONLINE, - BY_EMAIL: APPLICATION_BY_EMAIL, - UNSUPPORTED_1: APPLICATION_UNSUPPORTED_1, - UNSUPPORTED_2: APPLICATION_UNSUPPORTED_2, - UNSUPPORTED_3: APPLICATION_UNSUPPORTED_3, - UNSUPPORTED_4: APPLICATION_UNSUPPORTED_4, - CANNOT_APPLY_1: APPLICATION_CANNOT_APPLY_1, - NO_SHORT_TERM_COVER_1: APPLICATION_NO_SHORT_TERM_COVER_1, - NO_SHORT_TERM_COVER_2: APPLICATION_NO_SHORT_TERM_COVER_2, + ONLINE_SUPPORT_1, + NO_ONLINE_SUPPORT_1, + NO_ONLINE_SUPPORT_2, + NO_ONLINE_SUPPORT_3, + NO_ONLINE_SUPPORT_4, + NOT_SUPPORTED_1, + NOT_SUPPORTED_2, + NOT_SUPPORTED_3, + NOT_SUPPORTED_4, }; export default mockCountries; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js new file mode 100644 index 0000000000..298e3df3ae --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js @@ -0,0 +1,46 @@ +import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; +import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries'; + +const { + ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, +} = INSURANCE_ROUTES; + +const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_1.NAME; +const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_2.NAME; +const COUNTRY_NAME_3 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_3.NAME; +const COUNTRY_NAME_4 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_4.NAME; + +context( + 'Insurance - Buyer country page - As an exporter, I want to check if UKEF offer credit insurance policy for where my buyer is based - submit countries that have no online insurance support', + () => { + beforeEach(() => { + cy.saveSession(); + + cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + }); + + describe(COUNTRY_NAME_1, () => { + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + }); + }); + + describe(COUNTRY_NAME_2, () => { + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + }); + }); + + describe(COUNTRY_NAME_3, () => { + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_3, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + }); + }); + + describe(COUNTRY_NAME_4, () => { + it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + }); + }); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js deleted file mode 100644 index d4c0485ff7..0000000000 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; -import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries'; - -const { - ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, -} = INSURANCE_ROUTES; - -const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NO_SHORT_TERM_COVER_1.NAME; -const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.NO_SHORT_TERM_COVER_2.NAME; - -context( - 'Insurance - Buyer country page - As an exporter, I want to check if UKEF offer credit insurance policy for where my buyer is based - submit no short term country cover', - () => { - beforeEach(() => { - cy.saveSession(); - - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); - }); - - describe(COUNTRY_NAME_1, () => { - it(`redirects to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); - }); - }); - - describe(COUNTRY_NAME_2, () => { - it(`redirects to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); - }); - }); - }, -); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js index a7b8a94107..6f4a066572 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js @@ -2,16 +2,16 @@ import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries'; const { - ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT }, + ELIGIBILITY: { CANNOT_APPLY_EXIT }, } = INSURANCE_ROUTES; -const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME; -const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_2.NAME; -const COUNTRY_NAME_3 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_3.NAME; -const COUNTRY_NAME_4 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_4.NAME; +const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_1.NAME; +const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_2.NAME; +const COUNTRY_NAME_3 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_3.NAME; +const COUNTRY_NAME_4 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_4.NAME; const contextString = - 'As an exporter I want to enter the country where my buyer is based So that I can ascertain if I can obtain UKEF Credit Insurance for the country where my buyer is based'; + 'As an exporter I want to enter the country where my buyer is based So that I can ascertain if I can obtain UKEF Credit Insurance for the country where my buyer is based - submit countries that cannot apply'; context(`Insurance - Buyer country page - ${contextString} - Unsupported countries`, () => { beforeEach(() => { @@ -21,26 +21,26 @@ context(`Insurance - Buyer country page - ${contextString} - Unsupported countri }); describe(COUNTRY_NAME_1, () => { - it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, CANNOT_APPLY_EXIT); }); }); describe(COUNTRY_NAME_2, () => { - it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, CANNOT_APPLY_EXIT); }); }); describe(COUNTRY_NAME_3, () => { - it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_3, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_3, CANNOT_APPLY_EXIT); }); }); describe(COUNTRY_NAME_4, () => { - it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => { - cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT); + it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => { + cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, CANNOT_APPLY_EXIT); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js index b1e99a2372..87eebb1e2c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js @@ -13,7 +13,7 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME; +const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME; const baseUrl = Cypress.config('baseUrl'); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js index f8c95a6adb..4b6a5f86d9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js @@ -12,7 +12,7 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME_UNSUPPORTED = COUNTRY_APPLICATION_SUPPORT.CANNOT_APPLY_1.NAME; +const COUNTRY_NAME_UNSUPPORTED = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_1.NAME; const baseUrl = Cypress.config('baseUrl'); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js index 5dff77af05..d080be96d1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js @@ -13,7 +13,7 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.CANNOT_APPLY_1.NAME; +const COUNTRY_NAME = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_1.NAME; const baseUrl = Cypress.config('baseUrl'); @@ -35,7 +35,7 @@ context( cy.clickSubmitButton(); }); - it('redirects to `cannot apply` exit page', () => { + it(`redirects to ${CANNOT_APPLY_EXIT} exit page`, () => { const expectedUrl = `${baseUrl}${CANNOT_APPLY_EXIT}`; cy.assertUrl(expectedUrl); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js index 22fdadcf7f..3c4856e1d5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js @@ -131,7 +131,7 @@ context('Insurance - Export contract - About goods or services page - form valid cy.assertYesRadioOptionIsChecked(); - cy.checkText(autoCompleteField(FINAL_DESTINATION).results(), COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME); + cy.checkText(autoCompleteField(FINAL_DESTINATION).results(), COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME); }); }); diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-country-only-get-a-quote-by-email.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-country-only-get-a-quote-offline.spec.js similarity index 85% rename from e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-country-only-get-a-quote-by-email.spec.js rename to e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-country-only-get-a-quote-offline.spec.js index 696cb0394d..961d219d97 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-country-only-get-a-quote-by-email.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-country-only-get-a-quote-offline.spec.js @@ -9,12 +9,12 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const NEW_COUNTRY_INPUT = COUNTRY_QUOTE_SUPPORT.BY_EMAIL.NAME; +const COUNTRY_NAME = COUNTRY_QUOTE_SUPPORT.NO_ONLINE_SUPPORT_1.NAME; const baseUrl = Cypress.config('baseUrl'); context( - 'Buyer country page - as an exporter, I want to check if UKEF issue credit insurance cover for where my buyer is based - submit country that can only get a quote offline/via email', + 'Buyer country page - as an exporter, I want to check if UKEF issue credit insurance cover for where my buyer is based - submit country that can only get a quote offline', () => { const url = `${baseUrl}${BUYER_COUNTRY}`; @@ -22,7 +22,7 @@ context( cy.navigateToUrl(url); cy.assertUrl(url); - cy.keyboardInput(autoCompleteField(FIELD_ID).input(), NEW_COUNTRY_INPUT); + cy.keyboardInput(autoCompleteField(FIELD_ID).input(), COUNTRY_NAME); const results = autoCompleteField(FIELD_ID).results(); results.first().click(); @@ -43,7 +43,7 @@ context( it('should prepopulate the field when going back to the page via back link', () => { cy.clickBackLink(); - const expectedValue = NEW_COUNTRY_INPUT; + const expectedValue = COUNTRY_NAME; cy.checkTextAndValue({ textSelector: autoCompleteField(FIELD_ID).results(), diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js index bfd2b74af0..461c8b93b1 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country-unsupported-country.spec.js @@ -11,12 +11,12 @@ const { const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const NEW_COUNTRY_INPUT = COUNTRY_QUOTE_SUPPORT.UNSUPPORTED.NAME; +const COUNTRY_NAME = COUNTRY_QUOTE_SUPPORT.NOT_SUPPORTED_1.NAME; const baseUrl = Cypress.config('baseUrl'); context( - 'Buyer country page - as an exporter, I want to check if UKEF issue credit insurance cover for where my buyer is based - submit unsupported country', + 'Buyer country page - as an exporter, I want to check if UKEF issue credit insurance cover for where my buyer is based - submit a country that cannot get a quote', () => { const url = `${baseUrl}${BUYER_COUNTRY}`; @@ -30,7 +30,7 @@ context( cy.navigateToUrl(url); - cy.keyboardInput(autoCompleteField(FIELD_ID).input(), NEW_COUNTRY_INPUT); + cy.keyboardInput(autoCompleteField(FIELD_ID).input(), COUNTRY_NAME); const results = autoCompleteField(FIELD_ID).results(); results.first().click(); @@ -50,14 +50,14 @@ context( it('should render a specific reason', () => { const { REASON } = CONTENT_STRINGS; - const expected = `${REASON.INTRO} ${REASON.UNSUPPORTED_BUYER_COUNTRY_1} ${NEW_COUNTRY_INPUT}, ${REASON.UNSUPPORTED_BUYER_COUNTRY_2}`; + const expected = `${REASON.INTRO} ${REASON.UNSUPPORTED_BUYER_COUNTRY_1} ${COUNTRY_NAME}, ${REASON.UNSUPPORTED_BUYER_COUNTRY_2}`; cy.checkText(cannotApplyPage.reason(), expected); }); it('should prepopulate the field when going back to the page via back link', () => { cy.clickBackLink(); - const expectedValue = NEW_COUNTRY_INPUT; + const expectedValue = COUNTRY_NAME; cy.checkTextAndValue({ textSelector: autoCompleteField(FIELD_ID).results(), diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country.spec.js index 231084496d..f9781bca7a 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/buyer-country/buyer-country.spec.js @@ -12,7 +12,7 @@ const { QUOTE: { BUYER_COUNTRY, BUYER_BODY }, } = ROUTES; -const supportedCountryName = COUNTRY_QUOTE_SUPPORT.ONLINE.NAME; +const supportedCountryName = COUNTRY_QUOTE_SUPPORT.ONLINE_SUPPORT_1.NAME; const baseUrl = Cypress.config('baseUrl'); @@ -68,7 +68,7 @@ context('Buyer country page - as an exporter, I want to check if UKEF issue cred }); }); - describe('when submitting with a supported country', () => { + describe('when submitting with a country that can get a quote online', () => { const field = autoCompleteField(FIELD_ID); beforeEach(() => { diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js index 520e5c7ee0..7bc0773c6d 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/get-a-quote-via-email.spec.js @@ -8,7 +8,7 @@ const CONTENT_STRINGS = PAGES.QUOTE.GET_A_QUOTE_BY_EMAIL; const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY; -const COUNTRY_NAME_QUOTE_BY_EMAIL_ONLY = COUNTRY_QUOTE_SUPPORT.BY_EMAIL.NAME; +const COUNTRY_NAME_QUOTE_BY_EMAIL_ONLY = COUNTRY_QUOTE_SUPPORT.NO_ONLINE_SUPPORT_1.NAME; const baseUrl = Cypress.config('baseUrl'); diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index a9cb2e1d16..1928521d44 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -2824,7 +2824,6 @@ var typeDefs = ` esraClassification: String canGetAQuoteOnline: Boolean cannotGetAQuote: Boolean - cannotApply: Boolean canApplyForInsuranceOnline: Boolean noOnlineSupport: Boolean noInsuranceSupport: Boolean diff --git a/src/api/custom-schema/type-defs.ts b/src/api/custom-schema/type-defs.ts index 08f0ee4caf..5d959683d0 100644 --- a/src/api/custom-schema/type-defs.ts +++ b/src/api/custom-schema/type-defs.ts @@ -231,7 +231,6 @@ const typeDefs = ` esraClassification: String canGetAQuoteOnline: Boolean cannotGetAQuote: Boolean - cannotApply: Boolean canApplyForInsuranceOnline: Boolean noOnlineSupport: Boolean noInsuranceSupport: Boolean diff --git a/src/api/schema.graphql b/src/api/schema.graphql index 0d2431a695..ba0bd61a12 100644 --- a/src/api/schema.graphql +++ b/src/api/schema.graphql @@ -3745,7 +3745,6 @@ type MappedCisCountry { esraClassification: String canGetAQuoteOnline: Boolean cannotGetAQuote: Boolean - cannotApply: Boolean canApplyForInsuranceOnline: Boolean noOnlineSupport: Boolean noInsuranceSupport: Boolean diff --git a/src/ui/server/graphql/queries/APIM/CIS-countries.ts b/src/ui/server/graphql/queries/APIM/CIS-countries.ts index dac20373cb..414956fc8d 100644 --- a/src/ui/server/graphql/queries/APIM/CIS-countries.ts +++ b/src/ui/server/graphql/queries/APIM/CIS-countries.ts @@ -8,7 +8,6 @@ const getApimCisCountries = gql` esraClassification canGetAQuoteOnline cannotGetAQuote - cannotApply canApplyForInsuranceOnline noOnlineSupport noInsuranceSupport From 1f4b4d0bc9b2817ae1ea2339dd7592c7d6696fcc Mon Sep 17 00:00:00 2001 From: ttbarnes Date: Tue, 7 Jan 2025 09:52:35 +0000 Subject: [PATCH 11/12] chore(EMS-4097): fix typo --- .../controllers/quote/buyer-country/country-redirects.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts b/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts index 98c2eab24e..714d76c982 100644 --- a/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts +++ b/src/ui/server/controllers/quote/buyer-country/country-redirects.test.ts @@ -97,7 +97,7 @@ describe('controllers/quote/buyer-country - redirects', () => { }); }); - describe('when the API returns a canGetAQuoteByEmail flag for the submitted country', () => { + describe('when the API returns a noOnlineSupport flag for the submitted country', () => { const selectedCountryIsoCode = mockCountryCanGetAQuoteByEmail.isoCode; beforeEach(() => { From 8d465a764bc18a60070e10e727a2f0f662a1db14 Mon Sep 17 00:00:00 2001 From: ttbarnes Date: Tue, 7 Jan 2025 11:15:33 +0000 Subject: [PATCH 12/12] chore(EMS-4097): fix merge issue --- .../buyer-country/buyer-country-no-online-support.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js index 298e3df3ae..a4c024ed52 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-online-support.spec.js @@ -16,7 +16,7 @@ context( beforeEach(() => { cy.saveSession(); - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' }); }); describe(COUNTRY_NAME_1, () => {