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/weapp/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,68 +38,38 @@ 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
|
XHR = require('./Xhr.weapp');
|
|
90
53
|
var useXDomainRequest = false;
|
|
91
|
-
|
|
92
54
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
93
55
|
useXDomainRequest = true;
|
|
94
56
|
}
|
|
95
|
-
|
|
96
|
-
function ajaxIE9(method
|
|
97
|
-
/*: string*/
|
|
98
|
-
, url
|
|
99
|
-
/*: string*/
|
|
100
|
-
, data
|
|
101
|
-
/*: any*/
|
|
102
|
-
, headers
|
|
103
|
-
/*:: ?: any*/
|
|
104
|
-
, options
|
|
105
|
-
/*:: ?: FullOptions*/
|
|
106
|
-
) {
|
|
57
|
+
function ajaxIE9(method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
|
|
107
58
|
return new _promise.default(function (resolve, reject) {
|
|
108
59
|
var xdr = new XDomainRequest();
|
|
109
|
-
|
|
110
60
|
xdr.onload = function () {
|
|
111
61
|
var response;
|
|
112
|
-
|
|
113
62
|
try {
|
|
114
63
|
response = JSON.parse(xdr.responseText);
|
|
115
64
|
} catch (e) {
|
|
116
65
|
reject(e);
|
|
117
66
|
}
|
|
118
|
-
|
|
119
67
|
if (response) {
|
|
120
68
|
resolve({
|
|
121
69
|
response: response
|
|
122
70
|
});
|
|
123
71
|
}
|
|
124
72
|
};
|
|
125
|
-
|
|
126
73
|
xdr.onerror = xdr.ontimeout = function () {
|
|
127
74
|
// Let's fake a real error message.
|
|
128
75
|
var fakeResponse = {
|
|
@@ -133,73 +80,48 @@ function ajaxIE9(method
|
|
|
133
80
|
};
|
|
134
81
|
reject(fakeResponse);
|
|
135
82
|
};
|
|
136
|
-
|
|
137
83
|
xdr.onprogress = function () {
|
|
138
84
|
if (options && typeof options.progress === 'function') {
|
|
139
85
|
options.progress(xdr.responseText);
|
|
140
86
|
}
|
|
141
87
|
};
|
|
142
|
-
|
|
143
88
|
xdr.open(method, url);
|
|
144
89
|
xdr.send(data);
|
|
145
|
-
|
|
146
90
|
if (options && typeof options.requestTask === 'function') {
|
|
147
91
|
options.requestTask(xdr);
|
|
148
92
|
}
|
|
149
93
|
});
|
|
150
94
|
}
|
|
151
|
-
|
|
152
95
|
var RESTController = {
|
|
153
|
-
ajax: function (method
|
|
154
|
-
/*: string*/
|
|
155
|
-
, url
|
|
156
|
-
/*: string*/
|
|
157
|
-
, data
|
|
158
|
-
/*: any*/
|
|
159
|
-
, headers
|
|
160
|
-
/*:: ?: any*/
|
|
161
|
-
, options
|
|
162
|
-
/*:: ?: FullOptions*/
|
|
163
|
-
) {
|
|
96
|
+
ajax: function (method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
|
|
164
97
|
var _context;
|
|
165
|
-
|
|
166
98
|
if (useXDomainRequest) {
|
|
167
99
|
return ajaxIE9(method, url, data, headers, options);
|
|
168
100
|
}
|
|
169
|
-
|
|
170
101
|
var promise = (0, _promiseUtils.resolvingPromise)();
|
|
171
102
|
var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
|
|
172
103
|
var requestId = isIdempotent ? uuidv4() : '';
|
|
173
104
|
var attempts = 0;
|
|
174
|
-
|
|
175
105
|
(function dispatch() {
|
|
176
106
|
if (XHR == null) {
|
|
177
107
|
throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
178
108
|
}
|
|
179
|
-
|
|
180
109
|
var handled = false;
|
|
181
110
|
var xhr = new XHR();
|
|
182
|
-
|
|
183
111
|
xhr.onreadystatechange = function () {
|
|
184
112
|
if (xhr.readyState !== 4 || handled || xhr._aborted) {
|
|
185
113
|
return;
|
|
186
114
|
}
|
|
187
|
-
|
|
188
115
|
handled = true;
|
|
189
|
-
|
|
190
116
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
191
117
|
var response;
|
|
192
|
-
|
|
193
118
|
try {
|
|
194
119
|
response = JSON.parse(xhr.responseText);
|
|
195
|
-
|
|
196
120
|
if (typeof xhr.getResponseHeader === 'function') {
|
|
197
121
|
var _context2, _context3;
|
|
198
|
-
|
|
199
122
|
if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
|
|
200
123
|
response = xhr.getResponseHeader('x-parse-job-status-id');
|
|
201
124
|
}
|
|
202
|
-
|
|
203
125
|
if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
|
|
204
126
|
response = xhr.getResponseHeader('x-parse-push-status-id');
|
|
205
127
|
}
|
|
@@ -207,7 +129,6 @@ var RESTController = {
|
|
|
207
129
|
} catch (e) {
|
|
208
130
|
promise.reject(e.toString());
|
|
209
131
|
}
|
|
210
|
-
|
|
211
132
|
if (response) {
|
|
212
133
|
promise.resolve({
|
|
213
134
|
response: response,
|
|
@@ -231,9 +152,7 @@ var RESTController = {
|
|
|
231
152
|
promise.reject(xhr);
|
|
232
153
|
}
|
|
233
154
|
};
|
|
234
|
-
|
|
235
155
|
headers = headers || {};
|
|
236
|
-
|
|
237
156
|
if (typeof headers['Content-Type'] !== 'string') {
|
|
238
157
|
headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
|
|
239
158
|
}
|
|
@@ -241,23 +160,18 @@ var RESTController = {
|
|
|
241
160
|
if (_CoreManager.default.get('IS_NODE')) {
|
|
242
161
|
headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
|
|
243
162
|
}
|
|
244
|
-
|
|
245
163
|
if (isIdempotent) {
|
|
246
164
|
headers['X-Parse-Request-Id'] = requestId;
|
|
247
165
|
}
|
|
248
|
-
|
|
249
166
|
if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
|
|
250
167
|
headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
251
168
|
}
|
|
252
|
-
|
|
253
169
|
var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
|
|
254
|
-
|
|
255
170
|
for (var key in customHeaders) {
|
|
256
171
|
headers[key] = customHeaders[key];
|
|
257
172
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (options && typeof options.progress === 'function') {
|
|
173
|
+
if (options && typeof options.progress === 'function') {
|
|
174
|
+
var handleProgress = function handleProgress(type, event) {
|
|
261
175
|
if (event.lengthComputable) {
|
|
262
176
|
options.progress(event.loaded / event.total, event.loaded, event.total, {
|
|
263
177
|
type: type
|
|
@@ -267,25 +181,20 @@ var RESTController = {
|
|
|
267
181
|
type: type
|
|
268
182
|
});
|
|
269
183
|
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
xhr.onprogress = function (event) {
|
|
274
|
-
handleProgress('download', event);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
if (xhr.upload) {
|
|
278
|
-
xhr.upload.onprogress = function (event) {
|
|
279
|
-
handleProgress('upload', event);
|
|
280
184
|
};
|
|
185
|
+
xhr.onprogress = function (event) {
|
|
186
|
+
handleProgress('download', event);
|
|
187
|
+
};
|
|
188
|
+
if (xhr.upload) {
|
|
189
|
+
xhr.upload.onprogress = function (event) {
|
|
190
|
+
handleProgress('upload', event);
|
|
191
|
+
};
|
|
192
|
+
}
|
|
281
193
|
}
|
|
282
|
-
|
|
283
194
|
xhr.open(method, url, true);
|
|
284
|
-
|
|
285
195
|
for (var h in headers) {
|
|
286
196
|
xhr.setRequestHeader(h, headers[h]);
|
|
287
197
|
}
|
|
288
|
-
|
|
289
198
|
xhr.onabort = function () {
|
|
290
199
|
promise.resolve({
|
|
291
200
|
response: {
|
|
@@ -295,69 +204,46 @@ var RESTController = {
|
|
|
295
204
|
xhr: xhr
|
|
296
205
|
});
|
|
297
206
|
};
|
|
298
|
-
|
|
299
207
|
xhr.send(data);
|
|
300
|
-
|
|
301
208
|
if (options && typeof options.requestTask === 'function') {
|
|
302
209
|
options.requestTask(xhr);
|
|
303
210
|
}
|
|
304
211
|
})();
|
|
305
|
-
|
|
306
212
|
return promise;
|
|
307
213
|
},
|
|
308
|
-
request: function request(method
|
|
309
|
-
/*: string*/
|
|
310
|
-
, path
|
|
311
|
-
/*: string*/
|
|
312
|
-
, data
|
|
313
|
-
/*: mixed*/
|
|
314
|
-
, options
|
|
315
|
-
/*:: ?: RequestOptions*/
|
|
316
|
-
) {
|
|
214
|
+
request: function request(method /*: string*/, path /*: string*/, data /*: mixed*/, options /*:: ?: RequestOptions*/) {
|
|
317
215
|
options = options || {};
|
|
318
|
-
|
|
319
216
|
var url = _CoreManager.default.get('SERVER_URL');
|
|
320
|
-
|
|
321
217
|
if (url[url.length - 1] !== '/') {
|
|
322
218
|
url += '/';
|
|
323
219
|
}
|
|
324
|
-
|
|
325
220
|
url += path;
|
|
326
221
|
var payload = {};
|
|
327
|
-
|
|
328
222
|
if (data && (0, _typeof2.default)(data) === 'object') {
|
|
329
223
|
for (var k in data) {
|
|
330
224
|
payload[k] = data[k];
|
|
331
225
|
}
|
|
332
|
-
}
|
|
333
|
-
|
|
226
|
+
}
|
|
334
227
|
|
|
228
|
+
// Add context
|
|
335
229
|
var context = options.context;
|
|
336
|
-
|
|
337
230
|
if (context !== undefined) {
|
|
338
231
|
payload._context = context;
|
|
339
232
|
}
|
|
340
|
-
|
|
341
233
|
if (method !== 'POST') {
|
|
342
234
|
payload._method = method;
|
|
343
235
|
method = 'POST';
|
|
344
236
|
}
|
|
345
|
-
|
|
346
237
|
payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
|
|
347
|
-
|
|
348
238
|
var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
349
|
-
|
|
350
239
|
if (jsKey) {
|
|
351
240
|
payload._JavaScriptKey = jsKey;
|
|
352
241
|
}
|
|
353
|
-
|
|
354
242
|
payload._ClientVersion = _CoreManager.default.get('VERSION');
|
|
355
243
|
var useMasterKey = options.useMasterKey;
|
|
356
|
-
|
|
357
244
|
if (typeof useMasterKey === 'undefined') {
|
|
358
245
|
useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
|
|
359
246
|
}
|
|
360
|
-
|
|
361
247
|
if (useMasterKey) {
|
|
362
248
|
if (_CoreManager.default.get('MASTER_KEY')) {
|
|
363
249
|
delete payload._JavaScriptKey;
|
|
@@ -366,27 +252,20 @@ var RESTController = {
|
|
|
366
252
|
throw new Error('Cannot use the Master Key, it has not been provided.');
|
|
367
253
|
}
|
|
368
254
|
}
|
|
369
|
-
|
|
370
255
|
if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
|
|
371
256
|
payload._RevocableSession = '1';
|
|
372
257
|
}
|
|
373
|
-
|
|
374
258
|
var installationId = options.installationId;
|
|
375
259
|
var installationIdPromise;
|
|
376
|
-
|
|
377
260
|
if (installationId && typeof installationId === 'string') {
|
|
378
261
|
installationIdPromise = _promise.default.resolve(installationId);
|
|
379
262
|
} else {
|
|
380
263
|
var installationController = _CoreManager.default.getInstallationController();
|
|
381
|
-
|
|
382
264
|
installationIdPromise = installationController.currentInstallationId();
|
|
383
265
|
}
|
|
384
|
-
|
|
385
266
|
return installationIdPromise.then(function (iid) {
|
|
386
267
|
payload._InstallationId = iid;
|
|
387
|
-
|
|
388
268
|
var userController = _CoreManager.default.getUserController();
|
|
389
|
-
|
|
390
269
|
if (options && typeof options.sessionToken === 'string') {
|
|
391
270
|
return _promise.default.resolve(options.sessionToken);
|
|
392
271
|
} else if (userController) {
|
|
@@ -394,22 +273,18 @@ var RESTController = {
|
|
|
394
273
|
if (user) {
|
|
395
274
|
return _promise.default.resolve(user.getSessionToken());
|
|
396
275
|
}
|
|
397
|
-
|
|
398
276
|
return _promise.default.resolve(null);
|
|
399
277
|
});
|
|
400
278
|
}
|
|
401
|
-
|
|
402
279
|
return _promise.default.resolve(null);
|
|
403
280
|
}).then(function (token) {
|
|
404
281
|
if (token) {
|
|
405
282
|
payload._SessionToken = token;
|
|
406
283
|
}
|
|
407
|
-
|
|
408
284
|
var payloadString = (0, _stringify.default)(payload);
|
|
409
285
|
return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
|
|
410
286
|
var response = _ref.response,
|
|
411
|
-
|
|
412
|
-
|
|
287
|
+
status = _ref.status;
|
|
413
288
|
if (options.returnStatus) {
|
|
414
289
|
return _objectSpread(_objectSpread({}, response), {}, {
|
|
415
290
|
_status: status
|
|
@@ -424,7 +299,6 @@ var RESTController = {
|
|
|
424
299
|
// Transform the error into an instance of ParseError by trying to parse
|
|
425
300
|
// the error string as JSON
|
|
426
301
|
var error;
|
|
427
|
-
|
|
428
302
|
if (response && response.responseText) {
|
|
429
303
|
try {
|
|
430
304
|
var errorJSON = JSON.parse(response.responseText);
|
|
@@ -437,12 +311,9 @@ var RESTController = {
|
|
|
437
311
|
var message = response.message ? response.message : response;
|
|
438
312
|
error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
|
|
439
313
|
}
|
|
440
|
-
|
|
441
314
|
return _promise.default.reject(error);
|
|
442
315
|
},
|
|
443
|
-
_setXHR: function _setXHR(xhr
|
|
444
|
-
/*: any*/
|
|
445
|
-
) {
|
|
316
|
+
_setXHR: function _setXHR(xhr /*: any*/) {
|
|
446
317
|
XHR = xhr;
|
|
447
318
|
},
|
|
448
319
|
_getXHR: function _getXHR() {
|