@cubejs-client/core 0.29.8 → 0.29.33

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 CHANGED
@@ -3,6 +3,40 @@
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.29.33](https://github.com/cube-js/cube.js/compare/v0.29.32...v0.29.33) (2022-03-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * **playground:** non-additive measures message ([#4236](https://github.com/cube-js/cube.js/issues/4236)) ([ae18bbc](https://github.com/cube-js/cube.js/commit/ae18bbcb9030d0eef03c74410c25902602ec6d43))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.29.29](https://github.com/cube-js/cube.js/compare/v0.29.28...v0.29.29) (2022-03-03)
18
+
19
+
20
+ ### Features
21
+
22
+ * Compact JSON array based response data format support ([#4046](https://github.com/cube-js/cube.js/issues/4046)) ([e74d73c](https://github.com/cube-js/cube.js/commit/e74d73c140f56e71a24c35a5f03e9af63022bced)), closes [#1](https://github.com/cube-js/cube.js/issues/1)
23
+
24
+
25
+
26
+
27
+
28
+ ## [0.29.23](https://github.com/cube-js/cube.js/compare/v0.29.22...v0.29.23) (2022-01-26)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **@cubejs-client/core:** restore support for Angular by removing dependency on `@cubejs-client/dx` ([#3972](https://github.com/cube-js/cube.js/issues/3972)) ([13d30dc](https://github.com/cube-js/cube.js/commit/13d30dc98a08c6ef93808adaf1be6c2aa10c664a))
34
+ * **client-core:** apiToken nullable check ([3f93f68](https://github.com/cube-js/cube.js/commit/3f93f68170ff87a50bd6bbf768e1cd36c478c20c))
35
+
36
+
37
+
38
+
39
+
6
40
  ## [0.29.8](https://github.com/cube-js/cube.js/compare/v0.29.7...v0.29.8) (2021-12-21)
7
41
 
8
42
 
@@ -2,8 +2,6 @@ import 'core-js/modules/es.object.keys.js';
2
2
  import 'core-js/modules/es.symbol.js';
3
3
  import 'core-js/modules/es.array.filter.js';
4
4
  import 'core-js/modules/es.object.get-own-property-descriptor.js';
5
- import 'core-js/modules/es.array.for-each.js';
6
- import 'core-js/modules/web.dom-collections.for-each.js';
7
5
  import 'core-js/modules/es.object.get-own-property-descriptors.js';
8
6
  import 'core-js/modules/es.object.define-properties.js';
9
7
  import 'core-js/modules/es.object.define-property.js';
@@ -15,8 +13,11 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
15
13
  import _regeneratorRuntime from '@babel/runtime/regenerator';
16
14
  import 'core-js/modules/es.object.to-string.js';
17
15
  import 'core-js/modules/es.promise.js';
18
- import 'core-js/modules/web.timers.js';
19
16
  import 'core-js/modules/es.array.is-array.js';
17
+ import 'core-js/modules/web.timers.js';
18
+ import 'core-js/modules/es.array.for-each.js';
19
+ import 'core-js/modules/web.dom-collections.for-each.js';
20
+ import 'core-js/modules/es.function.bind.js';
20
21
  import 'core-js/modules/es.array.map.js';
21
22
  import { v4 } from 'uuid';
22
23
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
@@ -1622,6 +1623,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
1622
1623
  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; }
1623
1624
  var mutexCounter = 0;
1624
1625
  var MUTEX_ERROR = 'Mutex has been changed';
1626
+ /**
1627
+ * Query result dataset formats enum.
1628
+ */
1629
+
1630
+ var ResultType = {
1631
+ DEFAULT: 'default',
1632
+ COMPACT: 'compact'
1633
+ };
1625
1634
 
1626
1635
  function mutexPromise(promise) {
1627
1636
  return new Promise( /*#__PURE__*/function () {
@@ -1667,7 +1676,7 @@ var CubejsApi = /*#__PURE__*/function () {
1667
1676
  function CubejsApi(apiToken, options) {
1668
1677
  _classCallCheck(this, CubejsApi);
1669
1678
 
1670
- if (_typeof(apiToken) === 'object') {
1679
+ if (apiToken !== null && !Array.isArray(apiToken) && _typeof(apiToken) === 'object') {
1671
1680
  options = apiToken;
1672
1681
  apiToken = undefined;
1673
1682
  }
@@ -2144,29 +2153,128 @@ var CubejsApi = /*#__PURE__*/function () {
2144
2153
 
2145
2154
  return updateTransportAuthorization;
2146
2155
  }()
2156
+ /**
2157
+ * Add system properties to a query object.
2158
+ * @param {Query} query
2159
+ * @param {string} responseFormat
2160
+ * @returns {void}
2161
+ * @private
2162
+ */
2163
+
2164
+ }, {
2165
+ key: "patchQueryInternal",
2166
+ value: function patchQueryInternal(query, responseFormat) {
2167
+ if (responseFormat === ResultType.COMPACT && query.responseFormat !== ResultType.COMPACT) {
2168
+ query.responseFormat = ResultType.COMPACT;
2169
+ }
2170
+ }
2171
+ /**
2172
+ * Process result fetched from the gateway#load method according
2173
+ * to the network protocol.
2174
+ * @param {*} response
2175
+ * @returns ResultSet
2176
+ * @private
2177
+ */
2178
+
2179
+ }, {
2180
+ key: "loadResponseInternal",
2181
+ value: function loadResponseInternal(response) {
2182
+ if (response.results.length && response.results[0].query.responseFormat && response.results[0].query.responseFormat === ResultType.COMPACT) {
2183
+ response.results.forEach(function (result, j) {
2184
+ var data = [];
2185
+ result.data.dataset.forEach(function (r) {
2186
+ var row = {};
2187
+ result.data.members.forEach(function (m, i) {
2188
+ row[m] = r[i];
2189
+ });
2190
+ data.push(row);
2191
+ });
2192
+ response.results[j].data = data;
2193
+ });
2194
+ }
2195
+
2196
+ return new ResultSet(response, {
2197
+ parseDateMeasures: this.parseDateMeasures
2198
+ });
2199
+ }
2200
+ /**
2201
+ * Fetch data for the passed `query`. Operates with the
2202
+ * `ApiGateway#load` method to fetch the data.
2203
+ * @param {Query | Query[]} query
2204
+ * @param {LoadMethodOptions | undefined} options
2205
+ * @param {LoadMethodCallback<ResultSet> | undefined} callback
2206
+ * @param {string} responseFormat
2207
+ * @returns {undefined | Promise<ResultSet>}
2208
+ */
2209
+
2147
2210
  }, {
2148
2211
  key: "load",
2149
2212
  value: function load(query, options, callback) {
2150
2213
  var _this3 = this;
2151
2214
 
2215
+ var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ResultType.DEFAULT;
2216
+
2217
+ if (responseFormat === ResultType.COMPACT) {
2218
+ if (Array.isArray(query)) {
2219
+ query.forEach(function (q) {
2220
+ _this3.patchQueryInternal(q, ResultType.COMPACT);
2221
+ });
2222
+ } else {
2223
+ this.patchQueryInternal(query, ResultType.COMPACT);
2224
+ }
2225
+ }
2226
+
2152
2227
  return this.loadMethod(function () {
2153
2228
  return _this3.request('load', {
2154
2229
  query: query,
2155
2230
  queryType: 'multi'
2156
2231
  });
2157
- }, function (response) {
2158
- return new ResultSet(response, {
2159
- parseDateMeasures: _this3.parseDateMeasures
2232
+ }, this.loadResponseInternal.bind(this), options, callback);
2233
+ }
2234
+ /**
2235
+ * Allows you to fetch data and receive updates over time. Operates
2236
+ * with the `ApiGateway#load` method to fetch the data.
2237
+ * @link real-time-data-fetch
2238
+ * @param {Query | Query[]} query
2239
+ * @param {LoadMethodOptions | null} options
2240
+ * @param {LoadMethodCallback<ResultSet> | undefined} callback
2241
+ * @param {string} responseFormat
2242
+ * @returns {void}
2243
+ */
2244
+
2245
+ }, {
2246
+ key: "subscribe",
2247
+ value: function subscribe(query, options, callback) {
2248
+ var _this4 = this;
2249
+
2250
+ var responseFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ResultType.DEFAULT;
2251
+
2252
+ if (responseFormat === ResultType.COMPACT) {
2253
+ if (Array.isArray(query)) {
2254
+ query.forEach(function (q) {
2255
+ _this4.patchQueryInternal(q, ResultType.COMPACT);
2256
+ });
2257
+ } else {
2258
+ this.patchQueryInternal(query, ResultType.COMPACT);
2259
+ }
2260
+ }
2261
+
2262
+ return this.loadMethod(function () {
2263
+ return _this4.request('subscribe', {
2264
+ query: query,
2265
+ queryType: 'multi'
2160
2266
  });
2161
- }, options, callback);
2267
+ }, this.loadResponseInternal.bind(this), _objectSpread(_objectSpread({}, options), {}, {
2268
+ subscribe: true
2269
+ }), callback);
2162
2270
  }
2163
2271
  }, {
2164
2272
  key: "sql",
2165
2273
  value: function sql(query, options, callback) {
2166
- var _this4 = this;
2274
+ var _this5 = this;
2167
2275
 
2168
2276
  return this.loadMethod(function () {
2169
- return _this4.request('sql', {
2277
+ return _this5.request('sql', {
2170
2278
  query: query
2171
2279
  });
2172
2280
  }, function (response) {
@@ -2178,10 +2286,10 @@ var CubejsApi = /*#__PURE__*/function () {
2178
2286
  }, {
2179
2287
  key: "meta",
2180
2288
  value: function meta(options, callback) {
2181
- var _this5 = this;
2289
+ var _this6 = this;
2182
2290
 
2183
2291
  return this.loadMethod(function () {
2184
- return _this5.request('meta');
2292
+ return _this6.request('meta');
2185
2293
  }, function (body) {
2186
2294
  return new Meta(body);
2187
2295
  }, options, callback);
@@ -2189,34 +2297,16 @@ var CubejsApi = /*#__PURE__*/function () {
2189
2297
  }, {
2190
2298
  key: "dryRun",
2191
2299
  value: function dryRun(query, options, callback) {
2192
- var _this6 = this;
2300
+ var _this7 = this;
2193
2301
 
2194
2302
  return this.loadMethod(function () {
2195
- return _this6.request('dry-run', {
2303
+ return _this7.request('dry-run', {
2196
2304
  query: query
2197
2305
  });
2198
2306
  }, function (response) {
2199
2307
  return response;
2200
2308
  }, options, callback);
2201
2309
  }
2202
- }, {
2203
- key: "subscribe",
2204
- value: function subscribe(query, options, callback) {
2205
- var _this7 = this;
2206
-
2207
- return this.loadMethod(function () {
2208
- return _this7.request('subscribe', {
2209
- query: query,
2210
- queryType: 'multi'
2211
- });
2212
- }, function (body) {
2213
- return new ResultSet(body, {
2214
- parseDateMeasures: _this7.parseDateMeasures
2215
- });
2216
- }, _objectSpread(_objectSpread({}, options), {}, {
2217
- subscribe: true
2218
- }), callback);
2219
- }
2220
2310
  }]);
2221
2311
 
2222
2312
  return CubejsApi;