@defra/forms-model 3.0.167 → 3.0.169

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 (60) hide show
  1. package/dist/module/components/component-types.js +47 -46
  2. package/dist/module/components/component-types.js.map +1 -1
  3. package/dist/module/components/enums.js +31 -24
  4. package/dist/module/components/enums.js.map +1 -1
  5. package/dist/module/components/index.js +1 -2
  6. package/dist/module/components/index.js.map +1 -1
  7. package/dist/module/components/types.js.map +1 -1
  8. package/dist/module/conditions/condition-field.js.map +1 -1
  9. package/dist/module/conditions/condition-operators.js +12 -11
  10. package/dist/module/conditions/condition-operators.js.map +1 -1
  11. package/dist/module/conditions/enums.js +5 -0
  12. package/dist/module/conditions/enums.js.map +1 -1
  13. package/dist/module/conditions/index.js +1 -1
  14. package/dist/module/conditions/index.js.map +1 -1
  15. package/dist/module/form/form-definition/index.js +10 -4
  16. package/dist/module/form/form-definition/index.js.map +1 -1
  17. package/dist/module/form/form-definition/types.js.map +1 -1
  18. package/dist/module/index.js +0 -1
  19. package/dist/module/index.js.map +1 -1
  20. package/dist/types/components/component-types.d.ts.map +1 -1
  21. package/dist/types/components/enums.d.ts +8 -2
  22. package/dist/types/components/enums.d.ts.map +1 -1
  23. package/dist/types/components/index.d.ts +1 -2
  24. package/dist/types/components/index.d.ts.map +1 -1
  25. package/dist/types/components/types.d.ts +46 -47
  26. package/dist/types/components/types.d.ts.map +1 -1
  27. package/dist/types/conditions/condition-field.d.ts +1 -1
  28. package/dist/types/conditions/condition-operators.d.ts +2 -1
  29. package/dist/types/conditions/condition-operators.d.ts.map +1 -1
  30. package/dist/types/conditions/enums.d.ts +4 -0
  31. package/dist/types/conditions/enums.d.ts.map +1 -1
  32. package/dist/types/conditions/index.d.ts +1 -1
  33. package/dist/types/conditions/index.d.ts.map +1 -1
  34. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  35. package/dist/types/form/form-definition/types.d.ts +1 -0
  36. package/dist/types/form/form-definition/types.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +0 -1
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/components/component-types.ts +47 -46
  41. package/src/components/enums.ts +9 -2
  42. package/src/components/index.ts +1 -2
  43. package/src/components/types.ts +68 -71
  44. package/src/conditions/condition-field.ts +1 -1
  45. package/src/conditions/condition-operators.ts +19 -15
  46. package/src/conditions/enums.ts +5 -0
  47. package/src/conditions/index.ts +1 -1
  48. package/src/form/form-definition/index.ts +25 -12
  49. package/src/form/form-definition/types.ts +1 -0
  50. package/src/index.ts +0 -1
  51. package/dist/module/components/conditional-component-types.js +0 -10
  52. package/dist/module/components/conditional-component-types.js.map +0 -1
  53. package/dist/module/form/form-configuration/index.js +0 -16
  54. package/dist/module/form/form-configuration/index.js.map +0 -1
  55. package/dist/types/components/conditional-component-types.d.ts +0 -3
  56. package/dist/types/components/conditional-component-types.d.ts.map +0 -1
  57. package/dist/types/form/form-configuration/index.d.ts +0 -8
  58. package/dist/types/form/form-configuration/index.d.ts.map +0 -1
  59. package/src/components/conditional-component-types.ts +0 -14
  60. package/src/form/form-configuration/index.ts +0 -21
@@ -1,8 +1,13 @@
1
1
  import Joi from 'joi'
2
2
 
3
+ import {
4
+ type ComponentSubType,
5
+ type ComponentType
6
+ } from '~/src/components/enums.js'
3
7
  import { type ComponentDef } from '~/src/components/types.js'
