@cubejs-client/core 0.33.47 → 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 +5 -1
- package/package.json +2 -2
- package/src/index.js +42 -15
package/index.d.ts
CHANGED
|
@@ -96,9 +96,13 @@ declare module '@cubejs-client/core' {
|
|
|
96
96
|
*/
|
|
97
97
|
subscribe?: boolean;
|
|
98
98
|
/**
|
|
99
|
-
* A Cube
|
|
99
|
+
* A Cube API instance. If not provided will be taken from `CubeProvider`
|
|
100
100
|
*/
|
|
101
101
|
cubejsApi?: CubejsApi;
|
|
102
|
+
/**
|
|
103
|
+
* If enabled, all members of the 'number' type will be automatically converted to numerical values on the client side
|
|
104
|
+
*/
|
|
105
|
+
castNumerics?: boolean;
|
|
102
106
|
/**
|
|
103
107
|
* Function that receives `ProgressResult` on each `Continue wait` message.
|
|
104
108
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubejs-client/core",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.55",
|
|
4
4
|
"engines": {},
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"eslint-plugin-node": "^5.2.1",
|
|
46
46
|
"jest": "^26.0.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "7cb9ace521ab59474e54e4f7cbfb98acb91c9008"
|
|
49
49
|
}
|
package/src/index.js
CHANGED
|
@@ -257,24 +257,51 @@ class CubejsApi {
|
|
|
257
257
|
* @returns ResultSet
|
|
258
258
|
* @private
|
|
259
259
|
*/
|
|
260
|
-
loadResponseInternal(response) {
|
|
260
|
+
loadResponseInternal(response, options = {}) {
|
|
261
261
|
if (
|
|
262
|
-
response.results.length
|
|
263
|
-
response.results[0].query.responseFormat &&
|
|
264
|
-
response.results[0].query.responseFormat === ResultType.COMPACT
|
|
262
|
+
response.results.length
|
|
265
263
|
) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
264
|
+
if (options.castNumerics) {
|
|
265
|
+
response.results.forEach((result) => {
|
|
266
|
+
const numericMembers = Object.entries({
|
|
267
|
+
...result.annotation.measures,
|
|
268
|
+
...result.annotation.dimensions,
|
|
269
|
+
}).map(([k, v]) => {
|
|
270
|
+
if (v.type === 'number') {
|
|
271
|
+
return k;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return undefined;
|
|
275
|
+
}).filter(Boolean);
|
|
276
|
+
|
|
277
|
+
result.data = result.data.map((row) => {
|
|
278
|
+
numericMembers.forEach((key) => {
|
|
279
|
+
if (row[key] != null) {
|
|
280
|
+
row[key] = Number(row[key]);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return row;
|
|
272
285
|
});
|
|
273
|
-
data.push(row);
|
|
274
286
|
});
|
|
275
|
-
|
|
276
|
-
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (response.results[0].query.responseFormat &&
|
|
290
|
+
response.results[0].query.responseFormat === ResultType.COMPACT) {
|
|
291
|
+
response.results.forEach((result, j) => {
|
|
292
|
+
const data = [];
|
|
293
|
+
result.data.dataset.forEach((r) => {
|
|
294
|
+
const row = {};
|
|
295
|
+
result.data.members.forEach((m, i) => {
|
|
296
|
+
row[m] = r[i];
|
|
297
|
+
});
|
|
298
|
+
data.push(row);
|
|
299
|
+
});
|
|
300
|
+
response.results[j].data = data;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
277
303
|
}
|
|
304
|
+
|
|
278
305
|
return new ResultSet(response, {
|
|
279
306
|
parseDateMeasures: this.parseDateMeasures
|
|
280
307
|
});
|
|
@@ -293,7 +320,7 @@ class CubejsApi {
|
|
|
293
320
|
query,
|
|
294
321
|
queryType: 'multi',
|
|
295
322
|
}),
|
|
296
|
-
this.loadResponseInternal
|
|
323
|
+
(response) => this.loadResponseInternal(response, options),
|
|
297
324
|
options,
|
|
298
325
|
callback
|
|
299
326
|
);
|
|
@@ -312,7 +339,7 @@ class CubejsApi {
|
|
|
312
339
|
query,
|
|
313
340
|
queryType: 'multi',
|
|
314
341
|
}),
|
|
315
|
-
this.loadResponseInternal
|
|
342
|
+
(response) => this.loadResponseInternal(response, options),
|
|
316
343
|
{ ...options, subscribe: true },
|
|
317
344
|
callback
|
|
318
345
|
);
|