@dwp/govuk-casa 8.5.2 → 8.7.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/casa.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  export type PageField = import('./lib/field').PageField;
2
- export type ContextEventHandler = (opts: object, journeyContext: JourneyContext, previousContext: JourneyContext, session: object) => void;
2
+ export type ContextEventHandlerOptions = {
3
+ /**
4
+ * Context including changes
5
+ */
6
+ journeyContext: JourneyContext;
7
+ /**
8
+ * Context prior to changes
9
+ */
10
+ previousContext: JourneyContext;
11
+ /**
12
+ * Request session object
13
+ */
14
+ session: object;
15
+ };
16
+ export type ContextEventHandler = (opts: ContextEventHandlerOptions) => void;
3
17
  export type ContextEvent = {
4
18
  /**
5
19
  * Waypoint to watch for changes
@@ -100,6 +114,11 @@ export type SessionOptions = {
100
114
  * Session store (default MemoryStore)
101
115
  */
102
116
  store?: object | undefined;
117
+ /**
118
+ * the URL path on which the session cookie
119
+ * is valid (defaults to '/')
120
+ */
121
+ cookiePath?: string | undefined;
103
122
  };
104
123
  /**
105
124
  * Plugin interface
@@ -127,7 +146,6 @@ export type HelmetConfigurator = (config: object) => object;
127
146
  * they will be "sealed".
128
147
  */
129
148
  export type Mounter = (app: import('express').Express, opts: object, route?: string | undefined) => import('express').Express;
130
- export type MutableRouter = import('./lib/index').MutableRouter;
131
149
  /**
132
150
  * Configuration options
133
151
  */
