@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.26.7 → 4.27.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 (48) hide show
  1. package/dpr/middleware/setUpDprResources.js +1 -1
  2. package/dpr/middleware/setUpDprResources.js.map +3 -3
  3. package/dpr/middleware/setUpDprResources.ts +3 -1
  4. package/dpr/routes/journeys/download-report/request-download/form/controller.js +1 -1
  5. package/dpr/routes/journeys/download-report/request-download/form/controller.js.map +3 -3
  6. package/dpr/routes/journeys/download-report/request-download/form/controller.ts +1 -1
  7. package/dpr/routes/journeys/request-missing-report/form/controller.js +1 -1
  8. package/dpr/routes/journeys/request-missing-report/form/controller.js.map +3 -3
  9. package/dpr/routes/journeys/request-missing-report/form/controller.ts +6 -3
  10. package/dpr/routes/journeys/request-missing-report/submitted/controller.js +1 -1
  11. package/dpr/routes/journeys/request-missing-report/submitted/controller.js.map +3 -3
  12. package/dpr/routes/journeys/request-missing-report/submitted/controller.ts +1 -1
  13. package/dpr/routes/journeys/request-report/controller.js +1 -1
  14. package/dpr/routes/journeys/request-report/controller.js.map +3 -3
  15. package/dpr/routes/journeys/request-report/controller.ts +3 -1
  16. package/dpr/routes/journeys/request-report/filters/controller.js +1 -1
  17. package/dpr/routes/journeys/request-report/filters/controller.js.map +2 -2
  18. package/dpr/routes/journeys/request-report/filters/controller.ts +3 -3
  19. package/dpr/routes/journeys/request-report/routes.js +1 -1
  20. package/dpr/routes/journeys/request-report/routes.js.map +3 -3
  21. package/dpr/routes/journeys/request-report/routes.ts +2 -0
  22. package/dpr/routes/journeys/request-report/status/controller.js +1 -1
  23. package/dpr/routes/journeys/request-report/status/controller.js.map +2 -2
  24. package/dpr/routes/journeys/request-report/status/controller.ts +1 -1
  25. package/dpr/routes/journeys/view-report/async/controller.js +1 -1
  26. package/dpr/routes/journeys/view-report/async/controller.js.map +2 -2
  27. package/dpr/routes/journeys/view-report/async/controller.ts +2 -2
  28. package/dpr/routes/journeys/view-report/async/dashboard/controller.js +1 -1
  29. package/dpr/routes/journeys/view-report/async/dashboard/controller.js.map +2 -2
  30. package/dpr/routes/journeys/view-report/async/dashboard/controller.ts +1 -1
  31. package/dpr/routes/journeys/view-report/async/report/controller.js +1 -1
  32. package/dpr/routes/journeys/view-report/async/report/controller.js.map +2 -2
  33. package/dpr/routes/journeys/view-report/async/report/controller.ts +1 -1
  34. package/dpr/routes/journeys/view-report/controller.js +1 -1
  35. package/dpr/routes/journeys/view-report/controller.js.map +3 -3
  36. package/dpr/routes/journeys/view-report/controller.ts +7 -4
  37. package/dpr/routes/journeys/view-report/sync/dashboard/controller.js +1 -1
  38. package/dpr/routes/journeys/view-report/sync/dashboard/controller.js.map +2 -2
  39. package/dpr/routes/journeys/view-report/sync/dashboard/controller.ts +1 -1
  40. package/dpr/routes/journeys/view-report/sync/load-report/controller.js +1 -1
  41. package/dpr/routes/journeys/view-report/sync/load-report/controller.js.map +3 -3
  42. package/dpr/routes/journeys/view-report/sync/load-report/controller.ts +1 -1
  43. package/dpr/routes/journeys/view-report/sync/report/controller.js +1 -1
  44. package/dpr/routes/journeys/view-report/sync/report/controller.js.map +2 -2
  45. package/dpr/routes/journeys/view-report/sync/report/controller.ts +3 -3
  46. package/dpr/utils/ErrorHandler.js.map +1 -1
  47. package/dpr/utils/ErrorHandler.ts +1 -1
  48. package/package.json +9 -8
@@ -1,2 +1,2 @@
1
- "use strict";var w=Object.create;var d=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},S=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of y(e))!C.call(t,a)&&a!==o&&d(t,a,{get:()=>e[a],enumerable:!(r=q(e,a))||r.enumerable});return t};var P=(t,e,o)=>(o=t!=null?w(v(t)):{},S(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),H=t=>S(d({},"__esModule",{value:!0}),t);var B={};U(B,{default:()=>A,errorRequestHandler:()=>D,populateDefinitions:()=>k,populateRequestedReports:()=>F,setupResources:()=>b});module.exports=H(B);var c=P(require("../utils/definitionUtils")),m=P(require("../utils/localsHelper")),h=require("../services/featureFlagService");const Q=(t,e)=>t[e]?t[e].toString():null,V=t=>Q(t,"dataProductDefinitionsPath"),x=t=>{const e=V(t);return e||null},D=t=>(e,o,r,a)=>e.status===401||e.status===403?r.render("dpr/routes/authError.njk",{layoutPath:t,message:"Sorry, there is a problem with authenticating your request"}):e.status>=400?r.render("dpr/routes/serviceProblem.njk",{layoutPath:t}):a(),b=(t,e,o,r)=>async(a,i,s)=>{j(a,i);try{return await T(i,t.featureFlagService),await k(t,a,i,r),await F(t,i),I(o,i),s()}catch(n){return D(e)(n,a,i,s)}},I=(t,e)=>{t.addGlobal("getLocals",()=>({locals:{...e.locals,...e.app.locals}}))},T=async(t,e)=>{t.app.locals.featureFlags===void 0&&(t.app.locals.featureFlags={flags:{},lastUpdated:new Date().getTime()-601*1e3});const{featureFlags:o}=t.app.locals,r=new Date().getTime();if((r-o.lastUpdated)/1e3>600){t.app.locals.featureFlags.lastUpdated=r;const s=await e.getFlags().catch(n=>{throw t.app.locals.featureFlags.lastUpdated=r-601*1e3,n});t.app.locals.featureFlags.flags=Object.fromEntries(s.flags.map(n=>[n.key,n]))}},j=(t,e)=>{const o=t.flash("DPR_ERRORS");o&&o[0]&&(e.locals.validationErrors=JSON.parse(o[0]))},k=async(t,e,o,r)=>{const{token:a,dprUser:i}=m.default.getValues(o),s=x(e.query),n=e.body?.dataProductDefinitionsPath,l=s||n;l&&(o.locals.dpdPathFromQuery=!0);const g=r?.dataProductDefinitionsPath;g&&(o.locals.dpdPathFromConfig=!0),o.locals.definitionsPath=l||g,o.locals.pathSuffix=`?dataProductDefinitionsPath=${o.locals.definitionsPath}`;let u;a&&(u=await t.productCollectionStoreService.getSelectedProductCollectionId(i.id)),o.locals.definitions=await Promise.all([t.reportingService.getDefinitions(a,o.locals.definitionsPath),u&&t.productCollectionService.getProductCollection(a,u)]).then(([R,p])=>{if(p&&p){const E=p.products.map(f=>f.productId);return R.filter(f=>E.includes(f.id))}return R})??[]},F=async(t,e)=>{const{dprUser:o}=m.default.getValues(e);if(o.id){const{definitions:r,definitionsPath:a}=e.locals,i=await t.recentlyViewedService.getAllReports(o.id);await t.requestedReportService.cleanList(o.id,i);const s=await t.requestedReportService.getAllReports(o.id);if(e.locals.requestedReports=a?s.filter(n=>c.default.getCurrentVariantDefinition(r,n.reportId,n.id)):s,e.locals.recentlyViewedReports=a?i.filter(n=>c.default.getCurrentVariantDefinition(r,n.reportId,n.id)):i,e.locals.downloadingEnabled=t.downloadPermissionService.enabled,e.locals.bookmarkingEnabled=t.bookmarkService.enabled,e.locals.collectionsEnabled=t.productCollectionService.enabled,e.locals.requestMissingEnabled=t.missingReportService.enabled,e.locals.saveDefaultsEnabled=(0,h.isBooleanFlagEnabled)("saveDefaultsEnabled",e.app),e.locals.bookmarkingEnabled){const n=await t.bookmarkService.getAllBookmarks(o.id);e.locals.bookmarks=a?n.filter(l=>c.default.getCurrentVariantDefinition(r,l.reportId,l.id)):n}}};var A=b;0&&(module.exports={errorRequestHandler,populateDefinitions,populateRequestedReports,setupResources});
1
+ "use strict";var q=Object.create;var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},S=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of v(e))!U.call(t,a)&&a!==o&&d(t,a,{get:()=>e[a],enumerable:!(r=y(e,a))||r.enumerable});return t};var P=(t,e,o)=>(o=t!=null?q(C(t)):{},S(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),H=t=>S(d({},"__esModule",{value:!0}),t);var L={};x(L,{default:()=>B,errorRequestHandler:()=>b,populateDefinitions:()=>F,populateRequestedReports:()=>E,setupResources:()=>k});module.exports=H(L);var h=require("@sentry/node"),c=P(require("../utils/definitionUtils")),m=P(require("../utils/localsHelper")),D=require("../services/featureFlagService");const Q=(t,e)=>t[e]?t[e].toString():null,V=t=>Q(t,"dataProductDefinitionsPath"),I=t=>{const e=V(t);return e||null},b=t=>(e,o,r,a)=>e.status===401||e.status===403?r.render("dpr/routes/authError.njk",{layoutPath:t,message:"Sorry, there is a problem with authenticating your request"}):((0,h.captureException)(e),e.status>=400?r.render("dpr/routes/serviceProblem.njk",{layoutPath:t}):a(e)),k=(t,e,o,r)=>async(a,i,s)=>{A(a,i);try{return await j(i,t.featureFlagService),await F(t,a,i,r),await E(t,i),T(o,i),s()}catch(n){return b(e)(n,a,i,s)}},T=(t,e)=>{t.addGlobal("getLocals",()=>({locals:{...e.locals,...e.app.locals}}))},j=async(t,e)=>{t.app.locals.featureFlags===void 0&&(t.app.locals.featureFlags={flags:{},lastUpdated:new Date().getTime()-601*1e3});const{featureFlags:o}=t.app.locals,r=new Date().getTime();if((r-o.lastUpdated)/1e3>600){t.app.locals.featureFlags.lastUpdated=r;const s=await e.getFlags().catch(n=>{throw t.app.locals.featureFlags.lastUpdated=r-601*1e3,n});t.app.locals.featureFlags.flags=Object.fromEntries(s.flags.map(n=>[n.key,n]))}},A=(t,e)=>{const o=t.flash("DPR_ERRORS");o&&o[0]&&(e.locals.validationErrors=JSON.parse(o[0]))},F=async(t,e,o,r)=>{const{token:a,dprUser:i}=m.default.getValues(o),s=I(e.query),n=e.body?.dataProductDefinitionsPath,l=s||n;l&&(o.locals.dpdPathFromQuery=!0);const g=r?.dataProductDefinitionsPath;g&&(o.locals.dpdPathFromConfig=!0),o.locals.definitionsPath=l||g,o.locals.pathSuffix=`?dataProductDefinitionsPath=${o.locals.definitionsPath}`;let p;a&&(p=await t.productCollectionStoreService.getSelectedProductCollectionId(i.id)),o.locals.definitions=await Promise.all([t.reportingService.getDefinitions(a,o.locals.definitionsPath),p&&t.productCollectionService.getProductCollection(a,p)]).then(([R,u])=>{if(u&&u){const w=u.products.map(f=>f.productId);return R.filter(f=>w.includes(f.id))}return R})??[]},E=async(t,e)=>{const{dprUser:o}=m.default.getValues(e);if(o.id){const{definitions:r,definitionsPath:a}=e.locals,i=await t.recentlyViewedService.getAllReports(o.id);await t.requestedReportService.cleanList(o.id,i);const s=await t.requestedReportService.getAllReports(o.id);if(e.locals.requestedReports=a?s.filter(n=>c.default.getCurrentVariantDefinition(r,n.reportId,n.id)):s,e.locals.recentlyViewedReports=a?i.filter(n=>c.default.getCurrentVariantDefinition(r,n.reportId,n.id)):i,e.locals.downloadingEnabled=t.downloadPermissionService.enabled,e.locals.bookmarkingEnabled=t.bookmarkService.enabled,e.locals.collectionsEnabled=t.productCollectionService.enabled,e.locals.requestMissingEnabled=t.missingReportService.enabled,e.locals.saveDefaultsEnabled=(0,D.isBooleanFlagEnabled)("saveDefaultsEnabled",e.app),e.locals.bookmarkingEnabled){const n=await t.bookmarkService.getAllBookmarks(o.id);e.locals.bookmarks=a?n.filter(l=>c.default.getCurrentVariantDefinition(r,l.reportId,l.id)):n}}};var B=k;0&&(module.exports={errorRequestHandler,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, ErrorRequestHandler, NextFunction } from 'express'\nimport type { ParsedQs } from 'qs'\nimport { HTTPError } from 'superagent'\nimport type { Environment } from 'nunjucks'\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'\nimport { FeatureFlagService, isBooleanFlagEnabled } from '../services/featureFlagService'\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 errorRequestHandler =\n (layoutPath: string): ErrorRequestHandler =>\n (error: HTTPError, _req: Request, res: Response, next: NextFunction) => {\n if (error.status === 401 || error.status === 403) {\n return res.render('dpr/routes/authError.njk', {\n layoutPath,\n message: 'Sorry, there is a problem with authenticating your request',\n })\n }\n if (error.status >= 400) {\n return res.render('dpr/routes/serviceProblem.njk', {\n layoutPath,\n })\n }\n return next()\n }\n\nexport const setupResources = (\n services: Services,\n layoutPath: string,\n env: Environment,\n config?: DprConfig,\n): RequestHandler => {\n return async (req, res, next) => {\n populateValidationErrors(req, res)\n try {\n await setFeatures(res, services.featureFlagService)\n await populateDefinitions(services, req, res, config)\n await populateRequestedReports(services, res)\n setupRequestAwareNunjucks(env, res)\n return next()\n } catch (error) {\n return errorRequestHandler(layoutPath)(error, req, res, next)\n }\n }\n}\n\nconst setupRequestAwareNunjucks = (env: Environment, res: Response) => {\n env.addGlobal('getLocals', () => ({ locals: { ...res.locals, ...res.app.locals } }))\n}\n\nconst setFeatures = async (res: Response, featureFlagService: FeatureFlagService) => {\n if (res.app.locals.featureFlags === undefined) {\n res.app.locals.featureFlags = {\n flags: {},\n lastUpdated: new Date().getTime() - 601 * 1000,\n }\n }\n const { featureFlags } = res.app.locals\n const currentTime = new Date().getTime()\n const timeSinceLastUpdatedSeconds = (currentTime - featureFlags.lastUpdated) / 1000\n const shouldUpdate = timeSinceLastUpdatedSeconds > 600\n if (shouldUpdate) {\n // Refresh every 10 mins\n res.app.locals.featureFlags.lastUpdated = currentTime\n const flags = await featureFlagService.getFlags().catch((e) => {\n res.app.locals.featureFlags.lastUpdated = currentTime - 601 * 1000\n throw e\n })\n res.app.locals.featureFlags.flags = Object.fromEntries(flags.flags.map((flag) => [flag.key, flag]))\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 let selectedProductCollectionId: string | undefined\n if (token) {\n selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\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\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 recent = await services.recentlyViewedService.getAllReports(dprUser.id)\n await services.requestedReportService.cleanList(dprUser.id, recent)\n const requested = await services.requestedReportService.getAllReports(dprUser.id)\n\n res.locals['requestedReports'] = !definitionsPath\n ? requested\n : requested.filter((report: RequestedReport) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['recentlyViewedReports'] = !definitionsPath\n ? recent\n : recent.filter((report: StoredReportData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['downloadingEnabled'] = services.downloadPermissionService.enabled\n res.locals['bookmarkingEnabled'] = services.bookmarkService.enabled\n res.locals['collectionsEnabled'] = services.productCollectionService.enabled\n res.locals['requestMissingEnabled'] = services.missingReportService.enabled\n res.locals['saveDefaultsEnabled'] = isBooleanFlagEnabled('saveDefaultsEnabled', res.app)\n\n if (res.locals['bookmarkingEnabled']) {\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}\n\nexport default setupResources\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,wBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAP,GAOA,IAAAQ,EAA4B,uCAG5BC,EAAyB,oCACzBC,EAAyD,0CAEzD,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,EAEab,EACVc,GACD,CAACC,EAAkBC,EAAeC,EAAeC,IAC3CH,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AM,CAAE,QAAAiB,CAAQ,EAAI,EAAAC,QAAa,UAAUlB,CAAG,EAC9C,GAAIiB,EAAQ,GAAI,CACd,KAAM,CAAE,YAAAY,EAAa,gBAAAjC,CAAgB,EAAII,EAAI,OAEvC8B,EAAS,MAAM5B,EAAS,sBAAsB,cAAce,EAAQ,EAAE,EAC5E,MAAMf,EAAS,uBAAuB,UAAUe,EAAQ,GAAIa,CAAM,EAClE,MAAMC,EAAY,MAAM7B,EAAS,uBAAuB,cAAce,EAAQ,EAAE,EAoBhF,GAlBAjB,EAAI,OAAO,iBAAuBJ,EAE9BmC,EAAU,OAAQC,GACT,EAAAC,QAAgB,4BAA4BJ,EAAaG,EAAO,SAAUA,EAAO,EAAE,CAC3F,EAHDD,EAKJ/B,EAAI,OAAO,sBAA4BJ,EAEnCkC,EAAO,OAAQE,GACN,EAAAC,QAAgB,4BAA4BJ,EAAaG,EAAO,SAAUA,EAAO,EAAE,CAC3F,EAHDF,EAKJ9B,EAAI,OAAO,mBAAwBE,EAAS,0BAA0B,QACtEF,EAAI,OAAO,mBAAwBE,EAAS,gBAAgB,QAC5DF,EAAI,OAAO,mBAAwBE,EAAS,yBAAyB,QACrEF,EAAI,OAAO,sBAA2BE,EAAS,qBAAqB,QACpEF,EAAI,OAAO,uBAAyB,wBAAqB,sBAAuBA,EAAI,GAAG,EAEnFA,EAAI,OAAO,mBAAuB,CACpC,MAAMkC,EAAY,MAAMhC,EAAS,gBAAgB,gBAAgBe,EAAQ,EAAE,EAC3EjB,EAAI,OAAO,UAAgBJ,EAEvBsC,EAAU,OAAQC,GACT,EAAAF,QAAgB,4BAA4BJ,EAAaM,EAAS,SAAUA,EAAS,EAAE,CAC/F,EAHDD,CAIN,CACF,CACF,EAEA,IAAOpD,EAAQI",
6
- "names": ["setUpDprResources_exports", "__export", "setUpDprResources_default", "errorRequestHandler", "populateDefinitions", "populateRequestedReports", "setupResources", "__toCommonJS", "import_definitionUtils", "import_localsHelper", "import_featureFlagService", "getQueryParamAsString", "query", "name", "getDefinitionsPath", "deriveDefinitionsPath", "definitionsPath", "layoutPath", "error", "_req", "res", "next", "services", "env", "config", "req", "populateValidationErrors", "setFeatures", "setupRequestAwareNunjucks", "featureFlagService", "featureFlags", "currentTime", "flags", "e", "flag", "errors", "token", "dprUser", "localsHelper", "dpdPathFromQuery", "dpdPathFromBody", "definitionsPathFromQuery", "dpdPathFromConfig", "selectedProductCollectionId", "defs", "selectedProductCollection", "productIds", "product", "def", "definitions", "recent", "requested", "report", "DefinitionUtils", "bookmarks", "bookmark"]
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RequestHandler, Response, Request, ErrorRequestHandler, NextFunction } from 'express'\nimport type { ParsedQs } from 'qs'\nimport { HTTPError } from 'superagent'\nimport type { Environment } from 'nunjucks'\nimport { captureException } from '@sentry/node'\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'\nimport { FeatureFlagService, isBooleanFlagEnabled } from '../services/featureFlagService'\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 errorRequestHandler =\n (layoutPath: string): ErrorRequestHandler =>\n (error: HTTPError, _req: Request, res: Response, next: NextFunction) => {\n if (error.status === 401 || error.status === 403) {\n return res.render('dpr/routes/authError.njk', {\n layoutPath,\n message: 'Sorry, there is a problem with authenticating your request',\n })\n }\n captureException(error)\n if (error.status >= 400) {\n return res.render('dpr/routes/serviceProblem.njk', {\n layoutPath,\n })\n }\n return next(error)\n }\n\nexport const setupResources = (\n services: Services,\n layoutPath: string,\n env: Environment,\n config?: DprConfig,\n): RequestHandler => {\n return async (req, res, next) => {\n populateValidationErrors(req, res)\n try {\n await setFeatures(res, services.featureFlagService)\n await populateDefinitions(services, req, res, config)\n await populateRequestedReports(services, res)\n setupRequestAwareNunjucks(env, res)\n return next()\n } catch (error) {\n return errorRequestHandler(layoutPath)(error, req, res, next)\n }\n }\n}\n\nconst setupRequestAwareNunjucks = (env: Environment, res: Response) => {\n env.addGlobal('getLocals', () => ({ locals: { ...res.locals, ...res.app.locals } }))\n}\n\nconst setFeatures = async (res: Response, featureFlagService: FeatureFlagService) => {\n if (res.app.locals.featureFlags === undefined) {\n res.app.locals.featureFlags = {\n flags: {},\n lastUpdated: new Date().getTime() - 601 * 1000,\n }\n }\n const { featureFlags } = res.app.locals\n const currentTime = new Date().getTime()\n const timeSinceLastUpdatedSeconds = (currentTime - featureFlags.lastUpdated) / 1000\n const shouldUpdate = timeSinceLastUpdatedSeconds > 600\n if (shouldUpdate) {\n // Refresh every 10 mins\n res.app.locals.featureFlags.lastUpdated = currentTime\n const flags = await featureFlagService.getFlags().catch((e) => {\n res.app.locals.featureFlags.lastUpdated = currentTime - 601 * 1000\n throw e\n })\n res.app.locals.featureFlags.flags = Object.fromEntries(flags.flags.map((flag) => [flag.key, flag]))\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 let selectedProductCollectionId: string | undefined\n if (token) {\n selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\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\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 recent = await services.recentlyViewedService.getAllReports(dprUser.id)\n await services.requestedReportService.cleanList(dprUser.id, recent)\n const requested = await services.requestedReportService.getAllReports(dprUser.id)\n\n res.locals['requestedReports'] = !definitionsPath\n ? requested\n : requested.filter((report: RequestedReport) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['recentlyViewedReports'] = !definitionsPath\n ? recent\n : recent.filter((report: StoredReportData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['downloadingEnabled'] = services.downloadPermissionService.enabled\n res.locals['bookmarkingEnabled'] = services.bookmarkService.enabled\n res.locals['collectionsEnabled'] = services.productCollectionService.enabled\n res.locals['requestMissingEnabled'] = services.missingReportService.enabled\n res.locals['saveDefaultsEnabled'] = isBooleanFlagEnabled('saveDefaultsEnabled', res.app)\n\n if (res.locals['bookmarkingEnabled']) {\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}\n\nexport default setupResources\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,wBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAAiC,wBAGjCC,EAA4B,uCAG5BC,EAAyB,oCACzBC,EAAyD,0CAEzD,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,EAEad,EACVe,GACD,CAACC,EAAkBC,EAAeC,EAAeC,IAC3CH,EAAM,SAAW,KAAOA,EAAM,SAAW,IACpCE,EAAI,OAAO,2BAA4B,CAC5C,WAAAH,EACA,QAAS,4DACX,CAAC,MAEH,oBAAiBC,CAAK,EAClBA,EAAM,QAAU,IACXE,EAAI,OAAO,gCAAiC,CACjD,WAAAH,CACF,CAAC,EAEII,EAAKH,CAAK,GAGRb,EAAiB,CAC5BiB,EACAL,EACAM,EACAC,IAEO,MAAOC,EAAKL,EAAKC,IAAS,CAC/BK,EAAyBD,EAAKL,CAAG,EACjC,GAAI,CACF,aAAMO,EAAYP,EAAKE,EAAS,kBAAkB,EAClD,MAAMnB,EAAoBmB,EAAUG,EAAKL,EAAKI,CAAM,EACpD,MAAMpB,EAAyBkB,EAAUF,CAAG,EAC5CQ,EAA0BL,EAAKH,CAAG,EAC3BC,EAAK,CACd,OAASH,EAAO,CACd,OAAOhB,EAAoBe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AAO,OAAQE,GACN,EAAAC,QAAgB,4BAA4BJ,EAAaG,EAAO,SAAUA,EAAO,EAAE,CAC3F,EAHDF,EAKJ9B,EAAI,OAAO,mBAAwBE,EAAS,0BAA0B,QACtEF,EAAI,OAAO,mBAAwBE,EAAS,gBAAgB,QAC5DF,EAAI,OAAO,mBAAwBE,EAAS,yBAAyB,QACrEF,EAAI,OAAO,sBAA2BE,EAAS,qBAAqB,QACpEF,EAAI,OAAO,uBAAyB,wBAAqB,sBAAuBA,EAAI,GAAG,EAEnFA,EAAI,OAAO,mBAAuB,CACpC,MAAMkC,EAAY,MAAMhC,EAAS,gBAAgB,gBAAgBe,EAAQ,EAAE,EAC3EjB,EAAI,OAAO,UAAgBJ,EAEvBsC,EAAU,OAAQC,GACT,EAAAF,QAAgB,4BAA4BJ,EAAaM,EAAS,SAAUA,EAAS,EAAE,CAC/F,EAHDD,CAIN,CACF,CACF,EAEA,IAAOrD,EAAQI",
6
+ "names": ["setUpDprResources_exports", "__export", "setUpDprResources_default", "errorRequestHandler", "populateDefinitions", "populateRequestedReports", "setupResources", "__toCommonJS", "import_node", "import_definitionUtils", "import_localsHelper", "import_featureFlagService", "getQueryParamAsString", "query", "name", "getDefinitionsPath", "deriveDefinitionsPath", "definitionsPath", "layoutPath", "error", "_req", "res", "next", "services", "env", "config", "req", "populateValidationErrors", "setFeatures", "setupRequestAwareNunjucks", "featureFlagService", "featureFlags", "currentTime", "flags", "e", "flag", "errors", "token", "dprUser", "localsHelper", "dpdPathFromQuery", "dpdPathFromBody", "definitionsPathFromQuery", "dpdPathFromConfig", "selectedProductCollectionId", "defs", "selectedProductCollection", "productIds", "product", "def", "definitions", "recent", "requested", "report", "DefinitionUtils", "bookmarks", "bookmark"]
7
7
  }
