UNPKG

dta-vision-ocr

Version:

Biblioteca Angular com PO UI para extração de dados estruturados via OCR a partir de imagens ou PDFs, retornando JSON configurável com suporte a processamento em lote.

269 lines (255 loc) 9.15 kB
import * as i0 from '@angular/core'; import { EventEmitter, OnInit, OnDestroy } from '@angular/core'; import { PoDialogService, PoNotificationService, PoModalComponent } from '@po-ui/ng-components'; import { ActivatedRoute } from '@angular/router'; import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; type FieldType = 'string' | 'number' | 'date' | 'object' | 'array'; interface DocumentModel { imageReturn: boolean; idButton?: string; imageBase64: string; canUserSet: boolean; userFields?: DocumentJsonImageModel[]; } interface DocumentJsonImageModel { isRequired?: boolean; fieldName: string; fieldType: FieldType; fieldLabel?: string; fieldDescription?: string; userArray?: DocumentJsonImageModel[]; subFields?: DocumentJsonImageModel[]; } interface DocumentResponse { idButton?: string; imageBase64: string; ocrResponse: string; } interface ButtonDocumentModel { imageReturn: boolean; idButton: string; nameButton: string; canUserSet?: boolean; userFields?: DocumentJsonImageModel[]; } interface SessionIDModel { sessionID: string; expiredAt: Date; } interface AuthenticationDtaModel { totvsId: string; projectId: string; user: string; contingency: string; applicationID: number; } interface AuthenticationDtaResponseModel { token: string; success?: boolean; message?: string; } interface Credentials { totvsId: string; projectId: string; user: string; contingency: string; } declare class JwtAuthApi { private readonly http; private readonly tokenSubject; constructor(http: HttpClient); getValidToken(credentials: Credentials): Observable<string>; private isSameCredentials; private createToken; private refreshToken; private decodeJwt; private isTokenExpiring; static ɵfac: i0.ɵɵFactoryDeclaration<JwtAuthApi, never>; static ɵprov: i0.ɵɵInjectableDeclaration<JwtAuthApi>; } declare class SessionIdApi { private readonly http; private readonly jwtAuthApi; constructor(http: HttpClient, jwtAuthApi: JwtAuthApi); post(host: string, idDTAVision: string, idProjeto: string, user: string, contingency: string, buttonDocumentModel: Array<ButtonDocumentModel>): Observable<SessionIDModel>; delete(host: string, sessionID: string): Observable<any>; static ɵfac: i0.ɵɵFactoryDeclaration<SessionIdApi, never>; static ɵprov: i0.ɵɵInjectableDeclaration<SessionIdApi>; } declare class SignalRService { private hubConnection; host: string; messageReceived: EventEmitter<{ menssagem: DocumentResponse; uniqueKey: number; }>; statusUpdated: EventEmitter<{ status: any; }>; initializeConnection(sessionID: string): void; private closeConnection; startConnection(): Promise<void>; joinSession(sessionID: string): Promise<void>; leaveSession(sessionID: string): Promise<void>; formsLocal(sessionID: string | null, body: Array<DocumentModel | null>, idTotvs: string, idProjeto: string): Promise<Array<DocumentResponse> | undefined>; private ensureListening; dispose(): void; static ɵfac: i0.ɵɵFactoryDeclaration<SignalRService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<SignalRService>; } declare class DtaVisionAuthenticationTokenApi { private readonly http; private readonly baseUrl; constructor(http: HttpClient); /** * Gera um novo token de autenticação */ postToken(authenticationDtaModel: AuthenticationDtaModel): Observable<AuthenticationDtaResponseModel>; /** * Faz refresh do token atual */ postRefreshToken(tokenJwt: string): Observable<AuthenticationDtaResponseModel>; static ɵfac: i0.ɵɵFactoryDeclaration<DtaVisionAuthenticationTokenApi, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DtaVisionAuthenticationTokenApi>; } declare class DtaVisionAuthenticationTokenService { private readonly dtaVisionAuthenticationTokenApi; private readonly storageKey; private readonly authModelStorageKey; private readonly expWarningSeconds; constructor(dtaVisionAuthenticationTokenApi: DtaVisionAuthenticationTokenApi); /** * Gera o token e armazena no sessionStorage */ generateAndStoreToken(authenticationDtaModel: AuthenticationDtaModel): Observable<AuthenticationDtaResponseModel>; /** * Faz refresh do token atual e armazena no sessionStorage */ refreshToken(tokenJwt: string): Observable<AuthenticationDtaResponseModel>; /** * Verifica se o token armazenado é válido (não expirado) */ isTokenValid(): boolean; /** * Obtém o token JWT salvo no sessionStorage */ getToken(): string | null; /** * Salva o model de autenticação no sessionStorage (como JSON) */ setAuthModelToStorage(): void; /** * Recupera o model de autenticação salvo no sessionStorage */ getAuthModelFromStorage(): AuthenticationDtaModel | null; /** * Garante um token válido: se expirado, faz novo login, * se perto de expirar, faz refresh, senão retorna o atual */ getTokenValidOrRefresh(): Observable<string>; static ɵfac: i0.ɵɵFactoryDeclaration<DtaVisionAuthenticationTokenService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DtaVisionAuthenticationTokenService>; } declare enum SessionStatusEnum { /** * PENDENTE ==> (APAGAR EM 10 MINUTOS) */ Pendente = 1, /** * ATIVADO ==> (ATUALIZAR EM 10 MINUTOS E DEPOIS 10 MINUTOS) * E APAGAR SE CASO ULTRAPASSAR OS 10 MINUTOS. */ Ativado = 2, /** * Documento Processado ==> Entrou no loop de documentos. */ DocumentoProcessado = 3, /** * Consumido ==> Após a chamada do loop mandar uma chamada. */ Consumido = 4, /** * EXPIRADO ==> (Apenas para os status Pendente e Ativo). */ Expirado = 5, /** * Error .==> caso ocorra algum erro. */ Error = 100 } declare class DTAVisionOCRComponent implements OnInit, OnDestroy { private readonly poNotificationService; private readonly signalRService; private readonly sessionIDApi; poDialog: PoDialogService; private readonly route; private readonly sanitizer; idDTAVision: string; idProjeto: string; listButtonsDocument: Array<ButtonDocumentModel>; user: string; contingency: string; informacaoEnviada: EventEmitter<{ menssagem: DocumentResponse; uniqueKey: number; }>; loading: boolean; screenLock: boolean; doesNotDisplayMessage: boolean; telaInicial: boolean; iframeSrc?: SafeResourceUrl; sessionText: string; private readonly host; private readonly hostWebApp; private routeWeb; private sessionID; statusDocument: SessionStatusEnum; private statusSubscription; isMobileDevice: boolean; sessionExpired: boolean; listDocumentUniqueKey: Array<number>; constructor(poNotificationService: PoNotificationService, signalRService: SignalRService, sessionIDApi: SessionIdApi, poDialog: PoDialogService, route: ActivatedRoute, sanitizer: DomSanitizer); webAppModal?: PoModalComponent; ngOnInit(): void; private initializeSessionStatus; ngOnDestroy(): void; documentProcess(): boolean; openDialog(): void; iniciarSessao(): void; openWebAppModal(): void; closeWebAppModal(): void; newSession(): Promise<void>; private validateSession; private setUrl; private isAllowedUrl; private initializeSignalRConnection; private joinSession; private getSessionID; onCheckboxChange(): void; static ɵfac: i0.ɵɵFactoryDeclaration<DTAVisionOCRComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<DTAVisionOCRComponent, "dta-vision-ocr", never, { "idDTAVision": { "alias": "idDTAVision"; "required": false; }; "idProjeto": { "alias": "idProjeto"; "required": false; }; "listButtonsDocument": { "alias": "listButtonsDocument"; "required": false; }; "user": { "alias": "user"; "required": false; }; "contingency": { "alias": "contingency"; "required": false; }; }, { "informacaoEnviada": "informacaoEnviada"; }, never, never, true, never>; } declare const environment: { production: boolean; api: { dtaAuth: { baseUrl: string; endpoints: { token: string; refreshToken: string; }; }; }; apiHost: string; apiHostWebApp: string; sessionStorageKeys: { idTotvsVisionDocument: string; idProjetoDocument: string; userDocument: string; contingencyDocument: string; }; }; export { DTAVisionOCRComponent, DtaVisionAuthenticationTokenApi, DtaVisionAuthenticationTokenService, SignalRService, environment }; export type { AuthenticationDtaModel, AuthenticationDtaResponseModel, ButtonDocumentModel, DocumentJsonImageModel, DocumentModel, DocumentResponse, FieldType, SessionIDModel };