@@ -159,7 +177,7 @@ export type ConfigurationOptions = {
159
177
  /**
160
178
  * I18n configuration
161
179
  */
162
- i18n?: I18nOptions[] | undefined;
180
+ i18n?: I18nOptions | undefined;
163
181
  /**
164
182
  * CASA Plan
165
183
  */
@@ -435,7 +453,8 @@ import Plan from "./lib/Plan.js";
435
453
  import JourneyContext from "./lib/JourneyContext.js";
436
454
  import ValidatorFactory from "./lib/ValidatorFactory.js";
437
455
  import ValidationError from "./lib/ValidationError.js";
456
+ import MutableRouter from "./lib/MutableRouter.js";
438
457
  import waypointUrl from "./lib/waypoint-url.js";
439
458
  import endSession from "./lib/end-session.js";
440
459
  import * as nunjucksFilters from "./lib/nunjucks-filters.js";
441
- export { configure, validators, field, Plan, JourneyContext, ValidatorFactory, ValidationError, waypointUrl, endSession, nunjucksFilters };
460
+ export { configure, validators, field, Plan, JourneyContext, ValidatorFactory, ValidationError, MutableRouter, waypointUrl, endSession, nunjucksFilters };
package/dist/casa.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.nunjucksFilters = exports.endSession = exports.waypointUrl = exports.ValidationError = exports.ValidatorFactory = exports.JourneyContext = exports.Plan = exports.field = exports.validators = exports.configure = void 0;
29
+ exports.nunjucksFilters = exports.endSession = exports.waypointUrl = exports.MutableRouter = exports.ValidationError = exports.ValidatorFactory = exports.JourneyContext = exports.Plan = exports.field = exports.validators = exports.configure = void 0;
30
30
  // NOTE: Any changes made here must be reflected in `scripts/esm-wrapper.js`
31
31
  const configure_js_1 = __importDefault(require("./lib/configure.js"));
32
32
  exports.configure = configure_js_1.default;
@@ -42,6 +42,8 @@ const ValidatorFactory_js_1 = __importDefault(require("./lib/ValidatorFactory.js
42
42
  exports.ValidatorFactory = ValidatorFactory_js_1.default;
43
43
  const ValidationError_js_1 = __importDefault(require("./lib/ValidationError.js"));
44
44
  exports.ValidationError = ValidationError_js_1.default;
45
+ const MutableRouter_js_1 = __importDefault(require("./lib/MutableRouter.js"));
46
+ exports.MutableRouter = MutableRouter_js_1.default;
45
47
  const waypoint_url_js_1 = __importDefault(require("./lib/waypoint-url.js"));
46
48
  exports.waypointUrl = waypoint_url_js_1.default;
47
49
  const end_session_js_1 = __importDefault(require("./lib/end-session.js"));
@@ -53,12 +55,15 @@ exports.nunjucksFilters = nunjucksFilters;
53
55
  /**
54
56
  * @typedef {import('./lib/field').PageField} PageField
55
57
  */
58
+ /**
59
+ * @typedef {object} ContextEventHandlerOptions
60
+ * @property {JourneyContext} journeyContext Context including changes
61
+ * @property {JourneyContext} previousContext Context prior to changes
62
+ * @property {object} session Request session object
63
+ */
56
64
  /**
57
65
  * @callback ContextEventHandler
58
- * @param {object} opts Options
59
- * @param {JourneyContext} opts.journeyContext Context including changes
60
- * @param {JourneyContext} opts.previousContext Context prior to changes
61
- * @param {object} opts.session Request session object
66
+ * @param {ContextEventHandlerOptions} opts Options
62
67
  * @returns {void}
63
68
  */
64
69
  /**
@@ -98,6 +103,8 @@ exports.nunjucksFilters = nunjucksFilters;
98
103
  * @property {boolean} [secure=false] Whether to use secure session cookies
99
104
  * @property {boolean|string} [cookieSameSite=true] SameSite (true = Strict)
100
105
  * @property {object} [store] Session store (default MemoryStore)
106
+ * @property {string} [cookiePath] the URL path on which the session cookie
107
+ * is valid (defaults to '/')
101
108
  */
102
109
  /**
103
110
  * @typedef {object} IPlugin Plugin interface
@@ -132,9 +139,6 @@ exports.nunjucksFilters = nunjucksFilters;
132
139
  * @param {string} [opts.route='/'] Optional route to attach all middleware/routers too
133
140
  * @returns {import('express').Express} The prepared ExpressJS app instance
134
141
  */
135
- /**
136
- * @typedef {import('./lib/index').MutableRouter} MutableRouter
137
- */
138
142
  /**
139
143
  * Configure some middleware for use in creating a new CASA app.
140
144
  *
@@ -145,7 +149,7 @@ exports.nunjucksFilters = nunjucksFilters;
145
149
  * @property {Page[]} [pages=[]] Pages the represent waypoints
146
150
  * @property {GlobalHook[]} [hooks=[]] Hooks to apply
147
151
  * @property {IPlugin[]} [plugins=[]] Plugins
148
- * @property {I18nOptions[]} [i18n] I18n configuration
152
+ * @property {I18nOptions} [i18n] I18n configuration
149
153
  * @property {Plan} [plan] CASA Plan
150
154
  * @property {ContextEvent[]} [events=[]] Handlers for JourneyContext events
151
155
  * @property {HelmetConfigurator} [helmetConfigurator] Helmet configuration manipulator function
@@ -184,20 +184,20 @@ export default class JourneyContext {
184
184
  * `identity` holds information that helps uniquely identify this context
185
185
  * among a group of contexts stored in the session.
186
186
  *
187
- * @param {object} data Entire journey data.
187
+ * @param {Record<string,unknown>} data Entire journey data.
188
188
  * @param {object} validation Page errors (indexed by waypoint id).
189
189
  * @param {object} nav Navigation context.
190
190
  * @param {object} identity Some metadata for identifying this context among others.
191
191
  */
192
- constructor(data?: object, validation?: object, nav?: object, identity?: object);
192
+ constructor(data?: Record<string, unknown>, validation?: object, nav?: object, identity?: object);
193
193
  /**
194
194
  * Clone into an object that can be stringified.
195
195
  *
196
196
  * @returns {object} Plain object.
197
197
  */
198
198
  toObject(): object;
199
- set data(arg: object);
200
- get data(): object;
199
+ set data(arg: Record<string, unknown>);
200
+ get data(): Record<string, unknown>;
201
201
  get validation(): object;
202
202
  get nav(): object;
203
203
  get identity(): object;
@@ -88,7 +88,7 @@ class JourneyContext {
88
88
  * `identity` holds information that helps uniquely identify this context
89
89
  * among a group of contexts stored in the session.
90
90
  *
91
- * @param {object} data Entire journey data.
91
+ * @param {Record<string,unknown>} data Entire journey data.
92
92
  * @param {object} validation Page errors (indexed by waypoint id).
93
93
  * @param {object} nav Navigation context.
94
94
  * @param {object} identity Some metadata for identifying this context among others.
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @memberof module:@dwp/govuk-casa
3
+ */
1
4
  export default class MutableRouter {
2
5
  /**
3
6
  * Seals this router to make it immutable. Returns the ExpressJS router.
@@ -8,147 +11,147 @@ export default class MutableRouter {
8
11
  /**
9
12
  * Prepend middleware function(s) using the `all()` method.
10
13
  *
11
- * @param {string} path route path
12
- * @param {...Function} callbacks Middleware functions
14
+ * @param {string | Function} path route path or middleware function
15
+ * @param {...Function} callbacks Additional middleware functions
13
16
  * @returns {void}
14
17
  */
15
- prependAll(path: string, ...callbacks: Function[]): void;
18
+ prependAll(path: string | Function, ...callbacks: Function[]): void;
16
19
  /**
17
20
  * Prepend middleware function(s) using the `get()` method.
18
21
  *
19
- * @param {string} path route path
20
- * @param {...Function} callbacks Middleware functions
22
+ * @param {string | Function} path route path or middleware function
23
+ * @param {...Function} callbacks Additional middleware functions
21
24
  * @returns {void}
22
25
  */
23
- prependGet(path: string, ...callbacks: Function[]): void;
26
+ prependGet(path: string | Function, ...callbacks: Function[]): void;
24
27
  /**
25
28
  * Prepend middleware function(s) using the `post()` method.
26
29
  *
27
- * @param {string} path route path
28
- * @param {...Function} callbacks Middleware functions
30
+ * @param {string | Function} path route path or middleware function
31
+ * @param {...Function} callbacks Additional middleware functions
29
32
  * @returns {void}
30
33
  */
31
- prependPost(path: string, ...callbacks: Function[]): void;
34
+ prependPost(path: string | Function, ...callbacks: Function[]): void;
32
35
  /**
33
36
  * Prepend middleware function(s) using the `delete()` method.
34
37
  *
35
- * @param {string} path route path
36
- * @param {...Function} callbacks Middleware functions
38
+ * @param {string | Function} path route path or middleware function
39
+ * @param {...Function} callbacks Additional middleware functions
37
40
  * @returns {void}
38
41
  */
39
- prependDelete(path: string, ...callbacks: Function[]): void;
42
+ prependDelete(path: string | Function, ...callbacks: Function[]): void;
40
43
  /**
41
44
  * Prepend middleware function(s) using the `put()` method.
42
45
  *
43
- * @param {string} path route path
44
- * @param {...Function} callbacks Middleware functions
46
+ * @param {string | Function} path route path or middleware function
47
+ * @param {...Function} callbacks Additional middleware functions
45
48
  * @returns {void}
46
49
  */
47
- prependPut(path: string, ...callbacks: Function[]): void;
50
+ prependPut(path: string | Function, ...callbacks: Function[]): void;
48
51
  /**
49
52
  * Prepend middleware function(s) using the `use()` method.
50
53
  *
51
- * @param {string} path route path
52
- * @param {...Function} callbacks Middleware functions
54
+ * @param {string | Function} path route path or middleware function
55
+ * @param {...Function} callbacks Additional middleware functions
53
56
  * @returns {void}
54
57
  */
55
- prependUse(path: string, ...callbacks: Function[]): void;
58
+ prependUse(path: string | Function, ...callbacks: Function[]): void;
56
59
  /**
57
60
  * Replace middleware function(s) that were mounted using the `all()` method.
58
61
  *
59
- * @param {string} path route path
60
- * @param {...Function} callbacks Middleware functions
62
+ * @param {string | Function} path route path or middleware function
63
+ * @param {...Function} callbacks Additional middleware functions
61
64
  * @returns {void}
62
65
  */
63
- replaceAll(path: string, ...callbacks: Function[]): void;
66
+ replaceAll(path: string | Function, ...callbacks: Function[]): void;
64
67
  /**
65
68
  * Replace middleware function(s) that were mounted using the `get()` method.
66
69
  *
67
- * @param {string} path route path
68
- * @param {...Function} callbacks Middleware functions
70
+ * @param {string | Function} path route path or middleware function
71
+ * @param {...Function} callbacks Additional middleware functions
69
72
  * @returns {void}
70
73
  */
71
- replaceGet(path: string, ...callbacks: Function[]): void;
74
+ replaceGet(path: string | Function, ...callbacks: Function[]): void;
72
75
  /**
73
76
  * Replace middleware function(s) that were mounted using the `post()` method.
74
77
  *
75
- * @param {string} path route path
76
- * @param {...Function} callbacks Middleware functions
78
+ * @param {string | Function} path route path or middleware function
79
+ * @param {...Function} callbacks Additional middleware functions
77
80
  * @returns {void}
78
81
  */
79
- replacePost(path: string, ...callbacks: Function[]): void;
82
+ replacePost(path: string | Function, ...callbacks: Function[]): void;
80
83
  /**
81
84
  * Replace middleware function(s) that were mounted using the `delete()` method.
82
85
  *
83
- * @param {string} path route path
84
- * @param {...Function} callbacks Middleware functions
86
+ * @param {string | Function} path route path or middleware function
87
+ * @param {...Function} callbacks Additional middleware functions
85
88
  * @returns {void}
86
89
  */
87
- replaceDelete(path: string, ...callbacks: Function[]): void;
90
+ replaceDelete(path: string | Function, ...callbacks: Function[]): void;
88
91
  /**
89
92
  * Replace middleware function(s) that were mounted using the `put()` method.
90
93
  *
91
- * @param {string} path route path
92
- * @param {...Function} callbacks Middleware functions
94
+ * @param {string | Function} path route path or middleware function
95
+ * @param {...Function} callbacks Additional middleware functions
93
96
  * @returns {void}
94
97
  */
95
- replacePut(path: string, ...callbacks: Function[]): void;
98
+ replacePut(path: string | Function, ...callbacks: Function[]): void;
96
99
  /**
97
100
  * Replace middleware function(s) that were mounted using the `use()` method.
98
101
  *
99
- * @param {string} path route path
100
- * @param {...Function} callbacks Middleware functions
102
+ * @param {string | Function} path route path or middleware function
103
+ * @param {...Function} callbacks Additional middleware functions
101
104
  * @returns {void}
102
105
  */
103
- replaceUse(path: string, ...callbacks: Function[]): void;
106
+ replaceUse(path: string | Function, ...callbacks: Function[]): void;
104
107
  /**
105
108
  * Append middleware function(s) using the `all()` method.
106
109
  *
107
- * @param {string} path route path
108
- * @param {...Function} callbacks Middleware functions
110
+ * @param {string | Function} path route path or middleware function
111
+ * @param {...Function} callbacks Additional middleware functions
109
112
  * @returns {void}
110
113
  */
111
- all(path: string, ...callbacks: Function[]): void;
114
+ all(path: string | Function, ...callbacks: Function[]): void;
112
115
  /**
113
116
  * Append middleware function(s) using the `get()` method.
114
117
  *
115
- * @param {string} path route path
116
- * @param {...Function} callbacks Middleware functions
118
+ * @param {string | Function} path route path or middleware function
119
+ * @param {...Function} callbacks Additional middleware functions
117
120
  * @returns {void}
118
121
  */
119
- get(path: string, ...callbacks: Function[]): void;
122
+ get(path: string | Function, ...callbacks: Function[]): void;
120
123
  /**
121
124
  * Append middleware function(s) using the `post()` method.
122
125
  *
123
- * @param {string} path route path
124
- * @param {...Function} callbacks Middleware functions
126
+ * @param {string | Function} path route path or middleware function
127
+ * @param {...Function} callbacks Additional middleware functions
125
128
  * @returns {void}
126
129
  */
127
- post(path: string, ...callbacks: Function[]): void;
130
+ post(path: string | Function, ...callbacks: Function[]): void;
128
131
  /**
129
132
  * Append middleware function(s) using the `delete()` method.
130
133
  *
131
- * @param {string} path route path
132
- * @param {...Function} callbacks Middleware functions
134
+ * @param {string | Function} path route path or middleware function
135
+ * @param {...Function} callbacks Additional middleware functions
133
136
  * @returns {void}
134
137
  */
135
- delete(path: string, ...callbacks: Function[]): void;
138
+ delete(path: string | Function, ...callbacks: Function[]): void;
136
139
  /**
137
140
  * Append middleware function(s) using the `put()` method.
138
141
  *
139
- * @param {string} path route path
140
- * @param {...Function} callbacks Middleware functions
142
+ * @param {string | Function} path route path or middleware function
143
+ * @param {...Function} callbacks Additional middleware functions
141
144
  * @returns {void}
142
145
  */
143
- put(path: string, ...callbacks: Function[]): void;
146
+ put(path: string | Function, ...callbacks: Function[]): void;
144
147
  /**
145
148
  * Append middleware function(s) using the `use()` method.
146
149
  *
147
- * @param {string} path route path
148
- * @param {...Function} callbacks Middleware functions
150
+ * @param {string | Function} path route path or middleware function
151
+ * @param {...Function} callbacks Additional middleware functions
149
152
  * @returns {void}
150
153
  */
151
- use(path: string, ...callbacks: Function[]): void;
154
+ use(path: string | Function, ...callbacks: Function[]): void;
152
155
  route(): void;
153
156
  #private;
154
157
  }
@@ -14,9 +14,14 @@ var _MutableRouter_instances, _MutableRouter_stack, _MutableRouter_router, _Muta
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  /* eslint-disable sonarjs/no-duplicate-string,class-methods-use-this */
16
16
  const express_1 = require("express");
17
+ /**
18
+ * @memberof module:@dwp/govuk-casa
19
+ */
17
20
  class MutableRouter {
18
21
  /**
19
- * Mutable router.
22
+ * A wrapping class to make Express routers mutable. You can append, prepend
23
+ * and remove routes from a MutableRouter before finally "sealing" it and
24
+ * mounting it on your Express app.
20
25
  *
21
26
  * @class
22
27
  */
@@ -34,7 +39,7 @@ class MutableRouter {
34
39
  * @type {boolean}
35
40
  */
36
41
  _MutableRouter_sealed.set(this, void 0);
37
- __classPrivateFieldSet(this, _MutableRouter_router, new express_1.Router(), "f");
42
+ __classPrivateFieldSet(this, _MutableRouter_router, (0, express_1.Router)(), "f");
38
43
  __classPrivateFieldSet(this, _MutableRouter_stack, [], "f");
39
44
  __classPrivateFieldSet(this, _MutableRouter_sealed, false, "f");
40
45
  }
@@ -60,8 +65,8 @@ class MutableRouter {
60
65
  /**
61
66
  * Prepend middleware function(s) using the `all()` method.
62
67
  *
63
- * @param {string} path route path
64
- * @param {...Function} callbacks Middleware functions
68
+ * @param {string | Function} path route path or middleware function
69
+ * @param {...Function} callbacks Additional middleware functions
65
70
  * @returns {void}
66
71
  */
67
72
  prependAll(path, ...callbacks) {
@@ -70,8 +75,8 @@ class MutableRouter {
70
75
  /**
71
76
  * Prepend middleware function(s) using the `get()` method.
72
77
  *
73
- * @param {string} path route path
74
- * @param {...Function} callbacks Middleware functions
78
+ * @param {string | Function} path route path or middleware function
79
+ * @param {...Function} callbacks Additional middleware functions
75
80
  * @returns {void}
76
81
  */
77
82
  prependGet(path, ...callbacks) {
@@ -80,8 +85,8 @@ class MutableRouter {
80
85
  /**
81
86
  * Prepend middleware function(s) using the `post()` method.
82
87
  *
83
- * @param {string} path route path
84
- * @param {...Function} callbacks Middleware functions
88
+ * @param {string | Function} path route path or middleware function
89
+ * @param {...Function} callbacks Additional middleware functions
85
90
  * @returns {void}
86
91
  */
87
92
  prependPost(path, ...callbacks) {
@@ -90,8 +95,8 @@ class MutableRouter {
90
95
  /**
91
96
  * Prepend middleware function(s) using the `delete()` method.
92
97
  *
93
- * @param {string} path route path
94
- * @param {...Function} callbacks Middleware functions
98
+ * @param {string | Function} path route path or middleware function
99
+ * @param {...Function} callbacks Additional middleware functions
95
100
  * @returns {void}
96
101
  */
97
102
  prependDelete(path, ...callbacks) {
@@ -100,8 +105,8 @@ class MutableRouter {
100
105
  /**
101
106
  * Prepend middleware function(s) using the `put()` method.
102
107
  *
103
- * @param {string} path route path
104
- * @param {...Function} callbacks Middleware functions
108
+ * @param {string | Function} path route path or middleware function
109
+ * @param {...Function} callbacks Additional middleware functions
105
110
  * @returns {void}
106
111
  */
107
112
  prependPut(path, ...callbacks) {
@@ -110,8 +115,8 @@ class MutableRouter {
110
115
  /**
111
116
  * Prepend middleware function(s) using the `use()` method.
112
117
  *
113
- * @param {string} path route path
114
- * @param {...Function} callbacks Middleware functions
118
+ * @param {string | Function} path route path or middleware function
119
+ * @param {...Function} callbacks Additional middleware functions
115
120
  * @returns {void}
116
121
  */
117
122
  prependUse(path, ...callbacks) {
@@ -121,8 +126,8 @@ class MutableRouter {
121
126
  /**
122
127
  * Replace middleware function(s) that were mounted using the `all()` method.
123
128
  *
124
- * @param {string} path route path
125
- * @param {...Function} callbacks Middleware functions
129
+ * @param {string | Function} path route path or middleware function
130
+ * @param {...Function} callbacks Additional middleware functions
126
131
  * @returns {void}
127
132
  */
128
133
  replaceAll(path, ...callbacks) {
@@ -131,8 +136,8 @@ class MutableRouter {
131
136
  /**
132
137
  * Replace middleware function(s) that were mounted using the `get()` method.
133
138
  *
134
- * @param {string} path route path
135
- * @param {...Function} callbacks Middleware functions
139
+ * @param {string | Function} path route path or middleware function
140
+ * @param {...Function} callbacks Additional middleware functions
136
141
  * @returns {void}
137
142
  */
138
143
  replaceGet(path, ...callbacks) {
@@ -141,8 +146,8 @@ class MutableRouter {
141
146
  /**
142
147
  * Replace middleware function(s) that were mounted using the `post()` method.
143
148
  *
144
- * @param {string} path route path
145
- * @param {...Function} callbacks Middleware functions
149
+ * @param {string | Function} path route path or middleware function
150
+ * @param {...Function} callbacks Additional middleware functions
146
151
  * @returns {void}
147
152
  */
148
153
  replacePost(path, ...callbacks) {
@@ -151,8 +156,8 @@ class MutableRouter {
151
156
  /**
152
157
  * Replace middleware function(s) that were mounted using the `delete()` method.
153
158
  *
154
- * @param {string} path route path
155
- * @param {...Function} callbacks Middleware functions
159
+ * @param {string | Function} path route path or middleware function
160
+ * @param {...Function} callbacks Additional middleware functions
156
161
  * @returns {void}
157
162
  */
158
163
  replaceDelete(path, ...callbacks) {
@@ -161,8 +166,8 @@ class MutableRouter {
161
166
  /**
162
167
  * Replace middleware function(s) that were mounted using the `put()` method.
163
168
  *
164
- * @param {string} path route path
165
- * @param {...Function} callbacks Middleware functions
169
+ * @param {string | Function} path route path or middleware function
170
+ * @param {...Function} callbacks Additional middleware functions
166
171
  * @returns {void}
167
172
  */
168
173
  replacePut(path, ...callbacks) {
@@ -171,8 +176,8 @@ class MutableRouter {
171
176
  /**
172
177
  * Replace middleware function(s) that were mounted using the `use()` method.
173
178
  *
174
- * @param {string} path route path
175
- * @param {...Function} callbacks Middleware functions
179
+ * @param {string | Function} path route path or middleware function
180
+ * @param {...Function} callbacks Additional middleware functions
176
181
  * @returns {void}
177
182
  */
178
183
  replaceUse(path, ...callbacks) {
@@ -182,8 +187,8 @@ class MutableRouter {
182
187
  /**
183
188
  * Append middleware function(s) using the `all()` method.
184
189
  *
185
- * @param {string} path route path
186
- * @param {...Function} callbacks Middleware functions
190
+ * @param {string | Function} path route path or middleware function
191
+ * @param {...Function} callbacks Additional middleware functions
187
192
  * @returns {void}
188
193
  */
189
194
  all(path, ...callbacks) {
@@ -192,8 +197,8 @@ class MutableRouter {
192
197
  /**
193
198
  * Append middleware function(s) using the `get()` method.
194
199
  *
195
- * @param {string} path route path
196
- * @param {...Function} callbacks Middleware functions
200
+ * @param {string | Function} path route path or middleware function
201
+ * @param {...Function} callbacks Additional middleware functions
197
202
  * @returns {void}
198
203
  */
199
204
  get(path, ...callbacks) {
@@ -202,8 +207,8 @@ class MutableRouter {
202
207
  /**
203
208
  * Append middleware function(s) using the `post()` method.
204
209
  *
205
- * @param {string} path route path
206
- * @param {...Function} callbacks Middleware functions
210
+ * @param {string | Function} path route path or middleware function
211
+ * @param {...Function} callbacks Additional middleware functions
207
212
  * @returns {void}
208
213
  */
209
214
  post(path, ...callbacks) {
@@ -212,8 +217,8 @@ class MutableRouter {
212
217
  /**
213
218
  * Append middleware function(s) using the `delete()` method.
214
219
  *
215
- * @param {string} path route path
216
- * @param {...Function} callbacks Middleware functions
220
+ * @param {string | Function} path route path or middleware function
221
+ * @param {...Function} callbacks Additional middleware functions
217
222
  * @returns {void}
218
223
  */
219
224
  delete(path, ...callbacks) {
@@ -222,8 +227,8 @@ class MutableRouter {
222
227
  /**
223
228
  * Append middleware function(s) using the `put()` method.
224
229
  *
225
- * @param {string} path route path
226
- * @param {...Function} callbacks Middleware functions
230
+ * @param {string | Function} path route path or middleware function
231
+ * @param {...Function} callbacks Additional middleware functions
227
232
  * @returns {void}
228
233
  */
229
234
  put(path, ...callbacks) {
@@ -232,8 +237,8 @@ class MutableRouter {
232
237
  /**
233
238
  * Append middleware function(s) using the `use()` method.
234
239
  *
235
- * @param {string} path route path
236
- * @param {...Function} callbacks Middleware functions
240
+ * @param {string | Function} path route path or middleware function
241
+ * @param {...Function} callbacks Additional middleware functions
237
242
  * @returns {void}
238
243
  */
239
244
  use(path, ...callbacks) {
package/dist/lib/Plan.js CHANGED
@@ -147,6 +147,16 @@ const priv = new WeakMap();
147
147
  * @memberof module:@dwp/govuk-casa
148
148
  */
149
149
  class Plan {
150
+ /**
151
+ * Waypoints using the url:// protocol are known as "exit nodes" as they
152
+ * indicate an exit point to another Plan.
153
+ *
154
+ * @param {string} name Waypoint name
155
+ * @returns {boolean} True if the waypoint is a url:// type
156
+ */
157
+ static isExitNode(name) {
158
+ return reExitNodeProtocol.test(name);
159
+ }
150
160
  /**
151
161
  * Create a Plan.
152
162
  *
@@ -182,16 +192,6 @@ class Plan {
182
192
  });
183
193
  __classPrivateFieldSet(this, _Plan_skippableWaypoints, [], "f");
184
194
  }
185
- /**
186
- * Waypoints using the url:// protocol are known as "exit nodes" as they
187
- * indicate an exit point to another Plan.
188
- *
189
- * @param {string} name Waypoint name
190
- * @returns {boolean} True if the waypoint is a url:// type
191
- */
192
- static isExitNode(name) {
193
- return reExitNodeProtocol.test(name);
194
- }
195
195
  /**
196
196
  * Retrieve the options set on this Plan.
197
197
  *
@@ -496,7 +496,7 @@ class Plan {
496
496
  return self.follows[routeName][`${e.v}/${e.w}`](route, context);
497
497
  }
498
498
  catch (ex) {
499
- log.warn('Route follow function threw an exception, "%s" (%s)', ex.message, `${e.v}/${e.w}`);
499
+ log.warn('Route follow function threw an exception, "%s" (%s)', ex.message, `${e.v} -> ${e.w}`);
500
500
  return false;
501
501
  }
502
502
  });
@@ -19,7 +19,7 @@
19
19
  * @typedef {import('../casa').Validator} Validator
20
20
  */
21
21
  /**
22
- * @typedef {object} ValidatorFactoryOptions
22
+ * @typedef {Object.<string, unknown>} ValidatorFactoryOptions
23
23
  * @property {ErrorMessageConfig} errorMsg Error message
24
24
  */
25
25
  /**
@@ -42,7 +42,9 @@ export default class ValidatorFactory {
42
42
  * @param {ValidatorFactoryOptions} config Validator config (custom to each validator)
43
43
  */
44
44
  constructor(config?: ValidatorFactoryOptions);
45
- config: ValidatorFactoryOptions;
45
+ config: {
46
+ [x: string]: unknown;
47
+ };
46
48
  /**
47
49
  * Validate the given value.
48
50
  *
@@ -66,8 +68,5 @@ export type ValidationError = import('./index').ValidationError;
66
68
  export type ValidateContext = import('../casa').ValidateContext;
67
69
  export type Validator = import('../casa').Validator;
68
70
  export type ValidatorFactoryOptions = {
69
- /**
70
- * Error message
71
- */
72
- errorMsg: ErrorMessageConfig;
71
+ [x: string]: unknown;
73
72
  };
@@ -27,7 +27,7 @@ const { isPlainObject } = lodash_1.default; // CommonJS
27
27
  * @typedef {import('../casa').Validator} Validator
28
28
  */
29
29
  /**
30
- * @typedef {object} ValidatorFactoryOptions
30
+ * @typedef {Object.<string, unknown>} ValidatorFactoryOptions
31
31
  * @property {ErrorMessageConfig} errorMsg Error message
32
32
  */
33
33
  /**