@planning-inspectorate/dynamic-forms 3.10.10 → 3.10.12

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 (135) hide show
  1. package/package.json +1 -1
  2. package/src/questions/question.js +3 -3
  3. package/src/section.js +2 -2
  4. package/types/commitlint.config.d.ts +7 -0
  5. package/types/commitlint.config.d.ts.map +1 -0
  6. package/types/eslint.config.d.ts +95 -0
  7. package/types/eslint.config.d.ts.map +1 -0
  8. package/types/move-types.d.ts +2 -0
  9. package/types/move-types.d.ts.map +1 -0
  10. package/types/src/components/address/question.d.ts +36 -0
  11. package/types/src/components/address/question.d.ts.map +1 -0
  12. package/types/src/components/boolean/question.d.ts +52 -0
  13. package/types/src/components/boolean/question.d.ts.map +1 -0
  14. package/types/src/components/checkbox/question.d.ts +52 -0
  15. package/types/src/components/checkbox/question.d.ts.map +1 -0
  16. package/types/src/components/date/question.d.ts +23 -0
  17. package/types/src/components/date/question.d.ts.map +1 -0
  18. package/types/src/components/date-period/question.d.ts +35 -0
  19. package/types/src/components/date-period/question.d.ts.map +1 -0
  20. package/types/src/components/date-time/question.d.ts +25 -0
  21. package/types/src/components/date-time/question.d.ts.map +1 -0
  22. package/types/src/components/email/question.d.ts +31 -0
  23. package/types/src/components/email/question.d.ts.map +1 -0
  24. package/types/src/components/identifier/question.d.ts +16 -0
  25. package/types/src/components/identifier/question.d.ts.map +1 -0
  26. package/types/src/components/manage-list/manage-list-actions.d.ts +10 -0
  27. package/types/src/components/manage-list/manage-list-actions.d.ts.map +1 -0
  28. package/types/src/components/manage-list/manage-list-section.d.ts +16 -0
  29. package/types/src/components/manage-list/manage-list-section.d.ts.map +1 -0
  30. package/types/src/components/manage-list/question.d.ts +49 -0
  31. package/types/src/components/manage-list/question.d.ts.map +1 -0
  32. package/types/src/components/manage-list/utils.d.ts +18 -0
  33. package/types/src/components/manage-list/utils.d.ts.map +1 -0
  34. package/types/src/components/multi-field-input/question.d.ts +61 -0
  35. package/types/src/components/multi-field-input/question.d.ts.map +1 -0
  36. package/types/src/components/number-entry/question.d.ts +38 -0
  37. package/types/src/components/number-entry/question.d.ts.map +1 -0
  38. package/types/src/components/radio/question.d.ts +58 -0
  39. package/types/src/components/radio/question.d.ts.map +1 -0
  40. package/types/src/components/select/question.d.ts +55 -0
  41. package/types/src/components/select/question.d.ts.map +1 -0
  42. package/types/src/components/single-line-input/question.d.ts +19 -0
  43. package/types/src/components/single-line-input/question.d.ts.map +1 -0
  44. package/types/src/components/text-entry/question.d.ts +35 -0
  45. package/types/src/components/text-entry/question.d.ts.map +1 -0
  46. package/types/src/components/text-entry-redact/question.d.ts +35 -0
  47. package/types/src/components/text-entry-redact/question.d.ts.map +1 -0
  48. package/types/src/components/unit-option-entry/question.d.ts +84 -0
  49. package/types/src/components/unit-option-entry/question.d.ts.map +1 -0
  50. package/types/src/components/utils/component-types.d.ts +19 -0
  51. package/types/src/components/utils/component-types.d.ts.map +1 -0
  52. package/types/src/components/utils/persisted-number-answer.d.ts +2 -0
  53. package/types/src/components/utils/persisted-number-answer.d.ts.map +1 -0
  54. package/types/src/components/utils/question-has-answer.d.ts +17 -0
  55. package/types/src/components/utils/question-has-answer.d.ts.map +1 -0
  56. package/types/src/components/utils/question-utils.d.ts +15 -0
  57. package/types/src/components/utils/question-utils.d.ts.map +1 -0
  58. package/types/src/controller.d.ts +75 -0
  59. package/types/src/controller.d.ts.map +1 -0
  60. package/types/src/index.d.ts +59 -0
  61. package/types/src/index.d.ts.map +1 -0
  62. package/types/src/journey/journey-response.d.ts +32 -0
  63. package/types/src/journey/journey-response.d.ts.map +1 -0
  64. package/types/src/journey/journey-types.d.ts +28 -0
  65. package/types/src/journey/journey-types.d.ts.map +1 -0
  66. package/types/src/journey/journey.d.ts +136 -0
  67. package/types/src/journey/journey.d.ts.map +1 -0
  68. package/types/src/lib/address-utils.d.ts +6 -0
  69. package/types/src/lib/address-utils.d.ts.map +1 -0
  70. package/types/src/lib/address.d.ts +43 -0
  71. package/types/src/lib/address.d.ts.map +1 -0
  72. package/types/src/lib/date-utils.d.ts +60 -0
  73. package/types/src/lib/date-utils.d.ts.map +1 -0
  74. package/types/src/lib/session-answer-store.d.ts +88 -0
  75. package/types/src/lib/session-answer-store.d.ts.map +1 -0
  76. package/types/src/lib/utils.d.ts +26 -0
  77. package/types/src/lib/utils.d.ts.map +1 -0
  78. package/types/src/lib/uuid.d.ts +7 -0
  79. package/types/src/lib/uuid.d.ts.map +1 -0
  80. package/types/src/middleware/build-get-journey.d.ts +6 -0
  81. package/types/src/middleware/build-get-journey.d.ts.map +1 -0
  82. package/types/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
  83. package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
  84. package/types/src/questions/create-questions.d.ts +21 -0
  85. package/types/src/questions/create-questions.d.ts.map +1 -0
  86. package/types/src/questions/options-question.d.ts +80 -0
  87. package/types/src/questions/options-question.d.ts.map +1 -0
  88. package/types/src/questions/question-props.d.ts +182 -0
  89. package/types/src/questions/question-props.d.ts.map +1 -0
  90. package/types/src/questions/question-types.d.ts +86 -0
  91. package/types/src/questions/question-types.d.ts.map +1 -0
  92. package/types/src/questions/question.d.ts +272 -0
  93. package/types/src/questions/question.d.ts.map +1 -0
  94. package/types/src/questions/questions.d.ts +3 -0
  95. package/types/src/questions/questions.d.ts.map +1 -0
  96. package/types/src/section.d.ts +107 -0
  97. package/types/src/section.d.ts.map +1 -0
  98. package/types/src/validator/address-validator.d.ts +48 -0
  99. package/types/src/validator/address-validator.d.ts.map +1 -0
  100. package/types/src/validator/base-validator.d.ts +12 -0
  101. package/types/src/validator/base-validator.d.ts.map +1 -0
  102. package/types/src/validator/conditional-required-validator.d.ts +25 -0
  103. package/types/src/validator/conditional-required-validator.d.ts.map +1 -0
  104. package/types/src/validator/confirmation-checkbox-validator.d.ts +28 -0
  105. package/types/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
  106. package/types/src/validator/coordinates-validator.d.ts +23 -0
  107. package/types/src/validator/coordinates-validator.d.ts.map +1 -0
  108. package/types/src/validator/date-period-validator.d.ts +64 -0
  109. package/types/src/validator/date-period-validator.d.ts.map +1 -0
  110. package/types/src/validator/date-time-validator.d.ts +27 -0
  111. package/types/src/validator/date-time-validator.d.ts.map +1 -0
  112. package/types/src/validator/date-validator.d.ts +49 -0
  113. package/types/src/validator/date-validator.d.ts.map +1 -0
  114. package/types/src/validator/document-upload-validator.d.ts +12 -0
  115. package/types/src/validator/document-upload-validator.d.ts.map +1 -0
  116. package/types/src/validator/email-validator.d.ts +74 -0
  117. package/types/src/validator/email-validator.d.ts.map +1 -0
  118. package/types/src/validator/multi-field-input-validator.d.ts +91 -0
  119. package/types/src/validator/multi-field-input-validator.d.ts.map +1 -0
  120. package/types/src/validator/numeric-validator.d.ts +50 -0
  121. package/types/src/validator/numeric-validator.d.ts.map +1 -0
  122. package/types/src/validator/required-validator.d.ts +23 -0
  123. package/types/src/validator/required-validator.d.ts.map +1 -0
  124. package/types/src/validator/same-answer-validator.d.ts +19 -0
  125. package/types/src/validator/same-answer-validator.d.ts.map +1 -0
  126. package/types/src/validator/string-validator.d.ts +59 -0
  127. package/types/src/validator/string-validator.d.ts.map +1 -0
  128. package/types/src/validator/unit-option-entry-validator.d.ts +41 -0
  129. package/types/src/validator/unit-option-entry-validator.d.ts.map +1 -0
  130. package/types/src/validator/valid-option-validator.d.ts +19 -0
  131. package/types/src/validator/valid-option-validator.d.ts.map +1 -0
  132. package/types/src/validator/validation-error-handler.d.ts +20 -0
  133. package/types/src/validator/validation-error-handler.d.ts.map +1 -0
  134. package/types/src/validator/validator.d.ts +5 -0
  135. package/types/src/validator/validator.d.ts.map +1 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @typedef {import('./journey-factory').JourneyType} JourneyType
