@dwp/govuk-casa 9.7.0 → 10.0.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 (277) hide show
  1. package/dist/assets/css/casa.css +1 -1
  2. package/dist/assets/css/casa.css.map +1 -1
  3. package/dist/casa.d.ts +81 -41
  4. package/dist/casa.d.ts.map +1 -0
  5. package/dist/casa.js +72 -99
  6. package/dist/core-plugins/edit-snapshot/src/configure.d.ts +1 -0
  7. package/dist/core-plugins/edit-snapshot/src/configure.d.ts.map +1 -0
  8. package/dist/core-plugins/edit-snapshot/src/configure.js +7 -14
  9. package/dist/core-plugins/edit-snapshot/src/index.d.ts +1 -0
  10. package/dist/core-plugins/edit-snapshot/src/index.d.ts.map +1 -0
  11. package/dist/core-plugins/edit-snapshot/src/index.js +3 -9
  12. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.d.ts +2 -1
  13. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.d.ts.map +1 -0
  14. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.js +8 -13
  15. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.d.ts +2 -1
  16. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.d.ts.map +1 -0
  17. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.js +13 -18
  18. package/dist/core-plugins/edit-snapshot/src/utils.d.ts +8 -5
  19. package/dist/core-plugins/edit-snapshot/src/utils.d.ts.map +1 -0
  20. package/dist/core-plugins/edit-snapshot/src/utils.js +37 -19
  21. package/dist/core-plugins/index.d.ts +1 -0
  22. package/dist/core-plugins/index.d.ts.map +1 -0
  23. package/dist/core-plugins/index.js +1 -9
  24. package/dist/lib/CasaTemplateLoader.d.ts +1 -0
  25. package/dist/lib/CasaTemplateLoader.d.ts.map +1 -0
  26. package/dist/lib/CasaTemplateLoader.js +2 -6
  27. package/dist/lib/JourneyContext.d.ts +22 -11
  28. package/dist/lib/JourneyContext.d.ts.map +1 -0
  29. package/dist/lib/JourneyContext.js +40 -45
  30. package/dist/lib/MutableRouter.d.ts +74 -55
  31. package/dist/lib/MutableRouter.d.ts.map +1 -0
  32. package/dist/lib/MutableRouter.js +48 -45
  33. package/dist/lib/NullObject.d.ts +3 -0
  34. package/dist/lib/NullObject.d.ts.map +1 -0
  35. package/dist/lib/NullObject.js +3 -0
  36. package/dist/lib/Plan.d.ts +2 -1
  37. package/dist/lib/Plan.d.ts.map +1 -0
  38. package/dist/lib/Plan.js +44 -62
  39. package/dist/lib/ValidationError.d.ts +2 -1
  40. package/dist/lib/ValidationError.d.ts.map +1 -0
  41. package/dist/lib/ValidationError.js +3 -11
  42. package/dist/lib/ValidatorFactory.d.ts +5 -6
  43. package/dist/lib/ValidatorFactory.d.ts.map +1 -0
  44. package/dist/lib/ValidatorFactory.js +4 -12
  45. package/dist/lib/configuration-ingestor.d.ts +10 -22
  46. package/dist/lib/configuration-ingestor.d.ts.map +1 -0
  47. package/dist/lib/configuration-ingestor.js +61 -143
  48. package/dist/lib/configure.d.ts +2 -1
  49. package/dist/lib/configure.d.ts.map +1 -0
  50. package/dist/lib/configure.js +40 -52
  51. package/dist/lib/constants.d.ts +1 -0
  52. package/dist/lib/constants.d.ts.map +1 -0
  53. package/dist/lib/constants.js +8 -12
  54. package/dist/lib/context-id-generators.d.ts +1 -0
  55. package/dist/lib/context-id-generators.d.ts.map +1 -0
  56. package/dist/lib/context-id-generators.js +4 -9
  57. package/dist/lib/end-session.d.ts +2 -1
  58. package/dist/lib/end-session.d.ts.map +1 -0
  59. package/dist/lib/end-session.js +4 -11
  60. package/dist/lib/field.d.ts +2 -1
  61. package/dist/lib/field.d.ts.map +1 -0
  62. package/dist/lib/field.js +11 -21
  63. package/dist/lib/index.d.ts +1 -0
  64. package/dist/lib/index.d.ts.map +1 -0
  65. package/dist/lib/index.js +13 -65
  66. package/dist/lib/logger.d.ts +25 -2
  67. package/dist/lib/logger.d.ts.map +1 -0
  68. package/dist/lib/logger.js +18 -9
  69. package/dist/lib/mount.d.ts +1 -0
  70. package/dist/lib/mount.d.ts.map +1 -0
  71. package/dist/lib/mount.js +10 -16
  72. package/dist/lib/nunjucks-filters.d.ts +7 -3
  73. package/dist/lib/nunjucks-filters.d.ts.map +1 -0
  74. package/dist/lib/nunjucks-filters.js +58 -71
  75. package/dist/lib/nunjucks.d.ts +2 -2
  76. package/dist/lib/nunjucks.d.ts.map +1 -0
  77. package/dist/lib/nunjucks.js +12 -25
  78. package/dist/lib/utils.d.ts +4 -2
  79. package/dist/lib/utils.d.ts.map +1 -0
  80. package/dist/lib/utils.js +14 -28
  81. package/dist/lib/validators/dateObject.d.ts +1 -0
  82. package/dist/lib/validators/dateObject.d.ts.map +1 -0
  83. package/dist/lib/validators/dateObject.js +14 -21
  84. package/dist/lib/validators/email.d.ts +1 -0
  85. package/dist/lib/validators/email.d.ts.map +1 -0
  86. package/dist/lib/validators/email.js +8 -15
  87. package/dist/lib/validators/inArray.d.ts +1 -0
  88. package/dist/lib/validators/inArray.d.ts.map +1 -0
  89. package/dist/lib/validators/inArray.js +8 -15
  90. package/dist/lib/validators/index.d.ts +1 -0
  91. package/dist/lib/validators/index.d.ts.map +1 -0
  92. package/dist/lib/validators/index.js +21 -27
  93. package/dist/lib/validators/nino.d.ts +1 -0
  94. package/dist/lib/validators/nino.d.ts.map +1 -0
  95. package/dist/lib/validators/nino.js +6 -13
  96. package/dist/lib/validators/postalAddressObject.d.ts +1 -0
  97. package/dist/lib/validators/postalAddressObject.d.ts.map +1 -0
  98. package/dist/lib/validators/postalAddressObject.js +12 -19
  99. package/dist/lib/validators/range.d.ts +1 -0
  100. package/dist/lib/validators/range.d.ts.map +1 -0
  101. package/dist/lib/validators/range.js +6 -13
  102. package/dist/lib/validators/regex.d.ts +1 -0
  103. package/dist/lib/validators/regex.d.ts.map +1 -0
  104. package/dist/lib/validators/regex.js +6 -13
  105. package/dist/lib/validators/required.d.ts +1 -0
  106. package/dist/lib/validators/required.d.ts.map +1 -0
  107. package/dist/lib/validators/required.js +9 -17
  108. package/dist/lib/validators/strlen.d.ts +1 -0
  109. package/dist/lib/validators/strlen.d.ts.map +1 -0
  110. package/dist/lib/validators/strlen.js +6 -13
  111. package/dist/lib/validators/wordCount.d.ts +1 -0
  112. package/dist/lib/validators/wordCount.d.ts.map +1 -0
  113. package/dist/lib/validators/wordCount.js +6 -13
  114. package/dist/lib/waypoint-url.d.ts +3 -2
  115. package/dist/lib/waypoint-url.d.ts.map +1 -0
  116. package/dist/lib/waypoint-url.js +12 -19
  117. package/dist/middleware/body-parser.d.ts +1 -0
  118. package/dist/middleware/body-parser.d.ts.map +1 -0
  119. package/dist/middleware/body-parser.js +4 -9
  120. package/dist/middleware/csrf.d.ts +1 -0
  121. package/dist/middleware/csrf.d.ts.map +1 -0
  122. package/dist/middleware/csrf.js +4 -8
  123. package/dist/middleware/data.d.ts +2 -3
  124. package/dist/middleware/data.d.ts.map +1 -0
  125. package/dist/middleware/data.js +23 -25
  126. package/dist/middleware/gather-fields.d.ts +3 -1
  127. package/dist/middleware/gather-fields.d.ts.map +1 -0
  128. package/dist/middleware/gather-fields.js +13 -14
  129. package/dist/middleware/i18n.d.ts +1 -0
  130. package/dist/middleware/i18n.d.ts.map +1 -0
  131. package/dist/middleware/i18n.js +26 -31
  132. package/dist/middleware/post.d.ts +1 -0
  133. package/dist/middleware/post.d.ts.map +1 -0
  134. package/dist/middleware/post.js +3 -10
  135. package/dist/middleware/pre.d.ts +2 -1
  136. package/dist/middleware/pre.d.ts.map +1 -0
  137. package/dist/middleware/pre.js +6 -12
  138. package/dist/middleware/progress-journey.d.ts +5 -3
  139. package/dist/middleware/progress-journey.d.ts.map +1 -0
  140. package/dist/middleware/progress-journey.js +20 -18
  141. package/dist/middleware/sanitise-fields.d.ts +5 -3
  142. package/dist/middleware/sanitise-fields.d.ts.map +1 -0
  143. package/dist/middleware/sanitise-fields.js +25 -17
  144. package/dist/middleware/serve-first-waypoint.d.ts +1 -0
  145. package/dist/middleware/serve-first-waypoint.d.ts.map +1 -0
  146. package/dist/middleware/serve-first-waypoint.js +3 -6
  147. package/dist/middleware/session.d.ts +15 -0
  148. package/dist/middleware/session.d.ts.map +1 -0
  149. package/dist/middleware/session.js +53 -57
  150. package/dist/middleware/skip-waypoint.d.ts +3 -2
  151. package/dist/middleware/skip-waypoint.d.ts.map +1 -0
  152. package/dist/middleware/skip-waypoint.js +15 -14
  153. package/dist/middleware/steer-journey.d.ts +2 -1
  154. package/dist/middleware/steer-journey.d.ts.map +1 -0
  155. package/dist/middleware/steer-journey.js +7 -13
  156. package/dist/middleware/strip-proxy-path.d.ts +3 -2
  157. package/dist/middleware/strip-proxy-path.d.ts.map +1 -0
  158. package/dist/middleware/strip-proxy-path.js +24 -24
  159. package/dist/middleware/validate-fields.d.ts +7 -4
  160. package/dist/middleware/validate-fields.d.ts.map +1 -0
  161. package/dist/middleware/validate-fields.js +22 -11
  162. package/dist/routes/ancillary.d.ts +1 -0
  163. package/dist/routes/ancillary.d.ts.map +1 -0
  164. package/dist/routes/ancillary.js +3 -10
  165. package/dist/routes/journey.d.ts +7 -2
  166. package/dist/routes/journey.d.ts.map +1 -0
  167. package/dist/routes/journey.js +56 -55
  168. package/dist/routes/static.d.ts +1 -0
  169. package/dist/routes/static.d.ts.map +1 -0
  170. package/dist/routes/static.js +15 -23
  171. package/package.json +20 -26
  172. package/src/casa.js +49 -29
  173. package/src/core-plugins/edit-snapshot/src/post-steer-hook.js +1 -0
  174. package/src/core-plugins/edit-snapshot/src/pre-steer-hook.js +2 -1
  175. package/src/core-plugins/edit-snapshot/src/utils.js +29 -1
  176. package/src/lib/JourneyContext.js +31 -28
  177. package/src/lib/MutableRouter.js +47 -38
  178. package/src/lib/NullObject.js +4 -0
  179. package/src/lib/Plan.js +41 -55
  180. package/src/lib/ValidationError.js +2 -4
  181. package/src/lib/ValidatorFactory.js +3 -5
  182. package/src/lib/configuration-ingestor.js +18 -38
  183. package/src/lib/configure.js +7 -10
  184. package/src/lib/end-session.js +1 -1
  185. package/src/lib/field.js +7 -12
  186. package/src/lib/logger.js +16 -0
  187. package/src/lib/mount.js +1 -1
  188. package/src/lib/nunjucks-filters.js +51 -61
  189. package/src/lib/nunjucks.js +3 -12
  190. package/src/lib/utils.js +2 -1
  191. package/src/lib/validators/dateObject.js +3 -4
  192. package/src/lib/validators/postalAddressObject.js +6 -7
  193. package/src/lib/validators/required.js +1 -3
  194. package/src/lib/waypoint-url.js +15 -19
  195. package/src/middleware/csrf.js +1 -1
  196. package/src/middleware/data.js +13 -13
  197. package/src/middleware/gather-fields.js +8 -2
  198. package/src/middleware/i18n.js +9 -6
  199. package/src/middleware/pre.js +1 -1
  200. package/src/middleware/progress-journey.js +8 -0
  201. package/src/middleware/sanitise-fields.js +17 -2
  202. package/src/middleware/session.js +53 -12
  203. package/src/middleware/skip-waypoint.js +8 -1
  204. package/src/middleware/steer-journey.js +1 -1
  205. package/src/middleware/strip-proxy-path.js +21 -16
  206. package/src/middleware/validate-fields.js +19 -0
  207. package/src/routes/journey.js +18 -8
  208. package/src/routes/static.js +5 -4
  209. package/views/casa/layouts/journey.njk +1 -1
  210. package/views/casa/layouts/main.njk +11 -21
  211. package/dist/casa.js.map +0 -1
  212. package/dist/core-plugins/edit-snapshot/src/configure.js.map +0 -1
  213. package/dist/core-plugins/edit-snapshot/src/index.js.map +0 -1
  214. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.js.map +0 -1
  215. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.js.map +0 -1
  216. package/dist/core-plugins/edit-snapshot/src/utils.js.map +0 -1
  217. package/dist/core-plugins/index.js.map +0 -1
  218. package/dist/lib/CasaTemplateLoader.js.map +0 -1
  219. package/dist/lib/JourneyContext.js.map +0 -1
  220. package/dist/lib/MutableRouter.js.map +0 -1
  221. package/dist/lib/Plan.js.map +0 -1
  222. package/dist/lib/ValidationError.js.map +0 -1
  223. package/dist/lib/ValidatorFactory.js.map +0 -1
  224. package/dist/lib/configuration-ingestor.js.map +0 -1
  225. package/dist/lib/configure.js.map +0 -1
  226. package/dist/lib/constants.js.map +0 -1
  227. package/dist/lib/context-id-generators.js.map +0 -1
  228. package/dist/lib/dirname.cjs +0 -1
  229. package/dist/lib/dirname.d.cts +0 -2
  230. package/dist/lib/end-session.js.map +0 -1
  231. package/dist/lib/field.js.map +0 -1
  232. package/dist/lib/index.js.map +0 -1
  233. package/dist/lib/logger.js.map +0 -1
  234. package/dist/lib/mount.js.map +0 -1
  235. package/dist/lib/nunjucks-filters.js.map +0 -1
  236. package/dist/lib/nunjucks.js.map +0 -1
  237. package/dist/lib/utils.js.map +0 -1
  238. package/dist/lib/validators/dateObject.js.map +0 -1
  239. package/dist/lib/validators/email.js.map +0 -1
  240. package/dist/lib/validators/inArray.js.map +0 -1
  241. package/dist/lib/validators/index.js.map +0 -1
  242. package/dist/lib/validators/nino.js.map +0 -1
  243. package/dist/lib/validators/postalAddressObject.js.map +0 -1
  244. package/dist/lib/validators/range.js.map +0 -1
  245. package/dist/lib/validators/regex.js.map +0 -1
  246. package/dist/lib/validators/required.js.map +0 -1
  247. package/dist/lib/validators/strlen.js.map +0 -1
  248. package/dist/lib/validators/wordCount.js.map +0 -1
  249. package/dist/lib/waypoint-url.js.map +0 -1
  250. package/dist/middleware/body-parser.js.map +0 -1
  251. package/dist/middleware/csrf.js.map +0 -1
  252. package/dist/middleware/data.js.map +0 -1
  253. package/dist/middleware/dirname.cjs +0 -1
  254. package/dist/middleware/dirname.d.cts +0 -2
  255. package/dist/middleware/gather-fields.js.map +0 -1
  256. package/dist/middleware/i18n.js.map +0 -1
  257. package/dist/middleware/post.js.map +0 -1
  258. package/dist/middleware/pre.js.map +0 -1
  259. package/dist/middleware/progress-journey.js.map +0 -1
  260. package/dist/middleware/sanitise-fields.js.map +0 -1
  261. package/dist/middleware/serve-first-waypoint.js.map +0 -1
  262. package/dist/middleware/session.js.map +0 -1
  263. package/dist/middleware/skip-waypoint.js.map +0 -1
  264. package/dist/middleware/steer-journey.js.map +0 -1
  265. package/dist/middleware/strip-proxy-path.js.map +0 -1
  266. package/dist/middleware/validate-fields.js.map +0 -1
  267. package/dist/mjs/esm-wrapper.js +0 -20
  268. package/dist/mjs/package.json +0 -3
  269. package/dist/package.json +0 -3
  270. package/dist/routes/ancillary.js.map +0 -1
  271. package/dist/routes/dirname.cjs +0 -1
  272. package/dist/routes/dirname.d.cts +0 -2
  273. package/dist/routes/journey.js.map +0 -1
  274. package/dist/routes/static.js.map +0 -1
  275. package/src/lib/dirname.cjs +0 -1
  276. package/src/middleware/dirname.cjs +0 -1
  277. package/src/routes/dirname.cjs +0 -1
