@zeniai/client-epic-state 5.0.85-beta0ND → 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 (26) hide show
  1. package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +7 -1
  2. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +36 -2
  3. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +3 -1
  4. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +7 -4
  5. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +7 -6
  6. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +2 -0
  7. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +36 -2
  8. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +4 -1
  9. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +7 -1
  10. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +4 -0
  11. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +36 -2
  12. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -0
  13. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +3 -1
  14. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +5 -0
  15. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +23 -3
  16. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +6 -3
  17. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +25 -3
  18. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +6 -5
  19. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +6 -0
  20. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +3 -1
  21. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +4 -0
  22. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +36 -2
  23. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +3 -2
  24. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +4 -1
  25. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +7 -0
  26. package/package.json +1 -1
@@ -105,12 +105,18 @@ export const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.
105
105
  id: transactionId,
106
106
  type: sourceTransactionType,
107
107
  };
108
+ // The server contract for `transaction-type-update` expects
109
+ // `transaction_memo`, but the client-side action payload field is named
110
+ // `memo` (callers in web-components dispatch with `memo`). The names are
111
+ // intentionally kept separate: `memo` is the internal client model and
112
+ // `transaction_memo` is the wire format. Don't unify them without
113
+ // updating the action contract and all dispatchers in lockstep.
108
114
  const payload = {
109
115
  transaction_type: transactionType,
110
116
  transaction_id: transactionId,
111
117
  to_account_integration_id: creditAccountIntegrationId,
112
118
  from_account_integration_id: debitAccountIntegrationId,
113
- memo: memo ?? '',
119
+ transaction_memo: memo ?? '',
114
120
  };
115
121
  return zeniAPI
116
122
  .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
@@ -1,5 +1,6 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { date } from '../../../zeniDayJS';
3
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../spendManagement/commonSetup/kycKybAutofillActions';
3
4
  import { emptyAiAgentsActivationSubview, } from './onboardingCustomerViewState';
4
5
  const initialStatus = {
5
6
  fetchState: 'Not-Started',
@@ -10,6 +11,7 @@ export const initialState = {
10
11
  saveStatus: initialStatus,
11
12
  dashboardLoadedStatus: initialStatus,
12
13
  currentStep: 'link_payment_account',
14
+ parsingDocumentFileIds: [],
13
15
  companyDetails: {
14
16
  autoFilledFields: [],
15
17
  localData: undefined,
@@ -671,10 +673,11 @@ const onboardingCustomerView = createSlice({
671
673
  /** Merge AI-parsed officer fields into the officer's onboarding localData. */
672
674
  applyKycDocumentAutofillForOnboarding: {
673
675
  reducer(draft, action) {
674
- const { officerType, values, autoFilledFieldNames } = action.payload;
676
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
675
677
  const slot = draft.companyOfficerUpdateStatus[officerType];
676
678
  slot.localData = Object.assign({}, slot.localData, values);
677
679
  slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
680
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
678
681
  },
679
682
  prepare(payload) {
680
683
  return { payload };
@@ -683,10 +686,11 @@ const onboardingCustomerView = createSlice({
683
686
  /** Merge AI-parsed company fields into companyDetails onboarding localData. */
684
687
  applyKybDocumentAutofillForOnboarding: {
685
688
  reducer(draft, action) {
686
- const { values, autoFilledFieldNames } = action.payload;
689
+ const { values, autoFilledFieldNames, fileId } = action.payload;
687
690
  draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
688
691
  const prev = draft.companyDetails.autoFilledFields ?? [];
689
692
  draft.companyDetails.autoFilledFields = Array.from(new Set([...prev, ...autoFilledFieldNames]));
693
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
690
694
  },
691
695
  prepare(payload) {
692
696
  return { payload };
@@ -711,6 +715,36 @@ const onboardingCustomerView = createSlice({
711
715
  },
712
716
  },
713
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
+ });
747
+ },
714
748
  });
715
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;
716
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,
@@ -2,7 +2,7 @@ import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { isSuccessResponse } from '../../../../../responsePayload';
4
4
  import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
- import { parseUploadedKybDocument } from '../../kycKybAutofillActions';
5
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, } from '../../kycKybAutofillActions';
6
6
  import { mapCoiToCompanyDetails, mapTaxEinToCompanyDetails, } from '../../kycKybParseMapper';
7
7
  import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
8
8
  const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
@@ -15,11 +15,12 @@ export const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => acti
15
15
  processing_priority: 10,
16
16
  metadata: { source: 'kyc_kyb_autofill' },
17
17
  };
18
+ const failureAction = parseUploadedKybDocumentFailure({ target, fileId });
18
19
  return zeniAPI
19
20
  .postAndGetJSON(url, requestPayload)
20
21
  .pipe(mergeMap((response) => {
21
22
  if (!isSuccessResponse(response) || response.data == null) {
22
- return of();
23
+ return of(failureAction);
23
24
  }
24
25
  let result;
25
26
  switch (documentType) {
@@ -31,19 +32,21 @@ export const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => acti
31
32
  break;
32
33
  }
33
34
  if (result.autoFilledFieldNames.length === 0) {
34
- return of();
35
+ return of(failureAction);
35
36
  }
36
37
  const applyAction = target === 'setup'
37
38
  ? applyKybDocumentAutofillForSetup({
38
39
  companyId,
40
+ fileId,
39
41
  values: result.values,
40
42
  autoFilledFieldNames: result.autoFilledFieldNames,
41
43
  })
42
44
  : applyKybDocumentAutofillForOnboarding({
43
45
  companyId,
46
+ fileId,
44
47
  values: result.values,
45
48
  autoFilledFieldNames: result.autoFilledFieldNames,
46
49
  });
47
50
  return of(applyAction);
48
- }), catchError(() => of()));
51
+ }), catchError(() => of(failureAction)));
49
52
  }));
@@ -3,7 +3,7 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { getCountryList } from '../../../../../entity/countryList/countryListSelector';
4
4
  import { isSuccessResponse } from '../../../../../responsePayload';
5
5
  import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
6
- import { parseUploadedKycDocument } from '../../kycKybAutofillActions';
6
+ import { parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../kycKybAutofillActions';
7
7
  import { mapDrivingLicenseToOfficer, mapPassportToOfficer, mapSsnCardToOfficer, } from '../../kycKybParseMapper';
8
8
  import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
9
9
  const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
@@ -16,11 +16,12 @@ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actio
16
16
  processing_priority: 10,
17
17
  metadata: { source: 'kyc_kyb_autofill' },
18
18
  };
