@cubejs-client/core 0.29.5 → 0.29.29
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 +34 -0
- package/dist/cubejs-client-core.esm.js +122 -32
- package/dist/cubejs-client-core.esm.js.map +1 -1
- package/dist/cubejs-client-core.js +122 -32
- package/dist/cubejs-client-core.js.map +1 -1
- package/dist/cubejs-client-core.umd.js +157 -62
- package/dist/cubejs-client-core.umd.js.map +1 -1
- package/index.d.ts +18 -7
- package/package.json +3 -3
- package/src/index.js +118 -19
- package/src/index.test.js +454 -0
- package/src/tests/ResultSet.test.js +8 -0
|
@@ -3268,6 +3268,12 @@
|
|
|
3268
3268
|
}
|
|
3269
3269
|
});
|
|
3270
3270
|
|
|
3271
|
+
// `Array.isArray` method
|
|
3272
|
+
// https://tc39.es/ecma262/#sec-array.isarray
|
|
3273
|
+
_export({ target: 'Array', stat: true }, {
|
|
3274
|
+
isArray: isArray
|
|
3275
|
+
});
|
|
3276
|
+
|
|
3271
3277
|
var MSIE = /MSIE .\./.test(engineUserAgent); // <- dirty ie9- check
|
|
3272
3278
|
var Function$2 = global$1.Function;
|
|
3273
3279
|
|
|
@@ -3292,10 +3298,36 @@
|
|
|
3292
3298
|
setInterval: wrap(global$1.setInterval)
|
|
3293
3299
|
});
|
|
3294
3300
|
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3301
|
+
var Function$1 = global$1.Function;
|
|
3302
|
+
var concat = functionUncurryThis([].concat);
|
|
3303
|
+
var join$1 = functionUncurryThis([].join);
|
|
3304
|
+
var factories = {};
|
|
3305
|
+
|
|
3306
|
+
var construct = function (C, argsLength, args) {
|
|
3307
|
+
if (!hasOwnProperty_1(factories, argsLength)) {
|
|
3308
|
+
for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
|
|
3309
|
+
factories[argsLength] = Function$1('C,a', 'return new C(' + join$1(list, ',') + ')');
|
|
3310
|
+
} return factories[argsLength](C, args);
|
|
3311
|
+
};
|
|
3312
|
+
|
|
3313
|
+
// `Function.prototype.bind` method implementation
|
|
3314
|
+
// https://tc39.es/ecma262/#sec-function.prototype.bind
|
|
3315
|
+
var functionBind = Function$1.bind || function bind(that /* , ...args */) {
|
|
3316
|
+
var F = aCallable(this);
|
|
3317
|
+
var Prototype = F.prototype;
|
|
3318
|
+
var partArgs = arraySlice$1(arguments, 1);
|
|
3319
|
+
var boundFunction = function bound(/* args... */) {
|
|
3320
|
+
var args = concat(partArgs, arraySlice$1(arguments));
|
|
3321
|
+
return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
|
|
3322
|
+
};
|
|
3323
|
+
if (isObject(Prototype)) boundFunction.prototype = Prototype;
|
|
3324
|
+
return boundFunction;
|
|
3325
|
+
};
|
|
3326
|
+
|
|
3327
|
+
// `Function.prototype.bind` method
|
|
3328
|
+
// https://tc39.es/ecma262/#sec-function.prototype.bind
|
|
3329
|
+
_export({ target: 'Function', proto: true }, {
|
|
3330
|
+
bind: functionBind
|
|
3299
3331
|
});
|
|
3300
3332
|
|
|
3301
3333
|
var $map = arrayIteration.map;
|
|
@@ -9664,7 +9696,7 @@
|
|
|
9664
9696
|
var decodeURIComponent$1 = global$1.decodeURIComponent;
|
|
9665
9697
|
var encodeURIComponent$1 = global$1.encodeURIComponent;
|
|
9666
9698
|
var charAt = functionUncurryThis(''.charAt);
|
|
9667
|
-
var join
|
|
9699
|
+
var join = functionUncurryThis([].join);
|
|
9668
9700
|
var push$1 = functionUncurryThis([].push);
|
|
9669
9701
|
var replace = functionUncurryThis(''.replace);
|
|
9670
9702
|
var shift = functionUncurryThis([].shift);
|
|
@@ -9787,7 +9819,7 @@
|
|
|
9787
9819
|
entry = split(attribute, '=');
|
|
9788
9820
|
push$1(this.entries, {
|
|
9789
9821
|
key: deserialize(shift(entry)),
|
|
9790
|
-
value: deserialize(join
|
|
9822
|
+
value: deserialize(join(entry, '='))
|
|
9791
9823
|
});
|
|
9792
9824
|
}
|
|
9793
9825
|
}
|
|
@@ -9801,7 +9833,7 @@
|
|
|
9801
9833
|
while (index < entries.length) {
|
|
9802
9834
|
entry = entries[index++];
|
|
9803
9835
|
push$1(result, serialize(entry.key) + '=' + serialize(entry.value));
|
|
9804
|
-
} return join
|
|
9836
|
+
} return join(result, '&');
|
|
9805
9837
|
},
|
|
9806
9838
|
update: function () {
|
|
9807
9839
|
this.entries.length = 0;
|
|
@@ -10989,32 +11021,6 @@
|
|
|
10989
11021
|
return HttpTransport;
|
|
10990
11022
|
}();
|
|
10991
11023
|
|
|
10992
|
-
var Function$1 = global$1.Function;
|
|
10993
|
-
var concat = functionUncurryThis([].concat);
|
|
10994
|
-
var join = functionUncurryThis([].join);
|
|
10995
|
-
var factories = {};
|
|
10996
|
-
|
|
10997
|
-
var construct = function (C, argsLength, args) {
|
|
10998
|
-
if (!hasOwnProperty_1(factories, argsLength)) {
|
|
10999
|
-
for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
|
|
11000
|
-
factories[argsLength] = Function$1('C,a', 'return new C(' + join(list, ',') + ')');
|
|
11001
|
-
} return factories[argsLength](C, args);
|
|
11002
|
-
};
|
|
11003
|
-
|
|
11004
|
-
// `Function.prototype.bind` method implementation
|
|
11005
|
-
// https://tc39.es/ecma262/#sec-function.prototype.bind
|
|
11006
|
-
var functionBind = Function$1.bind || function bind(that /* , ...args */) {
|
|
11007
|
-
var F = aCallable(this);
|
|
11008
|
-
var Prototype = F.prototype;
|
|
11009
|
-
var partArgs = arraySlice$1(arguments, 1);
|
|
11010
|
-
var boundFunction = function bound(/* args... */) {
|
|
11011
|
-
var args = concat(partArgs, arraySlice$1(arguments));
|
|
11012
|
-
return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
|
|
11013
|
-
};
|
|
11014
|
-
if (isObject(Prototype)) boundFunction.prototype = Prototype;
|
|
11015
|
-
return boundFunction;
|
|
11016
|
-
};
|
|
11017
|
-
|
|
11018
11024
|
var nativeConstruct = getBuiltIn('Reflect', 'construct');
|
|
11019
11025
|
var ObjectPrototype = Object.prototype;
|
|
11020
11026
|
var push = [].push;
|
|
@@ -11209,6 +11215,14 @@
|
|
|
11209
11215
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11210
11216
|
var mutexCounter = 0;
|
|
11211
11217
|
var MUTEX_ERROR = 'Mutex has been changed';
|
|
11218
|
+
/**
|
|
11219
|
+
* Query result dataset formats enum.
|
|
11220
|
+
*/
|
|
11221
|
+
|
|
11222
|
+
var ResultType = {
|
|
11223
|
+
DEFAULT: 'default',
|
|
11224
|
+
COMPACT: 'compact'
|
|
11225
|
+
};
|
|
11212
11226
|
|
|
11213
11227
|
function mutexPromise(promise) {
|
|
11214
11228
|
return new Promise( /*#__PURE__*/function () {
|
|
@@ -11254,7 +11268,7 @@
|
|
|
11254
11268
|
function CubejsApi(apiToken, options) {
|
|
11255
11269
|
_classCallCheck(this, CubejsApi);
|
|
11256
11270
|
|
|
11257
|
-
if (_typeof(apiToken) === 'object') {
|
|
11271
|
+
if (apiToken !== null && !Array.isArray(apiToken) && _typeof(apiToken) === 'object') {
|
|
11258
11272
|
options = apiToken;
|
|
11259
11273
|
apiToken = undefined;
|
|
11260
11274
|
}
|
|
@@ -11731,29 +11745,128 @@
|
|
|
11731
11745
|
|
|
11732
11746
|
return updateTransportAuthorization;
|
|
11733
11747
|
}()
|
|
11748
|
+
/**
|
|
11749
|
+
* Add system properties to a query object.
|
|
11750
|
+
* @param {Query} query
|
|
11751
|
+
* @param {string} responseFormat
|
|
11752
|
+
* @returns {void}
|
|
11753
|
+
* @private
|
|
11754
|
+
*/
|
|
11755
|
+
|
|
11756
|
+
}, {
|
|
11757
|
+
key: "patchQueryInternal",
|
|
11758
|
+
value: function patchQueryInternal(query, responseFormat) {
|
|
11759
|
+
if (responseFormat === ResultType.COMPACT && query.responseFormat !== ResultType.COMPACT) {
|
|
11760
|
+
query.responseFormat = ResultType.COMPACT;
|
|
11761
|
+
}
|
|
11762
|
+
}
|
|
11763
|
+
/**
|
|
11764
|
+
* Process result fetched from the gateway#load method according
|
|
11765
|
+
* to the network protocol.
|
|
11766
|
+
* @param {*} response
|
|
11767
|
+
* @returns ResultSet
|
|
11768
|
+
* @private
|
|
11769
|
+
*/
|
|
11770
|
+
|
|
11771
|
+
}, {
|
|
11772
|
+
key: "loadResponseInternal",
|
|
11773
|
+
value: function loadResponseInternal(response) {
|
|
11774
|
+
if (response.results.length && response.results[0].query.responseFormat && response.results[0].query.responseFormat === ResultType.COMPACT) {
|
|
11775
|
+
response.results.forEach(function (result, j) {
|
|
11776
|
+
var data = [];
|
|
11777
|
+
result.data.dataset.forEach(function (r) {
|
|
11778
|
+
var row = {};
|
|
11779
|
+
result.data.members.forEach(function (m, i) {
|
|
11780
|
+
row[m] = r[i];
|
|
11781
|
+
});
|
|
11782
|
+
data.push(row);
|
|
11783
|
+
});
|
|
11784
|
+
response.results[j].data = data;
|
|
11785
|
+
});
|
|
11786
|
+
}
|
|
11787
|
+
|
|
11788
|
+
return new ResultSet(response, {
|
|
11789
|
+
parseDateMeasures: this.parseDateMeasures
|
|
11790
|
+
});
|
|
11791
|
+
}
|
|
11792
|
+
/**
|
|
11793
|
+
* Fetch data for the passed `query`. Operates with the
|
|
11794
|
+
* `ApiGateway#load` method to fetch the data.
|
|
11795
|
+
* @param {Query | Query[]} query
|
|
11796
|
+
* @param {LoadMethodOptions | undefined} options
|
|
11797
|
+
* @param {LoadMethodCallback<ResultSet> | undefined} callback
|
|
11798
|
+
* @param {string} responseFormat
|
|
11799
|
+
* @returns {undefined | Promise<ResultSet>}
|
|
11800
|
+
*/
|
|
11801
|
+
|
|
11734
11802
|
}, {
|
|
11735
11803
|
key: "load",
|
|
11736
11804
|
value: function load(query, options, callback) {
|
|
11737
11805
|
var _this3 = this;
|
|
11738
11806
|
|
|
11807
|
+
var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ResultType.DEFAULT;
|
|
11808
|
+
|
|
11809
|
+
if (responseFormat === ResultType.COMPACT) {
|
|
11810
|
+
if (Array.isArray(query)) {
|
|
11811
|
+
query.forEach(function (q) {
|
|
11812
|
+
_this3.patchQueryInternal(q, ResultType.COMPACT);
|
|
11813
|
+
});
|
|
11814
|
+
} else {
|
|
11815
|
+
this.patchQueryInternal(query, ResultType.COMPACT);
|
|
11816
|
+
}
|
|
11817
|
+
}
|
|
11818
|
+
|
|
11739
11819
|
return this.loadMethod(function () {
|
|
11740
11820
|
return _this3.request('load', {
|
|
11741
11821
|
query: query,
|
|
11742
11822
|
queryType: 'multi'
|
|
11743
11823
|
});
|
|
11744
|
-
},
|
|
11745
|
-
|
|
11746
|
-
|
|
11824
|
+
}, this.loadResponseInternal.bind(this), options, callback);
|
|
11825
|
+
}
|
|
11826
|
+
/**
|
|
11827
|
+
* Allows you to fetch data and receive updates over time. Operates
|
|
11828
|
+
* with the `ApiGateway#load` method to fetch the data.
|
|
11829
|
+
* @link real-time-data-fetch
|
|
11830
|
+
* @param {Query | Query[]} query
|
|
11831
|
+
* @param {LoadMethodOptions | null} options
|
|
11832
|
+
* @param {LoadMethodCallback<ResultSet> | undefined} callback
|
|
11833
|
+
* @param {string} responseFormat
|
|
11834
|
+
* @returns {void}
|
|
11835
|
+
*/
|
|
11836
|
+
|
|
11837
|
+
}, {
|
|
11838
|
+
key: "subscribe",
|
|
11839
|
+
value: function subscribe(query, options, callback) {
|
|
11840
|
+
var _this4 = this;
|
|
11841
|
+
|
|
11842
|
+
var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ResultType.DEFAULT;
|
|
11843
|
+
|
|
11844
|
+
if (responseFormat === ResultType.COMPACT) {
|
|
11845
|
+
if (Array.isArray(query)) {
|
|
11846
|
+
query.forEach(function (q) {
|
|
11847
|
+
_this4.patchQueryInternal(q, ResultType.COMPACT);
|
|
11848
|
+
});
|
|
11849
|
+
} else {
|
|
11850
|
+
this.patchQueryInternal(query, ResultType.COMPACT);
|
|
11851
|
+
}
|
|
11852
|
+
}
|
|
11853
|
+
|
|
11854
|
+
return this.loadMethod(function () {
|
|
11855
|
+
return _this4.request('subscribe', {
|
|
11856
|
+
query: query,
|
|
11857
|
+
queryType: 'multi'
|
|
11747
11858
|
});
|
|
11748
|
-
}, options,
|
|
11859
|
+
}, this.loadResponseInternal.bind(this), _objectSpread(_objectSpread({}, options), {}, {
|
|
11860
|
+
subscribe: true
|
|
11861
|
+
}), callback);
|
|
11749
11862
|
}
|
|
11750
11863
|
}, {
|
|
11751
11864
|
key: "sql",
|
|
11752
11865
|
value: function sql(query, options, callback) {
|
|
11753
|
-
var
|
|
11866
|
+
var _this5 = this;
|
|
11754
11867
|
|
|
11755
11868
|
return this.loadMethod(function () {
|
|
11756
|
-
return
|
|
11869
|
+
return _this5.request('sql', {
|
|
11757
11870
|
query: query
|
|
11758
11871
|
});
|
|
11759
11872
|
}, function (response) {
|
|
@@ -11765,10 +11878,10 @@
|
|
|
11765
11878
|
}, {
|
|
11766
11879
|
key: "meta",
|
|
11767
11880
|
value: function meta(options, callback) {
|
|
11768
|
-
var
|
|
11881
|
+
var _this6 = this;
|
|
11769
11882
|
|
|
11770
11883
|
return this.loadMethod(function () {
|
|
11771
|
-
return
|
|
11884
|
+
return _this6.request('meta');
|
|
11772
11885
|
}, function (body) {
|
|
11773
11886
|
return new Meta(body);
|
|
11774
11887
|
}, options, callback);
|
|
@@ -11776,34 +11889,16 @@
|
|
|
11776
11889
|
}, {
|
|
11777
11890
|
key: "dryRun",
|
|
11778
11891
|
value: function dryRun(query, options, callback) {
|
|
11779
|
-
var
|
|
11892
|
+
var _this7 = this;
|
|
11780
11893
|
|
|
11781
11894
|
return this.loadMethod(function () {
|
|
11782
|
-
return
|
|
11895
|
+
return _this7.request('dry-run', {
|
|
11783
11896
|
query: query
|
|
11784
11897
|
});
|
|
11785
11898
|
}, function (response) {
|
|
11786
11899
|
return response;
|
|
11787
11900
|
}, options, callback);
|
|
11788
11901
|
}
|
|
11789
|
-
}, {
|
|
11790
|
-
key: "subscribe",
|
|
11791
|
-
value: function subscribe(query, options, callback) {
|
|
11792
|
-
var _this7 = this;
|
|
11793
|
-
|
|
11794
|
-
return this.loadMethod(function () {
|
|
11795
|
-
return _this7.request('subscribe', {
|
|
11796
|
-
query: query,
|
|
11797
|
-
queryType: 'multi'
|
|
11798
|
-
});
|
|
11799
|
-
}, function (body) {
|
|
11800
|
-
return new ResultSet(body, {
|
|
11801
|
-
parseDateMeasures: _this7.parseDateMeasures
|
|
11802
|
-
});
|
|
11803
|
-
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
11804
|
-
subscribe: true
|
|
11805
|
-
}), callback);
|
|
11806
|
-
}
|
|
11807
11902
|
}]);
|
|
11808
11903
|
|
|
11809
11904
|
return CubejsApi;
|