package/dist/casa.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export type PageField = import("./lib/field").PageField;
2
+ export type ExpressRequest = import("express").Request;
3
+ export type RequestHandler = import("express").RequestHandler;
4
+ export type HelmetOptions = import("helmet").HelmetOptions;
2
5
  export type ContextEventHandlerOptions = {
3
6
  /**
4
7
  * Context including changes
@@ -39,6 +42,9 @@ export type ContextEvent = {
39
42
  */
40
43
  handler: ContextEventHandler;
41
44
  };
45
+ export type ErrorVisibiltyFunction = (opts: {
46
+ req: ExpressRequest;
47
+ }) => any;
42
48
  /**
43
49
  * Page configuration. A Page is the interactive
44
50
  * representation of a waypoint
@@ -52,6 +58,11 @@ export type Page = {
52
58
  * Template path
53
59
  */
54
60
  view: string;
61
+ /**
62
+ * Should page
63
+ * validation errors be visible on GET requests
64
+ */
65
+ errorVisibility: ErrorVisibiltyFunction | symbol;
55
66
  /**
56
67
  * Page-specific hooks (optional, default []).
57
68
  * Default is `[]`
@@ -88,10 +99,10 @@ export type GlobalHook = {
88
99
  */
89
100
  hook: string;
90
101
  /**
91
- * Middleware function to insert at the hook
92
- * point
102
+ * Middleware function to insert at the
103
+ * hook point
93
104
  */
