@defra/forms-model 3.0.672 → 3.0.674

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.
Files changed (45) hide show
  1. package/dist/module/components/enums.js +5 -0
  2. package/dist/module/components/enums.js.map +1 -1
  3. package/dist/module/components/index.js +1 -1
  4. package/dist/module/components/index.js.map +1 -1
  5. package/dist/module/components/types.js.map +1 -1
  6. package/dist/module/form/form-definition/index.js +14 -2
  7. package/dist/module/form/form-definition/index.js.map +1 -1
  8. package/dist/module/form/form-editor/index.js +4 -2
  9. package/dist/module/form/form-editor/index.js.map +1 -1
  10. package/dist/module/form/form-editor/types.js.map +1 -1
  11. package/dist/module/form/form-metrics/enums.js +2 -1
  12. package/dist/module/form/form-metrics/enums.js.map +1 -1
  13. package/dist/module/form/form-metrics/types.js.map +1 -1
  14. package/dist/types/components/enums.d.ts +4 -0
  15. package/dist/types/components/enums.d.ts.map +1 -1
  16. package/dist/types/components/index.d.ts +1 -1
  17. package/dist/types/components/index.d.ts.map +1 -1
  18. package/dist/types/components/types.d.ts +2 -0
  19. package/dist/types/components/types.d.ts.map +1 -1
  20. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  21. package/dist/types/form/form-editor/index.d.ts +2 -0
  22. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  23. package/dist/types/form/form-editor/types.d.ts +6 -2
  24. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  25. package/dist/types/form/form-metrics/enums.d.ts +2 -1
  26. package/dist/types/form/form-metrics/enums.d.ts.map +1 -1
  27. package/dist/types/form/form-metrics/types.d.ts +7 -1
  28. package/dist/types/form/form-metrics/types.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/schemas/component-schema-v2.json +38 -0
  31. package/schemas/component-schema.json +38 -0
  32. package/schemas/form-definition-schema.json +114 -0
  33. package/schemas/form-definition-v2-schema.json +190 -0
  34. package/schemas/list-schema-v2.json +76 -0
  35. package/schemas/list-schema.json +76 -0
  36. package/schemas/page-schema-v2.json +114 -0
  37. package/schemas/page-schema.json +38 -0
  38. package/src/components/enums.ts +5 -0
  39. package/src/components/index.ts +2 -1
  40. package/src/components/types.ts +3 -0
  41. package/src/form/form-definition/index.ts +42 -2
  42. package/src/form/form-editor/index.ts +8 -2
  43. package/src/form/form-editor/types.ts +8 -1
  44. package/src/form/form-metrics/enums.ts +2 -1
  45. package/src/form/form-metrics/types.ts +7 -1
@@ -234,6 +234,44 @@
234
234
  "type": "string",
235
235
  "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
236
236
  "title": "Email Field"
237
+ },
238
+ "countries": {
239
+ "type": "array",
240
+ "description": "Country filters for geospatial data - for GeospatialField only",
241
+ "items": {
242
+ "type": "string",
243
+ "enum": [
244
+ "england",
245
+ "northern-ireland",
246
+ "scotland",
247
+ "wales"
248
+ ],
249
+ "title": "Countries Item"
250
+ },
251
+ "title": "Countries"
252
+ },
253
+ "geometryTypes": {
254
+ "type": "array",
255
+ "description": "Geometry types for geospatial data - for GeospatialField only",
256
+ "items": {
257
+ "type": "string",
258
+ "enum": [
259
+ "point",
260
+ "line",
261
+ "shape"
262
+ ],
263
+ "title": "Geometry Types Item"
264
+ },
265
+ "title": "Geometry Types"
266
+ },
267
+ "format": {
268
+ "type": "string",
269
+ "description": "Format for telephone number - for TelephoneNumberField only",
270
+ "enum": [
271
+ "uk",
272
+ "international"
273
+ ],
274
+ "title": "Format"
237
275
  }
238
276
  },
239
277
  "additionalProperties": true,
@@ -546,6 +584,44 @@
546
584
  "type": "string",
547
585
  "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
548
586
  "title": "Email Field"
587
+ },
588
+ "countries": {
589
+ "type": "array",
590
+ "description": "Country filters for geospatial data - for GeospatialField only",
591
+ "items": {
592
+ "type": "string",
593
+ "enum": [
594
+ "england",
595
+ "northern-ireland",
596
+ "scotland",
597
+ "wales"
598
+ ],
599
+ "title": "Countries Item"
600
+ },
601
+ "title": "Countries"
602
+ },
603
+ "geometryTypes": {
604
+ "type": "array",
605
+ "description": "Geometry types for geospatial data - for GeospatialField only",
606
+ "items": {
607
+ "type": "string",
608
+ "enum": [
609
+ "point",
610
+ "line",
611
+ "shape"
612
+ ],
613
+ "title": "Geometry Types Item"
614
+ },
615
+ "title": "Geometry Types"
616
+ },
617
+ "format": {
618
+ "type": "string",
619
+ "description": "Format for telephone number - for TelephoneNumberField only",
620
+ "enum": [
621
+ "uk",
622
+ "international"
623
+ ],
624
+ "title": "Format"
549
625
  }
