@zeniai/client-epic-state 5.1.2 → 5.1.3-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.
- package/lib/commonPayloadTypes/commonPayload.d.ts +25 -4
- package/lib/entity/approvalRule/approvalRulePayload.d.ts +1 -1
- package/lib/entity/approvalRule/approvalRulePayload.js +5 -1
- package/lib/esm/entity/approvalRule/approvalRulePayload.js +5 -1
- package/lib/esm/index.js +6 -1
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -1
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +7 -3
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -34
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +146 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +40 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +86 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +55 -8
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -6
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +154 -0
- package/lib/index.d.ts +8 -2
- package/lib/index.js +25 -7
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +6 -2
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +2 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +32 -33
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +4 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +150 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +38 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +43 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +27 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +96 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +24 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +59 -9
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +4 -5
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +20 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +32 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +159 -0
- package/package.json +1 -1
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3-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",
|