@planning-inspectorate/dynamic-forms 3.10.8 → 3.10.10

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 (261) hide show
  1. package/move-types.js +6 -8
  2. package/package.json +1 -1
  3. package/src/components/boolean/question.js +1 -1
  4. package/src/components/manage-list/utils.js +4 -4
  5. package/src/components/radio/question.js +1 -1
  6. package/src/components/unit-option-entry/question.js +2 -2
  7. package/src/components/utils/question-has-answer.js +1 -1
  8. package/src/index.js +1 -0
  9. package/src/journey/journey-response.js +2 -2
  10. package/src/journey/journey-types.js +1 -0
  11. package/src/journey/journey.js +17 -23
  12. package/src/questions/create-questions.js +1 -1
  13. package/src/questions/options-question.js +7 -3
  14. package/src/questions/question-types.d.ts +6 -0
  15. package/src/questions/question.js +18 -21
  16. package/src/validator/valid-option-validator.js +1 -5
  17. package/tsconfig.json +1 -1
  18. package/types/commitlint.config.d.ts +0 -7
  19. package/types/commitlint.config.d.ts.map +0 -1
  20. package/types/eslint.config.d.ts +0 -95
  21. package/types/eslint.config.d.ts.map +0 -1
  22. package/types/move-types.d.ts +0 -2
  23. package/types/move-types.d.ts.map +0 -1
  24. package/types/src/components/address/question.d.ts +0 -36
  25. package/types/src/components/address/question.d.ts.map +0 -1
  26. package/types/src/components/address/question.test.d.ts +0 -2
  27. package/types/src/components/address/question.test.d.ts.map +0 -1
  28. package/types/src/components/boolean/question.d.ts +0 -50
  29. package/types/src/components/boolean/question.d.ts.map +0 -1
  30. package/types/src/components/boolean/question.test.d.ts +0 -2
  31. package/types/src/components/boolean/question.test.d.ts.map +0 -1
  32. package/types/src/components/checkbox/question.d.ts +0 -52
  33. package/types/src/components/checkbox/question.d.ts.map +0 -1
  34. package/types/src/components/checkbox/question.test.d.ts +0 -2
  35. package/types/src/components/checkbox/question.test.d.ts.map +0 -1
  36. package/types/src/components/date/question.d.ts +0 -23
  37. package/types/src/components/date/question.d.ts.map +0 -1
  38. package/types/src/components/date/question.test.d.ts +0 -2
  39. package/types/src/components/date/question.test.d.ts.map +0 -1
  40. package/types/src/components/date-period/question.d.ts +0 -35
  41. package/types/src/components/date-period/question.d.ts.map +0 -1
  42. package/types/src/components/date-period/question.test.d.ts +0 -2
  43. package/types/src/components/date-period/question.test.d.ts.map +0 -1
  44. package/types/src/components/date-time/question.d.ts +0 -25
  45. package/types/src/components/date-time/question.d.ts.map +0 -1
  46. package/types/src/components/date-time/question.test.d.ts +0 -2
  47. package/types/src/components/date-time/question.test.d.ts.map +0 -1
  48. package/types/src/components/email/question.d.ts +0 -31
  49. package/types/src/components/email/question.d.ts.map +0 -1
  50. package/types/src/components/email/question.test.d.ts +0 -2
  51. package/types/src/components/email/question.test.d.ts.map +0 -1
  52. package/types/src/components/identifier/question.d.ts +0 -16
  53. package/types/src/components/identifier/question.d.ts.map +0 -1
  54. package/types/src/components/identifier/question.test.d.ts +0 -2
  55. package/types/src/components/identifier/question.test.d.ts.map +0 -1
  56. package/types/src/components/manage-list/manage-list-actions.d.ts +0 -10
  57. package/types/src/components/manage-list/manage-list-actions.d.ts.map +0 -1
  58. package/types/src/components/manage-list/manage-list-section.d.ts +0 -16
  59. package/types/src/components/manage-list/manage-list-section.d.ts.map +0 -1
  60. package/types/src/components/manage-list/manage-list-section.test.d.ts +0 -2
  61. package/types/src/components/manage-list/manage-list-section.test.d.ts.map +0 -1
  62. package/types/src/components/manage-list/question.d.ts +0 -49
  63. package/types/src/components/manage-list/question.d.ts.map +0 -1
  64. package/types/src/components/manage-list/question.test.d.ts +0 -2
  65. package/types/src/components/manage-list/question.test.d.ts.map +0 -1
  66. package/types/src/components/manage-list/utils.d.ts +0 -18
  67. package/types/src/components/manage-list/utils.d.ts.map +0 -1
  68. package/types/src/components/manage-list/utils.test.d.ts +0 -2
  69. package/types/src/components/manage-list/utils.test.d.ts.map +0 -1
  70. package/types/src/components/multi-field-input/question.d.ts +0 -61
  71. package/types/src/components/multi-field-input/question.d.ts.map +0 -1
  72. package/types/src/components/multi-field-input/question.test.d.ts +0 -2
  73. package/types/src/components/multi-field-input/question.test.d.ts.map +0 -1
  74. package/types/src/components/number-entry/question.d.ts +0 -38
  75. package/types/src/components/number-entry/question.d.ts.map +0 -1
  76. package/types/src/components/radio/question.d.ts +0 -54
  77. package/types/src/components/radio/question.d.ts.map +0 -1
  78. package/types/src/components/radio/question.test.d.ts +0 -2
  79. package/types/src/components/radio/question.test.d.ts.map +0 -1
  80. package/types/src/components/select/question.d.ts +0 -55
  81. package/types/src/components/select/question.d.ts.map +0 -1
  82. package/types/src/components/select/question.test.d.ts +0 -2
  83. package/types/src/components/select/question.test.d.ts.map +0 -1
  84. package/types/src/components/single-line-input/question.d.ts +0 -19
  85. package/types/src/components/single-line-input/question.d.ts.map +0 -1
  86. package/types/src/components/single-line-input/question.test.d.ts +0 -2
  87. package/types/src/components/single-line-input/question.test.d.ts.map +0 -1
  88. package/types/src/components/text-entry/question.d.ts +0 -35
  89. package/types/src/components/text-entry/question.d.ts.map +0 -1
  90. package/types/src/components/text-entry/question.test.d.ts +0 -2
  91. package/types/src/components/text-entry/question.test.d.ts.map +0 -1
  92. package/types/src/components/text-entry-redact/question.d.ts +0 -35
  93. package/types/src/components/text-entry-redact/question.d.ts.map +0 -1
  94. package/types/src/components/text-entry-redact/question.test.d.ts +0 -2
  95. package/types/src/components/text-entry-redact/question.test.d.ts.map +0 -1
  96. package/types/src/components/unit-option-entry/question.d.ts +0 -84
  97. package/types/src/components/unit-option-entry/question.d.ts.map +0 -1
  98. package/types/src/components/unit-option-entry/question.test.d.ts +0 -2
  99. package/types/src/components/unit-option-entry/question.test.d.ts.map +0 -1
  100. package/types/src/components/utils/component-types.d.ts +0 -19
  101. package/types/src/components/utils/component-types.d.ts.map +0 -1
  102. package/types/src/components/utils/persisted-number-answer.d.ts +0 -2
  103. package/types/src/components/utils/persisted-number-answer.d.ts.map +0 -1
  104. package/types/src/components/utils/question-has-answer.d.ts +0 -17
  105. package/types/src/components/utils/question-has-answer.d.ts.map +0 -1
  106. package/types/src/components/utils/question-has-answer.test.d.ts +0 -2
  107. package/types/src/components/utils/question-has-answer.test.d.ts.map +0 -1
  108. package/types/src/components/utils/question-utils.d.ts +0 -15
  109. package/types/src/components/utils/question-utils.d.ts.map +0 -1
  110. package/types/src/components/utils/question-utils.test.d.ts +0 -2
  111. package/types/src/components/utils/question-utils.test.d.ts.map +0 -1
  112. package/types/src/controller.d.ts +0 -75
  113. package/types/src/controller.d.ts.map +0 -1
  114. package/types/src/controller.test.d.ts +0 -2
  115. package/types/src/controller.test.d.ts.map +0 -1
  116. package/types/src/index.d.ts +0 -58
  117. package/types/src/index.d.ts.map +0 -1
  118. package/types/src/index.test.d.ts +0 -2
  119. package/types/src/index.test.d.ts.map +0 -1
  120. package/types/src/journey/journey-response.d.ts +0 -32
  121. package/types/src/journey/journey-response.d.ts.map +0 -1
  122. package/types/src/journey/journey-response.test.d.ts +0 -2
  123. package/types/src/journey/journey-response.test.d.ts.map +0 -1
  124. package/types/src/journey/journey.d.ts +0 -144
  125. package/types/src/journey/journey.d.ts.map +0 -1
  126. package/types/src/journey/journey.test.d.ts +0 -2
  127. package/types/src/journey/journey.test.d.ts.map +0 -1
  128. package/types/src/lib/address-utils.d.ts +0 -6
  129. package/types/src/lib/address-utils.d.ts.map +0 -1
  130. package/types/src/lib/address-utils.test.d.ts +0 -2
  131. package/types/src/lib/address-utils.test.d.ts.map +0 -1
  132. package/types/src/lib/address.d.ts +0 -43
  133. package/types/src/lib/address.d.ts.map +0 -1
  134. package/types/src/lib/address.test.d.ts +0 -2
  135. package/types/src/lib/address.test.d.ts.map +0 -1
  136. package/types/src/lib/date-utils.d.ts +0 -60
  137. package/types/src/lib/date-utils.d.ts.map +0 -1
  138. package/types/src/lib/date-utils.test.d.ts +0 -2
  139. package/types/src/lib/date-utils.test.d.ts.map +0 -1
  140. package/types/src/lib/session-answer-store.d.ts +0 -88
  141. package/types/src/lib/session-answer-store.d.ts.map +0 -1
  142. package/types/src/lib/session-answer-store.test.d.ts +0 -2
  143. package/types/src/lib/session-answer-store.test.d.ts.map +0 -1
  144. package/types/src/lib/utils.d.ts +0 -26
  145. package/types/src/lib/utils.d.ts.map +0 -1
  146. package/types/src/lib/utils.test.d.ts +0 -2
  147. package/types/src/lib/utils.test.d.ts.map +0 -1
  148. package/types/src/lib/uuid.d.ts +0 -7
  149. package/types/src/lib/uuid.d.ts.map +0 -1
  150. package/types/src/lib/uuid.test.d.ts +0 -2
  151. package/types/src/lib/uuid.test.d.ts.map +0 -1
  152. package/types/src/middleware/build-get-journey.d.ts +0 -6
  153. package/types/src/middleware/build-get-journey.d.ts.map +0 -1
  154. package/types/src/middleware/redirect-to-unanswered-question.d.ts +0 -12
  155. package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +0 -1
  156. package/types/src/middleware/redirect-to-unanswered-question.test.d.ts +0 -2
  157. package/types/src/middleware/redirect-to-unanswered-question.test.d.ts.map +0 -1
  158. package/types/src/questions/create-questions.d.ts +0 -21
  159. package/types/src/questions/create-questions.d.ts.map +0 -1
  160. package/types/src/questions/options-question.d.ts +0 -74
  161. package/types/src/questions/options-question.d.ts.map +0 -1
  162. package/types/src/questions/options-question.test.d.ts +0 -2
  163. package/types/src/questions/options-question.test.d.ts.map +0 -1
  164. package/types/src/questions/question-props.d.ts +0 -182
  165. package/types/src/questions/question-props.d.ts.map +0 -1
  166. package/types/src/questions/question-types.d.ts +0 -80
  167. package/types/src/questions/question-types.d.ts.map +0 -1
  168. package/types/src/questions/question.d.ts +0 -278
  169. package/types/src/questions/question.d.ts.map +0 -1
  170. package/types/src/questions/question.test.d.ts +0 -2
  171. package/types/src/questions/question.test.d.ts.map +0 -1
  172. package/types/src/questions/questions.d.ts +0 -3
  173. package/types/src/questions/questions.d.ts.map +0 -1
  174. package/types/src/section.d.ts +0 -107
  175. package/types/src/section.d.ts.map +0 -1
  176. package/types/src/section.test.d.ts +0 -2
  177. package/types/src/section.test.d.ts.map +0 -1
  178. package/types/src/validator/address-validator.d.ts +0 -48
  179. package/types/src/validator/address-validator.d.ts.map +0 -1
  180. package/types/src/validator/address-validator.test.d.ts +0 -2
  181. package/types/src/validator/address-validator.test.d.ts.map +0 -1
  182. package/types/src/validator/base-validator.d.ts +0 -12
  183. package/types/src/validator/base-validator.d.ts.map +0 -1
  184. package/types/src/validator/base-validator.test.d.ts +0 -2
  185. package/types/src/validator/base-validator.test.d.ts.map +0 -1
  186. package/types/src/validator/conditional-required-validator.d.ts +0 -25
  187. package/types/src/validator/conditional-required-validator.d.ts.map +0 -1
  188. package/types/src/validator/conditional-required-validator.test.d.ts +0 -2
  189. package/types/src/validator/conditional-required-validator.test.d.ts.map +0 -1
  190. package/types/src/validator/confirmation-checkbox-validator.d.ts +0 -28
  191. package/types/src/validator/confirmation-checkbox-validator.d.ts.map +0 -1
  192. package/types/src/validator/confirmation-checkbox-validator.test.d.ts +0 -2
  193. package/types/src/validator/confirmation-checkbox-validator.test.d.ts.map +0 -1
  194. package/types/src/validator/coordinates-validator.d.ts +0 -23
  195. package/types/src/validator/coordinates-validator.d.ts.map +0 -1
  196. package/types/src/validator/coordinates-validator.test.d.ts +0 -2
  197. package/types/src/validator/coordinates-validator.test.d.ts.map +0 -1
  198. package/types/src/validator/date-period-validator.d.ts +0 -64
  199. package/types/src/validator/date-period-validator.d.ts.map +0 -1
  200. package/types/src/validator/date-period-validator.test.d.ts +0 -2
  201. package/types/src/validator/date-period-validator.test.d.ts.map +0 -1
  202. package/types/src/validator/date-time-validator.d.ts +0 -27
  203. package/types/src/validator/date-time-validator.d.ts.map +0 -1
  204. package/types/src/validator/date-time-validator.test.d.ts +0 -2
  205. package/types/src/validator/date-time-validator.test.d.ts.map +0 -1
  206. package/types/src/validator/date-validator.d.ts +0 -49
  207. package/types/src/validator/date-validator.d.ts.map +0 -1
  208. package/types/src/validator/date-validator.test.d.ts +0 -2
  209. package/types/src/validator/date-validator.test.d.ts.map +0 -1
  210. package/types/src/validator/document-upload-validator.d.ts +0 -12
  211. package/types/src/validator/document-upload-validator.d.ts.map +0 -1
  212. package/types/src/validator/document-upload-validator.test.d.ts +0 -2
  213. package/types/src/validator/document-upload-validator.test.d.ts.map +0 -1
  214. package/types/src/validator/email-validator.d.ts +0 -74
  215. package/types/src/validator/email-validator.d.ts.map +0 -1
  216. package/types/src/validator/email-validator.test.d.ts +0 -2
  217. package/types/src/validator/email-validator.test.d.ts.map +0 -1
  218. package/types/src/validator/multi-field-input-validator.d.ts +0 -91
  219. package/types/src/validator/multi-field-input-validator.d.ts.map +0 -1
  220. package/types/src/validator/multi-field-input-validator.test.d.ts +0 -2
  221. package/types/src/validator/multi-field-input-validator.test.d.ts.map +0 -1
  222. package/types/src/validator/numeric-validator.d.ts +0 -50
  223. package/types/src/validator/numeric-validator.d.ts.map +0 -1
  224. package/types/src/validator/numeric-validator.test.d.ts +0 -2
  225. package/types/src/validator/numeric-validator.test.d.ts.map +0 -1
  226. package/types/src/validator/required-validator.d.ts +0 -23
  227. package/types/src/validator/required-validator.d.ts.map +0 -1
  228. package/types/src/validator/required-validator.test.d.ts +0 -2
  229. package/types/src/validator/required-validator.test.d.ts.map +0 -1
  230. package/types/src/validator/same-answer-validator.d.ts +0 -19
  231. package/types/src/validator/same-answer-validator.d.ts.map +0 -1
  232. package/types/src/validator/same-answer-validator.test.d.ts +0 -2
  233. package/types/src/validator/same-answer-validator.test.d.ts.map +0 -1
  234. package/types/src/validator/string-validator.d.ts +0 -59
  235. package/types/src/validator/string-validator.d.ts.map +0 -1
  236. package/types/src/validator/string-validator.test.d.ts +0 -2
  237. package/types/src/validator/string-validator.test.d.ts.map +0 -1
  238. package/types/src/validator/unit-option-entry-validator.d.ts +0 -41
  239. package/types/src/validator/unit-option-entry-validator.d.ts.map +0 -1
  240. package/types/src/validator/unit-option-entry-validator.test.d.ts +0 -2
  241. package/types/src/validator/unit-option-entry-validator.test.d.ts.map +0 -1
  242. package/types/src/validator/valid-option-validator.d.ts +0 -23
  243. package/types/src/validator/valid-option-validator.d.ts.map +0 -1
  244. package/types/src/validator/valid-option-validator.test.d.ts +0 -2
  245. package/types/src/validator/valid-option-validator.test.d.ts.map +0 -1
  246. package/types/src/validator/validation-error-handler.d.ts +0 -20
  247. package/types/src/validator/validation-error-handler.d.ts.map +0 -1
  248. package/types/src/validator/validation-error-handler.test.d.ts +0 -2
  249. package/types/src/validator/validation-error-handler.test.d.ts.map +0 -1
  250. package/types/src/validator/validator.d.ts +0 -5
  251. package/types/src/validator/validator.d.ts.map +0 -1
  252. package/types/src/validator/validator.test.d.ts +0 -2
  253. package/types/src/validator/validator.test.d.ts.map +0 -1
  254. package/types/test/mock/journey.d.ts +0 -3
  255. package/types/test/mock/journey.d.ts.map +0 -1
  256. package/types/test/mock/uuid.d.ts +0 -7
  257. package/types/test/mock/uuid.d.ts.map +0 -1
  258. package/types/test/utils/nunjucks.d.ts +0 -2
  259. package/types/test/utils/nunjucks.d.ts.map +0 -1
  260. package/types/test/utils/utils.d.ts +0 -32
  261. package/types/test/utils/utils.d.ts.map +0 -1
