parse 4.3.0 → 4.3.1-alpha.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.
Files changed (49) hide show
  1. package/dist/parse.js +147 -97
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +1083 -698
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Cloud.js +22 -3
  6. package/lib/browser/CoreManager.js +1 -1
  7. package/lib/browser/IndexedDBStorageController.js +25 -20
  8. package/lib/browser/ObjectStateMutations.js +11 -17
  9. package/lib/browser/Parse.js +2 -1
  10. package/lib/browser/ParseObject.js +6 -2
  11. package/lib/browser/ParseOp.js +13 -20
  12. package/lib/browser/Push.js +20 -1
  13. package/lib/browser/RESTController.js +18 -14
  14. package/lib/browser/SingleInstanceStateController.js +6 -4
  15. package/lib/browser/UniqueInstanceStateController.js +2 -2
  16. package/lib/node/Cloud.js +5 -2
  17. package/lib/node/CoreManager.js +1 -1
  18. package/lib/node/IndexedDBStorageController.js +24 -19
  19. package/lib/node/ObjectStateMutations.js +6 -12
  20. package/lib/node/Parse.js +1 -0
  21. package/lib/node/ParseObject.js +6 -2
  22. package/lib/node/ParseOp.js +2 -8
  23. package/lib/node/Push.js +5 -2
  24. package/lib/node/RESTController.js +13 -9
  25. package/lib/node/SingleInstanceStateController.js +10 -4
  26. package/lib/node/UniqueInstanceStateController.js +2 -2
  27. package/lib/react-native/Cloud.js +15 -5
  28. package/lib/react-native/CoreManager.js +1 -1
  29. package/lib/react-native/IndexedDBStorageController.js +24 -20
  30. package/lib/react-native/ObjectStateMutations.js +11 -17
  31. package/lib/react-native/Parse.js +1 -0
  32. package/lib/react-native/ParseObject.js +6 -2
  33. package/lib/react-native/ParseOp.js +2 -8
  34. package/lib/react-native/Push.js +13 -3
  35. package/lib/react-native/RESTController.js +13 -9
  36. package/lib/react-native/SingleInstanceStateController.js +4 -2
  37. package/lib/react-native/UniqueInstanceStateController.js +2 -2
  38. package/lib/weapp/Cloud.js +22 -3
  39. package/lib/weapp/CoreManager.js +1 -1
  40. package/lib/weapp/IndexedDBStorageController.js +25 -20
  41. package/lib/weapp/ObjectStateMutations.js +11 -17
  42. package/lib/weapp/Parse.js +1 -0
  43. package/lib/weapp/ParseObject.js +6 -2
  44. package/lib/weapp/ParseOp.js +13 -20
  45. package/lib/weapp/Push.js +20 -1
  46. package/lib/weapp/RESTController.js +18 -14
  47. package/lib/weapp/SingleInstanceStateController.js +6 -4
  48. package/lib/weapp/UniqueInstanceStateController.js +2 -2
  49. package/package.json +7 -7
@@ -9,8 +9,10 @@ exports.getJobStatus = getJobStatus;
9
9
  exports.getJobsData = getJobsData;
10
10
  exports.run = run;
11
11
  exports.startJob = startJob;
12
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
12
13
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
13
14
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
15
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
14
16
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
15
17
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
16
18
  var _decode = _interopRequireDefault(require("./decode"));
@@ -133,9 +135,26 @@ var DefaultController = {
133
135
  return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
134
136
  },
135
137
  startJob: function (name, data, options /*: RequestOptions*/) {
136
- var RESTController = _CoreManager.default.getRESTController();
137
- var payload = (0, _encode.default)(data, true);
138
- return RESTController.request('POST', 'jobs/' + name, payload, options);
138
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
139
+ var _response$_headers;
140
+ var RESTController, payload, response;
141
+ return _regenerator.default.wrap(function (_context) {
142
+ while (1) switch (_context.prev = _context.next) {
143
+ case 0:
144
+ RESTController = _CoreManager.default.getRESTController();
145
+ payload = (0, _encode.default)(data, true);
146
+ options.returnStatus = true;
147
+ _context.next = 5;
148
+ return RESTController.request('POST', 'jobs/' + name, payload, options);
149
+ case 5:
150
+ response = _context.sent;
151
+ return _context.abrupt("return", (_response$_headers = response._headers) === null || _response$_headers === void 0 ? void 0 : _response$_headers['X-Parse-Job-Status-Id']);
152
+ case 7:
153
+ case "end":
154
+ return _context.stop();
155
+ }
156
+ }, _callee);
157
+ }))();
139
158
  }
