@defra/forms-model 3.0.674 → 3.0.676

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 (35) hide show
  1. package/dist/module/components/types.js.map +1 -1
  2. package/dist/module/form/form-definition/index.js +2 -0
  3. package/dist/module/form/form-definition/index.js.map +1 -1
  4. package/dist/module/form/form-editor/index.js +3 -1
  5. package/dist/module/form/form-editor/index.js.map +1 -1
  6. package/dist/module/form/form-editor/types.js.map +1 -1
  7. package/dist/module/form/form-metrics/enums.js +1 -0
  8. package/dist/module/form/form-metrics/enums.js.map +1 -1
  9. package/dist/module/form/form-metrics/types.js.map +1 -1
  10. package/dist/types/components/types.d.ts +2 -0
  11. package/dist/types/components/types.d.ts.map +1 -1
  12. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  13. package/dist/types/form/form-editor/index.d.ts +133 -133
  14. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  15. package/dist/types/form/form-editor/types.d.ts +9 -1
  16. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  17. package/dist/types/form/form-metrics/enums.d.ts +2 -1
  18. package/dist/types/form/form-metrics/enums.d.ts.map +1 -1
  19. package/dist/types/form/form-metrics/types.d.ts +8 -0
  20. package/dist/types/form/form-metrics/types.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/schemas/component-schema-v2.json +10 -0
  23. package/schemas/component-schema.json +10 -0
  24. package/schemas/form-definition-schema.json +30 -0
  25. package/schemas/form-definition-v2-schema.json +50 -0
  26. package/schemas/list-schema-v2.json +20 -0
  27. package/schemas/list-schema.json +20 -0
  28. package/schemas/page-schema-v2.json +30 -0
  29. package/schemas/page-schema.json +10 -0
  30. package/src/components/types.ts +2 -0
  31. package/src/form/form-definition/index.ts +10 -0
  32. package/src/form/form-editor/index.ts +6 -3
  33. package/src/form/form-editor/types.ts +12 -0
  34. package/src/form/form-metrics/enums.ts +2 -1
  35. package/src/form/form-metrics/types.ts +9 -0
@@ -473,6 +473,16 @@
473
473
  "description": "Maximum days in the future allowed for date inputs",
474
474
  "title": "Max Days In Future"
475
475
  },
476
+ "earliestDate": {
477
+ "type": "integer",
478
+ "description": "Earliest date of allowed date range for date inputs",
479
+ "title": "Earliest Date"
480
+ },
481
+ "latestDate": {
482
+ "type": "integer",
483
+ "description": "Latest date of allowed date range for date inputs",
484
+ "title": "Latest Date"
485
+ },
476
486
  "customValidationMessage": {
477
487
  "type": "string",
478
488
  "description": "Custom error message for validation failures",
@@ -753,6 +763,16 @@
753
763
  "description": "Maximum days in the future allowed for date inputs",
754
764
  "title": "Max Days In Future"
755
765
  },
766
+ "earliestDate": {
767
+ "type": "integer",
768
+ "description": "Earliest date of allowed date range for date inputs",
769
+ "title": "Earliest Date"
770
+ },
771
+ "latestDate": {
772
+ "type": "integer",
773
+ "description": "Latest date of allowed date range for date inputs",
774
+ "title": "Latest Date"
775
+ },
756
776
  "customValidationMessage": {
757
777
  "type": "string",
758
778
  "description": "Custom error message for validation failures",
@@ -1117,6 +1137,16 @@
1117
1137
  "description": "Maximum days in the future allowed for date inputs",
1118
1138
  "title": "Max Days In Future"
1119
1139
  },
1140
+ "earliestDate": {
1141
+ "type": "integer",
1142
+ "description": "Earliest date of allowed date range for date inputs",
1143
+ "title": "Earliest Date"
1144
+ },
1145
+ "latestDate": {
1146
+ "type": "integer",
1147
+ "description": "Latest date of allowed date range for date inputs",
1148
+ "title": "Latest Date"
1149
+ },
1120
1150
  "customValidationMessage": {
1121
1151
  "type": "string",
1122
1152
  "description": "Custom error message for validation failures",
@@ -1506,6 +1536,16 @@
1506
1536
  "description": "Maximum days in the future allowed for date inputs",
1507
1537
  "title": "Max Days In Future"
1508
1538
  },
1539
+ "earliestDate": {
1540
+ "type": "integer",
1541
+ "description": "Earliest date of allowed date range for date inputs",
1542
+ "title": "Earliest Date"
1543
+ },
1544
+ "latestDate": {
1545
+ "type": "integer",
1546
+ "description": "Latest date of allowed date range for date inputs",
1547
+ "title": "Latest Date"
1548
+ },
1509
1549
  "customValidationMessage": {
1510
1550
  "type": "string",
1511
1551
  "description": "Custom error message for validation failures",
@@ -1856,6 +1896,16 @@
1856
1896
  "description": "Maximum days in the future allowed for date inputs",
1857
1897
  "title": "Max Days In Future"
1858
1898
  },
