parse 4.0.1 → 4.1.0-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 (251) hide show
  1. package/dist/parse.js +17995 -26193
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +8739 -17728
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +2 -20
  6. package/lib/browser/AnonymousUtils.js +6 -35
  7. package/lib/browser/Cloud.js +12 -70
  8. package/lib/browser/CloudCode.js +0 -3
  9. package/lib/browser/CoreManager.js +46 -184
  10. package/lib/browser/CryptoController.js +2 -16
  11. package/lib/browser/EventEmitter.js +1 -1
  12. package/lib/browser/EventuallyQueue.js +277 -824
  13. package/lib/browser/FacebookUtils.js +6 -35
  14. package/lib/browser/IndexedDBStorageController.js +3 -14
  15. package/lib/browser/InstallationController.js +2 -13
  16. package/lib/browser/LiveQueryClient.js +87 -204
  17. package/lib/browser/LiveQuerySubscription.js +10 -39
  18. package/lib/browser/LocalDatastore.js +451 -1081
  19. package/lib/browser/LocalDatastoreController.js +145 -602
  20. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  21. package/lib/browser/LocalDatastoreUtils.js +2 -12
  22. package/lib/browser/ObjectStateMutations.js +18 -121
  23. package/lib/browser/OfflineQuery.js +42 -222
  24. package/lib/browser/Parse.js +12 -106
  25. package/lib/browser/ParseACL.js +33 -141
  26. package/lib/browser/ParseCLP.js +96 -314
  27. package/lib/browser/ParseConfig.js +18 -88
  28. package/lib/browser/ParseError.js +63 -90
  29. package/lib/browser/ParseFile.js +129 -685
  30. package/lib/browser/ParseGeoPoint.js +23 -82
  31. package/lib/browser/ParseHooks.js +1 -34
  32. package/lib/browser/ParseInstallation.js +4 -32
  33. package/lib/browser/ParseLiveQuery.js +96 -505
  34. package/lib/browser/ParseObject.js +628 -1840
  35. package/lib/browser/ParseOp.js +41 -287
  36. package/lib/browser/ParsePolygon.js +13 -63
  37. package/lib/browser/ParseQuery.js +404 -1505
  38. package/lib/browser/ParseRelation.js +12 -61
  39. package/lib/browser/ParseRole.js +13 -75
  40. package/lib/browser/ParseSchema.js +49 -201
  41. package/lib/browser/ParseSession.js +11 -69
  42. package/lib/browser/ParseUser.js +274 -1127
  43. package/lib/browser/Push.js +7 -43
  44. package/lib/browser/RESTController.js +18 -140
  45. package/lib/browser/SingleInstanceStateController.js +19 -137
  46. package/lib/browser/Socket.weapp.js +2 -12
  47. package/lib/browser/Storage.js +10 -73
  48. package/lib/browser/StorageController.browser.js +4 -17
  49. package/lib/browser/StorageController.default.js +4 -17
  50. package/lib/browser/StorageController.react-native.js +6 -33
  51. package/lib/browser/StorageController.weapp.js +5 -16
  52. package/lib/browser/TaskQueue.js +1 -22
  53. package/lib/browser/UniqueInstanceStateController.js +19 -142
  54. package/lib/browser/Xhr.weapp.js +0 -17
  55. package/lib/browser/arrayContainsObject.js +2 -16
  56. package/lib/browser/canBeSerialized.js +3 -33
  57. package/lib/browser/decode.js +3 -33
  58. package/lib/browser/encode.js +9 -70
  59. package/lib/browser/equals.js +2 -25
  60. package/lib/browser/escape.js +1 -8
  61. package/lib/browser/isRevocableSession.js +2 -11
  62. package/lib/browser/parseDate.js +2 -13
  63. package/lib/browser/promiseUtils.js +3 -21
  64. package/lib/browser/unique.js +3 -17
  65. package/lib/browser/unsavedChildren.js +6 -50
  66. package/lib/browser/uuid.js +3 -1
  67. package/lib/node/Analytics.js +1 -18
  68. package/lib/node/AnonymousUtils.js +5 -37
  69. package/lib/node/Cloud.js +10 -66
  70. package/lib/node/CloudCode.js +0 -3
  71. package/lib/node/CoreManager.js +47 -220
  72. package/lib/node/CryptoController.js +2 -16
  73. package/lib/node/EventEmitter.js +1 -1
  74. package/lib/node/EventuallyQueue.js +16 -123
  75. package/lib/node/FacebookUtils.js +5 -37
  76. package/lib/node/IndexedDBStorageController.js +3 -19
  77. package/lib/node/InstallationController.js +2 -15
  78. package/lib/node/LiveQueryClient.js +56 -136
  79. package/lib/node/LiveQuerySubscription.js +7 -16
  80. package/lib/node/LocalDatastore.js +19 -175
  81. package/lib/node/LocalDatastoreController.js +6 -38
  82. package/lib/node/LocalDatastoreController.react-native.js +6 -45
  83. package/lib/node/LocalDatastoreUtils.js +1 -6
  84. package/lib/node/ObjectStateMutations.js +13 -93
  85. package/lib/node/OfflineQuery.js +20 -152
  86. package/lib/node/Parse.js +11 -99
  87. package/lib/node/ParseACL.js +32 -150
  88. package/lib/node/ParseCLP.js +69 -262
  89. package/lib/node/ParseConfig.js +16 -84
  90. package/lib/node/ParseError.js +61 -65
  91. package/lib/node/ParseFile.js +50 -205
  92. package/lib/node/ParseGeoPoint.js +21 -82
  93. package/lib/node/ParseHooks.js +0 -35
  94. package/lib/node/ParseInstallation.js +1 -10
  95. package/lib/node/ParseLiveQuery.js +10 -36
  96. package/lib/node/ParseObject.js +193 -939
  97. package/lib/node/ParseOp.js +31 -255
  98. package/lib/node/ParsePolygon.js +12 -62
  99. package/lib/node/ParseQuery.js +170 -882
  100. package/lib/node/ParseRelation.js +11 -61
  101. package/lib/node/ParseRole.js +10 -57
  102. package/lib/node/ParseSchema.js +46 -222
  103. package/lib/node/ParseSession.js +8 -50
  104. package/lib/node/ParseUser.js +107 -576
  105. package/lib/node/Push.js +4 -37
  106. package/lib/node/RESTController.js +8 -110
  107. package/lib/node/SingleInstanceStateController.js +17 -130
  108. package/lib/node/Socket.weapp.js +2 -9
  109. package/lib/node/Storage.js +10 -83
  110. package/lib/node/StorageController.browser.js +4 -23
  111. package/lib/node/StorageController.default.js +5 -21
  112. package/lib/node/StorageController.react-native.js +6 -40
  113. package/lib/node/StorageController.weapp.js +6 -21
  114. package/lib/node/TaskQueue.js +1 -17
  115. package/lib/node/UniqueInstanceStateController.js +16 -133
  116. package/lib/node/Xhr.weapp.js +0 -15
  117. package/lib/node/arrayContainsObject.js +1 -12
  118. package/lib/node/canBeSerialized.js +2 -28
  119. package/lib/node/decode.js +1 -26
  120. package/lib/node/encode.js +3 -54
  121. package/lib/node/equals.js +0 -18
  122. package/lib/node/escape.js +1 -6
  123. package/lib/node/isRevocableSession.js +1 -5
  124. package/lib/node/parseDate.js +1 -7
  125. package/lib/node/promiseUtils.js +2 -14
  126. package/lib/node/unique.js +1 -11
  127. package/lib/node/unsavedChildren.js +2 -38
  128. package/lib/node/uuid.js +6 -1
  129. package/lib/react-native/Analytics.js +0 -9
  130. package/lib/react-native/AnonymousUtils.js +0 -10
  131. package/lib/react-native/Cloud.js +0 -26
  132. package/lib/react-native/CoreManager.js +1 -5
  133. package/lib/react-native/CryptoController.js +0 -2
  134. package/lib/react-native/EventEmitter.js +0 -2
  135. package/lib/react-native/EventuallyQueue.js +4 -52
  136. package/lib/react-native/FacebookUtils.js +0 -22
  137. package/lib/react-native/IndexedDBStorageController.js +0 -1
  138. package/lib/react-native/InstallationController.js +0 -6
  139. package/lib/react-native/LiveQueryClient.js +24 -101
  140. package/lib/react-native/LiveQuerySubscription.js +3 -27
  141. package/lib/react-native/LocalDatastore.js +6 -113
  142. package/lib/react-native/LocalDatastoreController.js +0 -21
  143. package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
  144. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  145. package/lib/react-native/ObjectStateMutations.js +0 -34
  146. package/lib/react-native/OfflineQuery.js +2 -137
  147. package/lib/react-native/Parse.js +0 -65
  148. package/lib/react-native/ParseACL.js +0 -44
  149. package/lib/react-native/ParseCLP.js +32 -96
  150. package/lib/react-native/ParseConfig.js +0 -42
  151. package/lib/react-native/ParseError.js +1 -21
  152. package/lib/react-native/ParseFile.js +4 -72
  153. package/lib/react-native/ParseGeoPoint.js +0 -17
  154. package/lib/react-native/ParseHooks.js +0 -30
  155. package/lib/react-native/ParseInstallation.js +1 -23
  156. package/lib/react-native/ParseLiveQuery.js +3 -25
  157. package/lib/react-native/ParseObject.js +4 -371
  158. package/lib/react-native/ParseOp.js +1 -138
  159. package/lib/react-native/ParsePolygon.js +0 -24
  160. package/lib/react-native/ParseQuery.js +6 -262
  161. package/lib/react-native/ParseRelation.js +0 -25
  162. package/lib/react-native/ParseRole.js +1 -36
  163. package/lib/react-native/ParseSchema.js +0 -51
  164. package/lib/react-native/ParseSession.js +1 -40
  165. package/lib/react-native/ParseUser.js +1 -224
  166. package/lib/react-native/Push.js +0 -16
  167. package/lib/react-native/RESTController.js +1 -70
  168. package/lib/react-native/SingleInstanceStateController.js +0 -44
  169. package/lib/react-native/Socket.weapp.js +2 -12
  170. package/lib/react-native/Storage.js +0 -24
  171. package/lib/react-native/StorageController.browser.js +0 -2
  172. package/lib/react-native/StorageController.default.js +0 -1
  173. package/lib/react-native/StorageController.react-native.js +0 -2
  174. package/lib/react-native/TaskQueue.js +0 -15
  175. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  176. package/lib/react-native/Xhr.weapp.js +0 -16
  177. package/lib/react-native/arrayContainsObject.js +0 -5
  178. package/lib/react-native/canBeSerialized.js +0 -18
  179. package/lib/react-native/decode.js +0 -21
  180. package/lib/react-native/encode.js +0 -25
  181. package/lib/react-native/equals.js +0 -18
  182. package/lib/react-native/escape.js +0 -1
  183. package/lib/react-native/isRevocableSession.js +0 -1
  184. package/lib/react-native/parseDate.js +0 -3
  185. package/lib/react-native/promiseUtils.js +0 -13
  186. package/lib/react-native/unique.js +0 -4
  187. package/lib/react-native/unsavedChildren.js +0 -21
  188. package/lib/react-native/uuid.js +3 -1
  189. package/lib/weapp/Analytics.js +2 -20
  190. package/lib/weapp/AnonymousUtils.js +6 -35
  191. package/lib/weapp/Cloud.js +12 -70
  192. package/lib/weapp/CloudCode.js +0 -3
  193. package/lib/weapp/CoreManager.js +46 -184
  194. package/lib/weapp/CryptoController.js +2 -16
  195. package/lib/weapp/EventEmitter.js +1 -1
  196. package/lib/weapp/EventuallyQueue.js +277 -824
  197. package/lib/weapp/FacebookUtils.js +6 -35
  198. package/lib/weapp/IndexedDBStorageController.js +3 -14
  199. package/lib/weapp/InstallationController.js +2 -13
  200. package/lib/weapp/LiveQueryClient.js +87 -204
  201. package/lib/weapp/LiveQuerySubscription.js +10 -39
  202. package/lib/weapp/LocalDatastore.js +451 -1081
  203. package/lib/weapp/LocalDatastoreController.js +145 -602
  204. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  205. package/lib/weapp/LocalDatastoreUtils.js +2 -12
  206. package/lib/weapp/ObjectStateMutations.js +18 -121
  207. package/lib/weapp/OfflineQuery.js +42 -222
  208. package/lib/weapp/Parse.js +12 -106
  209. package/lib/weapp/ParseACL.js +33 -141
  210. package/lib/weapp/ParseCLP.js +96 -314
  211. package/lib/weapp/ParseConfig.js +18 -88
  212. package/lib/weapp/ParseError.js +63 -90
  213. package/lib/weapp/ParseFile.js +130 -686
  214. package/lib/weapp/ParseGeoPoint.js +23 -82
  215. package/lib/weapp/ParseHooks.js +1 -34
  216. package/lib/weapp/ParseInstallation.js +4 -32
  217. package/lib/weapp/ParseLiveQuery.js +96 -505
  218. package/lib/weapp/ParseObject.js +628 -1840
  219. package/lib/weapp/ParseOp.js +41 -287
  220. package/lib/weapp/ParsePolygon.js +13 -63
  221. package/lib/weapp/ParseQuery.js +404 -1505
  222. package/lib/weapp/ParseRelation.js +12 -61
  223. package/lib/weapp/ParseRole.js +13 -75
  224. package/lib/weapp/ParseSchema.js +49 -201
  225. package/lib/weapp/ParseSession.js +11 -69
  226. package/lib/weapp/ParseUser.js +274 -1127
  227. package/lib/weapp/Push.js +7 -43
  228. package/lib/weapp/RESTController.js +18 -140
  229. package/lib/weapp/SingleInstanceStateController.js +19 -137
  230. package/lib/weapp/Socket.weapp.js +2 -12
  231. package/lib/weapp/Storage.js +10 -73
  232. package/lib/weapp/StorageController.browser.js +4 -17
  233. package/lib/weapp/StorageController.default.js +4 -17
  234. package/lib/weapp/StorageController.react-native.js +6 -33
  235. package/lib/weapp/StorageController.weapp.js +5 -16
  236. package/lib/weapp/TaskQueue.js +1 -22
  237. package/lib/weapp/UniqueInstanceStateController.js +19 -142
  238. package/lib/weapp/Xhr.weapp.js +0 -17
  239. package/lib/weapp/arrayContainsObject.js +2 -16
  240. package/lib/weapp/canBeSerialized.js +3 -33
  241. package/lib/weapp/decode.js +3 -33
  242. package/lib/weapp/encode.js +9 -70
  243. package/lib/weapp/equals.js +2 -25
  244. package/lib/weapp/escape.js +1 -8
  245. package/lib/weapp/isRevocableSession.js +2 -11
  246. package/lib/weapp/parseDate.js +2 -13
  247. package/lib/weapp/promiseUtils.js +3 -21
  248. package/lib/weapp/unique.js +3 -17
  249. package/lib/weapp/unsavedChildren.js +6 -50
  250. package/lib/weapp/uuid.js +1 -6
  251. package/package.json +45 -43
