UNPKG

@accounter/server

Version:
47 lines (46 loc) 2.38 kB
import type { Injector } from 'graphql-modules'; import { Currency, DocumentType } from '../../../shared/enums.js'; import type { BusinessMatchData, OwnerMatchInfo } from '../../app-providers/helpers/business-matcher.helper.js'; import type { IInsertDocumentsParams } from '../types.js'; export declare const uploadToCloudinary: (injector: Injector, file: File | Blob) => Promise<{ fileUrl: string; imageUrl: string; }>; export type OcrData = { isOwnerIssuer?: boolean; counterpartyId?: string; documentType: DocumentType; serial?: string; date?: Date; amount?: number; currency?: Currency; vat?: number; allocationNumber?: string; description?: string; remarks?: string; suggestedIssuer?: string; suggestedRecipient?: string; }; /** * Pre-resolved inputs for the OCR business matching, for callers that cannot use * the auth-coupled `BusinessesProvider` / `AdminContextProvider` loaders — namely * the gateway email-ingestion path, which runs under a control-plane context * where their `TenantAwareDBClient` throws "Missing businessId in AuthContext". */ export type BusinessMatchContext = { businesses: BusinessMatchData[]; owner?: OwnerMatchInfo; }; export declare function getOcrData(injector: Injector, file: File | Blob, isSensitive?: boolean | null, matchContext?: BusinessMatchContext): Promise<OcrData>; export declare function getDocumentFromUrlsAndOcrData(injector: Injector, fileUrl: string, imageUrl: string, ocrData: OcrData, adminBusinessId: string, chargeId?: string | null, fileHash?: number, vatFallbackContext?: { counterpartyCountry: string | null; adminLocality: string | null; }): Promise<IInsertDocumentsParams['documents'][number]>; /** * Turn the OCR business-match UUIDs (`suggestedIssuer` / `suggestedRecipient`) * into `isOwnerIssuer` + `counterpartyId`. `counterpartyId` is only filled when * unset (`??=`), so a caller that already resolved the counterparty from a * higher-confidence source (e.g. the email-ingestion grant) keeps it. */ export declare function resolveOwnerSideFromUuids(ocrData: OcrData, ownerId: string): void; export declare function getDocumentFromFile(injector: Injector, file: File | Blob, chargeId?: string | null, isSensitive?: boolean | null, counterPartyId?: string, hash?: number): Promise<IInsertDocumentsParams['documents'][number]>;