@zeniai/client-epic-state 5.0.95-beta0ND → 5.0.95-beta1ND
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.
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +2 -4
- package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +6 -56
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +1 -1
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +2 -4
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +1 -2
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +6 -56
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { from, of } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { getCountryList } from '../../../../../entity/countryList/countryListSelector';
|
|
4
3
|
import { isSuccessResponse } from '../../../../../responsePayload';
|
|
5
4
|
import { newAddressInLocalStore } from '../../../../addressView/addressViewReducer';
|
|
6
5
|
import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
|
|
@@ -8,7 +7,7 @@ import { parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../.
|
|
|
8
7
|
import { mapDrivingLicenseToOfficer, mapPassportToOfficer, mapSsnCardToOfficer, } from '../../kycKybParseMapper';
|
|
9
8
|
import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
|
|
10
9
|
const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
|
|
11
|
-
export const parseUploadedKycDocumentEpic = (actions$,
|
|
10
|
+
export const parseUploadedKycDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(parseUploadedKycDocument.match), mergeMap((action) => {
|
|
12
11
|
const { target, companyId, officerType, fileId, documentType } = action.payload;
|
|
13
12
|
const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
|
|
14
13
|
const requestPayload = {
|
|
@@ -32,11 +31,10 @@ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actio
|
|
|
32
31
|
if (extracted == null) {
|
|
33
32
|
return of(failureAction);
|
|
34
33
|
}
|
|
35
|
-
const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
|
|
36
34
|
let result;
|
|
37
35
|
switch (documentType) {
|
|
38
36
|
case 'passport':
|
|
39
|
-
result = mapPassportToOfficer(extracted
|
|
37
|
+
result = mapPassportToOfficer(extracted);
|
|
40
38
|
break;
|
|
41
39
|
case 'driving_license':
|
|
42
40
|
result = mapDrivingLicenseToOfficer(extracted);
|
|
@@ -43,57 +43,6 @@ const tryParseDate = (rawDate) => {
|
|
|
43
43
|
}
|
|
44
44
|
return undefined;
|
|
45
45
|
};
|
|
46
|
-
const NATIONALITY_SYNONYMS = {
|
|
47
|
-
usa: 'united states',
|
|
48
|
-
us: 'united states',
|
|
49
|
-
'united states of america': 'united states',
|
|
50
|
-
america: 'united states',
|
|
51
|
-
american: 'united states',
|
|
52
|
-
uk: 'united kingdom',
|
|
53
|
-
gbr: 'united kingdom',
|
|
54
|
-
'great britain': 'united kingdom',
|
|
55
|
-
british: 'united kingdom',
|
|
56
|
-
indian: 'india',
|
|
57
|
-
ind: 'india',
|
|
58
|
-
canadian: 'canada',
|
|
59
|
-
can: 'canada',
|
|
60
|
-
australian: 'australia',
|
|
61
|
-
aus: 'australia',
|
|
62
|
-
german: 'germany',
|
|
63
|
-
deu: 'germany',
|
|
64
|
-
french: 'france',
|
|
65
|
-
fra: 'france',
|
|
66
|
-
chinese: 'china',
|
|
67
|
-
chn: 'china',
|
|
68
|
-
japanese: 'japan',
|
|
69
|
-
jpn: 'japan',
|
|
70
|
-
mexican: 'mexico',
|
|
71
|
-
mex: 'mexico',
|
|
72
|
-
brazilian: 'brazil',
|
|
73
|
-
bra: 'brazil',
|
|
74
|
-
};
|
|
75
|
-
const normalizeNationality = (rawNationality, countries) => {
|
|
76
|
-
// Collapse whitespace + strip trailing punctuation so "U.S.A." and
|
|
77
|
-
// "UNITED STATES OF AMERICA " both resolve.
|
|
78
|
-
const needle = rawNationality
|
|
79
|
-
.trim()
|
|
80
|
-
.toLowerCase()
|
|
81
|
-
.replace(/\./g, '')
|
|
82
|
-
.replace(/\s+/g, ' ');
|
|
83
|
-
if (needle === '') {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
// ISO-2 exact match (country list stores codes as ISO-2 — "US", "GB" ...).
|
|
87
|
-
const isoMatch = countries.find((country) => country.countryCode.toLowerCase() === needle);
|
|
88
|
-
if (isoMatch != null) {
|
|
89
|
-
return isoMatch.countryCode;
|
|
90
|
-
}
|
|
91
|
-
// Resolve synonyms (ISO-3, adjective, long-form name) to the canonical
|
|
92
|
-
// country-list `countryName`, then look that up.
|
|
93
|
-
const resolvedName = NATIONALITY_SYNONYMS[needle] ?? needle;
|
|
94
|
-
const nameMatch = countries.find((country) => country.countryName.toLowerCase() === resolvedName);
|
|
95
|
-
return nameMatch?.countryCode;
|
|
96
|
-
};
|
|
97
46
|
const splitFullName = (fullName) => {
|
|
98
47
|
const parts = fullName.trim().split(/\s+/);
|
|
99
48
|
if (parts.length === 1) {
|
|
@@ -104,7 +53,7 @@ const splitFullName = (fullName) => {
|
|
|
104
53
|
return { firstName, lastName };
|
|
105
54
|
};
|
|
106
55
|
/** Passport → Company Officer. */
|
|
107
|
-
export const mapPassportToOfficer = (parsed
|
|
56
|
+
export const mapPassportToOfficer = (parsed) => {
|
|
108
57
|
const result = emptyResult();
|
|
109
58
|
if (isConfident(parsed.first_name)) {
|
|
110
59
|
assignAutofilledValue(result, 'firstName', parsed.first_name.value);
|
|
@@ -118,11 +67,12 @@ export const mapPassportToOfficer = (parsed, allNationalityCountries) => {
|
|
|
118
67
|
assignAutofilledValue(result, 'birthday', parsedDate);
|
|
119
68
|
}
|
|
120
69
|
}
|
|
70
|
+
// The raw nationality string (e.g. "USA", "UNITED STATES OF AMERICA") is
|
|
71
|
+
// passed through unresolved; the consuming form section normalizes it to an
|
|
72
|
+
// ISO-2 code via the `countries-list` dataset before `setValue`. The form
|
|
73
|
+
// value (not this localData seed) is what gets submitted.
|
|
121
74
|
if (isConfident(parsed.nationality)) {
|
|
122
|
-
|
|
123
|
-
if (isoCode != null) {
|
|
124
|
-
assignAutofilledValue(result, 'nationalityCountryCode', isoCode);
|
|
125
|
-
}
|
|
75
|
+
assignAutofilledValue(result, 'nationalityCountryCode', parsed.nationality.value);
|
|
126
76
|
}
|
|
127
77
|
return result;
|
|
128
78
|
};
|
|
@@ -6,4 +6,4 @@ import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingVie
|
|
|
6
6
|
import { parseUploadedKycDocument, parseUploadedKycDocumentFailure } from '../../kycKybAutofillActions';
|
|
7
7
|
import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
|
|
8
8
|
export type ActionType = ReturnType<typeof parseUploadedKycDocument | typeof parseUploadedKycDocumentFailure | typeof applyKycDocumentAutofillForSetup | typeof applyKycDocumentAutofillForOnboarding | typeof newAddressInLocalStore>;
|
|
9
|
-
export declare const parseUploadedKycDocumentEpic: (actions$: ActionsObservable<ActionType>,
|
|
9
|
+
export declare const parseUploadedKycDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseUploadedKycDocumentEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const countryListSelector_1 = require("../../../../../entity/countryList/countryListSelector");
|
|
7
6
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
8
7
|
const addressViewReducer_1 = require("../../../../addressView/addressViewReducer");
|
|
9
8
|
const onboardingCustomerViewReducer_1 = require("../../../../onboardingView/customerView/onboardingCustomerViewReducer");
|
|
@@ -11,7 +10,7 @@ const kycKybAutofillActions_1 = require("../../kycKybAutofillActions");
|
|
|
11
10
|
const kycKybParseMapper_1 = require("../../kycKybParseMapper");
|
|
12
11
|
const setupViewReducer_1 = require("../../setupViewReducer");
|
|
13
12
|
const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
|
|
14
|
-
const parseUploadedKycDocumentEpic = (actions$,
|
|
13
|
+
const parseUploadedKycDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(kycKybAutofillActions_1.parseUploadedKycDocument.match), (0, operators_1.mergeMap)((action) => {
|
|
15
14
|
const { target, companyId, officerType, fileId, documentType } = action.payload;
|
|
16
15
|
const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
|
|
17
16
|
const requestPayload = {
|
|
@@ -35,11 +34,10 @@ const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pip
|
|
|
35
34
|
if (extracted == null) {
|
|
36
35
|
return (0, rxjs_1.of)(failureAction);
|
|
37
36
|
}
|
|
38
|
-
const allCountries = (0, countryListSelector_1.getCountryList)(state$.value.countryListState, 'nationalityCountryList').countries;
|
|
39
37
|
let result;
|
|
40
38
|
switch (documentType) {
|
|
41
39
|
case 'passport':
|
|
42
|
-
result = (0, kycKybParseMapper_1.mapPassportToOfficer)(extracted
|
|
40
|
+
result = (0, kycKybParseMapper_1.mapPassportToOfficer)(extracted);
|
|
43
41
|
break;
|
|
44
42
|
case 'driving_license':
|
|
45
43
|
result = (0, kycKybParseMapper_1.mapDrivingLicenseToOfficer)(extracted);
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* both the merged values and the list of field names that were autofilled so the
|
|
6
6
|
* UI can show the ✦ AI badge next to each.
|
|
7
7
|
*/
|
|
8
|
-
import { Country } from '../../../entity/countryList/countryListState';
|
|
9
8
|
import { AddressUpdatableInfo } from '../../addressView/addressViewState';
|
|
10
9
|
import { CompanyDetailsLocalData, CompanyOfficerLocalData } from './setupViewState';
|
|
11
10
|
import { ExtendCertificateOfIncorporationParsed, ExtendDrivingLicenseParsed, ExtendPassportParsed, ExtendSsnCardParsed, ExtendTaxEinParsed } from './types/kycKybAutofill';
|
|
@@ -26,7 +25,7 @@ export interface OfficerAutofillResult extends AutofillResult<CompanyOfficerLoca
|
|
|
26
25
|
}
|
|
27
26
|
export declare const OFFICER_ADDRESS_AUTOFILL_FIELD = "officerAddress";
|
|
28
27
|
/** Passport → Company Officer. */
|
|
29
|
-
export declare const mapPassportToOfficer: (parsed: ExtendPassportParsed
|
|
28
|
+
export declare const mapPassportToOfficer: (parsed: ExtendPassportParsed) => AutofillResult<CompanyOfficerLocalData>;
|
|
30
29
|
/** Driving License → Company Officer (name, DOB, and home address). */
|
|
31
30
|
export declare const mapDrivingLicenseToOfficer: (parsed: ExtendDrivingLicenseParsed) => OfficerAutofillResult;
|
|
32
31
|
/** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
|
|
@@ -46,57 +46,6 @@ const tryParseDate = (rawDate) => {
|
|
|
46
46
|
}
|
|
47
47
|
return undefined;
|
|
48
48
|
};
|
|
49
|
-
const NATIONALITY_SYNONYMS = {
|
|
50
|
-
usa: 'united states',
|
|
51
|
-
us: 'united states',
|
|
52
|
-
'united states of america': 'united states',
|
|
53
|
-
america: 'united states',
|
|
54
|
-
american: 'united states',
|
|
55
|
-
uk: 'united kingdom',
|
|
56
|
-
gbr: 'united kingdom',
|
|
57
|
-
'great britain': 'united kingdom',
|
|
58
|
-
british: 'united kingdom',
|
|
59
|
-
indian: 'india',
|
|
60
|
-
ind: 'india',
|
|
61
|
-
canadian: 'canada',
|
|
62
|
-
can: 'canada',
|
|
63
|
-
australian: 'australia',
|
|
64
|
-
aus: 'australia',
|
|
65
|
-
german: 'germany',
|
|
66
|
-
deu: 'germany',
|
|
67
|
-
french: 'france',
|
|
68
|
-
fra: 'france',
|
|
69
|
-
chinese: 'china',
|
|
70
|
-
chn: 'china',
|
|
71
|
-
japanese: 'japan',
|
|
72
|
-
jpn: 'japan',
|
|
73
|
-
mexican: 'mexico',
|
|
74
|
-
mex: 'mexico',
|
|
75
|
-
brazilian: 'brazil',
|
|
76
|
-
bra: 'brazil',
|
|
77
|
-
};
|
|
78
|
-
const normalizeNationality = (rawNationality, countries) => {
|
|
79
|
-
// Collapse whitespace + strip trailing punctuation so "U.S.A." and
|
|
80
|
-
// "UNITED STATES OF AMERICA " both resolve.
|
|
81
|
-
const needle = rawNationality
|
|
82
|
-
.trim()
|
|
83
|
-
.toLowerCase()
|
|
84
|
-
.replace(/\./g, '')
|
|
85
|
-
.replace(/\s+/g, ' ');
|
|
86
|
-
if (needle === '') {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
// ISO-2 exact match (country list stores codes as ISO-2 — "US", "GB" ...).
|
|
90
|
-
const isoMatch = countries.find((country) => country.countryCode.toLowerCase() === needle);
|
|
91
|
-
if (isoMatch != null) {
|
|
92
|
-
return isoMatch.countryCode;
|
|
93
|
-
}
|
|
94
|
-
// Resolve synonyms (ISO-3, adjective, long-form name) to the canonical
|
|
95
|
-
// country-list `countryName`, then look that up.
|
|
96
|
-
const resolvedName = NATIONALITY_SYNONYMS[needle] ?? needle;
|
|
97
|
-
const nameMatch = countries.find((country) => country.countryName.toLowerCase() === resolvedName);
|
|
98
|
-
return nameMatch?.countryCode;
|
|
99
|
-
};
|
|
100
49
|
const splitFullName = (fullName) => {
|
|
101
50
|
const parts = fullName.trim().split(/\s+/);
|
|
102
51
|
if (parts.length === 1) {
|
|
@@ -107,7 +56,7 @@ const splitFullName = (fullName) => {
|
|
|
107
56
|
return { firstName, lastName };
|
|
108
57
|
};
|
|
109
58
|
/** Passport → Company Officer. */
|
|
110
|
-
const mapPassportToOfficer = (parsed
|
|
59
|
+
const mapPassportToOfficer = (parsed) => {
|
|
111
60
|
const result = emptyResult();
|
|
112
61
|
if (isConfident(parsed.first_name)) {
|
|
113
62
|
assignAutofilledValue(result, 'firstName', parsed.first_name.value);
|
|
@@ -121,11 +70,12 @@ const mapPassportToOfficer = (parsed, allNationalityCountries) => {
|
|
|
121
70
|
assignAutofilledValue(result, 'birthday', parsedDate);
|
|
122
71
|
}
|
|
123
72
|
}
|
|
73
|
+
// The raw nationality string (e.g. "USA", "UNITED STATES OF AMERICA") is
|
|
74
|
+
// passed through unresolved; the consuming form section normalizes it to an
|
|
75
|
+
// ISO-2 code via the `countries-list` dataset before `setValue`. The form
|
|
76
|
+
// value (not this localData seed) is what gets submitted.
|
|
124
77
|
if (isConfident(parsed.nationality)) {
|
|
125
|
-
|
|
126
|
-
if (isoCode != null) {
|
|
127
|
-
assignAutofilledValue(result, 'nationalityCountryCode', isoCode);
|
|
128
|
-
}
|
|
78
|
+
assignAutofilledValue(result, 'nationalityCountryCode', parsed.nationality.value);
|
|
129
79
|
}
|
|
130
80
|
return result;
|
|
131
81
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.95-
|
|
3
|
+
"version": "5.0.95-beta1ND",
|
|
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",
|