Skip to content

[SPIKE] External components#215

Closed
alexluckett wants to merge 8 commits intomainfrom
poc/external-components
Closed

[SPIKE] External components#215
alexluckett wants to merge 8 commits intomainfrom
poc/external-components

Conversation

@alexluckett
Copy link
Copy Markdown
Contributor

@alexluckett alexluckett commented Oct 7, 2025

Proposed change

POC to explore support for components where the input is external to the form journey. Example use-cases:

  • Postcode lookup for UK addresses
  • Maps
  • GOV.UK Pay

This PR is a draft to explore an implementation. It may not reflect the final feature.

Jira ticket: DF-537

Process

  • External component is built and pushed into the codebase. External components are standard components that expose a getRoutes() method and will usually have a consistent formSchema and stateSchema.
  • On server startup, we analyse all components registered with the plugin. Any components exposing getRoutes() will have their routes collected and added to the hapi server.
  • An external component is added to a form. Component is rendered as normal from its component class and associated view. The external component displays a secondary button prompting the user to take the mini journey. This button is a submit button.
  • User completes the mini journey
  • The external component sets yar.flash('externalStateAppendage', data) where data is a JSON string containing { component: 'name-of-component', data: { ... } }. Note this was previously done with redirects ?component=""&data="{}" but I removed it to avoid manipulation by a user.
  • When preparing the form context, the engine checks for the presence of externalStateAppendage. It is parsed as a JSON string, the content is validated against the component's isState method. If successful, it is merged into the main form state.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in README.md and docs/* (where appropriate, e.g. new features).
  • The tests are passing (npm run test).
  • The linting checks are passing (npm run lint).
  • The code has been formatted (npm run format).

@alexluckett alexluckett changed the title [POC] External components [SPIKE] External components Oct 7, 2025
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
0.0% Coverage on New Code (required ≥ 90%)
5 New Major Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@alexluckett
Copy link
Copy Markdown
Contributor Author

Feature delivered under #220.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant