@zeniai/client-epic-state 5.1.4-beta0ND → 5.1.4

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 (73) hide show
  1. package/lib/entity/company/companyPayload.d.ts +0 -4
  2. package/lib/entity/company/companyPayload.js +0 -6
  3. package/lib/entity/company/companyStateTypes.d.ts +0 -7
  4. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +0 -1
  5. package/lib/entity/paymentAccount/paymentAccountSelector.js +0 -9
  6. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  7. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  8. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  9. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  10. package/lib/entity/tenant/tenantPayload.d.ts +0 -1
  11. package/lib/entity/tenant/tenantReducer.d.ts +25 -38
  12. package/lib/entity/tenant/tenantReducer.js +5 -65
  13. package/lib/entity/tenant/tenantState.d.ts +0 -1
  14. package/lib/epic.d.ts +1 -6
  15. package/lib/epic.js +1 -7
  16. package/lib/esm/entity/company/companyPayload.js +0 -6
  17. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +0 -8
  18. package/lib/esm/entity/tenant/tenantReducer.js +3 -63
  19. package/lib/esm/epic.js +1 -7
  20. package/lib/esm/index.js +6 -9
  21. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  22. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  23. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  24. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +50 -218
  25. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +2 -12
  26. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +0 -12
  27. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +52 -106
  28. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +1 -6
  29. package/lib/index.d.ts +7 -11
  30. package/lib/index.js +35 -55
  31. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  32. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  33. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  34. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +0 -3
  35. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +4 -41
  36. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +51 -220
  37. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -5
  38. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +2 -15
  39. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +0 -40
  40. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +1 -13
  41. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +2 -28
  42. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +53 -107
  43. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +2 -7
  44. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +1 -6
  45. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +0 -19
  46. package/package.json +1 -1
  47. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +0 -21
  48. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -54
  49. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -50
  50. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -40
  51. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +0 -29
  52. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -40
  53. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -58
  54. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -77
  55. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -14
  56. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -207
  57. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -41
  58. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +0 -7
  59. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -44
  60. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +0 -8
  61. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +0 -33
  62. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +0 -9
  63. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -44
  64. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +0 -28
  65. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -62
  66. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +0 -9
  67. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -81
  68. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +0 -24
  69. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -17
  70. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +0 -29
  71. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -215
  72. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +0 -154
  73. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -46
