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,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.HiveStore = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
+
|
|
20
|
+
var _utils = _interopRequireDefault(require("../../utils"));
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
var HiveStore = /*#__PURE__*/function () {
|
|
27
|
+
function HiveStore(context, storeKey) {
|
|
28
|
+
(0, _classCallCheck2["default"])(this, HiveStore);
|
|
29
|
+
this.TYPE = this.constructor.TYPE;
|
|
30
|
+
|
|
31
|
+
if (!storeKey || typeof storeKey !== 'string') {
|
|
32
|
+
throw new Error('Store key must be a string.');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.app = context.app;
|
|
36
|
+
this.hiveName = context.hiveName;
|
|
37
|
+
this.storeKey = storeKey;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
(0, _createClass2["default"])(HiveStore, [{
|
|
41
|
+
key: "getBaseURL",
|
|
42
|
+
value: function getBaseURL() {
|
|
43
|
+
return "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/").concat(this.storeKey);
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "delete",
|
|
47
|
+
value: function _delete() {
|
|
48
|
+
return this.constructor["delete"].call(_objectSpread(_objectSpread({}, this), this.constructor), [this.storeKey]);
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "exists",
|
|
52
|
+
value: function () {
|
|
53
|
+
var _exists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
54
|
+
var result;
|
|
55
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
56
|
+
while (1) {
|
|
57
|
+
switch (_context.prev = _context.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
_context.next = 2;
|
|
60
|
+
return this.constructor.exists.call(_objectSpread(_objectSpread({}, this), this.constructor), [this.storeKey]);
|
|
61
|
+
|
|
62
|
+
case 2:
|
|
63
|
+
result = _context.sent;
|
|
64
|
+
return _context.abrupt("return", !!result);
|
|
65
|
+
|
|
66
|
+
case 4:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, _callee, this);
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
function exists() {
|
|
75
|
+
return _exists.apply(this, arguments);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return exists;
|
|
79
|
+
}()
|
|
80
|
+
}, {
|
|
81
|
+
key: "rename",
|
|
82
|
+
value: function rename(newKey, overwrite) {
|
|
83
|
+
if (!newKey || typeof newKey !== 'string') {
|
|
84
|
+
throw new Error('New key name must be provided and must be a string.');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (overwrite !== undefined && typeof overwrite !== 'boolean') {
|
|
88
|
+
throw new Error('Overwrite must be a boolean.');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return this.app.request.put({
|
|
92
|
+
url: "".concat(this.getBaseURL(), "/rename"),
|
|
93
|
+
query: {
|
|
94
|
+
newKey: newKey,
|
|
95
|
+
overwrite: overwrite
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "getExpiration",
|
|
101
|
+
value: function getExpiration() {
|
|
102
|
+
return this.app.request.get({
|
|
103
|
+
url: "".concat(this.getBaseURL(), "/get-expiration-ttl")
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "clearExpiration",
|
|
108
|
+
value: function clearExpiration() {
|
|
109
|
+
return this.app.request.put({
|
|
110
|
+
url: "".concat(this.getBaseURL(), "/clear-expiration")
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "expireAfter",
|
|
115
|
+
value: function expireAfter(ttl) {
|
|
116
|
+
if (isNaN(ttl) || typeof ttl !== 'number') {
|
|
117
|
+
throw new Error('TTL must be a number.');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return this.app.request.put({
|
|
121
|
+
url: "".concat(this.getBaseURL(), "/expire"),
|
|
122
|
+
query: {
|
|
123
|
+
ttl: ttl
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "expireAt",
|
|
129
|
+
value: function expireAt(unixTime) {
|
|
130
|
+
if (isNaN(unixTime) || typeof unixTime !== 'number') {
|
|
131
|
+
throw new Error('Expiration time must be a number.');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return this.app.request.put({
|
|
135
|
+
url: "".concat(this.getBaseURL(), "/expire-at"),
|
|
136
|
+
query: {
|
|
137
|
+
unixTime: unixTime
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "touch",
|
|
143
|
+
value: function touch() {
|
|
144
|
+
return this.constructor.touch.call(_objectSpread(_objectSpread({}, this), this.constructor), [this.storeKey]);
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "secondsSinceLastOperation",
|
|
148
|
+
value: function secondsSinceLastOperation() {
|
|
149
|
+
return this.app.request.get({
|
|
150
|
+
url: "".concat(this.getBaseURL(), "/seconds-since-last-operation")
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}], [{
|
|
154
|
+
key: "registerType",
|
|
155
|
+
value: function registerType(hive) {
|
|
156
|
+
var _this = this;
|
|
157
|
+
|
|
158
|
+
var context = _objectSpread(_objectSpread({}, this), {}, {
|
|
159
|
+
app: hive.app,
|
|
160
|
+
hiveName: hive.hiveName
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
var factory = function factory(storeKey) {
|
|
164
|
+
return new _this(context, storeKey);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
this.STATIC_METHODS.forEach(function (methodName) {
|
|
168
|
+
factory[methodName] = function () {
|
|
169
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
170
|
+
args[_key] = arguments[_key];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return _this[methodName].apply(context, args);
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
return factory;
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "keys",
|
|
180
|
+
value: function keys(options) {
|
|
181
|
+
if (options !== undefined) {
|
|
182
|
+
if (!_utils["default"].isObject(options)) {
|
|
183
|
+
throw new Error('Options must be an object.');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var cursor = options.cursor,
|
|
187
|
+
pageSize = options.pageSize,
|
|
188
|
+
filterPattern = options.filterPattern;
|
|
189
|
+
|
|
190
|
+
if (cursor !== undefined && (typeof cursor !== 'number' || isNaN(cursor))) {
|
|
191
|
+
throw new Error('Cursor must be a number.');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (pageSize !== undefined && (typeof pageSize !== 'number' || isNaN(pageSize))) {
|
|
195
|
+
throw new Error('Page size must be a number.');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (filterPattern !== undefined && (typeof filterPattern !== 'string' || !filterPattern)) {
|
|
199
|
+
throw new Error('Filter pattern must be a string.');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return this.app.request.get({
|
|
204
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/keys"),
|
|
205
|
+
query: options
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}, {
|
|
209
|
+
key: "delete",
|
|
210
|
+
value: function _delete(keys) {
|
|
211
|
+
if (!Array.isArray(keys)) {
|
|
212
|
+
throw new Error('Keys must be provided and must be a list of strings.');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return this.app.request["delete"]({
|
|
216
|
+
url: this.app.urls.hiveStore(this.hiveName, this.TYPE),
|
|
217
|
+
data: keys
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "exists",
|
|
222
|
+
value: function exists(keys) {
|
|
223
|
+
if (!Array.isArray(keys)) {
|
|
224
|
+
throw new Error('Keys must be provided and must be a list of strings.');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return this.app.request.post({
|
|
228
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/exists"),
|
|
229
|
+
data: keys
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "touch",
|
|
234
|
+
value: function touch(keys) {
|
|
235
|
+
if (!Array.isArray(keys)) {
|
|
236
|
+
throw new Error('Keys must be provided and must be a list of strings.');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return this.app.request.put({
|
|
240
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/action/touch"),
|
|
241
|
+
data: keys
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}]);
|
|
245
|
+
return HiveStore;
|
|
246
|
+
}();
|
|
247
|
+
|
|
248
|
+
exports.HiveStore = HiveStore;
|
|
249
|
+
(0, _defineProperty2["default"])(HiveStore, "STATIC_METHODS", ['keys', 'delete', 'exists', 'touch']);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _keyValue = require("./key-value");
|
|
8
|
+
|
|
9
|
+
Object.keys(_keyValue).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _keyValue[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _keyValue[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _list = require("./list");
|
|
21
|
+
|
|
22
|
+
Object.keys(_list).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _list[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _list[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _map = require("./map");
|
|
34
|
+
|
|
35
|
+
Object.keys(_map).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _map[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _map[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _set = require("./set");
|
|
47
|
+
|
|
48
|
+
Object.keys(_set).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _set[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _set[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _sortedSet = require("./sorted-set");
|
|
60
|
+
|
|
61
|
+
Object.keys(_sortedSet).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _sortedSet[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _sortedSet[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.KeyValueStore = 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 _constants = require("../constants");
|
|
25
|
+
|
|
26
|
+
var _baseStore = require("./base-store");
|
|
27
|
+
|
|
28
|
+
var _utils = _interopRequireDefault(require("../../utils"));
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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); }; }
|
|
35
|
+
|
|
36
|
+
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; } }
|
|
37
|
+
|
|
38
|
+
var KeyValueStore = /*#__PURE__*/function (_HiveStore) {
|
|
39
|
+
(0, _inherits2["default"])(KeyValueStore, _HiveStore);
|
|
40
|
+
|
|
41
|
+
var _super = _createSuper(KeyValueStore);
|
|
42
|
+
|
|
43
|
+
function KeyValueStore() {
|
|
44
|
+
(0, _classCallCheck2["default"])(this, KeyValueStore);
|
|
45
|
+
return _super.apply(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
(0, _createClass2["default"])(KeyValueStore, [{
|
|
49
|
+
key: "get",
|
|
50
|
+
value: function get() {
|
|
51
|
+
return this.app.request.get({
|
|
52
|
+
url: this.getBaseURL()
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "set",
|
|
57
|
+
value: function set(value, options) {
|
|
58
|
+
return this.constructor.set.apply(_objectSpread(_objectSpread({}, this), this.constructor), [this.storeKey, value, options]);
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "increment",
|
|
62
|
+
value: function increment(value) {
|
|
63
|
+
if (isNaN(value) || typeof value !== 'number') {
|
|
64
|
+
throw new Error('Value must be provided and must be a number.');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this.app.request.put({
|
|
68
|
+
url: "".concat(this.getBaseURL(), "/increment"),
|
|
69
|
+
query: {
|
|
70
|
+
value: value
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "decrement",
|
|
76
|
+
value: function decrement(value) {
|
|
77
|
+
if (isNaN(value) || typeof value !== 'number') {
|
|
78
|
+
throw new Error('Value must be provided and must be a number.');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return this.app.request.put({
|
|
82
|
+
url: "".concat(this.getBaseURL(), "/decrement"),
|
|
83
|
+
query: {
|
|
84
|
+
value: value
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}], [{
|
|
89
|
+
key: "get",
|
|
90
|
+
value: function get(keys) {
|
|
91
|
+
if (!Array.isArray(keys)) {
|
|
92
|
+
throw new Error('Keys must be provided and must be a list of strings.');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return this.app.request.post({
|
|
96
|
+
url: this.app.urls.hiveStore(this.hiveName, this.TYPE),
|
|
97
|
+
data: keys
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "set",
|
|
102
|
+
value: function set(key, value, options) {
|
|
103
|
+
if (_utils["default"].isObject(key)) {
|
|
104
|
+
if (!Object.keys(key).length) {
|
|
105
|
+
throw new Error('Provided object must have at least 1 key.');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return this.app.request.put({
|
|
109
|
+
url: this.app.urls.hiveStore(this.hiveName, this.TYPE),
|
|
110
|
+
data: key
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!key || typeof key !== 'string') {
|
|
115
|
+
throw new Error('Key must be provided and must be a string.');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (options !== undefined) {
|
|
119
|
+
if (!_utils["default"].isObject(options)) {
|
|
120
|
+
throw new Error('Options must be an object.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var ttl = options.ttl,
|
|
124
|
+
expireAt = options.expireAt,
|
|
125
|
+
condition = options.condition;
|
|
126
|
+
|
|
127
|
+
if (ttl !== undefined && (isNaN(ttl) || typeof ttl !== 'number')) {
|
|
128
|
+
throw new Error('TTL in seconds must be a number.');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (expireAt !== undefined && (isNaN(expireAt) || typeof expireAt !== 'number')) {
|
|
132
|
+
throw new Error('ExpireAt timestamp must be a number.');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (condition !== undefined && !['IfExists', 'IfNotExists', 'Always'].includes(condition)) {
|
|
136
|
+
throw new Error('Condition must be one of this values: [IfExists, IfNotExists, Always].');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return this.app.request.put({
|
|
141
|
+
url: "".concat(this.app.urls.hiveStore(this.hiveName, this.TYPE), "/").concat(key),
|
|
142
|
+
data: _objectSpread({
|
|
143
|
+
value: value
|
|
144
|
+
}, options)
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}]);
|
|
148
|
+
return KeyValueStore;
|
|
149
|
+
}(_baseStore.HiveStore);
|
|
150
|
+
|
|
151
|
+
exports.KeyValueStore = KeyValueStore;
|
|
152
|
+
(0, _defineProperty2["default"])(KeyValueStore, "TYPE", _constants.HiveTypes.KEY_VALUE);
|
|
153
|
+
(0, _defineProperty2["default"])(KeyValueStore, "STATIC_METHODS", [].concat((0, _toConsumableArray2["default"])(_baseStore.HiveStore.STATIC_METHODS), ['get', 'set']));
|
|
@@ -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);
|