94
- middleware: Function;
105
+ middleware: RequestHandler;
95
106
  /**
96
107
  * Only run if route path matches
97
108
  * this string/regexp. Default is `undefined`
@@ -107,10 +118,10 @@ export type PageHook = {
107
118
  */
108
119
  hook: string;
109
120
  /**
110
- * Middleware function to insert at the hook
111
- * point
121
+ * Middleware function to insert at the
122
+ * hook point
112
123
  */
113
- middleware: Function;
124
+ middleware: RequestHandler;
114
125
  };
115
126
  export type SessionOptions = {
116
127
  /**
@@ -161,7 +172,7 @@ export type IPlugin = {
161
172
  };
162
173
  export type PluginConfigureFunction = (config: ConfigurationOptions) => any;
163
174
  export type PluginBootstrapFunction = (config: ConfigureResult) => any;
164
- export type HelmetConfigurator = (config: object) => object;
175
+ export type HelmetConfigurator = (config: HelmetOptions) => HelmetOptions;
165
176
  /**
166
177
  * Mounting function.
167
178
  *
@@ -236,15 +247,10 @@ export type ConfigurationOptions = {
236
247
  */
237
248
  contextIdGenerator?: ContextIdGenerator | undefined;
238
249
  /**
239
- * Option to keep page errors
240
- * active on GET request
241
- */
242
- errorVisibility?: symbol | Function | undefined;
243
- /**
244
- * Sets whether you wish to use the
245
- * govuk rebrand. Default is `false`
250
+ * Option to keep
251
+ * page errors active on GET request
246
252
  */
247
- govukRebrand?: boolean | undefined;
253
+ errorVisibility?: symbol | ErrorVisibiltyFunction | undefined;
248
254
  };
