backendless 6.4.0 → 6.5.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 (41) hide show
  1. package/backendless.d.ts +332 -0
  2. package/dist/backendless.js +1783 -3
  3. package/dist/backendless.js.map +1 -1
  4. package/dist/backendless.min.js +2 -2
  5. package/es/hive/constants.js +14 -0
  6. package/es/hive/index.js +81 -0
  7. package/es/hive/stores/base-store.js +249 -0
  8. package/es/hive/stores/index.js +70 -0
  9. package/es/hive/stores/key-value.js +153 -0
  10. package/es/hive/stores/list.js +210 -0
  11. package/es/hive/stores/map.js +222 -0
  12. package/es/hive/stores/set.js +180 -0
  13. package/es/hive/stores/sorted-set.js +477 -0
  14. package/es/index.js +8 -0
  15. package/es/urls.js +16 -2
  16. package/es/utils.js +3 -0
  17. package/lib/hive/constants.js +14 -0
  18. package/lib/hive/index.js +81 -0
  19. package/lib/hive/stores/base-store.js +249 -0
  20. package/lib/hive/stores/index.js +70 -0
  21. package/lib/hive/stores/key-value.js +153 -0
  22. package/lib/hive/stores/list.js +210 -0
  23. package/lib/hive/stores/map.js +222 -0
  24. package/lib/hive/stores/set.js +180 -0
  25. package/lib/hive/stores/sorted-set.js +477 -0
  26. package/lib/index.js +8 -0
  27. package/lib/urls.js +16 -2
  28. package/lib/utils.js +3 -0
  29. package/package.json +1 -1
  30. package/src/hive/constants.js +7 -0
  31. package/src/hive/index.js +60 -0
  32. package/src/hive/stores/base-store.js +173 -0
  33. package/src/hive/stores/index.js +5 -0
  34. package/src/hive/stores/key-value.js +108 -0
  35. package/src/hive/stores/list.js +165 -0
  36. package/src/hive/stores/map.js +180 -0
  37. package/src/hive/stores/set.js +136 -0
  38. package/src/hive/stores/sorted-set.js +407 -0
  39. package/src/index.js +5 -0
  40. package/src/urls.js +11 -1
  41. package/src/utils.js +4 -0
