@zeniai/client-epic-state 5.1.3-betaAS1 → 5.1.3-betaJK1

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 (63) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +4 -25
  2. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  3. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  4. package/lib/entity/task/taskPayload.d.ts +1 -0
  5. package/lib/entity/task/taskPayload.js +1 -0
  6. package/lib/entity/task/taskReducer.d.ts +5 -1
  7. package/lib/entity/task/taskReducer.js +8 -2
  8. package/lib/entity/task/taskState.d.ts +1 -0
  9. package/lib/epic.d.ts +3 -1
  10. package/lib/epic.js +3 -1
  11. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  12. package/lib/esm/entity/task/taskPayload.js +1 -0
  13. package/lib/esm/entity/task/taskReducer.js +7 -1
  14. package/lib/esm/epic.js +3 -1
  15. package/lib/esm/index.js +3 -8
  16. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +3 -7
  17. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +34 -33
  18. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  19. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +8 -55
  20. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +6 -5
  21. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  22. package/lib/esm/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +80 -0
  23. package/lib/esm/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +36 -0
  24. package/lib/esm/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.js +13 -0
  25. package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +56 -2
  26. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +19 -8
  27. package/lib/index.d.ts +5 -11
  28. package/lib/index.js +12 -27
  29. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  30. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  31. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +2 -6
  32. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +1 -2
  33. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -32
  34. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  35. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +1 -24
  36. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +9 -59
  37. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -4
  38. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  39. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +1 -20
  40. package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.d.ts +9 -0
  41. package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +84 -0
  42. package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.d.ts +8 -0
  43. package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +40 -0
  44. package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.d.ts +2 -1
  45. package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.js +13 -0
  46. package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +13 -0
  47. package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +14 -2
  48. package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +57 -3
  49. package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +2 -1
  50. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +17 -6
  51. package/package.json +1 -1
  52. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -146
  53. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -40
  54. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -86
  55. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -154
  56. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +0 -4
  57. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -150
  58. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +0 -38
  59. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -43
  60. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +0 -27
  61. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -96
  62. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +0 -32
  63. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -159