550
626
  },
551
627
  "additionalProperties": true,
@@ -340,6 +340,44 @@
340
340
  "type": "string",
341
341
  "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
342
342
  "title": "Email Field"
343
+ },
344
+ "countries": {
345
+ "type": "array",
346
+ "description": "Country filters for geospatial data - for GeospatialField only",
347
+ "items": {
348
+ "type": "string",
349
+ "enum": [
350
+ "england",
351
+ "northern-ireland",
352
+ "scotland",
353
+ "wales"
354
+ ],
355
+ "title": "Countries Item"
356
+ },
357
+ "title": "Countries"
358
+ },
359
+ "geometryTypes": {
360
+ "type": "array",
361
+ "description": "Geometry types for geospatial data - for GeospatialField only",
362
+ "items": {
363
+ "type": "string",
364
+ "enum": [
365
+ "point",
366
+ "line",
367
+ "shape"
368
+ ],
369
+ "title": "Geometry Types Item"
370
+ },
371
+ "title": "Geometry Types"
372
+ },
373
+ "format": {
374
+ "type": "string",
375
+ "description": "Format for telephone number - for TelephoneNumberField only",
376
+ "enum": [
377
+ "uk",
378
+ "international"
379
+ ],
380
+ "title": "Format"
343
381
  }
344
382
  },
345
383
  "additionalProperties": true,
@@ -582,6 +620,44 @@
582
620
  "type": "string",
583
621
  "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
584
622
  "title": "Email Field"
623
+ },
624
+ "countries": {
625
+ "type": "array",
626
+ "description": "Country filters for geospatial data - for GeospatialField only",
627
+ "items": {
628
+ "type": "string",
629
+ "enum": [
630
+ "england",
631
+ "northern-ireland",
632
+ "scotland",
633
+ "wales"
634
+ ],
635
+ "title": "Countries Item"
636
+ },
637
+ "title": "Countries"
638
+ },
639
+ "geometryTypes": {
640
+ "type": "array",
641
+ "description": "Geometry types for geospatial data - for GeospatialField only",
642
+ "items": {
643
+ "type": "string",
644
+ "enum": [
645
+ "point",
646
+ "line",
647
+ "shape"
648
+ ],
649
+ "title": "Geometry Types Item"
650
+ },
651
+ "title": "Geometry Types"
652
+ },
653
+ "format": {
654
+ "type": "string",
655
+ "description": "Format for telephone number - for TelephoneNumberField only",
656
+ "enum": [
657
+ "uk",
658
+ "international"
659
+ ],
660
+ "title": "Format"
585
661
  }
586
662
  },
587
663
  "additionalProperties": true,
@@ -908,6 +984,44 @@
908
984
  "type": "string",
909
985
  "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
910
986
  "title": "Email Field"
987
+ },
988
+ "countries": {
989
+ "type": "array",
990
+ "description": "Country filters for geospatial data - for GeospatialField only",
991
+ "items": {
992
+ "type": "string",
993
+ "enum": [
994
+ "england",
995
+ "northern-ireland",
996
+ "scotland",
997
+ "wales"
998
+ ],
999
+ "title": "Countries Item"
1000
+ },
1001
+ "title": "Countries"
1002
+ },
1003
+ "geometryTypes": {
1004
+ "type": "array",
1005
+ "description": "Geometry types for geospatial data - for GeospatialField only",
1006
+ "items": {
1007
+ "type": "string",
1008
+ "enum": [
1009
+ "point",
1010
+ "line",
1011
+ "shape"
1012
+ ],
1013
+ "title": "Geometry Types Item"
1014
+ },
1015
+ "title": "Geometry Types"
1016
+ },
1017
+ "format": {
1018
+ "type": "string",
1019
+ "description": "Format for telephone number - for TelephoneNumberField only",
1020
+ "enum": [
1021
+ "uk",
1022
+ "international"
1023
+ ],
1024
+ "title": "Format"
911
1025
  }
912
1026
  },
913
1027
  "additionalProperties": true,
@@ -203,6 +203,44 @@
203
203
  "type": "string",
204
204
  "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
205
205
  "title": "Email Field"