@@ -1,9 +0,0 @@
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>;
@@ -1,81 +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 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;
@@ -1,24 +0,0 @@
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>;
@@ -1,17 +0,0 @@
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');
@@ -1,29 +0,0 @@
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>;
@@ -1,215 +0,0 @@
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;
@@ -1,154 +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
- import { ID } from '../../../../commonStateTypes/common';
11
- import { AllowedDocumentType } from '../../../../entity/file/fileState';
12
- /**
13
- * Form-side identity document types as picked in `SelectDocumentField`.
14
- * These are camelCase per the web-components convention.
15
- */
16
- export type KycSelectDocumentType = 'driverLicense' | 'passport' | 'ssnCard' | 'stateId';
17
- /**
18
- * KYC document types accepted by the document-service parsers (snake_case).
19
- * Subset of {@link KycKybProvidedDocumentType}. `stateId` from the form maps
20
- * to no parser today and is skipped at dispatch time.
21
- */
22
- export type KycProvidedDocumentType = 'passport' | 'driving_license' | 'social_security_card';
23
- /** KYB document types accepted by the document-service parsers. */
24
- export type KybProvidedDocumentType = 'certificate_of_incorporation' | 'tax_ein';
25
- /** All KYC / KYB document types accepted by document-communication-agent. */
26
- export type KycKybProvidedDocumentType = KycProvidedDocumentType | KybProvidedDocumentType;
27
- /** Field value with model confidence (0..1) as returned by ExtendAI parsers. */
28
- export interface FieldWithConfidence<T = string | null> {
29
- confidence: number;
30
- value: T | null;
31
- }
32
- /**
33
- * Parser payloads — keep in sync with document-service
34
- * `processors/parsers/extend_*_parser.py`.
35
- */
36
- export interface ExtendPassportParsed {
37
- date_of_birth?: FieldWithConfidence;
38
- date_of_expiry?: FieldWithConfidence;
39
- date_of_issue?: FieldWithConfidence;
40
- first_name?: FieldWithConfidence;
41
- gender?: FieldWithConfidence;
42
- issuing_authority?: FieldWithConfidence;
43
- last_name?: FieldWithConfidence;
44
- mrz_line_1?: FieldWithConfidence;
45
- mrz_line_2?: FieldWithConfidence;
46
- nationality?: FieldWithConfidence;
47
- passport_number?: FieldWithConfidence;
48
- place_of_birth?: FieldWithConfidence;
49
- }
50
- export interface ExtendDrivingLicenseParsed {
51
- address_city?: FieldWithConfidence;
52
- address_state?: FieldWithConfidence;
53
- address_street?: FieldWithConfidence;
54
- address_zip?: FieldWithConfidence;
55
- date_of_birth?: FieldWithConfidence;
56
- date_of_expiry?: FieldWithConfidence;
57
- date_of_issue?: FieldWithConfidence;
58
- first_name?: FieldWithConfidence;
59
- issuing_state?: FieldWithConfidence;
60
- last_name?: FieldWithConfidence;
61
- license_number?: FieldWithConfidence;
62
- middle_name?: FieldWithConfidence;
63
- }
64
- export interface ExtendSsnCardParsed {
65
- full_name?: FieldWithConfidence;
66
- }
67
- export interface ExtendCertificateOfIncorporationParsed {
68
- company_address?: FieldWithConfidence;
69
- company_legal_name?: FieldWithConfidence;
70
- countries_of_operations?: FieldWithConfidence<string[]>;
71
- date_of_incorporation?: FieldWithConfidence;
72
- ein?: FieldWithConfidence;
73
- industry?: FieldWithConfidence;
74
- phone_number?: FieldWithConfidence;
75
- product_description?: FieldWithConfidence;
76
- purpose_of_account?: FieldWithConfidence;
77
- registered_address?: FieldWithConfidence;
78
- regulated_status?: FieldWithConfidence;
79
- source_of_funds?: FieldWithConfidence;
80
- state_of_incorporation?: FieldWithConfidence;
81
- sub_industry?: FieldWithConfidence;
82
- sub_us_nexus?: FieldWithConfidence;
83
- transaction_volume_expectations?: FieldWithConfidence;
84
- type_of_incorporation?: FieldWithConfidence;
85
- us_nexus?: FieldWithConfidence;
86
- website?: FieldWithConfidence;
87
- }
88
- export interface ExtendTaxEinParsed {
89
- ein?: FieldWithConfidence;
90
- irs_address?: FieldWithConfidence;
91
- legal_business_name?: FieldWithConfidence;
92
- trade_name?: FieldWithConfidence;
93
- }
94
- /** POST /1.0/documents/process/sync request body. */
95
- export interface SyncDocumentsProcessRequest {
96
- files: Array<{
97
- file_id: ID;
98
- }>;
99
- provided_document_type: KycKybProvidedDocumentType;
100
- metadata?: {
101
- source?: string;
102
- } & Record<string, unknown>;
103
- processing_priority?: number;
104
- }
105
- /** Parser payload union — `data.files[0].extracted_data` for any document type. */
106
- export type ExtendExtractedData = ExtendPassportParsed | ExtendDrivingLicenseParsed | ExtendSsnCardParsed | ExtendCertificateOfIncorporationParsed | ExtendTaxEinParsed;
107
- /** Per-file row inside the batch response. */
108
- export interface SyncDocumentsProcessFileResult {
109
- extracted_data: ExtendExtractedData | null;
110
- file_id: ID;
111
- status: string;
112
- filename?: string | null;
113
- processing_metadata?: Record<string, unknown>;
114
- }
115
- /** POST /1.0/documents/process/sync response body. */
116
- export interface SyncDocumentsProcessResponse {
117
- data: {
118
- files: SyncDocumentsProcessFileResult[];
119
- provided_document_type: KycKybProvidedDocumentType;
120
- request_id: string;
121
- status: string;
122
- tenant_id: string;
123
- metadata?: Record<string, unknown>;
124
- } | null;
125
- status: {
126
- code: number;
127
- message: string;
128
- };
129
- }
130
- /**
131
- * Discriminator for which Redux slice to apply the autofill to — setup pages
132
- * (`spendManagement/commonSetup`) and onboarding (`onboardingView/customerView`)
133
- * share the same field shapes but live in separate slices.
134
- */
135
- export type KycKybAutofillTarget = 'setup' | 'onboarding';
136
- /** Confidence floor below which we drop an autofill candidate. */
137
- export declare const KYC_KYB_AUTOFILL_MIN_CONFIDENCE = 0.5;
138
- /**
139
- * Maps the form-side {@link KycSelectDocumentType} (camelCase) to the
140
- * parser-side {@link KycProvidedDocumentType} (snake_case). Returns `null` for
141
- * `stateId`, which has no parser today.
142
- */
143
- export declare const toKycProvidedDocumentType: (selectType: KycSelectDocumentType) => KycProvidedDocumentType | null;
144
- /**
145
- * Maps a persisted {@link AllowedDocumentType} (snake_case — the value stored on
146
- * an officer's `documentTypeSelectedForVerification`) to the parser-side
147
- * {@link KycProvidedDocumentType}. Returns `null` for document types with no KYC
148
- * parser today (e.g. `id_document` / state ID, and any non-identity doc).
149
- *
150
- * The officer's stored selection is an `AllowedDocumentType`, not a
151
- * {@link KycSelectDocumentType}; use this — not {@link toKycProvidedDocumentType}
152
- * — when triggering autofill off that field.
153
- */
154
- export declare const toKycProvidedDocumentTypeFromAllowed: (allowedType: AllowedDocumentType) => KycProvidedDocumentType | null;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toKycProvidedDocumentTypeFromAllowed = exports.toKycProvidedDocumentType = exports.KYC_KYB_AUTOFILL_MIN_CONFIDENCE = void 0;
4
- /** Confidence floor below which we drop an autofill candidate. */
5
- exports.KYC_KYB_AUTOFILL_MIN_CONFIDENCE = 0.5;
6
- /**
7
- * Maps the form-side {@link KycSelectDocumentType} (camelCase) to the
8
- * parser-side {@link KycProvidedDocumentType} (snake_case). Returns `null` for
9
- * `stateId`, which has no parser today.
10
- */
11
- const toKycProvidedDocumentType = (selectType) => {
12
- switch (selectType) {
13
- case 'driverLicense':
14
- return 'driving_license';
15
- case 'passport':
16
- return 'passport';
17
- case 'ssnCard':
18
- return 'social_security_card';
19
- case 'stateId':
20
- return null;
21
- }
22
- };
23
- exports.toKycProvidedDocumentType = toKycProvidedDocumentType;
24
- /**
25
- * Maps a persisted {@link AllowedDocumentType} (snake_case — the value stored on
26
- * an officer's `documentTypeSelectedForVerification`) to the parser-side
27
- * {@link KycProvidedDocumentType}. Returns `null` for document types with no KYC
28
- * parser today (e.g. `id_document` / state ID, and any non-identity doc).
29
- *
30
- * The officer's stored selection is an `AllowedDocumentType`, not a
31
- * {@link KycSelectDocumentType}; use this — not {@link toKycProvidedDocumentType}
32
- * — when triggering autofill off that field.
33
- */
34
- const toKycProvidedDocumentTypeFromAllowed = (allowedType) => {
35
- switch (allowedType) {
36
- case 'passport':
37
- return 'passport';
38
- case 'driving_license':
39
- return 'driving_license';
40
- case 'social_security_card':
41
- return 'social_security_card';
42
- default:
43
- return null;
44
- }
45
- };
46
- exports.toKycProvidedDocumentTypeFromAllowed = toKycProvidedDocumentTypeFromAllowed;