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