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.
- package/backendless.d.ts +332 -0
- package/dist/backendless.js +1783 -3
- package/dist/backendless.js.map +1 -1
- package/dist/backendless.min.js +2 -2
- package/es/hive/constants.js +14 -0
- package/es/hive/index.js +81 -0
- package/es/hive/stores/base-store.js +249 -0
- package/es/hive/stores/index.js +70 -0
- package/es/hive/stores/key-value.js +153 -0
- package/es/hive/stores/list.js +210 -0
- package/es/hive/stores/map.js +222 -0
- package/es/hive/stores/set.js +180 -0
- package/es/hive/stores/sorted-set.js +477 -0
- package/es/index.js +8 -0
- package/es/urls.js +16 -2
- package/es/utils.js +3 -0
- package/lib/hive/constants.js +14 -0
- package/lib/hive/index.js +81 -0
- package/lib/hive/stores/base-store.js +249 -0
- package/lib/hive/stores/index.js +70 -0
- package/lib/hive/stores/key-value.js +153 -0
- package/lib/hive/stores/list.js +210 -0
- package/lib/hive/stores/map.js +222 -0
- package/lib/hive/stores/set.js +180 -0
- package/lib/hive/stores/sorted-set.js +477 -0
- package/lib/index.js +8 -0
- package/lib/urls.js +16 -2
- package/lib/utils.js +3 -0
- package/package.json +1 -1
- package/src/hive/constants.js +7 -0
- package/src/hive/index.js +60 -0
- package/src/hive/stores/base-store.js +173 -0
- package/src/hive/stores/index.js +5 -0
- package/src/hive/stores/key-value.js +108 -0
- package/src/hive/stores/list.js +165 -0
- package/src/hive/stores/map.js +180 -0
- package/src/hive/stores/set.js +136 -0
- package/src/hive/stores/sorted-set.js +407 -0
- package/src/index.js +5 -0
- package/src/urls.js +11 -1
- package/src/utils.js +4 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ListStore = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _constants = require("../constants");
|
|
23
|
+
|
|
24
|
+
var _baseStore = require("./base-store");
|
|
25
|
+
|
|
26
|
+
var _utils = _interopRequireDefault(require("../../utils"));
|
|
27
|
+
|
|
28
|
+
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); }; }
|
|
29
|
+
|
|
30
|
+
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; } }
|
|
31
|
+
|
|
32
|
+
var ListStore = /*#__PURE__*/function (_HiveStore) {
|
|
33
|
+
(0, _inherits2["default"])(ListStore, _HiveStore);
|
|
34
|
+
|
|
35
|
+
var _super = _createSuper(ListStore);
|
|
36
|
+
|
|
37
|
+
function ListStore() {
|
|
38
|
+
(0, _classCallCheck2["default"])(this, ListStore);
|
|
39
|
+
return _super.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
(0, _createClass2["default"])(ListStore, [{
|
|
43
|
+
key: "get",
|
|
44
|
+
value: function get(from, to) {
|
|
45
|
+
if (to !== undefined) {
|
|
46
|
+
if (isNaN(to) || typeof to !== 'number') {
|
|
47
|
+
throw new Error('Index To must be a number.');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isNaN(from) || typeof from !== 'number') {
|
|
51
|
+
throw new Error('Index From must be a number.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return this.app.request.get({
|
|
55
|
+
url: this.getBaseURL(),
|
|
56
|
+
query: {
|
|
57
|
+
from: from,
|
|
58
|
+
to: to
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (from !== undefined) {
|
|
64
|
+
if (isNaN(from) || typeof from !== 'number') {
|
|
65
|
+
throw new Error('Index must be a number.');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return this.app.request.get({
|
|
69
|
+
url: "".concat(this.getBaseURL(), "/").concat(from)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this.app.request.get({
|
|
74
|
+
url: this.getBaseURL()
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "set",
|
|
79
|
+
value: function set(value, index) {
|
|
80
|
+
if (Array.isArray(value)) {
|
|
81
|
+
return this.app.request.put({
|
|
82
|
+
url: this.getBaseURL(),
|
|
83
|
+
data: value
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (isNaN(index) || typeof index !== 'number') {
|
|
88
|
+
throw new Error('Index must be a number.');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return this.app.request.put({
|
|
92
|
+
url: "".concat(this.getBaseURL(), "/").concat(index),
|
|
93
|
+
data: {
|
|
94
|
+
value: value
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "length",
|
|
100
|
+
value: function length() {
|
|
101
|
+
return this.app.request.get({
|
|
102
|
+
url: "".concat(this.getBaseURL(), "/length")
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "insertBefore",
|
|
107
|
+
value: function insertBefore(valueToInsert, anchorValue) {
|
|
108
|
+
return this.insert(valueToInsert, anchorValue, true);
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "insertAfter",
|
|
112
|
+
value: function insertAfter(valueToInsert, anchorValue) {
|
|
113
|
+
return this.insert(valueToInsert, anchorValue, false);
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "insert",
|
|
117
|
+
value: function insert(valueToInsert, anchorValue, before) {
|
|
118
|
+
if (!valueToInsert || typeof valueToInsert !== 'string') {
|
|
119
|
+
throw new Error('ValueToInsert must be provided and must be a string.');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!anchorValue || typeof anchorValue !== 'string') {
|
|
123
|
+
throw new Error('AnchorValue must be provided and must be a string.');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return this.app.request.put({
|
|
127
|
+
url: "".concat(this.getBaseURL(), "/insert-").concat(before ? 'before' : 'after'),
|
|
128
|
+
data: {
|
|
129
|
+
valueToInsert: valueToInsert,
|
|
130
|
+
anchorValue: anchorValue
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "deleteValue",
|
|
136
|
+
value: function deleteValue(value, count) {
|
|
137
|
+
if (!value || typeof value !== 'string') {
|
|
138
|
+
throw new Error('Value must be provided and must be a string.');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
142
|
+
throw new Error('Count must be a number.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this.app.request.put({
|
|
146
|
+
url: "".concat(this.getBaseURL(), "/delete-value"),
|
|
147
|
+
data: {
|
|
148
|
+
value: value,
|
|
149
|
+
count: count
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "addFirst",
|
|
155
|
+
value: function addFirst(value) {
|
|
156
|
+
if (!value || !(typeof value === 'string' || Array.isArray(value))) {
|
|
157
|
+
throw new Error('Value(s) must be provided and must be a string or list of strings.');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return this.app.request.put({
|
|
161
|
+
url: "".concat(this.getBaseURL(), "/add-first"),
|
|
162
|
+
data: _utils["default"].castArray(value)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "addLast",
|
|
167
|
+
value: function addLast(value) {
|
|
168
|
+
if (!value || !(typeof value === 'string' || Array.isArray(value))) {
|
|
169
|
+
throw new Error('Value(s) must be provided and must be a string or list of strings.');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return this.app.request.put({
|
|
173
|
+
url: "".concat(this.getBaseURL(), "/add-last"),
|
|
174
|
+
data: _utils["default"].castArray(value)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "deleteFirst",
|
|
179
|
+
value: function deleteFirst(count) {
|
|
180
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
181
|
+
throw new Error('Count must be a number.');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return this.app.request.put({
|
|
185
|
+
url: "".concat(this.getBaseURL(), "/get-first-and-delete"),
|
|
186
|
+
query: {
|
|
187
|
+
count: count
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "deleteLast",
|
|
193
|
+
value: function deleteLast(count) {
|
|
194
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
195
|
+
throw new Error('Count must be a number.');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return this.app.request.put({
|
|
199
|
+
url: "".concat(this.getBaseURL(), "/get-last-and-delete"),
|
|
200
|
+
query: {
|
|
201
|
+
count: count
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}]);
|
|
206
|
+
return ListStore;
|
|
207
|
+
}(_baseStore.HiveStore);
|
|
208
|
+
|
|
209
|
+
exports.ListStore = ListStore;
|
|
210
|
+
(0, _defineProperty2["default"])(ListStore, "TYPE", _constants.HiveTypes.LIST);
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.MapStore = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _constants = require("../constants");
|
|
23
|
+
|
|
24
|
+
var _baseStore = require("./base-store");
|
|
25
|
+
|
|
26
|
+
var _utils = _interopRequireDefault(require("../../utils"));
|
|
27
|
+
|
|
28
|
+
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); }; }
|
|
29
|
+
|
|
30
|
+
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; } }
|
|
31
|
+
|
|
32
|
+
var MapStore = /*#__PURE__*/function (_HiveStore) {
|
|
33
|
+
(0, _inherits2["default"])(MapStore, _HiveStore);
|
|
34
|
+
|
|
35
|
+
var _super = _createSuper(MapStore);
|
|
36
|
+
|
|
37
|
+
function MapStore() {
|
|
38
|
+
(0, _classCallCheck2["default"])(this, MapStore);
|
|
39
|
+
return _super.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
(0, _createClass2["default"])(MapStore, [{
|
|
43
|
+
key: "get",
|
|
44
|
+
value: function get(keys) {
|
|
45
|
+
if (keys !== undefined && !(typeof keys === 'string' || Array.isArray(keys))) {
|
|
46
|
+
throw new Error('Key(s) must be a string or list of strings.');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this.app.request.post({
|
|
50
|
+
url: this.getBaseURL(),
|
|
51
|
+
data: _utils["default"].castArray(keys)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "getValue",
|
|
56
|
+
value: function getValue(key) {
|
|
57
|
+
if (!key || typeof key !== 'string') {
|
|
58
|
+
throw new Error('Key must be provided and must be a string.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return this.app.request.get({
|
|
62
|
+
url: "".concat(this.getBaseURL(), "/get/").concat(key)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "keyExists",
|
|
67
|
+
value: function keyExists(key) {
|
|
68
|
+
if (!key || typeof key !== 'string') {
|
|
69
|
+
throw new Error('Key must be provided and must be a string.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.app.request.get({
|
|
73
|
+
url: "".concat(this.getBaseURL(), "/exists/").concat(key)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "length",
|
|
78
|
+
value: function length() {
|
|
79
|
+
return this.app.request.get({
|
|
80
|
+
url: "".concat(this.getBaseURL(), "/length")
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "keys",
|
|
85
|
+
value: function keys() {
|
|
86
|
+
return this.app.request.get({
|
|
87
|
+
url: "".concat(this.getBaseURL(), "/keys")
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "values",
|
|
92
|
+
value: function values() {
|
|
93
|
+
return this.app.request.get({
|
|
94
|
+
url: "".concat(this.getBaseURL(), "/values")
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "set",
|
|
99
|
+
value: function set(key, value) {
|
|
100
|
+
if (!key) {
|
|
101
|
+
throw new Error('First argument must be provided and must be a string or an object.');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (_utils["default"].isObject(key)) {
|
|
105
|
+
if (!Object.keys(key).length) {
|
|
106
|
+
throw new Error('Provided object must have at least 1 key.');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this.app.request.put({
|
|
110
|
+
url: this.getBaseURL(),
|
|
111
|
+
data: key
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (typeof key !== 'string') {
|
|
116
|
+
throw new Error('Key must be a string.');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!value || typeof value !== 'string') {
|
|
120
|
+
throw new Error('Value must be provided and must be a string.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return this.app.request.put({
|
|
124
|
+
url: "".concat(this.getBaseURL(), "/set/").concat(key),
|
|
125
|
+
data: {
|
|
126
|
+
value: value
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "setWithOverwrite",
|
|
132
|
+
value: function setWithOverwrite(key, value, overwrite) {
|
|
133
|
+
if (!key || typeof key !== 'string') {
|
|
134
|
+
throw new Error('Key must be provided and must be a string.');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!value || typeof value !== 'string') {
|
|
138
|
+
throw new Error('Value must be provided and must be a string.');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (overwrite !== undefined && typeof overwrite !== 'boolean') {
|
|
142
|
+
throw new Error('Overwrite must be a boolean.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this.app.request.put({
|
|
146
|
+
url: "".concat(this.getBaseURL(), "/set-with-overwrite/").concat(key),
|
|
147
|
+
data: {
|
|
148
|
+
value: value,
|
|
149
|
+
overwrite: overwrite
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "add",
|
|
155
|
+
value: function add(data) {
|
|
156
|
+
if (!_utils["default"].isObject(data)) {
|
|
157
|
+
throw new Error('Payload must be an object.');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!Object.keys(data).length) {
|
|
161
|
+
throw new Error('Provided object must have at least 1 key.');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return this.app.request.put({
|
|
165
|
+
url: "".concat(this.getBaseURL(), "/add"),
|
|
166
|
+
data: data
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "increment",
|
|
171
|
+
value: function increment(key, count) {
|
|
172
|
+
if (!key || typeof key !== 'string') {
|
|
173
|
+
throw new Error('Key must be provided and must be a string.');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
177
|
+
throw new Error('Count must be a number.');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return this.app.request.put({
|
|
181
|
+
url: "".concat(this.getBaseURL(), "/increment/").concat(key),
|
|
182
|
+
query: {
|
|
183
|
+
count: count
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
key: "decrement",
|
|
189
|
+
value: function decrement(key, count) {
|
|
190
|
+
if (!key || typeof key !== 'string') {
|
|
191
|
+
throw new Error('Key must be provided and must be a string.');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
195
|
+
throw new Error('Count must be a number.');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return this.app.request.put({
|
|
199
|
+
url: "".concat(this.getBaseURL(), "/decrement/").concat(key),
|
|
200
|
+
query: {
|
|
201
|
+
count: count
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "deleteKeys",
|
|
207
|
+
value: function deleteKeys(keys) {
|
|
208
|
+
if (!keys || !(typeof keys === 'string' || Array.isArray(keys))) {
|
|
209
|
+
throw new Error('Key(s) must be provided and must be a string or list of strings.');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return this.app.request["delete"]({
|
|
213
|
+
url: "".concat(this.getBaseURL(), "/by-obj-keys"),
|
|
214
|
+
data: _utils["default"].castArray(keys)
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}]);
|
|
218
|
+
return MapStore;
|
|
219
|
+
}(_baseStore.HiveStore);
|
|
220
|
+
|
|
221
|
+
exports.MapStore = MapStore;
|
|
222
|
+
(0, _defineProperty2["default"])(MapStore, "TYPE", _constants.HiveTypes.MAP);
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.SetStore = 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
|
+
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); }; }
|
|
31
|
+
|
|
32
|
+
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; } }
|
|
33
|
+
|
|
34
|
+
var SetStore = /*#__PURE__*/function (_HiveStore) {
|
|
35
|
+
(0, _inherits2["default"])(SetStore, _HiveStore);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(SetStore);
|
|
38
|
+
|
|
39
|
+
function SetStore() {
|
|
40
|
+
(0, _classCallCheck2["default"])(this, SetStore);
|
|
41
|
+
return _super.apply(this, arguments);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
(0, _createClass2["default"])(SetStore, [{
|
|
45
|
+
key: "get",
|
|
46
|
+
value: function get() {
|
|
47
|
+
return this.app.request.get({
|
|
48
|
+
url: this.getBaseURL()
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "getRandom",
|
|
53
|
+
value: function getRandom(count) {
|
|
54
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
55
|
+
throw new Error('Count must be a number.');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this.app.request.get({
|
|
59
|
+
url: "".concat(this.getBaseURL(), "/random"),
|
|
60
|
+
query: {
|
|
61
|
+
count: count
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "getRandomAndDelete",
|
|
67
|
+
value: function getRandomAndDelete(count) {
|
|
68
|
+
if (count !== undefined && (isNaN(count) || typeof count !== 'number')) {
|
|
69
|
+
throw new Error('Count must be a number.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.app.request.put({
|
|
73
|
+
url: "".concat(this.getBaseURL(), "/random"),
|
|
74
|
+
query: {
|
|
75
|
+
count: count
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "set",
|
|
81
|
+
value: function set(values) {
|
|
82
|
+
if (!values || typeof values !== 'string' && !Array.isArray(values)) {
|
|
83
|
+
throw new Error('Value(s) must be provided and must be a string or list of strings.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return this.app.request.put({
|
|
87
|
+
url: this.getBaseURL(),
|
|
88
|
+
data: _utils["default"].castArray(values)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "add",
|
|
93
|
+
value: function add(values) {
|
|
94
|
+
if (!values || !(typeof values === 'string' || Array.isArray(values))) {
|
|
95
|
+
throw new Error('Value(s) must be provided and must be a string or list of strings.');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return this.app.request.put({
|
|
99
|
+
url: "".concat(this.getBaseURL(), "/add"),
|
|
100
|
+
data: _utils["default"].castArray(values)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "deleteValues",
|
|
105
|
+
value: function deleteValues(values) {
|
|
106
|
+
if (!values || !(typeof values === 'string' || Array.isArray(values))) {
|
|
107
|
+
throw new Error('Value(s) must be provided and must be a string or list of strings.');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return this.app.request["delete"]({
|
|
111
|
+
url: "".concat(this.getBaseURL(), "/values"),
|
|
112
|
+
data: _utils["default"].castArray(values)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "isMember",
|
|
117
|
+
value: function isMember(value) {
|
|
118
|
+
if (typeof value === 'string') {
|
|
119
|
+
value = [value];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!Array.isArray(value)) {
|
|
123
|
+
throw new Error('Value must be provided and must be a string or a list of strings.');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return this.app.request.post({
|
|
127
|
+
url: "".concat(this.getBaseURL(), "/contains"),
|
|
128
|
+
data: value
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "length",
|
|
133
|
+
value: function length() {
|
|
134
|
+
return this.app.request.get({
|
|
135
|
+
url: "".concat(this.getBaseURL(), "/length")
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}], [{
|
|
139
|
+
key: "difference",
|
|
140
|
+
value: function difference(keyNames) {
|
|
141
|
+
if (!Array.isArray(keyNames)) {
|
|
142
|
+
throw new Error('Store keys must be provided and must be an array.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this.app.request.post({
|
|
146
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/difference"),
|
|
147
|
+
data: keyNames
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "intersection",
|
|
152
|
+
value: function intersection(keyNames) {
|
|
153
|
+
if (!Array.isArray(keyNames)) {
|
|
154
|
+
throw new Error('Store keys must be provided and must be an array.');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return this.app.request.post({
|
|
158
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/intersection"),
|
|
159
|
+
data: keyNames
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "union",
|
|
164
|
+
value: function union(keyNames) {
|
|
165
|
+
if (!Array.isArray(keyNames)) {
|
|
166
|
+
throw new Error('Store keys must be provided and must be an array.');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return this.app.request.post({
|
|
170
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/union"),
|
|
171
|
+
data: keyNames
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}]);
|
|
175
|
+
return SetStore;
|
|
176
|
+
}(_baseStore.HiveStore);
|
|
177
|
+
|
|
178
|
+
exports.SetStore = SetStore;
|
|
179
|
+
(0, _defineProperty2["default"])(SetStore, "TYPE", _constants.HiveTypes.SET);
|
|
180
|
+
(0, _defineProperty2["default"])(SetStore, "STATIC_METHODS", [].concat((0, _toConsumableArray2["default"])(_baseStore.HiveStore.STATIC_METHODS), ['difference', 'intersection', 'union']));
|