@adyen/kyc-components
Version:
`adyen-kyc-components` provides the required pieces to build an onboarding flow based on a legal entity. To onboard and verify users, you need to create a user interface (UI) to collect user data. To speed up building your integration, Adyen offers onboar
92 lines (91 loc) • 3.68 kB
TypeScript
import type { CustomerSupportSchema } from '../../components/Shared/tasks/CustomerSupport/types';
import type { ValidationRuleResult } from '../../utils/validation/types';
import type { PayoutDetailsSchema } from '../../components/BankAccount/forms/PayoutDetails/types';
import type { BusinessDetailsSchema } from '../../components/Business/forms/BusinessDetails/types';
import type { HighExposureSchema } from '../../components/EFP/tasks/HighExposureDropin/types';
import type { SourceOfFundsSchema } from '../../components/EFP/tasks/SourceOfFundsDropin/types';
import type { TaxReportingSchema } from '../../components/EFP/tasks/TaxReportingDropin/types';
import type { IndividualSchema } from '../../components/Individual/forms/Individual/types';
import type { IndividualOnfidoSchema } from '../../components/Individual/forms/IndividualOnfido/IndividualOnfido.types';
import type { TrustSchema } from '../../components/Trust/forms/Trust/types';
import type { TrustMemberSchema } from '../../components/Trust/tasks/RoleAndTypeDropin/types';
export interface SFValue {
caller?: string;
data?: object;
valid?: object;
errors?: object;
fieldProblems?: object;
schema?: string[];
dataStoreId?: string;
}
export interface SCAction {
type: 'addToState' | 'resetState' | 'removeFromState';
value?: SFValue;
}
export interface SCCurrent {
setState: null | ((action: SCAction) => void);
setActiveForms?: (forms: string[]) => void;
}
export interface StateContextRef {
current: SCCurrent;
}
interface StateContextBase {
owner?: string;
}
export interface SCSetter extends StateContextBase {
stateRef: StateContextRef;
}
export interface SCWatcher<TLDS extends TopLevelDataSchema> extends StateContextBase {
onChange: ({ currentState, prevState, changeInitiatedBy, }: StateModel<TLDS>['state'] & {
changeInitiatedBy?: string;
}) => void;
}
export type StateModel<TLDS extends TopLevelDataSchema = TopLevelDataSchema> = {
getData: () => TLDS;
getState: () => State<TLDS>;
dispatch: (action: SCAction) => void;
setActiveForms: (forms: string[]) => void;
state: {
currentState: State<TLDS>;
prevState?: State<TLDS>;
};
};
export type TopLevelDataSchema = IndividualSchema | IndividualOnfidoSchema | BusinessDetailsSchema | CustomerSupportSchema | PayoutDetailsSchema | TrustSchema | TrustMemberSchema | HighExposureSchema | SourceOfFundsSchema | TaxReportingSchema;
export type AnyFormIdOfTLDS = keyof IndividualSchema | keyof BusinessDetailsSchema | keyof PayoutDetailsSchema | keyof TrustSchema | keyof TrustMemberSchema;
export interface State<TLDS extends TopLevelDataSchema> {
data: TLDS;
allData: TLDS;
valid: {
[ActiveForm in keyof TLDS]: {
[Field in keyof TLDS[ActiveForm]]: boolean;
};
};
errors: {
[ActiveForm in keyof TLDS]: {
[Field in keyof TLDS[ActiveForm]]: ValidationRuleResult;
};
};
fieldProblems: {
[ActiveForm in keyof TLDS]: {
[Field in keyof TLDS[ActiveForm]]: boolean;
};
};
allValid: boolean;
isValid: boolean;
validityByForm?: Record<string, boolean>;
initialData: TLDS;
}
export interface StateSlice<TLDS extends TopLevelDataSchema, SliceName extends keyof TLDS, SliceData extends TLDS[SliceName]> {
data?: SliceData;
valid?: Partial<{
[key in keyof SliceData]: boolean;
}>;
errors?: Partial<{
[key in keyof SliceData]: ValidationRuleResult | null;
}>;
fieldProblems?: {
[key in keyof SliceData]: boolean;
};
schema?: ReadonlyArray<keyof SliceData>;
}
export {};