@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.
Files changed (65) hide show
  1. package/README.md +1 -0
  2. package/dist/casa.d.ts +198 -0
  3. package/dist/casa.js +129 -0
  4. package/dist/lib/CasaTemplateLoader.d.ts +4 -0
  5. package/dist/lib/CasaTemplateLoader.js +5 -0
  6. package/dist/lib/JourneyContext.d.ts +85 -13
  7. package/dist/lib/JourneyContext.js +78 -5
  8. package/dist/lib/Plan.d.ts +122 -49
  9. package/dist/lib/Plan.js +161 -37
  10. package/dist/lib/ValidationError.d.ts +38 -48
  11. package/dist/lib/ValidationError.js +30 -42
  12. package/dist/lib/ValidatorFactory.d.ts +42 -52
  13. package/dist/lib/ValidatorFactory.js +37 -48
  14. package/dist/lib/configuration-ingestor.d.ts +15 -0
  15. package/dist/lib/configuration-ingestor.js +17 -0
  16. package/dist/lib/configure.d.ts +4 -0
  17. package/dist/lib/configure.js +14 -1
  18. package/dist/lib/end-session.d.ts +3 -2
  19. package/dist/lib/end-session.js +2 -1
  20. package/dist/lib/field.d.ts +97 -35
  21. package/dist/lib/field.js +90 -41
  22. package/dist/lib/nunjucks-filters.d.ts +12 -2
  23. package/dist/lib/nunjucks-filters.js +11 -1
  24. package/dist/lib/nunjucks.d.ts +1 -0
  25. package/dist/lib/nunjucks.js +1 -0
  26. package/dist/lib/utils.d.ts +46 -14
  27. package/dist/lib/utils.js +43 -26
  28. package/dist/lib/validators/dateObject.d.ts +75 -1
  29. package/dist/lib/validators/dateObject.js +29 -18
  30. package/dist/lib/validators/email.d.ts +28 -1
  31. package/dist/lib/validators/email.js +20 -9
  32. package/dist/lib/validators/inArray.d.ts +34 -1
  33. package/dist/lib/validators/inArray.js +21 -0
  34. package/dist/lib/validators/index.js +3 -0
  35. package/dist/lib/validators/nino.d.ts +34 -1
  36. package/dist/lib/validators/nino.js +17 -7
  37. package/dist/lib/validators/postalAddressObject.d.ts +68 -1
  38. package/dist/lib/validators/postalAddressObject.js +27 -15
  39. package/dist/lib/validators/regex.d.ts +35 -1
  40. package/dist/lib/validators/regex.js +17 -7
  41. package/dist/lib/validators/required.d.ts +28 -1
  42. package/dist/lib/validators/required.js +19 -6
  43. package/dist/lib/validators/strlen.d.ts +40 -1
  44. package/dist/lib/validators/strlen.js +18 -8
  45. package/dist/lib/validators/wordCount.d.ts +40 -1
  46. package/dist/lib/validators/wordCount.js +18 -8
  47. package/dist/lib/waypoint-url.d.ts +1 -0
  48. package/dist/lib/waypoint-url.js +10 -0
  49. package/dist/middleware/data.js +21 -5
  50. package/dist/middleware/gather-fields.js +1 -0
  51. package/dist/middleware/pre.js +1 -0
  52. package/dist/middleware/steer-journey.js +2 -1
  53. package/dist/middleware/strip-proxy-path.js +6 -2
  54. package/dist/middleware/validate-fields.js +3 -0
  55. package/dist/routes/ancillary.d.ts +16 -5
  56. package/dist/routes/ancillary.js +7 -3
  57. package/dist/routes/journey.d.ts +30 -6
  58. package/dist/routes/journey.js +27 -0
  59. package/dist/routes/static.d.ts +1 -0
  60. package/dist/routes/static.js +2 -1
  61. package/package.json +16 -11
  62. package/views/casa/components/character-count/README.md +1 -1
  63. package/views/casa/components/input/README.md +1 -1
  64. package/views/casa/components/radios/README.md +2 -2
  65. package/views/casa/components/textarea/README.md +1 -1
@@ -1,7 +1,31 @@
1
- export default function journeyRouter({ globalHooks, pages, plan, csrfMiddleware, }: {
2
- globalHooks: any;
3
- pages: any;
4
- plan: any;
5
- csrfMiddleware: any;
6
- }): MutableRouter;
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";
@@ -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();
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * Create a router for serving CASA's static assets.
7
7
  *
8
+ * @access private
8
9
  * @param {StaticOptions} options Options
9
10
  * @returns {MutableRouter} ExpressJS Router instance
10
11
  */
@@ -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 : '', 'http://placeholder.test/');
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",
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.2",
53
- "i18next": "21.8.2",
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.17.12",
65
+ "@babel/core": "7.18.0",
65
66
  "@babel/eslint-parser": "7.17.0",
66
- "@babel/preset-env": "7.17.12",
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.34",
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.10",
80
+ "cheerio": "1.0.0-rc.11",
79
81
  "commitlint": "17.0.0",
80
- "eslint": "8.15.0",
81
- "eslint-plugin-no-unsafe-regex": "1.0.0",
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.51.0",
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",
@@ -11,7 +11,7 @@ Custom parameters:
11
11
  Basic example:
12
12
 
13
13
  ```nunjucks
14
- {% from "casa/components/input/macro.njk" import casaGovukInput %}
14
+ {% from "casa/components/input/macro.njk" import casaGovukInput with context %}
15
15
 
16
16
  casaGovukInput({
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",