@zeniai/client-epic-state 5.1.6 → 5.1.8-betaAS1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +25 -4
  2. package/lib/esm/index.js +6 -1
  3. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +13 -7
  4. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +8 -0
  5. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +7 -3
  6. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -34
  7. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
  8. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +146 -0
  9. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +40 -0
  10. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +86 -0
  11. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +55 -8
  12. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -6
  13. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
  14. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +154 -0
  15. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +15 -1
  16. package/lib/index.d.ts +8 -2
  17. package/lib/index.js +24 -6
  18. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +12 -6
  19. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +1 -0
  20. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +9 -1
  21. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  22. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +6 -2
  23. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +2 -1
  24. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +32 -33
  25. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
  26. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +4 -0
  27. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +150 -0
  28. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +38 -0
  29. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +43 -0
  30. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +27 -0
  31. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +96 -0
  32. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +24 -1
  33. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +59 -9
  34. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +4 -5
  35. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
  36. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +20 -1
  37. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +32 -0
  38. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +159 -0
  39. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +15 -1
  40. package/package.json +6 -4
@@ -1,15 +1,29 @@
1
1
  import { FetchStateAndError } from '../../../../commonStateTypes/common';
2
+ import { FieldPayload } from './internationalWireVerificationPayload';
2
3
  export interface InternationalWireVerificationState {
3
4
  verificationFormFetchState: FetchStateAndError;
5
+ verificationFormFieldLabels: Record<string, FieldPayload>;
4
6
  verificationFormFields: VerificationFormField[];
5
7
  verificationFormLocalData: VerificationFormLocalData;
6
8
  verificationFormSubmitState: FetchStateAndError;
7
9
  }
8
- export type VerificationFormLocalData = Record<string, string | string[]>;
10
+ export type VerificationFormLocalDataValue = string | string[] | number;
11
+ export type VerificationFormLocalData = Record<string, VerificationFormLocalDataValue>;
9
12
  export interface FieldValueType {
10
13
  code: string;
11
14
  description: string;
12
15
  }
