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
|
@@ -1,70 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = UnitOfWorkService;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
|
|
16
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
|
-
|
|
18
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
21
|
-
|
|
22
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
23
|
-
|
|
24
15
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
|
-
|
|
26
16
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
27
|
-
|
|
28
17
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
29
|
-
|
|
30
18
|
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
31
|
-
|
|
32
19
|
var _utils = _interopRequireDefault(require("../utils"));
|
|
33
|
-
|
|
34
20
|
var _dataQueryBuilder = _interopRequireDefault(require("../data/data-query-builder"));
|
|
35
|
-
|
|
36
21
|
var _constants = require("./constants");
|
|
37
|
-
|
|
38
22
|
var _jsonAdapter = require("./json-adapter");
|
|
39
|
-
|
|
40
23
|
var _opResult = require("./op-result");
|
|
41
|
-
|
|
42
24
|
var _opResultValueReference = require("./op-result-value-reference");
|
|
43
|
-
|
|
44
25
|
var _excluded = ["meta"];
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
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; }
|
|
49
|
-
|
|
26
|
+
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; }
|
|
27
|
+
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; }
|
|
50
28
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
51
|
-
|
|
52
29
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
|
-
|
|
54
30
|
var TransactionOperationError = /*#__PURE__*/function (_Error) {
|
|
55
31
|
(0, _inherits2["default"])(TransactionOperationError, _Error);
|
|
56
|
-
|
|
57
32
|
var _super = _createSuper(TransactionOperationError);
|
|
58
|
-
|
|
59
33
|
function TransactionOperationError(message, operation) {
|
|
60
34
|
var _this;
|
|
61
|
-
|
|
62
35
|
(0, _classCallCheck2["default"])(this, TransactionOperationError);
|
|
63
36
|
_this = _super.call(this, message);
|
|
64
37
|
_this.operation = operation;
|
|
65
38
|
return _this;
|
|
66
39
|
}
|
|
67
|
-
|
|
68
40
|
(0, _createClass2["default"])(TransactionOperationError, [{
|
|
69
41
|
key: "toJSON",
|
|
70
42
|
value: function toJSON() {
|
|
@@ -76,18 +48,16 @@ var TransactionOperationError = /*#__PURE__*/function (_Error) {
|
|
|
76
48
|
}]);
|
|
77
49
|
return TransactionOperationError;
|
|
78
50
|
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
|
|
79
|
-
|
|
80
51
|
var UnitOfWorkResult = /*#__PURE__*/function () {
|
|
81
52
|
function UnitOfWorkResult(_ref) {
|
|
82
53
|
var success = _ref.success,
|
|
83
|
-
|
|
84
|
-
|
|
54
|
+
error = _ref.error,
|
|
55
|
+
results = _ref.results;
|
|
85
56
|
(0, _classCallCheck2["default"])(this, UnitOfWorkResult);
|
|
86
57
|
this.success = success;
|
|
87
58
|
this.error = error;
|
|
88
59
|
this.results = results;
|
|
89
60
|
}
|
|
90
|
-
|
|
91
61
|
(0, _createClass2["default"])(UnitOfWorkResult, [{
|
|
92
62
|
key: "isSuccess",
|
|
93
63
|
value: function isSuccess() {
|
|
@@ -106,7 +76,6 @@ var UnitOfWorkResult = /*#__PURE__*/function () {
|
|
|
106
76
|
}]);
|
|
107
77
|
return UnitOfWorkResult;
|
|
108
78
|
}();
|
|
109
|
-
|
|
110
79
|
var UnitOfWork = /*#__PURE__*/function () {
|
|
111
80
|
function UnitOfWork(isolationLevelEnum, app) {
|
|
112
81
|
(0, _classCallCheck2["default"])(this, UnitOfWork);
|
|
@@ -117,7 +86,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
117
86
|
};
|
|
118
87
|
this.usedOpIds = {};
|
|
119
88
|
}
|
|
120
|
-
|
|
121
89
|
(0, _createClass2["default"])(UnitOfWork, [{
|
|
122
90
|
key: "getOpResultById",
|
|
123
91
|
value: function getOpResultById(opResultId) {
|
|
@@ -142,7 +110,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
142
110
|
if (!this.usedOpIds[stackName]) {
|
|
143
111
|
this.usedOpIds[stackName] = 0;
|
|
144
112
|
}
|
|
145
|
-
|
|
146
113
|
return ++this.usedOpIds[stackName];
|
|
147
114
|
}
|
|
148
115
|
}, {
|
|
@@ -156,7 +123,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
156
123
|
} else {
|
|
157
124
|
delete payload.___jsonclass;
|
|
158
125
|
}
|
|
159
|
-
|
|
160
126
|
var opResult = new _opResult.OpResult(this, {
|
|
161
127
|
operationType: operationType,
|
|
162
128
|
table: table,
|
|
@@ -178,7 +144,7 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
178
144
|
return _objectSpread(_objectSpread({}, this.payload), {}, {
|
|
179
145
|
operations: this.payload.operations.map(function (_ref2) {
|
|
180
146
|
var meta = _ref2.meta,
|
|
181
|
-
|
|
147
|
+
operation = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
182
148
|
return _objectSpread(_objectSpread({}, operation), {}, {
|
|
183
149
|
opResultId: meta.opResult.getOpResultId()
|
|
184
150
|
});
|
|
@@ -191,31 +157,25 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
191
157
|
var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
192
158
|
var result;
|
|
193
159
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
194
|
-
while (1) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
case 4:
|
|
208
|
-
case "end":
|
|
209
|
-
return _context.stop();
|
|
210
|
-
}
|
|
160
|
+
while (1) switch (_context.prev = _context.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
_context.next = 2;
|
|
163
|
+
return this.app.request.post({
|
|
164
|
+
url: this.app.urls.transactions(),
|
|
165
|
+
data: this.composePayload()
|
|
166
|
+
});
|
|
167
|
+
case 2:
|
|
168
|
+
result = _context.sent;
|
|
169
|
+
return _context.abrupt("return", this.setResult(result));
|
|
170
|
+
case 4:
|
|
171
|
+
case "end":
|
|
172
|
+
return _context.stop();
|
|
211
173
|
}
|
|
212
174
|
}, _callee, this);
|
|
213
175
|
}));
|
|
214
|
-
|
|
215
176
|
function execute() {
|
|
216
177
|
return _execute.apply(this, arguments);
|
|
217
178
|
}
|
|
218
|
-
|
|
219
179
|
return execute;
|
|
220
180
|
}()
|
|
221
181
|
}, {
|
|
@@ -224,13 +184,11 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
224
184
|
if (result.results) {
|
|
225
185
|
this.payload.operations.forEach(function (operation) {
|
|
226
186
|
var opResultId = operation.meta.opResult.getOpResultId();
|
|
227
|
-
|
|
228
187
|
if (result.results[opResultId]) {
|
|
229
188
|
operation.meta.opResult.setResult(result.results[opResultId].result);
|
|
230
189
|
}
|
|
231
190
|
});
|
|
232
191
|
}
|
|
233
|
-
|
|
234
192
|
if (result.error) {
|
|
235
193
|
var operation = this.payload.operations.find(function (op) {
|
|
236
194
|
return result.error.operation.opResultId === op.meta.opResult.getOpResultId();
|
|
@@ -238,87 +196,69 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
238
196
|
result.error = new TransactionOperationError(result.error.message, operation.meta.opResult);
|
|
239
197
|
operation.meta.opResult.setError(result.error);
|
|
240
198
|
}
|
|
241
|
-
|
|
242
199
|
return new UnitOfWorkResult(result);
|
|
243
200
|
}
|
|
244
201
|
}, {
|
|
245
202
|
key: "find",
|
|
246
203
|
value: function find(tableName, queryBuilder) {
|
|
247
204
|
var query = queryBuilder instanceof _dataQueryBuilder["default"] ? queryBuilder.toJSON() : queryBuilder || {};
|
|
248
|
-
|
|
249
205
|
if (!tableName || typeof tableName !== 'string') {
|
|
250
206
|
throw new Error('Invalid arguments');
|
|
251
207
|
}
|
|
252
|
-
|
|
253
208
|
if ((0, _typeof2["default"])(query) !== 'object' || Array.isArray(query)) {
|
|
254
209
|
throw new Error('Invalid arguments');
|
|
255
210
|
}
|
|
256
|
-
|
|
257
211
|
var payload = {
|
|
258
212
|
queryOptions: {}
|
|
259
213
|
};
|
|
260
|
-
|
|
261
214
|
if (query.pageSize > 0) {
|
|
262
215
|
payload.pageSize = query.pageSize;
|
|
263
216
|
}
|
|
264
|
-
|
|
265
217
|
if (query.offset > 0) {
|
|
266
218
|
payload.offset = query.offset;
|
|
267
219
|
}
|
|
268
|
-
|
|
269
220
|
if (query.properties) {
|
|
270
221
|
payload.properties = query.properties;
|
|
271
222
|
}
|
|
272
|
-
|
|
273
223
|
if (query.excludeProps) {
|
|
274
224
|
payload.excludeProps = query.excludeProps;
|
|
275
225
|
}
|
|
276
|
-
|
|
277
226
|
if (query.excludeProps) {
|
|
278
227
|
payload.excludeProps = query.excludeProps;
|
|
279
228
|
}
|
|
280
|
-
|
|
281
229
|
if (query.where) {
|
|
282
230
|
payload.whereClause = query.where;
|
|
283
231
|
}
|
|
284
|
-
|
|
285
232
|
if (query.having) {
|
|
286
233
|
payload.havingClause = query.having;
|
|
287
234
|
}
|
|
288
|
-
|
|
289
235
|
if (query.groupBy) {
|
|
290
236
|
payload.groupBy = query.groupBy;
|
|
291
237
|
}
|
|
292
|
-
|
|
293
238
|
if (query.sortBy) {
|
|
294
239
|
payload.queryOptions.sortBy = query.sortBy;
|
|
295
240
|
}
|
|
296
|
-
|
|
297
241
|
if (query.relations) {
|
|
298
242
|
payload.queryOptions.related = query.relations;
|
|
299
243
|
}
|
|
300
|
-
|
|
301
244
|
if (query.relationsDepth) {
|
|
302
245
|
payload.queryOptions.relationsDepth = query.relationsDepth;
|
|
303
246
|
}
|
|
304
|
-
|
|
305
247
|
if (query.relationsPageSize > 0) {
|
|
306
248
|
payload.queryOptions.relationsPageSize = query.relationsPageSize;
|
|
307
249
|
}
|
|
308
|
-
|
|
309
250
|
return this.addOperations(_constants.OperationType.FIND, tableName, payload);
|
|
310
251
|
}
|
|
252
|
+
|
|
311
253
|
/**
|
|
312
254
|
* upsert(object: object): OpResult;
|
|
313
255
|
* upsert(tableName: string, object: object): OpResult;
|
|
314
256
|
* **/
|
|
315
|
-
|
|
316
257
|
}, {
|
|
317
258
|
key: "upsert",
|
|
318
259
|
value: function upsert() {
|
|
319
260
|
var tableName;
|
|
320
261
|
var changes;
|
|
321
|
-
|
|
322
262
|
if (arguments.length === 1) {
|
|
323
263
|
tableName = _utils["default"].getClassName(arguments.length <= 0 ? undefined : arguments[0]);
|
|
324
264
|
changes = arguments.length <= 0 ? undefined : arguments[0];
|
|
@@ -328,28 +268,24 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
328
268
|
} else {
|
|
329
269
|
throw new Error('Invalid arguments');
|
|
330
270
|
}
|
|
331
|
-
|
|
332
271
|
if (!tableName || typeof tableName !== 'string') {
|
|
333
272
|
throw new Error('Invalid arguments');
|
|
334
273
|
}
|
|
335
|
-
|
|
336
274
|
if (!changes || (0, _typeof2["default"])(changes) !== 'object' || Array.isArray(changes)) {
|
|
337
275
|
throw new Error('Invalid arguments');
|
|
338
276
|
}
|
|
339
|
-
|
|
340
277
|
return this.addOperations(_constants.OperationType.UPSERT, tableName, changes);
|
|
341
278
|
}
|
|
279
|
+
|
|
342
280
|
/**
|
|
343
281
|
* create(object: object): OpResult;
|
|
344
282
|
* create(tableName: string, object: object): OpResult;
|
|
345
283
|
* **/
|
|
346
|
-
|
|
347
284
|
}, {
|
|
348
285
|
key: "create",
|
|
349
286
|
value: function create() {
|
|
350
287
|
var tableName;
|
|
351
288
|
var changes;
|
|
352
|
-
|
|
353
289
|
if (arguments.length === 1) {
|
|
354
290
|
tableName = _utils["default"].getClassName(arguments.length <= 0 ? undefined : arguments[0]);
|
|
355
291
|
changes = arguments.length <= 0 ? undefined : arguments[0];
|
|
@@ -359,17 +295,15 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
359
295
|
} else {
|
|
360
296
|
throw new Error('Invalid arguments');
|
|
361
297
|
}
|
|
362
|
-
|
|
363
298
|
if (!tableName || typeof tableName !== 'string') {
|
|
364
299
|
throw new Error('Invalid arguments');
|
|
365
300
|
}
|
|
366
|
-
|
|
367
301
|
if (!changes || (0, _typeof2["default"])(changes) !== 'object' || Array.isArray(changes)) {
|
|
368
302
|
throw new Error('Invalid arguments');
|
|
369
303
|
}
|
|
370
|
-
|
|
371
304
|
return this.addOperations(_constants.OperationType.CREATE, tableName, changes);
|
|
372
305
|
}
|
|
306
|
+
|
|
373
307
|
/**
|
|
374
308
|
* update(object: object): OpResult;
|
|
375
309
|
* update(tableName: string, object: object): OpResult;
|
|
@@ -385,17 +319,14 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
385
319
|
* propertyName: string,
|
|
386
320
|
* propertyValue: number | string | boolean): OpResult;
|
|
387
321
|
* **/
|
|
388
|
-
|
|
389
322
|
}, {
|
|
390
323
|
key: "update",
|
|
391
324
|
value: function update() {
|
|
392
325
|
var tableName;
|
|
393
326
|
var payload;
|
|
394
|
-
|
|
395
327
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
396
328
|
args[_key] = arguments[_key];
|
|
397
329
|
}
|
|
398
|
-
|
|
399
330
|
if (args.length === 1) {
|
|
400
331
|
tableName = _utils["default"].getClassName(args[0]);
|
|
401
332
|
payload = args[0];
|
|
@@ -407,7 +338,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
407
338
|
payload = {
|
|
408
339
|
objectId: args[0]
|
|
409
340
|
};
|
|
410
|
-
|
|
411
341
|
if (args.length === 3 && typeof args[1] === 'string') {
|
|
412
342
|
payload[args[1]] = args[2];
|
|
413
343
|
} else if (args.length === 2) {
|
|
@@ -418,30 +348,26 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
418
348
|
} else {
|
|
419
349
|
throw new Error('Invalid arguments');
|
|
420
350
|
}
|
|
421
|
-
|
|
422
351
|
if (!tableName || typeof tableName !== 'string') {
|
|
423
352
|
throw new Error('Invalid arguments');
|
|
424
353
|
}
|
|
425
|
-
|
|
426
354
|
return this.addOperations(_constants.OperationType.UPDATE, tableName, payload);
|
|
427
355
|
}
|
|
356
|
+
|
|
428
357
|
/**
|
|
429
358
|
* delete(opResult: OpResult | OpResultValueReference): OpResult;
|
|
430
359
|
* delete(object: object): OpResult;
|
|
431
360
|
* delete(tableName: string, object: object): OpResult;
|
|
432
361
|
* delete(tableName: string, objectId: string): OpResult;
|
|
433
362
|
* **/
|
|
434
|
-
|
|
435
363
|
}, {
|
|
436
364
|
key: "delete",
|
|
437
365
|
value: function _delete() {
|
|
438
366
|
var tableName;
|
|
439
367
|
var object;
|
|
440
|
-
|
|
441
368
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
442
369
|
args[_key2] = arguments[_key2];
|
|
443
370
|
}
|
|
444
|
-
|
|
445
371
|
if (args.length === 1) {
|
|
446
372
|
if (args[0] instanceof _opResult.OpResult || args[0] instanceof _opResultValueReference.OpResultValueReference) {
|
|
447
373
|
tableName = args[0].getTableName();
|
|
@@ -456,22 +382,19 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
456
382
|
} else {
|
|
457
383
|
throw new Error('Invalid arguments');
|
|
458
384
|
}
|
|
459
|
-
|
|
460
385
|
if (!object || Array.isArray(object) || typeof object !== 'string' && (0, _typeof2["default"])(object) !== 'object') {
|
|
461
386
|
throw new Error('Invalid arguments');
|
|
462
387
|
}
|
|
463
|
-
|
|
464
388
|
if (!tableName || typeof tableName !== 'string') {
|
|
465
389
|
throw new Error('Table Name must be a string.');
|
|
466
390
|
}
|
|
467
|
-
|
|
468
391
|
return this.addOperations(_constants.OperationType.DELETE, tableName, object);
|
|
469
392
|
}
|
|
393
|
+
|
|
470
394
|
/**
|
|
471
395
|
* bulkUpsert(tableName: string, objects: object[]): OpResult;
|
|
472
396
|
* bulkUpsert(objects: object[]): OpResult;
|
|
473
397
|
* **/
|
|
474
|
-
|
|
475
398
|
}, {
|
|
476
399
|
key: "bulkUpsert",
|
|
477
400
|
value: function bulkUpsert(tableName, objects) {
|
|
@@ -479,22 +402,19 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
479
402
|
objects = tableName;
|
|
480
403
|
tableName = _utils["default"].getClassName(objects[0]);
|
|
481
404
|
}
|
|
482
|
-
|
|
483
405
|
if (!objects || !Array.isArray(objects)) {
|
|
484
406
|
throw new Error('Objects must be an array of objects.');
|
|
485
407
|
}
|
|
486
|
-
|
|
487
408
|
if (!tableName || typeof tableName !== 'string') {
|
|
488
409
|
throw new Error('Table Name must be a string.');
|
|
489
410
|
}
|
|
490
|
-
|
|
491
411
|
return this.addOperations(_constants.OperationType.UPSERT_BULK, tableName, objects);
|
|
492
412
|
}
|
|
413
|
+
|
|
493
414
|
/**
|
|
494
415
|
* bulkCreate(tableName: string, objects: object[]): OpResult;
|
|
495
416
|
* bulkCreate(objects: object[]): OpResult;
|
|
496
417
|
* **/
|
|
497
|
-
|
|
498
418
|
}, {
|
|
499
419
|
key: "bulkCreate",
|
|
500
420
|
value: function bulkCreate(tableName, objects) {
|
|
@@ -502,17 +422,15 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
502
422
|
objects = tableName;
|
|
503
423
|
tableName = _utils["default"].getClassName(objects[0]);
|
|
504
424
|
}
|
|
505
|
-
|
|
506
425
|
if (!objects || !Array.isArray(objects)) {
|
|
507
426
|
throw new Error('Objects must be an array of objects.');
|
|
508
427
|
}
|
|
509
|
-
|
|
510
428
|
if (!tableName || typeof tableName !== 'string') {
|
|
511
429
|
throw new Error('Table Name must be a string.');
|
|
512
430
|
}
|
|
513
|
-
|
|
514
431
|
return this.addOperations(_constants.OperationType.CREATE_BULK, tableName, objects);
|
|
515
432
|
}
|
|
433
|
+
|
|
516
434
|
/**
|
|
517
435
|
* bulkUpdate(opResult: OpResult, changes: object): OpResult;
|
|
518
436
|
*
|
|
@@ -520,20 +438,16 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
520
438
|
* bulkUpdate(tableName: string, objectIds: string[], changes: object): OpResult;
|
|
521
439
|
* bulkUpdate(tableName: string, objects: object[], changes: object): OpResult;
|
|
522
440
|
* **/
|
|
523
|
-
|
|
524
441
|
}, {
|
|
525
442
|
key: "bulkUpdate",
|
|
526
443
|
value: function bulkUpdate() {
|
|
527
444
|
var tableName;
|
|
528
445
|
var payload = {};
|
|
529
|
-
|
|
530
446
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
531
447
|
args[_key3] = arguments[_key3];
|
|
532
448
|
}
|
|
533
|
-
|
|
534
449
|
if (args.length === 2) {
|
|
535
450
|
payload.changes = args[1];
|
|
536
|
-
|
|
537
451
|
if (typeof args[0] === 'string') {
|
|
538
452
|
tableName = _utils["default"].getClassName(args[1]);
|
|
539
453
|
payload.conditional = args[0];
|
|
@@ -544,7 +458,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
544
458
|
} else if (args.length === 3) {
|
|
545
459
|
tableName = args[0];
|
|
546
460
|
payload.changes = args[2];
|
|
547
|
-
|
|
548
461
|
if (typeof args[1] === 'string') {
|
|
549
462
|
payload.conditional = args[1];
|
|
550
463
|
} else if (Array.isArray(args[1])) {
|
|
@@ -557,13 +470,12 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
557
470
|
} else {
|
|
558
471
|
throw new Error('Invalid arguments');
|
|
559
472
|
}
|
|
560
|
-
|
|
561
473
|
if (!tableName || typeof tableName !== 'string') {
|
|
562
474
|
throw new Error('Table Name must be a string.');
|
|
563
475
|
}
|
|
564
|
-
|
|
565
476
|
return this.addOperations(_constants.OperationType.UPDATE_BULK, tableName, payload);
|
|
566
477
|
}
|
|
478
|
+
|
|
567
479
|
/**
|
|
568
480
|
* bulkDelete(opResult: OpResult): OpResult;
|
|
569
481
|
* bulkDelete(objects: object[]): OpResult;
|
|
@@ -572,17 +484,14 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
572
484
|
* bulkDelete(tableName: string, objectIds: string[]): OpResult;
|
|
573
485
|
* bulkDelete(tableName: string, whereClause: string): OpResult;
|
|
574
486
|
* **/
|
|
575
|
-
|
|
576
487
|
}, {
|
|
577
488
|
key: "bulkDelete",
|
|
578
489
|
value: function bulkDelete() {
|
|
579
490
|
var payload = {};
|
|
580
491
|
var tableName;
|
|
581
|
-
|
|
582
492
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
583
493
|
args[_key4] = arguments[_key4];
|
|
584
494
|
}
|
|
585
|
-
|
|
586
495
|
if (args.length === 1) {
|
|
587
496
|
if (args[0] instanceof _opResult.OpResult) {
|
|
588
497
|
tableName = args[0].getTableName();
|
|
@@ -597,7 +506,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
597
506
|
}
|
|
598
507
|
} else if (args.length === 2) {
|
|
599
508
|
tableName = args[0];
|
|
600
|
-
|
|
601
509
|
if (typeof args[1] === 'string') {
|
|
602
510
|
payload.conditional = args[1];
|
|
603
511
|
} else if (Array.isArray(args[1])) {
|
|
@@ -610,11 +518,9 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
610
518
|
} else {
|
|
611
519
|
throw new Error('Invalid arguments');
|
|
612
520
|
}
|
|
613
|
-
|
|
614
521
|
if (!tableName || typeof tableName !== 'string') {
|
|
615
522
|
throw new Error('Table Name must be a string.');
|
|
616
523
|
}
|
|
617
|
-
|
|
618
524
|
return this.addOperations(_constants.OperationType.DELETE_BULK, tableName, payload);
|
|
619
525
|
}
|
|
620
526
|
}, {
|
|
@@ -623,7 +529,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
623
529
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
624
530
|
args[_key5] = arguments[_key5];
|
|
625
531
|
}
|
|
626
|
-
|
|
627
532
|
return this.relationsOperation(_constants.OperationType.ADD_RELATION, args);
|
|
628
533
|
}
|
|
629
534
|
}, {
|
|
@@ -632,7 +537,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
632
537
|
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
633
538
|
args[_key6] = arguments[_key6];
|
|
634
539
|
}
|
|
635
|
-
|
|
636
540
|
return this.relationsOperation(_constants.OperationType.SET_RELATION, args);
|
|
637
541
|
}
|
|
638
542
|
}, {
|
|
@@ -641,9 +545,9 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
641
545
|
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
642
546
|
args[_key7] = arguments[_key7];
|
|
643
547
|
}
|
|
644
|
-
|
|
645
548
|
return this.relationsOperation(_constants.OperationType.DELETE_RELATION, args);
|
|
646
549
|
}
|
|
550
|
+
|
|
647
551
|
/**
|
|
648
552
|
*
|
|
649
553
|
* uow.[...]Relation(
|
|
@@ -660,7 +564,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
660
564
|
* )
|
|
661
565
|
*
|
|
662
566
|
* */
|
|
663
|
-
|
|
664
567
|
}, {
|
|
665
568
|
key: "relationsOperation",
|
|
666
569
|
value: function relationsOperation(operationType, args) {
|
|
@@ -670,12 +573,10 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
670
573
|
var conditional;
|
|
671
574
|
var unconditional;
|
|
672
575
|
var children;
|
|
673
|
-
|
|
674
576
|
if (args.length === 3) {
|
|
675
577
|
parentObject = args[0];
|
|
676
578
|
relationColumn = args[1];
|
|
677
579
|
children = args[2];
|
|
678
|
-
|
|
679
580
|
if (parentObject instanceof _opResult.OpResult || parentObject instanceof _opResultValueReference.OpResultValueReference) {
|
|
680
581
|
tableName = parentObject.getTableName();
|
|
681
582
|
} else if (parentObject && (0, _typeof2["default"])(parentObject) === 'object') {
|
|
@@ -687,7 +588,6 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
687
588
|
tableName = args[0];
|
|
688
589
|
relationColumn = args[2];
|
|
689
590
|
children = args[3];
|
|
690
|
-
|
|
691
591
|
if (typeof args[1] === 'string') {
|
|
692
592
|
parentObject = args[1];
|
|
693
593
|
} else if (args[1] && (0, _typeof2["default"])(args[1]) === 'object') {
|
|
@@ -698,11 +598,9 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
698
598
|
} else {
|
|
699
599
|
throw new Error('Invalid arguments');
|
|
700
600
|
}
|
|
701
|
-
|
|
702
601
|
if (parentObject && parentObject.objectId) {
|
|
703
602
|
parentObject = parentObject.objectId;
|
|
704
603
|
}
|
|
705
|
-
|
|
706
604
|
if (typeof children === 'string') {
|
|
707
605
|
conditional = children;
|
|
708
606
|
} else if (children instanceof _opResult.OpResult && children.isCollectionRef()) {
|
|
@@ -711,77 +609,61 @@ var UnitOfWork = /*#__PURE__*/function () {
|
|
|
711
609
|
if (!Array.isArray(children)) {
|
|
712
610
|
children = [children];
|
|
713
611
|
}
|
|
714
|
-
|
|
715
612
|
unconditional = children.map(function (child) {
|
|
716
613
|
if (child) {
|
|
717
614
|
if (child instanceof _opResult.OpResult || child instanceof _opResultValueReference.OpResultValueReference) {
|
|
718
615
|
return child;
|
|
719
616
|
}
|
|
720
|
-
|
|
721
617
|
if (typeof child === 'string') {
|
|
722
618
|
return child;
|
|
723
619
|
}
|
|
724
|
-
|
|
725
620
|
if (child.objectId) {
|
|
726
621
|
return child.objectId;
|
|
727
622
|
}
|
|
728
623
|
}
|
|
729
|
-
|
|
730
624
|
throw new Error('Invalid child argument, it must be an instance of [OpResult|OpResultValueReference|Object] or objectId');
|
|
731
625
|
});
|
|
732
626
|
}
|
|
733
|
-
|
|
734
627
|
if (!relationColumn || typeof relationColumn !== 'string') {
|
|
735
628
|
throw new Error('Invalid "relationColumn" parameter, check passed arguments');
|
|
736
629
|
}
|
|
737
|
-
|
|
738
630
|
if (!unconditional && !conditional) {
|
|
739
631
|
throw new Error('Neither "unconditional" nor "conditional" parameter is specified, check passed arguments');
|
|
740
632
|
}
|
|
741
|
-
|
|
742
633
|
if (!tableName || typeof tableName !== 'string') {
|
|
743
634
|
throw new Error('Table Name must be a string.');
|
|
744
635
|
}
|
|
745
|
-
|
|
746
636
|
var payload = {
|
|
747
637
|
parentObject: parentObject,
|
|
748
638
|
relationColumn: relationColumn
|
|
749
639
|
};
|
|
750
|
-
|
|
751
640
|
if (conditional) {
|
|
752
641
|
payload.conditional = conditional;
|
|
753
642
|
} else {
|
|
754
643
|
payload.unconditional = unconditional;
|
|
755
644
|
}
|
|
756
|
-
|
|
757
645
|
return this.addOperations(operationType, tableName, payload);
|
|
758
646
|
}
|
|
759
647
|
}]);
|
|
760
648
|
return UnitOfWork;
|
|
761
649
|
}();
|
|
762
|
-
|
|
763
650
|
(0, _defineProperty2["default"])(UnitOfWork, "IsolationLevelEnum", _constants.IsolationLevelEnum);
|
|
764
651
|
(0, _defineProperty2["default"])(UnitOfWork, "OpResult", _opResult.OpResult);
|
|
765
652
|
(0, _defineProperty2["default"])(UnitOfWork, "OpResultValueReference", _opResultValueReference.OpResultValueReference);
|
|
766
|
-
|
|
767
653
|
function UnitOfWorkService(app) {
|
|
768
654
|
return /*#__PURE__*/function (_UnitOfWork) {
|
|
769
655
|
(0, _inherits2["default"])(_class, _UnitOfWork);
|
|
770
|
-
|
|
771
656
|
var _super2 = _createSuper(_class);
|
|
772
|
-
|
|
773
657
|
function _class(isolationLevelEnum) {
|
|
774
658
|
(0, _classCallCheck2["default"])(this, _class);
|
|
775
659
|
return _super2.call(this, isolationLevelEnum, app);
|
|
776
660
|
}
|
|
777
|
-
|
|
778
661
|
(0, _createClass2["default"])(_class, null, [{
|
|
779
662
|
key: "initFromJSON",
|
|
780
663
|
value: function initFromJSON(data) {
|
|
781
664
|
var uow = new this(data.transactionIsolation);
|
|
782
665
|
data.operations.forEach(function (op) {
|
|
783
666
|
var opResult = _jsonAdapter.OperationJSONAdapter[op.operationType](uow, op);
|
|
784
|
-
|
|
785
667
|
opResult.setOpResultId(op.opResultId);
|
|
786
668
|
});
|
|
787
669
|
return uow;
|