import * as apollo_angular from 'apollo-angular'; import { Apollo } from 'apollo-angular'; import * as rxjs from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs'; import * as kif_lib_services from 'kif-lib/services'; import * as _apollo_client from '@apollo/client'; import { DefaultContext } from '@apollo/client/core'; import * as i0 from '@angular/core'; import { ModuleWithProviders, InjectionToken, EnvironmentProviders } from '@angular/core'; import { HttpBackend, HttpContextToken } from '@angular/common/http'; declare class GraphQLComponent { apollo: Apollo; constructor(apollo: Apollo); read(query: string, variables: any, fetchPolicy?: any, newVersion?: boolean, context?: DefaultContext): rxjs.Observable<{ data: unknown; error?: _apollo_client.ErrorLike; } | kif_lib_services.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; 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; } 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" } declare enum ErrorKindCodeEnumeration { ERROR = "ERROR", WARNING = "WARNING", SUCCESS = "SUCCESS" } 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; } 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; } 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; } /** * Marca una request HTTP como pública: el `AuthInterceptor` la deja pasar * sin `authorization` ni `active-role` y sin intentar refrescar el token. * * Caso de uso: la query de configuración del cliente (CLVDKIF-1858), que * corre antes de que Amplify esté configurado. Con un token vencido en el * storage, el refresh fallaría (Amplify todavía no existe) y el arranque * quedaría trabado en la pantalla de error. * * Con Apollo: `context: { httpContext: new HttpContext().set(KIF_PUBLIC_REQUEST, true) }`. */ declare const KIF_PUBLIC_REQUEST: HttpContextToken; /** Config de Cognito del cliente (bloque `aws` del JSON de configuración). */ interface ClientAwsConfig { region?: string; cognitoRegion?: string; userPoolId: string; userPoolWebClientId: string; oauthDomain?: string; } /** * Configuración multicliente resuelta en el arranque (CLVDKIF-1858). * Todo es opcional salvo `apiKey`: cada app declara en `required` lo que * necesita para arrancar (el shell exige además `aws`). */ interface ClientConfig { apiKey: string; /** Ya decodificada: el parser hace el `atob` del base64 que entrega back. */ googlePlacesApiKey?: string; urlAws?: string; urlPublish?: string; gtm?: string; aws?: ClientAwsConfig; } interface ClientConfigFetchContext { /** Subdominio del host (`sura-dev`, `dev`...) o el `?subdomain=` en localhost. */ subdomain: string; graphQL: GraphQLComponent; } /** * Obtiene el JSON crudo de la configuración; el parseo y la validación los * hace `ClientConfigService`. Por defecto es `defaultClientConfigFetcher` * (query GraphQL de la lib). El shell sólo lo reemplaza ante un hotfix. */ type ClientConfigFetcher = (ctx: ClientConfigFetchContext) => Promise; interface ClientConfigOptions { /** Reemplaza la query por defecto. Sólo para hotfix desde el shell. */ fetch?: ClientConfigFetcher; /** * Si viene, se usa en lugar de la query (mientras back no defina la * query definitiva, o para desarrollo local sin back). */ mock?: ClientConfigFetcher; /** Campos sin los cuales la app no puede arrancar. Default: `['apiKey']`. */ required?: ReadonlyArray; /** * Sólo desarrollo local: subdominio que se consulta en localhost cuando la * URL no trae `?subdomain=` ni hay uno recordado en la pestaña. En un host * real no tiene efecto. Default: `localhost` (back responde NOT_FOUND). */ localSubdomain?: string; /** Tiempo máximo de espera de la consulta. Default: 8000 ms. */ timeoutMs?: number; } type ClientConfigErrorReason = 'query' | 'invalid' | 'missing' | 'timeout'; declare class ClientConfigError extends Error { readonly reason: ClientConfigErrorReason; readonly missingFields: ReadonlyArray; readonly cause?: unknown | undefined; constructor(reason: ClientConfigErrorReason, message: string, missingFields?: ReadonlyArray, cause?: unknown | undefined); } declare const clientConfigStore: { /** Config ya resuelta, o `undefined` si todavía no se cargó. */ get(): Readonly | undefined; /** Carga en curso (la comparten todas las llamadas concurrentes). */ pending(): Promise> | undefined; /** * Registra una carga. Al resolver congela y publica la config; si falla * limpia la promesa para que el siguiente intento vuelva a consultar. */ track(load: Promise): Promise>; /** Sólo para tests. */ reset(): void; }; /** sessionStorage donde se recuerda el `?subdomain=` de localhost. */ declare const LOCAL_SUBDOMAIN_STORAGE_KEY = "kif-local-subdomain"; /** Mismo criterio que back: minúsculas y sin espacios. */ declare function normalizeSubdomain(value: string | null | undefined): string; declare function isValidSubdomain(value: string): boolean; /** * Subdominio del cliente: primera etiqueta del host (`sura-dev.kipinsurtech.com` * → `sura-dev`), normalizada como la normaliza back. En localhost se puede * simular con `?subdomain=` (queda recordado en la pestaña); sin el parámetro * devuelve `localFallback` (default `localhost`). Dominio desnudo o `www` → `''`. */ declare function resolveSubdomain(hostname?: string, search?: string, localFallback?: string): string; /** * Normaliza el JSON crudo a `ClientConfig`: acepta objeto o string JSON, * ignora campos desconocidos y valida que estén los `required`. * * @throws ClientConfigError `invalid` si no es un objeto JSON, `missing` si falta un requerido. */ declare function parseClientConfig(raw: unknown, required?: ReadonlyArray): ClientConfig; /** * Valida que la config traiga los campos que necesita quien la pide. Se usa * también sobre una config ya resuelta: cada app puede exigir campos distintos * (el shell `aws`, un MFE sólo `apiKey`) sobre la misma config compartida. * * @throws ClientConfigError `missing` con los campos que faltan. */ declare function assertRequired>(config: T, required: ReadonlyArray): T; /** * Query de configuración del cliente (CLVDKIF-1858). Es el único punto que * cambia si back modifica el contrato. * * Contrato de back: * - Pública: no necesita api-key ni token. Si se combina con otra operación en * la misma request, el gateway vuelve a exigir api-key, así que va sola. * - El subdominio viaja en el header `subdomain` (no como variable). Back lo * normaliza a minúsculas y sin espacios. * - `data` es un array con un objeto tipado. Los errores vienen en `errors` * con `data: null`: NOT_FOUND (no existe) o INVALID_FILTERS (falta el header * o tiene un formato inválido). * * Viaja como request pública (`KIF_PUBLIC_REQUEST`): sin token, para que un * token vencido no dispare un refresh antes de configurar Amplify. */ declare const CLIENT_CONFIG_QUERY = "\n query ClientConfig_BySubdomain {\n result: ClientConfig_BySubdomain {\n data {\n subdomain\n apiKey\n googlePlacesApiKey\n gtm\n urlAws\n urlPublish\n aws {\n region\n cognitoRegion\n userPoolId\n userPoolWebClientId\n oauthDomain\n }\n }\n errors {\n errorCode\n messageCode\n message\n }\n }\n }"; /** Header con el que back identifica al cliente. */ declare const CLIENT_CONFIG_SUBDOMAIN_HEADER = "subdomain"; /** * Query por defecto. No usa `ApolloResponseUtils.handleResponse` porque corre * dentro del initializer, antes de que exista la UI donde mostrar un snackbar: * los errores suben como `ClientConfigError` y los maneja quien arranca la app. */ declare const defaultClientConfigFetcher: ClientConfigFetcher; /** Opciones con las que se registró `provideClientConfig` (para llamadas lazy a `load()`). */ declare const CLIENT_CONFIG_OPTIONS: InjectionToken; declare class ClientConfigService { private readonly graphQL; private readonly defaultOptions; private readonly _config; /** Config resuelta; `undefined` hasta que termine la carga. */ readonly config: i0.Signal | undefined>; /** * Idempotente: si el shell (u otra llamada) ya resolvió la config o la * está resolviendo, la reutiliza sin volver a consultar. Los `required` de * quien llama se validan siempre, también sobre la config compartida: si * faltan, se rechaza esta llamada sin tocar la config de las demás. */ load(options?: ClientConfigOptions): Promise>; private fetchConfig; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Resuelve la configuración del cliente antes del bootstrap. * * En un MFE embebido el `app.config.ts` no se ejecuta (el shell sólo importa * sus rutas), así que este initializer corre únicamente en standalone; en * embebido la config ya la dejó el shell en el holder global. */ declare function provideClientConfig(options?: ClientConfigOptions): EnvironmentProviders; /** * Carga el script de Google Maps/Places con la key de la configuración del * cliente. Reemplaza las copias locales de `GoogleMapsLoaderService` de cada * MFE (que leían `environment.google_api_hash`). * * El estado de la carga vive en el propio `