@cubejs-client/core 0.28.17 → 0.28.37
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 +45 -0
- package/dist/cubejs-client-core.esm.js +237 -138
- package/dist/cubejs-client-core.esm.js.map +1 -1
- package/dist/cubejs-client-core.js +239 -139
- package/dist/cubejs-client-core.js.map +1 -1
- package/dist/cubejs-client-core.umd.js +282 -175
- package/dist/cubejs-client-core.umd.js.map +1 -1
- package/index.d.ts +10 -2
- package/package.json +2 -2
- package/src/ResultSet.js +8 -4
- package/src/index.js +41 -10
- package/src/tests/ResultSet.test.js +16 -0
- package/src/tests/table.test.js +95 -0
- package/src/utils.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,51 @@
|
|
|
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.28.37](https://github.com/cube-js/cube.js/compare/v0.28.36...v0.28.37) (2021-09-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **playground:** add rollup button ([#3424](https://github.com/cube-js/cube.js/issues/3424)) ([a5db7f1](https://github.com/cube-js/cube.js/commit/a5db7f1905d1eb50bb6e78b4c6c54e03ba7499c9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.28.35](https://github.com/cube-js/cube.js/compare/v0.28.34...v0.28.35) (2021-09-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **cubejs-client-core:** keep order of elements within tableColumns ([#3368](https://github.com/cube-js/cube.js/issues/3368)) ([b9a0f47](https://github.com/cube-js/cube.js/commit/b9a0f4744543d2d5facdbb191638f05790d21070))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [0.28.25](https://github.com/cube-js/cube.js/compare/v0.28.24...v0.28.25) (2021-08-20)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **@cubejs-client/core:** prevent redundant auth updates ([#3288](https://github.com/cube-js/cube.js/issues/3288)) ([5ebf211](https://github.com/cube-js/cube.js/commit/5ebf211fde56aeee1a59f0cabc9f7ae3f8e9ffaa))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [0.28.24](https://github.com/cube-js/cube.js/compare/v0.28.23...v0.28.24) (2021-08-19)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* Added Quarter to the timeDimensions of ([3f62b2c](https://github.com/cube-js/cube.js/commit/3f62b2c125b2b7b752e370b65be4c89a0c65a623))
|
|
45
|
+
* Support quarter granularity ([4ad1356](https://github.com/cube-js/cube.js/commit/4ad1356ac2d2c4d479c25e60519b0f7b4c1605bb))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
6
51
|
## [0.28.17](https://github.com/cube-js/cube.js/compare/v0.28.16...v0.28.17) (2021-08-11)
|
|
7
52
|
|
|
8
53
|
|
|
@@ -7,11 +7,11 @@ import 'core-js/modules/web.dom-collections.for-each.js';
|
|
|
7
7
|
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
8
8
|
import 'core-js/modules/es.object.define-properties.js';
|
|
9
9
|
import 'core-js/modules/es.object.define-property.js';
|
|
10
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
11
10
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
12
11
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
13
12
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
14
13
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
14
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
15
15
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
16
16
|
import 'core-js/modules/es.object.to-string.js';
|
|
17
17
|
import 'core-js/modules/es.promise.js';
|
|
@@ -46,6 +46,7 @@ import 'core-js/modules/es.set.js';
|
|
|
46
46
|
import 'core-js/modules/es.array.index-of.js';
|
|
47
47
|
import 'core-js/modules/es.string.trim.js';
|
|
48
48
|
import dayjs from 'dayjs';
|
|
49
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
49
50
|
import en from 'dayjs/locale/en';
|
|
50
51
|
import { equals, clone, indexBy, prop, pipe, map, filter, reduce, minBy, maxBy, flatten, fromPairs, pluck, mergeDeepLeft, mergeAll, uniq, dropLast, groupBy, unnest as unnest$1 } from 'ramda';
|
|
51
52
|
import 'core-js/modules/es.object.entries.js';
|
|
@@ -89,6 +90,9 @@ var GRANULARITIES = [{
|
|
|
89
90
|
}, {
|
|
90
91
|
name: 'month',
|
|
91
92
|
title: 'Month'
|
|
93
|
+
}, {
|
|
94
|
+
name: 'quarter',
|
|
95
|
+
title: 'Quarter'
|
|
92
96
|
}, {
|
|
93
97
|
name: 'year',
|
|
94
98
|
title: 'Year'
|
|
@@ -365,6 +369,7 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
365
369
|
dayjs.locale(_objectSpread$2(_objectSpread$2({}, en), {}, {
|
|
366
370
|
weekStart: 1
|
|
367
371
|
}));
|
|
372
|
+
dayjs.extend(quarterOfYear);
|
|
368
373
|
var TIME_SERIES = {
|
|
369
374
|
day: function day(range) {
|
|
370
375
|
return range.by('d').map(function (d) {
|
|
@@ -400,6 +405,11 @@ var TIME_SERIES = {
|
|
|
400
405
|
return range.snapTo('week').by('w').map(function (d) {
|
|
401
406
|
return d.startOf('week').format('YYYY-MM-DDT00:00:00.000');
|
|
402
407
|
});
|
|
408
|
+
},
|
|
409
|
+
quarter: function quarter(range) {
|
|
410
|
+
return range.snapTo('quarter').by('quarter').map(function (d) {
|
|
411
|
+
return d.startOf('quarter').format('YYYY-MM-DDT00:00:00.000');
|
|
412
|
+
});
|
|
403
413
|
}
|
|
404
414
|
};
|
|
405
415
|
var DateRegex = /^\d\d\d\d-\d\d-\d\d$/;
|
|
@@ -942,12 +952,12 @@ var ResultSet = /*#__PURE__*/function () {
|
|
|
942
952
|
if (yValues.length > 0) {
|
|
943
953
|
var currentItem = schema;
|
|
944
954
|
yValues.forEach(function (value, index) {
|
|
945
|
-
currentItem[value] = {
|
|
955
|
+
currentItem["_".concat(value)] = {
|
|
946
956
|
key: value,
|
|
947
957
|
memberId: normalizedPivotConfig.y[index] === 'measures' ? value : normalizedPivotConfig.y[index],
|
|
948
|
-
children: currentItem[value] && currentItem[value].children || {}
|
|
958
|
+
children: currentItem["_".concat(value)] && currentItem["_".concat(value)].children || {}
|
|
949
959
|
};
|
|
950
|
-
currentItem = currentItem[value].children;
|
|
960
|
+
currentItem = currentItem["_".concat(value)].children;
|
|
951
961
|
});
|
|
952
962
|
}
|
|
953
963
|
});
|
|
@@ -1612,15 +1622,45 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
1612
1622
|
var mutexCounter = 0;
|
|
1613
1623
|
var MUTEX_ERROR = 'Mutex has been changed';
|
|
1614
1624
|
|
|
1615
|
-
|
|
1616
|
-
return new Promise(function (
|
|
1617
|
-
|
|
1618
|
-
return
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1625
|
+
function mutexPromise(promise) {
|
|
1626
|
+
return new Promise( /*#__PURE__*/function () {
|
|
1627
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
|
|
1628
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1629
|
+
while (1) {
|
|
1630
|
+
switch (_context.prev = _context.next) {
|
|
1631
|
+
case 0:
|
|
1632
|
+
_context.prev = 0;
|
|
1633
|
+
_context.t0 = resolve;
|
|
1634
|
+
_context.next = 4;
|
|
1635
|
+
return promise;
|
|
1636
|
+
|
|
1637
|
+
case 4:
|
|
1638
|
+
_context.t1 = _context.sent;
|
|
1639
|
+
(0, _context.t0)(_context.t1);
|
|
1640
|
+
_context.next = 11;
|
|
1641
|
+
break;
|
|
1642
|
+
|
|
1643
|
+
case 8:
|
|
1644
|
+
_context.prev = 8;
|
|
1645
|
+
_context.t2 = _context["catch"](0);
|
|
1646
|
+
|
|
1647
|
+
if (_context.t2 !== MUTEX_ERROR) {
|
|
1648
|
+
reject(_context.t2);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
case 11:
|
|
1652
|
+
case "end":
|
|
1653
|
+
return _context.stop();
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}, _callee, null, [[0, 8]]);
|
|
1657
|
+
}));
|
|
1658
|
+
|
|
1659
|
+
return function (_x, _x2) {
|
|
1660
|
+
return _ref.apply(this, arguments);
|
|
1661
|
+
};
|
|
1662
|
+
}());
|
|
1663
|
+
}
|
|
1624
1664
|
|
|
1625
1665
|
var CubejsApi = /*#__PURE__*/function () {
|
|
1626
1666
|
function CubejsApi(apiToken, options) {
|
|
@@ -1651,6 +1691,7 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
1651
1691
|
});
|
|
1652
1692
|
this.pollInterval = options.pollInterval || 5;
|
|
1653
1693
|
this.parseDateMeasures = options.parseDateMeasures;
|
|
1694
|
+
this.updateAuthorizationPromise = null;
|
|
1654
1695
|
}
|
|
1655
1696
|
|
|
1656
1697
|
_createClass(CubejsApi, [{
|
|
@@ -1682,34 +1723,35 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
1682
1723
|
var requestPromise = this.updateTransportAuthorization().then(function () {
|
|
1683
1724
|
return request();
|
|
1684
1725
|
});
|
|
1726
|
+
var skipAuthorizationUpdate = true;
|
|
1685
1727
|
var unsubscribed = false;
|
|
1686
1728
|
|
|
1687
1729
|
var checkMutex = /*#__PURE__*/function () {
|
|
1688
|
-
var
|
|
1730
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
1689
1731
|
var requestInstance;
|
|
1690
|
-
return _regeneratorRuntime.wrap(function
|
|
1732
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
1691
1733
|
while (1) {
|
|
1692
|
-
switch (
|
|
1734
|
+
switch (_context2.prev = _context2.next) {
|
|
1693
1735
|
case 0:
|
|
1694
|
-
|
|
1736
|
+
_context2.next = 2;
|
|
1695
1737
|
return requestPromise;
|
|
1696
1738
|
|
|
1697
1739
|
case 2:
|
|
1698
|
-
requestInstance =
|
|
1740
|
+
requestInstance = _context2.sent;
|
|
1699
1741
|
|
|
1700
1742
|
if (!(options.mutexObj && options.mutexObj[mutexKey] !== mutexValue)) {
|
|
1701
|
-
|
|
1743
|
+
_context2.next = 9;
|
|
1702
1744
|
break;
|
|
1703
1745
|
}
|
|
1704
1746
|
|
|
1705
1747
|
unsubscribed = true;
|
|
1706
1748
|
|
|
1707
1749
|
if (!requestInstance.unsubscribe) {
|
|
1708
|
-
|
|
1750
|
+
_context2.next = 8;
|
|
1709
1751
|
break;
|
|
1710
1752
|
}
|
|
1711
1753
|
|
|
1712
|
-
|
|
1754
|
+
_context2.next = 8;
|
|
1713
1755
|
return requestInstance.unsubscribe();
|
|
1714
1756
|
|
|
1715
1757
|
case 8:
|
|
@@ -1717,50 +1759,50 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
1717
1759
|
|
|
1718
1760
|
case 9:
|
|
1719
1761
|
case "end":
|
|
1720
|
-
return
|
|
1762
|
+
return _context2.stop();
|
|
1721
1763
|
}
|
|
1722
1764
|
}
|
|
1723
|
-
},
|
|
1765
|
+
}, _callee2);
|
|
1724
1766
|
}));
|
|
1725
1767
|
|
|
1726
1768
|
return function checkMutex() {
|
|
1727
|
-
return
|
|
1769
|
+
return _ref2.apply(this, arguments);
|
|
1728
1770
|
};
|
|
1729
1771
|
}();
|
|
1730
1772
|
|
|
1731
1773
|
var loadImpl = /*#__PURE__*/function () {
|
|
1732
|
-
var
|
|
1774
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(response, next) {
|
|
1733
1775
|
var requestInstance, subscribeNext, continueWait, body, text, error, result;
|
|
1734
|
-
return _regeneratorRuntime.wrap(function
|
|
1776
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
1735
1777
|
while (1) {
|
|
1736
|
-
switch (
|
|
1778
|
+
switch (_context5.prev = _context5.next) {
|
|
1737
1779
|
case 0:
|
|
1738
|
-
|
|
1780
|
+
_context5.next = 2;
|
|
1739
1781
|
return requestPromise;
|
|
1740
1782
|
|
|
1741
1783
|
case 2:
|
|
1742
|
-
requestInstance =
|
|
1784
|
+
requestInstance = _context5.sent;
|
|
1743
1785
|
|
|
1744
1786
|
subscribeNext = /*#__PURE__*/function () {
|
|
1745
|
-
var
|
|
1746
|
-
return _regeneratorRuntime.wrap(function
|
|
1787
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
1788
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
1747
1789
|
while (1) {
|
|
1748
|
-
switch (
|
|
1790
|
+
switch (_context3.prev = _context3.next) {
|
|
1749
1791
|
case 0:
|
|
1750
1792
|
if (!(options.subscribe && !unsubscribed)) {
|
|
1751
|
-
|
|
1793
|
+
_context3.next = 8;
|
|
1752
1794
|
break;
|
|
1753
1795
|
}
|
|
1754
1796
|
|
|
1755
1797
|
if (!requestInstance.unsubscribe) {
|
|
1756
|
-
|
|
1798
|
+
_context3.next = 5;
|
|
1757
1799
|
break;
|
|
1758
1800
|
}
|
|
1759
1801
|
|
|
1760
|
-
return
|
|
1802
|
+
return _context3.abrupt("return", next());
|
|
1761
1803
|
|
|
1762
1804
|
case 5:
|
|
1763
|
-
|
|
1805
|
+
_context3.next = 7;
|
|
1764
1806
|
return new Promise(function (resolve) {
|
|
1765
1807
|
return setTimeout(function () {
|
|
1766
1808
|
return resolve();
|
|
@@ -1768,41 +1810,41 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
1768
1810
|
});
|
|
1769
1811
|
|
|
1770
1812
|
case 7:
|
|
1771
|
-
return
|
|
1813
|
+
return _context3.abrupt("return", next());
|
|
1772
1814
|
|
|
1773
1815
|
case 8:
|
|
1774
|
-
return
|
|
1816
|
+
return _context3.abrupt("return", null);
|
|
1775
1817
|
|
|
1776
1818
|
case 9:
|
|
1777
1819
|
case "end":
|
|
1778
|
-
return
|
|
1820
|
+
return _context3.stop();
|
|
1779
1821
|
}
|
|
1780
1822
|
}
|
|
1781
|
-
},
|
|
1823
|
+
}, _callee3);
|
|
1782
1824
|
}));
|
|
1783
1825
|
|
|
1784
1826
|
return function subscribeNext() {
|
|
1785
|
-
return
|
|
1827
|
+
return _ref4.apply(this, arguments);
|
|
1786
1828
|
};
|
|
1787
1829
|
}();
|
|
1788
1830
|
|
|
1789
1831
|
continueWait = /*#__PURE__*/function () {
|
|
1790
|
-
var
|
|
1791
|
-
return _regeneratorRuntime.wrap(function
|
|
1832
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(wait) {
|
|
1833
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
1792
1834
|
while (1) {
|
|
1793
|
-
switch (
|
|
1835
|
+
switch (_context4.prev = _context4.next) {
|
|
1794
1836
|
case 0:
|
|
1795
1837
|
if (unsubscribed) {
|
|
1796
|
-
|
|
1838
|
+
_context4.next = 5;
|
|
1797
1839
|
break;
|
|
1798
1840
|
}
|
|
1799
1841
|
|
|
1800
1842
|
if (!wait) {
|
|
1801
|
-
|
|
1843
|
+
_context4.next = 4;
|
|
1802
1844
|
break;
|
|
1803
1845
|
}
|
|
1804
1846
|
|
|
1805
|
-
|
|
1847
|
+
_context4.next = 4;
|
|
1806
1848
|
return new Promise(function (resolve) {
|
|
1807
1849
|
return setTimeout(function () {
|
|
1808
1850
|
return resolve();
|
|
@@ -1810,150 +1852,157 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
1810
1852
|
});
|
|
1811
1853
|
|
|
1812
1854
|
case 4:
|
|
1813
|
-
return
|
|
1855
|
+
return _context4.abrupt("return", next());
|
|
1814
1856
|
|
|
1815
1857
|
case 5:
|
|
1816
|
-
return
|
|
1858
|
+
return _context4.abrupt("return", null);
|
|
1817
1859
|
|
|
1818
1860
|
case 6:
|
|
1819
1861
|
case "end":
|
|
1820
|
-
return
|
|
1862
|
+
return _context4.stop();
|
|
1821
1863
|
}
|
|
1822
1864
|
}
|
|
1823
|
-
},
|
|
1865
|
+
}, _callee4);
|
|
1824
1866
|
}));
|
|
1825
1867
|
|
|
1826
|
-
return function continueWait(
|
|
1827
|
-
return
|
|
1868
|
+
return function continueWait(_x5) {
|
|
1869
|
+
return _ref5.apply(this, arguments);
|
|
1828
1870
|
};
|
|
1829
1871
|
}();
|
|
1830
1872
|
|
|
1831
|
-
|
|
1873
|
+
if (!(options.subscribe && !skipAuthorizationUpdate)) {
|
|
1874
|
+
_context5.next = 8;
|
|
1875
|
+
break;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
_context5.next = 8;
|
|
1832
1879
|
return _this.updateTransportAuthorization();
|
|
1833
1880
|
|
|
1834
|
-
case
|
|
1881
|
+
case 8:
|
|
1882
|
+
skipAuthorizationUpdate = false;
|
|
1883
|
+
|
|
1835
1884
|
if (!(response.status === 502)) {
|
|
1836
|
-
|
|
1885
|
+
_context5.next = 13;
|
|
1837
1886
|
break;
|
|
1838
1887
|
}
|
|
1839
1888
|
|
|
1840
|
-
|
|
1889
|
+
_context5.next = 12;
|
|
1841
1890
|
return checkMutex();
|
|
1842
1891
|
|
|
1843
|
-
case
|
|
1844
|
-
return
|
|
1892
|
+
case 12:
|
|
1893
|
+
return _context5.abrupt("return", continueWait(true));
|
|
1845
1894
|
|
|
1846
|
-
case
|
|
1895
|
+
case 13:
|
|
1847
1896
|
body = {};
|
|
1848
1897
|
text = '';
|
|
1849
|
-
|
|
1850
|
-
|
|
1898
|
+
_context5.prev = 15;
|
|
1899
|
+
_context5.next = 18;
|
|
1851
1900
|
return response.text();
|
|
1852
1901
|
|
|
1853
|
-
case
|
|
1854
|
-
text =
|
|
1902
|
+
case 18:
|
|
1903
|
+
text = _context5.sent;
|
|
1855
1904
|
body = JSON.parse(text);
|
|
1856
|
-
|
|
1905
|
+
_context5.next = 25;
|
|
1857
1906
|
break;
|
|
1858
1907
|
|
|
1859
|
-
case
|
|
1860
|
-
|
|
1861
|
-
|
|
1908
|
+
case 22:
|
|
1909
|
+
_context5.prev = 22;
|
|
1910
|
+
_context5.t0 = _context5["catch"](15);
|
|
1862
1911
|
body.error = text;
|
|
1863
1912
|
|
|
1864
|
-
case
|
|
1913
|
+
case 25:
|
|
1865
1914
|
if (!(body.error === 'Continue wait')) {
|
|
1866
|
-
|
|
1915
|
+
_context5.next = 30;
|
|
1867
1916
|
break;
|
|
1868
1917
|
}
|
|
1869
1918
|
|
|
1870
|
-
|
|
1919
|
+
_context5.next = 28;
|
|
1871
1920
|
return checkMutex();
|
|
1872
1921
|
|
|
1873
|
-
case
|
|
1922
|
+
case 28:
|
|
1874
1923
|
if (options.progressCallback) {
|
|
1875
1924
|
options.progressCallback(new ProgressResult(body));
|
|
1876
1925
|
}
|
|
1877
1926
|
|
|
1878
|
-
return
|
|
1927
|
+
return _context5.abrupt("return", continueWait());
|
|
1879
1928
|
|
|
1880
|
-
case
|
|
1929
|
+
case 30:
|
|
1881
1930
|
if (!(response.status !== 200)) {
|
|
1882
|
-
|
|
1931
|
+
_context5.next = 43;
|
|
1883
1932
|
break;
|
|
1884
1933
|
}
|
|
1885
1934
|
|
|
1886
|
-
|
|
1935
|
+
_context5.next = 33;
|
|
1887
1936
|
return checkMutex();
|
|
1888
1937
|
|
|
1889
|
-
case
|
|
1938
|
+
case 33:
|
|
1890
1939
|
if (!(!options.subscribe && requestInstance.unsubscribe)) {
|
|
1891
|
-
|
|
1940
|
+
_context5.next = 36;
|
|
1892
1941
|
break;
|
|
1893
1942
|
}
|
|
1894
1943
|
|
|
1895
|
-
|
|
1944
|
+
_context5.next = 36;
|
|
1896
1945
|
return requestInstance.unsubscribe();
|
|
1897
1946
|
|
|
1898
|
-
case
|
|
1947
|
+
case 36:
|
|
1899
1948
|
error = new RequestError(body.error, body); // TODO error class
|
|
1900
1949
|
|
|
1901
1950
|
if (!callback) {
|
|
1902
|
-
|
|
1951
|
+
_context5.next = 41;
|
|
1903
1952
|
break;
|
|
1904
1953
|
}
|
|
1905
1954
|
|
|
1906
1955
|
callback(error);
|
|
1907
|
-
|
|
1956
|
+
_context5.next = 42;
|
|
1908
1957
|
break;
|
|
1909
1958
|
|
|
1910
|
-
case
|
|
1959
|
+
case 41:
|
|
1911
1960
|
throw error;
|
|
1912
1961
|
|
|
1913
|
-
case
|
|
1914
|
-
return
|
|
1962
|
+
case 42:
|
|
1963
|
+
return _context5.abrupt("return", subscribeNext());
|
|
1915
1964
|
|
|
1916
|
-
case
|
|
1917
|
-
|
|
1965
|
+
case 43:
|
|
1966
|
+
_context5.next = 45;
|
|
1918
1967
|
return checkMutex();
|
|
1919
1968
|
|
|
1920
|
-
case
|
|
1969
|
+
case 45:
|
|
1921
1970
|
if (!(!options.subscribe && requestInstance.unsubscribe)) {
|
|
1922
|
-
|
|
1971
|
+
_context5.next = 48;
|
|
1923
1972
|
break;
|
|
1924
1973
|
}
|
|
1925
1974
|
|
|
1926
|
-
|
|
1975
|
+
_context5.next = 48;
|
|
1927
1976
|
return requestInstance.unsubscribe();
|
|
1928
1977
|
|
|
1929
|
-
case
|
|
1978
|
+
case 48:
|
|
1930
1979
|
result = toResult(body);
|
|
1931
1980
|
|
|
1932
1981
|
if (!callback) {
|
|
1933
|
-
|
|
1982
|
+
_context5.next = 53;
|
|
1934
1983
|
break;
|
|
1935
1984
|
}
|
|
1936
1985
|
|
|
1937
1986
|
callback(null, result);
|
|
1938
|
-
|
|
1987
|
+
_context5.next = 54;
|
|
1939
1988
|
break;
|
|
1940
1989
|
|
|
1941
|
-
case
|
|
1942
|
-
return
|
|
1990
|
+
case 53:
|
|
1991
|
+
return _context5.abrupt("return", result);
|
|
1943
1992
|
|
|
1944
|
-
case
|
|
1945
|
-
return
|
|
1993
|
+
case 54:
|
|
1994
|
+
return _context5.abrupt("return", subscribeNext());
|
|
1946
1995
|
|
|
1947
|
-
case
|
|
1996
|
+
case 55:
|
|
1948
1997
|
case "end":
|
|
1949
|
-
return
|
|
1998
|
+
return _context5.stop();
|
|
1950
1999
|
}
|
|
1951
2000
|
}
|
|
1952
|
-
},
|
|
2001
|
+
}, _callee5, null, [[15, 22]]);
|
|
1953
2002
|
}));
|
|
1954
2003
|
|
|
1955
|
-
return function loadImpl(
|
|
1956
|
-
return
|
|
2004
|
+
return function loadImpl(_x3, _x4) {
|
|
2005
|
+
return _ref3.apply(this, arguments);
|
|
1957
2006
|
};
|
|
1958
2007
|
}();
|
|
1959
2008
|
|
|
@@ -1964,35 +2013,35 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
1964
2013
|
if (callback) {
|
|
1965
2014
|
return {
|
|
1966
2015
|
unsubscribe: function () {
|
|
1967
|
-
var _unsubscribe = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2016
|
+
var _unsubscribe = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
1968
2017
|
var requestInstance;
|
|
1969
|
-
return _regeneratorRuntime.wrap(function
|
|
2018
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
1970
2019
|
while (1) {
|
|
1971
|
-
switch (
|
|
2020
|
+
switch (_context6.prev = _context6.next) {
|
|
1972
2021
|
case 0:
|
|
1973
|
-
|
|
2022
|
+
_context6.next = 2;
|
|
1974
2023
|
return requestPromise;
|
|
1975
2024
|
|
|
1976
2025
|
case 2:
|
|
1977
|
-
requestInstance =
|
|
2026
|
+
requestInstance = _context6.sent;
|
|
1978
2027
|
unsubscribed = true;
|
|
1979
2028
|
|
|
1980
2029
|
if (!requestInstance.unsubscribe) {
|
|
1981
|
-
|
|
2030
|
+
_context6.next = 6;
|
|
1982
2031
|
break;
|
|
1983
2032
|
}
|
|
1984
2033
|
|
|
1985
|
-
return
|
|
2034
|
+
return _context6.abrupt("return", requestInstance.unsubscribe());
|
|
1986
2035
|
|
|
1987
2036
|
case 6:
|
|
1988
|
-
return
|
|
2037
|
+
return _context6.abrupt("return", null);
|
|
1989
2038
|
|
|
1990
2039
|
case 7:
|
|
1991
2040
|
case "end":
|
|
1992
|
-
return
|
|
2041
|
+
return _context6.stop();
|
|
1993
2042
|
}
|
|
1994
2043
|
}
|
|
1995
|
-
},
|
|
2044
|
+
}, _callee6);
|
|
1996
2045
|
}));
|
|
1997
2046
|
|
|
1998
2047
|
function unsubscribe() {
|
|
@@ -2009,33 +2058,83 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
2009
2058
|
}, {
|
|
2010
2059
|
key: "updateTransportAuthorization",
|
|
2011
2060
|
value: function () {
|
|
2012
|
-
var _updateTransportAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2013
|
-
var
|
|
2014
|
-
|
|
2061
|
+
var _updateTransportAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
2062
|
+
var _this2 = this;
|
|
2063
|
+
|
|
2064
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
2015
2065
|
while (1) {
|
|
2016
|
-
switch (
|
|
2066
|
+
switch (_context8.prev = _context8.next) {
|
|
2017
2067
|
case 0:
|
|
2018
|
-
if (!
|
|
2019
|
-
|
|
2068
|
+
if (!this.updateAuthorizationPromise) {
|
|
2069
|
+
_context8.next = 4;
|
|
2020
2070
|
break;
|
|
2021
2071
|
}
|
|
2022
2072
|
|
|
2023
|
-
|
|
2024
|
-
return this.
|
|
2073
|
+
_context8.next = 3;
|
|
2074
|
+
return this.updateAuthorizationPromise;
|
|
2025
2075
|
|
|
2026
2076
|
case 3:
|
|
2027
|
-
|
|
2077
|
+
return _context8.abrupt("return");
|
|
2028
2078
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2079
|
+
case 4:
|
|
2080
|
+
if (!(typeof this.apiToken === 'function')) {
|
|
2081
|
+
_context8.next = 8;
|
|
2082
|
+
break;
|
|
2031
2083
|
}
|
|
2032
2084
|
|
|
2033
|
-
|
|
2085
|
+
this.updateAuthorizationPromise = new Promise( /*#__PURE__*/function () {
|
|
2086
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(resolve, reject) {
|
|
2087
|
+
var token;
|
|
2088
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
2089
|
+
while (1) {
|
|
2090
|
+
switch (_context7.prev = _context7.next) {
|
|
2091
|
+
case 0:
|
|
2092
|
+
_context7.prev = 0;
|
|
2093
|
+
_context7.next = 3;
|
|
2094
|
+
return _this2.apiToken();
|
|
2095
|
+
|
|
2096
|
+
case 3:
|
|
2097
|
+
token = _context7.sent;
|
|
2098
|
+
|
|
2099
|
+
if (_this2.transport.authorization !== token) {
|
|
2100
|
+
_this2.transport.authorization = token;
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
resolve();
|
|
2104
|
+
_context7.next = 11;
|
|
2105
|
+
break;
|
|
2106
|
+
|
|
2107
|
+
case 8:
|
|
2108
|
+
_context7.prev = 8;
|
|
2109
|
+
_context7.t0 = _context7["catch"](0);
|
|
2110
|
+
reject(_context7.t0);
|
|
2111
|
+
|
|
2112
|
+
case 11:
|
|
2113
|
+
_context7.prev = 11;
|
|
2114
|
+
_this2.updateAuthorizationPromise = null;
|
|
2115
|
+
return _context7.finish(11);
|
|
2116
|
+
|
|
2117
|
+
case 14:
|
|
2118
|
+
case "end":
|
|
2119
|
+
return _context7.stop();
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
}, _callee7, null, [[0, 8, 11, 14]]);
|
|
2123
|
+
}));
|
|
2124
|
+
|
|
2125
|
+
return function (_x6, _x7) {
|
|
2126
|
+
return _ref6.apply(this, arguments);
|
|
2127
|
+
};
|
|
2128
|
+
}());
|
|
2129
|
+
_context8.next = 8;
|
|
2130
|
+
return this.updateAuthorizationPromise;
|
|
2131
|
+
|
|
2132
|
+
case 8:
|
|
2034
2133
|
case "end":
|
|
2035
|
-
return
|
|
2134
|
+
return _context8.stop();
|
|
2036
2135
|
}
|
|
2037
2136
|
}
|
|
2038
|
-
},
|
|
2137
|
+
}, _callee8, this);
|
|
2039
2138
|
}));
|
|
2040
2139
|
|
|
2041
2140
|
function updateTransportAuthorization() {
|
|
@@ -2047,26 +2146,26 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
2047
2146
|
}, {
|
|
2048
2147
|
key: "load",
|
|
2049
2148
|
value: function load(query, options, callback) {
|
|
2050
|
-
var
|
|
2149
|
+
var _this3 = this;
|
|
2051
2150
|
|
|
2052
2151
|
return this.loadMethod(function () {
|
|
2053
|
-
return
|
|
2152
|
+
return _this3.request('load', {
|
|
2054
2153
|
query: query,
|
|
2055
2154
|
queryType: 'multi'
|
|
2056
2155
|
});
|
|
2057
2156
|
}, function (response) {
|
|
2058
2157
|
return new ResultSet(response, {
|
|
2059
|
-
parseDateMeasures:
|
|
2158
|
+
parseDateMeasures: _this3.parseDateMeasures
|
|
2060
2159
|
});
|
|
2061
2160
|
}, options, callback);
|
|
2062
2161
|
}
|
|
2063
2162
|
}, {
|
|
2064
2163
|
key: "sql",
|
|
2065
2164
|
value: function sql(query, options, callback) {
|
|
2066
|
-
var
|
|
2165
|
+
var _this4 = this;
|
|
2067
2166
|
|
|
2068
2167
|
return this.loadMethod(function () {
|
|
2069
|
-
return
|
|
2168
|
+
return _this4.request('sql', {
|
|
2070
2169
|
query: query
|
|
2071
2170
|
});
|
|
2072
2171
|
}, function (response) {
|
|
@@ -2078,10 +2177,10 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
2078
2177
|
}, {
|
|
2079
2178
|
key: "meta",
|
|
2080
2179
|
value: function meta(options, callback) {
|
|
2081
|
-
var
|
|
2180
|
+
var _this5 = this;
|
|
2082
2181
|
|
|
2083
2182
|
return this.loadMethod(function () {
|
|
2084
|
-
return
|
|
2183
|
+
return _this5.request('meta');
|
|
2085
2184
|
}, function (body) {
|
|
2086
2185
|
return new Meta(body);
|
|
2087
2186
|
}, options, callback);
|
|
@@ -2089,10 +2188,10 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
2089
2188
|
}, {
|
|
2090
2189
|
key: "dryRun",
|
|
2091
2190
|
value: function dryRun(query, options, callback) {
|
|
2092
|
-
var
|
|
2191
|
+
var _this6 = this;
|
|
2093
2192
|
|
|
2094
2193
|
return this.loadMethod(function () {
|
|
2095
|
-
return
|
|
2194
|
+
return _this6.request('dry-run', {
|
|
2096
2195
|
query: query
|
|
2097
2196
|
});
|
|
2098
2197
|
}, function (response) {
|
|
@@ -2102,16 +2201,16 @@ var CubejsApi = /*#__PURE__*/function () {
|
|
|
2102
2201
|
}, {
|
|
2103
2202
|
key: "subscribe",
|
|
2104
2203
|
value: function subscribe(query, options, callback) {
|
|
2105
|
-
var
|
|
2204
|
+
var _this7 = this;
|
|
2106
2205
|
|
|
2107
2206
|
return this.loadMethod(function () {
|
|
2108
|
-
return
|
|
2207
|
+
return _this7.request('subscribe', {
|
|
2109
2208
|
query: query,
|
|
2110
2209
|
queryType: 'multi'
|
|
2111
2210
|
});
|
|
2112
2211
|
}, function (body) {
|
|
2113
2212
|
return new ResultSet(body, {
|
|
2114
|
-
parseDateMeasures:
|
|
2213
|
+
parseDateMeasures: _this7.parseDateMeasures
|
|
2115
2214
|
});
|
|
2116
2215
|
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
2117
2216
|
subscribe: true
|