@zeniai/client-epic-state 5.0.89 → 5.0.90-beta0ND

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 (78) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +1 -0
  3. package/lib/entity/company/companyPayload.d.ts +4 -0
  4. package/lib/entity/company/companyPayload.js +4 -0
  5. package/lib/entity/company/companyStateTypes.d.ts +4 -0
  6. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  7. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  8. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  9. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  10. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  11. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  12. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  13. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  14. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  15. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  16. package/lib/entity/tenant/tenantReducer.js +65 -5
  17. package/lib/entity/tenant/tenantState.d.ts +1 -0
  18. package/lib/epic.d.ts +8 -3
  19. package/lib/epic.js +9 -3
  20. package/lib/esm/commonStateTypes/animations.js +1 -0
  21. package/lib/esm/entity/company/companyPayload.js +4 -0
  22. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  23. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  24. package/lib/esm/entity/tenant/tenantReducer.js +63 -3
  25. package/lib/esm/epic.js +9 -3
  26. package/lib/esm/index.js +9 -6
  27. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +106 -18
  28. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  29. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  30. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  31. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +42 -0
  32. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +29 -0
  33. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  34. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +217 -50
  35. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +7 -1
  36. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +12 -0
  37. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +52 -0
  38. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +59 -0
  39. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
  40. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  41. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +105 -52
  42. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  43. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  44. package/lib/index.d.ts +11 -7
  45. package/lib/index.js +51 -31
  46. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +106 -18
  47. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  48. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  49. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  50. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  51. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +46 -0
  52. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +8 -0
  53. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +33 -0
  54. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  55. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  56. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  57. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
  58. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +219 -51
  59. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +5 -1
  60. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +11 -2
  61. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +40 -0
  62. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -1
  63. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
  64. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +56 -0
  65. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +30 -0
  66. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +63 -0
  67. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +33 -0
  68. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
  69. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  70. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  71. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
  72. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +106 -53
  73. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
  74. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  75. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
  76. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  77. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  78. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProductSettingsString = exports.onboardingStepsData = void 0;
3
+ exports.getAiAgentsActivationCounts = exports.getAiAgentsActivationPhases = exports.getAiAgentsActivationSubview = exports.getProductSettingsString = exports.onboardingStepsData = void 0;
4
4
  exports.getOnboardingCustomerView = getOnboardingCustomerView;
5
5
  exports.isOfficerDetailsCompleted = isOfficerDetailsCompleted;
6
6
  exports.isCompanyDetailsSavePending = isCompanyDetailsSavePending;