19
+ const failureAction = parseUploadedKycDocumentFailure({ target, fileId });
19
20
  return zeniAPI
20
21
  .postAndGetJSON(url, requestPayload)
21
22
  .pipe(mergeMap((response) => {
22
23
  if (!isSuccessResponse(response) || response.data == null) {
23
- return of();
24
+ return of(failureAction);
24
25
  }
25
26
  const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
26
27
  let result;
@@ -36,23 +37,23 @@ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actio
36
37
  break;
37
38
  }
38
39
  if (result.autoFilledFieldNames.length === 0) {
39
- return of();
40
+ return of(failureAction);
40
41
  }
41
42
  const applyAction = target === 'setup'
42
43
  ? applyKycDocumentAutofillForSetup({
43
44
  companyId,
44
45
  officerType,
46
+ fileId,
45
47
  values: result.values,
46
48
  autoFilledFieldNames: result.autoFilledFieldNames,
47
49
  })
48
50
  : applyKycDocumentAutofillForOnboarding({
49
51
  companyId,
50
52
  officerType,
53
+ fileId,
51
54
  values: result.values,
52
55
  autoFilledFieldNames: result.autoFilledFieldNames,
53
56
  });
54
57
  return of(applyAction);
55
- }), catchError(() =>
56
- // Autofill is best-effort; swallow errors silently so the user can keep typing.
57
- of()));
58
+ }), catchError(() => of(failureAction)));
58
59
  }));
@@ -10,3 +10,5 @@
10
10
  import { createAction } from '@reduxjs/toolkit';
11
11
  export const parseUploadedKycDocument = createAction('commonSetup/parseUploadedKycDocument');
12
12
  export const parseUploadedKybDocument = createAction('commonSetup/parseUploadedKybDocument');
