@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.17.3 → 4.17.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.
- package/dpr/components/_catalogue/catalogue/utils.js +1 -1
- package/dpr/components/_catalogue/catalogue/utils.js.map +2 -2
- package/dpr/components/_catalogue/catalogue/utils.ts +1 -1
- package/dpr/middleware/setUpDprResources.js +1 -1
- package/dpr/middleware/setUpDprResources.js.map +2 -2
- package/dpr/middleware/setUpDprResources.ts +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var f=Object.create;var i=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var w=(o,e)=>{for(var t in e)i(o,t,{get:e[t],enumerable:!0})},
|
|
1
|
+
var f=Object.create;var i=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var w=(o,e)=>{for(var t in e)i(o,t,{get:e[t],enumerable:!0})},u=(o,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!T.call(o,n)&&n!==t&&i(o,n,{get:()=>e[n],enumerable:!(l=k(e,n))||l.enumerable});return o};var s=(o,e,t)=>(t=o!=null?f(S(o)):{},u(e||!o||!o.__esModule?i(t,"default",{value:o,enumerable:!0}):t,o)),v=o=>u(i({},"__esModule",{value:!0}),o);var U={};w(U,{default:()=>P,init:()=>p});module.exports=v(U);var g=s(require("../catalogue-list/utils")),b=s(require("../../../utils/localsHelper"));const p=async({features:o,res:e,services:t})=>{const l=await g.default.getReportsList(e,t,o),{token:n,bookmarkingEnabled:m,dprUser:E,csrfToken:C}=b.default.getValues(e),a=(await t.productCollectionService.getProductCollections(n))?.map(c=>({value:c.id,text:c.name}));a&&a.length>0&&a.unshift({value:"RESET",text:"Full catalogue"});const d=await t.productCollectionStoreService.getSelectedProductCollectionId(E.id),r=d&&await t.productCollectionService.getProductCollection(n,d);return{data:{...l,csrfToken:C},productCollectionInfo:{productCollections:a,...r&&{selectedProductCollection:r}},features:F(m,o)}},F=(o,e)=>({filteringEnabled:e?.filteringEnabled===void 0||e.filteringEnabled,unauthorisedToggleEnabled:e?.unauthorisedToggleEnabled===void 0||e.unauthorisedToggleEnabled,howToUseEnabled:e?.howToUseEnabled===void 0||e.howToUseEnabled,bookmarkingEnabled:e?.bookmarkingEnabled!==void 0?e.bookmarkingEnabled:o});var P={init:p};0&&(module.exports={init});
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/dpr/components/_catalogue/catalogue/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { Response } from 'express'\nimport CatalogueListUtils from '../catalogue-list/utils'\nimport { Services } from '../../../types/Services'\nimport LocalsHelper from '../../../utils/localsHelper'\nimport { CatalogueFeatures } from './types'\n\nexport const init = async ({\n features,\n res,\n services,\n}: {\n features?: CatalogueFeatures\n res: Response\n services: Services\n}) => {\n const data = await CatalogueListUtils.getReportsList(res, services, features)\n const { token, bookmarkingEnabled, dprUser, csrfToken } = LocalsHelper.getValues(res)\n const productCollections = (await services.productCollectionService.getProductCollections(token))?.map(\n (collection) => ({\n value: collection.id,\n text: collection.name,\n }),\n )\n if (productCollections && productCollections.length > 0) {\n productCollections.unshift({ value: 'RESET', text: 'Full catalogue' })\n }\n const selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\n const selectedProductCollection =\n selectedProductCollectionId &&\n (await services.productCollectionService.getProductCollection(
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,SAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAA+B,sCAE/BC,EAAyB,0CAGlB,MAAMH,EAAO,MAAO,CACzB,SAAAI,EACA,IAAAC,EACA,SAAAC,CACF,IAIM,CACJ,MAAMC,EAAO,MAAM,EAAAC,QAAmB,eAAeH,EAAKC,EAAUF,CAAQ,EACtE,CAAE,MAAAK,EAAO,mBAAAC,EAAoB,QAAAC,EAAS,UAAAC,CAAU,EAAI,EAAAC,QAAa,UAAUR,CAAG,EAC9ES,GAAsB,MAAMR,EAAS,yBAAyB,sBAAsBG,CAAK,IAAI,IAChGM,IAAgB,CACf,MAAOA,EAAW,GAClB,KAAMA,EAAW,IACnB,EACF,EACID,GAAsBA,EAAmB,OAAS,GACpDA,EAAmB,QAAQ,CAAE,MAAO,QAAS,KAAM,gBAAiB,CAAC,EAEvE,MAAME,EAA8B,MAAMV,EAAS,8BAA8B,+BAC/EK,EAAQ,EACV,EACMM,EACJD,GACC,MAAMV,EAAS,yBAAyB,
|
|
4
|
+
"sourcesContent": ["import { Response } from 'express'\nimport CatalogueListUtils from '../catalogue-list/utils'\nimport { Services } from '../../../types/Services'\nimport LocalsHelper from '../../../utils/localsHelper'\nimport { CatalogueFeatures } from './types'\n\nexport const init = async ({\n features,\n res,\n services,\n}: {\n features?: CatalogueFeatures\n res: Response\n services: Services\n}) => {\n const data = await CatalogueListUtils.getReportsList(res, services, features)\n const { token, bookmarkingEnabled, dprUser, csrfToken } = LocalsHelper.getValues(res)\n const productCollections = (await services.productCollectionService.getProductCollections(token))?.map(\n (collection) => ({\n value: collection.id,\n text: collection.name,\n }),\n )\n if (productCollections && productCollections.length > 0) {\n productCollections.unshift({ value: 'RESET', text: 'Full catalogue' })\n }\n const selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\n const selectedProductCollection =\n selectedProductCollectionId &&\n (await services.productCollectionService.getProductCollection(token, selectedProductCollectionId))\n return {\n data: {\n ...data,\n csrfToken,\n },\n productCollectionInfo: {\n productCollections,\n ...(selectedProductCollection && { selectedProductCollection }),\n },\n features: setFeatures(bookmarkingEnabled, features),\n }\n}\n\nconst setFeatures = (bookmarkingEnabled: boolean, features?: CatalogueFeatures) => {\n return {\n filteringEnabled: features?.filteringEnabled === undefined || features.filteringEnabled,\n unauthorisedToggleEnabled: features?.unauthorisedToggleEnabled === undefined || features.unauthorisedToggleEnabled,\n howToUseEnabled: features?.howToUseEnabled === undefined || features.howToUseEnabled,\n bookmarkingEnabled: features?.bookmarkingEnabled !== undefined ? features.bookmarkingEnabled : bookmarkingEnabled,\n }\n}\n\nexport default {\n init,\n}\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,SAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAA+B,sCAE/BC,EAAyB,0CAGlB,MAAMH,EAAO,MAAO,CACzB,SAAAI,EACA,IAAAC,EACA,SAAAC,CACF,IAIM,CACJ,MAAMC,EAAO,MAAM,EAAAC,QAAmB,eAAeH,EAAKC,EAAUF,CAAQ,EACtE,CAAE,MAAAK,EAAO,mBAAAC,EAAoB,QAAAC,EAAS,UAAAC,CAAU,EAAI,EAAAC,QAAa,UAAUR,CAAG,EAC9ES,GAAsB,MAAMR,EAAS,yBAAyB,sBAAsBG,CAAK,IAAI,IAChGM,IAAgB,CACf,MAAOA,EAAW,GAClB,KAAMA,EAAW,IACnB,EACF,EACID,GAAsBA,EAAmB,OAAS,GACpDA,EAAmB,QAAQ,CAAE,MAAO,QAAS,KAAM,gBAAiB,CAAC,EAEvE,MAAME,EAA8B,MAAMV,EAAS,8BAA8B,+BAC/EK,EAAQ,EACV,EACMM,EACJD,GACC,MAAMV,EAAS,yBAAyB,qBAAqBG,EAAOO,CAA2B,EAClG,MAAO,CACL,KAAM,CACJ,GAAGT,EACH,UAAAK,CACF,EACA,sBAAuB,CACrB,mBAAAE,EACA,GAAIG,GAA6B,CAAE,0BAAAA,CAA0B,CAC/D,EACA,SAAUC,EAAYR,EAAoBN,CAAQ,CACpD,CACF,EAEMc,EAAc,CAACR,EAA6BN,KACzC,CACL,iBAAkBA,GAAU,mBAAqB,QAAaA,EAAS,iBACvE,0BAA2BA,GAAU,4BAA8B,QAAaA,EAAS,0BACzF,gBAAiBA,GAAU,kBAAoB,QAAaA,EAAS,gBACrE,mBAAoBA,GAAU,qBAAuB,OAAYA,EAAS,mBAAqBM,CACjG,GAGF,IAAOX,EAAQ,CACb,KAAAC,CACF",
|
|
6
6
|
"names": ["utils_exports", "__export", "utils_default", "init", "__toCommonJS", "import_utils", "import_localsHelper", "features", "res", "services", "data", "CatalogueListUtils", "token", "bookmarkingEnabled", "dprUser", "csrfToken", "LocalsHelper", "productCollections", "collection", "selectedProductCollectionId", "selectedProductCollection", "setFeatures"]
|
|
7
7
|
}
|
|
@@ -29,7 +29,7 @@ export const init = async ({
|
|
|
29
29
|
)
|
|
30
30
|
const selectedProductCollection =
|
|
31
31
|
selectedProductCollectionId &&
|
|
32
|
-
(await services.productCollectionService.getProductCollection(
|
|
32
|
+
(await services.productCollectionService.getProductCollection(token, selectedProductCollectionId))
|
|
33
33
|
return {
|
|
34
34
|
data: {
|
|
35
35
|
...data,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var w=Object.create;var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var b=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0})},g=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of q(o))!V.call(t,r)&&r!==e&&l(t,r,{get:()=>o[r],enumerable:!(i=C(o,r))||i.enumerable});return t};var S=(t,o,e)=>(e=t!=null?w(Q(t)):{},g(o||!t||!t.__esModule?l(e,"default",{value:t,enumerable:!0}):e,t)),v=t=>g(l({},"__esModule",{value:!0}),t);var B={};b(B,{default:()=>A,populateDefinitions:()=>D,populateRequestedReports:()=>k,setupResources:()=>h});module.exports=v(B);var c=S(require("../utils/definitionUtils")),f=S(require("../utils/localsHelper"));const I=(t,o)=>t[o]?t[o].toString():null,F=t=>I(t,"dataProductDefinitionsPath"),E=t=>{const o=F(t);return o||null},h=(t,o)=>async(e,i,r)=>{x(e,i);try{return await D(t,e,i,o),await k(t,i),r()}catch(a){return r(a)}},x=(t,o)=>{const e=t.flash("DPR_ERRORS");e&&e[0]&&(o.locals.validationErrors=JSON.parse(e[0]))},D=async(t,o,e,i)=>{const{token:r,dprUser:a}=f.default.getValues(e),d=E(o.query),n=o.body?.dataProductDefinitionsPath,s=d||n;s&&(e.locals.dpdPathFromQuery=!0);const m=i?.dataProductDefinitionsPath;if(m&&(e.locals.dpdPathFromConfig=!0),e.locals.definitionsPath=s||m,e.locals.pathSuffix=`?dataProductDefinitionsPath=${e.locals.definitionsPath}`,r&&t.reportingService){const P=await t.productCollectionStoreService.getSelectedProductCollectionId(a.id);e.locals.definitions=await Promise.all([t.reportingService.getDefinitions(r,e.locals.definitionsPath),P&&t.productCollectionService.getProductCollection(
|
|
1
|
+
var w=Object.create;var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var b=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0})},g=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of q(o))!V.call(t,r)&&r!==e&&l(t,r,{get:()=>o[r],enumerable:!(i=C(o,r))||i.enumerable});return t};var S=(t,o,e)=>(e=t!=null?w(Q(t)):{},g(o||!t||!t.__esModule?l(e,"default",{value:t,enumerable:!0}):e,t)),v=t=>g(l({},"__esModule",{value:!0}),t);var B={};b(B,{default:()=>A,populateDefinitions:()=>D,populateRequestedReports:()=>k,setupResources:()=>h});module.exports=v(B);var c=S(require("../utils/definitionUtils")),f=S(require("../utils/localsHelper"));const I=(t,o)=>t[o]?t[o].toString():null,F=t=>I(t,"dataProductDefinitionsPath"),E=t=>{const o=F(t);return o||null},h=(t,o)=>async(e,i,r)=>{x(e,i);try{return await D(t,e,i,o),await k(t,i),r()}catch(a){return r(a)}},x=(t,o)=>{const e=t.flash("DPR_ERRORS");e&&e[0]&&(o.locals.validationErrors=JSON.parse(e[0]))},D=async(t,o,e,i)=>{const{token:r,dprUser:a}=f.default.getValues(e),d=E(o.query),n=o.body?.dataProductDefinitionsPath,s=d||n;s&&(e.locals.dpdPathFromQuery=!0);const m=i?.dataProductDefinitionsPath;if(m&&(e.locals.dpdPathFromConfig=!0),e.locals.definitionsPath=s||m,e.locals.pathSuffix=`?dataProductDefinitionsPath=${e.locals.definitionsPath}`,r&&t.reportingService){const P=await t.productCollectionStoreService.getSelectedProductCollectionId(a.id);e.locals.definitions=await Promise.all([t.reportingService.getDefinitions(r,e.locals.definitionsPath),P&&t.productCollectionService.getProductCollection(r,P)]).then(([R,p])=>{if(p&&p){const y=p.products.map(u=>u.productId);return R.filter(u=>y.includes(u.id))}return R})??[]}},k=async(t,o)=>{const{dprUser:e}=f.default.getValues(o);if(e.id){const{definitions:i,definitionsPath:r}=o.locals,a=await t.requestedReportService.getAllReports(e.id);o.locals.requestedReports=r?a.filter(n=>c.default.getCurrentVariantDefinition(i,n.reportId,n.id)):a;const d=await t.recentlyViewedService.getAllReports(e.id);if(o.locals.recentlyViewedReports=r?d.filter(n=>c.default.getCurrentVariantDefinition(i,n.reportId,n.id)):d,t.bookmarkService){o.locals.bookmarkingEnabled=!0;const n=await t.bookmarkService.getAllBookmarks(e.id);o.locals.bookmarks=r?n.filter(s=>c.default.getCurrentVariantDefinition(i,s.reportId,s.id)):n}t.downloadPermissionService&&(o.locals.downloadingEnabled=!0)}};var A=h;0&&(module.exports={populateDefinitions,populateRequestedReports,setupResources});
|
|
2
2
|
//# sourceMappingURL=setUpDprResources.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/dpr/middleware/setUpDprResources.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RequestHandler, Response, Request } from 'express'\nimport type { ParsedQs } from 'qs'\nimport { Services } from '../types/Services'\nimport { RequestedReport, StoredReportData } from '../types/UserReports'\nimport DefinitionUtils from '../utils/definitionUtils'\nimport { BookmarkStoreData } from '../types/Bookmark'\nimport { DprConfig } from '../types/DprConfig'\nimport localsHelper from '../utils/localsHelper'\n\nconst getQueryParamAsString = (query: ParsedQs, name: string) => (query[name] ? query[name].toString() : null)\nconst getDefinitionsPath = (query: ParsedQs) => getQueryParamAsString(query, 'dataProductDefinitionsPath')\n\nconst deriveDefinitionsPath = (query: ParsedQs): string | null => {\n const definitionsPath = getDefinitionsPath(query)\n if (definitionsPath) {\n return definitionsPath\n }\n\n return null\n}\n\nexport const setupResources = (services: Services, config?: DprConfig): RequestHandler => {\n return async (req, res, next) => {\n populateValidationErrors(req, res)\n try {\n await populateDefinitions(services, req, res, config)\n await populateRequestedReports(services, res)\n return next()\n } catch (error) {\n return next(error)\n }\n }\n}\n\nconst populateValidationErrors = (req: Request, res: Response) => {\n const errors = req.flash(`DPR_ERRORS`)\n if (errors && errors[0]) {\n res.locals.validationErrors = JSON.parse(errors[0])\n }\n}\n\nexport const populateDefinitions = async (services: Services, req: Request, res: Response, config?: DprConfig) => {\n // Get the DPD path from the query\n const { token, dprUser } = localsHelper.getValues(res)\n\n const dpdPathFromQuery = deriveDefinitionsPath(req.query)\n const dpdPathFromBody = req.body?.dataProductDefinitionsPath\n const definitionsPathFromQuery = dpdPathFromQuery || dpdPathFromBody\n\n if (definitionsPathFromQuery) {\n res.locals.dpdPathFromQuery = true\n }\n\n // Get the DPD path from the config\n const dpdPathFromConfig = config?.dataProductDefinitionsPath\n if (dpdPathFromConfig) {\n res.locals.dpdPathFromConfig = true\n }\n\n // query takes presedence over config\n res.locals.definitionsPath = definitionsPathFromQuery || dpdPathFromConfig\n res.locals.pathSuffix = `?dataProductDefinitionsPath=${res.locals.definitionsPath}`\n\n if (token && services.reportingService) {\n const selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\n\n res.locals.definitions =\n (await Promise.all([\n services.reportingService.getDefinitions(token, res.locals.definitionsPath),\n selectedProductCollectionId &&\n services.productCollectionService.getProductCollection(
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAN,GAKA,IAAAO,EAA4B,uCAG5BC,EAAyB,oCAEzB,MAAMC,EAAwB,CAACC,EAAiBC,IAAkBD,EAAMC,CAAI,EAAID,EAAMC,CAAI,EAAE,SAAS,EAAI,KACnGC,EAAsBF,GAAoBD,EAAsBC,EAAO,4BAA4B,EAEnGG,EAAyBH,GAAmC,CAChE,MAAMI,EAAkBF,EAAmBF,CAAK,EAChD,OAAII,GAIG,IACT,EAEaT,EAAiB,CAACU,EAAoBC,IAC1C,MAAOC,EAAKC,EAAKC,IAAS,CAC/BC,EAAyBH,EAAKC,CAAG,EACjC,GAAI,CACF,aAAMf,EAAoBY,EAAUE,EAAKC,EAAKF,CAAM,EACpD,MAAMZ,EAAyBW,EAAUG,CAAG,EACrCC,EAAK,CACd,OAASE,EAAO,CACd,OAAOF,EAAKE,CAAK,CACnB,CACF,EAGID,EAA2B,CAACH,EAAcC,IAAkB,CAChE,MAAMI,EAASL,EAAI,MAAM,YAAY,EACjCK,GAAUA,EAAO,CAAC,IACpBJ,EAAI,OAAO,iBAAmB,KAAK,MAAMI,EAAO,CAAC,CAAC,EAEtD,EAEanB,EAAsB,MAAOY,EAAoBE,EAAcC,EAAeF,IAAuB,CAEhH,KAAM,CAAE,MAAAO,EAAO,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUP,CAAG,EAE/CQ,EAAmBb,EAAsBI,EAAI,KAAK,EAClDU,EAAkBV,EAAI,MAAM,2BAC5BW,EAA2BF,GAAoBC,EAEjDC,IACFV,EAAI,OAAO,iBAAmB,IAIhC,MAAMW,EAAoBb,GAAQ,2BASlC,GARIa,IACFX,EAAI,OAAO,kBAAoB,IAIjCA,EAAI,OAAO,gBAAkBU,GAA4BC,EACzDX,EAAI,OAAO,WAAa,+BAA+BA,EAAI,OAAO,eAAe,GAE7EK,GAASR,EAAS,iBAAkB,CACtC,MAAMe,EAA8B,MAAMf,EAAS,8BAA8B,+BAC/ES,EAAQ,EACV,EAEAN,EAAI,OAAO,YACR,MAAM,QAAQ,IAAI,CACjBH,EAAS,iBAAiB,eAAeQ,EAAOL,EAAI,OAAO,eAAe,EAC1EY,GACEf,EAAS,yBAAyB,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RequestHandler, Response, Request } from 'express'\nimport type { ParsedQs } from 'qs'\nimport { Services } from '../types/Services'\nimport { RequestedReport, StoredReportData } from '../types/UserReports'\nimport DefinitionUtils from '../utils/definitionUtils'\nimport { BookmarkStoreData } from '../types/Bookmark'\nimport { DprConfig } from '../types/DprConfig'\nimport localsHelper from '../utils/localsHelper'\n\nconst getQueryParamAsString = (query: ParsedQs, name: string) => (query[name] ? query[name].toString() : null)\nconst getDefinitionsPath = (query: ParsedQs) => getQueryParamAsString(query, 'dataProductDefinitionsPath')\n\nconst deriveDefinitionsPath = (query: ParsedQs): string | null => {\n const definitionsPath = getDefinitionsPath(query)\n if (definitionsPath) {\n return definitionsPath\n }\n\n return null\n}\n\nexport const setupResources = (services: Services, config?: DprConfig): RequestHandler => {\n return async (req, res, next) => {\n populateValidationErrors(req, res)\n try {\n await populateDefinitions(services, req, res, config)\n await populateRequestedReports(services, res)\n return next()\n } catch (error) {\n return next(error)\n }\n }\n}\n\nconst populateValidationErrors = (req: Request, res: Response) => {\n const errors = req.flash(`DPR_ERRORS`)\n if (errors && errors[0]) {\n res.locals.validationErrors = JSON.parse(errors[0])\n }\n}\n\nexport const populateDefinitions = async (services: Services, req: Request, res: Response, config?: DprConfig) => {\n // Get the DPD path from the query\n const { token, dprUser } = localsHelper.getValues(res)\n\n const dpdPathFromQuery = deriveDefinitionsPath(req.query)\n const dpdPathFromBody = req.body?.dataProductDefinitionsPath\n const definitionsPathFromQuery = dpdPathFromQuery || dpdPathFromBody\n\n if (definitionsPathFromQuery) {\n res.locals.dpdPathFromQuery = true\n }\n\n // Get the DPD path from the config\n const dpdPathFromConfig = config?.dataProductDefinitionsPath\n if (dpdPathFromConfig) {\n res.locals.dpdPathFromConfig = true\n }\n\n // query takes presedence over config\n res.locals.definitionsPath = definitionsPathFromQuery || dpdPathFromConfig\n res.locals.pathSuffix = `?dataProductDefinitionsPath=${res.locals.definitionsPath}`\n\n if (token && services.reportingService) {\n const selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\n\n res.locals.definitions =\n (await Promise.all([\n services.reportingService.getDefinitions(token, res.locals.definitionsPath),\n selectedProductCollectionId &&\n services.productCollectionService.getProductCollection(token, selectedProductCollectionId),\n ]).then(([defs, selectedProductCollection]) => {\n if (selectedProductCollection && selectedProductCollection) {\n const productIds = selectedProductCollection.products.map((product) => product.productId)\n return defs.filter((def) => productIds.includes(def.id))\n }\n return defs\n })) ?? []\n }\n}\n\nexport const populateRequestedReports = async (services: Services, res: Response) => {\n const { dprUser } = localsHelper.getValues(res)\n if (dprUser.id) {\n const { definitions, definitionsPath } = res.locals\n\n const requested = await services.requestedReportService.getAllReports(dprUser.id)\n res.locals.requestedReports = !definitionsPath\n ? requested\n : requested.filter((report: RequestedReport) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n const recent = await services.recentlyViewedService.getAllReports(dprUser.id)\n res.locals.recentlyViewedReports = !definitionsPath\n ? recent\n : recent.filter((report: StoredReportData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n if (services.bookmarkService) {\n res.locals.bookmarkingEnabled = true\n\n const bookmarks = await services.bookmarkService.getAllBookmarks(dprUser.id)\n res.locals.bookmarks = !definitionsPath\n ? bookmarks\n : bookmarks.filter((bookmark: BookmarkStoreData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, bookmark.reportId, bookmark.id)\n })\n }\n\n if (services.downloadPermissionService) {\n res.locals.downloadingEnabled = true\n }\n }\n}\n\nexport default setupResources\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["setUpDprResources_exports", "__export", "setUpDprResources_default", "populateDefinitions", "populateRequestedReports", "setupResources", "__toCommonJS", "import_definitionUtils", "import_localsHelper", "getQueryParamAsString", "query", "name", "getDefinitionsPath", "deriveDefinitionsPath", "definitionsPath", "services", "config", "req", "res", "next", "populateValidationErrors", "error", "errors", "token", "dprUser", "localsHelper", "dpdPathFromQuery", "dpdPathFromBody", "definitionsPathFromQuery", "dpdPathFromConfig", "selectedProductCollectionId", "defs", "selectedProductCollection", "productIds", "product", "def", "definitions", "requested", "report", "DefinitionUtils", "recent", "bookmarks", "bookmark"]
|
|
7
7
|
}
|
|
@@ -71,7 +71,7 @@ export const populateDefinitions = async (services: Services, req: Request, res:
|
|
|
71
71
|
(await Promise.all([
|
|
72
72
|
services.reportingService.getDefinitions(token, res.locals.definitionsPath),
|
|
73
73
|
selectedProductCollectionId &&
|
|
74
|
-
services.productCollectionService.getProductCollection(
|
|
74
|
+
services.productCollectionService.getProductCollection(token, selectedProductCollectionId),
|
|
75
75
|
]).then(([defs, selectedProductCollection]) => {
|
|
76
76
|
if (selectedProductCollection && selectedProductCollection) {
|
|
77
77
|
const productIds = selectedProductCollection.products.map((product) => product.productId)
|
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.17.
|
|
4
|
+
"version": "4.17.4",
|
|
5
5
|
"main": "dpr/all.mjs",
|
|
6
6
|
"sass": "dpr/all.scss",
|
|
7
7
|
"engines": {
|