249
255
  /**
250
256
  * Result of a call to configure() function
@@ -267,39 +273,35 @@ export type ConfigureResult = {
267
273
  */
268
274
  journeyRouter: MutableRouter;
269
275
  /**
270
- * Middleware
271
- * mounted before everything
276
+ * Middleware mounted before
277
+ * everything
272
278
  */
273
- preMiddleware: import("express").RequestHandler[];
279
+ preMiddleware: RequestHandler[];
274
280
  /**
275
- * Middleware
276
- * mounted after everything
281
+ * Middleware mounted after
282
+ * everything
277
283
  */
278
- postMiddleware: import("express").RequestHandler[];
284
+ postMiddleware: RequestHandler[];
279
285
  /**
280
- * CSRF get/set
281
- * form middleware
286
+ * CSRF get/set form middleware
282
287
  */
283
- csrfMiddleware: import("express").RequestHandler[];
288
+ csrfMiddleware: RequestHandler[];
284
289
  /**
285
- * Session
286
- * middleware
290
+ * Session middleware
287
291
  */
288
- sessionMiddleware: import("express").RequestHandler;
292
+ sessionMiddleware: RequestHandler;
289
293
  /**
290
- * Cookie-parsing middleware
294
+ * Cookie-parsing middleware
291
295
  */
292
- cookieParserMiddleware: import("express").RequestHandler[];
296
+ cookieParserMiddleware: RequestHandler[];
293
297
  /**
294
- * I18n
295
- * preparation middleware
298
+ * I18n preparation middleware
296
299
  */
297
- i18nMiddleware: import("express").RequestHandler[];
300
+ i18nMiddleware: RequestHandler[];
298
301
  /**
299
- * Body
300
- * parsing middleware
302
+ * Body parsing middleware
301
303
  */
302
- bodyParserMiddleware: import("express").RequestHandler;
304
+ bodyParserMiddleware: RequestHandler;
303
305
  /**
304
306
  * Function used to mount all CASA artifacts onto an
305
307
  * ExpressJS app
@@ -465,6 +467,7 @@ export type PlanRoute = {
465
467
  label: string;
466
468
  };
467
469
  export type PlanRouteCondition = (route: PlanRoute, context: JourneyContext) => boolean;
470
+ export type StopCondition = (route: PlanRoute) => boolean;
468
471
  export type PlanTraverseOptions = {
469
472
  /**
470
473
  * Waypoint from which to start (defaults to
@@ -483,7 +486,7 @@ export type PlanTraverseOptions = {
483
486
  * If true, traversal will be stopped
484
487
  * (useful for performance)
485
488
  */
486
- stopCondition?: Function | undefined;
489
+ stopCondition?: StopCondition | undefined;
487
490
  /**
488
491
  * Multiple target routes found, this
489
492
  * decides which to use
@@ -506,6 +509,23 @@ export type PlanArbiterParams = {
506
509
  traverseOptions: PlanTraverseOptions;
507
510
  };
508
511
  export type PlanArbiter = (route: PlanArbiterParams) => PlanRoute[];
512
+ /**
513
+ * Journey Context Identity Object
514
+ */
515
+ export type JourneyContextIdentity = {
516
+ /**
517
+ * The context ID
518
+ */
519
+ id?: string | undefined;
520
+ /**
521
+ * Context name
522
+ */
523
+ name?: string | undefined;
524
+ /**
525
+ * JouneyContext tags
526
+ */
527
+ tags?: string[] | undefined;
528
+ };
509
529
  /**
510
530
  * Journey Context Object
511
531
  */
