import type { Accessors, EventHub, ReadonlyAccessors } from '../../common'; import { Document } from '../../common/shared/models/Document'; import type { CompleteStatus, FailedStatus, InputRequiredStatus, OCRClient, OCRResults } from '../../frankie-client/clients/OCRClient'; import { OCRStatus } from '../../frankie-client/clients/OCRClient'; import type { PartialDocument } from '../../frankie-client/mocks/options/simplified/ocrFlow'; import type { IndividualModule } from '../../individual'; import type { OCRRecipeOptions } from './..'; import type { GlobalEvents } from '../../sdk/types'; import type { Events } from '../events'; export type Dependencies = { _expectedSide$: ReadonlyAccessors<'front' | 'back' | null>; status$: Accessors; document$: Accessors; files$: Accessors; individual: IndividualModule['moduleContext']; eventHub: EventHub; client: OCRClient; isPreloaded$: Accessors; failedStatus$: Accessors; globalEventHub: EventHub; maxDocumentCount: number; documents: OCRRecipeOptions['documents']; }; export type DependenciesWithInterrupt = Dependencies & { interruptOCR: InterruptOCR; }; type InterruptOCR = (e: { message: string; payload?: unknown; }) => void; /** * Returns the start method called by customers to trigger the OCR flow * It first generates two observables by branching off the OCR's internal state variables * a) status$ * Which will cycle on every new status and * will interrupt the cycle once the value of status is COMPLETE OR there is a forced interruption * b) failedStatus$ * Which will cycle on every new fail status, ignoring null values, issued when failures are resolved * Will be interrupted by any forced interruptions * * Forced interruptions occur when the function interruptOCR is called by either the customer or internally, * when we reach an unrecoverable state. So far the unrecoverable states are * - Receiving a status PROVIDER_OFFLINE form backend * - File submission fails due to server/network issues * - Receiving a status WAITING_OCR_RUN, reattempting automatically and failing with another WAITING_OCR_RUN * * Each of the subscriber callbacks will trigger a different part of the OCR flow via events: * next => input_required, this one is triggered from both status$ and failedStatus$ observables * - Will happen on every failed status and every new that *IS NOT* * -- COMPLETE * -- WAITING_OCR_RUN * -- PROVIDER_OFFLINE * complete => results * - Will happen when the status is COMPLETE * error => error * - Will happen when the flow is interrupted by * -- calling interruptOCR * -- status is PROVIDER_OFFLINE * -- WAITING_OCR_RUN is received twice in a row * -- file submission fails * * Besides these, an exception is thrown from the function submitFile when * - file is not of type "image" * - file is missing a type property * * @param deps dependencies passed from the OCR module * @returns { interruptOCR }, where interruptOCR forces the end of the OCR cycles */ export declare const mkStartMethod: (deps: Dependencies) => () => Promise<{ interruptOCR: () => void; }>; export declare const isOcrPreloaded: (d: PartialDocument) => boolean; export declare const resetCurrentStatus: (deps: DependenciesWithInterrupt) => Promise; export declare const completeOCR: (deps: DependenciesWithInterrupt) => void; export declare const inputRequired: (status: OCRStatus, deps: DependenciesWithInterrupt) => void; export declare const mkProvideFile: (deps: DependenciesWithInterrupt) => (file: File) => void; export declare const mkEvaluateResults: (deps: DependenciesWithInterrupt) => (results: OCRResults, recursionFlag?: boolean) => void; export {}; //# sourceMappingURL=start.d.ts.map