backendless 6.7.1 → 7.0.1
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/dist/backendless.js +20994 -23948
- package/dist/backendless.js.map +1 -1
- package/dist/backendless.min.js +2 -2
- package/es/bl/constants.js +0 -2
- package/es/bl/custom-services.js +40 -65
- package/es/bl/events.js +30 -52
- package/es/bl/index.js +3 -9
- package/es/cache/index.js +125 -189
- package/es/commerce/index.js +78 -119
- package/es/counters/counter.js +0 -8
- package/es/counters/index.js +171 -258
- package/es/data/data-query-builder.js +2 -39
- package/es/data/geo/geo-constructor.js +5 -26
- package/es/data/geo/geo-json-parser.js +0 -7
- package/es/data/geo/geometry.js +4 -13
- package/es/data/geo/linestring.js +4 -21
- package/es/data/geo/point.js +4 -22
- package/es/data/geo/polygon.js +4 -30
- package/es/data/geo/spatial-reference-system.js +1 -7
- package/es/data/geo/wkt-parser.js +0 -10
- package/es/data/geo/wkt-to-geojson.js +4 -44
- package/es/data/group-query-builder.js +0 -23
- package/es/data/index.js +17 -54
- package/es/data/json-update-builder.js +0 -18
- package/es/data/load-relations-query-builder.js +0 -16
- package/es/data/persmission.js +0 -16
- package/es/data/rt-handlers.js +1 -46
- package/es/data/store.js +314 -518
- package/es/decorators/deprecated.js +2 -5
- package/es/decorators/index.js +0 -2
- package/es/device/index.js +3 -8
- package/es/expression.js +0 -8
- package/es/files/index.js +354 -493
- package/es/files/persmission.js +0 -15
- package/es/files/utils.js +32 -55
- package/es/hive/index.js +1 -13
- package/es/hive/stores/base-store.js +14 -50
- package/es/hive/stores/index.js +0 -10
- package/es/hive/stores/key-value.js +4 -37
- package/es/hive/stores/list.js +0 -32
- package/es/hive/stores/map.js +0 -34
- package/es/hive/stores/set.js +0 -29
- package/es/hive/stores/sorted-set.js +19 -94
- package/es/hive/utils.js +0 -2
- package/es/index.js +53 -72
- package/es/local-cache/index.js +0 -10
- package/es/local-cache/local-storage.js +1 -9
- package/es/local-cache/virtual-storage.js +0 -6
- package/es/logging/index.js +50 -49
- package/es/logging/logger.js +33 -12
- package/es/management/data.js +0 -8
- package/es/management/index.js +3 -7
- package/es/messaging/channel/index.js +0 -27
- package/es/messaging/helpers/body-parts.js +3 -6
- package/es/messaging/helpers/delivery-options.js +3 -6
- package/es/messaging/helpers/email-envelope.js +13 -25
- package/es/messaging/helpers/index.js +10 -16
- package/es/messaging/helpers/publish-options.js +3 -6
- package/es/messaging/index.js +213 -317
- package/es/persmission.js +7 -16
- package/es/request/index.js +2 -16
- package/es/rso/connection.js +3 -34
- package/es/rso/index.js +0 -7
- package/es/rt.js +21 -52
- package/es/unit-of-work/constants.js +1 -1
- package/es/unit-of-work/index.js +27 -145
- package/es/unit-of-work/json-adapter.js +14 -35
- package/es/unit-of-work/op-result-value-reference.js +1 -11
- package/es/unit-of-work/op-result.js +2 -13
- package/es/urls.js +23 -15
- package/es/user-agent.js +0 -7
- package/es/users/index.js +345 -552
- package/es/users/roles.js +79 -128
- package/es/users/social/container.js +0 -16
- package/es/users/social/index.js +166 -250
- package/es/users/user.js +2 -9
- package/es/users/utils.js +0 -3
- package/es/utils.js +0 -17
- package/lib/bl/constants.js +0 -2
- package/lib/bl/custom-services.js +40 -65
- package/lib/bl/events.js +30 -52
- package/lib/bl/index.js +3 -9
- package/lib/cache/index.js +125 -189
- package/lib/commerce/index.js +78 -119
- package/lib/counters/counter.js +0 -8
- package/lib/counters/index.js +171 -258
- package/lib/data/data-query-builder.js +2 -39
- package/lib/data/geo/geo-constructor.js +5 -26
- package/lib/data/geo/geo-json-parser.js +0 -7
- package/lib/data/geo/geometry.js +4 -13
- package/lib/data/geo/linestring.js +4 -21
- package/lib/data/geo/point.js +4 -22
- package/lib/data/geo/polygon.js +4 -30
- package/lib/data/geo/spatial-reference-system.js +1 -7
- package/lib/data/geo/wkt-parser.js +0 -10
- package/lib/data/geo/wkt-to-geojson.js +4 -44
- package/lib/data/group-query-builder.js +0 -23
- package/lib/data/index.js +17 -54
- package/lib/data/json-update-builder.js +0 -18
- package/lib/data/load-relations-query-builder.js +0 -16
- package/lib/data/persmission.js +0 -16
- package/lib/data/rt-handlers.js +1 -46
- package/lib/data/store.js +314 -518
- package/lib/decorators/deprecated.js +2 -5
- package/lib/decorators/index.js +0 -2
- package/lib/device/index.js +3 -8
- package/lib/expression.js +0 -8
- package/lib/files/index.js +354 -493
- package/lib/files/persmission.js +0 -15
- package/lib/files/utils.js +32 -55
- package/lib/hive/index.js +1 -13
- package/lib/hive/stores/base-store.js +14 -50
- package/lib/hive/stores/index.js +0 -10
- package/lib/hive/stores/key-value.js +4 -37
- package/lib/hive/stores/list.js +0 -32
- package/lib/hive/stores/map.js +0 -34
- package/lib/hive/stores/set.js +0 -29
- package/lib/hive/stores/sorted-set.js +19 -94
- package/lib/hive/utils.js +0 -2
- package/lib/index.js +53 -72
- package/lib/local-cache/index.js +0 -10
- package/lib/local-cache/local-storage.js +1 -9
- package/lib/local-cache/virtual-storage.js +0 -6
- package/lib/logging/index.js +50 -49
- package/lib/logging/logger.js +33 -12
- package/lib/management/data.js +0 -8
- package/lib/management/index.js +3 -7
- package/lib/messaging/channel/index.js +0 -27
- package/lib/messaging/helpers/body-parts.js +3 -6
- package/lib/messaging/helpers/delivery-options.js +3 -6
- package/lib/messaging/helpers/email-envelope.js +13 -25
- package/lib/messaging/helpers/index.js +10 -16
- package/lib/messaging/helpers/publish-options.js +3 -6
- package/lib/messaging/index.js +213 -317
- package/lib/persmission.js +7 -16
- package/lib/request/index.js +2 -16
- package/lib/rso/connection.js +3 -34
- package/lib/rso/index.js +0 -7
- package/lib/rt.js +21 -52
- package/lib/unit-of-work/constants.js +1 -1
- package/lib/unit-of-work/index.js +27 -145
- package/lib/unit-of-work/json-adapter.js +14 -35
- package/lib/unit-of-work/op-result-value-reference.js +1 -11
- package/lib/unit-of-work/op-result.js +2 -13
- package/lib/urls.js +23 -15
- package/lib/user-agent.js +0 -7
- package/lib/users/index.js +345 -552
- package/lib/users/roles.js +79 -128
- package/lib/users/social/container.js +0 -16
- package/lib/users/social/index.js +166 -250
- package/lib/users/user.js +2 -9
- package/lib/users/utils.js +0 -3
- package/lib/utils.js +0 -17
- package/package.json +16 -16
- package/src/files/utils.js +1 -1
- package/src/index.js +5 -0
- package/src/logging/index.js +28 -0
- package/src/logging/logger.js +35 -6
- package/src/urls.js +4 -0
package/lib/data/store.js
CHANGED
|
@@ -1,75 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
17
|
-
|
|
18
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
19
|
-
|
|
20
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
21
|
-
|
|
22
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
23
|
-
|
|
24
15
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
25
|
-
|
|
26
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
|
|
28
17
|
var _utils = _interopRequireDefault(require("../utils"));
|
|
29
|
-
|
|
30
18
|
var _expression = _interopRequireDefault(require("../expression"));
|
|
31
|
-
|
|
32
19
|
var _rtHandlers = _interopRequireDefault(require("./rt-handlers"));
|
|
33
|
-
|
|
34
20
|
var _dataQueryBuilder = _interopRequireDefault(require("./data-query-builder"));
|
|
35
|
-
|
|
36
21
|
var _loadRelationsQueryBuilder = _interopRequireDefault(require("./load-relations-query-builder"));
|
|
37
|
-
|
|
38
22
|
var _jsonUpdateBuilder = _interopRequireDefault(require("./json-update-builder"));
|
|
39
|
-
|
|
40
23
|
var _geoConstructor = _interopRequireWildcard(require("./geo/geo-constructor"));
|
|
41
|
-
|
|
42
24
|
var _geometry = _interopRequireDefault(require("./geo/geometry"));
|
|
43
|
-
|
|
44
25
|
var _excluded = ["relationName", "relationModel"];
|
|
45
|
-
|
|
46
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
|
-
|
|
48
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
49
|
-
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
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; }
|
|
53
|
-
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
54
30
|
function buildFindFirstLastQuery(queryBuilder, sortDir) {
|
|
55
31
|
var query = queryBuilder instanceof _dataQueryBuilder["default"] ? queryBuilder.toJSON() : queryBuilder ? _objectSpread({}, queryBuilder) : {};
|
|
56
32
|
query.pageSize = 1;
|
|
57
33
|
query.offset = 0;
|
|
58
34
|
var sortBy = query.sortBy;
|
|
59
|
-
|
|
60
35
|
if (!sortBy) {
|
|
61
36
|
query.sortBy = ["created ".concat(sortDir)];
|
|
62
37
|
}
|
|
63
|
-
|
|
64
38
|
return _dataQueryBuilder["default"].toRequestBody(query);
|
|
65
39
|
}
|
|
66
|
-
|
|
67
40
|
var DataStore = /*#__PURE__*/function () {
|
|
68
41
|
function DataStore(model, dataService) {
|
|
69
42
|
(0, _classCallCheck2["default"])(this, DataStore);
|
|
70
43
|
this.app = dataService.app;
|
|
71
44
|
this.classToTableMap = dataService.classToTableMap;
|
|
72
|
-
|
|
73
45
|
if (typeof model === 'string') {
|
|
74
46
|
this.className = model;
|
|
75
47
|
this.model = this.classToTableMap[this.className];
|
|
@@ -77,12 +49,10 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
77
49
|
this.className = _utils["default"].getClassName(model);
|
|
78
50
|
this.model = this.classToTableMap[this.className] || model;
|
|
79
51
|
}
|
|
80
|
-
|
|
81
52
|
if (!this.className) {
|
|
82
53
|
throw new Error('Class name should be specified');
|
|
83
54
|
}
|
|
84
55
|
}
|
|
85
|
-
|
|
86
56
|
(0, _createClass2["default"])(DataStore, [{
|
|
87
57
|
key: "rt",
|
|
88
58
|
value: function rt() {
|
|
@@ -93,32 +63,26 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
93
63
|
value: function () {
|
|
94
64
|
var _save = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(object, isUpsert) {
|
|
95
65
|
var _this = this;
|
|
96
|
-
|
|
97
66
|
var url;
|
|
98
67
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
99
|
-
while (1) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
case "end":
|
|
112
|
-
return _context.stop();
|
|
113
|
-
}
|
|
68
|
+
while (1) switch (_context.prev = _context.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
url = isUpsert ? this.app.urls.dataTableUpsert(this.className) : this.app.urls.dataTable(this.className);
|
|
71
|
+
return _context.abrupt("return", this.app.request.put({
|
|
72
|
+
url: url,
|
|
73
|
+
data: convertToServerRecord(object)
|
|
74
|
+
}).then(function (result) {
|
|
75
|
+
return _this.parseResponse(result);
|
|
76
|
+
}));
|
|
77
|
+
case 2:
|
|
78
|
+
case "end":
|
|
79
|
+
return _context.stop();
|
|
114
80
|
}
|
|
115
81
|
}, _callee, this);
|
|
116
82
|
}));
|
|
117
|
-
|
|
118
83
|
function save(_x, _x2) {
|
|
119
84
|
return _save.apply(this, arguments);
|
|
120
85
|
}
|
|
121
|
-
|
|
122
86
|
return save;
|
|
123
87
|
}()
|
|
124
88
|
}, {
|
|
@@ -126,30 +90,24 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
126
90
|
value: function () {
|
|
127
91
|
var _deepSave = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(object) {
|
|
128
92
|
var _this2 = this;
|
|
129
|
-
|
|
130
93
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
131
|
-
while (1) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
case "end":
|
|
143
|
-
return _context2.stop();
|
|
144
|
-
}
|
|
94
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
return _context2.abrupt("return", this.app.request.put({
|
|
97
|
+
url: this.app.urls.dataTableDeepSave(this.className),
|
|
98
|
+
data: convertToServerRecord(object)
|
|
99
|
+
}).then(function (result) {
|
|
100
|
+
return _this2.parseResponse(result);
|
|
101
|
+
}));
|
|
102
|
+
case 1:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context2.stop();
|
|
145
105
|
}
|
|
146
106
|
}, _callee2, this);
|
|
147
107
|
}));
|
|
148
|
-
|
|
149
108
|
function deepSave(_x3) {
|
|
150
109
|
return _deepSave.apply(this, arguments);
|
|
151
110
|
}
|
|
152
|
-
|
|
153
111
|
return deepSave;
|
|
154
112
|
}()
|
|
155
113
|
}, {
|
|
@@ -158,35 +116,27 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
158
116
|
var _remove = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(object) {
|
|
159
117
|
var objectId;
|
|
160
118
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
161
|
-
while (1) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}));
|
|
177
|
-
|
|
178
|
-
case 4:
|
|
179
|
-
case "end":
|
|
180
|
-
return _context3.stop();
|
|
181
|
-
}
|
|
119
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
objectId = object && object.objectId || object;
|
|
122
|
+
if (!(!objectId || typeof objectId !== 'string' && typeof objectId !== 'number')) {
|
|
123
|
+
_context3.next = 3;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
throw new Error('Object Id must be provided and must be a string or number.');
|
|
127
|
+
case 3:
|
|
128
|
+
return _context3.abrupt("return", this.app.request["delete"]({
|
|
129
|
+
url: this.app.urls.dataTableObject(this.className, objectId)
|
|
130
|
+
}));
|
|
131
|
+
case 4:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context3.stop();
|
|
182
134
|
}
|
|
183
135
|
}, _callee3, this);
|
|
184
136
|
}));
|
|
185
|
-
|
|
186
137
|
function remove(_x4) {
|
|
187
138
|
return _remove.apply(this, arguments);
|
|
188
139
|
}
|
|
189
|
-
|
|
190
140
|
return remove;
|
|
191
141
|
}()
|
|
192
142
|
}, {
|
|
@@ -194,30 +144,24 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
194
144
|
value: function () {
|
|
195
145
|
var _find = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(query) {
|
|
196
146
|
var _this3 = this;
|
|
197
|
-
|
|
198
147
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
199
|
-
while (1) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
case "end":
|
|
211
|
-
return _context4.stop();
|
|
212
|
-
}
|
|
148
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
return _context4.abrupt("return", this.app.request.post({
|
|
151
|
+
url: this.app.urls.dataTableFind(this.className),
|
|
152
|
+
data: _dataQueryBuilder["default"].toRequestBody(query)
|
|
153
|
+
}).then(function (result) {
|
|
154
|
+
return _this3.parseResponse(result);
|
|
155
|
+
}));
|
|
156
|
+
case 1:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context4.stop();
|
|
213
159
|
}
|
|
214
160
|
}, _callee4, this);
|
|
215
161
|
}));
|
|
216
|
-
|
|
217
162
|
function find(_x5) {
|
|
218
163
|
return _find.apply(this, arguments);
|
|
219
164
|
}
|
|
220
|
-
|
|
221
165
|
return find;
|
|
222
166
|
}()
|
|
223
167
|
}, {
|
|
@@ -225,26 +169,21 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
225
169
|
value: function () {
|
|
226
170
|
var _group = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(query) {
|
|
227
171
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
228
|
-
while (1) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
case "end":
|
|
238
|
-
return _context5.stop();
|
|
239
|
-
}
|
|
172
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
173
|
+
case 0:
|
|
174
|
+
return _context5.abrupt("return", this.app.request.post({
|
|
175
|
+
url: this.app.urls.dataGrouping(this.className),
|
|
176
|
+
data: _dataQueryBuilder["default"].toRequestBody(query)
|
|
177
|
+
}));
|
|
178
|
+
case 1:
|
|
179
|
+
case "end":
|
|
180
|
+
return _context5.stop();
|
|
240
181
|
}
|
|
241
182
|
}, _callee5, this);
|
|
242
183
|
}));
|
|
243
|
-
|
|
244
184
|
function group(_x6) {
|
|
245
185
|
return _group.apply(this, arguments);
|
|
246
186
|
}
|
|
247
|
-
|
|
248
187
|
return group;
|
|
249
188
|
}()
|
|
250
189
|
}, {
|
|
@@ -252,34 +191,27 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
252
191
|
value: function () {
|
|
253
192
|
var _countInGroup = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(query) {
|
|
254
193
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
255
|
-
while (1) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
case 3:
|
|
272
|
-
case "end":
|
|
273
|
-
return _context6.stop();
|
|
274
|
-
}
|
|
194
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
195
|
+
case 0:
|
|
196
|
+
if (!(!query.groupPath || (0, _typeof2["default"])(query.groupPath) !== 'object')) {
|
|
197
|
+
_context6.next = 2;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
throw new Error('Group Path must be provided and must be an object.');
|
|
201
|
+
case 2:
|
|
202
|
+
return _context6.abrupt("return", this.app.request.post({
|
|
203
|
+
url: "".concat(this.app.urls.dataGrouping(this.className), "/count"),
|
|
204
|
+
data: _dataQueryBuilder["default"].toRequestBody(query)
|
|
205
|
+
}));
|
|
206
|
+
case 3:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context6.stop();
|
|
275
209
|
}
|
|
276
210
|
}, _callee6, this);
|
|
277
211
|
}));
|
|
278
|
-
|
|
279
212
|
function countInGroup(_x7) {
|
|
280
213
|
return _countInGroup.apply(this, arguments);
|
|
281
214
|
}
|
|
282
|
-
|
|
283
215
|
return countInGroup;
|
|
284
216
|
}()
|
|
285
217
|
}, {
|
|
@@ -288,71 +220,56 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
288
220
|
var _findById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(objectId, query) {
|
|
289
221
|
var result;
|
|
290
222
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
291
|
-
while (1) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
_context7.next = 8;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (Object.keys(objectId).length) {
|
|
300
|
-
_context7.next = 3;
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
throw new Error('Provided object must have at least 1 primary keys.');
|
|
305
|
-
|
|
306
|
-
case 3:
|
|
307
|
-
_context7.next = 5;
|
|
308
|
-
return this.app.request.get({
|
|
309
|
-
url: this.app.urls.dataTablePrimaryKey(this.className),
|
|
310
|
-
query: objectId
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
case 5:
|
|
314
|
-
result = _context7.sent;
|
|
315
|
-
_context7.next = 14;
|
|
223
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
224
|
+
case 0:
|
|
225
|
+
if (!(objectId && (0, _typeof2["default"])(objectId) === 'object' && !Array.isArray(objectId))) {
|
|
226
|
+
_context7.next = 8;
|
|
316
227
|
break;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
228
|
+
}
|
|
229
|
+
if (Object.keys(objectId).length) {
|
|
230
|
+
_context7.next = 3;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
throw new Error('Provided object must have at least 1 primary keys.');
|
|
234
|
+
case 3:
|
|
235
|
+
_context7.next = 5;
|
|
236
|
+
return this.app.request.get({
|
|
237
|
+
url: this.app.urls.dataTablePrimaryKey(this.className),
|
|
238
|
+
query: objectId
|
|
239
|
+
});
|
|
240
|
+
case 5:
|
|
241
|
+
result = _context7.sent;
|
|
242
|
+
_context7.next = 14;
|
|
243
|
+
break;
|
|
244
|
+
case 8:
|
|
245
|
+
if (!(!objectId || typeof objectId !== 'string' && typeof objectId !== 'number')) {
|
|
246
|
+
_context7.next = 10;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
throw new Error('Object Id must be provided and must be a string or number or an object of primary keys.');
|
|
250
|
+
case 10:
|
|
251
|
+
if (query) {
|
|
252
|
+
query.pageSize = null;
|
|
253
|
+
query.offset = null;
|
|
254
|
+
}
|
|
255
|
+
_context7.next = 13;
|
|
256
|
+
return this.app.request.get({
|
|
257
|
+
url: this.app.urls.dataTableObject(this.className, objectId),
|
|
258
|
+
queryString: _dataQueryBuilder["default"].toQueryString(query)
|
|
259
|
+
});
|
|
260
|
+
case 13:
|
|
261
|
+
result = _context7.sent;
|
|
262
|
+
case 14:
|
|
263
|
+
return _context7.abrupt("return", this.parseResponse(result));
|
|
264
|
+
case 15:
|
|
265
|
+
case "end":
|
|
266
|
+
return _context7.stop();
|
|
348
267
|
}
|
|
349
268
|
}, _callee7, this);
|
|
350
269
|
}));
|
|
351
|
-
|
|
352
270
|
function findById(_x8, _x9) {
|
|
353
271
|
return _findById.apply(this, arguments);
|
|
354
272
|
}
|
|
355
|
-
|
|
356
273
|
return findById;
|
|
357
274
|
}()
|
|
358
275
|
}, {
|
|
@@ -360,30 +277,24 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
360
277
|
value: function () {
|
|
361
278
|
var _findFirst = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(query) {
|
|
362
279
|
var _this4 = this;
|
|
363
|
-
|
|
364
280
|
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
365
|
-
while (1) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
case "end":
|
|
377
|
-
return _context8.stop();
|
|
378
|
-
}
|
|
281
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
return _context8.abrupt("return", this.app.request.post({
|
|
284
|
+
url: this.app.urls.dataTableFind(this.className),
|
|
285
|
+
data: buildFindFirstLastQuery(query, 'asc')
|
|
286
|
+
}).then(function (result) {
|
|
287
|
+
return _this4.parseResponse(result[0]);
|
|
288
|
+
}));
|
|
289
|
+
case 1:
|
|
290
|
+
case "end":
|
|
291
|
+
return _context8.stop();
|
|
379
292
|
}
|
|
380
293
|
}, _callee8, this);
|
|
381
294
|
}));
|
|
382
|
-
|
|
383
295
|
function findFirst(_x10) {
|
|
384
296
|
return _findFirst.apply(this, arguments);
|
|
385
297
|
}
|
|
386
|
-
|
|
387
298
|
return findFirst;
|
|
388
299
|
}()
|
|
389
300
|
}, {
|
|
@@ -391,30 +302,24 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
391
302
|
value: function () {
|
|
392
303
|
var _findLast = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(query) {
|
|
393
304
|
var _this5 = this;
|
|
394
|
-
|
|
395
305
|
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
396
|
-
while (1) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
case "end":
|
|
408
|
-
return _context9.stop();
|
|
409
|
-
}
|
|
306
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
307
|
+
case 0:
|
|
308
|
+
return _context9.abrupt("return", this.app.request.post({
|
|
309
|
+
url: this.app.urls.dataTableFind(this.className),
|
|
310
|
+
data: buildFindFirstLastQuery(query, 'desc')
|
|
311
|
+
}).then(function (result) {
|
|
312
|
+
return _this5.parseResponse(result[0]);
|
|
313
|
+
}));
|
|
314
|
+
case 1:
|
|
315
|
+
case "end":
|
|
316
|
+
return _context9.stop();
|
|
410
317
|
}
|
|
411
318
|
}, _callee9, this);
|
|
412
319
|
}));
|
|
413
|
-
|
|
414
320
|
function findLast(_x11) {
|
|
415
321
|
return _findLast.apply(this, arguments);
|
|
416
322
|
}
|
|
417
|
-
|
|
418
323
|
return findLast;
|
|
419
324
|
}()
|
|
420
325
|
}, {
|
|
@@ -423,58 +328,47 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
423
328
|
var _getObjectCount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(condition) {
|
|
424
329
|
var distinct, groupBy;
|
|
425
330
|
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
426
|
-
while (1) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (!condition) {
|
|
433
|
-
_context10.next = 11;
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (!(condition instanceof _dataQueryBuilder["default"])) {
|
|
438
|
-
_context10.next = 9;
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
distinct = condition.getDistinct() || undefined;
|
|
443
|
-
groupBy = condition.getGroupBy() || undefined;
|
|
444
|
-
condition = condition.getWhereClause() || undefined;
|
|
331
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
332
|
+
case 0:
|
|
333
|
+
distinct = undefined;
|
|
334
|
+
groupBy = undefined;
|
|
335
|
+
if (!condition) {
|
|
445
336
|
_context10.next = 11;
|
|
446
337
|
break;
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
338
|
+
}
|
|
339
|
+
if (!(condition instanceof _dataQueryBuilder["default"])) {
|
|
340
|
+
_context10.next = 9;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
distinct = condition.getDistinct() || undefined;
|
|
344
|
+
groupBy = condition.getGroupBy() || undefined;
|
|
345
|
+
condition = condition.getWhereClause() || undefined;
|
|
346
|
+
_context10.next = 11;
|
|
347
|
+
break;
|
|
348
|
+
case 9:
|
|
349
|
+
if (!(typeof condition !== 'string')) {
|
|
350
|
+
_context10.next = 11;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
throw new Error('Condition must be a string or an instance of DataQueryBuilder.');
|
|
354
|
+
case 11:
|
|
355
|
+
return _context10.abrupt("return", this.app.request.post({
|
|
356
|
+
url: this.app.urls.dataTableCount(this.className),
|
|
357
|
+
data: {
|
|
358
|
+
where: condition,
|
|
359
|
+
distinct: distinct,
|
|
360
|
+
groupBy: groupBy
|
|
452
361
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return _context10.abrupt("return", this.app.request.post({
|
|
458
|
-
url: this.app.urls.dataTableCount(this.className),
|
|
459
|
-
data: {
|
|
460
|
-
where: condition,
|
|
461
|
-
distinct: distinct,
|
|
462
|
-
groupBy: groupBy
|
|
463
|
-
}
|
|
464
|
-
}));
|
|
465
|
-
|
|
466
|
-
case 12:
|
|
467
|
-
case "end":
|
|
468
|
-
return _context10.stop();
|
|
469
|
-
}
|
|
362
|
+
}));
|
|
363
|
+
case 12:
|
|
364
|
+
case "end":
|
|
365
|
+
return _context10.stop();
|
|
470
366
|
}
|
|
471
367
|
}, _callee10, this);
|
|
472
368
|
}));
|
|
473
|
-
|
|
474
369
|
function getObjectCount(_x12) {
|
|
475
370
|
return _getObjectCount.apply(this, arguments);
|
|
476
371
|
}
|
|
477
|
-
|
|
478
372
|
return getObjectCount;
|
|
479
373
|
}()
|
|
480
374
|
}, {
|
|
@@ -482,52 +376,39 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
482
376
|
value: function () {
|
|
483
377
|
var _loadRelations = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(parent, queryBuilder) {
|
|
484
378
|
var _this6 = this;
|
|
485
|
-
|
|
486
379
|
var parentObjectId, _ref, relationName, relationModel, query;
|
|
487
|
-
|
|
488
380
|
return _regenerator["default"].wrap(function _callee11$(_context11) {
|
|
489
|
-
while (1) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
queryString: _loadRelationsQueryBuilder["default"].toQueryString(query)
|
|
515
|
-
}).then(function (result) {
|
|
516
|
-
return _this6.parseRelationsResponse(result, relationModel);
|
|
517
|
-
}));
|
|
518
|
-
|
|
519
|
-
case 7:
|
|
520
|
-
case "end":
|
|
521
|
-
return _context11.stop();
|
|
522
|
-
}
|
|
381
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
382
|
+
case 0:
|
|
383
|
+
parentObjectId = parent && parent.objectId || parent;
|
|
384
|
+
if (!(!parentObjectId || typeof parentObjectId !== 'string' && typeof parentObjectId !== 'number')) {
|
|
385
|
+
_context11.next = 3;
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
throw new Error('Parent Object Id must be provided and must be a string or number.');
|
|
389
|
+
case 3:
|
|
390
|
+
_ref = queryBuilder instanceof _loadRelationsQueryBuilder["default"] ? queryBuilder.toJSON() : queryBuilder, relationName = _ref.relationName, relationModel = _ref.relationModel, query = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
391
|
+
if (!(!relationName || typeof relationName !== 'string')) {
|
|
392
|
+
_context11.next = 6;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
throw new Error('Relation Name must be provided and must be a string.');
|
|
396
|
+
case 6:
|
|
397
|
+
return _context11.abrupt("return", this.app.request.get({
|
|
398
|
+
url: this.app.urls.dataTableObjectRelation(this.className, parentObjectId, relationName),
|
|
399
|
+
queryString: _loadRelationsQueryBuilder["default"].toQueryString(query)
|
|
400
|
+
}).then(function (result) {
|
|
401
|
+
return _this6.parseRelationsResponse(result, relationModel);
|
|
402
|
+
}));
|
|
403
|
+
case 7:
|
|
404
|
+
case "end":
|
|
405
|
+
return _context11.stop();
|
|
523
406
|
}
|
|
524
407
|
}, _callee11, this);
|
|
525
408
|
}));
|
|
526
|
-
|
|
527
409
|
function loadRelations(_x13, _x14) {
|
|
528
410
|
return _loadRelations.apply(this, arguments);
|
|
529
411
|
}
|
|
530
|
-
|
|
531
412
|
return loadRelations;
|
|
532
413
|
}()
|
|
533
414
|
}, {
|
|
@@ -535,23 +416,18 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
535
416
|
value: function () {
|
|
536
417
|
var _setRelation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(parent, columnName, children) {
|
|
537
418
|
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
|
538
|
-
while (1) {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
case "end":
|
|
545
|
-
return _context12.stop();
|
|
546
|
-
}
|
|
419
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
420
|
+
case 0:
|
|
421
|
+
return _context12.abrupt("return", this.changeRelation(this.app.request.Methods.POST, parent, columnName, children));
|
|
422
|
+
case 1:
|
|
423
|
+
case "end":
|
|
424
|
+
return _context12.stop();
|
|
547
425
|
}
|
|
548
426
|
}, _callee12, this);
|
|
549
427
|
}));
|
|
550
|
-
|
|
551
428
|
function setRelation(_x15, _x16, _x17) {
|
|
552
429
|
return _setRelation.apply(this, arguments);
|
|
553
430
|
}
|
|
554
|
-
|
|
555
431
|
return setRelation;
|
|
556
432
|
}()
|
|
557
433
|
}, {
|
|
@@ -559,23 +435,18 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
559
435
|
value: function () {
|
|
560
436
|
var _addRelation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(parent, columnName, children) {
|
|
561
437
|
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
|
562
|
-
while (1) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
case "end":
|
|
569
|
-
return _context13.stop();
|
|
570
|
-
}
|
|
438
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
439
|
+
case 0:
|
|
440
|
+
return _context13.abrupt("return", this.changeRelation(this.app.request.Methods.PUT, parent, columnName, children));
|
|
441
|
+
case 1:
|
|
442
|
+
case "end":
|
|
443
|
+
return _context13.stop();
|
|
571
444
|
}
|
|
572
445
|
}, _callee13, this);
|
|
573
446
|
}));
|
|
574
|
-
|
|
575
447
|
function addRelation(_x18, _x19, _x20) {
|
|
576
448
|
return _addRelation.apply(this, arguments);
|
|
577
449
|
}
|
|
578
|
-
|
|
579
450
|
return addRelation;
|
|
580
451
|
}()
|
|
581
452
|
}, {
|
|
@@ -583,23 +454,18 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
583
454
|
value: function () {
|
|
584
455
|
var _deleteRelation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14(parent, columnName, children) {
|
|
585
456
|
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
|
586
|
-
while (1) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
case "end":
|
|
593
|
-
return _context14.stop();
|
|
594
|
-
}
|
|
457
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
458
|
+
case 0:
|
|
459
|
+
return _context14.abrupt("return", this.changeRelation(this.app.request.Methods.DELETE, parent, columnName, children));
|
|
460
|
+
case 1:
|
|
461
|
+
case "end":
|
|
462
|
+
return _context14.stop();
|
|
595
463
|
}
|
|
596
464
|
}, _callee14, this);
|
|
597
465
|
}));
|
|
598
|
-
|
|
599
466
|
function deleteRelation(_x21, _x22, _x23) {
|
|
600
467
|
return _deleteRelation.apply(this, arguments);
|
|
601
468
|
}
|
|
602
|
-
|
|
603
469
|
return deleteRelation;
|
|
604
470
|
}()
|
|
605
471
|
}, {
|
|
@@ -608,43 +474,34 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
608
474
|
var _bulkCreate = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(objects) {
|
|
609
475
|
var errorMessage;
|
|
610
476
|
return _regenerator["default"].wrap(function _callee15$(_context15) {
|
|
611
|
-
while (1) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
477
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
478
|
+
case 0:
|
|
479
|
+
errorMessage = 'Objects must be provided and must be an array of objects.';
|
|
480
|
+
if (!(!objects || !Array.isArray(objects))) {
|
|
481
|
+
_context15.next = 3;
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
throw new Error(errorMessage);
|
|
485
|
+
case 3:
|
|
486
|
+
objects = objects.map(function (object) {
|
|
487
|
+
if (!object || (0, _typeof2["default"])(object) !== 'object' || Array.isArray(object)) {
|
|
488
|
+
throw new Error(errorMessage);
|
|
619
489
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
return object;
|
|
630
|
-
});
|
|
631
|
-
return _context15.abrupt("return", this.app.request.post({
|
|
632
|
-
url: this.app.urls.dataBulkTable(this.className),
|
|
633
|
-
data: objects
|
|
634
|
-
}));
|
|
635
|
-
|
|
636
|
-
case 5:
|
|
637
|
-
case "end":
|
|
638
|
-
return _context15.stop();
|
|
639
|
-
}
|
|
490
|
+
return object;
|
|
491
|
+
});
|
|
492
|
+
return _context15.abrupt("return", this.app.request.post({
|
|
493
|
+
url: this.app.urls.dataBulkTable(this.className),
|
|
494
|
+
data: objects
|
|
495
|
+
}));
|
|
496
|
+
case 5:
|
|
497
|
+
case "end":
|
|
498
|
+
return _context15.stop();
|
|
640
499
|
}
|
|
641
500
|
}, _callee15, this);
|
|
642
501
|
}));
|
|
643
|
-
|
|
644
502
|
function bulkCreate(_x24) {
|
|
645
503
|
return _bulkCreate.apply(this, arguments);
|
|
646
504
|
}
|
|
647
|
-
|
|
648
505
|
return bulkCreate;
|
|
649
506
|
}()
|
|
650
507
|
}, {
|
|
@@ -653,43 +510,34 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
653
510
|
var _bulkUpsert = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(objects) {
|
|
654
511
|
var errorMessage;
|
|
655
512
|
return _regenerator["default"].wrap(function _callee16$(_context16) {
|
|
656
|
-
while (1) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
513
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
514
|
+
case 0:
|
|
515
|
+
errorMessage = 'Objects must be provided and must be an array of objects.';
|
|
516
|
+
if (!(!objects || !Array.isArray(objects) || !objects.length)) {
|
|
517
|
+
_context16.next = 3;
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
throw new Error(errorMessage);
|
|
521
|
+
case 3:
|
|
522
|
+
objects = objects.map(function (object) {
|
|
523
|
+
if (!object || (0, _typeof2["default"])(object) !== 'object' || Array.isArray(object)) {
|
|
524
|
+
throw new Error(errorMessage);
|
|
664
525
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
return object;
|
|
675
|
-
});
|
|
676
|
-
return _context16.abrupt("return", this.app.request.put({
|
|
677
|
-
url: this.app.urls.dataBulkTableUpsert(this.className),
|
|
678
|
-
data: objects
|
|
679
|
-
}));
|
|
680
|
-
|
|
681
|
-
case 5:
|
|
682
|
-
case "end":
|
|
683
|
-
return _context16.stop();
|
|
684
|
-
}
|
|
526
|
+
return object;
|
|
527
|
+
});
|
|
528
|
+
return _context16.abrupt("return", this.app.request.put({
|
|
529
|
+
url: this.app.urls.dataBulkTableUpsert(this.className),
|
|
530
|
+
data: objects
|
|
531
|
+
}));
|
|
532
|
+
case 5:
|
|
533
|
+
case "end":
|
|
534
|
+
return _context16.stop();
|
|
685
535
|
}
|
|
686
536
|
}, _callee16, this);
|
|
687
537
|
}));
|
|
688
|
-
|
|
689
538
|
function bulkUpsert(_x25) {
|
|
690
539
|
return _bulkUpsert.apply(this, arguments);
|
|
691
540
|
}
|
|
692
|
-
|
|
693
541
|
return bulkUpsert;
|
|
694
542
|
}()
|
|
695
543
|
}, {
|
|
@@ -697,45 +545,36 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
697
545
|
value: function () {
|
|
698
546
|
var _bulkUpdate = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(condition, changes) {
|
|
699
547
|
return _regenerator["default"].wrap(function _callee17$(_context17) {
|
|
700
|
-
while (1) {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
data: changes
|
|
725
|
-
}));
|
|
726
|
-
|
|
727
|
-
case 5:
|
|
728
|
-
case "end":
|
|
729
|
-
return _context17.stop();
|
|
730
|
-
}
|
|
548
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
549
|
+
case 0:
|
|
550
|
+
if (!(!condition || typeof condition !== 'string')) {
|
|
551
|
+
_context17.next = 2;
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
throw new Error('Condition must be provided and must be a string.');
|
|
555
|
+
case 2:
|
|
556
|
+
if (!(!changes || (0, _typeof2["default"])(changes) !== 'object' || Array.isArray(changes))) {
|
|
557
|
+
_context17.next = 4;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
throw new Error('Changes must be provided and must be an object.');
|
|
561
|
+
case 4:
|
|
562
|
+
return _context17.abrupt("return", this.app.request.put({
|
|
563
|
+
url: this.app.urls.dataBulkTable(this.className),
|
|
564
|
+
query: {
|
|
565
|
+
where: condition
|
|
566
|
+
},
|
|
567
|
+
data: changes
|
|
568
|
+
}));
|
|
569
|
+
case 5:
|
|
570
|
+
case "end":
|
|
571
|
+
return _context17.stop();
|
|
731
572
|
}
|
|
732
573
|
}, _callee17, this);
|
|
733
574
|
}));
|
|
734
|
-
|
|
735
575
|
function bulkUpdate(_x26, _x27) {
|
|
736
576
|
return _bulkUpdate.apply(this, arguments);
|
|
737
577
|
}
|
|
738
|
-
|
|
739
578
|
return bulkUpdate;
|
|
740
579
|
}()
|
|
741
580
|
}, {
|
|
@@ -744,114 +583,92 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
744
583
|
var _bulkDelete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18(condition) {
|
|
745
584
|
var queryData, objectIds;
|
|
746
585
|
return _regenerator["default"].wrap(function _callee18$(_context18) {
|
|
747
|
-
while (1) {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
return _context18.abrupt("return", this.app.request.post({
|
|
776
|
-
url: this.app.urls.dataBulkTableDelete(this.className),
|
|
777
|
-
data: queryData
|
|
778
|
-
}));
|
|
779
|
-
|
|
780
|
-
case 5:
|
|
781
|
-
case "end":
|
|
782
|
-
return _context18.stop();
|
|
783
|
-
}
|
|
586
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
587
|
+
case 0:
|
|
588
|
+
if (!(!condition || typeof condition !== 'string' && !Array.isArray(condition))) {
|
|
589
|
+
_context18.next = 2;
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
throw new Error('Condition must be provided and must be a string or a list of objects.');
|
|
593
|
+
case 2:
|
|
594
|
+
queryData = {};
|
|
595
|
+
if (typeof condition === 'string') {
|
|
596
|
+
queryData.where = condition;
|
|
597
|
+
} else {
|
|
598
|
+
objectIds = condition.map(function (object) {
|
|
599
|
+
var objectId = object && object.objectId || object;
|
|
600
|
+
if (!objectId || typeof objectId !== 'string' && typeof objectId !== 'number') {
|
|
601
|
+
throw new Error('Can not transform "objects" to "whereClause". ' + 'Item must be a string or number or an object with property "objectId" as string.');
|
|
602
|
+
}
|
|
603
|
+
return "'".concat(objectId, "'");
|
|
604
|
+
});
|
|
605
|
+
queryData.where = "objectId in (".concat(objectIds.join(','), ")");
|
|
606
|
+
}
|
|
607
|
+
return _context18.abrupt("return", this.app.request.post({
|
|
608
|
+
url: this.app.urls.dataBulkTableDelete(this.className),
|
|
609
|
+
data: queryData
|
|
610
|
+
}));
|
|
611
|
+
case 5:
|
|
612
|
+
case "end":
|
|
613
|
+
return _context18.stop();
|
|
784
614
|
}
|
|
785
615
|
}, _callee18, this);
|
|
786
616
|
}));
|
|
787
|
-
|
|
788
617
|
function bulkDelete(_x28) {
|
|
789
618
|
return _bulkDelete.apply(this, arguments);
|
|
790
619
|
}
|
|
791
|
-
|
|
792
620
|
return bulkDelete;
|
|
793
621
|
}()
|
|
794
622
|
/**
|
|
795
623
|
* @private
|
|
796
624
|
* */
|
|
797
|
-
|
|
798
625
|
}, {
|
|
799
626
|
key: "parseRelationsResponse",
|
|
800
627
|
value: function parseRelationsResponse(result, RelationModel) {
|
|
801
628
|
return convertToClientRecords(result, RelationModel, this);
|
|
802
629
|
}
|
|
630
|
+
|
|
803
631
|
/**
|
|
804
632
|
* @private
|
|
805
633
|
* */
|
|
806
|
-
|
|
807
634
|
}, {
|
|
808
635
|
key: "parseResponse",
|
|
809
636
|
value: function parseResponse(result) {
|
|
810
637
|
return convertToClientRecords(result, this.model, this);
|
|
811
638
|
}
|
|
639
|
+
|
|
812
640
|
/**
|
|
813
641
|
* @private
|
|
814
642
|
* */
|
|
815
|
-
|
|
816
643
|
}, {
|
|
817
644
|
key: "changeRelation",
|
|
818
645
|
value: function changeRelation(method, parent, columnName, children) {
|
|
819
646
|
var parentId = parent && parent.objectId || parent;
|
|
820
|
-
|
|
821
647
|
if (!parentId || typeof parentId !== 'string' && typeof parentId !== 'number') {
|
|
822
648
|
throw new Error('Relation Parent must be provided and must be a string or number or an object with objectId property.');
|
|
823
649
|
}
|
|
824
|
-
|
|
825
650
|
if (!columnName || typeof columnName !== 'string') {
|
|
826
651
|
throw new Error('Relation Column Name must be provided and must be a string.');
|
|
827
652
|
}
|
|
828
|
-
|
|
829
653
|
if (!children || typeof children !== 'string' && !Array.isArray(children)) {
|
|
830
654
|
throw new Error('Relation Children must be provided and must be a string or a list of objects.');
|
|
831
655
|
}
|
|
832
|
-
|
|
833
656
|
var condition = {};
|
|
834
|
-
|
|
835
657
|
if (typeof children === 'string') {
|
|
836
658
|
condition.whereClause = children;
|
|
837
659
|
} else {
|
|
838
660
|
condition.childrenIds = children.map(function (child) {
|
|
839
661
|
var childId = child && child.objectId || child;
|
|
840
|
-
|
|
841
662
|
if (!childId || typeof childId !== 'string' && typeof childId !== 'number') {
|
|
842
663
|
throw new Error('Child Id must be provided and must be a string or number.');
|
|
843
664
|
}
|
|
844
|
-
|
|
845
665
|
return childId;
|
|
846
666
|
});
|
|
847
667
|
}
|
|
848
|
-
|
|
849
668
|
var query = {};
|
|
850
|
-
|
|
851
669
|
if (condition.whereClause) {
|
|
852
670
|
query.whereClause = condition.whereClause;
|
|
853
671
|
}
|
|
854
|
-
|
|
855
672
|
return this.app.request.send({
|
|
856
673
|
method: method,
|
|
857
674
|
url: this.app.urls.dataTableObjectRelation(this.className, parentId, columnName),
|
|
@@ -862,9 +679,7 @@ var DataStore = /*#__PURE__*/function () {
|
|
|
862
679
|
}]);
|
|
863
680
|
return DataStore;
|
|
864
681
|
}();
|
|
865
|
-
|
|
866
682
|
exports["default"] = DataStore;
|
|
867
|
-
|
|
868
683
|
var convertToServerRecord = function () {
|
|
869
684
|
return function (sourceRecord) {
|
|
870
685
|
var context = {
|
|
@@ -872,7 +687,6 @@ var convertToServerRecord = function () {
|
|
|
872
687
|
};
|
|
873
688
|
return processTargetProps(context, sourceRecord, {});
|
|
874
689
|
};
|
|
875
|
-
|
|
876
690
|
function processTargetProps(context, source, target) {
|
|
877
691
|
for (var prop in source) {
|
|
878
692
|
if (Array.isArray(source[prop])) {
|
|
@@ -882,17 +696,14 @@ var convertToServerRecord = function () {
|
|
|
882
696
|
target[prop] = source[prop].getTime();
|
|
883
697
|
} else if (context.instancesMap.has(source[prop])) {
|
|
884
698
|
var iteratedTarget = context.instancesMap.get(source[prop]);
|
|
885
|
-
|
|
886
699
|
if (!iteratedTarget.__subID) {
|
|
887
700
|
iteratedTarget.__subID = _utils["default"].uuid();
|
|
888
701
|
}
|
|
889
|
-
|
|
890
702
|
target[prop] = {
|
|
891
703
|
__originSubID: iteratedTarget.__subID
|
|
892
704
|
};
|
|
893
705
|
} else {
|
|
894
706
|
var _iteratedTarget = target[prop] = {};
|
|
895
|
-
|
|
896
707
|
context.instancesMap.set(source[prop], _iteratedTarget);
|
|
897
708
|
processTargetProps(context, source[prop], _iteratedTarget);
|
|
898
709
|
}
|
|
@@ -900,17 +711,14 @@ var convertToServerRecord = function () {
|
|
|
900
711
|
target[prop] = source[prop];
|
|
901
712
|
}
|
|
902
713
|
}
|
|
903
|
-
|
|
904
714
|
return target;
|
|
905
715
|
}
|
|
906
716
|
}();
|
|
907
|
-
|
|
908
717
|
var convertToClientRecords = function () {
|
|
909
718
|
return function (records, RootModel, dataStore) {
|
|
910
719
|
if (!records) {
|
|
911
720
|
return records;
|
|
912
721
|
}
|
|
913
|
-
|
|
914
722
|
var context = {
|
|
915
723
|
RootModel: RootModel,
|
|
916
724
|
app: dataStore.app,
|
|
@@ -924,26 +732,21 @@ var convertToClientRecords = function () {
|
|
|
924
732
|
assignPostRelations(context);
|
|
925
733
|
return result;
|
|
926
734
|
};
|
|
927
|
-
|
|
928
735
|
function createTargetRecord(context, source, target, prop) {
|
|
929
736
|
var __subID = source[prop].__subID;
|
|
930
|
-
|
|
931
737
|
if (__subID && context.subIds[__subID]) {
|
|
932
738
|
target[prop] = context.subIds[__subID];
|
|
933
739
|
delete source[prop].__subID;
|
|
934
740
|
} else {
|
|
935
741
|
var Model = context.classToTableMap[source[prop].___class];
|
|
936
742
|
target[prop] = Model ? new Model() : {};
|
|
937
|
-
|
|
938
743
|
if (__subID && !context.subIds[__subID]) {
|
|
939
744
|
context.subIds[__subID] = target[prop];
|
|
940
745
|
delete source[prop].__subID;
|
|
941
746
|
}
|
|
942
|
-
|
|
943
747
|
processTargetProps(context, source[prop], target[prop]);
|
|
944
748
|
}
|
|
945
749
|
}
|
|
946
|
-
|
|
947
750
|
function processTargetProp(context, source, target, prop) {
|
|
948
751
|
if (Array.isArray(source[prop])) {
|
|
949
752
|
processTargetProps(context, source[prop], target[prop] = []);
|
|
@@ -959,37 +762,30 @@ var convertToClientRecords = function () {
|
|
|
959
762
|
target[prop] = source[prop];
|
|
960
763
|
}
|
|
961
764
|
}
|
|
962
|
-
|
|
963
765
|
function processTargetProps(context, source, target) {
|
|
964
766
|
for (var prop in source) {
|
|
965
767
|
processTargetProp(context, source, target, prop);
|
|
966
768
|
}
|
|
967
769
|
}
|
|
968
|
-
|
|
969
770
|
function sanitizeItem(context, sourceRecord) {
|
|
970
771
|
var Model = context.RootModel || context.classToTableMap[sourceRecord.___class];
|
|
971
772
|
var targetRecord = Model ? new Model() : {};
|
|
972
|
-
|
|
973
773
|
if (sourceRecord.__subID) {
|
|
974
774
|
if (context.subIds[sourceRecord.__subID]) {
|
|
975
775
|
return context.subIds[sourceRecord.__subID];
|
|
976
776
|
}
|
|
977
|
-
|
|
978
777
|
context.subIds[sourceRecord.__subID] = targetRecord;
|
|
979
778
|
delete sourceRecord.__subID;
|
|
980
779
|
}
|
|
981
|
-
|
|
982
780
|
processTargetProps(context, sourceRecord, targetRecord);
|
|
983
781
|
return targetRecord;
|
|
984
782
|
}
|
|
985
|
-
|
|
986
783
|
function assignPostRelations(context) {
|
|
987
784
|
context.postAssign.forEach(function (_ref2) {
|
|
988
785
|
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 3),
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
786
|
+
target = _ref3[0],
|
|
787
|
+
prop = _ref3[1],
|
|
788
|
+
__originSubID = _ref3[2];
|
|
993
789
|
target[prop] = context.subIds[__originSubID];
|
|
994
790
|
});
|
|
995
791
|
}
|