import type Mercure from '../mercure.js'; import type ApiDocumentation from '../api-documentation.js'; import type { FetcherStore } from '../../storage/stores/fetcher/fetcher-store.js'; import type { AddFetchResourceEvent, FinishFetchEvent, ManifestErrorFetchEvent, ManifestSuccessFetchEvent, SetManifestIrisByDepthEvent, StartFetchEvent, StartFetchResponse } from '../../storage/stores/fetcher/actions.js'; import type { ResourcesStore } from '../../storage/stores/resources/resources-store.js'; import type { CwaResourceError } from '../../errors/cwa-resource-error.js'; import type { CwaResource } from '../../resources/resource-utils.js'; import type { CwaFetchRequestHeaders, CwaFetchResponse } from './fetcher.js'; import type { FetchAbortReason } from '#cwa/storage/stores/fetcher/state'; import type { NuxtApp } from 'nuxt/app'; export interface FinishFetchResourceEvent { resource: string; userProvidedIri?: string; success: boolean; token: string; path: string; } export interface FinishFetchResourceSuccessEvent extends FinishFetchResourceEvent { success: true; fetchResponse: CwaFetchResponse | any; headers: CwaFetchRequestHeaders; noSave?: boolean; } export interface FinishFetchResourceErrorEvent extends FinishFetchResourceEvent { success: false; error?: CwaResourceError; } type _StartFetchEvent = Omit; /** * This class manages the state across the fetcher store, resources store and additional services for API Documentation and Mercure */ export default class FetchStatusManager { private readonly mercure; private readonly apiDocumentation; private readonly _fetcherStore; private readonly _resourcesStore; private readonly routeCacheLimit; private readonly nuxtApp; private readonly primaryFetchError; constructor(fetcherStoreDefinition: FetcherStore, mercure: Mercure, apiDocumentation: ApiDocumentation, resourcesStoreDefinition: ResourcesStore, routeCacheLimit: number | undefined, nuxtApp: NuxtApp); onPrimaryFetchError(handler: () => void): void; getFetchedCurrentResource(iri: string, timeout?: number): Promise; startFetch(event: _StartFetchEvent): StartFetchResponse; private getCachedRoute; private fetchHasDisplayablePage; startFetchResource(event: AddFetchResourceEvent): boolean; finishFetchResource(event: FinishFetchResourceSuccessEvent | FinishFetchResourceErrorEvent): CwaResource | undefined; finishFetch(event: FinishFetchEvent): Promise; private enforceRouteCacheLimit; private activeRoutePaths; private isResourceReferencedByCache; private isResourceProtectedFromEviction; private finishFetchShowError; private computedFetchChainComplete; private waitForFetchChainToComplete; setManifestIrisByDepth(event: SetManifestIrisByDepthEvent): void; getDepthForIri(iri: string): number | undefined; getPathForDepth(depth: number): string | undefined; registerIriDepth(iri: string, depth: number): void; finishManifestFetch(event: ManifestSuccessFetchEvent | ManifestErrorFetchEvent): void; isCurrentFetchingToken(token: string): boolean | undefined; abortFetch(token: string, reason?: FetchAbortReason): void; clearPrimaryFetch(): void; get primaryFetchPath(): string | undefined; get isCurrentSuccessResourcesResolved(): boolean; private get fetcherStore(); private get resourcesStore(); } export {};