rqlite-js 2.5.4 → 2.5.6

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.
@@ -1,4 +1,4 @@
1
1
  export const CONTENT_TYPE_TEXT_PLAIN = 'text/plain'
2
- export const CONTENT_TYPE_APPLICATION_JSON = 'application/json;charset=utf-8'
2
+ export const CONTENT_TYPE_APPLICATION_JSON = 'application/json'
3
3
  export const CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED = 'application/x-www-form-urlencoded'
4
4
  export const CONTENT_TYPE_APPLICATION_OCTET_STREAM = 'application/octet-stream'
@@ -89,14 +89,14 @@ function cleanPath (path) {
89
89
  * backoff algorithm.
90
90
  * @param {Number} attempt The retry attempt
91
91
  * @param {Number} base The base of the exponential backoff
92
- * @param {Number} pow The exponential power
92
+ * @param {Number} exponent The exponential power
93
93
  * @returns {Number} The time to wait in milliseconds
94
94
  */
95
- export function getWaitTimeExponential (attempt = 0, base = 100, pow = 2) {
95
+ export function getWaitTimeExponential (attempt = 0, base = 100, exponent = 2) {
96
96
  if (attempt === 0) {
97
97
  return 0
98
98
  }
99
- return (pow ** attempt) * base
99
+ return (exponent ** attempt) * base
100
100
  }
101
101
 
102
102
  /**
@@ -171,6 +171,11 @@ export default class HttpRequest {
171
171
  */
172
172
  exponentailBackoffBase = 100
173
173
 
174
+ /**
175
+ * The exponent to increase backoff each try
176
+ */
177
+ exponentailBackoffExponent = 1.1
178
+
174
179
  /**
175
180
  * Authentication Map
176
181
  * @type {Map}
@@ -199,6 +204,7 @@ export default class HttpRequest {
199
204
  * @param {Set|String[]} [options.retryableHttpMethods] The list of retryable http methods
200
205
  * @param {Number} [options.exponentailBackoffBase] The value for exponentail backoff base
201
206
  * for retry exponential backoff
207
+ * @param {Number} [options.exponentailBackoffExponent] Exponent to increase backoff each try
202
208
  */
203
209
  constructor (hosts, options = {}) {
204
210
  this.setHosts(hosts)
@@ -212,6 +218,7 @@ export default class HttpRequest {
212
218
  retryableErrorCodes,
213
219
  retryableStatusCodes,
214
220
  retryableHttpMethods,
221
+ exponentailBackoffExponent,
215
222
  exponentailBackoffBase,
216
223
  authentication,
217
224
  } = options
@@ -251,6 +258,9 @@ export default class HttpRequest {
251
258
  if (Number.isFinite(exponentailBackoffBase)) {
252
259
  this.setExponentailBackoffBase(exponentailBackoffBase)
253
260
  }
261
+ if (Number.isFinite(exponentailBackoffExponent)) {
262
+ this.setExponentailBackoffExponent(exponentailBackoffExponent)
263
+ }
254
264
  }
255
265
 
256
266
  /**
@@ -285,6 +295,22 @@ export default class HttpRequest {
285
295
  return this.exponentailBackoffBase
286
296
  }
287
297
 
298
+ /**
299
+ * Set the exponentail backoff exponent
300
+ * @param {Number} exponentailBackoffExponent
301
+ */
302
+ setExponentailBackoffExponent (exponentailBackoffExponent) {
303
+ this.exponentailBackoffExponent = exponentailBackoffExponent
304
+ }
305
+
306
+ /**
307
+ * Get the exponentail backoff exponent
308
+ * @return {Number} The exponentail backoff exponent
309
+ */
310
+ getExponentailBackoffExponent () {
311
+ return this.exponentailBackoffExponent
312
+ }
313
+
288
314
  /**
289
315
  * Set the retryable error codes
290
316
  * @param {Set} retryableErrorCodes
@@ -591,6 +617,7 @@ export default class HttpRequest {
591
617
  retryAttempt = 0,
592
618
  redirectAttempt = 0,
593
619
  attemptHostIndex,
620
+ exponentailBackoffExponent = this.getExponentailBackoffExponent(),
594
621
  exponentailBackoffBase = this.getExponentailBackoffBase(),
595
622
  httpAgent = this.getHttpAgent(),
596
623
  httpsAgent = this.getHttpsAgent(),
@@ -675,9 +702,16 @@ export default class HttpRequest {
675
702
  })
676
703
  }
677
704
  if (retryable && retryAttempt < retries) {
678
- const waitTime = getWaitTimeExponential(retryAttempt, exponentailBackoffBase)
679
- const delayPromise = new Promise((resolve) => setTimeout(resolve, waitTime))
680
- await delayPromise
705
+ const waitTime = getWaitTimeExponential(
706
+ retryAttempt,
707
+ exponentailBackoffBase,
708
+ exponentailBackoffExponent,
709
+ )
710
+ await new Promise((resolve) => {
711
+ setTimeout(() => {
712
+ resolve(undefined)
713
+ }, waitTime)
714
+ })
681
715
  return this.fetch({
682
716
  ...options,
683
717
  attempt: attempt + 1,
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.BACKUP_DATA_FORMAT_DUMP = exports.BACKUP_DATA_FORMAT_SQL = exports.PATH_BACKUP = exports.PATH_LOAD = void 0;var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.PATH_LOAD = exports.PATH_BACKUP = exports.BACKUP_DATA_FORMAT_SQL = exports.BACKUP_DATA_FORMAT_DUMP = void 0;var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
2
2
 
3
3
 
4
4
 
@@ -38,14 +38,14 @@ class BackupApiClient extends _httpRequest.default {
38
38
  const stream = _superprop_getGet().call(_this, {
39
39
  headers: {
40
40
  // Always sends application/octet-stream from the server in RQLite v4.x
41
- Accept: _contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM },
42
-
41
+ Accept: _contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM
42
+ },
43
43
  query: { fmt: format === BACKUP_DATA_FORMAT_SQL ? format : undefined },
44
44
  json: false,
45
45
  stream: true,
46
46
  uri: PATH_BACKUP,
47
- useLeader: true });
48
-
47
+ useLeader: true
48
+ });
49
49
  return stream;})();
50
50
  }
51
51
 
@@ -60,12 +60,13 @@ class BackupApiClient extends _httpRequest.default {
60
60
  body: data,
61
61
  headers: {
62
62
  // eslint-disable-next-line max-len
63
- 'Content-Type': format === BACKUP_DATA_FORMAT_SQL ? _contentTypes.CONTENT_TYPE_TEXT_PLAIN : _contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM },
64
-
63
+ 'Content-Type': format === BACKUP_DATA_FORMAT_SQL ? _contentTypes.CONTENT_TYPE_TEXT_PLAIN : _contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM
64
+ },
65
65
  json: false,
66
66
  stream: true,
67
67
  uri: PATH_LOAD,
68
- useLeader: true });})();
69
-
70
- }}exports.default = BackupApiClient;
68
+ useLeader: true
69
+ });})();
70
+ }
71
+ }exports.default = BackupApiClient;
71
72
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/backup/index.js"],"names":["PATH_LOAD","PATH_BACKUP","BACKUP_DATA_FORMAT_SQL","BACKUP_DATA_FORMAT_DUMP","BackupApiClient","HttpRequest","backup","format","stream","headers","Accept","CONTENT_TYPE_APPLICATION_OCTET_STREAM","query","fmt","undefined","json","uri","useLeader","load","data","body","CONTENT_TYPE_TEXT_PLAIN"],"mappings":";;;;AAIA;AACA,gE,CALA;AACA;AACA;AACA,G,CAIA;AACA;AACA,GACO,MAAMA,SAAS,GAAG,UAAlB;;AAEP;AACA;AACA,G;AACO,MAAMC,WAAW,GAAG,YAApB;;AAEP;AACA;AACA,G;AACO,MAAMC,sBAAsB,GAAG,KAA/B;;AAEP;AACA;AACA,G;AACO,MAAMC,uBAAuB,GAAG,MAAhC;;AAEP;AACA;AACA,G;AACe,MAAMC,eAAN,SAA8BC,oBAA9B,CAA0C;AACvD;AACF;AACA;AACA;AACA;AACQC,EAAAA,MAAM,CAAEC,MAAM,GAAGJ,uBAAX,EAAoC;AAC9C,YAAMK,MAAM,GAAG,gCAAU;AACvBC,QAAAA,OAAO,EAAE;AACP;AACAC,UAAAA,MAAM,EAAEC,mDAFD,EADc;;AAKvBC,QAAAA,KAAK,EAAE,EAAEC,GAAG,EAAEN,MAAM,KAAKL,sBAAX,GAAoCK,MAApC,GAA6CO,SAApD,EALgB;AAMvBC,QAAAA,IAAI,EAAE,KANiB;AAOvBP,QAAAA,MAAM,EAAE,IAPe;AAQvBQ,QAAAA,GAAG,EAAEf,WARkB;AASvBgB,QAAAA,SAAS,EAAE,IATY,EAAV,CAAf;;AAWA,aAAOT,MAAP,CAZ8C;AAa/C;;AAED;AACF;AACA;AACA;AACA;AACA;AACQU,EAAAA,IAAI,CAAEC,IAAF,EAAQZ,MAAM,GAAGL,sBAAjB,EAAyC;AACjD,aAAO,kCAAW;AAChBkB,QAAAA,IAAI,EAAED,IADU;AAEhBV,QAAAA,OAAO,EAAE;AACP;AACA,0BAAgBF,MAAM,KAAKL,sBAAX,GAAoCmB,qCAApC,GAA8DV,mDAFvE,EAFO;;AAMhBI,QAAAA,IAAI,EAAE,KANU;AAOhBP,QAAAA,MAAM,EAAE,IAPQ;AAQhBQ,QAAAA,GAAG,EAAEhB,SARW;AAShBiB,QAAAA,SAAS,EAAE,IATK,EAAX,CAAP,CADiD;;AAYlD,GAvCsD,C","sourcesContent":["/**\n * Backup api client to perform RQLite back and load operations\n * @module api/backup\n */\nimport HttpRequest from '../../http-request'\nimport { CONTENT_TYPE_APPLICATION_OCTET_STREAM, CONTENT_TYPE_TEXT_PLAIN } from '../../http-request/content-types'\n\n/**\n * The RQLite load api path\n */\nexport const PATH_LOAD = '/db/load'\n\n/**\n * The RQLite backup api path\n */\nexport const PATH_BACKUP = '/db/backup'\n\n/**\n * Use plain SQL dump as the back up format\n */\nexport const BACKUP_DATA_FORMAT_SQL = 'sql'\n\n/**\n * Use sqlite3 dump as the back up format\n */\nexport const BACKUP_DATA_FORMAT_DUMP = 'dump'\n\n/**\n * Backup api client to perform RQLite back up and load operations\n */\nexport default class BackupApiClient extends HttpRequest {\n /**\n * Perform a SQL dump backup from the RQLite server\n * @param {String} [format=BACKUP_DATA_FORMAT_DUMP] The backup data format\n * @returns {Stream} The response stream\n */\n async backup (format = BACKUP_DATA_FORMAT_DUMP) {\n const stream = super.get({\n headers: {\n // Always sends application/octet-stream from the server in RQLite v4.x\n Accept: CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n },\n query: { fmt: format === BACKUP_DATA_FORMAT_SQL ? format : undefined },\n json: false,\n stream: true,\n uri: PATH_BACKUP,\n useLeader: true,\n })\n return stream\n }\n\n /**\n * Perform a SQL restore by sending data the RQLite server\n * @param {Buffer|String} data The data to be loaded\n * @param {String} [format=BACKUP_DATA_FORMAT_SQL] The backup data format\n * @returns {Stream} The response stream\n */\n async load (data, format = BACKUP_DATA_FORMAT_SQL) {\n return super.post({\n body: data,\n headers: {\n // eslint-disable-next-line max-len\n 'Content-Type': format === BACKUP_DATA_FORMAT_SQL ? CONTENT_TYPE_TEXT_PLAIN : CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n },\n json: false,\n stream: true,\n uri: PATH_LOAD,\n useLeader: true,\n })\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_httpRequest","_interopRequireDefault","require","_contentTypes","PATH_LOAD","exports","PATH_BACKUP","BACKUP_DATA_FORMAT_SQL","BACKUP_DATA_FORMAT_DUMP","BackupApiClient","HttpRequest","backup","format","_superprop_getGet","get","_this","_asyncToGenerator2","default","stream","call","headers","Accept","CONTENT_TYPE_APPLICATION_OCTET_STREAM","query","fmt","undefined","json","uri","useLeader","load","data","_superprop_getPost","post","_this2","body","CONTENT_TYPE_TEXT_PLAIN"],"sources":["../../../es6/api/backup/index.js"],"sourcesContent":["/**\n * Backup api client to perform RQLite back and load operations\n * @module api/backup\n */\nimport HttpRequest from '../../http-request'\nimport { CONTENT_TYPE_APPLICATION_OCTET_STREAM, CONTENT_TYPE_TEXT_PLAIN } from '../../http-request/content-types'\n\n/**\n * The RQLite load api path\n */\nexport const PATH_LOAD = '/db/load'\n\n/**\n * The RQLite backup api path\n */\nexport const PATH_BACKUP = '/db/backup'\n\n/**\n * Use plain SQL dump as the back up format\n */\nexport const BACKUP_DATA_FORMAT_SQL = 'sql'\n\n/**\n * Use sqlite3 dump as the back up format\n */\nexport const BACKUP_DATA_FORMAT_DUMP = 'dump'\n\n/**\n * Backup api client to perform RQLite back up and load operations\n */\nexport default class BackupApiClient extends HttpRequest {\n /**\n * Perform a SQL dump backup from the RQLite server\n * @param {String} [format=BACKUP_DATA_FORMAT_DUMP] The backup data format\n * @returns {Stream} The response stream\n */\n async backup (format = BACKUP_DATA_FORMAT_DUMP) {\n const stream = super.get({\n headers: {\n // Always sends application/octet-stream from the server in RQLite v4.x\n Accept: CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n },\n query: { fmt: format === BACKUP_DATA_FORMAT_SQL ? format : undefined },\n json: false,\n stream: true,\n uri: PATH_BACKUP,\n useLeader: true,\n })\n return stream\n }\n\n /**\n * Perform a SQL restore by sending data the RQLite server\n * @param {Buffer|String} data The data to be loaded\n * @param {String} [format=BACKUP_DATA_FORMAT_SQL] The backup data format\n * @returns {Stream} The response stream\n */\n async load (data, format = BACKUP_DATA_FORMAT_SQL) {\n return super.post({\n body: data,\n headers: {\n // eslint-disable-next-line max-len\n 'Content-Type': format === BACKUP_DATA_FORMAT_SQL ? CONTENT_TYPE_TEXT_PLAIN : CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n },\n json: false,\n stream: true,\n uri: PATH_LOAD,\n useLeader: true,\n })\n }\n}\n"],"mappings":";;;;AAIA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA,qCAAiH,CALjH;AACA;AACA;AACA,GAHA,CAOA;AACA;AACA,GACO,MAAME,SAAS,GAAG,UAAU;;AAEnC;AACA;AACA,GAFAC,OAAA,CAAAD,SAAA,GAAAA,SAAA;AAGO,MAAME,WAAW,GAAG,YAAY;;AAEvC;AACA;AACA,GAFAD,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAGO,MAAMC,sBAAsB,GAAG,KAAK;;AAE3C;AACA;AACA,GAFAF,OAAA,CAAAE,sBAAA,GAAAA,sBAAA;AAGO,MAAMC,uBAAuB,GAAG,MAAM;;AAE7C;AACA;AACA,GAFAH,OAAA,CAAAG,uBAAA,GAAAA,uBAAA;AAGe,MAAMC,eAAe,SAASC,oBAAW,CAAC;EACvD;AACF;AACA;AACA;AACA;EACQC,MAAMA,CAAEC,MAAM,GAAGJ,uBAAuB,EAAE,KAAAK,iBAAA,GAAAA,CAAA,WAAAC,GAAA,CAAAC,KAAA,mBAAAC,kBAAA,CAAAC,OAAA;MAC9C,MAAMC,MAAM,GAAGL,iBAAA,GAAAM,IAAA,CAAAJ,KAAA,EAAU;QACvBK,OAAO,EAAE;UACP;UACAC,MAAM,EAAEC;QACV,CAAC;QACDC,KAAK,EAAE,EAAEC,GAAG,EAAEZ,MAAM,KAAKL,sBAAsB,GAAGK,MAAM,GAAGa,SAAS,CAAC,CAAC;QACtEC,IAAI,EAAE,KAAK;QACXR,MAAM,EAAE,IAAI;QACZS,GAAG,EAAErB,WAAW;QAChBsB,SAAS,EAAE;MACb,CAAC,CAAC;MACF,OAAOV,MAAM;EACf;;EAEA;AACF;AACA;AACA;AACA;AACA;EACQW,IAAIA,CAAEC,IAAI,EAAElB,MAAM,GAAGL,sBAAsB,EAAE,KAAAwB,kBAAA,GAAAA,CAAA,WAAAC,IAAA,CAAAC,MAAA,mBAAAjB,kBAAA,CAAAC,OAAA;MACjD,OAAOc,kBAAA,GAAAZ,IAAA,CAAAc,MAAA,EAAW;QAChBC,IAAI,EAAEJ,IAAI;QACVV,OAAO,EAAE;UACP;UACA,cAAc,EAAER,MAAM,KAAKL,sBAAsB,GAAG4B,qCAAuB,GAAGb;QAChF,CAAC;QACDI,IAAI,EAAE,KAAK;QACXR,MAAM,EAAE,IAAI;QACZS,GAAG,EAAEvB,SAAS;QACdwB,SAAS,EAAE;MACb,CAAC,CAAC;EACJ;AACF,CAACvB,OAAA,CAAAY,OAAA,GAAAR,eAAA"}
@@ -3,13 +3,13 @@
3
3
 
4
4
 
5
5
  var _httpRequest = _interopRequireDefault(require("../../http-request"));
6
- var _httpMethods = require("../../http-request/http-methods");function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) {symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;});}keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(Object(source), true).forEach(function (key) {(0, _defineProperty2.default)(target, key, source[key]);});} else if (Object.getOwnPropertyDescriptors) {Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));} else {ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}}return target;}
7
-
8
- /**
6
+ var _httpMethods = require("../../http-request/http-methods");function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);enumerableOnly && (symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;})), keys.push.apply(keys, symbols);}return keys;}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) {(0, _defineProperty2.default)(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;} /**
7
+ * Base API client for RQLite which abstracts the HTTP calls
8
+ * @module api/client
9
+ */ /**
9
10
  * @typedef HttpRequestOptions
10
11
  * @type {import('../../http-request').HttpRequestOptions}
11
12
  */
