@dwp/govuk-casa 8.15.0 → 9.1.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/README.md +9 -9
- package/dist/assets/css/casa.css +2 -1
- package/dist/assets/css/casa.css.map +1 -0
- package/dist/casa.d.ts +122 -99
- package/dist/casa.js +120 -88
- package/dist/casa.js.map +1 -1
- package/dist/lib/CasaTemplateLoader.d.ts +4 -4
- package/dist/lib/CasaTemplateLoader.js +16 -16
- package/dist/lib/CasaTemplateLoader.js.map +1 -1
- package/dist/lib/JourneyContext.d.ts +38 -40
- package/dist/lib/JourneyContext.js +89 -75
- package/dist/lib/JourneyContext.js.map +1 -1
- package/dist/lib/MutableRouter.d.ts +40 -41
- package/dist/lib/MutableRouter.js +64 -71
- package/dist/lib/MutableRouter.js.map +1 -1
- package/dist/lib/Plan.d.ts +29 -26
- package/dist/lib/Plan.js +85 -71
- package/dist/lib/Plan.js.map +1 -1
- package/dist/lib/ValidationError.d.ts +16 -15
- package/dist/lib/ValidationError.js +21 -20
- package/dist/lib/ValidationError.js.map +1 -1
- package/dist/lib/ValidatorFactory.d.ts +15 -13
- package/dist/lib/ValidatorFactory.js +14 -12
- package/dist/lib/ValidatorFactory.js.map +1 -1
- package/dist/lib/configuration-ingestor.d.ts +37 -40
- package/dist/lib/configuration-ingestor.js +93 -93
- package/dist/lib/configuration-ingestor.js.map +1 -1
- package/dist/lib/configure.d.ts +6 -6
- package/dist/lib/configure.js +14 -12
- package/dist/lib/configure.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -3
- package/dist/lib/constants.js +9 -11
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/context-id-generators.d.ts +3 -5
- package/dist/lib/context-id-generators.js +7 -6
- package/dist/lib/context-id-generators.js.map +1 -1
- package/dist/lib/end-session.d.ts +4 -4
- package/dist/lib/end-session.js +5 -5
- package/dist/lib/field.d.ts +24 -29
- package/dist/lib/field.js +41 -70
- package/dist/lib/field.js.map +1 -1
- package/dist/lib/index.d.ts +13 -13
- package/dist/lib/logger.d.ts +7 -6
- package/dist/lib/logger.js +7 -7
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mount.d.ts +5 -5
- package/dist/lib/mount.js +12 -17
- package/dist/lib/mount.js.map +1 -1
- package/dist/lib/nunjucks-filters.d.ts +10 -12
- package/dist/lib/nunjucks-filters.js +35 -35
- package/dist/lib/nunjucks-filters.js.map +1 -1
- package/dist/lib/nunjucks.d.ts +7 -5
- package/dist/lib/nunjucks.js +10 -8
- package/dist/lib/nunjucks.js.map +1 -1
- package/dist/lib/utils.d.ts +19 -19
- package/dist/lib/utils.js +62 -55
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validators/dateObject.d.ts +29 -22
- package/dist/lib/validators/dateObject.js +58 -49
- package/dist/lib/validators/dateObject.js.map +1 -1
- package/dist/lib/validators/email.d.ts +4 -4
- package/dist/lib/validators/email.js +4 -4
- package/dist/lib/validators/inArray.d.ts +4 -4
- package/dist/lib/validators/inArray.js +7 -8
- package/dist/lib/validators/inArray.js.map +1 -1
- package/dist/lib/validators/index.d.ts +10 -10
- package/dist/lib/validators/index.js +1 -3
- package/dist/lib/validators/index.js.map +1 -1
- package/dist/lib/validators/nino.d.ts +9 -8
- package/dist/lib/validators/nino.js +14 -10
- package/dist/lib/validators/nino.js.map +1 -1
- package/dist/lib/validators/postalAddressObject.d.ts +37 -24
- package/dist/lib/validators/postalAddressObject.js +65 -46
- package/dist/lib/validators/postalAddressObject.js.map +1 -1
- package/dist/lib/validators/range.d.ts +12 -8
- package/dist/lib/validators/range.js +11 -9
- package/dist/lib/validators/range.js.map +1 -1
- package/dist/lib/validators/regex.d.ts +4 -4
- package/dist/lib/validators/regex.js +5 -5
- package/dist/lib/validators/required.d.ts +6 -6
- package/dist/lib/validators/required.js +9 -11
- package/dist/lib/validators/required.js.map +1 -1
- package/dist/lib/validators/strlen.d.ts +12 -8
- package/dist/lib/validators/strlen.js +13 -11
- package/dist/lib/validators/strlen.js.map +1 -1
- package/dist/lib/validators/wordCount.d.ts +12 -8
- package/dist/lib/validators/wordCount.js +15 -11
- package/dist/lib/validators/wordCount.js.map +1 -1
- package/dist/lib/waypoint-url.d.ts +16 -13
- package/dist/lib/waypoint-url.js +39 -36
- package/dist/lib/waypoint-url.js.map +1 -1
- package/dist/middleware/body-parser.d.ts +1 -1
- package/dist/middleware/body-parser.js +6 -6
- package/dist/middleware/body-parser.js.map +1 -1
- package/dist/middleware/data.d.ts +1 -1
- package/dist/middleware/data.js +8 -7
- package/dist/middleware/data.js.map +1 -1
- package/dist/middleware/gather-fields.d.ts +2 -2
- package/dist/middleware/gather-fields.js +6 -4
- package/dist/middleware/gather-fields.js.map +1 -1
- package/dist/middleware/i18n.js +13 -15
- package/dist/middleware/i18n.js.map +1 -1
- package/dist/middleware/post.js +30 -18
- package/dist/middleware/post.js.map +1 -1
- package/dist/middleware/pre.d.ts +2 -2
- package/dist/middleware/pre.js +46 -26
- package/dist/middleware/pre.js.map +1 -1
- package/dist/middleware/progress-journey.d.ts +1 -1
- package/dist/middleware/progress-journey.js +5 -5
- package/dist/middleware/progress-journey.js.map +1 -1
- package/dist/middleware/sanitise-fields.d.ts +1 -1
- package/dist/middleware/sanitise-fields.js +13 -11
- package/dist/middleware/sanitise-fields.js.map +1 -1
- package/dist/middleware/serve-first-waypoint.d.ts +3 -3
- package/dist/middleware/serve-first-waypoint.js +8 -6
- package/dist/middleware/serve-first-waypoint.js.map +1 -1
- package/dist/middleware/session.js +14 -11
- package/dist/middleware/session.js.map +1 -1
- package/dist/middleware/skip-waypoint.d.ts +1 -1
- package/dist/middleware/skip-waypoint.js +3 -3
- package/dist/middleware/skip-waypoint.js.map +1 -1
- package/dist/middleware/steer-journey.d.ts +1 -1
- package/dist/middleware/steer-journey.js +16 -14
- package/dist/middleware/steer-journey.js.map +1 -1
- package/dist/middleware/strip-proxy-path.d.ts +1 -1
- package/dist/middleware/strip-proxy-path.js +3 -3
- package/dist/middleware/strip-proxy-path.js.map +1 -1
- package/dist/middleware/validate-fields.d.ts +1 -1
- package/dist/middleware/validate-fields.js +2 -5
- package/dist/middleware/validate-fields.js.map +1 -1
- package/dist/routes/ancillary.d.ts +3 -3
- package/dist/routes/ancillary.js +4 -4
- package/dist/routes/ancillary.js.map +1 -1
- package/dist/routes/journey.d.ts +2 -2
- package/dist/routes/journey.js +91 -39
- package/dist/routes/journey.js.map +1 -1
- package/dist/routes/static.d.ts +7 -5
- package/dist/routes/static.js +20 -20
- package/dist/routes/static.js.map +1 -1
- package/package.json +17 -16
- package/src/casa.js +134 -102
- package/src/lib/CasaTemplateLoader.js +24 -19
- package/src/lib/JourneyContext.js +147 -107
- package/src/lib/MutableRouter.js +72 -74
- package/src/lib/Plan.js +145 -97
- package/src/lib/ValidationError.js +25 -21
- package/src/lib/ValidatorFactory.js +17 -13
- package/src/lib/configuration-ingestor.js +147 -110
- package/src/lib/configure.js +34 -32
- package/src/lib/constants.js +9 -11
- package/src/lib/context-id-generators.js +40 -43
- package/src/lib/end-session.js +6 -6
- package/src/lib/field.js +74 -78
- package/src/lib/index.js +12 -12
- package/src/lib/logger.js +9 -9
- package/src/lib/mount.js +70 -80
- package/src/lib/nunjucks-filters.js +56 -59
- package/src/lib/nunjucks.js +23 -18
- package/src/lib/utils.js +78 -57
- package/src/lib/validators/dateObject.js +71 -60
- package/src/lib/validators/email.js +8 -8
- package/src/lib/validators/inArray.js +10 -11
- package/src/lib/validators/index.js +12 -14
- package/src/lib/validators/nino.js +29 -15
- package/src/lib/validators/postalAddressObject.js +87 -63
- package/src/lib/validators/range.js +14 -12
- package/src/lib/validators/regex.js +8 -8
- package/src/lib/validators/required.js +16 -16
- package/src/lib/validators/strlen.js +16 -14
- package/src/lib/validators/wordCount.js +22 -14
- package/src/lib/waypoint-url.js +64 -46
- package/src/middleware/body-parser.js +10 -10
- package/src/middleware/csrf.js +1 -1
- package/src/middleware/data.js +28 -24
- package/src/middleware/gather-fields.js +10 -9
- package/src/middleware/i18n.js +35 -37
- package/src/middleware/post.js +41 -21
- package/src/middleware/pre.js +62 -40
- package/src/middleware/progress-journey.js +32 -18
- package/src/middleware/sanitise-fields.js +43 -20
- package/src/middleware/serve-first-waypoint.js +14 -12
- package/src/middleware/session.js +74 -61
- package/src/middleware/skip-waypoint.js +7 -9
- package/src/middleware/steer-journey.js +40 -28
- package/src/middleware/strip-proxy-path.js +8 -7
- package/src/middleware/validate-fields.js +5 -12
- package/src/routes/ancillary.js +5 -7
- package/src/routes/journey.js +159 -85
- package/src/routes/static.js +62 -30
- package/views/casa/components/character-count/README.md +2 -2
- package/views/casa/components/checkboxes/README.md +6 -6
- package/views/casa/components/date-input/README.md +7 -7
- package/views/casa/components/input/README.md +2 -2
- package/views/casa/components/journey-form/README.md +33 -14
- package/views/casa/components/postal-address-object/README.md +4 -4
- package/views/casa/components/radios/README.md +6 -6
- package/views/casa/components/select/README.md +6 -6
- package/views/casa/components/textarea/README.md +2 -2
- package/views/casa/partials/scripts.njk +5 -3
- package/views/casa/partials/styles.njk +1 -4
- package/dist/assets/css/casa-ie8.css +0 -1
package/dist/casa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type PageField = import(
|
|
1
|
+
export type PageField = import("./lib/field").PageField;
|
|
2
2
|
export type ContextEventHandlerOptions = {
|
|
3
3
|
/**
|
|
4
4
|
* Context including changes
|
|
@@ -20,7 +20,8 @@ export type ContextEventHandlerOptions = {
|
|
|
20
20
|
export type ContextEventHandler = (opts: ContextEventHandlerOptions) => void;
|
|
21
21
|
export type ContextEventUserInfo = {
|
|
22
22
|
/**
|
|
23
|
-
* Request phase at which event is
|
|
23
|
+
* Request phase at which event is
|
|
24
|
+
* triggered
|
|
24
25
|
*/
|
|
25
26
|
casaRequestPhase?: symbol | undefined;
|
|
26
27
|
};
|
|
@@ -39,7 +40,8 @@ export type ContextEvent = {
|
|
|
39
40
|
handler: ContextEventHandler;
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
42
|
-
* Page configuration. A Page is the interactive
|
|
43
|
+
* Page configuration. A Page is the interactive
|
|
44
|
+
* representation of a waypoint
|
|
43
45
|
*/
|
|
44
46
|
export type Page = {
|
|
45
47
|
/**
|
|
@@ -51,11 +53,13 @@ export type Page = {
|
|
|
51
53
|
*/
|
|
52
54
|
view: string;
|
|
53
55
|
/**
|
|
54
|
-
* Page-specific hooks (optional, default [])
|
|
56
|
+
* Page-specific hooks (optional, default []).
|
|
57
|
+
* Default is `[]`
|
|
55
58
|
*/
|
|
56
59
|
hooks?: PageHook[] | undefined;
|
|
57
60
|
/**
|
|
58
|
-
* Fields to be managed on this page
|
|
61
|
+
* Fields to be managed on this page
|
|
62
|
+
* (optional, default []). Default is `[]`
|
|
59
63
|
*/
|
|
60
64
|
fields?: import("./lib/field.js").PageField[] | undefined;
|
|
61
65
|
};
|
|
@@ -65,7 +69,8 @@ export type I18nOptions = {
|
|
|
65
69
|
*/
|
|
66
70
|
dirs: string[];
|
|
67
71
|
/**
|
|
68
|
-
* Supported locales
|
|
72
|
+
* Supported locales. Default is
|
|
73
|
+
* `['en', 'cy']`
|
|
69
74
|
*/
|
|
70
75
|
locales?: string[] | undefined;
|
|
71
76
|
};
|
|
@@ -78,11 +83,13 @@ export type GlobalHook = {
|
|
|
78
83
|
*/
|
|
79
84
|
hook: string;
|
|
80
85
|
/**
|
|
81
|
-
* Middleware function to insert at the hook
|
|
86
|
+
* Middleware function to insert at the hook
|
|
87
|
+
* point
|
|
82
88
|
*/
|
|
83
89
|
middleware: Function;
|
|
84
90
|
/**
|
|
85
|
-
* Only run if route path matches
|
|
91
|
+
* Only run if route path matches
|
|
92
|
+
* this string/regexp. Default is `undefined`
|
|
86
93
|
*/
|
|
87
94
|
path?: string | RegExp | undefined;
|
|
88
95
|
};
|
|
@@ -95,29 +102,32 @@ export type PageHook = {
|
|
|
95
102
|
*/
|
|
96
103
|
hook: string;
|
|
97
104
|
/**
|
|
98
|
-
* Middleware function to insert at the hook
|
|
105
|
+
* Middleware function to insert at the hook
|
|
106
|
+
* point
|
|
99
107
|
*/
|
|
100
108
|
middleware: Function;
|
|
101
109
|
};
|
|
102
110
|
export type SessionOptions = {
|
|
103
111
|
/**
|
|
104
|
-
* Session name
|
|
112
|
+
* Session name. Default is `casasession`
|
|
105
113
|
*/
|
|
106
114
|
name?: string | undefined;
|
|
107
115
|
/**
|
|
108
|
-
* Encryption secret
|
|
116
|
+
* Encryption secret. Default is `secret`
|
|
109
117
|
*/
|
|
110
118
|
secret?: string | undefined;
|
|
111
119
|
/**
|
|
112
|
-
* Session ttl (seconds)
|
|
120
|
+
* Session ttl (seconds). Default is `3600`
|
|
113
121
|
*/
|
|
114
122
|
ttl?: number | undefined;
|
|
115
123
|
/**
|
|
116
|
-
* Whether to use secure session cookies
|
|
124
|
+
* Whether to use secure session cookies.
|
|
125
|
+
* Default is `false`
|
|
117
126
|
*/
|
|
118
127
|
secure?: boolean | undefined;
|
|
119
128
|
/**
|
|
120
|
-
* SameSite (true = Strict)
|
|
129
|
+
* SameSite (true = Strict).
|
|
130
|
+
* Default is `true`
|
|
121
131
|
*/
|
|
122
132
|
cookieSameSite?: string | boolean | undefined;
|
|
123
133
|
/**
|
|
@@ -125,8 +135,8 @@ export type SessionOptions = {
|
|
|
125
135
|
*/
|
|
126
136
|
store?: object | undefined;
|
|
127
137
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
138
|
+
* The URL path on which the session cookie is
|
|
139
|
+
* valid (defaults to '/')
|
|
130
140
|
*/
|
|
131
141
|
cookiePath?: string | undefined;
|
|
132
142
|
};
|
|
@@ -139,7 +149,8 @@ export type IPlugin = {
|
|
|
139
149
|
*/
|
|
140
150
|
configure?: PluginConfigureFunction | undefined;
|
|
141
151
|
/**
|
|
142
|
-
* Modify post-configuration
|
|
152
|
+
* Modify post-configuration
|
|
153
|
+
* artifacts
|
|
143
154
|
*/
|
|
144
155
|
bootstrap?: PluginBootstrapFunction | undefined;
|
|
145
156
|
};
|
|
@@ -149,15 +160,15 @@ export type HelmetConfigurator = (config: object) => object;
|
|
|
149
160
|
/**
|
|
150
161
|
* Mounting function.
|
|
151
162
|
*
|
|
152
|
-
* This will mount all of the routes and middleware in the correct order on
|
|
153
|
-
*
|
|
163
|
+
* This will mount all of the routes and middleware in the correct order on the
|
|
164
|
+
* given ExpressJS app.
|
|
154
165
|
*
|
|
155
166
|
* Once this is called, you will not be able to modify any of the routers as
|
|
156
167
|
* they will be "sealed".
|
|
157
168
|
*/
|
|
158
|
-
export type Mounter = (app: import(
|
|
169
|
+
export type Mounter = (app: import("express").Express, opts: {
|
|
159
170
|
route?: string | undefined;
|
|
160
|
-
}) => import(
|
|
171
|
+
}) => import("express").Express;
|
|
161
172
|
/**
|
|
162
173
|
* Configuration options
|
|
163
174
|
*/
|
|
@@ -167,7 +178,7 @@ export type ConfigurationOptions = {
|
|
|
167
178
|
*/
|
|
168
179
|
mountUrl?: string | undefined;
|
|
169
180
|
/**
|
|
170
|
-
* Template directories
|
|
181
|
+
* Template directories. Default is `[]`
|
|
171
182
|
*/
|
|
172
183
|
views?: string[] | undefined;
|
|
173
184
|
/**
|
|
@@ -175,15 +186,15 @@ export type ConfigurationOptions = {
|
|
|
175
186
|
*/
|
|
176
187
|
session?: SessionOptions | undefined;
|
|
177
188
|
/**
|
|
178
|
-
* Pages the represent waypoints
|
|
189
|
+
* Pages the represent waypoints. Default is `[]`
|
|
179
190
|
*/
|
|
180
191
|
pages?: Page[] | undefined;
|
|
181
192
|
/**
|
|
182
|
-
* Hooks to apply
|
|
193
|
+
* Hooks to apply. Default is `[]`
|
|
183
194
|
*/
|
|
184
195
|
hooks?: GlobalHook[] | undefined;
|
|
185
196
|
/**
|
|
186
|
-
* Plugins
|
|
197
|
+
* Plugins. Default is `[]`
|
|
187
198
|
*/
|
|
188
199
|
plugins?: IPlugin[] | undefined;
|
|
189
200
|
/**
|
|
@@ -195,27 +206,33 @@ export type ConfigurationOptions = {
|
|
|
195
206
|
*/
|
|
196
207
|
plan?: Plan | undefined;
|
|
197
208
|
/**
|
|
198
|
-
* Handlers for JourneyContext events
|
|
209
|
+
* Handlers for JourneyContext events.
|
|
210
|
+
* Default is `[]`
|
|
199
211
|
*/
|
|
200
212
|
events?: ContextEvent[] | undefined;
|
|
201
213
|
/**
|
|
202
|
-
* Helmet configuration
|
|
214
|
+
* Helmet configuration
|
|
215
|
+
* manipulator function
|
|
203
216
|
*/
|
|
204
217
|
helmetConfigurator?: HelmetConfigurator | undefined;
|
|
205
218
|
/**
|
|
206
|
-
* Max number of form parameters to
|
|
219
|
+
* Max number of form parameters to
|
|
220
|
+
* ingest. Default is `25`
|
|
207
221
|
*/
|
|
208
222
|
formMaxParams?: number | undefined;
|
|
209
223
|
/**
|
|
210
|
-
* Max total form payload size
|
|
224
|
+
* Max total form payload size
|
|
225
|
+
* to ingest. Default is `"50KB"`
|
|
211
226
|
*/
|
|
212
227
|
formMaxBytes?: string | number | undefined;
|
|
213
228
|
/**
|
|
214
|
-
* Custom context ID
|
|
229
|
+
* Custom context ID
|
|
230
|
+
* generator
|
|
215
231
|
*/
|
|
216
232
|
contextIdGenerator?: ContextIdGenerator | undefined;
|
|
217
233
|
/**
|
|
218
|
-
*
|
|
234
|
+
* Option to keep page errors
|
|
235
|
+
* active on GET request
|
|
219
236
|
*/
|
|
220
237
|
errorVisibility?: symbol | Function | undefined;
|
|
221
238
|
};
|
|
@@ -226,7 +243,7 @@ export type ConfigureResult = {
|
|
|
226
243
|
/**
|
|
227
244
|
* Nunjucks environment
|
|
228
245
|
*/
|
|
229
|
-
nunjucksEnv: import(
|
|
246
|
+
nunjucksEnv: import("nunjucks").Environment;
|
|
230
247
|
/**
|
|
231
248
|
* Router handling all static assets
|
|
232
249
|
*/
|
|
@@ -240,71 +257,71 @@ export type ConfigureResult = {
|
|
|
240
257
|
*/
|
|
241
258
|
journeyRouter: MutableRouter;
|
|
242
259
|
/**
|
|
243
|
-
* Middleware
|
|
260
|
+
* Middleware
|
|
261
|
+
* mounted before everything
|
|
244
262
|
*/
|
|
245
|
-
preMiddleware: import(
|
|
263
|
+
preMiddleware: import("express").RequestHandler[];
|
|
246
264
|
/**
|
|
247
|
-
* Middleware
|
|
265
|
+
* Middleware
|
|
266
|
+
* mounted after everything
|
|
248
267
|
*/
|
|
249
|
-
postMiddleware: import(
|
|
268
|
+
postMiddleware: import("express").RequestHandler[];
|
|
250
269
|
/**
|
|
251
|
-
* CSRF get/set
|
|
270
|
+
* CSRF get/set
|
|
271
|
+
* form middleware
|
|
252
272
|
*/
|
|
253
|
-
csrfMiddleware: import(
|
|
273
|
+
csrfMiddleware: import("express").RequestHandler[];
|
|
254
274
|
/**
|
|
255
|
-
* Session
|
|
275
|
+
* Session
|
|
276
|
+
* middleware
|
|
256
277
|
*/
|
|
257
|
-
sessionMiddleware: import(
|
|
278
|
+
sessionMiddleware: import("express").RequestHandler;
|
|
258
279
|
/**
|
|
259
|
-
*
|
|
280
|
+
* Cookie-parsing middleware
|
|
260
281
|
*/
|
|
261
|
-
cookieParserMiddleware: import(
|
|
282
|
+
cookieParserMiddleware: import("express").RequestHandler[];
|
|
262
283
|
/**
|
|
263
|
-
* I18n
|
|
284
|
+
* I18n
|
|
285
|
+
* preparation middleware
|
|
264
286
|
*/
|
|
265
|
-
i18nMiddleware: import(
|
|
287
|
+
i18nMiddleware: import("express").RequestHandler[];
|
|
266
288
|
/**
|
|
267
|
-
* Body
|
|
289
|
+
* Body
|
|
290
|
+
* parsing middleware
|
|
268
291
|
*/
|
|
269
|
-
bodyParserMiddleware: import(
|
|
292
|
+
bodyParserMiddleware: import("express").RequestHandler;
|
|
270
293
|
/**
|
|
271
|
-
* Function used to mount all CASA artifacts onto an
|
|
294
|
+
* Function used to mount all CASA artifacts onto an
|
|
295
|
+
* ExpressJS app
|
|
272
296
|
*/
|
|
273
297
|
mount: Mounter;
|
|
274
298
|
/**
|
|
275
|
-
* Ingested config supplied to
|
|
299
|
+
* Ingested config supplied to
|
|
300
|
+
* `configure()`
|
|
276
301
|
*/
|
|
277
302
|
config: ConfigurationOptions;
|
|
278
303
|
};
|
|
279
304
|
/**
|
|
280
|
-
* Configuration for generating a ValidationError.
|
|
281
|
-
*
|
|
282
|
-
* <br/><br/>
|
|
305
|
+
* Configuration for generating a ValidationError. i.e. `new
|
|
306
|
+
* ValidationError(configObject)` <br/><br/>
|
|
283
307
|
*
|
|
284
|
-
* The `fieldKeySuffix` is used to differentiate errors attached to
|
|
285
|
-
*
|
|
308
|
+
* The `fieldKeySuffix` is used to differentiate errors attached to the same
|
|
309
|
+
* field name. For example, given these fields inputs ...<pre> <input
|
|
310
|
+
* name="dateOfBirth[dd]" /> <input name="dateOfBirth[mm]" /> <input
|
|
311
|
+
* name="dateOfBirth[yyyy]" /> </pre>
|
|
286
312
|
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* <input name="dateOfBirth[mm]" />
|
|
290
|
-
* <input name="dateOfBirth[yyyy]" />
|
|
291
|
-
* </pre>
|
|
313
|
+
* If we wanted to generate an error specifically for the `dd` element, then
|
|
314
|
+
* we'd include `{ fieldKeySuffix: '[dd]' }` in this config. <br/><br/>
|
|
292
315
|
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
316
|
+
* We can also use `focusSuffix` to control which properties of an object field
|
|
317
|
+
* should be highlighted with a red border when in error. Looking again at the
|
|
318
|
+
* `dateOfBirth` example above, if we did not specify any `focusSuffix`, then
|
|
319
|
+
* all three inputs would be highlighted. However, if we use `{ focusSuffix:
|
|
320
|
+
* ['[dd]', '[yyyy]'] }` then only the `[dd]` and `[yyyy]` inputs would be
|
|
321
|
+
* highlighted. <br/><br/>
|
|
297
322
|
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* again at the `dateOfBirth` example above, if we did not specify
|
|
301
|
-
* any `focusSuffix`, then all three inputs would be highlighted.
|
|
302
|
-
* However, if we use `{ focusSuffix: ['[dd]', '[yyyy]'] }` then only
|
|
303
|
-
* the `[dd]` and `[yyyy]` inputs would be highlighted.
|
|
304
|
-
* <br/><br/>
|
|
305
|
-
*
|
|
306
|
-
* The `fieldHref` and `field` properties are strictly for
|
|
307
|
-
* internal use only and public access may be removed at any point.
|
|
323
|
+
* The `fieldHref` and `field` properties are strictly for internal use only and
|
|
324
|
+
* public access may be removed at any point.
|
|
308
325
|
*/
|
|
309
326
|
export type ErrorMessageConfigObject = {
|
|
310
327
|
/**
|
|
@@ -312,15 +329,18 @@ export type ErrorMessageConfigObject = {
|
|
|
312
329
|
*/
|
|
313
330
|
summary: string;
|
|
314
331
|
/**
|
|
315
|
-
* Inline message (@deprecated now uses summary
|
|
332
|
+
* Inline message (@deprecated now uses summary
|
|
333
|
+
* everywhere)
|
|
316
334
|
*/
|
|
317
335
|
inline?: string | undefined;
|
|
318
336
|
/**
|
|
319
|
-
* String(s) to append to URL hash
|
|
337
|
+
* String(s) to append to URL hash
|
|
338
|
+
* for focusing inputs
|
|
320
339
|
*/
|
|
321
340
|
focusSuffix?: string | string[] | undefined;
|
|
322
341
|
/**
|
|
323
|
-
* Object fields may use this to show errors
|
|
342
|
+
* Object fields may use this to show errors
|
|
343
|
+
* per sub-property
|
|
324
344
|
*/
|
|
325
345
|
fieldKeySuffix?: string | undefined;
|
|
326
346
|
/**
|
|
@@ -332,7 +352,8 @@ export type ErrorMessageConfigObject = {
|
|
|
332
352
|
*/
|
|
333
353
|
validator?: string | undefined;
|
|
334
354
|
/**
|
|
335
|
-
* (internal) URL hash to link to field in UI,
|
|
355
|
+
* (internal) URL hash to link to field in UI,
|
|
356
|
+
* i.e `#f-..`
|
|
336
357
|
*/
|
|
337
358
|
fieldHref?: string | undefined;
|
|
338
359
|
/**
|
|
@@ -380,7 +401,8 @@ export type Validator = {
|
|
|
380
401
|
*/
|
|
381
402
|
validate: ValidateFunction;
|
|
382
403
|
/**
|
|
383
|
-
* Sanitise a given value prior to
|
|
404
|
+
* Sanitise a given value prior to
|
|
405
|
+
* validation
|
|
384
406
|
*/
|
|
385
407
|
sanitise: FieldProcessorFunction;
|
|
386
408
|
/**
|
|
@@ -405,10 +427,6 @@ export type ValidatorConditionFunctionParams = {
|
|
|
405
427
|
* Waypoint
|
|
406
428
|
*/
|
|
407
429
|
waypoint: string;
|
|
408
|
-
/**
|
|
409
|
-
* [DEPRECATED] Waypoint (for backwards compatibility with v7)
|
|
410
|
-
*/
|
|
411
|
-
waypointId: string;
|
|
412
430
|
/**
|
|
413
431
|
* Journey Context
|
|
414
432
|
*/
|
|
@@ -439,7 +457,8 @@ export type PlanRoute = {
|
|
|
439
457
|
export type PlanRouteCondition = (route: PlanRoute, context: JourneyContext) => boolean;
|
|
440
458
|
export type PlanTraverseOptions = {
|
|
441
459
|
/**
|
|
442
|
-
* Waypoint from which to start (defaults to
|
|
460
|
+
* Waypoint from which to start (defaults to
|
|
461
|
+
* first in list)
|
|
443
462
|
*/
|
|
444
463
|
startWaypoint?: string | undefined;
|
|
445
464
|
/**
|
|
@@ -451,11 +470,13 @@ export type PlanTraverseOptions = {
|
|
|
451
470
|
*/
|
|
452
471
|
history: Map<any, any>;
|
|
453
472
|
/**
|
|
454
|
-
* If true, traversal will be stopped
|
|
473
|
+
* If true, traversal will be stopped
|
|
474
|
+
* (useful for performance)
|
|
455
475
|
*/
|
|
456
476
|
stopCondition?: Function | undefined;
|
|
457
477
|
/**
|
|
458
|
-
* Multiple target routes found, this
|
|
478
|
+
* Multiple target routes found, this
|
|
479
|
+
* decides which to use
|
|
459
480
|
*/
|
|
460
481
|
arbiter?: string | PlanArbiter | undefined;
|
|
461
482
|
};
|
|
@@ -469,7 +490,8 @@ export type PlanArbiterParams = {
|
|
|
469
490
|
*/
|
|
470
491
|
journeyContext: JourneyContext;
|
|
471
492
|
/**
|
|
472
|
-
* Original traverse options
|
|
493
|
+
* Original traverse options
|
|
494
|
+
* passed to `traverse()`
|
|
473
495
|
*/
|
|
474
496
|
traverseOptions: PlanTraverseOptions;
|
|
475
497
|
};
|
|
@@ -500,7 +522,7 @@ export type ContextIdGeneratorParams = {
|
|
|
500
522
|
* Arguments
|
|
501
523
|
*/
|
|
502
524
|
args: {
|
|
503
|
-
req: import(
|
|
525
|
+
req: import("express").Request;
|
|
504
526
|
reservedIds: [string];
|
|
505
527
|
};
|
|
506
528
|
};
|
|
@@ -509,22 +531,23 @@ export type ContextIdGeneratorParams = {
|
|
|
509
531
|
* any other context IDs in the given session.
|
|
510
532
|
*
|
|
511
533
|
* The resulting ID must match these criteria:
|
|
534
|
+
*
|
|
512
535
|
* - A string
|
|
513
536
|
* - Between 1 and 64 characters
|
|
514
537
|
* - Contain only the characters a-z, 0-9, -
|
|
515
538
|
*/
|
|
516
539
|
export type ContextIdGenerator = (params: ContextIdGeneratorParams) => string;
|
|
517
|
-
import configure from
|
|
518
|
-
import validators from
|
|
519
|
-
import field from
|
|
520
|
-
import Plan from
|
|
521
|
-
import JourneyContext from
|
|
522
|
-
import ValidatorFactory from
|
|
523
|
-
import ValidationError from
|
|
524
|
-
import MutableRouter from
|
|
525
|
-
import waypointUrl from
|
|
526
|
-
import endSession from
|
|
527
|
-
import * as nunjucksFilters from
|
|
528
|
-
import * as constants from
|
|
529
|
-
import * as contextIdGenerators from
|
|
540
|
+
import configure from "./lib/configure.js";
|
|
541
|
+
import validators from "./lib/validators/index.js";
|
|
542
|
+
import field from "./lib/field.js";
|
|
543
|
+
import Plan from "./lib/Plan.js";
|
|
544
|
+
import JourneyContext from "./lib/JourneyContext.js";
|
|
545
|
+
import ValidatorFactory from "./lib/ValidatorFactory.js";
|
|
546
|
+
import ValidationError from "./lib/ValidationError.js";
|
|
547
|
+
import MutableRouter from "./lib/MutableRouter.js";
|
|
548
|
+
import waypointUrl from "./lib/waypoint-url.js";
|
|
549
|
+
import endSession from "./lib/end-session.js";
|
|
550
|
+
import * as nunjucksFilters from "./lib/nunjucks-filters.js";
|
|
551
|
+
import * as constants from "./lib/constants.js";
|
|
552
|
+
import * as contextIdGenerators from "./lib/context-id-generators.js";
|
|
530
553
|
export { configure, validators, field, Plan, JourneyContext, ValidatorFactory, ValidationError, MutableRouter, waypointUrl, endSession, nunjucksFilters, constants, contextIdGenerators };
|