@cubejs-client/core 1.3.52 → 1.3.53
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/dist/cubejs-client-core.cjs.js +624 -50
- package/dist/cubejs-client-core.cjs.js.map +1 -1
- package/dist/cubejs-client-core.umd.js +579 -38
- package/dist/cubejs-client-core.umd.js.map +1 -1
- package/dist/src/HttpTransport.d.ts +15 -2
- package/dist/src/HttpTransport.d.ts.map +1 -1
- package/dist/src/HttpTransport.js +88 -12
- package/dist/src/index.d.ts +31 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +140 -1
- package/dist/src/streaming.d.ts +2 -0
- package/dist/src/streaming.d.ts.map +1 -0
- package/dist/src/streaming.js +34 -0
- package/package.json +3 -3
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('core-js/modules/es.array.for-each.js'), require('core-js/modules/es.object.keys.js'), require('core-js/modules/es.object.to-string.js'), require('core-js/modules/web.dom-collections.for-each.js'), require('@babel/runtime/helpers/slicedToArray'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/helpers/typeof'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/regenerator'), require('core-js/modules/es.symbol.js'), require('core-js/modules/es.array.filter.js'), require('core-js/modules/es.array.is-array.js'), require('core-js/modules/es.object.define-properties.js'), require('core-js/modules/es.object.define-property.js'), require('core-js/modules/es.object.get-own-property-descriptor.js'), require('core-js/modules/es.object.get-own-property-descriptors.js'), require('core-js/modules/es.
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['core-js/modules/es.array.for-each.js', 'core-js/modules/es.object.keys.js', 'core-js/modules/es.object.to-string.js', 'core-js/modules/web.dom-collections.for-each.js', '@babel/runtime/helpers/slicedToArray', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/helpers/typeof', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/defineProperty', '@babel/runtime/regenerator', 'core-js/modules/es.symbol.js', 'core-js/modules/es.array.filter.js', 'core-js/modules/es.array.is-array.js', 'core-js/modules/es.object.define-properties.js', 'core-js/modules/es.object.define-property.js', 'core-js/modules/es.object.get-own-property-descriptor.js', 'core-js/modules/es.object.get-own-property-descriptors.js', 'core-js/modules/es.
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.cubejs = factory(null, null, null, null, global._slicedToArray, global._asyncToGenerator, global._typeof, global._classCallCheck, global._createClass, global._defineProperty, global._regeneratorRuntime, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
|
5
|
-
}(this, (function (es_array_forEach_js, es_object_keys_js, es_object_toString_js, web_domCollections_forEach_js, _slicedToArray, _asyncToGenerator, _typeof, _classCallCheck, _createClass, _defineProperty, _regeneratorRuntime, es_symbol_js, es_array_filter_js, es_array_isArray_js, es_object_defineProperties_js, es_object_defineProperty_js, es_object_getOwnPropertyDescriptor_js, es_object_getOwnPropertyDescriptors_js,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('core-js/modules/es.array.for-each.js'), require('core-js/modules/es.object.keys.js'), require('core-js/modules/es.object.to-string.js'), require('core-js/modules/web.dom-collections.for-each.js'), require('@babel/runtime/helpers/toArray'), require('@babel/runtime/helpers/slicedToArray'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/helpers/typeof'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/awaitAsyncGenerator'), require('@babel/runtime/helpers/wrapAsyncGenerator'), require('@babel/runtime/regenerator'), require('core-js/modules/es.symbol.js'), require('core-js/modules/es.symbol.description.js'), require('core-js/modules/es.symbol.async-iterator.js'), require('core-js/modules/es.symbol.iterator.js'), require('core-js/modules/es.array.concat.js'), require('core-js/modules/es.array.filter.js'), require('core-js/modules/es.array.from.js'), require('core-js/modules/es.array.is-array.js'), require('core-js/modules/es.array.iterator.js'), require('core-js/modules/es.array.map.js'), require('core-js/modules/es.array.reduce.js'), require('core-js/modules/es.array.slice.js'), require('core-js/modules/es.function.name.js'), require('core-js/modules/es.date.to-string.js'), require('core-js/modules/es.number.constructor.js'), require('core-js/modules/es.object.entries.js'), require('core-js/modules/es.object.define-properties.js'), require('core-js/modules/es.object.define-property.js'), require('core-js/modules/es.object.get-own-property-descriptor.js'), require('core-js/modules/es.object.get-own-property-descriptors.js'), require('core-js/modules/es.promise.js'), require('core-js/modules/es.regexp.exec.js'), require('core-js/modules/es.regexp.to-string.js'), require('core-js/modules/es.string.iterator.js'), require('core-js/modules/es.string.trim.js'), require('core-js/modules/web.dom-collections.iterator.js'), require('core-js/modules/web.timers.js'), require('uuid'), require('@babel/runtime/helpers/readOnlyError'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/toConsumableArray'), require('core-js/modules/es.array.find.js'), require('core-js/modules/es.array.includes.js'), require('core-js/modules/es.array.index-of.js'), require('core-js/modules/es.array.join.js'), require('core-js/modules/es.map.js'), require('core-js/modules/es.number.is-nan.js'), require('core-js/modules/es.number.parse-float.js'), require('core-js/modules/es.object.values.js'), require('core-js/modules/es.set.js'), require('core-js/modules/es.string.includes.js'), require('core-js/modules/es.string.match.js'), require('dayjs'), require('ramda'), require('core-js/modules/es.array.every.js'), require('core-js/modules/es.array.flat-map.js'), require('core-js/modules/es.array.splice.js'), require('core-js/modules/es.array.unscopables.flat-map.js'), require('core-js/modules/es.parse-int.js'), require('core-js/modules/es.string.ends-with.js'), require('core-js/modules/es.string.split.js'), require('dayjs/plugin/quarterOfYear'), require('dayjs/plugin/duration'), require('dayjs/plugin/isoWeek'), require('dayjs/locale/en'), require('core-js/modules/es.array.sort.js'), require('core-js/modules/es.date.to-json.js'), require('core-js/modules/web.url-search-params.js'), require('cross-fetch'), require('url-search-params-polyfill'), require('core-js/modules/es.array-buffer.constructor.js'), require('core-js/modules/es.array-buffer.slice.js'), require('core-js/modules/es.data-view.js'), require('core-js/modules/es.typed-array.uint8-array.js'), require('core-js/modules/es.typed-array.copy-within.js'), require('core-js/modules/es.typed-array.every.js'), require('core-js/modules/es.typed-array.fill.js'), require('core-js/modules/es.typed-array.filter.js'), require('core-js/modules/es.typed-array.find.js'), require('core-js/modules/es.typed-array.find-index.js'), require('core-js/modules/es.typed-array.for-each.js'), require('core-js/modules/es.typed-array.includes.js'), require('core-js/modules/es.typed-array.index-of.js'), require('core-js/modules/es.typed-array.iterator.js'), require('core-js/modules/es.typed-array.join.js'), require('core-js/modules/es.typed-array.last-index-of.js'), require('core-js/modules/es.typed-array.map.js'), require('core-js/modules/es.typed-array.reduce.js'), require('core-js/modules/es.typed-array.reduce-right.js'), require('core-js/modules/es.typed-array.reverse.js'), require('core-js/modules/es.typed-array.set.js'), require('core-js/modules/es.typed-array.slice.js'), require('core-js/modules/es.typed-array.some.js'), require('core-js/modules/es.typed-array.sort.js'), require('core-js/modules/es.typed-array.subarray.js'), require('core-js/modules/es.typed-array.to-locale-string.js'), require('core-js/modules/es.typed-array.to-string.js'), require('core-js/modules/es.reflect.construct.js'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/wrapNativeSuper')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['core-js/modules/es.array.for-each.js', 'core-js/modules/es.object.keys.js', 'core-js/modules/es.object.to-string.js', 'core-js/modules/web.dom-collections.for-each.js', '@babel/runtime/helpers/toArray', '@babel/runtime/helpers/slicedToArray', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/helpers/typeof', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/awaitAsyncGenerator', '@babel/runtime/helpers/wrapAsyncGenerator', '@babel/runtime/regenerator', 'core-js/modules/es.symbol.js', 'core-js/modules/es.symbol.description.js', 'core-js/modules/es.symbol.async-iterator.js', 'core-js/modules/es.symbol.iterator.js', 'core-js/modules/es.array.concat.js', 'core-js/modules/es.array.filter.js', 'core-js/modules/es.array.from.js', 'core-js/modules/es.array.is-array.js', 'core-js/modules/es.array.iterator.js', 'core-js/modules/es.array.map.js', 'core-js/modules/es.array.reduce.js', 'core-js/modules/es.array.slice.js', 'core-js/modules/es.function.name.js', 'core-js/modules/es.date.to-string.js', 'core-js/modules/es.number.constructor.js', 'core-js/modules/es.object.entries.js', 'core-js/modules/es.object.define-properties.js', 'core-js/modules/es.object.define-property.js', 'core-js/modules/es.object.get-own-property-descriptor.js', 'core-js/modules/es.object.get-own-property-descriptors.js', 'core-js/modules/es.promise.js', 'core-js/modules/es.regexp.exec.js', 'core-js/modules/es.regexp.to-string.js', 'core-js/modules/es.string.iterator.js', 'core-js/modules/es.string.trim.js', 'core-js/modules/web.dom-collections.iterator.js', 'core-js/modules/web.timers.js', 'uuid', '@babel/runtime/helpers/readOnlyError', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/toConsumableArray', 'core-js/modules/es.array.find.js', 'core-js/modules/es.array.includes.js', 'core-js/modules/es.array.index-of.js', 'core-js/modules/es.array.join.js', 'core-js/modules/es.map.js', 'core-js/modules/es.number.is-nan.js', 'core-js/modules/es.number.parse-float.js', 'core-js/modules/es.object.values.js', 'core-js/modules/es.set.js', 'core-js/modules/es.string.includes.js', 'core-js/modules/es.string.match.js', 'dayjs', 'ramda', 'core-js/modules/es.array.every.js', 'core-js/modules/es.array.flat-map.js', 'core-js/modules/es.array.splice.js', 'core-js/modules/es.array.unscopables.flat-map.js', 'core-js/modules/es.parse-int.js', 'core-js/modules/es.string.ends-with.js', 'core-js/modules/es.string.split.js', 'dayjs/plugin/quarterOfYear', 'dayjs/plugin/duration', 'dayjs/plugin/isoWeek', 'dayjs/locale/en', 'core-js/modules/es.array.sort.js', 'core-js/modules/es.date.to-json.js', 'core-js/modules/web.url-search-params.js', 'cross-fetch', 'url-search-params-polyfill', 'core-js/modules/es.array-buffer.constructor.js', 'core-js/modules/es.array-buffer.slice.js', 'core-js/modules/es.data-view.js', 'core-js/modules/es.typed-array.uint8-array.js', 'core-js/modules/es.typed-array.copy-within.js', 'core-js/modules/es.typed-array.every.js', 'core-js/modules/es.typed-array.fill.js', 'core-js/modules/es.typed-array.filter.js', 'core-js/modules/es.typed-array.find.js', 'core-js/modules/es.typed-array.find-index.js', 'core-js/modules/es.typed-array.for-each.js', 'core-js/modules/es.typed-array.includes.js', 'core-js/modules/es.typed-array.index-of.js', 'core-js/modules/es.typed-array.iterator.js', 'core-js/modules/es.typed-array.join.js', 'core-js/modules/es.typed-array.last-index-of.js', 'core-js/modules/es.typed-array.map.js', 'core-js/modules/es.typed-array.reduce.js', 'core-js/modules/es.typed-array.reduce-right.js', 'core-js/modules/es.typed-array.reverse.js', 'core-js/modules/es.typed-array.set.js', 'core-js/modules/es.typed-array.slice.js', 'core-js/modules/es.typed-array.some.js', 'core-js/modules/es.typed-array.sort.js', 'core-js/modules/es.typed-array.subarray.js', 'core-js/modules/es.typed-array.to-locale-string.js', 'core-js/modules/es.typed-array.to-string.js', 'core-js/modules/es.reflect.construct.js', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/wrapNativeSuper'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.cubejs = factory(null, null, null, null, global._toArray, global._slicedToArray, global._asyncToGenerator, global._typeof, global._classCallCheck, global._createClass, global._defineProperty, global._awaitAsyncGenerator, global._wrapAsyncGenerator, global._regeneratorRuntime, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, global.uuid, null, global._objectWithoutProperties, global._toConsumableArray, null, null, null, null, null, null, null, null, null, null, null, global.dayjs, global.ramda, null, null, null, null, null, null, null, global.quarterOfYear, global.duration, global.isoWeek, global.en, null, null, null, global.fetch, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, global._possibleConstructorReturn, global._getPrototypeOf, global._inherits, global._wrapNativeSuper));
|
|
5
|
+
}(this, (function (es_array_forEach_js, es_object_keys_js, es_object_toString_js, web_domCollections_forEach_js, _toArray, _slicedToArray, _asyncToGenerator, _typeof, _classCallCheck, _createClass, _defineProperty, _awaitAsyncGenerator, _wrapAsyncGenerator, _regeneratorRuntime, es_symbol_js, es_symbol_description_js, es_symbol_asyncIterator_js, es_symbol_iterator_js, es_array_concat_js, es_array_filter_js, es_array_from_js, es_array_isArray_js, es_array_iterator_js, es_array_map_js, es_array_reduce_js, es_array_slice_js, es_function_name_js, es_date_toString_js, es_number_constructor_js, es_object_entries_js, es_object_defineProperties_js, es_object_defineProperty_js, es_object_getOwnPropertyDescriptor_js, es_object_getOwnPropertyDescriptors_js, es_promise_js, es_regexp_exec_js, es_regexp_toString_js, es_string_iterator_js, es_string_trim_js, web_domCollections_iterator_js, web_timers_js, uuid, readOnlyError, _objectWithoutProperties, _toConsumableArray, es_array_find_js, es_array_includes_js, es_array_indexOf_js, es_array_join_js, es_map_js, es_number_isNan_js, es_number_parseFloat_js, es_object_values_js, es_set_js, es_string_includes_js, es_string_match_js, dayjs, ramda, es_array_every_js, es_array_flatMap_js, es_array_splice_js, es_array_unscopables_flatMap_js, es_parseInt_js, es_string_endsWith_js, es_string_split_js, quarterOfYear, duration, isoWeek, en, es_array_sort_js, es_date_toJson_js, web_urlSearchParams_js, fetch, urlSearchParamsPolyfill, es_arrayBuffer_constructor_js, es_arrayBuffer_slice_js, es_dataView_js, es_typedArray_uint8Array_js, es_typedArray_copyWithin_js, es_typedArray_every_js, es_typedArray_fill_js, es_typedArray_filter_js, es_typedArray_find_js, es_typedArray_findIndex_js, es_typedArray_forEach_js, es_typedArray_includes_js, es_typedArray_indexOf_js, es_typedArray_iterator_js, es_typedArray_join_js, es_typedArray_lastIndexOf_js, es_typedArray_map_js, es_typedArray_reduce_js, es_typedArray_reduceRight_js, es_typedArray_reverse_js, es_typedArray_set_js, es_typedArray_slice_js, es_typedArray_some_js, es_typedArray_sort_js, es_typedArray_subarray_js, es_typedArray_toLocaleString_js, es_typedArray_toString_js, es_reflect_construct_js, _possibleConstructorReturn, _getPrototypeOf, _inherits, _wrapNativeSuper) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
+
var _toArray__default = /*#__PURE__*/_interopDefaultLegacy(_toArray);
|
|
9
10
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
10
11
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
11
12
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
12
13
|
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
13
14
|
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
14
15
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
+
var _awaitAsyncGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_awaitAsyncGenerator);
|
|
17
|
+
var _wrapAsyncGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_wrapAsyncGenerator);
|
|
15
18
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
16
19
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
17
20
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
@@ -2058,7 +2061,129 @@
|
|
|
2058
2061
|
}]);
|
|
2059
2062
|
}();
|
|
2060
2063
|
|
|
2061
|
-
var
|
|
2064
|
+
function _asyncIterator$1(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator$1(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
2065
|
+
function AsyncFromSyncIterator$1(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator$1 = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator$1.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator$1(r); }
|
|
2066
|
+
function responseChunks(_x) {
|
|
2067
|
+
return _responseChunks.apply(this, arguments);
|
|
2068
|
+
}
|
|
2069
|
+
function _responseChunks() {
|
|
2070
|
+
_responseChunks = _wrapAsyncGenerator__default['default'](/*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(res) {
|
|
2071
|
+
var body, reader, _yield$_awaitAsyncGen, done, value, _reader$releaseLock, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
|
|
2072
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
2073
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2074
|
+
case 0:
|
|
2075
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2076
|
+
body = res.body;
|
|
2077
|
+
if (!(body && typeof body.getReader === 'function')) {
|
|
2078
|
+
_context.next = 21;
|
|
2079
|
+
break;
|
|
2080
|
+
}
|
|
2081
|
+
reader = body.getReader(); // Browser / Node native fetch
|
|
2082
|
+
_context.prev = 3;
|
|
2083
|
+
case 4:
|
|
2084
|
+
_context.next = 7;
|
|
2085
|
+
return _awaitAsyncGenerator__default['default'](reader.read());
|
|
2086
|
+
case 7:
|
|
2087
|
+
_yield$_awaitAsyncGen = _context.sent;
|
|
2088
|
+
done = _yield$_awaitAsyncGen.done;
|
|
2089
|
+
value = _yield$_awaitAsyncGen.value;
|
|
2090
|
+
if (!done) {
|
|
2091
|
+
_context.next = 12;
|
|
2092
|
+
break;
|
|
2093
|
+
}
|
|
2094
|
+
return _context.abrupt("break", 17);
|
|
2095
|
+
case 12:
|
|
2096
|
+
if (!value) {
|
|
2097
|
+
_context.next = 15;
|
|
2098
|
+
break;
|
|
2099
|
+
}
|
|
2100
|
+
_context.next = 15;
|
|
2101
|
+
return value;
|
|
2102
|
+
case 15:
|
|
2103
|
+
_context.next = 4;
|
|
2104
|
+
break;
|
|
2105
|
+
case 17:
|
|
2106
|
+
_context.prev = 17;
|
|
2107
|
+
(_reader$releaseLock = reader.releaseLock) === null || _reader$releaseLock === void 0 || _reader$releaseLock.call(reader);
|
|
2108
|
+
return _context.finish(17);
|
|
2109
|
+
case 20:
|
|
2110
|
+
return _context.abrupt("return");
|
|
2111
|
+
case 21:
|
|
2112
|
+
if (!(body && Symbol.asyncIterator in body)) {
|
|
2113
|
+
_context.next = 57;
|
|
2114
|
+
break;
|
|
2115
|
+
}
|
|
2116
|
+
_iteratorAbruptCompletion = false;
|
|
2117
|
+
_didIteratorError = false;
|
|
2118
|
+
_context.prev = 24;
|
|
2119
|
+
_iterator = _asyncIterator$1(body);
|
|
2120
|
+
case 26:
|
|
2121
|
+
_context.next = 28;
|
|
2122
|
+
return _awaitAsyncGenerator__default['default'](_iterator.next());
|
|
2123
|
+
case 28:
|
|
2124
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
2125
|
+
_context.next = 40;
|
|
2126
|
+
break;
|
|
2127
|
+
}
|
|
2128
|
+
chunk = _step.value;
|
|
2129
|
+
if (!(typeof chunk === 'string')) {
|
|
2130
|
+
_context.next = 35;
|
|
2131
|
+
break;
|
|
2132
|
+
}
|
|
2133
|
+
_context.next = 33;
|
|
2134
|
+
return new TextEncoder().encode(chunk);
|
|
2135
|
+
case 33:
|
|
2136
|
+
_context.next = 37;
|
|
2137
|
+
break;
|
|
2138
|
+
case 35:
|
|
2139
|
+
_context.next = 37;
|
|
2140
|
+
return new Uint8Array(chunk);
|
|
2141
|
+
case 37:
|
|
2142
|
+
_iteratorAbruptCompletion = false;
|
|
2143
|
+
_context.next = 26;
|
|
2144
|
+
break;
|
|
2145
|
+
case 40:
|
|
2146
|
+
_context.next = 46;
|
|
2147
|
+
break;
|
|
2148
|
+
case 42:
|
|
2149
|
+
_context.prev = 42;
|
|
2150
|
+
_context.t0 = _context["catch"](24);
|
|
2151
|
+
_didIteratorError = true;
|
|
2152
|
+
_iteratorError = _context.t0;
|
|
2153
|
+
case 46:
|
|
2154
|
+
_context.prev = 46;
|
|
2155
|
+
_context.prev = 47;
|
|
2156
|
+
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
2157
|
+
_context.next = 51;
|
|
2158
|
+
break;
|
|
2159
|
+
}
|
|
2160
|
+
_context.next = 51;
|
|
2161
|
+
return _awaitAsyncGenerator__default['default'](_iterator["return"]());
|
|
2162
|
+
case 51:
|
|
2163
|
+
_context.prev = 51;
|
|
2164
|
+
if (!_didIteratorError) {
|
|
2165
|
+
_context.next = 54;
|
|
2166
|
+
break;
|
|
2167
|
+
}
|
|
2168
|
+
throw _iteratorError;
|
|
2169
|
+
case 54:
|
|
2170
|
+
return _context.finish(51);
|
|
2171
|
+
case 55:
|
|
2172
|
+
return _context.finish(46);
|
|
2173
|
+
case 56:
|
|
2174
|
+
return _context.abrupt("return");
|
|
2175
|
+
case 57:
|
|
2176
|
+
throw new Error('Unsupported response body type for streaming');
|
|
2177
|
+
case 58:
|
|
2178
|
+
case "end":
|
|
2179
|
+
return _context.stop();
|
|
2180
|
+
}
|
|
2181
|
+
}, _callee, null, [[3,, 17, 20], [24, 42, 46, 56], [47,, 51, 55]]);
|
|
2182
|
+
}));
|
|
2183
|
+
return _responseChunks.apply(this, arguments);
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
var _excluded = ["method", "fetchTimeout", "baseRequestId", "signal"];
|
|
2062
2187
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2063
2188
|
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty__default['default'](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2064
2189
|
/**
|
|
@@ -2092,9 +2217,12 @@
|
|
|
2092
2217
|
}
|
|
2093
2218
|
return _createClass__default['default'](HttpTransport, [{
|
|
2094
2219
|
key: "request",
|
|
2095
|
-
value: function request(
|
|
2096
|
-
var
|
|
2097
|
-
|
|
2220
|
+
value: function request(apiMethod, _ref2) {
|
|
2221
|
+
var _ref4,
|
|
2222
|
+
_this = this;
|
|
2223
|
+
var method = _ref2.method,
|
|
2224
|
+
fetchTimeout = _ref2.fetchTimeout,
|
|
2225
|
+
baseRequestId = _ref2.baseRequestId,
|
|
2098
2226
|
signal = _ref2.signal,
|
|
2099
2227
|
params = _objectWithoutProperties__default['default'](_ref2, _excluded);
|
|
2100
2228
|
var spanCounter = 1;
|
|
@@ -2103,12 +2231,14 @@
|
|
|
2103
2231
|
}).reduce(function (a, b) {
|
|
2104
2232
|
return _objectSpread$1(_objectSpread$1({}, a), b);
|
|
2105
2233
|
}, {}));
|
|
2106
|
-
var url = "".concat(this.apiUrl, "/").concat(
|
|
2107
|
-
var requestMethod = this.method
|
|
2234
|
+
var url = "".concat(this.apiUrl, "/").concat(apiMethod).concat(searchParams.toString().length ? "?".concat(searchParams) : '');
|
|
2235
|
+
var requestMethod = (_ref4 = method !== null && method !== void 0 ? method : this.method) !== null && _ref4 !== void 0 ? _ref4 : url.length < 2000 ? 'GET' : 'POST';
|
|
2108
2236
|
if (requestMethod === 'POST') {
|
|
2109
|
-
url = "".concat(this.apiUrl, "/").concat(
|
|
2237
|
+
url = "".concat(this.apiUrl, "/").concat(apiMethod);
|
|
2110
2238
|
this.headers['Content-Type'] = 'application/json';
|
|
2111
2239
|
}
|
|
2240
|
+
var effectiveFetchTimeout = fetchTimeout !== null && fetchTimeout !== void 0 ? fetchTimeout : this.fetchTimeout;
|
|
2241
|
+
var actualSignal = signal || this.signal || (effectiveFetchTimeout ? AbortSignal.timeout(effectiveFetchTimeout) : undefined);
|
|
2112
2242
|
|
|
2113
2243
|
// Currently, all methods make GET requests. If a method makes a request with a body payload,
|
|
2114
2244
|
// remember to add {'Content-Type': 'application/json'} to the header.
|
|
@@ -2121,14 +2251,14 @@
|
|
|
2121
2251
|
}, _this.headers),
|
|
2122
2252
|
credentials: _this.credentials,
|
|
2123
2253
|
body: requestMethod === 'POST' ? JSON.stringify(params) : null,
|
|
2124
|
-
signal:
|
|
2254
|
+
signal: actualSignal
|
|
2125
2255
|
});
|
|
2126
2256
|
};
|
|
2127
2257
|
return {
|
|
2128
2258
|
/* eslint no-unsafe-finally: off */subscribe: function subscribe(callback) {
|
|
2129
2259
|
var _this2 = this;
|
|
2130
2260
|
return _asyncToGenerator__default['default'](/*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
2131
|
-
var result, _result;
|
|
2261
|
+
var result, errorMessage, _actualSignal$reason, _result;
|
|
2132
2262
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
2133
2263
|
while (1) switch (_context.prev = _context.next) {
|
|
2134
2264
|
case 0:
|
|
@@ -2143,13 +2273,21 @@
|
|
|
2143
2273
|
case 7:
|
|
2144
2274
|
_context.prev = 7;
|
|
2145
2275
|
_context.t0 = _context["catch"](0);
|
|
2276
|
+
errorMessage = 'network Error';
|
|
2277
|
+
if (_context.t0.name === 'AbortError') {
|
|
2278
|
+
if ((actualSignal === null || actualSignal === void 0 ? void 0 : actualSignal.reason) === 'TimeoutError' || (actualSignal === null || actualSignal === void 0 || (_actualSignal$reason = actualSignal.reason) === null || _actualSignal$reason === void 0 ? void 0 : _actualSignal$reason.name) === 'TimeoutError') {
|
|
2279
|
+
errorMessage = 'timeout';
|
|
2280
|
+
} else {
|
|
2281
|
+
errorMessage = 'aborted';
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2146
2284
|
_result = {
|
|
2147
|
-
error:
|
|
2285
|
+
error: errorMessage
|
|
2148
2286
|
};
|
|
2149
2287
|
return _context.abrupt("return", callback(_result, function () {
|
|
2150
2288
|
return _this2.subscribe(callback);
|
|
2151
2289
|
}));
|
|
2152
|
-
case
|
|
2290
|
+
case 13:
|
|
2153
2291
|
case "end":
|
|
2154
2292
|
return _context.stop();
|
|
2155
2293
|
}
|
|
@@ -2158,6 +2296,110 @@
|
|
|
2158
2296
|
}
|
|
2159
2297
|
};
|
|
2160
2298
|
}
|
|
2299
|
+
}, {
|
|
2300
|
+
key: "requestStream",
|
|
2301
|
+
value: function requestStream(apiMethod, _ref5) {
|
|
2302
|
+
var _ref6,
|
|
2303
|
+
_this3 = this;
|
|
2304
|
+
var method = _ref5.method,
|
|
2305
|
+
fetchTimeout = _ref5.fetchTimeout,
|
|
2306
|
+
baseRequestId = _ref5.baseRequestId,
|
|
2307
|
+
signal = _ref5.signal,
|
|
2308
|
+
params = _ref5.params;
|
|
2309
|
+
var processedParams = {};
|
|
2310
|
+
|
|
2311
|
+
// Handle the generic params object
|
|
2312
|
+
if (params) {
|
|
2313
|
+
Object.keys(params).forEach(function (k) {
|
|
2314
|
+
var value = params[k];
|
|
2315
|
+
if (value !== undefined) {
|
|
2316
|
+
processedParams[k] = _typeof__default['default'](value) === 'object' ? JSON.stringify(value) : String(value);
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
var searchParams = new URLSearchParams(processedParams);
|
|
2321
|
+
var url = "".concat(this.apiUrl, "/").concat(apiMethod).concat(searchParams.toString().length ? "?".concat(searchParams) : '');
|
|
2322
|
+
var requestMethod = (_ref6 = method !== null && method !== void 0 ? method : this.method) !== null && _ref6 !== void 0 ? _ref6 : 'POST';
|
|
2323
|
+
if (requestMethod === 'POST') {
|
|
2324
|
+
url = "".concat(this.apiUrl, "/").concat(apiMethod);
|
|
2325
|
+
this.headers['Content-Type'] = 'application/json';
|
|
2326
|
+
}
|
|
2327
|
+
var effectiveFetchTimeout = fetchTimeout !== null && fetchTimeout !== void 0 ? fetchTimeout : this.fetchTimeout;
|
|
2328
|
+
var controller;
|
|
2329
|
+
var actualSignal = signal || this.signal;
|
|
2330
|
+
if (!actualSignal && effectiveFetchTimeout) {
|
|
2331
|
+
controller = new AbortController();
|
|
2332
|
+
actualSignal = controller.signal;
|
|
2333
|
+
setTimeout(function () {
|
|
2334
|
+
var _controller;
|
|
2335
|
+
return (_controller = controller) === null || _controller === void 0 ? void 0 : _controller.abort();
|
|
2336
|
+
}, effectiveFetchTimeout);
|
|
2337
|
+
}
|
|
2338
|
+
return {
|
|
2339
|
+
stream: function () {
|
|
2340
|
+
var _stream = _asyncToGenerator__default['default'](/*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
2341
|
+
var response;
|
|
2342
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
2343
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2344
|
+
case 0:
|
|
2345
|
+
_context2.next = 2;
|
|
2346
|
+
return fetch__default['default'](url, {
|
|
2347
|
+
method: requestMethod,
|
|
2348
|
+
headers: _objectSpread$1({
|
|
2349
|
+
Authorization: _this3.authorization,
|
|
2350
|
+
'x-request-id': baseRequestId || 'stream-request'
|
|
2351
|
+
}, _this3.headers),
|
|
2352
|
+
credentials: _this3.credentials,
|
|
2353
|
+
body: requestMethod === 'POST' ? JSON.stringify(params || {}) : null,
|
|
2354
|
+
signal: actualSignal
|
|
2355
|
+
});
|
|
2356
|
+
case 2:
|
|
2357
|
+
response = _context2.sent;
|
|
2358
|
+
if (response.ok) {
|
|
2359
|
+
_context2.next = 5;
|
|
2360
|
+
break;
|
|
2361
|
+
}
|
|
2362
|
+
throw new Error("HTTP ".concat(response.status, ": ").concat(response.statusText));
|
|
2363
|
+
case 5:
|
|
2364
|
+
if (response.body) {
|
|
2365
|
+
_context2.next = 7;
|
|
2366
|
+
break;
|
|
2367
|
+
}
|
|
2368
|
+
throw new Error('No response body available for streaming');
|
|
2369
|
+
case 7:
|
|
2370
|
+
return _context2.abrupt("return", responseChunks(response));
|
|
2371
|
+
case 8:
|
|
2372
|
+
case "end":
|
|
2373
|
+
return _context2.stop();
|
|
2374
|
+
}
|
|
2375
|
+
}, _callee2);
|
|
2376
|
+
}));
|
|
2377
|
+
function stream() {
|
|
2378
|
+
return _stream.apply(this, arguments);
|
|
2379
|
+
}
|
|
2380
|
+
return stream;
|
|
2381
|
+
}(),
|
|
2382
|
+
unsubscribe: function () {
|
|
2383
|
+
var _unsubscribe = _asyncToGenerator__default['default'](/*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
2384
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
2385
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2386
|
+
case 0:
|
|
2387
|
+
if (controller) {
|
|
2388
|
+
controller.abort();
|
|
2389
|
+
}
|
|
2390
|
+
case 1:
|
|
2391
|
+
case "end":
|
|
2392
|
+
return _context3.stop();
|
|
2393
|
+
}
|
|
2394
|
+
}, _callee3);
|
|
2395
|
+
}));
|
|
2396
|
+
function unsubscribe() {
|
|
2397
|
+
return _unsubscribe.apply(this, arguments);
|
|
2398
|
+
}
|
|
2399
|
+
return unsubscribe;
|
|
2400
|
+
}()
|
|
2401
|
+
};
|
|
2402
|
+
}
|
|
2161
2403
|
}]);
|
|
2162
2404
|
}();
|
|
2163
2405
|
|
|
@@ -2178,8 +2420,13 @@
|
|
|
2178
2420
|
return _createClass__default['default'](RequestError);
|
|
2179
2421
|
}(/*#__PURE__*/_wrapNativeSuper__default['default'](Error));
|
|
2180
2422
|
|
|
2423
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
2424
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
2425
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2181
2426
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2182
2427
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default['default'](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2428
|
+
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
2429
|
+
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
2183
2430
|
|
|
2184
2431
|
// If we can't infer any members at all, then return any.
|
|
2185
2432
|
|
|
@@ -2273,7 +2520,7 @@
|
|
|
2273
2520
|
}, {
|
|
2274
2521
|
key: "loadMethod",
|
|
2275
2522
|
value: function loadMethod(request, toResult, options, callback) {
|
|
2276
|
-
var
|
|
2523
|
+
var _this2 = this;
|
|
2277
2524
|
var mutexValue = ++mutexCounter;
|
|
2278
2525
|
if (typeof options === 'function' && !callback) {
|
|
2279
2526
|
callback = options;
|
|
@@ -2354,7 +2601,7 @@
|
|
|
2354
2601
|
return new Promise(function (resolve) {
|
|
2355
2602
|
return setTimeout(function () {
|
|
2356
2603
|
return resolve();
|
|
2357
|
-
},
|
|
2604
|
+
}, _this2.pollInterval * 1000);
|
|
2358
2605
|
});
|
|
2359
2606
|
case 7:
|
|
2360
2607
|
return _context2.abrupt("return", next());
|
|
@@ -2390,7 +2637,7 @@
|
|
|
2390
2637
|
return new Promise(function (resolve) {
|
|
2391
2638
|
return setTimeout(function () {
|
|
2392
2639
|
return resolve();
|
|
2393
|
-
},
|
|
2640
|
+
}, _this2.pollInterval * 1000);
|
|
2394
2641
|
});
|
|
2395
2642
|
case 5:
|
|
2396
2643
|
return _context3.abrupt("return", next());
|
|
@@ -2411,7 +2658,7 @@
|
|
|
2411
2658
|
break;
|
|
2412
2659
|
}
|
|
2413
2660
|
_context4.next = 8;
|
|
2414
|
-
return
|
|
2661
|
+
return _this2.updateTransportAuthorization();
|
|
2415
2662
|
case 8:
|
|
2416
2663
|
skipAuthorizationUpdate = false;
|
|
2417
2664
|
if (!('status' in response && response.status === 502 || 'error' in response && ((_response$error = response.error) === null || _response$error === void 0 ? void 0 : _response$error.toLowerCase()) === 'network error' && --networkRetries >= 0)) {
|
|
@@ -2466,7 +2713,7 @@
|
|
|
2466
2713
|
_context4.next = 37;
|
|
2467
2714
|
return requestInstance.unsubscribe();
|
|
2468
2715
|
case 37:
|
|
2469
|
-
_error = new RequestError(body.error || '', body, response.status);
|
|
2716
|
+
_error = new RequestError(body.error || response.error || '', body, response.status);
|
|
2470
2717
|
if (!callback) {
|
|
2471
2718
|
_context4.next = 42;
|
|
2472
2719
|
break;
|
|
@@ -2554,7 +2801,7 @@
|
|
|
2554
2801
|
key: "updateTransportAuthorization",
|
|
2555
2802
|
value: function () {
|
|
2556
2803
|
var _updateTransportAuthorization = _asyncToGenerator__default['default'](/*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7() {
|
|
2557
|
-
var
|
|
2804
|
+
var _this3 = this;
|
|
2558
2805
|
var tokenFetcher, promise;
|
|
2559
2806
|
return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
|
|
2560
2807
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -2583,12 +2830,12 @@
|
|
|
2583
2830
|
return tokenFetcher();
|
|
2584
2831
|
case 3:
|
|
2585
2832
|
token = _context6.sent;
|
|
2586
|
-
if (
|
|
2587
|
-
|
|
2833
|
+
if (_this3.transport.authorization !== token) {
|
|
2834
|
+
_this3.transport.authorization = token;
|
|
2588
2835
|
}
|
|
2589
2836
|
case 5:
|
|
2590
2837
|
_context6.prev = 5;
|
|
2591
|
-
|
|
2838
|
+
_this3.updateAuthorizationPromise = null;
|
|
2592
2839
|
return _context6.finish(5);
|
|
2593
2840
|
case 8:
|
|
2594
2841
|
case "end":
|
|
@@ -2707,7 +2954,7 @@
|
|
|
2707
2954
|
* @param responseFormat
|
|
2708
2955
|
*/
|
|
2709
2956
|
function load(query, options, callback) {
|
|
2710
|
-
var
|
|
2957
|
+
var _this4 = this;
|
|
2711
2958
|
var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'default';
|
|
2712
2959
|
var _this$prepareQueryOpt = this.prepareQueryOptions(query, options, responseFormat);
|
|
2713
2960
|
var _this$prepareQueryOpt2 = _slicedToArray__default['default'](_this$prepareQueryOpt, 2);
|
|
@@ -2715,19 +2962,19 @@
|
|
|
2715
2962
|
options = _this$prepareQueryOpt2[1];
|
|
2716
2963
|
return this.loadMethod(function () {
|
|
2717
2964
|
var _options6;
|
|
2718
|
-
return
|
|
2965
|
+
return _this4.request('load', {
|
|
2719
2966
|
query: query,
|
|
2720
2967
|
queryType: 'multi',
|
|
2721
2968
|
signal: (_options6 = options) === null || _options6 === void 0 ? void 0 : _options6.signal
|
|
2722
2969
|
});
|
|
2723
2970
|
}, function (response) {
|
|
2724
|
-
return
|
|
2971
|
+
return _this4.loadResponseInternal(response, options);
|
|
2725
2972
|
}, options, callback);
|
|
2726
2973
|
}
|
|
2727
2974
|
}, {
|
|
2728
2975
|
key: "prepareQueryOptions",
|
|
2729
2976
|
value: function prepareQueryOptions(query, options) {
|
|
2730
|
-
var
|
|
2977
|
+
var _this5 = this;
|
|
2731
2978
|
var responseFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
|
|
2732
2979
|
options = _objectSpread({
|
|
2733
2980
|
castNumerics: this.castNumerics
|
|
@@ -2735,7 +2982,7 @@
|
|
|
2735
2982
|
if (responseFormat === 'compact') {
|
|
2736
2983
|
if (Array.isArray(query)) {
|
|
2737
2984
|
var patched = query.map(function (q) {
|
|
2738
|
-
return
|
|
2985
|
+
return _this5.patchQueryInternal(q, 'compact');
|
|
2739
2986
|
});
|
|
2740
2987
|
return [patched, options];
|
|
2741
2988
|
} else {
|
|
@@ -2777,7 +3024,7 @@
|
|
|
2777
3024
|
}, {
|
|
2778
3025
|
key: "subscribe",
|
|
2779
3026
|
value: function subscribe(query, options, callback) {
|
|
2780
|
-
var
|
|
3027
|
+
var _this6 = this;
|
|
2781
3028
|
var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'default';
|
|
2782
3029
|
var _this$prepareQueryOpt3 = this.prepareQueryOptions(query, options, responseFormat);
|
|
2783
3030
|
var _this$prepareQueryOpt4 = _slicedToArray__default['default'](_this$prepareQueryOpt3, 2);
|
|
@@ -2785,13 +3032,13 @@
|
|
|
2785
3032
|
options = _this$prepareQueryOpt4[1];
|
|
2786
3033
|
return this.loadMethod(function () {
|
|
2787
3034
|
var _options7;
|
|
2788
|
-
return
|
|
3035
|
+
return _this6.request('subscribe', {
|
|
2789
3036
|
query: query,
|
|
2790
3037
|
queryType: 'multi',
|
|
2791
3038
|
signal: (_options7 = options) === null || _options7 === void 0 ? void 0 : _options7.signal
|
|
2792
3039
|
});
|
|
2793
3040
|
}, function (response) {
|
|
2794
|
-
return
|
|
3041
|
+
return _this6.loadResponseInternal(response, options);
|
|
2795
3042
|
}, _objectSpread(_objectSpread({}, options), {}, {
|
|
2796
3043
|
subscribe: true
|
|
2797
3044
|
}), callback);
|
|
@@ -2803,9 +3050,9 @@
|
|
|
2803
3050
|
* Get generated SQL string for the given `query`.
|
|
2804
3051
|
*/
|
|
2805
3052
|
function sql(query, options, callback) {
|
|
2806
|
-
var
|
|
3053
|
+
var _this7 = this;
|
|
2807
3054
|
return this.loadMethod(function () {
|
|
2808
|
-
return
|
|
3055
|
+
return _this7.request('sql', {
|
|
2809
3056
|
query: query,
|
|
2810
3057
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
2811
3058
|
});
|
|
@@ -2822,9 +3069,9 @@
|
|
|
2822
3069
|
* Get meta description of cubes available for querying.
|
|
2823
3070
|
*/
|
|
2824
3071
|
function meta(options, callback) {
|
|
2825
|
-
var
|
|
3072
|
+
var _this8 = this;
|
|
2826
3073
|
return this.loadMethod(function () {
|
|
2827
|
-
return
|
|
3074
|
+
return _this8.request('meta', {
|
|
2828
3075
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
2829
3076
|
});
|
|
2830
3077
|
}, function (body) {
|
|
@@ -2838,9 +3085,9 @@
|
|
|
2838
3085
|
* Get query related meta without query execution
|
|
2839
3086
|
*/
|
|
2840
3087
|
function dryRun(query, options, callback) {
|
|
2841
|
-
var
|
|
3088
|
+
var _this9 = this;
|
|
2842
3089
|
return this.loadMethod(function () {
|
|
2843
|
-
return
|
|
3090
|
+
return _this9.request('dry-run', {
|
|
2844
3091
|
query: query,
|
|
2845
3092
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
2846
3093
|
});
|
|
@@ -2848,6 +3095,300 @@
|
|
|
2848
3095
|
return response;
|
|
2849
3096
|
}, options, callback);
|
|
2850
3097
|
}
|
|
3098
|
+
}, {
|
|
3099
|
+
key: "cubeSql",
|
|
3100
|
+
value:
|
|
3101
|
+
/**
|
|
3102
|
+
* Execute a Cube SQL query against Cube SQL interface and return the results.
|
|
3103
|
+
*/
|
|
3104
|
+
function cubeSql(sqlQuery, options, callback) {
|
|
3105
|
+
var _this10 = this;
|
|
3106
|
+
return this.loadMethod(function () {
|
|
3107
|
+
var request = _this10.request('cubesql', {
|
|
3108
|
+
query: sqlQuery,
|
|
3109
|
+
method: 'POST',
|
|
3110
|
+
signal: options === null || options === void 0 ? void 0 : options.signal,
|
|
3111
|
+
fetchTimeout: options === null || options === void 0 ? void 0 : options.timeout
|
|
3112
|
+
});
|
|
3113
|
+
return request;
|
|
3114
|
+
}, function (response) {
|
|
3115
|
+
// TODO: The response is sending both errors and successful results as `error`
|
|
3116
|
+
if (!response || !response.error) {
|
|
3117
|
+
throw new Error('Invalid response format');
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// Check if this is a timeout or abort error from transport
|
|
3121
|
+
if (response.error === 'timeout') {
|
|
3122
|
+
var timeoutMs = (options === null || options === void 0 ? void 0 : options.timeout) || 5 * 60 * 1000;
|
|
3123
|
+
throw new Error("CubeSQL query timed out after ".concat(timeoutMs, "ms"));
|
|
3124
|
+
}
|
|
3125
|
+
if (response.error === 'aborted') {
|
|
3126
|
+
throw new Error('CubeSQL query was aborted');
|
|
3127
|
+
}
|
|
3128
|
+
var _response$error$split = response.error.split('\n'),
|
|
3129
|
+
_response$error$split2 = _toArray__default['default'](_response$error$split),
|
|
3130
|
+
schema = _response$error$split2[0],
|
|
3131
|
+
data = _response$error$split2.slice(1);
|
|
3132
|
+
try {
|
|
3133
|
+
return {
|
|
3134
|
+
schema: JSON.parse(schema).schema,
|
|
3135
|
+
data: data.filter(function (d) {
|
|
3136
|
+
return d.trim().length;
|
|
3137
|
+
}).map(function (d) {
|
|
3138
|
+
return JSON.parse(d).data;
|
|
3139
|
+
}).reduce(function (a, b) {
|
|
3140
|
+
return a.concat(b);
|
|
3141
|
+
}, [])
|
|
3142
|
+
};
|
|
3143
|
+
} catch (err) {
|
|
3144
|
+
throw new Error(response.error);
|
|
3145
|
+
}
|
|
3146
|
+
}, options, callback);
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/**
|
|
3150
|
+
* Execute a Cube SQL query against Cube SQL interface and return streaming results as an async generator.
|
|
3151
|
+
* The server returns JSONL (JSON Lines) format with schema first, then data rows.
|
|
3152
|
+
*/
|
|
3153
|
+
}, {
|
|
3154
|
+
key: "cubeSqlStream",
|
|
3155
|
+
value: function cubeSqlStream(sqlQuery, options) {
|
|
3156
|
+
var _this = this;
|
|
3157
|
+
return _wrapAsyncGenerator__default['default'](/*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee8() {
|
|
3158
|
+
var streamResponse, decoder, buffer, stream, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, lines, _iterator2, _step2, line, parsed, _parsed;
|
|
3159
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee8$(_context8) {
|
|
3160
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3161
|
+
case 0:
|
|
3162
|
+
if (_this.transport.requestStream) {
|
|
3163
|
+
_context8.next = 2;
|
|
3164
|
+
break;
|
|
3165
|
+
}
|
|
3166
|
+
throw new Error('Transport does not support streaming');
|
|
3167
|
+
case 2:
|
|
3168
|
+
streamResponse = _this.transport.requestStream('cubesql', {
|
|
3169
|
+
method: 'POST',
|
|
3170
|
+
signal: options === null || options === void 0 ? void 0 : options.signal,
|
|
3171
|
+
fetchTimeout: options === null || options === void 0 ? void 0 : options.timeout,
|
|
3172
|
+
baseRequestId: uuid.v4(),
|
|
3173
|
+
params: {
|
|
3174
|
+
query: sqlQuery
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
decoder = new TextDecoder();
|
|
3178
|
+
buffer = '';
|
|
3179
|
+
_context8.prev = 5;
|
|
3180
|
+
_context8.next = 8;
|
|
3181
|
+
return _awaitAsyncGenerator__default['default'](streamResponse.stream());
|
|
3182
|
+
case 8:
|
|
3183
|
+
stream = _context8.sent;
|
|
3184
|
+
_iteratorAbruptCompletion = false;
|
|
3185
|
+
_didIteratorError = false;
|
|
3186
|
+
_context8.prev = 11;
|
|
3187
|
+
_iterator = _asyncIterator(stream);
|
|
3188
|
+
case 13:
|
|
3189
|
+
_context8.next = 15;
|
|
3190
|
+
return _awaitAsyncGenerator__default['default'](_iterator.next());
|
|
3191
|
+
case 15:
|
|
3192
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context8.sent).done)) {
|
|
3193
|
+
_context8.next = 60;
|
|
3194
|
+
break;
|
|
3195
|
+
}
|
|
3196
|
+
chunk = _step.value;
|
|
3197
|
+
buffer += decoder.decode(chunk, {
|
|
3198
|
+
stream: true
|
|
3199
|
+
});
|
|
3200
|
+
lines = buffer.split('\n');
|
|
3201
|
+
buffer = lines.pop() || '';
|
|
3202
|
+
_iterator2 = _createForOfIteratorHelper(lines);
|
|
3203
|
+
_context8.prev = 21;
|
|
3204
|
+
_iterator2.s();
|
|
3205
|
+
case 23:
|
|
3206
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
3207
|
+
_context8.next = 49;
|
|
3208
|
+
break;
|
|
3209
|
+
}
|
|
3210
|
+
line = _step2.value;
|
|
3211
|
+
if (!line.trim()) {
|
|
3212
|
+
_context8.next = 47;
|
|
3213
|
+
break;
|
|
3214
|
+
}
|
|
3215
|
+
_context8.prev = 26;
|
|
3216
|
+
parsed = JSON.parse(line);
|
|
3217
|
+
if (!parsed.schema) {
|
|
3218
|
+
_context8.next = 33;
|
|
3219
|
+
break;
|
|
3220
|
+
}
|
|
3221
|
+
_context8.next = 31;
|
|
3222
|
+
return {
|
|
3223
|
+
type: 'schema',
|
|
3224
|
+
schema: parsed.schema
|
|
3225
|
+
};
|
|
3226
|
+
case 31:
|
|
3227
|
+
_context8.next = 41;
|
|
3228
|
+
break;
|
|
3229
|
+
case 33:
|
|
3230
|
+
if (!parsed.data) {
|
|
3231
|
+
_context8.next = 38;
|
|
3232
|
+
break;
|
|
3233
|
+
}
|
|
3234
|
+
_context8.next = 36;
|
|
3235
|
+
return {
|
|
3236
|
+
type: 'data',
|
|
3237
|
+
data: parsed.data
|
|
3238
|
+
};
|
|
3239
|
+
case 36:
|
|
3240
|
+
_context8.next = 41;
|
|
3241
|
+
break;
|
|
3242
|
+
case 38:
|
|
3243
|
+
if (!parsed.error) {
|
|
3244
|
+
_context8.next = 41;
|
|
3245
|
+
break;
|
|
3246
|
+
}
|
|
3247
|
+
_context8.next = 41;
|
|
3248
|
+
return {
|
|
3249
|
+
type: 'error',
|
|
3250
|
+
error: parsed.error
|
|
3251
|
+
};
|
|
3252
|
+
case 41:
|
|
3253
|
+
_context8.next = 47;
|
|
3254
|
+
break;
|
|
3255
|
+
case 43:
|
|
3256
|
+
_context8.prev = 43;
|
|
3257
|
+
_context8.t0 = _context8["catch"](26);
|
|
3258
|
+
_context8.next = 47;
|
|
3259
|
+
return {
|
|
3260
|
+
type: 'error',
|
|
3261
|
+
error: "Failed to parse JSON line: ".concat(line)
|
|
3262
|
+
};
|
|
3263
|
+
case 47:
|
|
3264
|
+
_context8.next = 23;
|
|
3265
|
+
break;
|
|
3266
|
+
case 49:
|
|
3267
|
+
_context8.next = 54;
|
|
3268
|
+
break;
|
|
3269
|
+
case 51:
|
|
3270
|
+
_context8.prev = 51;
|
|
3271
|
+
_context8.t1 = _context8["catch"](21);
|
|
3272
|
+
_iterator2.e(_context8.t1);
|
|
3273
|
+
case 54:
|
|
3274
|
+
_context8.prev = 54;
|
|
3275
|
+
_iterator2.f();
|
|
3276
|
+
return _context8.finish(54);
|
|
3277
|
+
case 57:
|
|
3278
|
+
_iteratorAbruptCompletion = false;
|
|
3279
|
+
_context8.next = 13;
|
|
3280
|
+
break;
|
|
3281
|
+
case 60:
|
|
3282
|
+
_context8.next = 66;
|
|
3283
|
+
break;
|
|
3284
|
+
case 62:
|
|
3285
|
+
_context8.prev = 62;
|
|
3286
|
+
_context8.t2 = _context8["catch"](11);
|
|
3287
|
+
_didIteratorError = true;
|
|
3288
|
+
_iteratorError = _context8.t2;
|
|
3289
|
+
case 66:
|
|
3290
|
+
_context8.prev = 66;
|
|
3291
|
+
_context8.prev = 67;
|
|
3292
|
+
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
3293
|
+
_context8.next = 71;
|
|
3294
|
+
break;
|
|
3295
|
+
}
|
|
3296
|
+
_context8.next = 71;
|
|
3297
|
+
return _awaitAsyncGenerator__default['default'](_iterator["return"]());
|
|
3298
|
+
case 71:
|
|
3299
|
+
_context8.prev = 71;
|
|
3300
|
+
if (!_didIteratorError) {
|
|
3301
|
+
_context8.next = 74;
|
|
3302
|
+
break;
|
|
3303
|
+
}
|
|
3304
|
+
throw _iteratorError;
|
|
3305
|
+
case 74:
|
|
3306
|
+
return _context8.finish(71);
|
|
3307
|
+
case 75:
|
|
3308
|
+
return _context8.finish(66);
|
|
3309
|
+
case 76:
|
|
3310
|
+
if (!buffer.trim()) {
|
|
3311
|
+
_context8.next = 98;
|
|
3312
|
+
break;
|
|
3313
|
+
}
|
|
3314
|
+
_context8.prev = 77;
|
|
3315
|
+
_parsed = JSON.parse(buffer);
|
|
3316
|
+
if (!_parsed.schema) {
|
|
3317
|
+
_context8.next = 84;
|
|
3318
|
+
break;
|
|
3319
|
+
}
|
|
3320
|
+
_context8.next = 82;
|
|
3321
|
+
return {
|
|
3322
|
+
type: 'schema',
|
|
3323
|
+
schema: _parsed.schema
|
|
3324
|
+
};
|
|
3325
|
+
case 82:
|
|
3326
|
+
_context8.next = 92;
|
|
3327
|
+
break;
|
|
3328
|
+
case 84:
|
|
3329
|
+
if (!_parsed.data) {
|
|
3330
|
+
_context8.next = 89;
|
|
3331
|
+
break;
|
|
3332
|
+
}
|
|
3333
|
+
_context8.next = 87;
|
|
3334
|
+
return {
|
|
3335
|
+
type: 'data',
|
|
3336
|
+
data: _parsed.data
|
|
3337
|
+
};
|
|
3338
|
+
case 87:
|
|
3339
|
+
_context8.next = 92;
|
|
3340
|
+
break;
|
|
3341
|
+
case 89:
|
|
3342
|
+
if (!_parsed.error) {
|
|
3343
|
+
_context8.next = 92;
|
|
3344
|
+
break;
|
|
3345
|
+
}
|
|
3346
|
+
_context8.next = 92;
|
|
3347
|
+
return {
|
|
3348
|
+
type: 'error',
|
|
3349
|
+
error: _parsed.error
|
|
3350
|
+
};
|
|
3351
|
+
case 92:
|
|
3352
|
+
_context8.next = 98;
|
|
3353
|
+
break;
|
|
3354
|
+
case 94:
|
|
3355
|
+
_context8.prev = 94;
|
|
3356
|
+
_context8.t3 = _context8["catch"](77);
|
|
3357
|
+
_context8.next = 98;
|
|
3358
|
+
return {
|
|
3359
|
+
type: 'error',
|
|
3360
|
+
error: "Failed to parse remaining JSON: ".concat(buffer)
|
|
3361
|
+
};
|
|
3362
|
+
case 98:
|
|
3363
|
+
_context8.next = 105;
|
|
3364
|
+
break;
|
|
3365
|
+
case 100:
|
|
3366
|
+
_context8.prev = 100;
|
|
3367
|
+
_context8.t4 = _context8["catch"](5);
|
|
3368
|
+
if (!(_context8.t4.name === 'AbortError')) {
|
|
3369
|
+
_context8.next = 104;
|
|
3370
|
+
break;
|
|
3371
|
+
}
|
|
3372
|
+
throw new Error('aborted');
|
|
3373
|
+
case 104:
|
|
3374
|
+
throw _context8.t4;
|
|
3375
|
+
case 105:
|
|
3376
|
+
_context8.prev = 105;
|
|
3377
|
+
if (!streamResponse.unsubscribe) {
|
|
3378
|
+
_context8.next = 109;
|
|
3379
|
+
break;
|
|
3380
|
+
}
|
|
3381
|
+
_context8.next = 109;
|
|
3382
|
+
return _awaitAsyncGenerator__default['default'](streamResponse.unsubscribe());
|
|
3383
|
+
case 109:
|
|
3384
|
+
return _context8.finish(105);
|
|
3385
|
+
case 110:
|
|
3386
|
+
case "end":
|
|
3387
|
+
return _context8.stop();
|
|
3388
|
+
}
|
|
3389
|
+
}, _callee8, null, [[5, 100, 105, 110], [11, 62, 66, 76], [21, 51, 54, 57], [26, 43], [67,, 71, 75], [77, 94]]);
|
|
3390
|
+
}))();
|
|
3391
|
+
}
|
|
2851
3392
|
}]);
|
|
2852
3393
|
}();
|
|
2853
3394
|
var cube = (function (apiToken, options) {
|