@cubejs-client/core 0.10.59 → 0.10.61
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/CHANGELOG.md +8 -0
- package/dist/cubejs-client-core.esm.js +176 -0
- package/dist/cubejs-client-core.js +176 -0
- package/dist/cubejs-client-core.umd.js +176 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.10.61](https://github.com/statsbotco/cubejs-client/compare/v0.10.60...v0.10.61) (2019-10-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @cubejs-client/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.10.59](https://github.com/statsbotco/cubejs-client/compare/v0.10.58...v0.10.59) (2019-10-08)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @cubejs-client/core
|
|
@@ -57,6 +57,9 @@ var TIME_SERIES = {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Provides a convenient interface for data manipulation.
|
|
62
|
+
*/
|
|
60
63
|
|
|
61
64
|
var ResultSet =
|
|
62
65
|
/*#__PURE__*/
|
|
@@ -320,6 +323,31 @@ function () {
|
|
|
320
323
|
// TODO
|
|
321
324
|
return this.chartPivot(pivotConfig);
|
|
322
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Returns normalized query result data in the following format.
|
|
328
|
+
*
|
|
329
|
+
* ```js
|
|
330
|
+
* // For query
|
|
331
|
+
* {
|
|
332
|
+
* measures: ['Stories.count'],
|
|
333
|
+
* timeDimensions: [{
|
|
334
|
+
* dimension: 'Stories.time',
|
|
335
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
336
|
+
* granularity: 'month'
|
|
337
|
+
* }]
|
|
338
|
+
* }
|
|
339
|
+
*
|
|
340
|
+
* // ResultSet.chartPivot() will return
|
|
341
|
+
* [
|
|
342
|
+
* { "x":"2015-01-01T00:00:00", "Stories.count": 27120 },
|
|
343
|
+
* { "x":"2015-02-01T00:00:00", "Stories.count": 25861 },
|
|
344
|
+
* { "x": "2015-03-01T00:00:00", "Stories.count": 29661 },
|
|
345
|
+
* //...
|
|
346
|
+
* ]
|
|
347
|
+
* ```
|
|
348
|
+
* @param pivotConfig
|
|
349
|
+
*/
|
|
350
|
+
|
|
323
351
|
}, {
|
|
324
352
|
key: "chartPivot",
|
|
325
353
|
value: function chartPivot(pivotConfig) {
|
|
@@ -343,6 +371,34 @@ function () {
|
|
|
343
371
|
}, {}));
|
|
344
372
|
});
|
|
345
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns normalized query result data prepared for visualization in the table format.
|
|
376
|
+
*
|
|
377
|
+
* For example
|
|
378
|
+
*
|
|
379
|
+
* ```js
|
|
380
|
+
* // For query
|
|
381
|
+
* {
|
|
382
|
+
* measures: ['Stories.count'],
|
|
383
|
+
* timeDimensions: [{
|
|
384
|
+
* dimension: 'Stories.time',
|
|
385
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
386
|
+
* granularity: 'month'
|
|
387
|
+
* }]
|
|
388
|
+
* }
|
|
389
|
+
*
|
|
390
|
+
* // ResultSet.tablePivot() will return
|
|
391
|
+
* [
|
|
392
|
+
* { "Stories.time": "2015-01-01T00:00:00", "Stories.count": 27120 },
|
|
393
|
+
* { "Stories.time": "2015-02-01T00:00:00", "Stories.count": 25861 },
|
|
394
|
+
* { "Stories.time": "2015-03-01T00:00:00", "Stories.count": 29661 },
|
|
395
|
+
* //...
|
|
396
|
+
* ]
|
|
397
|
+
* ```
|
|
398
|
+
* @param pivotConfig
|
|
399
|
+
* @returns {Array} of pivoted rows
|
|
400
|
+
*/
|
|
401
|
+
|
|
346
402
|
}, {
|
|
347
403
|
key: "tablePivot",
|
|
348
404
|
value: function tablePivot(pivotConfig) {
|
|
@@ -370,6 +426,33 @@ function () {
|
|
|
370
426
|
}, {});
|
|
371
427
|
});
|
|
372
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Returns array of column definitions for `tablePivot`.
|
|
431
|
+
*
|
|
432
|
+
* For example
|
|
433
|
+
*
|
|
434
|
+
* ```js
|
|
435
|
+
* // For query
|
|
436
|
+
* {
|
|
437
|
+
* measures: ['Stories.count'],
|
|
438
|
+
* timeDimensions: [{
|
|
439
|
+
* dimension: 'Stories.time',
|
|
440
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
441
|
+
* granularity: 'month'
|
|
442
|
+
* }]
|
|
443
|
+
* }
|
|
444
|
+
*
|
|
445
|
+
* // ResultSet.tableColumns() will return
|
|
446
|
+
* [
|
|
447
|
+
* { key: "Stories.time", title: "Stories Time" },
|
|
448
|
+
* { key: "Stories.count", title: "Stories Count" },
|
|
449
|
+
* //...
|
|
450
|
+
* ]
|
|
451
|
+
* ```
|
|
452
|
+
* @param pivotConfig
|
|
453
|
+
* @returns {Array} of columns
|
|
454
|
+
*/
|
|
455
|
+
|
|
373
456
|
}, {
|
|
374
457
|
key: "tableColumns",
|
|
375
458
|
value: function tableColumns(pivotConfig) {
|
|
@@ -404,6 +487,29 @@ function () {
|
|
|
404
487
|
// TODO
|
|
405
488
|
return this.chartPivot(pivotConfig);
|
|
406
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Returns the array of series objects, containing `key` and `title` parameters.
|
|
492
|
+
*
|
|
493
|
+
* ```js
|
|
494
|
+
* // For query
|
|
495
|
+
* {
|
|
496
|
+
* measures: ['Stories.count'],
|
|
497
|
+
* timeDimensions: [{
|
|
498
|
+
* dimension: 'Stories.time',
|
|
499
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
500
|
+
* granularity: 'month'
|
|
501
|
+
* }]
|
|
502
|
+
* }
|
|
503
|
+
*
|
|
504
|
+
* // ResultSet.seriesNames() will return
|
|
505
|
+
* [
|
|
506
|
+
* { "key":"Stories.count", "title": "Stories Count" }
|
|
507
|
+
* ]
|
|
508
|
+
* ```
|
|
509
|
+
* @param pivotConfig
|
|
510
|
+
* @returns {Array} of series names
|
|
511
|
+
*/
|
|
512
|
+
|
|
407
513
|
}, {
|
|
408
514
|
key: "seriesNames",
|
|
409
515
|
value: function seriesNames(pivotConfig) {
|
|
@@ -638,6 +744,11 @@ var mutexPromise = function mutexPromise(promise) {
|
|
|
638
744
|
});
|
|
639
745
|
});
|
|
640
746
|
};
|
|
747
|
+
/**
|
|
748
|
+
* Main class for accessing Cube.js API
|
|
749
|
+
* @order -5
|
|
750
|
+
*/
|
|
751
|
+
|
|
641
752
|
|
|
642
753
|
var CubejsApi =
|
|
643
754
|
/*#__PURE__*/
|
|
@@ -764,6 +875,34 @@ function () {
|
|
|
764
875
|
return mutexPromise(loadImpl());
|
|
765
876
|
}
|
|
766
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* Fetch data for passed `query`.
|
|
880
|
+
*
|
|
881
|
+
* ```js
|
|
882
|
+
* import cubejs from '@cubejs-client/core';
|
|
883
|
+
* import Chart from 'chart.js';
|
|
884
|
+
* import chartjsConfig from './toChartjsData';
|
|
885
|
+
*
|
|
886
|
+
* const cubejsApi = cubejs('CUBEJS_TOKEN');
|
|
887
|
+
*
|
|
888
|
+
* const resultSet = await cubejsApi.load({
|
|
889
|
+
* measures: ['Stories.count'],
|
|
890
|
+
* timeDimensions: [{
|
|
891
|
+
* dimension: 'Stories.time',
|
|
892
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
893
|
+
* granularity: 'month'
|
|
894
|
+
* }]
|
|
895
|
+
* });
|
|
896
|
+
*
|
|
897
|
+
* const context = document.getElementById('myChart');
|
|
898
|
+
* new Chart(context, chartjsConfig(resultSet));
|
|
899
|
+
* ```
|
|
900
|
+
* @param query - [Query object](query-format)
|
|
901
|
+
* @param options
|
|
902
|
+
* @param callback
|
|
903
|
+
* @returns {Promise} for {@link ResultSet} if `callback` isn't passed
|
|
904
|
+
*/
|
|
905
|
+
|
|
767
906
|
}, {
|
|
768
907
|
key: "load",
|
|
769
908
|
value: function load(query, options, callback) {
|
|
@@ -775,6 +914,14 @@ function () {
|
|
|
775
914
|
return new ResultSet(body);
|
|
776
915
|
}, options, callback);
|
|
777
916
|
}
|
|
917
|
+
/**
|
|
918
|
+
* Get generated SQL string for given `query`.
|
|
919
|
+
* @param query - [Query object](query-format)
|
|
920
|
+
* @param options
|
|
921
|
+
* @param callback
|
|
922
|
+
* @return {Promise} for {@link SqlQuery} if `callback` isn't passed
|
|
923
|
+
*/
|
|
924
|
+
|
|
778
925
|
}, {
|
|
779
926
|
key: "sql",
|
|
780
927
|
value: function sql(query, options, callback) {
|
|
@@ -786,6 +933,13 @@ function () {
|
|
|
786
933
|
return new SqlQuery(body);
|
|
787
934
|
}, options, callback);
|
|
788
935
|
}
|
|
936
|
+
/**
|
|
937
|
+
* Get meta description of cubes available for querying.
|
|
938
|
+
* @param options
|
|
939
|
+
* @param callback
|
|
940
|
+
* @return {Promise} for {@link Meta} if `callback` isn't passed
|
|
941
|
+
*/
|
|
942
|
+
|
|
789
943
|
}, {
|
|
790
944
|
key: "meta",
|
|
791
945
|
value: function meta(options, callback) {
|
|
@@ -801,6 +955,28 @@ function () {
|
|
|
801
955
|
|
|
802
956
|
return CubejsApi;
|
|
803
957
|
}();
|
|
958
|
+
/**
|
|
959
|
+
* Create instance of `CubejsApi`.
|
|
960
|
+
* API entry point.
|
|
961
|
+
*
|
|
962
|
+
* ```javascript
|
|
963
|
+
import cubejs from '@cubejs-client/core';
|
|
964
|
+
|
|
965
|
+
const cubejsApi = cubejs(
|
|
966
|
+
'CUBEJS-API-TOKEN',
|
|
967
|
+
{ apiUrl: 'http://localhost:4000/cubejs-api/v1' }
|
|
968
|
+
);
|
|
969
|
+
```
|
|
970
|
+
* @name cubejs
|
|
971
|
+
* @param apiToken - [API token](security) is used to authorize requests and determine SQL database you're accessing.
|
|
972
|
+
* In the development mode, Cube.js Backend will print the API token to the console on on startup.
|
|
973
|
+
* @param options - options object.
|
|
974
|
+
* @param options.apiUrl - URL of your Cube.js Backend.
|
|
975
|
+
* By default, in the development environment it is `http://localhost:4000/cubejs-api/v1`.
|
|
976
|
+
* @returns {CubejsApi}
|
|
977
|
+
* @order -10
|
|
978
|
+
*/
|
|
979
|
+
|
|
804
980
|
|
|
805
981
|
var index = (function (apiToken, options) {
|
|
806
982
|
return new CubejsApi(apiToken, options);
|
|
@@ -61,6 +61,9 @@ var TIME_SERIES = {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Provides a convenient interface for data manipulation.
|
|
66
|
+
*/
|
|
64
67
|
|
|
65
68
|
var ResultSet =
|
|
66
69
|
/*#__PURE__*/
|
|
@@ -324,6 +327,31 @@ function () {
|
|
|
324
327
|
// TODO
|
|
325
328
|
return this.chartPivot(pivotConfig);
|
|
326
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Returns normalized query result data in the following format.
|
|
332
|
+
*
|
|
333
|
+
* ```js
|
|
334
|
+
* // For query
|
|
335
|
+
* {
|
|
336
|
+
* measures: ['Stories.count'],
|
|
337
|
+
* timeDimensions: [{
|
|
338
|
+
* dimension: 'Stories.time',
|
|
339
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
340
|
+
* granularity: 'month'
|
|
341
|
+
* }]
|
|
342
|
+
* }
|
|
343
|
+
*
|
|
344
|
+
* // ResultSet.chartPivot() will return
|
|
345
|
+
* [
|
|
346
|
+
* { "x":"2015-01-01T00:00:00", "Stories.count": 27120 },
|
|
347
|
+
* { "x":"2015-02-01T00:00:00", "Stories.count": 25861 },
|
|
348
|
+
* { "x": "2015-03-01T00:00:00", "Stories.count": 29661 },
|
|
349
|
+
* //...
|
|
350
|
+
* ]
|
|
351
|
+
* ```
|
|
352
|
+
* @param pivotConfig
|
|
353
|
+
*/
|
|
354
|
+
|
|
327
355
|
}, {
|
|
328
356
|
key: "chartPivot",
|
|
329
357
|
value: function chartPivot(pivotConfig) {
|
|
@@ -347,6 +375,34 @@ function () {
|
|
|
347
375
|
}, {}));
|
|
348
376
|
});
|
|
349
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Returns normalized query result data prepared for visualization in the table format.
|
|
380
|
+
*
|
|
381
|
+
* For example
|
|
382
|
+
*
|
|
383
|
+
* ```js
|
|
384
|
+
* // For query
|
|
385
|
+
* {
|
|
386
|
+
* measures: ['Stories.count'],
|
|
387
|
+
* timeDimensions: [{
|
|
388
|
+
* dimension: 'Stories.time',
|
|
389
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
390
|
+
* granularity: 'month'
|
|
391
|
+
* }]
|
|
392
|
+
* }
|
|
393
|
+
*
|
|
394
|
+
* // ResultSet.tablePivot() will return
|
|
395
|
+
* [
|
|
396
|
+
* { "Stories.time": "2015-01-01T00:00:00", "Stories.count": 27120 },
|
|
397
|
+
* { "Stories.time": "2015-02-01T00:00:00", "Stories.count": 25861 },
|
|
398
|
+
* { "Stories.time": "2015-03-01T00:00:00", "Stories.count": 29661 },
|
|
399
|
+
* //...
|
|
400
|
+
* ]
|
|
401
|
+
* ```
|
|
402
|
+
* @param pivotConfig
|
|
403
|
+
* @returns {Array} of pivoted rows
|
|
404
|
+
*/
|
|
405
|
+
|
|
350
406
|
}, {
|
|
351
407
|
key: "tablePivot",
|
|
352
408
|
value: function tablePivot(pivotConfig) {
|
|
@@ -374,6 +430,33 @@ function () {
|
|
|
374
430
|
}, {});
|
|
375
431
|
});
|
|
376
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Returns array of column definitions for `tablePivot`.
|
|
435
|
+
*
|
|
436
|
+
* For example
|
|
437
|
+
*
|
|
438
|
+
* ```js
|
|
439
|
+
* // For query
|
|
440
|
+
* {
|
|
441
|
+
* measures: ['Stories.count'],
|
|
442
|
+
* timeDimensions: [{
|
|
443
|
+
* dimension: 'Stories.time',
|
|
444
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
445
|
+
* granularity: 'month'
|
|
446
|
+
* }]
|
|
447
|
+
* }
|
|
448
|
+
*
|
|
449
|
+
* // ResultSet.tableColumns() will return
|
|
450
|
+
* [
|
|
451
|
+
* { key: "Stories.time", title: "Stories Time" },
|
|
452
|
+
* { key: "Stories.count", title: "Stories Count" },
|
|
453
|
+
* //...
|
|
454
|
+
* ]
|
|
455
|
+
* ```
|
|
456
|
+
* @param pivotConfig
|
|
457
|
+
* @returns {Array} of columns
|
|
458
|
+
*/
|
|
459
|
+
|
|
377
460
|
}, {
|
|
378
461
|
key: "tableColumns",
|
|
379
462
|
value: function tableColumns(pivotConfig) {
|
|
@@ -408,6 +491,29 @@ function () {
|
|
|
408
491
|
// TODO
|
|
409
492
|
return this.chartPivot(pivotConfig);
|
|
410
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* Returns the array of series objects, containing `key` and `title` parameters.
|
|
496
|
+
*
|
|
497
|
+
* ```js
|
|
498
|
+
* // For query
|
|
499
|
+
* {
|
|
500
|
+
* measures: ['Stories.count'],
|
|
501
|
+
* timeDimensions: [{
|
|
502
|
+
* dimension: 'Stories.time',
|
|
503
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
504
|
+
* granularity: 'month'
|
|
505
|
+
* }]
|
|
506
|
+
* }
|
|
507
|
+
*
|
|
508
|
+
* // ResultSet.seriesNames() will return
|
|
509
|
+
* [
|
|
510
|
+
* { "key":"Stories.count", "title": "Stories Count" }
|
|
511
|
+
* ]
|
|
512
|
+
* ```
|
|
513
|
+
* @param pivotConfig
|
|
514
|
+
* @returns {Array} of series names
|
|
515
|
+
*/
|
|
516
|
+
|
|
411
517
|
}, {
|
|
412
518
|
key: "seriesNames",
|
|
413
519
|
value: function seriesNames(pivotConfig) {
|
|
@@ -642,6 +748,11 @@ var mutexPromise = function mutexPromise(promise) {
|
|
|
642
748
|
});
|
|
643
749
|
});
|
|
644
750
|
};
|
|
751
|
+
/**
|
|
752
|
+
* Main class for accessing Cube.js API
|
|
753
|
+
* @order -5
|
|
754
|
+
*/
|
|
755
|
+
|
|
645
756
|
|
|
646
757
|
var CubejsApi =
|
|
647
758
|
/*#__PURE__*/
|
|
@@ -768,6 +879,34 @@ function () {
|
|
|
768
879
|
return mutexPromise(loadImpl());
|
|
769
880
|
}
|
|
770
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* Fetch data for passed `query`.
|
|
884
|
+
*
|
|
885
|
+
* ```js
|
|
886
|
+
* import cubejs from '@cubejs-client/core';
|
|
887
|
+
* import Chart from 'chart.js';
|
|
888
|
+
* import chartjsConfig from './toChartjsData';
|
|
889
|
+
*
|
|
890
|
+
* const cubejsApi = cubejs('CUBEJS_TOKEN');
|
|
891
|
+
*
|
|
892
|
+
* const resultSet = await cubejsApi.load({
|
|
893
|
+
* measures: ['Stories.count'],
|
|
894
|
+
* timeDimensions: [{
|
|
895
|
+
* dimension: 'Stories.time',
|
|
896
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
897
|
+
* granularity: 'month'
|
|
898
|
+
* }]
|
|
899
|
+
* });
|
|
900
|
+
*
|
|
901
|
+
* const context = document.getElementById('myChart');
|
|
902
|
+
* new Chart(context, chartjsConfig(resultSet));
|
|
903
|
+
* ```
|
|
904
|
+
* @param query - [Query object](query-format)
|
|
905
|
+
* @param options
|
|
906
|
+
* @param callback
|
|
907
|
+
* @returns {Promise} for {@link ResultSet} if `callback` isn't passed
|
|
908
|
+
*/
|
|
909
|
+
|
|
771
910
|
}, {
|
|
772
911
|
key: "load",
|
|
773
912
|
value: function load(query, options, callback) {
|
|
@@ -779,6 +918,14 @@ function () {
|
|
|
779
918
|
return new ResultSet(body);
|
|
780
919
|
}, options, callback);
|
|
781
920
|
}
|
|
921
|
+
/**
|
|
922
|
+
* Get generated SQL string for given `query`.
|
|
923
|
+
* @param query - [Query object](query-format)
|
|
924
|
+
* @param options
|
|
925
|
+
* @param callback
|
|
926
|
+
* @return {Promise} for {@link SqlQuery} if `callback` isn't passed
|
|
927
|
+
*/
|
|
928
|
+
|
|
782
929
|
}, {
|
|
783
930
|
key: "sql",
|
|
784
931
|
value: function sql(query, options, callback) {
|
|
@@ -790,6 +937,13 @@ function () {
|
|
|
790
937
|
return new SqlQuery(body);
|
|
791
938
|
}, options, callback);
|
|
792
939
|
}
|
|
940
|
+
/**
|
|
941
|
+
* Get meta description of cubes available for querying.
|
|
942
|
+
* @param options
|
|
943
|
+
* @param callback
|
|
944
|
+
* @return {Promise} for {@link Meta} if `callback` isn't passed
|
|
945
|
+
*/
|
|
946
|
+
|
|
793
947
|
}, {
|
|
794
948
|
key: "meta",
|
|
795
949
|
value: function meta(options, callback) {
|
|
@@ -805,6 +959,28 @@ function () {
|
|
|
805
959
|
|
|
806
960
|
return CubejsApi;
|
|
807
961
|
}();
|
|
962
|
+
/**
|
|
963
|
+
* Create instance of `CubejsApi`.
|
|
964
|
+
* API entry point.
|
|
965
|
+
*
|
|
966
|
+
* ```javascript
|
|
967
|
+
import cubejs from '@cubejs-client/core';
|
|
968
|
+
|
|
969
|
+
const cubejsApi = cubejs(
|
|
970
|
+
'CUBEJS-API-TOKEN',
|
|
971
|
+
{ apiUrl: 'http://localhost:4000/cubejs-api/v1' }
|
|
972
|
+
);
|
|
973
|
+
```
|
|
974
|
+
* @name cubejs
|
|
975
|
+
* @param apiToken - [API token](security) is used to authorize requests and determine SQL database you're accessing.
|
|
976
|
+
* In the development mode, Cube.js Backend will print the API token to the console on on startup.
|
|
977
|
+
* @param options - options object.
|
|
978
|
+
* @param options.apiUrl - URL of your Cube.js Backend.
|
|
979
|
+
* By default, in the development environment it is `http://localhost:4000/cubejs-api/v1`.
|
|
980
|
+
* @returns {CubejsApi}
|
|
981
|
+
* @order -10
|
|
982
|
+
*/
|
|
983
|
+
|
|
808
984
|
|
|
809
985
|
var index = (function (apiToken, options) {
|
|
810
986
|
return new CubejsApi(apiToken, options);
|
|
@@ -14387,6 +14387,9 @@
|
|
|
14387
14387
|
});
|
|
14388
14388
|
}
|
|
14389
14389
|
};
|
|
14390
|
+
/**
|
|
14391
|
+
* Provides a convenient interface for data manipulation.
|
|
14392
|
+
*/
|
|
14390
14393
|
|
|
14391
14394
|
var ResultSet =
|
|
14392
14395
|
/*#__PURE__*/
|
|
@@ -14650,6 +14653,31 @@
|
|
|
14650
14653
|
// TODO
|
|
14651
14654
|
return this.chartPivot(pivotConfig);
|
|
14652
14655
|
}
|
|
14656
|
+
/**
|
|
14657
|
+
* Returns normalized query result data in the following format.
|
|
14658
|
+
*
|
|
14659
|
+
* ```js
|
|
14660
|
+
* // For query
|
|
14661
|
+
* {
|
|
14662
|
+
* measures: ['Stories.count'],
|
|
14663
|
+
* timeDimensions: [{
|
|
14664
|
+
* dimension: 'Stories.time',
|
|
14665
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
14666
|
+
* granularity: 'month'
|
|
14667
|
+
* }]
|
|
14668
|
+
* }
|
|
14669
|
+
*
|
|
14670
|
+
* // ResultSet.chartPivot() will return
|
|
14671
|
+
* [
|
|
14672
|
+
* { "x":"2015-01-01T00:00:00", "Stories.count": 27120 },
|
|
14673
|
+
* { "x":"2015-02-01T00:00:00", "Stories.count": 25861 },
|
|
14674
|
+
* { "x": "2015-03-01T00:00:00", "Stories.count": 29661 },
|
|
14675
|
+
* //...
|
|
14676
|
+
* ]
|
|
14677
|
+
* ```
|
|
14678
|
+
* @param pivotConfig
|
|
14679
|
+
*/
|
|
14680
|
+
|
|
14653
14681
|
}, {
|
|
14654
14682
|
key: "chartPivot",
|
|
14655
14683
|
value: function chartPivot(pivotConfig) {
|
|
@@ -14673,6 +14701,34 @@
|
|
|
14673
14701
|
}, {}));
|
|
14674
14702
|
});
|
|
14675
14703
|
}
|
|
14704
|
+
/**
|
|
14705
|
+
* Returns normalized query result data prepared for visualization in the table format.
|
|
14706
|
+
*
|
|
14707
|
+
* For example
|
|
14708
|
+
*
|
|
14709
|
+
* ```js
|
|
14710
|
+
* // For query
|
|
14711
|
+
* {
|
|
14712
|
+
* measures: ['Stories.count'],
|
|
14713
|
+
* timeDimensions: [{
|
|
14714
|
+
* dimension: 'Stories.time',
|
|
14715
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
14716
|
+
* granularity: 'month'
|
|
14717
|
+
* }]
|
|
14718
|
+
* }
|
|
14719
|
+
*
|
|
14720
|
+
* // ResultSet.tablePivot() will return
|
|
14721
|
+
* [
|
|
14722
|
+
* { "Stories.time": "2015-01-01T00:00:00", "Stories.count": 27120 },
|
|
14723
|
+
* { "Stories.time": "2015-02-01T00:00:00", "Stories.count": 25861 },
|
|
14724
|
+
* { "Stories.time": "2015-03-01T00:00:00", "Stories.count": 29661 },
|
|
14725
|
+
* //...
|
|
14726
|
+
* ]
|
|
14727
|
+
* ```
|
|
14728
|
+
* @param pivotConfig
|
|
14729
|
+
* @returns {Array} of pivoted rows
|
|
14730
|
+
*/
|
|
14731
|
+
|
|
14676
14732
|
}, {
|
|
14677
14733
|
key: "tablePivot",
|
|
14678
14734
|
value: function tablePivot(pivotConfig) {
|
|
@@ -14700,6 +14756,33 @@
|
|
|
14700
14756
|
}, {});
|
|
14701
14757
|
});
|
|
14702
14758
|
}
|
|
14759
|
+
/**
|
|
14760
|
+
* Returns array of column definitions for `tablePivot`.
|
|
14761
|
+
*
|
|
14762
|
+
* For example
|
|
14763
|
+
*
|
|
14764
|
+
* ```js
|
|
14765
|
+
* // For query
|
|
14766
|
+
* {
|
|
14767
|
+
* measures: ['Stories.count'],
|
|
14768
|
+
* timeDimensions: [{
|
|
14769
|
+
* dimension: 'Stories.time',
|
|
14770
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
14771
|
+
* granularity: 'month'
|
|
14772
|
+
* }]
|
|
14773
|
+
* }
|
|
14774
|
+
*
|
|
14775
|
+
* // ResultSet.tableColumns() will return
|
|
14776
|
+
* [
|
|
14777
|
+
* { key: "Stories.time", title: "Stories Time" },
|
|
14778
|
+
* { key: "Stories.count", title: "Stories Count" },
|
|
14779
|
+
* //...
|
|
14780
|
+
* ]
|
|
14781
|
+
* ```
|
|
14782
|
+
* @param pivotConfig
|
|
14783
|
+
* @returns {Array} of columns
|
|
14784
|
+
*/
|
|
14785
|
+
|
|
14703
14786
|
}, {
|
|
14704
14787
|
key: "tableColumns",
|
|
14705
14788
|
value: function tableColumns(pivotConfig) {
|
|
@@ -14734,6 +14817,29 @@
|
|
|
14734
14817
|
// TODO
|
|
14735
14818
|
return this.chartPivot(pivotConfig);
|
|
14736
14819
|
}
|
|
14820
|
+
/**
|
|
14821
|
+
* Returns the array of series objects, containing `key` and `title` parameters.
|
|
14822
|
+
*
|
|
14823
|
+
* ```js
|
|
14824
|
+
* // For query
|
|
14825
|
+
* {
|
|
14826
|
+
* measures: ['Stories.count'],
|
|
14827
|
+
* timeDimensions: [{
|
|
14828
|
+
* dimension: 'Stories.time',
|
|
14829
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
14830
|
+
* granularity: 'month'
|
|
14831
|
+
* }]
|
|
14832
|
+
* }
|
|
14833
|
+
*
|
|
14834
|
+
* // ResultSet.seriesNames() will return
|
|
14835
|
+
* [
|
|
14836
|
+
* { "key":"Stories.count", "title": "Stories Count" }
|
|
14837
|
+
* ]
|
|
14838
|
+
* ```
|
|
14839
|
+
* @param pivotConfig
|
|
14840
|
+
* @returns {Array} of series names
|
|
14841
|
+
*/
|
|
14842
|
+
|
|
14737
14843
|
}, {
|
|
14738
14844
|
key: "seriesNames",
|
|
14739
14845
|
value: function seriesNames(pivotConfig) {
|
|
@@ -14968,6 +15074,11 @@
|
|
|
14968
15074
|
});
|
|
14969
15075
|
});
|
|
14970
15076
|
};
|
|
15077
|
+
/**
|
|
15078
|
+
* Main class for accessing Cube.js API
|
|
15079
|
+
* @order -5
|
|
15080
|
+
*/
|
|
15081
|
+
|
|
14971
15082
|
|
|
14972
15083
|
var CubejsApi =
|
|
14973
15084
|
/*#__PURE__*/
|
|
@@ -15094,6 +15205,34 @@
|
|
|
15094
15205
|
return mutexPromise(loadImpl());
|
|
15095
15206
|
}
|
|
15096
15207
|
}
|
|
15208
|
+
/**
|
|
15209
|
+
* Fetch data for passed `query`.
|
|
15210
|
+
*
|
|
15211
|
+
* ```js
|
|
15212
|
+
* import cubejs from '@cubejs-client/core';
|
|
15213
|
+
* import Chart from 'chart.js';
|
|
15214
|
+
* import chartjsConfig from './toChartjsData';
|
|
15215
|
+
*
|
|
15216
|
+
* const cubejsApi = cubejs('CUBEJS_TOKEN');
|
|
15217
|
+
*
|
|
15218
|
+
* const resultSet = await cubejsApi.load({
|
|
15219
|
+
* measures: ['Stories.count'],
|
|
15220
|
+
* timeDimensions: [{
|
|
15221
|
+
* dimension: 'Stories.time',
|
|
15222
|
+
* dateRange: ['2015-01-01', '2015-12-31'],
|
|
15223
|
+
* granularity: 'month'
|
|
15224
|
+
* }]
|
|
15225
|
+
* });
|
|
15226
|
+
*
|
|
15227
|
+
* const context = document.getElementById('myChart');
|
|
15228
|
+
* new Chart(context, chartjsConfig(resultSet));
|
|
15229
|
+
* ```
|
|
15230
|
+
* @param query - [Query object](query-format)
|
|
15231
|
+
* @param options
|
|
15232
|
+
* @param callback
|
|
15233
|
+
* @returns {Promise} for {@link ResultSet} if `callback` isn't passed
|
|
15234
|
+
*/
|
|
15235
|
+
|
|
15097
15236
|
}, {
|
|
15098
15237
|
key: "load",
|
|
15099
15238
|
value: function load(query, options, callback) {
|
|
@@ -15105,6 +15244,14 @@
|
|
|
15105
15244
|
return new ResultSet(body);
|
|
15106
15245
|
}, options, callback);
|
|
15107
15246
|
}
|
|
15247
|
+
/**
|
|
15248
|
+
* Get generated SQL string for given `query`.
|
|
15249
|
+
* @param query - [Query object](query-format)
|
|
15250
|
+
* @param options
|
|
15251
|
+
* @param callback
|
|
15252
|
+
* @return {Promise} for {@link SqlQuery} if `callback` isn't passed
|
|
15253
|
+
*/
|
|
15254
|
+
|
|
15108
15255
|
}, {
|
|
15109
15256
|
key: "sql",
|
|
15110
15257
|
value: function sql(query, options, callback) {
|
|
@@ -15116,6 +15263,13 @@
|
|
|
15116
15263
|
return new SqlQuery(body);
|
|
15117
15264
|
}, options, callback);
|
|
15118
15265
|
}
|
|
15266
|
+
/**
|
|
15267
|
+
* Get meta description of cubes available for querying.
|
|
15268
|
+
* @param options
|
|
15269
|
+
* @param callback
|
|
15270
|
+
* @return {Promise} for {@link Meta} if `callback` isn't passed
|
|
15271
|
+
*/
|
|
15272
|
+
|
|
15119
15273
|
}, {
|
|
15120
15274
|
key: "meta",
|
|
15121
15275
|
value: function meta(options, callback) {
|
|
@@ -15131,6 +15285,28 @@
|
|
|
15131
15285
|
|
|
15132
15286
|
return CubejsApi;
|
|
15133
15287
|
}();
|
|
15288
|
+
/**
|
|
15289
|
+
* Create instance of `CubejsApi`.
|
|
15290
|
+
* API entry point.
|
|
15291
|
+
*
|
|
15292
|
+
* ```javascript
|
|
15293
|
+
import cubejs from '@cubejs-client/core';
|
|
15294
|
+
|
|
15295
|
+
const cubejsApi = cubejs(
|
|
15296
|
+
'CUBEJS-API-TOKEN',
|
|
15297
|
+
{ apiUrl: 'http://localhost:4000/cubejs-api/v1' }
|
|
15298
|
+
);
|
|
15299
|
+
```
|
|
15300
|
+
* @name cubejs
|
|
15301
|
+
* @param apiToken - [API token](security) is used to authorize requests and determine SQL database you're accessing.
|
|
15302
|
+
* In the development mode, Cube.js Backend will print the API token to the console on on startup.
|
|
15303
|
+
* @param options - options object.
|
|
15304
|
+
* @param options.apiUrl - URL of your Cube.js Backend.
|
|
15305
|
+
* By default, in the development environment it is `http://localhost:4000/cubejs-api/v1`.
|
|
15306
|
+
* @returns {CubejsApi}
|
|
15307
|
+
* @order -10
|
|
15308
|
+
*/
|
|
15309
|
+
|
|
15134
15310
|
|
|
15135
15311
|
var index = (function (apiToken, options) {
|
|
15136
15312
|
return new CubejsApi(apiToken, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubejs-client/core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.61",
|
|
4
4
|
"description": "cube.js client",
|
|
5
5
|
"main": "dist/cubejs-client-core.js",
|
|
6
6
|
"author": "Statsbot, Inc.",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"babel-jest": "^24.1.0",
|
|
27
27
|
"jest": "^24.1.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "cc5aa4570e7bf9f920686e3574f657ec474bceaf"
|
|
30
30
|
}
|