1899
+ "earliestDate": {
1900
+ "type": "integer",
1901
+ "description": "Earliest date of allowed date range for date inputs",
1902
+ "title": "Earliest Date"
1903
+ },
1904
+ "latestDate": {
1905
+ "type": "integer",
1906
+ "description": "Latest date of allowed date range for date inputs",
1907
+ "title": "Latest Date"
1908
+ },
1859
1909
  "customValidationMessage": {
1860
1910
  "type": "string",
1861
1911
  "description": "Custom error message for validation failures",
@@ -171,6 +171,16 @@
171
171
  "description": "Maximum days in the future allowed for date inputs",
172
172
  "title": "Max Days In Future"
173
173
  },
174
+ "earliestDate": {
175
+ "type": "integer",
176
+ "description": "Earliest date of allowed date range for date inputs",
177
+ "title": "Earliest Date"
178
+ },
179
+ "latestDate": {
180
+ "type": "integer",
181
+ "description": "Latest date of allowed date range for date inputs",
182
+ "title": "Latest Date"
183
+ },
174
184
  "customValidationMessage": {
175
185
  "type": "string",
176
186
  "description": "Custom error message for validation failures",
@@ -521,6 +531,16 @@
521
531
  "description": "Maximum days in the future allowed for date inputs",
522
532
  "title": "Max Days In Future"
523
533
  },
534
+ "earliestDate": {
535
+ "type": "integer",
536
+ "description": "Earliest date of allowed date range for date inputs",
537
+ "title": "Earliest Date"
538
+ },
539
+ "latestDate": {
540
+ "type": "integer",
541
+ "description": "Latest date of allowed date range for date inputs",
542
+ "title": "Latest Date"
543
+ },
524
544
  "customValidationMessage": {
525
545
  "type": "string",
526
546
  "description": "Custom error message for validation failures",
@@ -177,6 +177,16 @@
177
177
  "description": "Maximum days in the future allowed for date inputs",
178
178
  "title": "Max Days In Future"
179
179
  },
180
+ "earliestDate": {
181
+ "type": "integer",
182
+ "description": "Earliest date of allowed date range for date inputs",
183
+ "title": "Earliest Date"
184
+ },
185
+ "latestDate": {
186
+ "type": "integer",
187
+ "description": "Latest date of allowed date range for date inputs",
188
+ "title": "Latest Date"
189
+ },
180
190
  "customValidationMessage": {
181
191
  "type": "string",
182
192
  "description": "Custom error message for validation failures",
@@ -527,6 +537,16 @@
527
537
  "description": "Maximum days in the future allowed for date inputs",
528
538
  "title": "Max Days In Future"
529
539
  },
540
+ "earliestDate": {
541
+ "type": "integer",
542
+ "description": "Earliest date of allowed date range for date inputs",
543
+ "title": "Earliest Date"
544
+ },
545
+ "latestDate": {
546
+ "type": "integer",
547
+ "description": "Latest date of allowed date range for date inputs",
548
+ "title": "Latest Date"
549
+ },
530
550
  "customValidationMessage": {
531
551
  "type": "string",
532
552
  "description": "Custom error message for validation failures",
@@ -283,6 +283,16 @@
283
283
  "description": "Maximum days in the future allowed for date inputs",
284
284
  "title": "Max Days In Future"
285
285
  },
286
+ "earliestDate": {
287
+ "type": "integer",
288
+ "description": "Earliest date of allowed date range for date inputs",
289
+ "title": "Earliest Date"
290
+ },
291
+ "latestDate": {
292
+ "type": "integer",
293
+ "description": "Latest date of allowed date range for date inputs",
294
+ "title": "Latest Date"
295
+ },
286
296
  "customValidationMessage": {
287
297
  "type": "string",
288
298
  "description": "Custom error message for validation failures",
@@ -563,6 +573,16 @@
563
573
  "description": "Maximum days in the future allowed for date inputs",
564
574
  "title": "Max Days In Future"
565
575
  },
576
+ "earliestDate": {
577
+ "type": "integer",
578
+ "description": "Earliest date of allowed date range for date inputs",
579
+ "title": "Earliest Date"
580
+ },
581
+ "latestDate": {
582
+ "type": "integer",
583
+ "description": "Latest date of allowed date range for date inputs",
584
+ "title": "Latest Date"
585
+ },
566
586
  "customValidationMessage": {
567
587
  "type": "string",
568
588
  "description": "Custom error message for validation failures",
@@ -927,6 +947,16 @@
927
947
  "description": "Maximum days in the future allowed for date inputs",
928
948
  "title": "Max Days In Future"
929
949
  },
950
+ "earliestDate": {
951
+ "type": "integer",
952
+ "description": "Earliest date of allowed date range for date inputs",
953
+ "title": "Earliest Date"
954
+ },
955
+ "latestDate": {
956
+ "type": "integer",
957
+ "description": "Latest date of allowed date range for date inputs",
958
+ "title": "Latest Date"
959
+ },
930
960
  "customValidationMessage": {
931
961
  "type": "string",
932
962
  "description": "Custom error message for validation failures",
@@ -146,6 +146,16 @@
146
146
  "description": "Maximum days in the future allowed for date inputs",
147
147
  "title": "Max Days In Future"
148
148
  },