12
-
13
13
  /**
14
14
  * Create the base HTTP query options from RQLite API options
15
15
  * @param {Object} [options={}] The RQLite API options
@@ -57,8 +57,8 @@ class ApiClient extends _httpRequest.default {
57
57
  useLeader,
58
58
  uri: path,
59
59
  httpMethod: _httpMethods.HTTP_METHOD_GET,
60
- query: _objectSpread(_objectSpread({}, createQuery(options)), {}, { q: sql }) });})();
61
-
60
+ query: _objectSpread(_objectSpread({}, createQuery(options)), {}, { q: sql })
61
+ });})();
62
62
  }
63
63
 
64
64
  /**
@@ -77,7 +77,8 @@ class ApiClient extends _httpRequest.default {
77
77
  uri: path,
78
78
  httpMethod: _httpMethods.HTTP_METHOD_POST,
79
79
  query: createQuery(options),
80
- body: Array.isArray(sql) ? sql : [sql] });})();
81
-
82
- }}exports.default = ApiClient;
80
+ body: Array.isArray(sql) ? sql : [sql]
81
+ });})();
82
+ }
83
+ }exports.default = ApiClient;
83
84
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/client/index.js"],"names":["createQuery","options","level","pretty","timings","atomic","transaction","query","Object","entries","reduce","acc","entry","key","val","ApiClient","HttpRequest","get","path","sql","useLeader","Error","uri","httpMethod","HTTP_METHOD_GET","q","post","HTTP_METHOD_POST","body","Array","isArray"],"mappings":";;;;AAIA;AACA,8D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,OAAO,GAAG,EAAhC,EAAoC;AACzC,QAAQC,KAAR,GAAwDD,OAAxD,CAAQC,KAAR,CAAeC,MAAf,GAAwDF,OAAxD,CAAeE,MAAf,CAAuBC,OAAvB,GAAwDH,OAAxD,CAAuBG,OAAvB,CAAgCC,MAAhC,GAAwDJ,OAAxD,CAAgCI,MAAhC,CAAwCC,WAAxC,GAAwDL,OAAxD,CAAwCK,WAAxC;;AAEA;AACA,QAAMC,KAAK,GAAG,EAAEL,KAAF,EAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,EAAd;AACA,SAAOE,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,MAAtB,CAA6B,CAACC,GAAD,EAAMC,KAAN,KAAgB;AAClD,gDAAmBA,KAAnB,KAAOC,GAAP,aAAYC,GAAZ;AACA;AACA,QA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Base API client for RQLite which abstracts the HTTP calls\n * @module api/client\n */\nimport HttpRequest from '../../http-request'\nimport { HTTP_METHOD_GET, HTTP_METHOD_POST } from '../../http-request/http-methods'\n\n/**\n * @typedef HttpRequestOptions\n * @type {import('../../http-request').HttpRequestOptions}\n */\n\n/**\n * Create the base HTTP query options from RQLite API options\n * @param {Object} [options={}] The RQLite API options\n * @param {String} [options.level] The consistency level\n * @param {String} [options.pretty] Pretty print the response body\n * @param {String} [options.timings] Provide query timings\n * @param {String} [options.atomic] Treat all commands in the request as a single transaction\n * for RQLite v5 and higher\n * @param {String} [options.transaction] Treat all commands in the request as a single transaction\n * for RQLite v4 and lower\n * @returns {Object} The HTTP query\n */\nexport function createQuery (options = {}) {\n const { level, pretty, timings, atomic, transaction } = options\n\n // Remove all undefined values\n const query = { level, pretty, timings, atomic, transaction }\n return Object.entries(query).reduce((acc, entry) => {\n const [key, val] = entry\n // Only take defined values\n if (typeof val !== 'undefined') {\n acc[key] = val\n }\n return acc\n }, {})\n}\n\n/**\n * Base API client for RQLite which abstracts the HTTP calls\n * from the user\n */\nexport default class ApiClient extends HttpRequest {\n /**\n * Perform a RQLite data API get request\n * @param {String} path The path for the request i.e. /db/query\n * @param {String} sql The SQL query\n * @param {HttpRequestOptions} [options={}] RQLite API options\n */\n async get (path, sql, options = {}) {\n const { useLeader } = options\n if (!path) {\n throw new Error('The path argument is required')\n }\n return super.get({\n useLeader,\n uri: path,\n httpMethod: HTTP_METHOD_GET,\n query: { ...createQuery(options), q: sql },\n })\n }\n\n /**\n * Perform a RQLite data API post request\n * @param {String} path The path for the request i.e. /db/query\n * @param {String} sql The SQL query\n * @param {HttpRequestOptions} [options={}] RQLite API options\n */\n async post (path, sql, options = {}) {\n const { useLeader } = options\n if (!path) {\n throw new Error('The path argument is required')\n }\n return super.post({\n useLeader,\n uri: path,\n httpMethod: HTTP_METHOD_POST,\n query: createQuery(options),\n body: Array.isArray(sql) ? sql : [sql],\n })\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_httpRequest","_interopRequireDefault","require","_httpMethods","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","createQuery","options","level","pretty","timings","atomic","transaction","query","entries","reduce","acc","entry","_entry","_slicedToArray2","val","ApiClient","HttpRequest","get","path","sql","_superprop_getGet","_this","_asyncToGenerator2","useLeader","Error","call","uri","httpMethod","HTTP_METHOD_GET","q","post","_superprop_getPost","_this2","HTTP_METHOD_POST","body","Array","isArray","exports"],"sources":["../../../es6/api/client/index.js"],"sourcesContent":["/**\n * Base API client for RQLite which abstracts the HTTP calls\n * @module api/client\n */\nimport HttpRequest from '../../http-request'\nimport { HTTP_METHOD_GET, HTTP_METHOD_POST } from '../../http-request/http-methods'\n\n/**\n * @typedef HttpRequestOptions\n * @type {import('../../http-request').HttpRequestOptions}\n */\n\n/**\n * Create the base HTTP query options from RQLite API options\n * @param {Object} [options={}] The RQLite API options\n * @param {String} [options.level] The consistency level\n * @param {String} [options.pretty] Pretty print the response body\n * @param {String} [options.timings] Provide query timings\n * @param {String} [options.atomic] Treat all commands in the request as a single transaction\n * for RQLite v5 and higher\n * @param {String} [options.transaction] Treat all commands in the request as a single transaction\n * for RQLite v4 and lower\n * @returns {Object} The HTTP query\n */\nexport function createQuery (options = {}) {\n const { level, pretty, timings, atomic, transaction } = options\n\n // Remove all undefined values\n const query = { level, pretty, timings, atomic, transaction }\n return Object.entries(query).reduce((acc, entry) => {\n const [key, val] = entry\n // Only take defined values\n if (typeof val !== 'undefined') {\n acc[key] = val\n }\n return acc\n }, {})\n}\n\n/**\n * Base API client for RQLite which abstracts the HTTP calls\n * from the user\n */\nexport default class ApiClient extends HttpRequest {\n /**\n * Perform a RQLite data API get request\n * @param {String} path The path for the request i.e. /db/query\n * @param {String} sql The SQL query\n * @param {HttpRequestOptions} [options={}] RQLite API options\n */\n async get (path, sql, options = {}) {\n const { useLeader } = options\n if (!path) {\n throw new Error('The path argument is required')\n }\n return super.get({\n useLeader,\n uri: path,\n httpMethod: HTTP_METHOD_GET,\n query: { ...createQuery(options), q: sql },\n })\n }\n\n /**\n * Perform a RQLite data API post request\n * @param {String} path The path for the request i.e. /db/query\n * @param {String} sql The SQL query\n * @param {HttpRequestOptions} [options={}] RQLite API options\n */\n async post (path, sql, options = {}) {\n const { useLeader } = options\n if (!path) {\n throw new Error('The path argument is required')\n }\n return super.post({\n useLeader,\n uri: path,\n httpMethod: HTTP_METHOD_POST,\n query: createQuery(options),\n body: Array.isArray(sql) ? sql : [sql],\n })\n }\n}\n"],"mappings":";;;;AAIA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA,oCAAmF,SAAAE,QAAAC,MAAA,EAAAC,cAAA,OAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,MAAAG,MAAA,CAAAC,qBAAA,OAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,EAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,UAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,MAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,UAAAH,IAAA,WAAAU,cAAAC,MAAA,YAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,SAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,OAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CA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AA"}
@@ -1,16 +1,16 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.CONSISTENCY_LEVEL_WEAK = exports.CONSISTENCY_LEVEL_STRONG = exports.CONSISTENCY_LEVEL_NONE = exports.PATH_EXECUTE = exports.PATH_QUERY = void 0;var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.PATH_QUERY = exports.PATH_EXECUTE = exports.CONSISTENCY_LEVEL_WEAK = exports.CONSISTENCY_LEVEL_STRONG = exports.CONSISTENCY_LEVEL_NONE = void 0;var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
2
2
 
3
3
 
4
4
 
5
5
 
6
6
  var _client = _interopRequireDefault(require("../client"));
7
- var _results = require("../results");function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) {symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;});}keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(Object(source), true).forEach(function (key) {(0, _defineProperty2.default)(target, key, source[key]);});} else if (Object.getOwnPropertyDescriptors) {Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));} else {ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}}return target;}
8
-
9
- /**
7
+ var _results = require("../results");function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);enumerableOnly && (symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;})), keys.push.apply(keys, symbols);}return keys;}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) {(0, _defineProperty2.default)(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;} /**
8
+ * Data api client to perform RQLite data operations such
9
+ * as query and execute
10
+ * @module api/data
11
+ */ /**
10
12
  * The RQLite query api path
11
- */
12
- const PATH_QUERY = '/db/query';
13
-
13
+ */const PATH_QUERY = '/db/query';
14
14
  /**
15
15
  * The RQLite execute api path
16
16
  */exports.PATH_QUERY = PATH_QUERY;
