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