16
+ export interface VerificationFormFieldOption {
17
+ label: string;
18
+ }
19
+ export interface VerificationFormSubField {
20
+ fieldValues: FieldValueType[];
21
+ label: string;
22
+ placeholder: string;
23
+ type: string;
24
+ isMultipleOptionsSupported?: boolean;
25
+ options?: Record<string, VerificationFormFieldOption>;
26
+ }
13
27
  export interface VerificationFormField {
14
28
  fieldValues: FieldValueType[];
15
29
  isMultipleValuesAllowed: boolean;
@@ -17,4 +31,9 @@ export interface VerificationFormField {
17
31
  name: string;
18
32
  placeholder: string;
19
33
  type: string;
34
+ default?: boolean;
35
+ isMultipleOptionsSupported?: boolean;
36
+ options?: Record<string, VerificationFormFieldOption>;
37
+ requirements?: string[];
38
+ subfields?: Record<string, VerificationFormSubField>;
20
39
  }
@@ -0,0 +1,32 @@
1
+ import { VerificationFormLocalData } from './internationalWireVerificationState';
2
+ export interface IntlWireFileOptionPayload {
3
+ file_id: string;
4
+ option: string;
5
+ }
6
+ export interface IntlWirePersonNamePayload {
7
+ first_name: string;
8
+ last_name: string;
9
+ }
10
+ export interface IntlWirePersonPayload {
11
+ company_role?: string;
12
+ date_of_birth?: string;
13
+ email?: string;
14
+ name?: IntlWirePersonNamePayload;
15
+ nationality?: string;
16
+ ownership_percentage?: number;
17
+ proof_of_address?: IntlWireFileOptionPayload[];
18
+ proof_of_identity?: IntlWireFileOptionPayload[];
19
+ ssn?: string;
20
+ }
21
+ export type IntlWireFormDetailsPayload = Record<string, string | string[] | number | IntlWireFileOptionPayload[] | IntlWirePersonPayload | IntlWirePersonPayload[]>;
22
+ export declare const IntlWireVerificationLocalDataSuffix: {
23
+ readonly documentOption: "_option";
24
+ readonly documentBack: "_back";
25
+ readonly nameFirst: "_first_name";
26
+ readonly nameLast: "_last_name";
27
+ };
28
+ export declare const toIntlWireVerificationFormDetails: (localData: VerificationFormLocalData) => IntlWireFormDetailsPayload;
29
+ export declare const toIntlWireVerificationSubmitPayload: (localData: VerificationFormLocalData) => {
30
+ is_applicant_declaration: boolean;
31
+ form_details: IntlWireFormDetailsPayload;
32
+ };
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toIntlWireVerificationSubmitPayload = exports.toIntlWireVerificationFormDetails = exports.IntlWireVerificationLocalDataSuffix = void 0;
4
+ const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
5
+ exports.IntlWireVerificationLocalDataSuffix = {
6
+ documentOption: '_option',
7
+ documentBack: '_back',
8
+ nameFirst: '_first_name',
9
+ nameLast: '_last_name',
10
+ };
11
+ const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
12
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.businessOwnership,
13
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyProofOfAddress,
14
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
15
+ ]);
16
+ const BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES = new Set([
17
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder,
18
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson,
19
+ ]);
20
+ const FILE_SUBFIELD_NAMES = new Set([
21
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.proofOfIdentity,
22
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.proofOfAddress,
23
+ ]);
24
+ const isInternalLocalDataKey = (key) => key.endsWith(exports.IntlWireVerificationLocalDataSuffix.documentOption) ||
25
+ key.endsWith(exports.IntlWireVerificationLocalDataSuffix.documentBack) ||
26
+ key.endsWith(exports.IntlWireVerificationLocalDataSuffix.nameFirst) ||
27
+ key.endsWith(exports.IntlWireVerificationLocalDataSuffix.nameLast);
28
+ const isPersonSubfieldKey = (key) => key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`) ||
29
+ key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`);
30
+ const toFileOptionPayloads = (localData, baseKey) => {
31
+ const option = localData[`${baseKey}${exports.IntlWireVerificationLocalDataSuffix.documentOption}`];
32
+ if (typeof option !== 'string' || option.length === 0) {
33
+ return undefined;
34
+ }
35
+ const payloads = [];
36
+ const frontFileId = localData[baseKey];
37
+ if (typeof frontFileId === 'string' && frontFileId.length > 0) {
38
+ payloads.push({ file_id: frontFileId, option });
39
+ }
40
+ const backFileId = localData[`${baseKey}${exports.IntlWireVerificationLocalDataSuffix.documentBack}`];
41
+ if (typeof backFileId === 'string' && backFileId.length > 0) {
42
+ payloads.push({ file_id: backFileId, option });
43
+ }
44
+ return payloads.length > 0 ? payloads : undefined;
45
+ };
46
+ const buildPersonPayload = (localData, keyPrefix) => {
47
+ const person = {};
48
+ const nameBaseKey = `${keyPrefix}_${internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.name}`;
49
+ const firstName = localData[`${nameBaseKey}${exports.IntlWireVerificationLocalDataSuffix.nameFirst}`];
50
+ const lastName = localData[`${nameBaseKey}${exports.IntlWireVerificationLocalDataSuffix.nameLast}`];
51
+ if (typeof firstName === 'string' || typeof lastName === 'string') {
52
+ person.name = {
53
+ first_name: typeof firstName === 'string' ? firstName : '',
54
+ last_name: typeof lastName === 'string' ? lastName : '',
55
+ };
56
+ }
57
+ const assignStringField = (subfieldName, assign) => {
58
+ const value = localData[`${keyPrefix}_${subfieldName}`];
59
+ if (typeof value === 'string' && value.length > 0) {
60
+ assign(value);
61
+ }
62
+ };
63
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.nationality, (value) => {
64
+ person.nationality = value;
65
+ });
66
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.email, (value) => {
67
+ person.email = value;
68
+ });
69
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.companyRole, (value) => {
70
+ person.company_role = value;
71
+ });
72
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.ssn, (value) => {
73
+ person.ssn = value;
74
+ });
75
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.dateOfBirth, (value) => {
76
+ person.date_of_birth = value;
77
+ });
78
+ const ownershipValue = localData[`${keyPrefix}_${internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.ownershipPercentage}`];
79
+ if (ownershipValue != null && ownershipValue !== '') {
80
+ person.ownership_percentage = Number(ownershipValue);
81
+ }
82
+ FILE_SUBFIELD_NAMES.forEach((subfieldName) => {
83
+ const filePayloads = toFileOptionPayloads(localData, `${keyPrefix}_${subfieldName}`);
84
+ if (filePayloads != null) {
85
+ if (subfieldName ===
86
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.proofOfIdentity) {
87
+ person.proof_of_identity = filePayloads;
88
+ }
89
+ else {
90
+ person.proof_of_address = filePayloads;
91
+ }
92
+ }
93
+ });
94
+ return person;
95
+ };
96
+ const getStakeHolderOwnerIndices = (localData) => {
97
+ const stakeHolderPrefix = `${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`;
98
+ const indices = new Set();
99
+ Object.keys(localData).forEach((key) => {
100
+ const match = key.match(/^stake_holder_(\d+)_/);
101
+ if (match != null) {
102
+ indices.add(Number.parseInt(match[1], 10));
103
+ }
104
+ });
105
+ if (indices.size === 0) {
106
+ const hasUnindexedStakeHolderData = Object.keys(localData).some((key) => key.startsWith(stakeHolderPrefix) &&
107
+ !/^stake_holder_(true|false)$/.test(key));
108
+ if (hasUnindexedStakeHolderData) {
109
+ indices.add(0);
110
+ }
111
+ }
112
+ return Array.from(indices).sort((a, b) => a - b);
113
+ };
114
+ const hasPersonPayloadData = (person) => Object.keys(person).length > 0;
115
+ const toIntlWireVerificationFormDetails = (localData) => {
116
+ const formDetails = {};
117
+ Object.entries(localData).forEach(([key, value]) => {
118
+ if (BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES.has(key) ||
119
+ isInternalLocalDataKey(key) ||
120
+ isPersonSubfieldKey(key)) {
121
+ return;
122
+ }
123
+ if (MULTI_OPTION_FILE_FIELD_NAMES.has(key)) {
124
+ const filePayloads = toFileOptionPayloads(localData, key);
125
+ if (filePayloads != null) {
126
+ formDetails[key] = filePayloads;
127
+ }
128
+ return;
129
+ }
130
+ if (value == null || value === '') {
131
+ return;
132
+ }
133
+ formDetails[key] = value;
134
+ });
135
+ const stakeHolderSelection = localData[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder];
136
+ if (stakeHolderSelection === 'true') {
137
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = getStakeHolderOwnerIndices(localData)
138
+ .map((ownerIndex) => buildPersonPayload(localData, `${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_${ownerIndex}`))
139
+ .filter(hasPersonPayloadData);
140
+ }
141
+ else if (stakeHolderSelection === 'false') {
142
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = [];
143
+ }
144
+ const controllingPersonSelection = localData[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames
145
+ .controllingPerson];
146
+ if (controllingPersonSelection === 'false') {
147
+ const controllingPerson = buildPersonPayload(localData, internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson);
148
+ if (hasPersonPayloadData(controllingPerson)) {
149
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson] = controllingPerson;
150
+ }
151
+ }
152
+ return formDetails;
153
+ };
154
+ exports.toIntlWireVerificationFormDetails = toIntlWireVerificationFormDetails;
155
+ const toIntlWireVerificationSubmitPayload = (localData) => ({
156
+ is_applicant_declaration: true,
157
+ form_details: (0, exports.toIntlWireVerificationFormDetails)(localData),
158
+ });
159
+ exports.toIntlWireVerificationSubmitPayload = toIntlWireVerificationSubmitPayload;
@@ -14,7 +14,21 @@ const kycKybAutofill_1 = require("./types/kycKybAutofill");
14
14
  exports.OFFICER_ADDRESS_AUTOFILL_FIELD = 'officerAddress';
