@ministryofjustice/hmpps-connect-dps-components 5.1.0 → 5.1.1

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/dist/index.d.ts CHANGED
@@ -70,11 +70,6 @@ declare class ComponentsService {
70
70
  getFrontendComponents(requestOptions?: FrontendComponentRequestOptions): RequestHandler;
71
71
  }
72
72
 
73
- type MiddlewareOptions = {
74
- requestOptions?: FrontendComponentRequestOptions;
75
- } & Parameters<typeof ComponentsService.create>[0];
76
- declare function getFrontendComponents({ logger, componentApiConfig, dpsUrl, requestOptions, }: MiddlewareOptions): RequestHandler;
77
-
78
73
  declare class PrisonApiClient extends RestClient {
79
74
  constructor(logger: ConnectDpsComponentLogger, config: ApiConfig);
80
75
  getUserCaseLoads(userToken: string): Promise<CaseLoad[]>;
@@ -91,8 +86,6 @@ declare class CaseLoadService {
91
86
  retrieveCaseLoadData(): RequestHandler;
92
87
  }
93
88
 
94
- declare function retrieveCaseLoadData({ logger, prisonApiConfig, }: Parameters<typeof CaseLoadService.create>[0]): RequestHandler;
95
-
96
89
  type AuthSource = 'nomis' | 'delius' | 'external' | 'azuread';
97
90
  /**
98
91
  * These are the details that all user types share.
@@ -142,6 +135,13 @@ declare class AllocationService {
142
135
  retrieveAllocationJobResponsibilities(): RequestHandler;
143
136
  }
144
137
 
138
+ type MiddlewareOptions = {
139
+ requestOptions?: FrontendComponentRequestOptions;
140
+ } & Parameters<typeof ComponentsService.create>[0];
141
+ declare function getFrontendComponents({ logger, componentApiConfig, dpsUrl, requestOptions, }: MiddlewareOptions): RequestHandler;
142
+
143
+ declare function retrieveCaseLoadData({ logger, prisonApiConfig, }: Parameters<typeof CaseLoadService.create>[0]): RequestHandler;
144
+
145
145
  declare function retrieveAllocationJobResponsibilities({ logger, allocationsApiConfig, authenticationClient, }: Parameters<typeof AllocationService.create>[0]): RequestHandler;
146
146
 
147
147
  export { AllocationService, CaseLoadService, ComponentsService, getFrontendComponents, retrieveAllocationJobResponsibilities, retrieveCaseLoadData };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@ministryofjustice/hmpps-connect-dps-components",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "A package to allow the inclusion of connect DPS micro frontend components within DPS applications",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.esm.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "files": [
9
- "dist/**/*"
9
+ "dist/**/*",
10
+ "scripts/**/*"
10
11
  ],
11
12
  "bin": "./scripts/install.ts",
