parse 4.3.1-alpha.1 → 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.
@@ -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.1-alpha.1",
190
+ VERSION: 'js' + "4.3.1-alpha.2",
191
191
  APPLICATION_ID: null,
192
192
  JAVASCRIPT_KEY: null,
193
193
  MASTER_KEY: null,
@@ -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
  }
@@ -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
@@ -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);
@@ -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.1-alpha.1",
186
+ VERSION: 'js' + "4.3.1-alpha.2",
187
187
  APPLICATION_ID: null,
188
188
  JAVASCRIPT_KEY: null,
189
189
  MASTER_KEY: null,
@@ -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('.')) {
@@ -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;
@@ -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);
@@ -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.1-alpha.1",
15
+ VERSION: 'js' + "4.3.1-alpha.2",
16
16
  APPLICATION_ID: null,
17
17
  JAVASCRIPT_KEY: null,
18
18
  MASTER_KEY: null,
@@ -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
  }
@@ -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;
@@ -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);
@@ -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.1-alpha.1",
190
+ VERSION: 'js' + "4.3.1-alpha.2",
191
191
  APPLICATION_ID: null,
192
192
  JAVASCRIPT_KEY: null,
193
193
  MASTER_KEY: null,
@@ -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
  }
@@ -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