Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: get beta up to date with main, with additional documentation and dependency resolutions #1154

Merged
merged 13 commits into from
Nov 22, 2023
Merged
14 changes: 8 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"extends": [
"plugin:json/recommended",
"plugin:prettier/recommended"
],
"extends": ["plugin:json/recommended", "plugin:prettier/recommended"],
"plugins": ["@babel", "prettier"],
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"env": {
"browser": true,
"es6": true,
Expand Down Expand Up @@ -38,7 +35,12 @@
{
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"plugins": ["@babel", "prettier", "@typescript-eslint", "eslint-plugin-tsdoc"],
"plugins": [
"@babel",
"prettier",
"@typescript-eslint",
"eslint-plugin-tsdoc"
],
"parserOptions": {
"ecmaFeatures": { "jsx": true }
}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ jobs:
- name: "Dependency Review"
uses: actions/dependency-review-action@v2
with:
allow-ghsas: GHSA-c429-5p7v-vgjp
allow-ghsas:
- GHSA-c429-5p7v-vgjp
- GHSA-7fh5-64p2-3v2j
8 changes: 4 additions & 4 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"exclude": ["node_modules/**"],
"plugins": [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-property-in-object",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-private-property-in-object",
"@babel/plugin-transform-private-methods",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-jsx",
"@babel/plugin-proposal-logical-assignment-operators"
"@babel/plugin-transform-logical-assignment-operators"
]
}
10 changes: 5 additions & 5 deletions designer/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ module.exports = {
],
],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-private-methods",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-transform-nullish-coalescing-operator",
"@babel/plugin-transform-logical-assignment-operators",
"@babel/plugin-transform-optional-chaining",
[
"module-resolver",
{
Expand Down
35 changes: 15 additions & 20 deletions designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,20 @@
"yar": "^9.1.0"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.4",
"@babel/eslint-parser": "^7.21.3",
"@babel/eslint-plugin": "^7.19.1",
"@babel/node": "^7.20.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
"@babel/plugin-proposal-logical-assignment-operators": "^7.20.7",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/cli": "^7.23.3",
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.23.3",
"@babel/eslint-plugin": "^7.22.10",
"@babel/node": "^7.22.19",
"@babel/plugin-proposal-export-default-from": "7.23.3",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-modules-amd": "^7.20.11",
"@babel/plugin-transform-runtime": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.4",
"@babel/register": "^7.21.0",
"@babel/runtime": "^7.21.0",
"@babel/plugin-transform-modules-amd": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@babel/register": "^7.22.15",
"@babel/runtime": "^7.23.3",
"@hapi/code": "^8.0.7",
"@hapi/eslint-plugin": "^6.0.0",
"@hapi/lab": "^24.5.1",
Expand All @@ -99,7 +94,7 @@
"acorn": "8.7.0",
"autoprefixer": "^10.4.2",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.3",
"babel-loader": "^8.3.0",
"babel-plugin-module-name-mapper": "^1.2.0",
"babel-plugin-module-resolver": "^4.1.0",
"babel-plugin-transform-import-ignore": "^1.1.0",
Expand Down Expand Up @@ -128,7 +123,7 @@
"jsdom": "^19.0.0",
"lcov-result-merger": "^3.1.0",
"mini-css-extract-plugin": "^0.11.2",
"msw": "^1.2.1",
"msw": "^1.3.2",
"nodemon": "^2.0.20",
"nunjucks": "^3.2.3",
"postcss": "^8.2.4",
Expand Down
6 changes: 3 additions & 3 deletions designer/test/.transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ internals.transform = function (content, filename) {
auxiliaryCommentAfter: "$lab:coverage:on$",
plugins: [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-property-in-object",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-private-property-in-object",
"@babel/plugin-transform-private-methods",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
[
Expand Down
47 changes: 47 additions & 0 deletions docs/runner/fee-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Fee options

`feeOptions` is a top level property in a form json. Fee options are used to configure API keys for GOV.UK Pay, and the behaviour of retrying payments.


```.json5
{
// pages, sections, conditions etc ..
"feeOptions": {
/**
* If a payment is required, but the user fails, allow the user to skip payment
* and submit the form. this is the default behaviour.
*
* Any versions AFTER (and not including) v3.25.68-rc.927 allows this behaviour
* to be configurable. If you do not want payment to be skippable, set
* `allowSubmissionWithoutPayment: false`
*/
"allowSubmissionWithoutPayment": true,

/**
* The maximum number of times a user can attempt to pay before the form is auto submitted.
* There is no limit when allowSubmissionWithoutPayment is false. (The user can retry as many times as they like).
*/
"maxAttempts": 3,

/**
* A supplementary error message (`customPayErrorMessage`)
*/
"customPayErrorMessage": "Custom error message",
}
}
```

As a failsafe, if a user was not able to pay, we will allow them to try up to 3 times (`maxAttempts`), then auto submit (`"allowSubmissionWithoutPayment": true`).
This is the default behaviour. Makes sure you check your organisations policy or legislative requirements. You must ensure there is a process to remediate payment failures.

When a user fails a payment, they will see the page [pay-error](./../../runner/src/server/views/pay-error.html).

When `allowSubmissionWithoutPayment` is true, the user will also see a link which allows them to skip payment.


## Recommendations

If your service does not allow submission without payment, set
`allowSubmissionWithoutPayment: false`. `maxAttempts` will have no effect. The user will be able to retry as many times as they like.
You can provide them with `customPayErrorMessage` to provide them with another route to payment.

17 changes: 17 additions & 0 deletions docs/runner/submission-queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Submission queue

The runner can be configured to add new submissions to a queue, and for this queue to be processed by the submitter module.

By enabling the queue service this will change the webhook process, so that the runner will push the submission to a specified database, and will await a response from the submitter for a few seconds before returning the success screen to the user.

## Setup

Before enabling the queue service you will need a database instance set up which the runner can access. Once your database is set up, you can enable the queue service by configuring the following environment variables:

| Variable name | Definition | Default | Example |
| ------------------------------ | ---------------------------------------------------------------------------------------- | ------- | ------------------------------------------- |
| ENABLE_QUEUE_SERVICE | Whether the queue service is enabled or not | `false` | |
| QUEUE_DATABASE_URL | Used for configuring the endpoint of the database instance | | mysql://username:password@endpoint/database |
| QUEUE_DATABASE_USERNAME | Used for configuring the user being used to access the database | | root |
| QUEUE_DATABASE_PASSWORD | Used for configuring the password used for accessing the database | | password |
| QUEUE_SERVICE_POLLING_INTERVAL | The amount of time, in milliseconds, between poll requests for updates from the database | 500 | |
8 changes: 4 additions & 4 deletions model/babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
],
"plugins": [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-private-methods",
"@babel/plugin-transform-runtime"
],
"sourceMaps": true
Expand All @@ -34,8 +34,8 @@
],
"plugins": [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-private-methods",
"@babel/plugin-transform-runtime"
],
"sourceMaps": true
Expand Down
20 changes: 9 additions & 11 deletions model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,25 @@
},
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@babel/runtime": "^7.21.0",
"@babel/runtime": "^7.23.3",
"boom": "7.3.0",
"btoa": "^1.2.1",
"govuk-frontend": "^4.0.1",
"joi": "17.2.1"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.4",
"@babel/cli": "^7.23.3",
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.21.3",
"@babel/eslint-plugin": "^7.19.1",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-export-default-from": "^7.18.10",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@babel/eslint-plugin": "^7.22.10",
"@babel/plugin-proposal-export-default-from": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@types/jest": "^27.4.1",
"@xgovformbuilder/lab-babel": "2.1.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^29.2.0",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"depth-first": "^4.0.0",
"eslint": "^8.10.0",
Expand Down
7 changes: 7 additions & 0 deletions model/src/data-model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,11 @@ export type FormDefinition = {
payApiKey?: string | MultipleApiKeys | undefined;
specialPages?: SpecialPages;
paymentReferenceFormat?: string;
feeOptions: {
paymentReferenceFormat?: string;
payReturnUrl?: string;
allowSubmissionWithoutPayment: boolean;
maxAttempts: number;
customPayErrorMessage?: string;
};
};
8 changes: 8 additions & 0 deletions model/src/schema/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ describe("payment configuration", () => {
const configuration = {
...baseConfiguration,
feeOptions: {
allowSubmissionWithoutPayment: false,
maxAttempts: 10,
paymentReferenceFormat: "EGGS-",
payReturnUrl: "https://my.egg.service.scramble",
},
Expand All @@ -81,6 +83,8 @@ describe("payment configuration", () => {
});

expect(value.feeOptions).toEqual({
allowSubmissionWithoutPayment: false,
maxAttempts: 10,
paymentReferenceFormat: "EGGS-",
payReturnUrl: "https://my.egg.service.scramble",
});
Expand All @@ -91,6 +95,8 @@ describe("payment configuration", () => {
...baseConfiguration,
paymentReferenceFormat: "FRIED-",
feeOptions: {
allowSubmissionWithoutPayment: true,
maxAttempts: 3,
paymentReferenceFormat: "EGGS-",
payReturnUrl: "https://my.egg.service.scramble",
},
Expand All @@ -101,6 +107,8 @@ describe("payment configuration", () => {
});

expect(value.feeOptions).toEqual({
allowSubmissionWithoutPayment: true,
maxAttempts: 3,
paymentReferenceFormat: "EGGS-",
payReturnUrl: "https://my.egg.service.scramble",
});
Expand Down
3 changes: 3 additions & 0 deletions model/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ const feeOptionSchema = joi
payApiKey: [joi.string().allow("").optional(), multiApiKeySchema],
paymentReferenceFormat: [joi.string().optional()],
payReturnUrl: joi.string().optional(),
allowSubmissionWithoutPayment: joi.boolean().optional().default(true),
maxAttempts: joi.number().optional().default(3),
customPayErrorMessage: joi.string().optional(),
})
.default(({ payApiKey, paymentReferenceFormat }) => {
return {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@
"generate-architecture-diagrams": "concurrently 'npx arkit -c ./docs/designer/arkit.json' 'npx arkit -c ./docs/model/arkit.json' 'npx arkit -c ./docs/runner/arkit.json'"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.4",
"@babel/eslint-parser": "^7.21.3",
"@babel/eslint-plugin": "^7.19.1",
"@babel/plugin-proposal-logical-assignment-operators": "^7.20.7",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@babel/cli": "^7.23.3",
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.23.3",
"@babel/eslint-plugin": "^7.22.10",
"@babel/preset-env": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"babel-eslint": "^11.0.0-beta.2",
"concurrently": "^5.3.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -72,6 +70,8 @@
"hmpo-components": "^5.2.1"
},
"resolutions": {
"@babel/core": "^7.23.3",
"@babel/traverse": "^7.23.3",
"braces": "2.3.1",
"pathval": "1.1.1",
"y18n": "4.0.1",
Expand Down
12 changes: 6 additions & 6 deletions queue-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"type-check": "tsc --noEmit"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.4",
"@babel/eslint-parser": "^7.21.3",
"@babel/eslint-plugin": "^7.19.1",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@babel/cli": "^7.23.3",
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.23.3",
"@babel/eslint-plugin": "^7.22.10",
"@babel/preset-env": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@types/node": "^20.4.6",
"babel-eslint": "^10.1.0",
"eslint": "^8.10.0",
Expand Down
Loading
Loading