@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.23.2 → 4.25.0

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.
Files changed (53) hide show
  1. package/dpr/all.scss +1 -1
  2. package/dpr/components/_filters/filters-help/view.njk +9 -8
  3. package/dpr/components/_reports/report/view.njk +10 -3
  4. package/dpr/components/_reports/report-summary-table/styles.scss +1 -1
  5. package/dpr/components/_reports/report-template/view.njk +2 -2
  6. package/dpr/data/dprReportingClient.js +1 -1
  7. package/dpr/data/dprReportingClient.js.map +3 -3
  8. package/dpr/data/dprReportingClient.ts +6 -3
  9. package/dpr/data/types.d.js +1 -1
  10. package/dpr/data/types.d.js.map +1 -1
  11. package/dpr/data/types.d.ts +6 -0
  12. package/dpr/middleware/setUpDprResources.js +1 -1
  13. package/dpr/middleware/setUpDprResources.js.map +3 -3
  14. package/dpr/middleware/setUpDprResources.test.ts +11 -0
  15. package/dpr/middleware/setUpDprResources.ts +37 -2
  16. package/dpr/routes/journeys/download-report/tests.cy.js +1 -1
  17. package/dpr/routes/journeys/download-report/tests.cy.js.map +3 -3
  18. package/dpr/routes/journeys/download-report/tests.cy.ts +1 -1
  19. package/dpr/routes/journeys/my-reports/bookmarks/list/tests.cy.js +1 -1
  20. package/dpr/routes/journeys/my-reports/bookmarks/list/tests.cy.js.map +3 -3
  21. package/dpr/routes/journeys/my-reports/bookmarks/list/tests.cy.ts +1 -1
  22. package/dpr/routes/journeys/product-collection/selected/tests.cy.js +1 -1
  23. package/dpr/routes/journeys/product-collection/selected/tests.cy.js.map +3 -3
  24. package/dpr/routes/journeys/product-collection/selected/tests.cy.ts +2 -2
  25. package/dpr/routes/journeys/request-report/filters/tests.cy.js +1 -1
  26. package/dpr/routes/journeys/request-report/filters/tests.cy.js.map +3 -3
  27. package/dpr/routes/journeys/request-report/filters/tests.cy.ts +3 -4
  28. package/dpr/routes/journeys/request-report/filters/view.njk +2 -2
  29. package/dpr/routes/journeys/request-report/status/tests.cy.js +1 -1
  30. package/dpr/routes/journeys/request-report/status/tests.cy.js.map +3 -3
  31. package/dpr/routes/journeys/request-report/status/tests.cy.ts +1 -1
  32. package/dpr/routes/journeys/view-report/async/report/report-variants.cy.js +2 -0
  33. package/dpr/routes/journeys/view-report/async/report/report-variants.cy.js.map +7 -0
  34. package/dpr/routes/journeys/view-report/async/report/report-variants.cy.ts +96 -0
  35. package/dpr/services/featureFlagService.js +2 -0
  36. package/dpr/services/featureFlagService.js.map +7 -0
  37. package/dpr/services/featureFlagService.ts +43 -0
  38. package/dpr/services/featureFlags.cy.js +2 -0
  39. package/dpr/services/featureFlags.cy.js.map +7 -0
  40. package/dpr/services/featureFlags.cy.ts +93 -0
  41. package/dpr/types/Services.d.js +1 -1
  42. package/dpr/types/Services.d.js.map +1 -1
  43. package/dpr/types/Services.d.ts +2 -0
  44. package/dpr/types/express.d.js +2 -0
  45. package/dpr/types/express.d.js.map +7 -0
  46. package/dpr/types/express.d.ts +14 -0
  47. package/dpr/utils/CreateDprServices.js +1 -1
  48. package/dpr/utils/CreateDprServices.js.map +2 -2
  49. package/dpr/utils/CreateDprServices.ts +4 -0
  50. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.js +1 -1
  51. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.js.map +1 -1
  52. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.ts +1 -1
  53. package/package.json +4 -5
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/dpr/services/featureFlags.cy.ts"],
4
+ "sourcesContent": ["import { executeReportStubs } from 'cypress-tests/cypressUtils'\nimport { resetFeatureFlags } from 'test-app/routes/integrationTests/appStateUtils'\n\ncontext('Viewing a report', () => {\n const path = '/embedded/platform/'\n\n // Do a reset so that any tests after this re-query for feature flags\n after(() => {\n cy.task('stubFeatureFlags')\n resetFeatureFlags()\n })\n\n describe('Feature flags', () => {\n beforeEach(() => {\n executeReportStubs()\n cy.task('stubDefinitionRequestExamplesSuccess')\n cy.task('stubRequestSuccessResult20')\n resetFeatureFlags()\n })\n\n it('should show the ability to save filters as default with feature flag enabled', () => {\n cy.task('stubFeatureFlags')\n\n cy.visit(path)\n cy.findByLabelText(/Reports catalogue.*/i).within(() => {\n cy.findByRole('row', {\n name: (_, element) => {\n return (\n Boolean(element?.textContent?.includes('Successful Report')) &&\n Boolean(element?.textContent?.includes('this will succeed'))\n )\n },\n }).within(() => {\n cy.findByRole('link', { name: 'Request report' }).click()\n })\n })\n\n cy.findByRole('button', { name: /Save current filter values as defaults/ }).should('be.visible')\n const helpSummary = cy.contains('summary', /Help/)\n helpSummary.click()\n helpSummary.parent('details').invoke('attr', 'open').should('exist')\n cy.findByRole('heading', { name: /Save current filter values as defaults/ }).should('be.visible')\n })\n\n it('should show the ability to save filters as default with feature flag not existing', () => {\n cy.task('stubFeatureFlagsEmpty')\n\n cy.visit(path)\n cy.findByLabelText(/Reports catalogue.*/i).within(() => {\n cy.findByRole('row', {\n name: (_, element) => {\n return (\n Boolean(element?.textContent?.includes('Successful Report')) &&\n Boolean(element?.textContent?.includes('this will succeed'))\n )\n },\n }).within(() => {\n cy.findByRole('link', { name: 'Request report' }).click()\n })\n })\n\n cy.findByRole('button', { name: /Save current filter values as defaults/ }).should('be.visible')\n const helpSummary = cy.contains('summary', /Help/)\n helpSummary.click()\n helpSummary.parent('details').invoke('attr', 'open').should('exist')\n cy.findByRole('heading', { name: /Save current filter values as defaults/ }).should('be.visible')\n })\n\n it('should not show the ability to save filters as default with feature flag disabled', () => {\n cy.task('stubFeatureFlagsDisabled')\n\n cy.visit(path)\n cy.findByLabelText(/Reports catalogue.*/i).within(() => {\n cy.findByRole('row', {\n name: (_, element) => {\n return (\n Boolean(element?.textContent?.includes('Successful Report')) &&\n Boolean(element?.textContent?.includes('this will succeed'))\n )\n },\n }).within(() => {\n cy.findByRole('link', { name: 'Request report' }).click()\n })\n })\n\n cy.findByRole('button', { name: /Save current filter values as defaults/ }).should('not.exist')\n const helpSummary = cy.contains('summary', /Help/)\n helpSummary.click()\n helpSummary.parent('details').invoke('attr', 'open').should('exist')\n cy.findByRole('heading', { name: /Save current filter values as defaults/ }).should('not.exist')\n })\n })\n})\n"],
5
+ "mappings": "aAAA,IAAAA,EAAmC,sCACnCC,EAAkC,0DAElC,QAAQ,mBAAoB,IAAM,CAChC,MAAMC,EAAO,sBAGb,MAAM,IAAM,CACV,GAAG,KAAK,kBAAkB,KAC1B,qBAAkB,CACpB,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,WAAW,IAAM,IACf,sBAAmB,EACnB,GAAG,KAAK,sCAAsC,EAC9C,GAAG,KAAK,4BAA4B,KACpC,qBAAkB,CACpB,CAAC,EAED,GAAG,+EAAgF,IAAM,CACvF,GAAG,KAAK,kBAAkB,EAE1B,GAAG,MAAMA,CAAI,EACb,GAAG,gBAAgB,sBAAsB,EAAE,OAAO,IAAM,CACtD,GAAG,WAAW,MAAO,CACnB,KAAM,CAACC,EAAGC,IAEN,EAAQA,GAAS,aAAa,SAAS,mBAAmB,GAC1D,EAAQA,GAAS,aAAa,SAAS,mBAAmB,CAGhE,CAAC,EAAE,OAAO,IAAM,CACd,GAAG,WAAW,OAAQ,CAAE,KAAM,gBAAiB,CAAC,EAAE,MAAM,CAC1D,CAAC,CACH,CAAC,EAED,GAAG,WAAW,SAAU,CAAE,KAAM,wCAAyC,CAAC,EAAE,OAAO,YAAY,EAC/F,MAAMC,EAAc,GAAG,SAAS,UAAW,MAAM,EACjDA,EAAY,MAAM,EAClBA,EAAY,OAAO,SAAS,EAAE,OAAO,OAAQ,MAAM,EAAE,OAAO,OAAO,EACnE,GAAG,WAAW,UAAW,CAAE,KAAM,wCAAyC,CAAC,EAAE,OAAO,YAAY,CAClG,CAAC,EAED,GAAG,oFAAqF,IAAM,CAC5F,GAAG,KAAK,uBAAuB,EAE/B,GAAG,MAAMH,CAAI,EACb,GAAG,gBAAgB,sBAAsB,EAAE,OAAO,IAAM,CACtD,GAAG,WAAW,MAAO,CACnB,KAAM,CAACC,EAAGC,IAEN,EAAQA,GAAS,aAAa,SAAS,mBAAmB,GAC1D,EAAQA,GAAS,aAAa,SAAS,mBAAmB,CAGhE,CAAC,EAAE,OAAO,IAAM,CACd,GAAG,WAAW,OAAQ,CAAE,KAAM,gBAAiB,CAAC,EAAE,MAAM,CAC1D,CAAC,CACH,CAAC,EAED,GAAG,WAAW,SAAU,CAAE,KAAM,wCAAyC,CAAC,EAAE,OAAO,YAAY,EAC/F,MAAMC,EAAc,GAAG,SAAS,UAAW,MAAM,EACjDA,EAAY,MAAM,EAClBA,EAAY,OAAO,SAAS,EAAE,OAAO,OAAQ,MAAM,EAAE,OAAO,OAAO,EACnE,GAAG,WAAW,UAAW,CAAE,KAAM,wCAAyC,CAAC,EAAE,OAAO,YAAY,CAClG,CAAC,EAED,GAAG,oFAAqF,IAAM,CAC5F,GAAG,KAAK,0BAA0B,EAElC,GAAG,MAAMH,CAAI,EACb,GAAG,gBAAgB,sBAAsB,EAAE,OAAO,IAAM,CACtD,GAAG,WAAW,MAAO,CACnB,KAAM,CAACC,EAAGC,IAEN,EAAQA,GAAS,aAAa,SAAS,mBAAmB,GAC1D,EAAQA,GAAS,aAAa,SAAS,mBAAmB,CAGhE,CAAC,EAAE,OAAO,IAAM,CACd,GAAG,WAAW,OAAQ,CAAE,KAAM,gBAAiB,CAAC,EAAE,MAAM,CAC1D,CAAC,CACH,CAAC,EAED,GAAG,WAAW,SAAU,CAAE,KAAM,wCAAyC,CAAC,EAAE,OAAO,WAAW,EAC9F,MAAMC,EAAc,GAAG,SAAS,UAAW,MAAM,EACjDA,EAAY,MAAM,EAClBA,EAAY,OAAO,SAAS,EAAE,OAAO,OAAQ,MAAM,EAAE,OAAO,OAAO,EACnE,GAAG,WAAW,UAAW,CAAE,KAAM,wCAAyC,CAAC,EAAE,OAAO,WAAW,CACjG,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_cypressUtils", "import_appStateUtils", "path", "_", "element", "helpSummary"]
7
+ }
@@ -0,0 +1,93 @@
1
+ import { executeReportStubs } from 'cypress-tests/cypressUtils'
2
+ import { resetFeatureFlags } from 'test-app/routes/integrationTests/appStateUtils'
3
+
4
+ context('Viewing a report', () => {
5
+ const path = '/embedded/platform/'
6
+
7
+ // Do a reset so that any tests after this re-query for feature flags
8
+ after(() => {
9
+ cy.task('stubFeatureFlags')
10
+ resetFeatureFlags()
11
+ })
12
+
13
+ describe('Feature flags', () => {
14
+ beforeEach(() => {
15
+ executeReportStubs()
16
+ cy.task('stubDefinitionRequestExamplesSuccess')
17
+ cy.task('stubRequestSuccessResult20')
18
+ resetFeatureFlags()
19
+ })
20
+
21
+ it('should show the ability to save filters as default with feature flag enabled', () => {
22
+ cy.task('stubFeatureFlags')
23
+
24
+ cy.visit(path)
25
+ cy.findByLabelText(/Reports catalogue.*/i).within(() => {
26
+ cy.findByRole('row', {
27
+ name: (_, element) => {
28
+ return (
29
+ Boolean(element?.textContent?.includes('Successful Report')) &&
30
+ Boolean(element?.textContent?.includes('this will succeed'))
31
+ )
32
+ },
33
+ }).within(() => {
34
+ cy.findByRole('link', { name: 'Request report' }).click()
35
+ })
36
+ })
37
+
38
+ cy.findByRole('button', { name: /Save current filter values as defaults/ }).should('be.visible')
39
+ const helpSummary = cy.contains('summary', /Help/)
40
+ helpSummary.click()
41
+ helpSummary.parent('details').invoke('attr', 'open').should('exist')
42
+ cy.findByRole('heading', { name: /Save current filter values as defaults/ }).should('be.visible')
43
+ })
44
+
45
+ it('should show the ability to save filters as default with feature flag not existing', () => {
46
+ cy.task('stubFeatureFlagsEmpty')
47
+
48
+ cy.visit(path)
49
+ cy.findByLabelText(/Reports catalogue.*/i).within(() => {
50
+ cy.findByRole('row', {
51
+ name: (_, element) => {
52
+ return (
53
+ Boolean(element?.textContent?.includes('Successful Report')) &&
54
+ Boolean(element?.textContent?.includes('this will succeed'))
55
+ )
56
+ },
57
+ }).within(() => {
58
+ cy.findByRole('link', { name: 'Request report' }).click()
59
+ })
60
+ })
61
+
62
+ cy.findByRole('button', { name: /Save current filter values as defaults/ }).should('be.visible')
63
+ const helpSummary = cy.contains('summary', /Help/)
64
+ helpSummary.click()
65
+ helpSummary.parent('details').invoke('attr', 'open').should('exist')
66
+ cy.findByRole('heading', { name: /Save current filter values as defaults/ }).should('be.visible')
67
+ })
68
+
69
+ it('should not show the ability to save filters as default with feature flag disabled', () => {
70
+ cy.task('stubFeatureFlagsDisabled')
71
+
72
+ cy.visit(path)
73
+ cy.findByLabelText(/Reports catalogue.*/i).within(() => {
74
+ cy.findByRole('row', {
75
+ name: (_, element) => {
76
+ return (
77
+ Boolean(element?.textContent?.includes('Successful Report')) &&
78
+ Boolean(element?.textContent?.includes('this will succeed'))
79
+ )
80
+ },
81
+ }).within(() => {
82
+ cy.findByRole('link', { name: 'Request report' }).click()
83
+ })
84
+ })
85
+
86
+ cy.findByRole('button', { name: /Save current filter values as defaults/ }).should('not.exist')
87
+ const helpSummary = cy.contains('summary', /Help/)
88
+ helpSummary.click()
89
+ helpSummary.parent('details').invoke('attr', 'open').should('exist')
90
+ cy.findByRole('heading', { name: /Save current filter values as defaults/ }).should('not.exist')
91
+ })
92
+ })
93
+ })
@@ -1,2 +1,2 @@
1
- "use strict";var t=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(r,e,c,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!l.call(r,i)&&i!==c&&t(r,i,{get:()=>e[i],enumerable:!(o=S(e,i))||o.enumerable});return r};var n=r=>s(t({},"__esModule",{value:!0}),r);var d={};module.exports=n(d);
1
+ "use strict";var t=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(r,e,c,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!l.call(r,i)&&i!==c&&t(r,i,{get:()=>e[i],enumerable:!(o=S(e,i))||o.enumerable});return r};var a=r=>s(t({},"__esModule",{value:!0}),r);var n={};module.exports=a(n);
2
2
  //# sourceMappingURL=Services.d.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dpr/types/Services.d.ts"],
