@ministryofjustice/hmpps-digital-prison-reporting-frontend 3.8.2 → 3.8.4

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.
@@ -1,12 +1,12 @@
1
1
  import AsyncReportStoreService from '../../services/requestedReportsService'
2
2
  import { AsyncReportData, RequestStatus } from '../../types/AsyncReport'
3
- import ReportingClient from '../../data/reportingClient'
4
3
  import { AsyncReportUtilsParams } from '../../types/AsyncReportUtils'
5
4
  import Dict = NodeJS.Dict
5
+ import ReportingService from '../../services/reportingService'
6
6
 
7
7
  const formatCardData = async (
8
8
  requestedReportsData: AsyncReportData,
9
- dataSources: ReportingClient,
9
+ dataSources: ReportingService,
10
10
  token: string,
11
11
  asyncReportsStore: AsyncReportStoreService,
12
12
  ): Promise<CardData> => {
@@ -71,7 +71,7 @@ const setDataFromStatus = (status: RequestStatus, requestedReportsData: AsyncRep
71
71
 
72
72
  const formatCards = async (
73
73
  asyncReportsStore: AsyncReportStoreService,
74
- dataSources: ReportingClient,
74
+ dataSources: ReportingService,
75
75
  token: string,
76
76
  ): Promise<CardData[]> => {
77
77
  const requestedReportsData: AsyncReportData[] = await asyncReportsStore.getAllReports()
@@ -67,7 +67,7 @@ exports.default = {
67
67
  const { token } = res.locals.user || 'token';
68
68
  const { reportId, variantId } = req.params;
69
69
  const { dataProductDefinitionsPath: definitionPath } = req.query;
70
- const definition = await dataSources.getDefinition(token, reportId, variantId);
70
+ const definition = await dataSources.getDefinition(token, reportId, variantId, definitionPath);
71
71
  const { name: reportName } = definition;
72
72
  const { name: variantName, description } = definition.variant;
73
73
  return {
@@ -71,7 +71,7 @@ export default {
71
71
  const { token } = res.locals.user || 'token'
72
72
  const { reportId, variantId } = req.params
73
73
  const { dataProductDefinitionsPath: definitionPath } = req.query
74
- const definition = await dataSources.getDefinition(token, reportId, variantId)
74
+ const definition = await dataSources.getDefinition(token, reportId, variantId, <string>definitionPath)
75
75
  const { name: reportName } = definition
76
76
  const { name: variantName, description } = definition.variant
77
77
 
@@ -14,7 +14,7 @@ const initDataSources = ({ req, res, next, asyncReportsStore, dataSources }) =>
14
14
  const { token } = res.locals.user || 'token';
15
15
  const { reportId, reportVariantId, tableId } = req.params;
16
16
  const { selectedPage, pageSize, dataProductDefinitionsPath } = req.query;
17
- const reportDefinitionPromise = dataSources.getDefinition(token, reportId, reportVariantId);
17
+ const reportDefinitionPromise = dataSources.getDefinition(token, reportId, reportVariantId, dataProductDefinitionsPath);
18
18
  const reportDataPromise = dataSources.getAsyncReport(token, reportId, reportVariantId, tableId, {
19
19
  selectedPage: +selectedPage,
20
20
  pageSize: +pageSize,
@@ -15,7 +15,12 @@ const initDataSources = ({ req, res, next, asyncReportsStore, dataSources }: Asy
15
15
  const { token } = res.locals.user || 'token'
16
16
  const { reportId, reportVariantId, tableId } = req.params
17
17
  const { selectedPage, pageSize, dataProductDefinitionsPath } = req.query
18
- const reportDefinitionPromise = dataSources.getDefinition(token, reportId, reportVariantId)
18
+ const reportDefinitionPromise = dataSources.getDefinition(
19
+ token,
20
+ reportId,
21
+ reportVariantId,
22
+ <string>dataProductDefinitionsPath,
23
+ )
19
24
  const reportDataPromise = dataSources.getAsyncReport(token, reportId, reportVariantId, tableId, {
20
25
  selectedPage: +selectedPage,
21
26
  pageSize: +pageSize,
@@ -3,8 +3,8 @@ import type { Router } from 'express'
3
3
  import AsyncFiltersUtils from '../components/async-filters/utils'
4
4
  import AsyncReportListUtils from '../components/async-report-list/utils'
5
5
  import AsyncPollingUtils from '../components/async-polling/utils'
6
- import ReportingClient from '../data/reportingClient'
7
6
  import AsyncReportStoreService from '../services/requestedReportsService'
7
+ import ReportingService from '../services/reportingService'
8
8
 
9
9
  export default function routes({
10
10
  router,
@@ -13,7 +13,7 @@ export default function routes({
13
13
  }: {
14
14
  router: Router
15
15
  asyncReportsStore: AsyncReportStoreService
16
- dataSources: ReportingClient
16
+ dataSources: ReportingService
17
17
  }) {
18
18
  // 1 - get filters for the report + make request
19
19
  router.get('/async-reports/:reportId/:variantId/request', async (req, res, next) => {
@@ -13,6 +13,9 @@ class ReportingService {
13
13
  async getDefinitions(token, dataProductDefinitionsPath) {
14
14
  return this.reportingClient.getDefinitions(token, dataProductDefinitionsPath);
15
15
  }
16
+ async getDefinition(token, reportId, variantId, dataProductDefinitionsPath) {
17
+ return this.reportingClient.getDefinition(token, reportId, variantId, dataProductDefinitionsPath);
18
+ }
16
19
  async requestAsyncReport(token, reportId, variantId, query) {
17
20
  return this.reportingClient.requestAsyncReport(token, reportId, variantId, query);
18
21
  }
@@ -21,6 +21,15 @@ export default class ReportingService {
21
21
  return this.reportingClient.getDefinitions(token, dataProductDefinitionsPath)
22
22
  }
23
23
 
24
+ async getDefinition(
25
+ token: string,
26
+ reportId: string,
27
+ variantId: string,
28
+ dataProductDefinitionsPath?: string,
29
+ ): Promise<components['schemas']['SingleVariantReportDefinition']> {
30
+ return this.reportingClient.getDefinition(token, reportId, variantId, dataProductDefinitionsPath)
31
+ }
32
+
24
33
  async requestAsyncReport(
25
34
  token: string,
26
35
  reportId: string,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ministryofjustice/hmpps-digital-prison-reporting-frontend",
3
3
  "description": "The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.",
4
- "version": "3.8.2",
4
+ "version": "3.8.4",
5
5
  "main": "dpr/assets/js/all.mjs",
6
6
  "sass": "dpr/all.scss",
7
7
  "engines": {
package/package.zip CHANGED
Binary file