import * as apollo_angular from 'apollo-angular'; import { Apollo } from 'apollo-angular'; import * as rxjs from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs'; import * as _apollo_client from '@apollo/client'; import * as i0 from '@angular/core'; import { ModuleWithProviders, InjectionToken } from '@angular/core'; import { HttpBackend } from '@angular/common/http'; declare enum NetworkStatus { /** * The query has never been run before and the query is now currently running. A query will still * have this network status even if a partial data result was returned from the cache, but a * query was dispatched anyway. */ loading = 1, /** * If `setVariables` was called and a query was fired because of that then the network status * will be `setVariables` until the result of that query comes back. */ setVariables = 2, /** * Indicates that `fetchMore` was called on this query and that the query created is currently in * flight. */ fetchMore = 3, /** * Similar to the `setVariables` network status. It means that `refetch` was called on a query * and the refetch request is currently in flight. */ refetch = 4, /** * Indicates that a polling query is currently in flight. So for example if you are polling a * query every 10 seconds then the network status will switch to `poll` every 10 seconds whenever * a poll request has been sent but not resolved. */ poll = 6, /** * No request is in flight for this query, and no errors happened. Everything is OK. */ ready = 7, /** * No request is in flight for this query, but one or more errors were detected. */ error = 8 } interface ApolloQlErrorDetail { errorMessage: string; code?: string; locations?: { line: number; column: number; }[]; stacktrace?: string[]; } interface ApolloQueryResult { data?: T; loading: boolean; networkStatus: NetworkStatus; partial?: boolean; error?: ApolloQlErrorDetail; } declare enum ErrorKindCodeEnumeration { ERROR = "ERROR", WARNING = "WARNING", SUCCESS = "SUCCESS" } declare enum ErrorTypeCodeEnumeration { MICROSERVICE_CONNECTION_ERROR = "MICROSERVICE_CONNECTION_ERROR", DATABASE_CONNECTION_ERROR = "DATABASE_CONNECTION_ERROR", INSERTION_FAILED = "INSERTION_FAILED", UPDATE_FAILED = "UPDATE_FAILED", DELETED_FAILED = "DELETED_FAILED", NOT_FOUND = "NOT_FOUND", PARTIALLY_FOUND = "PARTIALLY_FOUND", UNAUTHORIZED = "UNAUTHORIZED", FORBIDDEN = "FORBIDDEN", INVALID_FILTERS = "INVALID_FILTERS", HANDLED_ERROR = "HANDLED_ERROR", UNKNOWN_ERROR = "UNKNOWN_ERROR" } interface Errors { entityField: string; entityKey: string; errorCode: ErrorTypeCodeEnumeration; kind: ErrorKindCodeEnumeration; message: string; messageCode: string; } interface PagingInfo { totalPages?: number; totalRecords?: number; actualPage?: number; actualOffset?: number; actualLimit?: number; } interface GraphQlResult { result: DataOutput; } interface DataOutput { data: T[]; pagingInfo?: PagingInfo; errors: Errors[] | null; } interface Location { line?: number; column?: number; } interface IKeys { domine: string; key: string; } declare class GraphQLComponent { apollo: Apollo; constructor(apollo: Apollo); read(query: string, variables: any, fetchPolicy?: any, newVersion?: boolean): rxjs.Observable<{ data: unknown; error?: _apollo_client.ErrorLike; } | ApolloQueryResult>; update(query: string, variables: any, newVersion?: boolean): rxjs.Observable | ({ data: unknown; error?: _apollo_client.ErrorLike; } & { extensions?: Record; } & { loading?: boolean; })>; watchQuery(query: string, variables: any): apollo_angular.QueryRef; resetCacheApollo(): void; create(query: any, variables?: any, newVersion?: boolean): rxjs.Observable | ({ data: unknown; error?: _apollo_client.ErrorLike; } & { extensions?: Record; } & { loading?: boolean; })>; delete(query: string, variables: any, newVersion?: boolean): rxjs.Observable | ({ data: unknown; error?: _apollo_client.ErrorLike; } & { extensions?: Record; } & { loading?: boolean; })>; private getCatchError; private standardizeError; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class GraphQLModule { static forRoot(environment: any): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } interface IRoleActive { name: string; code: string; } interface IAuthConfig { refresh_url?: string; /** * Clave del token en la respuesta del endpoint de refresh. * AWS Cognito retorna 'access_token' por defecto. */ refresh_token_key?: string; /** * Función provista por el consumidor para renovar el token silenciosamente. * Debe retornar el nuevo access token o null si la renovación falló. * Ejemplo con Amplify: () => fetchAuthSession({ forceRefresh: true }) * .then(s => s.tokens?.accessToken?.toString() ?? null) */ onRefresh?: () => Promise; } declare const AUTH_CONFIG: InjectionToken; declare class AuthService { private authConfig; private readonly TOKEN_KEY; private readonly TOKEN; private readonly REFRESH_TOKEN_KEY; private readonly ROLE_ACTIVE_KEY; private readonly USER_KEY; private readonly USER_CAPABILITIES_KEY; private readonly CIA_KEY; private tokenSubject; /** Indica si hay un refresh en curso para serializar peticiones concurrentes */ isRefreshing: boolean; /** Emite el nuevo token cuando el refresh finaliza; null mientras está en curso */ refreshTokenSubject: BehaviorSubject; private http; constructor(handler: HttpBackend, authConfig: IAuthConfig | null); setToken(token: string): void; getToken(): string | null; clearToken(): void; getTokenObservable(): Observable; isLoggedIn(): boolean; /** * Parsea el JWT y comprueba si el claim `exp` ya venció. * Retorna true si no hay token, si no es un JWT válido o si expiró. */ isTokenExpired(): boolean; setRefreshToken(token: string): void; getRefreshToken(): string | null; clearRefreshToken(): void; refreshAccessToken(): Observable; removeActiveRole(): void; setActiveRole(roleCode: IRoleActive): void; getActiveRole(): IRoleActive | null; logout(): void; getSubDomain(): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class SessionExpiredService { private readonly expired$; private hasEmitted; readonly sessionExpired: Observable; emit(): void; reset(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { AUTH_CONFIG, AuthService, ErrorKindCodeEnumeration, ErrorTypeCodeEnumeration, GraphQLComponent, GraphQLModule, SessionExpiredService }; export type { ApolloQlErrorDetail, ApolloQueryResult, Errors, GraphQlResult, IAuthConfig, IKeys, IRoleActive, Location, PagingInfo };