@dwp/govuk-casa 8.2.3 → 8.2.4
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 +1 -0
- package/dist/casa.d.ts +198 -0
- package/dist/casa.js +129 -0
- package/dist/lib/CasaTemplateLoader.d.ts +4 -0
- package/dist/lib/CasaTemplateLoader.js +5 -0
- package/dist/lib/JourneyContext.d.ts +85 -13
- package/dist/lib/JourneyContext.js +78 -5
- package/dist/lib/Plan.d.ts +122 -49
- package/dist/lib/Plan.js +161 -37
- package/dist/lib/ValidationError.d.ts +38 -48
- package/dist/lib/ValidationError.js +30 -42
- package/dist/lib/ValidatorFactory.d.ts +42 -52
- package/dist/lib/ValidatorFactory.js +37 -48
- package/dist/lib/configuration-ingestor.d.ts +15 -0
- package/dist/lib/configuration-ingestor.js +17 -0
- package/dist/lib/configure.d.ts +4 -0
- package/dist/lib/configure.js +14 -1
- package/dist/lib/end-session.d.ts +3 -2
- package/dist/lib/end-session.js +2 -1
- package/dist/lib/field.d.ts +97 -35
- package/dist/lib/field.js +90 -41
- package/dist/lib/nunjucks-filters.d.ts +12 -2
- package/dist/lib/nunjucks-filters.js +11 -1
- package/dist/lib/nunjucks.d.ts +1 -0
- package/dist/lib/nunjucks.js +1 -0
- package/dist/lib/utils.d.ts +46 -14
- package/dist/lib/utils.js +43 -26
- package/dist/lib/validators/dateObject.d.ts +75 -1
- package/dist/lib/validators/dateObject.js +29 -18
- package/dist/lib/validators/email.d.ts +28 -1
- package/dist/lib/validators/email.js +20 -9
- package/dist/lib/validators/inArray.d.ts +34 -1
- package/dist/lib/validators/inArray.js +21 -0
- package/dist/lib/validators/index.js +3 -0
- package/dist/lib/validators/nino.d.ts +34 -1
- package/dist/lib/validators/nino.js +17 -7
- package/dist/lib/validators/postalAddressObject.d.ts +68 -1
- package/dist/lib/validators/postalAddressObject.js +27 -15
- package/dist/lib/validators/regex.d.ts +35 -1
- package/dist/lib/validators/regex.js +17 -7
- package/dist/lib/validators/required.d.ts +28 -1
- package/dist/lib/validators/required.js +19 -6
- package/dist/lib/validators/strlen.d.ts +40 -1
- package/dist/lib/validators/strlen.js +18 -8
- package/dist/lib/validators/wordCount.d.ts +40 -1
- package/dist/lib/validators/wordCount.js +18 -8
- package/dist/lib/waypoint-url.d.ts +1 -0
- package/dist/lib/waypoint-url.js +10 -0
- package/dist/middleware/data.js +21 -5
- package/dist/middleware/gather-fields.js +1 -0
- package/dist/middleware/pre.js +1 -0
- package/dist/middleware/steer-journey.js +2 -1
- package/dist/middleware/strip-proxy-path.js +6 -2
- package/dist/middleware/validate-fields.js +3 -0
- package/dist/routes/ancillary.d.ts +16 -5
- package/dist/routes/ancillary.js +7 -3
- package/dist/routes/journey.d.ts +30 -6
- package/dist/routes/journey.js +27 -0
- package/dist/routes/static.d.ts +1 -0
- package/dist/routes/static.js +2 -1
- package/package.json +16 -11
- package/views/casa/components/character-count/README.md +1 -1
- package/views/casa/components/input/README.md +1 -1
- package/views/casa/components/radios/README.md +2 -2
- package/views/casa/components/textarea/README.md +1 -1
package/dist/routes/journey.d.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Create an instance of the router for all waypoints visited during a Journey
|
|
3
|
+
* through the Plan.
|
|
4
|
+
*
|
|
5
|
+
* @access private
|
|
6
|
+
* @param {JourneyRouterOptions} opts Options
|
|
7
|
+
* @returns {MutableRouter} Router
|
|
8
|
+
*/
|
|
9
|
+
export default function journeyRouter({ globalHooks, pages, plan, csrfMiddleware, }: JourneyRouterOptions): MutableRouter;
|
|
10
|
+
/**
|
|
11
|
+
* Options to configure static router
|
|
12
|
+
*/
|
|
13
|
+
export type JourneyRouterOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Global hooks
|
|
16
|
+
*/
|
|
17
|
+
globalHooks: GlobalHook[];
|
|
18
|
+
/**
|
|
19
|
+
* Page definitions
|
|
20
|
+
*/
|
|
21
|
+
pages: Page[];
|
|
22
|
+
/**
|
|
23
|
+
* Plan
|
|
24
|
+
*/
|
|
25
|
+
plan: Plan;
|
|
26
|
+
/**
|
|
27
|
+
* Middleware for providing CSRF controls
|
|
28
|
+
*/
|
|
29
|
+
csrfMiddleware: Function[];
|
|
30
|
+
};
|
|
7
31
|
import MutableRouter from "../lib/MutableRouter.js";
|
package/dist/routes/journey.js
CHANGED
|
@@ -15,6 +15,25 @@ const waypoint_url_js_1 = __importDefault(require("../lib/waypoint-url.js"));
|
|
|
15
15
|
const logger_js_1 = __importDefault(require("../lib/logger.js"));
|
|
16
16
|
const utils_js_1 = require("../lib/utils.js");
|
|
17
17
|
const log = (0, logger_js_1.default)('routes:journey');
|
|
18
|
+
/**
|
|
19
|
+
* @access private
|
|
20
|
+
* @param {import('../casa.js').GlobalHook} GlobalHook
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @access private
|
|
24
|
+
* @param {import('../casa.js').Page} Page
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @access private
|
|
28
|
+
* @param {import('../casa.js').Plan} Plan
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {object} JourneyRouterOptions Options to configure static router
|
|
32
|
+
* @property {GlobalHook[]} globalHooks Global hooks
|
|
33
|
+
* @property {Page[]} pages Page definitions
|
|
34
|
+
* @property {Plan} plan Plan
|
|
35
|
+
* @property {Function[]} csrfMiddleware Middleware for providing CSRF controls
|
|
36
|
+
*/
|
|
18
37
|
const renderMiddlewareFactory = (view, contextFactory) => [
|
|
19
38
|
(req, res, next) => {
|
|
20
39
|
res.render(view, Object.assign({
|
|
@@ -29,6 +48,14 @@ const renderMiddlewareFactory = (view, contextFactory) => [
|
|
|
29
48
|
});
|
|
30
49
|
},
|
|
31
50
|
];
|
|
51
|
+
/**
|
|
52
|
+
* Create an instance of the router for all waypoints visited during a Journey
|
|
53
|
+
* through the Plan.
|
|
54
|
+
*
|
|
55
|
+
* @access private
|
|
56
|
+
* @param {JourneyRouterOptions} opts Options
|
|
57
|
+
* @returns {MutableRouter} Router
|
|
58
|
+
*/
|
|
32
59
|
function journeyRouter({ globalHooks, pages, plan, csrfMiddleware, }) {
|
|
33
60
|
// Router
|
|
34
61
|
const router = new MutableRouter_js_1.default();
|
package/dist/routes/static.d.ts
CHANGED
package/dist/routes/static.js
CHANGED
|
@@ -20,6 +20,7 @@ const oneDay = 86400000;
|
|
|
20
20
|
/**
|
|
21
21
|
* Create a router for serving CASA's static assets.
|
|
22
22
|
*
|
|
23
|
+
* @access private
|
|
23
24
|
* @param {StaticOptions} options Options
|
|
24
25
|
* @returns {MutableRouter} ExpressJS Router instance
|
|
25
26
|
*/
|
|
@@ -34,7 +35,7 @@ function staticRouter({ maxAge = 3600000, } = {}) {
|
|
|
34
35
|
res.set('cache-control', 'public');
|
|
35
36
|
res.set('pragma', 'cache');
|
|
36
37
|
res.set('expires', new Date(Date.now() + oneDay).toUTCString());
|
|
37
|
-
const { pathname } = new url_1.URL((_a = req === null || req === void 0 ? void 0 : req.originalUrl) !== null && _a !== void 0 ? _a : '', '
|
|
38
|
+
const { pathname } = new url_1.URL((_a = req === null || req === void 0 ? void 0 : req.originalUrl) !== null && _a !== void 0 ? _a : '', 'https://placeholder.test/');
|
|
38
39
|
if (pathname.substr(-4) === '.css') {
|
|
39
40
|
// Just needed for our in-memory CSS assets
|
|
40
41
|
res.set('content-type', 'text/css');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dwp/govuk-casa",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.4",
|
|
4
4
|
"description": "A framework for building GOVUK Collect-And-Submit-Applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"build:prepare": "rm -rf dist/* && mkdir -p dist/assets/js/ && mkdir -p dist/assets/css/",
|
|
33
33
|
"build:sources": "tsc -p tsconfig-cjs.json && ./scripts/fixup.sh",
|
|
34
34
|
"build:css-assets": "node scripts/compile-sass.js",
|
|
35
|
+
"build:api-docs": "npx jsdoc -c ./jsdoc.json -d ./docs/api/ --debug -P '' -r -R ./README.md --verbose -t ./node_modules/docdash ./src",
|
|
35
36
|
"prepare": "npm run build",
|
|
36
37
|
"upgrade-deps": "OD=$(npm outdated --long --parseable); echo \"$OD\" | grep ':devDependencies:' | awk -F: '{ print $4 }' | xargs npm i -DE; echo \"$OD\" | grep ':dependencies:' | awk -F: '{ print $4 }' | xargs npm i -E",
|
|
37
38
|
"standard-version": "node scripts/standard-version.js"
|
|
@@ -49,8 +50,8 @@
|
|
|
49
50
|
"express-session": "1.17.3",
|
|
50
51
|
"govuk-frontend": "4.0.1",
|
|
51
52
|
"graphlib": "2.1.8",
|
|
52
|
-
"helmet": "5.0
|
|
53
|
-
"i18next": "21.8.
|
|
53
|
+
"helmet": "5.1.0",
|
|
54
|
+
"i18next": "21.8.4",
|
|
54
55
|
"i18next-http-middleware": "3.2.0",
|
|
55
56
|
"js-yaml": "4.1.0",
|
|
56
57
|
"lodash": "4.17.21",
|
|
@@ -61,30 +62,34 @@
|
|
|
61
62
|
"validator": "13.7.0"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@babel/core": "7.
|
|
65
|
+
"@babel/core": "7.18.0",
|
|
65
66
|
"@babel/eslint-parser": "7.17.0",
|
|
66
|
-
"@babel/preset-env": "7.
|
|
67
|
+
"@babel/preset-env": "7.18.0",
|
|
67
68
|
"@commitlint/config-conventional": "17.0.0",
|
|
69
|
+
"@ckeditor/jsdoc-plugins": "30.1.0",
|
|
68
70
|
"@dwp/casa-spiderplan": "2.4.0",
|
|
69
71
|
"@dwp/casa-spiderplan-a11y-plugin": "0.1.4",
|
|
70
72
|
"@dwp/casa-spiderplan-zap-plugin": "0.1.1",
|
|
71
73
|
"@dwp/eslint-config-base": "6.0.0",
|
|
72
74
|
"@types/express": "4.17.13",
|
|
73
|
-
"@types/node": "17.0.
|
|
75
|
+
"@types/node": "17.0.35",
|
|
74
76
|
"@types/nunjucks": "3.2.1",
|
|
75
77
|
"babel-eslint": "10.1.0",
|
|
76
78
|
"c8": "7.11.3",
|
|
77
79
|
"chai": "4.3.6",
|
|
78
|
-
"cheerio": "1.0.0-rc.
|
|
80
|
+
"cheerio": "1.0.0-rc.11",
|
|
79
81
|
"commitlint": "17.0.0",
|
|
80
|
-
"eslint": "8.
|
|
81
|
-
"
|
|
82
|
+
"eslint": "8.16.0",
|
|
83
|
+
"docdash": "1.2.0",
|
|
82
84
|
"eslint-plugin-security": "1.5.0",
|
|
83
|
-
"eslint-plugin-sonarjs": "0.13.0",
|
|
84
85
|
"fast-check": "2.25.0",
|
|
85
86
|
"husky": "8.0.1",
|
|
86
87
|
"mocha": "10.0.0",
|
|
87
|
-
"sass": "1.
|
|
88
|
+
"sass": "1.52.1",
|
|
89
|
+
"eslint-plugin-no-unsafe-regex": "1.0.0",
|
|
90
|
+
"eslint-plugin-sonarjs": "0.13.0",
|
|
91
|
+
"jsdoc": "3.6.10",
|
|
92
|
+
"jsdoc-tsimport-plugin": "1.0.5",
|
|
88
93
|
"sinon": "14.0.0",
|
|
89
94
|
"sinon-chai": "3.7.0",
|
|
90
95
|
"standard-version": "9.5.0",
|
|
@@ -11,7 +11,7 @@ Custom parameters:
|
|
|
11
11
|
Basic example:
|
|
12
12
|
|
|
13
13
|
```nunjucks
|
|
14
|
-
{% from "casa/components/character-count/macro.njk" import casaGovukCharacterCount %}
|
|
14
|
+
{% from "casa/components/character-count/macro.njk" import casaGovukCharacterCount with context %}
|
|
15
15
|
|
|
16
16
|
casaGovukCharacterCount({
|
|
17
17
|
name: "name",
|
|
@@ -13,7 +13,7 @@ Custom parameters:
|
|
|
13
13
|
Basic example:
|
|
14
14
|
|
|
15
15
|
```nunjucks
|
|
16
|
-
{% from "casa/components/radios/macro.njk" import casaGovukRadios %}
|
|
16
|
+
{% from "casa/components/radios/macro.njk" import casaGovukRadios with context %}
|
|
17
17
|
|
|
18
18
|
{{ casaGovukRadios({
|
|
19
19
|
name: 'myInput',
|
|
@@ -32,7 +32,7 @@ Basic example:
|
|
|
32
32
|
If you want one of the radio items to toggle the display of an element:
|
|
33
33
|
|
|
34
34
|
```nunjucks
|
|
35
|
-
{% from "casa/components/radios/macro.njk" import casaGovukRadios %}
|
|
35
|
+
{% from "casa/components/radios/macro.njk" import casaGovukRadios with context %}
|
|
36
36
|
|
|
37
37
|
{% set panel %}
|
|
38
38
|
This panel will remain hidden until the "Yes" radio button is chosen
|
|
@@ -11,7 +11,7 @@ Custom parameters:
|
|
|
11
11
|
Basic example:
|
|
12
12
|
|
|
13
13
|
```nunjucks
|
|
14
|
-
{% from "casa/components/textarea/macro.njk" import casaGovukTextarea %}
|
|
14
|
+
{% from "casa/components/textarea/macro.njk" import casaGovukTextarea with context %}
|
|
15
15
|
|
|
16
16
|
casaGovukTextarea({
|
|
17
17
|
name: "name",
|