@@ -119,5 +119,6 @@ class DataApiClient extends _client.default {
119
119
  execute(sql, options = {}) {var _superprop_getPost2 = () => super.post,_this2 = this;return (0, _asyncToGenerator2.default)(function* () {
120
120
  const response = yield _superprop_getPost2().call(_this2, PATH_EXECUTE, sql, options);
121
121
  return handleResponse(response, options);})();
122
- }}exports.default = DataApiClient;
122
+ }
123
+ }exports.default = DataApiClient;
123
124
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/data/index.js"],"names":["PATH_QUERY","PATH_EXECUTE","CONSISTENCY_LEVEL_NONE","CONSISTENCY_LEVEL_STRONG","CONSISTENCY_LEVEL_WEAK","handleResponse","response","options","raw","body","DataResults","DataApiClient","ApiClient","query","sql","level","useLeader","Array","isArray","setNextActiveHostIndex","execute"],"mappings":";;;;;AAKA;AACA,qC;;AAEA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,WAAnB;;AAEP;AACA;AACA,G;AACO,MAAMC,YAAY,GAAG,a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ACD;AACD;AACA;AACA,UAAI,CAACA,SAAL,EAAgB;AACd,QAAA,KAAI,CAACG,sBAAL;AACD;AACD,aAAOd,cAAc,CAACC,QAAD,EAAWC,OAAX,CAArB,CAnB8B;AAoB/B;;AAED;AACF;AACA;AACA;AACA;AACQa,EAAAA,OAAO,CAAEN,GAAF,EAAOP,OAAO,GAAG,EAAjB,EAAqB;AAChC,YAAMD,QAAQ,SAAS,mCAAWL,YAAX,EAAyBa,GAAzB,EAA8BP,OAA9B,CAAvB;AACA,aAAOF,cAAc,CAACC,QAAD,EAAWC,OAAX,CAArB,CAFgC;AAGjC,GApCkD,C","sourcesContent":["/**\n * Data api client to perform RQLite data operations such\n * as query and execute\n * @module api/data\n */\nimport ApiClient from '../client'\nimport { DataResults } from '../results'\n\n/**\n * The RQLite query api path\n */\nexport const PATH_QUERY = '/db/query'\n\n/**\n * The RQLite execute api path\n */\nexport const PATH_EXECUTE = '/db/execute'\n\n/**\n * Read query consistency level none which means\n * any node can respond\n */\nexport const CONSISTENCY_LEVEL_NONE = 'none'\n\n/**\n * Read query consistency strong which must come from\n * the master node\n */\nexport const CONSISTENCY_LEVEL_STRONG = 'strong'\n\n/**\n * Read query consistency weak which must come from\n * the master node\n */\nexport const CONSISTENCY_LEVEL_WEAK = 'weak'\n\n/**\n * @typedef HttpRequestOptions\n * @type {import('../../http-request').HttpRequestOptions}\n */\n\n/**\n * Data request base options\n * @typedef DataRequestBaseOptions\n * @type {Object}\n * @property {Boolean} [raw] If true return the raw http response from\n * RQLite response\n */\n\n/**\n * Data query request base options\n * @typedef QueryRequestBaseOptions\n * @type {Object}\n * @property {String} level The api consistency level\n */\n\n/**\n * Data query request options\n * @typedef QueryRequestOptions\n * @type {HttpRequestOptions & DataRequestBaseOptions & QueryRequestBaseOptions}\n */\n\n/**\n * Data execute request options\n * @typedef ExecuteRequestOptions\n * @type {HttpRequestOptions & DataRequestBaseOptions}\n */\n\n/**\n * Send an RQLite query API request to the RQLite server\n * @param {String} sql The SQL string to excute on the server\n * @param {DataRequestBaseOptions} [options={}] RQLite api options\n */\nfunction handleResponse (response, options = {}) {\n const { raw } = options\n const { body } = response\n if (raw) {\n return response\n }\n return new DataResults(body)\n}\n\n/**\n * Data api client to perform RQLite queries\n */\nexport default class DataApiClient extends ApiClient {\n /**\n * Send an RQLite query API request to the RQLite server\n * @param {String} sql The SQL string to excute on the server\n * @param {QueryRequestOptions} [options={}] RQLite api options\n */\n async query (sql, options = {}) {\n const { level } = options\n let { useLeader } = options\n // Weak and strong consistency will be redirect to the master anyway\n // so skip the redirect HTTP response and got right to the master\n if (level !== CONSISTENCY_LEVEL_NONE) {\n useLeader = true\n }\n let response\n if (Array.isArray(sql)) {\n response = await super.post(PATH_QUERY, sql, { ...options, useLeader })\n } else {\n response = await super.get(PATH_QUERY, sql, { ...options, useLeader })\n }\n // If round robin is true try and balance selects across hosts when\n // the master node is not queried directly\n if (!useLeader) {\n this.setNextActiveHostIndex()\n }\n return handleResponse(response, options)\n }\n\n /**\n * Send an RQLite execute API request to the RQLite server\n * @param {String} sql The SQL string to excute on the server\n * @param {ExecuteRequestOptions} [options={}] RQLite execute api options\n */\n async execute (sql, options = {}) {\n const response = await super.post(PATH_EXECUTE, sql, options)\n return handleResponse(response, options)\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_client","_interopRequireDefault","require","_results","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","PATH_QUERY","exports","PATH_EXECUTE","CONSISTENCY_LEVEL_NONE","CONSISTENCY_LEVEL_STRONG","CONSISTENCY_LEVEL_WEAK","handleResponse","response","options","raw","body","DataResults","DataApiClient","ApiClient","query","sql","_superprop_getPost","post","_superprop_getGet","get","_this","_asyncToGenerator2","level","useLeader","Array","isArray","call","setNextActiveHostIndex","execute","_superprop_getPost2","_this2"],"sources":["../../../es6/api/data/index.js"],"sourcesContent":["/**\n * Data api client to perform RQLite data operations such\n * as query and execute\n * @module api/data\n */\nimport ApiClient from '../client'\nimport { DataResults } from '../results'\n\n/**\n * The RQLite query api path\n */\nexport const PATH_QUERY = '/db/query'\n\n/**\n * The RQLite execute api path\n */\nexport const PATH_EXECUTE = '/db/execute'\n\n/**\n * Read query consistency level none which means\n * any node can respond\n */\nexport const CONSISTENCY_LEVEL_NONE = 'none'\n\n/**\n * Read query consistency strong which must come from\n * the master node\n */\nexport const CONSISTENCY_LEVEL_STRONG = 'strong'\n\n/**\n * Read query consistency weak which must come from\n * the master node\n */\nexport const CONSISTENCY_LEVEL_WEAK = 'weak'\n\n/**\n * @typedef HttpRequestOptions\n * @type {import('../../http-request').HttpRequestOptions}\n */\n\n/**\n * Data request base options\n * @typedef DataRequestBaseOptions\n * @type {Object}\n * @property {Boolean} [raw] If true return the raw http response from\n * RQLite response\n */\n\n/**\n * Data query request base options\n * @typedef QueryRequestBaseOptions\n * @type {Object}\n * @property {String} level The api consistency level\n */\n\n/**\n * Data query request options\n * @typedef QueryRequestOptions\n * @type {HttpRequestOptions & DataRequestBaseOptions & QueryRequestBaseOptions}\n */\n\n/**\n * Data execute request options\n * @typedef ExecuteRequestOptions\n * @type {HttpRequestOptions & DataRequestBaseOptions}\n */\n\n/**\n * Send an RQLite query API request to the RQLite server\n * @param {String} sql The SQL string to excute on the server\n * @param {DataRequestBaseOptions} [options={}] RQLite api options\n */\nfunction handleResponse (response, options = {}) {\n const { raw } = options\n const { body } = response\n if (raw) {\n return response\n }\n return new DataResults(body)\n}\n\n/**\n * Data api client to perform RQLite queries\n */\nexport default class DataApiClient extends ApiClient {\n /**\n * Send an RQLite query API request to the RQLite server\n * @param {String} sql The SQL string to excute on the server\n * @param {QueryRequestOptions} [options={}] RQLite api options\n */\n async query (sql, options = {}) {\n const { level } = options\n let { useLeader } = options\n // Weak and strong consistency will be redirect to the master anyway\n // so skip the redirect HTTP response and got right to the master\n if (level !== CONSISTENCY_LEVEL_NONE) {\n useLeader = true\n }\n let response\n if (Array.isArray(sql)) {\n response = await super.post(PATH_QUERY, sql, { ...options, useLeader })\n } else {\n response = await super.get(PATH_QUERY, sql, { ...options, useLeader })\n }\n // If round robin is true try and balance selects across hosts when\n // the master node is not queried directly\n if (!useLeader) {\n this.setNextActiveHostIndex()\n }\n return handleResponse(response, options)\n }\n\n /**\n * Send an RQLite execute API request to the RQLite server\n * @param {String} sql The SQL string to excute on the server\n * @param {ExecuteRequestOptions} [options={}] RQLite execute api options\n */\n async execute (sql, options = {}) {\n const response = await super.post(PATH_EXECUTE, sql, options)\n return handleResponse(response, options)\n }\n}\n"],"mappings":";;;;;AAKA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA,eAAwC,SAAAE,QAAAC,MAAA,EAAAC,cAAA,OAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,MAAAG,MAAA,CAAAC,qBAAA,OAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,EAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,UAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,MAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,UAAAH,IAAA,WAAAU,cAAAC,MAAA,YAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,SAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,OAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,Q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A,EAAW5B,YAAY,EAAEa,GAAG,EAAEP,OAAO,CAAC;MAC7D,OAAOF,cAAc,CAACC,QAAQ,EAAEC,OAAO,CAAC;EAC1C;AACF,CAACP,OAAA,CAAAL,OAAA,GAAAgB,aAAA"}
@@ -28,5 +28,6 @@ class DataResultError extends Error {
28
28
  */
29
29
  toString() {
30
30
  return JSON.stringify(this.toObject());
31
- }}exports.default = DataResultError;module.exports = exports.default;
31
+ }
32
+ }exports.default = DataResultError;module.exports = exports.default;
32
33
  //# sourceMappingURL=data-result-error.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/results/data-result-error.js"],"names":["DataResultError","Error","constructor","args","name","code","toObject","error","message","toString","JSON","stringify"],"mappings":"qGAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,MAAMA,eAAN,SAA8BC,KAA9B,CAAoC;AACjDC,EAAAA,WAAW,CAAE,GAAGC,IAAL,EAAW;AACpB,UAAM,GAAGA,IAAT;AACA,SAAKC,IAAL,GAAY,KAAKF,WAAL,CAAiBE,IAA7B;AACA,SAAKC,IAAL,GAAY,KAAKH,WAAL,CAAiBE,IAA7B;AACD;;AAED;AACF;AACA;AACA;AACEE,EAAAA,QAAQ,GAAI;AACV,WAAO,EAAEC,KAAK,EAAE,KAAKC,OAAd,EAAP;AACD;;AAED;AACF;AACA;AACA;AACEC,EAAAA,QAAQ,GAAI;AACV,WAAOC,IAAI,CAACC,SAAL,CAAe,KAAKL,QAAL,EAAf,CAAP;AACD,GArBgD,C","sourcesContent":["/**\n * Class for handling RQLite data api result error\n * @module api/results/data-results\n */\n\n/**\n * A class that represents one data error result from an RQLite query or execute\n * API call\n */\nexport default class DataResultError extends Error {\n constructor (...args) {\n super(...args)\n this.name = this.constructor.name\n this.code = this.constructor.name\n }\n\n /**\n * Get the result data error as plain object\n * @returns {Object} The data as an object\n */\n toObject () {\n return { error: this.message }\n }\n\n /**\n * Convert the result data error to a JSON string\n * @returns {String} The JSON string for the data object\n */\n toString () {\n return JSON.stringify(this.toObject())\n }\n}\n"],"file":"data-result-error.js"}