206
+ },
207
+ "countries": {
208
+ "type": "array",
209
+ "description": "Country filters for geospatial data - for GeospatialField only",
210
+ "items": {
211
+ "type": "string",
212
+ "enum": [
213
+ "england",
214
+ "northern-ireland",
215
+ "scotland",
216
+ "wales"
217
+ ],
218
+ "title": "Countries Item"
219
+ },
220
+ "title": "Countries"
221
+ },
222
+ "geometryTypes": {
223
+ "type": "array",
224
+ "description": "Geometry types for geospatial data - for GeospatialField only",
225
+ "items": {
226
+ "type": "string",
227
+ "enum": [
228
+ "point",
229
+ "line",
230
+ "shape"
231
+ ],
232
+ "title": "Geometry Types Item"
233
+ },
234
+ "title": "Geometry Types"
235
+ },
236
+ "format": {
237
+ "type": "string",
238
+ "description": "Format for telephone number - for TelephoneNumberField only",
239
+ "enum": [
240
+ "uk",
241
+ "international"
242
+ ],
243
+ "title": "Format"
206
244
  }
207
245
  },
208
246
  "additionalProperties": true,
@@ -42,6 +42,11 @@ export enum GeospatialFieldGeometryTypesEnum {
42
42
  Shape = 'shape'
43
43
  }
44
44
 
45
+ export enum TelephoneNumberFieldOptionsFormatEnum {
46
+ UK = 'uk',
47
+ International = 'international'
48
+ }
49
+
45
50
  export const PreviewTypeEnum = {
46
51
  ...ComponentType,
47
52
  Question: 'Question',
@@ -3,7 +3,8 @@ export {
3
3
  ComponentType,
4
4
  GeospatialFieldGeometryTypesEnum,
5
5
  GeospatialFieldOptionsCountryEnum,
6
- PreviewTypeEnum
6
+ PreviewTypeEnum,
7
+ TelephoneNumberFieldOptionsFormatEnum
7
8
  } from '~/src/components/enums.js'
8
9
  export {
9
10
  allDocumentTypes,
@@ -118,10 +118,13 @@ export interface NumberFieldComponent extends FormFieldBase {
118
118
  }
119
119
  }
120
120
 
121
+ export type TelephoneNumberFieldOptionsFormat = 'international' | 'uk'
122
+
121
123
  export interface TelephoneNumberFieldComponent extends FormFieldBase {
122
124
  type: ComponentType.TelephoneNumberField
123
125
  options: FormFieldBase['options'] & {
124
126
  condition?: string
127
+ format?: TelephoneNumberFieldOptionsFormat
125
128
  customValidationMessage?: string
126
129
  }
127
130
  }
@@ -3,7 +3,12 @@ import JoiBase, { type CustomHelpers, type LanguageMessages } from 'joi'
3
3
  import { v4 as uuidV4 } from 'uuid'
4
4
 
5
5
  import { rtrimOnly } from '~/src/common/rtrim-only.js'
6
- import { ComponentType } from '~/src/components/enums.js'
6
+ import {
7
+ ComponentType,
8
+ GeospatialFieldGeometryTypesEnum,
9
+ GeospatialFieldOptionsCountryEnum,
10
+ TelephoneNumberFieldOptionsFormatEnum
11
+ } from '~/src/components/enums.js'
7
12
  import { isConditionalType } from '~/src/components/helpers.js'
8
13
  import {
9
14
  type ComponentDef,
@@ -621,7 +626,42 @@ export const componentSchema = Joi.object<ComponentDef>()
621
626
  .description(
622
627
  'Name of EmailAddressField to prepopulate GOV.UK Pay email'
623
628
  )
624
- }).description('Email field reference - for PaymentField only')
629
+ }).description('Email field reference - for PaymentField only'),
630
+ countries: Joi.when('type', {
631
+ is: Joi.string().trim().valid(ComponentType.GeospatialField).required(),
632
+ then: Joi.array()
633
+ .items(
634
+ Joi.string().valid(
635
+ ...Object.values(GeospatialFieldOptionsCountryEnum)
636
+ )
637
+ )
638
+ .description(
639
+ 'Country filters for geospatial data - for GeospatialField only'
640
+ )
641
+ }).description('Country filters - for GeospatialField only'),
642
+ geometryTypes: Joi.when('type', {
643
+ is: Joi.string().trim().valid(ComponentType.GeospatialField).required(),
644
+ then: Joi.array()
645
+ .items(
646
+ Joi.string().valid(
647
+ ...Object.values(GeospatialFieldGeometryTypesEnum)
648
+ )
649
+ )
650
+ .description(
651
+ 'Geometry types for geospatial data - for GeospatialField only'
652
+ )
653
+ }).description('Geometry types - for GeospatialField only'),
654
+ format: Joi.when('type', {
655
+ is: Joi.string()
656
+ .trim()
657
+ .valid(ComponentType.TelephoneNumberField)
658
+ .required(),
659
+ then: Joi.string()
660
+ .valid(...Object.values(TelephoneNumberFieldOptionsFormatEnum))
661
+ .description(
662
+ 'Format for telephone number - for TelephoneNumberField only'
663
+ )
664
+ }).description('Format - for TelephoneNumberField only')
625
665
  })
