@zeniai/client-epic-state 5.1.3 → 5.1.4-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 (76) hide show
  1. package/lib/entity/company/companyPayload.d.ts +4 -0
  2. package/lib/entity/company/companyPayload.js +6 -0
  3. package/lib/entity/company/companyStateTypes.d.ts +7 -0
  4. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  5. package/lib/entity/paymentAccount/paymentAccountSelector.js +9 -0
  6. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  7. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  8. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  9. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  10. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  11. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  12. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  13. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  14. package/lib/entity/tenant/tenantReducer.js +65 -5
  15. package/lib/entity/tenant/tenantState.d.ts +1 -0
  16. package/lib/epic.d.ts +6 -1
  17. package/lib/epic.js +7 -1
  18. package/lib/esm/entity/company/companyPayload.js +6 -0
  19. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +8 -0
  20. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  21. package/lib/esm/entity/tenant/tenantReducer.js +63 -3
  22. package/lib/esm/epic.js +7 -1
  23. package/lib/esm/index.js +9 -6
  24. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  25. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  26. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  27. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +40 -0
  28. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +29 -0
  29. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  30. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +218 -50
  31. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +12 -2
  32. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +12 -0
  33. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +2 -2
  34. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +58 -0
  35. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +77 -0
  36. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
  37. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +207 -0
  38. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +106 -52
  39. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  40. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +41 -0
  41. package/lib/index.d.ts +11 -7
  42. package/lib/index.js +55 -35
  43. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  44. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  45. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  46. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  47. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +44 -0
  48. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +8 -0
  49. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +33 -0
  50. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  51. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  52. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  53. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
  54. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +220 -51
  55. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +5 -1
  56. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +15 -2
  57. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +40 -0
  58. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -1
  59. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.d.ts +1 -1
  60. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +2 -2
  61. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
  62. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +62 -0
  63. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +9 -0
  64. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +81 -0
  65. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +24 -0
  66. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
  67. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +29 -0
  68. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +215 -0
  69. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
  70. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +107 -53
  71. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
  72. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  73. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
  74. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +154 -0
  75. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +46 -0
  76. package/package.json +1 -1
@@ -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
+ };
@@ -26,7 +26,7 @@ export interface CashManagementSettingsPayload {
26
26
  cash_management_settings_id: string | null;
27
27
  frequency: string;
28
28
  minimum_buffer_usd: number;
29
- next_transfer_date: string;
29
+ next_run_date: string;
30
30
  source_bank_account: DepositAccountPayload;
31
31
  }
32
32
  export type CashManagementSettingsResponse = ZeniAPIResponse<CashManagementSettingsPayload>;
