Update dependency @ministryofjustice/hmpps-connect-dps-components to v2 #833
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^1.2.0
->^2.0.0
Release Notes
ministryofjustice/hmpps-connect-dps-components (@ministryofjustice/hmpps-connect-dps-components)
v2.0.0
: : Adding retrieveCaseLoadData middlewareCompare Source
January 2025
What's new in Version 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 ofincludeMeta
which would cause the middleware to add afeComponentsMeta
object containing extra data such as user case loads and service information tores.locals.user
as well as thefeComponents
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:
includeMeta
toincludeSharedData
feComponentsMeta
withfeComponents?.sharedData
sharedData
is a child object offeComponents
with all the same contents as was infeComponentsMeta
There is an example PR of this change being made here.
New
retrieveCaseLoadData
middlewareThe 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 someoptional middleware which populates:
res.locals.user.caseLoads
with all case loads the user has access tores.locals.user.activeCaseLoad
with the active case load of the userres.locals.user.activeCaseLoadId
with the id of the active case loadIt uses the
sharedData
object if it is present and caches inreq.session
so that any subsequent routes that do notuse 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:
As well as passing in the logger, you may optionally supply your own superagent timeoutOptions object for example:
This middleware checks the
res.locals.user.authSource
so ensure that any mock auth data used in tests includesauth_source: 'nomis'
in the response.Please also be careful that you check that your service refers to
caseLoad
and notcaseload
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.
This PR was generated by Mend Renovate. View the repository job log.