@cubejs-client/core 0.34.60 → 0.35.23

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/index.d.ts CHANGED
@@ -66,7 +66,7 @@ declare module '@cubejs-client/core' {
66
66
  public request(method: string, params: any): ITransportResponse<ResultSet>;
67
67
  }
68
68
 
69
- export type CubeJSApiOptions = {
69
+ export type CubeApiOptions = {
70
70
  /**
71
71
  * URL of your Cube.js Backend. By default, in the development environment it is `http://localhost:4000/cubejs-api/v1`
72
72
  */
@@ -80,6 +80,7 @@ declare module '@cubejs-client/core' {
80
80
  credentials?: 'omit' | 'same-origin' | 'include';
81
81
  parseDateMeasures?: boolean;
82
82
  resType?: 'default' | 'compact';
83
+ castNumerics?: boolean;
83
84
  };
84
85
 
85
86
  export type LoadMethodOptions = {
@@ -98,7 +99,7 @@ declare module '@cubejs-client/core' {
98
99
  /**
99
100
  * A Cube API instance. If not provided will be taken from `CubeProvider`
100
101
  */
101
- cubejsApi?: CubejsApi;
102
+ cubeApi?: CubeApi;
102
103
  /**
103
104
  * If enabled, all members of the 'number' type will be automatically converted to numerical values on the client side
104
105
  */
@@ -324,7 +325,7 @@ declare module '@cubejs-client/core' {
324
325
  * ```js
325
326
  * import { ResultSet } from '@cubejs-client/core';
326
327
  *
327
- * const resultSet = await cubejsApi.load(query);
328
+ * const resultSet = await cubeApi.load(query);
328
329
  * // You can store the result somewhere
329
330
  * const tmp = resultSet.serialize();
330
331
  *
@@ -1072,11 +1073,11 @@ declare module '@cubejs-client/core' {
1072
1073
  }
1073
1074
 
1074
1075
  /**
1075
- * Main class for accessing Cube.js API
1076
+ * Main class for accessing Cube API
1076
1077
  *
1077
1078
  * @order 2
1078
1079
  */
1079
- export class CubejsApi {
1080
+ export class CubeApi {
1080
1081
  load<QueryType extends DeeplyReadonly<Query | Query[]>>(
1081
1082
  query: QueryType,
1082
1083
  options?: LoadMethodOptions,
@@ -1085,13 +1086,13 @@ declare module '@cubejs-client/core' {
1085
1086
  * Fetch data for the passed `query`.
1086
1087
  *
1087
1088
  * ```js
1088
- * import cubejs from '@cubejs-client/core';
1089
+ * import cube from '@cubejs-client/core';
1089
1090
  * import Chart from 'chart.js';
1090
1091
  * import chartjsConfig from './toChartjsData';
1091
1092
  *
1092
- * const cubejsApi = cubejs('CUBEJS_TOKEN');
1093
+ * const cubeApi = cube('CUBEJS_TOKEN');
1093
1094
  *
1094
- * const resultSet = await cubejsApi.load({
1095
+ * const resultSet = await cubeApi.load({
1095
1096
  * measures: ['Stories.count'],
1096
1097
  * timeDimensions: [{
1097
1098
  * dimension: 'Stories.time',
@@ -1123,7 +1124,7 @@ declare module '@cubejs-client/core' {
1123
1124
  *
1124
1125
  * ```js
1125
1126
  * // Subscribe to a query's updates
1126
- * const subscription = await cubejsApi.subscribe(
1127
+ * const subscription = await cubeApi.subscribe(
1127
1128
  * {
1128
1129
  * measures: ['Logs.count'],
1129
1130
  * timeDimensions: [
@@ -1173,12 +1174,12 @@ declare module '@cubejs-client/core' {
1173
1174
  }
1174
1175
 
1175
1176
  /**
1176
- * Creates an instance of the `CubejsApi`. The API entry point.
1177
+ * Creates an instance of the `CubeApi`. The API entry point.
1177
1178
  *
1178
1179
  * ```js
1179
- * import cubejs from '@cubejs-client/core';
1180
- * const cubejsApi = cubejs(
1181
- * 'CUBEJS-API-TOKEN',
1180
+ * import cube from '@cubejs-client/core';
1181
+ * const cubeApi = cube(
1182
+ * 'CUBE-API-TOKEN',
1182
1183
  * { apiUrl: 'http://localhost:4000/cubejs-api/v1' }
1183
1184
  * );
1184
1185
  * ```
@@ -1186,8 +1187,8 @@ declare module '@cubejs-client/core' {
1186
1187
  * You can also pass an async function or a promise that will resolve to the API token
1187
1188
  *
1188
1189
  * ```js
1189
- * import cubejs from '@cubejs-client/core';
1190
- * const cubejsApi = cubejs(
1190
+ * import cube from '@cubejs-client/core';
1191
+ * const cubeApi = cube(
1191
1192
  * async () => await Auth.getJwtToken(),
1192
1193
  * { apiUrl: 'http://localhost:4000/cubejs-api/v1' }
1193
1194
  * );
@@ -1196,8 +1197,8 @@ declare module '@cubejs-client/core' {
1196
1197
  * @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.
1197
1198
  * @order 1
1198
1199
  */
1199
- export default function cubejs(apiToken: string | (() => Promise<string>), options: CubeJSApiOptions): CubejsApi;
1200
- export default function cubejs(options: CubeJSApiOptions): CubejsApi;
1200
+ export default function cube(apiToken: string | (() => Promise<string>), options: CubeApiOptions): CubeApi;
1201
+ export default function cube(options: CubeApiOptions): CubeApi;
1201
1202
 
1202
1203
  /**
1203
1204
  * @hidden
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-client/core",
3
- "version": "0.34.60",
3
+ "version": "0.35.23",
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": "^27"
47
47
  },
48
- "gitHead": "7434929be3e99eb1d1fbb8a6b6c7f2427c6fcae6"
48
+ "gitHead": "50ddcfc277feb55a8781129e7b3a5579e00ea334"
49
49
  }
package/src/index.js CHANGED
@@ -30,7 +30,7 @@ function mutexPromise(promise) {
30
30
  });
31
31
  }
32
32
 
33
- class CubejsApi {
33
+ class CubeApi {
34
34
  constructor(apiToken, options) {
35
35
  if (apiToken !== null && !Array.isArray(apiToken) && typeof apiToken === 'object') {
36
36
  options = apiToken;
@@ -56,6 +56,7 @@ class CubejsApi {
56
56
  });
57
57
  this.pollInterval = options.pollInterval || 5;
58
58
  this.parseDateMeasures = options.parseDateMeasures;
59
+ this.castNumerics = typeof options.castNumerics === 'boolean' ? options.castNumerics : false;
59
60
 
60
61
  this.updateAuthorizationPromise = null;
61
62
  }
@@ -308,6 +309,11 @@ class CubejsApi {
308
309
  }
309
310
 
310
311
  load(query, options, callback, responseFormat = ResultType.DEFAULT) {
312
+ options = {
313
+ castNumerics: this.castNumerics,
314
+ ...options
315
+ };
316
+
311
317
  if (responseFormat === ResultType.COMPACT) {
312
318
  if (Array.isArray(query)) {
313
319
  query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));
@@ -327,6 +333,11 @@ class CubejsApi {
327
333
  }
328
334
 
329
335
  subscribe(query, options, callback, responseFormat = ResultType.DEFAULT) {
336
+ options = {
337
+ castNumerics: this.castNumerics,
338
+ ...options
339
+ };
340
+
330
341
  if (responseFormat === ResultType.COMPACT) {
331
342
  if (Array.isArray(query)) {
332
343
  query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));
@@ -373,7 +384,7 @@ class CubejsApi {
373
384
  }
374
385
  }
375
386
 
376
- export default (apiToken, options) => new CubejsApi(apiToken, options);
387
+ export default (apiToken, options) => new CubeApi(apiToken, options);
377
388
 
378
- export { CubejsApi, CubejsApi as CubeApi, HttpTransport, ResultSet, RequestError, Meta };
389
+ export { CubeApi, HttpTransport, ResultSet, RequestError, Meta };
379
390
  export * from './utils';
package/src/index.test.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @license Apache-2.0
3
3
  * @copyright Cube Dev, Inc.
4
- * @fileoverview CubejsApi class unit tests.
4
+ * @fileoverview CubeApi class unit tests.
5
5
  */
6
6
 
7
7
  /* globals describe,test,expect,beforeEach,jest */
8
8
 
9
9
  import ResultSet from './ResultSet';
10
- import { CubejsApi } from './index';
10
+ import { CubeApi } from './index';
11
11
 
12
12
  jest.mock('./ResultSet');
13
13
  beforeEach(() => {
@@ -203,9 +203,9 @@ const mockData = {
203
203
  }],
204
204
  };
205
205
 
206
- describe('CubejsApi', () => {
207
- test('CubejsApi#loadResponseInternal should work with the "default" resType for regular query', () => {
208
- const api = new CubejsApi(undefined, {
206
+ describe('CubeApi', () => {
207
+ test('CubeApi#loadResponseInternal should work with the "default" resType for regular query', () => {
208
+ const api = new CubeApi(undefined, {
209
209
  apiUrl: 'http://localhost:4000/cubejs-api/v1',
210
210
  });
211
211
  const income = {
@@ -236,8 +236,8 @@ describe('CubejsApi', () => {
236
236
  });
237
237
  });
238
238
 
239
- test('CubejsApi#loadResponseInternal should work with the "default" resType for compare date range query', () => {
240
- const api = new CubejsApi(undefined, {
239
+ test('CubeApi#loadResponseInternal should work with the "default" resType for compare date range query', () => {
240
+ const api = new CubeApi(undefined, {
241
241
  apiUrl: 'http://localhost:4000/cubejs-api/v1',
242
242
  });
243
243
  const income = {
@@ -282,8 +282,8 @@ describe('CubejsApi', () => {
282
282
  });
283
283
  });
284
284
 
285
- test('CubejsApi#loadResponseInternal should work with the "default" resType for blending query', () => {
286
- const api = new CubejsApi(undefined, {
285
+ test('CubeApi#loadResponseInternal should work with the "default" resType for blending query', () => {
286
+ const api = new CubeApi(undefined, {
287
287
  apiUrl: 'http://localhost:4000/cubejs-api/v1',
288
288
  });
289
289
  const income = {
@@ -328,8 +328,8 @@ describe('CubejsApi', () => {
328
328
  });
329
329
  });
330
330
 
331
- test('CubejsApi#loadResponseInternal should work with the "compact" resType for regular query', () => {
332
- const api = new CubejsApi(undefined, {
331
+ test('CubeApi#loadResponseInternal should work with the "compact" resType for regular query', () => {
332
+ const api = new CubeApi(undefined, {
333
333
  apiUrl: 'http://localhost:4000/cubejs-api/v1',
334
334
  });
335
335
  const income = {
@@ -360,8 +360,8 @@ describe('CubejsApi', () => {
360
360
  });
361
361
  });
362
362
 
363
- test('CubejsApi#loadResponseInternal should work with the "compact" resType for compare date range query', () => {
364
- const api = new CubejsApi(undefined, {
363
+ test('CubeApi#loadResponseInternal should work with the "compact" resType for compare date range query', () => {
364
+ const api = new CubeApi(undefined, {
365
365
  apiUrl: 'http://localhost:4000/cubejs-api/v1',
366
366
  });
367
367
  const income = {
@@ -406,8 +406,8 @@ describe('CubejsApi', () => {
406
406
  });
407
407
  });
408
408
 
409
- test('CubejsApi#loadResponseInternal should work with the "compact" resType for blending query', () => {
410
- const api = new CubejsApi(undefined, {
409
+ test('CubeApi#loadResponseInternal should work with the "compact" resType for blending query', () => {
410
+ const api = new CubeApi(undefined, {
411
411
  apiUrl: 'http://localhost:4000/cubejs-api/v1',
412
412
  });
413
413
  const income = {
package/src/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
- import cubejs from './index';
1
+ import cube from './index';
2
2
  import * as clientCoreExports from './index';
3
3
 
4
4
  Object.keys(clientCoreExports).forEach((key) => {
5
- cubejs[key] = clientCoreExports[key];
5
+ cube[key] = clientCoreExports[key];
6
6
  });
7
7
 
8
- export default cubejs;
8
+ export default cube;