parse 5.1.0-alpha.1 → 5.1.0-alpha.11

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 (143) hide show
  1. package/README.md +13 -0
  2. package/dist/parse.js +1464 -1051
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +2367 -1090
  5. package/dist/parse.weapp.min.js +2 -2
  6. package/lib/browser/CoreManager.js +48 -171
  7. package/lib/browser/InstallationController.js +134 -23
  8. package/lib/browser/LiveQueryClient.js +43 -35
  9. package/lib/browser/LiveQuerySubscription.js +15 -5
  10. package/lib/browser/LocalDatastoreController.default.js +248 -0
  11. package/lib/browser/LocalDatastoreController.js +1 -246
  12. package/lib/browser/ObjectStateMutations.js +6 -5
  13. package/lib/browser/OfflineQuery.js +3 -2
  14. package/lib/browser/Parse.js +31 -7
  15. package/lib/browser/ParseACL.js +21 -11
  16. package/lib/browser/ParseFile.js +4 -0
  17. package/lib/browser/ParseGeoPoint.js +12 -8
  18. package/lib/browser/ParseHooks.js +2 -0
  19. package/lib/browser/ParseInstallation.js +274 -13
  20. package/lib/browser/ParseLiveQuery.js +32 -23
  21. package/lib/browser/ParseObject.js +37 -40
  22. package/lib/browser/ParseOp.js +21 -7
  23. package/lib/browser/ParseQuery.js +1 -0
  24. package/lib/browser/ParseRelation.js +12 -7
  25. package/lib/browser/ParseRole.js +2 -0
  26. package/lib/browser/ParseSession.js +1 -1
  27. package/lib/browser/ParseUser.js +51 -15
  28. package/lib/browser/RESTController.js +6 -5
  29. package/lib/browser/SingleInstanceStateController.js +2 -4
  30. package/lib/browser/Storage.js +1 -2
  31. package/lib/browser/StorageController.js +3 -0
  32. package/lib/browser/WebSocketController.js +13 -0
  33. package/lib/browser/arrayContainsObject.js +4 -3
  34. package/lib/browser/canBeSerialized.js +6 -4
  35. package/lib/browser/decode.js +8 -5
  36. package/lib/browser/encode.js +6 -4
  37. package/lib/browser/equals.js +4 -3
  38. package/lib/browser/unique.js +3 -2
  39. package/lib/browser/unsavedChildren.js +4 -2
  40. package/lib/browser/uuid.js +11 -5
  41. package/lib/node/CoreManager.js +48 -171
  42. package/lib/node/InstallationController.js +65 -21
  43. package/lib/node/LiveQueryClient.js +2 -5
  44. package/lib/node/LiveQuerySubscription.js +2 -2
  45. package/lib/node/LocalDatastoreController.default.js +67 -0
  46. package/lib/node/LocalDatastoreController.js +1 -65
  47. package/lib/node/ObjectStateMutations.js +8 -9
  48. package/lib/node/OfflineQuery.js +3 -2
  49. package/lib/node/Parse.js +31 -7
  50. package/lib/node/ParseACL.js +21 -11
  51. package/lib/node/ParseFile.js +4 -0
  52. package/lib/node/ParseGeoPoint.js +11 -11
  53. package/lib/node/ParseHooks.js +2 -0
  54. package/lib/node/ParseInstallation.js +207 -7
  55. package/lib/node/ParseLiveQuery.js +2 -3
  56. package/lib/node/ParseObject.js +9 -12
  57. package/lib/node/ParseOp.js +21 -7
  58. package/lib/node/ParseQuery.js +1 -0
  59. package/lib/node/ParseRelation.js +14 -8
  60. package/lib/node/ParseRole.js +2 -0
  61. package/lib/node/ParseSession.js +1 -1
  62. package/lib/node/ParseUser.js +20 -13
  63. package/lib/node/RESTController.js +5 -5
  64. package/lib/node/SingleInstanceStateController.js +2 -8
  65. package/lib/node/Storage.js +1 -2
  66. package/lib/node/StorageController.js +3 -0
  67. package/lib/node/WebSocketController.js +10 -0
  68. package/lib/node/arrayContainsObject.js +4 -3
  69. package/lib/node/canBeSerialized.js +6 -4
  70. package/lib/node/decode.js +9 -5
  71. package/lib/node/encode.js +7 -4
  72. package/lib/node/equals.js +4 -3
  73. package/lib/node/unique.js +3 -2
  74. package/lib/node/unsavedChildren.js +4 -2
  75. package/lib/node/uuid.js +10 -8
  76. package/lib/react-native/CoreManager.js +39 -2
  77. package/lib/react-native/InstallationController.js +77 -9
  78. package/lib/react-native/LiveQueryClient.js +28 -20
  79. package/lib/react-native/LiveQuerySubscription.js +14 -5
  80. package/lib/react-native/LocalDatastoreController.default.js +91 -0
  81. package/lib/react-native/LocalDatastoreController.js +1 -91
  82. package/lib/react-native/ObjectStateMutations.js +6 -5
  83. package/lib/react-native/OfflineQuery.js +3 -2
  84. package/lib/react-native/Parse.js +23 -7
  85. package/lib/react-native/ParseACL.js +19 -11
  86. package/lib/react-native/ParseGeoPoint.js +5 -3
  87. package/lib/react-native/ParseInstallation.js +115 -10
  88. package/lib/react-native/ParseLiveQuery.js +11 -2
  89. package/lib/react-native/ParseObject.js +28 -31
  90. package/lib/react-native/ParseOp.js +20 -6
  91. package/lib/react-native/ParseQuery.js +1 -0
  92. package/lib/react-native/ParseRelation.js +10 -7
  93. package/lib/react-native/ParseRole.js +2 -0
  94. package/lib/react-native/ParseUser.js +6 -2
  95. package/lib/react-native/RESTController.js +5 -5
  96. package/lib/react-native/SingleInstanceStateController.js +0 -2
  97. package/lib/react-native/Storage.js +1 -2
  98. package/lib/react-native/StorageController.js +1 -0
  99. package/lib/react-native/WebSocketController.js +5 -0
  100. package/lib/react-native/arrayContainsObject.js +3 -2
  101. package/lib/react-native/canBeSerialized.js +5 -3
  102. package/lib/react-native/decode.js +7 -5
  103. package/lib/react-native/encode.js +6 -4
  104. package/lib/react-native/equals.js +4 -3
  105. package/lib/react-native/unique.js +3 -2
  106. package/lib/react-native/unsavedChildren.js +3 -2
  107. package/lib/react-native/uuid.js +9 -4
  108. package/lib/weapp/CoreManager.js +48 -171
  109. package/lib/weapp/InstallationController.js +134 -23
  110. package/lib/weapp/LiveQueryClient.js +43 -35
  111. package/lib/weapp/LiveQuerySubscription.js +15 -5
  112. package/lib/weapp/LocalDatastoreController.default.js +248 -0
  113. package/lib/weapp/LocalDatastoreController.js +1 -246
  114. package/lib/weapp/ObjectStateMutations.js +6 -5
  115. package/lib/weapp/OfflineQuery.js +3 -2
  116. package/lib/weapp/Parse.js +31 -7
  117. package/lib/weapp/ParseACL.js +21 -11
  118. package/lib/weapp/ParseFile.js +4 -0
  119. package/lib/weapp/ParseGeoPoint.js +12 -8
  120. package/lib/weapp/ParseHooks.js +2 -0
  121. package/lib/weapp/ParseInstallation.js +274 -13
  122. package/lib/weapp/ParseLiveQuery.js +32 -23
  123. package/lib/weapp/ParseObject.js +37 -40
  124. package/lib/weapp/ParseOp.js +21 -7
  125. package/lib/weapp/ParseQuery.js +1 -0
  126. package/lib/weapp/ParseRelation.js +12 -7
  127. package/lib/weapp/ParseRole.js +2 -0
  128. package/lib/weapp/ParseSession.js +1 -1
  129. package/lib/weapp/ParseUser.js +51 -15
  130. package/lib/weapp/RESTController.js +6 -5
  131. package/lib/weapp/SingleInstanceStateController.js +2 -4
  132. package/lib/weapp/Storage.js +1 -2
  133. package/lib/weapp/StorageController.js +3 -0
  134. package/lib/weapp/WebSocketController.js +13 -0
  135. package/lib/weapp/arrayContainsObject.js +4 -3
  136. package/lib/weapp/canBeSerialized.js +6 -4
  137. package/lib/weapp/decode.js +8 -5
  138. package/lib/weapp/encode.js +6 -4
  139. package/lib/weapp/equals.js +4 -3
  140. package/lib/weapp/unique.js +3 -2
  141. package/lib/weapp/unsavedChildren.js +4 -2
  142. package/lib/weapp/uuid.js +12 -5
  143. package/package.json +3 -1
