@cubejs-client/core 1.8.13 → 1.8.15

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.
@@ -8,6 +8,7 @@ require('core-js/modules/es.array.is-array.js');
8
8
  require('core-js/modules/es.array.map.js');
9
9
  require('core-js/modules/es.array.reduce.js');
10
10
  require('core-js/modules/es.array.slice.js');
11
+ require('core-js/modules/es.date.to-json.js');
11
12
  require('core-js/modules/es.function.name.js');
12
13
  require('core-js/modules/es.number.constructor.js');
13
14
  require('core-js/modules/es.object.entries.js');
@@ -51,7 +52,6 @@ var duration = require('dayjs/plugin/duration.js');
51
52
  var isoWeek = require('dayjs/plugin/isoWeek.js');
52
53
  var en = require('dayjs/locale/en.js');
53
54
  require('core-js/modules/es.array.sort.js');
54
- require('core-js/modules/es.date.to-json.js');
55
55
  require('core-js/modules/web.url-search-params.js');
56
56
  require('url-search-params-polyfill');
57
57
 
@@ -3113,8 +3113,8 @@ var CubeApi = /*#__PURE__*/function () {
3113
3113
  var networkRetries = this.networkErrorRetries;
3114
3114
  var loadImpl = /*#__PURE__*/function () {
3115
3115
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(response, next) {
3116
- var _options2, _response$error, _body$error, _options5;
3117
- var requestInstance, subscribeNext, continueWait, body, text, _options3, _options4, _error, result;
3116
+ var _options2, _response$error, _body$error, _options4;
3117
+ var requestInstance, subscribeNext, continueWait, body, text, _options3, result, error, _t2;
3118
3118
  return _regenerator().w(function (_context4) {
3119
3119
  while (1) switch (_context4.p = _context4.n) {
3120
3120
  case 0:
@@ -3234,10 +3234,6 @@ var CubeApi = /*#__PURE__*/function () {
3234
3234
  }
3235
3235
  return _context4.a(2, continueWait());
3236
3236
  case 10:
3237
- if (!(response.status !== 200)) {
3238
- _context4.n = 15;
3239
- break;
3240
- }
3241
3237
  _context4.n = 11;
3242
3238
  return checkMutex();
3243
3239
  case 11:
@@ -3248,43 +3244,60 @@ var CubeApi = /*#__PURE__*/function () {
3248
3244
  _context4.n = 12;
3249
3245
  return requestInstance.unsubscribe();
3250
3246
  case 12:
3251
- _error = new RequestError(body.error || response.error || '', body, response.status);
3252
- if (!callback) {
3247
+ error = null;
3248
+ if (!(response.status !== 200)) {
3253
3249
  _context4.n = 13;
3254
3250
  break;
3255
3251
  }
3256
- callback(_error);
3257
- _context4.n = 14;
3252
+ error = new RequestError(body.error || response.error || '', body, response.status);
3253
+ _context4.n = 16;
3258
3254
  break;
3259
3255
  case 13:
3260
- throw _error;
3256
+ _context4.p = 13;
3257
+ result = toResult(body);
3258
+ _context4.n = 16;
3259
+ break;
3261
3260
  case 14:
3262
- return _context4.a(2, subscribeNext());
3261
+ _context4.p = 14;
3262
+ _t2 = _context4.v;
3263
+ if (_t2 instanceof RequestError) {
3264
+ _context4.n = 15;
3265
+ break;
3266
+ }
3267
+ throw _t2;
3263
3268
  case 15:
3264
- _context4.n = 16;
3265
- return checkMutex();
3269
+ error = _t2;
3266
3270
  case 16:
3267
- if (!(!((_options5 = options) !== null && _options5 !== void 0 && _options5.subscribe) && requestInstance.unsubscribe)) {
3271
+ if (!error) {
3272
+ _context4.n = 19;
3273
+ break;
3274
+ }
3275
+ if (!callback) {
3268
3276
  _context4.n = 17;
3269
3277
  break;
3270
3278
  }
3271
- _context4.n = 17;
3272
- return requestInstance.unsubscribe();
3279
+ callback(error);
3280
+ _context4.n = 18;
3281
+ break;
3273
3282
  case 17:
3274
- result = toResult(body);
3283
+ throw error;
3284
+ case 18:
3285
+ _context4.n = 21;
3286
+ break;
3287
+ case 19:
3275
3288
  if (!callback) {
3276
- _context4.n = 18;
3289
+ _context4.n = 20;
3277
3290
  break;
3278
3291
  }
3279
3292
  callback(null, result);
3280
- _context4.n = 19;
3293
+ _context4.n = 21;
3281
3294
  break;
3282
- case 18:
3295
+ case 20:
3283
3296
  return _context4.a(2, result);
3284
- case 19:
3297
+ case 21:
3285
3298
  return _context4.a(2, subscribeNext());
3286
3299
  }
3287
- }, _callee4, null, [[5, 7]]);
3300
+ }, _callee4, null, [[13, 14], [5, 7]]);
3288
3301
  }));
3289
3302
  return function loadImpl(_x, _x2) {
3290
3303
  return _ref2.apply(this, arguments);
@@ -3407,6 +3420,11 @@ var CubeApi = /*#__PURE__*/function () {
3407
3420
  key: "loadResponseInternal",
3408
3421
  value: function loadResponseInternal(response) {
3409
3422
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3423
+ // A 200 that isn't a load response, e.g. a non-JSON body like "[object Blob]" (#6149)
3424
+ if (!Array.isArray(response === null || response === void 0 ? void 0 : response.results)) {
3425
+ var body = response;
3426
+ throw new RequestError(body.error || "Invalid load response: ".concat(JSON.stringify(response)), response, 200);
3427
+ }
3410
3428
  if (response.results.length) {
3411
3429
  if (options !== null && options !== void 0 && options.castNumerics) {
3412
3430
  response.results.forEach(function (result) {
@@ -3501,9 +3519,9 @@ var CubeApi = /*#__PURE__*/function () {
3501
3519
  * @param responseFormat
3502
3520
  */
3503
3521
  function load(query, options, callback) {
3504
- var _options6,
3522
+ var _options5,
3523
+ _options6,
3505
3524
  _options7,
3506
- _options8,
3507
3525
  _this4 = this;
3508
3526
  var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'default';
3509
3527
  var _this$prepareQueryOpt = this.prepareQueryOptions(query, options, responseFormat);
@@ -3513,10 +3531,10 @@ var CubeApi = /*#__PURE__*/function () {
3513
3531
  var params = {
3514
3532
  query: query,
3515
3533
  queryType: 'multi',
3516
- signal: (_options6 = options) === null || _options6 === void 0 ? void 0 : _options6.signal,
3517
- baseRequestId: (_options7 = options) === null || _options7 === void 0 ? void 0 : _options7.baseRequestId
3534
+ signal: (_options5 = options) === null || _options5 === void 0 ? void 0 : _options5.signal,
3535
+ baseRequestId: (_options6 = options) === null || _options6 === void 0 ? void 0 : _options6.baseRequestId
3518
3536
  };
3519
- if ((_options8 = options) !== null && _options8 !== void 0 && _options8.cache) {
3537
+ if ((_options7 = options) !== null && _options7 !== void 0 && _options7.cache) {
3520
3538
  params.cache = options.cache;
3521
3539
  }
3522
3540
  return this.loadMethod(function () {
@@ -3585,12 +3603,12 @@ var CubeApi = /*#__PURE__*/function () {
3585
3603
  query = _this$prepareQueryOpt4[0];
3586
3604
  options = _this$prepareQueryOpt4[1];
3587
3605
  return this.loadMethod(function () {
3588
- var _options9, _options0;
3606
+ var _options8, _options9;
3589
3607
  return _this6.request('subscribe', {
3590
3608
  query: query,
3591
3609
  queryType: 'multi',
3592
- signal: (_options9 = options) === null || _options9 === void 0 ? void 0 : _options9.signal,
3593
- baseRequestId: (_options0 = options) === null || _options0 === void 0 ? void 0 : _options0.baseRequestId
3610
+ signal: (_options8 = options) === null || _options8 === void 0 ? void 0 : _options8.signal,
3611
+ baseRequestId: (_options9 = options) === null || _options9 === void 0 ? void 0 : _options9.baseRequestId
3594
3612
  });
3595
3613
  }, function (response) {
3596
3614
  return _this6.loadResponseInternal(response, options);
@@ -3773,7 +3791,7 @@ var CubeApi = /*#__PURE__*/function () {
3773
3791
  value: function cubeSqlStream(sqlQuery, options) {
3774
3792
  var _this = this;
3775
3793
  return _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
3776
- var streamResponse, decoder, buffer, stream, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, lines, _iterator3, _step3, line, parsed, _parsed, _t3, _t4, _t6;
3794
+ var streamResponse, decoder, buffer, stream, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, lines, _iterator3, _step3, line, parsed, _parsed, _t4, _t5, _t7;
3777
3795
  return _regenerator().w(function (_context8) {
3778
3796
  while (1) switch (_context8.p = _context8.n) {
3779
3797
  case 0:
@@ -3888,8 +3906,8 @@ var CubeApi = /*#__PURE__*/function () {
3888
3906
  break;
3889
3907
  case 18:
3890
3908
  _context8.p = 18;
3891
- _t3 = _context8.v;
3892
- _iterator3.e(_t3);
3909
+ _t4 = _context8.v;
3910
+ _iterator3.e(_t4);
3893
3911
  case 19:
3894
3912
  _context8.p = 19;
3895
3913
  _iterator3.f();
@@ -3903,9 +3921,9 @@ var CubeApi = /*#__PURE__*/function () {
3903
3921
  break;
3904
3922
  case 22:
3905
3923
  _context8.p = 22;
3906
- _t4 = _context8.v;
3924
+ _t5 = _context8.v;
3907
3925
  _didIteratorError = true;
3908
- _iteratorError = _t4;
3926
+ _iteratorError = _t5;
3909
3927
  case 23:
3910
3928
  _context8.p = 23;
3911
3929
  _context8.p = 24;
@@ -3984,14 +4002,14 @@ var CubeApi = /*#__PURE__*/function () {
3984
4002
  break;
3985
4003
  case 37:
3986
4004
  _context8.p = 37;
3987
- _t6 = _context8.v;
3988
- if (!(_t6.name === 'AbortError')) {
4005
+ _t7 = _context8.v;
4006
+ if (!(_t7.name === 'AbortError')) {
3989
4007
  _context8.n = 38;
3990
4008
  break;
3991
4009
  }
3992
4010
  throw new Error('aborted');
3993
4011
  case 38:
3994
- throw _t6;
4012
+ throw _t7;
3995
4013
  case 39:
3996
4014
  _context8.p = 39;
3997
4015
  if (!streamResponse.unsubscribe) {