13
+ export const parseUploadedKycDocumentFailure = createAction('commonSetup/parseUploadedKycDocumentFailure');
14
+ export const parseUploadedKybDocumentFailure = createAction('commonSetup/parseUploadedKybDocumentFailure');
@@ -1,4 +1,5 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from './kycKybAutofillActions';
2
3
  const initialFetchStatus = {
3
4
  fetchState: 'Not-Started',
4
5
  error: undefined,
@@ -11,6 +12,7 @@ const emptyOfficerSlot = {
11
12
  };
12
13
  export const initialState = {
13
14
  updateStatus: { fetchState: 'Not-Started', error: undefined },
15
+ parsingDocumentFileIds: [],
14
16
  companyDetails: { autoFilledFields: [] },
15
17
  companyOfficerUpdateStatus: {
16
18
  Officer_1: { ...emptyOfficerSlot },
@@ -269,10 +271,11 @@ const setupView = createSlice({
269
271
  */
270
272
  applyKycDocumentAutofillForSetup: {
271
273
  reducer(draft, action) {
272
- const { officerType, values, autoFilledFieldNames } = action.payload;
274
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
273
275
  const slot = draft.companyOfficerUpdateStatus[officerType];
274
276
  slot.localData = Object.assign({}, slot.localData, values);
275
277
  slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
278
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
276
279
  },
277
280
  prepare(payload) {
278
281
  return { payload };
@@ -284,12 +287,13 @@ const setupView = createSlice({
284
287
  */
285
288
  applyKybDocumentAutofillForSetup: {
286
289
  reducer(draft, action) {
287
- const { values, autoFilledFieldNames } = action.payload;
290
+ const { values, autoFilledFieldNames, fileId } = action.payload;
288
291
  draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
289
292
  draft.companyDetails.autoFilledFields = Array.from(new Set([
290
293
  ...draft.companyDetails.autoFilledFields,
291
294
  ...autoFilledFieldNames,
292
295
  ]));
296
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
293
297
  },
294
298
  prepare(payload) {
295
299
  return { payload };
@@ -317,6 +321,36 @@ const setupView = createSlice({
317
321
  },
318
322
  },
319
323
  },
324
+ extraReducers: (builder) => {
325
+ const addParsingFileId = (draft, fileId) => {
326
+ if (!draft.parsingDocumentFileIds.includes(fileId)) {
327
+ draft.parsingDocumentFileIds.push(fileId);
328
+ }
329
+ };
330
+ const removeParsingFileId = (draft, fileId) => {
331
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
332
+ };
333
+ builder.addCase(parseUploadedKycDocument, (draft, action) => {
334
+ if (action.payload.target === 'setup') {
335
+ addParsingFileId(draft, action.payload.fileId);
336
+ }
337
+ });
338
+ builder.addCase(parseUploadedKybDocument, (draft, action) => {
339
+ if (action.payload.target === 'setup') {
340
+ addParsingFileId(draft, action.payload.fileId);
341
+ }
342
+ });
343
+ builder.addCase(parseUploadedKycDocumentFailure, (draft, action) => {
344
+ if (action.payload.target === 'setup') {
345
+ removeParsingFileId(draft, action.payload.fileId);
346
+ }
347
+ });
348
+ builder.addCase(parseUploadedKybDocumentFailure, (draft, action) => {
349
+ if (action.payload.target === 'setup') {
350
+ removeParsingFileId(draft, action.payload.fileId);
351
+ }
352
+ });
353
+ },
320
354
  });
321
355
  export const { enableSetup, enableSetupSuccess, enableSetupFailure, updateBusinessVerificationDetails, updateBusinessVerificationDetailsSuccess, updateBusinessVerificationDetailsFailure, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveTreasuryAdditionalDocumentsInLocalStore, sendOtp: sendOtpSpendManagementSetUp, resendOtp: resendOtpSpendManagementSetUp, sendOtpSuccess: sendOtpSuccessSpendManagementSetUp, sendOtpFailure: sendOtpFailureSpendManagementSetUp, verifyOtp: verifyOtpSpendManagementSetUp, verifyOtpSuccess: verifyOtpSuccessSpendManagementSetUp, verifyOtpFailure: verifyOtpFailureSpendManagementSetUp, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, clearSetupView, applyKycDocumentAutofillForSetup, applyKybDocumentAutofillForSetup, clearKycKybAutofillForSetup, } = setupView.actions;
322
356
  export default setupView.reducer;
@@ -87,15 +87,17 @@ export function getBusinessVerificationDetails(state, companyId) {
87
87
  const { setupViewState, countryListState } = state;
88
88
  const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, updateStatus, } = setupViewState;
89
89
  const companyView = getCompanyView(state, companyId, []);
90
- const { companyDetailsLocalData, companyOfficerLocalData } = getCompanyAndIdentityDetails(state, companyId, {
90
+ const { companyDetailsLocalData, companyOfficerLocalData, parsingDocumentFileIds } = getCompanyAndIdentityDetails(state, companyId, {
91
91
  companyDetails,
92
92
  companyOfficerUpdateStatus,
93
93
  primaryContactDetails,
94
+ parsingDocumentFileIds: setupViewState.parsingDocumentFileIds,
94
95
  });
95
96
  const allNationalityCountries = countryListState.byCountryListCode.nationalityCountryList.countries;
96
97
  return {
97
98
  companyDetailsLocalData,
98
99
  companyOfficerLocalData,
100
+ parsingDocumentFileIds,
99
101
  companyView,
100
102
  updateStatus,
101
103
  allNationalityCountries,
@@ -206,6 +208,7 @@ export const getCompanyAndIdentityDetails = (state, companyId, companyAndIdentit
206
208
  return {
207
209
  companyDetailsLocalData,
208
210
  companyOfficerLocalData,
211
+ parsingDocumentFileIds: companyAndIdentityDetails.parsingDocumentFileIds,
209
212
  };
210
213
  };
211
214
  /* This helper function takes deposit accounts and payment accounts
@@ -108,12 +108,18 @@ const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0
108
108
  id: transactionId,
109
109
  type: sourceTransactionType,
110
110
  };
111
+ // The server contract for `transaction-type-update` expects
112
+ // `transaction_memo`, but the client-side action payload field is named
113
+ // `memo` (callers in web-components dispatch with `memo`). The names are
114
+ // intentionally kept separate: `memo` is the internal client model and
115
+ // `transaction_memo` is the wire format. Don't unify them without
116
+ // updating the action contract and all dispatchers in lockstep.
111
117
  const payload = {
112
118
  transaction_type: transactionType,
113
119
  transaction_id: transactionId,
114
120
  to_account_integration_id: creditAccountIntegrationId,
115
121
  from_account_integration_id: debitAccountIntegrationId,
116
- memo: memo ?? '',
122
+ transaction_memo: memo ?? '',
117
123
  };
118
124
  return zeniAPI
119
125
  .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
@@ -95,20 +95,24 @@ export declare const fetchOnboardingCustomerView: import("@reduxjs/toolkit").Act
95
95
  }, "onboardingCustomerView/sendOnboardingOfficerOtpSuccess">, sendOnboardingOfficerOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "onboardingCustomerView/sendOnboardingOfficerOtpFailure">, resendOnboardingOfficerOtp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"onboardingCustomerView/resendOnboardingOfficerOtp">, verifyOnboardingOfficerOtp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"onboardingCustomerView/verifyOnboardingOfficerOtp">, verifyOnboardingOfficerOtpSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"onboardingCustomerView/verifyOnboardingOfficerOtpSuccess">, verifyOnboardingOfficerOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "onboardingCustomerView/verifyOnboardingOfficerOtpFailure">, clearOnboardingCustomerViewDataInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"onboardingCustomerView/clearOnboardingCustomerViewDataInLocalStore">, clearOnboardingCustomerView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"onboardingCustomerView/clearOnboardingCustomerView">, applyKycDocumentAutofillForOnboarding: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
96
96
  autoFilledFieldNames: string[];
97
97
  companyId: ID;
98
+ fileId: ID;
98
99
  officerType: CompanyOfficerType;
99
100
  values: Partial<CompanyOfficerLocalData>;
100
101
  }], {
101
102
  autoFilledFieldNames: string[];
102
103
  companyId: ID;
104
+ fileId: ID;
103
105
  officerType: CompanyOfficerType;
104
106
  values: Partial<CompanyOfficerLocalData>;
105
107
  }, "onboardingCustomerView/applyKycDocumentAutofillForOnboarding", never, never>, applyKybDocumentAutofillForOnboarding: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
106
108
  autoFilledFieldNames: string[];
107
109
  companyId: ID;
110
+ fileId: ID;
108
111
  values: Partial<CompanyDetailsLocalData>;
109
112
  }], {
110
113
  autoFilledFieldNames: string[];
111
114
  companyId: ID;
115
+ fileId: ID;
112
116
  values: Partial<CompanyDetailsLocalData>;
113
117
  }, "onboardingCustomerView/applyKybDocumentAutofillForOnboarding", never, never>, clearKycKybAutofillForOnboarding: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload?: {
114
118
  officerType?: CompanyOfficerType;
@@ -5,6 +5,7 @@ exports.clearOnboardingCustomerView = exports.clearOnboardingCustomerViewDataInL
5
5
  exports.clearKycKybAutofillForOnboarding = exports.applyKybDocumentAutofillForOnboarding = exports.applyKycDocumentAutofillForOnboarding = void 0;
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const zeniDayJS_1 = require("../../../zeniDayJS");
8
+ const kycKybAutofillActions_1 = require("../../spendManagement/commonSetup/kycKybAutofillActions");
8
9
  const onboardingCustomerViewState_1 = require("./onboardingCustomerViewState");
9
10
  const initialStatus = {
10
11
  fetchState: 'Not-Started',
@@ -15,6 +16,7 @@ exports.initialState = {
15
16
  saveStatus: initialStatus,
16
17
  dashboardLoadedStatus: initialStatus,
17
18
  currentStep: 'link_payment_account',
19
+ parsingDocumentFileIds: [],
18
20
  companyDetails: {
19
21
  autoFilledFields: [],
20
22
  localData: undefined,
@@ -676,10 +678,11 @@ const onboardingCustomerView = (0, toolkit_1.createSlice)({
676
678
  /** Merge AI-parsed officer fields into the officer's onboarding localData. */
677
679
  applyKycDocumentAutofillForOnboarding: {
678
680
  reducer(draft, action) {
679
- const { officerType, values, autoFilledFieldNames } = action.payload;
681
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
680
682
  const slot = draft.companyOfficerUpdateStatus[officerType];
681
683
  slot.localData = Object.assign({}, slot.localData, values);
682
684
  slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
685
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
683
686
  },
684
687
  prepare(payload) {
685
688
  return { payload };
@@ -688,10 +691,11 @@ const onboardingCustomerView = (0, toolkit_1.createSlice)({
688
691
  /** Merge AI-parsed company fields into companyDetails onboarding localData. */
689
692
  applyKybDocumentAutofillForOnboarding: {
690
693
  reducer(draft, action) {
691
- const { values, autoFilledFieldNames } = action.payload;
694
+ const { values, autoFilledFieldNames, fileId } = action.payload;
692
695
  draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
693
696
  const prev = draft.companyDetails.autoFilledFields ?? [];
694
697
  draft.companyDetails.autoFilledFields = Array.from(new Set([...prev, ...autoFilledFieldNames]));
698
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
695
699
  },
696
700
  prepare(payload) {
697
701
  return { payload };
@@ -716,6 +720,36 @@ const onboardingCustomerView = (0, toolkit_1.createSlice)({
716
720
  },
717
721
  },
718
722
  },
723
+ extraReducers: (builder) => {
724
+ const addParsingFileId = (draft, fileId) => {
725
+ if (!draft.parsingDocumentFileIds.includes(fileId)) {
726
+ draft.parsingDocumentFileIds.push(fileId);
727
+ }
728
+ };
729
+ const removeParsingFileId = (draft, fileId) => {
730
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
731
+ };
732
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKycDocument, (draft, action) => {
733
+ if (action.payload.target === 'onboarding') {
734
+ addParsingFileId(draft, action.payload.fileId);
735
+ }
736
+ });
737
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKybDocument, (draft, action) => {
738
+ if (action.payload.target === 'onboarding') {
739
+ addParsingFileId(draft, action.payload.fileId);
740
+ }
741
+ });
742
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKycDocumentFailure, (draft, action) => {
743
+ if (action.payload.target === 'onboarding') {
744
+ removeParsingFileId(draft, action.payload.fileId);
745
+ }
746
+ });
747
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKybDocumentFailure, (draft, action) => {
748
+ if (action.payload.target === 'onboarding') {
749
+ removeParsingFileId(draft, action.payload.fileId);
750
+ }
751
+ });
752
+ },
719
753
  });
720
754
  _a = onboardingCustomerView.actions, exports.fetchOnboardingCustomerView = _a.fetchOnboardingCustomerView, exports.fetchOnboardingCustomerSetupView = _a.fetchOnboardingCustomerSetupView, exports.fetchOnboardingCustomerSetupViewSuccess = _a.fetchOnboardingCustomerSetupViewSuccess, exports.fetchOnboardingCustomerSetupViewFailure = _a.fetchOnboardingCustomerSetupViewFailure, exports.updateOnboardingCustomerViewCompleteStatus = _a.updateOnboardingCustomerViewCompleteStatus, exports.updateOnboardingCustomerViewCompleteStatusSuccess = _a.updateOnboardingCustomerViewCompleteStatusSuccess, exports.updateOnboardingCustomerViewCompleteStatusFailure = _a.updateOnboardingCustomerViewCompleteStatusFailure, exports.acknowledgeOnboardingAiFinanceTeam = _a.acknowledgeOnboardingAiFinanceTeam, exports.acknowledgeOnboardingAiFinanceTeamSuccess = _a.acknowledgeOnboardingAiFinanceTeamSuccess, exports.acknowledgeOnboardingAiFinanceTeamFailure = _a.acknowledgeOnboardingAiFinanceTeamFailure, exports.fetchAiAgentsActivationStatus = _a.fetchAiAgentsActivationStatus, exports.fetchAiAgentsActivationStatusSuccess = _a.fetchAiAgentsActivationStatusSuccess, exports.fetchAiAgentsActivationStatusFailure = _a.fetchAiAgentsActivationStatusFailure, exports.aiAgentsActivationCountsUpdated = _a.aiAgentsActivationCountsUpdated, exports.aiAgentsActivationPhaseChanged = _a.aiAgentsActivationPhaseChanged, exports.aiAgentsActivationSectionReady = _a.aiAgentsActivationSectionReady, exports.updateOnboardingCustomerViewDashboardLoaded = _a.updateOnboardingCustomerViewDashboardLoaded, exports.updateOnboardingCustomerViewDashboardLoadedSuccess = _a.updateOnboardingCustomerViewDashboardLoadedSuccess, exports.updateOnboardingCustomerViewDashboardLoadedFailure = _a.updateOnboardingCustomerViewDashboardLoadedFailure, exports.updateOnboardingCustomerView = _a.updateOnboardingCustomerView, exports.updateOnboardingCustomerViewSuccess = _a.updateOnboardingCustomerViewSuccess, exports.updateOnboardingCustomerViewFailure = _a.updateOnboardingCustomerViewFailure, exports.updateOnboardingPaymentAccountStatus = _a.updateOnboardingPaymentAccountStatus, exports.updateOnboardingPaymentAccountStatusSuccess = _a.updateOnboardingPaymentAccountStatusSuccess, exports.updateOnboardingPaymentAccountStatusFailure = _a.updateOnboardingPaymentAccountStatusFailure, exports.updateOnboardingPaymentAccountLoginStatus = _a.updateOnboardingPaymentAccountLoginStatus, exports.updateOnboardingPaymentAccountLoginStatusSuccess = _a.updateOnboardingPaymentAccountLoginStatusSuccess, exports.updateOnboardingPaymentAccountLoginStatusFailure = _a.updateOnboardingPaymentAccountLoginStatusFailure, exports.establishOnboardingPlaidConnection = _a.establishOnboardingPlaidConnection, exports.establishOnboardingPlaidConnectionSuccess = _a.establishOnboardingPlaidConnectionSuccess, exports.establishOnboardingPlaidConnectionFailure = _a.establishOnboardingPlaidConnectionFailure, exports.getOnboardingPlaidLinkToken = _a.getOnboardingPlaidLinkToken, exports.getOnboardingPlaidLinkTokenSuccess = _a.getOnboardingPlaidLinkTokenSuccess, exports.getOnboardingPlaidLinkTokenFailure = _a.getOnboardingPlaidLinkTokenFailure, exports.updateCurrentStep = _a.updateCurrentStep, exports.updateOnboardingCustomerViewAccountDetails = _a.updateOnboardingCustomerViewAccountDetails, exports.updateOnboardingCustomerViewLocalStoreData = _a.updateOnboardingCustomerViewLocalStoreData, exports.saveOnboardingCustomerViewDataInLocalStore = _a.saveOnboardingCustomerViewDataInLocalStore, exports.saveOnboardingCompnayOfficerPhoneInLocalStore = _a.saveOnboardingCompnayOfficerPhoneInLocalStore, exports.updateOnboardingCustomerViewUIState = _a.updateOnboardingCustomerViewUIState, exports.sendOnboardingOfficerOtp = _a.sendOnboardingOfficerOtp, exports.sendOnboardingOfficerOtpSuccess = _a.sendOnboardingOfficerOtpSuccess, exports.sendOnboardingOfficerOtpFailure = _a.sendOnboardingOfficerOtpFailure, exports.resendOnboardingOfficerOtp = _a.resendOnboardingOfficerOtp, exports.verifyOnboardingOfficerOtp = _a.verifyOnboardingOfficerOtp, exports.verifyOnboardingOfficerOtpSuccess = _a.verifyOnboardingOfficerOtpSuccess, exports.verifyOnboardingOfficerOtpFailure = _a.verifyOnboardingOfficerOtpFailure, exports.clearOnboardingCustomerViewDataInLocalStore = _a.clearOnboardingCustomerViewDataInLocalStore, exports.clearOnboardingCustomerView = _a.clearOnboardingCustomerView, exports.applyKycDocumentAutofillForOnboarding = _a.applyKycDocumentAutofillForOnboarding, exports.applyKybDocumentAutofillForOnboarding = _a.applyKybDocumentAutofillForOnboarding, exports.clearKycKybAutofillForOnboarding = _a.clearKycKybAutofillForOnboarding;
721
755
  exports.default = onboardingCustomerView.reducer;
@@ -28,6 +28,7 @@ export interface OnboardingCustomerView {
28
28
  fetchStatus: FetchStateAndError;
29
29
  halfCompletedSteps: OnboardingStep[];
30
30
  isInterimEmailSent: boolean;
31
+ parsingDocumentFileIds: ID[];
31
32
  paymentAccountFetchStatus: FetchStateAndError;
32
33
  paymentAccountUpdateStatus: FetchStateAndError;
33
34
  pendingSaveDetails: {
@@ -17,7 +17,7 @@ const setupViewSelector_1 = require("../../spendManagement/commonSetup/setupView
17
17
  const onboardingCustomerViewState_1 = require("./onboardingCustomerViewState");
18
18
  function getOnboardingCustomerView(state, companyId) {
19
19
  const { fileState, paymentAccountState, onboardingCustomerViewState, userState, userRoleState, subscriptionPaymentAccountState, companyConfigState, cardPaymentViewState, countryListState, addressViewState, } = state;
20
- const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
20
+ const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, parsingDocumentFileIds, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
21
21
  const { paymentAccountIds } = paymentAccountDetails;
22
22
  let subscriptionPaymentAccount;
23
23
  let paymentAccount;
@@ -60,6 +60,7 @@ function getOnboardingCustomerView(state, companyId) {
60
60
  companyDetails,
61
61
  companyOfficerUpdateStatus,
62
62
  primaryContactDetails,
63
+ parsingDocumentFileIds,
63
64
  });
64
65
  const companyAddress = addressViewState.newAddressState?.company_address;
65
66
  if (companyAddress == null &&
@@ -125,6 +126,7 @@ function getOnboardingCustomerView(state, companyId) {
125
126
  return {
126
127
  companyDetailsLocalData,
127
128
  companyOfficerLocalData,
129
+ parsingDocumentFileIds,
128
130
  subscriptionBillingAddress: subscriptionBillingAddress?.addressToCreate,
129
131
  companyView,
130
132
  allNationalityCountries,
@@ -42,6 +42,11 @@ export interface OnboardingCustomerViewState extends FetchedState {
42
42
  }>;
43
43
  currentStep: OnboardingStep;
44
44
  dashboardLoadedStatus: FetchStateAndError;
45
+ /**
46
+ * File IDs currently being parsed by the AI autofill epic for onboarding.
47
+ * Drives the "AI is reading your document" overlay on the upload field.
48
+ */
49
+ parsingDocumentFileIds: ID[];
45
50
  paymentAccountDetails: {
46
51
  fetchStatus: FetchStateAndError;
47
52
  paymentAccountIds: ID[];
@@ -2,7 +2,27 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { RootState } from '../../../../../reducer';
3
3
  import { ZeniAPI } from '../../../../../zeniAPI';
4
4
  import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
- import { parseUploadedKybDocument } from '../../kycKybAutofillActions';
5
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure } from '../../kycKybAutofillActions';
6
6
  import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
7
- export type ActionType = ReturnType<typeof parseUploadedKybDocument | typeof applyKybDocumentAutofillForSetup | typeof applyKybDocumentAutofillForOnboarding>;
8
- export declare const parseUploadedKybDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<unknown>;
7
+ import { CompanyDetailsLocalData } from '../../setupViewState';
8
+ export type ActionType = ReturnType<typeof parseUploadedKybDocument | typeof parseUploadedKybDocumentFailure | typeof applyKybDocumentAutofillForSetup | typeof applyKybDocumentAutofillForOnboarding>;
9
+ export declare const parseUploadedKybDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
10
+ payload: import("../../kycKybAutofillActions").ParseUploadedDocumentFailurePayload;
11
+ type: string;
12
+ } | {
13
+ payload: {
14
+ autoFilledFieldNames: string[];
15
+ companyId: import("../../../../..").ID;
16
+ fileId: import("../../../../..").ID;
17
+ values: Partial<CompanyDetailsLocalData>;
18
+ };
19
+ type: "onboardingCustomerView/applyKybDocumentAutofillForOnboarding";
20
+ } | {
21
+ payload: {
22
+ autoFilledFieldNames: string[];
23
+ companyId: import("../../../../..").ID;
24
+ fileId: import("../../../../..").ID;
25
+ values: Partial<CompanyDetailsLocalData>;
26
+ };
27
+ type: "setupView/applyKybDocumentAutofillForSetup";
28
+ }>;
@@ -18,11 +18,12 @@ const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pi
18
18
  processing_priority: 10,
19
19
  metadata: { source: 'kyc_kyb_autofill' },
20
20
  };
21
+ const failureAction = (0, kycKybAutofillActions_1.parseUploadedKybDocumentFailure)({ target, fileId });
21
22
  return zeniAPI
22
23
  .postAndGetJSON(url, requestPayload)
23
24
  .pipe((0, operators_1.mergeMap)((response) => {
24
25
  if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
25
- return (0, rxjs_1.of)();
26
+ return (0, rxjs_1.of)(failureAction);
26
27
  }
27
28
  let result;
28
29
  switch (documentType) {
@@ -34,20 +35,22 @@ const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pi
34
35
  break;
35
36
  }
36
37
  if (result.autoFilledFieldNames.length === 0) {
37
- return (0, rxjs_1.of)();
38
+ return (0, rxjs_1.of)(failureAction);
38
39
  }
39
40
  const applyAction = target === 'setup'
40
41
  ? (0, setupViewReducer_1.applyKybDocumentAutofillForSetup)({
41
42
  companyId,
43
+ fileId,
42
44
  values: result.values,
43
45
  autoFilledFieldNames: result.autoFilledFieldNames,
44
46
  })
45
47
  : (0, onboardingCustomerViewReducer_1.applyKybDocumentAutofillForOnboarding)({
46
48
  companyId,
49
+ fileId,
47
50
  values: result.values,
48
51
  autoFilledFieldNames: result.autoFilledFieldNames,
49
52
  });
50
53
  return (0, rxjs_1.of)(applyAction);
51
- }), (0, operators_1.catchError)(() => (0, rxjs_1.of)()));
54
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)(failureAction)));
52
55
  }));
53
56
  exports.parseUploadedKybDocumentEpic = parseUploadedKybDocumentEpic;
@@ -2,7 +2,29 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { RootState } from '../../../../../reducer';
3
3
  import { ZeniAPI } from '../../../../../zeniAPI';
4
4
  import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
- import { parseUploadedKycDocument } from '../../kycKybAutofillActions';
5
+ import { parseUploadedKycDocument, parseUploadedKycDocumentFailure } from '../../kycKybAutofillActions';
6
6
  import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
7
- export type ActionType = ReturnType<typeof parseUploadedKycDocument | typeof applyKycDocumentAutofillForSetup | typeof applyKycDocumentAutofillForOnboarding>;
8
- export declare const parseUploadedKycDocumentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<unknown>;
7
+ import { CompanyOfficerLocalData } from '../../setupViewState';
8
+ export type ActionType = ReturnType<typeof parseUploadedKycDocument | typeof parseUploadedKycDocumentFailure | typeof applyKycDocumentAutofillForSetup | typeof applyKycDocumentAutofillForOnboarding>;
9
+ export declare const parseUploadedKycDocumentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
10
+ payload: import("../../kycKybAutofillActions").ParseUploadedDocumentFailurePayload;
11
+ type: string;
12
+ } | {
13
+ payload: {
14
+ autoFilledFieldNames: string[];
15
+ companyId: import("../../../../..").ID;
16
+ fileId: import("../../../../..").ID;
17
+ officerType: import("../../../../..").CompanyOfficerType;
18
+ values: Partial<CompanyOfficerLocalData>;
19
+ };
20
+ type: "onboardingCustomerView/applyKycDocumentAutofillForOnboarding";
21
+ } | {
22
+ payload: {
23
+ autoFilledFieldNames: string[];
24
+ companyId: import("../../../../..").ID;
25
+ fileId: import("../../../../..").ID;
26
+ officerType: import("../../../../..").CompanyOfficerType;
27
+ values: Partial<CompanyOfficerLocalData>;
28
+ };
29
+ type: "setupView/applyKycDocumentAutofillForSetup";
30
+ }>;
@@ -19,11 +19,12 @@ const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pip
19
19
  processing_priority: 10,
20
20
  metadata: { source: 'kyc_kyb_autofill' },
21
21
  };
22
+ const failureAction = (0, kycKybAutofillActions_1.parseUploadedKycDocumentFailure)({ target, fileId });
22
23
  return zeniAPI
23
24
  .postAndGetJSON(url, requestPayload)
24
25
  .pipe((0, operators_1.mergeMap)((response) => {
25
26
  if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
26
- return (0, rxjs_1.of)();
27
+ return (0, rxjs_1.of)(failureAction);
27
28
  }
28
29
  const allCountries = (0, countryListSelector_1.getCountryList)(state$.value.countryListState, 'nationalityCountryList').countries;
29
30
  let result;
@@ -39,24 +40,24 @@ const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pip
39
40
  break;
40
41
  }
41
42
  if (result.autoFilledFieldNames.length === 0) {
42
- return (0, rxjs_1.of)();
43
+ return (0, rxjs_1.of)(failureAction);
43
44
  }
44
45
  const applyAction = target === 'setup'
45
46
  ? (0, setupViewReducer_1.applyKycDocumentAutofillForSetup)({
46
47
  companyId,
47
48
  officerType,
49
+ fileId,
48
50
  values: result.values,
49
51
  autoFilledFieldNames: result.autoFilledFieldNames,
50
52
  })
51
53
  : (0, onboardingCustomerViewReducer_1.applyKycDocumentAutofillForOnboarding)({
52
54
  companyId,
53
55
  officerType,
56
+ fileId,
54
57
  values: result.values,
55
58
  autoFilledFieldNames: result.autoFilledFieldNames,
56
59
  });
57
60
  return (0, rxjs_1.of)(applyAction);
58
- }), (0, operators_1.catchError)(() =>
59
- // Autofill is best-effort; swallow errors silently so the user can keep typing.
60
- (0, rxjs_1.of)()));
61
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)(failureAction)));
61
62
  }));