4
8
  import {
5
9
  type ConditionRawData,
10
+ type ConditionWrapperValue,
6
11
  type ConfirmationPage,
7
12
  type EmailOutputConfiguration,
8
13
  type FormDefinition,
@@ -75,21 +80,24 @@ const conditionGroupSchema = Joi.object().keys({
75
80
  )
76
81
  })
77
82
 
78
- const conditionsModelSchema = Joi.object().keys({
79
- name: Joi.string().required(),
80
- conditions: Joi.array().items(
81
- Joi.alternatives().try(
82
- conditionSchema,
83
- conditionRefSchema,
84
- conditionGroupSchema
83
+ const conditionsModelSchema = Joi.alternatives<ConditionWrapperValue>().try(
84
+ Joi.string(),
85
+ Joi.object().keys({
86
+ name: Joi.string().required(),
87
+ conditions: Joi.array().items(
88
+ Joi.alternatives().try(
89
+ conditionSchema,
90
+ conditionRefSchema,
91
+ conditionGroupSchema
92
+ )
85
93
  )
86
- )
87
- })
94
+ })
95
+ )
88
96
 
89
97
  const conditionsSchema = Joi.object<ConditionRawData>().keys({
90
98
  name: Joi.string().required(),
91
99
  displayName: Joi.string(),
92
- value: Joi.alternatives().try(Joi.string(), conditionsModelSchema).required()
100
+ value: conditionsModelSchema.required()
93
101
  })
94
102
 
95
103
  const localisedString = Joi.alternatives().try(
@@ -99,7 +107,8 @@ const localisedString = Joi.alternatives().try(
99
107
 
100
108
  export const componentSchema = Joi.object<ComponentDef>()
101
109
  .keys({
102
- type: Joi.string().required(),
110
+ subType: Joi.string<ComponentSubType>().optional(),
111
+ type: Joi.string<ComponentType>().required(),
103
112
  name: Joi.string(),
104
113
  title: localisedString,
105
114
  hint: localisedString.optional(),
@@ -260,7 +269,11 @@ export const formDefinitionSchema = Joi.object<FormDefinition>()
260
269
  outputs: Joi.array<Output>().items(outputSchema),
261
270
  skipSummary: Joi.boolean().optional().default(false),
262
271
  phaseBanner: phaseBannerSchema,
263
- specialPages: specialPagesSchema.optional()
272
+ specialPages: specialPagesSchema.optional(),
273
+ outputEmail: Joi.string()
274
+ .email({ tlds: { allow: ['uk'] } })
275
+ .trim()
276
+ .optional()
264
277
  })
265
278
 
266
279
  // Maintain compatibility with legacy named export
@@ -152,4 +152,5 @@ export interface FormDefinition {
152
152
  declaration?: string
153
153
  metadata?: Record<string, unknown>
154
154
  specialPages?: SpecialPages
155
+ outputEmail?: string
155
156
  }
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from '~/src/data-model/index.js'
2
- export * from '~/src/form/form-configuration/index.js'
3
2
  export * from '~/src/form/form-definition/index.js'
4
3
  export * from '~/src/form/form-metadata/index.js'
5
4
  export * from '~/src/components/index.js'
@@ -1,10 +0,0 @@
1
- export const ConditionalComponentTypes = [{
2
- name: 'TextField',
3
- title: 'Text field',
4
- subType: 'field'
5
- }, {
6
- name: 'NumberField',
7
- title: 'Number field',
8
- subType: 'field'
9
- }];
10
- //# sourceMappingURL=conditional-component-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conditional-component-types.js","names":["ConditionalComponentTypes","name","title","subType"],"sources":["../../../src/components/conditional-component-types.ts"],"sourcesContent":["import { type ConditionalComponent } from '~/src/components/types.js'\n\nexport const ConditionalComponentTypes: ConditionalComponent[] = [\n {\n name: 'TextField',\n title: 'Text field',\n subType: 'field'\n },\n {\n name: 'NumberField',\n title: 'Number field',\n subType: 'field'\n }\n]\n"],"mappings":"AAEA,OAAO,MAAMA,yBAAiD,GAAG,CAC/D;EACEC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE;AACX,CAAC,EACD;EACEF,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,cAAc;EACrBC,OAAO,EAAE;AACX,CAAC,CACF","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- export class FormConfiguration {
2
- Key;
3
- DisplayName;
4
- LastModified;
5
- feedbackForm;
6
- constructor(Key, DisplayName, LastModified, feedbackForm) {
7
- if (!Key) {
8
- throw Error('Form configuration must have a key');
9
- }
10
- this.Key = Key;
11
- this.DisplayName = DisplayName || Key;
12
- this.LastModified = LastModified;
13
- this.feedbackForm = feedbackForm || false;
14
- }
15
- }
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["FormConfiguration","Key","DisplayName","LastModified","feedbackForm","constructor","Error"],"sources":["../../../../src/form/form-configuration/index.ts"],"sourcesContent":["export class FormConfiguration {\n Key: string\n DisplayName: string\n LastModified: string | undefined\n feedbackForm: boolean | undefined\n\n constructor(\n Key: string,\n DisplayName?: string,\n LastModified?: string,\n feedbackForm?: boolean\n ) {\n if (!Key) {\n throw Error('Form configuration must have a key')\n }\n this.Key = Key\n this.DisplayName = DisplayName || Key\n this.LastModified = LastModified\n this.feedbackForm = feedbackForm || false\n }\n}\n"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,CAAC;EAC7BC,GAAG;EACHC,WAAW;EACXC,YAAY;EACZC,YAAY;EAEZC,WAAWA,CACTJ,GAAW,EACXC,WAAoB,EACpBC,YAAqB,EACrBC,YAAsB,EACtB;IACA,IAAI,CAACH,GAAG,EAAE;MACR,MAAMK,KAAK,CAAC,oCAAoC,CAAC;IACnD;IACA,IAAI,CAACL,GAAG,GAAGA,GAAG;IACd,IAAI,CAACC,WAAW,GAAGA,WAAW,IAAID,GAAG;IACrC,IAAI,CAACE,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,YAAY,GAAGA,YAAY,IAAI,KAAK;EAC3C;AACF","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { type ConditionalComponent } from '../components/types.js';
2
- export declare const ConditionalComponentTypes: ConditionalComponent[];
3
- //# sourceMappingURL=conditional-component-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conditional-component-types.d.ts","sourceRoot":"","sources":["../../../src/components/conditional-component-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE,eAAO,MAAM,yBAAyB,EAAE,oBAAoB,EAW3D,CAAA"}
@@ -1,8 +0,0 @@
1
- export declare class FormConfiguration {
2
- Key: string;
3
- DisplayName: string;
4
- LastModified: string | undefined;
5
- feedbackForm: boolean | undefined;
6
- constructor(Key: string, DisplayName?: string, LastModified?: string, feedbackForm?: boolean);
7
- }
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-configuration/index.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAiB;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,YAAY,EAAE,OAAO,GAAG,SAAS,CAAA;gBAG/B,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,OAAO;CAUzB"}
@@ -1,14 +0,0 @@
1
- import { type ConditionalComponent } from '~/src/components/types.js'
2
-
3
- export const ConditionalComponentTypes: ConditionalComponent[] = [
4
- {
5
- name: 'TextField',
6
- title: 'Text field',
7
- subType: 'field'
8
- },
9
- {
10
- name: 'NumberField',
11
- title: 'Number field',
12
- subType: 'field'
13
- }
14
- ]
@@ -1,21 +0,0 @@
1
- export class FormConfiguration {
2
- Key: string
3
- DisplayName: string
4
- LastModified: string | undefined
5
- feedbackForm: boolean | undefined
6
-
7
- constructor(
8
- Key: string,
9
- DisplayName?: string,
10
- LastModified?: string,
11
- feedbackForm?: boolean
12
- ) {
13
- if (!Key) {
14
- throw Error('Form configuration must have a key')
15
- }
16
- this.Key = Key
17
- this.DisplayName = DisplayName || Key
18
- this.LastModified = LastModified
19
- this.feedbackForm = feedbackForm || false
20
- }
21
- }