@defra/forms-model 3.0.711 → 4.0.1

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.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.711",
3
+ "version": "4.0.1",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
- "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
5
+ "homepage": "https://github.com/DEFRA/forms-model#readme",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "main": "dist/module/index.js",
8
8
  "exports": {
@@ -19,8 +19,7 @@
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/DEFRA/forms-designer.git",
23
- "directory": "model"
22
+ "url": "git+https://github.com/DEFRA/forms-model.git"
24
23
  },
25
24
  "license": "OGL-UK-3.0",
26
25
  "sideEffects": false,
@@ -30,27 +29,63 @@
30
29
  "build:node": "babel --delete-dir-on-start --extensions \".ts,.js\" --ignore \"**/*.test.*\" --copy-files --no-copy-ignored --source-maps --out-dir ./dist/module ./src",
31
30
  "build:types": "tsc --build --force tsconfig.build.json && tsc-alias --project tsconfig.build.json",
32
31
  "build:schemas": "node scripts/generate-schemas.js",
32
+ "format": "npm run format:check -- --write",
33
+ "format:check": "prettier --cache --cache-location .cache/prettier --cache-strategy content --check \"**/*.{cjs,js,json,md,mjs,ts}\"",
34
+ "lint": "npm run lint:editorconfig && npm run lint:js && npm run lint:types",
35
+ "lint:editorconfig": "editorconfig-checker",
36
+ "lint:fix": "npm run lint:js -- --fix",
37
+ "lint:js": "eslint --cache --cache-location .cache/eslint --cache-strategy content --color .",
38
+ "lint:types": "tsc --build tsconfig.json",
39
+ "prepare": "husky || true",
33
40
  "test": "jest --color --coverage --verbose",
41
+ "test:changed": "jest --coverage --changedSince=origin/main --coverageReporters=text",
34
42
  "test:watch": "jest --color --watch"
35
43
  },
36
44
  "dependencies": {
37
- "@joi/date": "^2.1.1",
45
+ "@joi/date": "^3.0.0",
38
46
  "marked": "^15.0.12",
39
47
  "nanoid": "^5.0.7",
40
48
  "slug": "^11.0.0",
41
49
  "uuid": "^11.1.0"
42
50
  },
43
51
  "devDependencies": {
52
+ "@babel/cli": "^7.29.7",
53
+ "@babel/core": "^7.29.7",
54
+ "@babel/preset-env": "^7.29.7",
55
+ "@babel/preset-typescript": "^7.29.7",
56
+ "@types/jest": "^29.5.14",
57
+ "@types/node": "^25.9.1",
44
58
  "@types/slug": "^5.0.9",
45
- "joi": "^17.13.4",
59
+ "@typescript-eslint/eslint-plugin": "^8.34.0",
60
+ "@typescript-eslint/parser": "^8.27.0",
61
+ "babel-plugin-module-resolver": "^5.0.3",
62
+ "babel-plugin-replace-import-extension": "^1.1.5",
63
+ "babel-plugin-transform-import-meta": "^2.3.3",
64
+ "editorconfig-checker": "^6.2.0",
65
+ "eslint": "^9.39.3",
66
+ "eslint-config-prettier": "^10.1.8",
67
+ "eslint-plugin-jest": "^29.15.2",
68
+ "eslint-plugin-jsdoc": "^63.0.1",
69
+ "globals": "^17.6.0",
70
+ "husky": "^9.1.7",
71
+ "jest": "^29.7.0",
72
+ "joi": "^18.2.9",
46
73
  "joi-to-json": "^4.3.2",
47
- "tsc-alias": "^1.8.11"
74
+ "lint-staged": "^17.0.7",
75
+ "neostandard": "^0.12.2",
76
+ "prettier": "^3.8.3",
77
+ "tsc-alias": "^1.8.11",
78
+ "typescript": "^5.8.2",
79
+ "typescript-eslint": "^8.56.1"
48
80
  },
49
81
  "peerDependencies": {
50
- "joi": "^17.0.0"
82
+ "joi": "^18.0.0"
51
83
  },