@@ -17,7 +17,7 @@ const setupViewSelector_1 = require("../../spendManagement/commonSetup/setupView
17
17
  const onboardingCustomerViewState_1 = require("./onboardingCustomerViewState");
18
18
  function getOnboardingCustomerView(state, companyId) {
19
19
  const { fileState, paymentAccountState, onboardingCustomerViewState, userState, userRoleState, subscriptionPaymentAccountState, companyConfigState, cardPaymentViewState, countryListState, addressViewState, } = state;
20
- const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
20
+ const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, parsingDocumentFileIds, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
21
21
  const { paymentAccountIds } = paymentAccountDetails;
22
22
  let subscriptionPaymentAccount;
23
23
  let paymentAccount;
@@ -60,6 +60,7 @@ function getOnboardingCustomerView(state, companyId) {
60
60
  companyDetails,
61
61
  companyOfficerUpdateStatus,
62
62
  primaryContactDetails,
63
+ parsingDocumentFileIds,
63
64
  });
64
65
  const companyAddress = addressViewState.newAddressState?.company_address;
65
66
  if (companyAddress == null &&
@@ -125,6 +126,7 @@ function getOnboardingCustomerView(state, companyId) {
125
126
  return {
126
127
  companyDetailsLocalData,
127
128
  companyOfficerLocalData,
129
+ parsingDocumentFileIds,
128
130
  subscriptionBillingAddress: subscriptionBillingAddress?.addressToCreate,
129
131
  companyView,
130
132
  allNationalityCountries,
@@ -331,3 +333,10 @@ const getProductSettingsString = (productSettings) => {
331
333
  .join(',');
332
334
  };
333
335
  exports.getProductSettingsString = getProductSettingsString;
336
+ const fromActivationView = (state) => state.onboardingCustomerViewState.aiAgentsActivation;
337
+ const getAiAgentsActivationSubview = (state) => fromActivationView(state);
338
+ exports.getAiAgentsActivationSubview = getAiAgentsActivationSubview;
339
+ const getAiAgentsActivationPhases = (state) => fromActivationView(state).phases;
340
+ exports.getAiAgentsActivationPhases = getAiAgentsActivationPhases;
341
+ const getAiAgentsActivationCounts = (state) => fromActivationView(state).counts;
342
+ exports.getAiAgentsActivationCounts = getAiAgentsActivationCounts;
@@ -21,16 +21,32 @@ export interface OnboardingCustomerViewUIState {
21
21
  isQBOPopupOpen: boolean;
22
22
  }
23
23
  export interface OnboardingCustomerViewState extends FetchedState {
24
+ aiAgentsActivation: AiAgentsActivationSubview;
24
25
  companyDetails: {
26
+ /**
27
+ * Field names from {@link CompanyDetailsLocalData} populated by AI autofill
28
+ * from an uploaded KYB document during onboarding. Drives the ✦ sparkle.
29
+ */
30
+ autoFilledFields: string[];
25
31
  localData?: CompanyDetailsLocalData;
26
32
  };
27
33
  companyOfficerUpdateStatus: Record<CompanyOfficerType, {
34
+ /**
35
+ * Field names from {@link CompanyOfficerLocalData} populated by AI autofill
36
+ * from an uploaded KYC identity document during onboarding.
37
+ */
38
+ autoFilledFields: string[];
28
39
  otpverificationStatus: FetchStateAndError;
29
40
  sendOtpStatus: FetchStateAndError;
30
41
  localData?: CompanyOfficerLocalData;
31
42
  }>;
32
43
  currentStep: OnboardingStep;
33
44
  dashboardLoadedStatus: FetchStateAndError;
45
+ /**
46
+ * File IDs currently being parsed by the AI autofill epic for onboarding.
47
+ * Drives the "AI is reading your document" overlay on the upload field.
48
+ */
49
+ parsingDocumentFileIds: ID[];
34
50
  paymentAccountDetails: {
35
51
  fetchStatus: FetchStateAndError;
36
52
  paymentAccountIds: ID[];
@@ -44,5 +60,29 @@ export interface OnboardingCustomerViewState extends FetchedState {
44
60
  subscriptionPaymentAccountIds: ID[];
45
61
  uiState: OnboardingCustomerViewUIState;
46
62
  updateStatus: FetchStateAndError;
63
+ aiActivationViewedAcknowledgementStatus?: FetchStateAndError;
64
+ aiFinanceTeamAcknowledgementStatus?: FetchStateAndError;
47
65
  subscriptionBillingAddress?: Address;
48
66
  }
67
+ export type AiAgentsActivationPhaseStatus = 'idle' | 'starting' | 'building' | 'ready';
68
+ export interface AiAgentsActivationPhase {
69
+ key: string;
70
+ status: AiAgentsActivationPhaseStatus;
71
+ completedAt?: string;
72
+ startedAt?: string;
73
+ }
74
+ export interface AiAgentsActivationCounts {
75
+ customerCount: number;
76
+ glAccountCount: number;
77
+ targetTransactionCount: number;
78
+ transactionCount: number;
79
+ vendorCount: number;
80
+ asOf?: string;
81
+ }
82
+ export interface AiAgentsActivationSubview {
83
+ counts: AiAgentsActivationCounts;
84
+ fetchStatus: FetchStateAndError;
85
+ phases: AiAgentsActivationPhase[];
86
+ }
87
+ export declare const emptyAiAgentsActivationCounts: AiAgentsActivationCounts;
88
+ export declare const emptyAiAgentsActivationSubview: AiAgentsActivationSubview;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toOnboardingStepType = exports.ALL_ONBOARDING_STEPS = exports.ALL_CUSTOMER_ONBOARDING_STEPS_WITH_QBO = exports.ALL_ZENI_USER_ONBOARDING_STEPS = exports.ALL_ZENI_USER_ONBOARDING_STEPS_WITHOUT_ACCOUNT = exports.REQUIRED_ONBOARDING_STEPS = exports.CUSTOMER_REQUIRED_ONBOARDING_STEPS_WITH_QBO = exports.ZENI_USER_REQUIRED_ONBOARDING_STEPS = void 0;
3
+ exports.emptyAiAgentsActivationSubview = exports.emptyAiAgentsActivationCounts = exports.toOnboardingStepType = exports.ALL_ONBOARDING_STEPS = exports.ALL_CUSTOMER_ONBOARDING_STEPS_WITH_QBO = exports.ALL_ZENI_USER_ONBOARDING_STEPS = exports.ALL_ZENI_USER_ONBOARDING_STEPS_WITHOUT_ACCOUNT = exports.REQUIRED_ONBOARDING_STEPS = exports.CUSTOMER_REQUIRED_ONBOARDING_STEPS_WITH_QBO = exports.ZENI_USER_REQUIRED_ONBOARDING_STEPS = void 0;
4
4
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
5
  exports.ZENI_USER_REQUIRED_ONBOARDING_STEPS = [
6
6
  'link_payment_account',
@@ -30,3 +30,15 @@ exports.ALL_ONBOARDING_STEPS = [
30
30
  ];
31
31
  const toOnboardingStepType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_ONBOARDING_STEPS);
32
32
  exports.toOnboardingStepType = toOnboardingStepType;
33
+ exports.emptyAiAgentsActivationCounts = {
34
+ customerCount: 0,
35
+ glAccountCount: 0,
36
+ targetTransactionCount: 0,
37
+ transactionCount: 0,
38
+ vendorCount: 0,
39
+ };
40
+ exports.emptyAiAgentsActivationSubview = {
41
+ counts: exports.emptyAiAgentsActivationCounts,
42
+ fetchStatus: { fetchState: 'Not-Started', error: undefined },
43
+ phases: [],
44
+ };
@@ -0,0 +1,28 @@
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, parseUploadedKybDocumentFailure } from '../../kycKybAutofillActions';
6
+ import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
7
+ import { CompanyDetailsLocalData } from '../../setupViewState';
8
+ export type ActionType = ReturnType<typeof parseUploadedKybDocument | typeof parseUploadedKybDocumentFailure | typeof applyKybDocumentAutofillForSetup | typeof applyKybDocumentAutofillForOnboarding>;
9
+ export declare const parseUploadedKybDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
10
+ payload: import("../../kycKybAutofillActions").ParseUploadedDocumentFailurePayload;
11
+ type: string;
12
+ } | {
13
+ payload: {
14
+ autoFilledFieldNames: string[];
15
+ companyId: import("../../../../..").ID;
16
+ fileId: import("../../../../..").ID;
17
+ values: Partial<CompanyDetailsLocalData>;
18
+ };
19
+ type: "onboardingCustomerView/applyKybDocumentAutofillForOnboarding";
20
+ } | {
21
+ payload: {
22
+ autoFilledFieldNames: string[];
23
+ companyId: import("../../../../..").ID;
24
+ fileId: import("../../../../..").ID;
25
+ values: Partial<CompanyDetailsLocalData>;
26
+ };
27
+ type: "setupView/applyKybDocumentAutofillForSetup";
28
+ }>;
@@ -0,0 +1,56 @@
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
+ const failureAction = (0, kycKybAutofillActions_1.parseUploadedKybDocumentFailure)({ target, fileId });
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)(failureAction);
27
+ }
28
+ let result;
29
+ switch (documentType) {
30
+ case 'certificate_of_incorporation':
31
+ result = (0, kycKybParseMapper_1.mapCoiToCompanyDetails)(response.data);
32
+ break;
33
+ case 'tax_ein':
34
+ result = (0, kycKybParseMapper_1.mapTaxEinToCompanyDetails)(response.data);
35
+ break;
36
+ }
37
+ if (result.autoFilledFieldNames.length === 0) {
38
+ return (0, rxjs_1.of)(failureAction);
39
+ }
40
+ const applyAction = target === 'setup'
41
+ ? (0, setupViewReducer_1.applyKybDocumentAutofillForSetup)({
42
+ companyId,
43
+ fileId,
44
+ values: result.values,
45
+ autoFilledFieldNames: result.autoFilledFieldNames,
46
+ })
47
+ : (0, onboardingCustomerViewReducer_1.applyKybDocumentAutofillForOnboarding)({
48
+ companyId,
49
+ fileId,
50
+ values: result.values,
51
+ autoFilledFieldNames: result.autoFilledFieldNames,
52
+ });
53
+ return (0, rxjs_1.of)(applyAction);
54
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)(failureAction)));
55
+ }));
56
+ exports.parseUploadedKybDocumentEpic = parseUploadedKybDocumentEpic;
@@ -0,0 +1,30 @@
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, parseUploadedKycDocumentFailure } from '../../kycKybAutofillActions';
6
+ import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
7
+ import { CompanyOfficerLocalData } from '../../setupViewState';
8
+ export type ActionType = ReturnType<typeof parseUploadedKycDocument | typeof parseUploadedKycDocumentFailure | typeof applyKycDocumentAutofillForSetup | typeof applyKycDocumentAutofillForOnboarding>;
9
+ export declare const parseUploadedKycDocumentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
10
+ payload: import("../../kycKybAutofillActions").ParseUploadedDocumentFailurePayload;
11
+ type: string;
12
+ } | {
13
+ payload: {
14
+ autoFilledFieldNames: string[];
15
+ companyId: import("../../../../..").ID;
16
+ fileId: import("../../../../..").ID;
17
+ officerType: import("../../../../..").CompanyOfficerType;
18
+ values: Partial<CompanyOfficerLocalData>;
19
+ };
20
+ type: "onboardingCustomerView/applyKycDocumentAutofillForOnboarding";
21
+ } | {
22
+ payload: {
23
+ autoFilledFieldNames: string[];
24
+ companyId: import("../../../../..").ID;
25
+ fileId: import("../../../../..").ID;
26
+ officerType: import("../../../../..").CompanyOfficerType;
27
+ values: Partial<CompanyOfficerLocalData>;
28
+ };
29
+ type: "setupView/applyKycDocumentAutofillForSetup";
30
+ }>;
@@ -0,0 +1,63 @@
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
+ const failureAction = (0, kycKybAutofillActions_1.parseUploadedKycDocumentFailure)({ target, fileId });
23
+ return zeniAPI
24
+ .postAndGetJSON(url, requestPayload)
25
+ .pipe((0, operators_1.mergeMap)((response) => {
26
+ if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
27
+ return (0, rxjs_1.of)(failureAction);
28
+ }
29
+ const allCountries = (0, countryListSelector_1.getCountryList)(state$.value.countryListState, 'nationalityCountryList').countries;
30
+ let result;
31
+ switch (documentType) {
32
+ case 'passport':
33
+ result = (0, kycKybParseMapper_1.mapPassportToOfficer)(response.data, allCountries);
34
+ break;
35
+ case 'driving_license':
36
+ result = (0, kycKybParseMapper_1.mapDrivingLicenseToOfficer)(response.data);
37
+ break;
38
+ case 'social_security_card':
39
+ result = (0, kycKybParseMapper_1.mapSsnCardToOfficer)(response.data);
40
+ break;
41
+ }
42
+ if (result.autoFilledFieldNames.length === 0) {
43
+ return (0, rxjs_1.of)(failureAction);
44
+ }
45
+ const applyAction = target === 'setup'
46
+ ? (0, setupViewReducer_1.applyKycDocumentAutofillForSetup)({
47
+ companyId,
48
+ officerType,
49
+ fileId,
50
+ values: result.values,
51
+ autoFilledFieldNames: result.autoFilledFieldNames,
52
+ })
53
+ : (0, onboardingCustomerViewReducer_1.applyKycDocumentAutofillForOnboarding)({
54
+ companyId,
55
+ officerType,
56
+ fileId,
57
+ values: result.values,
58
+ autoFilledFieldNames: result.autoFilledFieldNames,
59
+ });
60
+ return (0, rxjs_1.of)(applyAction);
61
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)(failureAction)));
62
+ }));
63
+ exports.parseUploadedKycDocumentEpic = parseUploadedKycDocumentEpic;
@@ -0,0 +1,33 @@
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>;
28
+ export interface ParseUploadedDocumentFailurePayload {
29
+ fileId: ID;
30
+ target: KycKybAutofillTarget;
31
+ }
32
+ export declare const parseUploadedKycDocumentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedDocumentFailurePayload, string>;
33
+ export declare const parseUploadedKybDocumentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedDocumentFailurePayload, string>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Trigger actions for the KYC / KYB autofill epics.
4
+ *
5
+ * These actions don't mutate state — the epic listens for them, calls
6
+ * document-communication-agent's sync endpoint, and dispatches the appropriate
7
+ * `applyKyc/KybDocumentAutofillFor{Setup,Onboarding}` against the matching
8
+ * slice. Co-located with the rest of the commonSetup module because the entire
9
+ * autofill flow is auxiliary to the setup view; there is no separate state.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.parseUploadedKybDocumentFailure = exports.parseUploadedKycDocumentFailure = exports.parseUploadedKybDocument = exports.parseUploadedKycDocument = void 0;
13
+ const toolkit_1 = require("@reduxjs/toolkit");
14
+ exports.parseUploadedKycDocument = (0, toolkit_1.createAction)('commonSetup/parseUploadedKycDocument');
15
+ exports.parseUploadedKybDocument = (0, toolkit_1.createAction)('commonSetup/parseUploadedKybDocument');
16
+ exports.parseUploadedKycDocumentFailure = (0, toolkit_1.createAction)('commonSetup/parseUploadedKycDocumentFailure');
17
+ exports.parseUploadedKybDocumentFailure = (0, toolkit_1.createAction)('commonSetup/parseUploadedKybDocumentFailure');
@@ -0,0 +1,24 @@
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 { Country } from '../../../entity/countryList/countryListState';
9
+ import { CompanyDetailsLocalData, CompanyOfficerLocalData } from './setupViewState';
10
+ import { ExtendCertificateOfIncorporationParsed, ExtendDrivingLicenseParsed, ExtendPassportParsed, ExtendSsnCardParsed, ExtendTaxEinParsed } from './types/kycKybAutofill';
11
+ export interface AutofillResult<TLocalData> {
12
+ autoFilledFieldNames: (keyof TLocalData & string)[];
13
+ values: Partial<TLocalData>;
14
+ }
15
+ /** Passport → Company Officer. */
16
+ export declare const mapPassportToOfficer: (parsed: ExtendPassportParsed, allNationalityCountries: Country[]) => AutofillResult<CompanyOfficerLocalData>;
17
+ /** Driving License → Company Officer. */
18
+ export declare const mapDrivingLicenseToOfficer: (parsed: ExtendDrivingLicenseParsed) => AutofillResult<CompanyOfficerLocalData>;
19
+ /** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
20
+ export declare const mapSsnCardToOfficer: (parsed: ExtendSsnCardParsed) => AutofillResult<CompanyOfficerLocalData>;
21
+ /** Certificate of Incorporation → Company Details. */
22
+ export declare const mapCoiToCompanyDetails: (parsed: ExtendCertificateOfIncorporationParsed) => AutofillResult<CompanyDetailsLocalData>;
23
+ /** Tax EIN letter → Company Details. */
24
+ export declare const mapTaxEinToCompanyDetails: (parsed: ExtendTaxEinParsed) => AutofillResult<CompanyDetailsLocalData>;
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ /**
3
+ * Pure mappers from ExtendAI parser payloads to our form-side local-data shapes.
4
+ *
5
+ * Each mapper filters out fields below KYC_KYB_AUTOFILL_MIN_CONFIDENCE and returns
6
+ * both the merged values and the list of field names that were autofilled so the
7
+ * UI can show the ✦ AI badge next to each.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.mapTaxEinToCompanyDetails = exports.mapCoiToCompanyDetails = exports.mapSsnCardToOfficer = exports.mapDrivingLicenseToOfficer = exports.mapPassportToOfficer = void 0;
11
+ const zeniDayJS_1 = require("../../../zeniDayJS");
12
+ const zeniUrl_1 = require("../../../zeniUrl");
13
+ const kycKybAutofill_1 = require("./types/kycKybAutofill");
14
+ const emptyResult = () => ({
15
+ values: {},
16
+ autoFilledFieldNames: [],
17
+ });
18
+ const isConfident = (field) => {
19
+ if (field == null) {
20
+ return false;
21
+ }
22
+ if (field.value == null) {
23
+ return false;
24
+ }
25
+ return field.confidence >= kycKybAutofill_1.KYC_KYB_AUTOFILL_MIN_CONFIDENCE;
26
+ };
27
+ const assignAutofilledValue = (result, key, value) => {
28
+ if (value == null) {
29
+ return;
30
+ }
31
+ if (typeof value === 'string' && value.trim() === '') {
32
+ return;
33
+ }
34
+ result.values[key] = value;
35
+ result.autoFilledFieldNames.push(key);
36
+ };
37
+ const tryParseDate = (rawDate) => {
38
+ const parsedDate = (0, zeniDayJS_1.date)(rawDate);
39
+ if (parsedDate.isValid()) {
40
+ return parsedDate;
41
+ }
42
+ return undefined;
43
+ };
44
+ const normalizeNationality = (rawNationality, countries) => {
45
+ const needle = rawNationality.trim().toLowerCase();
46
+ if (needle === '') {
47
+ return undefined;
48
+ }
49
+ // Exact ISO-2 / ISO-3 match.
50
+ const isoMatch = countries.find((country) => country.countryCode.toLowerCase() === needle);
51
+ if (isoMatch != null) {
52
+ return isoMatch.countryCode;
53
+ }
54
+ // Common nationality adjectives map to country names (e.g. "American" → "United States").
55
+ const adjectiveToCountry = {
56
+ american: 'united states',
57
+ british: 'united kingdom',
58
+ indian: 'india',
59
+ canadian: 'canada',
60
+ australian: 'australia',
61
+ german: 'germany',
62
+ french: 'france',
63
+ chinese: 'china',
64
+ japanese: 'japan',
65
+ mexican: 'mexico',
66
+ brazilian: 'brazil',
67
+ };
68
+ const resolvedName = adjectiveToCountry[needle] ?? needle;
69
+ const nameMatch = countries.find((country) => country.countryName.toLowerCase() === resolvedName);
70
+ return nameMatch?.countryCode;
71
+ };
72
+ const splitFullName = (fullName) => {
73
+ const parts = fullName.trim().split(/\s+/);
74
+ if (parts.length === 1) {
75
+ return { firstName: parts[0], lastName: '' };
76
+ }
77
+ const lastName = parts[parts.length - 1];
78
+ const firstName = parts.slice(0, -1).join(' ');
79
+ return { firstName, lastName };
80
+ };
81
+ /** Passport → Company Officer. */
82
+ const mapPassportToOfficer = (parsed, allNationalityCountries) => {
83
+ const result = emptyResult();
84
+ if (isConfident(parsed.first_name)) {
85
+ assignAutofilledValue(result, 'firstName', parsed.first_name.value);
86
+ }
87
+ if (isConfident(parsed.last_name)) {
88
+ assignAutofilledValue(result, 'lastName', parsed.last_name.value);
89
+ }
90
+ if (isConfident(parsed.date_of_birth)) {
91
+ const parsedDate = tryParseDate(parsed.date_of_birth.value);
92
+ if (parsedDate != null) {
93
+ assignAutofilledValue(result, 'birthday', parsedDate);
94
+ }
95
+ }
96
+ if (isConfident(parsed.nationality)) {
97
+ const isoCode = normalizeNationality(parsed.nationality.value, allNationalityCountries);
98
+ if (isoCode != null) {
99
+ assignAutofilledValue(result, 'nationalityCountryCode', isoCode);
100
+ }
101
+ }
102
+ return result;
103
+ };
104
+ exports.mapPassportToOfficer = mapPassportToOfficer;
105
+ /** Driving License → Company Officer. */
106
+ const mapDrivingLicenseToOfficer = (parsed) => {
107
+ const result = emptyResult();
108
+ if (isConfident(parsed.first_name)) {
109
+ assignAutofilledValue(result, 'firstName', parsed.first_name.value);
110
+ }
111
+ if (isConfident(parsed.last_name)) {
112
+ assignAutofilledValue(result, 'lastName', parsed.last_name.value);
113
+ }
114
+ if (isConfident(parsed.date_of_birth)) {
115
+ const parsedDate = tryParseDate(parsed.date_of_birth.value);
116
+ if (parsedDate != null) {
117
+ assignAutofilledValue(result, 'birthday', parsedDate);
118
+ }
119
+ }
120
+ // address_* fields are mapped at a higher layer (addressView reducer) — kept here as values
121
+ // only, the consuming epic dispatches the address payload separately.
122
+ return result;
123
+ };
124
+ exports.mapDrivingLicenseToOfficer = mapDrivingLicenseToOfficer;
125
+ /** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
126
+ const mapSsnCardToOfficer = (parsed) => {
127
+ const result = emptyResult();
128
+ if (isConfident(parsed.full_name)) {
129
+ const { firstName, lastName } = splitFullName(parsed.full_name.value);
130
+ if (firstName !== '') {
131
+ assignAutofilledValue(result, 'firstName', firstName);
132
+ }
133
+ if (lastName !== '') {
134
+ assignAutofilledValue(result, 'lastName', lastName);
135
+ }
136
+ }
137
+ return result;
138
+ };
139
+ exports.mapSsnCardToOfficer = mapSsnCardToOfficer;
140
+ /** Certificate of Incorporation → Company Details. */
141
+ const mapCoiToCompanyDetails = (parsed) => {
142
+ const result = emptyResult();
143
+ if (isConfident(parsed.company_legal_name)) {
144
+ assignAutofilledValue(result, 'companyLegalName', parsed.company_legal_name.value);
145
+ }
146
+ if (isConfident(parsed.ein)) {
147
+ assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
148
+ }
149
+ if (isConfident(parsed.phone_number)) {
150
+ assignAutofilledValue(result, 'phone', parsed.phone_number.value);
151
+ }
152
+ if (isConfident(parsed.product_description)) {
153
+ assignAutofilledValue(result, 'companyDescription', parsed.product_description.value);
154
+ }
155
+ if (isConfident(parsed.website)) {
156
+ try {
157
+ assignAutofilledValue(result, 'website', (0, zeniUrl_1.toZeniUrl)(parsed.website.value));
158
+ }
159
+ catch {
160
+ // ignore — malformed URL string from OCR
161
+ }
162
+ }
163
+ if (isConfident(parsed.industry)) {
164
+ assignAutofilledValue(result, 'companyIndustryType', parsed.industry.value);
165
+ }
166
+ if (isConfident(parsed.sub_industry)) {
167
+ assignAutofilledValue(result, 'companySubIndustry', parsed.sub_industry.value);
168
+ }
169
+ if (isConfident(parsed.type_of_incorporation)) {
170
+ assignAutofilledValue(result, 'typeOfIncorporation', parsed.type_of_incorporation.value);
171
+ }
172
+ if (isConfident(parsed.date_of_incorporation)) {
173
+ const parsedDate = tryParseDate(parsed.date_of_incorporation.value);
174
+ if (parsedDate != null) {
175
+ assignAutofilledValue(result, 'incDate', parsedDate);
176
+ }
177
+ }
178
+ if (isConfident(parsed.state_of_incorporation)) {
179
+ assignAutofilledValue(result, 'stateOfIncorporation', parsed.state_of_incorporation.value);
180
+ }
181
+ if (isConfident(parsed.countries_of_operations)) {
182
+ assignAutofilledValue(result, 'countriesOfOperations', parsed.countries_of_operations.value);
183
+ }
184
+ if (isConfident(parsed.source_of_funds)) {
185
+ assignAutofilledValue(result, 'sourceOfFunds', parsed.source_of_funds.value);
186
+ }
187
+ if (isConfident(parsed.transaction_volume_expectations)) {
188
+ assignAutofilledValue(result, 'transactionVolume', parsed.transaction_volume_expectations.value);
189
+ }
190
+ if (isConfident(parsed.purpose_of_account)) {
191
+ assignAutofilledValue(result, 'purposeOfAccount', parsed.purpose_of_account.value);
192
+ }
193
+ if (isConfident(parsed.regulated_status)) {
194
+ assignAutofilledValue(result, 'regulatedStatus', parsed.regulated_status.value);
195
+ }
196
+ if (isConfident(parsed.us_nexus)) {
197
+ assignAutofilledValue(result, 'usNexus', parsed.us_nexus.value);
198
+ }
199
+ return result;
200
+ };
201
+ exports.mapCoiToCompanyDetails = mapCoiToCompanyDetails;
202
+ /** Tax EIN letter → Company Details. */
203
+ const mapTaxEinToCompanyDetails = (parsed) => {
204
+ const result = emptyResult();
205
+ if (isConfident(parsed.legal_business_name)) {
206
+ assignAutofilledValue(result, 'companyLegalName', parsed.legal_business_name.value);
207
+ }
208
+ if (isConfident(parsed.ein)) {
209
+ assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
210
+ }
211
+ return result;
212
+ };
213
+ exports.mapTaxEinToCompanyDetails = mapTaxEinToCompanyDetails;
@@ -2,7 +2,7 @@ import { ID } from '../../../commonStateTypes/common';
2
2
  import { ZeniAPIStatus } from '../../../responsePayload';
