@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.14.1 → 4.15.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.
- package/dpr/all.mjs +2 -0
- package/dpr/all.scss +4 -0
- package/dpr/components/_catalogue/catalogue-list/utils.test.ts +1 -1
- package/dpr/components/_charts/chart/clientClass.mjs +4 -3
- package/dpr/components/_charts/chart/heatmap/clientClass.mjs +175 -0
- package/dpr/components/_charts/chart/heatmap/utils.js +2 -0
- package/dpr/components/_charts/chart/heatmap/utils.js.map +7 -0
- package/dpr/components/_charts/chart/heatmap/utils.ts +182 -0
- package/dpr/components/_charts/chart/styles.scss +4 -0
- package/dpr/components/_charts/utils.js +1 -1
- package/dpr/components/_charts/utils.js.map +3 -3
- package/dpr/components/_charts/utils.test.ts +4 -1
- package/dpr/components/_charts/utils.ts +73 -27
- package/dpr/components/_dashboards/dashboard/types.js +1 -1
- package/dpr/components/_dashboards/dashboard/types.js.map +2 -2
- package/dpr/components/_dashboards/dashboard/types.ts +13 -1
- package/dpr/components/_dashboards/dashboard-list/utils.js +1 -1
- package/dpr/components/_dashboards/dashboard-list/utils.js.map +3 -3
- package/dpr/components/_dashboards/dashboard-list/utils.test.ts +1 -0
- package/dpr/components/_dashboards/dashboard-list/utils.ts +4 -1
- package/dpr/components/_filters/types.d.js.map +1 -1
- package/dpr/components/_filters/types.d.ts +12 -8
- package/dpr/components/_filters/utils.js +1 -1
- package/dpr/components/_filters/utils.js.map +3 -3
- package/dpr/components/_filters/utils.ts +24 -2
- package/dpr/data/dashboardClient.js +1 -1
- package/dpr/data/dashboardClient.js.map +2 -2
- package/dpr/data/dashboardClient.ts +1 -1
- package/dpr/routes/journeys/request-report/filters/controller.js +1 -1
- package/dpr/routes/journeys/request-report/filters/controller.js.map +3 -3
- package/dpr/routes/journeys/request-report/filters/controller.ts +6 -2
- package/dpr/routes/journeys/request-report/filters/utils.js +1 -1
- package/dpr/routes/journeys/request-report/filters/utils.js.map +2 -2
- package/dpr/routes/journeys/request-report/filters/utils.ts +9 -3
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +3 -3
- package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +12 -3
- package/dpr/services/dashboardService.js +1 -1
- package/dpr/services/dashboardService.js.map +2 -2
- package/dpr/services/dashboardService.ts +1 -1
- package/dpr/types/Charts.js +1 -1
- package/dpr/types/Charts.js.map +1 -1
- package/dpr/types/Charts.ts +10 -3
- package/dpr/types/ExecutionData.d.js +1 -1
- package/dpr/types/ExecutionData.d.js.map +1 -1
- package/dpr/types/ExecutionData.d.ts +1 -0
- package/dpr/types/ReportQuery.js +1 -1
- package/dpr/types/ReportQuery.js.map +2 -2
- package/dpr/types/ReportQuery.ts +1 -0
- package/dpr/utils/DateMapper/DateMapper.js +1 -1
- package/dpr/utils/DateMapper/DateMapper.js.map +2 -2
- package/dpr/utils/DateMapper/DateMapper.ts +4 -0
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.js +1 -1
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.js.map +3 -3
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.ts +1 -41
- package/dpr/utils/UserStoreItemBuilder.js +1 -1
- package/dpr/utils/UserStoreItemBuilder.js.map +3 -3
- package/dpr/utils/UserStoreItemBuilder.ts +5 -3
- package/dpr/utils/requestStatusHelper.js +1 -1
- package/dpr/utils/requestStatusHelper.js.map +2 -2
- package/dpr/utils/requestStatusHelper.ts +1 -1
- package/package.json +5 -2
package/dpr/types/ReportQuery.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var b=Object.create;var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var F=(n,i)=>{for(var s in i)a(n,s,{get:i[s],enumerable:!0})},h=(n,i,s,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of R(i))!C.call(n,r)&&r!==s&&a(n,r,{get:()=>i[r],enumerable:!(t=x(i,r))||t.enumerable});return n};var T=(n,i,s)=>(s=n!=null?b(z(n)):{},h(i||!n||!n.__esModule?a(s,"default",{value:n,enumerable:!0}):s,n)),A=n=>h(a({},"__esModule",{value:!0}),n);var j={};F(j,{DEFAULT_FILTERS_PREFIX:()=>S,ReportQuery:()=>g,default:()=>O});module.exports=A(j);var m=require("../utils/urlHelper"),p=T(require("../components/_reports/report-columns-form/utils")),u=require("./UserReports");const S="filters.";class g{constructor({fields:i,template:s,queryParams:t,definitionsPath:r,filtersPrefix:D=S,reportType:P}){if(this.selectedPage=t.selectedPage?Number(t.selectedPage):1,this.pageSize=this.getPageSize(t,s,P),this.sortColumn=t.sortColumn?t.sortColumn.toString():this.getDefaultSortColumn(i),this.sortedAsc=t.sortedAsc!=="false",this.dataProductDefinitionsPath=r??(t.dataProductDefinitionsPath?t.dataProductDefinitionsPath.toString():null),this.filtersPrefix=D,t.columns){const e=typeof t.columns=="string"?t.columns.split(","):t.columns;this.columns=p.default.ensureMandatoryColumns(i,e)}else this.columns=i.filter(e=>e.visible).map(e=>e.name);let l,c;const o=i.find(e=>e.type==="date"&&e.filter&&e.filter.type==="daterange"||e.type==="date"&&e.filter&&e.filter.type==="date");o&&({min:l,max:c}=o.filter),this.filters={},Object.keys(t).filter(e=>e.startsWith(this.filtersPrefix)).filter(e=>t[e]).forEach(e=>{const d=e.replace(this.filtersPrefix,"");let f=t[e].toString();d.includes(".start")&&l&&new Date(f)<new Date(l)&&(f=l),d.includes(".end")&&c&&new Date(f)>new Date(c)&&(f=c),f!=="no-filter"&&(this.filters[d]=f)}),o&&o.filter.type==="daterange"&&(l&&Object.keys(t).some(e=>e.includes(this.filtersPrefix))&&Object.keys(t).every(e=>!e.includes(".start"))&&(this.filters[`${o.name}.start`]=l),c&&Object.keys(t).some(e=>e.includes(this.filtersPrefix))&&Object.keys(t).every(e=>!e.includes(".end"))&&(this.filters[`${o.name}.end`]=c)),o&&o.filter.type==="date"&&l&&Object.keys(t).some(e=>e.includes(this.filtersPrefix))&&Object.keys(t).every(e=>!e.includes(o.name))&&(this.filters[`${o.name}.start`]=l)}getDefaultSortColumn(i){const s=i.find(t=>t.defaultsort);return s?s.name:i.find(t=>t.sortable)?.name}getPageSize(i,s,t){let r;return(!t||t===u.ReportType.REPORT)&&(r=i.pageSize&&s?Number(i.pageSize):this.getDefaultPageSize(s)),r}toRecordWithFilterPrefix(i=!1){const s={selectedPage:this.selectedPage.toString(),...this.pageSize&&{pageSize:this.pageSize.toString()},sortColumn:this.sortColumn,sortedAsc:this.sortedAsc.toString(),columns:this.columns};return this.dataProductDefinitionsPath&&(s.dataProductDefinitionsPath=this.dataProductDefinitionsPath),Object.keys(this.filters).forEach(t=>{const r=this.filters[t];(!i||r!==m.clearFilterValue)&&(s[`${this.filtersPrefix}${t}`]=r)}),s}getDefaultPageSize(i){switch(i){case"list-section":case"summary-section":case"row-section-child":case"parent-child":return 5e5;default:return 20}}}var O=g;0&&(module.exports={DEFAULT_FILTERS_PREFIX,ReportQuery});
|
|
1
|
+
var b=Object.create;var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var F=(n,i)=>{for(var s in i)a(n,s,{get:i[s],enumerable:!0})},h=(n,i,s,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of R(i))!C.call(n,r)&&r!==s&&a(n,r,{get:()=>i[r],enumerable:!(t=x(i,r))||t.enumerable});return n};var T=(n,i,s)=>(s=n!=null?b(z(n)):{},h(i||!n||!n.__esModule?a(s,"default",{value:n,enumerable:!0}):s,n)),A=n=>h(a({},"__esModule",{value:!0}),n);var j={};F(j,{DEFAULT_FILTERS_PREFIX:()=>S,ReportQuery:()=>g,default:()=>O});module.exports=A(j);var m=require("../utils/urlHelper"),p=T(require("../components/_reports/report-columns-form/utils")),u=require("./UserReports");const S="filters.";class g{constructor({fields:i,template:s,queryParams:t,definitionsPath:r,filtersPrefix:D=S,reportType:P}){if(this.selectedPage=t.selectedPage?Number(t.selectedPage):1,this.pageSize=this.getPageSize(t,s,P),this.sortColumn=t.sortColumn?t.sortColumn.toString():this.getDefaultSortColumn(i),this.sortedAsc=t.sortedAsc!=="false",this.dataProductDefinitionsPath=r??(t.dataProductDefinitionsPath?t.dataProductDefinitionsPath.toString():null),this.filtersPrefix=D,t.columns){const e=typeof t.columns=="string"?t.columns.split(","):t.columns;this.columns=p.default.ensureMandatoryColumns(i,e)}else this.columns=i.filter(e=>e.visible).map(e=>e.name);let l,c;const o=i.find(e=>e.type==="date"&&e.filter&&e.filter.type==="daterange"||e.type==="date"&&e.filter&&e.filter.type==="date");o&&({min:l,max:c}=o.filter),this.filters={},Object.keys(t).filter(e=>e.startsWith(this.filtersPrefix)).filter(e=>t[e]).forEach(e=>{const d=e.replace(this.filtersPrefix,"");let f=t[e].toString();d.includes(".start")&&l&&new Date(f)<new Date(l)&&(f=l),d.includes(".end")&&c&&new Date(f)>new Date(c)&&(f=c),f!=="no-filter"&&(this.filters[d]=f)}),o&&o.filter.type==="daterange"&&(l&&Object.keys(t).some(e=>e.includes(this.filtersPrefix))&&Object.keys(t).every(e=>!e.includes(".start"))&&(this.filters[`${o.name}.start`]=l),c&&Object.keys(t).some(e=>e.includes(this.filtersPrefix))&&Object.keys(t).every(e=>!e.includes(".end"))&&(this.filters[`${o.name}.end`]=c)),o&&o.filter.type==="date"&&l&&Object.keys(t).some(e=>e.includes(this.filtersPrefix))&&Object.keys(t).every(e=>!e.includes(o.name))&&(this.filters[`${o.name}.start`]=l)}getDefaultSortColumn(i){const s=i.find(t=>t.defaultsort);return s?s.name:i.find(t=>t.sortable)?.name}getPageSize(i,s,t){let r;return(!t||t===u.ReportType.REPORT)&&(r=i.pageSize&&s?Number(i.pageSize):this.getDefaultPageSize(s)),r}toRecordWithFilterPrefix(i=!1){const s={selectedPage:this.selectedPage.toString(),...this.pageSize&&{pageSize:this.pageSize.toString()},sortColumn:this.sortColumn,sortedAsc:this.sortedAsc.toString(),columns:this.columns};return this.dataProductDefinitionsPath&&(s.dataProductDefinitionsPath=this.dataProductDefinitionsPath),Object.keys(this.filters).forEach(t=>{const r=this.filters[t];(!i||r!==m.clearFilterValue)&&(s[`${this.filtersPrefix}${t}`]=r)}),s}getDefaultPageSize(i){switch(i){case"list-section":case"summary-section":case"row-section-child":case"parent-child":case"parent-child-section":return 5e5;default:return 20}}}var O=g;0&&(module.exports={DEFAULT_FILTERS_PREFIX,ReportQuery});
|
|
2
2
|
//# sourceMappingURL=ReportQuery.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/dpr/types/ReportQuery.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ParsedQs } from 'qs'\nimport { FilteredListRequest } from './index'\nimport Dict = NodeJS.Dict\nimport { components } from './api'\nimport { clearFilterValue } from '../utils/urlHelper'\nimport ColumnUtils from '../components/_reports/report-columns-form/utils'\nimport { Template } from './Templates'\nimport { ReportType } from './UserReports'\n\nexport const DEFAULT_FILTERS_PREFIX = 'filters.'\n\nclass ReportQuery implements FilteredListRequest {\n selectedPage: number\n\n pageSize: number | undefined\n\n sortColumn?: string\n\n columns: Array<string>\n\n sortedAsc: boolean\n\n filters: Dict<string>\n\n filtersPrefix: string\n\n dataProductDefinitionsPath?: string\n\n constructor({\n fields,\n template,\n queryParams,\n definitionsPath,\n filtersPrefix = DEFAULT_FILTERS_PREFIX,\n reportType,\n }: {\n fields: components['schemas']['FieldDefinition'][]\n template?: Template\n queryParams: ParsedQs\n definitionsPath?: string\n filtersPrefix?: string\n reportType?: ReportType\n }) {\n this.selectedPage = queryParams.selectedPage ? Number(queryParams.selectedPage) : 1\n this.pageSize = this.getPageSize(queryParams, template, reportType)\n this.sortColumn = queryParams.sortColumn ? queryParams.sortColumn.toString() : this.getDefaultSortColumn(fields)\n this.sortedAsc = queryParams.sortedAsc !== 'false'\n this.dataProductDefinitionsPath =\n definitionsPath ??\n (queryParams.dataProductDefinitionsPath ? queryParams.dataProductDefinitionsPath.toString() : null)\n this.filtersPrefix = filtersPrefix\n\n if (queryParams.columns) {\n const columns =\n typeof queryParams.columns === 'string' ? queryParams.columns.split(',') : (queryParams.columns as string[])\n this.columns = ColumnUtils.ensureMandatoryColumns(fields, columns)\n } else {\n this.columns = fields.filter((f) => f.visible).map((f) => f.name)\n }\n\n let min: string\n let max: string\n const dateField: components['schemas']['FieldDefinition'] = fields.find((f) => {\n return (\n (f.type === 'date' && f.filter && f.filter.type === 'daterange') ||\n (f.type === 'date' && f.filter && f.filter.type === 'date')\n )\n })\n if (dateField) ({ min, max } = dateField.filter)\n\n this.filters = {}\n\n Object.keys(queryParams)\n .filter((key) => key.startsWith(this.filtersPrefix))\n .filter((key) => queryParams[key])\n .forEach((key) => {\n const filter = key.replace(this.filtersPrefix, '')\n let value = queryParams[key].toString()\n if (filter.includes('.start') && min) {\n if (new Date(value) < new Date(min)) value = min\n }\n if (filter.includes('.end') && max) {\n if (new Date(value) > new Date(max)) value = max\n }\n if (value !== 'no-filter') {\n this.filters[filter] = value\n }\n })\n\n if (dateField && dateField.filter.type === 'daterange') {\n if (\n min &&\n Object.keys(queryParams).some((key) => key.includes(this.filtersPrefix)) &&\n Object.keys(queryParams).every((key) => !key.includes('.start'))\n ) {\n this.filters[`${dateField.name}.start`] = min\n }\n\n if (\n max &&\n Object.keys(queryParams).some((key) => key.includes(this.filtersPrefix)) &&\n Object.keys(queryParams).every((key) => !key.includes('.end'))\n ) {\n this.filters[`${dateField.name}.end`] = max\n }\n }\n\n if (dateField && dateField.filter.type === 'date') {\n if (\n min &&\n Object.keys(queryParams).some((key) => key.includes(this.filtersPrefix)) &&\n Object.keys(queryParams).every((key) => !key.includes(dateField.name))\n ) {\n this.filters[`${dateField.name}.start`] = min\n }\n }\n }\n\n private getDefaultSortColumn(fields: components['schemas']['FieldDefinition'][]) {\n const defaultSortColumn = fields.find((f) => f.defaultsort)\n return defaultSortColumn ? defaultSortColumn.name : fields.find((f) => f.sortable)?.name\n }\n\n getPageSize(queryParams: ParsedQs, template: Template, reportType?: ReportType): number | undefined {\n let pageSize\n if (!reportType || reportType === ReportType.REPORT) {\n pageSize = queryParams.pageSize && template ? Number(queryParams.pageSize) : this.getDefaultPageSize(template)\n }\n return pageSize\n }\n\n toRecordWithFilterPrefix(removeClearedFilters = false): Record<string, string | Array<string>> {\n const record: Record<string, string | Array<string>> = {\n selectedPage: this.selectedPage.toString(),\n ...(this.pageSize && { pageSize: this.pageSize.toString() }),\n sortColumn: this.sortColumn,\n sortedAsc: this.sortedAsc.toString(),\n columns: this.columns,\n }\n\n if (this.dataProductDefinitionsPath) {\n record.dataProductDefinitionsPath = this.dataProductDefinitionsPath\n }\n\n Object.keys(this.filters).forEach((filterName) => {\n const value = this.filters[filterName]\n if (!removeClearedFilters || value !== clearFilterValue) {\n record[`${this.filtersPrefix}${filterName}`] = value\n }\n })\n\n return record\n }\n\n private getDefaultPageSize(template: Template) {\n const maxResultsSize = 500000\n const standardPage = 20\n\n switch (template) {\n case 'list-section':\n case 'summary-section':\n case 'row-section-child':\n case 'parent-child':\n return maxResultsSize\n\n default:\n return standardPage\n }\n }\n}\n\nexport { ReportQuery }\nexport default ReportQuery\n"],
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,gBAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAL,GAIA,IAAAM,EAAiC,8BACjCC,EAAwB,+DAExBC,EAA2B,yBAEpB,MAAMN,EAAyB,WAEtC,MAAMC,CAA2C,CAiB/C,YAAY,CACV,OAAAM,EACA,SAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,cAAAC,EAAgBX,EAChB,WAAAY,CACF,EAOG,CAUD,GATA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,GAAI,KAAK,UAAY,CAAE,SAAU,KAAK,SAAS,SAAS,CAAE,EAC1D,WAAY,KAAK,WACjB,UAAW,KAAK,UAAU,SAAS,EACnC,QAAS,KAAK,OAChB,EAEA,OAAI,KAAK,6BACPA,EAAO,2BAA6B,KAAK,4BAG3C,OAAO,KAAK,KAAK,OAAO,EAAE,QAASC,GAAe,CAChD,MAAML,EAAQ,KAAK,QAAQK,CAAU,GACjC,CAACF,GAAwBH,IAAU,sBACrCI,EAAO,GAAG,KAAK,aAAa,GAAGC,CAAU,EAAE,EAAIL,EAEnD,CAAC,EAEMI,CACT,CAEQ,mBAAmBjB,EAAoB,CAI7C,OAAQA,EAAU,CAChB,IAAK,eACL,IAAK,kBACL,IAAK,oBACL,IAAK,
|
|
4
|
+
"sourcesContent": ["import type { ParsedQs } from 'qs'\nimport { FilteredListRequest } from './index'\nimport Dict = NodeJS.Dict\nimport { components } from './api'\nimport { clearFilterValue } from '../utils/urlHelper'\nimport ColumnUtils from '../components/_reports/report-columns-form/utils'\nimport { Template } from './Templates'\nimport { ReportType } from './UserReports'\n\nexport const DEFAULT_FILTERS_PREFIX = 'filters.'\n\nclass ReportQuery implements FilteredListRequest {\n selectedPage: number\n\n pageSize: number | undefined\n\n sortColumn?: string\n\n columns: Array<string>\n\n sortedAsc: boolean\n\n filters: Dict<string>\n\n filtersPrefix: string\n\n dataProductDefinitionsPath?: string\n\n constructor({\n fields,\n template,\n queryParams,\n definitionsPath,\n filtersPrefix = DEFAULT_FILTERS_PREFIX,\n reportType,\n }: {\n fields: components['schemas']['FieldDefinition'][]\n template?: Template\n queryParams: ParsedQs\n definitionsPath?: string\n filtersPrefix?: string\n reportType?: ReportType\n }) {\n this.selectedPage = queryParams.selectedPage ? Number(queryParams.selectedPage) : 1\n this.pageSize = this.getPageSize(queryParams, template, reportType)\n this.sortColumn = queryParams.sortColumn ? queryParams.sortColumn.toString() : this.getDefaultSortColumn(fields)\n this.sortedAsc = queryParams.sortedAsc !== 'false'\n this.dataProductDefinitionsPath =\n definitionsPath ??\n (queryParams.dataProductDefinitionsPath ? queryParams.dataProductDefinitionsPath.toString() : null)\n this.filtersPrefix = filtersPrefix\n\n if (queryParams.columns) {\n const columns =\n typeof queryParams.columns === 'string' ? queryParams.columns.split(',') : (queryParams.columns as string[])\n this.columns = ColumnUtils.ensureMandatoryColumns(fields, columns)\n } else {\n this.columns = fields.filter((f) => f.visible).map((f) => f.name)\n }\n\n let min: string\n let max: string\n const dateField: components['schemas']['FieldDefinition'] = fields.find((f) => {\n return (\n (f.type === 'date' && f.filter && f.filter.type === 'daterange') ||\n (f.type === 'date' && f.filter && f.filter.type === 'date')\n )\n })\n if (dateField) ({ min, max } = dateField.filter)\n\n this.filters = {}\n\n Object.keys(queryParams)\n .filter((key) => key.startsWith(this.filtersPrefix))\n .filter((key) => queryParams[key])\n .forEach((key) => {\n const filter = key.replace(this.filtersPrefix, '')\n let value = queryParams[key].toString()\n if (filter.includes('.start') && min) {\n if (new Date(value) < new Date(min)) value = min\n }\n if (filter.includes('.end') && max) {\n if (new Date(value) > new Date(max)) value = max\n }\n if (value !== 'no-filter') {\n this.filters[filter] = value\n }\n })\n\n if (dateField && dateField.filter.type === 'daterange') {\n if (\n min &&\n Object.keys(queryParams).some((key) => key.includes(this.filtersPrefix)) &&\n Object.keys(queryParams).every((key) => !key.includes('.start'))\n ) {\n this.filters[`${dateField.name}.start`] = min\n }\n\n if (\n max &&\n Object.keys(queryParams).some((key) => key.includes(this.filtersPrefix)) &&\n Object.keys(queryParams).every((key) => !key.includes('.end'))\n ) {\n this.filters[`${dateField.name}.end`] = max\n }\n }\n\n if (dateField && dateField.filter.type === 'date') {\n if (\n min &&\n Object.keys(queryParams).some((key) => key.includes(this.filtersPrefix)) &&\n Object.keys(queryParams).every((key) => !key.includes(dateField.name))\n ) {\n this.filters[`${dateField.name}.start`] = min\n }\n }\n }\n\n private getDefaultSortColumn(fields: components['schemas']['FieldDefinition'][]) {\n const defaultSortColumn = fields.find((f) => f.defaultsort)\n return defaultSortColumn ? defaultSortColumn.name : fields.find((f) => f.sortable)?.name\n }\n\n getPageSize(queryParams: ParsedQs, template: Template, reportType?: ReportType): number | undefined {\n let pageSize\n if (!reportType || reportType === ReportType.REPORT) {\n pageSize = queryParams.pageSize && template ? Number(queryParams.pageSize) : this.getDefaultPageSize(template)\n }\n return pageSize\n }\n\n toRecordWithFilterPrefix(removeClearedFilters = false): Record<string, string | Array<string>> {\n const record: Record<string, string | Array<string>> = {\n selectedPage: this.selectedPage.toString(),\n ...(this.pageSize && { pageSize: this.pageSize.toString() }),\n sortColumn: this.sortColumn,\n sortedAsc: this.sortedAsc.toString(),\n columns: this.columns,\n }\n\n if (this.dataProductDefinitionsPath) {\n record.dataProductDefinitionsPath = this.dataProductDefinitionsPath\n }\n\n Object.keys(this.filters).forEach((filterName) => {\n const value = this.filters[filterName]\n if (!removeClearedFilters || value !== clearFilterValue) {\n record[`${this.filtersPrefix}${filterName}`] = value\n }\n })\n\n return record\n }\n\n private getDefaultPageSize(template: Template) {\n const maxResultsSize = 500000\n const standardPage = 20\n\n switch (template) {\n case 'list-section':\n case 'summary-section':\n case 'row-section-child':\n case 'parent-child':\n case 'parent-child-section':\n return maxResultsSize\n\n default:\n return standardPage\n }\n }\n}\n\nexport { ReportQuery }\nexport default ReportQuery\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,gBAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAL,GAIA,IAAAM,EAAiC,8BACjCC,EAAwB,+DAExBC,EAA2B,yBAEpB,MAAMN,EAAyB,WAEtC,MAAMC,CAA2C,CAiB/C,YAAY,CACV,OAAAM,EACA,SAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,cAAAC,EAAgBX,EAChB,WAAAY,CACF,EAOG,CAUD,GATA,KAAK,aAAeH,EAAY,aAAe,OAAOA,EAAY,YAAY,EAAI,EAClF,KAAK,SAAW,KAAK,YAAYA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AAW,KAAK,UAAU,SAAS,EACnC,QAAS,KAAK,OAChB,EAEA,OAAI,KAAK,6BACPA,EAAO,2BAA6B,KAAK,4BAG3C,OAAO,KAAK,KAAK,OAAO,EAAE,QAASC,GAAe,CAChD,MAAML,EAAQ,KAAK,QAAQK,CAAU,GACjC,CAACF,GAAwBH,IAAU,sBACrCI,EAAO,GAAG,KAAK,aAAa,GAAGC,CAAU,EAAE,EAAIL,EAEnD,CAAC,EAEMI,CACT,CAEQ,mBAAmBjB,EAAoB,CAI7C,OAAQA,EAAU,CAChB,IAAK,eACL,IAAK,kBACL,IAAK,oBACL,IAAK,eACL,IAAK,uBACH,MAAO,KAET,QACE,MAAO,GACX,CACF,CACF,CAGA,IAAON,EAAQD",
|
|
6
6
|
"names": ["ReportQuery_exports", "__export", "DEFAULT_FILTERS_PREFIX", "ReportQuery", "ReportQuery_default", "__toCommonJS", "import_urlHelper", "import_utils", "import_UserReports", "fields", "template", "queryParams", "definitionsPath", "filtersPrefix", "reportType", "columns", "ColumnUtils", "f", "min", "max", "dateField", "key", "filter", "value", "defaultSortColumn", "pageSize", "removeClearedFilters", "record", "filterName"]
|
|
7
7
|
}
|
package/dpr/types/ReportQuery.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var p=Object.create;var
|
|
1
|
+
var p=Object.create;var i=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var g=(a,t)=>{for(var e in t)i(a,e,{get:t[e],enumerable:!0})},D=(a,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of h(t))!d.call(a,l)&&l!==e&&i(a,l,{get:()=>t[l],enumerable:!(r=Y(t,l))||r.enumerable});return a};var m=(a,t,e)=>(e=a!=null?p(u(a)):{},D(t||!a||!a.__esModule?i(e,"default",{value:a,enumerable:!0}):e,a)),F=a=>D(i({},"__esModule",{value:!0}),a);var M={};g(M,{DateMapper:()=>s,default:()=>f});module.exports=F(M);var o=m(require("dayjs")),n=m(require("dayjs/plugin/customParseFormat")),c=m(require("../logger"));class s{constructor(){this.isoDateRegEx=/^(\d{4}[/-](0?[1-9]|1[012])[/-](0?[1-9]|[12][0-9]|3[01]))/;this.localDateRegEx=/^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\d{4}$/;this.localDateShortYearRegEx=/^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\d{2}$/;this.localDateTimeRegEx=/^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\d{4} [0-2]\d:[0-5]\d$/;this.localDateTimeShortYearRegEx=/^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\d{2} [0-2]\d:[0-5]\d$/;this.isoFormat="YYYY-MM-DD";this.localDateFormatInput="D/M/YYYY";this.localDateFormatOutput="DD/MM/YYYY";this.localDateShortYearFormatInput="D/M/YY";this.localDateShortYearFormatOutput="DD/MM/YY";this.localDateTimeFormatInput="D/M/YYYY HH:mm";this.localDateTimeFormatOutput="DD/MM/YYYY HH:mm";this.localDateTimeShortYearFormatInput="D/M/YY HH:mm";this.localDateTimeShortYearFormatOutput="DD/MM/YY HH:mm";this.localDateFormatMonthYear="MMM YY";this.localDateFormatYear="YYYY"}getDateType(t){if(t&&t.match){if(t.match(this.isoDateRegEx))return"iso";if(t.match(this.localDateRegEx))return"local-date";if(t.match(this.localDateShortYearRegEx))return"local-date-short-year";if(t.match(this.localDateTimeRegEx))return"local-datetime";if(t.match(this.localDateTimeShortYearRegEx))return"local-datetime-short-year"}return"none"}getDateWrapper(t){switch(o.default.extend(n.default),this.getDateType(t)){case"iso":return(0,o.default)(t);case"local-date":return(0,o.default)(t,this.localDateFormatInput);case"local-date-short-year":return(0,o.default)(t,this.localDateShortYearFormatInput);case"local-datetime":return(0,o.default)(t,this.localDateTimeFormatInput);case"local-datetime-short-year":return(0,o.default)(t,this.localDateTimeShortYearFormatInput);default:return null}}isDate(t){return this.getDateType(t)!=="none"}toDateString(t,e){const r=this.getDateWrapper(t);if(r)switch(e){case"iso":return r.format(this.isoFormat);case"local-date":return r.format(this.localDateFormatOutput);case"local-date-short-year":return r.format(this.localDateShortYearFormatOutput);case"local-datetime":return r.format(this.localDateTimeFormatOutput);case"local-datetime-short-year":return r.format(this.localDateTimeShortYearFormatOutput);default:return c.default.warn(`Invalid date type: ${e}`),null}return t&&c.default.warn(`Could not map non-date value : ${t}`),null}}var f=s;0&&(module.exports={DateMapper});
|
|
2
2
|
//# sourceMappingURL=DateMapper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/dpr/utils/DateMapper/DateMapper.ts"],
|
|
4
|
-
"sourcesContent": ["import dayjs, { Dayjs } from 'dayjs'\nimport customParseFormat from 'dayjs/plugin/customParseFormat'\nimport { DateType } from './types'\nimport logger from '../logger'\n\nclass DateMapper {\n private isoDateRegEx = /^(\\d{4}[/-](0?[1-9]|1[012])[/-](0?[1-9]|[12][0-9]|3[01]))/\n\n private localDateRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{4}$/\n\n private localDateShortYearRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{2}$/\n\n private localDateTimeRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{4} [0-2]\\d:[0-5]\\d$/\n\n private localDateTimeShortYearRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{2} [0-2]\\d:[0-5]\\d$/\n\n private isoFormat = 'YYYY-MM-DD'\n\n private localDateFormatInput = 'D/M/YYYY'\n\n private localDateFormatOutput = 'DD/MM/YYYY'\n\n private localDateShortYearFormatInput = 'D/M/YY'\n\n private localDateShortYearFormatOutput = 'DD/MM/YY'\n\n private localDateTimeFormatInput = 'D/M/YYYY HH:mm'\n\n private localDateTimeFormatOutput = 'DD/MM/YYYY HH:mm'\n\n private localDateTimeShortYearFormatInput = 'D/M/YY HH:mm'\n\n private localDateTimeShortYearFormatOutput = 'DD/MM/YY HH:mm'\n\n getDateType(value: string): DateType {\n if (value && value.match) {\n if (value.match(this.isoDateRegEx)) {\n return 'iso'\n }\n\n if (value.match(this.localDateRegEx)) {\n return 'local-date'\n }\n\n if (value.match(this.localDateShortYearRegEx)) {\n return 'local-date-short-year'\n }\n\n if (value.match(this.localDateTimeRegEx)) {\n return 'local-datetime'\n }\n\n if (value.match(this.localDateTimeShortYearRegEx)) {\n return 'local-datetime-short-year'\n }\n }\n\n return 'none'\n }\n\n getDateWrapper(value: string): Dayjs | null {\n dayjs.extend(customParseFormat)\n\n switch (this.getDateType(value)) {\n case 'iso':\n return dayjs(value)\n case 'local-date':\n return dayjs(value, this.localDateFormatInput)\n case 'local-date-short-year':\n return dayjs(value, this.localDateShortYearFormatInput)\n case 'local-datetime':\n return dayjs(value, this.localDateTimeFormatInput)\n case 'local-datetime-short-year':\n return dayjs(value, this.localDateTimeShortYearFormatInput)\n default:\n return null\n }\n }\n\n isDate(value: string): boolean {\n return this.getDateType(value) !== 'none'\n }\n\n toDateString(value: string, type: DateType): string | null {\n const dateWrapper = this.getDateWrapper(value)\n\n if (dateWrapper) {\n switch (type) {\n case 'iso':\n return dateWrapper.format(this.isoFormat)\n case 'local-date':\n return dateWrapper.format(this.localDateFormatOutput)\n case 'local-date-short-year':\n return dateWrapper.format(this.localDateShortYearFormatOutput)\n case 'local-datetime':\n return dateWrapper.format(this.localDateTimeFormatOutput)\n case 'local-datetime-short-year':\n return dateWrapper.format(this.localDateTimeShortYearFormatOutput)\n default:\n logger.warn(`Invalid date type: ${type}`)\n return null\n }\n }\n\n if (value) {\n logger.warn(`Could not map non-date value : ${value}`)\n }\n return null\n }\n}\n\nexport { DateMapper }\nexport default DateMapper\n"],
|
|
5
|
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ACX,CACF,CAEA,OAAOA,EAAwB,CAC7B,OAAO,KAAK,YAAYA,CAAK,IAAM,MACrC,CAEA,aAAaA,EAAeG,EAA+B,CACzD,MAAMC,EAAc,KAAK,eAAeJ,CAAK,EAE7C,GAAII,EACF,OAAQD,EAAM,CACZ,IAAK,MACH,OAAOC,EAAY,OAAO,KAAK,SAAS,EAC1C,IAAK,aACH,OAAOA,EAAY,OAAO,KAAK,qBAAqB,EACtD,IAAK,wBACH,OAAOA,EAAY,OAAO,KAAK,8BAA8B,EAC/D,IAAK,iBACH,OAAOA,EAAY,OAAO,KAAK,yBAAyB,EAC1D,IAAK,4BACH,OAAOA,EAAY,OAAO,KAAK,kCAAkC,EACnE,QACE,SAAAC,QAAO,KAAK,sBAAsBF,CAAI,EAAE,EACjC,IACX,CAGF,OAAIH,GACF,EAAAK,QAAO,KAAK,kCAAkCL,CAAK,EAAE,EAEhD,IACT,CACF,CAGA,IAAOL,EAAQD",
|
|
4
|
+
"sourcesContent": ["import dayjs, { Dayjs } from 'dayjs'\nimport customParseFormat from 'dayjs/plugin/customParseFormat'\nimport { DateType } from './types'\nimport logger from '../logger'\n\nclass DateMapper {\n private isoDateRegEx = /^(\\d{4}[/-](0?[1-9]|1[012])[/-](0?[1-9]|[12][0-9]|3[01]))/\n\n private localDateRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{4}$/\n\n private localDateShortYearRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{2}$/\n\n private localDateTimeRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{4} [0-2]\\d:[0-5]\\d$/\n\n private localDateTimeShortYearRegEx = /^(0?[1-9]|[12][0-9]|3[01])[/-](0?[1-9]|1[012])[/-]\\d{2} [0-2]\\d:[0-5]\\d$/\n\n private isoFormat = 'YYYY-MM-DD'\n\n private localDateFormatInput = 'D/M/YYYY'\n\n private localDateFormatOutput = 'DD/MM/YYYY'\n\n private localDateShortYearFormatInput = 'D/M/YY'\n\n private localDateShortYearFormatOutput = 'DD/MM/YY'\n\n private localDateTimeFormatInput = 'D/M/YYYY HH:mm'\n\n private localDateTimeFormatOutput = 'DD/MM/YYYY HH:mm'\n\n private localDateTimeShortYearFormatInput = 'D/M/YY HH:mm'\n\n private localDateTimeShortYearFormatOutput = 'DD/MM/YY HH:mm'\n\n private localDateFormatMonthYear = 'MMM YY'\n\n private localDateFormatYear = 'YYYY'\n\n getDateType(value: string): DateType {\n if (value && value.match) {\n if (value.match(this.isoDateRegEx)) {\n return 'iso'\n }\n\n if (value.match(this.localDateRegEx)) {\n return 'local-date'\n }\n\n if (value.match(this.localDateShortYearRegEx)) {\n return 'local-date-short-year'\n }\n\n if (value.match(this.localDateTimeRegEx)) {\n return 'local-datetime'\n }\n\n if (value.match(this.localDateTimeShortYearRegEx)) {\n return 'local-datetime-short-year'\n }\n }\n\n return 'none'\n }\n\n getDateWrapper(value: string): Dayjs | null {\n dayjs.extend(customParseFormat)\n\n switch (this.getDateType(value)) {\n case 'iso':\n return dayjs(value)\n case 'local-date':\n return dayjs(value, this.localDateFormatInput)\n case 'local-date-short-year':\n return dayjs(value, this.localDateShortYearFormatInput)\n case 'local-datetime':\n return dayjs(value, this.localDateTimeFormatInput)\n case 'local-datetime-short-year':\n return dayjs(value, this.localDateTimeShortYearFormatInput)\n default:\n return null\n }\n }\n\n isDate(value: string): boolean {\n return this.getDateType(value) !== 'none'\n }\n\n toDateString(value: string, type: DateType): string | null {\n const dateWrapper = this.getDateWrapper(value)\n\n if (dateWrapper) {\n switch (type) {\n case 'iso':\n return dateWrapper.format(this.isoFormat)\n case 'local-date':\n return dateWrapper.format(this.localDateFormatOutput)\n case 'local-date-short-year':\n return dateWrapper.format(this.localDateShortYearFormatOutput)\n case 'local-datetime':\n return dateWrapper.format(this.localDateTimeFormatOutput)\n case 'local-datetime-short-year':\n return dateWrapper.format(this.localDateTimeShortYearFormatOutput)\n default:\n logger.warn(`Invalid date type: ${type}`)\n return null\n }\n }\n\n if (value) {\n logger.warn(`Could not map non-date value : ${value}`)\n }\n return null\n }\n}\n\nexport { DateMapper }\nexport default DateMapper\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAA6B,oBAC7BC,EAA8B,6CAE9BC,EAAmB,wBAEnB,MAAML,CAAW,CAAjB,cACE,KAAQ,aAAe,4DAEvB,KAAQ,eAAiB,2DAEzB,KAAQ,wBAA0B,2DAElC,KAAQ,mBAAqB,2EAE7B,KAAQ,4BAA8B,2EAEtC,KAAQ,UAAY,aAEpB,KAAQ,qBAAuB,WAE/B,KAAQ,sBAAwB,aAEhC,KAAQ,8BAAgC,SAExC,KAAQ,+BAAiC,WAEzC,KAAQ,yBAA2B,iBAEnC,KAAQ,0BAA4B,mBAEpC,KAAQ,kCAAoC,eAE5C,KAAQ,mCAAqC,iBAE7C,KAAQ,yBAA2B,SAEnC,KAAQ,oBAAsB,OAE9B,YAAYM,EAAyB,CACnC,GAAIA,GAASA,EAAM,MAAO,CACxB,GAAIA,EAAM,MAAM,KAAK,YAAY,EAC/B,MAAO,MAGT,GAAIA,EAAM,MAAM,KAAK,cAAc,EACjC,MAAO,aAGT,GAAIA,EAAM,MAAM,KAAK,uBAAuB,EAC1C,MAAO,wBAGT,GAAIA,EAAM,MAAM,KAAK,kBAAkB,EACrC,MAAO,iBAGT,GAAIA,EAAM,MAAM,KAAK,2BAA2B,EAC9C,MAAO,2BAEX,CAEA,MAAO,MACT,CAEA,eAAeA,EAA6B,CAG1C,OAFA,EAAAC,QAAM,OAAO,EAAAC,OAAiB,EAEtB,KAAK,YAAYF,CAAK,EAAG,CAC/B,IAAK,MACH,SAAO,EAAAC,SAAMD,CAAK,EACpB,IAAK,aACH,SAAO,EAAAC,SAAMD,EAAO,KAAK,oBAAoB,EAC/C,IAAK,wBACH,SAAO,EAAAC,SAAMD,EAAO,KAAK,6BAA6B,EACxD,IAAK,iBACH,SAAO,EAAAC,SAAMD,EAAO,KAAK,wBAAwB,EACnD,IAAK,4BACH,SAAO,EAAAC,SAAMD,EAAO,KAAK,iCAAiC,EAC5D,QACE,OAAO,IACX,CACF,CAEA,OAAOA,EAAwB,CAC7B,OAAO,KAAK,YAAYA,CAAK,IAAM,MACrC,CAEA,aAAaA,EAAeG,EAA+B,CACzD,MAAMC,EAAc,KAAK,eAAeJ,CAAK,EAE7C,GAAII,EACF,OAAQD,EAAM,CACZ,IAAK,MACH,OAAOC,EAAY,OAAO,KAAK,SAAS,EAC1C,IAAK,aACH,OAAOA,EAAY,OAAO,KAAK,qBAAqB,EACtD,IAAK,wBACH,OAAOA,EAAY,OAAO,KAAK,8BAA8B,EAC/D,IAAK,iBACH,OAAOA,EAAY,OAAO,KAAK,yBAAyB,EAC1D,IAAK,4BACH,OAAOA,EAAY,OAAO,KAAK,kCAAkC,EACnE,QACE,SAAAC,QAAO,KAAK,sBAAsBF,CAAI,EAAE,EACjC,IACX,CAGF,OAAIH,GACF,EAAAK,QAAO,KAAK,kCAAkCL,CAAK,EAAE,EAEhD,IACT,CACF,CAGA,IAAOL,EAAQD",
|
|
6
6
|
"names": ["DateMapper_exports", "__export", "DateMapper", "DateMapper_default", "__toCommonJS", "import_dayjs", "import_customParseFormat", "import_logger", "value", "dayjs", "customParseFormat", "type", "dateWrapper", "logger"]
|
|
7
7
|
}
|
|
@@ -32,6 +32,10 @@ class DateMapper {
|
|
|
32
32
|
|
|
33
33
|
private localDateTimeShortYearFormatOutput = 'DD/MM/YY HH:mm'
|
|
34
34
|
|
|
35
|
+
private localDateFormatMonthYear = 'MMM YY'
|
|
36
|
+
|
|
37
|
+
private localDateFormatYear = 'YYYY'
|
|
38
|
+
|
|
35
39
|
getDateType(value: string): DateType {
|
|
36
40
|
if (value && value.match) {
|
|
37
41
|
if (value.match(this.isoDateRegEx)) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var P=Object.create;var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var N=(s,c)=>{for(var t in c)u(s,t,{get:c[t],enumerable:!0})},f=(s,c,t,r)=>{if(c&&typeof c=="object"||typeof c=="function")for(let e of A(c))!F.call(s,e)&&e!==t&&u(s,e,{get:()=>c[e],enumerable:!(r=v(c,e))||r.enumerable});return s};var S=(s,c,t)=>(t=s!=null?P(w(s)):{},f(c||!s||!s.__esModule?u(t,"default",{value:s,enumerable:!0}):t,s)),B=s=>f(u({},"__esModule",{value:!0}),s);var J={};N(J,{ParentChildDataTableBuilder:()=>C,default:()=>H});module.exports=B(J);var g=S(require("../DataTableBuilder/DataTableBuilder")),b=require("../arrayUtils"),T=S(require("../SectionedDataTableBuilder/SectionedDataTableBuilder"));class C extends T.default{constructor(t){const{specification:r}=t,{sections:e,template:i}=r;super(r);this.childData=[];this.sections=e,this.template=i,this.variant=t,this.childVariants=this.variant.childVariants||[]}createParentChildTable(t,r){let e={};const i=this.mapNamesToFields(this.childVariants.flatMap(a=>a.joinFields).reduce(b.distinct,[])),n=this.calculateParentChildKeys(t,i);n.forEach(a=>{e[a.sortKey]={parent:[]}}),e=this.splitParentDataIntoSections(e,t,i),e=this.splitChildDataIntoSections(n,e);const l=this.createChildDataTableBuilders();return n.flatMap(a=>{const d=e[a.sortKey]||{};let p=[];return d&&(p=d.parent?d.parent:[]),[r].concat(p.map(h=>this.mapRow(h,"dpr-parent-cell"))).concat(this.childVariants.filter(h=>d&&d[h.id]).map(h=>{const D=l[h.id],m=d[h.id],y=D&&m?D.buildTable(m):void 0,K=y?this.convertDataTableToHtml(y):"";return[{classes:"dpr-child-report-cell",format:"string",html:`<div class='dpr-child-report'><h2 class="govuk-heading-s">${h.name}</h2><div class="dpr-child-report_table">${K}</div></div>`,colspan:this.columns.length}]}))})}createParentChildSectionRows(t,r){const i=this.mapSections(t).sectionedData,n=[];return Object.keys(i).forEach(o=>{const a=i[o];n.push({sectionDescription:o,...this.getSectionCount(i,o),rows:this.createParentChildTable(a,r)})}),n.flatMap((o,a)=>[...this.createSectionHeader(o.sectionDescription,a,o.count,o.countDescription),...o.rows])}mapParentChildData(t,r){return this.sections?.length?this.createParentChildSectionRows(t,r):this.createParentChildTable(t,r)}createChildDataTableBuilders(){return this.childVariants.reduce((r,e)=>{const{specification:i}=e,n=i?i.fields:[],l=n.filter(a=>a.visible||a.mandatory).map(a=>a.name),o=new g.default(n).withNoHeaderOptions(l).withSortedData();return{...r,[e.id]:o}},{})}calculateParentChildKeys(t,r){return t.map(e=>({sortKey:this.getSortKey(e,r),childSortKeys:this.childVariants.reduce((i,n)=>({...i,[n.id]:this.getSortKey(e,this.mapNamesToFields(n.joinFields))}),{})})).reduce((e,i)=>e.find(n=>n.sortKey===i.sortKey)?e:e.concat(i),[])}splitParentDataIntoSections(t,r,e){return r.reduce((i,n)=>{const l=this.getSortKey(n,e),o=i[l]?i[l].parent:[];return{...i,...o&&{[l]:{parent:o.concat(n)}}}},t)}splitChildDataIntoSections(t,r){const e={...r};return this.childVariants.forEach(i=>{const n=this.mapNamesToFields(i.joinFields),l=this.childData.find(a=>a.id===i.id);(l?l.data:[]).filter(a=>{const d=this.getSortKey(a,n);return t.find(p=>p.childSortKeys[i.id]===d)}).forEach(a=>{const d=this.getSortKey(a,n),p=t.find(m=>m.childSortKeys[i.id]===d),h=p?p.sortKey:"",D=e[h];if(D){const m=D[i.id]||[];D[i.id]=m.concat(a)}})}),e}withChildData(t){return this.childData=t,this}buildTable(t){return{head:null,rows:this.mapParentChildData(t,this.mapHeader(!0,"govuk-table__header")),rowCount:t.length,colCount:this.columns.length}}}var H=C;0&&(module.exports={ParentChildDataTableBuilder});
|
|
2
2
|
//# sourceMappingURL=ParentChildDataTableBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import Dict = NodeJS.Dict\nimport { components } from '../../types/api'\nimport { Cell, DataTable, FieldDefinition } from '../DataTableBuilder/types'\nimport DataTableBuilder from '../DataTableBuilder/DataTableBuilder'\nimport { distinct } from '../arrayUtils'\nimport { ChildData, ParentChildSortKey } from './types'\nimport logger from '../logger'\nimport SectionedDataTableBuilder from '../SectionedDataTableBuilder/SectionedDataTableBuilder'\n\nclass ParentChildDataTableBuilder extends SectionedDataTableBuilder {\n variant: components['schemas']['VariantDefinition']\n\n childVariants: components['schemas']['ChildVariantDefinition'][]\n\n childData: Array<ChildData> = []\n\n constructor(variant: components['schemas']['VariantDefinition']) {\n const { specification } = variant\n const { sections, template } = <components['schemas']['Specification']>specification\n super(<components['schemas']['Specification']>specification)\n\n this.sections = sections\n this.template = template\n this.variant = variant\n this.childVariants = this.variant.childVariants || []\n }\n\n private createParentChildTable(parentData: Array<Dict<string>>, header: Cell[]) {\n let sectionedParentChildData: Dict<Dict<Array<Dict<string>>>> = {}\n const joinFields = this.mapNamesToFields(this.childVariants.flatMap((c) => c.joinFields).reduce(distinct, []))\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ joinFields }, null, 2))\n // Get the parent-child joins definition data\n\n // Create the section keys and\n const parentChildKeys = this.calculateParentChildKeys(parentData, joinFields)\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ parentChildKeys }, null, 2))\n parentChildKeys.forEach((parentKey) => {\n sectionedParentChildData[parentKey.sortKey] = {\n parent: [],\n }\n })\n\n sectionedParentChildData = this.splitParentDataIntoSections(sectionedParentChildData, parentData, joinFields)\n sectionedParentChildData = this.splitChildDataIntoSections(parentChildKeys, sectionedParentChildData)\n\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionedParentChildData }, null, 2))\n\n const childDataTableBuilders = this.createChildDataTableBuilders()\n\n const parentChildTable = parentChildKeys.flatMap((key) => {\n const sectionData = sectionedParentChildData[key.sortKey] || {}\n\n let parentSectionData: Dict<string>[] = []\n if (sectionData) {\n parentSectionData = sectionData.parent ? sectionData.parent : []\n }\n\n return [header].concat(parentSectionData.map((r) => this.mapRow(r, 'dpr-parent-cell'))).concat(\n this.childVariants\n .filter((childVariant) => sectionData && sectionData[childVariant.id])\n .map((childVariant) => {\n const builder = childDataTableBuilders[childVariant.id]\n const section = sectionData[childVariant.id]\n const dataTable = builder && section ? builder.buildTable(section) : undefined\n const dataTableHtml = dataTable ? this.convertDataTableToHtml(dataTable) : ''\n\n return [\n {\n classes: 'dpr-child-report-cell',\n format: 'string',\n html: `<div class='dpr-child-report'><h2 class=\"govuk-heading-s\">${childVariant.name}</h2><div class=\"dpr-child-report_table\">${dataTableHtml}</div></div>`,\n colspan: this.columns.length,\n },\n ]\n }),\n )\n })\n\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ parentChildTable }, null, 2))\n\n return parentChildTable\n }\n\n private createParentChildSectionRows(parentData: Array<Dict<string>>, header: Cell[]) {\n const sectionsDetails = this.mapSections(parentData)\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionsDetails }, null, 2))\n const sectionedData = sectionsDetails.sectionedData as Dict<Array<Dict<string>>>\n const sectionedParentChildSectionedRows: {\n sectionDescription: string\n rows: Cell[][]\n count: number\n countDescription: string\n }[] = []\n\n Object.keys(sectionedData).forEach((sectionDescription) => {\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionDescription }, null, 2))\n const data = sectionedData[sectionDescription] as Array<Dict<string>>\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ data }, null, 2))\n\n sectionedParentChildSectionedRows.push({\n sectionDescription,\n ...this.getSectionCount(sectionedData, sectionDescription),\n rows: this.createParentChildTable(data, header),\n })\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionedParentChildSectionedRows }, null, 2))\n })\n\n const rows = sectionedParentChildSectionedRows.flatMap((section, index) => {\n const sectionHeader = this.createSectionHeader(\n section.sectionDescription,\n index,\n section.count,\n section.countDescription,\n )\n return [...sectionHeader, ...section.rows]\n })\n logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ rows }, null, 2))\n\n return rows\n }\n\n private mapParentChildData(parentData: Array<Dict<string>>, header: Cell[]): Cell[][] {\n if (this.sections?.length) {\n return this.createParentChildSectionRows(parentData, header)\n }\n return this.createParentChildTable(parentData, header)\n }\n\n private createChildDataTableBuilders() {\n const childDataTables: Dict<DataTableBuilder> = this.childVariants.reduce((previousValue, childVariant) => {\n const { specification } = childVariant\n const fields = specification ? specification.fields : []\n const fieldNamesToDisplay = fields.filter((f) => f.visible || f.mandatory).map((f) => f.name)\n\n const dataTableBuilder = new DataTableBuilder(fields).withNoHeaderOptions(fieldNamesToDisplay).withSortedData()\n\n return {\n ...previousValue,\n [childVariant.id]: dataTableBuilder,\n }\n }, {})\n return childDataTables\n }\n\n private calculateParentChildKeys(parentData: Array<NodeJS.Dict<string>>, joinFields: FieldDefinition[]) {\n return parentData\n .map(\n (rowData): ParentChildSortKey => ({\n sortKey: this.getSortKey(rowData, joinFields),\n childSortKeys: this.childVariants.reduce((previousValue, childVariant) => {\n return {\n ...previousValue,\n [childVariant.id]: this.getSortKey(rowData, this.mapNamesToFields(childVariant.joinFields)),\n }\n }, {}),\n }),\n )\n .reduce((previousValue: ParentChildSortKey[], sortKey: ParentChildSortKey) => {\n if (previousValue.find((v) => v.sortKey === sortKey.sortKey)) {\n return previousValue\n }\n return previousValue.concat(sortKey)\n }, [])\n }\n\n private splitParentDataIntoSections(\n sectionedParentChildData: NodeJS.Dict<NodeJS.Dict<Array<NodeJS.Dict<string>>>>,\n parentData: Array<NodeJS.Dict<string>>,\n joinFields: FieldDefinition[],\n ) {\n return parentData.reduce((previousValue, rowData) => {\n const parentKey: string = this.getSortKey(rowData, joinFields)\n const previousParentValue = previousValue[parentKey] ? previousValue[parentKey].parent : []\n\n return {\n ...previousValue,\n ...(previousParentValue && {\n [parentKey]: {\n parent: previousParentValue.concat(rowData),\n },\n }),\n }\n }, sectionedParentChildData)\n }\n\n private splitChildDataIntoSections(\n parentKeys: ParentChildSortKey[],\n sectionedParentChildData: Dict<Dict<Array<Dict<string>>>>,\n ): Dict<Dict<Array<Dict<string>>>> {\n const sectionedParentChildDataWithChildren = { ...sectionedParentChildData }\n\n logger.info('DPR-Parent-child-template-debugging', JSON.stringify({ childData: this.childData }, null, 2))\n\n this.childVariants.forEach((childVariant) => {\n const childFields = this.mapNamesToFields(childVariant.joinFields)\n logger.info(\n 'DPR-Parent-child-template-debugging splitChildDataIntoSections',\n JSON.stringify(\n {\n childFields,\n parentKeys,\n },\n null,\n 2,\n ),\n )\n\n const matchingChildData = this.childData.find((d) => {\n logger.info(\n 'DPR-Parent-child-template-debugging',\n JSON.stringify({ childDataId: d.id, childVariantId: childVariant.id }, null, 2),\n )\n return d.id === childVariant.id\n })\n const data = matchingChildData ? matchingChildData.data : []\n\n logger.info('DPR-Parent-child-template-debugging', JSON.stringify({ matchingChildData, data }, null, 2))\n\n data\n .filter((rowData) => {\n const sortKey = this.getSortKey(rowData, childFields)\n return parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey)\n })\n .forEach((rowData) => {\n logger.info('DPR-Parent-child-template-debugging', JSON.stringify({ rowData }, null, 2))\n const sortKey = this.getSortKey(rowData, childFields)\n const parent = parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey)\n const parentSortKey = parent ? parent.sortKey : ''\n const parentSection = sectionedParentChildDataWithChildren[parentSortKey]\n if (parentSection) {\n const existingChildData = parentSection[childVariant.id] || []\n parentSection[childVariant.id] = existingChildData.concat(rowData)\n }\n })\n })\n\n logger.info(\n 'DPR-Parent-child-template-debugging',\n JSON.stringify({ sectionedParentChildDataWithChildren }, null, 2),\n )\n\n return sectionedParentChildDataWithChildren\n }\n\n withChildData(childData: Array<ChildData>) {\n this.childData = childData\n return this\n }\n\n buildTable(data: Array<Dict<string>>): DataTable {\n return {\n head: null,\n rows: this.mapParentChildData(data, this.mapHeader(true, 'govuk-table__header')),\n rowCount: data.length,\n colCount: this.columns.length,\n }\n }\n}\n\nexport { ParentChildDataTableBuilder }\nexport default ParentChildDataTableBuilder\n"],
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAA6B,mDAC7BC,EAAyB,yBAEzBC,
|
|
6
|
-
"names": ["ParentChildDataTableBuilder_exports", "__export", "ParentChildDataTableBuilder", "ParentChildDataTableBuilder_default", "__toCommonJS", "import_DataTableBuilder", "import_arrayUtils", "
|
|
4
|
+
"sourcesContent": ["import Dict = NodeJS.Dict\nimport { components } from '../../types/api'\nimport { Cell, DataTable, FieldDefinition } from '../DataTableBuilder/types'\nimport DataTableBuilder from '../DataTableBuilder/DataTableBuilder'\nimport { distinct } from '../arrayUtils'\nimport { ChildData, ParentChildSortKey } from './types'\nimport SectionedDataTableBuilder from '../SectionedDataTableBuilder/SectionedDataTableBuilder'\n\nclass ParentChildDataTableBuilder extends SectionedDataTableBuilder {\n variant: components['schemas']['VariantDefinition']\n\n childVariants: components['schemas']['ChildVariantDefinition'][]\n\n childData: Array<ChildData> = []\n\n constructor(variant: components['schemas']['VariantDefinition']) {\n const { specification } = variant\n const { sections, template } = <components['schemas']['Specification']>specification\n super(<components['schemas']['Specification']>specification)\n\n this.sections = sections\n this.template = template\n this.variant = variant\n this.childVariants = this.variant.childVariants || []\n }\n\n private createParentChildTable(parentData: Array<Dict<string>>, header: Cell[]) {\n let sectionedParentChildData: Dict<Dict<Array<Dict<string>>>> = {}\n const joinFields = this.mapNamesToFields(this.childVariants.flatMap((c) => c.joinFields).reduce(distinct, []))\n // Get the parent-child joins definition data\n\n // Create the section keys and\n const parentChildKeys = this.calculateParentChildKeys(parentData, joinFields)\n parentChildKeys.forEach((parentKey) => {\n sectionedParentChildData[parentKey.sortKey] = {\n parent: [],\n }\n })\n\n sectionedParentChildData = this.splitParentDataIntoSections(sectionedParentChildData, parentData, joinFields)\n sectionedParentChildData = this.splitChildDataIntoSections(parentChildKeys, sectionedParentChildData)\n\n const childDataTableBuilders = this.createChildDataTableBuilders()\n\n const parentChildTable = parentChildKeys.flatMap((key) => {\n const sectionData = sectionedParentChildData[key.sortKey] || {}\n\n let parentSectionData: Dict<string>[] = []\n if (sectionData) {\n parentSectionData = sectionData.parent ? sectionData.parent : []\n }\n\n return [header].concat(parentSectionData.map((r) => this.mapRow(r, 'dpr-parent-cell'))).concat(\n this.childVariants\n .filter((childVariant) => sectionData && sectionData[childVariant.id])\n .map((childVariant) => {\n const builder = childDataTableBuilders[childVariant.id]\n const section = sectionData[childVariant.id]\n const dataTable = builder && section ? builder.buildTable(section) : undefined\n const dataTableHtml = dataTable ? this.convertDataTableToHtml(dataTable) : ''\n\n return [\n {\n classes: 'dpr-child-report-cell',\n format: 'string',\n html: `<div class='dpr-child-report'><h2 class=\"govuk-heading-s\">${childVariant.name}</h2><div class=\"dpr-child-report_table\">${dataTableHtml}</div></div>`,\n colspan: this.columns.length,\n },\n ]\n }),\n )\n })\n\n return parentChildTable\n }\n\n private createParentChildSectionRows(parentData: Array<Dict<string>>, header: Cell[]) {\n const sectionsDetails = this.mapSections(parentData)\n const sectionedData = sectionsDetails.sectionedData as Dict<Array<Dict<string>>>\n const sectionedParentChildSectionedRows: {\n sectionDescription: string\n rows: Cell[][]\n count: number\n countDescription: string\n }[] = []\n\n Object.keys(sectionedData).forEach((sectionDescription) => {\n const data = sectionedData[sectionDescription] as Array<Dict<string>>\n\n sectionedParentChildSectionedRows.push({\n sectionDescription,\n ...this.getSectionCount(sectionedData, sectionDescription),\n rows: this.createParentChildTable(data, header),\n })\n })\n\n const rows = sectionedParentChildSectionedRows.flatMap((section, index) => {\n const sectionHeader = this.createSectionHeader(\n section.sectionDescription,\n index,\n section.count,\n section.countDescription,\n )\n return [...sectionHeader, ...section.rows]\n })\n\n return rows\n }\n\n private mapParentChildData(parentData: Array<Dict<string>>, header: Cell[]): Cell[][] {\n if (this.sections?.length) {\n return this.createParentChildSectionRows(parentData, header)\n }\n return this.createParentChildTable(parentData, header)\n }\n\n private createChildDataTableBuilders() {\n const childDataTables: Dict<DataTableBuilder> = this.childVariants.reduce((previousValue, childVariant) => {\n const { specification } = childVariant\n const fields = specification ? specification.fields : []\n const fieldNamesToDisplay = fields.filter((f) => f.visible || f.mandatory).map((f) => f.name)\n\n const dataTableBuilder = new DataTableBuilder(fields).withNoHeaderOptions(fieldNamesToDisplay).withSortedData()\n\n return {\n ...previousValue,\n [childVariant.id]: dataTableBuilder,\n }\n }, {})\n return childDataTables\n }\n\n private calculateParentChildKeys(parentData: Array<NodeJS.Dict<string>>, joinFields: FieldDefinition[]) {\n return parentData\n .map(\n (rowData): ParentChildSortKey => ({\n sortKey: this.getSortKey(rowData, joinFields),\n childSortKeys: this.childVariants.reduce((previousValue, childVariant) => {\n return {\n ...previousValue,\n [childVariant.id]: this.getSortKey(rowData, this.mapNamesToFields(childVariant.joinFields)),\n }\n }, {}),\n }),\n )\n .reduce((previousValue: ParentChildSortKey[], sortKey: ParentChildSortKey) => {\n if (previousValue.find((v) => v.sortKey === sortKey.sortKey)) {\n return previousValue\n }\n return previousValue.concat(sortKey)\n }, [])\n }\n\n private splitParentDataIntoSections(\n sectionedParentChildData: NodeJS.Dict<NodeJS.Dict<Array<NodeJS.Dict<string>>>>,\n parentData: Array<NodeJS.Dict<string>>,\n joinFields: FieldDefinition[],\n ) {\n return parentData.reduce((previousValue, rowData) => {\n const parentKey: string = this.getSortKey(rowData, joinFields)\n const previousParentValue = previousValue[parentKey] ? previousValue[parentKey].parent : []\n\n return {\n ...previousValue,\n ...(previousParentValue && {\n [parentKey]: {\n parent: previousParentValue.concat(rowData),\n },\n }),\n }\n }, sectionedParentChildData)\n }\n\n private splitChildDataIntoSections(\n parentKeys: ParentChildSortKey[],\n sectionedParentChildData: Dict<Dict<Array<Dict<string>>>>,\n ): Dict<Dict<Array<Dict<string>>>> {\n const sectionedParentChildDataWithChildren = { ...sectionedParentChildData }\n\n this.childVariants.forEach((childVariant) => {\n const childFields = this.mapNamesToFields(childVariant.joinFields)\n const matchingChildData = this.childData.find((d) => d.id === childVariant.id)\n const data = matchingChildData ? matchingChildData.data : []\n\n data\n .filter((rowData) => {\n const sortKey = this.getSortKey(rowData, childFields)\n return parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey)\n })\n .forEach((rowData) => {\n const sortKey = this.getSortKey(rowData, childFields)\n const parent = parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey)\n const parentSortKey = parent ? parent.sortKey : ''\n const parentSection = sectionedParentChildDataWithChildren[parentSortKey]\n if (parentSection) {\n const existingChildData = parentSection[childVariant.id] || []\n parentSection[childVariant.id] = existingChildData.concat(rowData)\n }\n })\n })\n\n return sectionedParentChildDataWithChildren\n }\n\n withChildData(childData: Array<ChildData>) {\n this.childData = childData\n return this\n }\n\n buildTable(data: Array<Dict<string>>): DataTable {\n return {\n head: null,\n rows: this.mapParentChildData(data, this.mapHeader(true, 'govuk-table__header')),\n rowCount: data.length,\n colCount: this.columns.length,\n }\n }\n}\n\nexport { ParentChildDataTableBuilder }\nexport default ParentChildDataTableBuilder\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAA6B,mDAC7BC,EAAyB,yBAEzBC,EAAsC,qEAEtC,MAAML,UAAoC,EAAAM,OAA0B,CAOlE,YAAYC,EAAqD,CAC/D,KAAM,CAAE,cAAAC,CAAc,EAAID,EACpB,CAAE,SAAAE,EAAU,SAAAC,CAAS,EAA4CF,EACvE,MAA8CA,CAAa,EAL7D,eAA8B,CAAC,EAO7B,KAAK,SAAWC,EAChB,KAAK,SAAWC,EAChB,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C7D4B,EAAc5B,EAAa,EAAE,EAAI6B,EAAkB,OAAOb,CAAO,CACnE,CACF,CAAC,CACL,CAAC,EAEMK,CACT,CAEA,cAAcS,EAA6B,CACzC,YAAK,UAAYA,EACV,IACT,CAEA,WAAWtB,EAAsC,CAC/C,MAAO,CACL,KAAM,KACN,KAAM,KAAK,mBAAmBA,EAAM,KAAK,UAAU,GAAM,qBAAqB,CAAC,EAC/E,SAAUA,EAAK,OACf,SAAU,KAAK,QAAQ,MACzB,CACF,CACF,CAGA,IAAO9B,EAAQD",
|
|
6
|
+
"names": ["ParentChildDataTableBuilder_exports", "__export", "ParentChildDataTableBuilder", "ParentChildDataTableBuilder_default", "__toCommonJS", "import_DataTableBuilder", "import_arrayUtils", "import_SectionedDataTableBuilder", "SectionedDataTableBuilder", "variant", "specification", "sections", "template", "parentData", "header", "sectionedParentChildData", "joinFields", "c", "parentChildKeys", "parentKey", "childDataTableBuilders", "key", "sectionData", "parentSectionData", "r", "childVariant", "builder", "section", "dataTable", "dataTableHtml", "sectionedData", "sectionedParentChildSectionedRows", "sectionDescription", "data", "index", "previousValue", "fields", "fieldNamesToDisplay", "f", "dataTableBuilder", "DataTableBuilder", "rowData", "sortKey", "v", "previousParentValue", "parentKeys", "sectionedParentChildDataWithChildren", "childFields", "matchingChildData", "d", "parent", "p", "parentSortKey", "parentSection", "existingChildData", "childData"]
|
|
7
7
|
}
|
|
@@ -4,7 +4,6 @@ import { Cell, DataTable, FieldDefinition } from '../DataTableBuilder/types'
|
|
|
4
4
|
import DataTableBuilder from '../DataTableBuilder/DataTableBuilder'
|
|
5
5
|
import { distinct } from '../arrayUtils'
|
|
6
6
|
import { ChildData, ParentChildSortKey } from './types'
|
|
7
|
-
import logger from '../logger'
|
|
8
7
|
import SectionedDataTableBuilder from '../SectionedDataTableBuilder/SectionedDataTableBuilder'
|
|
9
8
|
|
|
10
9
|
class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
@@ -28,12 +27,10 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
28
27
|
private createParentChildTable(parentData: Array<Dict<string>>, header: Cell[]) {
|
|
29
28
|
let sectionedParentChildData: Dict<Dict<Array<Dict<string>>>> = {}
|
|
30
29
|
const joinFields = this.mapNamesToFields(this.childVariants.flatMap((c) => c.joinFields).reduce(distinct, []))
|
|
31
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ joinFields }, null, 2))
|
|
32
30
|
// Get the parent-child joins definition data
|
|
33
31
|
|
|
34
32
|
// Create the section keys and
|
|
35
33
|
const parentChildKeys = this.calculateParentChildKeys(parentData, joinFields)
|
|
36
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ parentChildKeys }, null, 2))
|
|
37
34
|
parentChildKeys.forEach((parentKey) => {
|
|
38
35
|
sectionedParentChildData[parentKey.sortKey] = {
|
|
39
36
|
parent: [],
|
|
@@ -43,8 +40,6 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
43
40
|
sectionedParentChildData = this.splitParentDataIntoSections(sectionedParentChildData, parentData, joinFields)
|
|
44
41
|
sectionedParentChildData = this.splitChildDataIntoSections(parentChildKeys, sectionedParentChildData)
|
|
45
42
|
|
|
46
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionedParentChildData }, null, 2))
|
|
47
|
-
|
|
48
43
|
const childDataTableBuilders = this.createChildDataTableBuilders()
|
|
49
44
|
|
|
50
45
|
const parentChildTable = parentChildKeys.flatMap((key) => {
|
|
@@ -76,14 +71,11 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
76
71
|
)
|
|
77
72
|
})
|
|
78
73
|
|
|
79
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ parentChildTable }, null, 2))
|
|
80
|
-
|
|
81
74
|
return parentChildTable
|
|
82
75
|
}
|
|
83
76
|
|
|
84
77
|
private createParentChildSectionRows(parentData: Array<Dict<string>>, header: Cell[]) {
|
|
85
78
|
const sectionsDetails = this.mapSections(parentData)
|
|
86
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionsDetails }, null, 2))
|
|
87
79
|
const sectionedData = sectionsDetails.sectionedData as Dict<Array<Dict<string>>>
|
|
88
80
|
const sectionedParentChildSectionedRows: {
|
|
89
81
|
sectionDescription: string
|
|
@@ -93,16 +85,13 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
93
85
|
}[] = []
|
|
94
86
|
|
|
95
87
|
Object.keys(sectionedData).forEach((sectionDescription) => {
|
|
96
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionDescription }, null, 2))
|
|
97
88
|
const data = sectionedData[sectionDescription] as Array<Dict<string>>
|
|
98
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ data }, null, 2))
|
|
99
89
|
|
|
100
90
|
sectionedParentChildSectionedRows.push({
|
|
101
91
|
sectionDescription,
|
|
102
92
|
...this.getSectionCount(sectionedData, sectionDescription),
|
|
103
93
|
rows: this.createParentChildTable(data, header),
|
|
104
94
|
})
|
|
105
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ sectionedParentChildSectionedRows }, null, 2))
|
|
106
95
|
})
|
|
107
96
|
|
|
108
97
|
const rows = sectionedParentChildSectionedRows.flatMap((section, index) => {
|
|
@@ -114,7 +103,6 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
114
103
|
)
|
|
115
104
|
return [...sectionHeader, ...section.rows]
|
|
116
105
|
})
|
|
117
|
-
logger.info(`DPR-Parent-child-template-debugging`, JSON.stringify({ rows }, null, 2))
|
|
118
106
|
|
|
119
107
|
return rows
|
|
120
108
|
}
|
|
@@ -189,40 +177,17 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
189
177
|
): Dict<Dict<Array<Dict<string>>>> {
|
|
190
178
|
const sectionedParentChildDataWithChildren = { ...sectionedParentChildData }
|
|
191
179
|
|
|
192
|
-
logger.info('DPR-Parent-child-template-debugging', JSON.stringify({ childData: this.childData }, null, 2))
|
|
193
|
-
|
|
194
180
|
this.childVariants.forEach((childVariant) => {
|
|
195
181
|
const childFields = this.mapNamesToFields(childVariant.joinFields)
|
|
196
|
-
|
|
197
|
-
'DPR-Parent-child-template-debugging splitChildDataIntoSections',
|
|
198
|
-
JSON.stringify(
|
|
199
|
-
{
|
|
200
|
-
childFields,
|
|
201
|
-
parentKeys,
|
|
202
|
-
},
|
|
203
|
-
null,
|
|
204
|
-
2,
|
|
205
|
-
),
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
const matchingChildData = this.childData.find((d) => {
|
|
209
|
-
logger.info(
|
|
210
|
-
'DPR-Parent-child-template-debugging',
|
|
211
|
-
JSON.stringify({ childDataId: d.id, childVariantId: childVariant.id }, null, 2),
|
|
212
|
-
)
|
|
213
|
-
return d.id === childVariant.id
|
|
214
|
-
})
|
|
182
|
+
const matchingChildData = this.childData.find((d) => d.id === childVariant.id)
|
|
215
183
|
const data = matchingChildData ? matchingChildData.data : []
|
|
216
184
|
|
|
217
|
-
logger.info('DPR-Parent-child-template-debugging', JSON.stringify({ matchingChildData, data }, null, 2))
|
|
218
|
-
|
|
219
185
|
data
|
|
220
186
|
.filter((rowData) => {
|
|
221
187
|
const sortKey = this.getSortKey(rowData, childFields)
|
|
222
188
|
return parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey)
|
|
223
189
|
})
|
|
224
190
|
.forEach((rowData) => {
|
|
225
|
-
logger.info('DPR-Parent-child-template-debugging', JSON.stringify({ rowData }, null, 2))
|
|
226
191
|
const sortKey = this.getSortKey(rowData, childFields)
|
|
227
192
|
const parent = parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey)
|
|
228
193
|
const parentSortKey = parent ? parent.sortKey : ''
|
|
@@ -234,11 +199,6 @@ class ParentChildDataTableBuilder extends SectionedDataTableBuilder {
|
|
|
234
199
|
})
|
|
235
200
|
})
|
|
236
201
|
|
|
237
|
-
logger.info(
|
|
238
|
-
'DPR-Parent-child-template-debugging',
|
|
239
|
-
JSON.stringify({ sectionedParentChildDataWithChildren }, null, 2),
|
|
240
|
-
)
|
|
241
|
-
|
|
242
202
|
return sectionedParentChildDataWithChildren
|
|
243
203
|
}
|
|
244
204
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I=Object.create;var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var q=(r,t)=>{for(var e in t)u(r,e,{get:t[e],enumerable:!0})},d=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of y(t))!R.call(r,s)&&s!==e&&u(r,s,{get:()=>t[s],enumerable:!(i=g(t,s))||i.enumerable});return r};var f=(r,t,e)=>(e=r!=null?I(D(r)):{},d(t||!r||!r.__esModule?u(e,"default",{value:r,enumerable:!0}):e,r)),U=r=>d(u({},"__esModule",{value:!0}),r);var b={};q(b,{UserStoreItemBuilder:()=>h,default:()=>E});module.exports=U(b);var p=f(require("parseurl")),o=require("../types/UserReports");class h{constructor(t,e){this.build=()=>this.userStoreItem;this.addReportData=({type:t,reportId:e,reportName:i,description:s,id:m,name:n})=>({type:t,reportId:e,reportName:i,description:s,id:m,name:n,timestamp:{}});this.addExecutionData=t=>(this.userStoreItem={...this.userStoreItem,...t},this);this.addChildExecutionData=t=>(this.userStoreItem={...this.userStoreItem,childExecutionData:t},this);this.addFilters=t=>{const e=new URLSearchParams(t).toString();return this.userStoreItem={...this.userStoreItem,filters:{data:t,queryString:e}},this};this.addSortData=t=>{const e=new URLSearchParams(t).toString();return this.userStoreItem={...this.userStoreItem,sortBy:{data:t,queryString:e}},this};this.addRequestUrls=t=>{const{origin:e,pathname:i,search:s,href:m}=this.requestFormData,{executionId:n,dataProductDefinitionsPath:S,dpdPathFromQuery:l}=this.userStoreItem;let a=t.baseUrl.replace("/filters",`/${n}/status`);l&&(a=`${a}?dataProductDefinitionsPath=${S}`);const c=`${e}${a}`;return this.userStoreItem={...this.userStoreItem,url:{origin:e,request:{fullUrl:m,pathname:i,search:s},polling:{fullUrl:c,pathname:a}}},this};this.addAsyncUrls=t=>(this.userStoreItem={...this.userStoreItem,url:t},this);this.addReportUrls=t=>{const e=t.get("host"),i=`${t.protocol}://${t.get("host")}${t.originalUrl}`,s=(0,p.default)(t);return this.userStoreItem={...this.userStoreItem,url:{origin:e||this.userStoreItem.url?.origin||"",...this.userStoreItem.url?.request&&{request:this.userStoreItem.url.request},...this.userStoreItem.url?.polling&&{polling:this.userStoreItem.url.polling},report:{...this.userStoreItem.url?.report&&this.userStoreItem.url.report,fullUrl:i,...s&&s.search&&{search:s.search}}}},this};this.addLoadType=t=>(this.userStoreItem={...this.userStoreItem,loadType:t},this);this.addQuery=t=>(this.userStoreItem={...this.userStoreItem,...t&&{query:{data:t.query,summary:t.querySummary}}},this);this.addInteractiveQuery=t=>(t&&(this.userStoreItem={...this.userStoreItem,interactiveQuery:{data:t.query,summary:t.querySummary}}),this);this.addStatus=t=>(this.userStoreItem={...this.userStoreItem,status:t},this);this.addMetrics=t=>(this.userStoreItem={...this.userStoreItem,metrics:t.filter(e=>e.display).map(e=>({name:e.display||""}))},this);this.addTimestamp=()=>{const{status:t}=this.userStoreItem,e=new Date;switch(t){case o.RequestStatus.FAILED:this.userStoreItem.timestamp.failed=e;break;case o.RequestStatus.EXPIRED:this.userStoreItem.timestamp.expired=e;break;case o.RequestStatus.ABORTED:this.userStoreItem.timestamp.aborted=e;break;case o.RequestStatus.FINISHED:this.userStoreItem.timestamp.completed=e;break;case o.RequestStatus.SUBMITTED:this.userStoreItem.timestamp.requested=e;break;case o.RequestStatus.STARTED:case o.RequestStatus.PICKED:break;default:this.userStoreItem.timestamp.lastViewed=e;break}return this};this.addDefinitionsPath=(t,e)=>(t&&(this.userStoreItem={...this.userStoreItem,dataProductDefinitionsPath:t,dpdPathFromQuery:e}),this);this.requestFormData=e||{},this.userStoreItem=this.addReportData(t)}}var E=h;0&&(module.exports={UserStoreItemBuilder});
|
|
2
2
|
//# sourceMappingURL=UserStoreItemBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/dpr/utils/UserStoreItemBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Request } from 'express'\nimport parseUrl from 'parseurl'\nimport {\n AsyncReportUrlData,\n LoadType,\n ReportType,\n RequestedReport,\n RequestFormData,\n RequestStatus,\n UserReportData,\n} from '../types/UserReports'\nimport Dict = NodeJS.Dict\nimport { ChildReportExecutionData, ExecutionData } from '../types/ExecutionData'\nimport { DashboardSection } from '../components/_dashboards/dashboard/types'\n\nclass UserStoreItemBuilder {\n userStoreItem: UserReportData\n\n requestFormData: RequestFormData | Record<string, never>\n\n constructor(\n reportData: {\n type: ReportType\n reportId: string\n reportName: string\n description: string\n id: string\n name: string\n },\n requestFormData?: RequestFormData,\n ) {\n this.requestFormData = requestFormData || {}\n this.userStoreItem = this.addReportData(reportData)\n }\n\n build = () => {\n return this.userStoreItem as RequestedReport\n }\n\n addReportData = ({\n type,\n reportId,\n reportName,\n description,\n id,\n name,\n }: {\n type: ReportType\n reportId: string\n reportName: string\n description: string\n id: string\n name: string\n }) => {\n return {\n type: type as ReportType,\n reportId,\n reportName,\n description,\n id,\n name,\n timestamp: {},\n }\n }\n\n addExecutionData = (executionData: ExecutionData) => {\n this.userStoreItem = {\n ...(<UserReportData>this.userStoreItem),\n ...executionData,\n }\n return this\n }\n\n addChildExecutionData = (childExecutionData: Array<ChildReportExecutionData>) => {\n this.userStoreItem = {\n ...(<UserReportData>this.userStoreItem),\n childExecutionData,\n }\n return this\n }\n\n addFilters = (filterData?: Record<string, string>) => {\n const filtersQueryString = new URLSearchParams(filterData).toString()\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n filters: {\n data: filterData,\n queryString: filtersQueryString,\n },\n },\n }\n return this\n }\n\n addSortData = (sortData: Record<string, string>) => {\n const sortByQueryString = new URLSearchParams(sortData).toString()\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n sortBy: {\n data: sortData,\n queryString: sortByQueryString,\n },\n },\n }\n return this\n }\n\n addRequestUrls = (req: Request) => {\n const { origin, pathname, search, href } = this.requestFormData\n const { executionId } = this.userStoreItem\n\n // Polling path\n
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAqB,uBACrBC,EAQO,gCAKP,MAAMJ,CAAqB,CAKzB,YACEK,EAQAC,EACA,CAKF,WAAQ,IACC,KAAK,cAGd,mBAAgB,CAAC,CACf,KAAAC,EACA,SAAAC,EACA,WAAAC,EACA,YAAAC,EACA,GAAAC,EACA,KAAAC,CACF,KAQS,CACL,KAAML,EACN,SAAAC,EACA,WAAAC,EACA,YAAAC,EACA,GAAAC,EACA,KAAAC,EACA,UAAW,CAAC,CACd,GAGF,sBAAoBC,IAClB,KAAK,cAAgB,CACnB,GAAoB,KAAK,cACzB,GAAGA,CACL,EACO,MAGT,2BAAyBC,IACvB,KAAK,cAAgB,CACnB,GAAoB,KAAK,cACzB,mBAAAA,CACF,EACO,MAGT,gBAAcC,GAAwC,CACpD,MAAMC,EAAqB,IAAI,gBAAgBD,CAAU,EAAE,SAAS,EACpE,YAAK,cAAgB,CACnB,GAAG,KAAK,cAEN,QAAS,CACP,KAAMA,EACN,YAAaC,CACf,CAEJ,EACO,IACT,EAEA,iBAAeC,GAAqC,CAClD,MAAMC,EAAoB,IAAI,gBAAgBD,CAAQ,EAAE,SAAS,EACjE,YAAK,cAAgB,CACnB,GAAG,KAAK,cAEN,OAAQ,CACN,KAAMA,EACN,YAAaC,CACf,CAEJ,EACO,IACT,EAEA,oBAAkBC,GAAiB,CACjC,KAAM,CAAE,OAAAC,EAAQ,SAAAC,EAAU,OAAAC,EAAQ,KAAAC,CAAK,EAAI,KAAK,gBAC1C,CAAE,YAAAC,
|
|
6
|
-
"names": ["UserStoreItemBuilder_exports", "__export", "UserStoreItemBuilder", "UserStoreItemBuilder_default", "__toCommonJS", "import_parseurl", "import_UserReports", "reportData", "requestFormData", "type", "reportId", "reportName", "description", "id", "name", "executionData", "childExecutionData", "filterData", "filtersQueryString", "sortData", "sortByQueryString", "req", "origin", "pathname", "search", "href", "executionId", "pollingPath", "pollingFullUrl", "url", "fullUrl", "urlData", "parseUrl", "loadType", "queryData", "status", "metrics", "metric", "ts", "definitionsPath"
|
|
4
|
+
"sourcesContent": ["import type { Request } from 'express'\nimport parseUrl from 'parseurl'\nimport {\n AsyncReportUrlData,\n LoadType,\n ReportType,\n RequestedReport,\n RequestFormData,\n RequestStatus,\n UserReportData,\n} from '../types/UserReports'\nimport Dict = NodeJS.Dict\nimport { ChildReportExecutionData, ExecutionData } from '../types/ExecutionData'\nimport { DashboardSection } from '../components/_dashboards/dashboard/types'\n\nclass UserStoreItemBuilder {\n userStoreItem: UserReportData\n\n requestFormData: RequestFormData | Record<string, never>\n\n constructor(\n reportData: {\n type: ReportType\n reportId: string\n reportName: string\n description: string\n id: string\n name: string\n },\n requestFormData?: RequestFormData,\n ) {\n this.requestFormData = requestFormData || {}\n this.userStoreItem = this.addReportData(reportData)\n }\n\n build = () => {\n return this.userStoreItem as RequestedReport\n }\n\n addReportData = ({\n type,\n reportId,\n reportName,\n description,\n id,\n name,\n }: {\n type: ReportType\n reportId: string\n reportName: string\n description: string\n id: string\n name: string\n }) => {\n return {\n type: type as ReportType,\n reportId,\n reportName,\n description,\n id,\n name,\n timestamp: {},\n }\n }\n\n addExecutionData = (executionData: ExecutionData) => {\n this.userStoreItem = {\n ...(<UserReportData>this.userStoreItem),\n ...executionData,\n }\n return this\n }\n\n addChildExecutionData = (childExecutionData: Array<ChildReportExecutionData>) => {\n this.userStoreItem = {\n ...(<UserReportData>this.userStoreItem),\n childExecutionData,\n }\n return this\n }\n\n addFilters = (filterData?: Record<string, string>) => {\n const filtersQueryString = new URLSearchParams(filterData).toString()\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n filters: {\n data: filterData,\n queryString: filtersQueryString,\n },\n },\n }\n return this\n }\n\n addSortData = (sortData: Record<string, string>) => {\n const sortByQueryString = new URLSearchParams(sortData).toString()\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n sortBy: {\n data: sortData,\n queryString: sortByQueryString,\n },\n },\n }\n return this\n }\n\n addRequestUrls = (req: Request) => {\n const { origin, pathname, search, href } = this.requestFormData\n const { executionId, dataProductDefinitionsPath, dpdPathFromQuery } = this.userStoreItem\n\n // Polling path\n let pollingPath = req.baseUrl.replace('/filters', `/${executionId}/status`)\n if (dpdPathFromQuery) {\n pollingPath = `${pollingPath}?dataProductDefinitionsPath=${dataProductDefinitionsPath}`\n }\n const pollingFullUrl = `${origin}${pollingPath}`\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n url: {\n origin,\n request: {\n fullUrl: href,\n pathname,\n search,\n },\n polling: {\n fullUrl: pollingFullUrl,\n pathname: pollingPath,\n },\n },\n },\n }\n\n return this\n }\n\n addAsyncUrls = (url: AsyncReportUrlData) => {\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n url,\n },\n }\n\n return this\n }\n\n addReportUrls = (req: Request) => {\n const origin = req.get('host')\n const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`\n const urlData = parseUrl(req)\n\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n url: {\n origin: origin || this.userStoreItem.url?.origin || '',\n ...(this.userStoreItem.url?.request && { request: this.userStoreItem.url.request }),\n ...(this.userStoreItem.url?.polling && { polling: this.userStoreItem.url.polling }),\n report: {\n ...(this.userStoreItem.url?.report && this.userStoreItem.url.report),\n fullUrl,\n ...(urlData && urlData.search && { search: urlData.search }),\n },\n },\n },\n }\n\n return this\n }\n\n addLoadType = (loadType: LoadType) => {\n this.userStoreItem = {\n ...this.userStoreItem,\n loadType,\n }\n\n return this\n }\n\n addQuery = (queryData?: { query: Dict<string | string[]>; querySummary: Array<Dict<string>> }) => {\n this.userStoreItem = {\n ...this.userStoreItem,\n ...(queryData && {\n query: {\n data: queryData.query,\n summary: queryData.querySummary,\n },\n }),\n }\n return this\n }\n\n addInteractiveQuery = (queryData?: { query: Dict<string>; querySummary: Array<Dict<string>> }) => {\n if (queryData) {\n this.userStoreItem = {\n ...this.userStoreItem,\n ...{\n interactiveQuery: {\n data: queryData.query,\n summary: queryData.querySummary,\n },\n },\n }\n }\n return this\n }\n\n addStatus = (status: RequestStatus) => {\n this.userStoreItem = {\n ...this.userStoreItem,\n status,\n }\n return this\n }\n\n addMetrics = (metrics: DashboardSection[]) => {\n this.userStoreItem = {\n ...this.userStoreItem,\n metrics: metrics.filter((metric) => metric.display).map((metric) => ({ name: metric.display || '' })),\n }\n return this\n }\n\n addTimestamp = () => {\n const { status } = this.userStoreItem\n const ts = new Date()\n switch (status) {\n case RequestStatus.FAILED:\n this.userStoreItem.timestamp.failed = ts\n break\n case RequestStatus.EXPIRED:\n this.userStoreItem.timestamp.expired = ts\n break\n case RequestStatus.ABORTED:\n this.userStoreItem.timestamp.aborted = ts\n break\n case RequestStatus.FINISHED:\n this.userStoreItem.timestamp.completed = ts\n break\n case RequestStatus.SUBMITTED:\n this.userStoreItem.timestamp.requested = ts\n break\n case RequestStatus.STARTED:\n case RequestStatus.PICKED:\n break\n default:\n this.userStoreItem.timestamp.lastViewed = ts\n break\n }\n return this\n }\n\n addDefinitionsPath = (definitionsPath: string, dpdPathFromQuery: boolean) => {\n if (definitionsPath) {\n this.userStoreItem = {\n ...this.userStoreItem,\n dataProductDefinitionsPath: definitionsPath,\n dpdPathFromQuery,\n }\n }\n return this\n }\n}\n\nexport { UserStoreItemBuilder }\nexport default UserStoreItemBuilder\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,Y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AG,KAAK,cACR,QAASA,EAAQ,OAAQC,GAAWA,EAAO,OAAO,EAAE,IAAKA,IAAY,CAAE,KAAMA,EAAO,SAAW,EAAG,EAAE,CACtG,EACO,MAGT,kBAAe,IAAM,CACnB,KAAM,CAAE,OAAAF,CAAO,EAAI,KAAK,cAClBG,EAAK,IAAI,KACf,OAAQH,EAAQ,CACd,KAAK,gBAAc,OACjB,KAAK,cAAc,UAAU,OAASG,EACtC,MACF,KAAK,gBAAc,QACjB,KAAK,cAAc,UAAU,QAAUA,EACvC,MACF,KAAK,gBAAc,QACjB,KAAK,cAAc,UAAU,QAAUA,EACvC,MACF,KAAK,gBAAc,SACjB,KAAK,cAAc,UAAU,UAAYA,EACzC,MACF,KAAK,gBAAc,UACjB,KAAK,cAAc,UAAU,UAAYA,EACzC,MACF,KAAK,gBAAc,QACnB,KAAK,gBAAc,OACjB,MACF,QACE,KAAK,cAAc,UAAU,WAAaA,EAC1C,KACJ,CACA,OAAO,IACT,EAEA,wBAAqB,CAACC,EAAyBb,KACzCa,IACF,KAAK,cAAgB,CACnB,GAAG,KAAK,cACR,2BAA4BA,EAC5B,iBAAAb,CACF,GAEK,MA1OP,KAAK,gBAAkBpB,GAAmB,CAAC,EAC3C,KAAK,cAAgB,KAAK,cAAcD,CAAU,CACpD,CA0OF,CAGA,IAAOJ,EAAQD",
|
|
6
|
+
"names": ["UserStoreItemBuilder_exports", "__export", "UserStoreItemBuilder", "UserStoreItemBuilder_default", "__toCommonJS", "import_parseurl", "import_UserReports", "reportData", "requestFormData", "type", "reportId", "reportName", "description", "id", "name", "executionData", "childExecutionData", "filterData", "filtersQueryString", "sortData", "sortByQueryString", "req", "origin", "pathname", "search", "href", "executionId", "dataProductDefinitionsPath", "dpdPathFromQuery", "pollingPath", "pollingFullUrl", "url", "fullUrl", "urlData", "parseUrl", "loadType", "queryData", "status", "metrics", "metric", "ts", "definitionsPath"]
|
|
7
7
|
}
|
|
@@ -109,12 +109,14 @@ class UserStoreItemBuilder {
|
|
|
109
109
|
|
|
110
110
|
addRequestUrls = (req: Request) => {
|
|
111
111
|
const { origin, pathname, search, href } = this.requestFormData
|
|
112
|
-
const { executionId } = this.userStoreItem
|
|
112
|
+
const { executionId, dataProductDefinitionsPath, dpdPathFromQuery } = this.userStoreItem
|
|
113
113
|
|
|
114
114
|
// Polling path
|
|
115
|
-
|
|
115
|
+
let pollingPath = req.baseUrl.replace('/filters', `/${executionId}/status`)
|
|
116
|
+
if (dpdPathFromQuery) {
|
|
117
|
+
pollingPath = `${pollingPath}?dataProductDefinitionsPath=${dataProductDefinitionsPath}`
|
|
118
|
+
}
|
|
116
119
|
const pollingFullUrl = `${origin}${pollingPath}`
|
|
117
|
-
|
|
118
120
|
this.userStoreItem = {
|
|
119
121
|
...this.userStoreItem,
|
|
120
122
|
...{
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h=Object.create;var E=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var w=(e,t)=>{for(var r in t)E(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of b(t))!F.call(e,o)&&o!==r&&E(e,o,{get:()=>t[o],enumerable:!(u=v(t,o))||u.enumerable});return e};var l=(e,t,r)=>(r=e!=null?h(U(e)):{},A(t||!e||!e.__esModule?E(r,"default",{value:e,enumerable:!0}):r,e)),B=e=>A(E({},"__esModule",{value:!0}),e);var X={};w(X,{default:()=>N,getExpiredStatus:()=>M,getStatus:()=>x,shouldTimeoutRequest:()=>I});module.exports=B(X);var m=l(require("dayjs")),P=l(require("dayjs/plugin/customParseFormat")),s=require("../types/UserReports"),D=l(require("./logger")),g=l(require("./localsHelper"));m.default.extend(P.default);const L=[s.RequestStatus.ABORTED,s.RequestStatus.FAILED,s.RequestStatus.EXPIRED],O=[s.RequestStatus.SUBMITTED,s.RequestStatus.STARTED,s.RequestStatus.PICKED];function H(e){return Promise.all(e).then(t=>{const r=t.find(o=>typeof o.status=="number"||L.includes(o.status));if(r)return r;const u=t.find(o=>O.includes(o.status));return u||t[0]})}const T=async(e,t,r,u,o)=>{const{definitionsPath:R}=g.default.getValues(r),{type:d,reportId:c,executionId:a,id:i,tableId:n}=t.body,S=(await e.requestedReportService.getReportByExecutionId(a,o)).childExecutionData??[];d===s.ReportType.REPORT&&S.push({executionId:a,tableId:n,variantId:i});const q=S.map(f=>e.reportingService.getAsyncReportStatus(u,c,f.variantId,f.executionId,R,f.tableId));d===s.ReportType.DASHBOARD&&q.push(e.dashboardService.getAsyncStatus(u,c,i,a,R
|
|
1
|
+
var h=Object.create;var E=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var w=(e,t)=>{for(var r in t)E(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of b(t))!F.call(e,o)&&o!==r&&E(e,o,{get:()=>t[o],enumerable:!(u=v(t,o))||u.enumerable});return e};var l=(e,t,r)=>(r=e!=null?h(U(e)):{},A(t||!e||!e.__esModule?E(r,"default",{value:e,enumerable:!0}):r,e)),B=e=>A(E({},"__esModule",{value:!0}),e);var X={};w(X,{default:()=>N,getExpiredStatus:()=>M,getStatus:()=>x,shouldTimeoutRequest:()=>I});module.exports=B(X);var m=l(require("dayjs")),P=l(require("dayjs/plugin/customParseFormat")),s=require("../types/UserReports"),D=l(require("./logger")),g=l(require("./localsHelper"));m.default.extend(P.default);const L=[s.RequestStatus.ABORTED,s.RequestStatus.FAILED,s.RequestStatus.EXPIRED],O=[s.RequestStatus.SUBMITTED,s.RequestStatus.STARTED,s.RequestStatus.PICKED];function H(e){return Promise.all(e).then(t=>{const r=t.find(o=>typeof o.status=="number"||L.includes(o.status));if(r)return r;const u=t.find(o=>O.includes(o.status));return u||t[0]})}const T=async(e,t,r,u,o)=>{const{definitionsPath:R}=g.default.getValues(r),{type:d,reportId:c,executionId:a,id:i,tableId:n}=t.body,S=(await e.requestedReportService.getReportByExecutionId(a,o)).childExecutionData??[];d===s.ReportType.REPORT&&S.push({executionId:a,tableId:n,variantId:i});const q=S.map(f=>e.reportingService.getAsyncReportStatus(u,c,f.variantId,f.executionId,R,f.tableId));d===s.ReportType.DASHBOARD&&q.push(e.dashboardService.getAsyncStatus(u,c,i,a,n,R));const y=await H(q);return{status:y.status,statusResponse:y}},x=async({req:e,res:t,services:r})=>{const{token:u,dprUser:o}=g.default.getValues(t),{status:R,requestedAt:d}=e.body,c=[s.RequestStatus.READY,s.RequestStatus.EXPIRED,s.RequestStatus.FAILED];let a,i,n;try{if({status:a,statusResponse:n}=await T(r,e,t,u,o.id),I({requestedAt:d,compareTime:new Date,durationMins:15})&&!c.includes(a))throw new Error("Request taking too long. Request Halted");if(a===s.RequestStatus.FAILED){D.default.error(`Error: ${JSON.stringify(n.error)}`);const{userMessage:p,developerMessage:S}=n.error;p||S?i=n.error:i={developerMessage:n.error}}}catch(p){D.default.error(`Error: ${JSON.stringify(p)}`);const{data:S}=p;i=S||{userMessage:p.message},a=R===s.RequestStatus.FINISHED?s.RequestStatus.EXPIRED:s.RequestStatus.FAILED}return typeof a=="number"&&(a=s.RequestStatus.FAILED),{status:a,...i&&{errorMessage:i}}},M=async({req:e,res:t,services:r})=>{const{token:u,dprUser:o}=g.default.getValues(t),{executionId:R,status:d}=e.body;let c,a;try{({status:a}=await T(r,e,t,u,o.id))}catch(n){const{data:p}=n;c=(p??{}).userMessage,a=d===s.RequestStatus.READY||d===s.RequestStatus.FINISHED?s.RequestStatus.EXPIRED:s.RequestStatus.FAILED}return{isExpired:{status:a,...c&&{errorMessage:c}}.status===s.RequestStatus.EXPIRED,executionId:R}},I=({requestedAt:e,compareTime:t,durationMins:r})=>{const u=(0,m.default)(t),o=(0,m.default)(e);return u.diff(o,"minutes")>=r};var N={getStatus:x,getExpiredStatus:M,shouldTimeoutRequest:I};0&&(module.exports={getExpiredStatus,getStatus,shouldTimeoutRequest});
|
|
2
2
|
//# sourceMappingURL=requestStatusHelper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/dpr/utils/requestStatusHelper.ts"],
|
|
4
|
-
"sourcesContent": ["import dayjs from 'dayjs'\nimport customParse from 'dayjs/plugin/customParseFormat'\nimport { Request, Response } from 'express'\nimport { ReportType, RequestedReport, RequestStatus } from '../types/UserReports'\nimport { ChildReportExecutionData } from '../types/ExecutionData'\nimport logger from './logger'\nimport { Services } from '../types/Services'\nimport localsHelper from './localsHelper'\n\ndayjs.extend(customParse)\ninterface GetStatusUtilsResponse {\n status: RequestStatus\n errorMessage?: string\n reportData?: RequestedReport | undefined\n}\n\ninterface StatusResponseError {\n userMessage: string\n developerMessage: string\n}\n\ninterface StatusResponse {\n status: RequestStatus\n error: StatusResponseError\n}\n\nconst BAD_REQUEST_STATUSES: Array<RequestStatus> = [RequestStatus.ABORTED, RequestStatus.FAILED, RequestStatus.EXPIRED]\n\nconst IN_PROGRESS_REQUEST_STATUSES: Array<RequestStatus> = [\n RequestStatus.SUBMITTED,\n RequestStatus.STARTED,\n RequestStatus.PICKED,\n]\n\nfunction findWorstStatusResponse(statusRequests: Array<Promise<StatusResponse>>): Promise<StatusResponse> {\n return Promise.all(statusRequests).then((statusResponses) => {\n const badStatus = statusResponses.find(\n (response) =>\n typeof response.status === 'number' || BAD_REQUEST_STATUSES.includes(response.status as RequestStatus),\n )\n\n if (badStatus) {\n return badStatus\n }\n\n const inProgressStatus = statusResponses.find((response) =>\n IN_PROGRESS_REQUEST_STATUSES.includes(response.status as RequestStatus),\n )\n\n if (inProgressStatus) {\n return inProgressStatus\n }\n\n return statusResponses[0]\n })\n}\n\nconst getStatusByReportType = async (\n services: Services,\n req: Request,\n res: Response,\n token: string,\n userId: string,\n) => {\n const { definitionsPath } = localsHelper.getValues(res)\n const { type, reportId, executionId, id, tableId } = req.body\n\n const requestedReport = await services.requestedReportService.getReportByExecutionId(executionId, userId)\n\n const reports = requestedReport.childExecutionData ?? []\n\n if (type === ReportType.REPORT) {\n reports.push({ executionId, tableId, variantId: id })\n }\n\n const statusRequests = reports.map((executionData: ChildReportExecutionData) =>\n services.reportingService.getAsyncReportStatus(\n token,\n reportId,\n executionData.variantId,\n executionData.executionId,\n definitionsPath,\n executionData.tableId,\n ),\n )\n\n if (type === ReportType.DASHBOARD) {\n statusRequests.push(\n services.dashboardService.getAsyncStatus(token, reportId, id, executionId,
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,qBAAAC,EAAA,cAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAkB,oBAClBC,EAAwB,6CAExBC,EAA2D,gCAE3DC,EAAmB,uBAEnBC,EAAyB,6BAEzB,EAAAC,QAAM,OAAO,EAAAC,OAAW,EAiBxB,MAAMC,EAA6C,CAAC,gBAAc,QAAS,gBAAc,OAAQ,gBAAc,OAAO,EAEhHC,EAAqD,CACzD,gBAAc,UACd,gBAAc,QACd,gBAAc,MAChB,EAEA,SAASC,EAAwBC,EAAyE,CACxG,OAAO,QAAQ,IAAIA,CAAc,EAAE,KAAMC,GAAoB,CAC3D,MAAMC,EAAYD,EAAgB,KAC/BE,GACC,OAAOA,EAAS,QAAW,UAAYN,EAAqB,SAASM,EAAS,MAAuB,CACzG,EAEA,GAAID,EACF,OAAOA,EAGT,MAAME,EAAmBH,EAAgB,KAAME,GAC7CL,EAA6B,SAASK,EAAS,MAAuB,CACxE,EAEA,OAAIC,GAIGH,EAAgB,CAAC,CAC1B,CAAC,CACH,CAEA,MAAMI,EAAwB,MAC5BC,EACAC,EACAC,EACAC,EACAC,IACG,CACH,KAAM,CAAE,gBAAAC,CAAgB,EAAI,EAAAC,QAAa,UAAUJ,CAAG,EAChD,CAAE,KAAAK,EAAM,SAAAC,EAAU,YAAAC,EAAa,GAAAC,EAAI,QAAAC,CAAQ,EAAIV,EAAI,KAInDW,GAFkB,MAAMZ,EAAS,uBAAuB,uBAAuBS,EAAaL,CAAM,GAExE,oBAAsB,CAAC,EAEnDG,IAAS,aAAW,QACtBK,EAAQ,KAAK,CAAE,YAAAH,EAAa,QAAAE,EAAS,UAAWD,CAAG,CAAC,EAGtD,MAAMhB,EAAiBkB,EAAQ,IAAKC,GAClCb,EAAS,iBAAiB,qBACxBG,EACAK,EACAK,EAAc,UACdA,EAAc,YACdR,EACAQ,EAAc,OAChB,CACF,EAEIN,IAAS,aAAW,WACtBb,EAAe,KACbM,EAAS,iBAAiB,eAAeG,EAAOK,EAAUE,EAAID,
|
|
4
|
+
"sourcesContent": ["import dayjs from 'dayjs'\nimport customParse from 'dayjs/plugin/customParseFormat'\nimport { Request, Response } from 'express'\nimport { ReportType, RequestedReport, RequestStatus } from '../types/UserReports'\nimport { ChildReportExecutionData } from '../types/ExecutionData'\nimport logger from './logger'\nimport { Services } from '../types/Services'\nimport localsHelper from './localsHelper'\n\ndayjs.extend(customParse)\ninterface GetStatusUtilsResponse {\n status: RequestStatus\n errorMessage?: string\n reportData?: RequestedReport | undefined\n}\n\ninterface StatusResponseError {\n userMessage: string\n developerMessage: string\n}\n\ninterface StatusResponse {\n status: RequestStatus\n error: StatusResponseError\n}\n\nconst BAD_REQUEST_STATUSES: Array<RequestStatus> = [RequestStatus.ABORTED, RequestStatus.FAILED, RequestStatus.EXPIRED]\n\nconst IN_PROGRESS_REQUEST_STATUSES: Array<RequestStatus> = [\n RequestStatus.SUBMITTED,\n RequestStatus.STARTED,\n RequestStatus.PICKED,\n]\n\nfunction findWorstStatusResponse(statusRequests: Array<Promise<StatusResponse>>): Promise<StatusResponse> {\n return Promise.all(statusRequests).then((statusResponses) => {\n const badStatus = statusResponses.find(\n (response) =>\n typeof response.status === 'number' || BAD_REQUEST_STATUSES.includes(response.status as RequestStatus),\n )\n\n if (badStatus) {\n return badStatus\n }\n\n const inProgressStatus = statusResponses.find((response) =>\n IN_PROGRESS_REQUEST_STATUSES.includes(response.status as RequestStatus),\n )\n\n if (inProgressStatus) {\n return inProgressStatus\n }\n\n return statusResponses[0]\n })\n}\n\nconst getStatusByReportType = async (\n services: Services,\n req: Request,\n res: Response,\n token: string,\n userId: string,\n) => {\n const { definitionsPath } = localsHelper.getValues(res)\n const { type, reportId, executionId, id, tableId } = req.body\n\n const requestedReport = await services.requestedReportService.getReportByExecutionId(executionId, userId)\n\n const reports = requestedReport.childExecutionData ?? []\n\n if (type === ReportType.REPORT) {\n reports.push({ executionId, tableId, variantId: id })\n }\n\n const statusRequests = reports.map((executionData: ChildReportExecutionData) =>\n services.reportingService.getAsyncReportStatus(\n token,\n reportId,\n executionData.variantId,\n executionData.executionId,\n definitionsPath,\n executionData.tableId,\n ),\n )\n\n if (type === ReportType.DASHBOARD) {\n statusRequests.push(\n services.dashboardService.getAsyncStatus(token, reportId, id, executionId, tableId, definitionsPath),\n )\n }\n\n const statusResponse = await findWorstStatusResponse(statusRequests)\n\n return {\n status: statusResponse.status,\n statusResponse,\n }\n}\n\nexport const getStatus = async ({\n req,\n res,\n services,\n}: {\n req: Request\n res: Response\n services: Services\n}): Promise<GetStatusUtilsResponse> => {\n const { token, dprUser } = localsHelper.getValues(res)\n const { status: currentStatus, requestedAt } = req.body\n const timeoutExemptStatuses = [RequestStatus.READY, RequestStatus.EXPIRED, RequestStatus.FAILED]\n\n let status\n let errorMessage\n let statusResponse\n try {\n ;({ status, statusResponse } = await getStatusByReportType(services, req, res, token, dprUser.id))\n if (\n shouldTimeoutRequest({ requestedAt, compareTime: new Date(), durationMins: 15 }) &&\n !timeoutExemptStatuses.includes(status)\n ) {\n throw new Error('Request taking too long. Request Halted')\n }\n\n if (status === RequestStatus.FAILED) {\n logger.error(`Error: ${JSON.stringify(statusResponse.error)}`)\n const { userMessage, developerMessage } = statusResponse.error\n if (userMessage || developerMessage) {\n errorMessage = statusResponse.error\n } else {\n errorMessage = {\n developerMessage: statusResponse.error,\n }\n }\n }\n } catch (error) {\n logger.error(`Error: ${JSON.stringify(error)}`)\n const { data } = error\n errorMessage = data || { userMessage: error.message }\n status = currentStatus === RequestStatus.FINISHED ? RequestStatus.EXPIRED : RequestStatus.FAILED\n }\n\n if (typeof status === 'number') {\n status = RequestStatus.FAILED\n }\n\n return {\n status,\n ...(errorMessage && { errorMessage }),\n }\n}\n\n/**\n * Gets the expired status of a viewed report\n * - if reports status was READY/FINISHED\n * - And the new Status is an error status\n * - it means the report has expired\n *\n * @param {AsyncReportUtilsParams} { req, res, services }\n * @return {*}\n */\nexport const getExpiredStatus = async ({ req, res, services }: { req: Request; res: Response; services: Services }) => {\n const { token, dprUser } = localsHelper.getValues(res)\n const { executionId, status: currentStatus } = req.body\n\n let errorMessage\n let status\n try {\n ;({ status } = await getStatusByReportType(services, req, res, token, dprUser.id))\n } catch (error) {\n const { data } = error\n errorMessage = (data ?? {}).userMessage\n status =\n currentStatus === RequestStatus.READY || currentStatus === RequestStatus.FINISHED\n ? RequestStatus.EXPIRED\n : RequestStatus.FAILED\n }\n\n const result: GetStatusUtilsResponse = {\n status,\n ...(errorMessage && { errorMessage }),\n }\n\n return {\n isExpired: result.status === RequestStatus.EXPIRED,\n executionId,\n }\n}\n\nexport const shouldTimeoutRequest = ({\n requestedAt,\n compareTime,\n durationMins,\n}: {\n requestedAt: Date\n compareTime: Date\n durationMins: number\n}) => {\n const compareDate = dayjs(compareTime)\n const requestDate = dayjs(requestedAt)\n\n const result = compareDate.diff(requestDate, 'minutes')\n\n return result >= durationMins\n}\n\nexport default {\n getStatus,\n getExpiredStatus,\n shouldTimeoutRequest,\n}\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,qBAAAC,EAAA,cAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAkB,oBAClBC,EAAwB,6CAExBC,EAA2D,gC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F,CAAS,IAA2D,CACrH,KAAM,CAAE,MAAAG,EAAO,QAAAY,CAAQ,EAAI,EAAAT,QAAa,UAAUJ,CAAG,EAC/C,CAAE,YAAAO,EAAa,OAAQO,CAAc,EAAIf,EAAI,KAEnD,IAAImB,EACAD,EACJ,GAAI,EACA,CAAE,OAAAA,CAAO,EAAI,MAAMpB,EAAsBC,EAAUC,EAAKC,EAAKC,EAAOY,EAAQ,EAAE,EAClF,OAASS,EAAO,CACd,KAAM,CAAE,KAAAC,CAAK,EAAID,EACjBJ,GAAgBK,GAAQ,CAAC,GAAG,YAC5BN,EACEH,IAAkB,gBAAc,OAASA,IAAkB,gBAAc,SACrE,gBAAc,QACd,gBAAc,MACtB,CAOA,MAAO,CACL,UANqC,CACrC,OAAAG,EACA,GAAIC,GAAgB,CAAE,aAAAA,CAAa,CACrC,EAGoB,SAAW,gBAAc,QAC3C,YAAAX,CACF,CACF,EAEa3B,EAAuB,CAAC,CACnC,YAAAmC,EACA,YAAAS,EACA,aAAAC,CACF,IAIM,CACJ,MAAMC,KAAc,EAAAvC,SAAMqC,CAAW,EAC/BG,KAAc,EAAAxC,SAAM4B,CAAW,EAIrC,OAFeW,EAAY,KAAKC,EAAa,SAAS,GAErCF,CACnB,EAEA,IAAOhD,EAAQ,CACb,UAAAE,EACA,iBAAAD,EACA,qBAAAE,CACF",
|
|
6
6
|
"names": ["requestStatusHelper_exports", "__export", "requestStatusHelper_default", "getExpiredStatus", "getStatus", "shouldTimeoutRequest", "__toCommonJS", "import_dayjs", "import_customParseFormat", "import_UserReports", "import_logger", "import_localsHelper", "dayjs", "customParse", "BAD_REQUEST_STATUSES", "IN_PROGRESS_REQUEST_STATUSES", "findWorstStatusResponse", "statusRequests", "statusResponses", "badStatus", "response", "inProgressStatus", "getStatusByReportType", "services", "req", "res", "token", "userId", "definitionsPath", "localsHelper", "type", "reportId", "executionId", "id", "tableId", "reports", "executionData", "statusResponse", "dprUser", "currentStatus", "requestedAt", "timeoutExemptStatuses", "status", "errorMessage", "logger", "userMessage", "developerMessage", "error", "data", "compareTime", "durationMins", "compareDate", "requestDate"]
|
|
7
7
|
}
|
|
@@ -86,7 +86,7 @@ const getStatusByReportType = async (
|
|
|
86
86
|
|
|
87
87
|
if (type === ReportType.DASHBOARD) {
|
|
88
88
|
statusRequests.push(
|
|
89
|
-
services.dashboardService.getAsyncStatus(token, reportId, id, executionId,
|
|
89
|
+
services.dashboardService.getAsyncStatus(token, reportId, id, executionId, tableId, definitionsPath),
|
|
90
90
|
)
|
|
91
91
|
}
|
|
92
92
|
|