rqlite-js 2.5.7 → 3.0.0

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.
Files changed (71) hide show
  1. package/README.md +354 -157
  2. package/dist/index.cjs +904 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +329 -0
  5. package/dist/index.d.ts +329 -0
  6. package/dist/index.js +865 -0
  7. package/dist/index.js.map +1 -0
  8. package/docs/MIGRATION-v2-to-v3.md +71 -0
  9. package/package.json +73 -42
  10. package/src/api/backup/index.ts +69 -0
  11. package/src/api/backup-formats.ts +8 -0
  12. package/src/api/client/index.ts +97 -0
  13. package/src/api/consistency-levels.ts +10 -0
  14. package/src/api/data/index.ts +87 -0
  15. package/src/api/paths.ts +13 -0
  16. package/src/api/query-params.ts +15 -0
  17. package/src/api/results/data-result-error.ts +41 -0
  18. package/src/api/results/data-result.ts +91 -0
  19. package/src/api/results/data-results.ts +91 -0
  20. package/src/api/results/index.ts +7 -0
  21. package/src/api/results/result-fields.ts +14 -0
  22. package/src/api/status/index.ts +53 -0
  23. package/src/http-request/auth-keys.ts +14 -0
  24. package/{es6/http-request/errors.js → src/http-request/errors.ts} +4 -3
  25. package/src/http-request/http-headers.ts +19 -0
  26. package/{es6/http-request/http-methods.js → src/http-request/http-methods.ts} +0 -27
  27. package/src/http-request/index.ts +676 -0
  28. package/{es6/http-request/retryable.js → src/http-request/retryable.ts} +1 -1
  29. package/src/index.ts +38 -0
  30. package/.eslintrc +0 -20
  31. package/.travis.yml +0 -24
  32. package/es6/api/backup/index.js +0 -71
  33. package/es6/api/client/index.js +0 -83
  34. package/es6/api/data/index.js +0 -129
  35. package/es6/api/results/data-result-error.js +0 -32
  36. package/es6/api/results/data-result.js +0 -134
  37. package/es6/api/results/data-results.js +0 -121
  38. package/es6/api/results/index.js +0 -7
  39. package/es6/api/status/index.js +0 -54
  40. package/es6/http-request/index.js +0 -743
  41. package/es6/index.js +0 -19
  42. package/jsconfig.json +0 -19
  43. package/lib/api/backup/index.js +0 -72
  44. package/lib/api/backup/index.js.map +0 -1
  45. package/lib/api/client/index.js +0 -84
  46. package/lib/api/client/index.js.map +0 -1
  47. package/lib/api/data/index.js +0 -130
  48. package/lib/api/data/index.js.map +0 -1
  49. package/lib/api/results/data-result-error.js +0 -33
  50. package/lib/api/results/data-result-error.js.map +0 -1
  51. package/lib/api/results/data-result.js +0 -135
  52. package/lib/api/results/data-result.js.map +0 -1
  53. package/lib/api/results/data-results.js +0 -122
  54. package/lib/api/results/data-results.js.map +0 -1
  55. package/lib/api/results/index.js +0 -8
  56. package/lib/api/results/index.js.map +0 -1
  57. package/lib/api/status/index.js +0 -55
  58. package/lib/api/status/index.js.map +0 -1
  59. package/lib/http-request/content-types.js +0 -5
  60. package/lib/http-request/content-types.js.map +0 -1
  61. package/lib/http-request/errors.js +0 -17
  62. package/lib/http-request/errors.js.map +0 -1
  63. package/lib/http-request/http-methods.js +0 -40
  64. package/lib/http-request/http-methods.js.map +0 -1
  65. package/lib/http-request/index.js +0 -744
  66. package/lib/http-request/index.js.map +0 -1
  67. package/lib/http-request/retryable.js +0 -42
  68. package/lib/http-request/retryable.js.map +0 -1
  69. package/lib/index.js +0 -20
  70. package/lib/index.js.map +0 -1
  71. /package/{es6/http-request/content-types.js → src/http-request/content-types.ts} +0 -0
