UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

46 lines (45 loc) 3.28 kB
try { let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "d9d918ab-8811-49d8-8b24-458839106954", e._sentryDebugIdIdentifier = "sentry-dbid-d9d918ab-8811-49d8-8b24-458839106954"); } catch (e) {} import { i as getDirectEntityAssociations, p as TaskTypes } from "./entityAssociationUtil-BEzUdPbm.js"; import { t as DecisionMakerTypes } from "./decision-maker-type-Cow3CpUd.js"; import { r as getDecisionMakerRequirements } from "./decisionMaker-j9cwyXuS.js"; //#region src/utils/decisionMakerRoles.ts var getOwnDecisionMakers = (rootLegalEntity) => { if (!rootLegalEntity?.entityAssociations) return []; return rootLegalEntity.entityAssociations.filter((entityAssociation) => Object.values(DecisionMakerTypes).includes(entityAssociation.type) && entityAssociation.associatorId === rootLegalEntity.id); }; var getDecisionMakers = (rootLegalEntity, companyLegalEntityId) => getDirectEntityAssociations(rootLegalEntity, companyLegalEntityId).filter((association) => Object.values(DecisionMakerTypes).includes(association.type)); var getOwnSignatories = (rootLegalEntity) => getOwnDecisionMakers(rootLegalEntity).filter((decisionMaker) => decisionMaker.type === DecisionMakerTypes.SIGNATORY); var getOwnDecisionMakersLegalEntityIds = (rootLegalEntity) => getOwnDecisionMakers(rootLegalEntity).map((ea) => ea.legalEntityId).filter((id) => id !== void 0); var getDecisionMakerCount = (rootLegalEntity) => { return getOwnDecisionMakers(rootLegalEntity).reduce((decisionMakerCount, decisionMaker) => { decisionMakerCount[decisionMaker.type] = (decisionMakerCount[decisionMaker.type] ?? 0) + 1; return decisionMakerCount; }, {}); }; var getAllowedDecisionMakerRoles = (rootLegalEntity, taskType, scenarios) => { if (taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER) return [DecisionMakerTypes.OWNER]; const existingDecisionMakerCount = getDecisionMakerCount(rootLegalEntity); const registeredCountry = rootLegalEntity?.organization?.registeredAddress?.country; const allowedRoles = getDecisionMakerRequirements(registeredCountry, scenarios).reduce((acc, requirements) => { const { roleTypes, max } = requirements; if (roleTypes.length === 1) { const role = roleTypes[0]; if ((existingDecisionMakerCount?.[role] ?? 0) < max) acc.push(role); } return acc; }, []); return [...new Set(allowedRoles)]; }; var hasMinRequiredDecisionMakerCount = (rootLegalEntity) => { const existingDecisionMakerCount = getDecisionMakerCount(rootLegalEntity); const registeredCountry = rootLegalEntity?.organization?.registeredAddress?.country; return getDecisionMakerRequirements(registeredCountry).every((requirements) => { const { roleTypes, min } = requirements; return roleTypes.some((role) => min ? existingDecisionMakerCount?.[role] ?? min <= 0 : true); }); }; //#endregion export { getOwnSignatories as a, getOwnDecisionMakersLegalEntityIds as i, getDecisionMakers as n, hasMinRequiredDecisionMakerCount as o, getOwnDecisionMakers as r, getAllowedDecisionMakerRoles as t };