626
666
  .default({})
627
667
  .unknown(true)
@@ -4,7 +4,8 @@ import { rtrimOnly } from '~/src/common/rtrim-only.js'
4
4
  import {
5
5
  ComponentType,
6
6
  GeospatialFieldGeometryTypesEnum,
7
- GeospatialFieldOptionsCountryEnum
7
+ GeospatialFieldOptionsCountryEnum,
8
+ TelephoneNumberFieldOptionsFormatEnum
8
9
  } from '~/src/components/enums.js'
9
10
  import {
10
11
  MAX_NUMBER_OF_REPEAT_ITEMS,
@@ -484,6 +485,10 @@ export const geometryTypesSchema = Joi.array()
484
485
  .single()
485
486
  .description('The geometry types allowed in a geospatial field')
486
487
 
488
+ export const telephoneNumberFormatSchema = Joi.string()
489
+ .valid(...Object.values(TelephoneNumberFieldOptionsFormatEnum), 'any')
490
+ .description('The format for the telephone number field')
491
+
487
492
  type GenericRuleOptions<K extends string, T> = Omit<GetRuleOptions, 'args'> & {
488
493
  args: Record<K, T>
489
494
  }
@@ -680,7 +685,8 @@ export const questionDetailsFullSchema = {
680
685
  minFeaturesSchema,
681
686
  maxFeaturesSchema,
682
687
  exactFeaturesSchema,
683
- geometryTypesSchema
688
+ geometryTypesSchema,
689
+ telephoneNumberFormatSchema
684
690
  }
685
691
 
686
692
  export const formEditorInputPageKeys = {
@@ -4,7 +4,8 @@ import {
4
4
  } from '~/src/components/enums.js'
5
5
  import {
6
6
  type ComponentDef,
7
- type GeospatialFieldOptionsCountry
7
+ type GeospatialFieldOptionsCountry,
8
+ type TelephoneNumberFieldOptionsFormat
8
9
  } from '~/src/components/types.js'
9
10
  import { type DateDirections, type DateUnits } from '~/src/conditions/enums.js'
10
11
  import {
@@ -396,6 +397,11 @@ export interface FormEditor {
396
397
  * The geometry types restriction for geospatial questions
397
398
  */
398
399
  geometryTypes?: GeospatialFieldGeometryTypesEnum[]
400
+
401
+ /**
402
+ * The format restriction for telephone number questions
403
+ */
404
+ telephoneNumberFormat?: TelephoneNumberFieldOptionsFormat | 'any'
399
405
  }
400
406
 
401
407
  export type FormEditorInputPage = Pick<
@@ -482,6 +488,7 @@ export type FormEditorInputQuestion = Pick<
482
488
  | 'exactFeatures'
483
489
  | 'minFeatures'
484
490
  | 'maxFeatures'
491
+ | 'telephoneNumberFormat'
485
492
  >
486
493
 
487
494
  export type FormEditorInputPageSettings = Pick<
@@ -6,7 +6,8 @@ export enum FormMetricType {
6
6
 
7
7
  export enum FormMetricName {
8
8
  NewFormsCreated = 'NewFormsCreated',
9
- FormsPublished = 'FormsPublished',
9
+ FormsFirstPublished = 'FormsFirstPublished',
10
+ FormsRePublished = 'FormsRePublished',
10
11
  Submissions = 'Submissions',
11
12
  FormsInDraft = 'FormsInDraft',
12
13
  TimeToPublish = 'TimeToPublish'
@@ -6,6 +6,11 @@ import {
6
6
 
7
7
  export interface FormTotalMetric {
8
8
  count?: number
9
+ details?: {
10
+ formId: string
11
+ metricValue?: string | Date | number
12
+ createdAt?: Date
13
+ }
9
14
  }
10
15
 
11
16
  export interface FormTotalsMetric {
@@ -22,6 +27,7 @@ export interface FormTotalsMetric {
22
27
  daysToPublish?: Record<string, number>
23
28
  republished?: Record<string, number>
24
29
  updatedAt: Date
30
+ earliestDate: Date
25
31
  }
26
32
 
27
33
  export interface FormOverviewMetric {
@@ -38,7 +44,7 @@ export interface FormTimelineMetric {
38
44
  type: FormMetricType.TimelineMetric
39
45
  formId: string
40
46
  formStatus: FormStatus
41
- metricName: string
47
+ metricName: FormMetricName
42
48
  metricValue: number
43
49
  createdAt: Date
44
50
  }