@@ -3,6 +3,7 @@ import { RequestHandler, Response, Request, ErrorRequestHandler, NextFunction }
3
3
  import type { ParsedQs } from 'qs'
4
4
  import { HTTPError } from 'superagent'
5
5
  import type { Environment } from 'nunjucks'
6
+ import { captureException } from '@sentry/node'
6
7
  import { Services } from '../types/Services'
7
8
  import { RequestedReport, StoredReportData } from '../types/UserReports'
8
9
  import DefinitionUtils from '../utils/definitionUtils'
@@ -32,12 +33,13 @@ export const errorRequestHandler =
32
33
  message: 'Sorry, there is a problem with authenticating your request',
33
34
  })
34
35
  }
36
+ captureException(error)
35
37
  if (error.status >= 400) {
36
38
  return res.render('dpr/routes/serviceProblem.njk', {
37
39
  layoutPath,
38
40
  })
39
41
  }
40
- return next()
42
+ return next(error)
41
43
  }
42
44
 
43
45
  export const setupResources = (
@@ -1,2 +1,2 @@
1
- "use strict";var R=Object.create;var d=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var I=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},g=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of $(e))!C.call(r,o)&&o!==t&&d(r,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return r};var P=(r,e,t)=>(t=r!=null?R(b(r)):{},g(e||!r||!r.__esModule?d(t,"default",{value:r,enumerable:!0}):t,r)),T=r=>g(d({},"__esModule",{value:!0}),r);var k={};I(k,{RequestDownloadController:()=>h,default:()=>H});module.exports=T(k);var D=P(require("../../../../../utils/localsHelper")),f=require("../../../../../types/UserReports"),w=P(require("../../../../../utils/logger"));class h{layoutPath;services;constructor(e,t){this.layoutPath=e,this.services=t}GET=async(e,t,n)=>{const{token:o,csrfToken:m,definitionsPath:p,dprUser:l}=D.default.getValues(t),{reportId:c,variantId:i,tableId:a}=e.params,u=a?f.LoadType.ASYNC:f.LoadType.SYNC,{reportSearch:s,reportUrl:N}=e.query;let S,y;s&&(S=decodeURIComponent(s),y=new URLSearchParams(S).get("dataProductDefinitionsPath")||p);const v=await this.services.reportingService.getDefinition(o,c,i,y);try{t.render("dpr/routes/journeys/download-report/request-download/form/view",{title:"Download request form",user:l,report:{reportId:c,reportName:v.name,variantId:i,variantName:v.variant.name,tableId:a,loadType:u,reportUrl:N,reportSearch:s||void 0,time:new Date().toDateString()},csrfToken:m,layoutPath:this.layoutPath})}catch{n()}};POST=async(e,t,n)=>{const{body:o,baseUrl:m}=e,{reportName:p,variantName:l,reportUrl:c,reportSearch:i}=o;w.default.info("Download Feedback Submission:",`${JSON.stringify(o)}`);let a;if(a=`?reportName=${p}&variantName=${l}&reportUrl=${c}`,i){const s=encodeURIComponent(i);a=`${a}&reportSearch=${s}`}const u=`${m}/submitted${a}`;t.redirect(u)}}var H=h;0&&(module.exports={RequestDownloadController});
1
+ "use strict";var R=Object.create;var d=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var I=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},P=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of $(e))!C.call(r,o)&&o!==t&&d(r,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return r};var D=(r,e,t)=>(t=r!=null?R(b(r)):{},P(e||!r||!r.__esModule?d(t,"default",{value:r,enumerable:!0}):t,r)),T=r=>P(d({},"__esModule",{value:!0}),r);var k={};I(k,{RequestDownloadController:()=>h,default:()=>H});module.exports=T(k);var w=D(require("../../../../../utils/localsHelper")),f=require("../../../../../types/UserReports"),N=D(require("../../../../../utils/logger"));class h{layoutPath;services;constructor(e,t){this.layoutPath=e,this.services=t}GET=async(e,t,n)=>{const{token:o,csrfToken:m,definitionsPath:p,dprUser:l}=w.default.getValues(t),{reportId:c,variantId:i,tableId:a}=e.params,u=a?f.LoadType.ASYNC:f.LoadType.SYNC,{reportSearch:s,reportUrl:q}=e.query;let S,y;s&&(S=decodeURIComponent(s),y=new URLSearchParams(S).get("dataProductDefinitionsPath")||p);const v=await this.services.reportingService.getDefinition(o,c,i,y);try{t.render("dpr/routes/journeys/download-report/request-download/form/view",{title:"Download request form",user:l,report:{reportId:c,reportName:v.name,variantId:i,variantName:v.variant.name,tableId:a,loadType:u,reportUrl:q,reportSearch:s||void 0,time:new Date().toDateString()},csrfToken:m,layoutPath:this.layoutPath})}catch(g){n(g)}};POST=async(e,t,n)=>{const{body:o,baseUrl:m}=e,{reportName:p,variantName:l,reportUrl:c,reportSearch:i}=o;N.default.info("Download Feedback Submission:",`${JSON.stringify(o)}`);let a;if(a=`?reportName=${p}&variantName=${l}&reportUrl=${c}`,i){const s=encodeURIComponent(i);a=`${a}&reportSearch=${s}`}const u=`${m}/submitted${a}`;t.redirect(u)}}var H=h;0&&(module.exports={RequestDownloadController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/download-report/request-download/form/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { components } from '../../../../../types/api'\nimport { Services } from '../../../../../types/Services'\nimport { LoadType } from '../../../../../types/UserReports'\nimport logger from '../../../../../utils/logger'\n\nclass RequestDownloadController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { token, csrfToken, definitionsPath, dprUser } = LocalsHelper.getValues(res)\n const { reportId, variantId, tableId } = req.params\n const loadType = tableId ? LoadType.ASYNC : LoadType.SYNC\n\n const { reportSearch, reportUrl } = req.query\n let queryString\n let dataProductDefinitionsPath\n\n if (reportSearch) {\n queryString = decodeURIComponent(<string>reportSearch)\n const params = new URLSearchParams(queryString)\n dataProductDefinitionsPath = params.get('dataProductDefinitionsPath') || definitionsPath\n }\n\n const variantData: components['schemas']['SingleVariantReportDefinition'] =\n await this.services.reportingService.getDefinition(token, reportId, variantId, dataProductDefinitionsPath)\n\n try {\n res.render(`dpr/routes/journeys/download-report/request-download/form/view`, {\n title: 'Download request form',\n user: dprUser,\n report: {\n reportId,\n reportName: variantData.name,\n variantId,\n variantName: variantData.variant.name,\n tableId,\n loadType,\n reportUrl,\n reportSearch: reportSearch || undefined,\n time: new Date().toDateString(),\n },\n csrfToken,\n layoutPath: this.layoutPath,\n })\n } catch (error) {\n next()\n }\n }\n\n POST: RequestHandler = async (req, res, _next) => {\n const { body, baseUrl } = req\n const { reportName, variantName, reportUrl, reportSearch } = body\n logger.info('Download Feedback Submission:', `${JSON.stringify(body)}`)\n\n let queryParams\n queryParams = `?reportName=${reportName}&variantName=${variantName}&reportUrl=${reportUrl}`\n\n if (reportSearch) {\n const encodedSearch = encodeURIComponent(reportSearch)\n queryParams = `${queryParams}&reportSearch=${encodedSearch}`\n }\n\n const redirect = `${baseUrl}/submitted${queryParams}`\n\n res.redirect(redirect)\n }\n}\n\nexport { RequestDownloadController }\nexport default RequestDownloadController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAGzBC,EAAyB,4CACzBC,EAAmB,0CAEnB,MAAML,CAA0B,CAC9B,WAEA,SAEA,YAAYM,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,MAAAC,EAAO,UAAAC,EAAW,gBAAAC,EAAiB,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUN,CAAG,EAC3E,CAAE,SAAAO,EAAU,UAAAC,EAAW,QAAAC,CAAQ,EAAIV,EAAI,OACvCW,EAAWD,EAAU,WAAS,MAAQ,WAAS,KAE/C,CAAE,aAAAE,EAAc,UAAAC,CAAU,EAAIb,EAAI,MACxC,IAAIc,EACAC,EAEAH,IACFE,EAAc,mBAA2BF,CAAY,EAErDG,EADe,IAAI,gBAAgBD,CAAW,EACV,IAAI,4BAA4B,GAAKT,GAG3E,MAAMW,EACJ,MAAM,KAAK,SAAS,iBAAiB,cAAcb,EAAOK,EAAUC,EAAWM,CAA0B,EAE3G,GAAI,CACFd,EAAI,OAAO,iEAAkE,CAC3E,MAAO,wBACP,KAAMK,EACN,OAAQ,CACN,SAAAE,EACA,WAAYQ,EAAY,KACxB,UAAAP,EACA,YAAaO,EAAY,QAAQ,KACjC,QAAAN,EACA,SAAAC,EACA,UAAAE,EACA,aAAcD,GAAgB,OAC9B,KAAM,IAAI,KAAK,EAAE,aAAa,CAChC,EACA,UAAAR,EACA,WAAY,KAAK,UACnB,CAAC,CACH,MAAgB,CACdF,EAAK,CACP,CACF,EAEA,KAAuB,MAAOF,EAAKC,EAAKgB,IAAU,CAChD,KAAM,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAInB,EACpB,CAAE,WAAAoB,EAAY,YAAAC,EAAa,UAAAR,EAAW,aAAAD,CAAa,EAAIM,EAC7D,EAAAI,QAAO,KAAK,gCAAiC,GAAG,KAAK,UAAUJ,CAAI,CAAC,EAAE,EAEtE,IAAIK,EAGJ,GAFAA,EAAc,eAAeH,CAAU,gBAAgBC,CAAW,cAAcR,CAAS,GAErFD,EAAc,CAChB,MAAMY,EAAgB,mBAAmBZ,CAAY,EACrDW,EAAc,GAAGA,CAAW,iBAAiBC,CAAa,EAC5D,CAEA,MAAMC,EAAW,GAAGN,CAAO,aAAaI,CAAW,GAEnDtB,EAAI,SAASwB,CAAQ,CACvB,CACF,CAGA,IAAOhC,EAAQD",
6
- "names": ["controller_exports", "__export", "RequestDownloadController", "controller_default", "__toCommonJS", "import_localsHelper", "import_UserReports", "import_logger", "layoutPath", "services", "req", "res", "next", "token", "csrfToken", "definitionsPath", "dprUser", "LocalsHelper", "reportId", "variantId", "tableId", "loadType", "reportSearch", "reportUrl", "queryString", "dataProductDefinitionsPath", "variantData", "_next", "body", "baseUrl", "reportName", "variantName", "logger", "queryParams", "encodedSearch", "redirect"]
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { components } from '../../../../../types/api'\nimport { Services } from '../../../../../types/Services'\nimport { LoadType } from '../../../../../types/UserReports'\nimport logger from '../../../../../utils/logger'\n\nclass RequestDownloadController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { token, csrfToken, definitionsPath, dprUser } = LocalsHelper.getValues(res)\n const { reportId, variantId, tableId } = req.params\n const loadType = tableId ? LoadType.ASYNC : LoadType.SYNC\n\n const { reportSearch, reportUrl } = req.query\n let queryString\n let dataProductDefinitionsPath\n\n if (reportSearch) {\n queryString = decodeURIComponent(<string>reportSearch)\n const params = new URLSearchParams(queryString)\n dataProductDefinitionsPath = params.get('dataProductDefinitionsPath') || definitionsPath\n }\n\n const variantData: components['schemas']['SingleVariantReportDefinition'] =\n await this.services.reportingService.getDefinition(token, reportId, variantId, dataProductDefinitionsPath)\n\n try {\n res.render(`dpr/routes/journeys/download-report/request-download/form/view`, {\n title: 'Download request form',\n user: dprUser,\n report: {\n reportId,\n reportName: variantData.name,\n variantId,\n variantName: variantData.variant.name,\n tableId,\n loadType,\n reportUrl,\n reportSearch: reportSearch || undefined,\n time: new Date().toDateString(),\n },\n csrfToken,\n layoutPath: this.layoutPath,\n })\n } catch (error) {\n next(error)\n }\n }\n\n POST: RequestHandler = async (req, res, _next) => {\n const { body, baseUrl } = req\n const { reportName, variantName, reportUrl, reportSearch } = body\n logger.info('Download Feedback Submission:', `${JSON.stringify(body)}`)\n\n let queryParams\n queryParams = `?reportName=${reportName}&variantName=${variantName}&reportUrl=${reportUrl}`\n\n if (reportSearch) {\n const encodedSearch = encodeURIComponent(reportSearch)\n queryParams = `${queryParams}&reportSearch=${encodedSearch}`\n }\n\n const redirect = `${baseUrl}/submitted${queryParams}`\n\n res.redirect(redirect)\n }\n}\n\nexport { RequestDownloadController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WAAAqB,EAAY,YAAAC,EAAa,UAAAT,EAAW,aAAAD,CAAa,EAAIO,EAC7D,EAAAI,QAAO,KAAK,gCAAiC,GAAG,KAAK,UAAUJ,CAAI,CAAC,EAAE,EAEtE,IAAIK,EAGJ,GAFAA,EAAc,eAAeH,CAAU,gBAAgBC,CAAW,cAAcT,CAAS,GAErFD,EAAc,CAChB,MAAMa,EAAgB,mBAAmBb,CAAY,EACrDY,EAAc,GAAGA,CAAW,iBAAiBC,CAAa,EAC5D,CAEA,MAAMC,EAAW,GAAGN,CAAO,aAAaI,CAAW,GAEnDvB,EAAI,SAASyB,CAAQ,CACvB,CACF,CAGA,IAAOjC,EAAQD",
6
+ "names": ["controller_exports", "__export", "RequestDownloadController", "controller_default", "__toCommonJS", "import_localsHelper", "import_UserReports", "import_logger", "layoutPath", "services", "req", "res", "next", "token", "csrfToken", "definitionsPath", "dprUser", "LocalsHelper", "reportId", "variantId", "tableId", "loadType", "reportSearch", "reportUrl", "queryString", "dataProductDefinitionsPath", "variantData", "error", "_next", "body", "baseUrl", "reportName", "variantName", "logger", "queryParams", "encodedSearch", "redirect"]
7
7
  }
@@ -52,7 +52,7 @@ class RequestDownloadController {
52
52
  layoutPath: this.layoutPath,
53
53
  })
54
54
  } catch (error) {
55
- next()
55
+ next(error)
56
56
  }
57
57
  }
58
58
 