@@ -33,8 +33,13 @@ const getTaskDetail = (state, taskId) => {
33
33
  let recurringSourceTaskId = undefined;
34
34
  let snoozedUntil = undefined;
35
35
  let taskGroupId = undefined;
36
+ let subtasks = [];
36
37
  if (taskId != null && sourceTaskDetail != null) {
37
38
  const taskEntity = (0, taskSelector_1.getTaskById)(taskState, taskId);
39
+ subtasks =
40
+ taskEntity != null
41
+ ? (0, taskSelector_1.getTasksByIds)(taskState, taskEntity.subTasksIds)
42
+ : [];
38
43
  const fileIdsInEntity = taskEntity?.fileIds ?? [];
39
44
  if (taskEntity != null) {
40
45
  createdByUser = (0, userAndRole_1.getUserAndUserRole)(userState, userRoleState, addressState, taskEntity.createdBy);
@@ -45,25 +50,27 @@ const getTaskDetail = (state, taskId) => {
45
50
  taskGroupId = taskEntity.taskGroupIds[0];
46
51
  }
47
52
  if (fileIdsInEntity.length > 0) {
48
- fetchStatus = (0, reduceFetchState_1.reduceFetchState)([
53
+ fetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)([
49
54
  fileViewState.fetchFilesStatus,
50
55
  sourceTaskDetail.fetchTaskStatus,
51
56
  userList,
52
57
  classListState,
58
+ taskDetailState.subTaskListFetchStatusByParentId[taskId] ?? fetchStatus,
53
59
  ]);
54
60
  }
55
61
  else {
56
- fetchStatus = (0, reduceFetchState_1.reduceFetchState)([
62
+ fetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)([
57
63
  sourceTaskDetail.fetchTaskStatus,
58
64
  userList,
59
65
  classListState,
66
+ taskDetailState.subTaskListFetchStatusByParentId[taskId] ?? fetchStatus,
60
67
  ]);
61
68
  }
62
69
  showTaskDetailFormFooter = showFormFooter(sourceTaskDetail.taskDetailLocalData, taskEntity);
63
70
  taskHistory = taskDetailState.taskHistoryById[taskId]?.historicEvents ?? [];
64
71
  }
65
72
  else if (taskId == null) {
66
- fetchStatus = (0, reduceFetchState_1.reduceFetchState)([userList, classListState]);
73
+ fetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)([userList, classListState]);
67
74
  }
68
75
  const { classIds } = classListState;
69
76
  const allAccountingClasses = (0, classSelector_1.getClassesByIds)(classState, {
@@ -96,6 +103,7 @@ const getTaskDetail = (state, taskId) => {
96
103
  showTaskDetailFormFooter,
97
104
  snoozedUntil,
98
105
  taskGroupId,
106
+ subtasks,
99
107
  };
100
108
  };
101
109
  exports.getTaskDetail = getTaskDetail;
@@ -144,13 +152,16 @@ exports.allTaskPriority = [
144
152
  },
145
153
  ];
146
154
  const showFormFooter = (taskDetailLocalData, taskDetailInStore) => {
147
- if (taskDetailLocalData.name !== taskDetailInStore?.name ||
155
+ if (taskDetailInStore == null) {
156
+ return false;
157
+ }
158
+ if (taskDetailLocalData.name !== taskDetailInStore.name ||
148
159
  taskDetailLocalData.description !== taskDetailInStore.description ||
149
160
  taskDetailLocalData.priority !== taskDetailInStore.priority.code ||
150
161
  taskDetailLocalData.status !== taskDetailInStore.status.code ||
151
162
  !(0, isEqual_1.default)(taskDetailInStore.tagIds, taskDetailLocalData.tagIds) ||
152
- !(0, isEqual_1.default)(taskDetailLocalData.assignee, taskDetailInStore?.assignees ?? []) ||
153
- !(0, isEqual_1.default)(taskDetailLocalData.groupAssignees, taskDetailInStore?.groupAssignees ?? []) ||
163
+ !(0, isEqual_1.default)(taskDetailLocalData.assignee, taskDetailInStore.assignees ?? []) ||
164
+ !(0, isEqual_1.default)(taskDetailLocalData.groupAssignees, taskDetailInStore.groupAssignees ?? []) ||
154
165
  !(0, isEqual_1.default)(taskDetailLocalData.fileIds, taskDetailInStore.fileIds ?? []) ||
155
166
  !(0, isEqual_1.default)(taskDetailLocalData.dueDate, taskDetailInStore.dueDate) ||
156
167
  !(0, isEqual_1.default)(taskDetailLocalData.type, taskDetailInStore.type) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.3-betaAS1",
3
+ "version": "5.1.3-betaJK1",
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",
@@ -1,146 +0,0 @@
1
- import { InternationalWireVerificationBooleanWithSubfieldsFieldNames, InternationalWireVerificationFormFieldNames, } from './internationalWireVerificationFieldConstants';
2
- import { appendIntlWireFileOptionsToLocalData, appendIntlWirePersonToLocalData, isIntlWireFileOptionLike, isIntlWirePersonLike, toIntlWireFileOptionArray, } from './internationalWireVerificationLocalDataHelpers';
3
- const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
4
- InternationalWireVerificationFormFieldNames.businessOwnership,
5
- InternationalWireVerificationFormFieldNames.companyProofOfAddress,
6
- InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
7
- ]);
8
- const toValuesArray = (values) => {
9
- if (values == null) {
10
- return [];
11
- }
12
- if (Array.isArray(values)) {
13
- return values;
14
- }
15
- return [values];
16
- };
17
- const getCodeFromValue = (value) => {
18
- if (typeof value === 'string') {
19
- return value;
20
- }
21
- if (typeof value === 'object' &&
22
- value != null &&
23
- 'code' in value &&
24
- typeof value.code === 'string') {
25
- return value.code;
26
- }
27
- return '';
28
- };
29
- const setEmptyFieldDefault = (localData, fieldKey, fieldPayload) => {
30
- if (fieldPayload.type === 'enum') {
31
- localData[fieldKey] =
32
- fieldPayload.is_multiple_values_allowed === true ? [] : '';
33
- return;
34
- }
35
- if (fieldPayload.type === 'boolean_with_subfields') {
36
- if (fieldKey ===
37
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
38
- localData[fieldKey] = 'false';
39
- return;
40
- }
41
- if (fieldKey ===
42
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
43
- localData[fieldKey] = fieldPayload.default === true ? 'true' : 'false';
44
- }
45
- }
46
- };
47
- const parseEnumValues = (localData, fieldKey, fieldPayload, values) => {
48
- if (fieldPayload.is_multiple_values_allowed === true) {
49
- localData[fieldKey] = values
50
- .map(getCodeFromValue)
51
- .filter((code) => code.length > 0);
52
- return;
53
- }
54
- localData[fieldKey] = getCodeFromValue(values[0]);
55
- };
56
- const parseFileValues = (localData, fieldKey, fieldPayload, values) => {
57
- if (values.length > 0 &&
58
- (isIntlWireFileOptionLike(values[0]) ||
59
- MULTI_OPTION_FILE_FIELD_NAMES.has(fieldKey))) {
60
- const fileOptions = toIntlWireFileOptionArray(values);
61
- if (fileOptions.length > 0) {
62
- appendIntlWireFileOptionsToLocalData(localData, fieldKey, fileOptions);
63
- }
64
- return;
65
- }
66
- const fileIds = values.filter((value) => typeof value === 'string' && value.length > 0);
67
- if (fieldPayload.is_multiple_values_allowed === true) {
68
- localData[fieldKey] = fileIds;
69
- return;
70
- }
71
- localData[fieldKey] = fileIds[0] ?? '';
72
- };
73
- const parseBooleanWithSubfieldsValues = (localData, fieldKey, fieldPayload, rawValues) => {
74
- if (fieldKey ===
75
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
76
- if (isIntlWirePersonLike(rawValues)) {
77
- localData[fieldKey] = 'false';
78
- appendIntlWirePersonToLocalData(localData, fieldKey, rawValues);
79
- return;
80
- }
81
- const values = toValuesArray(rawValues);
82
- if (values.length > 0 && isIntlWirePersonLike(values[0])) {
83
- localData[fieldKey] = 'false';
84
- appendIntlWirePersonToLocalData(localData, fieldKey, values[0]);
85
- return;
86
- }
87
- const selection = getCodeFromValue(values[0]);
88
- localData[fieldKey] =
89
- selection.length > 0
90
- ? selection
91
- : fieldPayload.default === true
92
- ? 'true'
93
- : 'false';
94
- return;
95
- }
96
- if (fieldKey ===
97
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
98
- const values = toValuesArray(rawValues);
99
- if (values.length > 0 && isIntlWirePersonLike(values[0])) {
100
- localData[fieldKey] = 'true';
101
- values.forEach((person, ownerIndex) => {
102
- if (isIntlWirePersonLike(person)) {
103
- appendIntlWirePersonToLocalData(localData, `${fieldKey}_${ownerIndex}`, person);
104
- }
105
- });
106
- return;
107
- }
108
- const selection = getCodeFromValue(values[0]);
109
- localData[fieldKey] = selection.length > 0 ? selection : 'false';
110
- }
111
- };
112
- export const toVerificationFormLocalDataFromOnboardingDetails = (onboardingDetails, internationalWireFormPayload) => {
113
- const localData = {};
114
- Object.keys(internationalWireFormPayload).forEach((fieldKey) => {
115
- const fieldPayload = internationalWireFormPayload[fieldKey];
116
- const rawValues = onboardingDetails?.[fieldKey]?.values;
117
- if (rawValues == null) {
118
- setEmptyFieldDefault(localData, fieldKey, fieldPayload);
119
- return;
120
- }
121
- if (fieldPayload.type === 'boolean_with_subfields') {
122
- parseBooleanWithSubfieldsValues(localData, fieldKey, fieldPayload, rawValues);
123
- return;
124
- }
125
- const values = toValuesArray(rawValues);
126
- if (values.length === 0) {
127
- setEmptyFieldDefault(localData, fieldKey, fieldPayload);
128
- return;
129
- }
130
- switch (fieldPayload.type) {
131
- case 'enum':
132
- parseEnumValues(localData, fieldKey, fieldPayload, values);
133
- break;
134
- case 'file':
135
- parseFileValues(localData, fieldKey, fieldPayload, values);
136
- break;
137
- case 'date':
138
- localData[fieldKey] = getCodeFromValue(values[0]);
139
- break;
140
- default:
141
- localData[fieldKey] = getCodeFromValue(values[0]);
142
- break;
143
- }
144
- });
145
- return localData;
146
- };
@@ -1,40 +0,0 @@
1
- export const InternationalWireVerificationFormFieldNames = {
2
- certificateOfGoodStanding: 'certificate_of_good_standing',
3
- businessOwnership: 'business_ownership',
4
- companyProofOfAddress: 'company_proof_of_address',
5
- companyOfficerProofOfAddress: 'company_officer_proof_of_address',
6
- companyRegistrationDate: 'company_registration_date',
7
- annualTurnover: 'annual_turnover',
8
- expectedTransactionVolume: 'expected_transaction_volume',
9
- employeeCount: 'employee_count',
10
- intendedUseOfAccount: 'intended_use_of_account',
11
- transactionCountries: 'transaction_countries',
12
- stakeHolder: 'stake_holder',
13
- controllingPerson: 'controlling_person',
14
- };
15
- export const InternationalWireVerificationStakeHolderFieldName = InternationalWireVerificationFormFieldNames.stakeHolder;
16
- export const InternationalWireVerificationControllingPersonFieldName = InternationalWireVerificationFormFieldNames.controllingPerson;
17
- export const InternationalWireVerificationBooleanWithSubfieldsFieldNames = {
18
- stakeHolder: InternationalWireVerificationStakeHolderFieldName,
19
- controllingPerson: InternationalWireVerificationControllingPersonFieldName,
20
- };
21
- export const InternationalWireVerificationBooleanWithSubfieldsFieldNameList = Object.values(InternationalWireVerificationBooleanWithSubfieldsFieldNames);
22
- export const InternationalWireVerificationSubfieldNames = {
23
- companyRole: 'company_role',
24
- dateOfBirth: 'date_of_birth',
25
- name: 'name',
26
- email: 'email',
27
- nationality: 'nationality',
28
- ownershipPercentage: 'ownership_percentage',
29
- proofOfIdentity: 'proof_of_identity',
30
- proofOfAddress: 'proof_of_address',
31
- ssn: 'ssn',
32
- };
33
- export const InternationalWireVerificationReadonlyHideableFieldNames = [
34
- InternationalWireVerificationFormFieldNames.stakeHolder,
35
- InternationalWireVerificationFormFieldNames.controllingPerson,
36
- InternationalWireVerificationFormFieldNames.businessOwnership,
37
- InternationalWireVerificationFormFieldNames.companyProofOfAddress,
38
- InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
39
- ];
40
- export const InternationalWireVerificationReadonlyVisibilityGateFieldName = InternationalWireVerificationFormFieldNames.businessOwnership;
@@ -1,86 +0,0 @@
1
- import { InternationalWireVerificationFormFieldNames, InternationalWireVerificationSubfieldNames, } from './internationalWireVerificationFieldConstants';
2
- import { IntlWireVerificationLocalDataSuffix } from './internationalWireVerificationSubmitPayload';
3
- export const isIntlWireFileOptionLike = (value) => typeof value === 'object' &&
4
- value != null &&
5
- 'file_id' in value &&
6
- typeof value.file_id === 'string';
7
- export const isIntlWirePersonLike = (value) => {
8
- if (typeof value !== 'object' || value == null || Array.isArray(value)) {
9
- return false;
10
- }
11
- const person = value;
12
- return (person.name != null ||
13
- person.email != null ||
14
- person.nationality != null ||
15
- person.company_role != null ||
16
- person.ssn != null ||
17
- person.date_of_birth != null ||
18
- person.ownership_percentage != null ||
19
- person.proof_of_identity != null ||
20
- person.proof_of_address != null);
21
- };
22
- export const toIntlWireFileOptionArray = (items) => items.filter(isIntlWireFileOptionLike);
23
- export const appendIntlWireFileOptionsToLocalData = (localData, baseKey, fileOptions) => {
24
- const [front, back] = fileOptions;
25
- if (front?.file_id != null && front.file_id !== '') {
26
- localData[baseKey] = front.file_id;
27
- if (front.option != null && front.option !== '') {
28
- localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`] = front.option;
29
- }
30
- }
31
- if (back?.file_id != null && back.file_id !== '') {
32
- localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`] =
33
- back.file_id;
34
- }
35
- };
36
- export const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) => {
37
- const nameBaseKey = `${keyPrefix}_${InternationalWireVerificationSubfieldNames.name}`;
38
- if (person.name?.first_name != null) {
39
- localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameFirst}`] = person.name.first_name;
40
- }
41
- if (person.name?.last_name != null) {
42
- localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameLast}`] = person.name.last_name;
43
- }
44
- const assignStringField = (subfieldName, fieldValue) => {
45
- if (fieldValue != null && fieldValue !== '') {
46
- localData[`${keyPrefix}_${subfieldName}`] = fieldValue;
47
- }
48
- };
49
- assignStringField(InternationalWireVerificationSubfieldNames.nationality, person.nationality);
50
- assignStringField(InternationalWireVerificationSubfieldNames.email, person.email);
51
- assignStringField(InternationalWireVerificationSubfieldNames.companyRole, person.company_role);
52
- assignStringField(InternationalWireVerificationSubfieldNames.ssn, person.ssn);
53
- assignStringField(InternationalWireVerificationSubfieldNames.dateOfBirth, person.date_of_birth);
54
- if (person.ownership_percentage != null) {
55
- localData[`${keyPrefix}_${InternationalWireVerificationSubfieldNames.ownershipPercentage}`] = person.ownership_percentage;
56
- }
57
- if (person.proof_of_identity != null) {
58
- appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfIdentity}`, toIntlWireFileOptionArray(person.proof_of_identity));
59
- }
60
- if (person.proof_of_address != null) {
61
- appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfAddress}`, toIntlWireFileOptionArray(person.proof_of_address));
62
- }
63
- };
64
- export const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
65
- const indices = new Set();
66
- Object.keys(localData).forEach((key) => {
67
- const match = key.match(/^stake_holder_(\d+)_/);
68
- if (match != null) {
69
- indices.add(Number.parseInt(match[1], 10));
70
- }
71
- });
72
- return Array.from(indices).sort((a, b) => a - b);
73
- };
74
- export const hasBusinessOwnershipValueInLocalData = (localData) => {
75
- const baseKey = InternationalWireVerificationFormFieldNames.businessOwnership;
76
- const frontFileId = localData[baseKey];
77
- if (typeof frontFileId === 'string' && frontFileId !== '') {
78
- return true;
79
- }
80
- const backFileId = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`];
81
- if (typeof backFileId === 'string' && backFileId !== '') {
82
- return true;
83
- }
84
- const documentOption = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`];
85
- return typeof documentOption === 'string' && documentOption !== '';
86
- };
@@ -1,154 +0,0 @@
1
- import { InternationalWireVerificationBooleanWithSubfieldsFieldNames, InternationalWireVerificationFormFieldNames, InternationalWireVerificationSubfieldNames, } from './internationalWireVerificationFieldConstants';
2
- export const IntlWireVerificationLocalDataSuffix = {
3
- documentOption: '_option',
4
- documentBack: '_back',
5
- nameFirst: '_first_name',
6
- nameLast: '_last_name',
7
- };
8
- const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
9
- InternationalWireVerificationFormFieldNames.businessOwnership,
10
- InternationalWireVerificationFormFieldNames.companyProofOfAddress,
11
- InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
12
- ]);
13
- const BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES = new Set([
14
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder,
15
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson,
16
- ]);
17
- const FILE_SUBFIELD_NAMES = new Set([
18
- InternationalWireVerificationSubfieldNames.proofOfIdentity,
19
- InternationalWireVerificationSubfieldNames.proofOfAddress,
20
- ]);
21
- const isInternalLocalDataKey = (key) => key.endsWith(IntlWireVerificationLocalDataSuffix.documentOption) ||
22
- key.endsWith(IntlWireVerificationLocalDataSuffix.documentBack) ||
23
- key.endsWith(IntlWireVerificationLocalDataSuffix.nameFirst) ||
24
- key.endsWith(IntlWireVerificationLocalDataSuffix.nameLast);
25
- const isPersonSubfieldKey = (key) => key.startsWith(`${InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`) ||
26
- key.startsWith(`${InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`);
27
- const toFileOptionPayloads = (localData, baseKey) => {
28
- const option = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`];
29
- if (typeof option !== 'string' || option.length === 0) {
30
- return undefined;
31
- }
32
- const payloads = [];
33
- const frontFileId = localData[baseKey];
34
- if (typeof frontFileId === 'string' && frontFileId.length > 0) {
35
- payloads.push({ file_id: frontFileId, option });
36
- }
37
- const backFileId = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`];
38
- if (typeof backFileId === 'string' && backFileId.length > 0) {
39
- payloads.push({ file_id: backFileId, option });
40
- }
41
- return payloads.length > 0 ? payloads : undefined;
42
- };
43
- const buildPersonPayload = (localData, keyPrefix) => {
44
- const person = {};
45
- const nameBaseKey = `${keyPrefix}_${InternationalWireVerificationSubfieldNames.name}`;
46
- const firstName = localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameFirst}`];
47
- const lastName = localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameLast}`];
48
- if (typeof firstName === 'string' || typeof lastName === 'string') {
49
- person.name = {
50
- first_name: typeof firstName === 'string' ? firstName : '',
51
- last_name: typeof lastName === 'string' ? lastName : '',
52
- };
53
- }
54
- const assignStringField = (subfieldName, assign) => {
55
- const value = localData[`${keyPrefix}_${subfieldName}`];
56
- if (typeof value === 'string' && value.length > 0) {
57
- assign(value);
58
- }
59
- };
60
- assignStringField(InternationalWireVerificationSubfieldNames.nationality, (value) => {
61
- person.nationality = value;
62
- });
63
- assignStringField(InternationalWireVerificationSubfieldNames.email, (value) => {
64
- person.email = value;
65
- });
66
- assignStringField(InternationalWireVerificationSubfieldNames.companyRole, (value) => {
67
- person.company_role = value;
68
- });
69
- assignStringField(InternationalWireVerificationSubfieldNames.ssn, (value) => {
70
- person.ssn = value;
71
- });
72
- assignStringField(InternationalWireVerificationSubfieldNames.dateOfBirth, (value) => {
73
- person.date_of_birth = value;
74
- });
75
- const ownershipValue = localData[`${keyPrefix}_${InternationalWireVerificationSubfieldNames.ownershipPercentage}`];
76
- if (ownershipValue != null && ownershipValue !== '') {
77
- person.ownership_percentage = Number(ownershipValue);
78
- }
79
- FILE_SUBFIELD_NAMES.forEach((subfieldName) => {
80
- const filePayloads = toFileOptionPayloads(localData, `${keyPrefix}_${subfieldName}`);
81
- if (filePayloads != null) {
82
- if (subfieldName ===
83
- InternationalWireVerificationSubfieldNames.proofOfIdentity) {
84
- person.proof_of_identity = filePayloads;
85
- }
86
- else {
87
- person.proof_of_address = filePayloads;
88
- }
89
- }
90
- });
91
- return person;
92
- };
93
- const getStakeHolderOwnerIndices = (localData) => {
94
- const stakeHolderPrefix = `${InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`;
95
- const indices = new Set();
96
- Object.keys(localData).forEach((key) => {
97
- const match = key.match(/^stake_holder_(\d+)_/);
98
- if (match != null) {
99
- indices.add(Number.parseInt(match[1], 10));
100
- }
101
- });
102
- if (indices.size === 0) {
103
- const hasUnindexedStakeHolderData = Object.keys(localData).some((key) => key.startsWith(stakeHolderPrefix) &&
104
- !/^stake_holder_(true|false)$/.test(key));
105
- if (hasUnindexedStakeHolderData) {
106
- indices.add(0);
107
- }
108
- }
109
- return Array.from(indices).sort((a, b) => a - b);
110
- };
111
- const hasPersonPayloadData = (person) => Object.keys(person).length > 0;
112
- export const toIntlWireVerificationFormDetails = (localData) => {
113
- const formDetails = {};
114
- Object.entries(localData).forEach(([key, value]) => {
115
- if (BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES.has(key) ||
116
- isInternalLocalDataKey(key) ||
117
- isPersonSubfieldKey(key)) {
118
- return;
119
- }
120
- if (MULTI_OPTION_FILE_FIELD_NAMES.has(key)) {
121
- const filePayloads = toFileOptionPayloads(localData, key);
122
- if (filePayloads != null) {
123
- formDetails[key] = filePayloads;
124
- }
125
- return;
126
- }
127
- if (value == null || value === '') {
128
- return;
129
- }
130
- formDetails[key] = value;
131
- });
132
- const stakeHolderSelection = localData[InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder];
133
- if (stakeHolderSelection === 'true') {
134
- formDetails[InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = getStakeHolderOwnerIndices(localData)
135
- .map((ownerIndex) => buildPersonPayload(localData, `${InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_${ownerIndex}`))
136
- .filter(hasPersonPayloadData);
137
- }
138
- else if (stakeHolderSelection === 'false') {
139
- formDetails[InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = [];
140
- }
141
- const controllingPersonSelection = localData[InternationalWireVerificationBooleanWithSubfieldsFieldNames
142
- .controllingPerson];
143
- if (controllingPersonSelection === 'false') {
144
- const controllingPerson = buildPersonPayload(localData, InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson);
145
- if (hasPersonPayloadData(controllingPerson)) {
146
- formDetails[InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson] = controllingPerson;
147
- }
148
- }
149
- return formDetails;
150
- };
151
- export const toIntlWireVerificationSubmitPayload = (localData) => ({
152
- is_applicant_declaration: true,
153
- form_details: toIntlWireVerificationFormDetails(localData),
154
- });
@@ -1,4 +0,0 @@
1
- import { LabelValueCodesPayload } from '../../../../commonPayloadTypes/commonPayload';
2
- import { FieldPayload } from './internationalWireVerificationPayload';
3
- import { VerificationFormLocalData } from './internationalWireVerificationState';
4
- export declare const toVerificationFormLocalDataFromOnboardingDetails: (onboardingDetails: Record<string, LabelValueCodesPayload> | undefined, internationalWireFormPayload: Record<string, FieldPayload>) => VerificationFormLocalData;
@@ -1,150 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toVerificationFormLocalDataFromOnboardingDetails = void 0;
4
- const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
5
- const internationalWireVerificationLocalDataHelpers_1 = require("./internationalWireVerificationLocalDataHelpers");
6
- const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
7
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.businessOwnership,
8
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyProofOfAddress,
9
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
10
- ]);
11
- const toValuesArray = (values) => {
12
- if (values == null) {
13
- return [];
14
- }
15
- if (Array.isArray(values)) {
16
- return values;
17
- }
18
- return [values];
19
- };
20
- const getCodeFromValue = (value) => {
21
- if (typeof value === 'string') {
22
- return value;
23
- }
24
- if (typeof value === 'object' &&
25
- value != null &&
26
- 'code' in value &&
27
- typeof value.code === 'string') {
28
- return value.code;
29
- }
30
- return '';
31
- };
32
- const setEmptyFieldDefault = (localData, fieldKey, fieldPayload) => {
33
- if (fieldPayload.type === 'enum') {
34
- localData[fieldKey] =
35
- fieldPayload.is_multiple_values_allowed === true ? [] : '';
36
- return;
37
- }
38
- if (fieldPayload.type === 'boolean_with_subfields') {
39
- if (fieldKey ===
40
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
41
- localData[fieldKey] = 'false';
42
- return;
43
- }
44
- if (fieldKey ===
45
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
46
- localData[fieldKey] = fieldPayload.default === true ? 'true' : 'false';
47
- }
48
- }
49
- };
50
- const parseEnumValues = (localData, fieldKey, fieldPayload, values) => {
51
- if (fieldPayload.is_multiple_values_allowed === true) {
52
- localData[fieldKey] = values
53
- .map(getCodeFromValue)
54
- .filter((code) => code.length > 0);
55
- return;
56
- }
57
- localData[fieldKey] = getCodeFromValue(values[0]);
58
- };
59
- const parseFileValues = (localData, fieldKey, fieldPayload, values) => {
60
- if (values.length > 0 &&
61
- ((0, internationalWireVerificationLocalDataHelpers_1.isIntlWireFileOptionLike)(values[0]) ||
62
- MULTI_OPTION_FILE_FIELD_NAMES.has(fieldKey))) {
63
- const fileOptions = (0, internationalWireVerificationLocalDataHelpers_1.toIntlWireFileOptionArray)(values);
64
- if (fileOptions.length > 0) {
65
- (0, internationalWireVerificationLocalDataHelpers_1.appendIntlWireFileOptionsToLocalData)(localData, fieldKey, fileOptions);
66
- }
67
- return;
68
- }
69
- const fileIds = values.filter((value) => typeof value === 'string' && value.length > 0);
70
- if (fieldPayload.is_multiple_values_allowed === true) {
71
- localData[fieldKey] = fileIds;
72
- return;
73
- }
74
- localData[fieldKey] = fileIds[0] ?? '';
75
- };
76
- const parseBooleanWithSubfieldsValues = (localData, fieldKey, fieldPayload, rawValues) => {
77
- if (fieldKey ===
78
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
79
- if ((0, internationalWireVerificationLocalDataHelpers_1.isIntlWirePersonLike)(rawValues)) {
80
- localData[fieldKey] = 'false';
81
- (0, internationalWireVerificationLocalDataHelpers_1.appendIntlWirePersonToLocalData)(localData, fieldKey, rawValues);
82
- return;
83
- }
84
- const values = toValuesArray(rawValues);
85
- if (values.length > 0 && (0, internationalWireVerificationLocalDataHelpers_1.isIntlWirePersonLike)(values[0])) {
86
- localData[fieldKey] = 'false';
87
- (0, internationalWireVerificationLocalDataHelpers_1.appendIntlWirePersonToLocalData)(localData, fieldKey, values[0]);
88
- return;
89
- }
90
- const selection = getCodeFromValue(values[0]);
91
- localData[fieldKey] =
92
- selection.length > 0
93
- ? selection
94
- : fieldPayload.default === true
95
- ? 'true'
96
- : 'false';
97
- return;
98
- }
99
- if (fieldKey ===
100
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
101
- const values = toValuesArray(rawValues);
102
- if (values.length > 0 && (0, internationalWireVerificationLocalDataHelpers_1.isIntlWirePersonLike)(values[0])) {
103
- localData[fieldKey] = 'true';
104
- values.forEach((person, ownerIndex) => {
105
- if ((0, internationalWireVerificationLocalDataHelpers_1.isIntlWirePersonLike)(person)) {
106
- (0, internationalWireVerificationLocalDataHelpers_1.appendIntlWirePersonToLocalData)(localData, `${fieldKey}_${ownerIndex}`, person);
107
- }
108
- });
109
- return;
110
- }
111
- const selection = getCodeFromValue(values[0]);
112
- localData[fieldKey] = selection.length > 0 ? selection : 'false';
113
- }
114
- };
115
- const toVerificationFormLocalDataFromOnboardingDetails = (onboardingDetails, internationalWireFormPayload) => {
116
- const localData = {};
117
- Object.keys(internationalWireFormPayload).forEach((fieldKey) => {
118
- const fieldPayload = internationalWireFormPayload[fieldKey];
119
- const rawValues = onboardingDetails?.[fieldKey]?.values;
120
- if (rawValues == null) {
121
- setEmptyFieldDefault(localData, fieldKey, fieldPayload);
122
- return;
123
- }
124
- if (fieldPayload.type === 'boolean_with_subfields') {
125
- parseBooleanWithSubfieldsValues(localData, fieldKey, fieldPayload, rawValues);
126
- return;
127
- }
128
- const values = toValuesArray(rawValues);
129
- if (values.length === 0) {
130
- setEmptyFieldDefault(localData, fieldKey, fieldPayload);
131
- return;
132
- }
133
- switch (fieldPayload.type) {
134
- case 'enum':
135
- parseEnumValues(localData, fieldKey, fieldPayload, values);
136
- break;
137
- case 'file':
138
- parseFileValues(localData, fieldKey, fieldPayload, values);
139
- break;
140
- case 'date':
141
- localData[fieldKey] = getCodeFromValue(values[0]);
142
- break;
143
- default:
144
- localData[fieldKey] = getCodeFromValue(values[0]);
145
- break;
146
- }
147
- });
148
- return localData;
149
- };
150
- exports.toVerificationFormLocalDataFromOnboardingDetails = toVerificationFormLocalDataFromOnboardingDetails;