@defra/forms-engine-plugin 0.1.17 → 0.1.19
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/.server/config/index.js +1 -1
- package/.server/config/index.js.map +1 -1
- package/.server/server/devserver/dxt-devtool-baselayout.html +1 -1
- package/.server/server/plugins/nunjucks/context.js +8 -10
- package/.server/server/plugins/nunjucks/context.js.map +1 -1
- package/.server/server/plugins/nunjucks/types.js +0 -7
- package/.server/server/plugins/nunjucks/types.js.map +1 -1
- package/package.json +2 -1
- package/src/config/index.ts +1 -1
- package/src/server/devserver/dxt-devtool-baselayout.html +1 -1
- package/src/server/plugins/nunjucks/context.js +9 -10
- package/src/server/plugins/nunjucks/types.js +0 -7
package/.server/config/index.js
CHANGED
|
@@ -64,7 +64,7 @@ export const config = convict({
|
|
|
64
64
|
serviceName: {
|
|
65
65
|
doc: 'Applications Service Name',
|
|
66
66
|
format: String,
|
|
67
|
-
default: '
|
|
67
|
+
default: 'Digital Express Toolkit'
|
|
68
68
|
},
|
|
69
69
|
serviceVersion: {
|
|
70
70
|
doc: 'The service version, this variable is injected into your docker container in CDP environments',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["resolve","convict","isProduction","process","env","NODE_ENV","isDev","isTest","oneMinute","oneHour","config","appDir","format","String","default","import","meta","dirname","publicDir","port","doc","cdpEnvironment","enforceCsrf","Boolean","isDevelopment","serviceName","serviceVersion","nullable","feedbackLink","phaseTag","sessionTimeout","Number","confirmationSessionTimeout","sessionCookiePassword","sensitive","redis","host","username","password","keyPrefix","tracing","header","notifyTemplateId","notifyAPIKey","designerUrl","submissionUrl","uploaderUrl","uploaderBucketName","log","enabled","level","redact","Array","safelist","stagingPrefix","submissionEmailAddress","validate","allowed"],"sources":["../../src/config/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport convict, { type SchemaObj } from 'convict'\nimport { type LevelWithSilent } from 'pino'\n\nimport 'dotenv/config'\n\nconst isProduction = process.env.NODE_ENV === 'production'\nconst isDev = process.env.NODE_ENV !== 'production'\nconst isTest = process.env.NODE_ENV === 'test'\n\nconst oneMinute = 1000 * 60\nconst oneHour = oneMinute * 60\n\nexport const config = convict({\n appDir: {\n format: String,\n default: resolve(import.meta.dirname, '../server')\n },\n publicDir: {\n format: String,\n default: isTest\n ? resolve(import.meta.dirname, '../../test/fixtures')\n : resolve(import.meta.dirname, '../../.public')\n },\n\n /**\n * Server\n */\n port: {\n format: 'port',\n default: 3009,\n env: 'PORT'\n },\n env: {\n doc: 'The application environment.',\n format: ['production', 'development', 'test'],\n default: 'development',\n env: 'NODE_ENV'\n },\n cdpEnvironment: {\n doc: 'The CDP environment the app is currently in, with the addition of \"local\"',\n format: [\n 'local',\n 'infra-dev',\n 'management',\n 'dev',\n 'test',\n 'perf-test',\n 'ext-test',\n 'prod'\n ],\n default: 'local',\n env: 'ENVIRONMENT'\n },\n enforceCsrf: {\n format: Boolean,\n default: isProduction,\n env: 'ENFORCE_CSRF'\n },\n\n /**\n * Helper flags\n */\n isProduction: {\n doc: 'If this application running in the production environment',\n format: Boolean,\n default: isProduction\n },\n isDevelopment: {\n doc: 'If this application running in the development environment',\n format: Boolean,\n default: isDev\n },\n isTest: {\n doc: 'If this application running in the test environment',\n format: Boolean,\n default: isTest\n },\n\n /**\n * Service\n */\n serviceName: {\n doc: 'Applications Service Name',\n format: String,\n default: 'Submit a form to Defra'\n },\n serviceVersion: {\n doc: 'The service version, this variable is injected into your docker container in CDP environments',\n format: String,\n nullable: true,\n default: '',\n env: 'SERVICE_VERSION'\n } as SchemaObj<string>,\n feedbackLink: {\n doc: 'Used in your phase banner. Can be a URL or more commonly mailto mailto:feedback@department.gov.uk',\n format: String,\n default: '',\n env: 'FEEDBACK_LINK'\n } as SchemaObj<string>,\n phaseTag: {\n format: String,\n default: 'beta', // Accepts \"alpha\" |\"beta\" | \"\"\n env: 'PHASE_TAG'\n },\n\n /**\n * Session storage\n * Redis integration is optional, but recommended for production environments.\n */\n sessionTimeout: {\n format: Number,\n default: oneHour * 24, // 1 day\n env: 'SESSION_TIMEOUT'\n },\n confirmationSessionTimeout: {\n format: Number,\n default: oneMinute * 20,\n env: 'CONFIRMATION_SESSION_TIMEOUT'\n },\n sessionCookiePassword: {\n format: String,\n default: '',\n sensitive: true,\n env: 'SESSION_COOKIE_PASSWORD'\n } as SchemaObj<string>,\n redis: {\n host: {\n doc: 'Redis cache host',\n format: String,\n default: '',\n env: 'REDIS_HOST'\n } as SchemaObj<string>,\n username: {\n doc: 'Redis cache username',\n format: String,\n default: '',\n env: 'REDIS_USERNAME'\n } as SchemaObj<string>,\n password: {\n doc: 'Redis cache password',\n format: '*',\n default: '',\n sensitive: true,\n env: 'REDIS_PASSWORD'\n } as SchemaObj<string>,\n keyPrefix: {\n doc: 'Redis cache key prefix name used to isolate the cached results across multiple clients',\n format: String,\n default: '',\n env: 'REDIS_KEY_PREFIX'\n } as SchemaObj<string>\n },\n tracing: {\n header: {\n doc: 'Tracing header name',\n format: String,\n default: 'x-cdp-request-id',\n env: 'TRACING_HEADER'\n } as SchemaObj<string>\n },\n\n /**\n * Email outputs\n * Email outputs will use notify to send an email to a single inbox.\n */\n notifyTemplateId: {\n format: String,\n default: '',\n env: 'NOTIFY_TEMPLATE_ID'\n } as SchemaObj<string>,\n notifyAPIKey: {\n format: String,\n default: '',\n env: 'NOTIFY_API_KEY'\n } as SchemaObj<string>,\n\n /**\n * API integrations\n */\n designerUrl: {\n format: String,\n default: 'http://localhost:3000',\n env: 'DESIGNER_URL'\n } as SchemaObj<string>,\n\n submissionUrl: {\n format: String,\n default: 'http://localhost:3002',\n env: 'SUBMISSION_URL'\n } as SchemaObj<string>,\n\n uploaderUrl: {\n format: String,\n default: 'http://localhost:7337',\n env: 'UPLOADER_URL'\n } as SchemaObj<string>,\n\n uploaderBucketName: {\n format: String,\n default: 'files',\n env: 'UPLOADER_BUCKET_NAME'\n },\n\n /**\n * Logging\n */\n log: {\n enabled: {\n doc: 'Is logging enabled',\n format: Boolean,\n default: !isTest,\n env: 'LOG_ENABLED'\n },\n level: {\n doc: 'Logging level',\n format: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],\n default: 'info',\n env: 'LOG_LEVEL'\n } as SchemaObj<LevelWithSilent>,\n format: {\n doc: 'Format to output logs in.',\n format: ['ecs', 'pino-pretty'],\n default: isProduction ? 'ecs' : 'pino-pretty',\n env: 'LOG_FORMAT'\n } as SchemaObj<'ecs' | 'pino-pretty'>,\n redact: {\n doc: 'Log paths to redact',\n format: Array,\n default: isProduction\n ? ['req.headers.authorization', 'req.headers.cookie', 'res.headers']\n : ['req', 'res', 'responseTime']\n }\n },\n\n safelist: {\n format: Array,\n default: ['61bca17e-fe74-40e0-9c15-a901ad120eca.mock.pstmn.io'],\n env: 'SAFELIST'\n },\n\n stagingPrefix: {\n doc: 'Prefix for staging files in S3',\n format: String,\n default: 'staging',\n env: 'STAGING_PREFIX'\n },\n\n submissionEmailAddress: {\n doc: 'Email address to send the form to (local devtool only)',\n format: String,\n default: '',\n env: 'SUBMISSION_EMAIL_ADDRESS'\n } as SchemaObj<string>\n})\n\nconfig.validate({ allowed: 'strict' })\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,WAAW;AAEnC,OAAOC,OAAO,MAA0B,SAAS;AAGjD,OAAO,eAAe;AAEtB,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC1D,MAAMC,KAAK,GAAGH,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AACnD,MAAME,MAAM,GAAGJ,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM;AAE9C,MAAMG,SAAS,GAAG,IAAI,GAAG,EAAE;AAC3B,MAAMC,OAAO,GAAGD,SAAS,GAAG,EAAE;AAE9B,OAAO,MAAME,MAAM,GAAGT,OAAO,CAAC;EAC5BU,MAAM,EAAE;IACNC,MAAM,EAAEC,MAAM;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R,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;MACtEE,OAAO,EAAE,MAAM;MACfV,GAAG,EAAE;IACP,CAA+B;IAC/BQ,MAAM,EAAE;MACNQ,GAAG,EAAE,2BAA2B;MAChCR,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC;MAC9BE,OAAO,EAAEZ,YAAY,GAAG,KAAK,GAAG,aAAa;MAC7CE,GAAG,EAAE;IACP,CAAqC;IACrC+C,MAAM,EAAE;MACN/B,GAAG,EAAE,qBAAqB;MAC1BR,MAAM,EAAEwC,KAAK;MACbtC,OAAO,EAAEZ,YAAY,GACjB,CAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,CAAC,GAClE,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc;IACnC;EACF,CAAC;EAEDmD,QAAQ,EAAE;IACRzC,MAAM,EAAEwC,KAAK;IACbtC,OAAO,EAAE,CAAC,oDAAoD,CAAC;IAC/DV,GAAG,EAAE;EACP,CAAC;EAEDkD,aAAa,EAAE;IACblC,GAAG,EAAE,gCAAgC;IACrCR,MAAM,EAAEC,MAAM;IACdC,OAAO,EAAE,SAAS;IAClBV,GAAG,EAAE;EACP,CAAC;EAEDmD,sBAAsB,EAAE;IACtBnC,GAAG,EAAE,wDAAwD;IAC7DR,MAAM,EAAEC,MAAM;IACdC,OAAO,EAAE,EAAE;IACXV,GAAG,EAAE;EACP;AACF,CAAC,CAAC;AAEFM,MAAM,CAAC8C,QAAQ,CAAC;EAAEC,OAAO,EAAE;AAAS,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["resolve","convict","isProduction","process","env","NODE_ENV","isDev","isTest","oneMinute","oneHour","config","appDir","format","String","default","import","meta","dirname","publicDir","port","doc","cdpEnvironment","enforceCsrf","Boolean","isDevelopment","serviceName","serviceVersion","nullable","feedbackLink","phaseTag","sessionTimeout","Number","confirmationSessionTimeout","sessionCookiePassword","sensitive","redis","host","username","password","keyPrefix","tracing","header","notifyTemplateId","notifyAPIKey","designerUrl","submissionUrl","uploaderUrl","uploaderBucketName","log","enabled","level","redact","Array","safelist","stagingPrefix","submissionEmailAddress","validate","allowed"],"sources":["../../src/config/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport convict, { type SchemaObj } from 'convict'\nimport { type LevelWithSilent } from 'pino'\n\nimport 'dotenv/config'\n\nconst isProduction = process.env.NODE_ENV === 'production'\nconst isDev = process.env.NODE_ENV !== 'production'\nconst isTest = process.env.NODE_ENV === 'test'\n\nconst oneMinute = 1000 * 60\nconst oneHour = oneMinute * 60\n\nexport const config = convict({\n appDir: {\n format: String,\n default: resolve(import.meta.dirname, '../server')\n },\n publicDir: {\n format: String,\n default: isTest\n ? resolve(import.meta.dirname, '../../test/fixtures')\n : resolve(import.meta.dirname, '../../.public')\n },\n\n /**\n * Server\n */\n port: {\n format: 'port',\n default: 3009,\n env: 'PORT'\n },\n env: {\n doc: 'The application environment.',\n format: ['production', 'development', 'test'],\n default: 'development',\n env: 'NODE_ENV'\n },\n cdpEnvironment: {\n doc: 'The CDP environment the app is currently in, with the addition of \"local\"',\n format: [\n 'local',\n 'infra-dev',\n 'management',\n 'dev',\n 'test',\n 'perf-test',\n 'ext-test',\n 'prod'\n ],\n default: 'local',\n env: 'ENVIRONMENT'\n },\n enforceCsrf: {\n format: Boolean,\n default: isProduction,\n env: 'ENFORCE_CSRF'\n },\n\n /**\n * Helper flags\n */\n isProduction: {\n doc: 'If this application running in the production environment',\n format: Boolean,\n default: isProduction\n },\n isDevelopment: {\n doc: 'If this application running in the development environment',\n format: Boolean,\n default: isDev\n },\n isTest: {\n doc: 'If this application running in the test environment',\n format: Boolean,\n default: isTest\n },\n\n /**\n * Service\n */\n serviceName: {\n doc: 'Applications Service Name',\n format: String,\n default: 'Digital Express Toolkit'\n },\n serviceVersion: {\n doc: 'The service version, this variable is injected into your docker container in CDP environments',\n format: String,\n nullable: true,\n default: '',\n env: 'SERVICE_VERSION'\n } as SchemaObj<string>,\n feedbackLink: {\n doc: 'Used in your phase banner. Can be a URL or more commonly mailto mailto:feedback@department.gov.uk',\n format: String,\n default: '',\n env: 'FEEDBACK_LINK'\n } as SchemaObj<string>,\n phaseTag: {\n format: String,\n default: 'beta', // Accepts \"alpha\" |\"beta\" | \"\"\n env: 'PHASE_TAG'\n },\n\n /**\n * Session storage\n * Redis integration is optional, but recommended for production environments.\n */\n sessionTimeout: {\n format: Number,\n default: oneHour * 24, // 1 day\n env: 'SESSION_TIMEOUT'\n },\n confirmationSessionTimeout: {\n format: Number,\n default: oneMinute * 20,\n env: 'CONFIRMATION_SESSION_TIMEOUT'\n },\n sessionCookiePassword: {\n format: String,\n default: '',\n sensitive: true,\n env: 'SESSION_COOKIE_PASSWORD'\n } as SchemaObj<string>,\n redis: {\n host: {\n doc: 'Redis cache host',\n format: String,\n default: '',\n env: 'REDIS_HOST'\n } as SchemaObj<string>,\n username: {\n doc: 'Redis cache username',\n format: String,\n default: '',\n env: 'REDIS_USERNAME'\n } as SchemaObj<string>,\n password: {\n doc: 'Redis cache password',\n format: '*',\n default: '',\n sensitive: true,\n env: 'REDIS_PASSWORD'\n } as SchemaObj<string>,\n keyPrefix: {\n doc: 'Redis cache key prefix name used to isolate the cached results across multiple clients',\n format: String,\n default: '',\n env: 'REDIS_KEY_PREFIX'\n } as SchemaObj<string>\n },\n tracing: {\n header: {\n doc: 'Tracing header name',\n format: String,\n default: 'x-cdp-request-id',\n env: 'TRACING_HEADER'\n } as SchemaObj<string>\n },\n\n /**\n * Email outputs\n * Email outputs will use notify to send an email to a single inbox.\n */\n notifyTemplateId: {\n format: String,\n default: '',\n env: 'NOTIFY_TEMPLATE_ID'\n } as SchemaObj<string>,\n notifyAPIKey: {\n format: String,\n default: '',\n env: 'NOTIFY_API_KEY'\n } as SchemaObj<string>,\n\n /**\n * API integrations\n */\n designerUrl: {\n format: String,\n default: 'http://localhost:3000',\n env: 'DESIGNER_URL'\n } as SchemaObj<string>,\n\n submissionUrl: {\n format: String,\n default: 'http://localhost:3002',\n env: 'SUBMISSION_URL'\n } as SchemaObj<string>,\n\n uploaderUrl: {\n format: String,\n default: 'http://localhost:7337',\n env: 'UPLOADER_URL'\n } as SchemaObj<string>,\n\n uploaderBucketName: {\n format: String,\n default: 'files',\n env: 'UPLOADER_BUCKET_NAME'\n },\n\n /**\n * Logging\n */\n log: {\n enabled: {\n doc: 'Is logging enabled',\n format: Boolean,\n default: !isTest,\n env: 'LOG_ENABLED'\n },\n level: {\n doc: 'Logging level',\n format: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],\n default: 'info',\n env: 'LOG_LEVEL'\n } as SchemaObj<LevelWithSilent>,\n format: {\n doc: 'Format to output logs in.',\n format: ['ecs', 'pino-pretty'],\n default: isProduction ? 'ecs' : 'pino-pretty',\n env: 'LOG_FORMAT'\n } as SchemaObj<'ecs' | 'pino-pretty'>,\n redact: {\n doc: 'Log paths to redact',\n format: Array,\n default: isProduction\n ? ['req.headers.authorization', 'req.headers.cookie', 'res.headers']\n : ['req', 'res', 'responseTime']\n }\n },\n\n safelist: {\n format: Array,\n default: ['61bca17e-fe74-40e0-9c15-a901ad120eca.mock.pstmn.io'],\n env: 'SAFELIST'\n },\n\n stagingPrefix: {\n doc: 'Prefix for staging files in S3',\n format: String,\n default: 'staging',\n env: 'STAGING_PREFIX'\n },\n\n submissionEmailAddress: {\n doc: 'Email address to send the form to (local devtool only)',\n format: String,\n default: '',\n env: 'SUBMISSION_EMAIL_ADDRESS'\n } as SchemaObj<string>\n})\n\nconfig.validate({ allowed: 'strict' })\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,WAAW;AAEnC,OAAOC,OAAO,MAA0B,SAAS;AAGjD,OAAO,eAAe;AAEtB,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC1D,MAAMC,KAAK,GAAG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AACF,CAAC,CAAC;AAEFM,MAAM,CAAC8C,QAAQ,CAAC;EAAEC,OAAO,EAAE;AAAS,CAAC,CAAC","ignoreList":[]}
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
homepageUrl: currentPath if context.isForceAccess else "https://defra.github.io/forms-engine-plugin/",
|
|
37
37
|
containerClasses: "govuk-width-container",
|
|
38
38
|
productName: productName | safe | trim,
|
|
39
|
-
serviceName:
|
|
39
|
+
serviceName: config.serviceName,
|
|
40
40
|
serviceUrl: currentPath if context.isForceAccess else serviceUrl
|
|
41
41
|
}) }}
|
|
42
42
|
{% endblock %}
|
|
@@ -2,7 +2,6 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { basename, join } from 'node:path';
|
|
3
3
|
import Boom from '@hapi/boom';
|
|
4
4
|
import { StatusCodes } from 'http-status-codes';
|
|
5
|
-
import pkg from "../../../../package.json" with { type: 'json' };
|
|
6
5
|
import { config } from "../../../config/index.js";
|
|
7
6
|
import { createLogger } from "../../common/helpers/logging/logger.js";
|
|
8
7
|
import { checkFormStatus, encodeUrl, safeGenerateCrumb } from "../engine/helpers.js";
|
|
@@ -44,15 +43,6 @@ export async function context(request) {
|
|
|
44
43
|
// take consumers props first so we can override it
|
|
45
44
|
...consumerViewContext,
|
|
46
45
|
baseLayoutPath: pluginStorage.baseLayoutPath,
|
|
47
|
-
appVersion: pkg.version,
|
|
48
|
-
config: {
|
|
49
|
-
cdpEnvironment: config.get('cdpEnvironment'),
|
|
50
|
-
designerUrl: config.get('designerUrl'),
|
|
51
|
-
feedbackLink: encodeUrl(config.get('feedbackLink')),
|
|
52
|
-
phaseTag: config.get('phaseTag'),
|
|
53
|
-
serviceName: config.get('serviceName'),
|
|
54
|
-
serviceVersion: config.get('serviceVersion')
|
|
55
|
-
},
|
|
56
46
|
crumb: safeGenerateCrumb(request),
|
|
57
47
|
currentPath: `${request.path}${request.url.search}`,
|
|
58
48
|
previewMode: isPreviewMode ? formState : undefined,
|
|
@@ -77,6 +67,14 @@ export function devtoolContext(_request) {
|
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
69
|
return {
|
|
70
|
+
config: {
|
|
71
|
+
cdpEnvironment: config.get('cdpEnvironment'),
|
|
72
|
+
designerUrl: config.get('designerUrl'),
|
|
73
|
+
feedbackLink: encodeUrl(config.get('feedbackLink')),
|
|
74
|
+
phaseTag: config.get('phaseTag'),
|
|
75
|
+
serviceName: config.get('serviceName'),
|
|
76
|
+
serviceVersion: config.get('serviceVersion')
|
|
77
|
+
},
|
|
80
78
|
assetPath: '/assets',
|
|
81
79
|
getDxtAssetPath: (asset = '') => {
|
|
82
80
|
return `/${webpackManifest?.[asset] ?? asset}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["readFileSync","basename","join","Boom","StatusCodes","
|
|
1
|
+
{"version":3,"file":"context.js","names":["readFileSync","basename","join","Boom","StatusCodes","config","createLogger","checkFormStatus","encodeUrl","safeGenerateCrumb","logger","webpackManifest","context","request","params","response","isPreview","isPreviewMode","state","formState","isResponseOK","isBoom","statusCode","OK","pluginStorage","server","plugins","consumerViewContext","Error","baseLayoutPath","viewContext","ctx","crumb","currentPath","path","url","search","previewMode","undefined","slug","devtoolContext","_request","manifestPath","get","JSON","parse","error","cdpEnvironment","designerUrl","feedbackLink","phaseTag","serviceName","serviceVersion","assetPath","getDxtAssetPath","asset"],"sources":["../../../../src/server/plugins/nunjucks/context.js"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { basename, join } from 'node:path'\n\nimport Boom from '@hapi/boom'\nimport { StatusCodes } from 'http-status-codes'\n\nimport { config } from '~/src/config/index.js'\nimport { createLogger } from '~/src/server/common/helpers/logging/logger.js'\nimport {\n checkFormStatus,\n encodeUrl,\n safeGenerateCrumb\n} from '~/src/server/plugins/engine/helpers.js'\n\nconst logger = createLogger()\n\n/** @type {Record<string, string> | undefined} */\nlet webpackManifest\n\n/**\n * @param {FormRequest | FormRequestPayload | null} request\n */\nexport async function context(request) {\n const { params, response } = request ?? {}\n\n const { isPreview: isPreviewMode, state: formState } = checkFormStatus(params)\n\n // Only add the slug in to the context if the response is OK.\n // Footer meta links are not rendered when the slug is missing.\n const isResponseOK =\n !Boom.isBoom(response) && response?.statusCode === StatusCodes.OK\n\n const pluginStorage = request?.server.plugins['forms-engine-plugin']\n\n let consumerViewContext = {}\n\n if (!pluginStorage) {\n throw Error('context called before plugin registered')\n }\n\n if (!pluginStorage.baseLayoutPath) {\n throw Error('Missing baseLayoutPath in plugin.options.nunjucks')\n }\n\n if (typeof pluginStorage.viewContext === 'function') {\n consumerViewContext = await pluginStorage.viewContext(request)\n }\n\n /** @type {ViewContext} */\n const ctx = {\n // take consumers props first so we can override it\n ...consumerViewContext,\n baseLayoutPath: pluginStorage.baseLayoutPath,\n crumb: safeGenerateCrumb(request),\n currentPath: `${request.path}${request.url.search}`,\n previewMode: isPreviewMode ? formState : undefined,\n slug: isResponseOK ? params?.slug : undefined\n }\n\n return ctx\n}\n\n/**\n * Returns the context for the devtool. Consumers won't have access to this.\n * @param {FormRequest | FormRequestPayload | null} _request\n * @returns {Record<string, unknown> & { assetPath: string, getDxtAssetPath: (asset: string) => string }}\n */\nexport function devtoolContext(_request) {\n const manifestPath = join(config.get('publicDir'), 'assets-manifest.json')\n\n if (!webpackManifest) {\n try {\n // eslint-disable-next-line -- Allow JSON type 'any'\n webpackManifest = JSON.parse(readFileSync(manifestPath, 'utf-8'))\n } catch {\n logger.error(`Webpack ${basename(manifestPath)} not found`)\n }\n }\n\n return {\n config: {\n cdpEnvironment: config.get('cdpEnvironment'),\n designerUrl: config.get('designerUrl'),\n feedbackLink: encodeUrl(config.get('feedbackLink')),\n phaseTag: config.get('phaseTag'),\n serviceName: config.get('serviceName'),\n serviceVersion: config.get('serviceVersion')\n },\n assetPath: '/assets',\n getDxtAssetPath: (asset = '') => {\n return `/${webpackManifest?.[asset] ?? asset}`\n }\n }\n}\n\n/**\n * @import { ViewContext } from '~/src/server/plugins/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EAAE,KAAK;MAC/B,OAAO,IAAI5C,eAAe,GAAG4C,KAAK,CAAC,IAAIA,KAAK,EAAE;IAChD;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -11,20 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @typedef {object} ViewContext - Nunjucks view context
|
|
14
|
-
* @property {string} appVersion - Application version
|
|
15
14
|
* @property {string} [baseLayoutPath] - Base layout path
|
|
16
|
-
* @property {Partial<Config>} config - Application config properties
|
|
17
15
|
* @property {string} [crumb] - Cross-Site Request Forgery (CSRF) token
|
|
18
16
|
* @property {string} [cspNonce] - Content Security Policy (CSP) nonce
|
|
19
17
|
* @property {string} [currentPath] - Current path
|
|
20
18
|
* @property {string} [previewMode] - Preview mode
|
|
21
19
|
* @property {string} [slug] - Form slug
|
|
22
20
|
* @property {FormContext} [context] - the current form context
|
|
23
|
-
* @property {PluginOptions['viewContext']} [injectedViewContext] - the current form context
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {ReturnType<typeof config['getProperties']>} Config - Application config properties
|
|
28
21
|
*/
|
|
29
22
|
|
|
30
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/server/plugins/nunjucks/types.js"],"sourcesContent":["/**\n * @typedef {object} MacroOptions\n * @property {string} [callBlock] - Nunjucks call block content\n * @property {object} [params] - Nunjucks macro params\n */\n\n/**\n * @typedef {object} RenderOptions\n * @property {object} [context] - Nunjucks render context\n */\n\n/**\n * @typedef {object} ViewContext - Nunjucks view context\n * @property {string}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/server/plugins/nunjucks/types.js"],"sourcesContent":["/**\n * @typedef {object} MacroOptions\n * @property {string} [callBlock] - Nunjucks call block content\n * @property {object} [params] - Nunjucks macro params\n */\n\n/**\n * @typedef {object} RenderOptions\n * @property {object} [context] - Nunjucks render context\n */\n\n/**\n * @typedef {object} ViewContext - Nunjucks view context\n * @property {string} [baseLayoutPath] - Base layout path\n * @property {string} [crumb] - Cross-Site Request Forgery (CSRF) token\n * @property {string} [cspNonce] - Content Security Policy (CSP) nonce\n * @property {string} [currentPath] - Current path\n * @property {string} [previewMode] - Preview mode\n * @property {string} [slug] - Form slug\n * @property {FormContext} [context] - the current form context\n */\n\n/**\n * @typedef NunjucksContext\n * @property {ViewContext} ctx - the current nunjucks view context\n */\n\n/**\n * @import { config } from '~/src/config/index.js'\n * @import { FormContext } from '~/src/server/plugins/engine/types.js'\n * @import { PluginOptions } from '~/src/server/plugins/engine/plugin.js'\n */\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra/forms-engine-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Defra forms engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"./controllers/*": "./.server/server/plugins/engine/pageControllers/*",
|
|
26
26
|
"./services/*": "./.server/server/plugins/engine/services/*",
|
|
27
27
|
"./engine/*": "./.server/server/plugins/engine/*",
|
|
28
|
+
"./helpers.js": "./.server/server/plugins/engine/components/helpers.js",
|
|
28
29
|
"./package.json": "./package.json"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
package/src/config/index.ts
CHANGED
|
@@ -84,7 +84,7 @@ export const config = convict({
|
|
|
84
84
|
serviceName: {
|
|
85
85
|
doc: 'Applications Service Name',
|
|
86
86
|
format: String,
|
|
87
|
-
default: '
|
|
87
|
+
default: 'Digital Express Toolkit'
|
|
88
88
|
},
|
|
89
89
|
serviceVersion: {
|
|
90
90
|
doc: 'The service version, this variable is injected into your docker container in CDP environments',
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
homepageUrl: currentPath if context.isForceAccess else "https://defra.github.io/forms-engine-plugin/",
|
|
37
37
|
containerClasses: "govuk-width-container",
|
|
38
38
|
productName: productName | safe | trim,
|
|
39
|
-
serviceName:
|
|
39
|
+
serviceName: config.serviceName,
|
|
40
40
|
serviceUrl: currentPath if context.isForceAccess else serviceUrl
|
|
41
41
|
}) }}
|
|
42
42
|
{% endblock %}
|
|
@@ -4,7 +4,6 @@ import { basename, join } from 'node:path'
|
|
|
4
4
|
import Boom from '@hapi/boom'
|
|
5
5
|
import { StatusCodes } from 'http-status-codes'
|
|
6
6
|
|
|
7
|
-
import pkg from '~/package.json' with { type: 'json' }
|
|
8
7
|
import { config } from '~/src/config/index.js'
|
|
9
8
|
import { createLogger } from '~/src/server/common/helpers/logging/logger.js'
|
|
10
9
|
import {
|
|
@@ -32,6 +31,7 @@ export async function context(request) {
|
|
|
32
31
|
!Boom.isBoom(response) && response?.statusCode === StatusCodes.OK
|
|
33
32
|
|
|
34
33
|
const pluginStorage = request?.server.plugins['forms-engine-plugin']
|
|
34
|
+
|
|
35
35
|
let consumerViewContext = {}
|
|
36
36
|
|
|
37
37
|
if (!pluginStorage) {
|
|
@@ -51,15 +51,6 @@ export async function context(request) {
|
|
|
51
51
|
// take consumers props first so we can override it
|
|
52
52
|
...consumerViewContext,
|
|
53
53
|
baseLayoutPath: pluginStorage.baseLayoutPath,
|
|
54
|
-
appVersion: pkg.version,
|
|
55
|
-
config: {
|
|
56
|
-
cdpEnvironment: config.get('cdpEnvironment'),
|
|
57
|
-
designerUrl: config.get('designerUrl'),
|
|
58
|
-
feedbackLink: encodeUrl(config.get('feedbackLink')),
|
|
59
|
-
phaseTag: config.get('phaseTag'),
|
|
60
|
-
serviceName: config.get('serviceName'),
|
|
61
|
-
serviceVersion: config.get('serviceVersion')
|
|
62
|
-
},
|
|
63
54
|
crumb: safeGenerateCrumb(request),
|
|
64
55
|
currentPath: `${request.path}${request.url.search}`,
|
|
65
56
|
previewMode: isPreviewMode ? formState : undefined,
|
|
@@ -87,6 +78,14 @@ export function devtoolContext(_request) {
|
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
return {
|
|
81
|
+
config: {
|
|
82
|
+
cdpEnvironment: config.get('cdpEnvironment'),
|
|
83
|
+
designerUrl: config.get('designerUrl'),
|
|
84
|
+
feedbackLink: encodeUrl(config.get('feedbackLink')),
|
|
85
|
+
phaseTag: config.get('phaseTag'),
|
|
86
|
+
serviceName: config.get('serviceName'),
|
|
87
|
+
serviceVersion: config.get('serviceVersion')
|
|
88
|
+
},
|
|
90
89
|
assetPath: '/assets',
|
|
91
90
|
getDxtAssetPath: (asset = '') => {
|
|
92
91
|
return `/${webpackManifest?.[asset] ?? asset}`
|
|
@@ -11,20 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @typedef {object} ViewContext - Nunjucks view context
|
|
14
|
-
* @property {string} appVersion - Application version
|
|
15
14
|
* @property {string} [baseLayoutPath] - Base layout path
|
|
16
|
-
* @property {Partial<Config>} config - Application config properties
|
|
17
15
|
* @property {string} [crumb] - Cross-Site Request Forgery (CSRF) token
|
|
18
16
|
* @property {string} [cspNonce] - Content Security Policy (CSP) nonce
|
|
19
17
|
* @property {string} [currentPath] - Current path
|
|
20
18
|
* @property {string} [previewMode] - Preview mode
|
|
21
19
|
* @property {string} [slug] - Form slug
|
|
22
20
|
* @property {FormContext} [context] - the current form context
|
|
23
|
-
* @property {PluginOptions['viewContext']} [injectedViewContext] - the current form context
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {ReturnType<typeof config['getProperties']>} Config - Application config properties
|
|
28
21
|
*/
|
|
29
22
|
|
|
30
23
|
/**
|