import { SchemaVersion, type ComponentDef, type ConditionWrapper, type ConditionWrapperV2, type ConditionsModelData, type Engine, type FormDefinition, type List, type Page, type Section } from '@defra/forms-model'; import { Parser, type Value } from 'expr-eval-fork'; import joi from 'joi'; import { type Component } from '~/src/server/plugins/engine/components/helpers/components.js'; import { type ExecutableCondition } from '~/src/server/plugins/engine/models/types.js'; import { type PageController } from '~/src/server/plugins/engine/pageControllers/PageController.js'; import { type PageControllerClass } from '~/src/server/plugins/engine/pageControllers/helpers/pages.js'; import { type FormContext, type FormContextRequest, type FormState, type FormSubmissionError, type FormSubmissionState } from '~/src/server/plugins/engine/types.js'; import { type Services } from '~/src/server/types.js'; export declare class FormModel { /** The runtime engine that should be used */ engine?: Engine; schemaVersion: SchemaVersion; /** the entire form JSON as an object */ def: FormDefinition; lists: FormDefinition['lists']; sections: FormDefinition['sections']; name: string; formId: string; values: FormDefinition; basePath: string; ordnanceSurveyApiKey?: string; conditions: Partial>; pages: PageControllerClass[]; services: Services; controllers?: Record; pageDefMap: Map; listDefMap: Map; listDefIdMap: Map; componentDefMap: Map; componentDefIdMap: Map; pageMap: Map; componentMap: Map; constructor(def: typeof this.def, options: { basePath: string; ordnanceSurveyApiKey?: string; formId?: string; }, services?: Services, controllers?: Record); /** * build the entire model schema from individual pages/sections and filter out answers * for pages which are no longer accessible due to an answer that has been changed */ makeFilteredSchema(relevantPages: PageControllerClass[]): joi.ObjectSchema; /** * Instantiates a Condition based on {@link ConditionWrapper} * @param condition */ makeCondition(condition: ConditionWrapper): ExecutableCondition; toConditionContext(evaluationState: FormState, conditions: Partial>): Extract>; toConditionExpression(value: ConditionsModelData, parser: Parser): import("expr-eval-fork").Expression; getList(nameOrId: string): List | undefined; getSection(nameOrId: string): Section | undefined; /** * Form context for the current page */ getFormContext(request: FormContextRequest, state: FormSubmissionState, errors?: FormSubmissionError[]): FormContext; private initialiseContext; private assignEvaluationState; private assignRelevantState; private pageStateIsInvalid; private fieldStateIsInvalid; private assignPaths; getComponentById(componentId: string): ComponentDef | undefined; getListById(listId: string): List | undefined; /** * Returns a condition by its ID. O(n) lookup time. * @param conditionId * @returns */ getConditionById(conditionId: string): ConditionWrapperV2 | undefined; }