52
84
  "engines": {
53
85
  "node": "^24.19.0",
54
86
  "npm": "^11.17.0 || >=12.0.2"
87
+ },
88
+ "allowScripts": {
89
+ "unrs-resolver": true
55
90
  }
56
91
  }
@@ -0,0 +1,99 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "page": {
5
+ "type": "number",
6
+ "description": "Current page number, starting from 1",
7
+ "default": 1,
8
+ "exclusiveMinimum": 0,
9
+ "minimum": 1,
10
+ "title": "Page"
11
+ },
12
+ "perPage": {
13
+ "type": "number",
14
+ "description": "Number of items to display per page, between 1 and 200",
15
+ "default": 24,
16
+ "exclusiveMinimum": 0,
17
+ "minimum": 1,
18
+ "maximum": 200,
19
+ "title": "Per Page"
20
+ },
21
+ "sortBy": {
22
+ "type": "string",
23
+ "description": "Field to sort results by",
24
+ "enum": [
25
+ "updatedAt",
26
+ "title"
27
+ ],
28
+ "title": "Sort By"
29
+ },
30
+ "order": {
31
+ "type": "string",
32
+ "description": "Sort order (ascending or descending)",
33
+ "enum": [
34
+ "asc",
35
+ "desc"
36
+ ],
37
+ "title": "Order"
38
+ },
39
+ "title": {
40
+ "type": "string",
41
+ "description": "Search by form title, empty string matches all",
42
+ "default": "",
43
+ "maxLength": 255,
44
+ "title": "Title"
45
+ },
46
+ "author": {
47
+ "type": "string",
48
+ "description": "Search by form author, empty string matches all",
49
+ "default": "",
50
+ "maxLength": 100,
51
+ "title": "Author"
52
+ },
53
+ "organisations": {
54
+ "type": "array",
55
+ "description": "Filter by organisation(s), empty array matches all",
56
+ "default": [],
57
+ "items": {
58
+ "type": "string",
59
+ "enum": [
60
+ "Animal and Plant Health Agency – APHA",
61
+ "Centre for Environment, Fisheries and Aquaculture Science – Cefas",
62
+ "Defra",
63
+ "Environment Agency",
64
+ "Forestry Commission",
65
+ "Marine Management Organisation – MMO",
66
+ "Natural England",
67
+ "Rural Payments Agency – RPA",
68
+ "Veterinary Medicines Directorate – VMD"
69
+ ],
70
+ "title": "Organisations Item"
71
+ },
72
+ "title": "Organisations"
73
+ },
74
+ "offline": {
75
+ "type": "boolean",
76
+ "description": "Filter by forms that are offline",
77
+ "title": "Offline"
78
+ },
79
+ "status": {
80
+ "type": "array",
81
+ "description": "Filter by form status(es), empty array matches all",
82
+ "default": [],
83
+ "items": {
84
+ "type": "string",
85
+ "enum": [
86
+ "draft",
87
+ "live"
88
+ ],
89
+ "title": "Status Item"
90
+ },
91
+ "title": "Status"
92
+ }
93
+ },
94
+ "additionalProperties": false,
95
+ "$schema": "http://json-schema.org/draft-07/schema#",
96
+ "title": "Query Options Schema Manager",
97
+ "description": "JSON Schema for validating Query Options Schema Manager in Defra forms",
98
+ "$id": "@defra/forms-model/schemas/query-options-schema-manager.json"
99
+ }
@@ -0,0 +1,100 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "page": {
5
+ "type": "number",
6
+ "description": "Current page number, starting from 1",
7
+ "default": 1,
8
+ "exclusiveMinimum": 0,
9
+ "minimum": 1,
10
+ "title": "Page"
11
+ },
12
+ "perPage": {
13
+ "type": "number",
14
+ "description": "Number of items to display per page, between 1 and 200",
15
+ "default": 24,
16
+ "exclusiveMinimum": 0,
17
+ "minimum": 1,
18
+ "maximum": 200,
19
+ "title": "Per Page"
20
+ },
21
+ "sortBy": {
22
+ "type": "string",
23
+ "description": "Field to sort results by",
24
+ "enum": [
25
+ "updatedAt",
26
+ "title"
27
+ ],
28
+ "title": "Sort By"
29
+ },
30
+ "order": {
31
+ "type": "string",
32
+ "description": "Sort order (ascending or descending)",
33
+ "enum": [
34
+ "asc",
35
+ "desc"
36
+ ],
37
+ "title": "Order"
38
+ },
39
+ "title": {
40
+ "type": "string",
41
+ "description": "Search by form title, empty string matches all",
42
+ "default": "",
43
+ "maxLength": 255,
44
+ "title": "Title"
45
+ },
46
+ "author": {
47
+ "type": "string",
48
+ "description": "Search by form author, empty string matches all",
49
+ "default": "",
50
+ "maxLength": 100,
51
+ "title": "Author"
52
+ },
53
+ "organisations": {
54
+ "type": "array",
55
+ "description": "Filter by organisation(s), empty array matches all",
56
+ "default": [],
57
+ "items": {
58
+ "type": "string",
59
+ "enum": [
60
+ "Animal and Plant Health Agency – APHA",
61
+ "Centre for Environment, Fisheries and Aquaculture Science – Cefas",
62
+ "Defra",
63
+ "Environment Agency",
64
+ "Forestry Commission",
65
+ "Marine Management Organisation – MMO",
66
+ "Natural England",
67
+ "Rural Payments Agency – RPA",
68
+ "Veterinary Medicines Directorate – VMD"
69
+ ],
70
+ "title": "Organisations Item"
71
+ },
72
+ "title": "Organisations"
73
+ },
74
+ "offline": {
75
+ "type": "boolean",
76
+ "description": "Filter by forms that are offline",
77
+ "title": "Offline"
78
+ },
79
+ "status": {
80
+ "type": "array",
81
+ "description": "Filter by form status(es), empty array matches all",
82
+ "default": [],
83
+ "items": {
84
+ "type": "string",
85
+ "enum": [
86
+ "draft",
87
+ "live",
88
+ "offline"
89
+ ],
90
+ "title": "Status Item"
91
+ },
92
+ "title": "Status"
93
+ }
94
+ },
95
+ "additionalProperties": false,
96
+ "$schema": "http://json-schema.org/draft-07/schema#",
97
+ "title": "Query Options Schema Ui",
98
+ "description": "JSON Schema for validating Query Options Schema Ui in Defra forms",
99
+ "$id": "@defra/forms-model/schemas/query-options-schema-ui.json"
100
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "title": {
5
+ "type": "string",
6
+ "description": "Search by form title, empty string matches all",
7
+ "default": "",
8
+ "maxLength": 255,
9
+ "title": "Title"
10
+ },
11
+ "author": {
12
+ "type": "string",
13
+ "description": "Search by form author, empty string matches all",
14
+ "default": "",
15
+ "maxLength": 100,
16
+ "title": "Author"
17
+ },
18
+ "organisations": {
19
+ "type": "array",
20
+ "description": "Filter by organisation(s), empty array matches all",
21
+ "default": [],
22
+ "items": {
23
+ "type": "string",
24
+ "enum": [
25
+ "Animal and Plant Health Agency – APHA",
26
+ "Centre for Environment, Fisheries and Aquaculture Science – Cefas",
27
+ "Defra",
28
+ "Environment Agency",
29
+ "Forestry Commission",
30
+ "Marine Management Organisation – MMO",
31
+ "Natural England",
32
+ "Rural Payments Agency – RPA",
33
+ "Veterinary Medicines Directorate – VMD"
34
+ ],
35
+ "title": "Organisations Item"
36
+ },
37
+ "title": "Organisations"
38
+ },
39
+ "offline": {
40
+ "type": "boolean",
41
+ "description": "Filter by forms that are offline",
42
+ "title": "Offline"
43
+ },
44
+ "status": {
45
+ "type": "array",
46
+ "description": "Filter by form status(es), empty array matches all",
47
+ "default": [],
48
+ "items": {
49
+ "type": "string",
50
+ "enum": [
51
+ "draft",
52
+ "live"
53
+ ],
54
+ "title": "Status Item"
55
+ },
56
+ "title": "Status"
57
+ }
58
+ },
59
+ "additionalProperties": false,
60
+ "$schema": "http://json-schema.org/draft-07/schema#",
61
+ "title": "Search Options Schema Manager",
62
+ "description": "JSON Schema for validating Search Options Schema Manager in Defra forms",
63
+ "$id": "@defra/forms-model/schemas/search-options-schema-manager.json"
64
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "title": {
5
+ "type": "string",
6
+ "description": "Search by form title, empty string matches all",
7
+ "default": "",
8
+ "maxLength": 255,
9
+ "title": "Title"
10
+ },
11
+ "author": {
12
+ "type": "string",
13
+ "description": "Search by form author, empty string matches all",
14
+ "default": "",
15
+ "maxLength": 100,
16
+ "title": "Author"
17
+ },
18
+ "organisations": {
19
+ "type": "array",
20
+ "description": "Filter by organisation(s), empty array matches all",
21
+ "default": [],
22
+ "items": {
23
+ "type": "string",
24
+ "enum": [
25
+ "Animal and Plant Health Agency – APHA",
26
+ "Centre for Environment, Fisheries and Aquaculture Science – Cefas",
27
+ "Defra",
28
+ "Environment Agency",
29
+ "Forestry Commission",
30
+ "Marine Management Organisation – MMO",
31
+ "Natural England",
32
+ "Rural Payments Agency – RPA",
33
+ "Veterinary Medicines Directorate – VMD"
34
+ ],
35
+ "title": "Organisations Item"
36
+ },
37
+ "title": "Organisations"
38
+ },
39
+ "offline": {
40
+ "type": "boolean",
41
+ "description": "Filter by forms that are offline",
42
+ "title": "Offline"
43
+ },
44
+ "status": {
45
+ "type": "array",
46
+ "description": "Filter by form status(es), empty array matches all",
47
+ "default": [],
48
+ "items": {
49
+ "type": "string",
50
+ "enum": [
51
+ "draft",
52
+ "live",
53
+ "offline"
54
+ ],
55
+ "title": "Status Item"
56
+ },
57
+ "title": "Status"
58
+ }
59
+ },
60
+ "additionalProperties": false,
61
+ "$schema": "http://json-schema.org/draft-07/schema#",
62
+ "title": "Search Options Schema Ui",
63
+ "description": "JSON Schema for validating Search Options Schema Ui in Defra forms",
64
+ "$id": "@defra/forms-model/schemas/search-options-schema-ui.json"
65
+ }
@@ -1,4 +1,4 @@
1
- import JoiDate from '@joi/date'
1
+ import { JoiDate } from '@joi/date'
2
2
  import JoiBase, { type CustomHelpers, type LanguageMessages } from 'joi'