@@ -1,2 +1,2 @@
1
- "use strict";var S=Object.create;var d=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},h=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of y(e))!P.call(t,i)&&i!==r&&d(t,i,{get:()=>e[i],enumerable:!(n=R(e,i))||n.enumerable});return t};var b=(t,e,r)=>(r=t!=null?S(q(t)):{},h(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),I=t=>h(d({},"__esModule",{value:!0}),t);var w={};$(w,{MissingReportFormController:()=>u,default:()=>E});module.exports=I(w);var g=b(require("../../../../utils/localsHelper"));class u{layoutPath;missingReportService;reportingService;constructor(e,r){this.layoutPath=e,this.missingReportService=r.missingReportService,this.reportingService=r.reportingService}GET=async(e,r,n)=>{const{token:i,csrfToken:p,definitionsPath:c,dprUser:v}=g.default.getValues(r),{reportId:s,variantId:a}=e.params,m=await this.reportingService.getDefinition(i,s,a,c??"definitions/prisons/missing"),{variant:o,name:l}=m;try{r.render("dpr/routes/journeys/request-missing-report/form/view",{title:"This report is not available",report:{reportId:s,variantId:a,reportName:l,name:o.name,description:o.description||m.description},user:v,csrfToken:p,layoutPath:this.layoutPath,postEndpoint:`/dpr/request-missing-report/${s}/${a}/form/submit`})}catch{n()}};POST=async(e,r,n)=>{const{body:i}=e,{reportId:p,variantId:c,reportName:v,variantName:s,"more-detail":a}=i,{token:m}=g.default.getValues(r);try{const o=this.missingReportService.submitMissingReportEntry(m,p,c,a);o&&o.then(()=>{const f=`./submitted?${`reportName=${v}&name=${s}&reportId=${p}&variantId=${c}`}`;r.redirect(f)},()=>{r.render("dpr/components/serviceError/view")})}catch{r.render("dpr/components/serviceError/view")}}}var E=u;0&&(module.exports={MissingReportFormController});
1
+ "use strict";var R=Object.create;var u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var r in e)u(t,r,{get:e[r],enumerable:!0})},S=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of q(e))!$.call(t,i)&&i!==r&&u(t,i,{get:()=>e[i],enumerable:!(n=y(e,i))||n.enumerable});return t};var E=(t,e,r)=>(r=t!=null?R(P(t)):{},S(e||!t||!t.__esModule?u(r,"default",{value:t,enumerable:!0}):r,t)),I=t=>S(u({},"__esModule",{value:!0}),t);var x={};b(x,{MissingReportFormController:()=>h,default:()=>w});module.exports=I(x);var l=require("@sentry/node"),f=E(require("../../../../utils/localsHelper"));class h{layoutPath;missingReportService;reportingService;constructor(e,r){this.layoutPath=e,this.missingReportService=r.missingReportService,this.reportingService=r.reportingService}GET=async(e,r,n)=>{const{token:i,csrfToken:p,definitionsPath:c,dprUser:v}=f.default.getValues(r),{reportId:s,variantId:a}=e.params,m=await this.reportingService.getDefinition(i,s,a,c??"definitions/prisons/missing"),{variant:o,name:d}=m;try{r.render("dpr/routes/journeys/request-missing-report/form/view",{title:"This report is not available",report:{reportId:s,variantId:a,reportName:d,name:o.name,description:o.description||m.description},user:v,csrfToken:p,layoutPath:this.layoutPath,postEndpoint:`/dpr/request-missing-report/${s}/${a}/form/submit`})}catch(g){n(g)}};POST=async(e,r,n)=>{const{body:i}=e,{reportId:p,variantId:c,reportName:v,variantName:s,"more-detail":a}=i,{token:m}=f.default.getValues(r);try{const o=this.missingReportService.submitMissingReportEntry(m,p,c,a);o&&o.then(()=>{const g=`./submitted?${`reportName=${v}&name=${s}&reportId=${p}&variantId=${c}`}`;r.redirect(g)},d=>{(0,l.captureException)(d),r.render("dpr/components/serviceError/view")})}catch(o){(0,l.captureException)(o),r.render("dpr/components/serviceError/view")}}}var w=h;0&&(module.exports={MissingReportFormController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/request-missing-report/form/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport LocalsHelper from '../../../../utils/localsHelper'\nimport { components } from '../../../../types/api'\nimport { Services } from '../../../../types/Services'\nimport MissingReportService from '../../../../services/missingReport/missingReportService'\nimport { ReportingService } from '../../../../services'\n\nclass MissingReportFormController {\n layoutPath: string\n\n missingReportService: MissingReportService\n\n reportingService: ReportingService\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.missingReportService = services.missingReportService\n this.reportingService = services.reportingService\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { token, csrfToken, definitionsPath, dprUser } = LocalsHelper.getValues(res)\n const { reportId, variantId } = req.params\n\n const reportDefinition: components['schemas']['SingleVariantReportDefinition'] =\n await this.reportingService.getDefinition(\n token,\n reportId,\n variantId,\n definitionsPath ?? 'definitions/prisons/missing',\n )\n\n const { variant, name } = reportDefinition\n\n try {\n res.render(`dpr/routes/journeys/request-missing-report/form/view`, {\n title: 'This report is not available',\n report: {\n reportId,\n variantId,\n reportName: name,\n name: variant.name,\n description: variant.description || reportDefinition.description,\n },\n user: dprUser,\n csrfToken,\n layoutPath: this.layoutPath,\n postEndpoint: `/dpr/request-missing-report/${reportId}/${variantId}/form/submit`,\n })\n } catch (error) {\n next()\n }\n }\n\n POST: RequestHandler = async (req, res, _next) => {\n const { body } = req\n const { reportId, variantId, reportName, variantName, 'more-detail': requestDetails } = body\n\n const { token } = LocalsHelper.getValues(res)\n\n try {\n const submission = this.missingReportService.submitMissingReportEntry(token, reportId, variantId, requestDetails)\n if (submission) {\n submission.then(\n () => {\n const queryParams = `reportName=${reportName}&name=${variantName}&reportId=${reportId}&variantId=${variantId}`\n const redirect = `./submitted?${queryParams}`\n\n res.redirect(redirect)\n },\n () => {\n res.render(`dpr/components/serviceError/view`)\n },\n )\n }\n } catch (_error) {\n res.render(`dpr/components/serviceError/view`)\n }\n }\n}\n\nexport { MissingReportFormController }\nexport default MissingReportFormController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,6CAMzB,MAAMH,CAA4B,CAChC,WAEA,qBAEA,iBAEA,YAAYI,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,qBAAuBC,EAAS,qBACrC,KAAK,iBAAmBA,EAAS,gBACnC,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,MAAAC,EAAO,UAAAC,EAAW,gBAAAC,EAAiB,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUN,CAAG,EAC3E,CAAE,SAAAO,EAAU,UAAAC,CAAU,EAAIT,EAAI,OAE9BU,EACJ,MAAM,KAAK,iBAAiB,cAC1BP,EACAK,EACAC,EACAJ,GAAmB,6BACrB,EAEI,CAAE,QAAAM,EAAS,KAAAC,CAAK,EAAIF,EAE1B,GAAI,CACFT,EAAI,OAAO,uDAAwD,CACjE,MAAO,+BACP,OAAQ,CACN,SAAAO,EACA,UAAAC,EACA,WAAYG,EACZ,KAAMD,EAAQ,KACd,YAAaA,EAAQ,aAAeD,EAAiB,WACvD,EACA,KAAMJ,EACN,UAAAF,EACA,WAAY,KAAK,WACjB,aAAc,+BAA+BI,CAAQ,IAAIC,CAAS,cACpE,CAAC,CACH,MAAgB,CACdP,EAAK,CACP,CACF,EAEA,KAAuB,MAAOF,EAAKC,EAAKY,IAAU,CAChD,KAAM,CAAE,KAAAC,CAAK,EAAId,EACX,CAAE,SAAAQ,EAAU,UAAAC,EAAW,WAAAM,EAAY,YAAAC,EAAa,cAAeC,CAAe,EAAIH,EAElF,CAAE,MAAAX,CAAM,EAAI,EAAAI,QAAa,UAAUN,CAAG,EAE5C,GAAI,CACF,MAAMiB,EAAa,KAAK,qBAAqB,yBAAyBf,EAAOK,EAAUC,EAAWQ,CAAc,EAC5GC,GACFA,EAAW,KACT,IAAM,CAEJ,MAAMC,EAAW,eADG,cAAcJ,CAAU,SAASC,CAAW,aAAaR,CAAQ,cAAcC,CAAS,EACjE,GAE3CR,EAAI,SAASkB,CAAQ,CACvB,EACA,IAAM,CACJlB,EAAI,OAAO,kCAAkC,CAC/C,CACF,CAEJ,MAAiB,CACfA,EAAI,OAAO,kCAAkC,CAC/C,CACF,CACF,CAGA,IAAON,EAAQD",
6
- "names": ["controller_exports", "__export", "MissingReportFormController", "controller_default", "__toCommonJS", "import_localsHelper", "layoutPath", "services", "req", "res", "next", "token", "csrfToken", "definitionsPath", "dprUser", "LocalsHelper", "reportId", "variantId", "reportDefinition", "variant", "name", "_next", "body", "reportName", "variantName", "requestDetails", "submission", "redirect"]
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { captureException } from '@sentry/node'\nimport LocalsHelper from '../../../../utils/localsHelper'\nimport { components } from '../../../../types/api'\nimport { Services } from '../../../../types/Services'\nimport MissingReportService from '../../../../services/missingReport/missingReportService'\nimport { ReportingService } from '../../../../services'\n\nclass MissingReportFormController {\n layoutPath: string\n\n missingReportService: MissingReportService\n\n reportingService: ReportingService\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.missingReportService = services.missingReportService\n this.reportingService = services.reportingService\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { token, csrfToken, definitionsPath, dprUser } = LocalsHelper.getValues(res)\n const { reportId, variantId } = req.params\n\n const reportDefinition: components['schemas']['SingleVariantReportDefinition'] =\n await this.reportingService.getDefinition(\n token,\n reportId,\n variantId,\n definitionsPath ?? 'definitions/prisons/missing',\n )\n\n const { variant, name } = reportDefinition\n\n try {\n res.render(`dpr/routes/journeys/request-missing-report/form/view`, {\n title: 'This report is not available',\n report: {\n reportId,\n variantId,\n reportName: name,\n name: variant.name,\n description: variant.description || reportDefinition.description,\n },\n user: dprUser,\n csrfToken,\n layoutPath: this.layoutPath,\n postEndpoint: `/dpr/request-missing-report/${reportId}/${variantId}/form/submit`,\n })\n } catch (error) {\n next(error)\n }\n }\n\n POST: RequestHandler = async (req, res, _next) => {\n const { body } = req\n const { reportId, variantId, reportName, variantName, 'more-detail': requestDetails } = body\n\n const { token } = LocalsHelper.getValues(res)\n\n try {\n const submission = this.missingReportService.submitMissingReportEntry(token, reportId, variantId, requestDetails)\n if (submission) {\n submission.then(\n () => {\n const queryParams = `reportName=${reportName}&name=${variantName}&reportId=${reportId}&variantId=${variantId}`\n const redirect = `./submitted?${queryParams}`\n\n res.redirect(redirect)\n },\n (err) => {\n captureException(err)\n res.render(`dpr/components/serviceError/view`)\n },\n )\n }\n } catch (error) {\n captureException(error)\n res.render(`dpr/components/serviceError/view`)\n }\n }\n}\n\nexport { MissingReportFormController }\nexport default MissingReportFormController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAiC,wBACjCC,EAAyB,6CAMzB,MAAMJ,CAA4B,CAChC,WAEA,qBAEA,iBAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,qBAAuBC,EAAS,qBACrC,KAAK,iBAAmBA,EAAS,gBACnC,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,MAAAC,EAAO,UAAAC,EAAW,gBAAAC,EAAiB,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUN,CAAG,EAC3E,CAAE,SAAAO,EAAU,UAAAC,CAAU,EAAIT,EAAI,OAE9BU,EACJ,MAAM,KAAK,iBAAiB,cAC1BP,EACAK,EACAC,EACAJ,GAAmB,6BACrB,EAEI,CAAE,QAAAM,EAAS,KAAAC,CAAK,EAAIF,EAE1B,GAAI,CACFT,EAAI,OAAO,uDAAwD,CACjE,MAAO,+BACP,OAAQ,CACN,SAAAO,EACA,UAAAC,EACA,WAAYG,EACZ,KAAMD,EAAQ,KACd,YAAaA,EAAQ,aAAeD,EAAiB,WACvD,EACA,KAAMJ,EACN,UAAAF,EACA,WAAY,KAAK,WACjB,aAAc,+BAA+BI,CAAQ,IAAIC,CAAS,cACpE,CAAC,CACH,OAASI,EAAO,CACdX,EAAKW,CAAK,CACZ,CACF,EAEA,KAAuB,MAAOb,EAAKC,EAAKa,IAAU,CAChD,KAAM,CAAE,KAAAC,CAAK,EAAIf,EACX,CAAE,SAAAQ,EAAU,UAAAC,EAAW,WAAAO,EAAY,YAAAC,EAAa,cAAeC,CAAe,EAAIH,EAElF,CAAE,MAAAZ,CAAM,EAAI,EAAAI,QAAa,UAAUN,CAAG,EAE5C,GAAI,CACF,MAAMkB,EAAa,KAAK,qBAAqB,yBAAyBhB,EAAOK,EAAUC,EAAWS,CAAc,EAC5GC,GACFA,EAAW,KACT,IAAM,CAEJ,MAAMC,EAAW,eADG,cAAcJ,CAAU,SAASC,CAAW,aAAaT,CAAQ,cAAcC,CAAS,EACjE,GAE3CR,EAAI,SAASmB,CAAQ,CACvB,EACCC,GAAQ,IACP,oBAAiBA,CAAG,EACpBpB,EAAI,OAAO,kCAAkC,CAC/C,CACF,CAEJ,OAASY,EAAO,IACd,oBAAiBA,CAAK,EACtBZ,EAAI,OAAO,kCAAkC,CAC/C,CACF,CACF,CAGA,IAAOP,EAAQD",
6
+ "names": ["controller_exports", "__export", "MissingReportFormController", "controller_default", "__toCommonJS", "import_node", "import_localsHelper", "layoutPath", "services", "req", "res", "next", "token", "csrfToken", "definitionsPath", "dprUser", "LocalsHelper", "reportId", "variantId", "reportDefinition", "variant", "name", "error", "_next", "body", "reportName", "variantName", "requestDetails", "submission", "redirect", "err"]
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { RequestHandler } from 'express'
2
+ import { captureException } from '@sentry/node'
2
3
  import LocalsHelper from '../../../../utils/localsHelper'
3
4
  import { components } from '../../../../types/api'
4
5
  import { Services } from '../../../../types/Services'
@@ -48,7 +49,7 @@ class MissingReportFormController {
48
49
  postEndpoint: `/dpr/request-missing-report/${reportId}/${variantId}/form/submit`,
49
50
  })
50
51
  } catch (error) {
51
- next()
52
+ next(error)
52
53
  }
53
54
  }
54
55
 
@@ -68,12 +69,14 @@ class MissingReportFormController {
68
69
 
69
70
  res.redirect(redirect)
70
71
  },
71
- () => {
72
+ (err) => {
73
+ captureException(err)
72
74
  res.render(`dpr/components/serviceError/view`)
73
75
  },
74
76
  )
75
77
  }
76
- } catch (_error) {
78
+ } catch (error) {
79
+ captureException(error)
77
80
  res.render(`dpr/components/serviceError/view`)
78
81
  }
79
82
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.create;var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},i=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of h(e))!q.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(s=y(e,o))||s.enumerable});return t};var R=(t,e,r)=>(r=t!=null?c(g(t)):{},i(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t)),b=t=>i(a({},"__esModule",{value:!0}),t);var H={};P(H,{MissingReportSubmittedController:()=>u,default:()=>f});module.exports=b(H);var l=R(require("../../../../utils/localsHelper"));class u{layoutPath;constructor(e){this.layoutPath=e}GET=async(e,r,s)=>{const{nestedBaseUrl:o}=l.default.getValues(r),{reportId:n,variantId:d,reportName:p,name:m}=e.query;try{r.render("dpr/routes/journeys/request-missing-report/submitted/view",{title:"Request submitted",report:{reportId:n,variantId:d,reportName:p,name:m},nestedBaseUrl:o,layoutPath:this.layoutPath})}catch{s()}}}var f=u;0&&(module.exports={MissingReportSubmittedController});
1
+ "use strict";var y=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},i=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!P.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(s=h(e,o))||s.enumerable});return t};var b=(t,e,r)=>(r=t!=null?y(q(t)):{},i(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t)),f=t=>i(a({},"__esModule",{value:!0}),t);var v={};R(v,{MissingReportSubmittedController:()=>u,default:()=>H});module.exports=f(v);var l=b(require("../../../../utils/localsHelper"));class u{layoutPath;constructor(e){this.layoutPath=e}GET=async(e,r,s)=>{const{nestedBaseUrl:o}=l.default.getValues(r),{reportId:n,variantId:d,reportName:p,name:m}=e.query;try{r.render("dpr/routes/journeys/request-missing-report/submitted/view",{title:"Request submitted",report:{reportId:n,variantId:d,reportName:p,name:m},nestedBaseUrl:o,layoutPath:this.layoutPath})}catch(c){s(c)}}}var H=u;0&&(module.exports={MissingReportSubmittedController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/request-missing-report/submitted/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport localsHelper from '../../../../utils/localsHelper'\n\nclass MissingReportSubmittedController {\n layoutPath: string\n\n constructor(layoutPath: string) {\n this.layoutPath = layoutPath\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { nestedBaseUrl } = localsHelper.getValues(res)\n const { reportId, variantId, reportName, name } = req.query\n\n try {\n res.render(`dpr/routes/journeys/request-missing-report/submitted/view`, {\n title: 'Request submitted',\n report: {\n reportId,\n variantId,\n reportName,\n name,\n },\n nestedBaseUrl,\n layoutPath: this.layoutPath,\n })\n } catch (error) {\n next()\n }\n }\n}\n\nexport { MissingReportSubmittedController }\nexport default MissingReportSubmittedController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,6CAEzB,MAAMH,CAAiC,CACrC,WAEA,YAAYI,EAAoB,CAC9B,KAAK,WAAaA,CACpB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,cAAAC,CAAc,EAAI,EAAAC,QAAa,UAAUH,CAAG,EAC9C,CAAE,SAAAI,EAAU,UAAAC,EAAW,WAAAC,EAAY,KAAAC,CAAK,EAAIR,EAAI,MAEtD,GAAI,CACFC,EAAI,OAAO,4DAA6D,CACtE,MAAO,oBACP,OAAQ,CACN,SAAAI,EACA,UAAAC,EACA,WAAAC,EACA,KAAAC,CACF,EACA,cAAAL,EACA,WAAY,KAAK,UACnB,CAAC,CACH,MAAgB,CACdD,EAAK,CACP,CACF,CACF,CAGA,IAAON,EAAQD",
6
- "names": ["controller_exports", "__export", "MissingReportSubmittedController", "controller_default", "__toCommonJS", "import_localsHelper", "layoutPath", "req", "res", "next", "nestedBaseUrl", "localsHelper", "reportId", "variantId", "reportName", "name"]
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport localsHelper from '../../../../utils/localsHelper'\n\nclass MissingReportSubmittedController {\n layoutPath: string\n\n constructor(layoutPath: string) {\n this.layoutPath = layoutPath\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { nestedBaseUrl } = localsHelper.getValues(res)\n const { reportId, variantId, reportName, name } = req.query\n\n try {\n res.render(`dpr/routes/journeys/request-missing-report/submitted/view`, {\n title: 'Request submitted',\n report: {\n reportId,\n variantId,\n reportName,\n name,\n },\n nestedBaseUrl,\n layoutPath: this.layoutPath,\n })\n } catch (error) {\n next(error)\n }\n }\n}\n\nexport { MissingReportSubmittedController }\nexport default MissingReportSubmittedController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,6CAEzB,MAAMH,CAAiC,CACrC,WAEA,YAAYI,EAAoB,CAC9B,KAAK,WAAaA,CACpB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,cAAAC,CAAc,EAAI,EAAAC,QAAa,UAAUH,CAAG,EAC9C,CAAE,SAAAI,EAAU,UAAAC,EAAW,WAAAC,EAAY,KAAAC,CAAK,EAAIR,EAAI,MAEtD,GAAI,CACFC,EAAI,OAAO,4DAA6D,CACtE,MAAO,oBACP,OAAQ,CACN,SAAAI,EACA,UAAAC,EACA,WAAAC,EACA,KAAAC,CACF,EACA,cAAAL,EACA,WAAY,KAAK,UACnB,CAAC,CACH,OAASM,EAAO,CACdP,EAAKO,CAAK,CACZ,CACF,CACF,CAGA,IAAOb,EAAQD",
6
+ "names": ["controller_exports", "__export", "MissingReportSubmittedController", "controller_default", "__toCommonJS", "import_localsHelper", "layoutPath", "req", "res", "next", "nestedBaseUrl", "localsHelper", "reportId", "variantId", "reportName", "name", "error"]
7
7
  }
@@ -25,7 +25,7 @@ class MissingReportSubmittedController {
25
25
  layoutPath: this.layoutPath,
26
26
  })
27
27
  } catch (error) {
28
- next()
28
+ next(error)
29
29
  }
30
30
  }
