@dwp/govuk-casa 9.0.0 → 9.2.0

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 (199) hide show
  1. package/README.md +9 -9
  2. package/dist/assets/css/casa.css +1 -1
  3. package/dist/assets/css/casa.css.map +1 -1
  4. package/dist/casa.d.ts +122 -95
  5. package/dist/casa.js +119 -86
  6. package/dist/casa.js.map +1 -1
  7. package/dist/lib/CasaTemplateLoader.d.ts +4 -4
  8. package/dist/lib/CasaTemplateLoader.js +16 -16
  9. package/dist/lib/CasaTemplateLoader.js.map +1 -1
  10. package/dist/lib/JourneyContext.d.ts +58 -40
  11. package/dist/lib/JourneyContext.js +132 -75
  12. package/dist/lib/JourneyContext.js.map +1 -1
  13. package/dist/lib/MutableRouter.d.ts +40 -41
  14. package/dist/lib/MutableRouter.js +64 -71
  15. package/dist/lib/MutableRouter.js.map +1 -1
  16. package/dist/lib/Plan.d.ts +29 -26
  17. package/dist/lib/Plan.js +85 -71
  18. package/dist/lib/Plan.js.map +1 -1
  19. package/dist/lib/ValidationError.d.ts +16 -15
  20. package/dist/lib/ValidationError.js +21 -20
  21. package/dist/lib/ValidationError.js.map +1 -1
  22. package/dist/lib/ValidatorFactory.d.ts +15 -13
  23. package/dist/lib/ValidatorFactory.js +14 -12
  24. package/dist/lib/ValidatorFactory.js.map +1 -1
  25. package/dist/lib/configuration-ingestor.d.ts +37 -40
  26. package/dist/lib/configuration-ingestor.js +93 -93
  27. package/dist/lib/configuration-ingestor.js.map +1 -1
  28. package/dist/lib/configure.d.ts +6 -6
  29. package/dist/lib/configure.js +14 -12
  30. package/dist/lib/configure.js.map +1 -1
  31. package/dist/lib/constants.d.ts +1 -3
  32. package/dist/lib/constants.js +9 -11
  33. package/dist/lib/constants.js.map +1 -1
  34. package/dist/lib/context-id-generators.d.ts +3 -5
  35. package/dist/lib/context-id-generators.js +7 -6
  36. package/dist/lib/context-id-generators.js.map +1 -1
  37. package/dist/lib/end-session.d.ts +4 -4
  38. package/dist/lib/end-session.js +5 -5
  39. package/dist/lib/field.d.ts +20 -18
  40. package/dist/lib/field.js +35 -48
  41. package/dist/lib/field.js.map +1 -1
  42. package/dist/lib/index.d.ts +13 -13
  43. package/dist/lib/logger.d.ts +7 -6
  44. package/dist/lib/logger.js +7 -7
  45. package/dist/lib/logger.js.map +1 -1
  46. package/dist/lib/mount.d.ts +5 -5
  47. package/dist/lib/mount.js +11 -10
  48. package/dist/lib/mount.js.map +1 -1
  49. package/dist/lib/nunjucks-filters.d.ts +10 -12
  50. package/dist/lib/nunjucks-filters.js +35 -35
  51. package/dist/lib/nunjucks-filters.js.map +1 -1
  52. package/dist/lib/nunjucks.d.ts +7 -5
  53. package/dist/lib/nunjucks.js +10 -8
  54. package/dist/lib/nunjucks.js.map +1 -1
  55. package/dist/lib/utils.d.ts +19 -19
  56. package/dist/lib/utils.js +62 -55
  57. package/dist/lib/utils.js.map +1 -1
  58. package/dist/lib/validators/dateObject.d.ts +29 -22
  59. package/dist/lib/validators/dateObject.js +58 -49
  60. package/dist/lib/validators/dateObject.js.map +1 -1
  61. package/dist/lib/validators/email.d.ts +4 -4
  62. package/dist/lib/validators/email.js +4 -4
  63. package/dist/lib/validators/inArray.d.ts +4 -4
  64. package/dist/lib/validators/inArray.js +7 -8
  65. package/dist/lib/validators/inArray.js.map +1 -1
  66. package/dist/lib/validators/index.d.ts +10 -10
  67. package/dist/lib/validators/index.js +1 -3
  68. package/dist/lib/validators/index.js.map +1 -1
  69. package/dist/lib/validators/nino.d.ts +9 -8
  70. package/dist/lib/validators/nino.js +14 -10
  71. package/dist/lib/validators/nino.js.map +1 -1
  72. package/dist/lib/validators/postalAddressObject.d.ts +37 -24
  73. package/dist/lib/validators/postalAddressObject.js +65 -46
  74. package/dist/lib/validators/postalAddressObject.js.map +1 -1
  75. package/dist/lib/validators/range.d.ts +12 -8
  76. package/dist/lib/validators/range.js +11 -9
  77. package/dist/lib/validators/range.js.map +1 -1
  78. package/dist/lib/validators/regex.d.ts +4 -4
  79. package/dist/lib/validators/regex.js +5 -5
  80. package/dist/lib/validators/required.d.ts +6 -6
  81. package/dist/lib/validators/required.js +9 -11
  82. package/dist/lib/validators/required.js.map +1 -1
  83. package/dist/lib/validators/strlen.d.ts +12 -8
  84. package/dist/lib/validators/strlen.js +13 -11
  85. package/dist/lib/validators/strlen.js.map +1 -1
  86. package/dist/lib/validators/wordCount.d.ts +12 -8
  87. package/dist/lib/validators/wordCount.js +15 -11
  88. package/dist/lib/validators/wordCount.js.map +1 -1
  89. package/dist/lib/waypoint-url.d.ts +16 -13
  90. package/dist/lib/waypoint-url.js +39 -36
  91. package/dist/lib/waypoint-url.js.map +1 -1
  92. package/dist/middleware/body-parser.d.ts +1 -1
  93. package/dist/middleware/body-parser.js +6 -6
  94. package/dist/middleware/body-parser.js.map +1 -1
  95. package/dist/middleware/data.d.ts +1 -1
  96. package/dist/middleware/data.js +8 -7
  97. package/dist/middleware/data.js.map +1 -1
  98. package/dist/middleware/gather-fields.d.ts +2 -2
  99. package/dist/middleware/gather-fields.js +6 -4
  100. package/dist/middleware/gather-fields.js.map +1 -1
  101. package/dist/middleware/i18n.js +13 -15
  102. package/dist/middleware/i18n.js.map +1 -1
  103. package/dist/middleware/post.js +30 -18
  104. package/dist/middleware/post.js.map +1 -1
  105. package/dist/middleware/pre.d.ts +2 -2
  106. package/dist/middleware/pre.js +46 -27
  107. package/dist/middleware/pre.js.map +1 -1
  108. package/dist/middleware/progress-journey.d.ts +1 -1
  109. package/dist/middleware/progress-journey.js +5 -5
  110. package/dist/middleware/progress-journey.js.map +1 -1
  111. package/dist/middleware/sanitise-fields.d.ts +1 -1
  112. package/dist/middleware/sanitise-fields.js +13 -11
  113. package/dist/middleware/sanitise-fields.js.map +1 -1
  114. package/dist/middleware/serve-first-waypoint.d.ts +3 -3
  115. package/dist/middleware/serve-first-waypoint.js +8 -6
  116. package/dist/middleware/serve-first-waypoint.js.map +1 -1
  117. package/dist/middleware/session.js +14 -11
  118. package/dist/middleware/session.js.map +1 -1
  119. package/dist/middleware/skip-waypoint.d.ts +1 -1
  120. package/dist/middleware/skip-waypoint.js +5 -9
  121. package/dist/middleware/skip-waypoint.js.map +1 -1
  122. package/dist/middleware/steer-journey.d.ts +1 -1
  123. package/dist/middleware/steer-journey.js +16 -14
  124. package/dist/middleware/steer-journey.js.map +1 -1
  125. package/dist/middleware/strip-proxy-path.d.ts +1 -1
  126. package/dist/middleware/strip-proxy-path.js +3 -3
  127. package/dist/middleware/strip-proxy-path.js.map +1 -1
  128. package/dist/middleware/validate-fields.d.ts +1 -1
  129. package/dist/middleware/validate-fields.js +2 -5
  130. package/dist/middleware/validate-fields.js.map +1 -1
  131. package/dist/routes/ancillary.d.ts +3 -3
  132. package/dist/routes/ancillary.js +4 -4
  133. package/dist/routes/ancillary.js.map +1 -1
  134. package/dist/routes/journey.d.ts +2 -2
  135. package/dist/routes/journey.js +91 -39
  136. package/dist/routes/journey.js.map +1 -1
  137. package/dist/routes/static.d.ts +7 -5
  138. package/dist/routes/static.js +20 -19
  139. package/dist/routes/static.js.map +1 -1
  140. package/package.json +20 -19
  141. package/src/casa.js +133 -100
  142. package/src/lib/CasaTemplateLoader.js +24 -19
  143. package/src/lib/JourneyContext.js +190 -107
  144. package/src/lib/MutableRouter.js +72 -74
  145. package/src/lib/Plan.js +145 -97
  146. package/src/lib/ValidationError.js +25 -21
  147. package/src/lib/ValidatorFactory.js +17 -13
  148. package/src/lib/configuration-ingestor.js +147 -110
  149. package/src/lib/configure.js +34 -32
  150. package/src/lib/constants.js +9 -11
  151. package/src/lib/context-id-generators.js +40 -43
  152. package/src/lib/end-session.js +6 -6
  153. package/src/lib/field.js +69 -58
  154. package/src/lib/index.js +12 -12
  155. package/src/lib/logger.js +9 -9
  156. package/src/lib/mount.js +70 -74
  157. package/src/lib/nunjucks-filters.js +56 -59
  158. package/src/lib/nunjucks.js +23 -18
  159. package/src/lib/utils.js +78 -57
  160. package/src/lib/validators/dateObject.js +71 -60
  161. package/src/lib/validators/email.js +8 -8
  162. package/src/lib/validators/inArray.js +10 -11
  163. package/src/lib/validators/index.js +12 -14
  164. package/src/lib/validators/nino.js +29 -15
  165. package/src/lib/validators/postalAddressObject.js +87 -63
  166. package/src/lib/validators/range.js +14 -12
  167. package/src/lib/validators/regex.js +8 -8
  168. package/src/lib/validators/required.js +16 -16
  169. package/src/lib/validators/strlen.js +16 -14
  170. package/src/lib/validators/wordCount.js +22 -14
  171. package/src/lib/waypoint-url.js +64 -46
  172. package/src/middleware/body-parser.js +10 -10
  173. package/src/middleware/csrf.js +1 -1
  174. package/src/middleware/data.js +28 -24
  175. package/src/middleware/gather-fields.js +10 -9
  176. package/src/middleware/i18n.js +35 -37
  177. package/src/middleware/post.js +41 -21
  178. package/src/middleware/pre.js +62 -41
  179. package/src/middleware/progress-journey.js +32 -18
  180. package/src/middleware/sanitise-fields.js +43 -20
  181. package/src/middleware/serve-first-waypoint.js +14 -12
  182. package/src/middleware/session.js +74 -61
  183. package/src/middleware/skip-waypoint.js +8 -15
  184. package/src/middleware/steer-journey.js +40 -28
  185. package/src/middleware/strip-proxy-path.js +8 -7
  186. package/src/middleware/validate-fields.js +5 -12
  187. package/src/routes/ancillary.js +5 -7
  188. package/src/routes/journey.js +159 -85
  189. package/src/routes/static.js +62 -29
  190. package/views/casa/components/character-count/README.md +2 -2
  191. package/views/casa/components/checkboxes/README.md +6 -6
  192. package/views/casa/components/date-input/README.md +7 -7
  193. package/views/casa/components/input/README.md +2 -2
  194. package/views/casa/components/journey-form/README.md +33 -14
  195. package/views/casa/components/postal-address-object/README.md +4 -4
  196. package/views/casa/components/radios/README.md +6 -6
  197. package/views/casa/components/select/README.md +6 -6
  198. package/views/casa/components/textarea/README.md +2 -2
  199. package/views/casa/layouts/main.njk +2 -1
