@zeniai/client-epic-state 5.0.84 → 5.0.85-beta1ND

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +1 -0
  3. package/lib/entity/company/companyPayload.d.ts +2 -0
  4. package/lib/entity/company/companyPayload.js +2 -0
  5. package/lib/entity/company/companyStateTypes.d.ts +2 -0
  6. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  7. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  8. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  9. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  10. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  11. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  12. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  13. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  14. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  15. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  16. package/lib/entity/tenant/tenantPayload.d.ts +19 -0
  17. package/lib/entity/tenant/tenantReducer.d.ts +49 -28
  18. package/lib/entity/tenant/tenantReducer.js +111 -5
  19. package/lib/entity/tenant/tenantState.d.ts +21 -0
  20. package/lib/epic.d.ts +8 -2
  21. package/lib/epic.js +9 -2
  22. package/lib/esm/commonStateTypes/animations.js +1 -0
  23. package/lib/esm/entity/company/companyPayload.js +2 -0
  24. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  25. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  26. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  27. package/lib/esm/entity/tenant/tenantReducer.js +108 -3
  28. package/lib/esm/epic.js +9 -2
  29. package/lib/esm/index.js +12 -9
  30. package/lib/esm/view/companyView/companyViewReducer.js +45 -1
  31. package/lib/esm/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +25 -0
  32. package/lib/esm/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +79 -0
  33. package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
  34. package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +7 -1
  35. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +45 -0
  36. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  37. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +202 -50
  38. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +17 -1
  39. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -0
  40. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +52 -0
  41. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +59 -0
  42. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
  43. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  44. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +105 -52
  45. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  46. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  47. package/lib/index.d.ts +15 -11
  48. package/lib/index.js +56 -34
  49. package/lib/view/companyView/companyViewReducer.d.ts +11 -1
  50. package/lib/view/companyView/companyViewReducer.js +47 -3
  51. package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.d.ts +9 -0
  52. package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +29 -0
  53. package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.d.ts +10 -0
  54. package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +83 -0
  55. package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +1 -0
  56. package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
  57. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +7 -1
  58. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  59. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  60. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +49 -0
  61. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  62. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  63. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  64. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +45 -4
  65. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +204 -51
  66. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +8 -1
  67. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +24 -2
  68. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +42 -0
  69. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +14 -1
  70. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
  71. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +56 -0
  72. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +30 -0
  73. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +63 -0
  74. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +33 -0
  75. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
  76. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  77. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  78. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
  79. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +106 -53
  80. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
  81. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  82. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
  83. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  84. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  85. package/package.json +1 -1