4
- "sourcesContent": ["import {\n BookmarkService,\n DefaultFilterValuesService,\n DownloadPermissionService,\n RecentlyViewedStoreService,\n RequestedReportService,\n} from '../services'\nimport { ProductCollectionStoreService } from '../services/productCollection/productCollectionStoreService'\nimport MissingReportService from '../services/missingReport/missingReportService'\nimport ReportingService from '../services/reportingService'\nimport DashboardService from '../services/dashboardService'\nimport { ProductCollectionService } from '../services/productCollection/productCollectionService'\n\nexport type Services = UserStoreServices & {\n reportingService: ReportingService\n dashboardService: DashboardService\n missingReportService: MissingReportService\n productCollectionService: ProductCollectionService\n}\n\nexport interface UserStoreServices {\n downloadPermissionService: DownloadPermissionService\n requestedReportService: RequestedReportService\n recentlyViewedService: RecentlyViewedStoreService\n bookmarkService: BookmarkService\n defaultFilterValuesService: DefaultFilterValuesService\n productCollectionStoreService: ProductCollectionStoreService\n}\n"],
4
+ "sourcesContent": ["import {\n BookmarkService,\n DefaultFilterValuesService,\n DownloadPermissionService,\n RecentlyViewedStoreService,\n RequestedReportService,\n} from '../services'\nimport { ProductCollectionStoreService } from '../services/productCollection/productCollectionStoreService'\nimport MissingReportService from '../services/missingReport/missingReportService'\nimport ReportingService from '../services/reportingService'\nimport DashboardService from '../services/dashboardService'\nimport { ProductCollectionService } from '../services/productCollection/productCollectionService'\nimport { FeatureFlagService } from '../services/featureFlagService'\n\nexport type Services = UserStoreServices & {\n reportingService: ReportingService\n dashboardService: DashboardService\n missingReportService: MissingReportService\n productCollectionService: ProductCollectionService\n featureFlagService: FeatureFlagService\n}\n\nexport interface UserStoreServices {\n downloadPermissionService: DownloadPermissionService\n requestedReportService: RequestedReportService\n recentlyViewedService: RecentlyViewedStoreService\n bookmarkService: BookmarkService\n defaultFilterValuesService: DefaultFilterValuesService\n productCollectionStoreService: ProductCollectionStoreService\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["Services_d_exports", "__toCommonJS"]
7
7
  }