package/es6/index.js DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * RQLite JS client which export all of the api clients
3
- * @module rqlite-js
4
- */
5
- import DataApiClient from './api/data'
6
- import BackupApiClient from './api/backup'
7
- import StatusApiClient from './api/status'
8
-
9
- export {
10
- DataApiClient,
11
- BackupApiClient,
12
- StatusApiClient,
13
- }
14
-
15
- export default {
16
- DataApiClient,
17
- BackupApiClient,
18
- StatusApiClient,
19
- }
package/jsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "allowSyntheticDefaultImports": true,
4
- "moduleResolution": "node",
5
- "module": "commonJS",
6
- "target": "ES5"
7
- },
8
- "exclude": [
9
- "node_modules",
10
- "lib"
11
- ],
12
- "include": [
13
- "es6/**/*"
14
- ],
15
- "files.eol": "\n",
16
- "editor.insertSpaces": true,
17
- "editor.tabSize": 2,
18
- "editor.detectIndentation": false
19
- }
@@ -1,72 +0,0 @@
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
-
3
-
4
-
5
- var _httpRequest = _interopRequireDefault(require("../../http-request"));
6
- var _contentTypes = require("../../http-request/content-types"); /**
7
- * Backup api client to perform RQLite back and load operations
8
- * @module api/backup
9
- */ /**
10
- * The RQLite load api path
11
- */const PATH_LOAD = exports.PATH_LOAD = '/db/load';
12
-
13
- /**
14
- * The RQLite backup api path
15
- */
16
- const PATH_BACKUP = exports.PATH_BACKUP = '/db/backup';
17
-
18
- /**
19
- * Use plain SQL dump as the back up format
20
- */
21
- const BACKUP_DATA_FORMAT_SQL = exports.BACKUP_DATA_FORMAT_SQL = 'sql';
22
-
23
- /**
24
- * Use sqlite3 dump as the back up format
25
- */
26
- const BACKUP_DATA_FORMAT_DUMP = exports.BACKUP_DATA_FORMAT_DUMP = 'dump';
27
-
28
- /**
29
- * Backup api client to perform RQLite back up and load operations
30
- */
31
- class BackupApiClient extends _httpRequest.default {
32
- /**
33
- * Perform a SQL dump backup from the RQLite server
34
- * @param {String} [format=BACKUP_DATA_FORMAT_DUMP] The backup data format
35
- * @returns {Stream} The response stream
36
- */
37
- backup(format = BACKUP_DATA_FORMAT_DUMP) {var _superprop_getGet = () => super.get,_this = this;return (0, _asyncToGenerator2.default)(function* () {
38
- const stream = _superprop_getGet().call(_this, {
39
- headers: {
40
- // Always sends application/octet-stream from the server in RQLite v4.x
41
- Accept: _contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM
42
- },
43
- query: { fmt: format === BACKUP_DATA_FORMAT_SQL ? format : undefined },
44
- json: false,
45
- stream: true,
46
- uri: PATH_BACKUP,
47
- useLeader: true
48
- });
49
- return stream;})();
50
- }
51
-
52
- /**
53
- * Perform a SQL restore by sending data the RQLite server
54
- * @param {Buffer|String} data The data to be loaded
55
- * @param {String} [format=BACKUP_DATA_FORMAT_SQL] The backup data format
56
- * @returns {Stream} The response stream
57
- */
58
- load(data, format = BACKUP_DATA_FORMAT_SQL) {var _superprop_getPost = () => super.post,_this2 = this;return (0, _asyncToGenerator2.default)(function* () {
59
- return _superprop_getPost().call(_this2, {
60
- body: data,
61
- headers: {
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
- },
65
- json: false,
66
- stream: true,
67
- uri: PATH_LOAD,
68
- useLeader: true
69
- });})();
70
- }
71
- }exports.default = BackupApiClient;
72
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,GAAAC,OAAA,CAAAD,SAAA,GAAG,UAAU;;AAEnC;AACA;AACA;AACO,MAAME,WAAW,GAAAD,OAA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,CAACvB,OAAA,CAAAY,OAAA,GAAAR,eAAA","ignoreList":[]}
@@ -1,84 +0,0 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports.createQuery = createQuery;exports.default = void 0;var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
2
-
3
-
4
-
5
- var _httpRequest = _interopRequireDefault(require("../../http-request"));
6
- var _httpMethods = require("../../http-request/http-methods");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;}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) {(0, _defineProperty2.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;} /**
7
- * Base API client for RQLite which abstracts the HTTP calls
8
- * @module api/client
9
- */ /**
10
- * @typedef HttpRequestOptions
11
- * @type {import('../../http-request').HttpRequestOptions}
12
- */
13
- /**
14
- * Create the base HTTP query options from RQLite API options
15
- * @param {Object} [options={}] The RQLite API options
16
- * @param {String} [options.level] The consistency level
17
- * @param {String} [options.pretty] Pretty print the response body
18
- * @param {String} [options.timings] Provide query timings
19
- * @param {String} [options.atomic] Treat all commands in the request as a single transaction
20
- * for RQLite v5 and higher
21
- * @param {String} [options.transaction] Treat all commands in the request as a single transaction
22
- * for RQLite v4 and lower
23
- * @returns {Object} The HTTP query
24
- */
25
- function createQuery(options = {}) {
26
- const level = options.level,pretty = options.pretty,timings = options.timings,atomic = options.atomic,transaction = options.transaction;
27
-
28
- // Remove all undefined values
29
- const query = { level, pretty, timings, atomic, transaction };
30
- return Object.entries(query).reduce((acc, entry) => {
31
- const _entry = (0, _slicedToArray2.default)(entry, 2),key = _entry[0],val = _entry[1];
32
- // Only take defined values
33
- if (typeof val !== 'undefined') {
34
- acc[key] = val;
35
- }
36
- return acc;
37
- }, {});
38
- }
39
-
40
- /**
41
- * Base API client for RQLite which abstracts the HTTP calls
42
- * from the user
43
- */
44
- class ApiClient extends _httpRequest.default {
45
- /**
46
- * Perform a RQLite data API get request
47
- * @param {String} path The path for the request i.e. /db/query
48
- * @param {String} sql The SQL query
49
- * @param {HttpRequestOptions} [options={}] RQLite API options
50
- */
51
- get(path, sql, options = {}) {var _superprop_getGet = () => super.get,_this = this;return (0, _asyncToGenerator2.default)(function* () {
52
- const useLeader = options.useLeader;
53
- if (!path) {
54
- throw new Error('The path argument is required');
55
- }
56
- return _superprop_getGet().call(_this, {
57
- useLeader,
58
- uri: path,
59
- httpMethod: _httpMethods.HTTP_METHOD_GET,
60
- query: _objectSpread(_objectSpread({}, createQuery(options)), {}, { q: sql })
61
- });})();
62
- }
63
-
64
- /**
65
- * Perform a RQLite data API post request
66
- * @param {String} path The path for the request i.e. /db/query
67
- * @param {String} sql The SQL query
68
- * @param {HttpRequestOptions} [options={}] RQLite API options
69
- */
70
- post(path, sql, options = {}) {var _superprop_getPost = () => super.post,_this2 = this;return (0, _asyncToGenerator2.default)(function* () {
71
- const useLeader = options.useLeader;
72
- if (!path) {
73
- throw new Error('The path argument is required');
74
- }
75
- return _superprop_getPost().call(_this2, {
76
- useLeader,
77
- uri: path,
78
- httpMethod: _httpMethods.HTTP_METHOD_POST,
79
- query: createQuery(options),
80
- body: Array.isArray(sql) ? sql : [sql]
81
- });})();
82
- }
83
- }exports.default = ApiClient;
84
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_httpRequest","_interopRequireDefault","require","_httpMethods","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","createQuery","options","level","pretty","timings","atomic","transaction","query","entries","reduce","acc","entry","_entry","_slicedToArray2","key","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,CAAA,EAAAC,CAAA,OAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,MAAAG,MAAA,CAAAE,qBAAA,OAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,EAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,UAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,MAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,UAAAJ,CAAA,WAAAU,cAAAZ,CAAA,YAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,SAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,OAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,OAAAe,gBAAA,CAAAC,OAAA,EAAAjB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,QAAAE,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0,0 @@
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 = exports.CONSISTENCY_LEVEL_LINEARIZABLE = void 0;var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
2
-
3
-
4
-
5
-
6
- var _client = _interopRequireDefault(require("../client"));
7
- var _results = require("../results");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;}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) {(0, _defineProperty2.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;} /**
8
- * Data api client to perform RQLite data operations such
9
- * as query and execute
10
- * @module api/data
11
- */ /**
12
- * The RQLite query api path
13
- */const PATH_QUERY = exports.PATH_QUERY = '/db/query';
14
- /**
15
- * The RQLite execute api path
16
- */
17
- const PATH_EXECUTE = exports.PATH_EXECUTE = '/db/execute';
18
-
19
- /**
20
- * Read query consistency level none which means
21
- * any node can respond
22
- */
23
- const CONSISTENCY_LEVEL_NONE = exports.CONSISTENCY_LEVEL_NONE = 'none';
24
-
25
- /**
26
- * Read query consistency strong which must come from
27
- * the master node
28
- */
29
- const CONSISTENCY_LEVEL_STRONG = exports.CONSISTENCY_LEVEL_STRONG = 'strong';
30
-
31
- /**
32
- * Read query consistency linearizable which must come from
33
- * the master node
34
- */
35
- const CONSISTENCY_LEVEL_LINEARIZABLE = exports.CONSISTENCY_LEVEL_LINEARIZABLE = 'linearizable';
36
-
37
- /**
38
- * Read query consistency weak which must come from
39
- * the master node
40
- */
41
- const CONSISTENCY_LEVEL_WEAK = exports.CONSISTENCY_LEVEL_WEAK = 'weak';
42
-
43
- /**
44
- * @typedef HttpRequestOptions
45
- * @type {import('../../http-request').HttpRequestOptions}
46
- */
47
-
48
- /**
49
- * Data request base options
50
- * @typedef DataRequestBaseOptions
51
- * @type {Object}
52
- * @property {Boolean} [raw] If true return the raw http response from
53
- * RQLite response
54
- */
55
-
56
- /**
57
- * Data query request base options
58
- * @typedef QueryRequestBaseOptions
59
- * @type {Object}
60
- * @property {String} level The api consistency level
61
- */
62
-
63
- /**
64
- * Data query request options
65
- * @typedef QueryRequestOptions
66
- * @type {HttpRequestOptions & DataRequestBaseOptions & QueryRequestBaseOptions}
67
- */
68
-
69
- /**
70
- * Data execute request options
71
- * @typedef ExecuteRequestOptions
72
- * @type {HttpRequestOptions & DataRequestBaseOptions}
73
- */
74
-
75
- /**
76
- * Send an RQLite query API request to the RQLite server
77
- * @param {String} sql The SQL string to excute on the server
78
- * @param {DataRequestBaseOptions} [options={}] RQLite api options
79
- */
80
- function handleResponse(response, options = {}) {
81
- const raw = options.raw;
82
- const body = response.body;
83
- if (raw) {
84
- return response;
85
- }
86
- return new _results.DataResults(body);
87
- }
88
-
89
- /**
90
- * Data api client to perform RQLite queries
91
- */
92
- class DataApiClient extends _client.default {
93
- /**
94
- * Send an RQLite query API request to the RQLite server
95
- * @param {String} sql The SQL string to excute on the server
96
- * @param {QueryRequestOptions} [options={}] RQLite api options
97
- */
98
- query(sql, options = {}) {var _superprop_getPost = () => super.post,_superprop_getGet = () => super.get,_this = this;return (0, _asyncToGenerator2.default)(function* () {
99
- const level = options.level;
100
- let useLeader = options.useLeader;
101
- // Weak and strong consistency will be redirect to the master anyway
102
- // so skip the redirect HTTP response and got right to the master
103
- if (level !== CONSISTENCY_LEVEL_NONE) {
104
- useLeader = true;
105
- }
106
- let response;
107
- if (Array.isArray(sql)) {
108
- response = yield _superprop_getPost().call(_this, PATH_QUERY, sql, _objectSpread(_objectSpread({}, options), {}, { useLeader }));
109
- } else {
110
- response = yield _superprop_getGet().call(_this, PATH_QUERY, sql, _objectSpread(_objectSpread({}, options), {}, { useLeader }));
111
- }
112
- // If round robin is true try and balance selects across hosts when
113
- // the master node is not queried directly
114
- if (!useLeader) {
115
- _this.setNextActiveHostIndex();
116
- }
117
- return handleResponse(response, options);})();
118
- }
119
-
120
- /**
121
- * Send an RQLite execute API request to the RQLite server
122
- * @param {String} sql The SQL string to excute on the server
123
- * @param {ExecuteRequestOptions} [options={}] RQLite execute api options
124
- */
125
- execute(sql, options = {}) {var _superprop_getPost2 = () => super.post,_this2 = this;return (0, _asyncToGenerator2.default)(function* () {
126
- const response = yield _superprop_getPost2().call(_this2, PATH_EXECUTE, sql, options);
127
- return handleResponse(response, options);})();
128
- }
129
- }exports.default = DataApiClient;
130
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_client","_interopRequireDefault","require","_results","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","PATH_QUERY","exports","PATH_EXECUTE","CONSISTENCY_LEVEL_NONE","CONSISTENCY_LEVEL_STRONG","CONSISTENCY_LEVEL_LINEARIZABLE","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 linearizable which must come from\n * the master node\n */\nexport const CONSISTENCY_LEVEL_LINEARIZABLE = 'linearizable'\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,CAAA,EAAAC,CAAA,OAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,MAAAG,MAAA,CAAAE,qBAAA,OAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,EAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,UAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,MAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,UAAAJ,CAAA,WAAAU,cAAAZ,CAAA,YAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,SAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,OAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,OAAAe,gBAAA,CAAAC,OAAA,EAAAjB,CAAA,EAAAC,CAAA,EAAAC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A,GAAAH,IAAA,CAAAI,MAAA,EAAW7B,YAAY,EAAEc,GAAG,EAAEP,OAAO,CAAC;MAC7D,OAAOF,cAAc,CAACC,QAAQ,EAAEC,OAAO,CAAC;EAC1C;AACF,CAACR,OAAA,CAAAL,OAAA,GAAAiB,aAAA","ignoreList":[]}
@@ -1,33 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0; /**
2
- * Class for handling RQLite data api result error
3
- * @module api/results/data-results
4
- */
5
-
6
- /**
7
- * A class that represents one data error result from an RQLite query or execute
8
- * API call
9
- */
10
- class DataResultError extends Error {
11
- constructor(...args) {
12
- super(...args);
13
- this.name = this.constructor.name;
14
- this.code = this.constructor.name;
15
- }
16
-
17
- /**
18
- * Get the result data error as plain object
19
- * @returns {Object} The data as an object
20
- */
21
- toObject() {
22
- return { error: this.message };
23
- }
24
-
25
- /**
26
- * Convert the result data error to a JSON string
27
- * @returns {String} The JSON string for the data object
28
- */
29
- toString() {
30
- return JSON.stringify(this.toObject());
31
- }
32
- }exports.default = DataResultError;module.exports = exports.default;
33
- //# sourceMappingURL=data-result-error.js.map
@@ -1 +0,0 @@
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","ignoreList":[]}
@@ -1,135 +0,0 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); /**
2
- * Class for handling single RQLite data api result
3
- * @module api/results/data-result
4
- */
5
-
6
- /**
7
- * A class that represents one data result from an RQLite query or execute
8
- * API call
9
- */
10
- class DataResult {
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
- /**
42
- * The data result constructor
43
- * @param {Array} result An API response individual result
44
- * @param {Array} [valuesIndex] The index to get the values from the result
45
- */
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
- }
67
- }
68
- }
69
-
70
- /**
71
- * Return the value a property or undefined if it does not exist
72
- * @returns {*} The value of the property or undefined
73
- */
74
- get(property) {
75
- return this.data[property];
76
- }
77
-
78
- /**
79
- * Get the time the result took
80
- * @returns {Number} The time the query took
81
- */
82
- getTime() {
83
- return this.time;
84
- }
85
-
86
- /**
87
- * Get the last insert id
88
- * @returns {Number|undefined}
89
- */
90
- getLastInsertId() {
91
- return this.lastInsertId;
92
- }
93
-
94
- /**
95
- * Get the row affected
96
- * @returns {Number|undefined}
97
- */
98
- getRowsAffected() {
99
- return this.rowsAffected;
100
- }
101
-
102
- /**
103
- * Get the result data as plain object
104
- * @returns {Object} The data as an object
105
- */
106
- toObject() {
107
- // Clone deep
108
- return JSON.parse(JSON.stringify(this.data));
109
- }
110
-
111
- /**
112
- * Map the data values to an array
113
- * @returns {Array}
114
- */
115
- toArray() {
116
- return Object.values(this.data);
117
- }
118
-
119
- /**
120
- * Map the data properites to an array
121
- * @returns {String[]}
122
- */
123
- toColumnsArray() {
124
- return Object.keys(this.data);
125
- }
126
-
127
- /**
128
- * Convert the result data to a JSON string
129
- * @returns {String} The JSON string for the data object
130
- */
131
- toString() {
132
- return JSON.stringify(this.data);
133
- }
134
- }exports.default = DataResult;module.exports = exports.default;
135
- //# sourceMappingURL=data-result.js.map
@@ -1 +0,0 @@
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\n */\n toString () {\n return JSON.stringify(this.data)\n }\n}\n"],"mappings":"0RAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,MAAMA,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B9B;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAAEC,MAAM,EAAEC,WAAW,EAAE,CAnClC;AACF;AACA;AACA,OAHE,IAAAC,gBAAA,CAAAC,OAAA,gBAIO,GAAG,GAEV;AACF;AACA;AACA,OAHE,IAAAD,gBAAA,CAAAC,OAAA,iCAMA;AACF;AACA;AACA,OAHE,IAAAD,gBAAA,CAAAC,OAAA,wBAIe,CAAC,GAEhB;AACF;AACA;AACA,OAHE,IAAAD,gBAAA,CAAAC,OAAA,mBAIU,EAAE,GAEZ;AACF;AACA;AACA,OAHE,IAAAD,gBAAA,CAAAC,OAAA,gBAIO,CAAC,CAAC,EAQP,IAAI,OAAOH,MAAM,KAAK,QAAQ,EAAE,CAC9B,MAAM,IAAII,KAAK,CAAC,iDAAiD,CAAC,CACpE,CACA,IAAI,OAAO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