@@ -0,0 +1,477 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.SortedSetStore = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _baseStore = require("./base-store");
25
+
26
+ var _constants = require("../constants");
27
+
28
+ var _utils = _interopRequireDefault(require("../../utils"));
29
+
30
+ var _set = require("./set");
31
+
32
+ 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; }
33
+
34
+ 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; }
35
+
36
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
37
+
38
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
+
40
+ var SortedSetStore = /*#__PURE__*/function (_HiveStore) {
41
+ (0, _inherits2["default"])(SortedSetStore, _HiveStore);
42
+
43
+ var _super = _createSuper(SortedSetStore);
44
+
45
+ function SortedSetStore() {
46
+ (0, _classCallCheck2["default"])(this, SortedSetStore);
47
+ return _super.apply(this, arguments);
48
+ }
49
+
50
+ (0, _createClass2["default"])(SortedSetStore, [{
51
+ key: "add",
52
+ value: function add(items, options) {
53
+ if (!items || !Array.isArray(items)) {
54
+ throw new Error('Items must be provided and must be an array.');
55
+ }
56
+
57
+ if (options !== undefined) {
58
+ if (!_utils["default"].isObject(options)) {
59
+ throw new Error('Options must be an object.');
60
+ }
61
+
62
+ var duplicateBehaviour = options.duplicateBehaviour,
63
+ scoreUpdateMode = options.scoreUpdateMode,
64
+ resultType = options.resultType;
65
+
66
+ if (duplicateBehaviour !== undefined && !['OnlyUpdate', 'AlwaysAdd'].includes(duplicateBehaviour)) {
67
+ throw new Error('Duplicate Behaviour argument must be one of this values: OnlyUpdate, AlwaysAdd.');
68
+ }
69
+
70
+ if (scoreUpdateMode !== undefined && !['Greater', 'Less'].includes(scoreUpdateMode)) {
71
+ throw new Error('Score Update Mode argument must be one of this values: Greater, Less.');
72
+ }
73
+
74
+ if (resultType !== undefined && !['NewAdded', 'TotalChanged'].includes(resultType)) {
75
+ throw new Error('Result Type must be one of this values: NewAdded, TotalChanged.');
76
+ }
77
+ }
78
+
79
+ return this.app.request.put({
80
+ url: "".concat(this.getBaseURL(), "/add"),
81
+ data: _objectSpread({
82
+ items: items
83
+ }, options)
84
+ });
85
+ }
86
+ }, {
87
+ key: "set",
88
+ value: function set(items, options) {
89
+ if (!items || !Array.isArray(items)) {
90
+ throw new Error('Items must be provided and must be an array.');
91
+ }
92
+
93
+ if (options !== undefined) {
94
+ if (!_utils["default"].isObject(options)) {
95
+ throw new Error('Options must be an object.');
96
+ }
97
+
98
+ var duplicateBehaviour = options.duplicateBehaviour,
99
+ scoreUpdateMode = options.scoreUpdateMode,
100
+ resultType = options.resultType;
101
+
102
+ if (duplicateBehaviour !== undefined && !['OnlyUpdate', 'AlwaysAdd'].includes(duplicateBehaviour)) {
103
+ throw new Error('Duplicate Behaviour argument must be one of this values: OnlyUpdate, AlwaysAdd.');
104
+ }
105
+
106
+ if (scoreUpdateMode !== undefined && !['Greater', 'Less'].includes(scoreUpdateMode)) {
107
+ throw new Error('Score Update Mode argument must be one of this values: Greater, Less.');
108
+ }
109
+
110
+ if (resultType !== undefined && !['NewAdded', 'TotalChanged'].includes(resultType)) {
111
+ throw new Error('Result Type must be one of this values: NewAdded, TotalChanged.');
112
+ }
113
+ } //TODO: Waining for BKNDLSS-28543
114
+
115
+
116
+ return this.app.request.put({
117
+ url: this.getBaseURL(),
118
+ data: _objectSpread({
119
+ items: items
120
+ }, options)
121
+ });
122
+ }
123
+ }, {
124
+ key: "incrementScore",
125
+ value: function incrementScore(value, scoreValue) {
126
+ if (!value || typeof value !== 'string') {
127
+ throw new Error('Value must be provided and must be a string.');
128
+ }
129
+
130
+ if (isNaN(scoreValue) || typeof scoreValue !== 'number') {
131
+ throw new Error('ScoreValue must be provided and must be a number.');
132
+ }
133
+
134
+ return this.app.request.put({
135
+ url: "".concat(this.getBaseURL(), "/increment"),
136
+ data: {
137
+ scoreValue: scoreValue,
138
+ value: value
139
+ }
140
+ });
141
+ }
142
+ }, {
143
+ key: "decrementScore",
144
+ value: function decrementScore(value, scoreValue) {
145
+ if (!value || typeof value !== 'string') {
146
+ throw new Error('Value must be provided and must be a string.');
147
+ }
148
+
149
+ if (isNaN(scoreValue) || typeof scoreValue !== 'number') {
150
+ throw new Error('ScoreValue must be provided and must be a number.');
151
+ }
152
+
153
+ return this.app.request.put({
154
+ url: "".concat(this.getBaseURL(), "/decrement"),
155
+ data: {
156
+ scoreValue: scoreValue,
157
+ value: value
158
+ }
159
+ });
160
+ }
161
+ }, {
162
+ key: "getAndDeleteMaxScore",
163
+ value: function getAndDeleteMaxScore(count) {
164
+ if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
165
+ throw new Error('Count must be a number.');
166
+ }
167
+
168
+ return this.app.request.put({
169
+ url: "".concat(this.getBaseURL(), "/get-with-max-score-and-delete"),
170
+ query: {
171
+ count: count
172
+ }
173
+ });
174
+ }
175
+ }, {
176
+ key: "getAndDeleteMinScore",
177
+ value: function getAndDeleteMinScore(count) {
178
+ if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
179
+ throw new Error('Count must be a number.');
180
+ }
181
+
182
+ return this.app.request.put({
183
+ url: "".concat(this.getBaseURL(), "/get-with-min-score-and-delete"),
184
+ query: {
185
+ count: count
186
+ }
187
+ });
188
+ }
189
+ }, {
190
+ key: "getRandom",
191
+ value: function getRandom(options) {
192
+ if (options !== undefined) {
193
+ if (!_utils["default"].isObject(options)) {
194
+ throw new Error('Options must be an object.');
195
+ }
196
+
197
+ var count = options.count,
198
+ withScores = options.withScores;
199
+
200
+ if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
201
+ throw new Error('Count must be a number.');
202
+ }
203
+
204
+ if (withScores !== undefined && typeof withScores !== 'boolean') {
205
+ throw new Error('With Scores argument must be a boolean.');
206
+ }
207
+ }
208
+
209
+ return this.app.request.get({
210
+ url: "".concat(this.getBaseURL(), "/get-random"),
211
+ query: _objectSpread({}, options)
212
+ });
213
+ }
214
+ }, {
215
+ key: "getScore",
216
+ value: function getScore(value) {
217
+ if (!value || typeof value !== 'string') {
218
+ throw new Error('Value must be provided and must be a string.');
219
+ }
220
+
221
+ return this.app.request.post({
222
+ url: "".concat(this.getBaseURL(), "/get-score"),
223
+ data: {
224
+ value: value
225
+ }
226
+ });
227
+ }
228
+ }, {
229
+ key: "getRank",
230
+ value: function getRank(value, reverse) {
231
+ if (!value || typeof value !== 'string') {
232
+ throw new Error('Value must be provided and must be a string.');
233
+ }
234
+
235
+ if (reverse !== undefined && typeof reverse !== 'boolean') {
236
+ throw new Error('Reverse argument must be a boolean.');
237
+ }
238
+
239
+ return this.app.request.post({
240
+ url: "".concat(this.getBaseURL(), "/get-rank"),
241
+ data: {
242
+ value: value,
243
+ reverse: reverse
244
+ }
245
+ });
246
+ }
247
+ }, {
248
+ key: "getRangeByRank",
249
+ value: function getRangeByRank(startRank, stopRank, options) {
250
+ if (isNaN(startRank) || typeof startRank !== 'number') {
251
+ throw new Error('Start Rank must be provided and must be a number.');
252
+ }
253
+
254
+ if (isNaN(stopRank) || typeof stopRank !== 'number') {
255
+ throw new Error('Stop Rank must be provided and must be a number.');
256
+ }
257
+
258
+ if (options !== undefined) {
259
+ if (!_utils["default"].isObject(options)) {
260
+ throw new Error('Options must be an object.');
261
+ }
262
+
263
+ var withScores = options.withScores,
264
+ reverse = options.reverse;
265
+
266
+ if (withScores !== undefined && typeof withScores !== 'boolean') {
267
+ throw new Error('With Scores argument must be a boolean.');
268
+ }
269
+
270
+ if (reverse !== undefined && typeof reverse !== 'boolean') {
271
+ throw new Error('Reverse argument must be a boolean.');
272
+ }
273
+ }
274
+
275
+ return this.app.request.get({
276
+ url: "".concat(this.getBaseURL(), "/get-range-by-rank"),
277
+ query: _objectSpread({
278
+ startRank: startRank,
279
+ stopRank: stopRank
280
+ }, options)
281
+ });
282
+ }
283
+ }, {
284
+ key: "getRangeByScore",
285
+ value: function getRangeByScore(options) {
286
+ if (options !== undefined) {
287
+ if (!_utils["default"].isObject(options)) {
288
+ throw new Error('Options must be an object.');
289
+ }
290
+
291
+ var minScore = options.minScore,
292
+ maxScore = options.maxScore,
293
+ minBound = options.minBound,
294
+ maxBound = options.maxBound,
295
+ offset = options.offset,
296
+ count = options.count,
297
+ withScores = options.withScores,
298
+ reverse = options.reverse;
299
+
300
+ if (minScore !== undefined && (isNaN(minScore) || typeof minScore !== 'number')) {
301
+ throw new Error('Minimal Score must be a number.');
302
+ }
303
+
304
+ if (maxScore !== undefined && (isNaN(maxScore) || typeof maxScore !== 'number')) {
305
+ throw new Error('Maximal Score must be a number.');
306
+ }
307
+
308
+ if (minBound !== undefined && !['Include', 'Exclude', 'Infinity'].includes(minBound)) {
309
+ throw new Error('Minimal bound must be one of this values: Include, Exclude, Infinity.');
310
+ }
311
+
312
+ if (maxBound !== undefined && !['Include', 'Exclude', 'Infinity'].includes(maxBound)) {
313
+ throw new Error('Maximal bound must be one of this values: Include, Exclude, Infinity.');
314
+ }
315
+
316
+ if (offset !== undefined && (typeof offset !== 'number' || isNaN(offset))) {
317
+ throw new Error('Offset must be a number.');
318
+ }
319
+
320
+ if (count !== undefined && (typeof count !== 'number' || isNaN(count))) {
321
+ throw new Error('Count must be a number.');
322
+ }
323
+
324
+ if (withScores !== undefined && typeof withScores !== 'boolean') {
325
+ throw new Error('With Scores argument must be a boolean.');
326
+ }
327
+
328
+ if (reverse !== undefined && typeof reverse !== 'boolean') {
329
+ throw new Error('Reverse argument must be a boolean.');
330
+ }
331
+ }
332
+
333
+ return this.app.request.get({
334
+ url: "".concat(this.getBaseURL(), "/get-range-by-score"),
335
+ query: _objectSpread({}, options)
336
+ });
337
+ }
338
+ }, {
339
+ key: "deleteValues",
340
+ value: function deleteValues(values) {
341
+ if (!values || !(typeof values === 'string' || Array.isArray(values))) {
342
+ throw new Error('Value(s) must be provided and must be a string or list of strings.');
343
+ }
344
+
345
+ return this.app.request["delete"]({
346
+ url: "".concat(this.getBaseURL(), "/values"),
347
+ data: _utils["default"].castArray(values)
348
+ });
349
+ }
350
+ }, {
351
+ key: "deleteValuesByRank",
352
+ value: function deleteValuesByRank(startRank, stopRank) {
353
+ if (isNaN(startRank) || typeof startRank !== 'number') {
354
+ throw new Error('Start Rank must be provided and must be a number.');
355
+ }
356
+
357
+ if (isNaN(stopRank) || typeof stopRank !== 'number') {
358
+ throw new Error('Stop Rank must be provided and must be a number.');
359
+ }
360
+
361
+ return this.app.request["delete"]({
362
+ url: "".concat(this.getBaseURL(), "/delete-by-rank"),
363
+ query: {
364
+ startRank: startRank,
365
+ stopRank: stopRank
366
+ }
367
+ });
368
+ }
369
+ }, {
370
+ key: "deleteValuesByScore",
371
+ value: function deleteValuesByScore(options) {
372
+ if (options !== undefined) {
373
+ if (!_utils["default"].isObject(options)) {
374
+ throw new Error('Options must be an object.');
375
+ }
376
+
377
+ var minScore = options.minScore,
378
+ maxScore = options.maxScore,
379
+ minBound = options.minBound,
380
+ maxBound = options.maxBound;
381
+
382
+ if (minScore !== undefined && (isNaN(minScore) || typeof minScore !== 'number')) {
383
+ throw new Error('Minimal Score must be a number.');
384
+ }
385
+
386
+ if (maxScore !== undefined && (isNaN(maxScore) || typeof maxScore !== 'number')) {
387
+ throw new Error('Maximal Score must be a number.');
388
+ }
389
+
390
+ if (minBound !== undefined && !['Include', 'Exclude', 'Infinity'].includes(minBound)) {
391
+ throw new Error('Minimal bound must be one of this values: Include, Exclude, Infinity.');
392
+ }
393
+
394
+ if (maxBound !== undefined && !['Include', 'Exclude', 'Infinity'].includes(maxBound)) {
395
+ throw new Error('Maximal bound must be one of this values: Include, Exclude, Infinity.');
396
+ }
397
+ }
398
+
399
+ return this.app.request["delete"]({
400
+ url: "".concat(this.getBaseURL(), "/delete-by-score"),
401
+ query: _objectSpread({}, options)
402
+ });
403
+ }
404
+ }, {
405
+ key: "length",
406
+ value: function length() {
407
+ return this.app.request.get({
408
+ url: "".concat(this.getBaseURL(), "/length")
409
+ });
410
+ }
411
+ }, {
412
+ key: "countBetweenScores",
413
+ value: function countBetweenScores(options) {
414
+ if (options !== undefined) {
415
+ if (!_utils["default"].isObject(options)) {
416
+ throw new Error('Options must be an object.');
417
+ }
418
+
419
+ var minScore = options.minScore,
420
+ maxScore = options.maxScore,
421
+ minBound = options.minBound,
422
+ maxBound = options.maxBound;
423
+
424
+ if (minScore !== undefined && (isNaN(minScore) || typeof minScore !== 'number')) {
425
+ throw new Error('Minimal Score must be a number.');
426
+ }
427
+
428
+ if (maxScore !== undefined && (isNaN(maxScore) || typeof maxScore !== 'number')) {
429
+ throw new Error('Maximal Score must be a number.');
430
+ }
431
+
432
+ if (minBound !== undefined && !['Include', 'Exclude', 'Infinity'].includes(minBound)) {
433
+ throw new Error('Minimal bound must be one of this values: Include, Exclude, Infinity.');
434
+ }
435
+
436
+ if (maxBound !== undefined && !['Include', 'Exclude', 'Infinity'].includes(maxBound)) {
437
+ throw new Error('Maximal bound must be one of this values: Include, Exclude, Infinity.');
438
+ }
439
+ }
440
+
441
+ return this.app.request.get({
442
+ url: "".concat(this.getBaseURL(), "/count"),
443
+ query: _objectSpread({}, options)
444
+ });
445
+ }
446
+ }], [{
447
+ key: "intersection",
448
+ value: function intersection(keyNames) {
449
+ if (!Array.isArray(keyNames)) {
450
+ throw new Error('Store keys must be provided and must be an array.');
451
+ }
452
+
453
+ return this.app.request.post({
454
+ url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/intersection"),
455
+ data: keyNames
456
+ });
457
+ }
458
+ }, {
459
+ key: "union",
460
+ value: function union(keyNames) {
461
+ if (!Array.isArray(keyNames)) {
462
+ throw new Error('Store keys must be provided and must be an array.');
463
+ }
464
+
465
+ return this.app.request.post({
466
+ url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/union"),
467
+ data: keyNames
468
+ });
469
+ }
470
+ }]);
471
+ return SortedSetStore;
472
+ }(_baseStore.HiveStore);
473
+
474
+ exports.SortedSetStore = SortedSetStore;
475
+ (0, _defineProperty2["default"])(SortedSetStore, "TYPE", _constants.HiveTypes.SORTED_SET);
476
+ (0, _defineProperty2["default"])(SortedSetStore, "STATIC_METHODS", [].concat((0, _toConsumableArray2["default"])(_baseStore.HiveStore.STATIC_METHODS), ['difference', 'intersection', 'union']));
477
+ (0, _defineProperty2["default"])(SortedSetStore, "difference", _set.SetStore.difference);
package/es/index.js CHANGED
@@ -110,6 +110,9 @@ var SERVICES = {
110
110
  'Data': function Data() {
111
111
  return require('./data')["default"];
112
112
  },
113
+ 'Hive': function Hive() {
114
+ return require('./hive')["default"];
115
+ },
113
116
  'Messaging': function Messaging() {
114
117
  return require('./messaging')["default"];
115
118
  },
@@ -429,6 +432,11 @@ var Backendless = /*#__PURE__*/function () {
429
432
  get: function get() {
430
433
  return this.__getService('Data');
431
434
  }
435
+ }, {
436
+ key: "Hive",
437
+ get: function get() {
438
+ return this.__getService('Hive');
439
+ }
432
440
  }, {
433
441
  key: "Messaging",
434
442
  get: function get() {
package/es/urls.js CHANGED
@@ -211,8 +211,22 @@ var Urls = /*#__PURE__*/function () {
211
211
  key: "transactions",
212
212
  value: function transactions() {
213
213
  return "".concat(this.root(), "/transaction/unit-of-work");
214
- } //messaging
215
-
214
+ }
215
+ }, {
216
+ key: "dataHives",
217
+ value: function dataHives() {
218
+ return "".concat(this.root(), "/hive");
219
+ }
220
+ }, {
221
+ key: "dataHive",
222
+ value: function dataHive(name) {
223
+ return "".concat(this.dataHives(), "/").concat(name);
224
+ }
225
+ }, {
226
+ key: "hiveStore",
227
+ value: function hiveStore(name, storeType) {
228
+ return "".concat(this.dataHive(name), "/").concat(storeType);
229
+ }
216
230
  }, {
217
231
  key: "messaging",
218
232
  value: function messaging() {
package/es/utils.js CHANGED
@@ -68,6 +68,9 @@ var Utils = {
68
68
  };
69
69
 
70
70
  return "".concat(chr8(), "-").concat(chr4(), "-").concat(chr4(), "-").concat(chr4(), "-").concat(chr12());
71
+ },
72
+ isObject: function isObject(obj) {
73
+ return obj != null && obj.constructor.name === 'Object';
71
74
  }
72
75
  };
73
76
 
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HiveTypes = void 0;
7
+ var HiveTypes = {
8
+ KEY_VALUE: 'key-value',
9
+ LIST: 'list',
10
+ MAP: 'map',
11
+ SET: 'set',
12
+ SORTED_SET: 'sorted-set'
13
+ };
14
+ exports.HiveTypes = HiveTypes;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = HiveService;
9
+ exports.DataHive = void 0;
10
+
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+
13
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+
15
+ var _stores = require("./stores");
16
+
17
+ function HiveService(app) {
18
+ function getHive(name) {
19
+ if (!name || typeof name !== 'string') {
20
+ throw new Error('Hive name must be provided and must be a string.');
21
+ }
22
+
23
+ return new DataHive(name, {
24
+ app: app
25
+ });
26
+ }
27
+
28
+ getHive.getNames = function () {
29
+ return app.request.get({
30
+ url: app.urls.dataHives()
31
+ });
32
+ };
33
+
34
+ return getHive;
35
+ }
36
+
37
+ var DataHive = /*#__PURE__*/function () {
38
+ function DataHive(name, context) {
39
+ (0, _classCallCheck2["default"])(this, DataHive);
40
+ this.hiveName = name;
41
+ this.app = context.app;
42
+ this.KeyValueStore = _stores.KeyValueStore.registerType(this);
43
+ this.ListStore = _stores.ListStore.registerType(this);
44
+ this.MapStore = _stores.MapStore.registerType(this);
45
+ this.SetStore = _stores.SetStore.registerType(this);
46
+ this.SortedSetStore = _stores.SortedSetStore.registerType(this);
47
+ }
48
+
49
+ (0, _createClass2["default"])(DataHive, [{
50
+ key: "create",
51
+ value: function create() {
52
+ return this.app.request.post({
53
+ url: this.app.urls.dataHive(this.hiveName)
54
+ });
55
+ }
56
+ }, {
57
+ key: "delete",
58
+ value: function _delete() {
59
+ return this.app.request["delete"]({
60
+ url: this.app.urls.dataHive(this.hiveName)
61
+ });
62
+ }
63
+ }, {
64
+ key: "rename",
65
+ value: function rename(newName) {
66
+ if (!newName || typeof newName !== 'string') {
67
+ throw new Error('New Hive name must be provided and must be a string.');
68
+ }
69
+
70
+ return this.app.request.put({
71
+ url: this.app.urls.dataHive(this.hiveName),
72
+ query: {
73
+ newName: newName
74
+ }
75
+ });
76
+ }
77
+ }]);
78
+ return DataHive;
79
+ }();
80
+
81
+ exports.DataHive = DataHive;