parse 5.3.0-alpha.3 → 5.3.0-alpha.4

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.
@@ -19,7 +19,7 @@ const config = {
19
19
  SERVER_AUTH_TOKEN: null,
20
20
  LIVEQUERY_SERVER_URL: null,
21
21
  ENCRYPTED_KEY: null,
22
- VERSION: 'js' + "5.3.0-alpha.3",
22
+ VERSION: 'js' + "5.3.0-alpha.4",
23
23
  APPLICATION_ID: null,
24
24
  JAVASCRIPT_KEY: null,
25
25
  MASTER_KEY: null,
@@ -19,6 +19,7 @@ var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/cor
19
19
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
20
20
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
21
21
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
22
+ var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
22
23
  var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
23
24
  var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
24
25
  var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
@@ -1302,6 +1303,17 @@ class ParseObject {
1302
1303
  }
1303
1304
  const controller = _CoreManager.default.getObjectController();
1304
1305
  const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
1306
+ if (unsaved && unsaved.length && options.transaction === true && (0, _some.default)(unsaved).call(unsaved, el => el instanceof ParseObject)) {
1307
+ saveOptions.transaction = options.transaction;
1308
+ const unsavedFiles = [];
1309
+ const unsavedObjects = [];
1310
+ (0, _forEach.default)(unsaved).call(unsaved, el => {
1311
+ if (el instanceof _ParseFile.default) unsavedFiles.push(el);else unsavedObjects.push(el);
1312
+ });
1313
+ unsavedObjects.push(this);
1314
+ const filePromise = unsavedFiles.length ? controller.save(unsavedFiles, saveOptions) : _promise.default.resolve();
1315
+ return filePromise.then(() => controller.save(unsavedObjects, saveOptions)).then(savedOjbects => savedOjbects.pop());
1316
+ }
1305
1317
  return controller.save(unsaved, saveOptions).then(() => {
1306
1318
  return controller.save(this, saveOptions);
1307
1319
  });
@@ -1710,6 +1722,9 @@ class ParseObject {
1710
1722
  if (options.hasOwnProperty('sessionToken')) {
1711
1723
  destroyOptions.sessionToken = options.sessionToken;
1712
1724
  }
1725
+ if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1726
+ destroyOptions.transaction = options.transaction;
1727
+ }
1713
1728
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1714
1729
  destroyOptions.batchSize = options.batchSize;
1715
1730
  }
@@ -1746,6 +1761,9 @@ class ParseObject {
1746
1761
  if (options.hasOwnProperty('sessionToken')) {
1747
1762
  saveOptions.sessionToken = options.sessionToken;
1748
1763
  }
1764
+ if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1765
+ saveOptions.transaction = options.transaction;
1766
+ }
1749
1767
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1750
1768
  saveOptions.batchSize = options.batchSize;
1751
1769
  }
@@ -2233,10 +2251,12 @@ const DefaultController = {
2233
2251
  return _promise.default.resolve(undefined);
2234
2252
  },