62
63
  exports.parseUploadedKycDocumentEpic = parseUploadedKycDocumentEpic;
@@ -25,3 +25,9 @@ export interface ParseUploadedKybDocumentPayload {
25
25
  }
26
26
  export declare const parseUploadedKycDocument: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedKycDocumentPayload, string>;
27
27
  export declare const parseUploadedKybDocument: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedKybDocumentPayload, string>;
28
+ export interface ParseUploadedDocumentFailurePayload {
29
+ fileId: ID;
30
+ target: KycKybAutofillTarget;
31
+ }
32
+ export declare const parseUploadedKycDocumentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedDocumentFailurePayload, string>;
33
+ export declare const parseUploadedKybDocumentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedDocumentFailurePayload, string>;
@@ -9,7 +9,9 @@
9
9
  * autofill flow is auxiliary to the setup view; there is no separate state.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.parseUploadedKybDocument = exports.parseUploadedKycDocument = void 0;
12
+ exports.parseUploadedKybDocumentFailure = exports.parseUploadedKycDocumentFailure = exports.parseUploadedKybDocument = exports.parseUploadedKycDocument = void 0;
13
13
  const toolkit_1 = require("@reduxjs/toolkit");
14
14
  exports.parseUploadedKycDocument = (0, toolkit_1.createAction)('commonSetup/parseUploadedKycDocument');