@@ -515,24 +535,25 @@ export type JourneyContextObject = {
515
535
  */
516
536
  data?: Record<string, any> | undefined;
517
537
  /**
518
- * Validation state
538
+ * Validation
539
+ * state
519
540
  */
520
- validation?: any;
541
+ validation?: Record<string, ValidationError[] | null> | undefined;
521
542
  /**
522
543
  * Navigation meta
523
544
  */
524
- nav?: any;
545
+ nav?: object | undefined;
525
546
  /**
526
547
  * Identity meta
527
548
  */
528
- identity?: any;
549
+ identity?: JourneyContextIdentity | undefined;
529
550
  };
530
551
  export type ContextIdGeneratorParams = {
531
552
  /**
532
553
  * Arguments
533
554
  */
534
555
  args: {
535
- req: import("express").Request;
556
+ req: ExpressRequest;
536
557
  reservedIds: [string];
537
558
  };
538
559
  };
@@ -563,3 +584,22 @@ import * as constants from "./lib/constants.js";
563
584
  import * as contextIdGenerators from "./lib/context-id-generators.js";
564
585
  import * as corePlugins from "./core-plugins/index.js";
565
586
  export { configure, validators, field, Plan, JourneyContext, ValidatorFactory, ValidationError, MutableRouter, waypointUrl, endSession, generateGovukErrors, nunjucksFilters, constants, contextIdGenerators, corePlugins };
587
+ //# sourceMappingURL=casa.d.ts.map
588
+ declare global {
589
+ namespace Express {
590
+ type CasaRequestContext = {
591
+ plan: Plan,
592
+ journeyContext: JourneyContext,
593
+ editMode: boolean,
594
+ editOrigin: string,
595
+ }
596
+
597
+ // Inject additional properties on express.Request
598
+ interface Request {
599
+ /**
600
+ * CASA request context
601
+ */
602
+ casa: CasaRequestContext;
603
+ }
604
+ }
605
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"casa.d.ts","sourceRoot":"","sources":["../src/casa.js"],"names":[],"mappings":"wBAiDc,OAAO,aAAa,EAAE,SAAS;6BAC/B,OAAO,SAAS,EAAE,OAAO;6BACzB,OAAO,SAAS,EAAE,cAAc;4BAChC,OAAO,QAAQ,EAAE,aAAa;;;;;oBAI9B,cAAc;;;;qBACd,cAAc;;;;aACd,MAAM;;;;cACN,oBAAoB;;yCAKvB,0BAA0B,KACxB,IAAI;;;;;;;;;;;;cAWH,MAAM;;;;;;;;aAEN,mBAAmB;;4CAM9B;IAA6B,GAAG,EAAxB,cAAc;CACxB;;;;;;;;;cAKa,MAAM;;;;UACN,MAAM;;;;;qBACN,sBAAsB,GAAG,MAAM;;;;;;;;;;;;;;;;UAU/B,MAAM,EAAE;;;;;;;;;;;;;;;;;;;UASR,MAAM;;;;;gBACN,cAAc;;;;;;;;;;;;;;UAQd,MAAM;;;;;gBACN,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CA2BjB,oBAAoB;+CAKpB,eAAe;0CAKf,aAAa,KACX,aAAa;;;;;;;;;;4BAaf,OAAO,SAAS,EAAE,OAAO,QAEjC;IAAsB,KAAK;CAE3B,KAAU,OAAO,SAAS,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BxB,OAAO,UAAU,EAAE,WAAW;;;;kBAC9B,aAAa;;;;qBACb,aAAa;;;;mBACb,aAAa;;;;;mBACb,cAAc,EAAE;;;;;oBAEhB,cAAc,EAAE;;;;oBAEhB,cAAc,EAAE;;;;uBAChB,cAAc;;;;4BACd,cAAc,EAAE;;;;oBAChB,cAAc,EAAE;;;;0BAChB,cAAc;;;;;WACd,OAAO;;;;;YAEP,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2BpB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2DAoBT,eAAe,KACb,MAAM;wDAKR,eAAe,KACb,MAAM,GAAG,wBAAwB;iCAIjC,MAAM,GACZ,wBAAwB,GACxB,2BAA2B,GAC3B,KAAK;;;;;;;;oBAKE,cAAc;;;;cACd,MAAM;;;;eACN,MAAM;;;;iBACN,GAAG;;;;;;uCAMN,GAAG,WACH,eAAe,KACb,eAAe,EAAE;6CAKnB,GAAG,KACD,GAAG;;;;;cAKF,gBAAgB;;;;;cAChB,sBAAsB;;;;YAEtB,MAAM;;;;UACN,MAAM;;;;;;eAKN,MAAM;;;;gBACN,GAAG;;;;cACH,MAAM;;;;oBACN,cAAc;;;;;mDAOjB,gCAAgC,KAC9B,OAAO;;;;;YAKN,MAAM;;;;YACN,MAAM;;;;UACN,MAAM;;;;WACN,MAAM;;yCAKT,SAAS,WACT,cAAc,KACZ,OAAO;oCAKT,SAAS,KACP,OAAO;;;;;;;;;;eAON,MAAM;;;;;;;;;;;;;;;;;;;;aAUN,SAAS,EAAE;;;;oBACX,cAAc;;;;;qBACd,mBAAmB;;kCAMtB,iBAAiB,KACf,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuBrB;QAAgC,GAAG,EAAxB,cAAc;QACC,WAAW,EAA1B,CAAC,MAAM,CAAC;KAErB;;;;;;;;;;;;0CAaU,wBAAwB,KACtB,MAAM;sBAhaG,oBAAoB;uBACnB,2BAA2B;kBAChC,gBAAgB;iBACjB,eAAe;2BACL,yBAAyB;6BACvB,2BAA2B;4BAC5B,0BAA0B;0BAC5B,wBAAwB;wBAC1B,uBAAuB;uBACxB,sBAAsB;oCACT,qBAAqB;iCACxB,2BAA2B;2BACjC,oBAAoB;qCACV,gCAAgC;6BACxC,yBAAyB"}
package/dist/casa.js CHANGED
@@ -1,76 +1,37 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.corePlugins = exports.contextIdGenerators = exports.constants = exports.nunjucksFilters = exports.generateGovukErrors = exports.endSession = exports.waypointUrl = exports.MutableRouter = exports.ValidationError = exports.ValidatorFactory = exports.JourneyContext = exports.Plan = exports.field = exports.validators = exports.configure = void 0;
40
1
  // NOTE: Any changes made here must be reflected in `scripts/esm-wrapper.js`