140
159
  };
141
160
  _CoreManager.default.setCloudController(DefaultController);
@@ -187,7 +187,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
187
187
  SERVER_AUTH_TOKEN: null,
188
188
  LIVEQUERY_SERVER_URL: null,
189
189
  ENCRYPTED_KEY: null,
190
- VERSION: 'js' + "4.3.0",
190
+ VERSION: 'js' + "4.3.1-alpha.2",
191
191
  APPLICATION_ID: null,
192
192
  JAVASCRIPT_KEY: null,
193
193
  MASTER_KEY: null,
@@ -8,26 +8,31 @@ var _idbKeyval = require("idb-keyval");
8
8
  /* global window */
9
9
 
10
10
  if (typeof window !== 'undefined' && window.indexedDB) {
11
- var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
12
- var IndexedDBStorageController = {
13
- async: 1,
14
- getItemAsync: function (path /*: string*/) {
15
- return (0, _idbKeyval.get)(path, ParseStore);
16
- },
17
- setItemAsync: function (path /*: string*/, value /*: string*/) {
18
- return (0, _idbKeyval.set)(path, value, ParseStore);
19
- },
20
- removeItemAsync: function (path /*: string*/) {
21
- return (0, _idbKeyval.del)(path, ParseStore);
22
- },
23
- getAllKeysAsync: function () {
24
- return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
25
- },
26
- clear: function () {
27
- return (0, _idbKeyval.clear)(ParseStore);
28
- }
29
- };
30
- module.exports = IndexedDBStorageController;
11
+ try {
12
+ var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
13
+ var IndexedDBStorageController = {
14
+ async: 1,
15
+ getItemAsync: function (path /*: string*/) {
16
+ return (0, _idbKeyval.get)(path, ParseStore);
17
+ },
18
+ setItemAsync: function (path /*: string*/, value /*: string*/) {
19
+ return (0, _idbKeyval.set)(path, value, ParseStore);
20
+ },
21
+ removeItemAsync: function (path /*: string*/) {
22
+ return (0, _idbKeyval.del)(path, ParseStore);
23
+ },
24
+ getAllKeysAsync: function () {
25
+ return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
26
+ },
27
+ clear: function () {
28
+ return (0, _idbKeyval.clear)(ParseStore);
29
+ }
30
+ };
31
+ module.exports = IndexedDBStorageController;
32
+ } catch (_) {
33
+ // IndexedDB not accessible
34
+ module.exports = undefined;
35
+ }
31
36
  } else {
32
37
  // IndexedDB not supported
33
38
  module.exports = undefined;
@@ -116,16 +116,13 @@ function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
116
116
  }
117
117
  }
118
118
  }