15
15
  exports.parseUploadedKybDocument = (0, toolkit_1.createAction)('commonSetup/parseUploadedKybDocument');
16
+ exports.parseUploadedKycDocumentFailure = (0, toolkit_1.createAction)('commonSetup/parseUploadedKycDocumentFailure');
17
+ exports.parseUploadedKybDocumentFailure = (0, toolkit_1.createAction)('commonSetup/parseUploadedKybDocumentFailure');
@@ -32,20 +32,24 @@ export declare const enableSetup: import("@reduxjs/toolkit").ActionCreatorWithPr
32
32
  }, "setupView/saveIndustryAndIncDateInLocalStore">, clearSetupViewDataInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/clearSetupViewDataInLocalStore">, clearSetupView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/clearSetupView">, applyKycDocumentAutofillForSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
33
33
  autoFilledFieldNames: string[];
34
34
  companyId: ID;
35
+ fileId: ID;
35
36
  officerType: CompanyOfficerType;
36
37
  values: Partial<CompanyOfficerLocalData>;
37
38
  }], {
38
39
  autoFilledFieldNames: string[];
39
40
  companyId: ID;
41
+ fileId: ID;
40
42
  officerType: CompanyOfficerType;
41
43
  values: Partial<CompanyOfficerLocalData>;
42
44
  }, "setupView/applyKycDocumentAutofillForSetup", never, never>, applyKybDocumentAutofillForSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