41
- const configure_js_1 = __importDefault(require("./lib/configure.js"));
42
- exports.configure = configure_js_1.default;
43
- const index_js_1 = __importDefault(require("./lib/validators/index.js"));
44
- exports.validators = index_js_1.default;
45
- const field_js_1 = __importDefault(require("./lib/field.js"));
46
- exports.field = field_js_1.default;
47
- const Plan_js_1 = __importDefault(require("./lib/Plan.js"));
48
- exports.Plan = Plan_js_1.default;
49
- const JourneyContext_js_1 = __importDefault(require("./lib/JourneyContext.js"));
50
- exports.JourneyContext = JourneyContext_js_1.default;
51
- const ValidatorFactory_js_1 = __importDefault(require("./lib/ValidatorFactory.js"));
52
- exports.ValidatorFactory = ValidatorFactory_js_1.default;
53
- const ValidationError_js_1 = __importDefault(require("./lib/ValidationError.js"));
54
- exports.ValidationError = ValidationError_js_1.default;
55
- const MutableRouter_js_1 = __importDefault(require("./lib/MutableRouter.js"));
56
- exports.MutableRouter = MutableRouter_js_1.default;
57
- const waypoint_url_js_1 = __importDefault(require("./lib/waypoint-url.js"));
58
- exports.waypointUrl = waypoint_url_js_1.default;
59
- const end_session_js_1 = __importDefault(require("./lib/end-session.js"));
60
- exports.endSession = end_session_js_1.default;
61
- const journey_js_1 = require("./routes/journey.js");
62
- Object.defineProperty(exports, "generateGovukErrors", { enumerable: true, get: function () { return journey_js_1.generateGovukErrors; } });
63
- const nunjucksFilters = __importStar(require("./lib/nunjucks-filters.js"));
64
- exports.nunjucksFilters = nunjucksFilters;
65
- const constants = __importStar(require("./lib/constants.js"));
66
- exports.constants = constants;
67
- const contextIdGenerators = __importStar(require("./lib/context-id-generators.js"));
68
- exports.contextIdGenerators = contextIdGenerators;
69
- const corePlugins = __importStar(require("./core-plugins/index.js"));
70
- exports.corePlugins = corePlugins;
2
+ import configure from "./lib/configure.js";
3
+ import validators from "./lib/validators/index.js";
4
+ import field from "./lib/field.js";
5
+ import Plan from "./lib/Plan.js";
6
+ import JourneyContext from "./lib/JourneyContext.js";
7
+ import ValidatorFactory from "./lib/ValidatorFactory.js";
8
+ import ValidationError from "./lib/ValidationError.js";
9
+ import MutableRouter from "./lib/MutableRouter.js";
10
+ import waypointUrl from "./lib/waypoint-url.js";
11
+ import endSession from "./lib/end-session.js";
12
+ import { generateGovukErrors } from "./routes/journey.js";
13
+ import * as nunjucksFilters from "./lib/nunjucks-filters.js";
14
+ import * as constants from "./lib/constants.js";
15
+ import * as contextIdGenerators from "./lib/context-id-generators.js";
16
+ import * as corePlugins from "./core-plugins/index.js";
17
+ /** @module @dwp/govuk-casa */
18
+ export { configure, validators, field, Plan, JourneyContext, ValidatorFactory, ValidationError, MutableRouter,
19
+ // Utilities
20
+ waypointUrl, endSession, generateGovukErrors,
21
+ // Nunjucks filters
22
+ nunjucksFilters,
23
+ // Constants
24
+ constants,
25
+ // Context ID generators
26
+ contextIdGenerators,
27
+ // Core plugins
28
+ corePlugins, };
71
29
  /* ----------------------------------------------------------------- Typedefs */
72
30
  // These exist here so that consumer can import CASA's internal types
73
31
  /** @typedef {import("./lib/field").PageField} PageField */
32
+ /** @typedef {import("express").Request} ExpressRequest */
33
+ /** @typedef {import("express").RequestHandler} RequestHandler */
34
+ /** @typedef {import("helmet").HelmetOptions} HelmetOptions */
74
35
  /**
75
36
  * @typedef {object} ContextEventHandlerOptions
76
37
  * @property {JourneyContext} journeyContext Context including changes
@@ -94,11 +55,18 @@ exports.corePlugins = corePlugins;
94
55
  * @property {string} [field] Field to watch for changes
95
56
  * @property {ContextEventHandler} handler Handler to invoke when change happens
96
57
  */
58
+ /**
59
+ * @callback ErrorVisibiltyFunction
60
+ * @param {object} opts Options
61
+ * @param {ExpressRequest} opts.req Request
62
+ */
97
63
  /**
98
64
  * @typedef {object} Page Page configuration. A Page is the interactive
99
65
  * representation of a waypoint
100
66
  * @property {string} waypoint The waypoint with which this page is associated
101
67
  * @property {string} view Template path
68
+ * @property {ErrorVisibiltyFunction | symbol} errorVisibility Should page
69
+ * validation errors be visible on GET requests
102
70
  * @property {PageHook[]} [hooks=[]] Page-specific hooks (optional, default []).
103
71
  * Default is `[]`
104
72
  * @property {PageField[]} [fields=[]] Fields to be managed on this page
@@ -115,16 +83,16 @@ exports.corePlugins = corePlugins;
115
83
  /**
116
84
  * @typedef {object} GlobalHook Hook configuration
117
85
  * @property {string} hook Hook name in format `<router>.<hook>`
118
- * @property {Function} middleware Middleware function to insert at the hook
119
- * point
86
+ * @property {RequestHandler} middleware Middleware function to insert at the
87
+ * hook point
120
88
  * @property {string | RegExp} [path=undefined] Only run if route path matches
121
89
  * this string/regexp. Default is `undefined`
122
90
  */
