parse 5.3.0-alpha.2 → 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.
Files changed (52) hide show
  1. package/dist/parse.js +625 -557
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +625 -555
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/CoreManager.js +1 -1
  6. package/lib/browser/FacebookUtils.js +1 -1
  7. package/lib/browser/LocalDatastoreController.react-native.js +1 -1
  8. package/lib/browser/OfflineQuery.js +5 -9
  9. package/lib/browser/Parse.js +1 -3
  10. package/lib/browser/ParseConfig.js +1 -1
  11. package/lib/browser/ParseFile.js +0 -1
  12. package/lib/browser/ParseObject.js +54 -19
  13. package/lib/browser/ParseQuery.js +1 -1
  14. package/lib/browser/ParseUser.js +1 -1
  15. package/lib/browser/RESTController.js +2 -2
  16. package/lib/browser/StorageController.weapp.js +1 -1
  17. package/lib/node/CoreManager.js +1 -1
  18. package/lib/node/FacebookUtils.js +1 -1
  19. package/lib/node/LocalDatastoreController.react-native.js +1 -1
  20. package/lib/node/OfflineQuery.js +5 -9
  21. package/lib/node/Parse.js +1 -1
  22. package/lib/node/ParseConfig.js +1 -1
  23. package/lib/node/ParseFile.js +0 -1
  24. package/lib/node/ParseObject.js +53 -19
  25. package/lib/node/ParseQuery.js +1 -1
  26. package/lib/node/ParseUser.js +1 -1
  27. package/lib/node/RESTController.js +2 -2
  28. package/lib/node/StorageController.weapp.js +1 -1
  29. package/lib/react-native/CoreManager.js +1 -1
  30. package/lib/react-native/LocalDatastoreController.react-native.js +1 -1
  31. package/lib/react-native/OfflineQuery.js +5 -5
  32. package/lib/react-native/ParseConfig.js +1 -1
  33. package/lib/react-native/ParseInstallation.js +11 -5
  34. package/lib/react-native/ParseObject.js +60 -17
  35. package/lib/react-native/ParseQuery.js +1 -1
  36. package/lib/react-native/ParseRole.js +8 -2
  37. package/lib/react-native/ParseUser.js +12 -6
  38. package/lib/react-native/RESTController.js +11 -10
  39. package/lib/react-native/StorageController.weapp.js +1 -1
  40. package/lib/weapp/CoreManager.js +1 -1
  41. package/lib/weapp/FacebookUtils.js +1 -1
  42. package/lib/weapp/LocalDatastoreController.react-native.js +1 -1
  43. package/lib/weapp/OfflineQuery.js +5 -9
  44. package/lib/weapp/Parse.js +1 -1
  45. package/lib/weapp/ParseConfig.js +1 -1
  46. package/lib/weapp/ParseFile.js +0 -1
  47. package/lib/weapp/ParseObject.js +54 -19
  48. package/lib/weapp/ParseQuery.js +1 -1
  49. package/lib/weapp/ParseUser.js +1 -1
  50. package/lib/weapp/RESTController.js +2 -2
  51. package/lib/weapp/StorageController.weapp.js +1 -1
  52. package/package.json +25 -23
@@ -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"));
@@ -262,7 +263,7 @@ class ParseObject {
262
263
  if (objectCache[attr] !== stringified) {
263
264
  dirty[attr] = val;
264
265
  }
265
- } catch (e) {
266
+ } catch (_) {
266
267
  // Error occurred, possibly by a nested unsaved pointer in a mutable container
267
268
  // No matter how it happened, it indicates a change in the attribute
268
269
  dirty[attr] = val;
@@ -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
  });
@@ -342,7 +342,7 @@ class ParseQuery {
342
342
  _OfflineQuery.default.validateQuery(this);
343
343
  const localDatastore = _CoreManager.default.getLocalDatastore();
344
344
  const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
345
- let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, index, arr) => {
345
+ let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, _index, arr) => {
346
346
  const object = _ParseObject.default.fromJSON(json, false);
347
347
  if (json._localId && !json.objectId) {
348
348
  object._localId = json._localId;
@@ -125,7 +125,7 @@ class ParseUser extends _ParseObject.default {
125
125
  reject(error);
126
126
  });
127
127
  },
128
- error: (provider, error) => {
128
+ error: (_provider, error) => {
129
129
  reject(error);
130
130
  }
131
131
  });
@@ -29,7 +29,7 @@ let useXDomainRequest = false;
29
29
  if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
30
30
  useXDomainRequest = true;
31
31
  }