43
45
  autoFilledFieldNames: string[];
44
46
  companyId: ID;
47
+ fileId: ID;
45
48
  values: Partial<CompanyDetailsLocalData>;
46
49
  }], {
47
50
  autoFilledFieldNames: string[];
48
51
  companyId: ID;
52
+ fileId: ID;
49
53
  values: Partial<CompanyDetailsLocalData>;
50
54
  }, "setupView/applyKybDocumentAutofillForSetup", never, never>, clearKycKybAutofillForSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload?: {
51
55
  officerType?: CompanyOfficerType;
@@ -3,6 +3,7 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clearKycKybAutofillForSetup = exports.applyKybDocumentAutofillForSetup = exports.applyKycDocumentAutofillForSetup = exports.clearSetupView = exports.clearSetupViewDataInLocalStore = exports.saveIndustryAndIncDateInLocalStore = exports.verifyOtpFailureSpendManagementSetUp = exports.verifyOtpSuccessSpendManagementSetUp = exports.verifyOtpSpendManagementSetUp = exports.sendOtpFailureSpendManagementSetUp = exports.sendOtpSuccessSpendManagementSetUp = exports.resendOtpSpendManagementSetUp = exports.sendOtpSpendManagementSetUp = exports.saveTreasuryAdditionalDocumentsInLocalStore = exports.saveCompnayOfficerAdditionalDocumentsInLocalStore = exports.saveCompnayOfficerPhoneInLocalStore = exports.saveSetupViewDataInLocalStore = exports.updateSetupViewLocalStoreData = exports.updateSelectedCompanyOfficer = exports.updateBusinessVerificationDetailsFailure = exports.updateBusinessVerificationDetailsSuccess = exports.updateBusinessVerificationDetails = exports.enableSetupFailure = exports.enableSetupSuccess = exports.enableSetup = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
+ const kycKybAutofillActions_1 = require("./kycKybAutofillActions");
6
7
  const initialFetchStatus = {
7
8
  fetchState: 'Not-Started',
8
9
  error: undefined,
@@ -15,6 +16,7 @@ const emptyOfficerSlot = {
15
16
  };
16
17
  exports.initialState = {
17
18
  updateStatus: { fetchState: 'Not-Started', error: undefined },
19
+ parsingDocumentFileIds: [],
18
20
  companyDetails: { autoFilledFields: [] },
19
21
  companyOfficerUpdateStatus: {
20
22
  Officer_1: { ...emptyOfficerSlot },
@@ -273,10 +275,11 @@ const setupView = (0, toolkit_1.createSlice)({
273
275
  */
274
276
  applyKycDocumentAutofillForSetup: {
275
277
  reducer(draft, action) {
276
- const { officerType, values, autoFilledFieldNames } = action.payload;
278
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
277
279
  const slot = draft.companyOfficerUpdateStatus[officerType];
278
280
  slot.localData = Object.assign({}, slot.localData, values);
279
281
  slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
282
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
280
283
  },
281
284
  prepare(payload) {
282
285
  return { payload };
@@ -288,12 +291,13 @@ const setupView = (0, toolkit_1.createSlice)({
288
291
  */
289
292
  applyKybDocumentAutofillForSetup: {
290
293
  reducer(draft, action) {
291
- const { values, autoFilledFieldNames } = action.payload;
294
+ const { values, autoFilledFieldNames, fileId } = action.payload;
292
295
  draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
293
296
  draft.companyDetails.autoFilledFields = Array.from(new Set([
294
297
  ...draft.companyDetails.autoFilledFields,
295
298
  ...autoFilledFieldNames,
296
299
  ]));
300
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
297
301
  },
298
302
  prepare(payload) {
299
303
  return { payload };
@@ -321,6 +325,36 @@ const setupView = (0, toolkit_1.createSlice)({
321
325
  },
322
326
  },
323
327
  },
328
+ extraReducers: (builder) => {
329
+ const addParsingFileId = (draft, fileId) => {
330
+ if (!draft.parsingDocumentFileIds.includes(fileId)) {
331
+ draft.parsingDocumentFileIds.push(fileId);
332
+ }
333
+ };
334
+ const removeParsingFileId = (draft, fileId) => {
335
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
336
+ };
337
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKycDocument, (draft, action) => {
338
+ if (action.payload.target === 'setup') {
339
+ addParsingFileId(draft, action.payload.fileId);
340
+ }
341
+ });
342
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKybDocument, (draft, action) => {
343
+ if (action.payload.target === 'setup') {
344
+ addParsingFileId(draft, action.payload.fileId);
345
+ }
346
+ });
347
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKycDocumentFailure, (draft, action) => {
348
+ if (action.payload.target === 'setup') {
349
+ removeParsingFileId(draft, action.payload.fileId);
350
+ }
351
+ });
352
+ builder.addCase(kycKybAutofillActions_1.parseUploadedKybDocumentFailure, (draft, action) => {
353
+ if (action.payload.target === 'setup') {
354
+ removeParsingFileId(draft, action.payload.fileId);
355
+ }
356
+ });
357
+ },
324
358
  });
325
359
  _a = setupView.actions, exports.enableSetup = _a.enableSetup, exports.enableSetupSuccess = _a.enableSetupSuccess, exports.enableSetupFailure = _a.enableSetupFailure, exports.updateBusinessVerificationDetails = _a.updateBusinessVerificationDetails, exports.updateBusinessVerificationDetailsSuccess = _a.updateBusinessVerificationDetailsSuccess, exports.updateBusinessVerificationDetailsFailure = _a.updateBusinessVerificationDetailsFailure, exports.updateSelectedCompanyOfficer = _a.updateSelectedCompanyOfficer, exports.updateSetupViewLocalStoreData = _a.updateSetupViewLocalStoreData, exports.saveSetupViewDataInLocalStore = _a.saveSetupViewDataInLocalStore, exports.saveCompnayOfficerPhoneInLocalStore = _a.saveCompnayOfficerPhoneInLocalStore, exports.saveCompnayOfficerAdditionalDocumentsInLocalStore = _a.saveCompnayOfficerAdditionalDocumentsInLocalStore, exports.saveTreasuryAdditionalDocumentsInLocalStore = _a.saveTreasuryAdditionalDocumentsInLocalStore, exports.sendOtpSpendManagementSetUp = _a.sendOtp, exports.resendOtpSpendManagementSetUp = _a.resendOtp, exports.sendOtpSuccessSpendManagementSetUp = _a.sendOtpSuccess, exports.sendOtpFailureSpendManagementSetUp = _a.sendOtpFailure, exports.verifyOtpSpendManagementSetUp = _a.verifyOtp, exports.verifyOtpSuccessSpendManagementSetUp = _a.verifyOtpSuccess, exports.verifyOtpFailureSpendManagementSetUp = _a.verifyOtpFailure, exports.saveIndustryAndIncDateInLocalStore = _a.saveIndustryAndIncDateInLocalStore, exports.clearSetupViewDataInLocalStore = _a.clearSetupViewDataInLocalStore, exports.clearSetupView = _a.clearSetupView, exports.applyKycDocumentAutofillForSetup = _a.applyKycDocumentAutofillForSetup, exports.applyKybDocumentAutofillForSetup = _a.applyKybDocumentAutofillForSetup, exports.clearKycKybAutofillForSetup = _a.clearKycKybAutofillForSetup;
326
360
  exports.default = setupView.reducer;
@@ -16,7 +16,7 @@ import { CompanyOfficerType } from '../../companyView/types/companyPassport/comp
16
16
  import { CompanyView } from '../../companyView/types/companyView';
17
17
  import { AccountTypeSubConfigCodeKeyType } from '../billPay/billPayConfig/billPayConfigState';
18
18
  import { PlaidAccountKeyType, PlaidConnectionDetails } from '../plaidAccount/plaidAccountViewState';
19
- import { CompanyAndIdentityDetails, CompanyOfficerLocalData, PrimaryContactLocalData, SetupViewType } from './setupViewState';
19
+ import { CompanyAndIdentityDetails, CompanyOfficerLocalData, PrimaryContactLocalData, SetupViewState, SetupViewType } from './setupViewState';
20
20
  export interface SetupView {
21
21
  accountFetchStatus: FetchStateAndError;
22
22
  accountUpdateStatus: FetchStateAndError;
@@ -100,6 +100,7 @@ export interface CompanyDetails {
100
100
  }
101
101
  interface CompanyAndOfficerLocalData {
102
102
  companyOfficerLocalData: Record<CompanyOfficerType, CompanyOfficersDetails | undefined>;
103
+ parsingDocumentFileIds: ID[];
103
104
  companyDetailsLocalData?: CompanyDetails;
104
105
  }
105
106
  export interface BusinessVerificationDetails extends CompanyAndOfficerLocalData {
@@ -109,7 +110,7 @@ export interface BusinessVerificationDetails extends CompanyAndOfficerLocalData
109
110
  }
110
111
  export declare function getCommonSetupViewDetails(state: RootState, companyId: ID, setupViewType: SetupViewType, plaidAccountKeyType: PlaidAccountKeyType): SetupView;
111
112
  export declare function getBusinessVerificationDetails(state: RootState, companyId: ID): BusinessVerificationDetails;
112
- export declare const getCompanyAndIdentityDetails: (state: RootState, companyId: ID, companyAndIdentityDetails: CompanyAndIdentityDetails) => CompanyAndOfficerLocalData;
113
+ export declare const getCompanyAndIdentityDetails: (state: RootState, companyId: ID, companyAndIdentityDetails: CompanyAndIdentityDetails & Pick<SetupViewState, "parsingDocumentFileIds">) => CompanyAndOfficerLocalData;
113
114
  export declare const getAllFundingAccounts: (depositAccounts: DepositAccount[], paymentAccounts: PaymentAccount[], paymentAccountBalanceFetchStatus: Record<ID, FetchStateAndError>, includeOnlyVerifiedAccounts?: boolean) => FundingAccount[];
114
115
  export declare const mapDepositAccToFundingAccount: (depositAcc: DepositAccount) => FundingAccount;
115
116
  export declare const mapDepositAccountWithLimitToFundingAccount: (depositAcc: DepositAccountWithLimit) => FundingAccount;
@@ -92,15 +92,17 @@ function getBusinessVerificationDetails(state, companyId) {
92
92
  const { setupViewState, countryListState } = state;
93
93
  const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, updateStatus, } = setupViewState;
94
94
  const companyView = (0, getCompanyView_1.getCompanyView)(state, companyId, []);
95
- const { companyDetailsLocalData, companyOfficerLocalData } = (0, exports.getCompanyAndIdentityDetails)(state, companyId, {
95
+ const { companyDetailsLocalData, companyOfficerLocalData, parsingDocumentFileIds } = (0, exports.getCompanyAndIdentityDetails)(state, companyId, {
96
96
  companyDetails,
97
97
  companyOfficerUpdateStatus,
98
98
  primaryContactDetails,
99
+ parsingDocumentFileIds: setupViewState.parsingDocumentFileIds,
99
100
  });
100
101
  const allNationalityCountries = countryListState.byCountryListCode.nationalityCountryList.countries;
101
102
  return {
102
103
  companyDetailsLocalData,
103
104
  companyOfficerLocalData,
105
+ parsingDocumentFileIds,
104
106
  companyView,
105
107
  updateStatus,
106
108
  allNationalityCountries,
@@ -211,6 +213,7 @@ const getCompanyAndIdentityDetails = (state, companyId, companyAndIdentityDetail
211
213
  return {
212
214
  companyDetailsLocalData,
213
215
  companyOfficerLocalData,
216
+ parsingDocumentFileIds: companyAndIdentityDetails.parsingDocumentFileIds,
214
217
  };
215
218
  };
216
219
  exports.getCompanyAndIdentityDetails = getCompanyAndIdentityDetails;
@@ -105,6 +105,13 @@ export interface CompanyAndIdentityDetails {
105
105
  };
106
106
  }
107
107
  export interface SetupViewState extends CompanyAndIdentityDetails {
108
+ /**
109
+ * File IDs currently being parsed by the AI autofill epic. Populated when
110
+ * `parseUploadedKyc/KybDocument` dispatches and cleared when the
111
+ * corresponding apply / failure action fires. Drives the "AI is reading
112
+ * your document" overlay on the document upload field.
113
+ */
114
+ parsingDocumentFileIds: ID[];
108
115
  updateStatus: FetchStateAndError;
109
116
  }
110
117
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.85-beta0ND",
3
+ "version": "5.0.85-beta1ND",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",