123
91
  /**
124
92
  * @typedef {object} PageHook (extends GlobalHook)
125
93
  * @property {string} hook Hook name (without a scope prefix)
126
- * @property {Function} middleware Middleware function to insert at the hook
127
- * point
94
+ * @property {RequestHandler} middleware Middleware function to insert at the
95
+ * hook point
128
96
  */
129
97
  /**
130
98
  * @typedef {object} SessionOptions
@@ -155,8 +123,8 @@ exports.corePlugins = corePlugins;
155
123
  */
156
124
  /**
157
125
  * @callback HelmetConfigurator
158
- * @param {object} config A default Helmet configuration provided by CASA
159
- * @returns {object} The modified configuration object
126
+ * @param {HelmetOptions} config A default Helmet configuration provided by CASA
127
+ * @returns {HelmetOptions} The modified configuration object
160
128
  */
161
129
  /**
162
130
  * Mounting function.
@@ -196,10 +164,8 @@ exports.corePlugins = corePlugins;
196
164
  * to ingest. Default is `"50KB"`
197
165
  * @property {ContextIdGenerator} [contextIdGenerator] Custom context ID
198
166
  * generator
199
- * @property {symbol | Function} [errorVisibility] Option to keep page errors
200
- * active on GET request
201
- * @property {boolean} [govukRebrand=false] Sets whether you wish to use the
202
- * govuk rebrand. Default is `false`
167
+ * @property {symbol | ErrorVisibiltyFunction} [errorVisibility] Option to keep
168
+ * page errors active on GET request
203
169
  */
204
170
  /**
205
171
  * @typedef {object} ConfigureResult Result of a call to configure() function
@@ -207,20 +173,15 @@ exports.corePlugins = corePlugins;
207
173
  * @property {MutableRouter} staticRouter Router handling all static assets
208
174
  * @property {MutableRouter} ancillaryRouter Router handling ancillary routes
209
175
  * @property {MutableRouter} journeyRouter Router handling all waypoint requests
210
- * @property {import("express").RequestHandler[]} preMiddleware Middleware
211
- * mounted before everything
212
- * @property {import("express").RequestHandler[]} postMiddleware Middleware
213
- * mounted after everything
214
- * @property {import("express").RequestHandler[]} csrfMiddleware CSRF get/set
215
- * form middleware
216
- * @property {import("express").RequestHandler} sessionMiddleware Session
217
- * middleware
218
- * @property {import("express").RequestHandler[]} cookieParserMiddleware
219
- * Cookie-parsing middleware
220
- * @property {import("express").RequestHandler[]} i18nMiddleware I18n
221
- * preparation middleware
222
- * @property {import("express").RequestHandler} bodyParserMiddleware Body
223
- * parsing middleware
176
+ * @property {RequestHandler[]} preMiddleware Middleware mounted before
177
+ * everything
178
+ * @property {RequestHandler[]} postMiddleware Middleware mounted after
179
+ * everything
180
+ * @property {RequestHandler[]} csrfMiddleware CSRF get/set form middleware
181
+ * @property {RequestHandler} sessionMiddleware Session middleware
182
+ * @property {RequestHandler[]} cookieParserMiddleware Cookie-parsing middleware
183
+ * @property {RequestHandler[]} i18nMiddleware I18n preparation middleware
184
+ * @property {RequestHandler} bodyParserMiddleware Body parsing middleware
224
185
  * @property {Mounter} mount Function used to mount all CASA artifacts onto an
225
186
  * ExpressJS app
226
187
  * @property {ConfigurationOptions} config Ingested config supplied to
@@ -336,13 +297,18 @@ exports.corePlugins = corePlugins;
336
297
  * @param {JourneyContext} context Journey Context
337
298
  * @returns {boolean} Returns true is route should be followed
338
299
  */
300
+ /**
301
+ * @callback StopCondition
302
+ * @param {PlanRoute} route Route metadata
303
+ * @returns {boolean} Returns true is traversal should be stopped
304
+ */
339
305
  /**
340
306
  * @typedef PlanTraverseOptions
341
307
  * @property {string} [startWaypoint] Waypoint from which to start (defaults to
342
308
  * first in list)
343
309
  * @property {string} routeName Follow routes matching this name (next | prev)
344
310
  * @property {Map} history Used to detect loops in traversal (INTERNAL USE ONLY)
345
- * @property {Function} [stopCondition] If true, traversal will be stopped
311
+ * @property {StopCondition} [stopCondition] If true, traversal will be stopped
346
312
  * (useful for performance)
347
313
  * @property {string | PlanArbiter} [arbiter] Multiple target routes found, this
348
314
  * decides which to use
@@ -360,17 +326,24 @@ exports.corePlugins = corePlugins;
360
326
  * @returns {PlanRoute[]} Returns all routes, excluding those that the arbiter
361
327
  * could eliminate
362
328
  */
329
+ /**
330
+ * @typedef {object} JourneyContextIdentity Journey Context Identity Object
331
+ * @property {string} [id] The context ID
332
+ * @property {string} [name] Context name
333
+ * @property {string[]} [tags] JouneyContext tags
334
+ */
363
335
  /**
364
336
  * @typedef {object} JourneyContextObject Journey Context Object
365
337
  * @property {Record<string, any>} [data] Data
366
- * @property {any} [validation] Validation state
367
- * @property {any} [nav] Navigation meta
368
- * @property {any} [identity] Identity meta
338
+ * @property {Record<string, ValidationError[] | null>} [validation] Validation
339
+ * state
340
+ * @property {object} [nav] Navigation meta
341
+ * @property {JourneyContextIdentity} [identity] Identity meta
369
342
  */
370
343
  /**
371
344
  * @typedef ContextIdGeneratorParams
372
345
  * @property {object} args Arguments
373
- * @property {import("express").Request} args.req Request
346
+ * @property {ExpressRequest} args.req Request
374
347
  * @property {[string]} args.reservedIds List of IDs already in use in session
375
348
  * or request
376
349
  */