12
13
  "scripts": {
@@ -0,0 +1,170 @@
1
+ diff --git a/assets/scss/index.scss b/assets/scss/index.scss
2
+ index 70feedd..a7cd9fd 100644
3
+ --- a/assets/scss/index.scss
4
+ +++ b/assets/scss/index.scss
5
+ @@ -6,6 +6,8 @@ $govuk-page-width: $moj-page-width;
6
+
7
+ @import "govuk-frontend/dist/govuk/index";
8
+ @import "@ministryofjustice/frontend/moj/all";
9
+ +@import "@ministryofjustice/hmpps-connect-dps-components/dist/assets/footer";
10
+ +@import "@ministryofjustice/hmpps-connect-dps-components/dist/assets/header-bar";
11
+
12
+ @import './components/header-bar';
13
+ @import './overrides/local';
14
+ diff --git a/feature.env b/feature.env
15
+ index 9a3f344..11b4654 100644
16
+ --- a/feature.env
17
+ +++ b/feature.env
18
+ @@ -1,6 +1,8 @@
19
+ PORT=3007
20
+ HMPPS_AUTH_URL=http://localhost:9091/auth
21
+ TOKEN_VERIFICATION_API_URL=http://localhost:9091/verification
22
+ +COMPONENT_API_URL=http://localhost:9091/frontend-components
23
+ +DPS_HOME_PAGE_URL=http://localhost:9091/dpshomepage
24
+ EXAMPLE_API_URL=http://localhost:9091/example-api
25
+ TOKEN_VERIFICATION_ENABLED=true
26
+ REDIS_ENABLED=false
27
+ diff --git a/helm_deploy/values-dev.yaml b/helm_deploy/values-dev.yaml
28
+ index f40e7d3..52b7431 100644
29
+ --- a/helm_deploy/values-dev.yaml
30
+ +++ b/helm_deploy/values-dev.yaml
31
+ @@ -11,6 +11,8 @@ generic-service:
32
+ INGRESS_URL: "https://template-typescript-dev.hmpps.service.justice.gov.uk"
33
+ HMPPS_AUTH_URL: "https://sign-in-dev.hmpps.service.justice.gov.uk/auth"
34
+ TOKEN_VERIFICATION_API_URL: "https://token-verification-api-dev.prison.service.justice.gov.uk"
35
+ + COMPONENT_API_URL: "https://frontend-components-dev.hmpps.service.justice.gov.uk"
36
+ + DPS_HOME_PAGE_URL: "https://digital-dev.prison.service.justice.gov.uk"
37
+ EXAMPLE_API_URL: 'https://template-kotlin-dev.hmpps.service.justice.gov.uk'
38
+ ENVIRONMENT_NAME: DEV
39
+ AUDIT_ENABLED: "false"
40
+ diff --git a/helm_deploy/values-preprod.yaml b/helm_deploy/values-preprod.yaml
41
+ index 554e19a..0d577b2 100644
42
+ --- a/helm_deploy/values-preprod.yaml
43
+ +++ b/helm_deploy/values-preprod.yaml
44
+ @@ -11,6 +11,8 @@ generic-service:
45
+ INGRESS_URL: "https://template-typescript-preprod.hmpps.service.justice.gov.uk"
46
+ HMPPS_AUTH_URL: "https://sign-in-preprod.hmpps.service.justice.gov.uk/auth"
47
+ TOKEN_VERIFICATION_API_URL: "https://token-verification-api-preprod.prison.service.justice.gov.uk"
48
+ + COMPONENT_API_URL: "https://frontend-components-preprod.hmpps.service.justice.gov.uk"
49
+ + DPS_HOME_PAGE_URL: "https://digital-preprod.prison.service.justice.gov.uk"
50
+ EXAMPLE_API_URL: 'https://template-kotlin-preprod.hmpps.service.justice.gov.uk'
51
+ ENVIRONMENT_NAME: PRE-PRODUCTION
52
+ AUDIT_ENABLED: "false"
53
+ diff --git a/helm_deploy/values-prod.yaml b/helm_deploy/values-prod.yaml
54
+ index 6bb4e41..3a2ae46 100644
55
+ --- a/helm_deploy/values-prod.yaml
56
+ +++ b/helm_deploy/values-prod.yaml
57
+ @@ -9,6 +9,8 @@ generic-service:
58
+ INGRESS_URL: "https://template-typescript.hmpps.service.justice.gov.uk"
59
+ HMPPS_AUTH_URL: "https://sign-in.hmpps.service.justice.gov.uk/auth"
60
+ TOKEN_VERIFICATION_API_URL: "https://token-verification-api.prison.service.justice.gov.uk"
61
+ + COMPONENT_API_URL: "https://frontend-components.hmpps.service.justice.gov.uk"
62
+ + DPS_HOME_PAGE_URL: "https://digital.prison.service.justice.gov.uk"
63
+ EXAMPLE_API_URL: 'https://template-kotlin.hmpps.service.justice.gov.uk'
64
+ AUDIT_ENABLED: "false"
65
+
66
+ diff --git a/server/app.ts b/server/app.ts
67
+ index eddaa67..0dfb1fe 100755
68
+ --- a/server/app.ts
69
+ +++ b/server/app.ts
70
+ @@ -1,7 +1,10 @@
71
+ import express from 'express'
72
+ +import { getFrontendComponents } from '@ministryofjustice/hmpps-connect-dps-components'
73
+
74
+ import createError from 'http-errors'
75
+
76
+ +import logger from '../logger'
77
+ +import config from './config'
78
+ import nunjucksSetup from './utils/nunjucksSetup'
79
+ import errorHandler from './errorHandler'
80
+ import { appInsightsMiddleware } from './utils/azureAppInsights'
81
+ @@ -38,6 +41,15 @@ export default function createApp(services: Services): express.Application {
82
+ app.use(setUpCsrf())
83
+ app.use(setUpCurrentUser())
84
+
85
+ + app.use(
86
+ + getFrontendComponents({
87
+ + logger,
88
+ + componentApiConfig: config.apis.componentApi,
89
+ + dpsUrl: config.serviceUrls.digitalPrison,
90
+ + requestOptions: { includeSharedData: true },
91
+ + }),
92
+ + )
93
+ +
94
+ app.use(routes(services))
95
+
96
+ app.use((req, res, next) => next(createError(404, 'Not found')))
97
+ diff --git a/server/config.ts b/server/config.ts
98
+ index e49a07b..9bbba57 100755
99
+ --- a/server/config.ts
100
+ +++ b/server/config.ts
101
+ @@ -72,6 +72,15 @@ export default {
102
+ agent: new AgentConfig(Number(get('TOKEN_VERIFICATION_API_TIMEOUT_RESPONSE', 5000))),
103
+ enabled: get('TOKEN_VERIFICATION_ENABLED', 'false') === 'true',
104
+ },
105
+ + componentApi: {
106
+ + url: get('COMPONENT_API_URL', 'http://localhost:8082', requiredInProduction),
107
+ + healthPath: '/ping',
108
+ + timeout: {
109
+ + response: Number(get('COMPONENT_API_TIMEOUT_RESPONSE', 2500)),
110
+ + deadline: Number(get('COMPONENT_API_TIMEOUT_DEADLINE', 2500)),
111
+ + },
112
+ + agent: new AgentConfig(Number(get('COMPONENT_TIMEOUT_DEADLINE', 10000))),
113
+ + },
114
+ exampleApi: {
115
+ url: get('EXAMPLE_API_URL', 'http://localhost:8080', requiredInProduction),
116
+ healthPath: '/health/ping',
117
+ @@ -82,6 +91,7 @@ export default {
118
+ agent: new AgentConfig(Number(get('EXAMPLE_API_TIMEOUT_RESPONSE', 5000))),
119
+ },
120
+ },
121
+ + serviceUrls: { digitalPrison: get('DPS_HOME_PAGE_URL', 'http://localhost:3001', requiredInProduction) },
122
+ sqs: {
123
+ audit: auditConfig(),
124
+ },
125
+ diff --git a/server/utils/nunjucksSetup.ts b/server/utils/nunjucksSetup.ts
126
+ index 1d00293..69a787c 100644
127
+ --- a/server/utils/nunjucksSetup.ts
128
+ +++ b/server/utils/nunjucksSetup.ts
129
+ @@ -30,6 +30,7 @@ export default function nunjucksSetup(app: express.Express): void {
130
+ path.join(__dirname, '../../server/views'),
131
+ 'node_modules/govuk-frontend/dist/',
132
+ 'node_modules/@ministryofjustice/frontend/',
133
+ + 'node_modules/@ministryofjustice/hmpps-connect-dps-components/dist/assets/',
134
+ ],
135
+ {
136
+ autoescape: true,
137
+ diff --git a/server/views/partials/layout.njk b/server/views/partials/layout.njk
138
+ index 63653a0..d87b07a 100644
139
+ --- a/server/views/partials/layout.njk
140
+ +++ b/server/views/partials/layout.njk
141
+ @@ -2,17 +2,28 @@
142
+
143
+ {% block head %}
144
+ <link href="{{ '/assets/css/index.css' | assetMap }}" rel="stylesheet"/>
145
+ +
146
+ + {% for js in feComponents.jsIncludes %}
147
+ + <script src="{{ js }}" nonce="{{ cspNonce }}"></script>
148
+ + {% endfor %}
149
+ + {% for css in feComponents.cssIncludes %}
150
+ + <link href="{{ css }}" nonce="{{ cspNonce }}" rel="stylesheet" />
151
+ + {% endfor %}
152
+ {% endblock %}
153
+
154
+ {% block pageTitle %}{{pageTitle | default(applicationName)}}{% endblock %}
155
+
156
+ {% block header %}
157
+ - {% include "./header.njk" %}
158
+ + {{ feComponents.header | safe }}
159
+ {% endblock %}
160
+
161
+ {% block bodyStart %}
162
+ {% endblock %}
163
+
164
+ +{% block footer %}
165
+ + {{ feComponents.footer | safe }}
166
+ +{% endblock %}
167
+ +
168
+ {% block bodyEnd %}
169
+ <script type="module" src="{{ '/assets/js/index.js' | assetMap }}"></script>
170
+ {% endblock %}