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,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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parse",
3
- "version": "5.3.0-alpha.3",
3
+ "version": "5.3.0-alpha.4",
4
4
  "description": "Parse JavaScript SDK",
5
5
  "homepage": "https://parseplatform.org",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "react-native": false
30
30
  },
31
31
  "dependencies": {
32
- "@babel/runtime-corejs3": "7.24.8",
32
+ "@babel/runtime-corejs3": "7.25.7",
33
33
  "idb-keyval": "6.2.1",
34
34
  "react-native-crypto-js": "1.0.0",
35
35
  "uuid": "10.0.0",
@@ -37,20 +37,20 @@
37
37
  "xmlhttprequest": "1.8.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@babel/core": "7.24.9",
40
+ "@babel/core": "7.25.8",
41
41
  "@babel/plugin-proposal-class-properties": "7.18.6",
42
42
  "@babel/plugin-transform-runtime": "7.24.7",
43
- "@babel/preset-env": "7.25.3",
44
- "@babel/preset-react": "7.24.7",
45
- "@babel/preset-typescript": "7.24.7",
43
+ "@babel/preset-env": "7.25.8",
44
+ "@babel/preset-react": "7.25.7",
45
+ "@babel/preset-typescript": "7.25.7",
46
46
  "@definitelytyped/dtslint": "0.0.163",
47
- "@eslint/js": "9.7.0",
47
+ "@eslint/js": "9.12.0",
48
48
  "@parse/minami": "git+https://github.com/parse-community/minami#main",
49
49
  "@saithodev/semantic-release-backmerge": "4.0.1",
50
50
  "@semantic-release/changelog": "6.0.3",
51
51
  "@semantic-release/commit-analyzer": "13.0.0",
52
52
  "@semantic-release/git": "10.0.1",
53
- "@semantic-release/github": "10.1.1",
53
+ "@semantic-release/github": "11.0.0",
54
54
  "@semantic-release/npm": "12.0.1",
55
55
  "@semantic-release/release-notes-generator": "14.0.1",
56
56
  "@types/facebook-js-sdk": "3.3.11",
@@ -60,11 +60,11 @@
60
60
  "babel-plugin-transform-inline-environment-variables": "0.4.4",
61
61
  "browserify": "17.0.0",
62
62
  "codecov": "3.8.3",
63
- "core-js": "3.37.1",
63
+ "core-js": "3.38.1",
64
64
  "cross-env": "7.0.2",
65
- "eslint": "9.9.1",
66
- "eslint-plugin-jsdoc": "50.0.0",
67
- "express": "4.21.0",
65
+ "eslint": "9.12.0",
66
+ "eslint-plugin-jsdoc": "50.3.1",
67
+ "express": "4.21.1",
68
68
  "gulp": "5.0.0",
69
69
  "gulp-babel": "8.0.0",
70
70
  "gulp-derequire": "3.0.0",
@@ -72,23 +72,23 @@
72
72
  "gulp-rename": "2.0.0",
73
73
  "gulp-uglify": "3.0.2",
74
74
  "gulp-watch": "5.0.1",
75
- "husky": "9.1.5",
76
- "jasmine": "5.2.0",
75
+ "husky": "9.1.6",
76
+ "jasmine": "5.3.1",
77
77
  "jasmine-reporters": "2.5.2",
78
78
  "jasmine-spec-reporter": "7.0.0",
79
79
  "jest": "29.7.0",
80
80
  "jest-environment-jsdom": "29.7.0",
81
81
  "jsdoc": "4.0.3",
82
82
  "jsdoc-babel": "0.5.0",
83
- "lint-staged": "15.2.7",
84
- "madge": "7.0.0",
83
+ "lint-staged": "15.2.10",
84
+ "madge": "8.0.0",
85
85
  "metro-react-native-babel-preset": "0.77.0",
86
- "mongodb-runner": "5.6.4",
87
- "parse-server": "7.2.0",
86
+ "mongodb-runner": "5.7.0",
87
+ "parse-server": "7.3.0",
88
88
  "prettier": "3.3.3",
89
89
  "puppeteer": "20.4.0",
90
90
  "regenerator-runtime": "0.14.1",
91
- "semantic-release": "24.0.0",
91
+ "semantic-release": "24.1.2",
92
92
  "typescript-eslint": "8.0.0-alpha.10",
93
93
  "vinyl-source-stream": "2.0.0"
94
94
  },