@defra/forms-engine-plugin 0.1.9 → 0.1.11

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 (121) hide show
  1. package/.public/stylesheets/application.min.css +1 -1
  2. package/.public/stylesheets/application.min.css.map +1 -1
  3. package/.server/client/stylesheets/application.scss +10 -0
  4. package/.server/config/index.js +3 -14
  5. package/.server/config/index.js.map +1 -1
  6. package/.server/server/devserver/dxt-devtool-baselayout.html +71 -0
  7. package/.server/server/forms/register-as-a-unicorn-breeder.json +393 -0
  8. package/.server/server/forms/register-as-a-unicorn-breeder.yaml +251 -0
  9. package/.server/server/index.js +11 -16
  10. package/.server/server/index.js.map +1 -1
  11. package/.server/server/plugins/engine/configureEnginePlugin.js +16 -2
  12. package/.server/server/plugins/engine/configureEnginePlugin.js.map +1 -1
  13. package/.server/server/plugins/engine/plugin.js +27 -16
  14. package/.server/server/plugins/engine/plugin.js.map +1 -1
  15. package/.server/server/plugins/engine/services/formsService.js +15 -29
  16. package/.server/server/plugins/engine/services/formsService.js.map +1 -1
  17. package/.server/server/plugins/engine/services/localFormsService.js +52 -0
  18. package/.server/server/plugins/engine/services/localFormsService.js.map +1 -0
  19. package/.server/server/plugins/engine/views/confirmation.html +1 -1
  20. package/.server/server/plugins/engine/views/file-upload.html +1 -1
  21. package/.server/server/plugins/engine/views/index.html +1 -1
  22. package/.server/server/plugins/engine/views/item-delete.html +1 -1
  23. package/.server/server/plugins/engine/views/repeat-list-summary.html +1 -1
  24. package/.server/server/plugins/engine/views/summary.html +1 -1
  25. package/.server/server/plugins/errorPages.js +4 -26
  26. package/.server/server/plugins/errorPages.js.map +1 -1
  27. package/.server/server/plugins/nunjucks/context.js +37 -28
  28. package/.server/server/plugins/nunjucks/context.js.map +1 -1
  29. package/.server/server/plugins/nunjucks/context.test.js +23 -28
  30. package/.server/server/plugins/nunjucks/context.test.js.map +1 -1
  31. package/.server/server/plugins/nunjucks/types.js +3 -4
  32. package/.server/server/plugins/nunjucks/types.js.map +1 -1
  33. package/.server/server/routes/index.js +0 -1
  34. package/.server/server/routes/index.js.map +1 -1
  35. package/.server/server/utils/file-form-service.js +134 -0
  36. package/.server/server/utils/file-form-service.js.map +1 -0
  37. package/.server/typings/hapi/index.d.js.map +1 -1
  38. package/README.md +3 -1
  39. package/package.json +7 -3
  40. package/src/client/stylesheets/application.scss +10 -0
  41. package/src/config/index.ts +4 -17
  42. package/src/server/devserver/dxt-devtool-baselayout.html +71 -0
  43. package/src/server/forms/register-as-a-unicorn-breeder.json +393 -0
  44. package/src/server/forms/register-as-a-unicorn-breeder.yaml +251 -0
  45. package/src/server/index.test.ts +4 -37
  46. package/src/server/index.ts +13 -16
  47. package/src/server/plugins/engine/components/AutocompleteField.test.ts +5 -5
  48. package/src/server/plugins/engine/components/CheckboxesField.test.ts +7 -7
  49. package/src/server/plugins/engine/components/List.test.ts +3 -0
  50. package/src/server/plugins/engine/components/RadiosField.test.ts +5 -5
  51. package/src/server/plugins/engine/components/SelectField.test.ts +5 -5
  52. package/src/server/plugins/engine/configureEnginePlugin.ts +19 -1
  53. package/src/server/plugins/engine/pageControllers/QuestionPageController.test.ts +4 -0
  54. package/src/server/plugins/engine/plugin.ts +43 -17
  55. package/src/server/plugins/engine/services/formsService.js +17 -35
  56. package/src/server/plugins/engine/services/localFormsService.js +49 -0
  57. package/src/server/plugins/engine/views/confirmation.html +1 -1
  58. package/src/server/plugins/engine/views/file-upload.html +1 -1
  59. package/src/server/plugins/engine/views/index.html +1 -1
  60. package/src/server/plugins/engine/views/item-delete.html +1 -1
  61. package/src/server/plugins/engine/views/repeat-list-summary.html +1 -1
  62. package/src/server/plugins/engine/views/summary.html +1 -1
  63. package/src/server/plugins/errorPages.ts +4 -26
  64. package/src/server/plugins/nunjucks/context.js +41 -31
  65. package/src/server/plugins/nunjucks/context.test.js +24 -27
  66. package/src/server/plugins/nunjucks/types.js +3 -4
  67. package/src/server/routes/index.ts +0 -1
  68. package/src/server/utils/file-form-service.js +144 -0
  69. package/src/typings/hapi/index.d.ts +3 -9
  70. package/.server/common/cookies.js +0 -55
  71. package/.server/common/cookies.js.map +0 -1
  72. package/.server/common/cookies.test.js +0 -15
  73. package/.server/common/cookies.test.js.map +0 -1
  74. package/.server/common/types.js +0 -6
  75. package/.server/common/types.js.map +0 -1
  76. package/.server/server/forms/README.md +0 -10
  77. package/.server/server/forms/report-a-terrorist.json +0 -270
  78. package/.server/server/forms/runner-components-test.json +0 -365
  79. package/.server/server/forms/test.json +0 -581
  80. package/.server/server/plugins/blankie.js +0 -29
  81. package/.server/server/plugins/blankie.js.map +0 -1
  82. package/.server/server/plugins/engine/services/formsService.test.js +0 -71
  83. package/.server/server/plugins/engine/services/formsService.test.js.map +0 -1
  84. package/.server/server/plugins/engine/views/layout.html +0 -199
  85. package/.server/server/plugins/router.js +0 -169
  86. package/.server/server/plugins/router.js.map +0 -1
  87. package/.server/server/routes/health.js +0 -15
  88. package/.server/server/routes/health.js.map +0 -1
  89. package/.server/server/routes/health.test.js +0 -32
  90. package/.server/server/routes/health.test.js.map +0 -1
  91. package/.server/server/views/404.html +0 -16
  92. package/.server/server/views/500.html +0 -19
  93. package/.server/server/views/help/accessibility-statement.html +0 -58
  94. package/.server/server/views/help/cookie-preferences.html +0 -57
  95. package/.server/server/views/help/cookies.html +0 -71
  96. package/.server/server/views/help/get-support.html +0 -37
  97. package/.server/server/views/help/privacy-notice.html +0 -68
  98. package/.server/server/views/help/terms-and-conditions.html +0 -83
  99. package/src/common/cookies.js +0 -58
  100. package/src/common/cookies.test.js +0 -23
  101. package/src/common/types.js +0 -5
  102. package/src/server/forms/README.md +0 -10
  103. package/src/server/forms/report-a-terrorist.json +0 -270
  104. package/src/server/forms/runner-components-test.json +0 -365
  105. package/src/server/forms/test.json +0 -581
  106. package/src/server/plugins/blankie.test.ts +0 -73
  107. package/src/server/plugins/blankie.ts +0 -48
  108. package/src/server/plugins/engine/services/formsService.test.js +0 -90
  109. package/src/server/plugins/engine/views/layout.html +0 -199
  110. package/src/server/plugins/router.ts +0 -201
  111. package/src/server/routes/health.js +0 -13
  112. package/src/server/routes/health.test.js +0 -35
  113. package/src/server/routes/index.test.ts +0 -125
  114. package/src/server/views/404.html +0 -16
  115. package/src/server/views/500.html +0 -19
  116. package/src/server/views/help/accessibility-statement.html +0 -58
  117. package/src/server/views/help/cookie-preferences.html +0 -57
  118. package/src/server/views/help/cookies.html +0 -71
  119. package/src/server/views/help/get-support.html +0 -37
  120. package/src/server/views/help/privacy-notice.html +0 -68
  121. package/src/server/views/help/terms-and-conditions.html +0 -83