@@ -10,12 +10,14 @@ import MissingReportService from '../services/missingReport/missingReportService
10
10
  import ReportingService from '../services/reportingService'
11
11
  import DashboardService from '../services/dashboardService'
12
12
  import { ProductCollectionService } from '../services/productCollection/productCollectionService'
13
+ import { FeatureFlagService } from '../services/featureFlagService'
13
14
 
14
15
  export type Services = UserStoreServices & {
15
16
  reportingService: ReportingService
16
17
  dashboardService: DashboardService
17
18
  missingReportService: MissingReportService
18
19
  productCollectionService: ProductCollectionService
20
+ featureFlagService: FeatureFlagService
19
21
  }
20
22
 
21
23
  export interface UserStoreServices {
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var o=(e,a,g,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of f(a))!m.call(e,l)&&l!==g&&s(e,l,{get:()=>a[l],enumerable:!(r=t(a,l))||r.enumerable});return e};var p=e=>o(s({},"__esModule",{value:!0}),e);var c={};module.exports=p(c);
2
+ //# sourceMappingURL=express.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/dpr/types/express.d.ts"],
4
+ "sourcesContent": ["import { Flag } from '@flipt-io/flipt'\n\nexport declare global {\n namespace Express {\n interface Locals {\n featureFlags: {\n lastUpdated: number\n flags: {\n [flagName: string]: Flag\n }\n }\n }\n }\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["express_d_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,14 @@
1
+ import { Flag } from '@flipt-io/flipt'
2
+
3
+ export declare global {
4
+ namespace Express {
5
+ interface Locals {
6
+ featureFlags: {
7
+ lastUpdated: number
8
+ flags: {
9
+ [flagName: string]: Flag
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.create;var n=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var g=(r,e)=>{for(var t in e)n(r,t,{get:e[t],enumerable:!0})},l=(r,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!f.call(r,o)&&o!==t&&n(r,o,{get:()=>e[o],enumerable:!(c=R(e,o))||c.enumerable});return r};var w=(r,e,t)=>(t=r!=null?m(u(r)):{},l(e||!r||!r.__esModule?n(t,"default",{value:r,enumerable:!0}):t,r)),D=r=>l(n({},"__esModule",{value:!0}),r);var b={};g(b,{createDprServices:()=>P});module.exports=D(b);var i=require("../services"),s=w(require("./logger")),S=require("../services/missingReport/missingReportService"),a=require("../services/productCollection/productCollectionStoreService"),v=require("../services/productCollection/productCollectionService");const P=(r,e={bookmarking:!1,download:!1,collections:!1,missingReports:!1,saveDefaults:!1})=>{s.default.info("Initialising DPR services...");const{reportingClient:t,dashboardClient:c,reportDataStore:o,missingReportClient:p,productCollectionClient:d}=r;return{reportingService:new i.ReportingService(t),dashboardService:new i.DashboardService(c),requestedReportService:new i.RequestedReportService(o),recentlyViewedService:new i.RecentlyViewedStoreService(o),bookmarkService:new i.BookmarkService(o,e),defaultFilterValuesService:new i.DefaultFilterValuesService(o,e),productCollectionStoreService:new a.ProductCollectionStoreService(o,e),downloadPermissionService:new i.DownloadPermissionService(o,e),missingReportService:new S.MissingReportService(p,e),productCollectionService:new v.ProductCollectionService(d,e)}};0&&(module.exports={createDprServices});
1
+ "use strict";var m=Object.create;var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var C=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},n=(r,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of f(e))!R.call(r,o)&&o!==t&&l(r,o,{get:()=>e[o],enumerable:!(c=u(e,o))||c.enumerable});return r};var w=(r,e,t)=>(t=r!=null?m(g(r)):{},n(e||!r||!r.__esModule?l(t,"default",{value:r,enumerable:!0}):t,r)),D=r=>n(l({},"__esModule",{value:!0}),r);var b={};C(b,{createDprServices:()=>P});module.exports=D(b);var i=require("../services"),S=w(require("./logger")),s=require("../services/missingReport/missingReportService"),a=require("../services/productCollection/productCollectionStoreService"),v=require("../services/productCollection/productCollectionService");const P=(r,e={bookmarking:!1,download:!1,collections:!1,missingReports:!1,saveDefaults:!1})=>{S.default.info("Initialising DPR services...");const{reportingClient:t,dashboardClient:c,reportDataStore:o,missingReportClient:p,productCollectionClient:d}=r;return{reportingService:new i.ReportingService(t),dashboardService:new i.DashboardService(c),requestedReportService:new i.RequestedReportService(o),recentlyViewedService:new i.RecentlyViewedStoreService(o),bookmarkService:new i.BookmarkService(o,e),defaultFilterValuesService:new i.DefaultFilterValuesService(o,e),productCollectionStoreService:new a.ProductCollectionStoreService(o,e),downloadPermissionService:new i.DownloadPermissionService(o,e),missingReportService:new s.MissingReportService(p,e),productCollectionService:new v.ProductCollectionService(d,e),featureFlagService:r.featureFlagService}};0&&(module.exports={createDprServices});
2
2
  //# sourceMappingURL=CreateDprServices.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dpr/utils/CreateDprServices.ts"],
4
- "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport {\n DownloadPermissionService,\n BookmarkService,\n RequestedReportService,\n RecentlyViewedStoreService,\n ReportingService,\n DashboardService,\n DefaultFilterValuesService,\n} from '../services'\nimport ReportDataStore from '../data/reportDataStore'\nimport ReportingClient from '../data/reportingClient'\nimport DashboardClient from '../data/dashboardClient'\nimport MissingReportClient from '../data/missingReportClient'\nimport ProductCollectionClient from '../data/productCollectionClient'\nimport logger from './logger'\nimport { Services } from '../types/Services'\nimport { MissingReportService } from '../services/missingReport/missingReportService'\nimport { ProductCollectionStoreService } from '../services/productCollection/productCollectionStoreService'\nimport { ProductCollectionService } from '../services/productCollection/productCollectionService'\nimport { ServiceFeatureConfig } from '../types/DprConfig'\n\nexport interface InitDPRServicesArgs {\n reportingClient: ReportingClient\n dashboardClient: DashboardClient\n reportDataStore: ReportDataStore\n missingReportClient: MissingReportClient\n productCollectionClient: ProductCollectionClient\n}\n\ninterface dprServices {\n reportingService: ReportingService\n dashboardService: DashboardService\n productCollectionService: ProductCollectionService\n requestedReportService: RequestedReportService\n missingReportService: MissingReportService\n recentlyViewedService: RecentlyViewedStoreService\n bookmarkService: BookmarkService\n downloadPermissionService: DownloadPermissionService\n defaultFilterValuesService: DefaultFilterValuesService\n productCollectionStoreService: ProductCollectionStoreService\n}\n\nexport const createDprServices = (\n clients: InitDPRServicesArgs,\n serviceFeatureConfig: ServiceFeatureConfig = {\n bookmarking: false,\n download: false,\n collections: false,\n missingReports: false,\n saveDefaults: false,\n },\n): Services => {\n logger.info('Initialising DPR services...')\n\n const { reportingClient, dashboardClient, reportDataStore, missingReportClient, productCollectionClient } = clients\n const services: dprServices = {\n reportingService: new ReportingService(reportingClient),\n dashboardService: new DashboardService(dashboardClient),\n\n requestedReportService: new RequestedReportService(reportDataStore),\n recentlyViewedService: new RecentlyViewedStoreService(reportDataStore),\n bookmarkService: new BookmarkService(reportDataStore, serviceFeatureConfig),\n\n defaultFilterValuesService: new DefaultFilterValuesService(reportDataStore, serviceFeatureConfig),\n productCollectionStoreService: new ProductCollectionStoreService(reportDataStore, serviceFeatureConfig),\n downloadPermissionService: new DownloadPermissionService(reportDataStore, serviceFeatureConfig),\n\n missingReportService: new MissingReportService(missingReportClient, serviceFeatureConfig),\n productCollectionService: new ProductCollectionService(productCollectionClient, serviceFeatureConfig),\n }\n return services as Services\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAQO,uBAMPC,EAAmB,uBAEnBC,EAAqC,0DACrCC,EAA8C,uEAC9CC,EAAyC,kEAwBlC,MAAMN,EAAoB,CAC/BO,EACAC,EAA6C,CAC3C,YAAa,GACb,SAAU,GACV,YAAa,GACb,eAAgB,GAChB,aAAc,EAChB,IACa,CACb,EAAAC,QAAO,KAAK,8BAA8B,EAE1C,KAAM,CAAE,gBAAAC,EAAiB,gBAAAC,EAAiB,gBAAAC,EAAiB,oBAAAC,EAAqB,wBAAAC,CAAwB,EAAIP,EAgB5G,MAf8B,CAC5B,iBAAkB,IAAI,mBAAiBG,CAAe,EACtD,iBAAkB,IAAI,mBAAiBC,CAAe,EAEtD,uBAAwB,IAAI,yBAAuBC,CAAe,EAClE,sBAAuB,IAAI,6BAA2BA,CAAe,EACrE,gBAAiB,IAAI,kBAAgBA,EAAiBJ,CAAoB,EAE1E,2BAA4B,IAAI,6BAA2BI,EAAiBJ,CAAoB,EAChG,8BAA+B,IAAI,gCAA8BI,EAAiBJ,CAAoB,EACtG,0BAA2B,IAAI,4BAA0BI,EAAiBJ,CAAoB,EAE9F,qBAAsB,IAAI,uBAAqBK,EAAqBL,CAAoB,EACxF,yBAA0B,IAAI,2BAAyBM,EAAyBN,CAAoB,CACtG,CAEF",
4
+ "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport {\n DownloadPermissionService,\n BookmarkService,\n RequestedReportService,\n RecentlyViewedStoreService,\n ReportingService,\n DashboardService,\n DefaultFilterValuesService,\n} from '../services'\nimport ReportDataStore from '../data/reportDataStore'\nimport ReportingClient from '../data/reportingClient'\nimport DashboardClient from '../data/dashboardClient'\nimport MissingReportClient from '../data/missingReportClient'\nimport ProductCollectionClient from '../data/productCollectionClient'\nimport logger from './logger'\nimport { Services } from '../types/Services'\nimport { MissingReportService } from '../services/missingReport/missingReportService'\nimport { ProductCollectionStoreService } from '../services/productCollection/productCollectionStoreService'\nimport { ProductCollectionService } from '../services/productCollection/productCollectionService'\nimport { ServiceFeatureConfig } from '../types/DprConfig'\nimport { FeatureFlagService } from '../services/featureFlagService'\n\nexport interface InitDPRServicesArgs {\n reportingClient: ReportingClient\n dashboardClient: DashboardClient\n reportDataStore: ReportDataStore\n missingReportClient: MissingReportClient\n productCollectionClient: ProductCollectionClient\n featureFlagService: FeatureFlagService\n}\n\ninterface dprServices {\n reportingService: ReportingService\n dashboardService: DashboardService\n productCollectionService: ProductCollectionService\n requestedReportService: RequestedReportService\n missingReportService: MissingReportService\n recentlyViewedService: RecentlyViewedStoreService\n bookmarkService: BookmarkService\n downloadPermissionService: DownloadPermissionService\n defaultFilterValuesService: DefaultFilterValuesService\n productCollectionStoreService: ProductCollectionStoreService\n featureFlagService: FeatureFlagService\n}\n\nexport const createDprServices = (\n clients: InitDPRServicesArgs,\n serviceFeatureConfig: ServiceFeatureConfig = {\n bookmarking: false,\n download: false,\n collections: false,\n missingReports: false,\n saveDefaults: false,\n },\n): Services => {\n logger.info('Initialising DPR services...')\n\n const { reportingClient, dashboardClient, reportDataStore, missingReportClient, productCollectionClient } = clients\n const services: dprServices = {\n reportingService: new ReportingService(reportingClient),\n dashboardService: new DashboardService(dashboardClient),\n\n requestedReportService: new RequestedReportService(reportDataStore),\n recentlyViewedService: new RecentlyViewedStoreService(reportDataStore),\n bookmarkService: new BookmarkService(reportDataStore, serviceFeatureConfig),\n\n defaultFilterValuesService: new DefaultFilterValuesService(reportDataStore, serviceFeatureConfig),\n productCollectionStoreService: new ProductCollectionStoreService(reportDataStore, serviceFeatureConfig),\n downloadPermissionService: new DownloadPermissionService(reportDataStore, serviceFeatureConfig),\n\n missingReportService: new MissingReportService(missingReportClient, serviceFeatureConfig),\n productCollectionService: new ProductCollectionService(productCollectionClient, serviceFeatureConfig),\n featureFlagService: clients.featureFlagService,\n }\n return services as Services\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAQO,uBAMPC,EAAmB,uBAEnBC,EAAqC,0DACrCC,EAA8C,uEAC9CC,EAAyC,kEA2BlC,MAAMN,EAAoB,CAC/BO,EACAC,EAA6C,CAC3C,YAAa,GACb,SAAU,GACV,YAAa,GACb,eAAgB,GAChB,aAAc,EAChB,IACa,CACb,EAAAC,QAAO,KAAK,8BAA8B,EAE1C,KAAM,CAAE,gBAAAC,EAAiB,gBAAAC,EAAiB,gBAAAC,EAAiB,oBAAAC,EAAqB,wBAAAC,CAAwB,EAAIP,EAiB5G,MAhB8B,CAC5B,iBAAkB,IAAI,mBAAiBG,CAAe,EACtD,iBAAkB,IAAI,mBAAiBC,CAAe,EAEtD,uBAAwB,IAAI,yBAAuBC,CAAe,EAClE,sBAAuB,IAAI,6BAA2BA,CAAe,EACrE,gBAAiB,IAAI,kBAAgBA,EAAiBJ,CAAoB,EAE1E,2BAA4B,IAAI,6BAA2BI,EAAiBJ,CAAoB,EAChG,8BAA+B,IAAI,gCAA8BI,EAAiBJ,CAAoB,EACtG,0BAA2B,IAAI,4BAA0BI,EAAiBJ,CAAoB,EAE9F,qBAAsB,IAAI,uBAAqBK,EAAqBL,CAAoB,EACxF,yBAA0B,IAAI,2BAAyBM,EAAyBN,CAAoB,EACpG,mBAAoBD,EAAQ,kBAC9B,CAEF",
6
6
  "names": ["CreateDprServices_exports", "__export", "createDprServices", "__toCommonJS", "import_services", "import_logger", "import_missingReportService", "import_productCollectionStoreService", "import_productCollectionService", "clients", "serviceFeatureConfig", "logger", "reportingClient", "dashboardClient", "reportDataStore", "missingReportClient", "productCollectionClient"]
7
7
  }
@@ -19,6 +19,7 @@ import { MissingReportService } from '../services/missingReport/missingReportSer
19
19
  import { ProductCollectionStoreService } from '../services/productCollection/productCollectionStoreService'
20
20
  import { ProductCollectionService } from '../services/productCollection/productCollectionService'
21
21
  import { ServiceFeatureConfig } from '../types/DprConfig'
22
+ import { FeatureFlagService } from '../services/featureFlagService'
22
23
 
23
24
  export interface InitDPRServicesArgs {
24
25
  reportingClient: ReportingClient
@@ -26,6 +27,7 @@ export interface InitDPRServicesArgs {
26
27
  reportDataStore: ReportDataStore
27
28
  missingReportClient: MissingReportClient
28
29
  productCollectionClient: ProductCollectionClient
30
+ featureFlagService: FeatureFlagService
29
31
  }
30
32
 
31
33
  interface dprServices {
@@ -39,6 +41,7 @@ interface dprServices {
39
41
  downloadPermissionService: DownloadPermissionService
40
42
  defaultFilterValuesService: DefaultFilterValuesService
41
43
  productCollectionStoreService: ProductCollectionStoreService
44
+ featureFlagService: FeatureFlagService
42
45
  }
43
46
 
44
47
  export const createDprServices = (
@@ -68,6 +71,7 @@ export const createDprServices = (
68
71
 
69
72
  missingReportService: new MissingReportService(missingReportClient, serviceFeatureConfig),
70
73
  productCollectionService: new ProductCollectionService(productCollectionClient, serviceFeatureConfig),
74
+ featureFlagService: clients.featureFlagService,
71
75
  }
72
76
  return services as Services
73
77
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.create;var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var g=(a,i)=>{for(var t in i)o(a,t,{get:i[t],enumerable:!0})},h=(a,i,t,d)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of u(i))!F.call(a,e)&&e!==t&&o(a,e,{get:()=>i[e],enumerable:!(d=f(i,e))||d.enumerable});return a};var y=(a,i,t)=>(t=a!=null?p(D(a)):{},h(i||!a||!a.__esModule?o(t,"default",{value:a,enumerable:!0}):t,a)),C=a=>h(o({},"__esModule",{value:!0}),a);var T={};g(T,{SectionedFieldsDataTableBuilder:()=>c,default:()=>S});module.exports=C(T);var m=y(require("../ParentChildDataTableBuilder/ParentChildDataTableBuilder"));class c extends m.default{constructor(i){const{sectionedFields:t,template:d}=i.specification;super(i),this.sectionedFields=t,this.sections=this.sectionedFields.map(e=>e.name),this.template=d,this.childVariants=this.variant.childVariants||[]}getChildFields(i){const t=this.childVariants.find(e=>e.id===i);let d=[];if(t){const{specification:e}=t;d=e?e.fields:d}return d}getJoinKey(){return this.childVariants[0].joinFields[0]}initSectionedData(i){return i.flatMap(t=>this.sectionedFields.map(e=>{const s=this.mapNamesToFields([e.name])[0];let n=[];const{child:r}=e;return e.fields?n=this.mapNamesToFields(e.fields):e.child&&(n=this.getChildFields(e.child)),{header:s,fields:n,child:r}}).map(e=>{if(e.child){const s=this.getChildData(e.child),n=e.fields.filter(l=>l.visible),r=this.getJoinKey();return{header:e.header.display,fields:s?s.data.filter(l=>l[r]===t[r]).map(l=>({heading:l[n[0]?.name]||"Not found",data:l[n[1]?.name]||"Not found"})):[]}}return{header:e.header.display,fields:e.fields.filter(s=>s.visible).map(s=>({heading:s.display,data:t[s.name]}))}}))}getChildData(i){return this.childData.find(t=>t.id===i)}createRows(i){return this.initSectionedData(i).flatMap((e,s)=>{let n=[];e.header&&(n=this.createSectionHeader(e.header,s));const r=e.fields.map(l=>[{text:l.heading,classes:"dpr-row-heading"},{text:l.data,classes:"dpr-row-heading-data"}]);return[...n,...r]})}buildTable(i){return{head:[],rows:this.createRows(i),rowCount:i.length,colCount:this.columns.length}}}var S=c;0&&(module.exports={SectionedFieldsDataTableBuilder});
1
+ "use strict";var m=Object.create;var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var g=(a,i)=>{for(var t in i)o(a,t,{get:i[t],enumerable:!0})},h=(a,i,t,d)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of u(i))!F.call(a,e)&&e!==t&&o(a,e,{get:()=>i[e],enumerable:!(d=f(i,e))||d.enumerable});return a};var y=(a,i,t)=>(t=a!=null?m(D(a)):{},h(i||!a||!a.__esModule?o(t,"default",{value:a,enumerable:!0}):t,a)),C=a=>h(o({},"__esModule",{value:!0}),a);var T={};g(T,{SectionedFieldsDataTableBuilder:()=>c,default:()=>S});module.exports=C(T);var p=y(require("../ParentChildDataTableBuilder/ParentChildDataTableBuilder"));class c extends p.default{constructor(i){const{sectionedFields:t,template:d}=i.specification;super(i),this.sectionedFields=t,this.sections=this.sectionedFields.map(e=>e.name),this.template=d,this.childVariants=this.variant.childVariants||[]}getChildFields(i){const t=this.childVariants.find(e=>e.id===i);let d=[];if(t){const{specification:e}=t;d=e?e.fields:d}return d}getJoinKey(){return this.childVariants[0].joinFields[0]}initSectionedData(i){return i.flatMap(t=>this.sectionedFields.map(e=>{const s=this.mapNamesToFields([e.name])[0];let n=[];const{child:l}=e;return e.fields?n=this.mapNamesToFields(e.fields):e.child&&(n=this.getChildFields(e.child)),{header:s,fields:n,child:l}}).map(e=>{if(e.child){const s=this.getChildData(e.child),n=e.fields.filter(r=>r.visible),l=this.getJoinKey();return{header:e.header.display,fields:s?s.data.filter(r=>r[l]===t[l]).map(r=>({heading:r[n[0]?.name]||"Not found",data:r[n[1]?.name]||"Not found"})):[]}}return{header:e.header.display,fields:e.fields.filter(s=>s.visible).map(s=>({heading:s.display,data:t[s.name]}))}}))}getChildData(i){return this.childData.find(t=>t.id===i)}createRows(i){return this.initSectionedData(i).flatMap((e,s)=>{let n=[];e.header&&(n=this.createSectionHeader(e.header,s));const l=e.fields.map(r=>[{text:r.heading,classes:"dpr-row-heading"},{text:r.data,classes:"dpr-row-heading-data"}]);return[...n,...l]})}buildTable(i){return{head:[],rows:this.createRows(i),rowCount:i.length,colCount:this.columns.length}}}var S=c;0&&(module.exports={SectionedFieldsDataTableBuilder});
2
2
  //# sourceMappingURL=SectionedFieldsTableBuilder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.ts"],
4
- "sourcesContent": ["import Dict = NodeJS.Dict\nimport { components } from '../../types/api'\nimport { Cell, DataTable, FieldDefinition } from '../DataTableBuilder/types'\nimport type { Template } from '../../types/Templates'\nimport ParentChildDataTableBuilder from '../ParentChildDataTableBuilder/ParentChildDataTableBuilder'\n\ninterface SectionedField {\n name: string\n fields?: string[]\n child?: string\n}\n\nclass SectionedFieldsDataTableBuilder extends ParentChildDataTableBuilder {\n // TODO: change this to use schema type if ever implemented in the backend\n sectionedFields: SectionedField[]\n\n override template: Template\n\n override childVariants: components['schemas']['ChildVariantDefinition'][]\n\n constructor(variant: components['schemas']['VariantDefinition']) {\n // TODO: removed the union if sectionedFields changed to use schema type\n const { sectionedFields, template } = variant.specification as components['schemas']['Specification'] & {\n sectionedFields: SectionedField[]\n }\n super(variant)\n\n this.sectionedFields = sectionedFields\n this.sections = this.sectionedFields.map((f) => f.name)\n this.template = template\n this.childVariants = this.variant.childVariants || []\n }\n\n getChildFields(childId: string): FieldDefinition[] {\n const childVariant = this.childVariants.find((child) => child.id === childId)\n let fields: FieldDefinition[] = []\n if (childVariant) {\n const { specification } = childVariant\n fields = specification ? specification.fields : fields\n }\n return fields\n }\n\n getJoinKey() {\n return this.childVariants[0].joinFields[0]\n }\n\n initSectionedData(data: Array<Dict<string>>) {\n return data.flatMap((row) => {\n const initialisedSectionsWithFields = this.sectionedFields.map((section) => {\n const sectionHeader = this.mapNamesToFields([section.name])[0]\n\n let fields: FieldDefinition[] = []\n const { child } = section\n\n if (section.fields) {\n fields = this.mapNamesToFields(section.fields)\n } else if (section.child) {\n fields = this.getChildFields(section.child)\n }\n\n return {\n header: sectionHeader,\n fields,\n child,\n }\n })\n\n return initialisedSectionsWithFields.map((section) => {\n if (section.child) {\n const childData = this.getChildData(section.child)\n const displayFields = section.fields.filter((f) => f.visible)\n const joinKey = this.getJoinKey()\n\n return {\n header: section.header.display,\n fields: childData\n ? childData.data\n .filter((cd) => cd[joinKey] === row[joinKey])\n .map((cd) => {\n return {\n heading: cd[displayFields[0]?.name] || 'Not found',\n data: cd[displayFields[1]?.name] || 'Not found',\n }\n })\n : [],\n }\n }\n return {\n header: section.header.display,\n fields: section.fields\n .filter((f) => f.visible)\n .map((f) => {\n return {\n heading: f.display,\n data: row[f.name],\n }\n }),\n }\n })\n })\n }\n\n getChildData(childId: string) {\n return this.childData.find((d) => d.id === childId)\n }\n\n createRows(data: Array<Dict<string>>): Cell[][] {\n const sectionedData = this.initSectionedData(data)\n\n const rows = sectionedData.flatMap((section, index) => {\n let sectionHeaderRow: Cell[][] = []\n if (section.header) {\n sectionHeaderRow = this.createSectionHeader(section.header, index)\n }\n\n const sectionRows = section.fields.map((field) => {\n return [\n {\n text: field.heading,\n classes: 'dpr-row-heading',\n },\n {\n text: field.data,\n classes: 'dpr-row-heading-data',\n },\n ]\n })\n\n return [...sectionHeaderRow, ...sectionRows]\n })\n\n return rows\n }\n\n override buildTable(data: Array<Dict<string>>): DataTable {\n return {\n head: [\n // { text: '', classes: 'dpr-row-section-header' },\n // { text: '', classes: 'dpr-row-section-header-value' },\n ],\n rows: this.createRows(data),\n rowCount: data.length,\n colCount: this.columns.length,\n }\n }\n}\n\nexport { SectionedFieldsDataTableBuilder }\nexport default SectionedFieldsDataTableBuilder\n"],
4
+ "sourcesContent": ["import Dict = NodeJS.Dict\nimport { components } from '../../types/api'\nimport { Cell, DataTable, FieldDefinition } from '../DataTableBuilder/types'\nimport type { Template } from '../../types/Templates'\nimport ParentChildDataTableBuilder from '../ParentChildDataTableBuilder/ParentChildDataTableBuilder'\n\nexport interface SectionedField {\n name: string\n fields?: string[]\n child?: string\n}\n\nclass SectionedFieldsDataTableBuilder extends ParentChildDataTableBuilder {\n // TODO: change this to use schema type if ever implemented in the backend\n sectionedFields: SectionedField[]\n\n override template: Template\n\n override childVariants: components['schemas']['ChildVariantDefinition'][]\n\n constructor(variant: components['schemas']['VariantDefinition']) {\n // TODO: removed the union if sectionedFields changed to use schema type\n const { sectionedFields, template } = variant.specification as components['schemas']['Specification'] & {\n sectionedFields: SectionedField[]\n }\n super(variant)\n\n this.sectionedFields = sectionedFields\n this.sections = this.sectionedFields.map((f) => f.name)\n this.template = template\n this.childVariants = this.variant.childVariants || []\n }\n\n getChildFields(childId: string): FieldDefinition[] {\n const childVariant = this.childVariants.find((child) => child.id === childId)\n let fields: FieldDefinition[] = []\n if (childVariant) {\n const { specification } = childVariant\n fields = specification ? specification.fields : fields\n }\n return fields\n }\n\n getJoinKey() {\n return this.childVariants[0].joinFields[0]\n }\n\n initSectionedData(data: Array<Dict<string>>) {\n return data.flatMap((row) => {\n const initialisedSectionsWithFields = this.sectionedFields.map((section) => {\n const sectionHeader = this.mapNamesToFields([section.name])[0]\n\n let fields: FieldDefinition[] = []\n const { child } = section\n\n if (section.fields) {\n fields = this.mapNamesToFields(section.fields)\n } else if (section.child) {\n fields = this.getChildFields(section.child)\n }\n\n return {\n header: sectionHeader,\n fields,\n child,\n }\n })\n\n return initialisedSectionsWithFields.map((section) => {\n if (section.child) {\n const childData = this.getChildData(section.child)\n const displayFields = section.fields.filter((f) => f.visible)\n const joinKey = this.getJoinKey()\n\n return {\n header: section.header.display,\n fields: childData\n ? childData.data\n .filter((cd) => cd[joinKey] === row[joinKey])\n .map((cd) => {\n return {\n heading: cd[displayFields[0]?.name] || 'Not found',\n data: cd[displayFields[1]?.name] || 'Not found',\n }\n })\n : [],\n }\n }\n return {\n header: section.header.display,\n fields: section.fields\n .filter((f) => f.visible)\n .map((f) => {\n return {\n heading: f.display,\n data: row[f.name],\n }\n }),\n }\n })\n })\n }\n\n getChildData(childId: string) {\n return this.childData.find((d) => d.id === childId)\n }\n\n createRows(data: Array<Dict<string>>): Cell[][] {\n const sectionedData = this.initSectionedData(data)\n\n const rows = sectionedData.flatMap((section, index) => {\n let sectionHeaderRow: Cell[][] = []\n if (section.header) {\n sectionHeaderRow = this.createSectionHeader(section.header, index)\n }\n\n const sectionRows = section.fields.map((field) => {\n return [\n {\n text: field.heading,\n classes: 'dpr-row-heading',\n },\n {\n text: field.data,\n classes: 'dpr-row-heading-data',\n },\n ]\n })\n\n return [...sectionHeaderRow, ...sectionRows]\n })\n\n return rows\n }\n\n override buildTable(data: Array<Dict<string>>): DataTable {\n return {\n head: [\n // { text: '', classes: 'dpr-row-section-header' },\n // { text: '', classes: 'dpr-row-section-header-value' },\n ],\n rows: this.createRows(data),\n rowCount: data.length,\n colCount: this.columns.length,\n }\n }\n}\n\nexport { SectionedFieldsDataTableBuilder }\nexport default SectionedFieldsDataTableBuilder\n"],
5
5
  "mappings": "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",
6
6
  "names": ["SectionedFieldsTableBuilder_exports", "__export", "SectionedFieldsDataTableBuilder", "SectionedFieldsTableBuilder_default", "__toCommonJS", "import_ParentChildDataTableBuilder", "ParentChildDataTableBuilder", "variant", "sectionedFields", "template", "f", "childId", "childVariant", "child", "fields", "specification", "data", "row", "section", "sectionHeader", "childData", "displayFields", "joinKey", "cd", "d", "index", "sectionHeaderRow", "sectionRows", "field"]
7
7
  }
@@ -4,7 +4,7 @@ import { Cell, DataTable, FieldDefinition } from '../DataTableBuilder/types'
4
4
  import type { Template } from '../../types/Templates'
5
5
  import ParentChildDataTableBuilder from '../ParentChildDataTableBuilder/ParentChildDataTableBuilder'
6
6
 
7
- interface SectionedField {
7
+ export interface SectionedField {
8
8
  name: string
9
9
  fields?: string[]
10
10
  child?: 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": "4.23.2",
4
+ "version": "4.25.0",
5
5
  "main": "dpr/all.mjs",
6
6
  "sass": "dpr/all.scss",
7
7
  "engines": {
@@ -138,6 +138,7 @@
138
138
  ]
139
139
  },
140
140
  "dependencies": {
141
+ "@flipt-io/flipt": "^1.5.0",
141
142
  "@ministryofjustice/frontend": "^6.0.0",
142
143
  "agentkeepalive": "^4.5.0",
143
144
  "bunyan": "^1.8.15",
@@ -154,7 +155,7 @@
154
155
  "dayjs": "^1.11.12",
155
156
  "express": "^5.1.0",
156
157
  "express-session": "^1.18.2",
157
- "govuk-frontend": "^5.11.0",
158
+ "govuk-frontend": "^5.13.0",
158
159
  "jquery": "^3.7.1",
159
160
  "json-2-csv": "^5.5.6",
160
161
  "nocache": "^4.0.0",
@@ -168,8 +169,6 @@
168
169
  },
169
170
  "devDependencies": {
170
171
  "@11ty/eleventy": "^2.0.1",
171
- "@badeball/cypress-cucumber-preprocessor": "^22.2.0",
172
- "@bahmutov/cypress-esbuild-preprocessor": "^2.2.5",
173
172
  "@jest/globals": "^30.2.0",
174
173
  "@ministryofjustice/hmpps-npm-script-allowlist": "0.0.3",
175
174
  "@testing-library/cypress": "^10.0.3",
@@ -198,7 +197,7 @@
198
197
  "cypress-multi-reporters": "^1.6.3",
199
198
  "cypress-xpath": "^2.0.1",
200
199
  "del": "^7.1.0",
201
- "esbuild": "^0.25.5",
200
+ "esbuild": "^0.27.2",
202
201
  "esbuild-plugin-clean": "^1.0.1",
203
202
  "esbuild-plugin-copy": "^2.1.1",
204
203
  "esbuild-plugin-manifest": "^1.0.5",