@isoftdata/utility-dashboard-backend 1.2.2 → 1.4.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/formatter-templates.json +6 -0
- package/index.js +8 -7
- package/package.json +19 -19
package/formatter-templates.json
CHANGED
package/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const handleChartTypeSpecificQuirks = (chartType, resultSet) => {
|
|
|
31
31
|
return resultSet
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const loadChartData = async(mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, parameters, ...theRest }) => { // needs database connection
|
|
34
|
+
const loadChartData = async (mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, parameters, ...theRest }) => { // needs database connection
|
|
35
35
|
const dataTable = await loadDataTable(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper.chartType })
|
|
36
36
|
|
|
37
37
|
const proccessedFormatting = handleFormattingTemplates(formatting)
|
|
@@ -58,7 +58,7 @@ const loadChartData = async(mysqlConnection, { name, query: queryObject, formatt
|
|
|
58
58
|
* Otherwise, it will return data in the google chart Datatable object literal format.
|
|
59
59
|
* multiSeries, formatting properties should be deconstructed from the chart object, chartType should be deconstructed from the chart's chartWrapper property
|
|
60
60
|
*/
|
|
61
|
-
const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
|
|
61
|
+
const loadDataTable = async (mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
|
|
62
62
|
let { results: queryResultSet, fields } = (queryObject && queryObject.sql) ? await queryWithFields(mysqlConnection, queryObject) : { fields: [], results: [] }
|
|
63
63
|
let data = handleChartTypeSpecificQuirks(chartType, queryResultSet)
|
|
64
64
|
|
|
@@ -86,7 +86,7 @@ const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries,
|
|
|
86
86
|
return dataTable
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const loadOptionList = async(mysqlConnection, optionListQuery, optionList = []) => {
|
|
89
|
+
const loadOptionList = async (mysqlConnection, optionListQuery, optionList = []) => {
|
|
90
90
|
return [
|
|
91
91
|
...optionList,
|
|
92
92
|
// ...(optionListQuery && await query(mysqlConnection, optionListQuery)) || [],
|
|
@@ -95,7 +95,7 @@ const loadOptionList = async(mysqlConnection, optionListQuery, optionList = [])
|
|
|
95
95
|
]
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
const loadOutputParameterValues = async(mysqlConnection, { definitionList, selectionList = [], forClient = false }) => {
|
|
98
|
+
const loadOutputParameterValues = async (mysqlConnection, { definitionList, selectionList = [], forClient = false }) => {
|
|
99
99
|
let parameterValues = []
|
|
100
100
|
|
|
101
101
|
for (const definition of definitionList) {
|
|
@@ -156,7 +156,7 @@ const parameterizeQuery = (query, parameterValues) => {
|
|
|
156
156
|
//Then include a capture group to get the inner part of that to use as a key
|
|
157
157
|
const regexp = /\${([^}]+)}/g
|
|
158
158
|
|
|
159
|
-
const queryParameterKeys = [
|
|
159
|
+
const queryParameterKeys = [...query.matchAll(regexp)].map(([fullToken, insideToken]) => insideToken.trim())
|
|
160
160
|
//if they put a token in the query that isn't one of the defined parameters of the report, just return null?
|
|
161
161
|
const queryParameters = queryParameterKeys.map(key => queryParameterValues[key] || null)
|
|
162
162
|
|
|
@@ -167,7 +167,7 @@ const parameterizeQuery = (query, parameterValues) => {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
module.exports = {
|
|
170
|
-
formatReportMetadata: async(mysqlConnection, { report, chartsInReport }) => {
|
|
170
|
+
formatReportMetadata: async (mysqlConnection, { report, chartsInReport }) => {
|
|
171
171
|
try {
|
|
172
172
|
const parameterValues = await loadOutputParameterValues(mysqlConnection, { definitionList: report.parameters, forClient: true })
|
|
173
173
|
|
|
@@ -184,7 +184,7 @@ module.exports = {
|
|
|
184
184
|
throw err
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
|
-
formatChartDataForReport: async(mysqlConnection, { reportParameters, chart, reportChart, parameterSelectionList }) => {
|
|
187
|
+
formatChartDataForReport: async (mysqlConnection, { reportParameters, chart, reportChart, parameterSelectionList }) => {
|
|
188
188
|
try {
|
|
189
189
|
const parameterValues = await loadOutputParameterValues(mysqlConnection, { definitionList: reportParameters, selectionList: parameterSelectionList })
|
|
190
190
|
if (reportChart?.jsonOverride?.chartWrapper?.dataTable) {
|
|
@@ -204,4 +204,5 @@ module.exports = {
|
|
|
204
204
|
},
|
|
205
205
|
loadOutputParameterValues,
|
|
206
206
|
loadDataTable,
|
|
207
|
+
parameterizeQuery,
|
|
207
208
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@isoftdata/utility-dashboard-backend",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A utility for formatting chart and report data to be usable by the frontend dashboard component.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"author": "Charles Kaup",
|
|
10
|
-
"license": "ISC",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@isoftdata/utility-date-time": "^2.0.3",
|
|
13
|
-
"@isoftdata/utility-db": "^1.4.0",
|
|
14
|
-
"date-fns": "^2.23.0",
|
|
15
|
-
"klona": "^1.1.2",
|
|
16
|
-
"mysql": "^2.18.1",
|
|
17
|
-
"to-snake-case": "^1.0.0"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@isoftdata/utility-dashboard-backend",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "A utility for formatting chart and report data to be usable by the frontend dashboard component.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "Charles Kaup",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@isoftdata/utility-date-time": "^2.0.3",
|
|
13
|
+
"@isoftdata/utility-db": "^1.4.0",
|
|
14
|
+
"date-fns": "^2.23.0",
|
|
15
|
+
"klona": "^1.1.2",
|
|
16
|
+
"mysql": "^2.18.1",
|
|
17
|
+
"to-snake-case": "^1.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|