3
3
  import { v4 as uuidV4 } from 'uuid'
4
4
 
@@ -1,4 +1,4 @@
1
- import JoiDate from '@joi/date'
1
+ import { JoiDate } from '@joi/date'
2
2
  import JoiBase, { type ArraySchema, type GetRuleOptions } from 'joi'
3
3
 
4
4
  import { rtrimOnly } from '~/src/common/rtrim-only.js'
@@ -176,7 +176,8 @@ export const saveAndExitV2MessageData = Joi.object<SaveAndExitV2MessageData>()
176
176
  title: Joi.string().required(),
177
177
  status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),
178
178
  isPreview: Joi.boolean().required(),
179
- baseUrl: Joi.string().required()
179
+ baseUrl: Joi.string().required(),
180
+ language: Joi.string().optional()
180
181
  }).label('SaveAndExitForm'),
181
182
  email: Joi.string().required(),
182
183
  auth: Joi.object({
@@ -187,6 +187,7 @@ export interface SaveAndExitV2MessageData {
187
187
  status: FormStatus
188
188
  isPreview: boolean
189
189
  baseUrl: string
190
+ language?: string
190
191
  }
191
192
  email: string
192
193
  auth: {
@@ -245,6 +246,7 @@ export interface SaveAndExitV2Record {
245
246
  status: FormStatus
246
247
  isPreview: boolean
247
248
  baseUrl: string
249
+ language?: string
248
250
  }
249
251
  email: string
250
252
  auth: {