@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
@@ -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,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { updateTenantCapitalizationOnboardingDismissed } from '../../../../entity/tenant/tenantReducer';
5
- import { RootState } from '../../../../reducer';
6
- import { ZeniAPI } from '../../../../zeniAPI';
7
- import { dismissCapitalizationOnboarding } from '../../companyViewReducer';
8
- export type ActionType = ReturnType<typeof updateTenantCapitalizationOnboardingDismissed> | ReturnType<typeof openSnackbar> | ReturnType<typeof dismissCapitalizationOnboarding>;
9
- export declare const dismissCapitalizationOnboardingEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dismissCapitalizationOnboardingEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const tenantReducer_1 = require("../../../../entity/tenant/tenantReducer");
7
- const responsePayload_1 = require("../../../../responsePayload");
8
- const companyViewReducer_1 = require("../../companyViewReducer");
9
- const dismissCapitalizationOnboardingEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyViewReducer_1.dismissCapitalizationOnboarding.match), (0, operators_1.switchMap)((action) => {
10
- const { companyId, popupType } = action.payload;
11
- const tenantId = Object.values(state$.value.tenantState.tenantsById).find((t) => t.companyId === companyId)?.tenantId;
12
- const body = popupType === 'prepaid'
13
- ? { capitalization_onboarding_shown_for_prepaid: true }
14
- : { capitalization_onboarding_shown_for_fixed_asset: true };
15
- return zeniAPI
16
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, body)
17
- .pipe((0, operators_1.mergeMap)((response) => {
18
- if ((0, responsePayload_1.isSuccessResponse)(response) && tenantId != null) {
19
- return (0, rxjs_1.from)([
20
- (0, tenantReducer_1.updateTenantCapitalizationOnboardingDismissed)({
21
- tenantId,
22
- popupType,
23
- }),
24
- ]);
25
- }
26
- return (0, rxjs_1.from)([]);
27
- }), (0, operators_1.catchError)(() => (0, rxjs_1.from)([])));
28
- }));
29
- exports.dismissCapitalizationOnboardingEpic = dismissCapitalizationOnboardingEpic;
@@ -1,10 +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 { updateTenantCapitalizationOnboardingDismissed, updateTenantCapitalizationThreshold } from '../../../../entity/tenant/tenantReducer';
6
- import { RootState } from '../../../../reducer';
7
- import { ZeniAPI } from '../../../../zeniAPI';
8
- import { updateCapitalizationThreshold, updateCapitalizationThresholdFailure, updateCapitalizationThresholdSuccess } from '../../companyViewReducer';
9
- export type ActionType = ReturnType<typeof updateCompanies> | ReturnType<typeof updateTenantCapitalizationThreshold> | ReturnType<typeof updateTenantCapitalizationOnboardingDismissed> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateCapitalizationThreshold> | ReturnType<typeof updateCapitalizationThresholdSuccess> | ReturnType<typeof updateCapitalizationThresholdFailure>;
10
- export declare const updateCapitalizationThresholdEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateCapitalizationThresholdEpic = 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 snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
8
- const tenantReducer_1 = require("../../../../entity/tenant/tenantReducer");
9
- const responsePayload_1 = require("../../../../responsePayload");
10
- const companyViewReducer_1 = require("../../companyViewReducer");
11
- const updateCapitalizationThresholdEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyViewReducer_1.updateCapitalizationThreshold.match), (0, operators_1.switchMap)((action) => {
12
- const { companyId, capitalizationThreshold, capitalizationThresholdMaxCeiling, dismissOnboardingForPopupType, } = action.payload;
13
- const tenantId = Object.values(state$.value.tenantState.tenantsById).find((t) => t.companyId === companyId)?.tenantId;
14
- const body = {
15
- capitalization_threshold: capitalizationThreshold,
16
- capitalization_threshold_max_ceiling: capitalizationThresholdMaxCeiling,
17
- };
18
- if (dismissOnboardingForPopupType === 'prepaid') {
19
- body.capitalization_onboarding_shown_for_prepaid = true;
20
- }
21
- else if (dismissOnboardingForPopupType === 'fixed_asset') {
22
- body.capitalization_onboarding_shown_for_fixed_asset = true;
23
- }
24
- return zeniAPI
25
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, body)
26
- .pipe((0, operators_1.mergeMap)((response) => {
27
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
28
- const companies = response.data?.companies ?? [];
29
- const actions = [];
30
- if (companies.length > 0) {
31
- actions.push((0, companyReducer_1.updateCompanies)({
32
- payload: companies,
33
- schema: {},
34
- }));
35
- }
36
- if (tenantId != null) {
37
- actions.push((0, tenantReducer_1.updateTenantCapitalizationThreshold)({
38
- tenantId,
39
- capitalizationThreshold,
40
- capitalizationThresholdMaxCeiling,
41
- }));
42
- if (dismissOnboardingForPopupType != null) {
43
- actions.push((0, tenantReducer_1.updateTenantCapitalizationOnboardingDismissed)({
44
- tenantId,
45
- popupType: dismissOnboardingForPopupType,
46
- }));
47
- }
48
- }
49
- actions.push((0, companyViewReducer_1.updateCapitalizationThresholdSuccess)());
50
- actions.push((0, snackbarReducer_1.openSnackbar)({
51
- messageSection: 'capitalization_threshold_update',
52
- messageText: 'success',
53
- type: 'success',
54
- }));
55
- return (0, rxjs_1.from)(actions);
56
- }
57
- else {
58
- return (0, rxjs_1.from)([
59
- (0, companyViewReducer_1.updateCapitalizationThresholdFailure)({
60
- status: response.status,
61
- }),
62
- (0, snackbarReducer_1.openSnackbar)({
63
- messageSection: 'capitalization_threshold_update',
64
- messageText: 'failed',
65
- type: 'error',
66
- }),
67
- ]);
68
- }
69
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
70
- (0, companyViewReducer_1.updateCapitalizationThresholdFailure)({
71
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'Update Capitalization Threshold errored out' +
72
- (error instanceof Error
73
- ? error.message
74
- : JSON.stringify(error))),
75
- }),
76
- (0, snackbarReducer_1.openSnackbar)({
77
- messageSection: 'capitalization_threshold_update',
78
- messageText: 'failed',
79
- type: 'error',
80
- }),
81
- ])));
82
- }));
83
- exports.updateCapitalizationThresholdEpic = updateCapitalizationThresholdEpic;
@@ -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,49 +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 = (section, row) => ({
18
- key: row.key,
19
- section,
20
- status: toPhaseStatus(row.status),
21
- startedAt: row.started_at,
22
- completedAt: row.completed_at,
23
- });
24
- const toCounts = (payload) => ({
25
- customerCount: payload?.customer_count ?? 0,
26
- glAccountCount: payload?.gl_account_count ?? 0,
27
- targetTransactionCount: payload?.target_transaction_count ?? 0,
28
- transactionCount: payload?.transaction_count ?? 0,
29
- vendorCount: payload?.vendor_count ?? 0,
30
- });
31
- const fetchAiAgentsActivationStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatus.match), (0, operators_1.mergeMap)(() => {
32
- const url = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;
33
- return zeniAPI
34
- .getJSON(url)
35
- .pipe((0, operators_1.mergeMap)((response) => {
36
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
37
- const ledgerPhases = (response.data.ledger_section ?? []).map((row) => toPhase('ledger', row));
38
- const backgroundPhases = (response.data.background_section ?? []).map((row) => toPhase('background', row));
39
- return (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatusSuccess)({
40
- ledgerPhases,
41
- backgroundPhases,
42
- counts: toCounts(response.data.counts),
43
- }));
44
- }
45
- return (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatusFailure)(response.status));
46
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.fetchAiAgentsActivationStatusFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetchAiAgentsActivationStatus errored out ' +
47
- JSON.stringify(error))))));
48
- }));
49
- exports.fetchAiAgentsActivationStatusEpic = fetchAiAgentsActivationStatusEpic;
@@ -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>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.acknowledgeOnboardingAiFinanceTeamEpic = 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 snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
8
- const responsePayload_1 = require("../../../../../responsePayload");
9
- const onboardingCustomerViewReducer_1 = require("../../onboardingCustomerViewReducer");
10
- const acknowledgeOnboardingAiFinanceTeamEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(onboardingCustomerViewReducer_1.acknowledgeOnboardingAiFinanceTeam.match), (0, operators_1.mergeMap)((action) => {
11
- const { companyId } = action.payload;
12
- const payload = {
13
- is_onboarding_ai_finance_team_acknowledged: true,
14
- };
15
- return zeniAPI
16
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
17
- .pipe((0, operators_1.mergeMap)((response) => {
18
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
19
- const actions = [
20
- (0, companyReducer_1.updateCompanies)({
21
- payload: response.data.companies,
22
- schema: {},
23
- }),
24
- (0, onboardingCustomerViewReducer_1.acknowledgeOnboardingAiFinanceTeamSuccess)(),
25
- ];
26
- return (0, rxjs_1.from)(actions);
27
- }
28
- else {
29
- return (0, rxjs_1.of)((0, snackbarReducer_1.openSnackbar)({
30
- messageSection: 'onboarding_customer_view_complete',
31
- messageText: 'failed',
32
- type: 'error',
33
- variables: [
34
- {
35
- variableName: '_api-error_',
36
- variableValue: response.status.message,
37
- },
38
- ],
39
- }), (0, onboardingCustomerViewReducer_1.acknowledgeOnboardingAiFinanceTeamFailure)(response.status));
40
- }
41
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, onboardingCustomerViewReducer_1.acknowledgeOnboardingAiFinanceTeamFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Acknowledge - Onboarding AI Finance Team errored out' +
42
- JSON.stringify(error))))));
43
- }));
44
- exports.acknowledgeOnboardingAiFinanceTeamEpic = acknowledgeOnboardingAiFinanceTeamEpic;
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../../../reducer';
3
- import { ZeniAPI } from '../../../../../zeniAPI';
4
- import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
- import { parseUploadedKybDocument } from '../../kycKybAutofillActions';
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>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseUploadedKybDocumentEpic = 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("../../../../onboardingView/customerView/onboardingCustomerViewReducer");
8
- const kycKybAutofillActions_1 = require("../../kycKybAutofillActions");
9
- const kycKybParseMapper_1 = require("../../kycKybParseMapper");
10
- const setupViewReducer_1 = require("../../setupViewReducer");
11
- const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
12
- const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(kycKybAutofillActions_1.parseUploadedKybDocument.match), (0, operators_1.mergeMap)((action) => {
13
- const { target, companyId, fileId, documentType } = action.payload;
14
- const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
15
- const requestPayload = {
16
- provided_document_type: documentType,
17
- files: [{ file_id: fileId }],
18
- processing_priority: 10,
19
- metadata: { source: 'kyc_kyb_autofill' },
20
- };
21
- return zeniAPI
22
- .postAndGetJSON(url, requestPayload)
23
- .pipe((0, operators_1.mergeMap)((response) => {
24
- if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
25
- return (0, rxjs_1.of)();
26
- }
27
- let result;
28
- switch (documentType) {
29
- case 'certificate_of_incorporation':
30
- result = (0, kycKybParseMapper_1.mapCoiToCompanyDetails)(response.data);
31
- break;
32
- case 'tax_ein':
33
- result = (0, kycKybParseMapper_1.mapTaxEinToCompanyDetails)(response.data);
34
- break;
35
- }
36
- if (result.autoFilledFieldNames.length === 0) {
37
- return (0, rxjs_1.of)();
38
- }
39
- const applyAction = target === 'setup'
40
- ? (0, setupViewReducer_1.applyKybDocumentAutofillForSetup)({
41
- companyId,
42
- values: result.values,
43
- autoFilledFieldNames: result.autoFilledFieldNames,
44
- })
45
- : (0, onboardingCustomerViewReducer_1.applyKybDocumentAutofillForOnboarding)({
46
- companyId,
47
- values: result.values,
48
- autoFilledFieldNames: result.autoFilledFieldNames,
49
- });
50
- return (0, rxjs_1.of)(applyAction);
51
- }), (0, operators_1.catchError)(() => (0, rxjs_1.of)()));
52
- }));
53
- exports.parseUploadedKybDocumentEpic = parseUploadedKybDocumentEpic;
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../../../reducer';
3
- import { ZeniAPI } from '../../../../../zeniAPI';
4
- import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
- import { parseUploadedKycDocument } from '../../kycKybAutofillActions';
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>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseUploadedKycDocumentEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const countryListSelector_1 = require("../../../../../entity/countryList/countryListSelector");
7
- const responsePayload_1 = require("../../../../../responsePayload");
8
- const onboardingCustomerViewReducer_1 = require("../../../../onboardingView/customerView/onboardingCustomerViewReducer");
9
- const kycKybAutofillActions_1 = require("../../kycKybAutofillActions");
10
- const kycKybParseMapper_1 = require("../../kycKybParseMapper");
11
- const setupViewReducer_1 = require("../../setupViewReducer");
12
- const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
13
- const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(kycKybAutofillActions_1.parseUploadedKycDocument.match), (0, operators_1.mergeMap)((action) => {
14
- const { target, companyId, officerType, fileId, documentType } = action.payload;
15
- const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
16
- const requestPayload = {
17
- provided_document_type: documentType,
18
- files: [{ file_id: fileId }],
19
- processing_priority: 10,
20
- metadata: { source: 'kyc_kyb_autofill' },
21
- };
22
- return zeniAPI
23
- .postAndGetJSON(url, requestPayload)
24
- .pipe((0, operators_1.mergeMap)((response) => {
25
- if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
26
- return (0, rxjs_1.of)();
27
- }
28
- const allCountries = (0, countryListSelector_1.getCountryList)(state$.value.countryListState, 'nationalityCountryList').countries;
29
- let result;
30
- switch (documentType) {
31
- case 'passport':
32
- result = (0, kycKybParseMapper_1.mapPassportToOfficer)(response.data, allCountries);
33
- break;
34
- case 'driving_license':
35
- result = (0, kycKybParseMapper_1.mapDrivingLicenseToOfficer)(response.data);
36
- break;
37
- case 'social_security_card':
38
- result = (0, kycKybParseMapper_1.mapSsnCardToOfficer)(response.data);
39
- break;
40
- }
41
- if (result.autoFilledFieldNames.length === 0) {
42
- return (0, rxjs_1.of)();
43
- }
44
- const applyAction = target === 'setup'
45
- ? (0, setupViewReducer_1.applyKycDocumentAutofillForSetup)({
46
- companyId,
47
- officerType,
48
- values: result.values,
49
- autoFilledFieldNames: result.autoFilledFieldNames,
50
- })
51
- : (0, onboardingCustomerViewReducer_1.applyKycDocumentAutofillForOnboarding)({
52
- companyId,
53
- officerType,
54
- values: result.values,
55
- autoFilledFieldNames: result.autoFilledFieldNames,
56
- });
57
- 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
- }));
62
- exports.parseUploadedKycDocumentEpic = parseUploadedKycDocumentEpic;
@@ -1,27 +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 { ID } from '../../../commonStateTypes/common';
11
- import { CompanyOfficerType } from '../../companyView/types/companyPassport/companyUsersLocalData';
12
- import { KybProvidedDocumentType, KycKybAutofillTarget, KycProvidedDocumentType } from './types/kycKybAutofill';
13
- export interface ParseUploadedKycDocumentPayload {
14
- companyId: ID;
15
- documentType: KycProvidedDocumentType;
16
- fileId: ID;
17
- officerType: CompanyOfficerType;
18
- target: KycKybAutofillTarget;
19
- }
20
- export interface ParseUploadedKybDocumentPayload {
21
- companyId: ID;
22
- documentType: KybProvidedDocumentType;
23
- fileId: ID;
24
- target: KycKybAutofillTarget;
25
- }
26
- export declare const parseUploadedKycDocument: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedKycDocumentPayload, string>;
27
- export declare const parseUploadedKybDocument: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedKybDocumentPayload, string>;