@@ -4,25 +4,225 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
7
8
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
8
9
  function _interopRequireDefault(obj) {
9
10
  return obj && obj.__esModule ? obj : {
10
11
  default: obj
11
12
  };
12
13
  }
14
+ const DEVICE_TYPES /*: DeviceInterface*/ = {
15
+ IOS: 'ios',
16
+ MACOS: 'macos',
17
+ TVOS: 'tvos',
18
+ FCM: 'fcm',
19
+ ANDROID: 'android',
20
+ WEB: 'web'
21
+ };
22
+
13
23
  /**
14
- * @flow
24
+ * Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
25
+ * This class is a subclass of a Parse.Object, and retains the same functionality of a Parse.Object, but also extends it with installation-specific features.
26
+ *
27
+ * <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
28
+ *
29
+ * Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
30
+ * </p>
31
+ *
32
+ * @alias Parse.Installation
15
33
  */
16
- /*:: import type { AttributeMap } from './ObjectStateMutations';*/
17
- class Installation extends _ParseObject.default {
18
- constructor(attributes /*: ?AttributeMap*/) {
34
+ class ParseInstallation extends _ParseObject.default {
35
+ /**
36
+ * @param {object} attributes The initial set of data to store in the object.
37
+ */
38
+ constructor(attributes /*:: ?: AttributeMap*/) {
19
39
  super('_Installation');
20
40
  if (attributes && typeof attributes === 'object') {
21
- if (!this.set(attributes || {})) {
41
+ if (!this.set(attributes)) {
22
42
  throw new Error("Can't create an invalid Installation");
23
43
  }
24
44
  }
25
45
  }
46
+
47
+ /**
48
+ * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
49
+ *
50
+ * @property {string} appIdentifier
51
+ * @static
52
+ */
53
+ get appIdentifier() {
54
+ return this.get('appIdentifier');
55
+ }
56
+
57
+ /**
58
+ * The version string of the client application to which this installation belongs.
59
+ *
60
+ * @property {string} appVersion
61
+ * @static
62
+ */
63
+ get appVersion() {
64
+ return this.get('appVersion');
65
+ }
66
+
67
+ /**
68
+ * The display name of the client application to which this installation belongs.
69
+ *
70
+ * @property {string} appName
71
+ * @static
72
+ */
73
+ get appName() {
74
+ return this.get('appName');
75
+ }
76
+
77
+ /**
78
+ * The current value of the icon badge for iOS apps.
79
+ * Changes to this value on the server will be used
80
+ * for future badge-increment push notifications.
81
+ *
82
+ * @property {number} badge
83
+ * @static
84
+ */
85
+ get badge() {
86
+ return this.get('badge');
87
+ }
88
+
89
+ /**
90
+ * An array of the channels to which a device is currently subscribed.
91
+ *
92
+ * @property {string[]} channels
93
+ * @static
94
+ */
95
+ get channels() {
96
+ return this.get('channels');
97
+ }
98
+
99
+ /**
100
+ * Token used to deliver push notifications to the device.
101
+ *
102
+ * @property {string} deviceToken
103
+ * @static
104
+ */
105
+ get deviceToken() {
106
+ return this.get('deviceToken');
107
+ }
108
+
109
+ /**
110
+ * The type of device, “ios”, “android”, “web”, etc.
111
+ *
112
+ * @property {string} deviceType
113
+ * @static
114
+ */
115
+ get deviceType() {
116
+ return this.get('deviceType');
117
+ }
118
+
119
+ /**
120
+ * Gets the GCM sender identifier for this installation
121
+ *
122
+ * @property {string} GCMSenderId
123
+ * @static
124
+ */
125
+ get GCMSenderId() {
126
+ return this.get('GCMSenderId');
127
+ }
128
+
129
+ /**
130
+ * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
131
+ *
132
+ * @property {string} installationId
133
+ * @static
134
+ */
135
+ get installationId() {
136
+ return this.get('installationId');
137
+ }
138
+
139
+ /**
140
+ * Gets the local identifier for this installation
141
+ *
142
+ * @property {string} localeIdentifier
143
+ * @static
144
+ */
145
+ get localeIdentifier() {
146
+ return this.get('localeIdentifier');
147
+ }
148
+
149
+ /**
150
+ * Gets the parse server version for this installation
151
+ *
152
+ * @property {string} parseVersion
153
+ * @static
154
+ */
155
+ get parseVersion() {
156
+ return this.get('parseVersion');
157
+ }
158
+
159
+ /**
160
+ * This field is reserved for directing Parse to the push delivery network to be used.
161
+ *
162
+ * @property {string} pushType
163
+ * @static
164
+ */
165
+ get pushType() {
166
+ return this.get('pushType');
167
+ }
168
+
169
+ /**
170
+ * Gets the time zone for this installation
171
+ *
172
+ * @property {string} timeZone
173
+ * @static
174
+ */
175
+ get timeZone() {
176
+ return this.get('timeZone');
177
+ }
178
+
179
+ /**
180
+ * Returns the device types for used for Push Notifications.
181
+ *
182
+ * <pre>
183
+ * Parse.Installation.DEVICE_TYPES.IOS
184
+ * Parse.Installation.DEVICE_TYPES.MACOS
185
+ * Parse.Installation.DEVICE_TYPES.TVOS
186
+ * Parse.Installation.DEVICE_TYPES.FCM
187
+ * Parse.Installation.DEVICE_TYPES.ANDROID
188
+ * Parse.Installation.DEVICE_TYPES.WEB
189
+ * </pre
190
+ *
191
+ * @property {Object} DEVICE_TYPES
192
+ * @static
193
+ */
194
+ static get DEVICE_TYPES() /*: DeviceInterface*/{
195
+ return DEVICE_TYPES;
196
+ }
197
+
198
+ /**
199
+ * Wrap the default save behavior with functionality to save to local storage.
200
+ *
201
+ * @param {...any} args
202
+ * @returns {Promise}
203
+ */
204
+ async save(...args) /*: Promise<ParseInstallation>*/{
205
+ await super.save.apply(this, args);
206
+ await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
207
+ return this;
208
+ }
209
+
210
+ /**
211
+ * Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
212
+ *
213
+ * <pre>
214
+ * const installation = await Parse.Installation.currentInstallation();
215
+ * installation.set('deviceToken', '123');
216
+ * await installation.save();
217
+ * </pre>
218
+ *
219
+ * @returns {Promise} A promise that resolves to the local installation object.
220
+ */
221
+ static currentInstallation() /*: Promise<ParseInstallation>*/{
222
+ return _CoreManager.default.getInstallationController().currentInstallation();
223
+ }
26
224
  }
27
- exports.default = Installation;
28
- _ParseObject.default.registerSubclass('_Installation', Installation);
225
+ _ParseObject.default.registerSubclass('_Installation', ParseInstallation);
226
+ module.exports = ParseInstallation;
227
+ var _default = ParseInstallation;
228
+ exports.default = _default;
@@ -50,9 +50,8 @@ class LiveQuery {
50
50
  constructor() {
51
51
  const EventEmitter = _CoreManager.default.getEventEmitter();
52
52
  this.emitter = new EventEmitter();
53
- this.on = this.emitter.on;
54
- this.emit = this.emitter.emit;
55
-
53
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
54
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
56
55
  // adding listener so process does not crash
57
56
  // best practice is for developer to register their own listener
58
57
  this.on('error', () => {});
@@ -9,7 +9,6 @@ var _canBeSerialized = _interopRequireDefault(require("./canBeSerialized"));
9
9
  var _decode = _interopRequireDefault(require("./decode"));
10
10
  var _encode = _interopRequireDefault(require("./encode"));
11
11
  var _escape = _interopRequireDefault(require("./escape"));
12
- var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
13
12
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
14
13
  var _parseDate = _interopRequireDefault(require("./parseDate"));
15
14
  var _ParseError = _interopRequireDefault(require("./ParseError"));
@@ -17,7 +16,6 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
17
16
  var _promiseUtils = require("./promiseUtils");
18
17
  var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
19
18
  var _ParseOp = require("./ParseOp");
20
- var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
21
19
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
22
20
  var SingleInstanceStateController = _interopRequireWildcard(require("./SingleInstanceStateController"));
23
21
  var _unique = _interopRequireDefault(require("./unique"));
@@ -474,10 +472,6 @@ class ParseObject {
474
472
  json[attr] = (0, _encode.default)(attrs[attr], false, false, seen, offline);
475
473
  }
476
474
  }
477
- const pending = this._getPendingOps();
478
- for (const attr in pending[0]) {
479
- json[attr] = pending[0][attr].toJSON(offline);
480
- }
481
475
  if (this.id) {
482
476
  json.objectId = this.id;
483
477
  }
@@ -997,7 +991,8 @@ class ParseObject {
997
991
  return false;
998
992
  }
999
993
  try {
1000
- const query = new _ParseQuery.default(this.className);
994
+ const ParseQuery = _CoreManager.default.getParseQuery();
995
+ const query = new ParseQuery(this.className);
1001
996
  await query.get(this.id, options);
1002
997
  return true;
1003
998
  } catch (e) {
@@ -1207,8 +1202,8 @@ class ParseObject {
1207
1202
  await this.save(null, options);
1208
1203
  } catch (e) {
1209
1204
  if (e.code === _ParseError.default.CONNECTION_FAILED) {
1210
- await _EventuallyQueue.default.save(this, options);
1211
- _EventuallyQueue.default.poll();
1205
+ await _CoreManager.default.getEventuallyQueue().save(this, options);
1206
+ _CoreManager.default.getEventuallyQueue().poll();
1212
1207
  }
1213
1208
  }
1214
1209
  return this;
@@ -1348,8 +1343,8 @@ class ParseObject {
1348
1343
  await this.destroy(options);
1349
1344
  } catch (e) {
1350
1345
  if (e.code === _ParseError.default.CONNECTION_FAILED) {
1351
- await _EventuallyQueue.default.destroy(this, options);
1352
- _EventuallyQueue.default.poll();
1346
+ await _CoreManager.default.getEventuallyQueue().destroy(this, options);
1347
+ _CoreManager.default.getEventuallyQueue().poll();
1353
1348
  }
1354
1349
  }
1355
1350
  return this;
@@ -2187,7 +2182,8 @@ const DefaultController = {
2187
2182
  if (error) {
2188
2183
  return Promise.reject(error);
2189
2184
  }
2190
- const query = new _ParseQuery.default(className);
2185
+ const ParseQuery = _CoreManager.default.getParseQuery();
2186
+ const query = new ParseQuery(className);
2191
2187
  query.containedIn('objectId', ids);
2192
2188
  if (options && options.include) {
2193
2189
  query.include(options.include);
@@ -2449,6 +2445,7 @@ const DefaultController = {
2449
2445
  return Promise.resolve();
2450
2446
  }
2451
2447
  };
2448
+ _CoreManager.default.setParseObject(ParseObject);
2452
2449
  _CoreManager.default.setObjectController(DefaultController);
2453
2450
  var _default = ParseObject;
2454
2451
  exports.default = _default;
@@ -8,7 +8,7 @@ exports.opFromJSON = opFromJSON;
8
8
  var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
9
9
  var _decode = _interopRequireDefault(require("./decode"));
10
10
  var _encode = _interopRequireDefault(require("./encode"));
11
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
11
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
12
12
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
13
13
  var _unique = _interopRequireDefault(require("./unique"));
14
14
  function _interopRequireDefault(obj) {
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) {
19
19
  /**
20
20
  * @flow
21
21
  */
22
-
22
+ /*:: import type ParseObject from './ParseObject';*/
23
23
  function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
24
24
  if (!json || !json.__op) {
25
25
  return null;
@@ -195,9 +195,10 @@ class AddUniqueOp extends Op {
195
195
  return this._value || [];
196
196
  }
197
197
  if (Array.isArray(value)) {
198
+ const ParseObject = _CoreManager.default.getParseObject();
198
199
  const toAdd = [];
199
200
  this._value.forEach(v => {
200
- if (v instanceof _ParseObject.default) {
201
+ if (v instanceof ParseObject) {
201
202
  if (!(0, _arrayContainsObject.default)(value, v)) {
202
203
  toAdd.push(v);
203
204
  }
@@ -245,6 +246,7 @@ class RemoveOp extends Op {
245
246
  return [];
246
247
  }
247
248
  if (Array.isArray(value)) {
249
+ const ParseObject = _CoreManager.default.getParseObject();
248
250
  // var i = value.indexOf(this._value);
249
251
  const removed = value.concat([]);
250
252
  for (let i = 0; i < this._value.length; i++) {
@@ -253,9 +255,9 @@ class RemoveOp extends Op {
253
255
  removed.splice(index, 1);
254
256
  index = removed.indexOf(this._value[i]);
255
257
  }
256
- if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
258
+ if (this._value[i] instanceof ParseObject && this._value[i].id) {
257
259
  for (let j = 0; j < removed.length; j++) {
258
- if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
260
+ if (removed[j] instanceof ParseObject && this._value[i].id === removed[j].id) {
259
261
  removed.splice(j, 1);
260
262
  j--;
261
263
  }
@@ -277,9 +279,10 @@ class RemoveOp extends Op {
277
279
  return new UnsetOp();
278
280
  }
279
281
  if (previous instanceof RemoveOp) {
282
+ const ParseObject = _CoreManager.default.getParseObject();
280
283
  const uniques = previous._value.concat([]);
281
284
  for (let i = 0; i < this._value.length; i++) {
282
- if (this._value[i] instanceof _ParseObject.default) {
285
+ if (this._value[i] instanceof ParseObject) {
283
286
  if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
284
287
  uniques.push(this._value[i]);
285
288
  }
@@ -431,4 +434,15 @@ class RelationOp extends Op {
431
434
  return adds || removes || {};
432
435
  }
433
436
  }
434
- exports.RelationOp = RelationOp;
437
+ exports.RelationOp = RelationOp;
438
+ _CoreManager.default.setParseOp({
439
+ Op,
440
+ opFromJSON,
441
+ SetOp,
442
+ UnsetOp,
443
+ IncrementOp,
444
+ AddOp,
445
+ RelationOp,
446
+ RemoveOp,
447
+ AddUniqueOp
448
+ });
@@ -2039,6 +2039,7 @@ const DefaultController = {
2039
2039
  return RESTController.request('GET', 'aggregate/' + className, params, options);
2040
2040
  }
2041
2041
  };
2042
+ _CoreManager.default.setParseQuery(ParseQuery);
2042
2043
  _CoreManager.default.setQueryController(DefaultController);
2043
2044
  var _default = ParseQuery;
2044
2045
  exports.default = _default;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _ParseOp = require("./ParseOp");
8
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
9
- var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
10
8
  function _interopRequireDefault(obj) {
11
9
  return obj && obj.__esModule ? obj : {
12
10
  default: obj
@@ -15,7 +13,8 @@ function _interopRequireDefault(obj) {
15
13
  /**
16
14
  * @flow
17
15
  */
18
-
16
+ /*:: import type ParseObject from './ParseObject';*/
17
+ /*:: import type ParseQuery from './ParseQuery';*/
19
18
  /**
20
19
  * Creates a new Relation for the given parent object and key. This
21
20
  * constructor should rarely be used directly, but rather created by
@@ -77,7 +76,10 @@ class ParseRelation {
77
76
  if (!Array.isArray(objects)) {
78
77
  objects = [objects];
79
78
  }
80
- const change = new _ParseOp.RelationOp(objects, []);
79
+ const {
80
+ RelationOp
81
+ } = _CoreManager.default.getParseOp();
82
+ const change = new RelationOp(objects, []);
81
83
  const parent = this.parent;
82
84
  if (!parent) {
83
85
  throw new Error('Cannot add to a Relation without a parent');
@@ -99,7 +101,10 @@ class ParseRelation {
99
101
  if (!Array.isArray(objects)) {
100
102
  objects = [objects];
101
103
  }
102
- const change = new _ParseOp.RelationOp([], objects);
104
+ const {
105
+ RelationOp
106
+ } = _CoreManager.default.getParseOp();
107
+ const change = new RelationOp([], objects);
103
108
  if (!this.parent) {
104
109
  throw new Error('Cannot remove from a Relation without a parent');
105
110
  }
@@ -134,11 +139,12 @@ class ParseRelation {
134
139
  if (!parent) {
135
140
  throw new Error('Cannot construct a query for a Relation without a parent');
136
141
  }
142
+ const ParseQuery = _CoreManager.default.getParseQuery();
137
143
  if (!this.targetClassName) {
138
- query = new _ParseQuery.default(parent.className);
144
+ query = new ParseQuery(parent.className);
139
145
  query._extraOptions.redirectClassNameForKey = this.key;
140
146
  } else {
141
- query = new _ParseQuery.default(this.targetClassName);
147
+ query = new ParseQuery(this.targetClassName);
142
148
  }
143
149
  query._addCondition('$relatedTo', 'object', {
144
150
  __type: 'Pointer',
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
7
8
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
8
9
  var _ParseError = _interopRequireDefault(require("./ParseError"));
9
10
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
@@ -139,6 +140,7 @@ class ParseRole extends _ParseObject.default {
139
140
  return false;
140
141
  }
141
142
  }
143
+ _CoreManager.default.setParseRole(ParseRole);
142
144
  _ParseObject.default.registerSubclass('_Role', ParseRole);
143
145
  var _default = ParseRole;
144
146
  exports.default = _default;
@@ -62,7 +62,7 @@ class ParseSession extends _ParseObject.default {
62
62
  static current(options /*: FullOptions*/) {
63
63
  options = options || {};
64
64
  const controller = _CoreManager.default.getSessionController();
65
- const sessionOptions = {};
65
+ const sessionOptions /*: FullOptions*/ = {};
66
66
  if (options.hasOwnProperty('useMasterKey')) {
67
67
  sessionOptions.useMasterKey = options.useMasterKey;
68
68
  }
@@ -528,10 +528,11 @@ class ParseUser extends _ParseObject.default {
528
528
  /**
529
529
  * Verify whether a given password is the password of the current user.
530
530
  *
531
- * @param {string} password A password to be verified
532
- * @param {object} options
533
- * @returns {Promise} A promise that is fulfilled with a user
534
- * when the password is correct.
531
+ * @param {string} password The password to be verified.
532
+ * @param {object} options The options.
533
+ * @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify
534
+ * the password regardless of whether the email has been verified. This requires the master key.
535
+ * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
535
536
  */
536
537
  verifyPassword(password /*: string*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
537
538
  const username = this.getUsername() || '';
@@ -840,13 +841,14 @@ class ParseUser extends _ParseObject.default {
840
841
 
841
842
  /**
842
843
  * Verify whether a given password is the password of the current user.
843
- *
844
- * @param {string} username A username to be used for identificaiton
845
- * @param {string} password A password to be verified
846
- * @param {object} options
847
844
  * @static
848
- * @returns {Promise} A promise that is fulfilled with a user
849
- * when the password is correct.
845
+ *
846
+ * @param {string} username The username of the user whose password should be verified.
847
+ * @param {string} password The password to be verified.
848
+ * @param {object} options The options.
849
+ * @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify
850
+ * the password regardless of whether the email has been verified. This requires the master key.
851
+ * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
850
852
  */
851
853
  static verifyPassword(username /*: string*/, password /*: string*/, options /*:: ?: RequestOptions*/) {
852
854
  if (typeof username !== 'string') {
@@ -1214,10 +1216,14 @@ const DefaultController = {
1214
1216
  },
1215
1217
  verifyPassword(username /*: string*/, password /*: string*/, options /*: RequestOptions*/) {
1216
1218
  const RESTController = _CoreManager.default.getRESTController();
1217
- return RESTController.request('GET', 'verifyPassword', {
1219
+ const data = {
1218
1220
  username,
1219
- password
1220
- }, options);
1221
+ password,
1222
+ ...(options.ignoreEmailVerification !== undefined && {
1223
+ ignoreEmailVerification: options.ignoreEmailVerification
1224
+ })
1225
+ };
1226
+ return RESTController.request('GET', 'verifyPassword', data, options);
1221
1227
  },
1222
1228
  requestEmailVerification(email /*: string*/, options /*: RequestOptions*/) {
1223
1229
  const RESTController = _CoreManager.default.getRESTController();
@@ -1226,6 +1232,7 @@ const DefaultController = {
1226
1232
  }, options);
1227
1233
  }
1228
1234
  };
1235
+ _CoreManager.default.setParseUser(ParseUser);
1229
1236
  _CoreManager.default.setUserController(DefaultController);
1230
1237
  var _default = ParseUser;
1231
1238
  exports.default = _default;
@@ -105,11 +105,14 @@ const RESTController = {
105
105
  let response;
106
106
  try {
107
107
  response = JSON.parse(xhr.responseText);
108
+ const availableHeaders = typeof xhr.getAllResponseHeaders === 'function' ? xhr.getAllResponseHeaders() : "";
108
109
  headers = {};
109
- if (typeof xhr.getResponseHeader === 'function' && xhr.getResponseHeader('access-control-expose-headers')) {
110
+ if (typeof xhr.getResponseHeader === 'function' && (availableHeaders === null || availableHeaders === void 0 ? void 0 : availableHeaders.indexOf('access-control-expose-headers')) >= 0) {
110
111
  const responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
111
112
  responseHeaders.forEach(header => {
112
- headers[header] = xhr.getResponseHeader(header.toLowerCase());
113
+ if (availableHeaders.indexOf(header.toLowerCase()) >= 0) {
114
+ headers[header] = xhr.getResponseHeader(header.toLowerCase());
115
+ }
113
116
  });
114
117
  }
115
118
  } catch (e) {
@@ -240,9 +243,6 @@ const RESTController = {
240
243
  throw new Error('Cannot use the Master Key, it has not been provided.');
241
244
  }
242
245
  }
243
- if (options.ignoreEmailVerification !== undefined) {
244
- payload.ignoreEmailVerification = options.ignoreEmailVerification;
245
- }
246
246
  if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
247
247
  payload._RevocableSession = '1';
248
248
  }
@@ -21,12 +21,6 @@ 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
- }
30
24
  function _getRequireWildcardCache(nodeInterop) {
31
25
  if (typeof WeakMap !== "function") return null;
32
26
  var cacheBabelInterop = new WeakMap();
@@ -151,12 +145,12 @@ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
151
145
  }
152
146
  return {};
153
147
  }
154
- function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
148
+ function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
155
149
  const serverData = getServerData(obj);
156
150
  const pendingOps = getPendingOps(obj);
157
151
  return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
158
152
  }
159
- function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
153
+ function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
160
154
  const serverData = getServerData(obj);
161
155
  const pendingOps = getPendingOps(obj);
162
156
  return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
@@ -96,5 +96,4 @@ const Storage = {
96
96
  };
97
97
  module.exports = Storage;
98
98
  var _default = Storage;
99
- exports.default = _default;
100
- _CoreManager.default.setStorageController(require('./StorageController.default'));
99
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ module.exports = require('./StorageController.default');
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ /* global WebSocket */
4
+ let WebSocketController;
5
+ try {
6
+ WebSocketController = require('ws');
7
+ } catch (_) {
8
+ // WebSocket unavailable
9
+ }
10
+ module.exports = WebSocketController;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = arrayContainsObject;
7
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
8
8
  function _interopRequireDefault(obj) {
9
9
  return obj && obj.__esModule ? obj : {
10
10
  default: obj
@@ -13,13 +13,14 @@ function _interopRequireDefault(obj) {
13
13
  /**
14
14
  * @flow
15
15
  */
16
-
16
+ /*:: import type ParseObject from './ParseObject';*/
17
17
  function arrayContainsObject(array /*: Array<any>*/, object /*: ParseObject*/) /*: boolean*/{
18
18
  if (array.indexOf(object) > -1) {
19
19
  return true;
20
20
  }
21
+ const ParseObject = _CoreManager.default.getParseObject();
21
22
  for (let i = 0; i < array.length; i++) {
22
- if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
23
+ if (array[i] instanceof ParseObject && array[i].className === object.className && array[i]._getId() === object._getId()) {
23
24
  return true;
24
25
  }
25
26
  }