15
15
  // US driving licenses carry a US state in `address_state` but no country field;
16
16
  // default the composed address to the US.
17
- const DRIVING_LICENSE_DEFAULT_COUNTRY = 'United States';
17
+ // Extend's driving-license parser is US-focused — its response shape
18
+ // (`ExtendDrivingLicenseParsed`) only returns `issuing_state`, no
19
+ // `issuing_country` / `country_of_issue`. So we default the address country
20
+ // to US for autofill purposes.
21
+ //
22
+ // `country` is the alpha-3 ISO code (matches the rest of the codebase's
23
+ // address payloads — e.g. `subscriptionBillingAddress.country = 'USA'`).
24
+ // The Edit Address form's country dropdown looks up the option by alpha-3,
25
+ // so using the country name here would leave the dropdown blank.
26
+ //
27
+ // To support non-US driving licenses later: (1) extend the document-service
28
+ // Extend workflow to return an issuing-country field, (2) add it to
29
+ // `ExtendDrivingLicenseParsed`, (3) read it here with this US value as the
30
+ // fallback when the parser couldn't determine the country.
31
+ const DRIVING_LICENSE_DEFAULT_COUNTRY = 'USA';
18
32
  const DRIVING_LICENSE_DEFAULT_COUNTRY_CODE = 'US';