3
3
  import { ZeniDate } from '../../../zeniDayJS';
4
4
  import { CompanyOfficerType } from '../../companyView/types/companyPassport/companyUsersLocalData';
5
- import { CompanyDetailsLocalData, SetupViewLocalData, SetupViewState } from './setupViewState';
5
+ import { CompanyDetailsLocalData, CompanyOfficerLocalData, SetupViewLocalData, SetupViewState } from './setupViewState';
6
6
  export declare const initialState: SetupViewState;
7
7
  export declare const enableSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[companyId: string, setupViewType: "bill_pay" | "reimbursement" | "zeni_accounts" | "zeni_treasury" | "charge_cards" | "other_connection" | "billing" | "debit_cards" | "charge_cards__debit_cards"], {
8
8
  companyId: string;
@@ -29,6 +29,32 @@ export declare const enableSetup: import("@reduxjs/toolkit").ActionCreatorWithPr
29
29
  }, "setupView/sendOtpSuccess">, sendOtpFailureSpendManagementSetUp: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "setupView/sendOtpFailure">, verifyOtpSpendManagementSetUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/verifyOtp">, verifyOtpSuccessSpendManagementSetUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/verifyOtpSuccess">, verifyOtpFailureSpendManagementSetUp: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "setupView/verifyOtpFailure">, saveIndustryAndIncDateInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