31
31
  }
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.create;var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var h=(t,r)=>{for(var e in r)a(t,e,{get:r[e],enumerable:!0})},l=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of R(r))!f.call(t,o)&&o!==e&&a(t,o,{get:()=>r[o],enumerable:!(s=y(r,o))||s.enumerable});return t};var n=(t,r,e)=>(e=t!=null?u(p(t)):{},l(r||!t||!t.__esModule?a(e,"default",{value:t,enumerable:!0}):e,t)),m=t=>l(a({},"__esModule",{value:!0}),t);var g={};h(g,{RequestReportController:()=>i,default:()=>b});module.exports=m(g);var c=n(require("./filters/utils")),d=n(require("../../../utils/ErrorHandler"));class i{layoutPath;services;constructor(r,e){this.layoutPath=r,this.services=e}errorHandler=async(r,e,s,o)=>{s.render("dpr/routes/journeys/view-report/error",{layoutPath:this.layoutPath,...e.body&&{...e.body},...e.params,error:e.body?.error,params:e?.params})};CANCEL=async(r,e,s)=>{try{await c.default.cancelRequest({req:r,res:e,services:this.services})}catch(o){return r.body??={},r.body.title="Failed to abort request",r.body.errorDescription="We were unable to abort the report request for the following reason:",r.body.error=new d.default(o).formatError(),r.flash("ERROR_BODY",JSON.stringify(r.body)),r.flash("ERROR_PARAMS",JSON.stringify(r.params)),r.flash("ERROR",JSON.stringify(r.body?.error||{})),e.redirect(`${r.originalUrl}/failed`)}return e.redirect(r.originalUrl.replace("/cancel","/status"))}}var b=i;0&&(module.exports={RequestReportController});
1
+ "use strict";var y=Object.create;var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var h=(t,r)=>{for(var e in r)a(t,e,{get:r[e],enumerable:!0})},n=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of R(r))!m.call(t,o)&&o!==e&&a(t,o,{get:()=>r[o],enumerable:!(s=p(r,o))||s.enumerable});return t};var l=(t,r,e)=>(e=t!=null?y(f(t)):{},n(r||!t||!t.__esModule?a(e,"default",{value:t,enumerable:!0}):e,t)),b=t=>n(a({},"__esModule",{value:!0}),t);var g={};h(g,{RequestReportController:()=>i,default:()=>E});module.exports=b(g);var c=require("@sentry/node"),d=l(require("./filters/utils")),u=l(require("../../../utils/ErrorHandler"));class i{layoutPath;services;constructor(r,e){this.layoutPath=r,this.services=e}errorHandler=async(r,e,s,o)=>{(0,c.captureException)(r),s.render("dpr/routes/journeys/view-report/error",{layoutPath:this.layoutPath,...e.body&&{...e.body},...e.params,error:e.body?.error,params:e?.params})};CANCEL=async(r,e,s)=>{try{await d.default.cancelRequest({req:r,res:e,services:this.services})}catch(o){return r.body??={},r.body.title="Failed to abort request",r.body.errorDescription="We were unable to abort the report request for the following reason:",r.body.error=new u.default(o).formatError(),r.flash("ERROR_BODY",JSON.stringify(r.body)),r.flash("ERROR_PARAMS",JSON.stringify(r.params)),r.flash("ERROR",JSON.stringify(r.body?.error||{})),e.redirect(`${r.originalUrl}/failed`)}return e.redirect(r.originalUrl.replace("/cancel","/status"))}}var E=i;0&&(module.exports={RequestReportController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/dpr/routes/journeys/request-report/controller.ts"],
4
- "sourcesContent": ["import { ErrorRequestHandler, RequestHandler } from 'express'\nimport { Services } from '../../../types/Services'\nimport AsyncRequestUtils from './filters/utils'\nimport ErrorHandler from '../../../utils/ErrorHandler'\n\nclass RequestReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n errorHandler: ErrorRequestHandler = async (_error, req, res, _next) => {\n res.render(`dpr/routes/journeys/view-report/error`, {\n layoutPath: this.layoutPath,\n ...(req.body && { ...req.body }),\n ...req.params,\n error: req.body?.error,\n params: req?.params,\n })\n }\n\n CANCEL: RequestHandler = async (req, res, _next) => {\n try {\n await AsyncRequestUtils.cancelRequest({\n req,\n res,\n services: this.services,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = 'Failed to abort request'\n req.body.errorDescription = 'We were unable to abort the report request for the following reason:'\n req.body.error = new ErrorHandler(error).formatError()\n\n req.flash('ERROR_BODY', JSON.stringify(req.body))\n req.flash('ERROR_PARAMS', JSON.stringify(req.params))\n req.flash('ERROR', JSON.stringify(req.body?.error || {}))\n\n return res.redirect(`${req.originalUrl}/failed`)\n }\n return res.redirect(req.originalUrl.replace('/cancel', '/status'))\n }\n}\n\nexport { RequestReportController }\nexport default RequestReportController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAA8B,8BAC9BC,EAAyB,0CAEzB,MAAMJ,CAAwB,CAC5B,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,aAAoC,MAAOC,EAAQC,EAAKC,EAAKC,IAAU,CACrED,EAAI,OAAO,wCAAyC,CAClD,WAAY,KAAK,WACjB,GAAID,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,EAC9B,GAAGA,EAAI,OACP,MAAOA,EAAI,MAAM,MACjB,OAAQA,GAAK,MACf,CAAC,CACH,EAEA,OAAyB,MAAOA,EAAKC,EAAKC,IAAU,CAClD,GAAI,CACF,MAAM,EAAAC,QAAkB,cAAc,CACpC,IAAAH,EACA,IAAAC,EACA,SAAU,KAAK,QACjB,CAAC,CACH,OAASG,EAAO,CACd,OAAAJ,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,0BACjBA,EAAI,KAAK,iBAAmB,uEAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAK,QAAaD,CAAK,EAAE,YAAY,EAErDJ,EAAI,MAAM,aAAc,KAAK,UAAUA,EAAI,IAAI,CAAC,EAChDA,EAAI,MAAM,eAAgB,KAAK,UAAUA,EAAI,MAAM,CAAC,EACpDA,EAAI,MAAM,QAAS,KAAK,UAAUA,EAAI,MAAM,OAAS,CAAC,CAAC,CAAC,EAEjDC,EAAI,SAAS,GAAGD,EAAI,WAAW,SAAS,CACjD,CACA,OAAOC,EAAI,SAASD,EAAI,YAAY,QAAQ,UAAW,SAAS,CAAC,CACnE,CACF,CAGA,IAAOP,EAAQD",
6
- "names": ["controller_exports", "__export", "RequestReportController", "controller_default", "__toCommonJS", "import_utils", "import_ErrorHandler", "layoutPath", "services", "_error", "req", "res", "_next", "AsyncRequestUtils", "error", "ErrorHandler"]
4
+ "sourcesContent": ["import { ErrorRequestHandler, RequestHandler } from 'express'\nimport { captureException } from '@sentry/node'\nimport { Services } from '../../../types/Services'\nimport AsyncRequestUtils from './filters/utils'\nimport ErrorHandler from '../../../utils/ErrorHandler'\n\nclass RequestReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n errorHandler: ErrorRequestHandler = async (error, req, res, _next) => {\n captureException(error)\n res.render(`dpr/routes/journeys/view-report/error`, {\n layoutPath: this.layoutPath,\n ...(req.body && { ...req.body }),\n ...req.params,\n error: req.body?.error,\n params: req?.params,\n })\n }\n\n CANCEL: RequestHandler = async (req, res, _next) => {\n try {\n await AsyncRequestUtils.cancelRequest({\n req,\n res,\n services: this.services,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = 'Failed to abort request'\n req.body.errorDescription = 'We were unable to abort the report request for the following reason:'\n req.body.error = new ErrorHandler(error).formatError()\n\n req.flash('ERROR_BODY', JSON.stringify(req.body))\n req.flash('ERROR_PARAMS', JSON.stringify(req.params))\n req.flash('ERROR', JSON.stringify(req.body?.error || {}))\n\n return res.redirect(`${req.originalUrl}/failed`)\n }\n return res.redirect(req.originalUrl.replace('/cancel', '/status'))\n }\n}\n\nexport { RequestReportController }\nexport default RequestReportController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAiC,wBAEjCC,EAA8B,8BAC9BC,EAAyB,0CAEzB,MAAML,CAAwB,CAC5B,WAEA,SAEA,YAAYM,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,aAAoC,MAAOC,EAAOC,EAAKC,EAAKC,IAAU,IACpE,oBAAiBH,CAAK,EACtBE,EAAI,OAAO,wCAAyC,CAClD,WAAY,KAAK,WACjB,GAAID,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,EAC9B,GAAGA,EAAI,OACP,MAAOA,EAAI,MAAM,MACjB,OAAQA,GAAK,MACf,CAAC,CACH,EAEA,OAAyB,MAAOA,EAAKC,EAAKC,IAAU,CAClD,GAAI,CACF,MAAM,EAAAC,QAAkB,cAAc,CACpC,IAAAH,EACA,IAAAC,EACA,SAAU,KAAK,QACjB,CAAC,CACH,OAASF,EAAO,CACd,OAAAC,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,0BACjBA,EAAI,KAAK,iBAAmB,uEAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAI,QAAaL,CAAK,EAAE,YAAY,EAErDC,EAAI,MAAM,aAAc,KAAK,UAAUA,EAAI,IAAI,CAAC,EAChDA,EAAI,MAAM,eAAgB,KAAK,UAAUA,EAAI,MAAM,CAAC,EACpDA,EAAI,MAAM,QAAS,KAAK,UAAUA,EAAI,MAAM,OAAS,CAAC,CAAC,CAAC,EAEjDC,EAAI,SAAS,GAAGD,EAAI,WAAW,SAAS,CACjD,CACA,OAAOC,EAAI,SAASD,EAAI,YAAY,QAAQ,UAAW,SAAS,CAAC,CACnE,CACF,CAGA,IAAOR,EAAQD",
6
+ "names": ["controller_exports", "__export", "RequestReportController", "controller_default", "__toCommonJS", "import_node", "import_utils", "import_ErrorHandler", "layoutPath", "services", "error", "req", "res", "_next", "AsyncRequestUtils", "ErrorHandler"]
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { ErrorRequestHandler, RequestHandler } from 'express'
2
+ import { captureException } from '@sentry/node'
2
3
  import { Services } from '../../../types/Services'
3
4
  import AsyncRequestUtils from './filters/utils'
4
5
  import ErrorHandler from '../../../utils/ErrorHandler'
@@ -13,7 +14,8 @@ class RequestReportController {
13
14
  this.services = services
14
15
  }
15
16
 
16
- errorHandler: ErrorRequestHandler = async (_error, req, res, _next) => {
17
+ errorHandler: ErrorRequestHandler = async (error, req, res, _next) => {
18
+ captureException(error)
17
19
  res.render(`dpr/routes/journeys/view-report/error`, {
18
20
  layoutPath: this.layoutPath,
19
21
  ...(req.body && { ...req.body }),
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.create;var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var E=(s,e)=>{for(var t in e)l(s,t,{get:e[t],enumerable:!0})},m=(s,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!D.call(s,r)&&r!==t&&l(s,r,{get:()=>e[r],enumerable:!(o=v(e,r))||o.enumerable});return s};var u=(s,e,t)=>(t=s!=null?p(b(s)):{},m(e||!s||!s.__esModule?l(t,"default",{value:s,enumerable:!0}):t,s)),P=s=>m(l({},"__esModule",{value:!0}),s);var F={};E(F,{RequestReportController:()=>y,default:()=>w});module.exports=P(F);var d=u(require("./utils")),c=u(require("../../../../utils/Personalisation/personalisationUtils")),n=require("../../../../components/_filters/filtersTypeEnum"),i=u(require("../../../../utils/ErrorHandler"));class y{layoutPath;services;constructor(e,t){this.layoutPath=e,this.services=t}GET=async(e,t,o)=>{try{const r=await d.default.renderRequest({req:e,res:t,services:this.services,next:o});t.render("dpr/routes/journeys/request-report/filters/view",{layoutPath:this.layoutPath,...r})}catch(r){e.body??={},e.body.title="Request failed",e.body.errorDescription=`Your ${e.params.type} has failed to generate.`,e.body.error=new i.default(r).formatError(),o()}};POST=async(e,t,o)=>{try{const r=await d.default.request({req:e,res:t,services:this.services,next:o}),{executionId:a,dataProductDefinitionsPath:f}=r;if(a){const h=f?`${a}/status?dataProductDefinitionsPath=${f}`:`${a}/status`;t.redirect(h)}else t.end()}catch(r){const a=d.default.getFiltersFromReqBody(e);e.body={title:"Request Failed",errorDescription:`Your ${e.params.type} has failed to generate.`,error:new i.default(r).formatError(),retry:!0,filters:a,...e.body&&{...e.body}},o(r)}};saveDefaultFilterValues=async(e,t,o)=>{try{await c.default.saveDefaults(n.FiltersType.REQUEST,t,e,this.services),t.redirect(`${e.baseUrl}?defaultsSaved=true`)}catch(r){e.body={title:"Failed to save defaults",error:new i.default(r).formatError(),...e.body&&{...e.body}},o()}};removeDefaultFilterValues=async(e,t,o)=>{try{await c.default.removeDefaults(n.FiltersType.REQUEST,t,e,this.services),t.redirect(e.baseUrl)}catch(r){e.body={title:"Failed to remove defaults",error:new i.default(r).formatError(),...e.body&&{...e.body}},o()}}}var w=y;0&&(module.exports={RequestReportController});
1
+ "use strict";var p=Object.create;var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var E=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!D.call(o,r)&&r!==t&&l(o,r,{get:()=>e[r],enumerable:!(s=v(e,r))||s.enumerable});return o};var u=(o,e,t)=>(t=o!=null?p(b(o)):{},m(e||!o||!o.__esModule?l(t,"default",{value:o,enumerable:!0}):t,o)),P=o=>m(l({},"__esModule",{value:!0}),o);var F={};E(F,{RequestReportController:()=>y,default:()=>w});module.exports=P(F);var d=u(require("./utils")),c=u(require("../../../../utils/Personalisation/personalisationUtils")),n=require("../../../../components/_filters/filtersTypeEnum"),i=u(require("../../../../utils/ErrorHandler"));class y{layoutPath;services;constructor(e,t){this.layoutPath=e,this.services=t}GET=async(e,t,s)=>{try{const r=await d.default.renderRequest({req:e,res:t,services:this.services,next:s});t.render("dpr/routes/journeys/request-report/filters/view",{layoutPath:this.layoutPath,...r})}catch(r){e.body??={},e.body.title="Request failed",e.body.errorDescription=`Your ${e.params.type} has failed to generate.`,e.body.error=new i.default(r).formatError(),s(e.body.error)}};POST=async(e,t,s)=>{try{const r=await d.default.request({req:e,res:t,services:this.services,next:s}),{executionId:a,dataProductDefinitionsPath:f}=r;if(a){const h=f?`${a}/status?dataProductDefinitionsPath=${f}`:`${a}/status`;t.redirect(h)}else t.end()}catch(r){const a=d.default.getFiltersFromReqBody(e);e.body={title:"Request Failed",errorDescription:`Your ${e.params.type} has failed to generate.`,error:new i.default(r).formatError(),retry:!0,filters:a,...e.body&&{...e.body}},s(r)}};saveDefaultFilterValues=async(e,t,s)=>{try{await c.default.saveDefaults(n.FiltersType.REQUEST,t,e,this.services),t.redirect(`${e.baseUrl}?defaultsSaved=true`)}catch(r){e.body={title:"Failed to save defaults",error:new i.default(r).formatError(),...e.body&&{...e.body}},s(r)}};removeDefaultFilterValues=async(e,t,s)=>{try{await c.default.removeDefaults(n.FiltersType.REQUEST,t,e,this.services),t.redirect(e.baseUrl)}catch(r){e.body={title:"Failed to remove defaults",error:new i.default(r).formatError(),...e.body&&{...e.body}},s(r)}}}var w=y;0&&(module.exports={RequestReportController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/request-report/filters/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport { RequestDataResult } from '../../../../types/AsyncReportUtils'\nimport AysncRequestUtils from './utils'\nimport PersonalisationUtils from '../../../../utils/Personalisation/personalisationUtils'\nimport { FiltersType } from '../../../../components/_filters/filtersTypeEnum'\nimport ErrorHandler from '../../../../utils/ErrorHandler'\n\nclass RequestReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n // Render request page\n GET: RequestHandler = async (req, res, next) => {\n try {\n const requestRenderData = <RequestDataResult>await AysncRequestUtils.renderRequest({\n req,\n res,\n services: this.services,\n next,\n })\n\n res.render(`dpr/routes/journeys/request-report/filters/view`, {\n layoutPath: this.layoutPath,\n ...requestRenderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = 'Request failed'\n req.body.errorDescription = `Your ${req.params['type']} has failed to generate.`\n req.body.error = new ErrorHandler(error).formatError()\n next()\n }\n }\n\n // Request report\n POST: RequestHandler = async (req, res, next) => {\n try {\n const executionData = await AysncRequestUtils.request({\n req,\n res,\n services: this.services,\n next,\n })\n\n const { executionId, dataProductDefinitionsPath } = executionData\n\n if (executionId) {\n const redirect = dataProductDefinitionsPath\n ? `${executionId}/status?dataProductDefinitionsPath=${dataProductDefinitionsPath}`\n : `${executionId}/status`\n res.redirect(redirect)\n } else {\n res.end()\n }\n } catch (error) {\n const filters = AysncRequestUtils.getFiltersFromReqBody(req)\n\n req.body = {\n title: 'Request Failed',\n errorDescription: `Your ${req.params['type']} has failed to generate.`,\n error: new ErrorHandler(error).formatError(),\n retry: true,\n filters,\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n\n saveDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n await PersonalisationUtils.saveDefaults(FiltersType.REQUEST, res, req, this.services)\n res.redirect(`${req.baseUrl}?defaultsSaved=true`)\n } catch (error) {\n req.body = {\n title: 'Failed to save defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next()\n }\n }\n\n removeDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n await PersonalisationUtils.removeDefaults(FiltersType.REQUEST, res, req, this.services)\n res.redirect(req.baseUrl)\n } catch (error) {\n req.body = {\n title: 'Failed to remove defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next()\n }\n }\n}\n\nexport { RequestReportController }\nexport default RequestReportController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAA8B,sBAC9BC,EAAiC,qEACjCC,EAA4B,2DAC5BC,EAAyB,6CAEzB,MAAMN,CAAwB,CAC5B,WAEA,SAEA,YAAYO,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAGA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAuC,MAAM,EAAAC,QAAkB,cAAc,CACjF,IAAAJ,EACA,IAAAC,EACA,SAAU,KAAK,SACf,KAAAC,CACF,CAAC,EAEDD,EAAI,OAAO,kDAAmD,CAC5D,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,iBACjBA,EAAI,KAAK,iBAAmB,QAAQA,EAAI,OAAO,IAAO,2BACtDA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC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AO,4BACP,MAAO,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIL,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAE,EAAK,CACP,CACF,CACF,CAGA,IAAOV,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport { RequestDataResult } from '../../../../types/AsyncReportUtils'\nimport AysncRequestUtils from './utils'\nimport PersonalisationUtils from '../../../../utils/Personalisation/personalisationUtils'\nimport { FiltersType } from '../../../../components/_filters/filtersTypeEnum'\nimport ErrorHandler from '../../../../utils/ErrorHandler'\n\nclass RequestReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n // Render request page\n GET: RequestHandler = async (req, res, next) => {\n try {\n const requestRenderData = <RequestDataResult>await AysncRequestUtils.renderRequest({\n req,\n res,\n services: this.services,\n next,\n })\n\n res.render(`dpr/routes/journeys/request-report/filters/view`, {\n layoutPath: this.layoutPath,\n ...requestRenderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = 'Request failed'\n req.body.errorDescription = `Your ${req.params['type']} has failed to generate.`\n req.body.error = new ErrorHandler(error).formatError()\n next(req.body.error)\n }\n }\n\n // Request report\n POST: RequestHandler = async (req, res, next) => {\n try {\n const executionData = await AysncRequestUtils.request({\n req,\n res,\n services: this.services,\n next,\n })\n\n const { executionId, dataProductDefinitionsPath } = executionData\n\n if (executionId) {\n const redirect = dataProductDefinitionsPath\n ? `${executionId}/status?dataProductDefinitionsPath=${dataProductDefinitionsPath}`\n : `${executionId}/status`\n res.redirect(redirect)\n } else {\n res.end()\n }\n } catch (error) {\n const filters = AysncRequestUtils.getFiltersFromReqBody(req)\n\n req.body = {\n title: 'Request Failed',\n errorDescription: `Your ${req.params['type']} has failed to generate.`,\n error: new ErrorHandler(error).formatError(),\n retry: true,\n filters,\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n\n saveDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n await PersonalisationUtils.saveDefaults(FiltersType.REQUEST, res, req, this.services)\n res.redirect(`${req.baseUrl}?defaultsSaved=true`)\n } catch (error) {\n req.body = {\n title: 'Failed to save defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n\n removeDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n await PersonalisationUtils.removeDefaults(FiltersType.REQUEST, res, req, this.services)\n res.redirect(req.baseUrl)\n } catch (error) {\n req.body = {\n title: 'Failed to remove defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n}\n\nexport { RequestReportController }\nexport default RequestReportController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAA8B,sBAC9BC,EAAiC,qEACjCC,EAA4B,2DAC5BC,EAAyB,6CAEzB,MAAMN,CAAwB,CAC5B,WAEA,SAEA,YAAYO,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAGA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAuC,MAAM,EAAAC,QAAkB,cAAc,CACjF,IAAAJ,EACA,IAAAC,EACA,SAAU,KAAK,SACf,KAAAC,CACF,CAAC,EAEDD,EAAI,OAAO,kDAAmD,CAC5D,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,iBACjBA,EAAI,KAAK,iBAAmB,QAAQA,EAAI,OAAO,IAAO,2BACtDA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAKF,EAAI,KAAK,KAAK,CACrB,CACF,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AO,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIL,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAE,EAAKG,CAAK,CACZ,CACF,CACF,CAGA,IAAOb,EAAQD",
6
6
  "names": ["controller_exports", "__export", "RequestReportController", "controller_default", "__toCommonJS", "import_utils", "import_personalisationUtils", "import_filtersTypeEnum", "import_ErrorHandler", "layoutPath", "services", "req", "res", "next", "requestRenderData", "AysncRequestUtils", "error", "ErrorHandler", "executionData", "executionId", "dataProductDefinitionsPath", "redirect", "filters", "PersonalisationUtils"]
7
7
  }
@@ -35,7 +35,7 @@ class RequestReportController {
35
35
  req.body.title = 'Request failed'
36
36
  req.body.errorDescription = `Your ${req.params['type']} has failed to generate.`
37
37
  req.body.error = new ErrorHandler(error).formatError()
38
- next()
38
+ next(req.body.error)
39
39
  }
40
40
  }
41
41
 
@@ -84,7 +84,7 @@ class RequestReportController {
84
84
  error: new ErrorHandler(error).formatError(),
85
85
  ...(req.body && { ...req.body }),
86
86
  }
87
- next()
87
+ next(error)
88
88
  }
89
89
  }
90
90
 
@@ -98,7 +98,7 @@ class RequestReportController {
98
98
  error: new ErrorHandler(error).formatError(),
99
99
  ...(req.body && { ...req.body }),
100
100
  }
101
- next()
101
+ next(error)
102
102
  }
103
103
  }
104
104
  }
@@ -1,2 +1,2 @@
1
- "use strict";var $=Object.create;var n=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var E=(e,r)=>{for(var t in r)n(e,t,{get:r[t],enumerable:!0})},R=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of q(r))!A.call(e,s)&&s!==t&&n(e,s,{get:()=>r[s],enumerable:!(o=S(r,s))||o.enumerable});return e};var u=(e,r,t)=>(t=e!=null?$(O(e)):{},R(r||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),B=e=>R(n({},"__esModule",{value:!0}),e);var N={};E(N,{Redirects:()=>x,RequestReportRoutes:()=>C,Routes:()=>g});module.exports=B(N);var d=require("express"),l=u(require("./controller")),f=u(require("./filters/routes")),I=u(require("./status/routes")),c=u(require("../../../middleware/reportAuthoriser"));function g({layoutPath:e,services:r}){const t=(0,d.Router)({mergeParams:!0}),o=new l.default(e,r);return t.post("/:type/:reportId/:id/:executionId/cancel",o.CANCEL),t.use("/:type/:reportId/:id/filters",(0,c.default)(r,e),(0,f.default)({layoutPath:e,services:r}),o.errorHandler),t.use("/:type/:reportId/:id/:executionId/status",(0,c.default)(r,e),(0,I.default)({layoutPath:e,services:r}),o.errorHandler),t.get("/:type/:reportId/:id/:executionId/cancel/failed",(s,p,a)=>{const m=JSON.parse(s.flash("ERROR_BODY")?.[0]||""),i=JSON.parse(s.flash("ERROR_PARAMS")?.[0]||""),y=s.flash("ERROR");p.render("dpr/routes/journeys/view-report/error",{layoutPath:e,...m&&{...m},...i&&{...i},error:y,params:i})}),t}function x(){const e=(0,d.Router)({mergeParams:!0});return e.get("/async/:type/:reportId/:id/request",(r,t)=>{const{type:o,reportId:s,id:p}=r.params;t.redirect(`${t.locals.nestedBaseUrl}/dpr/request-report/${o}/${s}/${p}/filters`)}),e.get("/async/:type/:reportId/:id/request/:executionId",(r,t)=>{const{type:o,reportId:s,id:p,executionId:a}=r.params;t.redirect(`${t.locals.nestedBaseUrl}/dpr/request-report/${o}/${s}/${p}/${a}/status`)}),e}const C=({services:e,path:r,layoutPath:t})=>{const o=(0,d.Router)({mergeParams:!0});return o.use(r,g({services:e,layoutPath:t})),o.use("/",x()),o};0&&(module.exports={Redirects,RequestReportRoutes,Routes});
1
+ "use strict";var S=Object.create;var n=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var t in r)n(e,t,{get:r[t],enumerable:!0})},l=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of O(r))!A.call(e,s)&&s!==t&&n(e,s,{get:()=>r[s],enumerable:!(o=q(r,s))||o.enumerable});return e};var u=(e,r,t)=>(t=e!=null?S(E(e)):{},l(r||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),C=e=>l(n({},"__esModule",{value:!0}),e);var _={};B(_,{Redirects:()=>$,RequestReportRoutes:()=>N,Routes:()=>y});module.exports=C(_);var i=require("express"),f=require("@sentry/node"),I=u(require("./controller")),x=u(require("./filters/routes")),g=u(require("./status/routes")),c=u(require("../../../middleware/reportAuthoriser"));function y({layoutPath:e,services:r}){const t=(0,i.Router)({mergeParams:!0}),o=new I.default(e,r);return t.post("/:type/:reportId/:id/:executionId/cancel",o.CANCEL),t.use("/:type/:reportId/:id/filters",(0,c.default)(r,e),(0,x.default)({layoutPath:e,services:r}),o.errorHandler),t.use("/:type/:reportId/:id/:executionId/status",(0,c.default)(r,e),(0,g.default)({layoutPath:e,services:r}),o.errorHandler),t.get("/:type/:reportId/:id/:executionId/cancel/failed",(s,p,a)=>{const m=JSON.parse(s.flash("ERROR_BODY")?.[0]||""),d=JSON.parse(s.flash("ERROR_PARAMS")?.[0]||""),R=s.flash("ERROR");(0,f.captureException)(R),p.render("dpr/routes/journeys/view-report/error",{layoutPath:e,...m&&{...m},...d&&{...d},error:R,params:d})}),t}function $(){const e=(0,i.Router)({mergeParams:!0});return e.get("/async/:type/:reportId/:id/request",(r,t)=>{const{type:o,reportId:s,id:p}=r.params;t.redirect(`${t.locals.nestedBaseUrl}/dpr/request-report/${o}/${s}/${p}/filters`)}),e.get("/async/:type/:reportId/:id/request/:executionId",(r,t)=>{const{type:o,reportId:s,id:p,executionId:a}=r.params;t.redirect(`${t.locals.nestedBaseUrl}/dpr/request-report/${o}/${s}/${p}/${a}/status`)}),e}const N=({services:e,path:r,layoutPath:t})=>{const o=(0,i.Router)({mergeParams:!0});return o.use(r,y({services:e,layoutPath:t})),o.use("/",$()),o};0&&(module.exports={Redirects,RequestReportRoutes,Routes});
2
2
  //# sourceMappingURL=routes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/dpr/routes/journeys/request-report/routes.ts"],
4
- "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../types/Services'\nimport RequestReportController from './controller'\n\n// Routes\nimport requestReportRoutes from './filters/routes'\nimport requestStatusRoutes from './status/routes'\n\n// middleware\nimport reportAuthoriser from '../../../middleware/reportAuthoriser'\n\nexport function Routes({ layoutPath, services }: { services: Services; layoutPath: string }) {\n const router = Router({ mergeParams: true })\n\n const controller = new RequestReportController(layoutPath, services)\n\n router.post(`/:type/:reportId/:id/:executionId/cancel`, controller.CANCEL)\n router.use(\n `/:type/:reportId/:id/filters`,\n reportAuthoriser(services, layoutPath),\n requestReportRoutes({ layoutPath, services }),\n controller.errorHandler,\n )\n router.use(\n `/:type/:reportId/:id/:executionId/status`,\n reportAuthoriser(services, layoutPath),\n requestStatusRoutes({ layoutPath, services }),\n controller.errorHandler,\n )\n\n router.get(`/:type/:reportId/:id/:executionId/cancel/failed`, (req, res, _next) => {\n const body = JSON.parse(req.flash('ERROR_BODY')?.[0] || '')\n const params = JSON.parse(req.flash('ERROR_PARAMS')?.[0] || '')\n const error = req.flash('ERROR')\n\n res.render(`dpr/routes/journeys/view-report/error`, {\n layoutPath,\n ...(body && { ...body }),\n ...(params && { ...params }),\n error,\n params,\n })\n })\n\n return router\n}\n\nexport function Redirects() {\n const router = Router({ mergeParams: true })\n\n // Request route redirect\n router.get(`/async/:type/:reportId/:id/request`, (req, res) => {\n const { type, reportId, id } = req.params\n res.redirect(`${res.locals['nestedBaseUrl']}/dpr/request-report/${type}/${reportId}/${id}/filters`)\n })\n\n // Status route redirect\n router.get(`/async/:type/:reportId/:id/request/:executionId`, (req, res) => {\n const { type, reportId, id, executionId } = req.params\n res.redirect(`${res.locals['nestedBaseUrl']}/dpr/request-report/${type}/${reportId}/${id}/${executionId}/status`)\n })\n\n return router\n}\n\nexport const RequestReportRoutes = ({\n services,\n path,\n layoutPath,\n}: {\n services: Services\n path: string\n layoutPath: string\n}) => {\n const router = Router({ mergeParams: true })\n router.use(path, Routes({ services, layoutPath }))\n router.use('/', Redirects())\n\n return router\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,wBAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAAL,GACA,IAAAM,EAAuB,mBAEvBC,EAAoC,2BAGpCC,EAAgC,+BAChCA,EAAgC,8BAGhCC,EAA6B,mDAEtB,SAASL,EAAO,CAAE,WAAAM,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAAwBJ,EAAYC,CAAQ,EAEnE,OAAAC,EAAO,KAAK,2CAA4CC,EAAW,MAAM,EACzED,EAAO,IACL,kCACA,EAAAG,SAAiBJ,EAAUD,CAAU,KACrC,EAAAM,SAAoB,CAAE,WAAAN,EAAY,SAAAC,CAAS,CAAC,EAC5CE,EAAW,YACb,EACAD,EAAO,IACL,8CACA,EAAAG,SAAiBJ,EAAUD,CAAU,KACrC,EAAAO,SAAoB,CAAE,WAAAP,EAAY,SAAAC,CAAS,CAAC,EAC5CE,EAAW,YACb,EAEAD,EAAO,IAAI,kDAAmD,CAACM,EAAKC,EAAKC,IAAU,CACjF,MAAMC,EAAO,KAAK,MAAMH,EAAI,MAAM,YAAY,IAAI,CAAC,GAAK,EAAE,EACpDI,EAAS,KAAK,MAAMJ,EAAI,MAAM,cAAc,IAAI,CAAC,GAAK,EAAE,EACxDK,EAAQL,EAAI,MAAM,OAAO,EAE/BC,EAAI,OAAO,wCAAyC,CAClD,WAAAT,EACA,GAAIW,GAAQ,CAAE,GAAGA,CAAK,EACtB,GAAIC,GAAU,CAAE,GAAGA,CAAO,EAC1B,MAAAC,EACA,OAAAD,CACF,CAAC,CACH,CAAC,EAEMV,CACT,CAEO,SAASV,GAAY,CAC1B,MAAMU,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAG3C,OAAAA,EAAO,IAAI,qCAAsC,CAACM,EAAKC,IAAQ,CAC7D,KAAM,CAAE,KAAAK,EAAM,SAAAC,EAAU,GAAAC,CAAG,EAAIR,EAAI,OACnCC,EAAI,SAAS,GAAGA,EAAI,OAAO,aAAgB,uBAAuBK,CAAI,IAAIC,CAAQ,IAAIC,CAAE,UAAU,CACpG,CAAC,EAGDd,EAAO,IAAI,kDAAmD,CAACM,EAAKC,IAAQ,CAC1E,KAAM,CAAE,KAAAK,EAAM,SAAAC,EAAU,GAAAC,EAAI,YAAAC,CAAY,EAAIT,EAAI,OAChDC,EAAI,SAAS,GAAGA,EAAI,OAAO,aAAgB,uBAAuBK,CAAI,IAAIC,CAAQ,IAAIC,CAAE,IAAIC,CAAW,SAAS,CAClH,CAAC,EAEMf,CACT,CAEO,MAAMT,EAAsB,CAAC,CAClC,SAAAQ,EACA,KAAAiB,EACA,WAAAlB,CACF,IAIM,CACJ,MAAME,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAC3C,OAAAA,EAAO,IAAIgB,EAAMxB,EAAO,CAAE,SAAAO,EAAU,WAAAD,CAAW,CAAC,CAAC,EACjDE,EAAO,IAAI,IAAKV,EAAU,CAAC,EAEpBU,CACT",
6
- "names": ["routes_exports", "__export", "Redirects", "RequestReportRoutes", "Routes", "__toCommonJS", "import_express", "import_controller", "import_routes", "import_reportAuthoriser", "layoutPath", "services", "router", "controller", "RequestReportController", "reportAuthoriser", "requestReportRoutes", "requestStatusRoutes", "req", "res", "_next", "body", "params", "error", "type", "reportId", "id", "executionId", "path"]
4
+ "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { captureException } from '@sentry/node'\nimport { Services } from '../../../types/Services'\nimport RequestReportController from './controller'\n\n// Routes\nimport requestReportRoutes from './filters/routes'\nimport requestStatusRoutes from './status/routes'\n\n// middleware\nimport reportAuthoriser from '../../../middleware/reportAuthoriser'\n\nexport function Routes({ layoutPath, services }: { services: Services; layoutPath: string }) {\n const router = Router({ mergeParams: true })\n\n const controller = new RequestReportController(layoutPath, services)\n\n router.post(`/:type/:reportId/:id/:executionId/cancel`, controller.CANCEL)\n router.use(\n `/:type/:reportId/:id/filters`,\n reportAuthoriser(services, layoutPath),\n requestReportRoutes({ layoutPath, services }),\n controller.errorHandler,\n )\n router.use(\n `/:type/:reportId/:id/:executionId/status`,\n reportAuthoriser(services, layoutPath),\n requestStatusRoutes({ layoutPath, services }),\n controller.errorHandler,\n )\n\n router.get(`/:type/:reportId/:id/:executionId/cancel/failed`, (req, res, _next) => {\n const body = JSON.parse(req.flash('ERROR_BODY')?.[0] || '')\n const params = JSON.parse(req.flash('ERROR_PARAMS')?.[0] || '')\n const error = req.flash('ERROR')\n\n captureException(error)\n res.render(`dpr/routes/journeys/view-report/error`, {\n layoutPath,\n ...(body && { ...body }),\n ...(params && { ...params }),\n error,\n params,\n })\n })\n\n return router\n}\n\nexport function Redirects() {\n const router = Router({ mergeParams: true })\n\n // Request route redirect\n router.get(`/async/:type/:reportId/:id/request`, (req, res) => {\n const { type, reportId, id } = req.params\n res.redirect(`${res.locals['nestedBaseUrl']}/dpr/request-report/${type}/${reportId}/${id}/filters`)\n })\n\n // Status route redirect\n router.get(`/async/:type/:reportId/:id/request/:executionId`, (req, res) => {\n const { type, reportId, id, executionId } = req.params\n res.redirect(`${res.locals['nestedBaseUrl']}/dpr/request-report/${type}/${reportId}/${id}/${executionId}/status`)\n })\n\n return router\n}\n\nexport const RequestReportRoutes = ({\n services,\n path,\n layoutPath,\n}: {\n services: Services\n path: string\n layoutPath: string\n}) => {\n const router = Router({ mergeParams: true })\n router.use(path, Routes({ services, layoutPath }))\n router.use('/', Redirects())\n\n return router\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAA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,GAAAC,CAAG,EAAIR,EAAI,OACnCC,EAAI,SAAS,GAAGA,EAAI,OAAO,aAAgB,uBAAuBK,CAAI,IAAIC,CAAQ,IAAIC,CAAE,UAAU,CACpG,CAAC,EAGDd,EAAO,IAAI,kDAAmD,CAACM,EAAKC,IAAQ,CAC1E,KAAM,CAAE,KAAAK,EAAM,SAAAC,EAAU,GAAAC,EAAI,YAAAC,CAAY,EAAIT,EAAI,OAChDC,EAAI,SAAS,GAAGA,EAAI,OAAO,aAAgB,uBAAuBK,CAAI,IAAIC,CAAQ,IAAIC,CAAE,IAAIC,CAAW,SAAS,CAClH,CAAC,EAEMf,CACT,CAEO,MAAMV,EAAsB,CAAC,CAClC,SAAAS,EACA,KAAAiB,EACA,WAAAlB,CACF,IAIM,CACJ,MAAME,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAC3C,OAAAA,EAAO,IAAIgB,EAAMzB,EAAO,CAAE,SAAAQ,EAAU,WAAAD,CAAW,CAAC,CAAC,EACjDE,EAAO,IAAI,IAAKX,EAAU,CAAC,EAEpBW,CACT",
6
+ "names": ["routes_exports", "__export", "Redirects", "RequestReportRoutes", "Routes", "__toCommonJS", "import_express", "import_node", "import_controller", "import_routes", "import_reportAuthoriser", "layoutPath", "services", "router", "controller", "RequestReportController", "reportAuthoriser", "requestReportRoutes", "requestStatusRoutes", "req", "res", "_next", "body", "params", "error", "type", "reportId", "id", "executionId", "path"]
7
7
  }
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable no-param-reassign */
2
2
  import { Router } from 'express'
