@zeniai/client-epic-state 5.0.92-beta0ND → 5.0.92-betaNB2

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 (107) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +0 -1
  3. package/lib/commonStateTypes/viewAndReport/agingReportStateTypes.d.ts +1 -1
  4. package/lib/entity/accountRecon/accountReconPayload.d.ts +20 -1
  5. package/lib/entity/accountRecon/accountReconPayload.js +23 -1
  6. package/lib/entity/accountRecon/accountReconSelector.d.ts +6 -1
  7. package/lib/entity/accountRecon/accountReconSelector.js +5 -0
  8. package/lib/entity/accountRecon/accountReconState.d.ts +19 -0
  9. package/lib/entity/company/companyPayload.d.ts +0 -4
  10. package/lib/entity/company/companyPayload.js +0 -4
  11. package/lib/entity/company/companyStateTypes.d.ts +0 -4
  12. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksPayload.d.ts +7 -0
  13. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksPayload.js +9 -0
  14. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +7 -0
  15. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +0 -1
  16. package/lib/entity/paymentAccount/paymentAccountSelector.js +0 -4
  17. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  18. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  19. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  20. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  21. package/lib/entity/tenant/tenantPayload.d.ts +0 -1
  22. package/lib/entity/tenant/tenantReducer.d.ts +25 -38
  23. package/lib/entity/tenant/tenantReducer.js +5 -65
  24. package/lib/entity/tenant/tenantState.d.ts +0 -1
  25. package/lib/epic.d.ts +3 -6
  26. package/lib/epic.js +3 -7
  27. package/lib/esm/commonStateTypes/animations.js +0 -1
  28. package/lib/esm/entity/accountRecon/accountReconPayload.js +23 -1
  29. package/lib/esm/entity/accountRecon/accountReconSelector.js +5 -0
  30. package/lib/esm/entity/company/companyPayload.js +0 -4
  31. package/lib/esm/entity/monthEndCloseChecks/monthEndCloseChecksPayload.js +9 -0
  32. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +0 -3
  33. package/lib/esm/entity/tenant/tenantReducer.js +3 -63
  34. package/lib/esm/epic.js +3 -7
  35. package/lib/esm/index.js +8 -11
  36. package/lib/esm/view/expenseAutomationView/epics/accountRecon/parseStatementEpic.js +34 -0
  37. package/lib/esm/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.js +42 -0
  38. package/lib/esm/view/expenseAutomationView/payload/reconciliationPayload.js +73 -0
  39. package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +98 -4
  40. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +20 -0
  41. package/lib/esm/view/expenseAutomationView/types/reconciliationViewState.js +20 -0
  42. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  43. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  44. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  45. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +50 -217
  46. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +1 -7
  47. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +0 -12
  48. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +52 -105
  49. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +1 -6
  50. package/lib/index.d.ts +12 -16
  51. package/lib/index.js +37 -49
  52. package/lib/view/expenseAutomationView/epics/accountRecon/parseStatementEpic.d.ts +6 -0
  53. package/lib/view/expenseAutomationView/epics/accountRecon/parseStatementEpic.js +38 -0
  54. package/lib/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.d.ts +19 -0
  55. package/lib/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.js +46 -0
  56. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +83 -1
  57. package/lib/view/expenseAutomationView/payload/reconciliationPayload.js +75 -0
  58. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +35 -3
  59. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +99 -5
  60. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +5 -1
  61. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +20 -0
  62. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +128 -0
  63. package/lib/view/expenseAutomationView/types/reconciliationViewState.js +21 -0
  64. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  65. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  66. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  67. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +0 -3
  68. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +4 -41
  69. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +51 -219
  70. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -5
  71. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +2 -11
  72. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +0 -40
  73. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +1 -13
  74. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +2 -28
  75. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +53 -106
  76. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +2 -7
  77. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +1 -6
  78. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +0 -19
  79. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListState.d.ts +1 -1
  80. package/package.json +1 -1
  81. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +0 -21
  82. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -54
  83. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -50
  84. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -42
  85. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +0 -29
  86. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -40
  87. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -52
  88. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -59
  89. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -14
  90. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -205
  91. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -28
  92. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +0 -7
  93. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -46
  94. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +0 -8
  95. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +0 -33
  96. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +0 -9
  97. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -44
  98. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +0 -28
  99. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -56
  100. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +0 -30
  101. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -63
  102. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +0 -33
  103. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -17
  104. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +0 -24
  105. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -213
  106. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +0 -125
  107. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -32