1
+ {"version":3,"file":"data-result-error.js","names":["DataResultError","Error","constructor","args","name","code","toObject","error","message","toString","JSON","stringify","exports","default","module"],"sources":["../../../es6/api/results/data-result-error.js"],"sourcesContent":["/**\n * Class for handling RQLite data api result error\n * @module api/results/data-results\n */\n\n/**\n * A class that represents one data error result from an RQLite query or execute\n * API call\n */\nexport default class DataResultError extends Error {\n constructor (...args) {\n super(...args)\n this.name = this.constructor.name\n this.code = this.constructor.name\n }\n\n /**\n * Get the result data error as plain object\n * @returns {Object} The data as an object\n */\n toObject () {\n return { error: this.message }\n }\n\n /**\n * Convert the result data error to a JSON string\n * @returns {String} The JSON string for the data object\n */\n toString () {\n return JSON.stringify(this.toObject())\n }\n}\n"],"mappings":"qGAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,MAAMA,eAAe,SAASC,KAAK,CAAC;EACjDC,WAAWA,CAAE,GAAGC,IAAI,EAAE;IACpB,KAAK,CAAC,GAAGA,IAAI,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,IAAI,CAACF,WAAW,CAACE,IAAI;IACjC,IAAI,CAACC,IAAI,GAAG,IAAI,CAACH,WAAW,CAACE,IAAI;EACnC;;EAEA;AACF;AACA;AACA;EACEE,QAAQA,CAAA,EAAI;IACV,OAAO,EAAEC,KAAK,EAAE,IAAI,CAACC,OAAO,CAAC,CAAC;EAChC;;EAEA;AACF;AACA;AACA;EACEC,QAAQA,CAAA,EAAI;IACV,OAAOC,IAAI,CAACC,SAAS,CAAC,IAAI,CAACL,QAAQ,CAAC,CAAC,CAAC;EACxC;AACF,CAACM,OAAA,CAAAC,OAAA,GAAAb,eAAA,CAAAc,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA"}
@@ -8,34 +8,34 @@
8
8
  * API call