@@ -1,5 +1,7 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { date } from '../../../zeniDayJS';
3
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../spendManagement/commonSetup/kycKybAutofillActions';
4
+ import { emptyAiAgentsActivationSubview, } from './onboardingCustomerViewState';
3
5
  const initialStatus = {
4
6
  fetchState: 'Not-Started',
5
7
  error: undefined,
@@ -9,61 +11,31 @@ export const initialState = {
9
11
  saveStatus: initialStatus,
10
12
  dashboardLoadedStatus: initialStatus,
11
13
  currentStep: 'link_payment_account',
14
+ parsingDocumentFileIds: [],
12
15
  companyDetails: {
16
+ autoFilledFields: [],
13
17
  localData: undefined,
14
18
  },
15
- companyOfficerUpdateStatus: {
16
- Officer_1: {
19
+ companyOfficerUpdateStatus: (() => {
20
+ const emptyOfficerSlot = {
21
+ autoFilledFields: [],
17
22
  localData: undefined,
18
23
  sendOtpStatus: initialStatus,
19
24
  otpverificationStatus: initialStatus,
20
- },
21
- Officer_2: {
22
- localData: undefined,
23
- sendOtpStatus: initialStatus,
24
- otpverificationStatus: initialStatus,
25
- },
26
- Officer_3: {
27
- localData: undefined,
28
- sendOtpStatus: initialStatus,
29
- otpverificationStatus: initialStatus,
30
- },
31
- Officer_4: {
32
- localData: undefined,
33
- sendOtpStatus: initialStatus,
34
- otpverificationStatus: initialStatus,
35
- },
36
- Officer_5: {
37
- localData: undefined,
38
- sendOtpStatus: initialStatus,
39
- otpverificationStatus: initialStatus,
40
- },
41
- Officer_6: {
42
- localData: undefined,
43
- sendOtpStatus: initialStatus,
44
- otpverificationStatus: initialStatus,
45
- },
46
- Officer_7: {
47
- localData: undefined,
48
- sendOtpStatus: initialStatus,
49
- otpverificationStatus: initialStatus,
50
- },
51
- Officer_8: {
52
- localData: undefined,
53
- sendOtpStatus: initialStatus,
54
- otpverificationStatus: initialStatus,
55
- },
56
- Officer_9: {
57
- localData: undefined,
58
- sendOtpStatus: initialStatus,
59
- otpverificationStatus: initialStatus,
60
- },
61
- Officer_10: {
62
- localData: undefined,
63
- sendOtpStatus: initialStatus,
64
- otpverificationStatus: initialStatus,
65
- },
66
- },
25
+ };
26
+ return {
27
+ Officer_1: { ...emptyOfficerSlot },
28
+ Officer_2: { ...emptyOfficerSlot },
29
+ Officer_3: { ...emptyOfficerSlot },
30
+ Officer_4: { ...emptyOfficerSlot },
31
+ Officer_5: { ...emptyOfficerSlot },
32
+ Officer_6: { ...emptyOfficerSlot },
33
+ Officer_7: { ...emptyOfficerSlot },
34
+ Officer_8: { ...emptyOfficerSlot },
35
+ Officer_9: { ...emptyOfficerSlot },
36
+ Officer_10: { ...emptyOfficerSlot },
37
+ };
38
+ })(),
67
39
  primaryContactDetails: {},
68
40
  paymentAccountDetails: {
69
41
  fetchStatus: initialStatus,
@@ -91,6 +63,7 @@ export const initialState = {
91
63
  },
92
64
  fetchState: 'Not-Started',
93
65
  error: undefined,
66
+ aiAgentsActivation: { ...emptyAiAgentsActivationSubview },
94
67
  uiState: {
95
68
  isQBOPopupOpen: false,
96
69
  isCardPaymentPopupOpen: false,
@@ -180,6 +153,111 @@ const onboardingCustomerView = createSlice({
180
153
  };
181
154
  },
182
155
  },
156
+ acknowledgeOnboardingAiFinanceTeam: {
157
+ reducer(draft) {
158
+ draft.aiFinanceTeamAcknowledgementStatus = {
159
+ fetchState: 'In-Progress',
160
+ error: undefined,
161
+ };
162
+ },
163
+ prepare(companyId) {
164
+ return {
165
+ payload: { companyId },
166
+ };
167
+ },
168
+ },
169
+ acknowledgeOnboardingAiFinanceTeamSuccess(draft) {
170
+ draft.aiFinanceTeamAcknowledgementStatus = {
171
+ fetchState: 'Completed',
172
+ error: undefined,
173
+ };
174
+ },
175
+ acknowledgeOnboardingAiFinanceTeamFailure: {
176
+ reducer(draft, action) {
177
+ draft.aiFinanceTeamAcknowledgementStatus = {
178
+ fetchState: 'Error',
179
+ error: action.payload,
180
+ };
181
+ },
182
+ prepare(error) {
183
+ return {
184
+ payload: error,
185
+ };
186
+ },
187
+ },
188
+ fetchAiAgentsActivationStatus(draft) {
189
+ draft.aiAgentsActivation.fetchStatus = {
190
+ fetchState: 'In-Progress',
191
+ error: undefined,
192
+ };
193
+ },
194
+ fetchAiAgentsActivationStatusSuccess: {
195
+ reducer(draft, action) {
196
+ draft.aiAgentsActivation.fetchStatus = {
197
+ fetchState: 'Completed',
198
+ error: undefined,
199
+ };
200
+ draft.aiAgentsActivation.ledgerPhases = action.payload.ledgerPhases;
201
+ draft.aiAgentsActivation.backgroundPhases =
202
+ action.payload.backgroundPhases;
203
+ draft.aiAgentsActivation.counts = action.payload.counts;
204
+ },
205
+ prepare(payload) {
206
+ return { payload };
207
+ },
208
+ },
209
+ fetchAiAgentsActivationStatusFailure: {
210
+ reducer(draft, action) {
211
+ draft.aiAgentsActivation.fetchStatus = {
212
+ fetchState: 'Error',
213
+ error: action.payload,
214
+ };
215
+ },
216
+ prepare(error) {
217
+ return { payload: error };
218
+ },
219
+ },
220
+ aiAgentsActivationCountsUpdated: {
221
+ reducer(draft, action) {
222
+ draft.aiAgentsActivation.counts = {
223
+ ...draft.aiAgentsActivation.counts,
224
+ ...action.payload,
225
+ };
226
+ },
227
+ prepare(payload) {
228
+ return { payload };
229
+ },
230
+ },
231
+ aiAgentsActivationPhaseChanged: {
232
+ reducer(draft, action) {
233
+ const target = action.payload.section === 'ledger'
234
+ ? draft.aiAgentsActivation.ledgerPhases
235
+ : draft.aiAgentsActivation.backgroundPhases;
236
+ const index = target.findIndex((phase) => phase.key === action.payload.key);
237
+ if (index === -1) {
238
+ target.push(action.payload);
239
+ }
240
+ else {
241
+ target[index] = { ...target[index], ...action.payload };
242
+ }
243
+ },
244
+ prepare(payload) {
245
+ return { payload };
246
+ },
247
+ },
248
+ aiAgentsActivationSectionReady: {
249
+ reducer(draft, action) {
250
+ const target = action.payload.section === 'ledger'
251
+ ? draft.aiAgentsActivation.ledgerPhases
252
+ : draft.aiAgentsActivation.backgroundPhases;
253
+ target.forEach((phase) => {
254
+ phase.status = 'ready';
255
+ });
256
+ },
257
+ prepare(payload) {
258
+ return { payload };
259
+ },
260
+ },
183
261
  updateOnboardingCustomerViewDashboardLoaded: {
184
262
  reducer(draft) {
185
263
  draft.dashboardLoadedStatus = {
@@ -592,7 +670,81 @@ const onboardingCustomerView = createSlice({
592
670
  clearOnboardingCustomerView(draft) {
593
671
  Object.assign(draft, initialState);
594
672
  },
673
+ /** Merge AI-parsed officer fields into the officer's onboarding localData. */
674
+ applyKycDocumentAutofillForOnboarding: {
675
+ reducer(draft, action) {
676
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
677
+ const slot = draft.companyOfficerUpdateStatus[officerType];
678
+ slot.localData = Object.assign({}, slot.localData, values);
679
+ slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
680
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
681
+ },
682
+ prepare(payload) {
683
+ return { payload };
684
+ },
685
+ },
686
+ /** Merge AI-parsed company fields into companyDetails onboarding localData. */
687
+ applyKybDocumentAutofillForOnboarding: {
688
+ reducer(draft, action) {
689
+ const { values, autoFilledFieldNames, fileId } = action.payload;
690
+ draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
691
+ const prev = draft.companyDetails.autoFilledFields ?? [];
692
+ draft.companyDetails.autoFilledFields = Array.from(new Set([...prev, ...autoFilledFieldNames]));
693
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
694
+ },
695
+ prepare(payload) {
696
+ return { payload };
697
+ },
698
+ },
699
+ /** Wipe AI-autofill badges during onboarding. */
700
+ clearKycKybAutofillForOnboarding: {
701
+ reducer(draft, action) {
702
+ const { officerType } = action.payload;
703
+ if (officerType != null) {
704
+ draft.companyOfficerUpdateStatus[officerType].autoFilledFields = [];
705
+ }
706
+ else {
707
+ draft.companyDetails.autoFilledFields = [];
708
+ Object.keys(draft.companyOfficerUpdateStatus).forEach((key) => {
709
+ draft.companyOfficerUpdateStatus[key].autoFilledFields = [];
710
+ });
711
+ }
712
+ },
713
+ prepare(payload = {}) {
714
+ return { payload };
715
+ },
716
+ },
717
+ },
718
+ extraReducers: (builder) => {
719
+ const addParsingFileId = (draft, fileId) => {
720
+ if (!draft.parsingDocumentFileIds.includes(fileId)) {
721
+ draft.parsingDocumentFileIds.push(fileId);
722
+ }
723
+ };
724
+ const removeParsingFileId = (draft, fileId) => {
725
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
726
+ };
727
+ builder.addCase(parseUploadedKycDocument, (draft, action) => {
728
+ if (action.payload.target === 'onboarding') {
729
+ addParsingFileId(draft, action.payload.fileId);
730
+ }
731
+ });
732
+ builder.addCase(parseUploadedKybDocument, (draft, action) => {
733
+ if (action.payload.target === 'onboarding') {
734
+ addParsingFileId(draft, action.payload.fileId);
735
+ }
736
+ });
737
+ builder.addCase(parseUploadedKycDocumentFailure, (draft, action) => {
738
+ if (action.payload.target === 'onboarding') {
739
+ removeParsingFileId(draft, action.payload.fileId);
740
+ }
741
+ });
742
+ builder.addCase(parseUploadedKybDocumentFailure, (draft, action) => {
743
+ if (action.payload.target === 'onboarding') {
744
+ removeParsingFileId(draft, action.payload.fileId);
745
+ }
746
+ });
595
747
  },
596
748
  });
597
- export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, } = onboardingCustomerView.actions;
749
+ export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamSuccess, acknowledgeOnboardingAiFinanceTeamFailure, fetchAiAgentsActivationStatus, fetchAiAgentsActivationStatusSuccess, fetchAiAgentsActivationStatusFailure, aiAgentsActivationCountsUpdated, aiAgentsActivationPhaseChanged, aiAgentsActivationSectionReady, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, applyKycDocumentAutofillForOnboarding, applyKybDocumentAutofillForOnboarding, clearKycKybAutofillForOnboarding, } = onboardingCustomerView.actions;
598
750
  export default onboardingCustomerView.reducer;
@@ -11,7 +11,7 @@ import { getCompanyAndIdentityDetails, } from '../../spendManagement/commonSetup
11
11
  import { ALL_ONBOARDING_STEPS, ALL_ZENI_USER_ONBOARDING_STEPS, REQUIRED_ONBOARDING_STEPS, ZENI_USER_REQUIRED_ONBOARDING_STEPS, toOnboardingStepType, } from './onboardingCustomerViewState';
12
12
  export function getOnboardingCustomerView(state, companyId) {
13
13
  const { fileState, paymentAccountState, onboardingCustomerViewState, userState, userRoleState, subscriptionPaymentAccountState, companyConfigState, cardPaymentViewState, countryListState, addressViewState, } = state;
14
- const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
14
+ const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, parsingDocumentFileIds, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
15
15
  const { paymentAccountIds } = paymentAccountDetails;
16
16
  let subscriptionPaymentAccount;
17
17
  let paymentAccount;
@@ -54,6 +54,7 @@ export function getOnboardingCustomerView(state, companyId) {
54
54
  companyDetails,
55
55
  companyOfficerUpdateStatus,
56
56
  primaryContactDetails,
57
+ parsingDocumentFileIds,
57
58
  });
58
59
  const companyAddress = addressViewState.newAddressState?.company_address;
59
60
  if (companyAddress == null &&
@@ -119,6 +120,7 @@ export function getOnboardingCustomerView(state, companyId) {
119
120
  return {
120
121
  companyDetailsLocalData,
121
122
  companyOfficerLocalData,
123
+ parsingDocumentFileIds,
122
124
  subscriptionBillingAddress: subscriptionBillingAddress?.addressToCreate,
123
125
  companyView,
124
126
  allNationalityCountries,
@@ -323,3 +325,17 @@ export const getProductSettingsString = (productSettings) => {
323
325
  .map((key) => productKeyMap[key])
324
326
  .join(',');
325
327
  };
328
+ const fromActivationView = (state) => state.onboardingCustomerViewState.aiAgentsActivation;
329
+ export const getAiAgentsActivationSubview = (state) => fromActivationView(state);
330
+ export const getAiAgentsActivationLedgerPhases = (state) => fromActivationView(state).ledgerPhases;
331
+ export const getAiAgentsActivationBackgroundPhases = (state) => fromActivationView(state).backgroundPhases;
332
+ export const getAiAgentsActivationCounts = (state) => fromActivationView(state).counts;
333
+ const SECTION_ROW_STATUS_FALLBACK = 'idle';
334
+ const phaseStatusToRowStatus = (status) => {
335
+ if (status === 'ready') {
336
+ return 'building';
337
+ }
338
+ return status;
339
+ };
340
+ export const getAiAgentsActivationLedgerRowStatuses = (state) => fromActivationView(state).ledgerPhases.map((phase) => phaseStatusToRowStatus(phase.status ?? SECTION_ROW_STATUS_FALLBACK));
341
+ export const getAiAgentsActivationBackgroundRowStatuses = (state) => fromActivationView(state).backgroundPhases.map((phase) => phaseStatusToRowStatus(phase.status ?? SECTION_ROW_STATUS_FALLBACK));
@@ -26,3 +26,16 @@ export const ALL_ONBOARDING_STEPS = [
26
26
  ...ALL_ZENI_USER_ONBOARDING_STEPS_WITHOUT_ACCOUNT,
27
27
  ];
28
28
  export const toOnboardingStepType = (v) => stringToUnion(v, ALL_ONBOARDING_STEPS);
29
+ export const emptyAiAgentsActivationCounts = {
30
+ customerCount: 0,
31
+ glAccountCount: 0,
32
+ targetTransactionCount: 0,
33
+ transactionCount: 0,
34
+ vendorCount: 0,
35
+ };
36
+ export const emptyAiAgentsActivationSubview = {
37
+ backgroundPhases: [],
38
+ counts: emptyAiAgentsActivationCounts,
39
+ fetchStatus: { fetchState: 'Not-Started', error: undefined },
40
+ ledgerPhases: [],
41
+ };
@@ -0,0 +1,52 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { isSuccessResponse } from '../../../../../responsePayload';
4
+ import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, } from '../../kycKybAutofillActions';
6
+ import { mapCoiToCompanyDetails, mapTaxEinToCompanyDetails, } from '../../kycKybParseMapper';
7
+ import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
8
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
9
+ export const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(parseUploadedKybDocument.match), mergeMap((action) => {
10
+ const { target, companyId, fileId, documentType } = action.payload;
11
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
12
+ const requestPayload = {
13
+ provided_document_type: documentType,
14
+ files: [{ file_id: fileId }],
15
+ processing_priority: 10,
16
+ metadata: { source: 'kyc_kyb_autofill' },
17
+ };
18
+ const failureAction = parseUploadedKybDocumentFailure({ target, fileId });
19
+ return zeniAPI
20
+ .postAndGetJSON(url, requestPayload)
21
+ .pipe(mergeMap((response) => {
22
+ if (!isSuccessResponse(response) || response.data == null) {
23
+ return of(failureAction);
24
+ }
25
+ let result;
26
+ switch (documentType) {
27
+ case 'certificate_of_incorporation':
28
+ result = mapCoiToCompanyDetails(response.data);
29
+ break;
30
+ case 'tax_ein':
31
+ result = mapTaxEinToCompanyDetails(response.data);
32
+ break;
33
+ }
34
+ if (result.autoFilledFieldNames.length === 0) {
35
+ return of(failureAction);
36
+ }
37
+ const applyAction = target === 'setup'
38
+ ? applyKybDocumentAutofillForSetup({
39
+ companyId,
40
+ fileId,
41
+ values: result.values,
42
+ autoFilledFieldNames: result.autoFilledFieldNames,
43
+ })
44
+ : applyKybDocumentAutofillForOnboarding({
45
+ companyId,
46
+ fileId,
47
+ values: result.values,
48
+ autoFilledFieldNames: result.autoFilledFieldNames,
49
+ });
50
+ return of(applyAction);
51
+ }), catchError(() => of(failureAction)));
52
+ }));
@@ -0,0 +1,59 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { getCountryList } from '../../../../../entity/countryList/countryListSelector';
4
+ import { isSuccessResponse } from '../../../../../responsePayload';
5
+ import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
6
+ import { parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../kycKybAutofillActions';
7
+ import { mapDrivingLicenseToOfficer, mapPassportToOfficer, mapSsnCardToOfficer, } from '../../kycKybParseMapper';
8
+ import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
9
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
10
+ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(parseUploadedKycDocument.match), mergeMap((action) => {
11
+ const { target, companyId, officerType, fileId, documentType } = action.payload;
12
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
13
+ const requestPayload = {
14
+ provided_document_type: documentType,
15
+ files: [{ file_id: fileId }],
16
+ processing_priority: 10,
17
+ metadata: { source: 'kyc_kyb_autofill' },
18
+ };
19
+ const failureAction = parseUploadedKycDocumentFailure({ target, fileId });
20
+ return zeniAPI
21
+ .postAndGetJSON(url, requestPayload)
22
+ .pipe(mergeMap((response) => {
23
+ if (!isSuccessResponse(response) || response.data == null) {
24
+ return of(failureAction);
25
+ }
26
+ const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
27
+ let result;
28
+ switch (documentType) {
29
+ case 'passport':
30
+ result = mapPassportToOfficer(response.data, allCountries);
31
+ break;
32
+ case 'driving_license':
33
+ result = mapDrivingLicenseToOfficer(response.data);
34
+ break;
35
+ case 'social_security_card':
36
+ result = mapSsnCardToOfficer(response.data);
37
+ break;
38
+ }
39
+ if (result.autoFilledFieldNames.length === 0) {
40
+ return of(failureAction);
41
+ }
42
+ const applyAction = target === 'setup'
43
+ ? applyKycDocumentAutofillForSetup({
44
+ companyId,
45
+ officerType,
46
+ fileId,
47
+ values: result.values,
48
+ autoFilledFieldNames: result.autoFilledFieldNames,
49
+ })
50
+ : applyKycDocumentAutofillForOnboarding({
51
+ companyId,
52
+ officerType,
53
+ fileId,
54
+ values: result.values,
55
+ autoFilledFieldNames: result.autoFilledFieldNames,
56
+ });
57
+ return of(applyAction);
58
+ }), catchError(() => of(failureAction)));
59
+ }));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Trigger actions for the KYC / KYB autofill epics.
3
+ *
4
+ * These actions don't mutate state — the epic listens for them, calls
5
+ * document-communication-agent's sync endpoint, and dispatches the appropriate
6
+ * `applyKyc/KybDocumentAutofillFor{Setup,Onboarding}` against the matching
7
+ * slice. Co-located with the rest of the commonSetup module because the entire
8
+ * autofill flow is auxiliary to the setup view; there is no separate state.
9
+ */
10
+ import { createAction } from '@reduxjs/toolkit';
11
+ export const parseUploadedKycDocument = createAction('commonSetup/parseUploadedKycDocument');
12
+ export const parseUploadedKybDocument = createAction('commonSetup/parseUploadedKybDocument');
13
+ export const parseUploadedKycDocumentFailure = createAction('commonSetup/parseUploadedKycDocumentFailure');
14
+ export const parseUploadedKybDocumentFailure = createAction('commonSetup/parseUploadedKybDocumentFailure');