@cubejs-client/core 0.33.44 → 0.33.55
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/dist/cubejs-client-core.esm.js +37 -13
- package/dist/cubejs-client-core.esm.js.map +1 -1
- package/dist/cubejs-client-core.js +49 -18
- package/dist/cubejs-client-core.js.map +1 -1
- package/dist/cubejs-client-core.umd.js +382 -356
- package/dist/cubejs-client-core.umd.js.map +1 -1
- package/index.d.ts +8 -4
- package/package.json +2 -2
- package/src/index.js +42 -15
|
@@ -1498,19 +1498,43 @@ class CubejsApi {
|
|
|
1498
1498
|
*/
|
|
1499
1499
|
|
|
1500
1500
|
|
|
1501
|
-
loadResponseInternal(response) {
|
|
1502
|
-
if (response.results.length
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1501
|
+
loadResponseInternal(response, options = {}) {
|
|
1502
|
+
if (response.results.length) {
|
|
1503
|
+
if (options.castNumerics) {
|
|
1504
|
+
response.results.forEach(result => {
|
|
1505
|
+
const numericMembers = Object.entries({ ...result.annotation.measures,
|
|
1506
|
+
...result.annotation.dimensions
|
|
1507
|
+
}).map(([k, v]) => {
|
|
1508
|
+
if (v.type === 'number') {
|
|
1509
|
+
return k;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
return undefined;
|
|
1513
|
+
}).filter(Boolean);
|
|
1514
|
+
result.data = result.data.map(row => {
|
|
1515
|
+
numericMembers.forEach(key => {
|
|
1516
|
+
if (row[key] != null) {
|
|
1517
|
+
row[key] = Number(row[key]);
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
return row;
|
|
1509
1521
|
});
|
|
1510
|
-
data.push(row);
|
|
1511
1522
|
});
|
|
1512
|
-
|
|
1513
|
-
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
if (response.results[0].query.responseFormat && response.results[0].query.responseFormat === ResultType.COMPACT) {
|
|
1526
|
+
response.results.forEach((result, j) => {
|
|
1527
|
+
const data = [];
|
|
1528
|
+
result.data.dataset.forEach(r => {
|
|
1529
|
+
const row = {};
|
|
1530
|
+
result.data.members.forEach((m, i) => {
|
|
1531
|
+
row[m] = r[i];
|
|
1532
|
+
});
|
|
1533
|
+
data.push(row);
|
|
1534
|
+
});
|
|
1535
|
+
response.results[j].data = data;
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1514
1538
|
}
|
|
1515
1539
|
|
|
1516
1540
|
return new ResultSet(response, {
|
|
@@ -1530,7 +1554,7 @@ class CubejsApi {
|
|
|
1530
1554
|
return this.loadMethod(() => this.request('load', {
|
|
1531
1555
|
query,
|
|
1532
1556
|
queryType: 'multi'
|
|
1533
|
-
}), this.loadResponseInternal
|
|
1557
|
+
}), response => this.loadResponseInternal(response, options), options, callback);
|
|
1534
1558
|
}
|
|
1535
1559
|
|
|
1536
1560
|
subscribe(query, options, callback, responseFormat = ResultType.DEFAULT) {
|
|
@@ -1545,7 +1569,7 @@ class CubejsApi {
|
|
|
1545
1569
|
return this.loadMethod(() => this.request('subscribe', {
|
|
1546
1570
|
query,
|
|
1547
1571
|
queryType: 'multi'
|
|
1548
|
-
}), this.loadResponseInternal
|
|
1572
|
+
}), response => this.loadResponseInternal(response, options), { ...options,
|
|
1549
1573
|
subscribe: true
|
|
1550
1574
|
}, callback);
|
|
1551
1575
|
}
|