@@ -388,4 +361,4 @@ exports.corePlugins = corePlugins;
388
361
  * @param {ContextIdGeneratorParams} params Parameters
389
362
  * @returns {string} A newly generated GUID
390
363
  */
391
- //# sourceMappingURL=casa.js.map
364
+ /** @typedef {import("../src/globals.d.ts")} */
@@ -4,3 +4,4 @@
4
4
  */
5
5
  export default function _default(config: ConfigurationOptions): void;
6
6
  export type ConfigurationOptions = import("../../../casa.js").ConfigurationOptions;
7
+ //# sourceMappingURL=configure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/core-plugins/edit-snapshot/src/configure.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH,yCAHW,oBAAoB,GAClB,IAAI,CAgBhB;mCAxBY,OAAO,kBAAkB,EAAE,oBAAoB"}
@@ -1,30 +1,23 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = default_1;
7
- const logger_js_1 = __importDefault(require("../../../lib/logger.js"));
8
- const pre_steer_hook_js_1 = __importDefault(require("./pre-steer-hook.js"));
9
- const post_steer_hook_js_1 = __importDefault(require("./post-steer-hook.js"));
1
+ import logger from "../../../lib/logger.js";
2
+ import preSteerHook from "./pre-steer-hook.js";
3
+ import postSteerHook from "./post-steer-hook.js";
10
4
  /**
11
5
  * @typedef {import("../../../casa.js").ConfigurationOptions} ConfigurationOptions
12
6
  * @access private
13
7
  */
14
- const log = (0, logger_js_1.default)("lib:internal-plugin:edit-snapshot");
8
+ const log = logger("lib:internal-plugin:edit-snapshot");
15
9
  /**
16
10
  * @param {ConfigurationOptions} config Configuration object
17
11
  * @returns {void}
18
12
  */
19
- function default_1(config) {
13
+ export default function (config) {
20
14
  log.info("Configuring 'edit-snapshot' plugin");
21
15
  config.hooks ??= [];
22
16
  config.hooks.push({
23
17
  hook: "journey.presteer",
24
- middleware: pre_steer_hook_js_1.default,
18
+ middleware: preSteerHook,
25
19
  }, {
26
20
  hook: "journey.poststeer",
27
- middleware: post_steer_hook_js_1.default,
21
+ middleware: postSteerHook,
28
22
  });
29
23
  }
30
- //# sourceMappingURL=configure.js.map
@@ -3,3 +3,4 @@ declare function _default(): {
3
3
  };
4
4
  export default _default;
5
5
  import configure from "./configure.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core-plugins/edit-snapshot/src/index.js"],"names":[],"mappings":"AAEe;;EAId;;sBANqB,gBAAgB"}
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const configure_js_1 = __importDefault(require("./configure.js"));
7
- exports.default = () => {
1
+ import configure from "./configure.js";
2
+ export default () => {
8
3
  return {
9
- configure: configure_js_1.default,
4
+ configure,
10
5
  };
11
6
  };
12
- //# sourceMappingURL=index.js.map
@@ -1,2 +1,3 @@
1
- declare function _default(req: any, res: any, next: any): any;
1
+ declare const _default: (req: import("express-serve-static-core").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express-serve-static-core").Response<any, Record<string, any>, number>, next: import("express-serve-static-core").NextFunction) => unknown;
2
2
  export default _default;
3
+ //# sourceMappingURL=post-steer-hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-steer-hook.d.ts","sourceRoot":"","sources":["../../../../src/core-plugins/edit-snapshot/src/post-steer-hook.js"],"names":[],"mappings":"yBAMgB,4JAAG,EAAE,mFAAG,EAAE,sDAAI"}
@@ -1,23 +1,18 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const logger_js_1 = __importDefault(require("../../../lib/logger.js"));
7
- const utils_js_1 = require("./utils.js");
8
- const log = (0, logger_js_1.default)("lib:internal-plugin:edit-snapshot:post-steer-hook");
9
- exports.default = (req, res, next) => {
1
+ import logger from "../../../lib/logger.js";
2
+ import { FLAG_FOR_PURGING, deleteSnapshot } from "./utils.js";
3
+ const log = logger("lib:internal-plugin:edit-snapshot:post-steer-hook");
4
+ /** @type {import("express").RequestHandler} */
5
+ export default (req, res, next) => {
10
6
  // Snapshot purging is carried out here rather than in the presteer hook,
11
7
  // because the `middleware/steer-journey.js` middleware first needs the opportunity
12
8
  // to redirect if the journey cannot be traversed to the edit origin.
13
9
  // eslint-disable-next-line security/detect-object-injection
14
- if (req.casa[utils_js_1.FLAG_FOR_PURGING] === true) {
10
+ if (req.casa[FLAG_FOR_PURGING] === true) {
15
11
  log.debug(`Snapshot purging flag has been set for context '${req.casa.journeyContext.identity.id}'. Snapshot will be deleted.`);
16
- (0, utils_js_1.deleteSnapshot)(log, req);
12
+ deleteSnapshot(log, req);
17
13
  // eslint-disable-next-line security/detect-object-injection
18
- req.casa[utils_js_1.FLAG_FOR_PURGING] = false;
14
+ req.casa[FLAG_FOR_PURGING] = false;
19
15
  return req.session.save(next);
20
16
  }
21
17
  next();
22
18
  };
23
- //# sourceMappingURL=post-steer-hook.js.map
@@ -1,2 +1,3 @@
1
- declare function _default(req: any, res: any, next: any): any;
1
+ declare const _default: (req: import("express-serve-static-core").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express-serve-static-core").Response<any, Record<string, any>, number>, next: import("express-serve-static-core").NextFunction) => unknown;
2
2
  export default _default;
3
+ //# sourceMappingURL=pre-steer-hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-steer-hook.d.ts","sourceRoot":"","sources":["../../../../src/core-plugins/edit-snapshot/src/pre-steer-hook.js"],"names":[],"mappings":"yBAYgB,4JAAG,EAAE,mFAAG,EAAE,sDAAI"}