3
+ import { captureException } from '@sentry/node'
3
4
  import { Services } from '../../../types/Services'
4
5
  import RequestReportController from './controller'
5
6
 
@@ -34,6 +35,7 @@ export function Routes({ layoutPath, services }: { services: Services; layoutPat
34
35
  const params = JSON.parse(req.flash('ERROR_PARAMS')?.[0] || '')
35
36
  const error = req.flash('ERROR')
36
37
 
38
+ captureException(error)
37
39
  res.render(`dpr/routes/journeys/view-report/error`, {
38
40
  layoutPath,
39
41
  ...(body && { ...body }),
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(r,t)=>{for(var e in t)i(r,e,{get:t[e],enumerable:!0})},u=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!m.call(r,s)&&s!==e&&i(r,s,{get:()=>t[s],enumerable:!(o=p(t,s))||o.enumerable});return r};var a=(r,t,e)=>(e=r!=null?y(v(r)):{},u(t||!r||!r.__esModule?i(e,"default",{value:r,enumerable:!0}):e,r)),P=r=>u(i({},"__esModule",{value:!0}),r);var g={};f(g,{RequestStatusController:()=>n,default:()=>R});module.exports=P(g);var c=a(require("./utils")),l=a(require("../../../../components/user-reports/requested/utils")),d=a(require("../../../../utils/ErrorHandler"));class n{layoutPath;services;constructor(t,e){this.layoutPath=t,this.services=e}GET=async(t,e,o)=>{try{const s=await c.default.renderPolling({req:t,res:e,services:this.services,next:o});e.render("dpr/routes/journeys/request-report/status/view",{layoutPath:this.layoutPath,...s})}catch(s){t.body??={},t.body.title="Failed to retrieve report status",t.body.errorDescription="We were unable to retrieve the report status:",t.body.error=new d.default(s).formatError(),o()}};POST=async(t,e,o)=>{try{const s=await l.default.getRequestStatus({req:t,res:e,services:this.services});e.send({status:s.status})}catch{e.send({status:"FAILED"})}}}var R=n;0&&(module.exports={RequestStatusController});
1
+ "use strict";var y=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(r,t)=>{for(var e in t)i(r,e,{get:t[e],enumerable:!0})},u=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!m.call(r,s)&&s!==e&&i(r,s,{get:()=>t[s],enumerable:!(o=p(t,s))||o.enumerable});return r};var a=(r,t,e)=>(e=r!=null?y(v(r)):{},u(t||!r||!r.__esModule?i(e,"default",{value:r,enumerable:!0}):e,r)),P=r=>u(i({},"__esModule",{value:!0}),r);var g={};f(g,{RequestStatusController:()=>n,default:()=>R});module.exports=P(g);var c=a(require("./utils")),l=a(require("../../../../components/user-reports/requested/utils")),d=a(require("../../../../utils/ErrorHandler"));class n{layoutPath;services;constructor(t,e){this.layoutPath=t,this.services=e}GET=async(t,e,o)=>{try{const s=await c.default.renderPolling({req:t,res:e,services:this.services,next:o});e.render("dpr/routes/journeys/request-report/status/view",{layoutPath:this.layoutPath,...s})}catch(s){t.body??={},t.body.title="Failed to retrieve report status",t.body.errorDescription="We were unable to retrieve the report status:",t.body.error=new d.default(s).formatError(),o(s)}};POST=async(t,e,o)=>{try{const s=await l.default.getRequestStatus({req:t,res:e,services:this.services});e.send({status:s.status})}catch{e.send({status:"FAILED"})}}}var R=n;0&&(module.exports={RequestStatusController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/request-report/status/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport AsyncPollingUtils from './utils'\nimport AsyncRequestListUtils from '../../../../components/user-reports/requested/utils'\nimport ErrorHandler from '../../../../utils/ErrorHandler'\n\nclass RequestStatusController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n // Render status page\n GET: RequestHandler = async (req, res, next) => {\n try {\n const pollingRenderData = await AsyncPollingUtils.renderPolling({\n req,\n res,\n services: this.services,\n next,\n })\n res.render(`dpr/routes/journeys/request-report/status/view`, {\n layoutPath: this.layoutPath,\n ...pollingRenderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = 'Failed to retrieve report status'\n req.body.errorDescription = 'We were unable to retrieve the report status:'\n req.body.error = new ErrorHandler(error).formatError()\n next()\n }\n }\n\n // Poll request status\n POST: RequestHandler = async (req, res, _next) => {\n try {\n const response = await AsyncRequestListUtils.getRequestStatus({ req, res, services: this.services })\n res.send({ status: response.status })\n } catch (error) {\n res.send({ status: 'FAILED' })\n }\n }\n}\n\nexport { RequestStatusController }\nexport default RequestStatusController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAA8B,sBAC9BA,EAAkC,kEAClCC,EAAyB,6CAEzB,MAAMJ,CAAwB,CAC5B,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAGA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAoB,MAAM,EAAAC,QAAkB,cAAc,CAC9D,IAAAJ,EACA,IAAAC,EACA,SAAU,KAAK,SACf,KAAAC,CACF,CAAC,EACDD,EAAI,OAAO,iDAAkD,CAC3D,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,mCACjBA,EAAI,KAAK,iBAAmB,gDAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAK,CACP,CACF,EAGA,KAAuB,MAAOF,EAAKC,EAAKM,IAAU,CAChD,GAAI,CACF,MAAMC,EAAW,MAAM,EAAAC,QAAsB,iBAAiB,CAAE,IAAAT,EAAK,IAAAC,EAAK,SAAU,KAAK,QAAS,CAAC,EACnGA,EAAI,KAAK,CAAE,OAAQO,EAAS,MAAO,CAAC,CACtC,MAAgB,CACdP,EAAI,KAAK,CAAE,OAAQ,QAAS,CAAC,CAC/B,CACF,CACF,CAGA,IAAOP,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport AsyncPollingUtils from './utils'\nimport AsyncRequestListUtils from '../../../../components/user-reports/requested/utils'\nimport ErrorHandler from '../../../../utils/ErrorHandler'\n\nclass RequestStatusController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n // Render status page\n GET: RequestHandler = async (req, res, next) => {\n try {\n const pollingRenderData = await AsyncPollingUtils.renderPolling({\n req,\n res,\n services: this.services,\n next,\n })\n res.render(`dpr/routes/journeys/request-report/status/view`, {\n layoutPath: this.layoutPath,\n ...pollingRenderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = 'Failed to retrieve report status'\n req.body.errorDescription = 'We were unable to retrieve the report status:'\n req.body.error = new ErrorHandler(error).formatError()\n next(error)\n }\n }\n\n // Poll request status\n POST: RequestHandler = async (req, res, _next) => {\n try {\n const response = await AsyncRequestListUtils.getRequestStatus({ req, res, services: this.services })\n res.send({ status: response.status })\n } catch (error) {\n res.send({ status: 'FAILED' })\n }\n }\n}\n\nexport { RequestStatusController }\nexport default RequestStatusController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAA8B,sBAC9BA,EAAkC,kEAClCC,EAAyB,6CAEzB,MAAMJ,CAAwB,CAC5B,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAGA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAoB,MAAM,EAAAC,QAAkB,cAAc,CAC9D,IAAAJ,EACA,IAAAC,EACA,SAAU,KAAK,SACf,KAAAC,CACF,CAAC,EACDD,EAAI,OAAO,iDAAkD,CAC3D,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,mCACjBA,EAAI,KAAK,iBAAmB,gDAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAKG,CAAK,CACZ,CACF,EAGA,KAAuB,MAAOL,EAAKC,EAAKM,IAAU,CAChD,GAAI,CACF,MAAMC,EAAW,MAAM,EAAAC,QAAsB,iBAAiB,CAAE,IAAAT,EAAK,IAAAC,EAAK,SAAU,KAAK,QAAS,CAAC,EACnGA,EAAI,KAAK,CAAE,OAAQO,EAAS,MAAO,CAAC,CACtC,MAAgB,CACdP,EAAI,KAAK,CAAE,OAAQ,QAAS,CAAC,CAC/B,CACF,CACF,CAGA,IAAOP,EAAQD",
6
6
  "names": ["controller_exports", "__export", "RequestStatusController", "controller_default", "__toCommonJS", "import_utils", "import_ErrorHandler", "layoutPath", "services", "req", "res", "next", "pollingRenderData", "AsyncPollingUtils", "error", "ErrorHandler", "_next", "response", "AsyncRequestListUtils"]
7
7
  }
@@ -32,7 +32,7 @@ class RequestStatusController {
32
32
  req.body.title = 'Failed to retrieve report status'
33
33
  req.body.errorDescription = 'We were unable to retrieve the report status:'
34
34
  req.body.error = new ErrorHandler(error).formatError()
35
- next()
35
+ next(error)
36
36
  }
37
37
  }
38
38
 
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.create;var a=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var E=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!h.call(t,s)&&s!==r&&a(t,s,{get:()=>e[s],enumerable:!(o=v(e,s))||o.enumerable});return t};var i=(t,e,r)=>(r=t!=null?f(p(t)):{},u(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t)),b=t=>u(a({},"__esModule",{value:!0}),t);var F={};E(F,{AsyncController:()=>n,default:()=>R});module.exports=b(F);var l=i(require("../../../../utils/ErrorHandler")),m=i(require("../../../../components/user-reports/utils")),c=require("../../../../components/_filters/filtersTypeEnum"),d=i(require("../../../../utils/Personalisation/personalisationUtils"));class n{layoutPath;services;constructor(e,r){this.layoutPath=e,this.services=r}POST=async(e,r,o)=>{try{const s=await m.default.updateExpiredStatus({req:e,res:r,services:this.services});r.send({isExpired:s})}catch{r.send({status:"FAILED"})}};saveDefaultFilterValues=async(e,r,o)=>{try{d.default.saveDefaults(c.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(`${e.baseUrl}?defaultsSaved=true`)}catch(s){e.body={title:"Failed to save defaults",error:new l.default(s).formatError(),...e.body&&{...e.body}},o()}};removeDefaultFilterValues=async(e,r,o)=>{try{d.default.removeDefaults(c.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(e.baseUrl)}catch(s){e.body={title:"Failed to remove defaults",error:new l.default(s).formatError(),...e.body&&{...e.body}},o()}}}var R=n;0&&(module.exports={AsyncController});
1
+ "use strict";var f=Object.create;var a=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var E=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!h.call(t,s)&&s!==r&&a(t,s,{get:()=>e[s],enumerable:!(o=v(e,s))||o.enumerable});return t};var i=(t,e,r)=>(r=t!=null?f(p(t)):{},u(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t)),b=t=>u(a({},"__esModule",{value:!0}),t);var F={};E(F,{AsyncController:()=>n,default:()=>R});module.exports=b(F);var l=i(require("../../../../utils/ErrorHandler")),m=i(require("../../../../components/user-reports/utils")),c=require("../../../../components/_filters/filtersTypeEnum"),d=i(require("../../../../utils/Personalisation/personalisationUtils"));class n{layoutPath;services;constructor(e,r){this.layoutPath=e,this.services=r}POST=async(e,r,o)=>{try{const s=await m.default.updateExpiredStatus({req:e,res:r,services:this.services});r.send({isExpired:s})}catch{r.send({status:"FAILED"})}};saveDefaultFilterValues=async(e,r,o)=>{try{d.default.saveDefaults(c.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(`${e.baseUrl}?defaultsSaved=true`)}catch(s){e.body={title:"Failed to save defaults",error:new l.default(s).formatError(),...e.body&&{...e.body}},o(s)}};removeDefaultFilterValues=async(e,r,o)=>{try{d.default.removeDefaults(c.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(e.baseUrl)}catch(s){e.body={title:"Failed to remove defaults",error:new l.default(s).formatError(),...e.body&&{...e.body}},o(s)}}}var R=n;0&&(module.exports={AsyncController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/view-report/async/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../utils/ErrorHandler'\nimport { Services } from '../../../../types/Services'\nimport UserReportsListUtils from '../../../../components/user-reports/utils'\nimport { FiltersType } from '../../../../components/_filters/filtersTypeEnum'\nimport PersonalisationUtils from '../../../../utils/Personalisation/personalisationUtils'\n\nclass AsyncController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n POST: RequestHandler = async (req, res, _next) => {\n try {\n const response = await UserReportsListUtils.updateExpiredStatus({\n req,\n res,\n services: this.services,\n })\n res.send({ isExpired: response })\n } catch (error) {\n res.send({ status: 'FAILED' })\n }\n }\n\n saveDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.saveDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(`${req.baseUrl}?defaultsSaved=true`)\n } catch (error) {\n req.body = {\n title: 'Failed to save defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next()\n }\n }\n\n removeDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.removeDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(req.baseUrl)\n } catch (error) {\n req.body = {\n title: 'Failed to remove defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next()\n }\n }\n}\n\nexport { AsyncController }\nexport default AsyncController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,6CAEzBC,EAAiC,wDACjCC,EAA4B,2DAC5BC,EAAiC,qEAEjC,MAAMN,CAAgB,CACpB,WAEA,SAEA,YAAYO,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,KAAuB,MAAOC,EAAKC,EAAKC,IAAU,CAChD,GAAI,CACF,MAAMC,EAAW,MAAM,EAAAC,QAAqB,oBAAoB,CAC9D,IAAAJ,EACA,IAAAC,EACA,SAAU,KAAK,QACjB,CAAC,EACDA,EAAI,KAAK,CAAE,UAAWE,CAAS,CAAC,CAClC,MAAgB,CACdF,EAAI,KAAK,CAAE,OAAQ,QAAS,CAAC,CAC/B,CACF,EAEA,wBAA0C,MAAOD,EAAKC,EAAKI,IAAS,CAClE,GAAI,CACF,EAAAC,QAAqB,aAAa,cAAY,YAAaL,EAAKD,EAAK,KAAK,QAAQ,EAClFC,EAAI,SAAS,GAAGD,EAAI,OAAO,qBAAqB,CAClD,OAASO,EAAO,CACdP,EAAI,KAAO,CACT,MAAO,0BACP,MAAO,IAAI,EAAAQ,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIP,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAK,EAAK,CACP,CACF,EAEA,0BAA4C,MAAOL,EAAKC,EAAKI,IAAS,CACpE,GAAI,CACF,EAAAC,QAAqB,eAAe,cAAY,YAAaL,EAAKD,EAAK,KAAK,QAAQ,EACpFC,EAAI,SAASD,EAAI,OAAO,CAC1B,OAASO,EAAO,CACdP,EAAI,KAAO,CACT,MAAO,4BACP,MAAO,IAAI,EAAAQ,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIP,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAK,EAAK,CACP,CACF,CACF,CAGA,IAAOb,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../utils/ErrorHandler'\nimport { Services } from '../../../../types/Services'\nimport UserReportsListUtils from '../../../../components/user-reports/utils'\nimport { FiltersType } from '../../../../components/_filters/filtersTypeEnum'\nimport PersonalisationUtils from '../../../../utils/Personalisation/personalisationUtils'\n\nclass AsyncController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n POST: RequestHandler = async (req, res, _next) => {\n try {\n const response = await UserReportsListUtils.updateExpiredStatus({\n req,\n res,\n services: this.services,\n })\n res.send({ isExpired: response })\n } catch (error) {\n res.send({ status: 'FAILED' })\n }\n }\n\n saveDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.saveDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(`${req.baseUrl}?defaultsSaved=true`)\n } catch (error) {\n req.body = {\n title: 'Failed to save defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n\n removeDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.removeDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(req.baseUrl)\n } catch (error) {\n req.body = {\n title: 'Failed to remove defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n}\n\nexport { AsyncController }\nexport default AsyncController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EA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6
6
  "names": ["controller_exports", "__export", "AsyncController", "controller_default", "__toCommonJS", "import_ErrorHandler", "import_utils", "import_filtersTypeEnum", "import_personalisationUtils", "layoutPath", "services", "req", "res", "_next", "response", "UserReportsListUtils", "next", "PersonalisationUtils", "error", "ErrorHandler"]
7
7
  }
@@ -38,7 +38,7 @@ class AsyncController {
38
38
  error: new ErrorHandler(error).formatError(),
39
39
  ...(req.body && { ...req.body }),
40
40
  }
41
- next()
41
+ next(error)
42
42
  }
43
43
  }
44
44
 
@@ -52,7 +52,7 @@ class AsyncController {
52
52
  error: new ErrorHandler(error).formatError(),
53
53
  ...(req.body && { ...req.body }),
54
54
  }
55
- next()
55
+ next(error)
56
56
  }
57
57
  }
