@cubejs-client/core 0.29.23 → 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 +11 -0
- package/dist/cubejs-client-core.esm.js +120 -30
- package/dist/cubejs-client-core.esm.js.map +1 -1
- package/dist/cubejs-client-core.js +120 -30
- package/dist/cubejs-client-core.js.map +1 -1
- package/dist/cubejs-client-core.umd.js +152 -57
- package/dist/cubejs-client-core.umd.js.map +1 -1
- package/index.d.ts +13 -2
- package/package.json +3 -2
- package/src/index.js +117 -18
- package/src/index.test.js +454 -0
- package/src/tests/ResultSet.test.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.29](https://github.com/cube-js/cube.js/compare/v0.29.28...v0.29.29) (2022-03-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* 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)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.29.23](https://github.com/cube-js/cube.js/compare/v0.29.22...v0.29.23) (2022-01-26)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -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';
|
|
@@ -17,6 +15,9 @@ import 'core-js/modules/es.object.to-string.js';
|
|
|
17
15
|
import 'core-js/modules/es.promise.js';
|
|
18
16
|
import 'core-js/modules/es.array.is-array.js';
|
|
19
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 () {
|
|
@@ -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
|
-
},
|
|
2158
|
-
|
|
2159
|
-
|
|
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,
|
|
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
|
|
2274
|
+
var _this5 = this;
|
|
2167
2275
|
|
|
2168
2276
|
return this.loadMethod(function () {
|
|
2169
|
-
return
|
|
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
|
|
2289
|
+
var _this6 = this;
|
|
2182
2290
|
|
|
2183
2291
|
return this.loadMethod(function () {
|
|
2184
|
-
return
|
|
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
|
|
2300
|
+
var _this7 = this;
|
|
2193
2301
|
|
|
2194
2302
|
return this.loadMethod(function () {
|
|
2195
|
-
return
|
|
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;
|