parse 4.0.0-alpha.1 → 4.0.0-alpha.10
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 +34 -30
- package/PATENTS +0 -37
package/lib/browser/Push.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.getPushStatus = getPushStatus;
|
|
12
9
|
exports.send = send;
|
|
13
|
-
|
|
14
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
15
|
-
|
|
16
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
17
|
-
|
|
18
12
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
19
13
|
/**
|
|
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
14
|
* @flow
|
|
28
15
|
*/
|
|
29
16
|
|
|
@@ -63,43 +50,29 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
|
63
50
|
* @returns {Promise} A promise that is fulfilled when the push request
|
|
64
51
|
* completes.
|
|
65
52
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function send(data
|
|
69
|
-
/*: PushData*/
|
|
70
|
-
)
|
|
71
|
-
/*: Promise*/
|
|
72
|
-
{
|
|
73
|
-
var options
|
|
74
|
-
/*:: ?: FullOptions*/
|
|
75
|
-
= arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
76
|
-
|
|
53
|
+
function send(data /*: PushData*/) /*: Promise*/{
|
|
54
|
+
var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
77
55
|
if (data.where && data.where instanceof _ParseQuery.default) {
|
|
78
56
|
data.where = data.where.toJSON().where;
|
|
79
57
|
}
|
|
80
|
-
|
|
81
58
|
if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
|
|
82
59
|
data.push_time = data.push_time.toJSON();
|
|
83
60
|
}
|
|
84
|
-
|
|
85
61
|
if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
|
|
86
62
|
data.expiration_time = data.expiration_time.toJSON();
|
|
87
63
|
}
|
|
88
|
-
|
|
89
64
|
if (data.expiration_time && data.expiration_interval) {
|
|
90
65
|
throw new Error('expiration_time and expiration_interval cannot both be set.');
|
|
91
66
|
}
|
|
92
|
-
|
|
93
67
|
var pushOptions = {
|
|
94
68
|
useMasterKey: true
|
|
95
69
|
};
|
|
96
|
-
|
|
97
70
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
98
71
|
pushOptions.useMasterKey = options.useMasterKey;
|
|
99
72
|
}
|
|
100
|
-
|
|
101
73
|
return _CoreManager.default.getPushController().send(data, pushOptions);
|
|
102
74
|
}
|
|
75
|
+
|
|
103
76
|
/**
|
|
104
77
|
* Gets push status by Id
|
|
105
78
|
*
|
|
@@ -113,36 +86,20 @@ function send(data
|
|
|
113
86
|
* </ul>
|
|
114
87
|
* @returns {Parse.Object} Status of Push.
|
|
115
88
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
function getPushStatus(pushStatusId
|
|
119
|
-
/*: string*/
|
|
120
|
-
)
|
|
121
|
-
/*: Promise<string>*/
|
|
122
|
-
{
|
|
123
|
-
var options
|
|
124
|
-
/*:: ?: FullOptions*/
|
|
125
|
-
= arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
89
|
+
function getPushStatus(pushStatusId /*: string*/) /*: Promise<string>*/{
|
|
90
|
+
var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
126
91
|
var pushOptions = {
|
|
127
92
|
useMasterKey: true
|
|
128
93
|
};
|
|
129
|
-
|
|
130
94
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
131
95
|
pushOptions.useMasterKey = options.useMasterKey;
|
|
132
96
|
}
|
|
133
|
-
|
|
134
97
|
var query = new _ParseQuery.default('_PushStatus');
|
|
135
98
|
return query.get(pushStatusId, pushOptions);
|
|
136
99
|
}
|
|
137
|
-
|
|
138
100
|
var DefaultController = {
|
|
139
|
-
send: function (data
|
|
140
|
-
/*: PushData*/
|
|
141
|
-
, options
|
|
142
|
-
/*:: ?: FullOptions*/
|
|
143
|
-
) {
|
|
101
|
+
send: function (data /*: PushData*/, options /*:: ?: FullOptions*/) {
|
|
144
102
|
return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
|
|
145
103
|
}
|
|
146
104
|
};
|
|
147
|
-
|
|
148
105
|
_CoreManager.default.setPushController(DefaultController);
|
|
@@ -1,59 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
7
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
8
|
-
|
|
9
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
10
|
-
|
|
11
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
12
|
-
|
|
13
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
14
|
-
|
|
15
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
16
|
-
|
|
17
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
18
|
-
|
|
19
3
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
20
|
-
|
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
21
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
22
|
-
|
|
23
13
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
24
|
-
|
|
25
|
-
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
26
|
-
|
|
27
|
-
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
28
|
-
|
|
29
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
30
|
-
|
|
31
14
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
32
|
-
|
|
15
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
16
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
17
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
33
18
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
34
|
-
|
|
35
19
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
36
|
-
|
|
37
20
|
var _promiseUtils = require("./promiseUtils");
|
|
38
|
-
|
|
39
21
|
function ownKeys(object, enumerableOnly) {
|
|
40
22
|
var keys = _Object$keys(object);
|
|
41
|
-
|
|
42
23
|
if (_Object$getOwnPropertySymbols) {
|
|
43
24
|
var symbols = _Object$getOwnPropertySymbols(object);
|
|
44
|
-
|
|
45
25
|
enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
46
26
|
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
47
27
|
})), keys.push.apply(keys, symbols);
|
|
48
28
|
}
|
|
49
|
-
|
|
50
29
|
return keys;
|
|
51
30
|
}
|
|
52
|
-
|
|
53
31
|
function _objectSpread(target) {
|
|
54
32
|
for (var i = 1; i < arguments.length; i++) {
|
|
55
33
|
var _context4, _context5;
|
|
56
|
-
|
|
57
34
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
58
35
|
i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
|
|
59
36
|
(0, _defineProperty2.default)(target, key, source[key]);
|
|
@@ -61,67 +38,37 @@ function _objectSpread(target) {
|
|
|
61
38
|
_Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
|
|
62
39
|
});
|
|
63
40
|
}
|
|
64
|
-
|
|
65
41
|
return target;
|
|
66
42
|
}
|
|
67
43
|
/**
|
|
68
|
-
* Copyright (c) 2015-present, Parse, LLC.
|
|
69
|
-
* All rights reserved.
|
|
70
|
-
*
|
|
71
|
-
* This source code is licensed under the BSD-style license found in the
|
|
72
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
73
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
74
|
-
*
|
|
75
44
|
* @flow
|
|
76
45
|
*/
|
|
77
|
-
|
|
78
46
|
/* global XMLHttpRequest, XDomainRequest */
|
|
79
|
-
|
|
80
|
-
|
|
81
47
|
var uuidv4 = require('./uuid');
|
|
82
|
-
|
|
83
48
|
var XHR = null;
|
|
84
|
-
|
|
85
49
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
86
50
|
XHR = XMLHttpRequest;
|
|
87
51
|
}
|
|
88
|
-
|
|
89
52
|
var useXDomainRequest = false;
|
|
90
|
-
|
|
91
53
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
92
54
|
useXDomainRequest = true;
|
|
93
55
|
}
|
|
94
|
-
|
|
95
|
-
function ajaxIE9(method
|
|
96
|
-
/*: string*/
|
|
97
|
-
, url
|
|
98
|
-
/*: string*/
|
|
99
|
-
, data
|
|
100
|
-
/*: any*/
|
|
101
|
-
, headers
|
|
102
|
-
/*:: ?: any*/
|
|
103
|
-
, options
|
|
104
|
-
/*:: ?: FullOptions*/
|
|
105
|
-
) {
|
|
56
|
+
function ajaxIE9(method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
|
|
106
57
|
return new _promise.default(function (resolve, reject) {
|
|
107
58
|
var xdr = new XDomainRequest();
|
|
108
|
-
|
|
109
59
|
xdr.onload = function () {
|
|
110
60
|
var response;
|
|
111
|
-
|
|
112
61
|
try {
|
|
113
62
|
response = JSON.parse(xdr.responseText);
|
|
114
63
|
} catch (e) {
|
|
115
64
|
reject(e);
|
|
116
65
|
}
|
|
117
|
-
|
|
118
66
|
if (response) {
|
|
119
67
|
resolve({
|
|
120
68
|
response: response
|
|
121
69
|
});
|
|
122
70
|
}
|
|
123
71
|
};
|
|
124
|
-
|
|
125
72
|
xdr.onerror = xdr.ontimeout = function () {
|
|
126
73
|
// Let's fake a real error message.
|
|
127
74
|
var fakeResponse = {
|
|
@@ -132,73 +79,48 @@ function ajaxIE9(method
|
|
|
132
79
|
};
|
|
133
80
|
reject(fakeResponse);
|
|
134
81
|
};
|
|
135
|
-
|
|
136
82
|
xdr.onprogress = function () {
|
|
137
83
|
if (options && typeof options.progress === 'function') {
|
|
138
84
|
options.progress(xdr.responseText);
|
|
139
85
|
}
|
|
140
86
|
};
|
|
141
|
-
|
|
142
87
|
xdr.open(method, url);
|
|
143
88
|
xdr.send(data);
|
|
144
|
-
|
|
145
89
|
if (options && typeof options.requestTask === 'function') {
|
|
146
90
|
options.requestTask(xdr);
|
|
147
91
|
}
|
|
148
92
|
});
|
|
149
93
|
}
|
|
150
|
-
|
|
151
94
|
var RESTController = {
|
|
152
|
-
ajax: function (method
|
|
153
|
-
/*: string*/
|
|
154
|
-
, url
|
|
155
|
-
/*: string*/
|
|
156
|
-
, data
|
|
157
|
-
/*: any*/
|
|
158
|
-
, headers
|
|
159
|
-
/*:: ?: any*/
|
|
160
|
-
, options
|
|
161
|
-
/*:: ?: FullOptions*/
|
|
162
|
-
) {
|
|
95
|
+
ajax: function (method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
|
|
163
96
|
var _context;
|
|
164
|
-
|
|
165
97
|
if (useXDomainRequest) {
|
|
166
98
|
return ajaxIE9(method, url, data, headers, options);
|
|
167
99
|
}
|
|
168
|
-
|
|
169
100
|
var promise = (0, _promiseUtils.resolvingPromise)();
|
|
170
101
|
var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
|
|
171
102
|
var requestId = isIdempotent ? uuidv4() : '';
|
|
172
103
|
var attempts = 0;
|
|
173
|
-
|
|
174
104
|
(function dispatch() {
|
|
175
105
|
if (XHR == null) {
|
|
176
106
|
throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
177
107
|
}
|
|
178
|
-
|
|
179
108
|
var handled = false;
|
|
180
109
|
var xhr = new XHR();
|
|
181
|
-
|
|
182
110
|
xhr.onreadystatechange = function () {
|
|
183
111
|
if (xhr.readyState !== 4 || handled || xhr._aborted) {
|
|
184
112
|
return;
|
|
185
113
|
}
|
|
186
|
-
|
|
187
114
|
handled = true;
|
|
188
|
-
|
|
189
115
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
190
116
|
var response;
|
|
191
|
-
|
|
192
117
|
try {
|
|
193
118
|
response = JSON.parse(xhr.responseText);
|
|
194
|
-
|
|
195
119
|
if (typeof xhr.getResponseHeader === 'function') {
|
|
196
120
|
var _context2, _context3;
|
|
197
|
-
|
|
198
121
|
if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
|
|
199
122
|
response = xhr.getResponseHeader('x-parse-job-status-id');
|
|
200
123
|
}
|
|
201
|
-
|
|
202
124
|
if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
|
|
203
125
|
response = xhr.getResponseHeader('x-parse-push-status-id');
|
|
204
126
|
}
|
|
@@ -206,7 +128,6 @@ var RESTController = {
|
|
|
206
128
|
} catch (e) {
|
|
207
129
|
promise.reject(e.toString());
|
|
208
130
|
}
|
|
209
|
-
|
|
210
131
|
if (response) {
|
|
211
132
|
promise.resolve({
|
|
212
133
|
response: response,
|
|
@@ -230,9 +151,7 @@ var RESTController = {
|
|
|
230
151
|
promise.reject(xhr);
|
|
231
152
|
}
|
|
232
153
|
};
|
|
233
|
-
|
|
234
154
|
headers = headers || {};
|
|
235
|
-
|
|
236
155
|
if (typeof headers['Content-Type'] !== 'string') {
|
|
237
156
|
headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
|
|
238
157
|
}
|
|
@@ -240,23 +159,18 @@ var RESTController = {
|
|
|
240
159
|
if (_CoreManager.default.get('IS_NODE')) {
|
|
241
160
|
headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
|
|
242
161
|
}
|
|
243
|
-
|
|
244
162
|
if (isIdempotent) {
|
|
245
163
|
headers['X-Parse-Request-Id'] = requestId;
|
|
246
164
|
}
|
|
247
|
-
|
|
248
165
|
if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
|
|
249
166
|
headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
250
167
|
}
|
|
251
|
-
|
|
252
168
|
var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
|
|
253
|
-
|
|
254
169
|
for (var key in customHeaders) {
|
|
255
170
|
headers[key] = customHeaders[key];
|
|
256
171
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (options && typeof options.progress === 'function') {
|
|
172
|
+
if (options && typeof options.progress === 'function') {
|
|
173
|
+
var handleProgress = function handleProgress(type, event) {
|
|
260
174
|
if (event.lengthComputable) {
|
|
261
175
|
options.progress(event.loaded / event.total, event.loaded, event.total, {
|
|
262
176
|
type: type
|
|
@@ -266,25 +180,20 @@ var RESTController = {
|
|
|
266
180
|
type: type
|
|
267
181
|
});
|
|
268
182
|
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
xhr.onprogress = function (event) {
|
|
273
|
-
handleProgress('download', event);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
if (xhr.upload) {
|
|
277
|
-
xhr.upload.onprogress = function (event) {
|
|
278
|
-
handleProgress('upload', event);
|
|
279
183
|
};
|
|
184
|
+
xhr.onprogress = function (event) {
|
|
185
|
+
handleProgress('download', event);
|
|
186
|
+
};
|
|
187
|
+
if (xhr.upload) {
|
|
188
|
+
xhr.upload.onprogress = function (event) {
|
|
189
|
+
handleProgress('upload', event);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
280
192
|
}
|
|
281
|
-
|
|
282
193
|
xhr.open(method, url, true);
|
|
283
|
-
|
|
284
194
|
for (var h in headers) {
|
|
285
195
|
xhr.setRequestHeader(h, headers[h]);
|
|
286
196
|
}
|
|
287
|
-
|
|
288
197
|
xhr.onabort = function () {
|
|
289
198
|
promise.resolve({
|
|
290
199
|
response: {
|
|
@@ -294,69 +203,46 @@ var RESTController = {
|
|
|
294
203
|
xhr: xhr
|
|
295
204
|
});
|
|
296
205
|
};
|
|
297
|
-
|
|
298
206
|
xhr.send(data);
|
|
299
|
-
|
|
300
207
|
if (options && typeof options.requestTask === 'function') {
|
|
301
208
|
options.requestTask(xhr);
|
|
302
209
|
}
|
|
303
210
|
})();
|
|
304
|
-
|
|
305
211
|
return promise;
|
|
306
212
|
},
|
|
307
|
-
request: function request(method
|
|
308
|
-
/*: string*/
|
|
309
|
-
, path
|
|
310
|
-
/*: string*/
|
|
311
|
-
, data
|
|
312
|
-
/*: mixed*/
|
|
313
|
-
, options
|
|
314
|
-
/*:: ?: RequestOptions*/
|
|
315
|
-
) {
|
|
213
|
+
request: function request(method /*: string*/, path /*: string*/, data /*: mixed*/, options /*:: ?: RequestOptions*/) {
|
|
316
214
|
options = options || {};
|
|
317
|
-
|
|
318
215
|
var url = _CoreManager.default.get('SERVER_URL');
|
|
319
|
-
|
|
320
216
|
if (url[url.length - 1] !== '/') {
|
|
321
217
|
url += '/';
|
|
322
218
|
}
|
|
323
|
-
|
|
324
219
|
url += path;
|
|
325
220
|
var payload = {};
|
|
326
|
-
|
|
327
221
|
if (data && (0, _typeof2.default)(data) === 'object') {
|
|
328
222
|
for (var k in data) {
|
|
329
223
|
payload[k] = data[k];
|
|
330
224
|
}
|
|
331
|
-
}
|
|
332
|
-
|
|
225
|
+
}
|
|
333
226
|
|
|
227
|
+
// Add context
|
|
334
228
|
var context = options.context;
|
|
335
|
-
|
|
336
229
|
if (context !== undefined) {
|
|
337
230
|
payload._context = context;
|
|
338
231
|
}
|
|
339
|
-
|
|
340
232
|
if (method !== 'POST') {
|
|
341
233
|
payload._method = method;
|
|
342
234
|
method = 'POST';
|
|
343
235
|
}
|
|
344
|
-
|
|
345
236
|
payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
|
|
346
|
-
|
|
347
237
|
var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
348
|
-
|
|
349
238
|
if (jsKey) {
|
|
350
239
|
payload._JavaScriptKey = jsKey;
|
|
351
240
|
}
|
|
352
|
-
|
|
353
241
|
payload._ClientVersion = _CoreManager.default.get('VERSION');
|
|
354
242
|
var useMasterKey = options.useMasterKey;
|
|
355
|
-
|
|
356
243
|
if (typeof useMasterKey === 'undefined') {
|
|
357
244
|
useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
|
|
358
245
|
}
|
|
359
|
-
|
|
360
246
|
if (useMasterKey) {
|
|
361
247
|
if (_CoreManager.default.get('MASTER_KEY')) {
|
|
362
248
|
delete payload._JavaScriptKey;
|
|
@@ -365,27 +251,20 @@ var RESTController = {
|
|
|
365
251
|
throw new Error('Cannot use the Master Key, it has not been provided.');
|
|
366
252
|
}
|
|
367
253
|
}
|
|
368
|
-
|
|
369
254
|
if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
|
|
370
255
|
payload._RevocableSession = '1';
|
|
371
256
|
}
|
|
372
|
-
|
|
373
257
|
var installationId = options.installationId;
|
|
374
258
|
var installationIdPromise;
|
|
375
|
-
|
|
376
259
|
if (installationId && typeof installationId === 'string') {
|
|
377
260
|
installationIdPromise = _promise.default.resolve(installationId);
|
|
378
261
|
} else {
|
|
379
262
|
var installationController = _CoreManager.default.getInstallationController();
|
|
380
|
-
|
|
381
263
|
installationIdPromise = installationController.currentInstallationId();
|
|
382
264
|
}
|
|
383
|
-
|
|
384
265
|
return installationIdPromise.then(function (iid) {
|
|
385
266
|
payload._InstallationId = iid;
|
|
386
|
-
|
|
387
267
|
var userController = _CoreManager.default.getUserController();
|
|
388
|
-
|
|
389
268
|
if (options && typeof options.sessionToken === 'string') {
|
|
390
269
|
return _promise.default.resolve(options.sessionToken);
|
|
391
270
|
} else if (userController) {
|
|
@@ -393,22 +272,18 @@ var RESTController = {
|
|
|
393
272
|
if (user) {
|
|
394
273
|
return _promise.default.resolve(user.getSessionToken());
|
|
395
274
|
}
|
|
396
|
-
|
|
397
275
|
return _promise.default.resolve(null);
|
|
398
276
|
});
|
|
399
277
|
}
|
|
400
|
-
|
|
401
278
|
return _promise.default.resolve(null);
|
|
402
279
|
}).then(function (token) {
|
|
403
280
|
if (token) {
|
|
404
281
|
payload._SessionToken = token;
|
|
405
282
|
}
|
|
406
|
-
|
|
407
283
|
var payloadString = (0, _stringify.default)(payload);
|
|
408
284
|
return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
|
|
409
285
|
var response = _ref.response,
|
|
410
|
-
|
|
411
|
-
|
|
286
|
+
status = _ref.status;
|
|
412
287
|
if (options.returnStatus) {
|
|
413
288
|
return _objectSpread(_objectSpread({}, response), {}, {
|
|
414
289
|
_status: status
|
|
@@ -423,7 +298,6 @@ var RESTController = {
|
|
|
423
298
|
// Transform the error into an instance of ParseError by trying to parse
|
|
424
299
|
// the error string as JSON
|
|
425
300
|
var error;
|
|
426
|
-
|
|
427
301
|
if (response && response.responseText) {
|
|
428
302
|
try {
|
|
429
303
|
var errorJSON = JSON.parse(response.responseText);
|
|
@@ -436,12 +310,9 @@ var RESTController = {
|
|
|
436
310
|
var message = response.message ? response.message : response;
|
|
437
311
|
error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
|
|
438
312
|
}
|
|
439
|
-
|
|
440
313
|
return _promise.default.reject(error);
|
|
441
314
|
},
|
|
442
|
-
_setXHR: function _setXHR(xhr
|
|
443
|
-
/*: any*/
|
|
444
|
-
) {
|
|
315
|
+
_setXHR: function _setXHR(xhr /*: any*/) {
|
|
445
316
|
XHR = xhr;
|
|
446
317
|
},
|
|
447
318
|
_getXHR: function _getXHR() {
|