119
- function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/, attr /*: string*/) /*: mixed*/{
119
+ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
120
120
  var value = serverData[attr];
121
121
  for (var i = 0; i < pendingOps.length; i++) {
122
122
  if (pendingOps[i][attr]) {
123
123
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
124
- if (id) {
125
- value = pendingOps[i][attr].applyTo(value, {
126
- className: className,
127
- id: id
128
- }, attr);
124
+ if (object.id) {
125
+ value = pendingOps[i][attr].applyTo(value, object, attr);
129
126
  }
130
127
  } else {
131
128
  value = pendingOps[i][attr].applyTo(value);
@@ -134,7 +131,7 @@ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<O
134
131
  }
135
132
  return value;
136
133
  }
137
- function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/) /*: AttributeMap*/{
134
+ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/) /*: AttributeMap*/{
138
135
  var data = {};
139
136
  for (var attr in serverData) {
140
137
  data[attr] = serverData[attr];
@@ -142,11 +139,8 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
142
139
  for (var i = 0; i < pendingOps.length; i++) {
143
140
  for (attr in pendingOps[i]) {
144
141
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
145
- if (id) {
146
- data[attr] = pendingOps[i][attr].applyTo(data[attr], {
147
- className: className,
148
- id: id
149
- }, attr);
142
+ if (object.id) {
143
+ data[attr] = pendingOps[i][attr].applyTo(data[attr], object, attr);
150
144
  }
151
145
  } else {
152
146
  if ((0, _includes.default)(attr).call(attr, '.')) {
@@ -155,15 +149,15 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
155
149
  var first = fields[0];
156
150
  var last = fields[fields.length - 1];
157
151
  data[first] = _objectSpread({}, serverData[first]);
158
- var object = _objectSpread({}, data);
152
+ var _object = _objectSpread({}, data);
159
153
  for (var _i = 0; _i < fields.length - 1; _i++) {
160
154
  var key = fields[_i];
161
- if (!(key in object)) {
162
- object[key] = {};
155
+ if (!(key in _object)) {
156
+ _object[key] = {};
163
157
  }
164
- object = object[key];
158
+ _object = _object[key];
165
159
  }
166
- object[last] = pendingOps[i][attr].applyTo(object[last]);
160
+ _object[last] = pendingOps[i][attr].applyTo(_object[last]);
167
161
  } else {
168
162
  data[attr] = pendingOps[i][attr].applyTo(data[attr]);
169
163
  }
@@ -14,6 +14,7 @@ var _decode2 = _interopRequireDefault(require("./decode"));
14
14
  var _encode2 = _interopRequireDefault(require("./encode"));
15
15
  var _CryptoController = _interopRequireDefault(require("./CryptoController"));
16
16
  var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
17
+ var _IndexedDBStorageController = _interopRequireDefault(require("./IndexedDBStorageController"));
17
18
  var _InstallationController = _interopRequireDefault(require("./InstallationController"));
18
19
  var ParseOp = _interopRequireWildcard(require("./ParseOp"));
19
20
  var _RESTController = _interopRequireDefault(require("./RESTController"));
@@ -154,6 +155,7 @@ var Parse /*: ParseType*/ = {
154
155
  _CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
155
156
  Parse.LiveQuery = new _ParseLiveQuery.default();
156
157
  _CoreManager.default.setIfNeeded('LiveQuery', Parse.LiveQuery);
158
+ Parse.IndexedDB = _CoreManager.default.setIfNeeded('IndexedDBStorageController', _IndexedDBStorageController.default);
157
159
  },
158
160
  /**
159
161
  * Call this method to set your AsyncStorage engine
@@ -385,7 +387,6 @@ var Parse /*: ParseType*/ = {
385
387
  return this.encryptedUser;
386
388
  }
387
389
  };
388
- Parse.IndexedDB = require('./IndexedDBStorageController');
389
390
  _CoreManager.default.setCryptoController(_CryptoController.default);
390
391
  _CoreManager.default.setInstallationController(_InstallationController.default);
391
392
  _CoreManager.default.setRESTController(_RESTController.default);
@@ -1473,7 +1473,7 @@ var ParseObject = /*#__PURE__*/function () {
1473
1473
  case 5:
1474
1474
  _context4.prev = 5;
1475
1475
  _context4.t0 = _context4["catch"](0);
1476
- if (!(_context4.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
1476
+ if (!(_context4.t0.code === _ParseError.default.CONNECTION_FAILED)) {
1477
1477
  _context4.next = 11;
1478
1478
  break;
1479
1479
  }
@@ -1639,7 +1639,7 @@ var ParseObject = /*#__PURE__*/function () {
1639
1639
  case 5:
1640
1640
  _context5.prev = 5;
1641
1641
  _context5.t0 = _context5["catch"](0);
1642
- if (!(_context5.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
1642
+ if (!(_context5.t0.code === _ParseError.default.CONNECTION_FAILED)) {
1643
1643
  _context5.next = 11;
1644
1644
  break;
1645
1645
  }
@@ -2913,6 +2913,8 @@ var DefaultController = {
2913
2913
  var objectId = responses[index].success.objectId;
2914
2914
  var status = responses[index]._status;
2915
2915
  delete responses[index]._status;
2916
+ delete responses[index]._headers;
2917
+ delete responses[index]._xhr;
2916
2918
  mapIdForPin[objectId] = obj._localId;
2917
2919
  obj._handleSaveResponse(responses[index].success, status);
2918
2920
  } else {
@@ -3008,6 +3010,8 @@ var DefaultController = {
3008
3010
  return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
3009
3011
  var status = response._status;
3010
3012
  delete response._status;
3013
+ delete response._headers;
3014
+ delete response._xhr;
3011
3015
  targetCopy._handleSaveResponse(response, status);
3012
3016
  }, function (error) {
3013
3017
  targetCopy._handleSaveError();
@@ -466,18 +466,11 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
466
466
  }
467
467
  }, {
468
468
  key: "applyTo",
469
- value: function (value /*: mixed*/, object /*:: ?: { className: string, id: ?string }*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
469
+ value: function (value /*: mixed*/, parent /*: ParseObject*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
470
470
  if (!value) {
471
- var _context3;
472
- if (!object || !key) {
471
+ if (!parent || !key) {
473
472
  throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
474
473
  }
475
- var parent = new _ParseObject.default(object.className);
476
- if (object.id && (0, _indexOf.default)(_context3 = object.id).call(_context3, 'local') === 0) {
477
- parent._localId = object.id;
478
- } else if (object.id) {
479
- parent.id = object.id;
480
- }
481
474
  var relation = new _ParseRelation.default(parent, key);
482
475
  relation.targetClassName = this._targetClassName;
483
476
  return relation;
@@ -507,31 +500,31 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
507
500
  } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
508
501
  return this;
509
502
  } else if (previous instanceof RelationOp) {
510
- var _context4, _context5, _context6, _context7, _context8, _context9;
503
+ var _context3, _context4, _context5, _context6, _context7, _context8;
511
504
  if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
512
505
  throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
513
506
  }
514
- var newAdd = (0, _concat.default)(_context4 = previous.relationsToAdd).call(_context4, []);
515
- (0, _forEach.default)(_context5 = this.relationsToRemove).call(_context5, function (r) {
507
+ var newAdd = (0, _concat.default)(_context3 = previous.relationsToAdd).call(_context3, []);
508
+ (0, _forEach.default)(_context4 = this.relationsToRemove).call(_context4, function (r) {
516
509
  var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
517
510
  if (index > -1) {
518
511
  (0, _splice.default)(newAdd).call(newAdd, index, 1);
519
512
  }
520
513
  });
521
- (0, _forEach.default)(_context6 = this.relationsToAdd).call(_context6, function (r) {
514
+ (0, _forEach.default)(_context5 = this.relationsToAdd).call(_context5, function (r) {
522
515
  var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
523
516
  if (index < 0) {
524
517
  newAdd.push(r);
525
518
  }
526
519
  });
527
- var newRemove = (0, _concat.default)(_context7 = previous.relationsToRemove).call(_context7, []);
528
- (0, _forEach.default)(_context8 = this.relationsToAdd).call(_context8, function (r) {
520
+ var newRemove = (0, _concat.default)(_context6 = previous.relationsToRemove).call(_context6, []);
521
+ (0, _forEach.default)(_context7 = this.relationsToAdd).call(_context7, function (r) {
529
522
  var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
530
523
  if (index > -1) {
531
524
  (0, _splice.default)(newRemove).call(newRemove, index, 1);
532
525
  }
533
526
  });
534
- (0, _forEach.default)(_context9 = this.relationsToRemove).call(_context9, function (r) {
527
+ (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, function (r) {
535
528
  var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
536
529
  if (index < 0) {
537
530
  newRemove.push(r);
@@ -558,16 +551,16 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
558
551
  var removes = null;
559
552
  var pointers = null;
560
553
  if (this.relationsToAdd.length > 0) {
561
- var _context10;
562
- pointers = (0, _map.default)(_context10 = this.relationsToAdd).call(_context10, idToPointer);
554
+ var _context9;
555
+ pointers = (0, _map.default)(_context9 = this.relationsToAdd).call(_context9, idToPointer);
563
556
  adds = {
564
557
  __op: 'AddRelation',
565
558
  objects: pointers
566
559
  };
567
560
  }
568
561
  if (this.relationsToRemove.length > 0) {
569
- var _context11;
570
- pointers = (0, _map.default)(_context11 = this.relationsToRemove).call(_context11, idToPointer);
562
+ var _context10;
563
+ pointers = (0, _map.default)(_context10 = this.relationsToRemove).call(_context10, idToPointer);
571
564
  removes = {
572
565
  __op: 'RemoveRelation',
573
566
  objects: pointers
@@ -7,6 +7,8 @@ _Object$defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.getPushStatus = getPushStatus;
9
9
  exports.send = send;
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
10
12
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
11
13
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
12
14
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
@@ -105,7 +107,24 @@ function getPushStatus(pushStatusId /*: string*/) /*: Promise<string>*/{
105
107
  }
106
108
  var DefaultController = {
107
109
  send: function (data /*: PushData*/, options /*:: ?: FullOptions*/) {
108
- return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
110
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
111
+ var _response$_headers;
112
+ var response;
113
+ return _regenerator.default.wrap(function (_context) {
114
+ while (1) switch (_context.prev = _context.next) {
115
+ case 0:
116
+ options.returnStatus = true;
117
+ _context.next = 3;
118
+ return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
119
+ case 3:
120
+ response = _context.sent;
121
+ return _context.abrupt("return", (_response$_headers = response._headers) === null || _response$_headers === void 0 ? void 0 : _response$_headers['X-Parse-Push-Status-Id']);
122
+ case 5:
123
+ case "end":
124
+ return _context.stop();
125
+ }
126
+ }, _callee);
127
+ }))();
109
128
  }
110
129
  };
111
130
  _CoreManager.default.setPushController(DefaultController);
@@ -4,7 +4,7 @@ var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
5
  var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
6
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
- var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
7
+ var _forEachInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
8
8
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
9
  var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
10
10
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
@@ -14,6 +14,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/ty
14
14
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
15
15
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
16
16
  var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
17
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
17
18
  var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
18
19
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
19
20
  var _ParseError = _interopRequireDefault(require("./ParseError"));
@@ -30,11 +31,11 @@ function ownKeys(object, enumerableOnly) {
30
31
  }
31
32
  function _objectSpread(target) {
32
33
  for (var i = 1; i < arguments.length; i++) {
33
- var _context4, _context5;
34
+ var _context2, _context3;
34
35
  var source = null != arguments[i] ? arguments[i] : {};
35
- i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
36
+ i % 2 ? _forEachInstanceProperty2(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) {
36
37
  (0, _defineProperty2.default)(target, key, source[key]);
37
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) {
38
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context3 = ownKeys(Object(source))).call(_context3, function (key) {
38
39
  _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
39
40
  });
40
41
  }
@@ -136,14 +137,12 @@ var RESTController = {
136
137
  var response;
137
138
  try {
138
139
  response = JSON.parse(xhr.responseText);
139
- if (typeof xhr.getResponseHeader === 'function') {
140
- var _context2, _context3;
141
- if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
142
- response = xhr.getResponseHeader('x-parse-job-status-id');
143
- }
144
- if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
145
- response = xhr.getResponseHeader('x-parse-push-status-id');
146
- }
140
+ headers = {};
141
+ if (typeof xhr.getResponseHeader === 'function' && xhr.getResponseHeader('access-control-expose-headers')) {
142
+ var responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
143
+ (0, _forEach.default)(responseHeaders).call(responseHeaders, function (header) {
144
+ headers[header] = xhr.getResponseHeader(header.toLowerCase());
145
+ });
147
146
  }
148
147
  } catch (e) {
149
148
  promise.reject(e.toString());
@@ -151,6 +150,7 @@ var RESTController = {
151
150
  if (response) {
152
151
  promise.resolve({
153
152
  response: response,
153
+ headers: headers,
154
154
  status: xhr.status,
155
155
  xhr: xhr
156
156
  });
@@ -303,10 +303,14 @@ var RESTController = {
303
303
  var payloadString = (0, _stringify.default)(payload);
304
304
  return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
305
305
  var response = _ref.response,
306
- status = _ref.status;
306
+ status = _ref.status,
307
+ headers = _ref.headers,
308
+ xhr = _ref.xhr;
307
309
  if (options.returnStatus) {
308
310
  return _objectSpread(_objectSpread({}, response), {}, {
309
- _status: status
311
+ _status: status,
312
+ _headers: headers,
313
+ _xhr: xhr
310
314
  });
311
315
  } else {
312
316
  return response;
@@ -4,6 +4,7 @@ var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
4
4
  var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
5
5
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
6
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
7
8
  _Object$defineProperty(exports, "__esModule", {
8
9
  value: true
9
10
  });
@@ -25,6 +26,7 @@ exports.removeState = removeState;
25
26
  exports.setPendingOp = setPendingOp;
26
27
  exports.setServerData = setServerData;
27
28
  var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
29
+ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
28
30
  function _getRequireWildcardCache(nodeInterop) {
29
31
  if (typeof _WeakMap !== "function") return null;
30
32
  var cacheBabelInterop = new _WeakMap();
@@ -148,15 +150,15 @@ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
148
150
  }
149
151
  return {};
150
152
  }
151
- function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
153
+ function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
152
154
  var serverData = getServerData(obj);
153
155
  var pendingOps = getPendingOps(obj);
154
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
156
+ return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
155
157
  }
156
- function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
158
+ function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
157
159
  var serverData = getServerData(obj);
158
160
  var pendingOps = getPendingOps(obj);
159
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
161
+ return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
160
162
  }
161
163
  function commitServerChanges(obj /*: ObjectIdentifier*/, changes /*: AttributeMap*/) {
162
164
  var state = initializeState(obj);
@@ -147,12 +147,12 @@ function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
147
147
  function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
148
148
  var serverData = getServerData(obj);
149
149
  var pendingOps = getPendingOps(obj);
150
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
150
+ return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
151
151
  }
152
152
  function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
153
153
  var serverData = getServerData(obj);
154
154
  var pendingOps = getPendingOps(obj);
155
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
155
+ return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
156
156
  }
157
157
  function commitServerChanges(obj /*: ParseObject*/, changes /*: AttributeMap*/) {
158
158
  var state = initializeState(obj);
package/lib/node/Cloud.js CHANGED
@@ -132,10 +132,13 @@ const DefaultController = {
132
132
  const RESTController = _CoreManager.default.getRESTController();
133
133
  return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
134
134
  },
135
- startJob(name, data, options /*: RequestOptions*/) {
135
+ async startJob(name, data, options /*: RequestOptions*/) {
136
+ var _response$_headers;
136
137
  const RESTController = _CoreManager.default.getRESTController();
137
138
  const payload = (0, _encode.default)(data, true);
138
- return RESTController.request('POST', 'jobs/' + name, payload, options);
139
+ options.returnStatus = true;
140
+ const response = await RESTController.request('POST', 'jobs/' + name, payload, options);
141
+ return (_response$_headers = response._headers) === null || _response$_headers === void 0 ? void 0 : _response$_headers['X-Parse-Job-Status-Id'];
139
142
  }
140
143
  };
141
144
  _CoreManager.default.setCloudController(DefaultController);
@@ -183,7 +183,7 @@ const config /*: Config & { [key: string]: mixed }*/ = {
183
183
  SERVER_AUTH_TOKEN: null,
184
184
  LIVEQUERY_SERVER_URL: null,
185
185
  ENCRYPTED_KEY: null,
186
- VERSION: 'js' + "4.3.0",
186
+ VERSION: 'js' + "4.3.1-alpha.2",
187
187
  APPLICATION_ID: null,
188
188
  JAVASCRIPT_KEY: null,
189
189
  MASTER_KEY: null,
@@ -7,25 +7,30 @@ var _idbKeyval = require("idb-keyval");
7
7
  /* global window */
8
8
 
9
9
  if (typeof window !== 'undefined' && window.indexedDB) {
10
- const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
11
- module.exports = {
12
- async: 1,
13
- getItemAsync(path /*: string*/) {
14
- return (0, _idbKeyval.get)(path, ParseStore);
15
- },
16
- setItemAsync(path /*: string*/, value /*: string*/) {
17
- return (0, _idbKeyval.set)(path, value, ParseStore);
18
- },
19
- removeItemAsync(path /*: string*/) {
20
- return (0, _idbKeyval.del)(path, ParseStore);
21
- },
22
- getAllKeysAsync() {
23
- return (0, _idbKeyval.keys)(ParseStore);
24
- },
25
- clear() {
26
- return (0, _idbKeyval.clear)(ParseStore);
27
- }
28
- };
10
+ try {
11
+ const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
12
+ module.exports = {
13
+ async: 1,
14
+ getItemAsync(path /*: string*/) {
15
+ return (0, _idbKeyval.get)(path, ParseStore);
16
+ },
17
+ setItemAsync(path /*: string*/, value /*: string*/) {
18
+ return (0, _idbKeyval.set)(path, value, ParseStore);
19
+ },
20
+ removeItemAsync(path /*: string*/) {
21
+ return (0, _idbKeyval.del)(path, ParseStore);
22
+ },
23
+ getAllKeysAsync() {
24
+ return (0, _idbKeyval.keys)(ParseStore);
25
+ },
26
+ clear() {
27
+ return (0, _idbKeyval.clear)(ParseStore);
28
+ }
29
+ };
30
+ } catch (_) {
31
+ // IndexedDB not accessible
32
+ module.exports = undefined;
33
+ }
29
34
  } else {
30
35
  // IndexedDB not supported
31
36
  module.exports = undefined;
@@ -87,16 +87,13 @@ function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
87
87
  }
88
88
  }
89
89
  }
90
- function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/, attr /*: string*/) /*: mixed*/{
90
+ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
91
91
  let value = serverData[attr];
92
92
  for (let i = 0; i < pendingOps.length; i++) {
93
93
  if (pendingOps[i][attr]) {
94
94
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
95
- if (id) {
96
- value = pendingOps[i][attr].applyTo(value, {
97
- className: className,
98
- id: id
99
- }, attr);
95
+ if (object.id) {
96
+ value = pendingOps[i][attr].applyTo(value, object, attr);
100
97
  }
101
98
  } else {
102
99
  value = pendingOps[i][attr].applyTo(value);
@@ -105,7 +102,7 @@ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<O
105
102
  }
106
103
  return value;
107
104
  }
108
- function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/) /*: AttributeMap*/{
105
+ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/) /*: AttributeMap*/{
109
106
  const data = {};
110
107
  for (var attr in serverData) {
111
108
  data[attr] = serverData[attr];
@@ -113,11 +110,8 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
113
110
  for (let i = 0; i < pendingOps.length; i++) {
114
111
  for (attr in pendingOps[i]) {
115
112
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
116
- if (id) {
117
- data[attr] = pendingOps[i][attr].applyTo(data[attr], {
118
- className: className,
119
- id: id
120
- }, attr);
113
+ if (object.id) {
114
+ data[attr] = pendingOps[i][attr].applyTo(data[attr], object, attr);
121
115
  }
122
116
  } else {
123
117
  if (attr.includes('.')) {
package/lib/node/Parse.js CHANGED
@@ -8,6 +8,7 @@ var _decode2 = _interopRequireDefault(require("./decode"));
8
8
  var _encode2 = _interopRequireDefault(require("./encode"));
9
9
  var _CryptoController = _interopRequireDefault(require("./CryptoController"));
10
10
  var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
11
+ var _IndexedDBStorageController = _interopRequireDefault(require("./IndexedDBStorageController"));
11
12
  var _InstallationController = _interopRequireDefault(require("./InstallationController"));
12
13
  var ParseOp = _interopRequireWildcard(require("./ParseOp"));
13
14
  var _RESTController = _interopRequireDefault(require("./RESTController"));