2235
2253
  async destroy(target, options) {
2236
- const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2254
+ if (options && options.batchSize && options.transaction) throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.');
2255
+ let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2237
2256
  const localDatastore = _CoreManager.default.getLocalDatastore();
2238
2257
  const RESTController = _CoreManager.default.getRESTController();
2239
2258
  if ((0, _isArray.default)(target)) {
2259
+ if (options && options.transaction && target.length > 1) batchSize = target.length;
2240
2260
  if (target.length < 1) {
2241
2261
  return _promise.default.resolve([]);
2242
2262
  }
@@ -2257,16 +2277,21 @@ const DefaultController = {
2257
2277
  let deleteCompleted = _promise.default.resolve();
2258
2278
  const errors = [];
2259
2279
  (0, _forEach.default)(batches).call(batches, batch => {
2280
+ const requests = (0, _map.default)(batch).call(batch, obj => {
2281
+ return {
2282
+ method: 'DELETE',
2283
+ path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
2284
+ body: {}
2285
+ };
2286
+ });
2287
+ const body = options && options.transaction && requests.length > 1 ? {
2288
+ requests,
2289
+ transaction: true
2290
+ } : {
2291
+ requests
2292
+ };
2260
2293
  deleteCompleted = deleteCompleted.then(() => {
2261
- return RESTController.request('POST', 'batch', {
2262
- requests: (0, _map.default)(batch).call(batch, obj => {
2263
- return {
2264
- method: 'DELETE',
2265
- path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
2266
- body: {}
2267
- };
2268
- })
2269
- }, options).then(results => {
2294
+ return RESTController.request('POST', 'batch', body, options).then(results => {
2270
2295
  for (let i = 0; i < results.length; i++) {
2271
2296
  if (results[i] && results[i].hasOwnProperty('error')) {
2272
2297
  const err = new _ParseError.default(results[i].error.code, results[i].error.error);
@@ -2297,7 +2322,8 @@ const DefaultController = {
2297
2322
  return _promise.default.resolve(target);
2298
2323
  },
2299
2324
  save(target, options) {
2300
- const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2325
+ if (options && options.batchSize && options.transaction) return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.'));
2326
+ let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2301
2327
  const localDatastore = _CoreManager.default.getLocalDatastore();
2302
2328
  const mapIdForPin = {};
2303
2329
  const RESTController = _CoreManager.default.getRESTController();
@@ -2326,6 +2352,10 @@ const DefaultController = {
2326
2352
  pending.push(el);
2327
2353
  }
2328
2354
  });
2355
+ if (options && options.transaction && pending.length > 1) {
2356
+ if ((0, _some.default)(pending).call(pending, el => !(0, _canBeSerialized.default)(el))) return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a transactional batch containing an object with unserializable attributes.'));
2357
+ batchSize = pending.length;
2358
+ }
2329
2359
  return _promise.default.all(filesSaved).then(() => {
2330
2360
  let objectError = null;
2331
2361
  return (0, _promiseUtils.continueWhile)(() => {
@@ -2382,13 +2412,18 @@ const DefaultController = {
2382
2412
  });
2383
2413
  (0, _promiseUtils.when)(batchReady).then(() => {
2384
2414
  // Kick off the batch request
2385
- return RESTController.request('POST', 'batch', {
2386
- requests: (0, _map.default)(batch).call(batch, obj => {
2387
- const params = obj._getSaveParams();
2388
- params.path = getServerUrlPath() + params.path;
2389
- return params;
2390
- })
2391
- }, options);
2415
+ const requests = (0, _map.default)(batch).call(batch, obj => {
2416
+ const params = obj._getSaveParams();
2417
+ params.path = getServerUrlPath() + params.path;
2418
+ return params;
2419
+ });
2420
+ const body = options && options.transaction && requests.length > 1 ? {
2421
+ requests,
2422
+ transaction: true
2423
+ } : {
2424
+ requests
2425
+ };
2426
+ return RESTController.request('POST', 'batch', body, options);
2392
2427
  }).then(batchReturned.resolve, error => {
2393
2428
  batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
2394
2429
  });
@@ -16,7 +16,7 @@ const config = {
16
16
  SERVER_AUTH_TOKEN: null,
17
17
  LIVEQUERY_SERVER_URL: null,
18
18
  ENCRYPTED_KEY: null,
19
- VERSION: 'js' + "5.3.0-alpha.3",
19
+ VERSION: 'js' + "5.3.0-alpha.4",
20
20
  APPLICATION_ID: null,
21
21
  JAVASCRIPT_KEY: null,
22
22
  MASTER_KEY: null,
@@ -1282,6 +1282,17 @@ class ParseObject {
1282
1282
  }
1283
1283
  const controller = _CoreManager.default.getObjectController();
1284
1284
  const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
1285
+ if (unsaved && unsaved.length && options.transaction === true && unsaved.some(el => el instanceof ParseObject)) {
1286
+ saveOptions.transaction = options.transaction;
1287
+ const unsavedFiles = [];
1288
+ const unsavedObjects = [];
1289
+ unsaved.forEach(el => {
1290
+ if (el instanceof _ParseFile.default) unsavedFiles.push(el);else unsavedObjects.push(el);
1291
+ });
1292
+ unsavedObjects.push(this);
1293
+ const filePromise = unsavedFiles.length ? controller.save(unsavedFiles, saveOptions) : Promise.resolve();
1294
+ return filePromise.then(() => controller.save(unsavedObjects, saveOptions)).then(savedOjbects => savedOjbects.pop());
1295
+ }
1285
1296
  return controller.save(unsaved, saveOptions).then(() => {
1286
1297
  return controller.save(this, saveOptions);
1287
1298
  });
@@ -1687,6 +1698,9 @@ class ParseObject {
1687
1698
  if (options.hasOwnProperty('sessionToken')) {
1688
1699
  destroyOptions.sessionToken = options.sessionToken;
1689
1700
  }
1701
+ if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1702
+ destroyOptions.transaction = options.transaction;
1703
+ }
1690
1704
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1691
1705
  destroyOptions.batchSize = options.batchSize;
1692
1706
  }
@@ -1722,6 +1736,9 @@ class ParseObject {
1722
1736
  if (options.hasOwnProperty('sessionToken')) {
1723
1737
  saveOptions.sessionToken = options.sessionToken;
1724
1738
  }
1739
+ if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1740
+ saveOptions.transaction = options.transaction;
1741
+ }
1725
1742
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1726
1743
  saveOptions.batchSize = options.batchSize;
1727
1744
  }
@@ -2209,10 +2226,12 @@ const DefaultController = {
2209
2226
  return Promise.resolve(undefined);
2210
2227
  },
2211
2228
  async destroy(target, options) {
2212
- const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2229
+ if (options && options.batchSize && options.transaction) throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.');
2230
+ let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2213
2231
  const localDatastore = _CoreManager.default.getLocalDatastore();
2214
2232
  const RESTController = _CoreManager.default.getRESTController();
2215
2233
  if (Array.isArray(target)) {
2234
+ if (options && options.transaction && target.length > 1) batchSize = target.length;
2216
2235
  if (target.length < 1) {
2217
2236
  return Promise.resolve([]);
2218
2237
  }
@@ -2233,16 +2252,21 @@ const DefaultController = {
2233
2252
  let deleteCompleted = Promise.resolve();
2234
2253
  const errors = [];
2235
2254
  batches.forEach(batch => {
2255
+ const requests = batch.map(obj => {
2256
+ return {
2257
+ method: 'DELETE',
2258
+ path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
2259
+ body: {}
2260
+ };
2261
+ });
2262
+ const body = options && options.transaction && requests.length > 1 ? {
2263
+ requests,
2264
+ transaction: true
2265
+ } : {
2266
+ requests
2267
+ };
2236
2268
  deleteCompleted = deleteCompleted.then(() => {
2237
- return RESTController.request('POST', 'batch', {
2238
- requests: batch.map(obj => {
2239
- return {
2240
- method: 'DELETE',
2241
- path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
2242
- body: {}
2243
- };
2244
- })
2245
- }, options).then(results => {
2269
+ return RESTController.request('POST', 'batch', body, options).then(results => {
2246
2270
  for (let i = 0; i < results.length; i++) {
2247
2271
  if (results[i] && results[i].hasOwnProperty('error')) {
2248
2272
  const err = new _ParseError.default(results[i].error.code, results[i].error.error);
@@ -2273,7 +2297,8 @@ const DefaultController = {
2273
2297
  return Promise.resolve(target);
2274
2298
  },
2275
2299
  save(target, options) {
2276
- const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2300
+ if (options && options.batchSize && options.transaction) return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.'));
2301
+ let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2277
2302
  const localDatastore = _CoreManager.default.getLocalDatastore();
2278
2303
  const mapIdForPin = {};
2279
2304
  const RESTController = _CoreManager.default.getRESTController();
@@ -2302,6 +2327,10 @@ const DefaultController = {
2302
2327
  pending.push(el);
2303
2328
  }
2304
2329
  });
2330
+ if (options && options.transaction && pending.length > 1) {
2331
+ if (pending.some(el => !(0, _canBeSerialized.default)(el))) return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a transactional batch containing an object with unserializable attributes.'));
2332
+ batchSize = pending.length;
2333
+ }
2305
2334
  return Promise.all(filesSaved).then(() => {
2306
2335
  let objectError = null;
2307
2336
  return (0, _promiseUtils.continueWhile)(() => {
@@ -2358,13 +2387,18 @@ const DefaultController = {
2358
2387
  });
2359
2388
  (0, _promiseUtils.when)(batchReady).then(() => {
2360
2389
  // Kick off the batch request
2361
- return RESTController.request('POST', 'batch', {
2362
- requests: batch.map(obj => {
2363
- const params = obj._getSaveParams();
2364
- params.path = getServerUrlPath() + params.path;
2365
- return params;
2366
- })
2367
- }, options);
2390
+ const requests = batch.map(obj => {
2391
+ const params = obj._getSaveParams();
2392
+ params.path = getServerUrlPath() + params.path;
2393
+ return params;
2394
+ });
2395
+ const body = options && options.transaction && requests.length > 1 ? {
2396
+ requests,
2397
+ transaction: true
2398
+ } : {
2399
+ requests
2400
+ };
2401
+ return RESTController.request('POST', 'batch', body, options);
2368
2402
  }).then(batchReturned.resolve, error => {
2369
2403
  batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
2370
2404
  });
@@ -12,7 +12,7 @@ var config = {
12
12
  SERVER_AUTH_TOKEN: null,
13
13
  LIVEQUERY_SERVER_URL: null,
14
14
  ENCRYPTED_KEY: null,
15
- VERSION: 'js' + "5.3.0-alpha.3",
15
+ VERSION: 'js' + "5.3.0-alpha.4",
16
16
  APPLICATION_ID: null,
17
17
  JAVASCRIPT_KEY: null,
18
18
  MASTER_KEY: null,
@@ -8,8 +8,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
12
11
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
15
15
  var _ParseError = _interopRequireDefault(require("./ParseError"));
@@ -25,6 +25,12 @@ function _isNativeReflectConstruct() {
25
25
  return !!t;
26
26
  })();
27
27
  }
28
+ function _superPropGet(t, e, o, r) {
29
+ var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), e, o);
30
+ return 2 & r && "function" == typeof p ? function (t) {
31
+ return p.apply(o, t);
32
+ } : p;
33
+ }
28
34
  var DEVICE_TYPES = {
29
35
  IOS: 'ios',
30
36
  MACOS: 'macos',
@@ -119,7 +125,7 @@ var ParseInstallation = function (_ParseObject) {
119
125
  args[_key] = arguments[_key];
120
126
  }
121
127
  try {
122
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseInstallation.prototype), "fetch", this).apply(this, args);
128
+ yield _superPropGet(ParseInstallation, "fetch", this, 1).apply(this, args);
123
129
  } catch (e) {
124
130
  if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
125
131
  throw e;
@@ -127,7 +133,7 @@ var ParseInstallation = function (_ParseObject) {
127
133
  delete this.id;
128
134
  this._getId();
129
135
  this._markAllFieldsDirty();
130
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseInstallation.prototype), "save", this).apply(this, args);
136
+ yield _superPropGet(ParseInstallation, "save", this, 1).apply(this, args);
131
137
  }
132
138
  yield _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
133
139
  return this;
@@ -145,7 +151,7 @@ var ParseInstallation = function (_ParseObject) {
145
151
  args[_key2] = arguments[_key2];
146
152
  }
147
153
  try {
148
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseInstallation.prototype), "save", this).apply(this, args);
154
+ yield _superPropGet(ParseInstallation, "save", this, 1).apply(this, args);
149
155
  } catch (e) {
150
156
  if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
151
157
  throw e;
@@ -153,7 +159,7 @@ var ParseInstallation = function (_ParseObject) {
153
159
  delete this.id;
154
160
  this._getId();
155
161
  this._markAllFieldsDirty();
156
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseInstallation.prototype), "save", this).apply(this, args);
162
+ yield _superPropGet(ParseInstallation, "save", this, 1).apply(this, args);
157
163
  }
158
164
  yield _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
159
165
  return this;
@@ -896,6 +896,23 @@ var ParseObject = function () {
896
896
  }
897
897
  var controller = _CoreManager.default.getObjectController();
898
898
  var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
899
+ if (unsaved && unsaved.length && options.transaction === true && unsaved.some(function (el) {
900
+ return el instanceof ParseObject;
901
+ })) {
902
+ saveOptions.transaction = options.transaction;
903
+ var unsavedFiles = [];
904
+ var unsavedObjects = [];
905
+ unsaved.forEach(function (el) {
906
+ if (el instanceof _ParseFile.default) unsavedFiles.push(el);else unsavedObjects.push(el);
907
+ });
908
+ unsavedObjects.push(this);
909
+ var filePromise = unsavedFiles.length ? controller.save(unsavedFiles, saveOptions) : Promise.resolve();
910
+ return filePromise.then(function () {
911
+ return controller.save(unsavedObjects, saveOptions);
912
+ }).then(function (savedOjbects) {
913
+ return savedOjbects.pop();
914
+ });
915
+ }
899
916
  return controller.save(unsaved, saveOptions).then(function () {
900
917
  return controller.save(_this, saveOptions);
901
918
  });
@@ -1082,6 +1099,9 @@ var ParseObject = function () {
1082
1099
  if (options.hasOwnProperty('sessionToken')) {
1083
1100
  destroyOptions.sessionToken = options.sessionToken;
1084
1101
  }
1102
+ if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1103
+ destroyOptions.transaction = options.transaction;
1104
+ }
1085
1105
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1086
1106
  destroyOptions.batchSize = options.batchSize;
1087
1107
  }
@@ -1101,6 +1121,9 @@ var ParseObject = function () {
1101
1121
  if (options.hasOwnProperty('sessionToken')) {
1102
1122
  saveOptions.sessionToken = options.sessionToken;
1103
1123
  }
1124
+ if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1125
+ saveOptions.transaction = options.transaction;
1126
+ }
1104
1127
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1105
1128
  saveOptions.batchSize = options.batchSize;
1106
1129
  }
@@ -1437,10 +1460,12 @@ var DefaultController = {
1437
1460
  },
1438
1461
  destroy: function () {
1439
1462
  var _destroy = (0, _asyncToGenerator2.default)(function* (target, options) {
1463
+ if (options && options.batchSize && options.transaction) throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.');
1440
1464
  var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
1441
1465
  var localDatastore = _CoreManager.default.getLocalDatastore();
1442
1466
  var RESTController = _CoreManager.default.getRESTController();
1443
1467
  if (Array.isArray(target)) {
1468
+ if (options && options.transaction && target.length > 1) batchSize = target.length;
1444
1469
  if (target.length < 1) {
1445
1470
  return Promise.resolve([]);
1446
1471
  }
@@ -1460,16 +1485,21 @@ var DefaultController = {
1460
1485
  var deleteCompleted = Promise.resolve();
1461
1486
  var errors = [];
1462
1487
  batches.forEach(function (batch) {
1488
+ var requests = batch.map(function (obj) {
1489
+ return {
1490
+ method: 'DELETE',
1491
+ path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
1492
+ body: {}
1493
+ };
1494
+ });
1495
+ var body = options && options.transaction && requests.length > 1 ? {
1496
+ requests: requests,
1497
+ transaction: true
1498
+ } : {
1499
+ requests: requests
1500
+ };
1463
1501
  deleteCompleted = deleteCompleted.then(function () {
1464
- return RESTController.request('POST', 'batch', {
1465
- requests: batch.map(function (obj) {
1466
- return {
1467
- method: 'DELETE',
1468
- path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
1469
- body: {}
1470
- };
1471
- })
1472
- }, options).then(function (results) {
1502
+ return RESTController.request('POST', 'batch', body, options).then(function (results) {
1473
1503
  for (var i = 0; i < results.length; i++) {
1474
1504
  if (results[i] && results[i].hasOwnProperty('error')) {
1475
1505
  var err = new _ParseError.default(results[i].error.code, results[i].error.error);
@@ -1505,6 +1535,7 @@ var DefaultController = {
1505
1535
  return destroy;
1506
1536
  }(),
1507
1537
  save: function (target, options) {
1538
+ if (options && options.batchSize && options.transaction) return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.'));
1508
1539
  var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
1509
1540
  var localDatastore = _CoreManager.default.getLocalDatastore();
1510
1541
  var mapIdForPin = {};
@@ -1534,6 +1565,12 @@ var DefaultController = {
1534
1565
  pending.push(el);
1535
1566
  }
1536
1567
  });
1568
+ if (options && options.transaction && pending.length > 1) {
1569
+ if (pending.some(function (el) {
1570
+ return !(0, _canBeSerialized.default)(el);
1571
+ })) return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a transactional batch containing an object with unserializable attributes.'));
1572
+ batchSize = pending.length;
1573
+ }
1537
1574
  return Promise.all(filesSaved).then(function () {
1538
1575
  var objectError = null;
1539
1576
  return (0, _promiseUtils.continueWhile)(function () {
@@ -1586,13 +1623,18 @@ var DefaultController = {
1586
1623
  batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), task));
1587
1624
  });
1588
1625
  (0, _promiseUtils.when)(batchReady).then(function () {
1589
- return RESTController.request('POST', 'batch', {
1590
- requests: batch.map(function (obj) {
1591
- var params = obj._getSaveParams();
1592
- params.path = getServerUrlPath() + params.path;
1593
- return params;
1594
- })
1595
- }, options);
1626
+ var requests = batch.map(function (obj) {
1627
+ var params = obj._getSaveParams();
1628
+ params.path = getServerUrlPath() + params.path;
1629
+ return params;
1630
+ });
1631
+ var body = options && options.transaction && requests.length > 1 ? {
1632
+ requests: requests,
1633
+ transaction: true
1634
+ } : {
1635
+ requests: requests
1636
+ };
1637
+ return RESTController.request('POST', 'batch', body, options);
1596
1638
  }).then(batchReturned.resolve, function (error) {
1597
1639
  batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
1598
1640
  });
@@ -6,8 +6,8 @@ exports.default = void 0;
6
6
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
7
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
8
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
9
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
10
9
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
10
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
11
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
12
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
13
13
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
@@ -24,6 +24,12 @@ function _isNativeReflectConstruct() {
24
24
  return !!t;
25
25
  })();
26
26
  }
27
+ function _superPropGet(t, e, o, r) {
28
+ var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), e, o);
29
+ return 2 & r && "function" == typeof p ? function (t) {
30
+ return p.apply(o, t);
31
+ } : p;
32
+ }
27
33
  var ParseRole = function (_ParseObject) {
28
34
  function ParseRole(name, acl) {
29
35
  var _this;
@@ -74,7 +80,7 @@ var ParseRole = function (_ParseObject) {
74
80
  }, {
75
81
  key: "validate",
76
82
  value: function (attrs, options) {
77
- var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this)(attrs, options);
83
+ var isInvalid = _superPropGet(ParseRole, "validate", this, 1)(attrs, options);
78
84
  if (isInvalid) {
79
85
  return isInvalid;
80
86
  }
@@ -7,8 +7,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
7
7
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
8
8
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
9
9
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
10
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
11
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
12
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
13
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
14
14
  var _isRevocableSession = _interopRequireDefault(require("./isRevocableSession"));
@@ -26,6 +26,12 @@ function _isNativeReflectConstruct() {
26
26
  return !!t;
27
27
  })();
28
28
  }
29
+ function _superPropGet(t, e, o, r) {
30
+ var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), e, o);
31
+ return 2 & r && "function" == typeof p ? function (t) {
32
+ return p.apply(o, t);
33
+ } : p;
34
+ }
29
35
  var CURRENT_USER_KEY = 'currentUser';
30
36
  var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
31
37
  var currentUserCacheMatchesDisk = false;
@@ -356,7 +362,7 @@ var ParseUser = function (_ParseObject) {
356
362
  for (var _len = arguments.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
357
363
  args[_key4] = arguments[_key4];
358
364
  }
359
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args);
365
+ yield _superPropGet(ParseUser, "save", this, 1).apply(this, args);
360
366
  var current = yield this.isCurrentAsync();
361
367
  if (current) {
362
368
  return _CoreManager.default.getUserController().updateUserOnDisk(this);
@@ -375,7 +381,7 @@ var ParseUser = function (_ParseObject) {
375
381
  for (var _len2 = arguments.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
376
382
  args[_key5] = arguments[_key5];
377
383
  }
378
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args);
384
+ yield _superPropGet(ParseUser, "destroy", this, 1).apply(this, args);
379
385
  var current = yield this.isCurrentAsync();
380
386
  if (current) {
381
387
  return _CoreManager.default.getUserController().removeUserFromDisk();
@@ -394,7 +400,7 @@ var ParseUser = function (_ParseObject) {
394
400
  for (var _len3 = arguments.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
395
401
  args[_key6] = arguments[_key6];
396
402
  }
397
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args);
403
+ yield _superPropGet(ParseUser, "fetch", this, 1).apply(this, args);
398
404
  var current = yield this.isCurrentAsync();
399
405
  if (current) {
400
406
  return _CoreManager.default.getUserController().updateUserOnDisk(this);
@@ -413,7 +419,7 @@ var ParseUser = function (_ParseObject) {
413
419
  for (var _len4 = arguments.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
414
420
  args[_key7] = arguments[_key7];
415
421
  }
416
- yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args);
422
+ yield _superPropGet(ParseUser, "fetchWithInclude", this, 1).apply(this, args);
417
423
  var current = yield this.isCurrentAsync();
418
424
  if (current) {
419
425
  return _CoreManager.default.getUserController().updateUserOnDisk(this);
@@ -19,7 +19,7 @@ const config = {
19
19
  SERVER_AUTH_TOKEN: null,
20
20
  LIVEQUERY_SERVER_URL: null,
21
21
  ENCRYPTED_KEY: null,
22
- VERSION: 'js' + "5.3.0-alpha.3",
22
+ VERSION: 'js' + "5.3.0-alpha.4",
23
23
  APPLICATION_ID: null,
24
24
  JAVASCRIPT_KEY: null,
25
25
  MASTER_KEY: null,