@zeniai/client-epic-state 5.0.84-beta0ND → 5.0.84-beta24RJ

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 (87) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +0 -1
  3. package/lib/entity/company/companyPayload.d.ts +0 -2
  4. package/lib/entity/company/companyPayload.js +0 -2
  5. package/lib/entity/company/companyStateTypes.d.ts +0 -2
  6. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -0
  7. package/lib/entity/jeSchedules/jeSchedulesPayload.js +7 -0
  8. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -0
  9. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +0 -1
  10. package/lib/entity/paymentAccount/paymentAccountSelector.js +0 -4
  11. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  12. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  13. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  14. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  15. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  16. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  17. package/lib/entity/tenant/tenantPayload.d.ts +0 -19
  18. package/lib/entity/tenant/tenantReducer.d.ts +28 -49
  19. package/lib/entity/tenant/tenantReducer.js +5 -111
  20. package/lib/entity/tenant/tenantState.d.ts +0 -21
  21. package/lib/epic.d.ts +1 -6
  22. package/lib/epic.js +1 -7
  23. package/lib/esm/commonStateTypes/animations.js +0 -1
  24. package/lib/esm/entity/company/companyPayload.js +0 -2
  25. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +7 -0
  26. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +0 -3
  27. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  28. package/lib/esm/entity/tenant/tenantReducer.js +3 -108
  29. package/lib/esm/epic.js +1 -7
  30. package/lib/esm/index.js +6 -9
  31. package/lib/esm/view/companyView/companyViewReducer.js +1 -45
  32. package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +0 -4
  33. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +50 -168
  34. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +0 -14
  35. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +0 -13
  36. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +52 -71
  37. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +0 -2
  38. package/lib/index.d.ts +8 -12
  39. package/lib/index.js +21 -36
  40. package/lib/view/companyView/companyViewReducer.d.ts +1 -11
  41. package/lib/view/companyView/companyViewReducer.js +3 -47
  42. package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +0 -1
  43. package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +0 -4
  44. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  45. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +0 -3
  46. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +4 -41
  47. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +51 -170
  48. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -7
  49. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +1 -21
  50. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +0 -37
  51. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +1 -14
  52. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +2 -24
  53. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +53 -72
  54. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +0 -4
  55. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +0 -2
  56. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +0 -12
  57. package/package.json +1 -1
  58. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +0 -21
  59. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -54
  60. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -50
  61. package/lib/esm/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +0 -25
  62. package/lib/esm/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +0 -79
  63. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -45
  64. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -40
  65. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -49
  66. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -58
  67. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -12
  68. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -205
  69. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -28
  70. package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.d.ts +0 -9
  71. package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +0 -29
  72. package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.d.ts +0 -10
  73. package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +0 -83
  74. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +0 -7
  75. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -49
  76. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +0 -9
  77. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -44
  78. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +0 -8
  79. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -53
  80. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +0 -8
  81. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -62
  82. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +0 -27
  83. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -15
  84. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +0 -24
  85. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -213
  86. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +0 -125
  87. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -32