19
33
  const emptyResult = () => ({
20
34
  values: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.6",
3
+ "version": "5.1.8-betaAS1",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -106,9 +106,11 @@
106
106
  "scripts": {
107
107
  "clean": "rimraf lib",
108
108
  "test:typecheck": "echo 'Typechecking test files...' && NODE_OPTIONS=--max-old-space-size=4096 time tsc -p tsconfig.typecheck.json",
109
- "test:typecheck-modified-files": "chmod +x ./scripts/tsc-modified-files.sh && ./scripts/tsc-modified-files.sh master tsconfig.typecheck.json",
110
- "test": "pnpm lint-modified-files && pnpm test:typecheck-modified-files && vitest run --typecheck",
111
- "test:full": "vitest run --typecheck",
109
+ "test:typecheck-modified-files": "chmod +x ./scripts/tsc-modified-files.sh && SINCE_DAYS=2 ./scripts/tsc-modified-files.sh master tsconfig.typecheck.json",
110
+ "test:typecheck-mocks": "echo 'Typechecking mock files...' && NODE_OPTIONS=--max-old-space-size=4096 time tsc -p tsconfig.mocks.json",
111
+ "test:typecheck-mocks-modified-files": "chmod +x ./scripts/tsc-modified-files.sh && SINCE_DAYS=2 ./scripts/tsc-modified-files.sh master tsconfig.mocks.json",
112
+ "test": "pnpm lint-modified-files && pnpm test:typecheck-modified-files && pnpm test:typecheck-mocks-modified-files && vitest run --typecheck",
113
+ "test:full": "pnpm test:typecheck-modified-files && pnpm test:typecheck-mocks-modified-files && vitest run --typecheck",
112
114
  "lint": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 --fix",
113
115
  "lint-modified-files": "chmod +x ./scripts/lint-modified-files.sh && ./scripts/lint-modified-files.sh",
114
116
  "lint:fix-modified-files": "chmod +x ./scripts/lint-modified-files.sh && LINT_FIX=true ./scripts/lint-modified-files.sh",