@@ -31,36 +31,25 @@ exports.default = void 0;
31
31
  *
32
32
  * @alias Parse.GeoPoint
33
33
  */
34
-
35
34
  /* global navigator */
36
-
37
35
  class ParseGeoPoint {
38
36
  /*:: _latitude: number;*/
39
-
40
37
  /*:: _longitude: number;*/
41
-
42
38
  /**
43
39
  * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
44
40
  * @param {number} arg2 The longitude of the GeoPoint
45
41
  */
46
- constructor(arg1
47
- /*: Array<number> | { latitude: number, longitude: number } | number*/
48
- , arg2
49
- /*:: ?: number*/
50
- ) {
42
+ constructor(arg1 /*: Array<number> | { latitude: number, longitude: number } | number*/, arg2 /*:: ?: number*/) {
51
43
  if (Array.isArray(arg1)) {
52
44
  ParseGeoPoint._validate(arg1[0], arg1[1]);
53
-
54
45
  this._latitude = arg1[0];
55
46
  this._longitude = arg1[1];
56
47
  } else if (typeof arg1 === 'object') {
57
48
  ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
58
-
59
49
  this._latitude = arg1.latitude;
60
50
  this._longitude = arg1.longitude;
61
51
  } else if (arg1 !== undefined && arg2 !== undefined) {
62
52
  ParseGeoPoint._validate(arg1, arg2);
63
-
64
53
  this._latitude = arg1;
65
54
  this._longitude = arg2;
66
55
  } else {
@@ -68,6 +57,7 @@ class ParseGeoPoint {
68
57
  this._longitude = 0;
69
58
  }
70
59
  }
60
+
71
61
  /**
72
62
  * North-south portion of the coordinate, in range [-90, 90].
73
63
  * Throws an exception if set out of range in a modern browser.
@@ -75,21 +65,14 @@ class ParseGeoPoint {
75
65
  * @property {number} latitude
76
66
  * @returns {number}
77
67
  */
78
-
79
-
80
- get latitude()
81
- /*: number*/
82
- {
68
+ get latitude() /*: number*/{
83
69
  return this._latitude;
84
70
  }
85
-
86
- set latitude(val
87
- /*: number*/
88
- ) {
71
+ set latitude(val /*: number*/) {
89
72
  ParseGeoPoint._validate(val, this.longitude);
90
-
91
73
  this._latitude = val;
92
74
  }
75
+
93
76
  /**
94
77
  * East-west portion of the coordinate, in range [-180, 180].
95
78
  * Throws if set out of range in a modern browser.
@@ -97,147 +80,103 @@ class ParseGeoPoint {
97
80
  * @property {number} longitude
98
81
  * @returns {number}
99
82
  */
100
-
101
-
102
- get longitude()
103
- /*: number*/
104
- {
83
+ get longitude() /*: number*/{
105
84
  return this._longitude;
106
85
  }
107
-
108
- set longitude(val
109
- /*: number*/
110
- ) {
86
+ set longitude(val /*: number*/) {
111
87
  ParseGeoPoint._validate(this.latitude, val);
112
-
113
88
  this._longitude = val;
114
89
  }
90
+
115
91
  /**
116
92
  * Returns a JSON representation of the GeoPoint, suitable for Parse.
117
93
  *
118
94
  * @returns {object}
119
95
  */
120
-
121
-
122
- toJSON()
123
- /*: { __type: string, latitude: number, longitude: number }*/
124
- {
96
+ toJSON() /*: { __type: string, latitude: number, longitude: number }*/{
125
97
  ParseGeoPoint._validate(this._latitude, this._longitude);
126
-
127
98
  return {
128
99
  __type: 'GeoPoint',
129
100
  latitude: this._latitude,
130
101
  longitude: this._longitude
131
102
  };
132
103
  }
133
-
134
- equals(other
135
- /*: mixed*/
136
- )
137
- /*: boolean*/
138
- {
104
+ equals(other /*: mixed*/) /*: boolean*/{
139
105
  return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
140
106
  }
107
+
141
108
  /**
142
109
  * Returns the distance from this GeoPoint to another in radians.
143
110
  *
144
111
  * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
145
112
  * @returns {number}
146
113
  */
147
-
148
-
149
- radiansTo(point
150
- /*: ParseGeoPoint*/
151
- )
152
- /*: number*/
153
- {
114
+ radiansTo(point /*: ParseGeoPoint*/) /*: number*/{
154
115
  const d2r = Math.PI / 180.0;
155
116
  const lat1rad = this.latitude * d2r;
156
117
  const long1rad = this.longitude * d2r;
157
118
  const lat2rad = point.latitude * d2r;
158
119
  const long2rad = point.longitude * d2r;
159
120
  const sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
160
- const sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2); // Square of half the straight line chord distance between both points.
161
-
121
+ const sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2);
122
+ // Square of half the straight line chord distance between both points.
162
123
  let a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
163
124
  a = Math.min(1.0, a);
164
125
  return 2 * Math.asin(Math.sqrt(a));
165
126
  }
127
+
166
128
  /**
167
129
  * Returns the distance from this GeoPoint to another in kilometers.
168
130
  *
169
131
  * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
170
132
  * @returns {number}
171
133
  */
172
-
173
-
174
- kilometersTo(point
175
- /*: ParseGeoPoint*/
176
- )
177
- /*: number*/
178
- {
134
+ kilometersTo(point /*: ParseGeoPoint*/) /*: number*/{
179
135
  return this.radiansTo(point) * 6371.0;
180
136
  }
137
+
181
138
  /**
182
139
  * Returns the distance from this GeoPoint to another in miles.
183
140
  *
184
141
  * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
185
142
  * @returns {number}
186
143
  */
187
-
188
-
189
- milesTo(point
190
- /*: ParseGeoPoint*/
191
- )
192
- /*: number*/
193
- {
144
+ milesTo(point /*: ParseGeoPoint*/) /*: number*/{
194
145
  return this.radiansTo(point) * 3958.8;
195
146
  }
147
+
196
148
  /*
197
149
  * Throws an exception if the given lat-long is out of bounds.
198
150
  */
199
-
200
-
201
- static _validate(latitude
202
- /*: number*/
203
- , longitude
204
- /*: number*/
205
- ) {
151
+ static _validate(latitude /*: number*/, longitude /*: number*/) {
206
152
  if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
207
153
  throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
208
154
  }
209
-
210
155
  if (latitude < -90.0) {
211
156
  throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
212
157
  }
213
-
214
158
  if (latitude > 90.0) {
215
159
  throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
216
160
  }
217
-
218
161
  if (longitude < -180.0) {
219
162
  throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
220
163
  }
221
-
222
164
  if (longitude > 180.0) {
223
165
  throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
224
166
  }
225
167
  }
168
+
226
169
  /**
227
170
  * Creates a GeoPoint with the user's current location, if available.
228
171
  *
229
172
  * @static
230
173
  * @returns {Parse.GeoPoint} User's current location
231
174
  */
232
-
233
-
234
175
  static current() {
235
176
  return navigator.geolocation.getCurrentPosition(location => {
236
177
  return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
237
178
  });
238
179
  }
239
-
240
180
  }
241
-
242
181
  var _default = ParseGeoPoint;
243
182
  exports.default = _default;
@@ -16,42 +16,32 @@ exports.removeTrigger = removeTrigger;
16
16
  exports.update = update;
17
17
  exports.updateFunction = updateFunction;
18
18
  exports.updateTrigger = updateTrigger;
19
-
20
19
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
21
-
22
20
  var _decode = _interopRequireDefault(require("./decode"));
23
-
24
21
  var _ParseError = _interopRequireDefault(require("./ParseError"));
25
-
26
22
  function _interopRequireDefault(obj) {
27
23
  return obj && obj.__esModule ? obj : {
28
24
  default: obj
29
25
  };
30
26
  }
31
-
32
27
  function getFunctions() {
33
28
  return _CoreManager.default.getHooksController().get('functions');
34
29
  }
35
-
36
30
  function getTriggers() {
37
31
  return _CoreManager.default.getHooksController().get('triggers');
38
32
  }
39
-
40
33
  function getFunction(name) {
41
34
  return _CoreManager.default.getHooksController().get('functions', name);
42
35
  }
43
-
44
36
  function getTrigger(className, triggerName) {
45
37
  return _CoreManager.default.getHooksController().get('triggers', className, triggerName);
46
38
  }
47
-
48
39
  function createFunction(functionName, url) {
49
40
  return create({
50
41
  functionName: functionName,
51
42
  url: url
52
43
  });
53
44
  }
54
-
55
45
  function createTrigger(className, triggerName, url) {
56
46
  return create({
57
47
  className: className,
@@ -59,18 +49,15 @@ function createTrigger(className, triggerName, url) {
59
49
  url: url
60
50
  });
61
51
  }
62
-
63
52
  function create(hook) {
64
53
  return _CoreManager.default.getHooksController().create(hook);
65
54
  }
66
-
67
55
  function updateFunction(functionName, url) {
68
56
  return update({
69
57
  functionName: functionName,
70
58
  url: url
71
59
  });
72
60
  }
73
-
74
61
  function updateTrigger(className, triggerName, url) {
75
62
  return update({
76
63
  className: className,
@@ -78,46 +65,36 @@ function updateTrigger(className, triggerName, url) {
78
65
  url: url
79
66
  });
80
67
  }
81
-
82
68
  function update(hook) {
83
69
  return _CoreManager.default.getHooksController().update(hook);
84
70
  }
85
-
86
71
  function removeFunction(functionName) {
87
72
  return remove({
88
73
  functionName: functionName
89
74
  });
90
75
  }
91
-
92
76
  function removeTrigger(className, triggerName) {
93
77
  return remove({
94
78
  className: className,
95
79
  triggerName: triggerName
96
80
  });
97
81
  }
98
-
99
82
  function remove(hook) {
100
83
  return _CoreManager.default.getHooksController().remove(hook);
101
84
  }
102
-
103
85
  const DefaultController = {
104
86
  get(type, functionName, triggerName) {
105
87
  let url = '/hooks/' + type;
106
-
107
88
  if (functionName) {
108
89
  url += '/' + functionName;
109
-
110
90
  if (triggerName) {
111
91
  url += '/' + triggerName;
112
92
  }
113
93
  }
114
-
115
94
  return this.sendRequest('GET', url);
116
95
  },
117
-
118
96
  create(hook) {
119
97
  let url;
120
-
121
98
  if (hook.functionName && hook.url) {
122
99
  url = '/hooks/functions';
123
100
  } else if (hook.className && hook.triggerName && hook.url) {
@@ -128,13 +105,10 @@ const DefaultController = {
128
105
  code: 143
129
106
  });
130
107
  }
131
-
132
108
  return this.sendRequest('POST', url, hook);
133
109
  },
134
-
135
110
  remove(hook) {
136
111
  let url;
137
-
138
112
  if (hook.functionName) {
139
113
  url = '/hooks/functions/' + hook.functionName;
140
114
  delete hook.functionName;
@@ -148,15 +122,12 @@ const DefaultController = {
148
122
  code: 143
149
123
  });
150
124
  }
151
-
152
125
  return this.sendRequest('PUT', url, {
153
126
  __op: 'Delete'
154
127
  });
155
128
  },
156
-
157
129
  update(hook) {
158
130
  let url;
159
-
160
131
  if (hook.functionName && hook.url) {
161
132
  url = '/hooks/functions/' + hook.functionName;
162
133
  delete hook.functionName;
@@ -170,24 +141,18 @@ const DefaultController = {
170
141
  code: 143
171
142
  });
172
143
  }
173
-
174
144
  return this.sendRequest('PUT', url, hook);
175
145
  },
176
-
177
146
  sendRequest(method, url, body) {
178
147
  return _CoreManager.default.getRESTController().request(method, url, body, {
179
148
  useMasterKey: true
180
149
  }).then(res => {
181
150
  const decoded = (0, _decode.default)(res);
182
-
183
151
  if (decoded) {
184
152
  return Promise.resolve(decoded);
185
153
  }
186
-
187
154
  return Promise.reject(new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.'));
188
155
  });
189
156
  }
190
-
191
157
  };
192
-
193
158
  _CoreManager.default.setHooksController(DefaultController);
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
9
-
10
8
  function _interopRequireDefault(obj) {
11
9
  return obj && obj.__esModule ? obj : {
12
10
  default: obj
@@ -16,22 +14,15 @@ function _interopRequireDefault(obj) {
16
14
  * @flow
17
15
  */
18
16
 
19
-
20
17
  class Installation extends _ParseObject.default {
21
- constructor(attributes
22
- /*: ?AttributeMap*/
23
- ) {
18
+ constructor(attributes /*: ?AttributeMap*/) {
24
19
  super('_Installation');
25
-
26
20
  if (attributes && typeof attributes === 'object') {
27
21
  if (!this.set(attributes || {})) {
28
22
  throw new Error("Can't create an invalid Installation");
29
23
  }
30
24
  }
31
25
  }
32
-
33
26
  }
34
-
35
27
  exports.default = Installation;
36
-
37
28
  _ParseObject.default.registerSubclass('_Installation', Installation);
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _EventEmitter = _interopRequireDefault(require("./EventEmitter"));
9
-
10
8
  var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
11
-
12
9
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
13
-
14
10
  function _interopRequireDefault(obj) {
15
11
  return obj && obj.__esModule ? obj : {
16
12
  default: obj
@@ -20,12 +16,10 @@ function _interopRequireDefault(obj) {
20
16
  * @flow
21
17
  */
22
18
 
23
-
24
- function getLiveQueryClient()
25
- /*: LiveQueryClient*/
26
- {
19
+ function getLiveQueryClient() /*: LiveQueryClient*/{
27
20
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
28
21
  }
22
+
29
23
  /**
30
24
  * We expose three events to help you monitor the status of the WebSocket connection:
31
25
  *
@@ -53,18 +47,17 @@ function getLiveQueryClient()
53
47
  * @class Parse.LiveQuery
54
48
  * @static
55
49
  */
56
-
57
-
58
50
  const LiveQuery = new _EventEmitter.default();
51
+
59
52
  /**
60
53
  * After open is called, the LiveQuery will try to send a connect request
61
54
  * to the LiveQuery server.
62
55
  */
63
-
64
56
  LiveQuery.open = async () => {
65
57
  const liveQueryClient = await getLiveQueryClient();
66
58
  liveQueryClient.open();
67
59
  };
60
+
68
61
  /**
69
62
  * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
70
63
  * This function will close the WebSocket connection to the LiveQuery server,
@@ -72,58 +65,42 @@ LiveQuery.open = async () => {
72
65
  * If you call query.subscribe() after this, we'll create a new WebSocket
73
66
  * connection to the LiveQuery server.
74
67
  */
75
-
76
-
77
68
  LiveQuery.close = async () => {
78
69
  const liveQueryClient = await getLiveQueryClient();
79
70
  liveQueryClient.close();
80
- }; // Register a default onError callback to make sure we do not crash on error
81
-
71
+ };
82
72
 
73
+ // Register a default onError callback to make sure we do not crash on error
83
74
  LiveQuery.on('error', () => {});
84
75
  var _default = LiveQuery;
85
76
  exports.default = _default;
86
77
  let defaultLiveQueryClient;
87
78
  const DefaultLiveQueryController = {
88
- setDefaultLiveQueryClient(liveQueryClient
89
- /*: LiveQueryClient*/
90
- ) {
79
+ setDefaultLiveQueryClient(liveQueryClient /*: LiveQueryClient*/) {
91
80
  defaultLiveQueryClient = liveQueryClient;
92
81
  },
93
-
94
- async getDefaultLiveQueryClient()
95
- /*: Promise<LiveQueryClient>*/
96
- {
82
+ async getDefaultLiveQueryClient() /*: Promise<LiveQueryClient>*/{
97
83
  if (defaultLiveQueryClient) {
98
84
  return defaultLiveQueryClient;
99
85
  }
100
-
101
86
  const [currentUser, installationId] = await Promise.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
102
87
  const sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
103
-
104
88
  let liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
105
-
106
89
  if (liveQueryServerURL && liveQueryServerURL.indexOf('ws') !== 0) {
107
90
  throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
108
- } // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
109
-
91
+ }
110
92
 
93
+ // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
111
94
  if (!liveQueryServerURL) {
112
95
  const serverURL = _CoreManager.default.get('SERVER_URL');
113
-
114
96
  const protocol = serverURL.indexOf('https') === 0 ? 'wss://' : 'ws://';
115
97
  const host = serverURL.replace(/^https?:\/\//, '');
116
98
  liveQueryServerURL = protocol + host;
117
-
118
99
  _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
119
100
  }
120
-
121
101
  const applicationId = _CoreManager.default.get('APPLICATION_ID');
122
-
123
102
  const javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
124
-
125
103
  const masterKey = _CoreManager.default.get('MASTER_KEY');
126
-
127
104
  defaultLiveQueryClient = new _LiveQueryClient.default({
128
105
  applicationId,
129
106
  serverURL: liveQueryServerURL,
@@ -143,11 +120,8 @@ const DefaultLiveQueryController = {
143
120
  });
144
121
  return defaultLiveQueryClient;
145
122
  },
146
-
147
123
  _clearCachedDefaultClient() {
148
124
  defaultLiveQueryClient = null;
149
125
  }
150
-
151
126
  };
152
-
153
127
  _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);