@cubejs-client/core
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -218,2 +218,26 @@ 'use strict'; | ||
var SqlQuery = | ||
/*#__PURE__*/ | ||
function () { | ||
function SqlQuery(sqlQuery) { | ||
_classCallCheck(this, SqlQuery); | ||
this.sqlQuery = sqlQuery; | ||
} | ||
_createClass(SqlQuery, [{ | ||
key: "rawQuery", | ||
value: function rawQuery() { | ||
return this.sqlQuery.sql; | ||
} | ||
}, { | ||
key: "sql", | ||
value: function sql() { | ||
return this.rawQuery().sql[0]; | ||
} | ||
}]); | ||
return SqlQuery; | ||
}(); | ||
var ProgressResult = | ||
@@ -265,6 +289,4 @@ /*#__PURE__*/ | ||
}, { | ||
key: "load", | ||
value: function load(query, options, callback) { | ||
var _this = this; | ||
key: "loadMethod", | ||
value: function loadMethod(request, toResult, options, callback) { | ||
if (typeof options === 'function' && !callback) { | ||
@@ -289,3 +311,3 @@ callback = options; | ||
_context.next = 2; | ||
return _this.request("/load?query=".concat(JSON.stringify(query))); | ||
return request(); | ||
@@ -329,3 +351,3 @@ case 2: | ||
case 13: | ||
return _context.abrupt("return", new ResultSet(body)); | ||
return _context.abrupt("return", toResult(body)); | ||
@@ -355,2 +377,24 @@ case 14: | ||
} | ||
}, { | ||
key: "load", | ||
value: function load(query, options, callback) { | ||
var _this = this; | ||
return this.loadMethod(function () { | ||
return _this.request("/load?query=".concat(JSON.stringify(query))); | ||
}, function (body) { | ||
return new ResultSet(body); | ||
}, options, callback); | ||
} | ||
}, { | ||
key: "sql", | ||
value: function sql(query, options, callback) { | ||
var _this2 = this; | ||
return this.loadMethod(function () { | ||
return _this2.request("/sql?query=".concat(JSON.stringify(query))); | ||
}, function (body) { | ||
return new SqlQuery(body); | ||
}, options, callback); | ||
} | ||
}]); | ||
@@ -357,0 +401,0 @@ |
{ | ||
"name": "@cubejs-client/core", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "cube.js client", | ||
@@ -5,0 +5,0 @@ "main": "dist/cubejs-client-core.js", |
import { fetch } from 'whatwg-fetch'; | ||
import ResultSet from './ResultSet'; | ||
import SqlQuery from './SqlQuery'; | ||
import ProgressResult from './ProgressResult'; | ||
@@ -19,3 +20,3 @@ | ||
load(query, options, callback) { | ||
loadMethod(request, toResult, options, callback) { | ||
if (typeof options === 'function' && !callback) { | ||
@@ -28,4 +29,5 @@ callback = options; | ||
const loadImpl = async () => { | ||
const response = await this.request(`/load?query=${JSON.stringify(query)}`); | ||
const response = await request(); | ||
if (response.status === 502) { | ||
@@ -44,3 +46,3 @@ return loadImpl(); // TODO backoff wait | ||
} | ||
return new ResultSet(body); | ||
return toResult(body); | ||
}; | ||
@@ -53,2 +55,20 @@ if (callback) { | ||
} | ||
load(query, options, callback) { | ||
return this.loadMethod( | ||
() => this.request(`/load?query=${JSON.stringify(query)}`), | ||
(body) => new ResultSet(body), | ||
options, | ||
callback | ||
); | ||
} | ||
sql(query, options, callback) { | ||
return this.loadMethod( | ||
() => this.request(`/sql?query=${JSON.stringify(query)}`), | ||
(body) => new SqlQuery(body), | ||
options, | ||
callback | ||
); | ||
} | ||
} | ||
@@ -55,0 +75,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
280798
7
8269