3
+ */
4
+ /**
5
+ * Defines a response to a journey, a set of Answers to the questions
6
+ * @class
7
+ */
8
+ export class JourneyResponse {
9
+ /**
10
+ * creates an instance of a JourneyResponse
11
+ * @param {JourneyType} journeyId
12
+ * @param {string} referenceId
13
+ * @param {import('./journey-types.js').JourneyAnswers | null} answers
14
+ * @param {string} [lpaCode]
15
+ */
16
+ constructor(journeyId: JourneyType, referenceId: string, answers: import("./journey-types.js").JourneyAnswers | null, lpaCode?: string);
17
+ /**
18
+ * @type {string} - reference id used in the url for the journey e.g. appeal id - provides a unique lookup for responses in combination with formId
19
+ */
20
+ referenceId: string;
21
+ /**
22
+ * @type {JourneyType} - a reference to the journey type e.g. has-questionnaire - provides a unique lookup for responses in combination with referenceId
23
+ */
24
+ journeyId: JourneyType;
25
+ /**
26
+ * @type {import('./journey-types.js').JourneyAnswers} - answers to the journey
27
+ */
28
+ answers: import("./journey-types.js").JourneyAnswers;
29
+ LPACode: string | undefined;
30
+ }
31
+ export type JourneyType = any;
32
+ //# sourceMappingURL=journey-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-response.d.ts","sourceRoot":"","sources":["../../../src/journey/journey-response.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH;IAgBC;;;;;;OAMG;IACH,uBALW,WAAW,eACX,MAAM,WACN,OAAO,oBAAoB,EAAE,cAAc,GAAG,IAAI,YAClD,MAAM,EAWhB;IA/BD;;OAEG;IACH,aAFU,MAAM,CAEJ;IAEZ;;OAEG;IACH,WAFU,WAAW,CAEX;IAEV;;OAEG;IACH,SAFU,OAAO,oBAAoB,EAAE,cAAc,CAE7C;IAiBP,4BAAsB;CAEvB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Express route parameters used for journey routes
3
+ */
4
+ export type RouteParams = CoreRouteParams & ManageListRouteParams;
5
+
6
+ export type CoreRouteParams = {
7
+ section: string;
8
+ question: string;
9
+ [key: string]: string;
10
+ };
11
+
12
+ export type ManageListRouteParams =
13
+ | {
14
+ manageListAction: string;
15
+ manageListItemId: string;
16
+ manageListQuestion: string;
17
+ }
18
+ | {};
19
+
20
+ export interface JourneyAnswers {
21
+ // if the answer is for a manage list question, the answer will be an array of answer objects
22
+ [k: string]: unknown | ManageListAnswers[];
23
+ }
24
+
25
+ export interface ManageListAnswers {
26
+ id: string;
27
+ [k: string]: unknown;
28
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-types.d.ts","sourceRoot":"","sources":["../../../src/journey/journey-types.js"],"names":[],"mappings":""}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * A journey (An entire set of questions required for a completion of a submission)
3
+ * @class
4
+ */
5
+ export class Journey {
6
+ /**
7
+ * creates an instance of a journey
8
+ * @param {object} options
9
+ * @param {string} options.journeyId - a unique, human-readable id for this journey
10
+ * @param {(response: import('./journey-response.js').JourneyResponse) => string} options.makeBaseUrl - base url of journey
11
+ * @param {string} [options.taskListUrl] - task list url - added to base url, can be left undefined
12
+ * @param {import('./journey-response.js').JourneyResponse} options.response - user's response
13
+ * @param {string} options.journeyTemplate - template used for all views
14
+ * @param {string} options.taskListTemplate - path to njk view for listing page
15
+ * @param {string} [options.informationPageViewPath] - path to njk view for pdf summary page
16
+ * @param {string} options.journeyTitle - part of the title in the njk view
17
+ * @param {boolean} [options.returnToListing] - defines how the next/previous question handles end of sections
18
+ * @param {import('../section.js').Section[]} options.sections
19
+ * @param {string} [options.initialBackLink] - back link when on the first question
20
+ */
21
+ constructor({ journeyId, makeBaseUrl, taskListUrl, response, journeyTemplate, taskListTemplate, informationPageViewPath, journeyTitle, returnToListing, sections, initialBackLink }: {
22
+ journeyId: string;
23
+ makeBaseUrl: (response: import("./journey-response.js").JourneyResponse) => string;
24
+ taskListUrl?: string | undefined;
25
+ response: import("./journey-response.js").JourneyResponse;
26
+ journeyTemplate: string;
27
+ taskListTemplate: string;
28
+ informationPageViewPath?: string | undefined;
29
+ journeyTitle: string;
30
+ returnToListing?: boolean | undefined;
31
+ sections: import("../section.js").Section[];
32
+ initialBackLink?: string | undefined;
33
+ });
34
+ /** @type {string} journeyId - a unique, human-readable id for this journey */
35
+ journeyId: string;
36
+ /** @type {Array.<import('../section.js').Section>} sections - sections within the journey */
37
+ sections: Array<import("../section.js").Section>;
38
+ /** @type {import('./journey-response.js').JourneyResponse} response - the user's response to the journey so far */
39
+ response: import("./journey-response.js").JourneyResponse;
40
+ /** @type {string} baseUrl - base url of the journey, gets prepended to question urls */
41
+ baseUrl: string;
42
+ /** @type {(journeyResponse: import('./journey-response.js').JourneyResponse) => string} makeBaseUrl - function to generate base url of the journey */
43
+ makeBaseUrl: (journeyResponse: import("./journey-response.js").JourneyResponse) => string;
44
+ /** @type {string} taskListUrl - url that renders the task list */
45
+ taskListUrl: string;
46
+ /** @type {string} journeyTemplate - nunjucks template file used for */
47
+ journeyTemplate: string;
48
+ /** @type {string} taskListTemplate - nunjucks template file used for listing page */
49
+ taskListTemplate: string;
50
+ /** @type {string} informationPageViewPath - nunjucks template file used for pdf summary information page */
51
+ informationPageViewPath: string;
52
+ /** @type {boolean} defines how the next/previous question handles end of sections */
53
+ returnToListing: boolean;
54
+ /**@type {string} used as part of the overall page title */
55
+ journeyTitle: string;
56
+ initialBackLink: string | null;
57
+ /**
58
+ * Gets section based on segment
59
+ * @param {string} sectionSegment
60
+ * @returns {import('../section.js').Section | undefined}
61
+ */
62
+ getSection(sectionSegment: string): import("../section.js").Section | undefined;
63
+ /**
64
+ * gets a question from the object's sections based on a section + question names
65
+ * @param {import('./journey-types.js').RouteParams} params
66
+ * @returns {import('../questions/question.js').Question | undefined} question found by lookup
67
+ */
68
+ getQuestionByParams(params: import("./journey-types.js").RouteParams): import("../questions/question.js").Question | undefined;
69
+ /**
70
+ * Get the back link for the journey - e.g. the previous question
71
+ *
72
+ * @param {Object} options
73
+ * @param {import('./journey-types.js').RouteParams} options.params
74
+ * @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
75
+ * @returns {string|null} url for the next question, or null if unmatched
76
+ */
77
+ getBackLink({ params, manageListQuestion }: {
78
+ params: import("./journey-types.js").RouteParams;
79
+ manageListQuestion?: typeof import("#src/components/manage-list/question.js") | undefined;
80
+ }): string | null;
81
+ /**
82
+ * Handles redirect to the next question in the journey
83
+ * Used after question post/saving
84
+ *
85
+ * @param {import('express').Response} res
86
+ * @param {import('./journey-types.js').RouteParams} params
87
+ * @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
88
+ * @returns {void}
89
+ */
90
+ redirectToNextQuestion(res: import("express").Response, params: import("./journey-types.js").RouteParams, manageListQuestion?: typeof import("#src/components/manage-list/question.js")): void;
91
+ /**
92
+ * Get url for the next question in the journey
93
+ *
94
+ * @param {import('./journey-types.js').RouteParams} params
95
+ * @param {Object} options
96
+ * @param {boolean} [options.reverse] - if passed in this will get the previous question
97
+ * @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
98
+ * @returns {string|null} url for the next question, or null if unmatched
99
+ */
100
+ getNextQuestionUrl(params: import("./journey-types.js").RouteParams, { reverse, manageListQuestion }?: {
101
+ reverse?: boolean | undefined;
102
+ manageListQuestion?: typeof import("#src/components/manage-list/question.js") | undefined;
103
+ }): string | null;
104
+ /**
105
+ * Gets the url for the current question
106
+ * @param {string} sectionSegment - section segment name
107
+ * @param {string} questionSegment - question segment name
108
+ * @returns {string} url for the current question
109
+ */
110
+ getCurrentQuestionUrl: (sectionSegment: string, questionSegment: string) => string;
111
+ /**
112
+ * Gets the url for the current question
113
+ * @param {string} questionSegment - question segment name
114
+ * @returns {string} url for the current question
115
+ */
116
+ getCurrentQuestionUrlWithoutSection: (questionSegment: string) => string;
117
+ /**
118
+ * Gets the url for the current question
119
+ * @param {string} sectionSegment - section segment name
120
+ * @param {string} questionSegment - question segment name
121
+ * @param {string} addition - question segment name
122
+ * @returns {string} url for the current question
123
+ */
124
+ addToCurrentQuestionUrl: (sectionSegment: string, questionSegment: string, addition: string) => string;
125
+ /**
126
+ * Gets the overall completeness status of a journey based on the response associated with it and the complete state of each section.
127
+ * @returns {boolean} Boolean indicating if a journey response is complete
128
+ */
129
+ isComplete(): boolean;
130
+ /**
131
+ * @param {import('./journey-response.js').JourneyResponse} journeyResponse
132
+ */
133
+ setResponse(journeyResponse: import("./journey-response.js").JourneyResponse): void;
134
+ #private;
135
+ }
136
+ //# sourceMappingURL=journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.d.ts","sourceRoot":"","sources":["../../../src/journey/journey.js"],"names":[],"mappings":"AAQA;;;GAGG;AACH;IAwBC;;;;;;;;;;;;;;OAcG;IACH,qLAZG;QAAwB,SAAS,EAAzB,MAAM;QACyE,WAAW,EAA1F,CAAC,QAAQ,EAAE,OAAO,uBAAuB,EAAE,eAAe,KAAK,MAAM;QACpD,WAAW;QAC6B,QAAQ,EAAjE,OAAO,uBAAuB,EAAE,eAAe;QAC/B,eAAe,EAA/B,MAAM;QACU,gBAAgB,EAAhC,MAAM;QACW,uBAAuB;QACxB,YAAY,EAA5B,MAAM;QACY,eAAe;QACU,QAAQ,EAAnD,OAAO,eAAe,EAAE,OAAO,EAAE;QAChB,eAAe;KAC1C,EAoDA;IAzFD,8EAA8E;IAC9E,WADW,MAAM,CACP;IACV,6FAA6F;IAC7F,UADW,KAAK,CAAE,OAAO,eAAe,EAAE,OAAO,CAAC,CACpC;IACd,mHAAmH;IACnH,UADW,OAAO,uBAAuB,EAAE,eAAe,CACjD;IACT,wFAAwF;IACxF,SADW,MAAM,CACJ;IACb,sJAAsJ;IACtJ,aADW,CAAC,eAAe,EAAE,OAAO,uBAAuB,EAAE,eAAe,KAAK,MAAM,CAChE;IACvB,kEAAkE;IAClE,aADW,MAAM,CACA;IACjB,uEAAuE;IACvE,iBADW,MAAM,CACI;IACrB,qFAAqF;IACrF,kBADW,MAAM,CACK;IACtB,4GAA4G;IAC5G,yBADW,MAAM,CACY;IAC7B,qFAAqF;IACrF,iBADW,OAAO,CACM;IACxB,2DAA2D;IAC3D,cADU,MAAM,CACH;IAmEZ,+BAA8C;IA2C/C;;;;OAIG;IACH,2BAHW,MAAM,GACJ,OAAO,eAAe,EAAE,OAAO,GAAG,SAAS,CAMvD;IA8BD;;;;OAIG;IACH,4BAHW,OAAO,oBAAoB,EAAE,WAAW,GACtC,OAAO,0BAA0B,EAAE,QAAQ,GAAG,SAAS,CAiBnE;IAED;;;;;;;OAOG;IACH,4CAJG;QAA0D,MAAM,EAAxD,OAAO,oBAAoB,EAAE,WAAW;QACoB,kBAAkB;KACtF,GAAU,MAAM,GAAC,IAAI,CAWvB;IAED;;;;;;;;OAQG;IACH,4BALW,OAAO,SAAS,EAAE,QAAQ,UAC1B,OAAO,oBAAoB,EAAE,WAAW,kFAEtC,IAAI,CAKhB;IAED;;;;;;;;OAQG;IACH,2BANW,OAAO,oBAAoB,EAAE,WAAW,oCAEhD;QAA0B,OAAO;QACmC,kBAAkB;KACtF,GAAU,MAAM,GAAC,IAAI,CAyEvB;IAED;;;;;OAKG;IACH,wBAAyB,gBAJd,MAI4B,EAAE,iBAH9B,MAG6C,KAF3C,MAAM,CAqBjB;IAEF;;;;OAIG;IACH,sCAAuC,iBAH5B,MAG2C,KAFzC,MAAM,CAIjB;IAEF;;;;;;OAMG;IACH,0BAA2B,gBALhB,MAK8B,EAAE,iBAJhC,MAI+C,EAAE,UAHjD,MAGyD,KAFvD,MAAM,CAuBjB;IAEF;;;OAGG;IACH,cAFa,OAAO,CAInB;IAED;;OAEG;IACH,6BAFW,OAAO,uBAAuB,EAAE,eAAe,QAKzD;;CACD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {import('@prisma/client').Prisma.AddressGetPayload<{}>} address
3
+ * @returns {string}
4
+ */
5
+ export function addressToViewModel(address: any): string;
6
+ //# sourceMappingURL=address-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/address-utils.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,kDAFa,MAAM,CAKlB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Defines the shape of an address object
3
+ * @class
4
+ */
5
+ export class Address {
6
+ /**
7
+ * creates an instance of an address
8
+ * @param {Object} params
9
+ * @param {string} params.addressLine1
10
+ * @param {string} params.addressLine2
11
+ * @param {string} params.townCity
12
+ * @param {string} params.county
13
+ * @param {string} params.postcode
14
+ */
15
+ constructor({ addressLine1, addressLine2, townCity, county, postcode }: {
16
+ addressLine1: string;
17
+ addressLine2: string;
18
+ townCity: string;
19
+ county: string;
20
+ postcode: string;
21
+ });
22
+ /**
23
+ * @type {string} - the first line of the address
24
+ */
25
+ addressLine1: string;
26
+ /**
27
+ * @type {string} - the second line of the address
28
+ */
29
+ addressLine2: string;
30
+ /**
31
+ * @type {string} - the name of the town, city or other settlement
32
+ */
33
+ townCity: string;
34
+ /**
35
+ * @type {string} - the name of the town, city or other settlement
36
+ */
37
+ county: string;
38
+ /**
39
+ * @type {string} - the postcode
40
+ */
41
+ postcode: string;
42
+ }
43
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/lib/address.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IA0BC;;;;;;;;OAQG;IACH,wEANG;QAAuB,YAAY,EAA3B,MAAM;QACS,YAAY,EAA3B,MAAM;QACS,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;QACS,QAAQ,EAAvB,MAAM;KAChB,EAOA;IAxCD;;OAEG;IACH,cAFU,MAAM,CAEH;IAEb;;OAEG;IACH,cAFU,MAAM,CAEH;IAEb;;OAEG;IACH,UAFU,MAAM,CAEP;IAET;;OAEG;IACH,QAFU,MAAM,CAET;IAEP;;OAEG;IACH,UAFU,MAAM,CAEP;CAkBT"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Display the date in Europe/London
3
+ * @param {Date|string} [date]
4
+ * @param {Object} [options]
5
+ * @param {string} [options.format] date formatting string
6
+ * @returns {string} formatted date string or empty string if invalid value passed in
7
+ */
8
+ export function formatDateForDisplay(date?: Date | string, { format }?: {
9
+ format?: string | undefined;
10
+ }): string;
11
+ /**
12
+ * @typedef {Object} DateTimeParams
13
+ * @property {number} year
14
+ * @property {number} month
15
+ * @property {number} day
16
+ * @property {number} [hour]
17
+ * @property {number} [minute]
18
+ * @property {number} [second]
19
+ * @property {boolean} [convertToUTC]
20
+ */
21
+ /**
22
+ * Parse the date and time parameters provided by a user
23
+ * @param {DateTimeParams} params
24
+ * @returns {Date}
25
+ */
26
+ export function parseDateInput({ year, month, day, hour, minute, second }: DateTimeParams): Date;
27
+ /**
28
+ * Start of the day in UK time zone
29
+ */
30
+ export function startOfDay(): Date;
31
+ /**
32
+ * End of the day in UK time zone
33
+ */
34
+ export function endOfDay(): Date;
35
+ /**
36
+ * Check if today is within the date range inclusive (start <= now <= end)
37
+ * @param {Date} startDate
38
+ * @param {Date} endDate
39
+ * @returns {boolean}
40
+ */
41
+ export function nowIsWithinRange(startDate: Date, endDate: Date): boolean;
42
+ /**
43
+ * Check if today is on or after the start date
44
+ * @param {Date} startDate
45
+ * @returns {boolean}
46
+ */
47
+ export function isNowAfterStartDate(startDate: Date): boolean;
48
+ export function dateIsAfterToday(date: Date): boolean;
49
+ export function dateIsBeforeToday(date: Date): boolean;
50
+ export function dateIsToday(date: Date): boolean;
51
+ export type DateTimeParams = {
52
+ year: number;
53
+ month: number;
54
+ day: number;
55
+ hour?: number | undefined;
56
+ minute?: number | undefined;
57
+ second?: number | undefined;
58
+ convertToUTC?: boolean | undefined;
59
+ };
60
+ //# sourceMappingURL=date-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/date-utils.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,4CALW,IAAI,GAAC,MAAM,eAEnB;IAAyB,MAAM;CAC/B,GAAU,MAAM,CAMlB;AAED;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,2EAHW,cAAc,GACZ,IAAI,CAMhB;AAED;;GAEG;AACH,mCAWC;AAED;;GAEG;AACH,iCAWC;AAqCD;;;;;GAKG;AACH,4CAJW,IAAI,WACJ,IAAI,GACF,OAAO,CASnB;AAED;;;;GAIG;AACH,+CAHW,IAAI,GACF,OAAO,CASnB;AA/CM,uCAHI,IAAI,GACF,OAAO,CAInB;AAMM,wCAHI,IAAI,GACF,OAAO,CAInB;AAMM,kCAHI,IAAI,GACF,OAAO,CAInB;;UArFa,MAAM;WACN,MAAM;SACN,MAAM"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * A `SaveDataFn` implementation that saves answers to the session.
3
+ * Answers are saved into a forms object, keyed by the journeyId, and optionally by a request parameter
4
+ * @example
5
+ * req: {
6
+ * session: {
7
+ * forms: {
8
+ * 'journey-id-1': {
9
+ * questionOne: 'my answer'
10
+ * // ...
11
+ * }
12
+ * }
13
+ * }
14
+ * }
15
+ *
16
+ * or when keyed by a req parameter:
17
+ * @example
18
+ * req: {
19
+ * session: {
20
+ * forms: {
21
+ * 'some-req-param': {
22
+ * 'journey-id-1': {
23
+ * questionOne: 'my answer'
24
+ * // ...
25
+ * }
26
+ * }
27
+ * }
28
+ * }
29
+ * }
30
+ *
31
+ * Delete behavior for manage-list items:
32
+ * - When `manageListItemRemove === true`, and both `manageListQuestionFieldName` and `req.params.manageListItemId`
33
+ * are present, the item with a matching `id` is removed from the array stored at `answers[manageListQuestionFieldName]`.
34
+ * - If the list does not exist or is not an array, no action is taken.
35
+ *
36
+ * @param {Object} opts
37
+ * @param {string} [opts.reqParam]
38
+ * - optional request parameter to use as a key
39
+ * @returns {import('../controller.js').SaveDataFn}
40
+ */
41
+ export function buildSaveDataToSession({ reqParam }?: {
42
+ reqParam?: string | undefined;
43
+ }): import("../controller.js").SaveDataFn;
44
+ /**
45
+ * A function to clear journey answers from the session
46
+ *
47
+ * @example
48
+ * req: {
49
+ * session: {
50
+ * forms: {
51
+ * 'journey-id-1': {
52
+ * questionOne: 'my answer'
53
+ * // ...
54
+ * }
55
+ * }
56
+ * }
57
+ * }
58
+ *
59
+ * @param {Object} params
60
+ * @param {import('express').Request} params.req
61
+ * @param {string} params.journeyId
62
+ * @param {Object<string, any>} [params.replaceWith] - optional data to replace the form answers with
63
+ * @param {string} [params.reqParam] - optional request parameter used as a key
64
+ * @returns {void}
65
+ */
66
+ export function clearDataFromSession({ req, journeyId, replaceWith, reqParam }: {
67
+ req: import("express").Request;
68
+ journeyId: string;
69
+ replaceWith?: {
70
+ [x: string]: any;
71
+ } | undefined;
72
+ reqParam?: string | undefined;
73
+ }): void;
74
+ /**
75
+ * Fetch session answers from the session
76
+ *
77
+ * @param {string} journeyId
78
+ * @param {string} [reqParam] - optional request parameter used as a key
79
+ * @returns {import('express').Handler}
80
+ */
81
+ export function buildGetJourneyResponseFromSession(journeyId: string, reqParam?: string): import("express").Handler;
82
+ /**
83
+ * Default save-to-session function with no request parameter
84
+ *
85
+ * @type {import('../controller.js').SaveDataFn}
86
+ */
87
+ export const saveDataToSession: import("../controller.js").SaveDataFn;
88
+ //# sourceMappingURL=session-answer-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-answer-store.d.ts","sourceRoot":"","sources":["../../../src/lib/session-answer-store.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,sDAJG;IAAsB,QAAQ;CAE9B,GAAU,OAAO,kBAAkB,EAAE,UAAU,CA8CjD;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gFANG;IAA0C,GAAG,EAArC,OAAO,SAAS,EAAE,OAAO;IACV,SAAS,EAAxB,MAAM;IACuB,WAAW;;;IACxB,QAAQ;CAChC,GAAU,IAAI,CAkBhB;AAED;;;;;;GAMG;AACH,8DAJW,MAAM,aACN,MAAM,GACJ,OAAO,SAAS,EAAE,OAAO,CA2BrC;AA/ED;;;;GAIG;AACH,gCAFU,OAAO,kBAAkB,EAAE,UAAU,CAEW"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * replaces new line chars with a <br>
3
+ * @param {string} [value]
4
+ * @returns {string}
5
+ */
6
+ export function nl2br(value?: string): string;
7
+ /**
8
+ * @param {string|any} str
9
+ * @returns {string}
10
+ */
11
+ export function capitalize(str: string | any): string;
12
+ /**
13
+ * Trim a trailing slash if present
14
+ *
15
+ * @param {string} [str]
16
+ * @returns {string}
17
+ */
18
+ export function trimTrailingSlash(str?: string): string;
19
+ /**
20
+ * Convert a value to an array, unless it is already
21
+ *
22
+ * @param {T|T[]} value
23
+ * @template T
24
+ */
25
+ export function toArray<T>(value: T | T[]): T[];
26
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;GAGG;AACH,gCAHW,MAAM,GAAC,GAAG,GACR,MAAM,CAKlB;AAED;;;;;GAKG;AACH,wCAHW,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;GAKG;AACH,wBAFa,CAAC,SADH,CAAC,GAAC,CAAC,EAAE,OAKf"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Wrapper class so it can be overridden by test mocks
3
+ */
4
+ export class Uuid {
5
+ static randomUUID(): `${string}-${string}-${string}-${string}-${string}`;
6
+ }
7
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/lib/uuid.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACC,yEAEC;CACD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {(req: import('express').Request, journeyResponse: import('../journey/journey-response.js').JourneyResponse) => import('../journey/journey.js').Journey} createJourney
3
+ * @returns {import('express').Handler}
4
+ */
5
+ export function buildGetJourney(createJourney: (req: import("express").Request, journeyResponse: import("../journey/journey-response.js").JourneyResponse) => import("../journey/journey.js").Journey): import("express").Handler;
6
+ //# sourceMappingURL=build-get-journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-get-journey.d.ts","sourceRoot":"","sources":["../../../src/middleware/build-get-journey.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+CAHW,CAAC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,gCAAgC,EAAE,eAAe,KAAK,OAAO,uBAAuB,EAAE,OAAO,GACpJ,OAAO,SAAS,EAAE,OAAO,CAgBrC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @typedef {function(import('../section').Question, import('../journey/journey-response').JourneyResponse): boolean} ShouldDisplayCondition
3
+ */
4
+ /**
5
+ * Redirects to the first unanswered question in a journey, or to the task list if complete
6
+ *
7
+ * @param {ShouldDisplayCondition[]} [conditions]
8
+ * @returns {import('express').Handler}
9
+ */
10
+ export function redirectToUnansweredQuestion(conditions?: ShouldDisplayCondition[]): import("express").Handler;
11
+ export type ShouldDisplayCondition = (arg0: any, arg1: any) => boolean;
12
+ //# sourceMappingURL=redirect-to-unanswered-question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-to-unanswered-question.d.ts","sourceRoot":"","sources":["../../../src/middleware/redirect-to-unanswered-question.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,0DAHW,sBAAsB,EAAE,GACtB,OAAO,SAAS,EAAE,OAAO,CA8BrC;qCArCY,CAAS,IAA6B,EAA7B,GAA6B,EAAE,IAAqD,EAArD,GAAqD,KAAG,OAAO"}
@@ -0,0 +1,21 @@
1
+ /** @typedef {import('./question-props').QuestionProps} QuestionProps */
2
+ /**
3
+ * @param {{[questionName: string]: QuestionProps}} questionPropsRecord
4
+ * @param {Record<string, import('./question-types.js').QuestionClass>} questionClasses
5
+ * @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
6
+ * @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
7
+ */
8
+ export function createQuestions(questionPropsRecord: {
9
+ [questionName: string]: QuestionProps;
10
+ }, questionClasses: Record<string, import("./question-types.js").QuestionClass>, questionMethodOverrides: {
11
+ [questionType: string]: Record<string, Function>;
12
+ }, textOverrides?: {
13
+ notStartedText?: string;
14
+ continueButtonText?: string;
15
+ changeActionText?: string;
16
+ answerActionText?: string;
17
+ }): {
18
+ [k: string]: Question;
19
+ };
20
+ export type QuestionProps = any;
21
+ //# sourceMappingURL=create-questions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-questions.d.ts","sourceRoot":"","sources":["../../../src/questions/create-questions.js"],"names":[],"mappings":"AAAA,wEAAwE;AAExE;;;;;GAKG;AACH,qDALW;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAAA;CAAC,mBACvC,MAAM,CAAC,MAAM,EAAE,OAAO,qBAAqB,EAAE,aAAa,CAAC,2BAC3D;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,WAAW,CAAA;CAAC,kBAClD;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAC;;EAwBtH"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @typedef {{
3
+ * text: string;
4
+ * value: string;
5
+ * hint?: object;
6
+ * checked?: boolean | undefined;
7
+ * attributes?: Record<string, string>;
8
+ * behaviour?: 'exclusive';
9
+ * conditional?: {
10
+ * question: string;
11
+ * type: string;
12
+ * fieldName: string;
13
+ * inputClasses?: string;
14
+ * html?: string;
15
+ * value?: unknown;
16
+ * label?: string;
17
+ * hint?: string
18
+ * };
19
+ * conditionalText?: {
20
+ * html: string;
21
+ * }
22
+ *}} Option
23
+ */
24
+ /**
25
+ * @typedef {import('./question').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
26
+ */
27
+ /**
28
+ * @typedef {import('#question-types').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
29
+ */
30
+ export class OptionsQuestion extends Question {
31
+ /**
32
+ * @param {OptionsQuestionParameters} params
33
+ */
34
+ constructor(params: OptionsQuestionParameters);
35
+ /** @type {Array<Option>} */
36
+ options: Array<Option>;
37
+ optionJoinString: string;
38
+ /**
39
+ * gets the view model for this question
40
+ * @param {import('#section').Section} section - the current section
41
+ * @param {import('#journey').Journey} journey - the journey we are in
42
+ * @param {Record<string, unknown>} [customViewData] additional data to send to view
43
+ * @param {Record<string, unknown>} [payload]
44
+ * @param {import('#question-types').PrepQuestionForRenderingOptions} options
45
+ * @returns {import('./question').QuestionViewModel} QuestionViewModel
46
+ */
47
+ prepQuestionForRendering(section: import("#section").Section, journey: import("#journey").Journey, customViewData?: Record<string, unknown>, payload?: Record<string, unknown>, options: import("#question-types").PrepQuestionForRenderingOptions): any;
48
+ }
49
+ export default OptionsQuestion;
50
+ export type Option = {
51
+ text: string;
52
+ value: string;
53
+ hint?: object;
54
+ checked?: boolean | undefined;
55
+ attributes?: Record<string, string>;
56
+ behaviour?: "exclusive";
57
+ conditional?: {
58
+ question: string;
59
+ type: string;
60
+ fieldName: string;
61
+ inputClasses?: string;
62
+ html?: string;
63
+ value?: unknown;
64
+ label?: string;
65
+ hint?: string;
66
+ };
67
+ conditionalText?: {
68
+ html: string;
69
+ };
70
+ };
71
+ export type OptionsViewModel = any & {
72
+ question: {
73
+ options: Option[];
74
+ };
75
+ };
76
+ export type OptionsQuestionParameters = import("#question-types").QuestionParameters & {
77
+ options: Array<Option>;
78
+ };
79
+ import { Question } from './question.js';
80
+ //# sourceMappingURL=options-question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-question.d.ts","sourceRoot":"","sources":["../../../src/questions/options-question.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AACH;;GAEG;AAEH;IAIC;;OAEG;IACH,oBAFW,yBAAyB,EAenC;IAnBD,4BAA4B;IAC5B,SADW,KAAK,CAAC,MAAM,CAAC,CAChB;IAiBP,yBAA+C;IAGhD;;;;;;;;OAQG;IACH,kCAPW,OAAO,UAAU,EAAE,OAAO,WAC1B,OAAO,UAAU,EAAE,OAAO,mBAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WACvB,OAAO,iBAAiB,EAAE,+BAA+B,OAmDnE;CAmCD;;qBAhJY;IACR,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;KAClB,CAAC;IACA,eAAe,CAAC,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAA;CACH;+BAIU,GAAsC,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE;wCAG5E,OAAO,iBAAiB,EAAE,kBAAkB,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAE;yBAnC7D,eAAe"}