@cubejs-client/core 0.34.37 → 0.35.0

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
  */
@@ -98,7 +98,7 @@ declare module '@cubejs-client/core' {
98
98
  /**
99
99
  * A Cube API instance. If not provided will be taken from `CubeProvider`
100
100
  */
101
- cubejsApi?: CubejsApi;
101
+ cubeApi?: CubeApi;
102
102
  /**
103
103
  * If enabled, all members of the 'number' type will be automatically converted to numerical values on the client side
104
104
  */
@@ -324,7 +324,7 @@ declare module '@cubejs-client/core' {
324
324
  * ```js
325
325
  * import { ResultSet } from '@cubejs-client/core';
326
326
  *
327
- * const resultSet = await cubejsApi.load(query);
327
+ * const resultSet = await cubeApi.load(query);
328
328
  * // You can store the result somewhere
329
329
  * const tmp = resultSet.serialize();
330
330
  *
@@ -1072,11 +1072,11 @@ declare module '@cubejs-client/core' {
1072
1072
  }
1073
1073
 
1074
1074
  /**
1075
- * Main class for accessing Cube.js API
1075
+ * Main class for accessing Cube API
1076
1076
  *
1077
1077
  * @order 2
1078
1078
  */
1079
- export class CubejsApi {
1079
+ export class CubeApi {
1080
1080
  load<QueryType extends DeeplyReadonly<Query | Query[]>>(
1081
1081
  query: QueryType,
1082
1082
  options?: LoadMethodOptions,
@@ -1085,13 +1085,13 @@ declare module '@cubejs-client/core' {
1085
1085
  * Fetch data for the passed `query`.
1086
1086
  *
1087
1087
  * ```js
1088
- * import cubejs from '@cubejs-client/core';
1088
+ * import cube from '@cubejs-client/core';
1089
1089
  * import Chart from 'chart.js';
1090
1090
  * import chartjsConfig from './toChartjsData';
1091
1091
  *
1092
- * const cubejsApi = cubejs('CUBEJS_TOKEN');
1092
+ * const cubeApi = cube('CUBEJS_TOKEN');
1093
1093
  *
1094
- * const resultSet = await cubejsApi.load({
1094
+ * const resultSet = await cubeApi.load({
1095
1095
  * measures: ['Stories.count'],
1096
1096
  * timeDimensions: [{
1097
1097
  * dimension: 'Stories.time',
@@ -1123,7 +1123,7 @@ declare module '@cubejs-client/core' {
1123
1123
  *
1124
1124
  * ```js
1125
1125
  * // Subscribe to a query's updates
1126
- * const subscription = await cubejsApi.subscribe(
1126
+ * const subscription = await cubeApi.subscribe(
1127
1127
  * {
1128
1128
  * measures: ['Logs.count'],
1129
1129
  * timeDimensions: [
@@ -1173,12 +1173,12 @@ declare module '@cubejs-client/core' {
1173
1173
  }
1174
1174
 
1175
1175
  /**
1176
- * Creates an instance of the `CubejsApi`. The API entry point.
1176
+ * Creates an instance of the `CubeApi`. The API entry point.
1177
1177
  *
1178
1178
  * ```js
1179
- * import cubejs from '@cubejs-client/core';
1180
- * const cubejsApi = cubejs(
1181
- * 'CUBEJS-API-TOKEN',
1179
+ * import cube from '@cubejs-client/core';
1180
+ * const cubeApi = cube(
1181
+ * 'CUBE-API-TOKEN',
1182
1182
  * { apiUrl: 'http://localhost:4000/cubejs-api/v1' }
1183
1183
  * );
1184
1184
  * ```
@@ -1186,8 +1186,8 @@ declare module '@cubejs-client/core' {
1186
1186
  * You can also pass an async function or a promise that will resolve to the API token
1187
1187
  *
1188
1188
  * ```js
1189
- * import cubejs from '@cubejs-client/core';
1190
- * const cubejsApi = cubejs(
1189
+ * import cube from '@cubejs-client/core';
1190
+ * const cubeApi = cube(
1191
1191
  * async () => await Auth.getJwtToken(),
1192
1192
  * { apiUrl: 'http://localhost:4000/cubejs-api/v1' }
1193
1193
  * );
@@ -1196,8 +1196,8 @@ declare module '@cubejs-client/core' {
1196
1196
  * @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
1197
  * @order 1
1198
1198
  */
1199
- export default function cubejs(apiToken: string | (() => Promise<string>), options: CubeJSApiOptions): CubejsApi;
1200
- export default function cubejs(options: CubeJSApiOptions): CubejsApi;
1199
+ export default function cube(apiToken: string | (() => Promise<string>), options: CubeApiOptions): CubeApi;
1200
+ export default function cube(options: CubeApiOptions): CubeApi;
1201
1201
 
1202
1202
  /**
1203
1203
  * @hidden
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-client/core",
3
- "version": "0.34.37",
3
+ "version": "0.35.0",
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": "595c23dc095825180036b2c3950671d6a75065eb"
48
+ "gitHead": "75bc6c3d96392b7823e714d17ac85ab435e55b05"
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;
@@ -373,7 +373,7 @@ class CubejsApi {
373
373
  }
374
374
  }
375
375
 
376
- export default (apiToken, options) => new CubejsApi(apiToken, options);
376
+ export default (apiToken, options) => new CubeApi(apiToken, options);
377
377
 
378
- export { CubejsApi, CubejsApi as CubeApi, HttpTransport, ResultSet, RequestError, Meta };
378
+ export { CubeApi, HttpTransport, ResultSet, RequestError, Meta };
379
379
  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;
package/src/utils.js CHANGED
@@ -288,10 +288,17 @@ export function movePivotItem(
288
288
  if (id === 'measures') {
289
289
  destinationIndex = lastIndex + 1;
290
290
  } else if (
291
+ sourceAxis === destinationAxis &&
291
292
  destinationIndex >= lastIndex &&
292
293
  nextPivotConfig[destinationAxis][lastIndex] === 'measures'
293
294
  ) {
294
295
  destinationIndex = lastIndex - 1;
296
+ } else if (
297
+ sourceAxis !== destinationAxis &&
298
+ destinationIndex > lastIndex &&
299
+ nextPivotConfig[destinationAxis][lastIndex] === 'measures'
300
+ ) {
301
+ destinationIndex = lastIndex;
295
302
  }
296
303
 
297
304
  nextPivotConfig[sourceAxis].splice(sourceIndex, 1);