import { type Awaitable } from "./types"; type Path = TParams extends [] ? "" : TParams extends [string] ? `${TPrefix}:${TParams[0]}${string}` : TParams extends readonly [string, ...infer Rest extends string[]] ? Path : string; /** * A function responsible for fetching the data required to render a given file * at the provided path. Used for optimization like server side rendering or * serverless. */ export type FilesDataFn = (context: { /** Path to get data for. */ path: string; /** Path parameters if any. */ params: Record; /** Akte app global data. */ globalData: TGlobalData; }) => Awaitable; /** A function responsible for fetching all the data required to render files. */ export type FilesBulkDataFn = (context: { /** Akte app global data. */ globalData: TGlobalData; }) => Awaitable>; export type FilesDefinition = { /** * Path pattern for the Akte files. * * @example * "/"; * "/foo"; * "/bar.json"; * "/posts/:slug"; * "/posts/:taxonomy/:slug"; * "/pages/**"; * "/assets/**.json"; */ path: Path; /** * A function responsible for fetching the data required to render a given * file. Used for optimization like server side rendering or serverless. * * Throwing a {@link NotFoundError} makes the file at path to be treated as a * 404, any other error makes it treated as a 500. */ data?: FilesDataFn; /** A function responsible for fetching all the data required to render files. */ bulkData?: FilesBulkDataFn; /** * A function responsible for rendering the file. * * @param context - Resolved file path, app global data, and data to render * the file. * @returns Rendered file. */ render: (context: { /** Path to render. */ path: string; /** Akte app global data. */ globalData: TGlobalData; /** File data for path. */ data: TData; }) => Awaitable; }; /** An Akte files, managing its data cascade and rendering process. */ export declare class AkteFiles { protected definition: FilesDefinition; /** Path pattern of this Akte files. */ get path(): string; constructor(definition: FilesDefinition); /** @internal Prefer {@link AkteApp.render} or use at your own risks. */ render(args: { path: string; params: Record; globalData: TGlobalData; data?: TData; }): Promise; /** @internal Prefer {@link AkteApp.renderAll} or use at your own risks. */ renderAll(args: { globalData: TGlobalData; }): Promise>; /** @internal Prefer {@link AkteApp.clearCache} or use at your own risks. */ clearCache(): void; /** * Readonly cache of files' definition `data` method. * * @experimental Programmatic API might still change not following SemVer. */ get dataMapCache(): ReadonlyMap>; private _dataMapCache; /** * Retrieves data from files' definition `data` method with given context. * * @param context - Context to get data with. * @returns Retrieved data. * @remark Returned data may come from cache. * @experimental Programmatic API might still change not following SemVer. */ getData: FilesDataFn; /** * Readonly cache of files' definition `bulkData` method. * * @experimental Programmatic API might still change not following SemVer. */ get bulkDataCache(): Awaitable> | undefined; private _bulkDataCache; /** * Retrieves data from files' definition `bulkData` method with given context. * * @param context - Context to get bulk data with. * @returns Retrieved bulk data. * @remark Returned bulk data may come from cache. * @experimental Programmatic API might still change not following SemVer. */ getBulkData: FilesBulkDataFn; } export {};