58
58
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.create;var i=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var H=(t,r)=>{for(var e in r)i(t,e,{get:r[e],enumerable:!0})},p=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of w(r))!D.call(t,s)&&s!==e&&i(t,s,{get:()=>r[s],enumerable:!(a=b(r,s))||a.enumerable});return t};var c=(t,r,e)=>(e=t!=null?v(E(t)):{},p(r||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),P=t=>p(i({},"__esModule",{value:!0}),t);var S={};H(S,{ViewAsyncDashboardController:()=>n,default:()=>R});module.exports=P(S);var y=c(require("../../../../../utils/ErrorHandler")),h=c(require("../../../../../utils/localsHelper")),m=c(require("./utils")),u=c(require("../../utils"));class n{layoutPath;services;constructor(r,e){this.layoutPath=r,this.services=e}GET=async(r,e,a)=>{const{type:s}=r.params;try{const d={req:r,res:e,services:this.services,next:a},o=await m.default.renderAsyncDashboard(d);e.render("dpr/routes/journeys/view-report/dashboard",{layoutPath:this.layoutPath,...o})}catch(d){const o=new y.default(d).formatError();let l;if(o.status==="EXPIRED"){const{dprUser:f}=h.default.getValues(e);l=await this.services.recentlyViewedService.asyncSetToExpiredByTableId(r.params.tableId,f.id)}r.body??={},r.body.title=`Failed to retrieve ${s}`,r.body.error=o,l&&(r.body.refreshLink=l),a()}};applyFilters=async(r,e,a)=>{await u.default.applyDashboardInteractiveQuery(r,e,this.services,"filters")}}var R=n;0&&(module.exports={ViewAsyncDashboardController});
1
+ "use strict";var v=Object.create;var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var H=(t,r)=>{for(var e in r)c(t,e,{get:r[e],enumerable:!0})},p=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of w(r))!D.call(t,s)&&s!==e&&c(t,s,{get:()=>r[s],enumerable:!(a=b(r,s))||a.enumerable});return t};var d=(t,r,e)=>(e=t!=null?v(E(t)):{},p(r||!t||!t.__esModule?c(e,"default",{value:t,enumerable:!0}):e,t)),P=t=>p(c({},"__esModule",{value:!0}),t);var S={};H(S,{ViewAsyncDashboardController:()=>n,default:()=>R});module.exports=P(S);var y=d(require("../../../../../utils/ErrorHandler")),h=d(require("../../../../../utils/localsHelper")),m=d(require("./utils")),u=d(require("../../utils"));class n{layoutPath;services;constructor(r,e){this.layoutPath=r,this.services=e}GET=async(r,e,a)=>{const{type:s}=r.params;try{const o={req:r,res:e,services:this.services,next:a},i=await m.default.renderAsyncDashboard(o);e.render("dpr/routes/journeys/view-report/dashboard",{layoutPath:this.layoutPath,...i})}catch(o){const i=new y.default(o).formatError();let l;if(i.status==="EXPIRED"){const{dprUser:f}=h.default.getValues(e);l=await this.services.recentlyViewedService.asyncSetToExpiredByTableId(r.params.tableId,f.id)}r.body??={},r.body.title=`Failed to retrieve ${s}`,r.body.error=i,l&&(r.body.refreshLink=l),a(o)}};applyFilters=async(r,e,a)=>{await u.default.applyDashboardInteractiveQuery(r,e,this.services,"filters")}}var R=n;0&&(module.exports={ViewAsyncDashboardController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/view-report/async/dashboard/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\nimport { Services } from '../../../../../types/Services'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport DashboardUtils from './utils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewAsyncDashboardController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { type } = req.params\n try {\n const params = { req, res, services: this.services, next }\n\n const renderData = await DashboardUtils.renderAsyncDashboard(params)\n\n res.render(`dpr/routes/journeys/view-report/dashboard`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n const dprError = new ErrorHandler(error).formatError()\n let refreshLink\n if (dprError.status === 'EXPIRED') {\n const { dprUser } = LocalsHelper.getValues(res)\n refreshLink = await this.services.recentlyViewedService.asyncSetToExpiredByTableId(\n req.params['tableId'],\n dprUser.id,\n )\n }\n req.body ??= {}\n req.body.title = `Failed to retrieve ${type}`\n req.body.error = dprError\n if (refreshLink) {\n req.body.refreshLink = refreshLink\n }\n next()\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyDashboardInteractiveQuery(req, res, this.services, 'filters')\n }\n}\n\nexport { ViewAsyncDashboardController }\nexport default ViewAsyncDashboardController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAEzBC,EAAyB,gDACzBC,EAA2B,sBAC3BA,EAA4B,0BAE5B,MAAML,CAA6B,CACjC,WAEA,SAEA,YAAYM,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,KAAAC,CAAK,EAAIH,EAAI,OACrB,GAAI,CACF,MAAMI,EAAS,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,SAAU,KAAAC,CAAK,EAEnDG,EAAa,MAAM,EAAAC,QAAe,qBAAqBF,CAAM,EAEnEH,EAAI,OAAO,4CAA6C,CACtD,WAAY,KAAK,WACjB,GAAGI,CACL,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAAW,IAAI,EAAAC,QAAaF,CAAK,EAAE,YAAY,EACrD,IAAIG,EACJ,GAAIF,EAAS,SAAW,UAAW,CACjC,KAAM,CAAE,QAAAG,CAAQ,EAAI,EAAAC,QAAa,UAAUX,CAAG,EAC9CS,EAAc,MAAM,KAAK,SAAS,sBAAsB,2BACtDV,EAAI,OAAO,QACXW,EAAQ,EACV,CACF,CACAX,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,sBAAsBG,CAAI,GAC3CH,EAAI,KAAK,MAAQQ,EACbE,IACFV,EAAI,KAAK,YAAcU,GAEzBR,EAAK,CACP,CACF,EAEA,aAA+B,MAAOF,EAAKC,EAAKY,IAAU,CACxD,MAAM,EAAAC,QAAgB,+BAA+Bd,EAAKC,EAAK,KAAK,SAAU,SAAS,CACzF,CACF,CAGA,IAAOR,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\nimport { Services } from '../../../../../types/Services'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport DashboardUtils from './utils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewAsyncDashboardController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { type } = req.params\n try {\n const params = { req, res, services: this.services, next }\n\n const renderData = await DashboardUtils.renderAsyncDashboard(params)\n\n res.render(`dpr/routes/journeys/view-report/dashboard`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n const dprError = new ErrorHandler(error).formatError()\n let refreshLink\n if (dprError.status === 'EXPIRED') {\n const { dprUser } = LocalsHelper.getValues(res)\n refreshLink = await this.services.recentlyViewedService.asyncSetToExpiredByTableId(\n req.params['tableId'],\n dprUser.id,\n )\n }\n req.body ??= {}\n req.body.title = `Failed to retrieve ${type}`\n req.body.error = dprError\n if (refreshLink) {\n req.body.refreshLink = refreshLink\n }\n next(error)\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyDashboardInteractiveQuery(req, res, this.services, 'filters')\n }\n}\n\nexport { ViewAsyncDashboardController }\nexport default ViewAsyncDashboardController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAEzBC,EAAyB,gDACzBC,EAA2B,sBAC3BA,EAA4B,0BAE5B,MAAML,CAA6B,CACjC,WAEA,SAEA,YAAYM,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,KAAAC,CAAK,EAAIH,EAAI,OACrB,GAAI,CACF,MAAMI,EAAS,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,SAAU,KAAAC,CAAK,EAEnDG,EAAa,MAAM,EAAAC,QAAe,qBAAqBF,CAAM,EAEnEH,EAAI,OAAO,4CAA6C,CACtD,WAAY,KAAK,WACjB,GAAGI,CACL,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAAW,IAAI,EAAAC,QAAaF,CAAK,EAAE,YAAY,EACrD,IAAIG,EACJ,GAAIF,EAAS,SAAW,UAAW,CACjC,KAAM,CAAE,QAAAG,CAAQ,EAAI,EAAAC,QAAa,UAAUX,CAAG,EAC9CS,EAAc,MAAM,KAAK,SAAS,sBAAsB,2BACtDV,EAAI,OAAO,QACXW,EAAQ,EACV,CACF,CACAX,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,sBAAsBG,CAAI,GAC3CH,EAAI,KAAK,MAAQQ,EACbE,IACFV,EAAI,KAAK,YAAcU,GAEzBR,EAAKK,CAAK,CACZ,CACF,EAEA,aAA+B,MAAOP,EAAKC,EAAKY,IAAU,CACxD,MAAM,EAAAC,QAAgB,+BAA+Bd,EAAKC,EAAK,KAAK,SAAU,SAAS,CACzF,CACF,CAGA,IAAOR,EAAQD",
6
6
  "names": ["controller_exports", "__export", "ViewAsyncDashboardController", "controller_default", "__toCommonJS", "import_ErrorHandler", "import_localsHelper", "import_utils", "layoutPath", "services", "req", "res", "next", "type", "params", "renderData", "DashboardUtils", "error", "dprError", "ErrorHandler", "refreshLink", "dprUser", "LocalsHelper", "_next", "ViewReportUtils"]
7
7
  }
@@ -42,7 +42,7 @@ class ViewAsyncDashboardController {
42
42
  if (refreshLink) {
43
43
  req.body.refreshLink = refreshLink
44
44
  }
45
- next()
45
+ next(error)
46
46
  }
47
47
  }
48
48
 
@@ -1,2 +1,2 @@
1
- "use strict";var R=Object.create;var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!H.call(t,o)&&o!==r&&i(t,o,{get:()=>e[o],enumerable:!(s=w(e,o))||s.enumerable});return t};var n=(t,e,r)=>(r=t!=null?R(b(t)):{},m(e||!t||!t.__esModule?i(r,"default",{value:t,enumerable:!0}):r,t)),P=t=>m(i({},"__esModule",{value:!0}),t);var x={};I(x,{ViewAyncReportController:()=>y,default:()=>S});module.exports=P(x);var u=n(require("../../../../../utils/localsHelper")),v=n(require("./utils")),l=n(require("../../utils")),h=n(require("../../../../../utils/ErrorHandler"));class y{layoutPath;services;constructor(e,r){this.layoutPath=e,this.services=r}GET=async(e,r,s)=>{const{type:o}=e.params;try{const c={req:e,res:r,services:this.services,next:s},a=await v.default.renderReport(c);r.render("dpr/routes/journeys/view-report/report",{layoutPath:this.layoutPath,...a})}catch(c){const a=new h.default(c).formatError();let p;const{recentlyViewedService:d}=this.services;if(a.status==="EXPIRED"&&d){const{dprUser:f}=u.default.getValues(r);p=await d.asyncSetToExpiredByTableId(e.params.tableId,f.id)}e.body??={},e.body.title=`Failed to retrieve ${o}`,e.body.error=a,p&&(e.body.refreshLink=p),s()}};applyFilters=async(e,r,s)=>{await l.default.applyReportInteractiveQuery(e,r,this.services,"filters")};applyColumns=async(e,r,s)=>{await l.default.applyReportInteractiveQuery(e,r,this.services,"columns")}}var S=y;0&&(module.exports={ViewAyncReportController});
1
+ "use strict";var R=Object.create;var n=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!H.call(t,o)&&o!==r&&n(t,o,{get:()=>e[o],enumerable:!(s=w(e,o))||s.enumerable});return t};var c=(t,e,r)=>(r=t!=null?R(b(t)):{},m(e||!t||!t.__esModule?n(r,"default",{value:t,enumerable:!0}):r,t)),P=t=>m(n({},"__esModule",{value:!0}),t);var x={};I(x,{ViewAyncReportController:()=>y,default:()=>S});module.exports=P(x);var u=c(require("../../../../../utils/localsHelper")),v=c(require("./utils")),l=c(require("../../utils")),h=c(require("../../../../../utils/ErrorHandler"));class y{layoutPath;services;constructor(e,r){this.layoutPath=e,this.services=r}GET=async(e,r,s)=>{const{type:o}=e.params;try{const a={req:e,res:r,services:this.services,next:s},i=await v.default.renderReport(a);r.render("dpr/routes/journeys/view-report/report",{layoutPath:this.layoutPath,...i})}catch(a){const i=new h.default(a).formatError();let p;const{recentlyViewedService:d}=this.services;if(i.status==="EXPIRED"&&d){const{dprUser:f}=u.default.getValues(r);p=await d.asyncSetToExpiredByTableId(e.params.tableId,f.id)}e.body??={},e.body.title=`Failed to retrieve ${o}`,e.body.error=i,p&&(e.body.refreshLink=p),s(a)}};applyFilters=async(e,r,s)=>{await l.default.applyReportInteractiveQuery(e,r,this.services,"filters")};applyColumns=async(e,r,s)=>{await l.default.applyReportInteractiveQuery(e,r,this.services,"columns")}}var S=y;0&&(module.exports={ViewAyncReportController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/view-report/async/report/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport AsyncReportUtils from './utils'\nimport ViewReportUtils from '../../utils'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\n\nclass ViewAyncReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { type } = req.params\n try {\n const params = { req, res, services: this.services, next }\n\n const renderData = await AsyncReportUtils.renderReport(params)\n\n res.render(`dpr/routes/journeys/view-report/report`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n const dprError = new ErrorHandler(error).formatError()\n let refreshLink\n const { recentlyViewedService } = this.services\n if (dprError.status === 'EXPIRED' && recentlyViewedService) {\n const { dprUser } = LocalsHelper.getValues(res)\n refreshLink = await recentlyViewedService.asyncSetToExpiredByTableId(req.params['tableId'], dprUser.id)\n }\n req.body ??= {}\n req.body.title = `Failed to retrieve ${type}`\n req.body.error = dprError\n if (refreshLink) {\n req.body.refreshLink = refreshLink\n }\n next()\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'filters')\n }\n\n applyColumns: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'columns')\n }\n}\n\nexport { ViewAyncReportController }\nexport default ViewAyncReportController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,gDACzBC,EAA6B,sBAC7BA,EAA4B,0BAC5BC,EAAyB,gDAEzB,MAAML,CAAyB,CAC7B,WAEA,SAEA,YAAYM,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,KAAAC,CAAK,EAAIH,EAAI,OACrB,GAAI,CACF,MAAMI,EAAS,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,SAAU,KAAAC,CAAK,EAEnDG,EAAa,MAAM,EAAAC,QAAiB,aAAaF,CAAM,EAE7DH,EAAI,OAAO,yCAA0C,CACnD,WAAY,KAAK,WACjB,GAAGI,CACL,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAAW,IAAI,EAAAC,QAAaF,CAAK,EAAE,YAAY,EACrD,IAAIG,EACJ,KAAM,CAAE,sBAAAC,CAAsB,EAAI,KAAK,SACvC,GAAIH,EAAS,SAAW,WAAaG,EAAuB,CAC1D,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUZ,CAAG,EAC9CS,EAAc,MAAMC,EAAsB,2BAA2BX,EAAI,OAAO,QAAYY,EAAQ,EAAE,CACxG,CACAZ,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,sBAAsBG,CAAI,GAC3CH,EAAI,KAAK,MAAQQ,EACbE,IACFV,EAAI,KAAK,YAAcU,GAEzBR,EAAK,CACP,CACF,EAEA,aAA+B,MAAOF,EAAKC,EAAKa,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4Bf,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,EAEA,aAA+B,MAAOD,EAAKC,EAAKa,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4Bf,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,CACF,CAGA,IAAOR,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport AsyncReportUtils from './utils'\nimport ViewReportUtils from '../../utils'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\n\nclass ViewAyncReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { type } = req.params\n try {\n const params = { req, res, services: this.services, next }\n\n const renderData = await AsyncReportUtils.renderReport(params)\n\n res.render(`dpr/routes/journeys/view-report/report`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n const dprError = new ErrorHandler(error).formatError()\n let refreshLink\n const { recentlyViewedService } = this.services\n if (dprError.status === 'EXPIRED' && recentlyViewedService) {\n const { dprUser } = LocalsHelper.getValues(res)\n refreshLink = await recentlyViewedService.asyncSetToExpiredByTableId(req.params['tableId'], dprUser.id)\n }\n req.body ??= {}\n req.body.title = `Failed to retrieve ${type}`\n req.body.error = dprError\n if (refreshLink) {\n req.body.refreshLink = refreshLink\n }\n next(error)\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'filters')\n }\n\n applyColumns: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'columns')\n }\n}\n\nex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EAAKa,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4Bf,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,CACF,CAGA,IAAOR,EAAQD",
6
6
  "names": ["controller_exports", "__export", "ViewAyncReportController", "controller_default", "__toCommonJS", "import_localsHelper", "import_utils", "import_ErrorHandler", "layoutPath", "services", "req", "res", "next", "type", "params", "renderData", "AsyncReportUtils", "error", "dprError", "ErrorHandler", "refreshLink", "recentlyViewedService", "dprUser", "LocalsHelper", "_next", "ViewReportUtils"]
7
7
  }
@@ -40,7 +40,7 @@ class ViewAyncReportController {
40
40
  if (refreshLink) {
41
41
  req.body.refreshLink = refreshLink
42
42
  }
43
- next()
43
+ next(error)
44
44
  }
45
45
  }