32
- function ajaxIE9(method, url, data, headers, options) {
32
+ function ajaxIE9(method, url, data, _headers, options) {
33
33
  return new _promise.default((resolve, reject) => {
34
34
  // @ts-ignore
35
35
  const xdr = new XDomainRequest();
@@ -292,7 +292,7 @@ const RESTController = {
292
292
  try {
293
293
  const errorJSON = JSON.parse(response.responseText);
294
294
  error = new _ParseError.default(errorJSON.code, errorJSON.error);
295
- } catch (e) {
295
+ } catch (_) {
296
296
  // If we fail to parse the error text, that's okay.
297
297
  error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
298
298
  }
@@ -17,7 +17,7 @@ const StorageController = {
17
17
  try {
18
18
  // @ts-ignore
19
19
  wx.setStorageSync(path, value);
20
- } catch (e) {
20
+ } catch (_) {
21
21
  // Quota exceeded
22
22
  }
23
23
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parse",
3
- "version": "5.3.0-alpha.2",
3
+ "version": "5.3.0-alpha.4",
4
4
  "description": "Parse JavaScript SDK",
5
5
  "homepage": "https://parseplatform.org",
6
6
  "keywords": [
@@ -29,27 +29,28 @@
29
29
  "react-native": false
30
30
  },
31
31
  "dependencies": {
32
- "@babel/runtime-corejs3": "7.24.6",
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",
36
- "ws": "8.17.1",
36
+ "ws": "8.18.0",
37
37
  "xmlhttprequest": "1.8.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@babel/core": "7.24.7",
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.24.7",
44
- "@babel/preset-react": "7.22.5",
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.12.0",
47
48
  "@parse/minami": "git+https://github.com/parse-community/minami#main",
48
49
  "@saithodev/semantic-release-backmerge": "4.0.1",
49
50
  "@semantic-release/changelog": "6.0.3",
50
51
  "@semantic-release/commit-analyzer": "13.0.0",
51
52
  "@semantic-release/git": "10.0.1",
52
- "@semantic-release/github": "10.0.7",
53
+ "@semantic-release/github": "11.0.0",
53
54
  "@semantic-release/npm": "12.0.1",
54
55
  "@semantic-release/release-notes-generator": "14.0.1",
55
56
  "@types/facebook-js-sdk": "3.3.11",
@@ -59,11 +60,11 @@
59
60
  "babel-plugin-transform-inline-environment-variables": "0.4.4",
60
61
  "browserify": "17.0.0",
61
62
  "codecov": "3.8.3",
62
- "core-js": "3.37.1",
63
+ "core-js": "3.38.1",
63
64
  "cross-env": "7.0.2",
64
- "eslint": "8.56.0",
65
- "eslint-plugin-jsdoc": "48.5.0",
66
- "express": "4.18.2",
65
+ "eslint": "9.12.0",
66
+ "eslint-plugin-jsdoc": "50.3.1",
67
+ "express": "4.21.1",
67
68
  "gulp": "5.0.0",
68
69
  "gulp-babel": "8.0.0",
69
70
  "gulp-derequire": "3.0.0",
@@ -71,23 +72,24 @@
71
72
  "gulp-rename": "2.0.0",
72
73
  "gulp-uglify": "3.0.2",
73
74
  "gulp-watch": "5.0.1",
74
- "husky": "9.0.11",
75
- "jasmine": "5.1.0",
75
+ "husky": "9.1.6",
76
+ "jasmine": "5.3.1",
76
77
  "jasmine-reporters": "2.5.2",
77
78
  "jasmine-spec-reporter": "7.0.0",
78
79
  "jest": "29.7.0",
79
80
  "jest-environment-jsdom": "29.7.0",
80
81
  "jsdoc": "4.0.3",
81
82
  "jsdoc-babel": "0.5.0",
82
- "lint-staged": "15.2.7",
83
- "madge": "7.0.0",
83
+ "lint-staged": "15.2.10",
84
+ "madge": "8.0.0",
84
85
  "metro-react-native-babel-preset": "0.77.0",
85
- "mongodb-runner": "5.6.2",
86
- "parse-server": "7.1.0",
87
- "prettier": "3.3.2",
86
+ "mongodb-runner": "5.7.0",
87
+ "parse-server": "7.3.0",
88
+ "prettier": "3.3.3",
88
89
  "puppeteer": "20.4.0",
89
90
  "regenerator-runtime": "0.14.1",
90
- "semantic-release": "24.0.0",
91
+ "semantic-release": "24.1.2",
92
+ "typescript-eslint": "8.0.0-alpha.10",
91
93
  "vinyl-source-stream": "2.0.0"
92
94
  },
93
95
  "optionalDependencies": {
@@ -102,9 +104,9 @@
102
104
  "test:mongodb:runnerstart": "mongodb-runner start -- --port 27017",
103
105
  "test:types": "dtslint --expectOnly types",
104
106
  "posttest:mongodb": "mongodb-runner stop --all",
105
- "lint": "eslint --cache src/ integration/ --ext .js --ext .ts",
106
- "lint:fix": "eslint --fix --cache src/ integration/ --ext .js --ext .ts",
107
- "lint:types": "dtslint types",
107
+ "lint": "eslint --cache src/ integration/",
108
+ "lint:fix": "eslint --fix --cache src/ integration/",
109
+ "lint:types": "eslint --cache types/",
108
110
  "watch": "cross-env PARSE_BUILD=${PARSE_BUILD} gulp watch",
109
111
  "watch:browser": "cross-env PARSE_BUILD=browser npm run watch",
110
112
  "watch:node": "cross-env PARSE_BUILD=node npm run watch",