@@ -1 +0,0 @@
1
- {"version":3,"file":"formsService.test.js","names":["StatusCodes","getFormDefinition","getFormMetadata","FormStatus","getJson","fixtures","MANAGER_URL","process","env","jest","mock","describe","definition","metadata","form","beforeEach","mocked","mockResolvedValue","res","statusCode","OK","payload","it","slug","expect","toHaveBeenCalledWith","structuredClone","createdAt","toISOString","updatedAt","resolves","toEqual","any","Date","id","Draft","Live"],"sources":["../../../../../src/server/plugins/engine/services/formsService.test.js"],"sourcesContent":["import { StatusCodes } from 'http-status-codes'\n\nimport {\n getFormDefinition,\n getFormMetadata\n} from '~/src/server/plugins/engine/services/formsService.js'\nimport { FormStatus } from '~/src/server/routes/types.js'\nimport { getJson } from '~/src/server/services/httpService.js'\nimport * as fixtures from '~/test/fixtures/index.js'\n\nconst { MANAGER_URL } = process.env\n\njest.mock('~/src/server/services/httpService')\n\ndescribe('Forms service', () => {\n const { definition, metadata } = fixtures.form\n\n describe('getFormMetadata', () => {\n beforeEach(() => {\n jest.mocked(getJson).mockResolvedValue({\n res: /** @type {IncomingMessage} */ ({\n statusCode: StatusCodes.OK\n }),\n payload: metadata\n })\n })\n\n it('requests JSON via form slug', async () => {\n await getFormMetadata(metadata.slug)\n\n expect(getJson).toHaveBeenCalledWith(\n `${MANAGER_URL}/forms/slug/${metadata.slug}`\n )\n })\n\n it('coerces timestamps from string to Date', async () => {\n const payload = {\n ...structuredClone(metadata),\n\n // JSON payload uses string dates in transit\n createdAt: metadata.createdAt.toISOString(),\n updatedAt: metadata.updatedAt.toISOString()\n }\n\n jest.mocked(getJson).mockResolvedValue({\n res: /** @type {IncomingMessage} */ ({\n statusCode: StatusCodes.OK\n }),\n payload\n })\n\n await expect(getFormMetadata(metadata.slug)).resolves.toEqual({\n ...metadata,\n createdAt: expect.any(Date),\n updatedAt: expect.any(Date)\n })\n })\n })\n\n describe('getFormDefinition', () => {\n beforeEach(() => {\n jest.mocked(getJson).mockResolvedValue({\n res: /** @type {IncomingMessage} */ ({\n statusCode: StatusCodes.OK\n }),\n payload: definition\n })\n })\n\n it('requests JSON via form ID (draft)', async () => {\n await getFormDefinition(metadata.id, FormStatus.Draft)\n\n expect(getJson).toHaveBeenCalledWith(\n `${MANAGER_URL}/forms/${metadata.id}/definition/draft`\n )\n })\n\n it('requests JSON via form ID (live)', async () => {\n await getFormDefinition(metadata.id, FormStatus.Live)\n\n expect(getJson).toHaveBeenCalledWith(\n `${MANAGER_URL}/forms/${metadata.id}/definition`\n )\n })\n })\n})\n\n/**\n * @import { IncomingMessage } from 'node:http'\n */\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,mBAAmB;AAE/C,SACEC,iBAAiB,EACjBC,eAAe;AAEjB,SAASC,UAAU;AACnB,SAASC,OAAO;AAChB,OAAO,KAAKC,QAAQ;AAEpB,MAAM;EAAEC;AAAY,CAAC,GAAGC,OAAO,CAACC,GAAG;AAEnCC,IAAI,CAACC,IAAI,gCAAoC,CAAC;AAE9CC,QAAQ,CAAC,eAAe,EAAE,MAAM;EAC9B,MAAM;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGR,QAAQ,CAACS,IAAI;EAE9CH,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IAChCI,UAAU,CAAC,MAAM;MACfN,IAAI,CAACO,MAAM,CAACZ,OAAO,CAAC,CAACa,iBAAiB,CAAC;QACrCC,GAAG,GAAE,8BAAgC;UACnCC,UAAU,EAAEnB,W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AO,EAAET;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;IAEFU,EAAE,CAAC,mCAAmC,EAAE,YAAY;MAClD,MAAMrB,iBAAiB,CAACY,QAAQ,CAACqB,EAAE,EAAE/B,UAAU,CAACgC,KAAK,CAAC;MAEtDX,MAAM,CAACpB,OAAO,CAAC,CAACqB,oBAAoB,CAClC,GAAGnB,WAAW,UAAUO,QAAQ,CAACqB,EAAE,mBACrC,CAAC;IACH,CAAC,CAAC;IAEFZ,EAAE,CAAC,kCAAkC,EAAE,YAAY;MACjD,MAAMrB,iBAAiB,CAACY,QAAQ,CAACqB,EAAE,EAAE/B,UAAU,CAACiC,IAAI,CAAC;MAErDZ,MAAM,CAACpB,OAAO,CAAC,CAACqB,oBAAoB,CAClC,GAAGnB,WAAW,UAAUO,QAAQ,CAACqB,EAAE,aACrC,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC;;AAEF;AACA;AACA","ignoreList":[]}
@@ -1,199 +0,0 @@
1
- {% extends "govuk/template.njk" %}
2
-
3
- {% from "govuk/components/back-link/macro.njk" import govukBackLink -%}
4
- {% from "govuk/components/footer/macro.njk" import govukFooter -%}
5
- {% from "govuk/components/phase-banner/macro.njk" import govukPhaseBanner -%}
6
- {% from "govuk/components/skip-link/macro.njk" import govukSkipLink -%}
7
- {% from "govuk/macros/attributes.njk" import govukAttributes -%}
8
- {% from "components/service-banner/macro.njk" import appServiceBanner -%}
9
- {% from "components/tag-env/macro.njk" import appTagEnv -%}
10
- {% from "govuk/components/cookie-banner/macro.njk" import govukCookieBanner -%}
11
- {% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner -%}
12
-
13
- {% set productName %}
14
- {% if config.cdpEnvironment !== "prod" %}
15
- {{ appTagEnv({ env: config.cdpEnvironment }) }}
16
- {% endif %}
17
- {% endset %}
18
-
19
- {% block head %}
20
- <meta name="application-name" content="@defra/forms-runner" {{- govukAttributes({
21
- "data-environment": {
22
- value: config.cdpEnvironment,
23
- optional: true
24
- },
25
- "data-version": {
26
- value: config.serviceVersion,
27
- optional: true
28
- }
29
- }) }}>
30
-
31
- <link rel="preload" as="font" href="{{ assetPath }}/fonts/bold-b542beb274-v2.woff2" type="font/woff2" crossorigin="anonymous">
32
- <link rel="preload" as="font" href="{{ assetPath }}/fonts/light-94a07e06a1-v2.woff2" type="font/woff2" crossorigin="anonymous">
33
- <link rel="stylesheet" href="{{ getAssetPath("stylesheets/application.scss") }}">
34
- {% endblock %}
35
-
36
- {% block pageTitle -%}
37
- {{ "Error: " if errors | length }}{{ pageTitle | evaluate }} - {{ name if name else config.serviceName }} - GOV.UK
38
- {%- endblock %}
39
-
40
- {% block skipLink %}
41
- {{ govukSkipLink({
42
- href: '#main-content',
43
- text: 'Skip to main content'
44
- }) }}
45
- {% endblock %}
46
-
47
- {% block header %}
48
- {% if config.googleAnalyticsTrackingId and slug %}
49
- <form method="post" action="/help/cookie-preferences/{{ slug }}?returnUrl={{ currentPath | urlencode }}">
50
- <input type="hidden" name="crumb" value="{{ crumb }}">
51
-
52
- {% set acceptHtml %}
53
- <p class="govuk-body">You’ve accepted analytics cookies. You can <a class="govuk-link" href="/help/cookies/{{ slug }}">change your cookie settings</a> at any time.</p>
54
- {% endset %}
55
-
56
- {% set rejectedHtml %}
57
- <p class="govuk-body">You’ve rejected analytics cookies. You can <a class="govuk-link" href="/help/cookies/{{ slug }}">change your cookie settings</a> at any time.</p>
58
- {% endset %}
59
-
60
- {% if cookieConsent.analytics !== true and cookieConsent.analytics !== false and cookieConsent.dismissed !== true %}
61
- {% set html %}
62
- <p class="govuk-body">We use some essential cookies to make this service work.</p>
63
- <p class="govuk-body">We’d like to set analytics cookies so we can understand how people use the service and make improvements.</p>
64
- {% endset %}
65
-
66
- {{ govukCookieBanner({
67
- ariaLabel: "Cookies on " + config.serviceName,
68
- messages: [
69
- {
70
- headingText: config.serviceName,
71
- html: html,
72
- actions: [
73
- {
74
- text: "Accept analytics cookies",
75
- type: "submit",
76
- name: "cookies[analytics]",
77
- value: "yes"
78
- },
79
- {
80
- text: "Reject analytics cookies",
81
- type: "submit",
82
- name: "cookies[analytics]",
83
- value: "no"
84
- },
85
- {
86
- text: "View cookies",
87
- href: "/help/cookies/" + slug
88
- }
89
- ]
90
- }
91
- ]
92
- }) }}
93
- {% elif cookieConsent.dismissed === false %}
94
- {{ govukCookieBanner({
95
- ariaLabel: "Cookies on " + config.serviceName,
96
- messages: [
97
- {
98
- html: acceptHtml if cookieConsent.analytics === true else rejectedHtml,
99
- actions: [
100
- {
101
- text: "Hide cookie message",
102
- type: "submit",
103
- name: "cookies[dismissed]",
104
- value: "yes"
105
- }
106
- ]
107
- }
108
- ]
109
- }) }}
110
- {% endif %}
111
-
112
- </form>
113
- {% endif %}
114
-
115
- {% if config.serviceBannerText | length %}
116
- {{ appServiceBanner({
117
- title: "Service status",
118
- text: config.serviceBannerText
119
- }) }}
120
- {% endif %}
121
-
122
- {{ govukHeader({
123
- homepageUrl: currentPath if context.isForceAccess else "https://www.gov.uk",
124
- containerClasses: "govuk-width-container",
125
- productName: productName | safe | trim,
126
- serviceName: name if name else config.serviceName,
127
- serviceUrl: currentPath if context.isForceAccess else serviceUrl
128
- }) }}
129
- {% endblock %}
130
-
131
- {% block beforeContent %}
132
- {% set feedbackLink = feedbackLink or config.feedbackLink -%}
133
- {% set phaseTag = phaseTag or config.phaseTag -%}
134
-
135
- {% if phaseTag and feedbackLink %}
136
- {% set feedbackLinkHtml -%}
137
- <a href="{{ currentPath if context.isForceAccess else feedbackLink }}" class="govuk-link" {%- if not context.isForceAccess %} target="_blank" rel="noopener noreferrer" {%- endif %}>
138
- {%- if "mailto:" in feedbackLink -%}
139
- give your feedback by email
140
- {%- else -%}
141
- give your feedback (opens in new tab)
142
- {%- endif -%}
143
- </a>
144
- {%- endset %}
145
-
146
- {{ govukPhaseBanner({
147
- tag: { text: phaseTag | capitalize },
148
- html: "This is a new service. Help us improve it and " + feedbackLinkHtml | safe + "."
149
- }) }}
150
- {% endif %}
151
- {% if backLink %}
152
- {{ govukBackLink(backLink) }}
153
- {% endif %}
154
- {% endblock %}
155
-
156
- {% block content %}
157
- <h1 class="govuk-heading-l">Default page template</h1>
158
- {% endblock %}
159
-
160
- {% block bodyEnd %}
161
- <script type="module" nonce="{{ cspNonce }}" src="{{ getAssetPath("application.js") }}"></script>
162
-
163
- {% if config.googleAnalyticsTrackingId and cookieConsent.analytics === true %}
164
- <script id="ga-tag-js-main" nonce="{{ cspNonce }}" src="https://www.googletagmanager.com/gtag/js?id={{ config.googleAnalyticsTrackingId }}" defer></script>
165
- <script id="ga-tag-js-init" nonce="{{ cspNonce }}">
166
- window.dataLayer = window.dataLayer || [];
167
- function gtag(){dataLayer.push(arguments);}
168
- gtag('js', new Date());
169
- gtag('config', '{{ config.googleAnalyticsTrackingId }}');
170
- </script>
171
- {% endif %}
172
- {% endblock %}
173
-
174
- {% block footer %}
175
- {% set meta = {
176
- items: [
177
- {
178
- href: '/help/get-support/' + slug,
179
- text: 'Get help with this form'
180
- },
181
- {
182
- href: '/help/privacy/' + slug,
183
- text: 'Privacy'
184
- },
185
- {
186
- href: '/help/cookies/' + slug,
187
- text: 'Cookies'
188
- },
189
- {
190
- href: '/help/accessibility-statement/' + slug,
191
- text: 'Accessibility Statement'
192
- }
193
- ]
194
- } if slug %}
195
-
196
- {% if not context.isForceAccess %}
197
- {{ govukFooter({ meta: meta }) }}
198
- {% endif %}
199
- {% endblock %}
@@ -1,169 +0,0 @@
1
- import { slugSchema } from '@defra/forms-model';
2
- import Boom from '@hapi/boom';
3
- import humanizeDuration from 'humanize-duration';
4
- import Joi from 'joi';
5
- import { defaultConsent, parseCookieConsent, serialiseCookieConsent } from "../../common/cookies.js";
6
- import { config } from "../../config/index.js";
7
- import { isPathRelative } from "./engine/helpers.js";
8
- import { getFormMetadata } from "./engine/services/formsService.js";
9
- import { healthRoute, publicRoutes } from "../routes/index.js";
10
- import { crumbSchema } from "../schemas/index.js";
11
- const routes = [...publicRoutes, healthRoute];
12
- export default {
13
- plugin: {
14
- name: 'router',
15
- register: server => {
16
- server.route(routes);
17
-
18
- // Shared help routes params schema & options
19
- const params = Joi.object().keys({
20
- slug: slugSchema
21
- }).required();
22
- const options = {
23
- validate: {
24
- params
25
- }
26
- };
27
- server.route({
28
- method: 'get',
29
- path: '/help/get-support/{slug}',
30
- async handler(request, h) {
31
- const {
32
- slug
33
- } = request.params;
34
- const form = await getFormMetadata(slug);
35
- return h.view('help/get-support', {
36
- form
37
- });
38
- },
39
- options
40
- });
41
- server.route({
42
- method: 'get',
43
- path: '/help/privacy/{slug}',
44
- async handler(request, h) {
45
- const {
46
- slug
47
- } = request.params;
48
- const form = await getFormMetadata(slug);
49
- return h.view('help/privacy-notice', {
50
- form
51
- });
52
- },
53
- options
54
- });
55
- server.route({
56
- method: 'get',
57
- path: '/help/cookies/{slug}',
58
- handler(_request, h) {
59
- const sessionTimeout = config.get('sessionTimeout');
60
- const sessionDurationPretty = humanizeDuration(sessionTimeout);
61
- return h.view('help/cookies', {
62
- googleAnalyticsContainerId: config.get('googleAnalyticsTrackingId').replace(/^G-/, ''),
63
- sessionDurationPretty
64
- });
65
- },
66
- options
67
- });
68
- server.route({
69
- method: 'post',
70
- path: '/help/cookie-preferences/{slug}',
71
- handler(request, h) {
72
- const {
73
- params,
74
- payload,
75
- query
76
- } = request;
77
- const {
78
- slug
79
- } = params;
80
- let {
81
- returnUrl
82
- } = query;
83
- if (returnUrl && !isPathRelative(returnUrl)) {
84
- throw Boom.badRequest('Return URL must be relative');
85
- }
86
- const analyticsDecision = (payload['cookies[analytics]'] ?? '').toLowerCase();
87
- const dismissedDecision = (payload['cookies[dismissed]'] ?? '').toLowerCase();
88
-
89
- // move the parser into our JS code so we can delegate to the frontend in a future iteration
90
- let cookieConsent;
91
- if (typeof request.state.cookieConsent === 'string') {
92
- cookieConsent = parseCookieConsent(request.state.cookieConsent);
93
- } else {
94
- cookieConsent = defaultConsent;
95
- }
96
- if (analyticsDecision) {
97
- cookieConsent.analytics = analyticsDecision === 'yes';
98
- cookieConsent.dismissed = false;
99
- }
100
- if (dismissedDecision) {
101
- cookieConsent.dismissed = dismissedDecision === 'yes';
102
- }
103
- if (!returnUrl) {
104
- cookieConsent.dismissed = true; // this page already has a confirmation message, don't show another
105
- returnUrl = `/help/cookie-preferences/${slug}`;
106
- }
107
- const serialisedCookieConsent = serialiseCookieConsent(cookieConsent);
108
- h.state('cookieConsent', serialisedCookieConsent);
109
- return h.redirect(returnUrl);
110
- },
111
- options: {
112
- validate: {
113
- params,
114
- payload: Joi.object({
115
- crumb: crumbSchema,
116
- 'cookies[analytics]': Joi.string().valid('yes', 'no').optional(),
117
- 'cookies[dismissed]': Joi.string().valid('yes', 'no').optional()
118
- }),
119
- query: Joi.object({
120
- returnUrl: Joi.string().optional()
121
- })
122
- }
123
- }
124
- });
125
- server.route({
126
- method: 'get',
127
- path: '/',
128
- handler() {
129
- throw Boom.notFound();
130
- }
131
- });
132
- server.route({
133
- method: 'get',
134
- path: '/help/cookie-preferences/{slug}',
135
- handler(request, h) {
136
- const {
137
- params
138
- } = request;
139
- const {
140
- slug
141
- } = params;
142
- let cookieConsentDismissed = false;
143
- if (typeof request.state.cookieConsent === 'string') {
144
- const cookieConsent = parseCookieConsent(request.state.cookieConsent);
145
- cookieConsentDismissed = cookieConsent.dismissed;
146
- }
147
-
148
- // if the user has come back to this page after updating their preferences
149
- // override the 'dismissed' behaviour to show a success notification instead of
150
- // the cookie banner
151
- const showConsentSuccess = cookieConsentDismissed && request.info.referrer.endsWith(`/help/cookie-preferences/${slug}`);
152
- return h.view('help/cookie-preferences', {
153
- cookieConsentUpdated: showConsentSuccess
154
- });
155
- },
156
- options
157
- });
158
- server.route({
159
- method: 'get',
160
- path: '/help/accessibility-statement/{slug}',
161
- handler(_request, h) {
162
- return h.view('help/accessibility-statement');
163
- },
164
- options
165
- });
166
- }
167
- }
168
- };
169
- //# sourceMappingURL=router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.js","names":["slugSchema","Boom","humanizeDuration","Joi","defaultConsent","parseCookieConsent","serialiseCookieConsent","config","isPathRelative","getFormMetadata","healthRoute","publicRoutes","crumbSchema","routes","plugin","name","register","server","route","params","object","keys","slug","required","options","validate","method","path","handler","request","h","form","view","_request","sessionTimeout","get","sessionDurationPretty","googleAnalyticsContainerId","replace","payload","query","returnUrl","badRequest","analyticsDecision","toLowerCase","dismissedDecision","cookieConsent","state","analytics","dismissed","serialisedCookieConsent","redirect","crumb","string","valid","optional","notFound","cookieConsentDismissed","showConsentSuccess","info","referrer","endsWith","cookieConsentUpdated"],"sources":["../../../src/server/plugins/router.ts"],"sourcesContent":["import { slugSchema } from '@defra/forms-model'\nimport Boom from '@hapi/boom'\nimport { type ServerRegisterPluginObject } from '@hapi/hapi'\nimport humanizeDuration from 'humanize-duration'\nimport Joi from 'joi'\n\nimport {\n defaultConsent,\n parseCookieConsent,\n serialiseCookieConsent\n} from '~/src/common/cookies.js'\nimport { type CookieConsent } from '~/src/common/types.js'\nimport { config } from '~/src/config/index.js'\nimport { isPathRelative } from '~/src/server/plugins/engine/helpers.js'\nimport { getFormMetadata } from '~/src/server/plugins/engine/services/formsService.js'\nimport { healthRoute, publicRoutes } from '~/src/server/routes/index.js'\nimport { crumbSchema } from '~/src/server/schemas/index.js'\n\nconst routes = [...publicRoutes, healthRoute]\n\nexport default {\n plugin: {\n name: 'router',\n register: (server) => {\n server.route(routes)\n\n // Shared help routes params schema & options\n const params = Joi.object()\n .keys({\n slug: slugSchema\n })\n .required()\n\n const options = {\n validate: {\n params\n }\n }\n\n server.route<{ Params: { slug: string } }>({\n method: 'get',\n path: '/help/get-support/{slug}',\n async handler(request, h) {\n const { slug } = request.params\n const form = await getFormMetadata(slug)\n\n return h.view('help/get-support', { form })\n },\n options\n })\n\n server.route<{ Params: { slug: string } }>({\n method: 'get',\n path: '/help/privacy/{slug}',\n async handler(request, h) {\n const { slug } = request.params\n const form = await getFormMetadata(slug)\n\n return h.view('help/privacy-notice', { form })\n },\n options\n })\n\n server.route<{ Params: { slug: string } }>({\n method: 'get',\n path: '/help/cookies/{slug}',\n handler(_request, h) {\n const sessionTimeout = config.get('sessionTimeout')\n\n const sessionDurationPretty = humanizeDuration(sessionTimeout)\n\n return h.view('help/cookies', {\n googleAnalyticsContainerId: config\n .get('googleAnalyticsTrackingId')\n .replace(/^G-/, ''),\n sessionDurationPretty\n })\n },\n options\n })\n\n server.route<{\n Params: { slug: string }\n Payload: {\n crumb?: string\n 'cookies[analytics]'?: string\n 'cookies[dismissed]'?: string\n }\n Query: { returnUrl?: string }\n }>({\n method: 'post',\n path: '/help/cookie-preferences/{slug}',\n handler(request, h) {\n const { params, payload, query } = request\n const { slug } = params\n let { returnUrl } = query\n\n if (returnUrl && !isPathRelative(returnUrl)) {\n throw Boom.badRequest('Return URL must be relative')\n }\n\n const analyticsDecision = (\n payload['cookies[analytics]'] ?? ''\n ).toLowerCase()\n\n const dismissedDecision = (\n payload['cookies[dismissed]'] ?? ''\n ).toLowerCase()\n\n // move the parser into our JS code so we can delegate to the frontend in a future iteration\n let cookieConsent: CookieConsent\n\n if (typeof request.state.cookieConsent === 'string') {\n cookieConsent = parseCookieConsent(request.state.cookieConsent)\n } else {\n cookieConsent = defaultConsent\n }\n\n if (analyticsDecision) {\n cookieConsent.analytics = analyticsDecision === 'yes'\n cookieConsent.dismissed = false\n }\n\n if (dismissedDecision) {\n cookieConsent.dismissed = dismissedDecision === 'yes'\n }\n\n if (!returnUrl) {\n cookieConsent.dismissed = true // this page already has a confirmation message, don't show another\n returnUrl = `/help/cookie-preferences/${slug}`\n }\n\n const serialisedCookieConsent = serialiseCookieConsent(cookieConsent)\n h.state('cookieConsent', serialisedCookieConsent)\n\n return h.redirect(returnUrl)\n },\n options: {\n validate: {\n params,\n payload: Joi.object({\n crumb: crumbSchema,\n 'cookies[analytics]': Joi.string().valid('yes', 'no').optional(),\n 'cookies[dismissed]': Joi.string().valid('yes', 'no').optional()\n }),\n query: Joi.object({\n returnUrl: Joi.string().optional()\n })\n }\n }\n })\n\n server.route({\n method: 'get',\n path: '/',\n handler() {\n throw Boom.notFound()\n }\n })\n\n server.route<{ Params: { slug: string } }>({\n method: 'get',\n path: '/help/cookie-preferences/{slug}',\n handler(request, h) {\n const { params } = request\n const { slug } = params\n let cookieConsentDismissed = false\n\n if (typeof request.state.cookieConsent === 'string') {\n const cookieConsent = parseCookieConsent(\n request.state.cookieConsent\n )\n\n cookieConsentDismissed = cookieConsent.dismissed\n }\n\n // if the user has come back to this page after updating their preferences\n // override the 'dismissed' behaviour to show a success notification instead of\n // the cookie banner\n const showConsentSuccess =\n cookieConsentDismissed &&\n request.info.referrer.endsWith(`/help/cookie-preferences/${slug}`)\n\n return h.view('help/cookie-preferences', {\n cookieConsentUpdated: showConsentSuccess\n })\n },\n options\n })\n\n server.route<{ Params: { slug: string } }>({\n method: 'get',\n path: '/help/accessibility-statement/{slug}',\n handler(_request, h) {\n return h.view('help/accessibility-statement')\n },\n options\n })\n }\n }\n} satisfies ServerRegisterPluginObject<void>\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C,OAAOC,IAAI,MAAM,YAAY;AAE7B,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,GAAG,MAAM,KAAK;AAErB,SACEC,cAAc,EACdC,kBAAkB,EAClBC,sBAAsB;AAGxB,SAASC,MAAM;AACf,SAASC,cAAc;AACvB,SAASC,eAAe;AACxB,SAASC,WAAW,EAAEC,YAAY;AAClC,SAASC,WAAW;AAEpB,MAAMC,MAAM,GAAG,CAAC,GAAGF,YAAY,EAAED,WAAW,CAAC;AAE7C,eAAe;EACbI,MAAM,EAAE;IACNC,IAAI,EAAE,QAAQ;IACdC,QAAQ,EAAGC,MAAM,IAAK;MACpBA,MAAM,CAACC,KAAK,CAACL,MAAM,CAAC;;MAEpB;MACA,MAAMM,MAAM,GAAGhB,GAAG,CAACiB,MAAM,CAAC,CAAC,CACxBC,IAAI,CAAC;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OAAO,CAACkB,KAAK,CAACD,aAAa,KAAK,QAAQ,EAAE;YACnD,MAAMA,aAAa,GAAGzC,kBAAkB,CACtCwB,OAAO,CAACkB,KAAK,CAACD,aAChB,CAAC;YAEDW,sBAAsB,GAAGX,aAAa,CAACG,SAAS;UAClD;;UAEA;UACA;UACA;UACA,MAAMS,kBAAkB,GACtBD,sBAAsB,IACtB5B,OAAO,CAAC8B,IAAI,CAACC,QAAQ,CAACC,QAAQ,CAAC,4BAA4BvC,IAAI,EAAE,CAAC;UAEpE,OAAOQ,CAAC,CAACE,IAAI,CAAC,yBAAyB,EAAE;YACvC8B,oBAAoB,EAAEJ;UACxB,CAAC,CAAC;QACJ,CAAC;QACDlC;MACF,CAAC,CAAC;MAEFP,MAAM,CAACC,KAAK,CAA+B;QACzCQ,MAAM,EAAE,KAAK;QACbC,IAAI,EAAE,sCAAsC;QAC5CC,OAAOA,CAACK,QAAQ,EAAEH,CAAC,EAAE;UACnB,OAAOA,CAAC,CAACE,IAAI,CAAC,8BAA8B,CAAC;QAC/C,CAAC;QACDR;MACF,CAAC,CAAC;IACJ;EACF;AACF,CAAC","ignoreList":[]}
@@ -1,15 +0,0 @@
1
- import { StatusCodes } from 'http-status-codes';
2
- export default (/** @type {ServerRoute} */{
3
- method: 'GET',
4
- path: '/health',
5
- handler(_, h) {
6
- return h.response({
7
- message: 'success'
8
- }).code(StatusCodes.OK);
9
- }
10
- });
11
-
12
- /**
13
- * @import { ServerRoute } from '@hapi/hapi'
14
- */
15
- //# sourceMappingURL=health.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"health.js","names":["StatusCodes","method","path","handler","_","h","response","message","code","OK"],"sources":["../../../src/server/routes/health.js"],"sourcesContent":["import { StatusCodes } from 'http-status-codes'\n\nexport default /** @type {ServerRoute} */ ({\n method: 'GET',\n path: '/health',\n handler(_, h) {\n return h.response({ message: 'success' }).code(StatusCodes.OK)\n }\n})\n\n/**\n * @import { ServerRoute } from '@hapi/hapi'\n */\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,mBAAmB;AAE/C,gBAAe,0BAA4B;EACzCC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,SAAS;EACfC,OAAOA,CAACC,CAAC,EAAEC,CAAC,EAAE;IACZ,OAAOA,CAAC,CAACC,QAAQ,CAAC;MAAEC,OAAO,EAAE;IAAU,CAAC,CAAC,CAACC,IAAI,CAACR,WAAW,CAACS,EAAE,CAAC;EAChE;AACF,CAAC;;AAED;AACA;AACA","ignoreList":[]}
@@ -1,32 +0,0 @@
1
- import { createServer } from "../index.js";
2
- describe('Health check route', () => {
3
- const startServer = async () => {
4
- const server = await createServer();
5
- await server.initialize();
6
- return server;
7
- };
8
-
9
- /** @type {Server} */
10
- let server;
11
- afterEach(async () => {
12
- await server.stop();
13
- });
14
- test('/health route response is correct', async () => {
15
- server = await startServer();
16
- const options = {
17
- method: 'GET',
18
- url: '/health'
19
- };
20
- const {
21
- result
22
- } = await server.inject(options);
23
- expect(result).toMatchObject({
24
- message: 'success'
25
- });
26
- });
27
- });
28
-
29
- /**
30
- * @import { Server } from '@hapi/hapi'
31
- */
32
- //# sourceMappingURL=health.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"health.test.js","names":["createServer","describe","startServer","server","initialize","afterEach","stop","test","options","method","url","result","inject","expect","toMatchObject","message"],"sources":["../../../src/server/routes/health.test.js"],"sourcesContent":["import { createServer } from '~/src/server/index.js'\n\ndescribe('Health check route', () => {\n const startServer = async () => {\n const server = await createServer()\n await server.initialize()\n return server\n }\n\n /** @type {Server} */\n let server\n\n afterEach(async () => {\n await server.stop()\n })\n\n test('/health route response is correct', async () => {\n server = await startServer()\n\n const options = {\n method: 'GET',\n url: '/health'\n }\n\n const { result } = await server.inject(options)\n\n expect(result).toMatchObject({\n message: 'success'\n })\n })\n})\n\n/**\n * @import { Server } from '@hapi/hapi'\n */\n"],"mappings":"AAAA,SAASA,YAAY;AAErBC,QAAQ,CAAC,oBAAoB,EAAE,MAAM;EACnC,MAAMC,WAAW,GAAG,MAAAA,CAAA,KAAY;IAC9B,MAAMC,MAAM,GAAG,MAAMH,YAAY,CAAC,CAAC;IACnC,MAAMG,MAAM,CAACC,UAAU,CAAC,CAAC;IACzB,OAAOD,MAAM;EACf,CAAC;;EAED;EACA,IAAIA,MAAM;EAEVE,SAAS,CAAC,YAAY;IACpB,MAAMF,MAAM,CAACG,IAAI,CAAC,CAAC;EACrB,CAAC,CAAC;EAEFC,IAAI,CAAC,mCAAmC,EAAE,YAAY;IACpDJ,MAAM,GAAG,MAAMD,WAAW,CAAC,CAAC;IAE5B,MAAMM,OAAO,GAAG;MACdC,MAAM,EAAE,KAAK;MACbC,GAAG,EAAE;IACP,CAAC;IAED,MAAM;MAAEC;IAAO,CAAC,GAAG,MAAMR,MAAM,CAACS,MAAM,CAACJ,OAAO,CAAC;IAE/CK,MAAM,CAACF,MAAM,CAAC,CAACG,aAAa,CAAC;MAC3BC,OAAO,EAAE;IACX,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC;;AAEF;AACA;AACA","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- {% extends 'layout.html' %}
2
-
3
- {% block content %}
4
- <div class="govuk-width-container">
5
- <div class="govuk-main-wrapper">
6
- <div class="govuk-grid-row">
7
- <div class="govuk-grid-column-two-thirds">
8
- <h1 class="govuk-heading-l">Page not found</h1>
9
- <p class="govuk-body">If you typed the web address, check it is correct.</p>
10
- <p class="govuk-body">If you pasted the web address, check you copied the entire address.</p>
11
- <p class="govuk-body">If the web address is correct or you selected a link or button, <a href="https://www.gov.uk/guidance/contact-defra" class="govuk-link">contact the Defra Helpline</a> if you need to speak to someone about your form.</p>
12
- </div>
13
- </div>
14
- </div>
15
- </div>
16
- {% endblock %}
@@ -1,19 +0,0 @@
1
- {% extends 'layout.html' %}
2
-
3
- {% block content %}
4
- <div class="govuk-width-container">
5
- <div class="govuk-main-wrapper">
6
- <div class="govuk-grid-row">
7
- <div class="govuk-grid-column-two-thirds">
8
- <h1 class="govuk-heading-l">Sorry, there is a problem with the service</h1>
9
- <p class="govuk-body">You can:</p>
10
- <ul class="govuk-list govuk-list--bullet">
11
- <li>try your browser back button as your data may be saved</li>
12
- <li><a class="govuk-link" href="https://www.gov.uk/guidance/contact-defra">contact the Defra Helpline</a> if you
13
- have any questions</li>
14
- </ul>
15
- </div>
16
- </div>
17
- </div>
18
- </div>
19
- {% endblock %}
@@ -1,58 +0,0 @@
1
- {% extends 'layout.html' %}
2
-
3
- {% set pageTitle = "Accessibility statement" %}
4
-
5
- {% block content %}
6
- <div class="govuk-grid-row">
7
- <div class="govuk-grid-column-two-thirds">
8
- <h1 class="govuk-heading-l">Accessibility statement for this form</h1>
9
- <p class="govuk-body">This accessibility statement applies to online forms with a URL that starts with
10
- https://submit-forms-to-defra.service.gov.uk.</p>
11
-
12
- <h2 class="govuk-heading-m">Technical information about this website’s accessibility</h2>
13
- <p class="govuk-body">Defra is committed to making its forms accessible, in accordance with the Public Sector Bodies
14
- (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018.</p>
15
-
16
- <h2 class="govuk-heading-m">Compliance status</h2>
17
- <p class="govuk-body">Forms created by Defra are fully compliant with the Web Content Accessibility Guidelines
18
- (WCAG) version 2.2 AA standard.</p>
19
-
20
- <h2 class="govuk-heading-m">How accessible this website is</h2>
21
- <p class="govuk-body">This section lists accessibility issues with content found in Defra forms.</p>
22
-
23
- <h3 class="govuk-heading-s">Non-compliance with the accessibility regulations</h3>
24
- <p class="govuk-body">Defra forms do not have accessibility issues that fail the WCAG 2.2 accessibility regulations.</p>
25
-
26
- <h3 class="govuk-heading-s">Content that’s not within the scope of the accessibility regulations</h3>
27
- <p class="govuk-body">The accessibility issues listed in this section do not fail the accessibility regulations. We
28
- plan to fix them as soon as possible.</p>
29
- <ul class="govuk-list govuk-list--number">
30
- <li>Forms do not default to a dark or light theme based on the ‘prefers-color-scheme’.</li>
31
- <li>The email field allows for the entry of values that are not formatted as an email address.</li>
32
- <li>The summary screen for each form does not display the question asked. Instead, it displays a summarised version of
33
- the question.</li>
34
- <li>Some optional questions are not marked as optional.</li>
35
- <li>Section titles in some forms are formatted as H2 level headings. These headings are shown before page titles
36
- which are formatted as H1 level headings (skipped heading hierarchy).</li>
37
- </ul>
38
-
39
- <h2 class="govuk-heading-m">Preparation of this accessibility statement</h2>
40
- <p class="govuk-body">This statement was prepared on 24 June 2024. It was last reviewed on 26 June 2024.</p>
41
- <p class="govuk-body">The Defra Accessibility team tested 2 online forms against the WCAG 2.2 AA standard on 17 June
42
- 2024. The tests were done using automated testing tools.</p>
43
- <p class="govuk-body">We will commission a full accessibility audit of forms created by Defra before April 2025.</p>
44
-
45
- <h2 class="govuk-heading-m">Feedback and contact information</h2>
46
- <p class="govuk-body">If you find any problems not listed on this page or think we’re not meeting accessibility
47
- requirements, email the Defra Forms team on <a class="govuk-link"
48
- href="mailto:defraforms@defra.gov.uk">defraforms@defra.gov.uk</a>.</p>
49
-
50
- <h2 class="govuk-heading-m">Enforcement procedure</h2>
51
- <p class="govuk-body">The Equality and Human Rights Commission (EHRC) is responsible for enforcing the Public Sector
52
- Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018 (the ‘accessibility
53
- regulations’). If you’re not happy with how we respond to your complaint, contact the <a class="govuk-link"
54
- href="https://www.equalityadvisoryservice.com/" rel="external">Equality Advisory and Support Service (EASS)</a>.
55
- </p>
56
- </div>
57
- </div>
58
- {% endblock %}
@@ -1,57 +0,0 @@
1
- {% extends "layout.html" %}
2
-
3
- {% from "govuk/components/radios/macro.njk" import govukRadios %}
4
- {% from "govuk/components/button/macro.njk" import govukButton %}
5
- {% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner -%}
6
-
7
- {% set pageTitle = "Cookies" %}
8
-
9
- {% block content %}
10
- <div class="govuk-grid-row">
11
- <div class="govuk-grid-column-two-thirds">
12
- {% if cookieConsentUpdated %}
13
- {% set notificationHtml %}
14
- <p class="govuk-notification-banner__heading">
15
- You’ve set your cookie preferences.
16
- </p>
17
- {% endset %}
18
-
19
- {{ govukNotificationBanner({
20
- type: "success",
21
- html: notificationHtml
22
- }) }}
23
- {% endif %}
24
-
25
- <h2 class="govuk-heading-l">Change your cookie settings</h2>
26
-
27
- <form method="post" novalidate>
28
- <input type="hidden" name="crumb" value="{{ crumb }}">
29
-
30
- {{ govukRadios({
31
- name: "cookies[analytics]",
32
- fieldset: {
33
- legend: {
34
- text: "Do you want to accept analytics cookies?",
35
- classes: "govuk-fieldset__legend--s"
36
- }
37
- },
38
- items: [
39
- {
40
- value: "yes",
41
- text: "Yes"
42
- },
43
- {
44
- value: "no",
45
- text: "No"
46
- }
47
- ],
48
- value: "yes" if cookieConsent.analytics === true else "no"
49
- }) }}
50
-
51
- {{ govukButton({
52
- text: "Save cookie settings"
53
- }) }}
54
- </form>
55
- </div>
56
- </div>
57
- {% endblock %}