@isoftdata/utility-dashboard-backend 2.0.0 → 2.0.1
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/package.json +2 -1
- package/style-templates.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoftdata/utility-dashboard-backend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A utility for formatting chart and report data to be usable by the frontend dashboard component.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"klona": "^1.1.2",
|
|
18
18
|
"mathjs": "^11.5.0",
|
|
19
19
|
"mysql": "^2.18.1",
|
|
20
|
+
"snakecase-keys": "^5.4.4",
|
|
20
21
|
"snakeize": "^0.1.0",
|
|
21
22
|
"to-snake-case": "^1.0.0"
|
|
22
23
|
}
|
package/style-templates.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
const mathjs = require('mathjs')
|
|
3
|
-
const
|
|
3
|
+
const snakecaseKeys = require('snakecase-keys')
|
|
4
4
|
|
|
5
5
|
function handleMathJsCellStyleTemplate(row, columnToStyle, templates) {
|
|
6
6
|
let outColumn = { value: row[columnToStyle] }
|
|
7
7
|
if (columnToStyle in templates) {
|
|
8
8
|
// MathJS mutates the object you pass it, and we need to ensure keys are single "word" strings, so snakeize a copy of the row
|
|
9
|
-
const scope =
|
|
9
|
+
const scope = snakecaseKeys({ ...row }, { deep: true })
|
|
10
10
|
for (const key in templates[columnToStyle]) {
|
|
11
11
|
try {
|
|
12
12
|
outColumn[key] = mathjs.evaluate(templates[columnToStyle][key], scope)
|