149
+ "earliestDate": {
150
+ "type": "integer",
151
+ "description": "Earliest date of allowed date range for date inputs",
152
+ "title": "Earliest Date"
153
+ },
154
+ "latestDate": {
155
+ "type": "integer",
156
+ "description": "Latest date of allowed date range for date inputs",
157
+ "title": "Latest Date"
158
+ },
149
159
  "customValidationMessage": {
150
160
  "type": "string",
151
161
  "description": "Custom error message for validation failures",
@@ -72,6 +72,8 @@ interface DateFieldBase extends FormFieldBase {
72
72
  options: FormFieldBase['options'] & {
73
73
  maxDaysInPast?: number
74
74
  maxDaysInFuture?: number
75
+ earliestDate?: string
76
+ latestDate?: string
75
77
  }
76
78
  }
77
79
 
@@ -576,6 +576,16 @@ export const componentSchema = Joi.object<ComponentDef>()
576
576
  maxDaysInFuture: Joi.number()
577
577
  .empty('')
578
578
  .description('Maximum days in the future allowed for date inputs'),
579
+ earliestDate: Joi.date()
580
+ .format('YYYY-MM-DD')
581
+ .raw()
582
+ .empty('')
583
+ .description('Earliest date of allowed date range for date inputs'),
584
+ latestDate: Joi.date()
585
+ .format('YYYY-MM-DD')
586
+ .raw()
587
+ .empty('')
588
+ .description('Latest date of allowed date range for date inputs'),
579
589
  customValidationMessage: Joi.string()
580
590
  .trim()
581
591
  .allow('')
@@ -1,4 +1,5 @@
1
- import Joi, { type ArraySchema, type GetRuleOptions } from 'joi'
1
+ import JoiDate from '@joi/date'
2
+ import JoiBase, { type ArraySchema, type GetRuleOptions } from 'joi'
2
3
 
3
4
  import { rtrimOnly } from '~/src/common/rtrim-only.js'
4
5
  import {
@@ -23,6 +24,8 @@ import {
23
24
  } from '~/src/form/form-editor/types.js'
24
25
  import { preventUnicodeInEmail } from '~/src/form/utils/prevent-unicode.js'
25
26
 
27
+ const Joi = JoiBase.extend(JoiDate) as JoiBase.Root
28
+
26
29
  export const emailAddressNoUnicodeSchema = Joi.string()
27
30
  .trim()
28
31
  .email({ tlds: { allow: false } })
@@ -502,11 +505,11 @@ interface DSLSchema<TSchema = Record<string, unknown>[]>
502
505
  keys: (keys: string[]) => DSLSchema<TSchema>
503
506
  }
504
507
 
505
- interface CustomValidator extends Joi.Root {
508
+ interface CustomValidator extends JoiBase.Root {
506
509
  dsv<TSchema>(): DSLSchema<TSchema>
507
510
  }
508
511
 
509
- export const customValidator = Joi.extend((joi: Joi.Root) => {
512
+ export const customValidator = Joi.extend((joi: JoiBase.Root) => {
510
513
  return {
511
514
  type: 'dsv',
512
515
  base: joi.array(),
@@ -202,6 +202,16 @@ export interface FormEditor {
202
202
  */
203
203
  maxPast: string
204
204
 
205
+ /**
206
+ * The earliest date in a date range that users can enter (YYYY-MM-DD)
207
+ */
208
+ earliestDate: string
209
+
210
+ /**
211
+ * The latest date in a date range that users can enter (YYYY-MM-DD)
212
+ */
213
+ latestDate: string
214
+
205
215
  /**
206
216
  * The exact number of files to upload
207
217
  */
@@ -455,6 +465,8 @@ export type FormEditorInputQuestion = Pick<
455
465
  | 'max'
456
466
  | 'maxFuture'
457
467
  | 'maxPast'
468
+ | 'earliestDate'
469
+ | 'latestDate'
458
470
  | 'exactFiles'
459
471
  | 'minFiles'
460
472
  | 'maxFiles'
@@ -1,7 +1,8 @@
1
1
  export enum FormMetricType {
2
2
  TotalsMetric = 'totals-metric',
3
3
  OverviewMetric = 'overview-metric',
4
- TimelineMetric = 'timeline-metric'
4
+ TimelineMetric = 'timeline-metric',
5
+ DrilldownMetric = 'drilldown-metric'
5
6
  }
6
7
 
7
8
  export enum FormMetricName {
@@ -49,6 +49,15 @@ export interface FormTimelineMetric {
49
49
  createdAt: Date
50
50
  }
51
51
 
52
+ export interface FormDrilldownMetric {
53
+ type: FormMetricType.DrilldownMetric
54
+ formId: string
55
+ metricName: FormMetricName
56
+ metricValue: number
57
+ periodName: string
58
+ createdAt: Date
59
+ }
60
+
52
61
  export type FormMetric =
53
62
  | FormTotalsMetric
54
63
  | FormOverviewMetric