46
46
 
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.create;var s=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var h=(o,r)=>{for(var e in r)s(o,e,{get:r[e],enumerable:!0})},n=(o,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of c(r))!f.call(o,t)&&t!==e&&s(o,t,{get:()=>r[t],enumerable:!(a=y(r,t))||a.enumerable});return o};var l=(o,r,e)=>(e=o!=null?d(u(o)):{},n(r||!o||!o.__esModule?s(e,"default",{value:o,enumerable:!0}):e,o)),v=o=>n(s({},"__esModule",{value:!0}),o);var b={};h(b,{ViewReportController:()=>i,default:()=>g});module.exports=v(b);var m=l(require("../../../utils/ErrorHandler")),p=l(require("../../../utils/logger"));class i{layoutPath;services;constructor(r,e){this.layoutPath=r,this.services=e}errorHandler=async(r,e,a)=>{p.default.error(`Error: ${JSON.stringify(r.body)}`);const t=new m.default(r.body?.error||{}).formatError();e.render("dpr/routes/journeys/view-report/error",{layoutPath:this.layoutPath,...r.body&&{...r.body},...r.params,error:t,params:r.params})}}var g=i;0&&(module.exports={ViewReportController});
1
+ "use strict";var u=Object.create;var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var v=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},n=(e,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of f(r))!E.call(e,t)&&t!==o&&a(e,t,{get:()=>r[t],enumerable:!(s=y(r,t))||s.enumerable});return e};var m=(e,r,o)=>(o=e!=null?u(h(e)):{},n(r||!e||!e.__esModule?a(o,"default",{value:e,enumerable:!0}):o,e)),g=e=>n(a({},"__esModule",{value:!0}),e);var x={};v(x,{ViewReportController:()=>i,default:()=>H});module.exports=g(x);var p=require("@sentry/node"),l=m(require("../../../utils/ErrorHandler")),c=m(require("../../../utils/logger"));class i{layoutPath;services;constructor(r,o){this.layoutPath=r,this.services=o}errorHandler=async(r,o,s,t)=>{c.default.error(`Error: ${JSON.stringify(o.body)}`);const d=new l.default(r||{}).formatError();(0,p.captureException)(r),s.render("dpr/routes/journeys/view-report/error",{layoutPath:this.layoutPath,...o.body&&{...o.body},...o.params,error:d,params:o.params})}}var H=i;0&&(module.exports={ViewReportController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/dpr/routes/journeys/view-report/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../utils/ErrorHandler'\nimport { Services } from '../../../types/Services'\nimport logger from '../../../utils/logger'\n\nclass ViewReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n errorHandler: RequestHandler = async (req, res, _next) => {\n logger.error(`Error: ${JSON.stringify(req.body)}`)\n const error = new ErrorHandler(req.body?.error || {}).formatError()\n\n res.render(`dpr/routes/journeys/view-report/error`, {\n layoutPath: this.layoutPath,\n ...(req.body && { ...req.body }),\n ...req.params,\n error,\n params: req.params,\n })\n }\n}\n\nexport { ViewReportController }\nexport default ViewReportController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,0CAEzBC,EAAmB,oCAEnB,MAAMJ,CAAqB,CACzB,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,aAA+B,MAAOC,EAAKC,EAAKC,IAAU,CACxD,EAAAC,QAAO,MAAM,UAAU,KAAK,UAAUH,EAAI,IAAI,CAAC,EAAE,EACjD,MAAMI,EAAQ,IAAI,EAAAC,QAAaL,EAAI,MAAM,OAAS,CAAC,CAAC,EAAE,YAAY,EAElEC,EAAI,OAAO,wCAAyC,CAClD,WAAY,KAAK,WACjB,GAAID,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,EAC9B,GAAGA,EAAI,OACP,MAAAI,EACA,OAAQJ,EAAI,MACd,CAAC,CACH,CACF,CAGA,IAAON,EAAQD",
6
- "names": ["controller_exports", "__export", "ViewReportController", "controller_default", "__toCommonJS", "import_ErrorHandler", "import_logger", "layoutPath", "services", "req", "res", "_next", "logger", "error", "ErrorHandler"]
4
+ "sourcesContent": ["import { ErrorRequestHandler, RequestHandler } from 'express'\nimport { captureException } from '@sentry/node'\nimport ErrorHandler from '../../../utils/ErrorHandler'\nimport { Services } from '../../../types/Services'\nimport logger from '../../../utils/logger'\n\nclass ViewReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n errorHandler: ErrorRequestHandler = async (error, req, res, _next) => {\n logger.error(`Error: ${JSON.stringify(req.body)}`)\n const formattedErr = new ErrorHandler(error || {}).formatError()\n\n captureException(error)\n\n res.render(`dpr/routes/journeys/view-report/error`, {\n layoutPath: this.layoutPath,\n ...(req.body && { ...req.body }),\n ...req.params,\n error: formattedErr,\n params: req.params,\n })\n }\n}\n\nexport { ViewReportController }\nexport default ViewReportController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAiC,wBACjCC,EAAyB,0CAEzBC,EAAmB,oCAEnB,MAAML,CAAqB,CACzB,WAEA,SAEA,YAAYM,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,aAAoC,MAAOC,EAAOC,EAAKC,EAAKC,IAAU,CACpE,EAAAC,QAAO,MAAM,UAAU,KAAK,UAAUH,EAAI,IAAI,CAAC,EAAE,EACjD,MAAMI,EAAe,IAAI,EAAAC,QAAaN,GAAS,CAAC,CAAC,EAAE,YAAY,KAE/D,oBAAiBA,CAAK,EAEtBE,EAAI,OAAO,wCAAyC,CAClD,WAAY,KAAK,WACjB,GAAID,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,EAC9B,GAAGA,EAAI,OACP,MAAOI,EACP,OAAQJ,EAAI,MACd,CAAC,CACH,CACF,CAGA,IAAOR,EAAQD",
6
+ "names": ["controller_exports", "__export", "ViewReportController", "controller_default", "__toCommonJS", "import_node", "import_ErrorHandler", "import_logger", "layoutPath", "services", "error", "req", "res", "_next", "logger", "formattedErr", "ErrorHandler"]
7
7
  }
@@ -1,4 +1,5 @@
1
- import { RequestHandler } from 'express'
1
+ import { ErrorRequestHandler, RequestHandler } from 'express'
2
+ import { captureException } from '@sentry/node'
2
3
  import ErrorHandler from '../../../utils/ErrorHandler'
3
4
  import { Services } from '../../../types/Services'
4
5
  import logger from '../../../utils/logger'
@@ -13,15 +14,17 @@ class ViewReportController {
13
14
  this.services = services
14
15
  }
15
16
 
16
- errorHandler: RequestHandler = async (req, res, _next) => {
17
+ errorHandler: ErrorRequestHandler = async (error, req, res, _next) => {
17
18
  logger.error(`Error: ${JSON.stringify(req.body)}`)
18
- const error = new ErrorHandler(req.body?.error || {}).formatError()
19
+ const formattedErr = new ErrorHandler(error || {}).formatError()
20
+
21
+ captureException(error)
19
22
 
20
23
  res.render(`dpr/routes/journeys/view-report/error`, {
21
24
  layoutPath: this.layoutPath,
22
25
  ...(req.body && { ...req.body }),
23
26
  ...req.params,
24
- error,
27
+ error: formattedErr,
25
28
  params: req.params,
26
29
  })
27
30
  }
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.create;var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(e,r)=>{for(var t in r)a(e,t,{get:r[t],enumerable:!0})},d=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of u(r))!m.call(e,o)&&o!==t&&a(e,o,{get:()=>r[o],enumerable:!(s=p(r,o))||s.enumerable});return e};var i=(e,r,t)=>(t=e!=null?y(b(e)):{},d(r||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e)),v=e=>d(a({},"__esModule",{value:!0}),e);var D={};f(D,{ViewSyncDashboardController:()=>n,default:()=>w});module.exports=v(D);var l=i(require("../../../../../utils/ErrorHandler")),c=i(require("./utils")),h=i(require("../../utils"));class n{layoutPath;services;constructor(r,t){this.layoutPath=r,this.services=t}GET=async(r,t,s)=>{try{const o=await c.default.renderSyncDashboard({req:r,res:t,services:this.services});t.render("dpr/routes/journeys/view-report/dashboard",{layoutPath:this.layoutPath,...o})}catch(o){r.body??={},r.body.title="Dashboard Failed",r.body.errorDescription="We were unable to show this dashboard for the following reason:",r.body.error=new l.default(o).formatError(),s()}};applyFilters=async(r,t,s)=>{await h.default.applyDashboardInteractiveQuery(r,t,this.services,"filters")}}var w=n;0&&(module.exports={ViewSyncDashboardController});
1
+ "use strict";var y=Object.create;var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(e,r)=>{for(var t in r)a(e,t,{get:r[t],enumerable:!0})},d=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of u(r))!m.call(e,o)&&o!==t&&a(e,o,{get:()=>r[o],enumerable:!(s=p(r,o))||s.enumerable});return e};var i=(e,r,t)=>(t=e!=null?y(b(e)):{},d(r||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e)),v=e=>d(a({},"__esModule",{value:!0}),e);var D={};f(D,{ViewSyncDashboardController:()=>n,default:()=>w});module.exports=v(D);var l=i(require("../../../../../utils/ErrorHandler")),c=i(require("./utils")),h=i(require("../../utils"));class n{layoutPath;services;constructor(r,t){this.layoutPath=r,this.services=t}GET=async(r,t,s)=>{try{const o=await c.default.renderSyncDashboard({req:r,res:t,services:this.services});t.render("dpr/routes/journeys/view-report/dashboard",{layoutPath:this.layoutPath,...o})}catch(o){r.body??={},r.body.title="Dashboard Failed",r.body.errorDescription="We were unable to show this dashboard for the following reason:",r.body.error=new l.default(o).formatError(),s(o)}};applyFilters=async(r,t,s)=>{await h.default.applyDashboardInteractiveQuery(r,t,this.services,"filters")}}var w=n;0&&(module.exports={ViewSyncDashboardController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/view-report/sync/dashboard/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\nimport { Services } from '../../../../../types/Services'\nimport SyncDashboardUtils from './utils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewSyncDashboardController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n try {\n const renderData = await SyncDashboardUtils.renderSyncDashboard({ req, res, services: this.services })\n\n res.render(`dpr/routes/journeys/view-report/dashboard`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = `Dashboard Failed`\n req.body.errorDescription = 'We were unable to show this dashboard for the following reason:'\n req.body.error = new ErrorHandler(error).formatError()\n next()\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyDashboardInteractiveQuery(req, res, this.services, 'filters')\n }\n}\n\nexport { ViewSyncDashboardController }\nexport default ViewSyncDashboardController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAEzBC,EAA+B,sBAC/BA,EAA4B,0BAE5B,MAAMJ,CAA4B,CAChC,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAa,MAAM,EAAAC,QAAmB,oBAAoB,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,QAAS,CAAC,EAErGA,EAAI,OAAO,4CAA6C,CACtD,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,mBACjBA,EAAI,KAAK,iBAAmB,kEAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAK,CACP,CACF,EAEA,aAA+B,MAAOF,EAAKC,EAAKM,IAAU,CACxD,MAAM,EAAAC,QAAgB,+BAA+BR,EAAKC,EAAK,KAAK,SAAU,SAAS,CACzF,CACF,CAGA,IAAOP,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\nimport { Services } from '../../../../../types/Services'\nimport SyncDashboardUtils from './utils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewSyncDashboardController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n try {\n const renderData = await SyncDashboardUtils.renderSyncDashboard({ req, res, services: this.services })\n\n res.render(`dpr/routes/journeys/view-report/dashboard`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = `Dashboard Failed`\n req.body.errorDescription = 'We were unable to show this dashboard for the following reason:'\n req.body.error = new ErrorHandler(error).formatError()\n next(error)\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyDashboardInteractiveQuery(req, res, this.services, 'filters')\n }\n}\n\nexport { ViewSyncDashboardController }\nexport default ViewSyncDashboardController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAEzBC,EAA+B,sBAC/BA,EAA4B,0BAE5B,MAAMJ,CAA4B,CAChC,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAa,MAAM,EAAAC,QAAmB,oBAAoB,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,QAAS,CAAC,EAErGA,EAAI,OAAO,4CAA6C,CACtD,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,mBACjBA,EAAI,KAAK,iBAAmB,kEAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAKG,CAAK,CACZ,CACF,EAEA,aAA+B,MAAOL,EAAKC,EAAKM,IAAU,CACxD,MAAM,EAAAC,QAAgB,+BAA+BR,EAAKC,EAAK,KAAK,SAAU,SAAS,CACzF,CACF,CAGA,IAAOP,EAAQD",
6
6
  "names": ["controller_exports", "__export", "ViewSyncDashboardController", "controller_default", "__toCommonJS", "import_ErrorHandler", "import_utils", "layoutPath", "services", "req", "res", "next", "renderData", "SyncDashboardUtils", "error", "ErrorHandler", "_next", "ViewReportUtils"]
7
7
  }
@@ -27,7 +27,7 @@ class ViewSyncDashboardController {
27
27
  req.body.title = `Dashboard Failed`
28
28
  req.body.errorDescription = 'We were unable to show this dashboard for the following reason:'
29
29
  req.body.error = new ErrorHandler(error).formatError()
30
- next()
30
+ next(error)
31
31
  }
32
32
  }
33
33
 
@@ -1,2 +1,2 @@
1
- "use strict";var w=Object.create;var a=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var i in e)a(t,i,{get:e[i],enumerable:!0})},v=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of T(e))!q.call(t,r)&&r!==i&&a(t,r,{get:()=>e[r],enumerable:!(n=H(e,r))||n.enumerable});return t};var E=(t,e,i)=>(i=t!=null?w(b(t)):{},v(e||!t||!t.__esModule?a(i,"default",{value:t,enumerable:!0}):i,t)),L=t=>v(a({},"__esModule",{value:!0}),t);var j={};x(j,{LoadReportController:()=>f,default:()=>V});module.exports=L(j);var y=E(require("../../../../../utils/localsHelper")),g=require("../../../../../types/UserReports");class f{layoutPath;services;constructor(e,i){this.layoutPath=e,this.services=i}GET=async(e,i,n)=>{try{const{token:r}=y.default.getValues(i),{reportId:s,id:c,type:u}=e.params,{dataProductDefinitionsPath:p}=e.query,D=await this.services.reportingService.getDefinitionSummary(r,s,p);let o,h,d,m;if(u===g.ReportType.REPORT){o=await this.services.reportingService.getDefinition(r,s,c,p);const{variant:l}=o;h=l.classification,d=l.description,m=l.name}else o=await this.services.dashboardService.getDefinition(r,s,c,p),d=o.description,m=o.name;const{name:S,description:P}=D,R={reportId:s,id:c,type:u,reportName:S,name:m,classification:h,description:d||P};i.render("dpr/routes/journeys/view-report/sync/load-report/view",{renderData:R,layoutPath:this.layoutPath})}catch{n()}}}var V=f;0&&(module.exports={LoadReportController});
1
+ "use strict";var w=Object.create;var a=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var i in e)a(t,i,{get:e[i],enumerable:!0})},v=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of T(e))!q.call(t,r)&&r!==i&&a(t,r,{get:()=>e[r],enumerable:!(n=H(e,r))||n.enumerable});return t};var E=(t,e,i)=>(i=t!=null?w(b(t)):{},v(e||!t||!t.__esModule?a(i,"default",{value:t,enumerable:!0}):i,t)),L=t=>v(a({},"__esModule",{value:!0}),t);var j={};x(j,{LoadReportController:()=>f,default:()=>V});module.exports=L(j);var y=E(require("../../../../../utils/localsHelper")),g=require("../../../../../types/UserReports");class f{layoutPath;services;constructor(e,i){this.layoutPath=e,this.services=i}GET=async(e,i,n)=>{try{const{token:r}=y.default.getValues(i),{reportId:s,id:c,type:u}=e.params,{dataProductDefinitionsPath:p}=e.query,D=await this.services.reportingService.getDefinitionSummary(r,s,p);let o,h,d,m;if(u===g.ReportType.REPORT){o=await this.services.reportingService.getDefinition(r,s,c,p);const{variant:l}=o;h=l.classification,d=l.description,m=l.name}else o=await this.services.dashboardService.getDefinition(r,s,c,p),d=o.description,m=o.name;const{name:S,description:P}=D,R={reportId:s,id:c,type:u,reportName:S,name:m,classification:h,description:d||P};i.render("dpr/routes/journeys/view-report/sync/load-report/view",{renderData:R,layoutPath:this.layoutPath})}catch(r){n(r)}}}var V=f;0&&(module.exports={LoadReportController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/view-report/sync/load-report/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { ReportType } from '../../../../../types/UserReports'\nimport { components } from '../../../../../types/api'\n\nclass LoadReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n try {\n const { token } = LocalsHelper.getValues(res)\n const { reportId, id, type } = req.params\n const { dataProductDefinitionsPath } = req.query\n\n const definitionSummary = await this.services.reportingService.getDefinitionSummary(\n token,\n reportId,\n <string | undefined>dataProductDefinitionsPath,\n )\n\n let definition:\n | components['schemas']['SingleVariantReportDefinition']\n | components['schemas']['DashboardDefinition']\n\n let classification\n let description\n let name\n if (type === ReportType.REPORT) {\n definition = await this.services.reportingService.getDefinition(\n token,\n reportId,\n id,\n <string | undefined>dataProductDefinitionsPath,\n )\n const { variant } = definition\n classification = variant.classification\n description = variant.description\n name = variant.name\n } else {\n definition = await this.services.dashboardService.getDefinition(\n token,\n reportId,\n id,\n <string | undefined>dataProductDefinitionsPath,\n )\n description = definition.description\n name = definition.name\n }\n const { name: reportName, description: reportDescription } = definitionSummary\n\n const renderData = {\n reportId,\n id,\n type,\n reportName,\n name,\n classification,\n description: description || reportDescription,\n }\n\n res.render(`dpr/routes/journeys/view-report/sync/load-report/view`, {\n renderData,\n layoutPath: this.layoutPath,\n })\n } catch (error) {\n next()\n }\n }\n}\n\nexport { LoadReportController }\nexport default LoadReportController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,gDACzBC,EAA2B,4CAG3B,MAAMJ,CAAqB,CACzB,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,KAAM,CAAE,MAAAC,CAAM,EAAI,EAAAC,QAAa,UAAUH,CAAG,EACtC,CAAE,SAAAI,EAAU,GAAAC,EAAI,KAAAC,CAAK,EAAIP,EAAI,OAC7B,CAAE,2BAAAQ,CAA2B,EAAIR,EAAI,MAErCS,EAAoB,MAAM,KAAK,SAAS,iBAAiB,qBAC7DN,EACAE,EACoBG,CACtB,EAEA,IAAIE,EAIAC,EACAC,EACAC,EACJ,GAAIN,IAAS,aAAW,OAAQ,CAC9BG,EAAa,MAAM,KAAK,SAAS,iBAAiB,cAChDP,EACAE,EACAC,EACoBE,CACtB,EACA,KAAM,CAAE,QAAAM,CAAQ,EAAIJ,EACpBC,EAAiBG,EAAQ,eACzBF,EAAcE,EAAQ,YACtBD,EAAOC,EAAQ,IACjB,MACEJ,EAAa,MAAM,KAAK,SAAS,iBAAiB,cAChDP,EACAE,EACAC,EACoBE,CACtB,EACAI,EAAcF,EAAW,YACzBG,EAAOH,EAAW,KAEpB,KAAM,CAAE,KAAMK,EAAY,YAAaC,CAAkB,EAAIP,EAEvDQ,EAAa,CACjB,SAAAZ,EACA,GAAAC,EACA,KAAAC,EACA,WAAAQ,EACA,KAAAF,EACA,eAAAF,EACA,YAAaC,GAAeI,CAC9B,EAEAf,EAAI,OAAO,wDAAyD,CAClE,WAAAgB,EACA,WAAY,KAAK,UACnB,CAAC,CACH,MAAgB,CACdf,EAAK,CACP,CACF,CACF,CAGA,IAAOR,EAAQD",
6
- "names": ["controller_exports", "__export", "LoadReportController", "controller_default", "__toCommonJS", "import_localsHelper", "import_UserReports", "layoutPath", "services", "req", "res", "next", "token", "LocalsHelper", "reportId", "id", "type", "dataProductDefinitionsPath", "definitionSummary", "definition", "classification", "description", "name", "variant", "reportName", "reportDescription", "renderData"]
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { ReportType } from '../../../../../types/UserReports'\nimport { components } from '../../../../../types/api'\n\nclass LoadReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n try {\n const { token } = LocalsHelper.getValues(res)\n const { reportId, id, type } = req.params\n const { dataProductDefinitionsPath } = req.query\n\n const definitionSummary = await this.services.reportingService.getDefinitionSummary(\n token,\n reportId,\n <string | undefined>dataProductDefinitionsPath,\n )\n\n let definition:\n | components['schemas']['SingleVariantReportDefinition']\n | components['schemas']['DashboardDefinition']\n\n let classification\n let description\n let name\n if (type === ReportType.REPORT) {\n definition = await this.services.reportingService.getDefinition(\n token,\n reportId,\n id,\n <string | undefined>dataProductDefinitionsPath,\n )\n const { variant } = definition\n classification = variant.classification\n description = variant.description\n name = variant.name\n } else {\n definition = await this.services.dashboardService.getDefinition(\n token,\n reportId,\n id,\n <string | undefined>dataProductDefinitionsPath,\n )\n description = definition.description\n name = definition.name\n }\n const { name: reportName, description: reportDescription } = definitionSummary\n\n const renderData = {\n reportId,\n id,\n type,\n reportName,\n name,\n classification,\n description: description || reportDescription,\n }\n\n res.render(`dpr/routes/journeys/view-report/sync/load-report/view`, {\n renderData,\n layoutPath: this.layoutPath,\n })\n } catch (error) {\n next(error)\n }\n }\n}\n\nexport { LoadReportController }\nexport default LoadReportController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,gDACzBC,EAA2B,4CAG3B,MAAMJ,CAAqB,CACzB,WAEA,SAEA,YAAYK,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,KAAM,CAAE,MAAAC,CAAM,EAAI,EAAAC,QAAa,UAAUH,CAAG,EACtC,CAAE,SAAAI,EAAU,GAAAC,EAAI,KAAAC,CAAK,EAAIP,EAAI,OAC7B,CAAE,2BAAAQ,CAA2B,EAAIR,EAAI,MAErCS,EAAoB,MAAM,KAAK,SAAS,iBAAiB,qBAC7DN,EACAE,EACoBG,CACtB,EAEA,IAAIE,EAIAC,EACAC,EACAC,EACJ,GAAIN,IAAS,aAAW,OAAQ,CAC9BG,EAAa,MAAM,KAAK,SAAS,iBAAiB,cAChDP,EACAE,EACAC,EACoBE,CACtB,EACA,KAAM,CAAE,QAAAM,CAAQ,EAAIJ,EACpBC,EAAiBG,EAAQ,eACzBF,EAAcE,EAAQ,YACtBD,EAAOC,EAAQ,IACjB,MACEJ,EAAa,MAAM,KAAK,SAAS,iBAAiB,cAChDP,EACAE,EACAC,EACoBE,CACtB,EACAI,EAAcF,EAAW,YACzBG,EAAOH,EAAW,KAEpB,KAAM,CAAE,KAAMK,EAAY,YAAaC,CAAkB,EAAIP,EAEvDQ,EAAa,CACjB,SAAAZ,EACA,GAAAC,EACA,KAAAC,EACA,WAAAQ,EACA,KAAAF,EACA,eAAAF,EACA,YAAaC,GAAeI,CAC9B,EAEAf,EAAI,OAAO,wDAAyD,CAClE,WAAAgB,EACA,WAAY,KAAK,UACnB,CAAC,CACH,OAASC,EAAO,CACdhB,EAAKgB,CAAK,CACZ,CACF,CACF,CAGA,IAAOxB,EAAQD",
6
+ "names": ["controller_exports", "__export", "LoadReportController", "controller_default", "__toCommonJS", "import_localsHelper", "import_UserReports", "layoutPath", "services", "req", "res", "next", "token", "LocalsHelper", "reportId", "id", "type", "dataProductDefinitionsPath", "definitionSummary", "definition", "classification", "description", "name", "variant", "reportName", "reportDescription", "renderData", "error"]
7
7
  }
@@ -71,7 +71,7 @@ class LoadReportController {
71
71
  layoutPath: this.layoutPath,
72
72
  })
73
73
  } catch (error) {
74
- next()
74
+ next(error)
75
75
  }
76
76
  }
