@zeniai/client-epic-state 5.1.68-beta0GS → 5.1.68-beta0RR

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 (60) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +25 -4
  2. package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
  3. package/lib/entity/tenant/clearAllEpic.js +0 -2
  4. package/lib/epic.d.ts +1 -3
  5. package/lib/epic.js +1 -3
  6. package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
  7. package/lib/esm/epic.js +1 -3
  8. package/lib/esm/index.js +8 -6
  9. package/lib/esm/reducer.js +0 -3
  10. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +7 -3
  11. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +56 -34
  12. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
  13. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +164 -0
  14. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +45 -0
  15. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +105 -0
  16. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +55 -8
  17. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +23 -7
  18. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
  19. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +189 -0
  20. package/lib/index.d.ts +10 -9
  21. package/lib/index.js +63 -53
  22. package/lib/reducer.d.ts +0 -3
  23. package/lib/reducer.js +0 -3
  24. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  25. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +6 -2
  26. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +2 -1
  27. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +55 -33
  28. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
  29. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +4 -0
  30. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +168 -0
  31. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +43 -0
  32. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +48 -0
  33. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +29 -0
  34. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +115 -0
  35. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +24 -1
  36. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +59 -9
  37. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +22 -6
  38. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
  39. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +20 -1
  40. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +32 -0
  41. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +194 -0
  42. package/package.json +1 -1
  43. package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +0 -21
  44. package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.js +0 -20
  45. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.js +0 -1
  46. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.js +0 -76
  47. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.js +0 -9
  48. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.js +0 -1
  49. package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.d.ts +0 -7
  50. package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +0 -25
  51. package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.d.ts +0 -6
  52. package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.js +0 -24
  53. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.d.ts +0 -29
  54. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.js +0 -2
  55. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.d.ts +0 -16
  56. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.js +0 -80
  57. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.d.ts +0 -12
  58. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.js +0 -12
  59. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.d.ts +0 -8
  60. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.js +0 -2
