@dwp/govuk-casa 9.0.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 +1 -1
- package/dist/assets/css/casa.css.map +1 -1
- package/dist/casa.d.ts +122 -95
- package/dist/casa.js +119 -86
- 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 +81 -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 +20 -18
- package/dist/lib/field.js +35 -48
- 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 +11 -10
- 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 -27
- 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 -19
- package/dist/routes/static.js.map +1 -1
- package/package.json +19 -18
- package/src/casa.js +133 -100
- package/src/lib/CasaTemplateLoader.js +24 -19
- package/src/lib/JourneyContext.js +138 -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 +69 -58
- package/src/lib/index.js +12 -12
- package/src/lib/logger.js +9 -9
- package/src/lib/mount.js +70 -74
- 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 -41
- 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 -29
- 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/layouts/main.njk +2 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @memberof module:@dwp/govuk-casa
|
|
3
|
-
*/
|
|
1
|
+
/** @memberof module:@dwp/govuk-casa */
|
|
4
2
|
export default class MutableRouter {
|
|
5
3
|
/**
|
|
6
4
|
* Seals this router to make it immutable. Returns the ExpressJS router.
|
|
@@ -11,148 +9,149 @@ export default class MutableRouter {
|
|
|
11
9
|
/**
|
|
12
10
|
* Prepend middleware function(s) using the `all()` method.
|
|
13
11
|
*
|
|
14
|
-
* @param {string | Function} path
|
|
15
|
-
* @param
|
|
12
|
+
* @param {string | Function} path Route path or middleware function
|
|
13
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
16
14
|
* @returns {void}
|
|
17
15
|
*/
|
|
18
16
|
prependAll(path: string | Function, ...callbacks: Function[]): void;
|
|
19
17
|
/**
|
|
20
18
|
* Prepend middleware function(s) using the `get()` method.
|
|
21
19
|
*
|
|
22
|
-
* @param {string | Function} path
|
|
23
|
-
* @param
|
|
20
|
+
* @param {string | Function} path Route path or middleware function
|
|
21
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
24
22
|
* @returns {void}
|
|
25
23
|
*/
|
|
26
24
|
prependGet(path: string | Function, ...callbacks: Function[]): void;
|
|
27
25
|
/**
|
|
28
26
|
* Prepend middleware function(s) using the `post()` method.
|
|
29
27
|
*
|
|
30
|
-
* @param {string | Function} path
|
|
31
|
-
* @param
|
|
28
|
+
* @param {string | Function} path Route path or middleware function
|
|
29
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
32
30
|
* @returns {void}
|
|
33
31
|
*/
|
|
34
32
|
prependPost(path: string | Function, ...callbacks: Function[]): void;
|
|
35
33
|
/**
|
|
36
34
|
* Prepend middleware function(s) using the `delete()` method.
|
|
37
35
|
*
|
|
38
|
-
* @param {string | Function} path
|
|
39
|
-
* @param
|
|
36
|
+
* @param {string | Function} path Route path or middleware function
|
|
37
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
40
38
|
* @returns {void}
|
|
41
39
|
*/
|
|
42
40
|
prependDelete(path: string | Function, ...callbacks: Function[]): void;
|
|
43
41
|
/**
|
|
44
42
|
* Prepend middleware function(s) using the `put()` method.
|
|
45
43
|
*
|
|
46
|
-
* @param {string | Function} path
|
|
47
|
-
* @param
|
|
44
|
+
* @param {string | Function} path Route path or middleware function
|
|
45
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
48
46
|
* @returns {void}
|
|
49
47
|
*/
|
|
50
48
|
prependPut(path: string | Function, ...callbacks: Function[]): void;
|
|
51
49
|
/**
|
|
52
50
|
* Prepend middleware function(s) using the `use()` method.
|
|
53
51
|
*
|
|
54
|
-
* @param {string | Function} path
|
|
55
|
-
* @param
|
|
52
|
+
* @param {string | Function} path Route path or middleware function
|
|
53
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
56
54
|
* @returns {void}
|
|
57
55
|
*/
|
|
58
56
|
prependUse(path: string | Function, ...callbacks: Function[]): void;
|
|
59
57
|
/**
|
|
60
58
|
* Replace middleware function(s) that were mounted using the `all()` method.
|
|
61
59
|
*
|
|
62
|
-
* @param {string | Function} path
|
|
63
|
-
* @param
|
|
60
|
+
* @param {string | Function} path Route path or middleware function
|
|
61
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
64
62
|
* @returns {void}
|
|
65
63
|
*/
|
|
66
64
|
replaceAll(path: string | Function, ...callbacks: Function[]): void;
|
|
67
65
|
/**
|
|
68
66
|
* Replace middleware function(s) that were mounted using the `get()` method.
|
|
69
67
|
*
|
|
70
|
-
* @param {string | Function} path
|
|
71
|
-
* @param
|
|
68
|
+
* @param {string | Function} path Route path or middleware function
|
|
69
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
72
70
|
* @returns {void}
|
|
73
71
|
*/
|
|
74
72
|
replaceGet(path: string | Function, ...callbacks: Function[]): void;
|
|
75
73
|
/**
|
|
76
74
|
* Replace middleware function(s) that were mounted using the `post()` method.
|
|
77
75
|
*
|
|
78
|
-
* @param {string | Function} path
|
|
79
|
-
* @param
|
|
76
|
+
* @param {string | Function} path Route path or middleware function
|
|
77
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
80
78
|
* @returns {void}
|
|
81
79
|
*/
|
|
82
80
|
replacePost(path: string | Function, ...callbacks: Function[]): void;
|
|
83
81
|
/**
|
|
84
|
-
* Replace middleware function(s) that were mounted using the `delete()`
|
|
82
|
+
* Replace middleware function(s) that were mounted using the `delete()`
|
|
83
|
+
* method.
|
|
85
84
|
*
|
|
86
|
-
* @param {string | Function} path
|
|
87
|
-
* @param
|
|
85
|
+
* @param {string | Function} path Route path or middleware function
|
|
86
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
88
87
|
* @returns {void}
|
|
89
88
|
*/
|
|
90
89
|
replaceDelete(path: string | Function, ...callbacks: Function[]): void;
|
|
91
90
|
/**
|
|
92
91
|
* Replace middleware function(s) that were mounted using the `put()` method.
|
|
93
92
|
*
|
|
94
|
-
* @param {string | Function} path
|
|
95
|
-
* @param
|
|
93
|
+
* @param {string | Function} path Route path or middleware function
|
|
94
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
96
95
|
* @returns {void}
|
|
97
96
|
*/
|
|
98
97
|
replacePut(path: string | Function, ...callbacks: Function[]): void;
|
|
99
98
|
/**
|
|
100
99
|
* Replace middleware function(s) that were mounted using the `use()` method.
|
|
101
100
|
*
|
|
102
|
-
* @param {string | Function} path
|
|
103
|
-
* @param
|
|
101
|
+
* @param {string | Function} path Route path or middleware function
|
|
102
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
104
103
|
* @returns {void}
|
|
105
104
|
*/
|
|
106
105
|
replaceUse(path: string | Function, ...callbacks: Function[]): void;
|
|
107
106
|
/**
|
|
108
107
|
* Append middleware function(s) using the `all()` method.
|
|
109
108
|
*
|
|
110
|
-
* @param {string | Function} path
|
|
111
|
-
* @param
|
|
109
|
+
* @param {string | Function} path Route path or middleware function
|
|
110
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
112
111
|
* @returns {void}
|
|
113
112
|
*/
|
|
114
113
|
all(path: string | Function, ...callbacks: Function[]): void;
|
|
115
114
|
/**
|
|
116
115
|
* Append middleware function(s) using the `get()` method.
|
|
117
116
|
*
|
|
118
|
-
* @param {string | Function} path
|
|
119
|
-
* @param
|
|
117
|
+
* @param {string | Function} path Route path or middleware function
|
|
118
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
120
119
|
* @returns {void}
|
|
121
120
|
*/
|
|
122
121
|
get(path: string | Function, ...callbacks: Function[]): void;
|
|
123
122
|
/**
|
|
124
123
|
* Append middleware function(s) using the `post()` method.
|
|
125
124
|
*
|
|
126
|
-
* @param {string | Function} path
|
|
127
|
-
* @param
|
|
125
|
+
* @param {string | Function} path Route path or middleware function
|
|
126
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
128
127
|
* @returns {void}
|
|
129
128
|
*/
|
|
130
129
|
post(path: string | Function, ...callbacks: Function[]): void;
|
|
131
130
|
/**
|
|
132
131
|
* Append middleware function(s) using the `delete()` method.
|
|
133
132
|
*
|
|
134
|
-
* @param {string | Function} path
|
|
135
|
-
* @param
|
|
133
|
+
* @param {string | Function} path Route path or middleware function
|
|
134
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
136
135
|
* @returns {void}
|
|
137
136
|
*/
|
|
138
137
|
delete(path: string | Function, ...callbacks: Function[]): void;
|
|
139
138
|
/**
|
|
140
139
|
* Append middleware function(s) using the `put()` method.
|
|
141
140
|
*
|
|
142
|
-
* @param {string | Function} path
|
|
143
|
-
* @param
|
|
141
|
+
* @param {string | Function} path Route path or middleware function
|
|
142
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
144
143
|
* @returns {void}
|
|
145
144
|
*/
|
|
146
145
|
put(path: string | Function, ...callbacks: Function[]): void;
|
|
147
146
|
/**
|
|
148
147
|
* Append middleware function(s) using the `use()` method.
|
|
149
148
|
*
|
|
150
|
-
* @param {string | Function} path
|
|
151
|
-
* @param
|
|
149
|
+
* @param {string | Function} path Route path or middleware function
|
|
150
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
152
151
|
* @returns {void}
|
|
153
152
|
*/
|
|
154
153
|
use(path: string | Function, ...callbacks: Function[]): void;
|
|
155
154
|
route(): void;
|
|
156
155
|
#private;
|
|
157
156
|
}
|
|
158
|
-
import { Router } from
|
|
157
|
+
import { Router } from "express";
|
|
@@ -14,9 +14,7 @@ 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
|
+
/** @memberof module:@dwp/govuk-casa */
|
|
20
18
|
class MutableRouter {
|
|
21
19
|
/**
|
|
22
20
|
* A wrapping class to make Express routers mutable. You can append, prepend
|
|
@@ -27,17 +25,11 @@ class MutableRouter {
|
|
|
27
25
|
*/
|
|
28
26
|
constructor() {
|
|
29
27
|
_MutableRouter_instances.add(this);
|
|
30
|
-
/**
|
|
31
|
-
* @type {Array}
|
|
32
|
-
*/
|
|
28
|
+
/** @type {Array} */
|
|
33
29
|
_MutableRouter_stack.set(this, void 0);
|
|
34
|
-
/**
|
|
35
|
-
* @type {Router}
|
|
36
|
-
*/
|
|
30
|
+
/** @type {Router} */
|
|
37
31
|
_MutableRouter_router.set(this, void 0);
|
|
38
|
-
/**
|
|
39
|
-
* @type {boolean}
|
|
40
|
-
*/
|
|
32
|
+
/** @type {boolean} */
|
|
41
33
|
_MutableRouter_sealed.set(this, void 0);
|
|
42
34
|
__classPrivateFieldSet(this, _MutableRouter_router, (0, express_1.Router)(), "f");
|
|
43
35
|
__classPrivateFieldSet(this, _MutableRouter_stack, [], "f");
|
|
@@ -65,192 +57,193 @@ class MutableRouter {
|
|
|
65
57
|
/**
|
|
66
58
|
* Prepend middleware function(s) using the `all()` method.
|
|
67
59
|
*
|
|
68
|
-
* @param {string | Function} path
|
|
69
|
-
* @param
|
|
60
|
+
* @param {string | Function} path Route path or middleware function
|
|
61
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
70
62
|
* @returns {void}
|
|
71
63
|
*/
|
|
72
64
|
prependAll(path, ...callbacks) {
|
|
73
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this,
|
|
65
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this, "all", path, ...callbacks);
|
|
74
66
|
}
|
|
75
67
|
/**
|
|
76
68
|
* Prepend middleware function(s) using the `get()` method.
|
|
77
69
|
*
|
|
78
|
-
* @param {string | Function} path
|
|
79
|
-
* @param
|
|
70
|
+
* @param {string | Function} path Route path or middleware function
|
|
71
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
80
72
|
* @returns {void}
|
|
81
73
|
*/
|
|
82
74
|
prependGet(path, ...callbacks) {
|
|
83
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this,
|
|
75
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this, "get", path, ...callbacks);
|
|
84
76
|
}
|
|
85
77
|
/**
|
|
86
78
|
* Prepend middleware function(s) using the `post()` method.
|
|
87
79
|
*
|
|
88
|
-
* @param {string | Function} path
|
|
89
|
-
* @param
|
|
80
|
+
* @param {string | Function} path Route path or middleware function
|
|
81
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
90
82
|
* @returns {void}
|
|
91
83
|
*/
|
|
92
84
|
prependPost(path, ...callbacks) {
|
|
93
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this,
|
|
85
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this, "post", path, ...callbacks);
|
|
94
86
|
}
|
|
95
87
|
/**
|
|
96
88
|
* Prepend middleware function(s) using the `delete()` method.
|
|
97
89
|
*
|
|
98
|
-
* @param {string | Function} path
|
|
99
|
-
* @param
|
|
90
|
+
* @param {string | Function} path Route path or middleware function
|
|
91
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
100
92
|
* @returns {void}
|
|
101
93
|
*/
|
|
102
94
|
prependDelete(path, ...callbacks) {
|
|
103
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this,
|
|
95
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this, "delete", path, ...callbacks);
|
|
104
96
|
}
|
|
105
97
|
/**
|
|
106
98
|
* Prepend middleware function(s) using the `put()` method.
|
|
107
99
|
*
|
|
108
|
-
* @param {string | Function} path
|
|
109
|
-
* @param
|
|
100
|
+
* @param {string | Function} path Route path or middleware function
|
|
101
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
110
102
|
* @returns {void}
|
|
111
103
|
*/
|
|
112
104
|
prependPut(path, ...callbacks) {
|
|
113
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this,
|
|
105
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this, "put", path, ...callbacks);
|
|
114
106
|
}
|
|
115
107
|
/**
|
|
116
108
|
* Prepend middleware function(s) using the `use()` method.
|
|
117
109
|
*
|
|
118
|
-
* @param {string | Function} path
|
|
119
|
-
* @param
|
|
110
|
+
* @param {string | Function} path Route path or middleware function
|
|
111
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
120
112
|
* @returns {void}
|
|
121
113
|
*/
|
|
122
114
|
prependUse(path, ...callbacks) {
|
|
123
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this,
|
|
115
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_prepend).call(this, "use", path, ...callbacks);
|
|
124
116
|
}
|
|
125
117
|
/* -------------------------------------------------------------- replacers */
|
|
126
118
|
/**
|
|
127
119
|
* Replace middleware function(s) that were mounted using the `all()` method.
|
|
128
120
|
*
|
|
129
|
-
* @param {string | Function} path
|
|
130
|
-
* @param
|
|
121
|
+
* @param {string | Function} path Route path or middleware function
|
|
122
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
131
123
|
* @returns {void}
|
|
132
124
|
*/
|
|
133
125
|
replaceAll(path, ...callbacks) {
|
|
134
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this,
|
|
126
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this, "all", path, ...callbacks);
|
|
135
127
|
}
|
|
136
128
|
/**
|
|
137
129
|
* Replace middleware function(s) that were mounted using the `get()` method.
|
|
138
130
|
*
|
|
139
|
-
* @param {string | Function} path
|
|
140
|
-
* @param
|
|
131
|
+
* @param {string | Function} path Route path or middleware function
|
|
132
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
141
133
|
* @returns {void}
|
|
142
134
|
*/
|
|
143
135
|
replaceGet(path, ...callbacks) {
|
|
144
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this,
|
|
136
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this, "get", path, ...callbacks);
|
|
145
137
|
}
|
|
146
138
|
/**
|
|
147
139
|
* Replace middleware function(s) that were mounted using the `post()` method.
|
|
148
140
|
*
|
|
149
|
-
* @param {string | Function} path
|
|
150
|
-
* @param
|
|
141
|
+
* @param {string | Function} path Route path or middleware function
|
|
142
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
151
143
|
* @returns {void}
|
|
152
144
|
*/
|
|
153
145
|
replacePost(path, ...callbacks) {
|
|
154
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this,
|
|
146
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this, "post", path, ...callbacks);
|
|
155
147
|
}
|
|
156
148
|
/**
|
|
157
|
-
* Replace middleware function(s) that were mounted using the `delete()`
|
|
149
|
+
* Replace middleware function(s) that were mounted using the `delete()`
|
|
150
|
+
* method.
|
|
158
151
|
*
|
|
159
|
-
* @param {string | Function} path
|
|
160
|
-
* @param
|
|
152
|
+
* @param {string | Function} path Route path or middleware function
|
|
153
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
161
154
|
* @returns {void}
|
|
162
155
|
*/
|
|
163
156
|
replaceDelete(path, ...callbacks) {
|
|
164
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this,
|
|
157
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this, "delete", path, ...callbacks);
|
|
165
158
|
}
|
|
166
159
|
/**
|
|
167
160
|
* Replace middleware function(s) that were mounted using the `put()` method.
|
|
168
161
|
*
|
|
169
|
-
* @param {string | Function} path
|
|
170
|
-
* @param
|
|
162
|
+
* @param {string | Function} path Route path or middleware function
|
|
163
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
171
164
|
* @returns {void}
|
|
172
165
|
*/
|
|
173
166
|
replacePut(path, ...callbacks) {
|
|
174
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this,
|
|
167
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this, "put", path, ...callbacks);
|
|
175
168
|
}
|
|
176
169
|
/**
|
|
177
170
|
* Replace middleware function(s) that were mounted using the `use()` method.
|
|
178
171
|
*
|
|
179
|
-
* @param {string | Function} path
|
|
180
|
-
* @param
|
|
172
|
+
* @param {string | Function} path Route path or middleware function
|
|
173
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
181
174
|
* @returns {void}
|
|
182
175
|
*/
|
|
183
176
|
replaceUse(path, ...callbacks) {
|
|
184
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this,
|
|
177
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_replace).call(this, "use", path, ...callbacks);
|
|
185
178
|
}
|
|
186
179
|
/* ---------------------------------------------- express.Router() wrappers */
|
|
187
180
|
/**
|
|
188
181
|
* Append middleware function(s) using the `all()` method.
|
|
189
182
|
*
|
|
190
|
-
* @param {string | Function} path
|
|
191
|
-
* @param
|
|
183
|
+
* @param {string | Function} path Route path or middleware function
|
|
184
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
192
185
|
* @returns {void}
|
|
193
186
|
*/
|
|
194
187
|
all(path, ...callbacks) {
|
|
195
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this,
|
|
188
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this, "all", path, ...callbacks);
|
|
196
189
|
}
|
|
197
190
|
/**
|
|
198
191
|
* Append middleware function(s) using the `get()` method.
|
|
199
192
|
*
|
|
200
|
-
* @param {string | Function} path
|
|
201
|
-
* @param
|
|
193
|
+
* @param {string | Function} path Route path or middleware function
|
|
194
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
202
195
|
* @returns {void}
|
|
203
196
|
*/
|
|
204
197
|
get(path, ...callbacks) {
|
|
205
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this,
|
|
198
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this, "get", path, ...callbacks);
|
|
206
199
|
}
|
|
207
200
|
/**
|
|
208
201
|
* Append middleware function(s) using the `post()` method.
|
|
209
202
|
*
|
|
210
|
-
* @param {string | Function} path
|
|
211
|
-
* @param
|
|
203
|
+
* @param {string | Function} path Route path or middleware function
|
|
204
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
212
205
|
* @returns {void}
|
|
213
206
|
*/
|
|
214
207
|
post(path, ...callbacks) {
|
|
215
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this,
|
|
208
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this, "post", path, ...callbacks);
|
|
216
209
|
}
|
|
217
210
|
/**
|
|
218
211
|
* Append middleware function(s) using the `delete()` method.
|
|
219
212
|
*
|
|
220
|
-
* @param {string | Function} path
|
|
221
|
-
* @param
|
|
213
|
+
* @param {string | Function} path Route path or middleware function
|
|
214
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
222
215
|
* @returns {void}
|
|
223
216
|
*/
|
|
224
217
|
delete(path, ...callbacks) {
|
|
225
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this,
|
|
218
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this, "delete", path, ...callbacks);
|
|
226
219
|
}
|
|
227
220
|
/**
|
|
228
221
|
* Append middleware function(s) using the `put()` method.
|
|
229
222
|
*
|
|
230
|
-
* @param {string | Function} path
|
|
231
|
-
* @param
|
|
223
|
+
* @param {string | Function} path Route path or middleware function
|
|
224
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
232
225
|
* @returns {void}
|
|
233
226
|
*/
|
|
234
227
|
put(path, ...callbacks) {
|
|
235
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this,
|
|
228
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this, "put", path, ...callbacks);
|
|
236
229
|
}
|
|
237
230
|
/**
|
|
238
231
|
* Append middleware function(s) using the `use()` method.
|
|
239
232
|
*
|
|
240
|
-
* @param {string | Function} path
|
|
241
|
-
* @param
|
|
233
|
+
* @param {string | Function} path Route path or middleware function
|
|
234
|
+
* @param {...Function} callbacks Additional middleware functions
|
|
242
235
|
* @returns {void}
|
|
243
236
|
*/
|
|
244
237
|
use(path, ...callbacks) {
|
|
245
|
-
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this,
|
|
238
|
+
__classPrivateFieldGet(this, _MutableRouter_instances, "m", _MutableRouter_append).call(this, "use", path, ...callbacks);
|
|
246
239
|
}
|
|
247
240
|
route() {
|
|
248
|
-
throw new Error(
|
|
241
|
+
throw new Error("route() method is not supported on MutableRouter. Use verb methods for now.");
|
|
249
242
|
}
|
|
250
243
|
}
|
|
251
244
|
_MutableRouter_stack = new WeakMap(), _MutableRouter_router = new WeakMap(), _MutableRouter_sealed = new WeakMap(), _MutableRouter_instances = new WeakSet(), _MutableRouter_append = function _MutableRouter_append(method, path, ...callbacks) {
|
|
252
245
|
if (__classPrivateFieldGet(this, _MutableRouter_sealed, "f")) {
|
|
253
|
-
throw new Error(
|
|
246
|
+
throw new Error("Cannot alter middleware in a sealed mutable router");
|
|
254
247
|
}
|
|
255
248
|
__classPrivateFieldGet(this, _MutableRouter_stack, "f").push({
|
|
256
249
|
method,
|
|
@@ -259,7 +252,7 @@ _MutableRouter_stack = new WeakMap(), _MutableRouter_router = new WeakMap(), _Mu
|
|
|
259
252
|
});
|
|
260
253
|
}, _MutableRouter_prepend = function _MutableRouter_prepend(method, path, ...callbacks) {
|
|
261
254
|
if (__classPrivateFieldGet(this, _MutableRouter_sealed, "f")) {
|
|
262
|
-
throw new Error(
|
|
255
|
+
throw new Error("Cannot alter middleware in a sealed mutable router");
|
|
263
256
|
}
|
|
264
257
|
__classPrivateFieldGet(this, _MutableRouter_stack, "f").splice(0, 0, {
|
|
265
258
|
method,
|
|
@@ -268,7 +261,7 @@ _MutableRouter_stack = new WeakMap(), _MutableRouter_router = new WeakMap(), _Mu
|
|
|
268
261
|
});
|
|
269
262
|
}, _MutableRouter_replace = function _MutableRouter_replace(method, path, ...callbacks) {
|
|
270
263
|
if (__classPrivateFieldGet(this, _MutableRouter_sealed, "f")) {
|
|
271
|
-
throw new Error(
|
|
264
|
+
throw new Error("Cannot alter middleware in a sealed mutable router");
|
|
272
265
|
}
|
|
273
266
|
const finder = (command) => `${command.method}|${command.path}` === `${method}|${path}`;
|
|
274
267
|
const index = __classPrivateFieldGet(this, _MutableRouter_stack, "f").findIndex(finder);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutableRouter.js","sourceRoot":"","sources":["../../src/lib/MutableRouter.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uEAAuE;AACvE,qCAAiC;AAEjC
|
|
1
|
+
{"version":3,"file":"MutableRouter.js","sourceRoot":"","sources":["../../src/lib/MutableRouter.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uEAAuE;AACvE,qCAAiC;AAEjC,uCAAuC;AACvC,MAAqB,aAAa;IAUhC;;;;;;OAMG;IACH;;QAhBA,oBAAoB;QACpB,uCAAO;QAEP,qBAAqB;QACrB,wCAAQ;QAER,sBAAsB;QACtB,wCAAQ;QAUN,uBAAA,IAAI,yBAAW,IAAA,gBAAM,GAAE,MAAA,CAAC;QACxB,uBAAA,IAAI,wBAAU,EAAE,MAAA,CAAC;QACjB,uBAAA,IAAI,yBAAW,KAAK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AO,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CACnD,MAAA,CAAC;IACJ,CAAC;AACH,CAAC;kBArEkB,aAAa"}
|
package/dist/lib/Plan.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @memberof module:@dwp/govuk-casa
|
|
3
|
-
*/
|
|
1
|
+
/** @memberof module:@dwp/govuk-casa */
|
|
4
2
|
export default class Plan {
|
|
5
3
|
/**
|
|
6
4
|
* Waypoints using the url:// protocol are known as "exit nodes" as they
|
|
@@ -31,7 +29,7 @@ export default class Plan {
|
|
|
31
29
|
/**
|
|
32
30
|
* Add one or more skippable waypoints.
|
|
33
31
|
*
|
|
34
|
-
* @param
|
|
32
|
+
* @param {...string} waypoints Waypoints
|
|
35
33
|
* @returns {Plan} Chain
|
|
36
34
|
*/
|
|
37
35
|
addSkippables(...waypoints: string[]): Plan;
|
|
@@ -92,7 +90,7 @@ export default class Plan {
|
|
|
92
90
|
* Add a sequence of waypoints that will follow on from each other, with no
|
|
93
91
|
* routing logic between them.
|
|
94
92
|
*
|
|
95
|
-
* @param
|
|
93
|
+
* @param {...string} waypoints Waypoints to add
|
|
96
94
|
* @returns {void}
|
|
97
95
|
*/
|
|
98
96
|
addSequence(...waypoints: string[]): void;
|
|
@@ -122,8 +120,8 @@ export default class Plan {
|
|
|
122
120
|
* condition must be true, and so to reverse the direction we also need that
|
|
123
121
|
* same condition to be true.
|
|
124
122
|
*
|
|
125
|
-
* However, if the condition function uses the `source`/`target` property
|
|
126
|
-
*
|
|
123
|
+
* However, if the condition function uses the `source`/`target` property of
|
|
124
|
+
* the route in some way, then we must reverse these before passing to the
|
|
127
125
|
* condition on the "prev" route because `source` in the condition will almost
|
|
128
126
|
* certainly be referring to the source of the "next" route.
|
|
129
127
|
*
|
|
@@ -140,27 +138,29 @@ export default class Plan {
|
|
|
140
138
|
/**
|
|
141
139
|
* Create a named route between two waypoints, and give that route a function
|
|
142
140
|
* that determine whether it should be followed during traversal operations.
|
|
143
|
-
* Note that the source waypoint must be in a successful validation state
|
|
144
|
-
*
|
|
141
|
+
* Note that the source waypoint must be in a successful validation state to
|
|
142
|
+
* be considered for traversal, regardless of what the custom function
|
|
145
143
|
* determines.
|
|
146
144
|
*
|
|
147
145
|
* You may also define routes that take the user to any generic URL within the
|
|
148
|
-
* same domain by using the `url://` protocol. These are considered
|
|
149
|
-
*
|
|
146
|
+
* same domain by using the `url://` protocol. These are considered "exit
|
|
147
|
+
* nodes".
|
|
150
148
|
*
|
|
151
|
-
*
|
|
149
|
+
* SetNamedRoute("my-waypoint", "url:///some/absolute/url");
|
|
152
150
|
*
|
|
153
151
|
* @param {string} src Source waypoint.
|
|
154
152
|
* @param {string} tgt Target waypoint.
|
|
155
|
-
* @param {string} name Name of the route (must be unique for this waypoint
|
|
156
|
-
*
|
|
153
|
+
* @param {string} name Name of the route (must be unique for this waypoint
|
|
154
|
+
* pairing).
|
|
155
|
+
* @param {PlanRouteCondition} follow Test function to determine if route can
|
|
156
|
+
* be followed.
|
|
157
157
|
* @returns {Plan} Chain
|
|
158
158
|
* @throws {Error} If attempting to create a "next" route from an exit node
|
|
159
159
|
*/
|
|
160
160
|
setNamedRoute(src: string, tgt: string, name: string, follow: PlanRouteCondition): Plan;
|
|
161
161
|
/**
|
|
162
|
-
* This is a convenience method for traversing all "next" routes, and
|
|
163
|
-
* the IDs of all waypoints visited along the way.
|
|
162
|
+
* This is a convenience method for traversing all "next" routes, and
|
|
163
|
+
* returning the IDs of all waypoints visited along the way.
|
|
164
164
|
*
|
|
165
165
|
* @param {JourneyContext} context Journey Context
|
|
166
166
|
* @param {PlanTraverseOptions} options Options
|
|
@@ -189,8 +189,9 @@ export default class Plan {
|
|
|
189
189
|
* Traverse through the plan from a particular starting waypoint. This is a
|
|
190
190
|
* non-exhaustive Graph Exploration.
|
|
191
191
|
*
|
|
192
|
-
* The last route in the list will contain the source of the last waypoint
|
|
193
|
-
* can be reached, i.e. The waypoint that has no further satisfiable
|
|
192
|
+
* The last route in the list will contain the source of the last waypoint
|
|
193
|
+
* that can be reached, i.e. The waypoint that has no further satisfiable
|
|
194
|
+
* out-edges.
|
|
194
195
|
*
|
|
195
196
|
* If a cyclical set of routes are encountered, traversal will stop after
|
|
196
197
|
* reaching the first repeated waypoint.
|
|
@@ -210,19 +211,21 @@ export default class Plan {
|
|
|
210
211
|
getGraphStructure(): Graph;
|
|
211
212
|
#private;
|
|
212
213
|
}
|
|
213
|
-
export type PlanRoute = import(
|
|
214
|
-
export type PlanRouteCondition = import(
|
|
215
|
-
export type PlanTraverseOptions = import(
|
|
216
|
-
export type PlanArbiter = import(
|
|
214
|
+
export type PlanRoute = import("../casa").PlanRoute;
|
|
215
|
+
export type PlanRouteCondition = import("../casa").PlanRouteCondition;
|
|
216
|
+
export type PlanTraverseOptions = import("../casa").PlanTraverseOptions;
|
|
217
|
+
export type PlanArbiter = import("../casa").PlanArbiter;
|
|
217
218
|
export type PlanConstructorOptions = {
|
|
218
219
|
/**
|
|
219
|
-
* Check page validity
|
|
220
|
+
* Check page validity
|
|
221
|
+
* before conditions. Default is `true`
|
|
220
222
|
*/
|
|
221
223
|
validateBeforeRouteCondition?: boolean | undefined;
|
|
222
224
|
/**
|
|
223
|
-
* Arbitration mechanism
|
|
225
|
+
* Arbitration mechanism.
|
|
226
|
+
* Default is `undefined`
|
|
224
227
|
*/
|
|
225
228
|
arbiter?: string | import("../casa").PlanArbiter | undefined;
|
|
226
229
|
};
|
|
227
|
-
import JourneyContext from
|
|
228
|
-
import { Graph } from
|
|
230
|
+
import JourneyContext from "./JourneyContext.js";
|
|
231
|
+
import { Graph } from "@dagrejs/graphlib";
|