import {TypedRecord, makeTypedFactory} from "typed-immutable-record"; import { FormDefinition, FormMetadata, Section, SectionMetadata, FormInput, DropdownOption } from './form.server.models' export interface FormDefinitionRecord extends TypedRecord, FormDefinition {} export interface FormMetadataRecord extends TypedRecord, FormMetadata {} export interface SectionRecord extends TypedRecord, Section {} export interface SectionMetadataRecord extends TypedRecord, SectionMetadata {} export interface FormInputRecord extends TypedRecord, FormInput {} export interface DropdownOptionRecord extends TypedRecord, DropdownOption {} export class ServerFactoryImpl { formMetadataRecord = makeTypedFactory({ formId: null, instanceId: null, title: null }); formDefinitionRecord = makeTypedFactory({ meta: this.formMetadataRecord(), sections: [] }); sectionMetadataRecord = makeTypedFactory({ title: null, sectionId: null, layout: 'simple' }); sectionRecord = makeTypedFactory({ meta: this.sectionMetadataRecord(), layout: [] }); formInputRecord = makeTypedFactory({ Name: 'unknown', Type: 'unknown', Label: '', Required: false, Options: null }); dropdownOptionRecord = makeTypedFactory({ Label: '', Value: '' }); } export const ServerFactory = new ServerFactoryImpl();