@cubejs-backend/api-gateway
Advanced tools
Comparing version 0.0.20 to 0.0.26
23
index.js
const jwt = require('jsonwebtoken'); | ||
const R = require('ramda'); | ||
const Joi = require('joi'); | ||
const moment = require('moment'); | ||
@@ -60,8 +61,17 @@ class UserError extends Error {} | ||
const transformValue = (value) => value && value.value ? value.value : value; // TODO move to sql adapter | ||
const transformValue = (value, type) => { | ||
if (value && type === 'time') { | ||
return moment(value).format(moment.HTML5_FMT.DATETIME_LOCAL_MS); | ||
} | ||
return value && value.value ? value.value : value // TODO move to sql adapter | ||
}; | ||
const transformData = (aliasToMemberNameMap, data) => { | ||
const transformData = (aliasToMemberNameMap, annotation, data) => { | ||
return data.map(r => R.pipe( | ||
R.toPairs, | ||
R.map(p => [aliasToMemberNameMap[p[0]], transformValue(p[1])]), | ||
R.map(p => [ | ||
aliasToMemberNameMap[p[0]], | ||
transformValue(p[1], annotation[aliasToMemberNameMap[p[0]]].type) | ||
]), | ||
R.fromPairs | ||
@@ -206,5 +216,10 @@ )(r)); | ||
}); | ||
const flattenAnnotation = { | ||
...annotation.measures, | ||
...annotation.dimensions, | ||
...annotation.timeDimensions | ||
}; | ||
res.json({ | ||
query: normalizedQuery, | ||
data: transformData(aliasToMemberNameMap, response.data), | ||
data: transformData(aliasToMemberNameMap, flattenAnnotation, response.data), | ||
annotation | ||
@@ -211,0 +226,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"author": "Statsbot, Inc.", | ||
"version": "0.0.20", | ||
"version": "0.0.26", | ||
"engines": { | ||
@@ -17,2 +17,3 @@ "node": ">=8.11.1" | ||
"jsonwebtoken": "^8.3.0", | ||
"moment": "^2.24.0", | ||
"ramda": "^0.25.0" | ||
@@ -19,0 +20,0 @@ }, |
Sorry, the diff of this file is not supported yet
66809
273
4
+ Addedmoment@^2.24.0
+ Addedmoment@2.30.1(transitive)