@@ -81,21 +81,9 @@ export interface SetupViewLocalData {
81
81
  */
82
82
  export interface CompanyAndIdentityDetails {
83
83
  companyDetails: {
84
- /**
85
- * Field names from {@link CompanyDetailsLocalData} that were populated by AI
86
- * autofill from an uploaded KYB document. Drives the ✦ sparkle in the form.
87
- * Always present (empty when no autofill has run yet).
88
- */
89
- autoFilledFields: string[];
90
84
  localData?: CompanyDetailsLocalData;
91
85
  };
92
86
  companyOfficerUpdateStatus: Record<CompanyOfficerType, {
93
- /**
94
- * Field names from {@link CompanyOfficerLocalData} populated by AI autofill
95
- * from an uploaded KYC identity document. Drives the ✦ sparkle in the form.
96
- * Always present (empty when no autofill has run yet).
97
- */
98
- autoFilledFields: string[];
99
87
  otpverificationStatus: FetchStateAndError;
100
88
  sendOtpStatus: FetchStateAndError;
101
89
  localData?: CompanyOfficerLocalData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.84-beta0ND",
3
+ "version": "5.0.84-beta24RJ",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,21 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../reducer';
3
- import { ZeniAPI } from '../../../zeniAPI';
4
- import { initEmailConnectOAuth, initEmailConnectOAuthFailure, initEmailConnectOAuthSuccess } from '../tenantReducer';
5
- export type ActionType = ReturnType<typeof initEmailConnectOAuth> | ReturnType<typeof initEmailConnectOAuthSuccess> | ReturnType<typeof initEmailConnectOAuthFailure>;
6
- export type NavigateFn = (url: string) => void;
7
- export declare const initEmailConnectOAuthEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI, navigate?: NavigateFn) => import("rxjs").Observable<{
8
- payload: {
9
- tenantId: string;
10
- provider: "gmail" | "outlook";
11
- authorizationUrl: string;
12
- };
13
- type: "tenant/initEmailConnectOAuthSuccess";
14
- } | {
15
- payload: {
16
- tenantId: string;
17
- provider: "gmail" | "outlook";
18
- status: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
19
- };
20
- type: "tenant/initEmailConnectOAuthFailure";
21
- }>;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initEmailConnectOAuthEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const tenantReducer_1 = require("../tenantReducer");
8
- const defaultNavigate = (url) => {
9
- // Production path: full-page redirect. The user's session continues on the
10
- // provider's consent screen and lands back on this app via auth's HTML
11
- // callback page (which itself redirects to redirect_after_url with the
12
- // result encoded as a query param).
13
- if (typeof window !== 'undefined') {
14
- window.location.href = url;
15
- }
16
- };
17
- // Backs the new POST /1.0/connectors/email/<provider>/init endpoint on the
18
- // auth service. The endpoint creates a CSRF state token in the auth NDB
19
- // store and returns the provider's authorization_url; this epic then drives
20
- // a full-page redirect so the user lands on Google's / Microsoft's consent
21
- // screen. After consent the user lands on auth's callback, which writes the
22
- // resulting tokens through to tenant and redirects the browser back to
23
- // ``redirectAfterUrl`` with ``?email_connect_result=<json>`` for the
24
- // integrations page to consume on mount.
25
- const initEmailConnectOAuthEpic = (actions$, _state$, zeniAPI,
26
- // Test seam: callers can override to assert intended URL without actually
27
- // navigating. Default is full-page redirect via window.location.
28
- navigate = defaultNavigate) => actions$.pipe((0, operators_1.filter)(tenantReducer_1.initEmailConnectOAuth.match), (0, operators_1.switchMap)((action) => zeniAPI
29
- .postAndGetJSON(`${zeniAPI.apiEndPoints.authMicroServiceBaseUrl}/1.0/connectors/email/${action.payload.provider}/init`, { redirect_after_url: action.payload.redirectAfterUrl }, { 'zeni-tenant-id': action.payload.tenantId })
30
- .pipe((0, operators_1.mergeMap)((response) => {
31
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
32
- // Fire-and-forget side effect — once the browser navigates,
33
- // any further state we'd dispatch here is irrelevant. We still
34
- // emit the success action so subscribers (tests, analytics)
35
- // can observe the URL the epic decided to navigate to.
36
- navigate(response.data.authorization_url);
37
- return (0, rxjs_1.from)([
38
- (0, tenantReducer_1.initEmailConnectOAuthSuccess)(action.payload.tenantId, action.payload.provider, response.data.authorization_url),
39
- ]);
40
- }
41
- const status = response.status ??
42
- (0, responsePayload_1.createZeniAPIStatus)(`Failed to start ${action.payload.provider} connection. Please try again.`);
43
- return (0, rxjs_1.from)([
44
- (0, tenantReducer_1.initEmailConnectOAuthFailure)(action.payload.tenantId, action.payload.provider, status),
45
- ]);
46
- }), (0, operators_1.catchError)((error) => {
47
- const message = error instanceof Error
48
- ? error.message
49
- : `Unexpected error starting ${action.payload.provider} connection.`;
50
- return (0, rxjs_1.from)([
51
- (0, tenantReducer_1.initEmailConnectOAuthFailure)(action.payload.tenantId, action.payload.provider, (0, responsePayload_1.createZeniAPIStatus)(message)),
52
- ]);
53
- }))));
54
- exports.initEmailConnectOAuthEpic = initEmailConnectOAuthEpic;
@@ -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,25 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateTenantCapitalizationOnboardingDismissed } from '../../../../entity/tenant/tenantReducer';
4
- import { isSuccessResponse } from '../../../../responsePayload';
5
- import { dismissCapitalizationOnboarding } from '../../companyViewReducer';
6
- export const dismissCapitalizationOnboardingEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(dismissCapitalizationOnboarding.match), switchMap((action) => {
7
- const { companyId, popupType } = action.payload;
8
- const tenantId = Object.values(state$.value.tenantState.tenantsById).find((t) => t.companyId === companyId)?.tenantId;
9
- const body = popupType === 'prepaid'
10
- ? { capitalization_onboarding_shown_for_prepaid: true }
11
- : { capitalization_onboarding_shown_for_fixed_asset: true };
12
- return zeniAPI
13
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, body)
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response) && tenantId != null) {
16
- return from([
17
- updateTenantCapitalizationOnboardingDismissed({
18
- tenantId,
19
- popupType,
20
- }),
21
- ]);
22
- }
23
- return from([]);
24
- }), catchError(() => from([])));
25
- }));
@@ -1,79 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateCompanies } from '../../../../entity/company/companyReducer';
4
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
- import { updateTenantCapitalizationOnboardingDismissed, updateTenantCapitalizationThreshold, } from '../../../../entity/tenant/tenantReducer';
6
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
7
- import { updateCapitalizationThreshold, updateCapitalizationThresholdFailure, updateCapitalizationThresholdSuccess, } from '../../companyViewReducer';
8
- export const updateCapitalizationThresholdEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateCapitalizationThreshold.match), switchMap((action) => {
9
- const { companyId, capitalizationThreshold, capitalizationThresholdMaxCeiling, dismissOnboardingForPopupType, } = action.payload;
10
- const tenantId = Object.values(state$.value.tenantState.tenantsById).find((t) => t.companyId === companyId)?.tenantId;
11
- const body = {
12
- capitalization_threshold: capitalizationThreshold,
13
- capitalization_threshold_max_ceiling: capitalizationThresholdMaxCeiling,
14
- };
15
- if (dismissOnboardingForPopupType === 'prepaid') {
16
- body.capitalization_onboarding_shown_for_prepaid = true;
17
- }
18
- else if (dismissOnboardingForPopupType === 'fixed_asset') {
19
- body.capitalization_onboarding_shown_for_fixed_asset = true;
20
- }
21
- return zeniAPI
22
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, body)
23
- .pipe(mergeMap((response) => {
24
- if (isSuccessResponse(response)) {
25
- const companies = response.data?.companies ?? [];
26
- const actions = [];
27
- if (companies.length > 0) {
28
- actions.push(updateCompanies({
29
- payload: companies,
30
- schema: {},
31
- }));
32
- }
33
- if (tenantId != null) {
34
- actions.push(updateTenantCapitalizationThreshold({
35
- tenantId,
36
- capitalizationThreshold,
37
- capitalizationThresholdMaxCeiling,
38
- }));
39
- if (dismissOnboardingForPopupType != null) {
40
- actions.push(updateTenantCapitalizationOnboardingDismissed({
41
- tenantId,
42
- popupType: dismissOnboardingForPopupType,
43
- }));
44
- }
45
- }
46
- actions.push(updateCapitalizationThresholdSuccess());
47
- actions.push(openSnackbar({
48
- messageSection: 'capitalization_threshold_update',
49
- messageText: 'success',
50
- type: 'success',
51
- }));
52
- return from(actions);
53
- }
54
- else {
55
- return from([
56
- updateCapitalizationThresholdFailure({
57
- status: response.status,
58
- }),
59
- openSnackbar({
60
- messageSection: 'capitalization_threshold_update',
61
- messageText: 'failed',
62
- type: 'error',
63
- }),
64
- ]);
65
- }
66
- }), catchError((error) => from([
67
- updateCapitalizationThresholdFailure({
68
- status: createZeniAPIStatus('Unexpected error', 'Update Capitalization Threshold errored out' +
69
- (error instanceof Error
70
- ? error.message
71
- : JSON.stringify(error))),
72
- }),
73
- openSnackbar({
74
- messageSection: 'capitalization_threshold_update',
75
- messageText: 'failed',
76
- type: 'error',
77
- }),
78
- ])));
79
- }));
@@ -1,45 +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 = (section, row) => ({
15
- key: row.key,
16
- section,
17
- status: toPhaseStatus(row.status),
18
- startedAt: row.started_at,
19
- completedAt: row.completed_at,
20
- });
21
- const toCounts = (payload) => ({
22
- customerCount: payload?.customer_count ?? 0,
23
- glAccountCount: payload?.gl_account_count ?? 0,
24
- targetTransactionCount: payload?.target_transaction_count ?? 0,
25
- transactionCount: payload?.transaction_count ?? 0,
26
- vendorCount: payload?.vendor_count ?? 0,
27
- });
28
- export const fetchAiAgentsActivationStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchAiAgentsActivationStatus.match), mergeMap(() => {
29
- const url = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;
30
- return zeniAPI
31
- .getJSON(url)
32
- .pipe(mergeMap((response) => {
33
- if (isSuccessResponse(response) && response.data != null) {
34
- const ledgerPhases = (response.data.ledger_section ?? []).map((row) => toPhase('ledger', row));
35
- const backgroundPhases = (response.data.background_section ?? []).map((row) => toPhase('background', row));
36
- return of(fetchAiAgentsActivationStatusSuccess({
37
- ledgerPhases,
38
- backgroundPhases,
39
- counts: toCounts(response.data.counts),
40
- }));
41
- }
42
- return of(fetchAiAgentsActivationStatusFailure(response.status));
43
- }), catchError((error) => of(fetchAiAgentsActivationStatusFailure(createZeniAPIStatus('Unexpected Error', 'fetchAiAgentsActivationStatus errored out ' +
44
- JSON.stringify(error))))));
45
- }));
@@ -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,49 +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 } 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
- return zeniAPI
19
- .postAndGetJSON(url, requestPayload)
20
- .pipe(mergeMap((response) => {
21
- if (!isSuccessResponse(response) || response.data == null) {
22
- return of();
23
- }
24
- let result;
25
- switch (documentType) {
26
- case 'certificate_of_incorporation':
27
- result = mapCoiToCompanyDetails(response.data);
28
- break;
29
- case 'tax_ein':
30
- result = mapTaxEinToCompanyDetails(response.data);
31
- break;
32
- }
33
- if (result.autoFilledFieldNames.length === 0) {
34
- return of();
35
- }
36
- const applyAction = target === 'setup'
37
- ? applyKybDocumentAutofillForSetup({
38
- companyId,
39
- values: result.values,
40
- autoFilledFieldNames: result.autoFilledFieldNames,
41
- })
42
- : applyKybDocumentAutofillForOnboarding({
43
- companyId,
44
- values: result.values,
45
- autoFilledFieldNames: result.autoFilledFieldNames,
46
- });
47
- return of(applyAction);
48
- }), catchError(() => of()));
49
- }));
@@ -1,58 +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 } 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
- return zeniAPI
20
- .postAndGetJSON(url, requestPayload)
21
- .pipe(mergeMap((response) => {
22
- if (!isSuccessResponse(response) || response.data == null) {
23
- return of();
24
- }
25
- const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
26
- let result;
27
- switch (documentType) {
28
- case 'passport':
29
- result = mapPassportToOfficer(response.data, allCountries);
30
- break;
31
- case 'driving_license':
32
- result = mapDrivingLicenseToOfficer(response.data);
33
- break;
34
- case 'social_security_card':
35
- result = mapSsnCardToOfficer(response.data);
36
- break;
37
- }
38
- if (result.autoFilledFieldNames.length === 0) {
39
- return of();
40
- }
41
- const applyAction = target === 'setup'
42
- ? applyKycDocumentAutofillForSetup({
43
- companyId,
44
- officerType,
45
- values: result.values,
46
- autoFilledFieldNames: result.autoFilledFieldNames,
47
- })
48
- : applyKycDocumentAutofillForOnboarding({
49
- companyId,
50
- officerType,
51
- values: result.values,
52
- autoFilledFieldNames: result.autoFilledFieldNames,
53
- });
54
- return of(applyAction);
55
- }), catchError(() =>
56
- // Autofill is best-effort; swallow errors silently so the user can keep typing.
57
- of()));
58
- }));
@@ -1,12 +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');