@defra/forms-model 3.0.463 → 3.0.464

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,168 @@
1
+ import { ComponentType } from "../components/enums.js";
2
+ /**
3
+ * @param {Partial<TextFieldComponent>} partialTextField
4
+ * @returns {TextFieldComponent}
5
+ */
6
+ export function buildTextFieldComponent(partialTextField = {}) {
7
+ const textFieldComponent = {
8
+ id: '407dd0d7-cce9-4f43-8e1f-7d89cb698875',
9
+ name: 'TextField',
10
+ title: 'Text field',
11
+ type: ComponentType.TextField,
12
+ hint: '',
13
+ options: {},
14
+ schema: {}
15
+ };
16
+ return {
17
+ ...textFieldComponent,
18
+ ...partialTextField
19
+ };
20
+ }
21
+
22
+ /**
23
+ * @param {Partial<FileUploadFieldComponent>} partialFileUploadField
24
+ * @returns {FileUploadFieldComponent}
25
+ */
26
+ export function buildFileUploadComponent(partialFileUploadField) {
27
+ const fileUploadFieldComponent = {
28
+ name: 'FileUploadField',
29
+ type: ComponentType.FileUploadField,
30
+ title: 'File Upload Field',
31
+ options: {},
32
+ schema: {}
33
+ };
34
+ return {
35
+ ...fileUploadFieldComponent,
36
+ ...partialFileUploadField
37
+ };
38
+ }
39
+
40
+ /**
41
+ *
42
+ * @param {Partial<AutocompleteFieldComponent>} partialAutoCompleteField
43
+ * @returns {AutocompleteFieldComponent}
44
+ */
45
+ export function buildAutoCompleteComponent(partialAutoCompleteField) {
46
+ const autocompleteComponent = {
47
+ name: 'AutoCompleteField',
48
+ title: 'What languages do you speak?',
49
+ type: ComponentType.AutocompleteField,
50
+ list: 'AutoCompleteList',
51
+ options: {}
52
+ };
53
+ return {
54
+ ...autocompleteComponent,
55
+ ...partialAutoCompleteField
56
+ };
57
+ }
58
+
59
+ /**
60
+ * @param {Partial<RadiosFieldComponent>} partialListComponent
61
+ * @returns {RadiosFieldComponent}
62
+ */
63
+ export function buildRadioComponent(partialListComponent = {}) {
64
+ const radioFieldComponent = {
65
+ name: 'RadioField',
66
+ title: 'Which country do you live in?',
67
+ type: ComponentType.RadiosField,
68
+ list: 'RadioList',
69
+ options: {}
70
+ };
71
+ return {
72
+ ...radioFieldComponent,
73
+ ...partialListComponent
74
+ };
75
+ }
76
+
77
+ /**
78
+ * @param {Partial<CheckboxesFieldComponent>} partialListComponent
79
+ * @returns {CheckboxesFieldComponent}
80
+ */
81
+ export function buildCheckboxComponent(partialListComponent) {
82
+ const checkboxesFieldComponent = {
83
+ name: 'FellowshipOfTheRing',
84
+ title: 'Which are your favourite characters from the fellowship?',
85
+ type: ComponentType.CheckboxesField,
86
+ list: 'CheckboxList',
87
+ options: {}
88
+ };
89
+ return {
90
+ ...checkboxesFieldComponent,
91
+ ...partialListComponent
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Builder to create a stub List item
97
+ * @param {Partial<Item>} partialListItem
98
+ * @returns {Item}
99
+ */
100
+ export function buildListItem(partialListItem = {}) {
101
+ return {
102
+ text: 'Javascript',
103
+ value: 'javascript',
104
+ ...partialListItem
105
+ };
106
+ }
107
+
108
+ /**
109
+ * @param {Partial<List>} partialList
110
+ * @returns {List}
111
+ */
112
+ export function buildList(partialList = {}) {
113
+ return {
114
+ title: 'Development language2',
115
+ name: 'YhmNDD',
116
+ type: 'string',
117
+ items: [buildListItem({
118
+ text: 'Javascript',
119
+ value: 'javascript'
120
+ }), buildListItem({
121
+ text: 'TypeScript',
122
+ value: 'typescript'
123
+ }), buildListItem({
124
+ text: 'Python',
125
+ value: 'python'
126
+ }), buildListItem({
127
+ text: 'Haskell',
128
+ value: 'haskell'
129
+ }), buildListItem({
130
+ text: 'Erlang',
131
+ value: 'erlang'
132
+ }), buildListItem({
133
+ text: 'Java',
134
+ value: 'java'
135
+ })],
136
+ ...partialList
137
+ };
138
+ }
139
+ export function buildNumberFieldComponent(partialComponent) {
140
+ return {
141
+ name: 'year',
142
+ title: 'Year',
143
+ options: {},
144
+ schema: {},
145
+ ...partialComponent,
146
+ type: ComponentType.NumberField
147
+ };
148
+ }
149
+ export function buildDateComponent(partialComponent) {
150
+ return {
151
+ name: 'bcdefg',
152
+ title: 'Default title',
153
+ options: {},
154
+ ...partialComponent,
155
+ type: ComponentType.DatePartsField
156
+ };
157
+ }
158
+ export function buildRadiosComponent(partialComponent) {
159
+ return {
160
+ name: 'cdefgh',
161
+ title: 'Default title',
162
+ options: {},
163
+ list: 'Default list Id ref',
164
+ ...partialComponent,
165
+ type: ComponentType.RadiosField
166
+ };
167
+ }
168
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","names":["ComponentType","buildTextFieldComponent","partialTextField","textFieldComponent","id","name","title","type","TextField","hint","options","schema","buildFileUploadComponent","partialFileUploadField","fileUploadFieldComponent","FileUploadField","buildAutoCompleteComponent","partialAutoCompleteField","autocompleteComponent","AutocompleteField","list","buildRadioComponent","partialListComponent","radioFieldComponent","RadiosField","buildCheckboxComponent","checkboxesFieldComponent","CheckboxesField","buildListItem","partialListItem","text","value","buildList","partialList","items","buildNumberFieldComponent","partialComponent","NumberField","buildDateComponent","DatePartsField","buildRadiosComponent"],"sources":["../../../src/__stubs__/components.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n type AutocompleteFieldComponent,\n type CheckboxesFieldComponent,\n type DatePartsFieldComponent,\n type FileUploadFieldComponent,\n type NumberFieldComponent,\n type RadiosFieldComponent,\n type TextFieldComponent\n} from '~/src/components/types.js'\nimport { type Item, type List } from '~/src/form/form-definition/types.js'\n\n/**\n * @param {Partial<TextFieldComponent>} partialTextField\n * @returns {TextFieldComponent}\n */\nexport function buildTextFieldComponent(\n partialTextField: Partial<TextFieldComponent> = {}\n): TextFieldComponent {\n const textFieldComponent: TextFieldComponent = {\n id: '407dd0d7-cce9-4f43-8e1f-7d89cb698875',\n name: 'TextField',\n title: 'Text field',\n type: ComponentType.TextField,\n hint: '',\n options: {},\n schema: {}\n }\n\n return {\n ...textFieldComponent,\n ...partialTextField\n }\n}\n\n/**\n * @param {Partial<FileUploadFieldComponent>} partialFileUploadField\n * @returns {FileUploadFieldComponent}\n */\nexport function buildFileUploadComponent(\n partialFileUploadField: Partial<FileUploadFieldComponent>\n): FileUploadFieldComponent {\n const fileUploadFieldComponent: FileUploadFieldComponent = {\n name: 'FileUploadField',\n type: ComponentType.FileUploadField,\n title: 'File Upload Field',\n options: {},\n schema: {}\n }\n\n return {\n ...fileUploadFieldComponent,\n ...partialFileUploadField\n }\n}\n\n/**\n *\n * @param {Partial<AutocompleteFieldComponent>} partialAutoCompleteField\n * @returns {AutocompleteFieldComponent}\n */\nexport function buildAutoCompleteComponent(\n partialAutoCompleteField: Partial<AutocompleteFieldComponent>\n): AutocompleteFieldComponent {\n const autocompleteComponent: AutocompleteFieldComponent = {\n name: 'AutoCompleteField',\n title: 'What languages do you speak?',\n type: ComponentType.AutocompleteField,\n list: 'AutoCompleteList',\n options: {}\n }\n\n return {\n ...autocompleteComponent,\n ...partialAutoCompleteField\n }\n}\n\n/**\n * @param {Partial<RadiosFieldComponent>} partialListComponent\n * @returns {RadiosFieldComponent}\n */\nexport function buildRadioComponent(\n partialListComponent: Partial<RadiosFieldComponent> = {}\n): RadiosFieldComponent {\n const radioFieldComponent: RadiosFieldComponent = {\n name: 'RadioField',\n title: 'Which country do you live in?',\n type: ComponentType.RadiosField,\n list: 'RadioList',\n options: {}\n }\n\n return {\n ...radioFieldComponent,\n ...partialListComponent\n }\n}\n\n/**\n * @param {Partial<CheckboxesFieldComponent>} partialListComponent\n * @returns {CheckboxesFieldComponent}\n */\nexport function buildCheckboxComponent(\n partialListComponent: Partial<CheckboxesFieldComponent>\n): CheckboxesFieldComponent {\n const checkboxesFieldComponent: CheckboxesFieldComponent = {\n name: 'FellowshipOfTheRing',\n title: 'Which are your favourite characters from the fellowship?',\n type: ComponentType.CheckboxesField,\n list: 'CheckboxList',\n options: {}\n }\n\n return {\n ...checkboxesFieldComponent,\n ...partialListComponent\n }\n}\n\n/**\n * Builder to create a stub List item\n * @param {Partial<Item>} partialListItem\n * @returns {Item}\n */\nexport function buildListItem(partialListItem: Partial<Item> = {}): Item {\n return {\n text: 'Javascript',\n value: 'javascript',\n ...partialListItem\n }\n}\n\n/**\n * @param {Partial<List>} partialList\n * @returns {List}\n */\nexport function buildList(partialList: Partial<List> = {}): List {\n return {\n title: 'Development language2',\n name: 'YhmNDD',\n type: 'string',\n items: [\n buildListItem({\n text: 'Javascript',\n value: 'javascript'\n }),\n buildListItem({\n text: 'TypeScript',\n value: 'typescript'\n }),\n buildListItem({\n text: 'Python',\n value: 'python'\n }),\n buildListItem({\n text: 'Haskell',\n value: 'haskell'\n }),\n buildListItem({\n text: 'Erlang',\n value: 'erlang'\n }),\n buildListItem({\n text: 'Java',\n value: 'java'\n })\n ],\n ...partialList\n }\n}\n\nexport function buildNumberFieldComponent(\n partialComponent: Partial<NumberFieldComponent>\n): NumberFieldComponent {\n return {\n name: 'year',\n title: 'Year',\n options: {},\n schema: {},\n ...partialComponent,\n type: ComponentType.NumberField\n }\n}\n\nexport function buildDateComponent(\n partialComponent: Partial<DatePartsFieldComponent>\n): DatePartsFieldComponent {\n return {\n name: 'bcdefg',\n title: 'Default title',\n options: {},\n ...partialComponent,\n type: ComponentType.DatePartsField\n }\n}\n\nexport function buildRadiosComponent(\n partialComponent: Partial<RadiosFieldComponent>\n): RadiosFieldComponent {\n return {\n name: 'cdefgh',\n title: 'Default title',\n options: {},\n list: 'Default list Id ref',\n ...partialComponent,\n type: ComponentType.RadiosField\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa;AAYtB;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CACrCC,gBAA6C,GAAG,CAAC,CAAC,EAC9B;EACpB,MAAMC,kBAAsC,GAAG;IAC7CC,EAAE,EAAE,sCAAsC;IAC1CC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAE,YAAY;IACnBC,IAAI,EAAEP,aAAa,CAACQ,SAAS;IAC7BC,IAAI,EAA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MAAM,EAAE,CAAC,CAAC;IACV,GAAGyB,gBAAgB;IACnB7B,IAAI,EAAEP,aAAa,CAACqC;EACtB,CAAC;AACH;AAEA,OAAO,SAASC,kBAAkBA,CAChCF,gBAAkD,EACzB;EACzB,OAAO;IACL/B,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE,eAAe;IACtBI,OAAO,EAAE,CAAC,CAAC;IACX,GAAG0B,gBAAgB;IACnB7B,IAAI,EAAEP,aAAa,CAACuC;EACtB,CAAC;AACH;AAEA,OAAO,SAASC,oBAAoBA,CAClCJ,gBAA+C,EACzB;EACtB,OAAO;IACL/B,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE,eAAe;IACtBI,OAAO,EAAE,CAAC,CAAC;IACXU,IAAI,EAAE,qBAAqB;IAC3B,GAAGgB,gBAAgB;IACnB7B,IAAI,EAAEP,aAAa,CAACwB;EACtB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Builder to create a Form Definition
3
+ * @param {Partial<FormDefinition>} definitionPartial
4
+ * @returns {FormDefinition}
5
+ */
6
+ export function buildDefinition(definitionPartial = {}) {
7
+ const formDefinition = {
8
+ name: 'Test form',
9
+ pages: [],
10
+ conditions: [],
11
+ sections: [],
12
+ lists: []
13
+ };
14
+ return {
15
+ ...formDefinition,
16
+ ...definitionPartial
17
+ };
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @param {Partial<FormMetadata>} partialMetaData
23
+ * @returns {FormMetadata}
24
+ */
25
+ export function buildMetaData(partialMetaData = {}) {
26
+ return {
27
+ id: '681b184463c68bf6b99e2c62',
28
+ slug: 'chemistry',
29
+ title: 'Chemistry',
30
+ organisation: 'Defra',
31
+ teamName: 'Forms Team',
32
+ teamEmail: 'name@example.gov.uk',
33
+ draft: {
34
+ createdAt: new Date('2025-05-07T08:22:28.035Z'),
35
+ createdBy: {
36
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
37
+ displayName: 'Internal User'
38
+ },
39
+ updatedAt: new Date('2025-05-20T13:00:54.794Z'),
40
+ updatedBy: {
41
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
42
+ displayName: 'Internal User'
43
+ }
44
+ },
45
+ createdBy: {
46
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
47
+ displayName: 'Internal User'
48
+ },
49
+ createdAt: new Date('2025-05-07T08:22:28.035Z'),
50
+ updatedBy: {
51
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
52
+ displayName: 'Internal User'
53
+ },
54
+ updatedAt: new Date('2025-05-20T13:00:54.794Z'),
55
+ ...partialMetaData
56
+ };
57
+ }
58
+ //# sourceMappingURL=form-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-definition.js","names":["buildDefinition","definitionPartial","formDefinition","name","pages","conditions","sections","lists","buildMetaData","partialMetaData","id","slug","title","organisation","teamName","teamEmail","draft","createdAt","Date","createdBy","displayName","updatedAt","updatedBy"],"sources":["../../../src/__stubs__/form-definition.ts"],"sourcesContent":["import { type FormDefinition } from '~/src/form/form-definition/types.js'\nimport { type FormMetadata } from '~/src/form/form-metadata/types.js'\n\n/**\n * Builder to create a Form Definition\n * @param {Partial<FormDefinition>} definitionPartial\n * @returns {FormDefinition}\n */\nexport function buildDefinition(\n definitionPartial: Partial<FormDefinition> = {}\n): FormDefinition {\n const formDefinition: FormDefinition = {\n name: 'Test form',\n pages: [],\n conditions: [],\n sections: [],\n lists: []\n }\n return {\n ...formDefinition,\n ...definitionPartial\n }\n}\n\n/**\n *\n * @param {Partial<FormMetadata>} partialMetaData\n * @returns {FormMetadata}\n */\nexport function buildMetaData(\n partialMetaData: Partial<FormMetadata> = {}\n): FormMetadata {\n return {\n id: '681b184463c68bf6b99e2c62',\n slug: 'chemistry',\n title: 'Chemistry',\n organisation: 'Defra',\n teamName: 'Forms Team',\n teamEmail: 'name@example.gov.uk',\n draft: {\n createdAt: new Date('2025-05-07T08:22:28.035Z'),\n createdBy: {\n id: '84305e4e-1f52-43d0-a123-9c873b0abb35',\n displayName: 'Internal User'\n },\n updatedAt: new Date('2025-05-20T13:00:54.794Z'),\n updatedBy: {\n id: '84305e4e-1f52-43d0-a123-9c873b0abb35',\n displayName: 'Internal User'\n }\n },\n createdBy: {\n id: '84305e4e-1f52-43d0-a123-9c873b0abb35',\n displayName: 'Internal User'\n },\n createdAt: new Date('2025-05-07T08:22:28.035Z'),\n updatedBy: {\n id: '84305e4e-1f52-43d0-a123-9c873b0abb35',\n displayName: 'Internal User'\n },\n updatedAt: new Date('2025-05-20T13:00:54.794Z'),\n ...partialMetaData\n }\n}\n"],"mappings":"AAGA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAC7BC,iBAA0C,GAAG,CAAC,CAAC,EAC/B;EAChB,MAAMC,cAA8B,GAAG;IACrCC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAE,EAAE;IACTC,UAAU,EAAE,EAAE;IACdC,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAE;EACT,CAAC;EACD,OAAO;IACL,GAAGL,cAAc;IACjB,GAAGD;EACL,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,aAAaA,CAC3BC,eAAsC,GAAG,CAAC,CAAC,EAC7B;EACd,OAAO;IACLC,EAAE,EAAE,0BAA0B;IAC9BC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAE,WAAW;IAClBC,YAAY,EAAE,OAAO;IACrBC,QAAQ,EAAE,YAAY;IACtBC,SAAS,EAAE,qBAAqB;IAChCC,KAAK,EAAE;MACLC,SAAS,EAAE,IAAIC,IAAI,CAAC,0BAA0B,CAAC;MAC/CC,SAAS,EAAE;QACTT,EAAE,EAAE,sCAAsC;QAC1CU,WAAW,EAAE;MACf,CAAC;MACDC,SAAS,EAAE,IAAIH,IAAI,CAAC,0BAA0B,CAAC;MAC/CI,SAAS,EAAE;QACTZ,EAAE,EAAE,sCAAsC;QAC1CU,WAAW,EAAE;MACf;IACF,CAAC;IACDD,SAAS,EAAE;MACTT,EAAE,EAAE,sCAAsC;MAC1CU,WAAW,EAAE;IACf,CAAC;IACDH,SAAS,EAAE,IAAIC,IAAI,CAAC,0BAA0B,CAAC;IAC/CI,SAAS,EAAE;MACTZ,EAAE,EAAE,sCAAsC;MAC1CU,WAAW,EAAE;IACf,CAAC;IACDC,SAAS,EAAE,IAAIH,IAAI,CAAC,0BAA0B,CAAC;IAC/C,GAAGT;EACL,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,107 @@
1
+ import { buildFileUploadComponent } from "./components.js";
2
+ import { ComponentType } from "../components/enums.js";
3
+ import { ControllerPath, ControllerType } from "../pages/enums.js";
4
+
5
+ /**
6
+ * Stub builder for a question page
7
+ * @param {Partial<PageQuestion>} [partialPage]
8
+ * @returns {PageQuestion}
9
+ */
10
+ export function buildQuestionPage(partialPage) {
11
+ return {
12
+ id: 'ffefd409-f3f4-49fe-882e-6e89f44631b1',
13
+ title: 'Page One',
14
+ path: '/page-one',
15
+ next: [],
16
+ components: [],
17
+ ...partialPage
18
+ };
19
+ }
20
+
21
+ /**
22
+ * Stub builder for a Summary page
23
+ * @param {Partial<PageSummary>} [partialSummaryPage]
24
+ */
25
+ export function buildSummaryPage(partialSummaryPage = {}) {
26
+ const pageSummary = {
27
+ id: '449a45f6-4541-4a46-91bd-8b8931b07b50',
28
+ title: 'Summary page',
29
+ path: ControllerPath.Summary,
30
+ controller: ControllerType.Summary
31
+ };
32
+ return {
33
+ ...pageSummary,
34
+ ...partialSummaryPage
35
+ };
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @param {Partial<PageFileUpload>} partialFileUploadPage
41
+ * @returns {PageFileUpload}
42
+ */
43
+ export function buildFileUploadPage(partialFileUploadPage = {}) {
44
+ const fileUploadPage = {
45
+ id: '85e5c8da-88f5-4009-a821-7d7de1364318',
46
+ title: '',
47
+ path: '/supporting-evidence',
48
+ components: [buildFileUploadComponent({
49
+ type: ComponentType.FileUploadField,
50
+ title: 'Supporting Evidence',
51
+ name: 'yBpZQO',
52
+ shortDescription: 'Supporting evidence',
53
+ hint: '',
54
+ options: {
55
+ required: true,
56
+ accept: 'application/pdf,application/msword,image/jpeg,application/vnd.ms-excel,text/csv'
57
+ },
58
+ id: '4189b8a1-1a04-4f74-a7a0-dd23012a0ee0'
59
+ })],
60
+ controller: ControllerType.FileUpload,
61
+ next: []
62
+ };
63
+ return {
64
+ ...fileUploadPage,
65
+ ...partialFileUploadPage
66
+ };
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @param {Partial<PageRepeat>} partialRepeaterPage
72
+ * @returns {PageRepeat}
73
+ */
74
+ export function buildRepeaterPage(partialRepeaterPage = {}) {
75
+ const repeaterPage = {
76
+ title: 'Repeater Page',
77
+ path: '/repeater-page',
78
+ components: [{
79
+ type: ComponentType.TextField,
80
+ title: 'Simple text field',
81
+ name: 'IHAIzC',
82
+ shortDescription: 'Your simple text field',
83
+ hint: '',
84
+ options: {},
85
+ schema: {},
86
+ id: 'ee83413e-31b6-4158-98e0-4611479582ce'
87
+ }],
88
+ next: [],
89
+ id: '32888028-61db-40fc-b255-80bc67829d31',
90
+ controller: ControllerType.Repeat,
91
+ repeat: {
92
+ options: {
93
+ name: 'fawfed',
94
+ title: 'Simple question responses'
95
+ },
96
+ schema: {
97
+ min: 1,
98
+ max: 3
99
+ }
100
+ }
101
+ };
102
+ return {
103
+ ...repeaterPage,
104
+ ...partialRepeaterPage
105
+ };
106
+ }
107
+ //# sourceMappingURL=pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.js","names":["buildFileUploadComponent","ComponentType","ControllerPath","ControllerType","buildQuestionPage","partialPage","id","title","path","next","components","buildSummaryPage","partialSummaryPage","pageSummary","Summary","controller","buildFileUploadPage","partialFileUploadPage","fileUploadPage","type","FileUploadField","name","shortDescription","hint","options","required","accept","FileUpload","buildRepeaterPage","partialRepeaterPage","repeaterPage","TextField","schema","Repeat","repeat","min","max"],"sources":["../../../src/__stubs__/pages.ts"],"sourcesContent":["import { buildFileUploadComponent } from '~/src/__stubs__/components.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type PageFileUpload,\n type PageQuestion,\n type PageRepeat,\n type PageSummary\n} from '~/src/form/form-definition/types.js'\nimport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n\n/**\n * Stub builder for a question page\n * @param {Partial<PageQuestion>} [partialPage]\n * @returns {PageQuestion}\n */\nexport function buildQuestionPage(\n partialPage: Partial<PageQuestion>\n): PageQuestion {\n return {\n id: 'ffefd409-f3f4-49fe-882e-6e89f44631b1',\n title: 'Page One',\n path: '/page-one',\n next: [],\n components: [],\n ...partialPage\n }\n}\n\n/**\n * Stub builder for a Summary page\n * @param {Partial<PageSummary>} [partialSummaryPage]\n */\nexport function buildSummaryPage(\n partialSummaryPage: Partial<PageSummary> = {}\n): PageSummary {\n const pageSummary: PageSummary = {\n id: '449a45f6-4541-4a46-91bd-8b8931b07b50',\n title: 'Summary page',\n path: ControllerPath.Summary,\n controller: ControllerType.Summary\n }\n return { ...pageSummary, ...partialSummaryPage }\n}\n\n/**\n *\n * @param {Partial<PageFileUpload>} partialFileUploadPage\n * @returns {PageFileUpload}\n */\nexport function buildFileUploadPage(\n partialFileUploadPage: Partial<PageFileUpload> = {}\n): PageFileUpload {\n const fileUploadPage: PageFileUpload = {\n id: '85e5c8da-88f5-4009-a821-7d7de1364318',\n title: '',\n path: '/supporting-evidence',\n components: [\n buildFileUploadComponent({\n type: ComponentType.FileUploadField,\n title: 'Supporting Evidence',\n name: 'yBpZQO',\n shortDescription: 'Supporting evidence',\n hint: '',\n options: {\n required: true,\n accept:\n 'application/pdf,application/msword,image/jpeg,application/vnd.ms-excel,text/csv'\n },\n id: '4189b8a1-1a04-4f74-a7a0-dd23012a0ee0'\n })\n ],\n controller: ControllerType.FileUpload,\n next: []\n }\n\n return {\n ...fileUploadPage,\n ...partialFileUploadPage\n }\n}\n\n/**\n *\n * @param {Partial<PageRepeat>} partialRepeaterPage\n * @returns {PageRepeat}\n */\nexport function buildRepeaterPage(\n partialRepeaterPage: Partial<PageRepeat> = {}\n): PageRepeat {\n const repeaterPage: PageRepeat = {\n title: 'Repeater Page',\n path: '/repeater-page',\n components: [\n {\n type: ComponentType.TextField,\n title: 'Simple text field',\n name: 'IHAIzC',\n shortDescription: 'Your simple text field',\n hint: '',\n options: {},\n schema: {},\n id: 'ee83413e-31b6-4158-98e0-4611479582ce'\n }\n ],\n next: [],\n id: '32888028-61db-40fc-b255-80bc67829d31',\n controller: ControllerType.Repeat,\n repeat: {\n options: { name: 'fawfed', title: 'Simple question responses' },\n schema: { min: 1, max: 3 }\n }\n }\n\n return {\n ...repeaterPage,\n ...partialRepeaterPage\n }\n}\n"],"mappings":"AAAA,SAASA,wBAAwB;AACjC,SAASC,aAAa;AAOtB,SAASC,cAAc,EAAEC,cAAc;;AAEvC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,WAAkC,EACpB;EACd,OAAO;IACLC,EAAE,EAAE,sCAAsC;IAC1CC,KAAK,EAAE,UAAU;IACjBC,IAAI,EAAE,WAAW;IACjBC,IAAI,EAAE,EAAE;IACRC,UAAU,EAAE,EAAE;IACd,GAAGL;EACL,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASM,gBAAgBA,CAC9BC,kBAAwC,GAAG,CAAC,CAAC,EAChC;EACb,MAAMC,WAAwB,GAAG;IAC/BP,EAAE,EAAE,sCAAsC;IAC1CC,KAAK,EAAE,cAAc;IACrBC,IAAI,EAAEN,cAAc,CAACY,OAAO;IAC5BC,UAAU,EAAEZ,cAAc,CAACW;EAC7B,CAAC;EACD,OAAO;IAAE,GAAGD,WAAW;IAAE,GAAGD;EAAmB,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,mBAAmBA,CACjCC,qBAA8C,GAAG,CAAC,CAAC,EACnC;EAChB,MAAMC,cAA8B,GAAG;IACrCZ,EAAE,EAAE,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AO;IACL,GAAGN,YAAY;IACf,GAAGD;EACL,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ export * from "./__stubs__/form-definition.js";
2
+ export { buildList } from "./__stubs__/components.js";
3
+ export { buildListItem } from "./__stubs__/components.js";
4
+ export { buildCheckboxComponent } from "./__stubs__/components.js";
5
+ export { buildRadioComponent } from "./__stubs__/components.js";
6
+ export { buildAutoCompleteComponent } from "./__stubs__/components.js";
7
+ export { buildFileUploadComponent } from "./__stubs__/components.js";
8
+ export { buildTextFieldComponent } from "./__stubs__/components.js";
9
+ export { buildRepeaterPage } from "./__stubs__/pages.js";
10
+ export { buildFileUploadPage } from "./__stubs__/pages.js";
11
+ export { buildSummaryPage } from "./__stubs__/pages.js";
12
+ export { buildQuestionPage } from "./__stubs__/pages.js";
13
+ //# sourceMappingURL=stubs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.js","names":["buildList","buildListItem","buildCheckboxComponent","buildRadioComponent","buildAutoCompleteComponent","buildFileUploadComponent","buildTextFieldComponent","buildRepeaterPage","buildFileUploadPage","buildSummaryPage","buildQuestionPage"],"sources":["../../src/stubs.ts"],"sourcesContent":["export * from '~/src/__stubs__/form-definition.js'\nexport { buildList } from '~/src/__stubs__/components.js'\nexport { buildListItem } from '~/src/__stubs__/components.js'\nexport { buildCheckboxComponent } from '~/src/__stubs__/components.js'\nexport { buildRadioComponent } from '~/src/__stubs__/components.js'\nexport { buildAutoCompleteComponent } from '~/src/__stubs__/components.js'\nexport { buildFileUploadComponent } from '~/src/__stubs__/components.js'\nexport { buildTextFieldComponent } from '~/src/__stubs__/components.js'\nexport { buildRepeaterPage } from '~/src/__stubs__/pages.js'\nexport { buildFileUploadPage } from '~/src/__stubs__/pages.js'\nexport { buildSummaryPage } from '~/src/__stubs__/pages.js'\nexport { buildQuestionPage } from '~/src/__stubs__/pages.js'\n"],"mappings":"AAAA;AACA,SAASA,SAAS;AAClB,SAASC,aAAa;AACtB,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;AAC5B,SAASC,0BAA0B;AACnC,SAASC,wBAAwB;AACjC,SAASC,uBAAuB;AAChC,SAASC,iBAAiB;AAC1B,SAASC,mBAAmB;AAC5B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ import { type AutocompleteFieldComponent, type CheckboxesFieldComponent, type DatePartsFieldComponent, type FileUploadFieldComponent, type NumberFieldComponent, type RadiosFieldComponent, type TextFieldComponent } from '../components/types.js';
2
+ import { type Item, type List } from '../form/form-definition/types.js';
3
+ /**
4
+ * @param {Partial<TextFieldComponent>} partialTextField
5
+ * @returns {TextFieldComponent}
6
+ */
7
+ export declare function buildTextFieldComponent(partialTextField?: Partial<TextFieldComponent>): TextFieldComponent;
8
+ /**
9
+ * @param {Partial<FileUploadFieldComponent>} partialFileUploadField
10
+ * @returns {FileUploadFieldComponent}
11
+ */
12
+ export declare function buildFileUploadComponent(partialFileUploadField: Partial<FileUploadFieldComponent>): FileUploadFieldComponent;
13
+ /**
14
+ *
15
+ * @param {Partial<AutocompleteFieldComponent>} partialAutoCompleteField
16
+ * @returns {AutocompleteFieldComponent}
17
+ */
18
+ export declare function buildAutoCompleteComponent(partialAutoCompleteField: Partial<AutocompleteFieldComponent>): AutocompleteFieldComponent;
19
+ /**
20
+ * @param {Partial<RadiosFieldComponent>} partialListComponent
21
+ * @returns {RadiosFieldComponent}
22
+ */
23
+ export declare function buildRadioComponent(partialListComponent?: Partial<RadiosFieldComponent>): RadiosFieldComponent;
24
+ /**
25
+ * @param {Partial<CheckboxesFieldComponent>} partialListComponent
26
+ * @returns {CheckboxesFieldComponent}
27
+ */
28
+ export declare function buildCheckboxComponent(partialListComponent: Partial<CheckboxesFieldComponent>): CheckboxesFieldComponent;
29
+ /**
30
+ * Builder to create a stub List item
31
+ * @param {Partial<Item>} partialListItem
32
+ * @returns {Item}
33
+ */
34
+ export declare function buildListItem(partialListItem?: Partial<Item>): Item;
35
+ /**
36
+ * @param {Partial<List>} partialList
37
+ * @returns {List}
38
+ */
39
+ export declare function buildList(partialList?: Partial<List>): List;
40
+ export declare function buildNumberFieldComponent(partialComponent: Partial<NumberFieldComponent>): NumberFieldComponent;
41
+ export declare function buildDateComponent(partialComponent: Partial<DatePartsFieldComponent>): DatePartsFieldComponent;
42
+ export declare function buildRadiosComponent(partialComponent: Partial<RadiosFieldComponent>): RadiosFieldComponent;
43
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/__stubs__/components.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,qCAAqC,CAAA;AAE1E;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,gBAAgB,GAAE,OAAO,CAAC,kBAAkB,CAAM,GACjD,kBAAkB,CAepB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,sBAAsB,EAAE,OAAO,CAAC,wBAAwB,CAAC,GACxD,wBAAwB,CAa1B;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,wBAAwB,EAAE,OAAO,CAAC,0BAA0B,CAAC,GAC5D,0BAA0B,CAa5B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,oBAAoB,GAAE,OAAO,CAAC,oBAAoB,CAAM,GACvD,oBAAoB,CAatB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,oBAAoB,EAAE,OAAO,CAAC,wBAAwB,CAAC,GACtD,wBAAwB,CAa1B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,eAAe,GAAE,OAAO,CAAC,IAAI,CAAM,GAAG,IAAI,CAMvE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,WAAW,GAAE,OAAO,CAAC,IAAI,CAAM,GAAG,IAAI,CAiC/D;AAED,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAC9C,oBAAoB,CAStB;AAED,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACjD,uBAAuB,CAQzB;AAED,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAC9C,oBAAoB,CAStB"}
@@ -0,0 +1,15 @@
1
+ import { type FormDefinition } from '../form/form-definition/types.js';
2
+ import { type FormMetadata } from '../form/form-metadata/types.js';
3
+ /**
4
+ * Builder to create a Form Definition
5
+ * @param {Partial<FormDefinition>} definitionPartial
6
+ * @returns {FormDefinition}
7
+ */
8
+ export declare function buildDefinition(definitionPartial?: Partial<FormDefinition>): FormDefinition;
9
+ /**
10
+ *
11
+ * @param {Partial<FormMetadata>} partialMetaData
12
+ * @returns {FormMetadata}
13
+ */
14
+ export declare function buildMetaData(partialMetaData?: Partial<FormMetadata>): FormMetadata;
15
+ //# sourceMappingURL=form-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-definition.d.ts","sourceRoot":"","sources":["../../../src/__stubs__/form-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAErE;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,iBAAiB,GAAE,OAAO,CAAC,cAAc,CAAM,GAC9C,cAAc,CAYhB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,eAAe,GAAE,OAAO,CAAC,YAAY,CAAM,GAC1C,YAAY,CAgCd"}
@@ -0,0 +1,25 @@
1
+ import { type PageFileUpload, type PageQuestion, type PageRepeat, type PageSummary } from '../form/form-definition/types.js';
2
+ /**
3
+ * Stub builder for a question page
4
+ * @param {Partial<PageQuestion>} [partialPage]
5
+ * @returns {PageQuestion}
6
+ */
7
+ export declare function buildQuestionPage(partialPage: Partial<PageQuestion>): PageQuestion;
8
+ /**
9
+ * Stub builder for a Summary page
10
+ * @param {Partial<PageSummary>} [partialSummaryPage]
11
+ */
12
+ export declare function buildSummaryPage(partialSummaryPage?: Partial<PageSummary>): PageSummary;
13
+ /**
14
+ *
15
+ * @param {Partial<PageFileUpload>} partialFileUploadPage
16
+ * @returns {PageFileUpload}
17
+ */
18
+ export declare function buildFileUploadPage(partialFileUploadPage?: Partial<PageFileUpload>): PageFileUpload;
19
+ /**
20
+ *
21
+ * @param {Partial<PageRepeat>} partialRepeaterPage
22
+ * @returns {PageRepeat}
23
+ */
24
+ export declare function buildRepeaterPage(partialRepeaterPage?: Partial<PageRepeat>): PageRepeat;
25
+ //# sourceMappingURL=pages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/__stubs__/pages.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qCAAqC,CAAA;AAG5C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,GACjC,YAAY,CASd;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,kBAAkB,GAAE,OAAO,CAAC,WAAW,CAAM,GAC5C,WAAW,CAQb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,qBAAqB,GAAE,OAAO,CAAC,cAAc,CAAM,GAClD,cAAc,CA4BhB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,mBAAmB,GAAE,OAAO,CAAC,UAAU,CAAM,GAC5C,UAAU,CA6BZ"}
@@ -0,0 +1,13 @@
1
+ export * from './__stubs__/form-definition.js';
2
+ export { buildList } from './__stubs__/components.js';
3
+ export { buildListItem } from './__stubs__/components.js';
4
+ export { buildCheckboxComponent } from './__stubs__/components.js';
5
+ export { buildRadioComponent } from './__stubs__/components.js';
6
+ export { buildAutoCompleteComponent } from './__stubs__/components.js';
7
+ export { buildFileUploadComponent } from './__stubs__/components.js';
8
+ export { buildTextFieldComponent } from './__stubs__/components.js';
9
+ export { buildRepeaterPage } from './__stubs__/pages.js';
10
+ export { buildFileUploadPage } from './__stubs__/pages.js';
11
+ export { buildSummaryPage } from './__stubs__/pages.js';
12
+ export { buildQuestionPage } from './__stubs__/pages.js';
13
+ //# sourceMappingURL=stubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../../src/stubs.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA"}
package/package.json CHANGED
@@ -1,8 +1,22 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.463",
3
+ "version": "3.0.464",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
+ "types": "dist/types/index.d.ts",
7
+ "main": "dist/module/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/module/index.js",
11
+ "default": "./dist/module/index.js",
12
+ "types": "./dist/types/index.d.ts"
13
+ },
14
+ "./stubs": {
15
+ "import": "./dist/module/stubs.js",
16
+ "default": "./dist/module/stubs.js",
17
+ "types": "./dist/types/stubs.d.ts"
18
+ }
19
+ },
6
20
  "repository": {
7
21
  "type": "git",
8
22
  "url": "git+https://github.com/DEFRA/forms-designer.git",
@@ -11,8 +25,6 @@
11
25
  "license": "OGL-UK-3.0",
12
26
  "sideEffects": false,
13
27
  "type": "module",
14
- "main": "dist/module/index.js",
15
- "types": "dist/types/index.d.ts",
16
28
  "scripts": {
17
29
  "build": "npm run build:types && npm run build:node && npm run build:schemas",
18
30
  "build:node": "babel --delete-dir-on-start --extensions \".ts,.js\" --ignore \"**/*.test.*\" --copy-files --no-copy-ignored --source-maps --out-dir ./dist/module ./src",
@@ -0,0 +1,209 @@
1
+ import { ComponentType } from '~/src/components/enums.js'
2
+ import {
3
+ type AutocompleteFieldComponent,
4
+ type CheckboxesFieldComponent,
5
+ type DatePartsFieldComponent,
6
+ type FileUploadFieldComponent,
7
+ type NumberFieldComponent,
8
+ type RadiosFieldComponent,
9
+ type TextFieldComponent
10
+ } from '~/src/components/types.js'
11
+ import { type Item, type List } from '~/src/form/form-definition/types.js'
12
+
13
+ /**
14
+ * @param {Partial<TextFieldComponent>} partialTextField
15
+ * @returns {TextFieldComponent}
16
+ */
17
+ export function buildTextFieldComponent(
18
+ partialTextField: Partial<TextFieldComponent> = {}
19
+ ): TextFieldComponent {
20
+ const textFieldComponent: TextFieldComponent = {
21
+ id: '407dd0d7-cce9-4f43-8e1f-7d89cb698875',
22
+ name: 'TextField',
23
+ title: 'Text field',
24
+ type: ComponentType.TextField,
25
+ hint: '',
26
+ options: {},
27
+ schema: {}
28
+ }
29
+
30
+ return {
31
+ ...textFieldComponent,
32
+ ...partialTextField
33
+ }
34
+ }
35
+
36
+ /**
37
+ * @param {Partial<FileUploadFieldComponent>} partialFileUploadField
38
+ * @returns {FileUploadFieldComponent}
39
+ */
40
+ export function buildFileUploadComponent(
41
+ partialFileUploadField: Partial<FileUploadFieldComponent>
42
+ ): FileUploadFieldComponent {
43
+ const fileUploadFieldComponent: FileUploadFieldComponent = {
44
+ name: 'FileUploadField',
45
+ type: ComponentType.FileUploadField,
46
+ title: 'File Upload Field',
47
+ options: {},
48
+ schema: {}
49
+ }
50
+
51
+ return {
52
+ ...fileUploadFieldComponent,
53
+ ...partialFileUploadField
54
+ }
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @param {Partial<AutocompleteFieldComponent>} partialAutoCompleteField
60
+ * @returns {AutocompleteFieldComponent}
61
+ */
62
+ export function buildAutoCompleteComponent(
63
+ partialAutoCompleteField: Partial<AutocompleteFieldComponent>
64
+ ): AutocompleteFieldComponent {
65
+ const autocompleteComponent: AutocompleteFieldComponent = {
66
+ name: 'AutoCompleteField',
67
+ title: 'What languages do you speak?',
68
+ type: ComponentType.AutocompleteField,
69
+ list: 'AutoCompleteList',
70
+ options: {}
71
+ }
72
+
73
+ return {
74
+ ...autocompleteComponent,
75
+ ...partialAutoCompleteField
76
+ }
77
+ }
78
+
79
+ /**
80
+ * @param {Partial<RadiosFieldComponent>} partialListComponent
81
+ * @returns {RadiosFieldComponent}
82
+ */
83
+ export function buildRadioComponent(
84
+ partialListComponent: Partial<RadiosFieldComponent> = {}
85
+ ): RadiosFieldComponent {
86
+ const radioFieldComponent: RadiosFieldComponent = {
87
+ name: 'RadioField',
88
+ title: 'Which country do you live in?',
89
+ type: ComponentType.RadiosField,
90
+ list: 'RadioList',
91
+ options: {}
92
+ }
93
+
94
+ return {
95
+ ...radioFieldComponent,
96
+ ...partialListComponent
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @param {Partial<CheckboxesFieldComponent>} partialListComponent
102
+ * @returns {CheckboxesFieldComponent}
103
+ */
104
+ export function buildCheckboxComponent(
105
+ partialListComponent: Partial<CheckboxesFieldComponent>
106
+ ): CheckboxesFieldComponent {
107
+ const checkboxesFieldComponent: CheckboxesFieldComponent = {
108
+ name: 'FellowshipOfTheRing',
109
+ title: 'Which are your favourite characters from the fellowship?',
110
+ type: ComponentType.CheckboxesField,
111
+ list: 'CheckboxList',
112
+ options: {}
113
+ }
114
+
115
+ return {
116
+ ...checkboxesFieldComponent,
117
+ ...partialListComponent
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Builder to create a stub List item
123
+ * @param {Partial<Item>} partialListItem
124
+ * @returns {Item}
125
+ */
126
+ export function buildListItem(partialListItem: Partial<Item> = {}): Item {
127
+ return {
128
+ text: 'Javascript',
129
+ value: 'javascript',
130
+ ...partialListItem
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @param {Partial<List>} partialList
136
+ * @returns {List}
137
+ */
138
+ export function buildList(partialList: Partial<List> = {}): List {
139
+ return {
140
+ title: 'Development language2',
141
+ name: 'YhmNDD',
142
+ type: 'string',
143
+ items: [
144
+ buildListItem({
145
+ text: 'Javascript',
146
+ value: 'javascript'
147
+ }),
148
+ buildListItem({
149
+ text: 'TypeScript',
150
+ value: 'typescript'
151
+ }),
152
+ buildListItem({
153
+ text: 'Python',
154
+ value: 'python'
155
+ }),
156
+ buildListItem({
157
+ text: 'Haskell',
158
+ value: 'haskell'
159
+ }),
160
+ buildListItem({
161
+ text: 'Erlang',
162
+ value: 'erlang'
163
+ }),
164
+ buildListItem({
165
+ text: 'Java',
166
+ value: 'java'
167
+ })
168
+ ],
169
+ ...partialList
170
+ }
171
+ }
172
+
173
+ export function buildNumberFieldComponent(
174
+ partialComponent: Partial<NumberFieldComponent>
175
+ ): NumberFieldComponent {
176
+ return {
177
+ name: 'year',
178
+ title: 'Year',
179
+ options: {},
180
+ schema: {},
181
+ ...partialComponent,
182
+ type: ComponentType.NumberField
183
+ }
184
+ }
185
+
186
+ export function buildDateComponent(
187
+ partialComponent: Partial<DatePartsFieldComponent>
188
+ ): DatePartsFieldComponent {
189
+ return {
190
+ name: 'bcdefg',
191
+ title: 'Default title',
192
+ options: {},
193
+ ...partialComponent,
194
+ type: ComponentType.DatePartsField
195
+ }
196
+ }
197
+
198
+ export function buildRadiosComponent(
199
+ partialComponent: Partial<RadiosFieldComponent>
200
+ ): RadiosFieldComponent {
201
+ return {
202
+ name: 'cdefgh',
203
+ title: 'Default title',
204
+ options: {},
205
+ list: 'Default list Id ref',
206
+ ...partialComponent,
207
+ type: ComponentType.RadiosField
208
+ }
209
+ }
@@ -0,0 +1,64 @@
1
+ import { type FormDefinition } from '~/src/form/form-definition/types.js'
2
+ import { type FormMetadata } from '~/src/form/form-metadata/types.js'
3
+
4
+ /**
5
+ * Builder to create a Form Definition
6
+ * @param {Partial<FormDefinition>} definitionPartial
7
+ * @returns {FormDefinition}
8
+ */
9
+ export function buildDefinition(
10
+ definitionPartial: Partial<FormDefinition> = {}
11
+ ): FormDefinition {
12
+ const formDefinition: FormDefinition = {
13
+ name: 'Test form',
14
+ pages: [],
15
+ conditions: [],
16
+ sections: [],
17
+ lists: []
18
+ }
19
+ return {
20
+ ...formDefinition,
21
+ ...definitionPartial
22
+ }
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @param {Partial<FormMetadata>} partialMetaData
28
+ * @returns {FormMetadata}
29
+ */
30
+ export function buildMetaData(
31
+ partialMetaData: Partial<FormMetadata> = {}
32
+ ): FormMetadata {
33
+ return {
34
+ id: '681b184463c68bf6b99e2c62',
35
+ slug: 'chemistry',
36
+ title: 'Chemistry',
37
+ organisation: 'Defra',
38
+ teamName: 'Forms Team',
39
+ teamEmail: 'name@example.gov.uk',
40
+ draft: {
41
+ createdAt: new Date('2025-05-07T08:22:28.035Z'),
42
+ createdBy: {
43
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
44
+ displayName: 'Internal User'
45
+ },
46
+ updatedAt: new Date('2025-05-20T13:00:54.794Z'),
47
+ updatedBy: {
48
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
49
+ displayName: 'Internal User'
50
+ }
51
+ },
52
+ createdBy: {
53
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
54
+ displayName: 'Internal User'
55
+ },
56
+ createdAt: new Date('2025-05-07T08:22:28.035Z'),
57
+ updatedBy: {
58
+ id: '84305e4e-1f52-43d0-a123-9c873b0abb35',
59
+ displayName: 'Internal User'
60
+ },
61
+ updatedAt: new Date('2025-05-20T13:00:54.794Z'),
62
+ ...partialMetaData
63
+ }
64
+ }
@@ -0,0 +1,118 @@
1
+ import { buildFileUploadComponent } from '~/src/__stubs__/components.js'
2
+ import { ComponentType } from '~/src/components/enums.js'
3
+ import {
4
+ type PageFileUpload,
5
+ type PageQuestion,
6
+ type PageRepeat,
7
+ type PageSummary
8
+ } from '~/src/form/form-definition/types.js'
9
+ import { ControllerPath, ControllerType } from '~/src/pages/enums.js'
10
+
11
+ /**
12
+ * Stub builder for a question page
13
+ * @param {Partial<PageQuestion>} [partialPage]
14
+ * @returns {PageQuestion}
15
+ */
16
+ export function buildQuestionPage(
17
+ partialPage: Partial<PageQuestion>
18
+ ): PageQuestion {
19
+ return {
20
+ id: 'ffefd409-f3f4-49fe-882e-6e89f44631b1',
21
+ title: 'Page One',
22
+ path: '/page-one',
23
+ next: [],
24
+ components: [],
25
+ ...partialPage
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Stub builder for a Summary page
31
+ * @param {Partial<PageSummary>} [partialSummaryPage]
32
+ */
33
+ export function buildSummaryPage(
34
+ partialSummaryPage: Partial<PageSummary> = {}
35
+ ): PageSummary {
36
+ const pageSummary: PageSummary = {
37
+ id: '449a45f6-4541-4a46-91bd-8b8931b07b50',
38
+ title: 'Summary page',
39
+ path: ControllerPath.Summary,
40
+ controller: ControllerType.Summary
41
+ }
42
+ return { ...pageSummary, ...partialSummaryPage }
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param {Partial<PageFileUpload>} partialFileUploadPage
48
+ * @returns {PageFileUpload}
49
+ */
50
+ export function buildFileUploadPage(
51
+ partialFileUploadPage: Partial<PageFileUpload> = {}
52
+ ): PageFileUpload {
53
+ const fileUploadPage: PageFileUpload = {
54
+ id: '85e5c8da-88f5-4009-a821-7d7de1364318',
55
+ title: '',
56
+ path: '/supporting-evidence',
57
+ components: [
58
+ buildFileUploadComponent({
59
+ type: ComponentType.FileUploadField,
60
+ title: 'Supporting Evidence',
61
+ name: 'yBpZQO',
62
+ shortDescription: 'Supporting evidence',
63
+ hint: '',
64
+ options: {
65
+ required: true,
66
+ accept:
67
+ 'application/pdf,application/msword,image/jpeg,application/vnd.ms-excel,text/csv'
68
+ },
69
+ id: '4189b8a1-1a04-4f74-a7a0-dd23012a0ee0'
70
+ })
71
+ ],
72
+ controller: ControllerType.FileUpload,
73
+ next: []
74
+ }
75
+
76
+ return {
77
+ ...fileUploadPage,
78
+ ...partialFileUploadPage
79
+ }
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @param {Partial<PageRepeat>} partialRepeaterPage
85
+ * @returns {PageRepeat}
86
+ */
87
+ export function buildRepeaterPage(
88
+ partialRepeaterPage: Partial<PageRepeat> = {}
89
+ ): PageRepeat {
90
+ const repeaterPage: PageRepeat = {
91
+ title: 'Repeater Page',
92
+ path: '/repeater-page',
93
+ components: [
94
+ {
95
+ type: ComponentType.TextField,
96
+ title: 'Simple text field',
97
+ name: 'IHAIzC',
98
+ shortDescription: 'Your simple text field',
99
+ hint: '',
100
+ options: {},
101
+ schema: {},
102
+ id: 'ee83413e-31b6-4158-98e0-4611479582ce'
103
+ }
104
+ ],
105
+ next: [],
106
+ id: '32888028-61db-40fc-b255-80bc67829d31',
107
+ controller: ControllerType.Repeat,
108
+ repeat: {
109
+ options: { name: 'fawfed', title: 'Simple question responses' },
110
+ schema: { min: 1, max: 3 }
111
+ }
112
+ }
113
+
114
+ return {
115
+ ...repeaterPage,
116
+ ...partialRepeaterPage
117
+ }
118
+ }
package/src/stubs.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from '~/src/__stubs__/form-definition.js'
2
+ export { buildList } from '~/src/__stubs__/components.js'
3
+ export { buildListItem } from '~/src/__stubs__/components.js'
4
+ export { buildCheckboxComponent } from '~/src/__stubs__/components.js'
5
+ export { buildRadioComponent } from '~/src/__stubs__/components.js'
6
+ export { buildAutoCompleteComponent } from '~/src/__stubs__/components.js'
7
+ export { buildFileUploadComponent } from '~/src/__stubs__/components.js'
8
+ export { buildTextFieldComponent } from '~/src/__stubs__/components.js'
9
+ export { buildRepeaterPage } from '~/src/__stubs__/pages.js'
10
+ export { buildFileUploadPage } from '~/src/__stubs__/pages.js'
11
+ export { buildSummaryPage } from '~/src/__stubs__/pages.js'
12
+ export { buildQuestionPage } from '~/src/__stubs__/pages.js'