@@ -1,19 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toDynamicFormField = void 0;
3
+ exports.toVerificationFormFields = exports.sortVerificationFormFields = exports.filterVerificationFormFieldsForReadonlyView = exports.toDynamicFormField = exports.InternationalWireVerificationFormOrder = void 0;
4
+ const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
5
+ const internationalWireVerificationLocalDataHelpers_1 = require("./internationalWireVerificationLocalDataHelpers");
6
+ exports.InternationalWireVerificationFormOrder = [
7
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.certificateOfGoodStanding,
8
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.businessOwnership,
9
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyProofOfAddress,
10
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
11
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyRegistrationDate,
12
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.annualTurnover,
13
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.expectedTransactionVolume,
14
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.employeeCount,
15
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.intendedUseOfAccount,
16
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.transactionCountries,
17
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.stakeHolder,
18
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.controllingPerson,
19
+ ];
20
+ const orderIndex = new Map(exports.InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
21
+ const toFieldValues = (fieldValues) => fieldValues?.map(({ code, description }) => ({ code, description })) ?? [];
22
+ const toSubField = (subfield) => ({
23
+ label: subfield.label,
24
+ placeholder: subfield.field_hint_text ?? '',
25
+ type: subfield.type,
26
+ fieldValues: toFieldValues(subfield.field_values),
27
+ isMultipleOptionsSupported: subfield.is_multiple_options_supported,
28
+ options: subfield.options,
29
+ });
4
30
  const toDynamicFormField = (key, payload) => ({
5
31
  name: key,
6
32
  label: payload.label,
7
33
  placeholder: payload.field_hint_text ?? '',
8
34
  isMultipleValuesAllowed: payload.is_multiple_values_allowed ?? false,
9
35
  type: payload.type,
10
- fieldValues: payload.field_values != null && payload.field_values.length > 0
11
- ? payload.field_values.map((fieldValue) => {
12
- return {
13
- code: fieldValue.code,
14
- description: fieldValue.description,
15
- };
16
- })
17
- : [],
36
+ fieldValues: toFieldValues(payload.field_values),
37
+ isMultipleOptionsSupported: payload.is_multiple_options_supported,
38
+ options: payload.options,
39
+ requirements: payload.requirements,
40
+ default: payload.default,
41
+ subfields: payload.subfields != null
42
+ ? Object.fromEntries(Object.entries(payload.subfields).map(([subfieldKey, subfield]) => [
43
+ subfieldKey,
44
+ toSubField(subfield),
45
+ ]))
46
+ : undefined,
18
47
  });
19
48
  exports.toDynamicFormField = toDynamicFormField;
49
+ const readonlyHideableVerificationFormFieldNames = new Set(internationalWireVerificationFieldConstants_1.InternationalWireVerificationReadonlyHideableFieldNames);
50
+ const filterVerificationFormFieldsForReadonlyView = (fields, localData, isReadonly) => {
51
+ if (!isReadonly || (0, internationalWireVerificationLocalDataHelpers_1.hasBusinessOwnershipValueInLocalData)(localData)) {
52
+ return fields;
53
+ }
54
+ return fields.filter((field) => !readonlyHideableVerificationFormFieldNames.has(field.name));
55
+ };
56
+ exports.filterVerificationFormFieldsForReadonlyView = filterVerificationFormFieldsForReadonlyView;
57
+ const sortVerificationFormFields = (fields) => {
58
+ return fields.slice().sort((a, b) => {
59
+ const aIndex = orderIndex.get(a.name) ?? exports.InternationalWireVerificationFormOrder.length;
60
+ const bIndex = orderIndex.get(b.name) ?? exports.InternationalWireVerificationFormOrder.length;
61
+ if (aIndex !== bIndex) {
62
+ return aIndex - bIndex;
63
+ }
64
+ return a.name.localeCompare(b.name);
65
+ });
66
+ };
67
+ exports.sortVerificationFormFields = sortVerificationFormFields;
68
+ const toVerificationFormFields = (internationalWireFormPayload) => (0, exports.sortVerificationFormFields)(Object.keys(internationalWireFormPayload).map((key) => (0, exports.toDynamicFormField)(key, internationalWireFormPayload[key])));
69
+ exports.toVerificationFormFields = toVerificationFormFields;
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clearInternationalVerificationView = exports.initializeIntlVerificationForm = exports.updateVerificationFormSubmissionStatus = exports.submitInternationalVerificationForm = exports.updateVerificationFormLocalData = exports.updateVerificationFormFailure = exports.updateInternationalVerificationForm = exports.fetchInternationalVerificationForm = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const internationalWireVerificationPayload_1 = require("./internationalWireVerificationPayload");
7
+ const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
7
8
  exports.initialState = {
8
9
  verificationFormFetchState: {
9
10
  fetchState: 'Not-Started',
10
11
  },
12
+ verificationFormFieldLabels: {},
11
13
  verificationFormFields: [],
12
14
  verificationFormLocalData: {},
13
15
  verificationFormSubmitState: {
@@ -35,11 +37,8 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
35
37
  },
36
38
  updateInternationalVerificationForm(draft, action) {
37
39
  const { internationalWireFormPayload } = action.payload;
38
- const verificationFormFields = [];
39
- Object.keys(internationalWireFormPayload).forEach((key) => {
40
- verificationFormFields.push((0, internationalWireVerificationPayload_1.toDynamicFormField)(key, internationalWireFormPayload[key]));
41
- });
42
- draft.verificationFormFields = verificationFormFields;
40
+ draft.verificationFormFieldLabels = internationalWireFormPayload;
41
+ draft.verificationFormFields = (0, internationalWireVerificationPayload_1.toVerificationFormFields)(internationalWireFormPayload);
43
42
  draft.verificationFormFetchState.fetchState = 'Completed';
44
43
  },
45
44
  updateVerificationFormFailure(draft, action) {
@@ -48,9 +47,26 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
48
47
  draft.verificationFormFetchState.error = error;
49
48
  },
50
49
  updateVerificationFormLocalData(draft, action) {
51
- draft.verificationFormLocalData = {
50
+ const mergedLocalData = {
51
+ ...draft.verificationFormLocalData,
52
52
  ...action.payload,
53
53
  };
54
+ if (action.payload[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] === 'false') {
55
+ Object.keys(mergedLocalData).forEach((key) => {
56
+ if (key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`)) {
57
+ delete mergedLocalData[key];
58
+ }
59
+ });
60
+ }
61
+ if (action.payload[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames
62
+ .controllingPerson] === 'true') {
63
+ Object.keys(mergedLocalData).forEach((key) => {
64
+ if (key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`)) {
65
+ delete mergedLocalData[key];
66
+ }
67
+ });
68
+ }
69
+ draft.verificationFormLocalData = mergedLocalData;
54
70
  },
55
71
  submitInternationalVerificationForm: {
56
72
  reducer(draft) {
@@ -1,29 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIntlWireVerificationView = void 0;
4
+ const companySelector_1 = require("../../../../entity/company/companySelector");
4
5
  const fileSelector_1 = require("../../../../entity/file/fileSelector");
6
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
5
7
  const fileViewSelector_1 = require("../../../fileView/fileViewSelector");
8
+ const internationalWireVerificationPayload_1 = require("./internationalWireVerificationPayload");
9
+ const collectFileIdsFromLocalData = (localData) => {
10
+ const fileIds = new Set();
11
+ Object.values(localData).forEach((value) => {
12
+ if (typeof value === 'string' && value.startsWith('file_')) {
13
+ fileIds.add(value);
14
+ return;
15
+ }
16
+ if (Array.isArray(value)) {
17
+ value.forEach((item) => {
18
+ if (typeof item === 'string' && item.startsWith('file_')) {
19
+ fileIds.add(item);
20
+ }
21
+ });
22
+ }
23
+ });
24
+ return Array.from(fileIds);
25
+ };
6
26
  const getIntlWireVerificationView = (state) => {
7
27
  const deleteFileStatusById = {};
8
28
  const updateFileStatusById = {};
9
- // field with type = file
10
- const fileField = state.internationalWireVerificationState.verificationFormFields.find((field) => field.type === 'file');
11
- let fileId;
12
- if (fileField != null) {
13
- fileId = state.internationalWireVerificationState.verificationFormLocalData[fileField.name];
14
- }
15
- if (fileId != null) {
29
+ const { verificationFormFetchState, verificationFormFields, verificationFormLocalData, verificationFormSubmitState, } = state.internationalWireVerificationState;
30
+ const fileIds = collectFileIdsFromLocalData(verificationFormLocalData);
31
+ fileIds.forEach((fileId) => {
16
32
  deleteFileStatusById[fileId] = (0, fileViewSelector_1.getFileDeleteStatusById)(state, fileId);
17
33
  updateFileStatusById[fileId] = (0, fileViewSelector_1.getFileUpdateNameStatusById)(state, fileId);
18
- }
19
- let userFiles = [];
20
- if (fileId != null) {
21
- userFiles = (0, fileSelector_1.getFilesByFileIds)(state.fileState, [fileId]);
22
- }
23
- const fetchState = state.internationalWireVerificationState.verificationFormFetchState
24
- .fetchState;
34
+ });
35
+ const userFiles = fileIds.length > 0 ? (0, fileSelector_1.getFilesByFileIds)(state.fileState, fileIds) : [];
36
+ const fetchState = verificationFormFetchState.fetchState;
37
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
38
+ const company = currentTenant?.companyId != null
39
+ ? (0, companySelector_1.getCompanyByCompanyId)(state.companyState, currentTenant.companyId)
40
+ ?.company
41
+ : undefined;
42
+ const onboardingStatusCode = company?.companyBillPayInfo?.internationalWireOnboardingStatus?.code;
43
+ const isReadonly = onboardingStatusCode != null &&
44
+ onboardingStatusCode !== 'onboarding_status_not_started';
45
+ const visibleVerificationFormFields = (0, internationalWireVerificationPayload_1.filterVerificationFormFieldsForReadonlyView)(verificationFormFields, verificationFormLocalData, isReadonly);
25
46
  return {
26
- ...state.internationalWireVerificationState,
47
+ verificationFormFetchState,
48
+ verificationFormFields: visibleVerificationFormFields,
49
+ verificationFormLocalData,
50
+ verificationFormSubmitState,
27
51
  deleteFileStatusById,
28
52
  updateFileStatusById,
29
53
  userFiles,
@@ -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,194 @@
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, options) => {
31
+ const includeBack = options?.includeBack ?? true;
32
+ const option = localData[`${baseKey}${exports.IntlWireVerificationLocalDataSuffix.documentOption}`];
33
+ if (typeof option !== 'string' || option.length === 0) {
34
+ return undefined;
35
+ }
36
+ const payloads = [];
37
+ const frontFileId = localData[baseKey];
38
+ if (typeof frontFileId === 'string' && frontFileId.length > 0) {
39
+ payloads.push({ file_id: frontFileId, option });
40
+ }
41
+ if (includeBack) {
42
+ const backFileId = localData[`${baseKey}${exports.IntlWireVerificationLocalDataSuffix.documentBack}`];
43
+ if (typeof backFileId === 'string' && backFileId.length > 0) {
44
+ payloads.push({ file_id: backFileId, option });
45
+ }
46
+ }
47
+ return payloads.length > 0 ? payloads : undefined;
48
+ };
49
+ const buildPersonPayload = (localData, keyPrefix) => {
50
+ const person = {};
51
+ const nameBaseKey = `${keyPrefix}_${internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.name}`;
52
+ const firstName = localData[`${nameBaseKey}${exports.IntlWireVerificationLocalDataSuffix.nameFirst}`];
53
+ const lastName = localData[`${nameBaseKey}${exports.IntlWireVerificationLocalDataSuffix.nameLast}`];
54
+ if (typeof firstName === 'string' || typeof lastName === 'string') {
55
+ person.name = {
56
+ first_name: typeof firstName === 'string' ? firstName : '',
57
+ last_name: typeof lastName === 'string' ? lastName : '',
58
+ };
59
+ }
60
+ const assignStringField = (subfieldName, assign) => {
61
+ const value = localData[`${keyPrefix}_${subfieldName}`];
62
+ if (typeof value === 'string' && value.length > 0) {
63
+ assign(value);
64
+ }
65
+ };
66
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.nationality, (value) => {
67
+ person.nationality = value;
68
+ });
69
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.email, (value) => {
70
+ person.email = value;
71
+ });
72
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.companyRole, (value) => {
73
+ person.company_role = value;
74
+ });
75
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.ssn, (value) => {
76
+ person.ssn = value;
77
+ });
78
+ assignStringField(internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.dateOfBirth, (value) => {
79
+ person.date_of_birth = value;
80
+ });
81
+ const ownershipValue = localData[`${keyPrefix}_${internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.ownershipPercentage}`];
82
+ if (ownershipValue != null && ownershipValue !== '') {
83
+ const parsedOwnership = Number(ownershipValue);
84
+ if (!Number.isNaN(parsedOwnership)) {
85
+ person.ownership_percentage = parsedOwnership;
86
+ }
87
+ }
88
+ FILE_SUBFIELD_NAMES.forEach((subfieldName) => {
89
+ const filePayloads = toFileOptionPayloads(localData, `${keyPrefix}_${subfieldName}`);
90
+ if (filePayloads != null) {
91
+ if (subfieldName ===
92
+ internationalWireVerificationFieldConstants_1.InternationalWireVerificationSubfieldNames.proofOfIdentity) {
93
+ person.proof_of_identity = filePayloads;
94
+ }
95
+ else {
96
+ person.proof_of_address = filePayloads;
97
+ }
98
+ }
99
+ });
100
+ return person;
101
+ };
102
+ const getStakeHolderOwnerKeyPrefix = (localData, ownerIndex) => {
103
+ const indexedKeyPrefix = `${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_${ownerIndex}`;
104
+ if (ownerIndex !== 0) {
105
+ return indexedKeyPrefix;
106
+ }
107
+ const hasIndexedOwnerZeroData = Object.keys(localData).some((key) => key.startsWith(`${indexedKeyPrefix}_`));
108
+ if (hasIndexedOwnerZeroData) {
109
+ return indexedKeyPrefix;
110
+ }
111
+ return internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder;
112
+ };
113
+ const getStakeHolderOwnerIndices = (localData) => {
114
+ const stakeHolderPrefix = `${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`;
115
+ const stakeHolderIndexedPattern = new RegExp(`^${stakeHolderPrefix}(\\d+)_`);
116
+ const stakeHolderBooleanSelectionPattern = new RegExp(`^${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_(true|false)$`);
117
+ const indices = new Set();
118
+ Object.keys(localData).forEach((key) => {
119
+ const match = key.match(stakeHolderIndexedPattern);
120
+ if (match != null) {
121
+ indices.add(Number.parseInt(match[1], 10));
122
+ }
123
+ });
124
+ if (indices.size === 0) {
125
+ const hasUnindexedStakeHolderData = Object.keys(localData).some((key) => key.startsWith(stakeHolderPrefix) &&
126
+ !stakeHolderBooleanSelectionPattern.test(key));
127
+ if (hasUnindexedStakeHolderData) {
128
+ indices.add(0);
129
+ }
130
+ }
131
+ return Array.from(indices).sort((a, b) => a - b);
132
+ };
133
+ const hasPersonPayloadData = (person) => Object.keys(person).length > 0;
134
+ const toIntlWireVerificationFormDetails = (localData) => {
135
+ const formDetails = {};
136
+ Object.entries(localData).forEach(([key, value]) => {
137
+ if (BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES.has(key) ||
138
+ isInternalLocalDataKey(key) ||
139
+ isPersonSubfieldKey(key)) {
140
+ return;
141
+ }
142
+ if (MULTI_OPTION_FILE_FIELD_NAMES.has(key)) {
143
+ const filePayloads = toFileOptionPayloads(localData, key, {
144
+ includeBack: false,
145
+ });
146
+ if (filePayloads != null) {
147
+ formDetails[key] = filePayloads;
148
+ }
149
+ else if (Array.isArray(value)) {
150
+ const fileIds = value.filter((fileId) => typeof fileId === 'string' && fileId.length > 0);
151
+ if (fileIds.length > 0) {
152
+ formDetails[key] = fileIds;
153
+ }
154
+ }
155
+ else if (typeof value === 'string' && value.length > 0) {
156
+ // Backward compatibility: older onboarding records can store plain file ids
157
+ // without a paired `_option` key.
158
+ formDetails[key] = value;
159
+ }
160
+ return;
161
+ }
162
+ if (value == null || value === '') {
163
+ return;
164
+ }
165
+ formDetails[key] = value;
166
+ });
167
+ const stakeHolderSelection = localData[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder];
168
+ if (stakeHolderSelection === 'true') {
169
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = getStakeHolderOwnerIndices(localData)
170
+ .map((ownerIndex) => buildPersonPayload(localData, getStakeHolderOwnerKeyPrefix(localData, ownerIndex)))
171
+ .filter(hasPersonPayloadData);
172
+ }
173
+ else if (stakeHolderSelection === 'false') {
174
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = [];
175
+ }
176
+ const controllingPersonSelection = localData[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames
177
+ .controllingPerson];
178
+ if (controllingPersonSelection === 'false') {
179
+ const controllingPerson = buildPersonPayload(localData, internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson);
180
+ if (hasPersonPayloadData(controllingPerson)) {
181
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson] = controllingPerson;
182
+ }
183
+ }
184
+ else if (controllingPersonSelection === 'true') {
185
+ formDetails[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson] = 'true';
186
+ }
187
+ return formDetails;
188
+ };
189
+ exports.toIntlWireVerificationFormDetails = toIntlWireVerificationFormDetails;
190
+ const toIntlWireVerificationSubmitPayload = (localData) => ({
191
+ is_applicant_declaration: true,
192
+ form_details: (0, exports.toIntlWireVerificationFormDetails)(localData),
193
+ });
194
+ exports.toIntlWireVerificationSubmitPayload = toIntlWireVerificationSubmitPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.68-beta0GS",
3
+ "version": "5.1.68-beta0RR",
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,21 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
4
- import { fetchJEScheduleApprovalRules, fetchJEScheduleApprovalRulesFailure, fetchJEScheduleApprovalRulesSuccess, } from '../jeScheduleApprovalRulesReducer';
5
- export const fetchJEScheduleApprovalRulesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchJEScheduleApprovalRules.match), switchMap((action) => {
6
- const { cacheOverride } = action.payload;
7
- const { jeScheduleApprovalRulesState } = state$.value;
8
- const cachedSettings = jeScheduleApprovalRulesState.settings;
9
- if (cacheOverride !== true &&
10
- jeScheduleApprovalRulesState.hasValidState() === true &&
11
- cachedSettings != null) {
12
- return of(fetchJEScheduleApprovalRulesSuccess(cachedSettings));
13
- }
14
- const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/je-schedules/approval-rules`;
15
- return zeniAPI.getJSON(endpoint).pipe(mergeMap((response) => {
16
- if (isSuccessResponse(response) && response.data != null) {
17
- return of(fetchJEScheduleApprovalRulesSuccess(response.data.settings));
18
- }
19
- return of(fetchJEScheduleApprovalRulesFailure(response.status));
20
- }), catchError((error) => of(fetchJEScheduleApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Fetch JE approval rules errored out' + JSON.stringify(error))))));
21
- }));
@@ -1,20 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
4
- import { saveJEScheduleApprovalRules, saveJEScheduleApprovalRulesConflict, saveJEScheduleApprovalRulesFailure, saveJEScheduleApprovalRulesSuccess, } from '../jeScheduleApprovalRulesReducer';
5
- const HTTP_CONFLICT = 409;
6
- export const saveJEScheduleApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveJEScheduleApprovalRules.match), mergeMap((action) => {
7
- const { body } = action.payload;
8
- const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/je-schedules/approval-rules`;
9
- return zeniAPI
10
- .postAndGetJSON(endpoint, body)
11
- .pipe(mergeMap((response) => {
12
- if (isSuccessResponse(response) && response.data != null) {
13
- return of(saveJEScheduleApprovalRulesSuccess(response.data.settings, response.data.reevaluation_triggered));
14
- }
15
- if (response.status.code === HTTP_CONFLICT) {
16
- return of(saveJEScheduleApprovalRulesConflict(response.status));
17
- }
18
- return of(saveJEScheduleApprovalRulesFailure(response.status));
19
- }), catchError((error) => of(saveJEScheduleApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Save JE approval rules errored out' + JSON.stringify(error))))));
20
- }));
@@ -1,76 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- export const initialState = {
3
- fetchState: 'Not-Started',
4
- error: undefined,
5
- saveStatus: { fetchState: 'Not-Started', error: undefined },
6
- settings: undefined,
7
- hadVersionConflict: false,
8
- reevaluationTriggered: false,
9
- hasValidState() {
10
- return this.fetchState === 'Completed';
11
- },
12
- };
13
- const jeScheduleApprovalRules = createSlice({
14
- name: 'jeScheduleApprovalRules',
15
- initialState,
16
- reducers: {
17
- fetchJEScheduleApprovalRules: {
18
- reducer(draft) {
19
- draft.fetchState = 'In-Progress';
20
- draft.error = undefined;
21
- },
22
- prepare(cacheOverride = false) {
23
- return { payload: { cacheOverride } };
24
- },
25
- },
26
- fetchJEScheduleApprovalRulesSuccess: {
27
- reducer(draft, action) {
28
- draft.fetchState = 'Completed';
29
- draft.error = undefined;
30
- draft.settings = action.payload.settings;
31
- },
32
- prepare(settings) {
33
- return { payload: { settings } };
34
- },
35
- },
36
- fetchJEScheduleApprovalRulesFailure(draft, action) {
37
- draft.fetchState = 'Error';
38
- draft.error = action.payload;
39
- },
40
- saveJEScheduleApprovalRules: {
41
- reducer(draft) {
42
- draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
43
- draft.hadVersionConflict = false;
44
- draft.reevaluationTriggered = false;
45
- },
46
- prepare(body) {
47
- return { payload: { body } };
48
- },
49
- },
50
- saveJEScheduleApprovalRulesSuccess: {
51
- reducer(draft, action) {
52
- draft.saveStatus = { fetchState: 'Completed', error: undefined };
53
- draft.settings = action.payload.settings;
54
- draft.reevaluationTriggered = action.payload.reevaluationTriggered;
55
- draft.hadVersionConflict = false;
56
- },
57
- prepare(settings, reevaluationTriggered) {
58
- return { payload: { settings, reevaluationTriggered } };
59
- },
60
- },
61
- // 409 — the stored version moved under us. The screen should re-fetch and
62
- // ask the user to re-apply. Kept distinct from a generic save failure.
63
- saveJEScheduleApprovalRulesConflict(draft, action) {
64
- draft.saveStatus = { fetchState: 'Error', error: action.payload };
65
- draft.hadVersionConflict = true;
66
- },
67
- saveJEScheduleApprovalRulesFailure(draft, action) {
68
- draft.saveStatus = { fetchState: 'Error', error: action.payload };
69
- },
70
- clearJEScheduleApprovalRules() {
71
- return initialState;
72
- },
73
- },
74
- });
75
- export const { fetchJEScheduleApprovalRules, fetchJEScheduleApprovalRulesSuccess, fetchJEScheduleApprovalRulesFailure, saveJEScheduleApprovalRules, saveJEScheduleApprovalRulesSuccess, saveJEScheduleApprovalRulesConflict, saveJEScheduleApprovalRulesFailure, clearJEScheduleApprovalRules, } = jeScheduleApprovalRules.actions;
76
- export default jeScheduleApprovalRules.reducer;
@@ -1,9 +0,0 @@
1
- import { createSelector } from '@reduxjs/toolkit';
2
- export const getJEScheduleApprovalRulesView = createSelector((state) => state.jeScheduleApprovalRulesState, (jeScheduleApprovalRulesState) => ({
3
- fetchState: jeScheduleApprovalRulesState.fetchState,
4
- error: jeScheduleApprovalRulesState.error,
5
- saveStatus: jeScheduleApprovalRulesState.saveStatus,
6
- settings: jeScheduleApprovalRulesState.settings,
7
- hadVersionConflict: jeScheduleApprovalRulesState.hadVersionConflict ?? false,
8
- reevaluationTriggered: jeScheduleApprovalRulesState.reevaluationTriggered ?? false,
9
- }));
@@ -1,7 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../../../reducer';
4
- import { ZeniAPI } from '../../../../zeniAPI';
5
- import { fetchJEScheduleApprovalRules, fetchJEScheduleApprovalRulesFailure, fetchJEScheduleApprovalRulesSuccess } from '../jeScheduleApprovalRulesReducer';
6
- export type ActionType = ReturnType<typeof fetchJEScheduleApprovalRules> | ReturnType<typeof fetchJEScheduleApprovalRulesSuccess> | ReturnType<typeof fetchJEScheduleApprovalRulesFailure>;
7
- export declare const fetchJEScheduleApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;