9
9
  */
10
10
  class DataResult {
11
- /**
12
- * The time the results query took to complete
13
- * @type {Number}
14
- */
15
11
 
16
12
 
17
- /**
18
- * The last insert id
19
- * @type {Number}
20
- */
21
13
 
22
14
 
23
- /**
24
- * The rows affected
25
- * @type {Number}
26
- */
27
15
 
28
16
 
29
- /**
30
- * An array of DataResult and/or DataResultError instances
31
- * @type {Array<DataResult|DataResultError>}
32
- */
33
17
 
34
18
 
35
- /**
36
- * An object after the columns and values are mapped from
37
- * an RQLite response
38
- */
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
39
 
40
40
 
41
41
  /**
@@ -43,26 +43,26 @@ class DataResult {
43
43
  * @param {Array} result An API response individual result
44
44
  * @param {Array} [valuesIndex] The index to get the values from the result
45
45
  */
46
- constructor(result, valuesIndex) {(0, _defineProperty2.default)(this, "time", 0.0);(0, _defineProperty2.default)(this, "lastInsertId", void 0);(0, _defineProperty2.default)(this, "rowsAffected", 0);(0, _defineProperty2.default)(this, "results", []);(0, _defineProperty2.default)(this, "data", {});
47
- if (typeof result !== 'object') {
48
- throw new Error('The result argument is required to be an object');
49
- }
50
- if (typeof valuesIndex !== 'undefined' && !Number.isFinite(valuesIndex)) {
51
- throw new Error('The valuesIndex argument is required to be a finite number when provided');
52
- }
53
- this.time = parseFloat(result.time || 0.0);
54
- this.rowsAffected = parseInt(result.rows_affected || 0, 10);
55
- this.lastInsertId = result.last_insert_id;
56
- // Map the values array to an object where columns are the properties
57
- if (Number.isFinite(valuesIndex)) {
58
- const columns = result.columns;
59
- const resultValues = result.values[valuesIndex];
60
- if (resultValues) {
61
- this.data = resultValues.reduce((acc, val, i) => {
62
- const col = columns[i];
63
- acc[col] = val;
64
- return acc;
65
- }, {});
46
+ constructor(result, valuesIndex) {/**
47
+ * The time the results query took to complete
48
+ * @type {Number}
49
+ */(0, _defineProperty2.default)(this, "time", 0.0); /**
50
+ * The last insert id
51
+ * @type {Number}
52
+ */(0, _defineProperty2.default)(this, "lastInsertId", void 0); /**
53
+ * The rows affected
54
+ * @type {Number}
55
+ */(0, _defineProperty2.default)(this, "rowsAffected", 0); /**
56
+ * An array of DataResult and/or DataResultError instances
57
+ * @type {Array<DataResult|DataResultError>}
58
+ */(0, _defineProperty2.default)(this, "results", []); /**
59
+ * An object after the columns and values are mapped from
60
+ * an RQLite response
61
+ */(0, _defineProperty2.default)(this, "data", {});if (typeof result !== 'object') {throw new Error('The result argument is required to be an object');}if (typeof valuesIndex !== 'undefined' && !Number.isFinite(valuesIndex)) {throw new Error('The valuesIndex argument is required to be a finite number when provided');}this.time = parseFloat(result.time || 0.0);this.rowsAffected = parseInt(result.rows_affected || 0, 10);this.lastInsertId = result.last_insert_id; // Map the values array to an object where columns are the properties
62
+ if (Number.isFinite(valuesIndex)) {const columns = result.columns;const resultValues = result.values[valuesIndex];if (resultValues) {this.data = resultValues.reduce((acc, val, i) => {const col = columns[i];
63
+ acc[col] = val;
64
+ return acc;
65
+ }, {});
66
66
  }
67
67
  }
68
68
  }
@@ -130,5 +130,6 @@ class DataResult {
130
130
  */
131
131
  toString() {
132
132
  return JSON.stringify(this.data);
133
- }}exports.default = DataResult;module.exports = exports.default;
133
+ }
134
+ }exports.default = DataResult;module.exports = exports.default;
134
135
  //# sourceMappingURL=data-result.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/results/data-result.js"],"names":["DataResult","constructor","result","valuesIndex","Error","Number","isFinite","time","parseFloat","rowsAffected","parseInt","rows_affected","lastInsertId","last_insert_id","columns","resultValues","values","data","reduce","acc","val","i","col","get","property","getTime","getLastInsertId","getRowsAffected","toObject","JSON","parse","stringify","toArray","Object","toColumnsArray","keys","toString"],"mappings":"0RAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,MAAMA,UAAN,CAAiB;AAC9B;AACF;AACA;AACA;;;AAGE;AACF;AACA;AACA;;;AAGE;AACF;AACA;AACA;;;AAGE;AACF;AACA;AACA;;;AAGE;AACF;AACA;AACA;;;AAGE;AACF;AACA;AACA;AACA;AACEC,E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AED;AACF;AACA;AACA;AACEmB,EAAAA,eAAe,GAAI;AACjB,WAAO,KAAKd,YAAZ;AACD;;AAED;AACF;AACA;AACA;AACEe,EAAAA,eAAe,GAAI;AACjB,WAAO,KAAKlB,YAAZ;AACD;;AAED;AACF;AACA;AACA;AACEmB,EAAAA,QAAQ,GAAI;AACV;AACA,WAAOC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAe,KAAKd,IAApB,CAAX,CAAP;AACD;;AAED;AACF;AACA;AACA;AACEe,EAAAA,OAAO,GAAI;AACT,WAAOC,MAAM,CAACjB,MAAP,CAAc,KAAKC,IAAnB,CAAP;AACD;;AAED;AACF;AACA;AACA;AACEiB,EAAAA,cAAc,GAAI;AAChB,WAAOD,MAAM,CAACE,IAAP,CAAY,KAAKlB,IAAjB,CAAP;AACD;;AAED;AACF;AACA;AACA;AACEmB,EAAAA,QAAQ,GAAI;AACV,WAAOP,IAAI,CAACE,SAAL,CAAe,KAAKd,IAApB,CAAP;AACD,GA3H6B,C","sourcesContent":["/**\n * Class for handling single RQLite data api result\n * @module api/results/data-result\n */\n\n/**\n * A class that represents one data result from an RQLite query or execute\n * API call\n */\nexport default class DataResult {\n /**\n * The time the results query took to complete\n * @type {Number}\n */\n time = 0.0\n\n /**\n * The last insert id\n * @type {Number}\n */\n lastInsertId\n\n /**\n * The rows affected\n * @type {Number}\n */\n rowsAffected = 0\n\n /**\n * An array of DataResult and/or DataResultError instances\n * @type {Array<DataResult|DataResultError>}\n */\n results = []\n\n /**\n * An object after the columns and values are mapped from\n * an RQLite response\n */\n data = {}\n\n /**\n * The data result constructor\n * @param {Array} result An API response individual result\n * @param {Array} [valuesIndex] The index to get the values from the result\n */\n constructor (result, valuesIndex) {\n if (typeof result !== 'object') {\n throw new Error('The result argument is required to be an object')\n }\n if (typeof valuesIndex !== 'undefined' && !Number.isFinite(valuesIndex)) {\n throw new Error('The valuesIndex argument is required to be a finite number when provided')\n }\n this.time = parseFloat(result.time || 0.0)\n this.rowsAffected = parseInt(result.rows_affected || 0, 10)\n this.lastInsertId = result.last_insert_id\n // Map the values array to an object where columns are the properties\n if (Number.isFinite(valuesIndex)) {\n const { columns } = result\n const resultValues = result.values[valuesIndex]\n if (resultValues) {\n this.data = resultValues.reduce((acc, val, i) => {\n const col = columns[i]\n acc[col] = val\n return acc\n }, {})\n }\n }\n }\n\n /**\n * Return the value a property or undefined if it does not exist\n * @returns {*} The value of the property or undefined\n */\n get (property) {\n return this.data[property]\n }\n\n /**\n * Get the time the result took\n * @returns {Number} The time the query took\n */\n getTime () {\n return this.time\n }\n\n /**\n * Get the last insert id\n * @returns {Number|undefined}\n */\n getLastInsertId () {\n return this.lastInsertId\n }\n\n /**\n * Get the row affected\n * @returns {Number|undefined}\n */\n getRowsAffected () {\n return this.rowsAffected\n }\n\n /**\n * Get the result data as plain object\n * @returns {Object} The data as an object\n */\n toObject () {\n // Clone deep\n return JSON.parse(JSON.stringify(this.data))\n }\n\n /**\n * Map the data values to an array\n * @returns {Array}\n */\n toArray () {\n return Object.values(this.data)\n }\n\n /**\n * Map the data properites to an array\n * @returns {String[]}\n */\n toColumnsArray () {\n return Object.keys(this.data)\n }\n\n /**\n * Convert the result data to a JSON string\n * @returns {String} The JSON string for the data object\n */\n toString () {\n return JSON.stringify(this.data)\n }\n}\n"],"file":"data-result.js"}
1
+ {"version":3,"file":"data-result.js","names":["DataResult","constructor","result","valuesIndex","_defineProperty2","default","Error","Number","isFinite","time","parseFloat","rowsAffected","parseInt","rows_affected","lastInsertId","last_insert_id","columns","resultValues","values","data","reduce","acc","val","i","col","get","property","getTime","getLastInsertId","getRowsAffected","toObject","JSON","parse","stringify","toArray","Object","toColumnsArray","keys","toString","exports","module"],"sources":["../../../es6/api/results/data-result.js"],"sourcesContent":["/**\n * Class for handling single RQLite data api result\n * @module api/results/data-result\n */\n\n/**\n * A class that represents one data result from an RQLite query or execute\n * API call\n */\nexport default class DataResult {\n /**\n * The time the results query took to complete\n * @type {Number}\n */\n time = 0.0\n\n /**\n * The last insert id\n * @type {Number}\n */\n lastInsertId\n\n /**\n * The rows affected\n * @type {Number}\n */\n rowsAffected = 0\n\n /**\n * An array of DataResult and/or DataResultError instances\n * @type {Array<DataResult|DataResultError>}\n */\n results = []\n\n /**\n * An object after the columns and values are mapped from\n * an RQLite response\n */\n data = {}\n\n /**\n * The data result constructor\n * @param {Array} result An API response individual result\n * @param {Array} [valuesIndex] The index to get the values from the result\n */\n constructor (result, valuesIndex) {\n if (typeof result !== 'object') {\n throw new Error('The result argument is required to be an object')\n }\n if (typeof valuesIndex !== 'undefined' && !Number.isFinite(valuesIndex)) {\n throw new Error('The valuesIndex argument is required to be a finite number when provided')\n }\n this.time = parseFloat(result.time || 0.0)\n this.rowsAffected = parseInt(result.rows_affected || 0, 10)\n this.lastInsertId = result.last_insert_id\n // Map the values array to an object where columns are the properties\n if (Number.isFinite(valuesIndex)) {\n const { columns } = result\n const resultValues = result.values[valuesIndex]\n if (resultValues) {\n this.data = resultValues.reduce((acc, val, i) => {\n const col = columns[i]\n acc[col] = val\n return acc\n }, {})\n }\n }\n }\n\n /**\n * Return the value a property or undefined if it does not exist\n * @returns {*} The value of the property or undefined\n */\n get (property) {\n return this.data[property]\n }\n\n /**\n * Get the time the result took\n * @returns {Number} The time the query took\n */\n getTime () {\n return this.time\n }\n\n /**\n * Get the last insert id\n * @returns {Number|undefined}\n */\n getLastInsertId () {\n return this.lastInsertId\n }\n\n /**\n * Get the row affected\n * @returns {Number|undefined}\n */\n getRowsAffected () {\n return this.rowsAffected\n }\n\n /**\n * Get the result data as plain object\n * @returns {Object} The data as an object\n */\n toObject () {\n // Clone deep\n return JSON.parse(JSON.stringify(this.data))\n }\n\n /**\n * Map the data values to an array\n * @returns {Array}\n */\n toArray () {\n return Object.values(this.data)\n }\n\n /**\n * Map the data properites to an array\n * @returns {String[]}\n */\n toColumnsArray () {\n return Object.keys(this.data)\n }\n\n /**\n * Convert the result data to a JSON string\n * @returns {String} The JSON string for the data object\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 @@ var _dataResultError = _interopRequireDefault(require("./data-result-error")); /
9
9
  */ /**
10
10
  * A class to manage a list of results from an RQLite query or execute API response
11
11
  */class DataResults {
12
- /**
13
- * The time the results took to return from the
14
- * RQLite api
15
- * @type {Number}
16
- */
17
12
 
18
13
 
19
- /**
20
- * The results which is an empty arry to start
21
- * @type {DataResult[]}
22
- */
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
23
 
24
24
 
25
25
  /**
@@ -28,17 +28,17 @@ var _dataResultError = _interopRequireDefault(require("./data-result-error")); /
28
28
  * @param {Number} data.time The time the API response took to complete
29
29
  * @param {Object[{error:String,values:Object}]} data.results The results array
30
30
  */
31
- constructor(data) {(0, _defineProperty2.default)(this, "time", 0.0);(0, _defineProperty2.default)(this, "results", []);
32
- this.setApiData(data);
33
- }
34
-
35
- /**
31
+ constructor(data) {/**
32
+ * The time the results took to return from the
33
+ * RQLite api
34
+ * @type {Number}
35
+ */(0, _defineProperty2.default)(this, "time", 0.0); /**
36
+ * The results which is an empty arry to start
37
+ * @type {DataResult[]}
38
+ */(0, _defineProperty2.default)(this, "results", []);this.setApiData(data);} /**
36
39
  * Set the api as results
37
40
  * @param {Object} data Api data
38
- */
39
- setApiData(data) {
40
- if (typeof data !== 'object') {
41
- throw new Error('The data argument is required to be an object');
41
+ */setApiData(data) {if (typeof data !== 'object') {throw new Error('The data argument is required to be an object');
42
42
  }
43
43
  if (!data.results) {
44
44
  throw new Error('The data object is required to have a results property');
@@ -117,5 +117,6 @@ var _dataResultError = _interopRequireDefault(require("./data-result-error")); /
117
117
  toString() {
118
118
  const list = this.results.map((result) => result.toObject());
119
119
  return JSON.stringify(list);
120
- }}exports.default = DataResults;module.exports = exports.default;
120
+ }
121
+ }exports.default = DataResults;module.exports = exports.default;
121
122
  //# sourceMappingURL=data-results.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/results/data-results.js"],"names":["DataResults","constructor","data","setApiData","Error","results","time","parseFloat","reduce","acc","result","error","concat","DataResultError","vals","values","DataResult","dataResults","map","_v","valuesIndex","hasError","getFirstError","find","v","getTime","get","index","getResults","toArray","toObject","toString","list","JSON","stringify"],"mappings":";;;;AAIA;AACA,8E,CALA;AACA;AACA;AACA,G,CAIA;AACA;AACA,GACe,MAAMA,WAAN,CAAkB;AAC/B;AACF;AACA;AACA;AACA;;;AAGE;AACF;AACA;AACA;;;AAGE;AACF;AACA;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAAEC,IAAF,EAAQ,6CAdZ,GAcY,iDART,EAQS;AACjB,SAAKC,UAAL,CAAgBD,IAAhB;AACD;;AAED;AACF;AACA;AACA;AACEC,EAAAA,UAAU,CAAED,IAAF,EAAQ;AAChB,QAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,YAAM,IAAIE,KAAJ,CAAU,+CAAV,CAAN;AACD;AACD,QAAI,CAACF,IAAI,CAACG,OAAV,EAAmB;AACjB,YAAM,IAAID,KAAJ,CAAU,wDAAV,CAAN;AACD;AACD,SAAKE,IAAL,GAAYC,UAAU,CAACL,IAAI,CAACI,IAAL,IAAa,GAAd,CAAtB;AACA,0BAAyBJ,IAAzB,CAAQG,OAAR,CAAQA,OAAR,8BAAkB,EAAlB;AACA,SAAKA,OAAL,GAAeA,OAAO,CAACG,MAAR,CAAe,CAACC,GAAD,EAAMC,MAAN,KAAiB;AAC7C;AACA,UAAI,OAAOA,MAAP,KAAkB,QAAlB,IAA8BA,MAAM,CAACC,KAAzC,EAAgD;AAC9C,eAAOF,GAAG,CAACG,MAAJ,CAAW,IAAIC,wBAAJ,CAAoBH,MAAM,CAACC,KAA3B,CAAX,CAAP;AACD;AACD,YAAgBG,IAAhB,GAAyBJ,MAAzB,CAAQK,MAAR;AACA;AACA,UAAI,CAACD,IAAL,EAAW;AACT,eAAOL,GAAG,CAACG,MAAJ,CAAW,IAAII,mBAAJ,CAAeN,MAAf,CAAX,CAAP;AACD;AACD;AACA,YAAMO,WAAW,GAAGH,IAAI,CAACI,GAAL,CAAS,CAACC,EAAD,EAAKC,WAAL,KAAqB,IAAIJ,mBAAJ,CAAeN,MAAf,EAAuBU,WAAvB,CAA9B,CAApB;AACA,aAAOX,GAAG,CAACG,MAAJ,CAAWK,WAAX,CAAP;AACD,KAbc,EAaZ,EAbY,CAAf;AAcD;;AAED;AACF;AACA;AACA;AACEI,EAAAA,QAAQ,GAAI;AACV,WAAO,CAAC,CAAC,KAAKC,aAAL,EAAT;AACD;;AAED;AACF;AACA;AACA;AACEA,EAAAA,aAAa,GAAI;AACf,WAAO,KAAKjB,OAAL,CAAakB,IAAb,CAAkB,CAACC,CAAD,KAAOA,CAAC,YAAYX,wBAAtC,CAAP;AACD;;AAED;AACF;AACA;AACA;AACEY,EAAAA,OAAO,GAAI;AACT,WAAO,KAAKnB,IAAZ;AACD;;AAED;AACF;AACA;AACA;AACEoB,EAAAA,GAAG,CAAEC,KAAF,EAAS;AACV,WAAO,KAAKtB,OAAL,CAAasB,KAAb,CAAP;AACD;;AAED;AACF;AACA;AACA;AACEC,EAAAA,UAAU,GAAI;AACZ,WAAO,KAAKvB,OAAZ;AACD;;AAED;AACF;AACA;AACA;AACEwB,EAAAA,OAAO,GAAI;AACT,WAAO,KAAKxB,OAAL,CAAaa,GAAb,CAAiB,CAACR,MAAD,KAAYA,MAAM,CAACoB,QAAP,EAA7B,CAAP;AACD;;AAED;AACF;AACA;AACA;AACA;AACEC,EAAAA,QAAQ,GAAI;AACV,UAAMC,IAAI,GAAG,KAAK3B,OAAL,CAAaa,GAAb,CAAiB,CAACR,MAAD,KAAYA,MAAM,CAACoB,QAAP,EAA7B,CAAb;AACA,WAAOG,IAAI,CAACC,SAAL,CAAeF,IAAf,CAAP;AACD,GA7G8B,C","sourcesContent":["/**\n * Class for handling many RQLite data api results\n * @module api/results/data-results\n */\nimport DataResult from './data-result'\nimport DataResultError from './data-result-error'\n\n/**\n * A class to manage a list of results from an RQLite query or execute API response\n */\nexport default class DataResults {\n /**\n * The time the results took to return from the\n * RQLite api\n * @type {Number}\n */\n time = 0.0\n\n /**\n * The results which is an empty arry to start\n * @type {DataResult[]}\n */\n results = []\n\n /**\n * The data result list constructor\n * @param {Object} data The data object sent from a RQLite API response\n * @param {Number} data.time The time the API response took to complete\n * @param {Object[{error:String,values:Object}]} data.results The results array\n */\n constructor (data) {\n this.setApiData(data)\n }\n\n /**\n * Set the api as results\n * @param {Object} data Api data\n */\n setApiData (data) {\n if (typeof data !== 'object') {\n throw new Error('The data argument is required to be an object')\n }\n if (!data.results) {\n throw new Error('The data object is required to have a results property')\n }\n this.time = parseFloat(data.time || 0.0)\n const { results = [] } = data\n this.results = results.reduce((acc, result) => {\n // If there is an error property this is an error\n if (typeof result === 'object' && result.error) {\n return acc.concat(new DataResultError(result.error))\n }\n const { values: vals } = result\n // We don't have values so this is a single result row\n if (!vals) {\n return acc.concat(new DataResult(result))\n }\n // Map the values to DataResult instances\n const dataResults = vals.map((_v, valuesIndex) => new DataResult(result, valuesIndex))\n return acc.concat(dataResults)\n }, [])\n }\n\n /**\n * Returns true if an instance of DataResultError exists in the results\n * @returns {Boolean} True if a DataResultError instance exists\n */\n hasError () {\n return !!this.getFirstError()\n }\n\n /**\n * Get the first error that occured\n * @returns {DataResultError|undefined}\n */\n getFirstError () {\n return this.results.find((v) => v instanceof DataResultError)\n }\n\n /**\n * Get the time the results took\n * @returns {Number} The time the query took\n */\n getTime () {\n return this.time\n }\n\n /**\n * Return one result at a specific index or undefined it it does not exist\n * @returns {DataResult|DataResultError|undefined}\n */\n get (index) {\n return this.results[index]\n }\n\n /**\n * Return the results array\n * @returns {Array<DataResult|DataResultError>}\n */\n getResults () {\n return this.results\n }\n\n /**\n * Get the result data list as array of plain objects\n * @returns {Object[]} The data as an array or objects\n */\n toArray () {\n return this.results.map((result) => result.toObject())\n }\n\n /**\n * Convert the result data list to a JSON string that is an\n * array of objects\n * @returns {String} A JSON string\n */\n toString () {\n const list = this.results.map((result) => result.toObject())\n return JSON.stringify(list)\n }\n}\n"],"file":"data-results.js"}
1
+ {"version":3,"file":"data-results.js","names":["_dataResult","_interopRequireDefault","require","_dataResultError","DataResults","constructor","data","_defineProperty2","default","setApiData","Error","results","time","parseFloat","_data$results","reduce","acc","result","error","concat","DataResultError","vals","values","DataResult","dataResults","map","_v","valuesIndex","hasError","getFirstError","find","v","getTime","get","index","getResults","toArray","toObject","toString","list","JSON","stringify","exports","module"],"sources":["../../../es6/api/results/data-results.js"],"sourcesContent":["/**\n * Class for handling many RQLite data api results\n * @module api/results/data-results\n */\nimport DataResult from './data-result'\nimport DataResultError from './data-result-error'\n\n/**\n * A class to manage a list of results from an RQLite query or execute API response\n */\nexport default class DataResults {\n /**\n * The time the results took to return from the\n * RQLite api\n * @type {Number}\n */\n time = 0.0\n\n /**\n * The results which is an empty arry to start\n * @type {DataResult[]}\n */\n results = []\n\n /**\n * The data result list constructor\n * @param {Object} data The data object sent from a RQLite API response\n * @param {Number} data.time The time the API response took to complete\n * @param {Object[{error:String,values:Object}]} data.results The results array\n */\n constructor (data) {\n this.setApiData(data)\n }\n\n /**\n * Set the api as results\n * @param {Object} data Api data\n */\n setApiData (data) {\n if (typeof data !== 'object') {\n throw new Error('The data argument is required to be an object')\n }\n if (!data.results) {\n throw new Error('The data object is required to have a results property')\n }\n this.time = parseFloat(data.time || 0.0)\n const { results = [] } = data\n this.results = results.reduce((acc, result) => {\n // If there is an error property this is an error\n if (typeof result === 'object' && result.error) {\n return acc.concat(new DataResultError(result.error))\n }\n const { values: vals } = result\n // We don't have values so this is a single result row\n if (!vals) {\n return acc.concat(new DataResult(result))\n }\n // Map the values to DataResult instances\n const dataResults = vals.map((_v, valuesIndex) => new DataResult(result, valuesIndex))\n return acc.concat(dataResults)\n }, [])\n }\n\n /**\n * Returns true if an instance of DataResultError exists in the results\n * @returns {Boolean} True if a DataResultError instance exists\n */\n hasError () {\n return !!this.getFirstError()\n }\n\n /**\n * Get the first error that occured\n * @returns {DataResultError|undefined}\n */\n getFirstError () {\n return this.results.find((v) => v instanceof DataResultError)\n }\n\n /**\n * Get the time the results took\n * @returns {Number} The time the query took\n */\n getTime () {\n return this.time\n }\n\n /**\n * Return one result at a specific index or undefined it it does not exist\n * @returns {DataResult|DataResultError|undefined}\n */\n get (index) {\n return this.results[index]\n }\n\n /**\n * Return the results array\n * @returns {Array<DataResult|DataResultError>}\n */\n getResults () {\n return this.results\n }\n\n /**\n * Get the result data list as array of plain objects\n * @returns {Object[]} The data as an array or objects\n */\n toArray () {\n return this.results.map((result) => result.toObject())\n }\n\n /**\n * Convert the result data list to a JSON string that is an\n * array of objects\n * @returns {String} A JSON string\n */\n toString () {\n const list = this.results.map((result) => result.toObject())\n return JSON.stringify(list)\n }\n}\n"],"mappings":";;;;AAIA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA,yBAAiD,CALjD;AACA;AACA;AACA,GAHA,CAOA;AACA;AACA,GACe,MAAME,WAAW,CAAC;;;;;;;;;;;;;;EAc/B;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAEC,IAAI,EAAE,CAnBnB;AACF;AACA;AACA;AACA,OAJE,IAAAC,gBAAA,CAAAC,OAAA,gBAKO,GAAG,GAEV;AACF;AACA;AACA,OAHE,IAAAD,gBAAA,CAAAC,OAAA,mBAIU,EAAE,EASV,IAAI,CAACC,UAAU,CAACH,IAAI,CAAC,CACvB,CAAC,CAED;AACF;AACA;AACA,KACEG,UAAUA,CAAEH,IAAI,EAAE,CAChB,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE,CAC5B,MAAM,IAAII,KAAK,CAAC,+CAA+C,CAAC;IAClE;IACA,IAAI,CAACJ,IAAI,CAACK,OAAO,EAAE;MACjB,MAAM,IAAID,KAAK,CAAC,wDAAwD,CAAC;IAC3E;IACA,IAAI,CAACE,IAAI,GAAGC,UAAU,CAACP,IAAI,CAACM,IAAI,IAAI,GAAG,CAAC;IACxC,MAAAE,aAAA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,IAAI,CAACxB,OAAO;EACrB;;EAEA;AACF;AACA;AACA;EACEyB,OAAOA,CAAA,EAAI;IACT,OAAO,IAAI,CAACzB,OAAO,CAACc,GAAG,CAAC,CAACR,MAAM,KAAKA,MAAM,CAACoB,QAAQ,CAAC,CAAC,CAAC;EACxD;;EAEA;AACF;AACA;AACA;AACA;EACEC,QAAQA,CAAA,EAAI;IACV,MAAMC,IAAI,GAAG,IAAI,CAAC5B,OAAO,CAACc,GAAG,CAAC,CAACR,MAAM,KAAKA,MAAM,CAACoB,QAAQ,CAAC,CAAC,CAAC;IAC5D,OAAOG,IAAI,CAACC,SAAS,CAACF,IAAI,CAAC;EAC7B;AACF,CAACG,OAAA,CAAAlC,OAAA,GAAAJ,WAAA,CAAAuC,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAlC,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../es6/api/results/index.js"],"names":[],"mappings":";;;;AAIA;AACA;AACA","sourcesContent":["/**\n * Features for handle RQLite data api responses for success and errors\n * @module api/results\n */\nexport { default as DataResult } from './data-result'\nexport { default as DataResultError } from './data-result-error'\nexport { default as DataResults } from './data-results'\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_dataResult","_interopRequireDefault","require","_dataResultError","_dataResults"],"sources":["../../../es6/api/results/index.js"],"sourcesContent":["/**\n * Features for handle RQLite data api responses for success and errors\n * @module api/results\n */\nexport { default as DataResult } from './data-result'\nexport { default as DataResultError } from './data-result-error'\nexport { default as DataResults } from './data-results'\n"],"mappings":";;;;AAIA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA"}