@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.
- package/dist/assets/css/casa.css +1 -1
- package/dist/assets/css/casa.css.map +1 -1
- package/dist/casa.d.ts +81 -41
- package/dist/casa.d.ts.map +1 -0
- package/dist/casa.js +72 -99
- package/dist/core-plugins/edit-snapshot/src/configure.d.ts +1 -0
- package/dist/core-plugins/edit-snapshot/src/configure.d.ts.map +1 -0
- package/dist/core-plugins/edit-snapshot/src/configure.js +7 -14
- package/dist/core-plugins/edit-snapshot/src/index.d.ts +1 -0
- package/dist/core-plugins/edit-snapshot/src/index.d.ts.map +1 -0
- package/dist/core-plugins/edit-snapshot/src/index.js +3 -9
- package/dist/core-plugins/edit-snapshot/src/post-steer-hook.d.ts +2 -1
- package/dist/core-plugins/edit-snapshot/src/post-steer-hook.d.ts.map +1 -0
- package/dist/core-plugins/edit-snapshot/src/post-steer-hook.js +8 -13
- package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.d.ts +2 -1
- package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.d.ts.map +1 -0
- package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.js +13 -18
- package/dist/core-plugins/edit-snapshot/src/utils.d.ts +8 -5
- package/dist/core-plugins/edit-snapshot/src/utils.d.ts.map +1 -0
- package/dist/core-plugins/edit-snapshot/src/utils.js +37 -19
- package/dist/core-plugins/index.d.ts +1 -0
- package/dist/core-plugins/index.d.ts.map +1 -0
- package/dist/core-plugins/index.js +1 -9
- package/dist/lib/CasaTemplateLoader.d.ts +1 -0
- package/dist/lib/CasaTemplateLoader.d.ts.map +1 -0
- package/dist/lib/CasaTemplateLoader.js +2 -6
- package/dist/lib/JourneyContext.d.ts +22 -11
- package/dist/lib/JourneyContext.d.ts.map +1 -0
- package/dist/lib/JourneyContext.js +40 -45
- package/dist/lib/MutableRouter.d.ts +74 -55
- package/dist/lib/MutableRouter.d.ts.map +1 -0
- package/dist/lib/MutableRouter.js +48 -45
- package/dist/lib/NullObject.d.ts +3 -0
- package/dist/lib/NullObject.d.ts.map +1 -0
- package/dist/lib/NullObject.js +3 -0
- package/dist/lib/Plan.d.ts +2 -1
- package/dist/lib/Plan.d.ts.map +1 -0
- package/dist/lib/Plan.js +44 -62
- package/dist/lib/ValidationError.d.ts +2 -1
- package/dist/lib/ValidationError.d.ts.map +1 -0
- package/dist/lib/ValidationError.js +3 -11
- package/dist/lib/ValidatorFactory.d.ts +5 -6
- package/dist/lib/ValidatorFactory.d.ts.map +1 -0
- package/dist/lib/ValidatorFactory.js +4 -12
- package/dist/lib/configuration-ingestor.d.ts +10 -22
- package/dist/lib/configuration-ingestor.d.ts.map +1 -0
- package/dist/lib/configuration-ingestor.js +61 -143
- package/dist/lib/configure.d.ts +2 -1
- package/dist/lib/configure.d.ts.map +1 -0
- package/dist/lib/configure.js +40 -52
- package/dist/lib/constants.d.ts +1 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +8 -12
- package/dist/lib/context-id-generators.d.ts +1 -0
- package/dist/lib/context-id-generators.d.ts.map +1 -0
- package/dist/lib/context-id-generators.js +4 -9
- package/dist/lib/end-session.d.ts +2 -1
- package/dist/lib/end-session.d.ts.map +1 -0
- package/dist/lib/end-session.js +4 -11
- package/dist/lib/field.d.ts +2 -1
- package/dist/lib/field.d.ts.map +1 -0
- package/dist/lib/field.js +11 -21
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +13 -65
- package/dist/lib/logger.d.ts +25 -2
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +18 -9
- package/dist/lib/mount.d.ts +1 -0
- package/dist/lib/mount.d.ts.map +1 -0
- package/dist/lib/mount.js +10 -16
- package/dist/lib/nunjucks-filters.d.ts +7 -3
- package/dist/lib/nunjucks-filters.d.ts.map +1 -0
- package/dist/lib/nunjucks-filters.js +58 -71
- package/dist/lib/nunjucks.d.ts +2 -2
- package/dist/lib/nunjucks.d.ts.map +1 -0
- package/dist/lib/nunjucks.js +12 -25
- package/dist/lib/utils.d.ts +4 -2
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +14 -28
- package/dist/lib/validators/dateObject.d.ts +1 -0
- package/dist/lib/validators/dateObject.d.ts.map +1 -0
- package/dist/lib/validators/dateObject.js +14 -21
- package/dist/lib/validators/email.d.ts +1 -0
- package/dist/lib/validators/email.d.ts.map +1 -0
- package/dist/lib/validators/email.js +8 -15
- package/dist/lib/validators/inArray.d.ts +1 -0
- package/dist/lib/validators/inArray.d.ts.map +1 -0
- package/dist/lib/validators/inArray.js +8 -15
- package/dist/lib/validators/index.d.ts +1 -0
- package/dist/lib/validators/index.d.ts.map +1 -0
- package/dist/lib/validators/index.js +21 -27
- package/dist/lib/validators/nino.d.ts +1 -0
- package/dist/lib/validators/nino.d.ts.map +1 -0
- package/dist/lib/validators/nino.js +6 -13
- package/dist/lib/validators/postalAddressObject.d.ts +1 -0
- package/dist/lib/validators/postalAddressObject.d.ts.map +1 -0
- package/dist/lib/validators/postalAddressObject.js +12 -19
- package/dist/lib/validators/range.d.ts +1 -0
- package/dist/lib/validators/range.d.ts.map +1 -0
- package/dist/lib/validators/range.js +6 -13
- package/dist/lib/validators/regex.d.ts +1 -0
- package/dist/lib/validators/regex.d.ts.map +1 -0
- package/dist/lib/validators/regex.js +6 -13
- package/dist/lib/validators/required.d.ts +1 -0
- package/dist/lib/validators/required.d.ts.map +1 -0
- package/dist/lib/validators/required.js +9 -17
- package/dist/lib/validators/strlen.d.ts +1 -0
- package/dist/lib/validators/strlen.d.ts.map +1 -0
- package/dist/lib/validators/strlen.js +6 -13
- package/dist/lib/validators/wordCount.d.ts +1 -0
- package/dist/lib/validators/wordCount.d.ts.map +1 -0
- package/dist/lib/validators/wordCount.js +6 -13
- package/dist/lib/waypoint-url.d.ts +3 -2
- package/dist/lib/waypoint-url.d.ts.map +1 -0
- package/dist/lib/waypoint-url.js +12 -19
- package/dist/middleware/body-parser.d.ts +1 -0
- package/dist/middleware/body-parser.d.ts.map +1 -0
- package/dist/middleware/body-parser.js +4 -9
- package/dist/middleware/csrf.d.ts +1 -0
- package/dist/middleware/csrf.d.ts.map +1 -0
- package/dist/middleware/csrf.js +4 -8
- package/dist/middleware/data.d.ts +2 -3
- package/dist/middleware/data.d.ts.map +1 -0
- package/dist/middleware/data.js +23 -25
- package/dist/middleware/gather-fields.d.ts +3 -1
- package/dist/middleware/gather-fields.d.ts.map +1 -0
- package/dist/middleware/gather-fields.js +13 -14
- package/dist/middleware/i18n.d.ts +1 -0
- package/dist/middleware/i18n.d.ts.map +1 -0
- package/dist/middleware/i18n.js +26 -31
- package/dist/middleware/post.d.ts +1 -0
- package/dist/middleware/post.d.ts.map +1 -0
- package/dist/middleware/post.js +3 -10
- package/dist/middleware/pre.d.ts +2 -1
- package/dist/middleware/pre.d.ts.map +1 -0
- package/dist/middleware/pre.js +6 -12
- package/dist/middleware/progress-journey.d.ts +5 -3
- package/dist/middleware/progress-journey.d.ts.map +1 -0
- package/dist/middleware/progress-journey.js +20 -18
- package/dist/middleware/sanitise-fields.d.ts +5 -3
- package/dist/middleware/sanitise-fields.d.ts.map +1 -0
- package/dist/middleware/sanitise-fields.js +25 -17
- package/dist/middleware/serve-first-waypoint.d.ts +1 -0
- package/dist/middleware/serve-first-waypoint.d.ts.map +1 -0
- package/dist/middleware/serve-first-waypoint.js +3 -6
- package/dist/middleware/session.d.ts +15 -0
- package/dist/middleware/session.d.ts.map +1 -0
- package/dist/middleware/session.js +53 -57
- package/dist/middleware/skip-waypoint.d.ts +3 -2
- package/dist/middleware/skip-waypoint.d.ts.map +1 -0
- package/dist/middleware/skip-waypoint.js +15 -14
- package/dist/middleware/steer-journey.d.ts +2 -1
- package/dist/middleware/steer-journey.d.ts.map +1 -0
- package/dist/middleware/steer-journey.js +7 -13
- package/dist/middleware/strip-proxy-path.d.ts +3 -2
- package/dist/middleware/strip-proxy-path.d.ts.map +1 -0
- package/dist/middleware/strip-proxy-path.js +24 -24
- package/dist/middleware/validate-fields.d.ts +7 -4
- package/dist/middleware/validate-fields.d.ts.map +1 -0
- package/dist/middleware/validate-fields.js +22 -11
- package/dist/routes/ancillary.d.ts +1 -0
- package/dist/routes/ancillary.d.ts.map +1 -0
- package/dist/routes/ancillary.js +3 -10
- package/dist/routes/journey.d.ts +7 -2
- package/dist/routes/journey.d.ts.map +1 -0
- package/dist/routes/journey.js +56 -55
- package/dist/routes/static.d.ts +1 -0
- package/dist/routes/static.d.ts.map +1 -0
- package/dist/routes/static.js +15 -23
- package/package.json +20 -26
- package/src/casa.js +49 -29
- package/src/core-plugins/edit-snapshot/src/post-steer-hook.js +1 -0
- package/src/core-plugins/edit-snapshot/src/pre-steer-hook.js +2 -1
- package/src/core-plugins/edit-snapshot/src/utils.js +29 -1
- package/src/lib/JourneyContext.js +31 -28
- package/src/lib/MutableRouter.js +47 -38
- package/src/lib/NullObject.js +4 -0
- package/src/lib/Plan.js +41 -55
- package/src/lib/ValidationError.js +2 -4
- package/src/lib/ValidatorFactory.js +3 -5
- package/src/lib/configuration-ingestor.js +18 -38
- package/src/lib/configure.js +7 -10
- package/src/lib/end-session.js +1 -1
- package/src/lib/field.js +7 -12
- package/src/lib/logger.js +16 -0
- package/src/lib/mount.js +1 -1
- package/src/lib/nunjucks-filters.js +51 -61
- package/src/lib/nunjucks.js +3 -12
- package/src/lib/utils.js +2 -1
- package/src/lib/validators/dateObject.js +3 -4
- package/src/lib/validators/postalAddressObject.js +6 -7
- package/src/lib/validators/required.js +1 -3
- package/src/lib/waypoint-url.js +15 -19
- package/src/middleware/csrf.js +1 -1
- package/src/middleware/data.js +13 -13
- package/src/middleware/gather-fields.js +8 -2
- package/src/middleware/i18n.js +9 -6
- package/src/middleware/pre.js +1 -1
- package/src/middleware/progress-journey.js +8 -0
- package/src/middleware/sanitise-fields.js +17 -2
- package/src/middleware/session.js +53 -12
- package/src/middleware/skip-waypoint.js +8 -1
- package/src/middleware/steer-journey.js +1 -1
- package/src/middleware/strip-proxy-path.js +21 -16
- package/src/middleware/validate-fields.js +19 -0
- package/src/routes/journey.js +18 -8
- package/src/routes/static.js +5 -4
- package/views/casa/layouts/journey.njk +1 -1
- package/views/casa/layouts/main.njk +11 -21
- package/dist/casa.js.map +0 -1
- package/dist/core-plugins/edit-snapshot/src/configure.js.map +0 -1
- package/dist/core-plugins/edit-snapshot/src/index.js.map +0 -1
- package/dist/core-plugins/edit-snapshot/src/post-steer-hook.js.map +0 -1
- package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.js.map +0 -1
- package/dist/core-plugins/edit-snapshot/src/utils.js.map +0 -1
- package/dist/core-plugins/index.js.map +0 -1
- package/dist/lib/CasaTemplateLoader.js.map +0 -1
- package/dist/lib/JourneyContext.js.map +0 -1
- package/dist/lib/MutableRouter.js.map +0 -1
- package/dist/lib/Plan.js.map +0 -1
- package/dist/lib/ValidationError.js.map +0 -1
- package/dist/lib/ValidatorFactory.js.map +0 -1
- package/dist/lib/configuration-ingestor.js.map +0 -1
- package/dist/lib/configure.js.map +0 -1
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/context-id-generators.js.map +0 -1
- package/dist/lib/dirname.cjs +0 -1
- package/dist/lib/dirname.d.cts +0 -2
- package/dist/lib/end-session.js.map +0 -1
- package/dist/lib/field.js.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/logger.js.map +0 -1
- package/dist/lib/mount.js.map +0 -1
- package/dist/lib/nunjucks-filters.js.map +0 -1
- package/dist/lib/nunjucks.js.map +0 -1
- package/dist/lib/utils.js.map +0 -1
- package/dist/lib/validators/dateObject.js.map +0 -1
- package/dist/lib/validators/email.js.map +0 -1
- package/dist/lib/validators/inArray.js.map +0 -1
- package/dist/lib/validators/index.js.map +0 -1
- package/dist/lib/validators/nino.js.map +0 -1
- package/dist/lib/validators/postalAddressObject.js.map +0 -1
- package/dist/lib/validators/range.js.map +0 -1
- package/dist/lib/validators/regex.js.map +0 -1
- package/dist/lib/validators/required.js.map +0 -1
- package/dist/lib/validators/strlen.js.map +0 -1
- package/dist/lib/validators/wordCount.js.map +0 -1
- package/dist/lib/waypoint-url.js.map +0 -1
- package/dist/middleware/body-parser.js.map +0 -1
- package/dist/middleware/csrf.js.map +0 -1
- package/dist/middleware/data.js.map +0 -1
- package/dist/middleware/dirname.cjs +0 -1
- package/dist/middleware/dirname.d.cts +0 -2
- package/dist/middleware/gather-fields.js.map +0 -1
- package/dist/middleware/i18n.js.map +0 -1
- package/dist/middleware/post.js.map +0 -1
- package/dist/middleware/pre.js.map +0 -1
- package/dist/middleware/progress-journey.js.map +0 -1
- package/dist/middleware/sanitise-fields.js.map +0 -1
- package/dist/middleware/serve-first-waypoint.js.map +0 -1
- package/dist/middleware/session.js.map +0 -1
- package/dist/middleware/skip-waypoint.js.map +0 -1
- package/dist/middleware/steer-journey.js.map +0 -1
- package/dist/middleware/strip-proxy-path.js.map +0 -1
- package/dist/middleware/validate-fields.js.map +0 -1
- package/dist/mjs/esm-wrapper.js +0 -20
- package/dist/mjs/package.json +0 -3
- package/dist/package.json +0 -3
- package/dist/routes/ancillary.js.map +0 -1
- package/dist/routes/dirname.cjs +0 -1
- package/dist/routes/dirname.d.cts +0 -2
- package/dist/routes/journey.js.map +0 -1
- package/dist/routes/static.js.map +0 -1
- package/src/lib/dirname.cjs +0 -1
- package/src/middleware/dirname.cjs +0 -1
- 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
|
|
92
|
-
* point
|
|
102
|
+
* Middleware function to insert at the
|
|
103
|
+
* hook point
|
|
93
104
|
*/
|
|
94
|
-
middleware:
|
|
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
|
|
111
|
-
* point
|
|
121
|
+
* Middleware function to insert at the
|
|
122
|
+
* hook point
|
|
112
123
|
*/
|
|
113
|
-
middleware:
|
|
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:
|
|
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
|
|
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
|
-
|
|
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
|
-
*
|
|
276
|
+
* Middleware mounted before
|
|
277
|
+
* everything
|
|
272
278
|
*/
|
|
273
|
-
preMiddleware:
|
|
279
|
+
preMiddleware: RequestHandler[];
|
|
274
280
|
/**
|
|
275
|
-
* Middleware
|
|
276
|
-
*
|
|
281
|
+
* Middleware mounted after
|
|
282
|
+
* everything
|
|
277
283
|
*/
|
|
278
|
-
postMiddleware:
|
|
284
|
+
postMiddleware: RequestHandler[];
|
|
279
285
|
/**
|
|
280
|
-
* CSRF get/set
|
|
281
|
-
* form middleware
|
|
286
|
+
* CSRF get/set form middleware
|
|
282
287
|
*/
|
|
283
|
-
csrfMiddleware:
|
|
288
|
+
csrfMiddleware: RequestHandler[];
|
|
284
289
|
/**
|
|
285
|
-
* Session
|
|
286
|
-
* middleware
|
|
290
|
+
* Session middleware
|
|
287
291
|
*/
|
|
288
|
-
sessionMiddleware:
|
|
292
|
+
sessionMiddleware: RequestHandler;
|
|
289
293
|
/**
|
|
290
|
-
*
|
|
294
|
+
* Cookie-parsing middleware
|
|
291
295
|
*/
|
|
292
|
-
cookieParserMiddleware:
|
|
296
|
+
cookieParserMiddleware: RequestHandler[];
|
|
293
297
|
/**
|
|
294
|
-
* I18n
|
|
295
|
-
* preparation middleware
|
|
298
|
+
* I18n preparation middleware
|
|
296
299
|
*/
|
|
297
|
-
i18nMiddleware:
|
|
300
|
+
i18nMiddleware: RequestHandler[];
|
|
298
301
|
/**
|
|
299
|
-
* Body
|
|
300
|
-
* parsing middleware
|
|
302
|
+
* Body parsing middleware
|
|
301
303
|
*/
|
|
302
|
-
bodyParserMiddleware:
|
|
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?:
|
|
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
|
|
538
|
+
* Validation
|
|
539
|
+
* state
|
|
519
540
|
*/
|
|
520
|
-
validation?:
|
|
541
|
+
validation?: Record<string, ValidationError[] | null> | undefined;
|
|
521
542
|
/**
|
|
522
543
|
* Navigation meta
|
|
523
544
|
*/
|
|
524
|
-
nav?:
|
|
545
|
+
nav?: object | undefined;
|
|
525
546
|
/**
|
|
526
547
|
* Identity meta
|
|
527
548
|
*/
|
|
528
|
-
identity?:
|
|
549
|
+
identity?: JourneyContextIdentity | undefined;
|
|
529
550
|
};
|
|
530
551
|
export type ContextIdGeneratorParams = {
|
|
531
552
|
/**
|
|
532
553
|
* Arguments
|
|
533
554
|
*/
|
|
534
555
|
args: {
|
|
535
|
-
req:
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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 {
|
|
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 {
|
|
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 {
|
|
159
|
-
* @returns {
|
|
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 |
|
|
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 {
|
|
211
|
-
*
|
|
212
|
-
* @property {
|
|
213
|
-
*
|
|
214
|
-
* @property {
|
|
215
|
-
*
|
|
216
|
-
* @property {
|
|
217
|
-
*
|
|
218
|
-
* @property {
|
|
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 {
|
|
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 {
|
|
367
|
-
*
|
|
368
|
-
* @property {
|
|
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 {
|
|
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
|
-
|
|
364
|
+
/** @typedef {import("../src/globals.d.ts")} */
|
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 = (
|
|
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
|
|
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:
|
|
18
|
+
middleware: preSteerHook,
|
|
25
19
|
}, {
|
|
26
20
|
hook: "journey.poststeer",
|
|
27
|
-
middleware:
|
|
21
|
+
middleware: postSteerHook,
|
|
28
22
|
});
|
|
29
23
|
}
|
|
30
|
-
//# sourceMappingURL=configure.js.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
|
-
|
|
2
|
-
|
|
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
|
|
4
|
+
configure,
|
|
10
5
|
};
|
|
11
6
|
};
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
declare
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
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[
|
|
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
|
-
|
|
12
|
+
deleteSnapshot(log, req);
|
|
17
13
|
// eslint-disable-next-line security/detect-object-injection
|
|
18
|
-
req.casa[
|
|
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
|
|
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"}
|