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
@@ -1206,7 +1206,7 @@ class ParseObject {
1206
1206
  try {
1207
1207
  await this.save(null, options);
1208
1208
  } catch (e) {
1209
- if (e.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
1209
+ if (e.code === _ParseError.default.CONNECTION_FAILED) {
1210
1210
  await _EventuallyQueue.default.save(this, options);
1211
1211
  _EventuallyQueue.default.poll();
1212
1212
  }
@@ -1344,7 +1344,7 @@ class ParseObject {
1344
1344
  try {
1345
1345
  await this.destroy(options);
1346
1346
  } catch (e) {
1347
- if (e.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
1347
+ if (e.code === _ParseError.default.CONNECTION_FAILED) {
1348
1348
  await _EventuallyQueue.default.destroy(this, options);
1349
1349
  _EventuallyQueue.default.poll();
1350
1350
  }
@@ -2369,6 +2369,8 @@ const DefaultController = {
2369
2369
  const objectId = responses[index].success.objectId;
2370
2370
  const status = responses[index]._status;
2371
2371
  delete responses[index]._status;
2372
+ delete responses[index]._headers;
2373
+ delete responses[index]._xhr;
2372
2374
  mapIdForPin[objectId] = obj._localId;
2373
2375
  obj._handleSaveResponse(responses[index].success, status);
2374
2376
  } else {
@@ -2424,6 +2426,8 @@ const DefaultController = {
2424
2426
  return RESTController.request(params.method, params.path, params.body, options).then(response => {
2425
2427
  const status = response._status;
2426
2428
  delete response._status;
2429
+ delete response._headers;
2430
+ delete response._xhr;
2427
2431
  targetCopy._handleSaveResponse(response, status);
2428
2432
  }, error => {
2429
2433
  targetCopy._handleSaveError();
@@ -330,17 +330,11 @@ class RelationOp extends Op {
330
330
  }
331
331
  return obj.id;
332
332
  }
333
- applyTo(value /*: mixed*/, object /*:: ?: { className: string, id: ?string }*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
333
+ applyTo(value /*: mixed*/, parent /*: ParseObject*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
334
334
  if (!value) {
335
- if (!object || !key) {
335
+ if (!parent || !key) {
336
336
  throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
337
337
  }
338
- const parent = new _ParseObject.default(object.className);
339
- if (object.id && object.id.indexOf('local') === 0) {
340
- parent._localId = object.id;
341
- } else if (object.id) {
342
- parent.id = object.id;
343
- }
344
338
  const relation = new _ParseRelation.default(parent, key);
345
339
  relation.targetClassName = this._targetClassName;
346
340
  return relation;
package/lib/node/Push.js CHANGED
@@ -104,8 +104,11 @@ function getPushStatus(pushStatusId /*: string*/, options /*:: ?: FullOptions*/
104
104
  return query.get(pushStatusId, pushOptions);
105
105
  }
106
106
  const DefaultController = {
107
- send(data /*: PushData*/, options /*:: ?: FullOptions*/) {
108
- return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
107
+ async send(data /*: PushData*/, options /*:: ?: FullOptions*/) {
108
+ var _response$_headers;
109
+ options.returnStatus = true;
110
+ const response = await _CoreManager.default.getRESTController().request('POST', 'push', data, options);
111
+ return (_response$_headers = response._headers) === null || _response$_headers === void 0 ? void 0 : _response$_headers['X-Parse-Push-Status-Id'];
109
112
  }
110
113
  };
111
114
  _CoreManager.default.setPushController(DefaultController);
@@ -104,13 +104,12 @@ const RESTController = {
104
104
  let response;
105
105
  try {
106
106
  response = JSON.parse(xhr.responseText);
107
- if (typeof xhr.getResponseHeader === 'function') {
108
- if ((xhr.getAllResponseHeaders() || '').includes('x-parse-job-status-id: ')) {
109
- response = xhr.getResponseHeader('x-parse-job-status-id');
110
- }
111
- if ((xhr.getAllResponseHeaders() || '').includes('x-parse-push-status-id: ')) {
112
- response = xhr.getResponseHeader('x-parse-push-status-id');
113
- }
107
+ headers = {};
108
+ if (typeof xhr.getResponseHeader === 'function' && xhr.getResponseHeader('access-control-expose-headers')) {
109
+ const responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
110
+ responseHeaders.forEach(header => {
111
+ headers[header] = xhr.getResponseHeader(header.toLowerCase());
112
+ });
114
113
  }
115
114
  } catch (e) {
116
115
  promise.reject(e.toString());
@@ -118,6 +117,7 @@ const RESTController = {
118
117
  if (response) {
119
118
  promise.resolve({
120
119
  response,
120
+ headers,
121
121
  status: xhr.status,
122
122
  xhr
123
123
  });
@@ -271,12 +271,16 @@ const RESTController = {
271
271
  const payloadString = JSON.stringify(payload);
272
272
  return RESTController.ajax(method, url, payloadString, {}, options).then(({
273
273
  response,
274
- status
274
+ status,
275
+ headers,
276
+ xhr
275
277
  }) => {
276
278
  if (options.returnStatus) {
277
279
  return {
278
280
  ...response,
279
- _status: status
281
+ _status: status,
282
+ _headers: headers,
283
+ _xhr: xhr
280
284
  };
281
285
  } else {
282
286
  return response;
@@ -21,6 +21,12 @@ exports.removeState = removeState;
21
21
  exports.setPendingOp = setPendingOp;
22
22
  exports.setServerData = setServerData;
23
23
  var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
24
+ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
24
30
  function _getRequireWildcardCache(nodeInterop) {
25
31
  if (typeof WeakMap !== "function") return null;
26
32
  var cacheBabelInterop = new WeakMap();
@@ -145,15 +151,15 @@ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
145
151
  }
146
152
  return {};
147
153
  }
148
- function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
154
+ function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
149
155
  const serverData = getServerData(obj);
150
156
  const pendingOps = getPendingOps(obj);
151
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
157
+ return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
152
158
  }
153
- function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
159
+ function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
154
160
  const serverData = getServerData(obj);
155
161
  const pendingOps = getPendingOps(obj);
156
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
162
+ return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
157
163
  }
158
164
  function commitServerChanges(obj /*: ObjectIdentifier*/, changes /*: AttributeMap*/) {
159
165
  const state = initializeState(obj);
@@ -147,12 +147,12 @@ function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
147
147
  function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
148
148
  const serverData = getServerData(obj);
149
149
  const 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
  const serverData = getServerData(obj);
154
154
  const 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
  const state = initializeState(obj);
@@ -6,6 +6,7 @@ exports.getJobStatus = getJobStatus;
6
6
  exports.getJobsData = getJobsData;
7
7
  exports.run = run;
8
8
  exports.startJob = startJob;
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
10
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
10
11
  var _decode = _interopRequireDefault(require("./decode"));
11
12
  var _encode = _interopRequireDefault(require("./encode"));
@@ -71,10 +72,19 @@ var DefaultController = {
71
72
  var RESTController = _CoreManager.default.getRESTController();
72
73
  return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
73
74
  },
74
- startJob: function (name, data, options) {
75
- var RESTController = _CoreManager.default.getRESTController();
76
- var payload = (0, _encode.default)(data, true);
77
- return RESTController.request('POST', 'jobs/' + name, payload, options);
78
- }
75
+ startJob: function () {
76
+ var _startJob = (0, _asyncToGenerator2.default)(function* (name, data, options) {
77
+ var _response$_headers;
78
+ var RESTController = _CoreManager.default.getRESTController();
79
+ var payload = (0, _encode.default)(data, true);
80
+ options.returnStatus = true;
81
+ var response = yield RESTController.request('POST', 'jobs/' + name, payload, options);
82
+ return (_response$_headers = response._headers) == null ? void 0 : _response$_headers['X-Parse-Job-Status-Id'];
83
+ });
84
+ function startJob() {
85
+ return _startJob.apply(this, arguments);
86
+ }
87
+ return startJob;
88
+ }()
79
89
  };
80
90
  _CoreManager.default.setCloudController(DefaultController);
@@ -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' + "4.3.0",
15
+ VERSION: 'js' + "4.3.1-alpha.2",
16
16
  APPLICATION_ID: null,
17
17
  JAVASCRIPT_KEY: null,
18
18
  MASTER_KEY: null,
@@ -1,25 +1,29 @@
1
1
  var _idbKeyval = require("idb-keyval");
2
2
  if (typeof window !== 'undefined' && window.indexedDB) {
3
- var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
4
- var IndexedDBStorageController = {
5
- async: 1,
6
- getItemAsync: function (path) {
7
- return (0, _idbKeyval.get)(path, ParseStore);
8
- },
9
- setItemAsync: function (path, value) {
10
- return (0, _idbKeyval.set)(path, value, ParseStore);
11
- },
12
- removeItemAsync: function (path) {
13
- return (0, _idbKeyval.del)(path, ParseStore);
14
- },
15
- getAllKeysAsync: function () {
16
- return (0, _idbKeyval.keys)(ParseStore);
17
- },
18
- clear: function () {
19
- return (0, _idbKeyval.clear)(ParseStore);
20
- }
21
- };
22
- module.exports = IndexedDBStorageController;
3
+ try {
4
+ var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
5
+ var IndexedDBStorageController = {
6
+ async: 1,
7
+ getItemAsync: function (path) {
8
+ return (0, _idbKeyval.get)(path, ParseStore);
9
+ },
10
+ setItemAsync: function (path, value) {
11
+ return (0, _idbKeyval.set)(path, value, ParseStore);
12
+ },
13
+ removeItemAsync: function (path) {
14
+ return (0, _idbKeyval.del)(path, ParseStore);
15
+ },
16
+ getAllKeysAsync: function () {
17
+ return (0, _idbKeyval.keys)(ParseStore);
18
+ },
19
+ clear: function () {
20
+ return (0, _idbKeyval.clear)(ParseStore);
21
+ }
22
+ };
23
+ module.exports = IndexedDBStorageController;
24
+ } catch (_) {
25
+ module.exports = undefined;
26
+ }
23
27
  } else {
24
28
  module.exports = undefined;
25
29
  }
@@ -67,16 +67,13 @@ function mergeFirstPendingState(pendingOps) {
67
67
  }
68
68
  }
69
69
  }
70
- function estimateAttribute(serverData, pendingOps, className, id, attr) {
70
+ function estimateAttribute(serverData, pendingOps, object, attr) {
71
71
  var value = serverData[attr];
72
72
  for (var i = 0; i < pendingOps.length; i++) {
73
73
  if (pendingOps[i][attr]) {
74
74
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
75
- if (id) {
76
- value = pendingOps[i][attr].applyTo(value, {
77
- className: className,
78
- id: id
79
- }, attr);
75
+ if (object.id) {
76
+ value = pendingOps[i][attr].applyTo(value, object, attr);
80
77
  }
81
78
  } else {
82
79
  value = pendingOps[i][attr].applyTo(value);
@@ -85,7 +82,7 @@ function estimateAttribute(serverData, pendingOps, className, id, attr) {
85
82
  }
86
83
  return value;
87
84
  }
88
- function estimateAttributes(serverData, pendingOps, className, id) {
85
+ function estimateAttributes(serverData, pendingOps, object) {
89
86
  var data = {};
90
87
  for (var attr in serverData) {
91
88
  data[attr] = serverData[attr];
@@ -93,11 +90,8 @@ function estimateAttributes(serverData, pendingOps, className, id) {
93
90
  for (var i = 0; i < pendingOps.length; i++) {
94
91
  for (attr in pendingOps[i]) {
95
92
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
96
- if (id) {
97
- data[attr] = pendingOps[i][attr].applyTo(data[attr], {
98
- className: className,
99
- id: id
100
- }, attr);
93
+ if (object.id) {
94
+ data[attr] = pendingOps[i][attr].applyTo(data[attr], object, attr);
101
95
  }
102
96
  } else {
103
97
  if (attr.includes('.')) {
@@ -105,15 +99,15 @@ function estimateAttributes(serverData, pendingOps, className, id) {
105
99
  var first = fields[0];
106
100
  var last = fields[fields.length - 1];
107
101
  data[first] = Object.assign({}, serverData[first]);
108
- var object = Object.assign({}, data);
102
+ var _object = Object.assign({}, data);
109
103
  for (var _i = 0; _i < fields.length - 1; _i++) {
110
104
  var key = fields[_i];
111
- if (!(key in object)) {
112
- object[key] = {};
105
+ if (!(key in _object)) {
106
+ _object[key] = {};
113
107
  }
114
- object = object[key];
108
+ _object = _object[key];
115
109
  }
116
- object[last] = pendingOps[i][attr].applyTo(object[last]);
110
+ _object[last] = pendingOps[i][attr].applyTo(_object[last]);
117
111
  } else {
118
112
  data[attr] = pendingOps[i][attr].applyTo(data[attr]);
119
113
  }
@@ -7,6 +7,7 @@ var _decode2 = _interopRequireDefault(require("./decode"));
7
7
  var _encode2 = _interopRequireDefault(require("./encode"));
8
8
  var _CryptoController = _interopRequireDefault(require("./CryptoController"));
9
9
  var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
10
+ var _IndexedDBStorageController = _interopRequireDefault(require("./IndexedDBStorageController"));
10
11
  var _InstallationController = _interopRequireDefault(require("./InstallationController"));
11
12
  var ParseOp = _interopRequireWildcard(require("./ParseOp"));
12
13
  var _RESTController = _interopRequireDefault(require("./RESTController"));
@@ -854,7 +854,7 @@ var ParseObject = function () {
854
854
  try {
855
855
  yield this.save(null, options);
856
856
  } catch (e) {
857
- if (e.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
857
+ if (e.code === _ParseError.default.CONNECTION_FAILED) {
858
858
  yield _EventuallyQueue.default.save(this, options);
859
859
  _EventuallyQueue.default.poll();
860
860
  }
@@ -916,7 +916,7 @@ var ParseObject = function () {
916
916
  try {
917
917
  yield this.destroy(options);
918
918
  } catch (e) {
919
- if (e.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
919
+ if (e.code === _ParseError.default.CONNECTION_FAILED) {
920
920
  yield _EventuallyQueue.default.destroy(this, options);
921
921
  _EventuallyQueue.default.poll();
922
922
  }
@@ -1576,6 +1576,8 @@ var DefaultController = {
1576
1576
  var objectId = responses[index].success.objectId;
1577
1577
  var status = responses[index]._status;
1578
1578
  delete responses[index]._status;
1579
+ delete responses[index]._headers;
1580
+ delete responses[index]._xhr;
1579
1581
  mapIdForPin[objectId] = obj._localId;
1580
1582
  obj._handleSaveResponse(responses[index].success, status);
1581
1583
  } else {
@@ -1628,6 +1630,8 @@ var DefaultController = {
1628
1630
  return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
1629
1631
  var status = response._status;
1630
1632
  delete response._status;
1633
+ delete response._headers;
1634
+ delete response._xhr;
1631
1635
  targetCopy._handleSaveResponse(response, status);
1632
1636
  }, function (error) {
1633
1637
  targetCopy._handleSaveError();
@@ -440,17 +440,11 @@ var RelationOp = function (_Op7) {
440
440
  }
441
441
  }, {
442
442
  key: "applyTo",
443
- value: function (value, object, key) {
443
+ value: function (value, parent, key) {
444
444
  if (!value) {
445
- if (!object || !key) {
445
+ if (!parent || !key) {
446
446
  throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
447
447
  }
448
- var parent = new _ParseObject.default(object.className);
449
- if (object.id && object.id.indexOf('local') === 0) {
450
- parent._localId = object.id;
451
- } else if (object.id) {
452
- parent.id = object.id;
453
- }
454
448
  var relation = new _ParseRelation.default(parent, key);
455
449
  relation.targetClassName = this._targetClassName;
456
450
  return relation;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.getPushStatus = getPushStatus;
6
6
  exports.send = send;
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
7
8
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
8
9
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
9
10
  function send(data) {
@@ -40,8 +41,17 @@ function getPushStatus(pushStatusId) {
40
41
  return query.get(pushStatusId, pushOptions);
41
42
  }
42
43
  var DefaultController = {
43
- send: function (data, options) {
44
- return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
45
- }
44
+ send: function () {
45
+ var _send = (0, _asyncToGenerator2.default)(function* (data, options) {
46
+ var _response$_headers;
47
+ options.returnStatus = true;
48
+ var response = yield _CoreManager.default.getRESTController().request('POST', 'push', data, options);
49
+ return (_response$_headers = response._headers) == null ? void 0 : _response$_headers['X-Parse-Push-Status-Id'];
50
+ });
51
+ function send() {
52
+ return _send.apply(this, arguments);
53
+ }
54
+ return send;
55
+ }()
46
56
  };
47
57
  _CoreManager.default.setPushController(DefaultController);
@@ -72,13 +72,12 @@ var RESTController = {
72
72
  var response;
73
73
  try {
74
74
  response = JSON.parse(xhr.responseText);
75
- if (typeof xhr.getResponseHeader === 'function') {
76
- if ((xhr.getAllResponseHeaders() || '').includes('x-parse-job-status-id: ')) {
77
- response = xhr.getResponseHeader('x-parse-job-status-id');
78
- }
79
- if ((xhr.getAllResponseHeaders() || '').includes('x-parse-push-status-id: ')) {
80
- response = xhr.getResponseHeader('x-parse-push-status-id');
81
- }
75
+ headers = {};
76
+ if (typeof xhr.getResponseHeader === 'function' && xhr.getResponseHeader('access-control-expose-headers')) {
77
+ var responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
78
+ responseHeaders.forEach(function (header) {
79
+ headers[header] = xhr.getResponseHeader(header.toLowerCase());
80
+ });
82
81
  }
83
82
  } catch (e) {
84
83
  promise.reject(e.toString());
@@ -86,6 +85,7 @@ var RESTController = {
86
85
  if (response) {
87
86
  promise.resolve({
88
87
  response: response,
88
+ headers: headers,
89
89
  status: xhr.status,
90
90
  xhr: xhr
91
91
  });
@@ -232,10 +232,14 @@ var RESTController = {
232
232
  var payloadString = JSON.stringify(payload);
233
233
  return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
234
234
  var response = _ref.response,
235
- status = _ref.status;
235
+ status = _ref.status,
236
+ headers = _ref.headers,
237
+ xhr = _ref.xhr;
236
238
  if (options.returnStatus) {
237
239
  return Object.assign({}, response, {
238
- _status: status
240
+ _status: status,
241
+ _headers: headers,
242
+ _xhr: xhr
239
243
  });
240
244
  } else {
241
245
  return response;
@@ -1,3 +1,4 @@
1
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1
2
  Object.defineProperty(exports, "__esModule", {
2
3
  value: true
3
4
  });
@@ -19,6 +20,7 @@ exports.removeState = removeState;
19
20
  exports.setPendingOp = setPendingOp;
20
21
  exports.setServerData = setServerData;
21
22
  var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
23
+ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
22
24
  function _getRequireWildcardCache(nodeInterop) {
23
25
  if (typeof WeakMap !== "function") return null;
24
26
  var cacheBabelInterop = new WeakMap();
@@ -132,12 +134,12 @@ function getObjectCache(obj) {
132
134
  function estimateAttribute(obj, attr) {
133
135
  var serverData = getServerData(obj);
134
136
  var pendingOps = getPendingOps(obj);
135
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
137
+ return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
136
138
  }
137
139
  function estimateAttributes(obj) {
138
140
  var serverData = getServerData(obj);
139
141
  var pendingOps = getPendingOps(obj);
140
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
142
+ return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
141
143
  }
142
144
  function commitServerChanges(obj, changes) {
143
145
  var state = initializeState(obj);
@@ -135,12 +135,12 @@ function getObjectCache(obj) {
135
135
  function estimateAttribute(obj, attr) {
136
136
  var serverData = getServerData(obj);
137
137
  var pendingOps = getPendingOps(obj);
138
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
138
+ return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
139
139
  }
140
140
  function estimateAttributes(obj) {
141
141
  var serverData = getServerData(obj);
142
142
  var pendingOps = getPendingOps(obj);
143
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
143
+ return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
144
144
  }
145
145
  function commitServerChanges(obj, changes) {
146
146
  var state = initializeState(obj);
@@ -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;