package/move-types.js CHANGED
@@ -1,14 +1,12 @@
1
1
  import { copyFile } from 'node:fs/promises';
2
2
  import path from 'path';
3
3
 
4
- async function copyAndOverwrite(src, dest) {
4
+ const filesToCopy = ['questions/question-props.d.ts', 'questions/question-types.d.ts', 'journey/journey-types.d.ts'];
5
+
6
+ // copy some of the type definition files to the types output that are not automatically included
7
+ for (const file of filesToCopy) {
8
+ const src = path.join(import.meta.dirname, 'src', file);
9
+ const dest = path.join(import.meta.dirname, 'types', 'src', file);
5
10
  await copyFile(src, dest);
6
11
  console.log(`Copied ${src} to ${dest}`);
7
12
  }
8
-
9
- const srcDir = path.join(import.meta.dirname, 'src', 'questions');
10
- const typesDir = path.join(import.meta.dirname, 'types', 'src', 'questions');
11
-
12
- // copy some of the type definition files to the types output that are not automatically included
13
- copyAndOverwrite(path.join(srcDir, 'question-props.d.ts'), path.join(typesDir, 'question-props.d.ts'));
14
- copyAndOverwrite(path.join(srcDir, 'question-types.d.ts'), path.join(typesDir, 'question-types.d.ts'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planning-inspectorate/dynamic-forms",
3
- "version": "3.10.8",
3
+ "version": "3.10.10",
4
4
  "description": "This package is for building GDS forms using a configuration-based approach.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -103,7 +103,7 @@ export class BooleanQuestion extends RadioQuestion {
103
103
  * Get the data to save from the request, returns an object of answers
104
104
  * @param {import('express').Request} req
105
105
  * @param {JourneyResponse} journeyResponse - current journey response, modified with the new answers
106
- * @returns {Promise.<Object>}
106
+ * @returns {Promise<{ answers: Record<string, unknown> }>}
107
107
  */ //eslint-disable-next-line no-unused-vars -- journeyResponse kept for other questions to use
108
108
  async getDataToSave(req, journeyResponse) {
109
109
  const answers = {};
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  *
3
- * @param {import('#src/journey/journey-response.js').JourneyResponse} response
3
+ * @param {import('../../journey/journey-response.js').JourneyResponse} response
4
4
  * @param {import('./question.js')} manageListQuestion
5
5
  * @param {string} manageListItemId
6
6
  * @returns {Record<string, unknown>}
@@ -16,10 +16,10 @@ export function answerObjectForManageList(response, manageListQuestion, manageLi
16
16
  /**
17
17
  * Similar to answerObjectForManageList but will edit response and add a new array entry if not found
18
18
  *
19
- * @param {import('#src/journey/journey-response.js').JourneyResponse} response
19
+ * @param {import('../../journey/journey-response.js').JourneyResponse} response
20
20
  * @param {import('./question.js')} manageListQuestion
21
- * @param {import('#src/journey/journey-types.d.ts').RouteParams} params
22
- * @returns {import('#src/journey/journey-types.d.ts').ManageListAnswers}
21
+ * @param {import('../../journey/journey-types.js').RouteParams} params
22
+ * @returns {import('../../journey/journey-types.js').ManageListAnswers}
23
23
  */
24
24
  export function answerObjectForManageListSaving(response, manageListQuestion, params) {
25
25
  const answersList =
@@ -72,7 +72,7 @@ export class RadioQuestion extends OptionsQuestion {
72
72
  * @param {Object} answer
73
73
  * @param {Journey} journey
74
74
  * @param {String} sectionSegment
75
- * @returns {Array.<Object>}
75
+ * @returns {Array<{ key: string; value: string | Object; action?: ActionView | ActionView[] | undefined; }>}
76
76
  */
77
77
  formatAnswerForSummary(sectionSegment, journey, answer) {
78
78
  if (answer?.conditional) {
@@ -66,8 +66,8 @@ export class UnitOptionEntryQuestion extends Question {
66
66
  * @param {Record<string, unknown>} [customViewData] additional data to send to view
67
67
  * @param {Record<string, unknown>} [payload]
68
68
  * @param {import('#question-types').PrepQuestionForRenderingOptions} options
69
- * @returns {import('#question').QuestionViewModel & {
70
- * question: import('#question').QuestionViewModel['question'] & {
69
+ * @returns {import('../../questions/question.js').QuestionViewModel & {
70
+ * question: import('../../questions/question.js').QuestionViewModel['question'] & {
71
71
  * options:UnitOption[]
72
72
  * }
73
73
  * }}
@@ -20,7 +20,7 @@ export const logicalCombinations = (response) => ({
20
20
  *
21
21
  * @param {import('#question').Question} question
22
22
  * @param {unknown} expectedValue
23
- * @returns {import('#src/section.js').QuestionCondition}
23
+ * @returns {import('../../section.js').QuestionCondition}
24
24
  */
25
25
  export const whenQuestionHasAnswer = (question, expectedValue) => {
26
26
  return (response) => questionHasAnswer(response, question, expectedValue);
package/src/index.js CHANGED
@@ -28,6 +28,7 @@ export * from './controller.js';
28
28
  // Journey
29
29
  export { Journey } from './journey/journey.js';
30
30
  export { JourneyResponse } from './journey/journey-response.js';
31
+ export * from './journey/journey-types.js';
31
32
 
32
33
  // lib
33
34
  export * from './lib/address.js';
@@ -18,7 +18,7 @@ export class JourneyResponse {
18
18
  journeyId;
19
19
 
20
20
  /**
21
- * @type {import('./journey-types.d.ts').JourneyAnswers} - answers to the journey
21
+ * @type {import('./journey-types.js').JourneyAnswers} - answers to the journey
22
22
  */
23
23
  answers;
24
24
 
@@ -26,7 +26,7 @@ export class JourneyResponse {
26
26
  * creates an instance of a JourneyResponse
27
27
  * @param {JourneyType} journeyId
28
28
  * @param {string} referenceId
29
- * @param {import('./journey-types.d.ts').JourneyAnswers | null} answers
29
+ * @param {import('./journey-types.js').JourneyAnswers | null} answers
30
30
  * @param {string} [lpaCode]
31
31
  */
32
32
  constructor(journeyId, referenceId, answers, lpaCode) {
@@ -0,0 +1 @@
1
+ // empty source file to go with .d.ts file
@@ -6,12 +6,6 @@
6
6
  import { END_OF_SECTION } from '#src/section.js';
7
7
  import { MANAGE_LIST_ACTIONS } from '#src/components/manage-list/manage-list-actions.js';
8
8
 
9
- /**
10
- * @typedef {import('./journey-response').JourneyResponse} JourneyResponse
11
- * @typedef {import('../section').Section} Section
12
- * @typedef {import('../questions/question').Question} Question
13
- */
14
-
15
9
  /**
16
10
  * A journey (An entire set of questions required for a completion of a submission)
17
11
  * @class
@@ -19,13 +13,13 @@ import { MANAGE_LIST_ACTIONS } from '#src/components/manage-list/manage-list-act
19
13
  export class Journey {
20
14
  /** @type {string} journeyId - a unique, human-readable id for this journey */
21
15
  journeyId;
22
- /** @type {Array.<Section>} sections - sections within the journey */
16
+ /** @type {Array.<import('../section.js').Section>} sections - sections within the journey */
23
17
  sections = [];
24
- /** @type {JourneyResponse} response - the user's response to the journey so far */
18
+ /** @type {import('./journey-response.js').JourneyResponse} response - the user's response to the journey so far */
25
19
  response;
26
20
  /** @type {string} baseUrl - base url of the journey, gets prepended to question urls */
27
21
  baseUrl = '';
28
- /** @type {(journeyResponse: JourneyResponse) => string} baseUrl - base url of the journey, gets prepended to question urls */
22
+ /** @type {(journeyResponse: import('./journey-response.js').JourneyResponse) => string} makeBaseUrl - function to generate base url of the journey */
29
23
  makeBaseUrl = () => '';
30
24
  /** @type {string} taskListUrl - url that renders the task list */
31
25
  taskListUrl = '';
@@ -44,15 +38,15 @@ export class Journey {
44
38
  * creates an instance of a journey
45
39
  * @param {object} options
46
40
  * @param {string} options.journeyId - a unique, human-readable id for this journey
47
- * @param {(response: JourneyResponse) => string} options.makeBaseUrl - base url of journey
41
+ * @param {(response: import('./journey-response.js').JourneyResponse) => string} options.makeBaseUrl - base url of journey
48
42
  * @param {string} [options.taskListUrl] - task list url - added to base url, can be left undefined
49
- * @param {JourneyResponse} options.response - user's response
43
+ * @param {import('./journey-response.js').JourneyResponse} options.response - user's response
50
44
  * @param {string} options.journeyTemplate - template used for all views
51
45
  * @param {string} options.taskListTemplate - path to njk view for listing page
52
46
  * @param {string} [options.informationPageViewPath] - path to njk view for pdf summary page
53
47
  * @param {string} options.journeyTitle - part of the title in the njk view
54
48
  * @param {boolean} [options.returnToListing] - defines how the next/previous question handles end of sections
55
- * @param {Section[]} options.sections
49
+ * @param {import('../section.js').Section[]} options.sections
56
50
  * @param {string} [options.initialBackLink] - back link when on the first question
57
51
  */
58
52
  constructor({
@@ -137,7 +131,7 @@ export class Journey {
137
131
 
138
132
  /**
139
133
  * utility function to build up a url to a question
140
- * @param {import('./journey-types.d.ts').RouteParams} params
134
+ * @param {import('./journey-types.js').RouteParams} params
141
135
  * @returns {string} url for a question
142
136
  */
143
137
  #buildQuestionUrl(params) {
@@ -151,7 +145,7 @@ export class Journey {
151
145
  /**
152
146
  * Gets section based on segment
153
147
  * @param {string} sectionSegment
154
- * @returns {Section | undefined}
148
+ * @returns {import('../section.js').Section | undefined}
155
149
  */
156
150
  getSection(sectionSegment) {
157
151
  return this.sections.find((s) => {
@@ -161,10 +155,10 @@ export class Journey {
161
155
 
162
156
  /**
163
157
  * Get question within a section
164
- * @param {Section} section
158
+ * @param {import('../section.js').Section} section
165
159
  * @param {string} questionSegment
166
160
  * @param {{action: string, itemId: string, question: string}} [manageListParams]
167
- * @returns {Question | undefined} question if it belongs in the given section
161
+ * @returns {import('../questions/question.js').Question | undefined} question if it belongs in the given section
168
162
  */
169
163
  #getQuestion(section, questionSegment, manageListParams) {
170
164
  const matchQuestion = (q, toMatch) => {
@@ -189,8 +183,8 @@ export class Journey {
189
183
 
190
184
  /**
191
185
  * gets a question from the object's sections based on a section + question names
192
- * @param {import('./journey-types.d.ts').RouteParams} params
193
- * @returns {Question | undefined} question found by lookup
186
+ * @param {import('./journey-types.js').RouteParams} params
187
+ * @returns {import('../questions/question.js').Question | undefined} question found by lookup
194
188
  */
195
189
  getQuestionByParams(params) {
196
190
  const section = this.getSection(params.section);
@@ -213,7 +207,7 @@ export class Journey {
213
207
  * Get the back link for the journey - e.g. the previous question
214
208
  *
215
209
  * @param {Object} options
216
- * @param {import('./journey-types.d.ts').RouteParams} options.params
210
+ * @param {import('./journey-types.js').RouteParams} options.params
217
211
  * @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
218
212
  * @returns {string|null} url for the next question, or null if unmatched
219
213
  */
@@ -233,7 +227,7 @@ export class Journey {
233
227
  * Used after question post/saving
234
228
  *
235
229
  * @param {import('express').Response} res
236
- * @param {import('./journey-types.d.ts').RouteParams} params
230
+ * @param {import('./journey-types.js').RouteParams} params
237
231
  * @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
238
232
  * @returns {void}
239
233
  */
@@ -245,7 +239,7 @@ export class Journey {
245
239
  /**
246
240
  * Get url for the next question in the journey
247
241
  *
248
- * @param {import('./journey-types.d.ts').RouteParams} params
242
+ * @param {import('./journey-types.js').RouteParams} params
249
243
  * @param {Object} options
250
244
  * @param {boolean} [options.reverse] - if passed in this will get the previous question
251
245
  * @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
@@ -299,7 +293,7 @@ export class Journey {
299
293
  * don't include other params which may be set (e.g. manageList* params), as we may now be
300
294
  * redirecting to a non-manage list question, having previously been on a manage list question
301
295
  *
302
- * @type {import('./journey-types.d.ts').RouteParams}
296
+ * @type {import('./journey-types.js').RouteParams}
303
297
  */
304
298
  let newParams = {
305
299
  section: currentSection.segment,
@@ -399,7 +393,7 @@ export class Journey {
399
393
  }
400
394
 
401
395
  /**
402
- * @param {JourneyResponse} journeyResponse
396
+ * @param {import('./journey-response.js').JourneyResponse} journeyResponse
403
397
  */
404
398
  setResponse(journeyResponse) {
405
399
  this.response = journeyResponse;
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * @param {{[questionName: string]: QuestionProps}} questionPropsRecord
5
- * @param {Record<string, typeof import('./question').Question>} questionClasses
5
+ * @param {Record<string, import('./question-types.js').QuestionClass>} questionClasses
6
6
  * @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
7
7
  * @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
8
8
  */
@@ -33,14 +33,16 @@ const defaultOptionJoinString = ',';
33
33
  /**
34
34
  * @typedef {import('./question').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
35
35
  */
36
+ /**
37
+ * @typedef {import('#question-types').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
38
+ */
36
39
 
37
- export default class OptionsQuestion extends Question {
40
+ export class OptionsQuestion extends Question {
38
41
  /** @type {Array<Option>} */
39
42
  options;
40
43
 
41
44
  /**
42
- * @param {import('#question-types').QuestionParameters} params
43
- * @param {Array<Option>} params.options
45
+ * @param {OptionsQuestionParameters} params
44
46
  */
45
47
  constructor(params) {
46
48
  // add default valid options validator to all options questions
@@ -150,3 +152,5 @@ export default class OptionsQuestion extends Question {
150
152
  return { answers };
151
153
  }
152
154
  }
155
+
156
+ export default OptionsQuestion;
@@ -78,3 +78,9 @@ export interface PrepQuestionForRenderingOptions {
78
78
  params: RouteParams;
79
79
  manageListQuestion?: ManageListQuestion;
80
80
  }
81
+
82
+ /**
83
+ * Define a question class type so that projects downstream can extend the
84
+ * Question class and still pass them to the createQuestions function.
85
+ */
86
+ export type QuestionClass<TQuestion extends Question = Question> = new (...args: never[]) => TQuestion;
@@ -7,9 +7,6 @@ import { answerObjectForManageList } from '#src/components/manage-list/utils.js'
7
7
 
8
8
  /**
9
9
  * @import {BaseValidator} from "#base-validator"
10
- * @import {Journey} from "#journey"
11
- * @import {JourneyResponse} from "#journey-response"
12
- * @import {Section} from "#section"
13
10
  * @import {ActionView} from "../controller.js"
14
11
  * @import {ActionLink} from "./question-types.js"
15
12
  */
@@ -83,7 +80,7 @@ export class Question {
83
80
  addActionText = 'Add';
84
81
 
85
82
  /**
86
- * @param {JourneyResponse} [response]
83
+ * @param {import('../journey/journey-response.js').JourneyResponse} [response]
87
84
  * @returns {boolean}
88
85
  */
89
86
  shouldDisplay = () => true;
@@ -193,10 +190,10 @@ export class Question {
193
190
  * that prepQuestionForRendering doesn't need
194
191
  *
195
192
  * @param {Object} options
196
- * @param {import('#src/journey/journey-types.d.ts').RouteParams} options.params
197
- * @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
198
- * @param {Section} options.section - the current section
199
- * @param {Journey} options.journey - the journey we are in
193
+ * @param {import('../journey/journey-types.js').RouteParams} options.params
194
+ * @param {import('../components/manage-list/question.js')} [options.manageListQuestion]
195
+ * @param {import('../section.js').Section} options.section - the current section
196
+ * @param {import('../journey/journey.js').Journey} options.journey - the journey we are in
200
197
  * @param {Record<string, unknown>} [options.customViewData] additional data to send to view
201
198
  * @param {unknown} [options.payload]
202
199
  * @returns {QuestionViewModel}
@@ -213,8 +210,8 @@ export class Question {
213
210
  /**
214
211
  * gets the base view model for this question
215
212
  *
216
- * @param {Section} section - the current section
217
- * @param {Journey} journey - the journey we are in
213
+ * @param {import('../section.js').Section} section - the current section
214
+ * @param {import('../journey/journey.js').Journey} journey - the journey we are in
218
215
  * @param {Record<string, unknown>} [customViewData] additional data to send to view
219
216
  * @param {unknown} [payload]
220
217
  * @param {import('#question-types').PrepQuestionForRenderingOptions} [options] - required to support manage list question
@@ -284,7 +281,7 @@ export class Question {
284
281
  /**
285
282
  * Get the answers object from the journey response, which may be nested in an array for manage list questions
286
283
  *
287
- * @param {JourneyResponse} response
284
+ * @param {import('../journey/journey-response.js').JourneyResponse} response
288
285
  * @param {import('#question-types').PrepQuestionForRenderingOptions} [options]
289
286
  * @returns {Record<string, any>}
290
287
  */
@@ -320,9 +317,9 @@ export class Question {
320
317
  /**
321
318
  * check for validation errors
322
319
  * @param {import('express').Request} req
323
- * @param {Journey} journey
324
- * @param {Section} section
325
- * @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
320
+ * @param {import('../journey/journey.js').Journey} journey
321
+ * @param {import('../section.js').Section} section
322
+ * @param {import('../components/manage-list/question.js')} [manageListQuestion]
326
323
  * @returns {QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
327
324
  */
328
325
  checkForValidationErrors(req, section, journey, manageListQuestion) {
@@ -348,7 +345,7 @@ export class Question {
348
345
  * Get the data to save from the request, returns an object of answers
349
346
  *
350
347
  * @param {import('express').Request} req
351
- * @param {JourneyResponse} journeyResponse - current journey response
348
+ * @param {import('../journey/journey-response.js').JourneyResponse} journeyResponse - current journey response
352
349
  * @returns {Promise<{ answers: Record<string, unknown> }>}
353
350
  */ //eslint-disable-next-line no-unused-vars -- journeyResponse kept for other questions to use
354
351
  async getDataToSave(req, journeyResponse) {
@@ -368,8 +365,8 @@ export class Question {
368
365
  /**
369
366
  * check for errors after saving, by default this does nothing
370
367
  * @param {import('express').Request} req
371
- * @param {Journey} journey
372
- * @param {Section} sectionObj
368
+ * @param {import('../journey/journey.js').Journey} journey
369
+ * @param {import('../section.js').Section} sectionObj
373
370
  * @returns {QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
374
371
  */ //eslint-disable-next-line no-unused-vars
375
372
  checkForSavingErrors(req, sectionObj, journey) {
@@ -380,7 +377,7 @@ export class Question {
380
377
  * Handles redirect after saving. Kept around for backwards compatibility.
381
378
  *
382
379
  * @param {import('express').Response} res
383
- * @param {Journey} journey
380
+ * @param {import('../journey/journey.js').Journey} journey
384
381
  * @param {string} sectionSegment
385
382
  * @param {string} questionSegment
386
383
  * @returns {void}
@@ -396,7 +393,7 @@ export class Question {
396
393
  /**
397
394
  * returns the formatted answers values to be used to build task list elements
398
395
  * @param {String} sectionSegment
399
- * @param {Journey} journey
396
+ * @param {import('../journey/journey.js').Journey} journey
400
397
  * @param {Object} answer
401
398
  * @returns {Array<{
402
399
  * key: string;
@@ -420,7 +417,7 @@ export class Question {
420
417
  /**
421
418
  * Returns the action link for the question
422
419
  * @param {Object} answer
423
- * @param {Journey} journey
420
+ * @param {import('../journey/journey.js').Journey} journey
424
421
  * @param {String} sectionSegment
425
422
  * @returns {ActionView|ActionView[]|undefined}
426
423
  */
@@ -475,7 +472,7 @@ export class Question {
475
472
  }
476
473
 
477
474
  /**
478
- * @param {JourneyResponse} journeyResponse
475
+ * @param {import('../journey/journey-response.js').JourneyResponse} journeyResponse
479
476
  * @param {string} [fieldName] optional fieldname for multi field input questions
480
477
  * @returns {boolean}
481
478
  */
@@ -3,10 +3,6 @@ import { body } from 'express-validator';
3
3
  import BaseValidator from './base-validator.js';
4
4
  import { toArray } from '#src/lib/utils.js';
5
5
 
6
- /**
7
- * @typedef {import('../questions/options-question.js')} OptionsQuestion
8
- */
9
-
10
6
  /**
11
7
  * enforces a field is within the question's predefined list of options
12
8
  * @class
@@ -28,7 +24,7 @@ export class ValidOptionValidator extends BaseValidator {
28
24
 
29
25
  /**
30
26
  * validates the response body, checking the value sent for the questionObj's fieldname is within the predefined list of options
31
- * @param {OptionsQuestion} questionObj
27
+ * @param {import('../questions/options-question.js').default} questionObj
32
28
  */
33
29
  validate(questionObj) {
34
30
  return body(questionObj.fieldName)
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "include": ["**/*.ts", "**/*.js"],
3
- "exclude": ["node_modules", "packages/database/src/client/**", "**/*.test.ts", "test/**"],
3
+ "exclude": ["node_modules", "packages/database/src/client/**", "**/*.test.ts", "**/*.test.js", "test/**"],
4
4
  "compilerOptions": {
5
5
  "allowImportingTsExtensions": true,
6
6
  "allowJs": true,
@@ -1,7 +0,0 @@
1
- declare namespace _default {
2
- let _extends: string[];
3
- export { _extends as extends };
4
- export let ignores: ((commit: any) => any)[];
5
- }
6
- export default _default;
7
- //# sourceMappingURL=commitlint.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commitlint.config.d.ts","sourceRoot":"","sources":["../commitlint.config.js"],"names":[],"mappings":""}
@@ -1,95 +0,0 @@
1
- declare const _default: ({
2
- readonly rules: Readonly<import("eslint").Linter.RulesRecord>;
3
- } | {
4
- ignores: string[];
5
- languageOptions: {
6
- ecmaVersion: number;
7
- sourceType: string;
8
- globals: {
9
- __dirname: false;
10
- __filename: false;
11
- AbortController: false;
12
- AbortSignal: false;
13
- AsyncDisposableStack: false;
14
- atob: false;
15
- Blob: false;
16
- BroadcastChannel: false;
17
- btoa: false;
18
- Buffer: false;
19
- ByteLengthQueuingStrategy: false;
20
- clearImmediate: false;
21
- clearInterval: false;
22
- clearTimeout: false;
23
- CloseEvent: false;
24
- CompressionStream: false;
25
- console: false;
26
- CountQueuingStrategy: false;
27
- crypto: false;
28
- Crypto: false;
29
- CryptoKey: false;
30
- CustomEvent: false;
31
- DecompressionStream: false;
32
- DisposableStack: false;
33
- DOMException: false;
34
- ErrorEvent: false;
35
- Event: false;
36
- EventTarget: false;
37
- exports: true;
38
- fetch: false;
39
- File: false;
40
- FormData: false;
41
- global: false;
42
- Headers: false;
43
- localStorage: false;
44
- MessageChannel: false;
45
- MessageEvent: false;
46
- MessagePort: false;
47
- module: false;
48
- navigator: false;
49
- Navigator: false;
50
- performance: false;
51
- Performance: false;
52
- PerformanceEntry: false;
53
- PerformanceMark: false;
54
- PerformanceMeasure: false;
55
- PerformanceObserver: false;
56
- PerformanceObserverEntryList: false;
57
- PerformanceResourceTiming: false;
58
- process: false;
59
- queueMicrotask: false;
60
- ReadableByteStreamController: false;
61
- ReadableStream: false;
62
- ReadableStreamBYOBReader: false;
63
- ReadableStreamBYOBRequest: false;
64
- ReadableStreamDefaultController: false;
65
- ReadableStreamDefaultReader: false;
66
- Request: false;
67
- require: false;
68
- Response: false;
69
- sessionStorage: false;
70
- setImmediate: false;
71
- setInterval: false;
72
- setTimeout: false;
73
- Storage: false;
74
- structuredClone: false;
75
- SubtleCrypto: false;
76
- SuppressedError: false;
77
- TextDecoder: false;
78
- TextDecoderStream: false;
79
- TextEncoder: false;
80
- TextEncoderStream: false;
81
- TransformStream: false;
82
- TransformStreamDefaultController: false;
83
- URL: false;
84
- URLPattern: false;
85
- URLSearchParams: false;
86
- WebAssembly: false;
87
- WebSocket: false;
88
- WritableStream: false;
89
- WritableStreamDefaultController: false;
90
- WritableStreamDefaultWriter: false;
91
- };
92
- };
93
- })[];
94
- export default _default;
95
- //# sourceMappingURL=eslint.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eslint.config.d.ts","sourceRoot":"","sources":["../eslint.config.js"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=move-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"move-types.d.ts","sourceRoot":"","sources":["../move-types.js"],"names":[],"mappings":""}
@@ -1,36 +0,0 @@
1
- export class AddressQuestion extends Question {
2
- /**
3
- * @param {import('#question-types').QuestionParameters} params
4
- */
5
- constructor(params: import("#question-types").QuestionParameters);
6
- requiredFields: {
7
- addressLine1: boolean;
8
- addressLine2: boolean;
9
- townCity: boolean;
10
- county: boolean;
11
- postcode: boolean;
12
- } | undefined;
13
- addressLabels: {
14
- addressLine1: string;
15
- addressLine2: string;
16
- townCity: string;
17
- county: string;
18
- postcode: string;
19
- };
20
- /**
21
- * @param {Record<string, any>} answers
22
- * @returns {*|string}
23
- */
24
- answerForViewModel(answers: Record<string, any>): any | string;
25
- /**
26
- * @param {Object<string, any>} answer
27
- * @returns The formatted address to be presented in the UI
28
- */
29
- format(answer: {
30
- [x: string]: any;
31
- }): string;
32
- formatLabelFromRequiredFields(fieldName: any): "" | " (optional)";
33
- }
34
- export default AddressQuestion;
35
- import { Question } from '#question';
36
- //# sourceMappingURL=question.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/address/question.js"],"names":[],"mappings":"AAOA;IACC;;OAEG;IACH,oBAFW,OAAO,iBAAiB,EAAE,kBAAkB,EAqBtD;IAXE;;;;;;kBAA8C;IAIhD;;;;;;MAMC;IAGF;;;OAGG;IACH,4BAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjB,GAAC,GAAC,MAAM,CAqBpB;IAqCD;;;OAGG;IACH;;eAUC;IAuBD,kEAMC;CACD;;yBAxIwB,WAAW"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=question.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../../src/components/address/question.test.js"],"names":[],"mappings":""}