import { type ComponentDef, type FormDefinition, type Page } from '@defra/forms-model'; import { type ResponseToolkit, type Server } from '@hapi/hapi'; import { type ValidationErrorItem } from 'joi'; import { Liquid } from 'liquidjs'; import { type FormModel } from '~/src/server/plugins/engine/models/FormModel.js'; import { type PageControllerClass } from '~/src/server/plugins/engine/pageControllers/helpers/pages.js'; import { type FormContext, type FormContextRequest, type FormSubmissionError } from '~/src/server/plugins/engine/types.js'; import { FormStatus, type FormParams, type FormQuery, type FormResponseToolkit } from '~/src/server/routes/types.js'; export declare const engine: Liquid; export interface GlobalScope { context: FormContext; pages: Map; components: Map; } export declare function proceed(request: Pick, h: FormResponseToolkit, nextUrl: string): import("@hapi/hapi").ResponseObject; /** * Encodes a URL, returning undefined if the process fails. */ export declare function encodeUrl(link?: string): string | undefined; /** * Get page href */ export declare function getPageHref(page: PageControllerClass, query?: FormQuery): string; /** * Get page href by path */ export declare function getPageHref(page: PageControllerClass, path: string, query?: FormQuery): string; /** * Get redirect path with optional query params */ export declare function redirectPath(nextUrl: string, query?: FormQuery): string; export declare function isPathRelative(path?: string): boolean; export declare function normalisePath(path?: string): string; export declare function getPage(model: FormModel | undefined, request: FormContextRequest): PageControllerClass; export declare function findPage(model: FormModel | undefined, path?: string): PageControllerClass | undefined; export declare function getStartPath(model?: FormModel): string; export declare function checkFormStatus(params?: FormParams): { isPreview: boolean; state: FormStatus; }; export declare function checkEmailAddressForLiveFormSubmission(emailAddress: string | undefined, isPreview: boolean): void; /** * Parses the errors from {@link Schema.validate} so they can be rendered by govuk-frontend templates * @param [details] - provided by {@link Schema.validate} */ export declare function getErrors(details?: ValidationErrorItem[]): FormSubmissionError[] | undefined; export declare function getError(detail: ValidationErrorItem): FormSubmissionError; export declare function createError(componentName: string, message: string): { href: string; name: string; text: string; }; /** * Calculates an exponential backoff delay (in milliseconds) based on the current retry depth, * using a base delay of 2000ms (2 seconds) and doubling for each additional depth, while capping the delay at 25,000ms (25 seconds). * @param depth - The current retry depth (1, 2, 3, …) * @returns The calculated delay in milliseconds. */ export declare function getExponentialBackoffDelay(depth: number): number; export declare function evaluateTemplate(template: string, context: FormContext): string; export declare function getCacheService(server: Server): import("../../services/cacheService.js").CacheService; export declare function getSaveAndExitHelpers(server: Server): import("~/src/server/plugins/engine/types.js").SaveAndExitHandler | undefined; export declare function getPluginOptions(server: Server): { baseLayoutPath: string; cacheService: import("../../services/cacheService.js").CacheService; viewContext?: (request: import("~/src/server/plugins/engine/types.js").AnyFormRequest | null) => Record | Promise>; saveAndExit?: import("~/src/server/plugins/engine/types.js").PluginOptions["saveAndExit"]; baseUrl: string; services: import("~/src/server/plugins/engine/types.js").PluginOptions["services"]; }; /** * Handles logging and issuing a permanent redirect for legacy routes. * @param h - The Hapi response toolkit. * @param targetUrl - The URL to redirect to. * @returns The Hapi response object configured for permanent redirect. */ export declare function handleLegacyRedirect(h: ResponseToolkit, targetUrl: string): import("@hapi/hapi").ResponseObject; /** * If the page doesn't have a title, set it from the title of the first form component * @param def - the form definition */ export interface FormVersionMetadata { versionNumber: number; createdAt: Date; } /** * Extracts form version metadata from a form definition */ export declare function getFormVersion(definition: Pick): FormVersionMetadata | undefined; export declare function setPageTitles(def: FormDefinition): void;