@cubejs-client/core 1.6.59 → 1.6.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.
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('core-js/modules/es.array.concat.js');
6
- require('core-js/modules/es.array.filter.js');
7
5
  require('core-js/modules/es.array.for-each.js');
8
6
  require('core-js/modules/es.array.includes.js');
9
7
  require('core-js/modules/es.array.is-array.js');
@@ -21,6 +19,8 @@ require('core-js/modules/es.string.trim.js');
21
19
  require('core-js/modules/web.dom-collections.for-each.js');
22
20
  require('core-js/modules/web.timers.js');
23
21
  var uuid = require('uuid');
22
+ require('core-js/modules/es.array.concat.js');
23
+ require('core-js/modules/es.array.filter.js');
24
24
  require('core-js/modules/es.array.find.js');
25
25
  require('core-js/modules/es.array.from.js');
26
26
  require('core-js/modules/es.array.index-of.js');
@@ -3779,23 +3779,53 @@ var CubeApi = /*#__PURE__*/function () {
3779
3779
  _response$error$split2 = _toArray(_response$error$split),
3780
3780
  schema = _response$error$split2[0],
3781
3781
  data = _arrayLikeToArray(_response$error$split2).slice(1);
3782
+ var parsedSchema;
3782
3783
  try {
3783
- var parsedSchema = JSON.parse(schema);
3784
- return _objectSpread2({
3785
- schema: parsedSchema.schema,
3786
- data: data.filter(function (d) {
3787
- return d.trim().length;
3788
- }).map(function (d) {
3789
- return JSON.parse(d).data;
3790
- }).reduce(function (a, b) {
3791
- return a.concat(b);
3792
- }, [])
3793
- }, parsedSchema.lastRefreshTime ? {
3794
- lastRefreshTime: parsedSchema.lastRefreshTime
3795
- } : {});
3784
+ parsedSchema = JSON.parse(schema);
3796
3785
  } catch (err) {
3786
+ // Schema line isn't valid JSON — the whole `error` payload is a real error.
3797
3787
  throw new Error(response.error);
3798
3788
  }
3789
+ var rows = [];
3790
+ var _iterator2 = _createForOfIteratorHelper(data),
3791
+ _step2;
3792
+ try {
3793
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3794
+ var line = _step2.value;
3795
+ if (line.trim().length) {
3796
+ var parsed = void 0;
3797
+ try {
3798
+ parsed = JSON.parse(line);
3799
+ } catch (err) {
3800
+ // A non-JSON line after a valid schema means a malformed payload — fall
3801
+ // back to surfacing the raw response rather than dropping rows silently.
3802
+ throw new Error(response.error);
3803
+ }
3804
+
3805
+ // The stream can interleave an error chunk after the schema (e.g. a
3806
+ // post-processing/cast error surfaced mid-result). Such a line has no
3807
+ // `data`, so the previous `JSON.parse(d).data` concat pushed an `undefined`
3808
+ // "phantom" row and silently swallowed the failure. Surface it instead —
3809
+ // matching how `cubeSqlStream` classifies `error` chunks.
3810
+ if (parsed.error) {
3811
+ throw new Error(parsed.error);
3812
+ }
3813
+ if (parsed.data) {
3814
+ rows.push.apply(rows, _toConsumableArray(parsed.data));
3815
+ }
3816
+ }
3817
+ }
3818
+ } catch (err) {
3819
+ _iterator2.e(err);
3820
+ } finally {
3821
+ _iterator2.f();
3822
+ }
3823
+ return _objectSpread2({
3824
+ schema: parsedSchema.schema,
3825
+ data: rows
3826
+ }, parsedSchema.lastRefreshTime ? {
3827
+ lastRefreshTime: parsedSchema.lastRefreshTime
3828
+ } : {});
3799
3829
  }, options, callback);
3800
3830
  }
3801
3831
 
@@ -3808,7 +3838,7 @@ var CubeApi = /*#__PURE__*/function () {
3808
3838
  value: function cubeSqlStream(sqlQuery, options) {
3809
3839
  var _this = this;
3810
3840
  return _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
3811
- var streamResponse, decoder, buffer, stream, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, lines, _iterator2, _step2, line, parsed, _parsed, _t3, _t4, _t6;
3841
+ var streamResponse, decoder, buffer, stream, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, lines, _iterator3, _step3, line, parsed, _parsed, _t3, _t4, _t6;
3812
3842
  return _regenerator().w(function (_context8) {
3813
3843
  while (1) switch (_context8.p = _context8.n) {
3814
3844
  case 0:
@@ -3853,15 +3883,15 @@ var CubeApi = /*#__PURE__*/function () {
3853
3883
  });
3854
3884
  lines = buffer.split('\n');
3855
3885
  buffer = lines.pop() || '';
3856
- _iterator2 = _createForOfIteratorHelper(lines);
3886
+ _iterator3 = _createForOfIteratorHelper(lines);
3857
3887
  _context8.p = 7;
3858
- _iterator2.s();
3888
+ _iterator3.s();
3859
3889
  case 8:
3860
- if ((_step2 = _iterator2.n()).done) {
3890
+ if ((_step3 = _iterator3.n()).done) {
3861
3891
  _context8.n = 17;
3862
3892
  break;
3863
3893
  }
3864
- line = _step2.value;
3894
+ line = _step3.value;
3865
3895
  if (!line.trim()) {
3866
3896
  _context8.n = 16;
3867
3897
  break;
@@ -3925,10 +3955,10 @@ var CubeApi = /*#__PURE__*/function () {
3925
3955
  case 18:
3926
3956
  _context8.p = 18;
3927
3957
  _t3 = _context8.v;
3928
- _iterator2.e(_t3);
3958
+ _iterator3.e(_t3);
3929
3959
  case 19:
3930
3960
  _context8.p = 19;
3931
- _iterator2.f();
3961
+ _iterator3.f();
3932
3962
  return _context8.f(19);
3933
3963
  case 20:
3934
3964
  _iteratorAbruptCompletion = false;