@@ -24,8 +24,8 @@ const toAutoSweepFlowStatePatch = (payload) => {
24
24
  return {
25
25
  bufferAmount: (0, amount_1.toAmount)(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
26
26
  frequency: (0, autoSweepFlowState_1.toAutoSweepFrequency)(payload.frequency) ?? 'weekly',
27
- nextTransferDate: payload.next_transfer_date != null && payload.next_transfer_date !== ''
28
- ? (0, zeniDayJS_1.date)(payload.next_transfer_date)
27
+ nextTransferDate: payload.next_run_date != null && payload.next_run_date !== ''
28
+ ? (0, zeniDayJS_1.date)(payload.next_run_date)
29
29
  : undefined,
30
30
  primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
31
31
  settingsId: payload.cash_management_settings_id ?? undefined,
@@ -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,62 @@
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
+ // Sync API returns a batch envelope: `data.files[0].extracted_data`
29
+ // is the parser payload; `data` itself is the request-level wrapper.
30
+ const extracted = response.data.files?.[0]?.extracted_data;
31
+ if (extracted == null) {
32
+ return (0, rxjs_1.of)(failureAction);
33
+ }
34
+ let result;
35
+ switch (documentType) {
36
+ case 'certificate_of_incorporation':
37
+ result = (0, kycKybParseMapper_1.mapCoiToCompanyDetails)(extracted);
38
+ break;
39
+ case 'tax_ein':
40
+ result = (0, kycKybParseMapper_1.mapTaxEinToCompanyDetails)(extracted);
41
+ break;
42
+ }
43
+ if (result.autoFilledFieldNames.length === 0) {
44
+ return (0, rxjs_1.of)(failureAction);
45
+ }
46
+ const applyAction = target === 'setup'
47
+ ? (0, setupViewReducer_1.applyKybDocumentAutofillForSetup)({
48
+ companyId,
49
+ fileId,
50
+ values: result.values,
51
+ autoFilledFieldNames: result.autoFilledFieldNames,
52
+ })
53
+ : (0, onboardingCustomerViewReducer_1.applyKybDocumentAutofillForOnboarding)({
54
+ companyId,
55
+ fileId,
56
+ values: result.values,
57
+ autoFilledFieldNames: result.autoFilledFieldNames,
58
+ });
59
+ return (0, rxjs_1.of)(applyAction);
60
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)(failureAction)));
61
+ }));
62
+ exports.parseUploadedKybDocumentEpic = parseUploadedKybDocumentEpic;
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { RootState } from '../../../../../reducer';
3
+ import { ZeniAPI } from '../../../../../zeniAPI';
4
+ import { newAddressInLocalStore } from '../../../../addressView/addressViewReducer';
5
+ import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
6
+ import { parseUploadedKycDocument, parseUploadedKycDocumentFailure } from '../../kycKybAutofillActions';
7
+ import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
8
+ export type ActionType = ReturnType<typeof parseUploadedKycDocument | typeof parseUploadedKycDocumentFailure | typeof applyKycDocumentAutofillForSetup | typeof applyKycDocumentAutofillForOnboarding | typeof newAddressInLocalStore>;
9
+ export declare const parseUploadedKycDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -0,0 +1,81 @@
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 responsePayload_1 = require("../../../../../responsePayload");
7
+ const addressViewReducer_1 = require("../../../../addressView/addressViewReducer");
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
+ // Sync API returns a batch envelope: `data.files[0].extracted_data`
30
+ // is the parser payload; `data` itself is the request-level wrapper
31
+ // ({request_id, status, files, metadata, ...}). Drill in before
32
+ // dispatching to the mapper.
33
+ const extracted = response.data.files?.[0]?.extracted_data;
34
+ if (extracted == null) {
35
+ return (0, rxjs_1.of)(failureAction);
36
+ }
37
+ let result;
38
+ switch (documentType) {
39
+ case 'passport':
40
+ result = (0, kycKybParseMapper_1.mapPassportToOfficer)(extracted);
41
+ break;
42
+ case 'driving_license':
43
+ result = (0, kycKybParseMapper_1.mapDrivingLicenseToOfficer)(extracted);
44
+ break;
45
+ case 'social_security_card':
46
+ result = (0, kycKybParseMapper_1.mapSsnCardToOfficer)(extracted);
47
+ break;
48
+ }
49
+ if (result.autoFilledFieldNames.length === 0) {
50
+ return (0, rxjs_1.of)(failureAction);
51
+ }
52
+ const applyAction = target === 'setup'
53
+ ? (0, setupViewReducer_1.applyKycDocumentAutofillForSetup)({
54
+ companyId,
55
+ officerType,
56
+ fileId,
57
+ values: result.values,
58
+ autoFilledFieldNames: result.autoFilledFieldNames,
59
+ })
60
+ : (0, onboardingCustomerViewReducer_1.applyKycDocumentAutofillForOnboarding)({
61
+ companyId,
62
+ officerType,
63
+ fileId,
64
+ values: result.values,
65
+ autoFilledFieldNames: result.autoFilledFieldNames,
66
+ });
67
+ const actions = [applyAction];
68
+ // Driving licenses also carry the home address, which lives in the
69
+ // addressView slice (keyed `officer_<n>_address`). Seed it so the
70
+ // section's address field + ✦ badge pick it up.
71
+ if (result.address != null) {
72
+ const addressType = `${officerType.toLowerCase()}_address`;
73
+ actions.push((0, addressViewReducer_1.newAddressInLocalStore)({
74
+ addressType,
75
+ addressToCreate: result.address,
76
+ }));
77
+ }
78
+ return (0, rxjs_1.from)(actions);
79
+ }), (0, operators_1.catchError)(() => (0, rxjs_1.of)(failureAction)));
80
+ }));
81
+ exports.parseUploadedKycDocumentEpic = parseUploadedKycDocumentEpic;
@@ -0,0 +1,24 @@
1
+ import { ID } from '../../../commonStateTypes/common';
2
+ import { CompanyOfficerType } from '../../companyView/types/companyPassport/companyUsersLocalData';
3
+ import { KybProvidedDocumentType, KycKybAutofillTarget, KycProvidedDocumentType } from './types/kycKybAutofill';
4
+ export interface ParseUploadedKycDocumentPayload {
5
+ companyId: ID;
6
+ documentType: KycProvidedDocumentType;
7
+ fileId: ID;
8
+ officerType: CompanyOfficerType;
9
+ target: KycKybAutofillTarget;
10
+ }
11
+ export interface ParseUploadedKybDocumentPayload {
12
+ companyId: ID;
13
+ documentType: KybProvidedDocumentType;
14
+ fileId: ID;
15
+ target: KycKybAutofillTarget;
16
+ }
17
+ export declare const parseUploadedKycDocument: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedKycDocumentPayload, string>;
18
+ export declare const parseUploadedKybDocument: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedKybDocumentPayload, string>;
19
+ export interface ParseUploadedDocumentFailurePayload {
20
+ fileId: ID;
21
+ target: KycKybAutofillTarget;
22
+ }
23
+ export declare const parseUploadedKycDocumentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedDocumentFailurePayload, string>;
24
+ export declare const parseUploadedKybDocumentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ParseUploadedDocumentFailurePayload, string>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseUploadedKybDocumentFailure = exports.parseUploadedKycDocumentFailure = exports.parseUploadedKybDocument = exports.parseUploadedKycDocument = void 0;
4
+ /**
5
+ * Trigger actions for the KYC / KYB autofill epics.
6
+ *
7
+ * These actions don't mutate state — the epic listens for them, calls
8
+ * document-communication-agent's sync endpoint, and dispatches the appropriate
9
+ * `applyKyc/KybDocumentAutofillFor{Setup,Onboarding}` against the matching
10
+ * slice. Co-located with the rest of the commonSetup module because the entire
11
+ * autofill flow is auxiliary to the setup view; there is no separate state.
12
+ */
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,29 @@
1
+ import { AddressUpdatableInfo } from '../../addressView/addressViewState';
2
+ import { CompanyDetailsLocalData, CompanyOfficerLocalData } from './setupViewState';
3
+ import { ExtendCertificateOfIncorporationParsed, ExtendDrivingLicenseParsed, ExtendPassportParsed, ExtendSsnCardParsed, ExtendTaxEinParsed } from './types/kycKybAutofill';
4
+ export interface AutofillResult<TLocalData> {
5
+ autoFilledFieldNames: (keyof TLocalData & string)[];
6
+ values: Partial<TLocalData>;
7
+ }
8
+ /**
9
+ * Officer mappers may additionally produce an address (driving license only).
10
+ * The officer's address lives in the `addressView` slice — not in
11
+ * `CompanyOfficerLocalData` — so it is returned separately and the consuming
12
+ * epic dispatches `newAddressInLocalStore` for it. The synthetic field name
13
+ * `'officerAddress'` is appended to `autoFilledFieldNames` so the form section
14
+ * shows the ✦ badge next to the address field.
15
+ */
16
+ export interface OfficerAutofillResult extends AutofillResult<CompanyOfficerLocalData> {
17
+ address?: AddressUpdatableInfo;
18
+ }
19
+ export declare const OFFICER_ADDRESS_AUTOFILL_FIELD = "officerAddress";
20
+ /** Passport → Company Officer. */
21
+ export declare const mapPassportToOfficer: (parsed: ExtendPassportParsed) => AutofillResult<CompanyOfficerLocalData>;
22
+ /** Driving License → Company Officer (name, DOB, and home address). */
23
+ export declare const mapDrivingLicenseToOfficer: (parsed: ExtendDrivingLicenseParsed) => OfficerAutofillResult;
24
+ /** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
25
+ export declare const mapSsnCardToOfficer: (parsed: ExtendSsnCardParsed) => AutofillResult<CompanyOfficerLocalData>;
26
+ /** Certificate of Incorporation → Company Details. */
27
+ export declare const mapCoiToCompanyDetails: (parsed: ExtendCertificateOfIncorporationParsed) => AutofillResult<CompanyDetailsLocalData>;
28
+ /** Tax EIN letter → Company Details. */
29
+ export declare const mapTaxEinToCompanyDetails: (parsed: ExtendTaxEinParsed) => AutofillResult<CompanyDetailsLocalData>;
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapTaxEinToCompanyDetails = exports.mapCoiToCompanyDetails = exports.mapSsnCardToOfficer = exports.mapDrivingLicenseToOfficer = exports.mapPassportToOfficer = exports.OFFICER_ADDRESS_AUTOFILL_FIELD = void 0;
4
+ /**
5
+ * Pure mappers from ExtendAI parser payloads to our form-side local-data shapes.
6
+ *
7
+ * Each mapper filters out fields below KYC_KYB_AUTOFILL_MIN_CONFIDENCE and returns
8
+ * both the merged values and the list of field names that were autofilled so the
9
+ * UI can show the ✦ AI badge next to each.
10
+ */
11
+ const zeniDayJS_1 = require("../../../zeniDayJS");
12
+ const zeniUrl_1 = require("../../../zeniUrl");
13
+ const kycKybAutofill_1 = require("./types/kycKybAutofill");
14
+ exports.OFFICER_ADDRESS_AUTOFILL_FIELD = 'officerAddress';
15
+ // US driving licenses carry a US state in `address_state` but no country field;
16
+ // default the composed address to the US.
17
+ const DRIVING_LICENSE_DEFAULT_COUNTRY = 'United States';
18
+ const DRIVING_LICENSE_DEFAULT_COUNTRY_CODE = 'US';
19
+ const emptyResult = () => ({
20
+ values: {},
21
+ autoFilledFieldNames: [],
22
+ });
23
+ const isConfident = (field) => {
24
+ if (field == null) {
25
+ return false;
26
+ }
27
+ if (field.value == null) {
28
+ return false;
29
+ }
30
+ return field.confidence >= kycKybAutofill_1.KYC_KYB_AUTOFILL_MIN_CONFIDENCE;
31
+ };
32
+ const assignAutofilledValue = (result, key, value) => {
33
+ if (value == null) {
34
+ return;
35
+ }
36
+ if (typeof value === 'string' && value.trim() === '') {
37
+ return;
38
+ }
39
+ result.values[key] = value;
40
+ result.autoFilledFieldNames.push(key);
41
+ };
42
+ const tryParseDate = (rawDate) => {
43
+ const parsedDate = (0, zeniDayJS_1.date)(rawDate);
44
+ if (parsedDate.isValid()) {
45
+ return parsedDate;
46
+ }
47
+ return undefined;
48
+ };
49
+ const splitFullName = (fullName) => {
50
+ const parts = fullName.trim().split(/\s+/);
51
+ if (parts.length === 1) {
52
+ return { firstName: parts[0], lastName: '' };
53
+ }
54
+ const lastName = parts[parts.length - 1];
55
+ const firstName = parts.slice(0, -1).join(' ');
56
+ return { firstName, lastName };
57
+ };
58
+ /** Passport → Company Officer. */
59
+ const mapPassportToOfficer = (parsed) => {
60
+ const result = emptyResult();
61
+ if (isConfident(parsed.first_name)) {
62
+ assignAutofilledValue(result, 'firstName', parsed.first_name.value);
63
+ }
64
+ if (isConfident(parsed.last_name)) {
65
+ assignAutofilledValue(result, 'lastName', parsed.last_name.value);
66
+ }
67
+ if (isConfident(parsed.date_of_birth)) {
68
+ const parsedDate = tryParseDate(parsed.date_of_birth.value);
69
+ if (parsedDate != null) {
70
+ assignAutofilledValue(result, 'birthday', parsedDate);
71
+ }
72
+ }
73
+ // The raw nationality string (e.g. "USA", "UNITED STATES OF AMERICA") is
74
+ // passed through unresolved; the consuming form section normalizes it to an
75
+ // ISO-2 code via the `countries-list` dataset before `setValue`. The form
76
+ // value (not this localData seed) is what gets submitted.
77
+ if (isConfident(parsed.nationality)) {
78
+ assignAutofilledValue(result, 'nationalityCountryCode', parsed.nationality.value);
79
+ }
80
+ return result;
81
+ };
82
+ exports.mapPassportToOfficer = mapPassportToOfficer;
83
+ /** Driving License → Company Officer (name, DOB, and home address). */
84
+ const mapDrivingLicenseToOfficer = (parsed) => {
85
+ const result = emptyResult();
86
+ if (isConfident(parsed.first_name)) {
87
+ assignAutofilledValue(result, 'firstName', parsed.first_name.value);
88
+ }
89
+ if (isConfident(parsed.last_name)) {
90
+ assignAutofilledValue(result, 'lastName', parsed.last_name.value);
91
+ }
92
+ if (isConfident(parsed.date_of_birth)) {
93
+ const parsedDate = tryParseDate(parsed.date_of_birth.value);
94
+ if (parsedDate != null) {
95
+ assignAutofilledValue(result, 'birthday', parsedDate);
96
+ }
97
+ }
98
+ // The officer address lives in the addressView slice rather than
99
+ // CompanyOfficerLocalData, so it's returned separately for the epic to
100
+ // dispatch via newAddressInLocalStore.
101
+ const street = isConfident(parsed.address_street)
102
+ ? parsed.address_street.value.trim()
103
+ : undefined;
104
+ const city = isConfident(parsed.address_city)
105
+ ? parsed.address_city.value.trim()
106
+ : undefined;
107
+ const state = isConfident(parsed.address_state)
108
+ ? parsed.address_state.value.trim()
109
+ : undefined;
110
+ const postalCode = isConfident(parsed.address_zip)
111
+ ? parsed.address_zip.value.trim()
112
+ : undefined;
113
+ if (street != null || city != null || state != null || postalCode != null) {
114
+ result.address = {
115
+ street: street != null ? [street] : [],
116
+ city: city ?? '',
117
+ state: state ?? '',
118
+ postalCode: postalCode ?? '',
119
+ country: DRIVING_LICENSE_DEFAULT_COUNTRY,
120
+ countryCode: DRIVING_LICENSE_DEFAULT_COUNTRY_CODE,
121
+ };
122
+ result.autoFilledFieldNames.push(exports.OFFICER_ADDRESS_AUTOFILL_FIELD);
123
+ }
124
+ return result;
125
+ };
126
+ exports.mapDrivingLicenseToOfficer = mapDrivingLicenseToOfficer;
127
+ /** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
128
+ const mapSsnCardToOfficer = (parsed) => {
129
+ const result = emptyResult();
130
+ if (isConfident(parsed.full_name)) {
131
+ const { firstName, lastName } = splitFullName(parsed.full_name.value);
132
+ if (firstName !== '') {
133
+ assignAutofilledValue(result, 'firstName', firstName);
134
+ }
135
+ if (lastName !== '') {
136
+ assignAutofilledValue(result, 'lastName', lastName);
137
+ }
138
+ }
139
+ return result;
140
+ };
141
+ exports.mapSsnCardToOfficer = mapSsnCardToOfficer;
142
+ /** Certificate of Incorporation → Company Details. */
143
+ const mapCoiToCompanyDetails = (parsed) => {
144
+ const result = emptyResult();
145
+ if (isConfident(parsed.company_legal_name)) {
146
+ assignAutofilledValue(result, 'companyLegalName', parsed.company_legal_name.value);
147
+ }
148
+ if (isConfident(parsed.ein)) {
149
+ assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
150
+ }
151
+ if (isConfident(parsed.phone_number)) {
152
+ assignAutofilledValue(result, 'phone', parsed.phone_number.value);
153
+ }
154
+ if (isConfident(parsed.product_description)) {
155
+ assignAutofilledValue(result, 'companyDescription', parsed.product_description.value);
156
+ }
157
+ if (isConfident(parsed.website)) {
158
+ try {
159
+ assignAutofilledValue(result, 'website', (0, zeniUrl_1.toZeniUrl)(parsed.website.value));
160
+ }
161
+ catch {
162
+ // ignore — malformed URL string from OCR
163
+ }
164
+ }
165
+ if (isConfident(parsed.industry)) {
166
+ assignAutofilledValue(result, 'companyIndustryType', parsed.industry.value);
167
+ }
168
+ if (isConfident(parsed.sub_industry)) {
169
+ assignAutofilledValue(result, 'companySubIndustry', parsed.sub_industry.value);
170
+ }
171
+ if (isConfident(parsed.type_of_incorporation)) {
172
+ assignAutofilledValue(result, 'typeOfIncorporation', parsed.type_of_incorporation.value);
173
+ }
174
+ if (isConfident(parsed.date_of_incorporation)) {
175
+ const parsedDate = tryParseDate(parsed.date_of_incorporation.value);
176
+ if (parsedDate != null) {
177
+ assignAutofilledValue(result, 'incDate', parsedDate);
178
+ }
179
+ }
180
+ if (isConfident(parsed.state_of_incorporation)) {
181
+ assignAutofilledValue(result, 'stateOfIncorporation', parsed.state_of_incorporation.value);
182
+ }
183
+ if (isConfident(parsed.countries_of_operations)) {
184
+ assignAutofilledValue(result, 'countriesOfOperations', parsed.countries_of_operations.value);
185
+ }
186
+ if (isConfident(parsed.source_of_funds)) {
187
+ assignAutofilledValue(result, 'sourceOfFunds', parsed.source_of_funds.value);
188
+ }
189
+ if (isConfident(parsed.transaction_volume_expectations)) {
190
+ assignAutofilledValue(result, 'transactionVolume', parsed.transaction_volume_expectations.value);
191
+ }
192
+ if (isConfident(parsed.purpose_of_account)) {
193
+ assignAutofilledValue(result, 'purposeOfAccount', parsed.purpose_of_account.value);
194
+ }
195
+ if (isConfident(parsed.regulated_status)) {
196
+ assignAutofilledValue(result, 'regulatedStatus', parsed.regulated_status.value);
197
+ }
198
+ if (isConfident(parsed.us_nexus)) {
199
+ assignAutofilledValue(result, 'usNexus', parsed.us_nexus.value);
200
+ }
201
+ return result;
202
+ };
203
+ exports.mapCoiToCompanyDetails = mapCoiToCompanyDetails;
204
+ /** Tax EIN letter → Company Details. */
205
+ const mapTaxEinToCompanyDetails = (parsed) => {
206
+ const result = emptyResult();
207
+ if (isConfident(parsed.legal_business_name)) {
208
+ assignAutofilledValue(result, 'companyLegalName', parsed.legal_business_name.value);
209
+ }
210
+ if (isConfident(parsed.ein)) {
211
+ assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
212
+ }
213
+ return result;
214
+ };
215
+ 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;