@@ -1,50 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
4
- import { initEmailConnectOAuth, initEmailConnectOAuthFailure, initEmailConnectOAuthSuccess, } from '../tenantReducer';
5
- const defaultNavigate = (url) => {
6
- // Production path: full-page redirect. The user's session continues on the
7
- // provider's consent screen and lands back on this app via auth's HTML
8
- // callback page (which itself redirects to redirect_after_url with the
9
- // result encoded as a query param).
10
- if (typeof window !== 'undefined') {
11
- window.location.href = url;
12
- }
13
- };
14
- // Backs the new POST /1.0/connectors/email/<provider>/init endpoint on the
15
- // auth service. The endpoint creates a CSRF state token in the auth NDB
16
- // store and returns the provider's authorization_url; this epic then drives
17
- // a full-page redirect so the user lands on Google's / Microsoft's consent
18
- // screen. After consent the user lands on auth's callback, which writes the
19
- // resulting tokens through to tenant and redirects the browser back to
20
- // ``redirectAfterUrl`` with ``?email_connect_result=<json>`` for the
21
- // integrations page to consume on mount.
22
- export const initEmailConnectOAuthEpic = (actions$, _state$, zeniAPI,
23
- // Test seam: callers can override to assert intended URL without actually
24
- // navigating. Default is full-page redirect via window.location.
25
- navigate = defaultNavigate) => actions$.pipe(filter(initEmailConnectOAuth.match), switchMap((action) => zeniAPI
26
- .postAndGetJSON(`${zeniAPI.apiEndPoints.authMicroServiceBaseUrl}/1.0/connectors/email/${action.payload.provider}/init`, { redirect_after_url: action.payload.redirectAfterUrl }, { 'zeni-tenant-id': action.payload.tenantId })
27
- .pipe(mergeMap((response) => {
28
- if (isSuccessResponse(response) && response.data != null) {
29
- // Fire-and-forget side effect — once the browser navigates,
30
- // any further state we'd dispatch here is irrelevant. We still
31
- // emit the success action so subscribers (tests, analytics)
32
- // can observe the URL the epic decided to navigate to.
33
- navigate(response.data.authorization_url);
34
- return from([
35
- initEmailConnectOAuthSuccess(action.payload.tenantId, action.payload.provider, response.data.authorization_url),
36
- ]);
37
- }
38
- const status = response.status ??
39
- createZeniAPIStatus(`Failed to start ${action.payload.provider} connection. Please try again.`);
40
- return from([
41
- initEmailConnectOAuthFailure(action.payload.tenantId, action.payload.provider, status),
42
- ]);
43
- }), catchError((error) => {
44
- const message = error instanceof Error
45
- ? error.message
46
- : `Unexpected error starting ${action.payload.provider} connection.`;
47
- return from([
48
- initEmailConnectOAuthFailure(action.payload.tenantId, action.payload.provider, createZeniAPIStatus(message)),
49
- ]);
50
- }))));
@@ -1,42 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
4
- import { fetchAiAgentsActivationStatus, fetchAiAgentsActivationStatusFailure, fetchAiAgentsActivationStatusSuccess, } from '../../onboardingCustomerViewReducer';
5
- const toPhaseStatus = (raw) => {
6
- if (raw === 'idle' ||
7
- raw === 'starting' ||
8
- raw === 'building' ||
9
- raw === 'ready') {
10
- return raw;
11
- }
12
- return 'idle';
13
- };
14
- const toPhase = (row) => ({
15
- key: row.key,
16
- status: toPhaseStatus(row.status),
17
- startedAt: row.started_at,
18
- completedAt: row.completed_at,
19
- });
20
- const toCounts = (payload) => ({
21
- customerCount: payload?.customer_count ?? 0,
22
- glAccountCount: payload?.gl_account_count ?? 0,
23
- targetTransactionCount: payload?.target_transaction_count ?? 0,
24
- transactionCount: payload?.transaction_count ?? 0,
25
- vendorCount: payload?.vendor_count ?? 0,
26
- });
27
- export const fetchAiAgentsActivationStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchAiAgentsActivationStatus.match), mergeMap(() => {
28
- const url = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;
29
- return zeniAPI
30
- .getJSON(url)
31
- .pipe(mergeMap((response) => {
32
- if (isSuccessResponse(response) && response.data != null) {
33
- const phases = (response.data.phases ?? []).map(toPhase);
34
- return of(fetchAiAgentsActivationStatusSuccess({
35
- phases,
36
- counts: toCounts(response.data.counts),
37
- }));
38
- }
39
- return of(fetchAiAgentsActivationStatusFailure(response.status));
40
- }), catchError((error) => of(fetchAiAgentsActivationStatusFailure(createZeniAPIStatus('Unexpected Error', 'fetchAiAgentsActivationStatus errored out ' +
41
- JSON.stringify(error))))));
42
- }));
@@ -1,29 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
5
- import { acknowledgeOnboardingAiActivationViewed, acknowledgeOnboardingAiActivationViewedFailure, acknowledgeOnboardingAiActivationViewedSuccess, } from '../../onboardingCustomerViewReducer';
6
- export const acknowledgeOnboardingAiActivationViewedEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(acknowledgeOnboardingAiActivationViewed.match), mergeMap((action) => {
7
- const { companyId } = action.payload;
8
- const payload = {
9
- is_onboarding_ai_activation_viewed: true,
10
- };
11
- return zeniAPI
12
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
13
- .pipe(mergeMap((response) => {
14
- if (isSuccessResponse(response) && response.data != null) {
15
- const actions = [
16
- updateCompanies({
17
- payload: response.data.companies,
18
- schema: {},
19
- }),
20
- acknowledgeOnboardingAiActivationViewedSuccess(),
21
- ];
22
- return from(actions);
23
- }
24
- return of(acknowledgeOnboardingAiActivationViewedFailure(response.status));
25
- }),
26
- // Best-effort — failure is silent; cascade just runs again next visit.
27
- catchError((error) => of(acknowledgeOnboardingAiActivationViewedFailure(createZeniAPIStatus('Unexpected Error', 'Acknowledge - Onboarding AI Activation Viewed errored out' +
28
- JSON.stringify(error))))));
29
- }));
@@ -1,40 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
6
- import { acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamFailure, acknowledgeOnboardingAiFinanceTeamSuccess, } from '../../onboardingCustomerViewReducer';
7
- export const acknowledgeOnboardingAiFinanceTeamEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(acknowledgeOnboardingAiFinanceTeam.match), mergeMap((action) => {
8
- const { companyId } = action.payload;
9
- const payload = {
10
- is_onboarding_ai_finance_team_acknowledged: true,
11
- };
12
- return zeniAPI
13
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response) && response.data != null) {
16
- const actions = [
17
- updateCompanies({
18
- payload: response.data.companies,
19
- schema: {},
20
- }),
21
- acknowledgeOnboardingAiFinanceTeamSuccess(),
22
- ];
23
- return from(actions);
24
- }
25
- else {
26
- return of(openSnackbar({
27
- messageSection: 'onboarding_customer_view_complete',
28
- messageText: 'failed',
29
- type: 'error',
30
- variables: [
31
- {
32
- variableName: '_api-error_',
33
- variableValue: response.status.message,
34
- },
35
- ],
36
- }), acknowledgeOnboardingAiFinanceTeamFailure(response.status));
37
- }
38
- }), catchError((error) => of(acknowledgeOnboardingAiFinanceTeamFailure(createZeniAPIStatus('Unexpected Error', 'Acknowledge - Onboarding AI Finance Team errored out' +
39
- JSON.stringify(error))))));
40
- }));
@@ -1,52 +0,0 @@
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
- }));
@@ -1,59 +0,0 @@
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
- }));
@@ -1,14 +0,0 @@
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');
@@ -1,205 +0,0 @@
1
- /**
2
- * Pure mappers from ExtendAI parser payloads to our form-side local-data shapes.
3
- *
4
- * Each mapper filters out fields below KYC_KYB_AUTOFILL_MIN_CONFIDENCE and returns
5
- * both the merged values and the list of field names that were autofilled so the
6
- * UI can show the ✦ AI badge next to each.
7
- */
8
- import { date } from '../../../zeniDayJS';
9
- import { toZeniUrl } from '../../../zeniUrl';
10
- import { KYC_KYB_AUTOFILL_MIN_CONFIDENCE, } from './types/kycKybAutofill';
11
- const emptyResult = () => ({
12
- values: {},
13
- autoFilledFieldNames: [],
14
- });
15
- const isConfident = (field) => {
16
- if (field == null) {
17
- return false;
18
- }
19
- if (field.value == null) {
20
- return false;
21
- }
22
- return field.confidence >= KYC_KYB_AUTOFILL_MIN_CONFIDENCE;
23
- };
24
- const assignAutofilledValue = (result, key, value) => {
25
- if (value == null) {
26
- return;
27
- }
28
- if (typeof value === 'string' && value.trim() === '') {
29
- return;
30
- }
31
- result.values[key] = value;
32
- result.autoFilledFieldNames.push(key);
33
- };
34
- const tryParseDate = (rawDate) => {
35
- const parsedDate = date(rawDate);
36
- if (parsedDate.isValid()) {
37
- return parsedDate;
38
- }
39
- return undefined;
40
- };
41
- const normalizeNationality = (rawNationality, countries) => {
42
- const needle = rawNationality.trim().toLowerCase();
43
- if (needle === '') {
44
- return undefined;
45
- }
46
- // Exact ISO-2 / ISO-3 match.
47
- const isoMatch = countries.find((country) => country.countryCode.toLowerCase() === needle);
48
- if (isoMatch != null) {
49
- return isoMatch.countryCode;
50
- }
51
- // Common nationality adjectives map to country names (e.g. "American" → "United States").
52
- const adjectiveToCountry = {
53
- american: 'united states',
54
- british: 'united kingdom',
55
- indian: 'india',
56
- canadian: 'canada',
57
- australian: 'australia',
58
- german: 'germany',
59
- french: 'france',
60
- chinese: 'china',
61
- japanese: 'japan',
62
- mexican: 'mexico',
63
- brazilian: 'brazil',
64
- };
65
- const resolvedName = adjectiveToCountry[needle] ?? needle;
66
- const nameMatch = countries.find((country) => country.countryName.toLowerCase() === resolvedName);
67
- return nameMatch?.countryCode;
68
- };
69
- const splitFullName = (fullName) => {
70
- const parts = fullName.trim().split(/\s+/);
71
- if (parts.length === 1) {
72
- return { firstName: parts[0], lastName: '' };
73
- }
74
- const lastName = parts[parts.length - 1];
75
- const firstName = parts.slice(0, -1).join(' ');
76
- return { firstName, lastName };
77
- };
78
- /** Passport → Company Officer. */
79
- export const mapPassportToOfficer = (parsed, allNationalityCountries) => {
80
- const result = emptyResult();
81
- if (isConfident(parsed.first_name)) {
82
- assignAutofilledValue(result, 'firstName', parsed.first_name.value);
83
- }
84
- if (isConfident(parsed.last_name)) {
85
- assignAutofilledValue(result, 'lastName', parsed.last_name.value);
86
- }
87
- if (isConfident(parsed.date_of_birth)) {
88
- const parsedDate = tryParseDate(parsed.date_of_birth.value);
89
- if (parsedDate != null) {
90
- assignAutofilledValue(result, 'birthday', parsedDate);
91
- }
92
- }
93
- if (isConfident(parsed.nationality)) {
94
- const isoCode = normalizeNationality(parsed.nationality.value, allNationalityCountries);
95
- if (isoCode != null) {
96
- assignAutofilledValue(result, 'nationalityCountryCode', isoCode);
97
- }
98
- }
99
- return result;
100
- };
101
- /** Driving License → Company Officer. */
102
- export const mapDrivingLicenseToOfficer = (parsed) => {
103
- const result = emptyResult();
104
- if (isConfident(parsed.first_name)) {
105
- assignAutofilledValue(result, 'firstName', parsed.first_name.value);
106
- }
107
- if (isConfident(parsed.last_name)) {
108
- assignAutofilledValue(result, 'lastName', parsed.last_name.value);
109
- }
110
- if (isConfident(parsed.date_of_birth)) {
111
- const parsedDate = tryParseDate(parsed.date_of_birth.value);
112
- if (parsedDate != null) {
113
- assignAutofilledValue(result, 'birthday', parsedDate);
114
- }
115
- }
116
- // address_* fields are mapped at a higher layer (addressView reducer) — kept here as values
117
- // only, the consuming epic dispatches the address payload separately.
118
- return result;
119
- };
120
- /** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
121
- export const mapSsnCardToOfficer = (parsed) => {
122
- const result = emptyResult();
123
- if (isConfident(parsed.full_name)) {
124
- const { firstName, lastName } = splitFullName(parsed.full_name.value);
125
- if (firstName !== '') {
126
- assignAutofilledValue(result, 'firstName', firstName);
127
- }
128
- if (lastName !== '') {
129
- assignAutofilledValue(result, 'lastName', lastName);
130
- }
131
- }
132
- return result;
133
- };
134
- /** Certificate of Incorporation → Company Details. */
135
- export const mapCoiToCompanyDetails = (parsed) => {
136
- const result = emptyResult();
137
- if (isConfident(parsed.company_legal_name)) {
138
- assignAutofilledValue(result, 'companyLegalName', parsed.company_legal_name.value);
139
- }
140
- if (isConfident(parsed.ein)) {
141
- assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
142
- }
143
- if (isConfident(parsed.phone_number)) {
144
- assignAutofilledValue(result, 'phone', parsed.phone_number.value);
145
- }
146
- if (isConfident(parsed.product_description)) {
147
- assignAutofilledValue(result, 'companyDescription', parsed.product_description.value);
148
- }
149
- if (isConfident(parsed.website)) {
150
- try {
151
- assignAutofilledValue(result, 'website', toZeniUrl(parsed.website.value));
152
- }
153
- catch {
154
- // ignore — malformed URL string from OCR
155
- }
156
- }
157
- if (isConfident(parsed.industry)) {
158
- assignAutofilledValue(result, 'companyIndustryType', parsed.industry.value);
159
- }
160
- if (isConfident(parsed.sub_industry)) {
161
- assignAutofilledValue(result, 'companySubIndustry', parsed.sub_industry.value);
162
- }
163
- if (isConfident(parsed.type_of_incorporation)) {
164
- assignAutofilledValue(result, 'typeOfIncorporation', parsed.type_of_incorporation.value);
165
- }
166
- if (isConfident(parsed.date_of_incorporation)) {
167
- const parsedDate = tryParseDate(parsed.date_of_incorporation.value);
168
- if (parsedDate != null) {
169
- assignAutofilledValue(result, 'incDate', parsedDate);
170
- }
171
- }
172
- if (isConfident(parsed.state_of_incorporation)) {
173
- assignAutofilledValue(result, 'stateOfIncorporation', parsed.state_of_incorporation.value);
174
- }
175
- if (isConfident(parsed.countries_of_operations)) {
176
- assignAutofilledValue(result, 'countriesOfOperations', parsed.countries_of_operations.value);
177
- }
178
- if (isConfident(parsed.source_of_funds)) {
179
- assignAutofilledValue(result, 'sourceOfFunds', parsed.source_of_funds.value);
180
- }
181
- if (isConfident(parsed.transaction_volume_expectations)) {
182
- assignAutofilledValue(result, 'transactionVolume', parsed.transaction_volume_expectations.value);
183
- }
184
- if (isConfident(parsed.purpose_of_account)) {
185
- assignAutofilledValue(result, 'purposeOfAccount', parsed.purpose_of_account.value);
186
- }
187
- if (isConfident(parsed.regulated_status)) {
188
- assignAutofilledValue(result, 'regulatedStatus', parsed.regulated_status.value);
189
- }
190
- if (isConfident(parsed.us_nexus)) {
191
- assignAutofilledValue(result, 'usNexus', parsed.us_nexus.value);
192
- }
193
- return result;
194
- };
195
- /** Tax EIN letter → Company Details. */
196
- export const mapTaxEinToCompanyDetails = (parsed) => {
197
- const result = emptyResult();
198
- if (isConfident(parsed.legal_business_name)) {
199
- assignAutofilledValue(result, 'companyLegalName', parsed.legal_business_name.value);
200
- }
201
- if (isConfident(parsed.ein)) {
202
- assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
203
- }
204
- return result;
205
- };
@@ -1,28 +0,0 @@
1
- /**
2
- * Shared types for the KYC / KYB document autofill flow that lives inside the
3
- * commonSetup feature (Setup pages + Onboarding both consume it via the same
4
- * selector view; there is no separate state slice).
5
- *
6
- * Backed by document-communication-agent `POST /1.0/documents/process/sync`,
7
- * which proxies document-service ExtendAI parsers and returns one of the
8
- * parser payloads below — each value shaped as `{value, confidence}` per field.
9
- */
10
- /** Confidence floor below which we drop an autofill candidate. */
11
- export const KYC_KYB_AUTOFILL_MIN_CONFIDENCE = 0.5;
12
- /**
13
- * Maps the form-side {@link KycSelectDocumentType} (camelCase) to the
14
- * parser-side {@link KycProvidedDocumentType} (snake_case). Returns `null` for
15
- * `stateId`, which has no parser today.
16
- */
17
- export const toKycProvidedDocumentType = (selectType) => {
18
- switch (selectType) {
19
- case 'driverLicense':
20
- return 'driving_license';
21
- case 'passport':
22
- return 'passport';
23
- case 'ssnCard':
24
- return 'social_security_card';
25
- case 'stateId':
26
- return null;
27
- }
28
- };
@@ -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 { fetchAiAgentsActivationStatus, fetchAiAgentsActivationStatusFailure, fetchAiAgentsActivationStatusSuccess } from '../../onboardingCustomerViewReducer';
6
- export type ActionType = ReturnType<typeof fetchAiAgentsActivationStatus> | ReturnType<typeof fetchAiAgentsActivationStatusSuccess> | ReturnType<typeof fetchAiAgentsActivationStatusFailure>;
7
- export declare const fetchAiAgentsActivationStatusEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchAiAgentsActivationStatusEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../../../responsePayload");
7
- const onboardingCustomerViewReducer_1 = require("../../onboardingCustomerViewReducer");
8
- const toPhaseStatus = (raw) => {
9
- if (raw === 'idle' ||
10
- raw === 'starting' ||
11
- raw === 'building' ||
12
- raw === 'ready') {
13
- return raw;
14
- }
15
- return 'idle';
16
- };
17
- const toPhase = (row) => ({
18
- key: row.key,
19
- status: toPhaseStatus(row.status),
20
- startedAt: row.started_at,
21
- completedAt: row.completed_at,
22
- });
23
- const toCounts = (payload) => ({
24
- customerCount: payload?.customer_count ?? 0,
25
- glAccountCount: payload?.gl_account_count ?? 0,
26
- targetTransactionCount: payload?.target_transaction_count ?? 0,
27
- transactionCount: payload?.transaction_count ?? 0,
28
- vendorCount: payload?.vendor_count ?? 0,
29
- });
30
- const fetchAiAgentsActivationStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatus.match), (0, operators_1.mergeMap)(() => {
31
- const url = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;
32
- return zeniAPI
33
- .getJSON(url)
34
- .pipe((0, operators_1.mergeMap)((response) => {
35
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
36
- const phases = (response.data.phases ?? []).map(toPhase);
37
- return (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatusSuccess)({
38
- phases,
39
- counts: toCounts(response.data.counts),
40
- }));
41
- }
42
- return (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatusFailure)(response.status));
43
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatusFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetchAiAgentsActivationStatus errored out ' +
44
- JSON.stringify(error))))));
45
- }));
46
- exports.fetchAiAgentsActivationStatusEpic = fetchAiAgentsActivationStatusEpic;
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
- import { RootState } from '../../../../../reducer';
5
- import { ZeniAPI } from '../../../../../zeniAPI';
6
- import { acknowledgeOnboardingAiActivationViewed, acknowledgeOnboardingAiActivationViewedFailure, acknowledgeOnboardingAiActivationViewedSuccess } from '../../onboardingCustomerViewReducer';
7
- export type ActionType = ReturnType<typeof acknowledgeOnboardingAiActivationViewed> | ReturnType<typeof updateCompanies> | ReturnType<typeof acknowledgeOnboardingAiActivationViewedSuccess> | ReturnType<typeof acknowledgeOnboardingAiActivationViewedFailure>;
8
- export declare const acknowledgeOnboardingAiActivationViewedEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.acknowledgeOnboardingAiActivationViewedEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const companyReducer_1 = require("../../../../../entity/company/companyReducer");
7
- const responsePayload_1 = require("../../../../../responsePayload");
8
- const onboardingCustomerViewReducer_1 = require("../../onboardingCustomerViewReducer");
9
- const acknowledgeOnboardingAiActivationViewedEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(onboardingCustomerViewReducer_1.acknowledgeOnboardingAiActivationViewed.match), (0, operators_1.mergeMap)((action) => {
10
- const { companyId } = action.payload;
11
- const payload = {
12
- is_onboarding_ai_activation_viewed: true,
13
- };
14
- return zeniAPI
15
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
16
- .pipe((0, operators_1.mergeMap)((response) => {
17
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
18
- const actions = [
19
- (0, companyReducer_1.updateCompanies)({
20
- payload: response.data.companies,
21
- schema: {},
22
- }),
23
- (0, onboardingCustomerViewReducer_1.acknowledgeOnboardingAiActivationViewedSuccess)(),
24
- ];
25
- return (0, rxjs_1.from)(actions);
26
- }
27
- return (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.acknowledgeOnboardingAiActivationViewedFailure)(response.status));
28
- }),
29
- // Best-effort — failure is silent; cascade just runs again next visit.
30
- (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.acknowledgeOnboardingAiActivationViewedFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Acknowledge - Onboarding AI Activation Viewed errored out' +
31
- JSON.stringify(error))))));
32
- }));
33
- exports.acknowledgeOnboardingAiActivationViewedEpic = acknowledgeOnboardingAiActivationViewedEpic;
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
- import { RootState } from '../../../../../reducer';
6
- import { ZeniAPI } from '../../../../../zeniAPI';
7
- import { acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamFailure, acknowledgeOnboardingAiFinanceTeamSuccess } from '../../onboardingCustomerViewReducer';
8
- export type ActionType = ReturnType<typeof acknowledgeOnboardingAiFinanceTeam> | ReturnType<typeof updateCompanies> | ReturnType<typeof openSnackbar> | ReturnType<typeof acknowledgeOnboardingAiFinanceTeamSuccess> | ReturnType<typeof acknowledgeOnboardingAiFinanceTeamFailure>;
9
- export declare const acknowledgeOnboardingAiFinanceTeamEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;