@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
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
|
*/
|
|
@@ -1068,7 +1072,7 @@ declare module '@cubejs-client/core' {
|
|
|
1068
1072
|
* const context = document.getElementById('myChart');
|
|
1069
1073
|
* new Chart(context, chartjsConfig(resultSet));
|
|
1070
1074
|
* ```
|
|
1071
|
-
* @param query - [Query object](query-format)
|
|
1075
|
+
* @param query - [Query object](/product/apis-integrations/rest-api/query-format)
|
|
1072
1076
|
*/
|
|
1073
1077
|
load<QueryType extends DeeplyReadonly<Query | Query[]>>(
|
|
1074
1078
|
query: QueryType,
|
|
@@ -1084,7 +1088,7 @@ declare module '@cubejs-client/core' {
|
|
|
1084
1088
|
): Promise<ResultSet<QueryRecordType<QueryType>>>;
|
|
1085
1089
|
|
|
1086
1090
|
/**
|
|
1087
|
-
* Allows you to fetch data and receive updates over time. See [Real-Time Data Fetch](real-time-data-fetch)
|
|
1091
|
+
* Allows you to fetch data and receive updates over time. See [Real-Time Data Fetch](/product/apis-integrations/rest-api/real-time-data-fetch)
|
|
1088
1092
|
*
|
|
1089
1093
|
* ```js
|
|
1090
1094
|
* // Subscribe to a query's updates
|
|
@@ -1158,7 +1162,7 @@ declare module '@cubejs-client/core' {
|
|
|
1158
1162
|
* );
|
|
1159
1163
|
* ```
|
|
1160
1164
|
*
|
|
1161
|
-
* @param apiToken - [API token](
|
|
1165
|
+
* @param apiToken - [API token](/product/auth) is used to authorize requests and determine SQL database you're accessing. In the development mode, Cube.js Backend will print the API token to the console on startup. In case of async function `authorization` is updated for `options.transport` on each request.
|
|
1162
1166
|
* @order 1
|
|
1163
1167
|
*/
|
|
1164
1168
|
export default function cubejs(apiToken: string | (() => Promise<string>), options: CubeJSApiOptions): CubejsApi;
|
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
|
);
|