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

Update dependency @ministryofjustice/hmpps-connect-dps-components to v2 #833

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jan 10, 2025

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@ministryofjustice/hmpps-connect-dps-components ^1.2.0 -> ^2.0.0 age adoption passing confidence

Release Notes

ministryofjustice/hmpps-connect-dps-components (@​ministryofjustice/hmpps-connect-dps-components)

v2.0.0: : Adding retrieveCaseLoadData middleware

Compare Source

January 2025

What's new in Version 2.0.0...

npm install @​ministryofjustice/hmpps-connect-dps-components@2.0.0
Breaking changes

After some feedback we have renamed references to 'metadata' in favour of 'shared data'.

The getFrontendComponents library middleware used to accept an option of includeMeta which would cause the middleware to add a feComponentsMeta object containing extra data such as user case loads and service information to res.locals.user as well as the feComponents object containing the html/css/js.

The feedback was that this data isn't really metadata, it's data that the components needed and that can be shared, to avoid services re-requesting the same thing.

So if you were already using this data in your service, the change required is:

  • Rename includeMeta to includeSharedData
  • Replace feComponentsMeta with feComponents?.sharedData
  • Update any defined types so that sharedData is a child object of feComponents with all the same contents as was in feComponentsMeta

There is an example PR of this change being made here.

New retrieveCaseLoadData middleware

The Connect DPS team discovered that we weren't actually making use of the shared case load data in the Prisoner Profile and the new DPS Homepage and were making LOTS of unnecessary Prison API calls! So rather than reimplement the required middleware separately in each project, we added the retrieveCaseLoadData middleware here.

Many services typically add case load information to the user object on res.locals. This library provides some
optional middleware which populates:

  • res.locals.user.caseLoads with all case loads the user has access to
  • res.locals.user.activeCaseLoad with the active case load of the user
  • res.locals.user.activeCaseLoadId with the id of the active case load

It uses the sharedData object if it is present and caches in req.session so that any subsequent routes that do not
use the component middleware can still use the data. If there is no data in the cache, it will fall back to making a
call to Prison API to retrieve the data using the user token, making it resilient against any errors with the Micro Frontend
Components API call.

To enable this, add the middleware after the component middleware as follows:

app.use(dpsComponents.retrieveCaseLoadData({ logger }))

As well as passing in the logger, you may optionally supply your own superagent timeoutOptions object for example:

app.use(dpsComponents.retrieveCaseLoadData({
    logger,
    timeoutOptions: { response: 2500, deadline: 2500 }, // these are the default values
})

This middleware checks the res.locals.user.authSource so ensure that any mock auth data used in tests includes
auth_source: 'nomis' in the response.

Please also be careful that you check that your service refers to caseLoad and not caseload as there are a couple of competing versions.

There is an example PR of this middleware being introduced here.

Wait... I didn't know this library existed!

When we first introduced the Micro Frontend Components service and asked teams to integrate with it, this library didn't exist. There were many steps involved in implementing the header and footer and so we have introduced this library to make the implementation easier. For new services introducing the header and footer, please now follow this library's README for instructions instead.

For services that already incorporate the Micro Frontend Components and would like to update to use this library, there is an example PR demonstrating the process here.

Please reach out to #connect-dps-devs for help if required.

Thanks.


Configuration

📅 Schedule: Branch creation - "after 9am every weekday,before 5pm every weekday" in timezone Europe/London, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/ministryofjustice-hmpps-connect-dps-components-2.x branch 7 times, most recently from f953fb6 to 2cd8c8e Compare January 16, 2025 15:51
@renovate renovate bot force-pushed the renovate/ministryofjustice-hmpps-connect-dps-components-2.x branch 2 times, most recently from 989d542 to 704da6a Compare January 17, 2025 13:36
@renovate renovate bot force-pushed the renovate/ministryofjustice-hmpps-connect-dps-components-2.x branch from 704da6a to 8464415 Compare January 17, 2025 13:51
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.

0 participants