package/dist/casa.js CHANGED
@@ -56,9 +56,7 @@ const contextIdGenerators = __importStar(require("./lib/context-id-generators.js
56
56
  exports.contextIdGenerators = contextIdGenerators;
57
57
  /* ----------------------------------------------------------------- Typedefs */
58
58
  // These exist here so that consumer can import CASA's internal types
59
- /**
60
- * @typedef {import('./lib/field').PageField} PageField
61
- */
59
+ /** @typedef {import("./lib/field").PageField} PageField */
62
60
  /**
63
61
  * @typedef {object} ContextEventHandlerOptions
64
62
  * @property {JourneyContext} journeyContext Context including changes
@@ -73,7 +71,8 @@ exports.contextIdGenerators = contextIdGenerators;
73
71
  */
74
72
  /**
75
73
  * @typedef {object} ContextEventUserInfo
76
- * @property {symbol} [casaRequestPhase] Request phase at which event is triggered
74
+ * @property {symbol} [casaRequestPhase] Request phase at which event is
75
+ * triggered
77
76
  */
78
77
  /**
79
78
  * @typedef {object} ContextEvent
@@ -82,43 +81,53 @@ exports.contextIdGenerators = contextIdGenerators;
82
81
  * @property {ContextEventHandler} handler Handler to invoke when change happens
83
82
  */
84
83
  /**
85
- * @typedef {object} Page Page configuration. A Page is the interactive representation of a waypoint
84
+ * @typedef {object} Page Page configuration. A Page is the interactive
85
+ * representation of a waypoint
86
86
  * @property {string} waypoint The waypoint with which this page is associated
87
87
  * @property {string} view Template path
88
- * @property {PageHook[]} [hooks=[]] Page-specific hooks (optional, default [])
89
- * @property {PageField[]} [fields=[]] Fields to be managed on this page (optional, default [])
88
+ * @property {PageHook[]} [hooks=[]] Page-specific hooks (optional, default []).
89
+ * Default is `[]`
90
+ * @property {PageField[]} [fields=[]] Fields to be managed on this page
91
+ * (optional, default []). Default is `[]`
90
92
  */
91
93
  /**
92
94
  * @typedef {object} I18nOptions
93
95
  * @property {string[]} dirs Directories to search for locale dictionaries
94
- * @property {string[]} [locales=['en', 'cy']] Supported locales
96
+ * @property {string[]} [locales=['en', 'cy']] Supported locales. Default is
97
+ * `['en', 'cy']`
95
98
  */
96
99
  /**
97
100
  * @typedef {object} GlobalHook Hook configuration
98
101
  * @property {string} hook Hook name in format `<router>.<hook>`
99
- * @property {Function} middleware Middleware function to insert at the hook point
100
- * @property {string|RegExp} [path=undefined] Only run if route path matches this string/regexp
102
+ * @property {Function} middleware Middleware function to insert at the hook
103
+ * point
104
+ * @property {string | RegExp} [path=undefined] Only run if route path matches
105
+ * this string/regexp. Default is `undefined`
101
106
  */
102
107
  /**
103
108
  * @typedef {object} PageHook (extends GlobalHook)
104
109
  * @property {string} hook Hook name (without a scope prefix)
105
- * @property {Function} middleware Middleware function to insert at the hook point
110
+ * @property {Function} middleware Middleware function to insert at the hook
111
+ * point
106
112
  */
107
113
  /**
108
114
  * @typedef {object} SessionOptions
109
- * @property {string} [name=casasession] Session name
110
- * @property {string} [secret=secret] Encryption secret
111
- * @property {number} [ttl=3600] Session ttl (seconds)
112
- * @property {boolean} [secure=false] Whether to use secure session cookies
113
- * @property {boolean|string} [cookieSameSite=true] SameSite (true = Strict)
115
+ * @property {string} [name=casasession] Session name. Default is `casasession`
116
+ * @property {string} [secret=secret] Encryption secret. Default is `secret`
117
+ * @property {number} [ttl=3600] Session ttl (seconds). Default is `3600`
118
+ * @property {boolean} [secure=false] Whether to use secure session cookies.
119
+ * Default is `false`
120
+ * @property {boolean | string} [cookieSameSite=true] SameSite (true = Strict).
121
+ * Default is `true`
114
122
  * @property {object} [store] Session store (default MemoryStore)
115
- * @property {string} [cookiePath] the URL path on which the session cookie
116
- * is valid (defaults to '/')
123
+ * @property {string} [cookiePath] The URL path on which the session cookie is
124
+ * valid (defaults to '/')
117
125
  */
118
126
  /**
119
127
  * @typedef {object} IPlugin Plugin interface
120
128
  * @property {PluginConfigureFunction} [configure] Modify the app config
121
- * @property {PluginBootstrapFunction} [bootstrap] Modify post-configuration artifacts
129
+ * @property {PluginBootstrapFunction} [bootstrap] Modify post-configuration
130
+ * artifacts
122
131
  */
123
132
  /**
124
133
  * @callback PluginConfigureFunction
@@ -136,91 +145,104 @@ exports.contextIdGenerators = contextIdGenerators;
136
145
  /**
137
146
  * Mounting function.
138
147
  *
139
- * This will mount all of the routes and middleware in the correct order on
140
- * the given ExpressJS app.
148
+ * This will mount all of the routes and middleware in the correct order on the
149
+ * given ExpressJS app.
141
150
  *
142
151
  * Once this is called, you will not be able to modify any of the routers as
143
152
  * they will be "sealed".
144
153
  *
145
154
  * @callback Mounter
146
- * @param {import('express').Express} app Express application
155
+ * @param {import("express").Express} app Express application
147
156
  * @param {object} opts Mounting options
148
- * @param {string} [opts.route='/'] Optional route to attach all middleware/routers too
149
- * @returns {import('express').Express} The prepared ExpressJS app instance
157
+ * @param {string} [opts.route='/'] Optional route to attach all
158
+ * middleware/routers too. Default is `'/'`
159
+ * @returns {import("express").Express} The prepared ExpressJS app instance
150
160
  */
151
161
  /**
152
162
  * Configure some middleware for use in creating a new CASA app.
153
163
  *
154
164
  * @typedef {object} ConfigurationOptions Configuration options
155
165
  * @property {string} [mountUrl] Prefix for all URLS in browser address bar
156
- * @property {string[]} [views=[]] Template directories
166
+ * @property {string[]} [views=[]] Template directories. Default is `[]`
157
167
  * @property {SessionOptions} [session] Session configuration
158
- * @property {Page[]} [pages=[]] Pages the represent waypoints
159
- * @property {GlobalHook[]} [hooks=[]] Hooks to apply
160
- * @property {IPlugin[]} [plugins=[]] Plugins
168
+ * @property {Page[]} [pages=[]] Pages the represent waypoints. Default is `[]`
169
+ * @property {GlobalHook[]} [hooks=[]] Hooks to apply. Default is `[]`
170
+ * @property {IPlugin[]} [plugins=[]] Plugins. Default is `[]`
161
171
  * @property {I18nOptions} [i18n] I18n configuration
162
172
  * @property {Plan} [plan] CASA Plan
163
- * @property {ContextEvent[]} [events=[]] Handlers for JourneyContext events
164
- * @property {HelmetConfigurator} [helmetConfigurator] Helmet configuration manipulator function
165
- * @property {number} [formMaxParams=25] Max number of form parameters to ingest
166
- * @property {number|string} [formMaxBytes="50KB"] Max total form payload size to ingest
167
- * @property {ContextIdGenerator} [contextIdGenerator] Custom context ID generator
168
- * @property {symbol|Function} [errorVisibility] option to keep page errors active on GET request
173
+ * @property {ContextEvent[]} [events=[]] Handlers for JourneyContext events.
174
+ * Default is `[]`
175
+ * @property {HelmetConfigurator} [helmetConfigurator] Helmet configuration
176
+ * manipulator function
177
+ * @property {number} [formMaxParams=25] Max number of form parameters to
178
+ * ingest. Default is `25`
179
+ * @property {number | string} [formMaxBytes="50KB"] Max total form payload size
180
+ * to ingest. Default is `"50KB"`
181
+ * @property {ContextIdGenerator} [contextIdGenerator] Custom context ID
182
+ * generator
183
+ * @property {symbol | Function} [errorVisibility] Option to keep page errors
184
+ * active on GET request
169
185
  */
170
186
  /**
171
187
  * @typedef {object} ConfigureResult Result of a call to configure() function
172
- * @property {import('nunjucks').Environment} nunjucksEnv Nunjucks environment
188
+ * @property {import("nunjucks").Environment} nunjucksEnv Nunjucks environment
173
189
  * @property {MutableRouter} staticRouter Router handling all static assets
174
190
  * @property {MutableRouter} ancillaryRouter Router handling ancillary routes
175
191
  * @property {MutableRouter} journeyRouter Router handling all waypoint requests
176
- * @property {import('express').RequestHandler[]} preMiddleware Middleware mounted before everything
177
- * @property {import('express').RequestHandler[]} postMiddleware Middleware mounted after everything
178
- * @property {import('express').RequestHandler[]} csrfMiddleware CSRF get/set form middleware
179
- * @property {import('express').RequestHandler} sessionMiddleware Session middleware
180
- * @property {import('express').RequestHandler[]} cookieParserMiddleware Cookie-parsing middleware
181
- * @property {import('express').RequestHandler[]} i18nMiddleware I18n preparation middleware
182
- * @property {import('express').RequestHandler} bodyParserMiddleware Body parsing middleware
183
- * @property {Mounter} mount Function used to mount all CASA artifacts onto an ExpressJS app
184
- * @property {ConfigurationOptions} config Ingested config supplied to `configure()`
185
- */
186
- /**
187
- * Configuration for generating a ValidationError.
188
- * i.e. `new ValidationError(configObject)`
189
- * <br/><br/>
192
+ * @property {import("express").RequestHandler[]} preMiddleware Middleware
193
+ * mounted before everything
194
+ * @property {import("express").RequestHandler[]} postMiddleware Middleware
195
+ * mounted after everything
196
+ * @property {import("express").RequestHandler[]} csrfMiddleware CSRF get/set
197
+ * form middleware
198
+ * @property {import("express").RequestHandler} sessionMiddleware Session
199
+ * middleware
200
+ * @property {import("express").RequestHandler[]} cookieParserMiddleware
201
+ * Cookie-parsing middleware
202
+ * @property {import("express").RequestHandler[]} i18nMiddleware I18n
203
+ * preparation middleware
204
+ * @property {import("express").RequestHandler} bodyParserMiddleware Body
205
+ * parsing middleware
206
+ * @property {Mounter} mount Function used to mount all CASA artifacts onto an
207
+ * ExpressJS app
208
+ * @property {ConfigurationOptions} config Ingested config supplied to
209
+ * `configure()`
210
+ */
211
+ /**
212
+ * Configuration for generating a ValidationError. i.e. `new
213
+ * ValidationError(configObject)` <br/><br/>
190
214
  *
191
- * The `fieldKeySuffix` is used to differentiate errors attached to
192
- * the same field name. For example, given these fields inputs ...
215
+ * The `fieldKeySuffix` is used to differentiate errors attached to the same
216
+ * field name. For example, given these fields inputs ...<pre> <input
217
+ * name="dateOfBirth[dd]" /> <input name="dateOfBirth[mm]" /> <input
218
+ * name="dateOfBirth[yyyy]" /> </pre>
193
219
  *
194
- * <pre>
195
- * &lt;input name="dateOfBirth[dd]" /&gt;
196
- * &lt;input name="dateOfBirth[mm]" /&gt;
197
- * &lt;input name="dateOfBirth[yyyy]" /&gt;
198
- * </pre>
220
+ * If we wanted to generate an error specifically for the `dd` element, then
221
+ * we'd include `{ fieldKeySuffix: '[dd]' }` in this config. <br/><br/>
199
222
  *
200
- * If we wanted to generate an error specifically for the `dd`
201
- * element, then we'd include `{ fieldKeySuffix: '[dd]' }` in this
202
- * config.
203
- * <br/><br/>
223
+ * We can also use `focusSuffix` to control which properties of an object field
224
+ * should be highlighted with a red border when in error. Looking again at the
225
+ * `dateOfBirth` example above, if we did not specify any `focusSuffix`, then
226
+ * all three inputs would be highlighted. However, if we use `{ focusSuffix:
227
+ * ['[dd]', '[yyyy]'] }` then only the `[dd]` and `[yyyy]` inputs would be
228
+ * highlighted. <br/><br/>
204
229
  *
205
- * We can also use `focusSuffix` to control which properties of an
206
- * object field should be highlighted with a red border when in error. Looking
207
- * again at the `dateOfBirth` example above, if we did not specify
208
- * any `focusSuffix`, then all three inputs would be highlighted.
209
- * However, if we use `{ focusSuffix: ['[dd]', '[yyyy]'] }` then only
210
- * the `[dd]` and `[yyyy]` inputs would be highlighted.
211
- * <br/><br/>
212
- *
213
- * The `fieldHref` and `field` properties are strictly for
214
- * internal use only and public access may be removed at any point.
230
+ * The `fieldHref` and `field` properties are strictly for internal use only and
231
+ * public access may be removed at any point.
215
232
  *
216
233
  * @typedef {object} ErrorMessageConfigObject
217
234
  * @property {string} summary Summary message
218
- * @property {string} [inline] Inline message (@deprecated now uses summary everywhere)
219
- * @property {string|string[]} [focusSuffix] String(s) to append to URL hash for focusing inputs
220
- * @property {string} [fieldKeySuffix] Object fields may use this to show errors per sub-property
221
- * @property {object|ErrorMessageVariablesGenerator} [variables] Interpolation variables
235
+ * @property {string} [inline] Inline message (@deprecated now uses summary
236
+ * everywhere)
237
+ * @property {string | string[]} [focusSuffix] String(s) to append to URL hash
238
+ * for focusing inputs
239
+ * @property {string} [fieldKeySuffix] Object fields may use this to show errors
240
+ * per sub-property
241
+ * @property {object | ErrorMessageVariablesGenerator} [variables]
242
+ * Interpolation variables
222
243
  * @property {string} [validator] Name of the validator
223
- * @property {string} [fieldHref] (internal) URL hash to link to field in UI, i.e `#f-..`
244
+ * @property {string} [fieldHref] (internal) URL hash to link to field in UI,
245
+ * i.e `#f-..`
224
246
  * @property {string} [field] (internal) Field name, including any focus suffix
225
247
  */
226
248
  /**
@@ -234,10 +256,13 @@ exports.contextIdGenerators = contextIdGenerators;
234
256
  /**
235
257
  * @callback ErrorMessageConfigGenerator
236
258
  * @param {ValidateContext} dataContext Data context
237
- * @returns {string|ErrorMessageConfigObject} Compiled error message config
259
+ * @returns {string | ErrorMessageConfigObject} Compiled error message config
238
260
  */
239
261
  /**
240
- * @typedef {string|ErrorMessageConfigObject|ErrorMessageConfigGenerator|Error} ErrorMessageConfig
262
+ * @typedef {string
263
+ * | ErrorMessageConfigObject
264
+ * | ErrorMessageConfigGenerator
265
+ * | Error} ErrorMessageConfig
241
266
  */
242
267
  /**
243
268
  * @typedef {object} ValidateContext Context passed to validate function
@@ -261,7 +286,8 @@ exports.contextIdGenerators = contextIdGenerators;
261
286
  /**
262
287
  * @typedef {object} Validator
263
288
  * @property {ValidateFunction} validate Validation function
264
- * @property {FieldProcessorFunction} sanitise Sanitise a given value prior to validation
289
+ * @property {FieldProcessorFunction} sanitise Sanitise a given value prior to
290
+ * validation
265
291
  * @property {object} config Configuration
266
292
  * @property {string} name Validator name
267
293
  */
@@ -294,26 +320,31 @@ exports.contextIdGenerators = contextIdGenerators;
294
320
  */
295
321
  /**
296
322
  * @typedef PlanTraverseOptions
297
- * @property {string} [startWaypoint] Waypoint from which to start (defaults to first in list)
323
+ * @property {string} [startWaypoint] Waypoint from which to start (defaults to
324
+ * first in list)
298
325
  * @property {string} routeName Follow routes matching this name (next | prev)
299
326
  * @property {Map} history Used to detect loops in traversal (INTERNAL USE ONLY)
300
- * @property {Function} [stopCondition] If true, traversal will be stopped (useful for performance)
301
- * @property {string|PlanArbiter} [arbiter] Multiple target routes found, this decides which to use
327
+ * @property {Function} [stopCondition] If true, traversal will be stopped
328
+ * (useful for performance)
329
+ * @property {string | PlanArbiter} [arbiter] Multiple target routes found, this
330
+ * decides which to use
302
331
  */
303
332
  /**
304
333
  * @typedef {object} PlanArbiterParams
305
334
  * @property {PlanRoute[]} targets Potential target routes that need arbitration
306
335
  * @property {JourneyContext} journeyContext Journey Context
307
- * @property {PlanTraverseOptions} traverseOptions Original traverse options passed to `traverse()`
336
+ * @property {PlanTraverseOptions} traverseOptions Original traverse options
337
+ * passed to `traverse()`
308
338
  */
309
339
  /**
310
340
  * @callback PlanArbiter
311
341
  * @param {PlanArbiterParams} route Route metadata
312
- * @returns {PlanRoute[]} Returns all routes, excluding those that the arbiter could eliminate
342
+ * @returns {PlanRoute[]} Returns all routes, excluding those that the arbiter
343
+ * could eliminate
313
344
  */
314
345
  /**
315
346
  * @typedef {object} JourneyContextObject Journey Context Object
316
- * @property {Record<string,any>} [data] Data
347
+ * @property {Record<string, any>} [data] Data
317
348
  * @property {any} [validation] Validation state
318
349
  * @property {any} [nav] Navigation meta
319
350
  * @property {any} [identity] Identity meta
@@ -321,14 +352,16 @@ exports.contextIdGenerators = contextIdGenerators;
321
352
  /**
322
353
  * @typedef ContextIdGeneratorParams
323
354
  * @property {object} args Arguments
324
- * @property {import('express').Request} args.req Request
325
- * @property {[string]} args.reservedIds List of IDs already in use in session or request
355
+ * @property {import("express").Request} args.req Request
356
+ * @property {[string]} args.reservedIds List of IDs already in use in session
357
+ * or request
326
358
  */
327
359
  /**
328
360
  * Generates a GUID for use as a journey context ID. This ID must not clash with
329
361
  * any other context IDs in the given session.
330
362
  *
331
363
  * The resulting ID must match these criteria:
364
+ *
332
365
  * - A string
333
366
  * - Between 1 and 64 characters
334
367
  * - Contain only the characters a-z, 0-9, -
package/dist/casa.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"casa.js","sourceRoot":"","sources":["../src/casa.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA4E;AAC5E,sEAA2C;AAgBzC,oBAhBK,sBAAS,CAgBL;AAfX,yEAAmD;AAgBjD,qBAhBK,kBAAU,CAgBL;AAfZ,8DAAmC;AAgBjC,gBAhBK,kBAAK,CAgBL;AAfP,4DAAiC;AAgB/B,eAhBK,iBAAI,CAgBL;AAfN,gFAAqD;AAgBnD,yBAhBK,2BAAc,CAgBL;AAfhB,oFAAyD;AAgBvD,2BAhBK,6BAAgB,CAgBL;AAflB,kFAAuD;AAgBrD,0BAhBK,4BAAe,CAgBL;AAfjB,8EAAmD;AAgBjD,wBAhBK,0BAAa,CAgBL;AAff,4EAAgD;AAkB9C,sBAlBK,yBAAW,CAkBL;AAjBb,0EAA8C;AAkB5C,qBAlBK,wBAAU,CAkBL;AAjBZ,2EAA6D;AAoB3D,0CAAe;AAnBjB,8DAAgD;AAsB9C,8BAAS;AArBX,oFAAsE;AAwBpE,kDAAmB;AAGrB,gFAAgF;AAChF,qEAAqE;AAErE;;GA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AU,CAkBL;AAjBZ,2EAA6D;AAoB3D,0CAAe;AAnBjB,8DAAgD;AAsB9C,8BAAS;AArBX,oFAAsE;AAwBpE,kDAAmB;AAGrB,gFAAgF;AAChF,qEAAqE;AAErE,2DAA2D;AAE3D;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;;;GASG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG"}
@@ -4,8 +4,8 @@
4
4
  * @returns {string} The modified template source
5
5
  */
6
6
  /**
7
- * @access private
8
7
  * @augments FileSystemLoader
8
+ * @access private
9
9
  */
10
10
  export default class CasaTemplateLoader extends FileSystemLoader {
11
11
  /**
@@ -26,7 +26,7 @@ export default class CasaTemplateLoader extends FileSystemLoader {
26
26
  modifyBlock(block: string, modifier: BlockModifier): void;
27
27
  #private;
28
28
  }
29
- export type FileSystemLoaderOptions = import('nunjucks').FileSystemLoaderOptions;
30
- export type LoaderSource = import('nunjucks').LoaderSource;
29
+ export type FileSystemLoaderOptions = import("nunjucks").FileSystemLoaderOptions;
30
+ export type LoaderSource = import("nunjucks").LoaderSource;
31
31
  export type BlockModifier = (templateName: string) => string;
32
- import { FileSystemLoader } from 'nunjucks';
32
+ import { FileSystemLoader } from "nunjucks";
@@ -14,27 +14,27 @@ var _CasaTemplateLoader_instances, _CasaTemplateLoader_blockModifiers, _CasaTemp
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const nunjucks_1 = require("nunjucks");
16
16
  /**
17
+ * @typedef {import("nunjucks").FileSystemLoaderOptions} FileSystemLoaderOptions
17
18
  * @access private
18
- * @typedef {import('nunjucks').FileSystemLoaderOptions} FileSystemLoaderOptions
19
19
  */
20
20
  /**
21
+ * @typedef {import("nunjucks").LoaderSource} LoaderSource
21
22
  * @access private
22
- * @typedef {import('nunjucks').LoaderSource} LoaderSource
23
23
  */
24
24
  const VALID_BLOCKS = [
25
- 'beforeContent',
26
- 'bodyEnd',
27
- 'bodyStart',
28
- 'casaPageTitle',
29
- 'content',
30
- 'footer',
31
- 'head',
32
- 'header',
33
- 'headIcons',
34
- 'journey_form',
35
- 'main',
36
- 'pageTitle',
37
- 'skipLink',
25
+ "beforeContent",
26
+ "bodyEnd",
27
+ "bodyStart",
28
+ "casaPageTitle",
29
+ "content",
30
+ "footer",
31
+ "head",
32
+ "header",
33
+ "headIcons",
34
+ "journey_form",
35
+ "main",
36
+ "pageTitle",
37
+ "skipLink",
38
38
  ];
39
39
  /**
40
40
  * @callback BlockModifier
@@ -42,8 +42,8 @@ const VALID_BLOCKS = [
42
42
  * @returns {string} The modified template source
43
43
  */
44
44
  /**
45
- * @access private
46
45
  * @augments FileSystemLoader
46
+ * @access private
47
47
  */
48
48
  class CasaTemplateLoader extends nunjucks_1.FileSystemLoader {
49
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CasaTemplateLoader.js","sourceRoot":"","sources":["../../src/lib/CasaTemplateLoader.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAA4C;AAE5C;;;GAG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ACnE,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ;QACzB,6EAA6E;QAC7E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,UAAU,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAC/D,CAAC;QACJ,CAAC;QAED,uBAAA,IAAI,0CAAgB,CAAC,IAAI,CAAC;YACxB,KAAK;YACL,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;CAwBF;8LAfsB,IAAI,EAAE,MAAM;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAA,IAAI,0CAAgB,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5D,uCAAuC;QACvC,+DAA+D;QAC/D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,uBAAA,IAAI,0CAAgB,CAAC,CAAC,CAAC,CAAC;QACpD,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC9C,gDAAgD;YAChD,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAC7B,SAAS,KAAK,KAAK,EACnB,SAAS,KAAK,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,CACrC,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;kBArEkB,kBAAkB"}
@@ -1,40 +1,34 @@
1
1
  /**
2
+ * @typedef {import("../casa").ContextEventUserInfo} ContextEventUserInfo
2
3
  * @access private
3
- * @typedef {import('../casa').ContextEventUserInfo} ContextEventUserInfo
4
4
  */
5
5
  /**
6
+ * @typedef {import("../casa").Page} Page
6
7
  * @access private
7
- * @typedef {import('../casa').Page} Page
8
8
  */
9
9
  /**
10
+ * @typedef {import("../casa").ContextEventHandler} ContextEventHandler
10
11
  * @access private
11
- * @typedef {import('../casa').ContextEventHandler} ContextEventHandler
12
12
  */
13
13
  /**
14
+ * @typedef {import("../casa").ContextEvent} ContextEvent
14
15
  * @access private
15
- * @typedef {import('../casa').ContextEvent} ContextEvent
16
16
  */
17
17
  /**
18
+ * @typedef {import("../casa").JourneyContextObject} JourneyContextObject
18
19
  * @access private
19
- * @typedef {import('../casa').JourneyContextObject} JourneyContextObject
20
20
  */
21
21
  /**
22
+ * @typedef {import("express").Request} ExpressRequest
22
23
  * @access private
23
- * @typedef {import('express').Request} ExpressRequest
24
24
  */
25
25
  export function validateObjectKey(key?: string): string;
26
- /**
27
- * @memberof module:@dwp/govuk-casa
28
- */
26
+ /** @memberof module:@dwp/govuk-casa */
29
27
  export default class JourneyContext {
30
28
  static DEFAULT_CONTEXT_ID: string;
31
- /**
32
- * @type {symbol}
33
- */
29
+ /** @type {symbol} */
34
30
  static ID_GENERATOR_REQ_LOG: symbol;
35
- /**
36
- * @type {symbol}
37
- */
31
+ /** @type {symbol} */
38
32
  static ID_GENERATOR_REQ_KEY: symbol;
39
33
  /**
40
34
  * Create a new JourneyContext using the plain object.
@@ -72,6 +66,7 @@ export default class JourneyContext {
72
66
  static initContextStore(session: object): void;
73
67
  /**
74
68
  * Validate the format of a context ID:
69
+ *
75
70
  * - Between 1 and 64 characters
76
71
  * - Contain only the characters a-z, 0-9, -
77
72
  *
@@ -82,8 +77,8 @@ export default class JourneyContext {
82
77
  */
83
78
  static validateContextId(id: string): string;
84
79
  /**
85
- * Generate a new context ID, validate it, and throw if the ID has already been
86
- * generated during this request lifecycle. This may happen if an ID was
80
+ * Generate a new context ID, validate it, and throw if the ID has already
81
+ * been generated during this request lifecycle. This may happen if an ID was
87
82
  * generated, but never used to store a new context in the session. Therefore
88
83
  * it is important for user code to always call `putContext()` before
89
84
  * generating another ID.
@@ -122,9 +117,9 @@ export default class JourneyContext {
122
117
  *
123
118
  * @param {object} session Request session
124
119
  * @param {string} tag Context tag
125
- * @returns {Array<JourneyContext>} The discovered JourneyContext instance
120
+ * @returns {JourneyContext[]} The discovered JourneyContext instance
126
121
  */
127
- static getContextsByTag(session: object, tag: string): Array<JourneyContext>;
122
+ static getContextsByTag(session: object, tag: string): JourneyContext[];
128
123
  /**
129
124
  * Return all contexts currently stored in the session.
130
125
  *
@@ -138,7 +133,8 @@ export default class JourneyContext {
138
133
  * @param {object} session Request session
139
134
  * @param {JourneyContext} context Context
140
135
  * @param {object} options Options
141
- * @param {ContextEventUserInfo|object} [options.userInfo] Pass-through event info
136
+ * @param {ContextEventUserInfo | object} [options.userInfo] Pass-through
137
+ * event info
142
138
  * @returns {void}
143
139
  * @throws {TypeError} When session is not a valid type, or context has no ID
144
140
  */
@@ -187,9 +183,9 @@ export default class JourneyContext {
187
183
  /**
188
184
  * Extract the Journey Context referred to in the incoming request.
189
185
  *
190
- * This will look in `req.params`, `req.query` and
191
- * `req.body` for a `contextid` parameter, and use that
192
- * to load the correct Journey Context from the session.
186
+ * This will look in `req.params`, `req.query` and `req.body` for a
187
+ * `contextid` parameter, and use that to load the correct Journey Context
188
+ * from the session.
193
189
  *
194
190
  * @param {ExpressRequest} req ExpressJS incoming request
195
191
  * @returns {JourneyContext} The Journey Context
@@ -200,7 +196,7 @@ export default class JourneyContext {
200
196
  *
201
197
  * `data` is the "single source of truth" for all data gathered during the
202
198
  * user's journey. This is referred to as the "canonical data model".
203
- * Page-specific "views" of this data are generated at runtime in order to
199
+ * Page-specific "views" of this data are generated at runtime in order to
204
200
  * populate/validate specific form fields.
205
201
  *
206
202
  * `validation` holds the results of form field validation carried out when
@@ -213,10 +209,11 @@ export default class JourneyContext {
213
209
  * `identity` holds information that helps uniquely identify this context
214
210
  * among a group of contexts stored in the session.
215
211
  *
216
- * @param {Record<string,any>} data Entire journey data.
212
+ * @param {Record<string, any>} data Entire journey data.
217
213
  * @param {object} validation Page errors (indexed by waypoint id).
218
214
  * @param {object} nav Navigation context.
219
- * @param {object} identity Some metadata for identifying this context among others.
215
+ * @param {object} identity Some metadata for identifying this context among
216
+ * others.
220
217
  */
221
218
  constructor(data?: Record<string, any>, validation?: object, nav?: object, identity?: object);
222
219
  /**
@@ -233,7 +230,7 @@ export default class JourneyContext {
233
230
  /**
234
231
  * Get data context for a specific a specific page.
235
232
  *
236
- * @param {string | Page} page Page waypoint ID, or Page object.
233
+ * @param {string | Page} page Page waypoint ID, or Page object.
237
234
  * @returns {object} Page data.
238
235
  * @throws {TypeError} When page is invalid.
239
236
  */
@@ -303,12 +300,13 @@ export default class JourneyContext {
303
300
  */
304
301
  getValidationErrorsForPage(pageId: string): ValidationError[];
305
302
  /**
306
- * Same as `getValidationErrorsForPage()`, but the return value is
307
- * an object whose keys are the field names, and values are the list of errors
303
+ * Same as `getValidationErrorsForPage()`, but the return value is an object
304
+ * whose keys are the field names, and values are the list of errors
308
305
  * associated with that particular field.
309
306
  *
310
307
  * @param {string} pageId Page ID.
311
- * @returns {object} Object indexed by field names; values containing list of errors
308
+ * @returns {object} Object indexed by field names; values containing list of
309
+ * errors
312
310
  */
313
311
  getValidationErrorsForPageByField(pageId: string): object;
314
312
  /**
@@ -348,8 +346,8 @@ export default class JourneyContext {
348
346
  */
349
347
  invalidate(waypoints?: string[]): void;
350
348
  /**
351
- * Event listeners are transient. They are not stored in session, and generally
352
- * only apply for the current request.
349
+ * Event listeners are transient. They are not stored in session, and
350
+ * generally only apply for the current request.
353
351
  *
354
352
  * They also only act on a fixed snapshot of this context's state, which is
355
353
  * taken at the point of attaching the listeners (in the "data" middleware).
@@ -369,7 +367,7 @@ export default class JourneyContext {
369
367
  * @param {object} params Params
370
368
  * @param {string} params.event Event (waypoint-change | context-change)
371
369
  * @param {object} params.session Session
372
- * @param {ContextEventUserInfo|object} [params.userInfo] Pass-through info
370
+ * @param {ContextEventUserInfo | object} [params.userInfo] Pass-through info
373
371
  * @returns {JourneyContext} Chain
374
372
  */
375
373
  applyEventListeners({ event, session, userInfo }: {
@@ -383,12 +381,32 @@ export default class JourneyContext {
383
381
  * @returns {boolean} True if this is the "default" journey context
384
382
  */
385
383
  isDefault(): boolean;
384
+ /**
385
+ * Set page skipped status.
386
+ *
387
+ * @param {string} waypoint Waypoint to skip.
388
+ * @param {boolean | object} opts Is skipped flag or options.
389
+ * @param {string} opts.to Waypoint to skip to.
390
+ */
391
+ setSkipped(waypoint: string, opts: boolean | object): void;
392
+ /**
393
+ * Tests if a page has been skipped.
394
+ *
395
+ * @param {string} page Page ID (waypoint).
396
+ * @param {object} opts Skip ptions.
397
+ * @param {string} opts.to Waypoint that should be skipped to.
398
+ * @returns {boolean} True if the page has been skipped, or if it has been
399
+ * skipped to a specific page.
400
+ */
401
+ isSkipped(waypoint: any, opts: {
402
+ to: string;
403
+ }): boolean;
386
404
  #private;
387
405
  }
388
- export type ContextEventUserInfo = import('../casa').ContextEventUserInfo;
389
- export type Page = import('../casa').Page;
390
- export type ContextEventHandler = import('../casa').ContextEventHandler;
391
- export type ContextEvent = import('../casa').ContextEvent;
392
- export type JourneyContextObject = import('../casa').JourneyContextObject;
393
- export type ExpressRequest = import('express').Request;
394
- import ValidationError from './ValidationError.js';
406
+ export type ContextEventUserInfo = import("../casa").ContextEventUserInfo;
407
+ export type Page = import("../casa").Page;
408
+ export type ContextEventHandler = import("../casa").ContextEventHandler;
409
+ export type ContextEvent = import("../casa").ContextEvent;
410
+ export type JourneyContextObject = import("../casa").JourneyContextObject;
411
+ export type ExpressRequest = import("express").Request;
412
+ import ValidationError from "./ValidationError.js";