77
77
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.create;var a=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of v(e))!R.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(s=f(e,o))||s.enumerable});return t};var i=(t,e,r)=>(r=t!=null?m(h(t)):{},p(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t)),w=t=>p(a({},"__esModule",{value:!0}),t);var F={};b(F,{ViewSyncReportController:()=>d,default:()=>E});module.exports=w(F);var l=i(require("../../../../../utils/ErrorHandler")),u=i(require("./utils")),n=require("../../../../../components/_filters/filtersTypeEnum"),c=i(require("../../../../../utils/Personalisation/personalisationUtils")),y=i(require("../../utils"));class d{layoutPath;services;constructor(e,r){this.layoutPath=e,this.services=r}GET=async(e,r,s)=>{try{const o=await u.default.getReport({req:e,res:r,services:this.services});r.render("dpr/routes/journeys/view-report/report",{layoutPath:this.layoutPath,...o})}catch(o){e.body??={},e.body.title="Report Failed",e.body.errorDescription="We were unable to show this report for the following reason:",e.body.error=new l.default(o).formatError(),s()}};saveDefaultFilterValues=async(e,r,s)=>{try{c.default.saveDefaults(n.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(`${e.baseUrl}?defaultsSaved=true`)}catch(o){e.body={title:"Failed to save defaults",error:new l.default(o).formatError(),...e.body&&{...e.body}},s()}};removeDefaultFilterValues=async(e,r,s)=>{try{c.default.removeDefaults(n.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(e.baseUrl)}catch(o){e.body={title:"Failed to remove defaults",error:new l.default(o).formatError(),...e.body&&{...e.body}},s()}};applyFilters=async(e,r,s)=>{await y.default.applyReportInteractiveQuery(e,r,this.services,"filters")};applyColumns=async(e,r,s)=>{await y.default.applyReportInteractiveQuery(e,r,this.services,"columns")}}var E=d;0&&(module.exports={ViewSyncReportController});
1
+ "use strict";var m=Object.create;var a=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var b=(o,e)=>{for(var r in e)a(o,r,{get:e[r],enumerable:!0})},p=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of v(e))!R.call(o,t)&&t!==r&&a(o,t,{get:()=>e[t],enumerable:!(s=f(e,t))||s.enumerable});return o};var i=(o,e,r)=>(r=o!=null?m(h(o)):{},p(e||!o||!o.__esModule?a(r,"default",{value:o,enumerable:!0}):r,o)),w=o=>p(a({},"__esModule",{value:!0}),o);var F={};b(F,{ViewSyncReportController:()=>d,default:()=>E});module.exports=w(F);var l=i(require("../../../../../utils/ErrorHandler")),u=i(require("./utils")),n=require("../../../../../components/_filters/filtersTypeEnum"),c=i(require("../../../../../utils/Personalisation/personalisationUtils")),y=i(require("../../utils"));class d{layoutPath;services;constructor(e,r){this.layoutPath=e,this.services=r}GET=async(e,r,s)=>{try{const t=await u.default.getReport({req:e,res:r,services:this.services});r.render("dpr/routes/journeys/view-report/report",{layoutPath:this.layoutPath,...t})}catch(t){e.body??={},e.body.title="Report Failed",e.body.errorDescription="We were unable to show this report for the following reason:",e.body.error=new l.default(t).formatError(),s(t)}};saveDefaultFilterValues=async(e,r,s)=>{try{c.default.saveDefaults(n.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(`${e.baseUrl}?defaultsSaved=true`)}catch(t){e.body={title:"Failed to save defaults",error:new l.default(t).formatError(),...e.body&&{...e.body}},s(t)}};removeDefaultFilterValues=async(e,r,s)=>{try{c.default.removeDefaults(n.FiltersType.INTERACTIVE,r,e,this.services),r.redirect(e.baseUrl)}catch(t){e.body={title:"Failed to remove defaults",error:new l.default(t).formatError(),...e.body&&{...e.body}},s(t)}};applyFilters=async(e,r,s)=>{await y.default.applyReportInteractiveQuery(e,r,this.services,"filters")};applyColumns=async(e,r,s)=>{await y.default.applyReportInteractiveQuery(e,r,this.services,"columns")}}var E=d;0&&(module.exports={ViewSyncReportController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/view-report/sync/report/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\nimport { Services } from '../../../../../types/Services'\nimport SyncReportUtils from './utils'\nimport { FiltersType } from '../../../../../components/_filters/filtersTypeEnum'\nimport PersonalisationUtils from '../../../../../utils/Personalisation/personalisationUtils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewSyncReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n try {\n const renderData = await SyncReportUtils.getReport({ req, res, services: this.services })\n res.render(`dpr/routes/journeys/view-report/report`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = `Report Failed`\n req.body.errorDescription = 'We were unable to show this report for the following reason:'\n req.body.error = new ErrorHandler(error).formatError()\n next()\n }\n }\n\n saveDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.saveDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(`${req.baseUrl}?defaultsSaved=true`)\n } catch (error) {\n req.body = {\n title: 'Failed to save defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next()\n }\n }\n\n removeDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.removeDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(req.baseUrl)\n } catch (error) {\n req.body = {\n title: 'Failed to remove defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next()\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'filters')\n }\n\n applyColumns: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'columns')\n }\n}\n\nexport { ViewSyncReportController }\nexport default ViewSyncReportController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAEzBC,EAA4B,sBAC5BC,EAA4B,8DAC5BC,EAAiC,wEACjCF,EAA4B,0BAE5B,MAAMJ,CAAyB,CAC7B,WAEA,SAEA,YAAYO,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAa,MAAM,EAAAC,QAAgB,UAAU,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,QAAS,CAAC,EACxFA,EAAI,OAAO,yCAA0C,CACnD,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,gBACjBA,EAAI,KAAK,iBAAmB,+DAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAK,CACP,CACF,EAEA,wBAA0C,MAAOF,EAAKC,EAAKC,IAAS,CAClE,GAAI,CACF,EAAAK,QAAqB,aAAa,cAAY,YAAaN,EAAKD,EAAK,KAAK,QAAQ,EAClFC,EAAI,SAAS,GAAGD,EAAI,OAAO,qBAAqB,CAClD,OAASK,EAAO,CACdL,EAAI,KAAO,CACT,MAAO,0BACP,MAAO,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIL,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAE,EAAK,CACP,CACF,EAEA,0BAA4C,MAAOF,EAAKC,EAAKC,IAAS,CACpE,GAAI,CACF,EAAAK,QAAqB,eAAe,cAAY,YAAaN,EAAKD,EAAK,KAAK,QAAQ,EACpFC,EAAI,SAASD,EAAI,OAAO,CAC1B,OAASK,EAAO,CACdL,EAAI,KAAO,CACT,MAAO,4BACP,MAAO,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIL,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAE,EAAK,CACP,CACF,EAEA,aAA+B,MAAOF,EAAKC,EAAKO,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4BT,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,EAEA,aAA+B,MAAOD,EAAKC,EAAKO,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4BT,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,CACF,CAGA,IAAOT,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport ErrorHandler from '../../../../../utils/ErrorHandler'\nimport { Services } from '../../../../../types/Services'\nimport SyncReportUtils from './utils'\nimport { FiltersType } from '../../../../../components/_filters/filtersTypeEnum'\nimport PersonalisationUtils from '../../../../../utils/Personalisation/personalisationUtils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewSyncReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n try {\n const renderData = await SyncReportUtils.getReport({ req, res, services: this.services })\n res.render(`dpr/routes/journeys/view-report/report`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n req.body ??= {}\n req.body.title = `Report Failed`\n req.body.errorDescription = 'We were unable to show this report for the following reason:'\n req.body.error = new ErrorHandler(error).formatError()\n next(error)\n }\n }\n\n saveDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.saveDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(`${req.baseUrl}?defaultsSaved=true`)\n } catch (error) {\n req.body = {\n title: 'Failed to save defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n\n removeDefaultFilterValues: RequestHandler = async (req, res, next) => {\n try {\n PersonalisationUtils.removeDefaults(FiltersType.INTERACTIVE, res, req, this.services)\n res.redirect(req.baseUrl)\n } catch (error) {\n req.body = {\n title: 'Failed to remove defaults',\n error: new ErrorHandler(error).formatError(),\n ...(req.body && { ...req.body }),\n }\n next(error)\n }\n }\n\n applyFilters: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'filters')\n }\n\n applyColumns: RequestHandler = async (req, res, _next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'columns')\n }\n}\n\nexport { ViewSyncReportController }\nexport default ViewSyncReportController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAyB,gDAEzBC,EAA4B,sBAC5BC,EAA4B,8DAC5BC,EAAiC,wEACjCF,EAA4B,0BAE5B,MAAMJ,CAAyB,CAC7B,WAEA,SAEA,YAAYO,EAAoBC,EAAoB,CAClD,KAAK,WAAaD,EAClB,KAAK,SAAWC,CAClB,CAEA,IAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,GAAI,CACF,MAAMC,EAAa,MAAM,EAAAC,QAAgB,UAAU,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,QAAS,CAAC,EACxFA,EAAI,OAAO,yCAA0C,CACnD,WAAY,KAAK,WACjB,GAAGE,CACL,CAAC,CACH,OAASE,EAAO,CACdL,EAAI,OAAS,CAAC,EACdA,EAAI,KAAK,MAAQ,gBACjBA,EAAI,KAAK,iBAAmB,+DAC5BA,EAAI,KAAK,MAAQ,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EACrDH,EAAKG,CAAK,CACZ,CACF,EAEA,wBAA0C,MAAOL,EAAKC,EAAKC,IAAS,CAClE,GAAI,CACF,EAAAK,QAAqB,aAAa,cAAY,YAAaN,EAAKD,EAAK,KAAK,QAAQ,EAClFC,EAAI,SAAS,GAAGD,EAAI,OAAO,qBAAqB,CAClD,OAASK,EAAO,CACdL,EAAI,KAAO,CACT,MAAO,0BACP,MAAO,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIL,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAE,EAAKG,CAAK,CACZ,CACF,EAEA,0BAA4C,MAAOL,EAAKC,EAAKC,IAAS,CACpE,GAAI,CACF,EAAAK,QAAqB,eAAe,cAAY,YAAaN,EAAKD,EAAK,KAAK,QAAQ,EACpFC,EAAI,SAASD,EAAI,OAAO,CAC1B,OAASK,EAAO,CACdL,EAAI,KAAO,CACT,MAAO,4BACP,MAAO,IAAI,EAAAM,QAAaD,CAAK,EAAE,YAAY,EAC3C,GAAIL,EAAI,MAAQ,CAAE,GAAGA,EAAI,IAAK,CAChC,EACAE,EAAKG,CAAK,CACZ,CACF,EAEA,aAA+B,MAAOL,EAAKC,EAAKO,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4BT,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,EAEA,aAA+B,MAAOD,EAAKC,EAAKO,IAAU,CACxD,MAAM,EAAAC,QAAgB,4BAA4BT,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,CACF,CAGA,IAAOT,EAAQD",
6
6
  "names": ["controller_exports", "__export", "ViewSyncReportController", "controller_default", "__toCommonJS", "import_ErrorHandler", "import_utils", "import_filtersTypeEnum", "import_personalisationUtils", "layoutPath", "services", "req", "res", "next", "renderData", "SyncReportUtils", "error", "ErrorHandler", "PersonalisationUtils", "_next", "ViewReportUtils"]
7
7
  }
@@ -28,7 +28,7 @@ class ViewSyncReportController {
28
28
  req.body.title = `Report Failed`
29
29
  req.body.errorDescription = 'We were unable to show this report for the following reason:'
30
30
  req.body.error = new ErrorHandler(error).formatError()
31
- next()
31
+ next(error)
32
32
  }
33
33
  }
34
34
 
@@ -42,7 +42,7 @@ class ViewSyncReportController {
42
42
  error: new ErrorHandler(error).formatError(),
43
43
  ...(req.body && { ...req.body }),
44
44
  }
45
- next()
45
+ next(error)
46
46
  }
47
47
  }
48
48
 
@@ -56,7 +56,7 @@ class ViewSyncReportController {
56
56
  error: new ErrorHandler(error).formatError(),
57
57
  ...(req.body && { ...req.body }),
58
58
  }
59
- next()
59
+ next(error)
60
60
  }
61
61
  }
62
62
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dpr/utils/ErrorHandler.ts"],
4
- "sourcesContent": ["import { components } from '../types/api'\nimport logger from './logger'\n\ninterface DprErrorMessage {\n userMessage?: string\n developerMessage?: string\n stack?: string\n moreInfo?: string\n status?: string | number\n}\n\ninterface DprErrorData {\n data: components['schemas']['ErrorResponse']\n}\n\ninterface ZodValidationError {\n userMessage: string\n stack: string\n}\n\nclass ErrorHandler {\n error: Error | components['schemas']['ErrorResponse'] | string | undefined | unknown | DprErrorData\n\n developerMessage?: string | undefined\n\n userMessage?: string | undefined\n\n moreInfo?: string | undefined\n\n stack?: string | undefined\n\n status?: number | string | undefined\n\n constructor(error: Error | components['schemas']['ErrorResponse'] | string | undefined | unknown) {\n this.error = error\n logger.error(`Error: ${JSON.stringify(error)}`)\n }\n\n formatError = (): DprErrorMessage => {\n return this.handleError()\n }\n\n private handleError = (): DprErrorMessage => {\n // status: FAILED\n if (typeof this.error === 'string') {\n this.developerMessage = this.error\n }\n\n // Error response\n else if ((<DprErrorData>this.error).data) {\n const error = (<DprErrorData>this.error).data\n this.developerMessage = error.developerMessage\n this.userMessage = error.userMessage\n this.moreInfo = error.moreInfo\n this.status = error.status\n }\n\n // client side error\n else if (Object.prototype.hasOwnProperty.call(this.error, 'message')) {\n const error = <Error>this.error\n this.userMessage = error.message\n this.stack = error.stack\n this.status = 500\n }\n\n // Server response error\n else if (Object.prototype.hasOwnProperty.call(this.error, 'developerMessage')) {\n const error = <components['schemas']['ErrorResponse']>this.error\n this.developerMessage = error.developerMessage\n this.userMessage = error.userMessage\n this.moreInfo = error.moreInfo\n this.status = error.status\n }\n\n // Zod error\n else if (Object.prototype.hasOwnProperty.call(this.error, 'userMessage')) {\n const error = <ZodValidationError>this.error\n if (error.stack && error.stack.includes('ZodError')) {\n const errorArr: { message: string }[] = JSON.parse(error.userMessage)\n this.userMessage = errorArr.map((m) => m.message).join(', ')\n this.status = 500\n this.stack = error.stack\n }\n }\n\n const formattedError = {\n ...(this.developerMessage && { developerMessage: this.developerMessage }),\n ...(this.userMessage && { userMessage: this.userMessage }),\n ...(this.moreInfo && { moreInfo: this.moreInfo }),\n ...(this.stack && { stack: this.stack }),\n ...(this.status && { status: this.status }),\n }\n\n logger.error(JSON.stringify(formattedError, null, 2))\n\n return formattedError\n }\n}\n\nexport { ErrorHandler }\nexport default ErrorHandler\n"],
4
+ "sourcesContent": ["import { components } from '../types/api'\nimport logger from './logger'\n\nexport interface DprErrorMessage {\n userMessage?: string\n developerMessage?: string\n stack?: string\n moreInfo?: string\n status?: string | number\n}\n\ninterface DprErrorData {\n data: components['schemas']['ErrorResponse']\n}\n\ninterface ZodValidationError {\n userMessage: string\n stack: string\n}\n\nclass ErrorHandler {\n error: Error | components['schemas']['ErrorResponse'] | string | undefined | unknown | DprErrorData\n\n developerMessage?: string | undefined\n\n userMessage?: string | undefined\n\n moreInfo?: string | undefined\n\n stack?: string | undefined\n\n status?: number | string | undefined\n\n constructor(error: Error | components['schemas']['ErrorResponse'] | string | undefined | unknown) {\n this.error = error\n logger.error(`Error: ${JSON.stringify(error)}`)\n }\n\n formatError = (): DprErrorMessage => {\n return this.handleError()\n }\n\n private handleError = (): DprErrorMessage => {\n // status: FAILED\n if (typeof this.error === 'string') {\n this.developerMessage = this.error\n }\n\n // Error response\n else if ((<DprErrorData>this.error).data) {\n const error = (<DprErrorData>this.error).data\n this.developerMessage = error.developerMessage\n this.userMessage = error.userMessage\n this.moreInfo = error.moreInfo\n this.status = error.status\n }\n\n // client side error\n else if (Object.prototype.hasOwnProperty.call(this.error, 'message')) {\n const error = <Error>this.error\n this.userMessage = error.message\n this.stack = error.stack\n this.status = 500\n }\n\n // Server response error\n else if (Object.prototype.hasOwnProperty.call(this.error, 'developerMessage')) {\n const error = <components['schemas']['ErrorResponse']>this.error\n this.developerMessage = error.developerMessage\n this.userMessage = error.userMessage\n this.moreInfo = error.moreInfo\n this.status = error.status\n }\n\n // Zod error\n else if (Object.prototype.hasOwnProperty.call(this.error, 'userMessage')) {\n const error = <ZodValidationError>this.error\n if (error.stack && error.stack.includes('ZodError')) {\n const errorArr: { message: string }[] = JSON.parse(error.userMessage)\n this.userMessage = errorArr.map((m) => m.message).join(', ')\n this.status = 500\n this.stack = error.stack\n }\n }\n\n const formattedError = {\n ...(this.developerMessage && { developerMessage: this.developerMessage }),\n ...(this.userMessage && { userMessage: this.userMessage }),\n ...(this.moreInfo && { moreInfo: this.moreInfo }),\n ...(this.stack && { stack: this.stack }),\n ...(this.status && { status: this.status }),\n }\n\n logger.error(JSON.stringify(formattedError, null, 2))\n\n return formattedError\n }\n}\n\nexport { ErrorHandler }\nexport default ErrorHandler\n"],
5
5
  "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAmB,uBAmBnB,MAAMH,CAAa,CACjB,MAEA,iBAEA,YAEA,SAEA,MAEA,OAEA,YAAYI,EAAsF,CAChG,KAAK,MAAQA,EACb,EAAAC,QAAO,MAAM,UAAU,KAAK,UAAUD,CAAK,CAAC,EAAE,CAChD,CAEA,YAAc,IACL,KAAK,YAAY,EAG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,CAAC,EAE7CA,CACT,CACF,CAGA,IAAOP,EAAQD",
6
6
  "names": ["ErrorHandler_exports", "__export", "ErrorHandler", "ErrorHandler_default", "__toCommonJS", "import_logger", "error", "logger", "errorArr", "m", "formattedError"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import { components } from '../types/api'
2
2
  import logger from './logger'
3
3
 
4
- interface DprErrorMessage {
4
+ export interface DprErrorMessage {
5
5
  userMessage?: string
6
6
  developerMessage?: string
7
7
  stack?: 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.26.7",
4
+ "version": "4.27.0",
5
5
  "main": "dpr/all.mjs",
6
6
  "sass": "dpr/all.scss",
7
7
  "engines": {
@@ -46,7 +46,7 @@
46
46
  "test:jest": "jest --verbose --silent=false",
47
47
  "test:docs": "npm run docs",
48
48
  "test:packaging": "npm run package",
49
- "wiremock": "concurrently -p \"[{name}]\" -n \"Wiremock,SetupMocks\" -c \"yellow.bold,cyan.bold\" \"wiremock --verbose --port=9091\" \"wait-on http-get://localhost:9091/__admin/health && ts-node -T ./_networkMocks/setupMocks.ts\"",
49
+ "wiremock": "concurrently -p \"[{name}]\" -n \"Wiremock,SetupMocks\" -c \"yellow.bold,cyan.bold\" \"wiremock --verbose --port=9091\" \"wait-on http-get://localhost:9091/__admin/health && tsx ./_networkMocks/setupMocks.ts\"",
50
50
  "start-test-app": "npm run package && node $NODE_OPTIONS test-app/start-server.js",
51
51
  "start:dev": "USE_MOCK_CLIENTS=true concurrently -k -p \"[{name}]\" -n \"ESBuild,Node\" -c \"yellow.bold,cyan.bold\" \"node esbuild/esbuild.config.js --build --watch\" \"node esbuild/esbuild.config.js --dev-server\"",
52
52
  "start:dev:noMockClients": "concurrently -k -p \"[{name}]\" -n \"ESBuild,Node\" -c \"yellow.bold,cyan.bold\" \"node esbuild/esbuild.config.js --build --watch\" \"node esbuild/esbuild.config.js --dev-server\"",
@@ -140,6 +140,7 @@
140
140
  "dependencies": {
141
141
  "@flipt-io/flipt": "^1.5.0",
142
142
  "@ministryofjustice/frontend": "^6.0.0",
143
+ "@sentry/node": "10.34.0",
143
144
  "@tsconfig/node24": "24.0.3",
144
145
  "agentkeepalive": "^4.5.0",
145
146
  "bunyan": "^1.8.15",
@@ -179,7 +180,7 @@
179
180
  "@types/csurf": "^1.11.5",
180
181
  "@types/express": "4.17.21",
181
182
  "@types/express-session": "^1.18.2",
182
- "@types/jest": "^29.5.4",
183
+ "@types/jest": "^30.0.0",
183
184
  "@types/node": "24.10.4",
184
185
  "@types/nunjucks": "^3.2.3",
185
186
  "@types/nunjucks-date": "^0.0.10",
@@ -194,7 +195,7 @@
194
195
  "cssnano": "^6.0.1",
195
196
  "cypress": "^14.5.4",
196
197
  "cypress-axe": "^1.6.0",
197
- "cypress-multi-reporters": "^1.6.3",
198
+ "cypress-multi-reporters": "^2.0.5",
198
199
  "cypress-xpath": "^2.0.1",
199
200
  "del": "^7.1.0",
200
201
  "esbuild": "^0.27.2",
@@ -214,8 +215,8 @@
214
215
  "gray-matter": "^4.0.3",
215
216
  "highlight.js": "^11.9.0",
216
217
  "husky": "^8.0.3",
217
- "jest": "^29.6.4",
218
- "jest-html-reporter": "^3.10.1",
218
+ "jest": "^30.2.0",
219
+ "jest-html-reporter": "^4.1.0",
219
220
  "jest-junit": "^16.0.0",
220
221
  "js-beautify": "^1.15.4",
221
222
  "lint-staged": "^16.0.0",
@@ -233,9 +234,9 @@
233
234
  "sass": "^1.66.1",
234
235
  "serve": "^14.2.4",
235
236
  "superagent": "^10.3.0",
236
- "ts-jest": "^29.1.1",
237
- "ts-node": "^10.9.2",
237
+ "ts-jest": "^29.4.6",
238
238
  "tsconfig-paths": "^4.2.0",
239
+ "tsx": "4.21.0",
239
240
  "typescript": "^5.9.3",
240
241
  "wait-on": "^9.0.1",
241
242
  "wiremock": "^3.13.1"