@defra/forms-model 3.0.711 → 3.0.713

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/README.md CHANGED
@@ -138,13 +138,53 @@ Available schema files include:
138
138
 
139
139
  ##### Common Schemas
140
140
 
141
- - `search-options-schema.json` - Search options validation
142
- - `query-options-schema.json` - Query options validation
141
+ - `search-options-schema-ui.json` - Search options validation (forms-designer)
142
+ - `search-options-schema-manager.json` - Search options validation (forms-manager)
143
+ - `query-options-schema-ui.json` - Query options validation (forms-designer)
144
+ - `query-options-schema-manager.json` - Query options validation (forms-manager)
143
145
  - `pagination-options-schema.json` - Pagination options validation
144
146
  - `sorting-options-schema.json` - Sorting options validation
145
147
 
146
148
  ## Development
147
149
 
150
+ This package was previously developed as the `model` workspace of [forms-designer](https://github.com/DEFRA/forms-designer).
151
+
152
+ ### Setup
153
+
154
+ ```shell
155
+ nvm use
156
+ npm install
157
+ npm run build
158
+ ```
159
+
160
+ ### Common commands
161
+
162
+ | Command | Description |
163
+ | ---------------- | ---------------------------------------------------------------- |
164
+ | `npm run build` | Build the type declarations, JavaScript modules and JSON schemas |
165
+ | `npm run lint` | Run EditorConfig, ESLint and TypeScript checks |
166
+ | `npm run format` | Format files with Prettier |
167
+ | `npm test` | Run the unit tests with coverage |
168
+
169
+ ### Testing changes in a consuming service
170
+
171
+ To test unpublished changes in a consuming service (for example forms-designer), build this package and link it:
172
+
173
+ ```shell
174
+ # In forms-model
175
+ npm run build
176
+ npm link
177
+
178
+ # In the consuming service
179
+ npm link @defra/forms-model
180
+ ```
181
+
182
+ Run `npm run build` in forms-model after each change so that the consuming service picks up the new `dist` output. Run `npm unlink @defra/forms-model && npm install` in the consuming service to return to the published version.
183
+
184
+ ### Publishing
185
+
186
+ Merging to `main` with changes to `src/`, `scripts/`, `babel.config.*` or `.browserslistrc` runs the [Publish](.github/workflows/publish.yml) workflow, which increments the patch version and publishes the package to npm.
187
+
148
188
  ### Test Coverage
149
189
 
150
190
  Unit test coverage threshold, code coverage below which build will fail is set by using jest config, at the moment line coverage threshold is set as 92%, see [jest.config.js](jest.config.js)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.711",
3
+ "version": "3.0.713",
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,7 +29,16 @@
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": {
@@ -41,10 +49,34 @@
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",
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",
45
72
  "joi": "^17.13.4",
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
82
  "joi": "^17.0.0"
@@ -52,5 +84,8 @@
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
+ }