30
30
  incDate: ZeniDate;
31
31
  industry: string;
32
- }, "setupView/saveIndustryAndIncDateInLocalStore">, clearSetupViewDataInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/clearSetupViewDataInLocalStore">, clearSetupView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/clearSetupView">;
32
+ }, "setupView/saveIndustryAndIncDateInLocalStore">, clearSetupViewDataInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/clearSetupViewDataInLocalStore">, clearSetupView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"setupView/clearSetupView">, applyKycDocumentAutofillForSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
33
+ autoFilledFieldNames: string[];
34
+ companyId: ID;
35
+ fileId: ID;
36
+ officerType: CompanyOfficerType;
37
+ values: Partial<CompanyOfficerLocalData>;
38
+ }], {
39
+ autoFilledFieldNames: string[];
40
+ companyId: ID;
41
+ fileId: ID;
42
+ officerType: CompanyOfficerType;
43
+ values: Partial<CompanyOfficerLocalData>;
44
+ }, "setupView/applyKycDocumentAutofillForSetup", never, never>, applyKybDocumentAutofillForSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
45
+ autoFilledFieldNames: string[];
46
+ companyId: ID;
47
+ fileId: ID;
48
+ values: Partial<CompanyDetailsLocalData>;
49
+ }], {
50
+ autoFilledFieldNames: string[];
51
+ companyId: ID;
52
+ fileId: ID;
53
+ values: Partial<CompanyDetailsLocalData>;
54
+ }, "setupView/applyKybDocumentAutofillForSetup", never, never>, clearKycKybAutofillForSetup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload?: {
55
+ officerType?: CompanyOfficerType;
56
+ } | undefined], {
57
+ officerType?: CompanyOfficerType;
58
+ }, "setupView/clearKycKybAutofillForSetup", never, never>;
33
59
  declare const _default: import("redux").Reducer<SetupViewState>;
34
60
  export default _default;