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; }): 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; private _dataPromiseMap; protected getDataPromise: FilesDataFn; private _bulkDataPromise; protected getBulkDataPromise: FilesBulkDataFn; } export {};