parse 4.0.1 → 4.1.0-beta.1
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/dist/parse.js +17994 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8738 -17728
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +2 -20
- package/lib/browser/AnonymousUtils.js +6 -35
- package/lib/browser/Cloud.js +12 -70
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -184
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -1
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -35
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -13
- package/lib/browser/LiveQueryClient.js +87 -204
- 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 -12
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +42 -222
- package/lib/browser/Parse.js +12 -106
- package/lib/browser/ParseACL.js +33 -141
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -88
- package/lib/browser/ParseError.js +63 -90
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -82
- 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 +628 -1840
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -63
- package/lib/browser/ParseQuery.js +404 -1505
- package/lib/browser/ParseRelation.js +12 -61
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -201
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -43
- package/lib/browser/RESTController.js +18 -140
- package/lib/browser/SingleInstanceStateController.js +19 -137
- package/lib/browser/Socket.weapp.js +2 -12
- package/lib/browser/Storage.js +10 -73
- package/lib/browser/StorageController.browser.js +4 -17
- package/lib/browser/StorageController.default.js +4 -17
- package/lib/browser/StorageController.react-native.js +6 -33
- package/lib/browser/StorageController.weapp.js +5 -16
- package/lib/browser/TaskQueue.js +1 -22
- package/lib/browser/UniqueInstanceStateController.js +19 -142
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -16
- package/lib/browser/canBeSerialized.js +3 -33
- package/lib/browser/decode.js +3 -33
- package/lib/browser/encode.js +9 -70
- package/lib/browser/equals.js +2 -25
- package/lib/browser/escape.js +1 -8
- package/lib/browser/isRevocableSession.js +2 -11
- package/lib/browser/parseDate.js +2 -13
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -17
- package/lib/browser/unsavedChildren.js +6 -50
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -18
- package/lib/node/AnonymousUtils.js +5 -37
- package/lib/node/Cloud.js +10 -66
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -220
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -1
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -37
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -15
- package/lib/node/LiveQueryClient.js +56 -136
- package/lib/node/LiveQuerySubscription.js +7 -16
- package/lib/node/LocalDatastore.js +19 -175
- package/lib/node/LocalDatastoreController.js +6 -38
- package/lib/node/LocalDatastoreController.react-native.js +6 -45
- package/lib/node/LocalDatastoreUtils.js +1 -6
- package/lib/node/ObjectStateMutations.js +13 -93
- package/lib/node/OfflineQuery.js +20 -152
- package/lib/node/Parse.js +11 -99
- package/lib/node/ParseACL.js +32 -150
- package/lib/node/ParseCLP.js +69 -262
- package/lib/node/ParseConfig.js +16 -84
- package/lib/node/ParseError.js +61 -65
- package/lib/node/ParseFile.js +49 -205
- package/lib/node/ParseGeoPoint.js +21 -82
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -10
- package/lib/node/ParseLiveQuery.js +10 -36
- package/lib/node/ParseObject.js +193 -939
- package/lib/node/ParseOp.js +31 -255
- package/lib/node/ParsePolygon.js +12 -62
- package/lib/node/ParseQuery.js +170 -882
- package/lib/node/ParseRelation.js +11 -61
- package/lib/node/ParseRole.js +10 -57
- package/lib/node/ParseSchema.js +46 -222
- package/lib/node/ParseSession.js +8 -50
- package/lib/node/ParseUser.js +107 -576
- package/lib/node/Push.js +4 -37
- package/lib/node/RESTController.js +8 -110
- package/lib/node/SingleInstanceStateController.js +17 -130
- package/lib/node/Socket.weapp.js +2 -9
- package/lib/node/Storage.js +10 -83
- package/lib/node/StorageController.browser.js +4 -23
- package/lib/node/StorageController.default.js +5 -21
- package/lib/node/StorageController.react-native.js +6 -40
- package/lib/node/StorageController.weapp.js +6 -21
- package/lib/node/TaskQueue.js +1 -17
- package/lib/node/UniqueInstanceStateController.js +16 -133
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -12
- package/lib/node/canBeSerialized.js +2 -28
- package/lib/node/decode.js +1 -26
- package/lib/node/encode.js +3 -54
- package/lib/node/equals.js +0 -18
- package/lib/node/escape.js +1 -6
- package/lib/node/isRevocableSession.js +1 -5
- package/lib/node/parseDate.js +1 -7
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -11
- package/lib/node/unsavedChildren.js +2 -38
- 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 +1 -5
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +4 -52
- 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 +24 -101
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +6 -113
- package/lib/react-native/LocalDatastoreController.js +0 -21
- package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +0 -34
- package/lib/react-native/OfflineQuery.js +2 -137
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +32 -96
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +3 -72
- 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 +3 -25
- package/lib/react-native/ParseObject.js +4 -371
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +6 -262
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +0 -51
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +1 -224
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +1 -70
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +2 -12
- 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 -20
- package/lib/weapp/AnonymousUtils.js +6 -35
- package/lib/weapp/Cloud.js +12 -70
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -184
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -1
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -35
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -13
- package/lib/weapp/LiveQueryClient.js +87 -204
- 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 -12
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +42 -222
- package/lib/weapp/Parse.js +12 -106
- package/lib/weapp/ParseACL.js +33 -141
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -88
- package/lib/weapp/ParseError.js +63 -90
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -82
- 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 +628 -1840
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -63
- package/lib/weapp/ParseQuery.js +404 -1505
- package/lib/weapp/ParseRelation.js +12 -61
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -201
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -43
- package/lib/weapp/RESTController.js +18 -140
- package/lib/weapp/SingleInstanceStateController.js +19 -137
- package/lib/weapp/Socket.weapp.js +2 -12
- package/lib/weapp/Storage.js +10 -73
- package/lib/weapp/StorageController.browser.js +4 -17
- package/lib/weapp/StorageController.default.js +4 -17
- package/lib/weapp/StorageController.react-native.js +6 -33
- package/lib/weapp/StorageController.weapp.js +5 -16
- package/lib/weapp/TaskQueue.js +1 -22
- package/lib/weapp/UniqueInstanceStateController.js +19 -142
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -16
- package/lib/weapp/canBeSerialized.js +3 -33
- package/lib/weapp/decode.js +3 -33
- package/lib/weapp/encode.js +9 -70
- package/lib/weapp/equals.js +2 -25
- package/lib/weapp/escape.js +1 -8
- package/lib/weapp/isRevocableSession.js +2 -11
- package/lib/weapp/parseDate.js +2 -13
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -17
- package/lib/weapp/unsavedChildren.js +6 -50
- package/lib/weapp/uuid.js +1 -6
- package/package.json +45 -43
package/lib/browser/Push.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
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
14
|
* @flow
|
|
@@ -56,43 +50,29 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
|
56
50
|
* @returns {Promise} A promise that is fulfilled when the push request
|
|
57
51
|
* completes.
|
|
58
52
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function send(data
|
|
62
|
-
/*: PushData*/
|
|
63
|
-
)
|
|
64
|
-
/*: Promise*/
|
|
65
|
-
{
|
|
66
|
-
var options
|
|
67
|
-
/*:: ?: FullOptions*/
|
|
68
|
-
= arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
-
|
|
53
|
+
function send(data /*: PushData*/) /*: Promise*/{
|
|
54
|
+
var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
70
55
|
if (data.where && data.where instanceof _ParseQuery.default) {
|
|
71
56
|
data.where = data.where.toJSON().where;
|
|
72
57
|
}
|
|
73
|
-
|
|
74
58
|
if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
|
|
75
59
|
data.push_time = data.push_time.toJSON();
|
|
76
60
|
}
|
|
77
|
-
|
|
78
61
|
if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
|
|
79
62
|
data.expiration_time = data.expiration_time.toJSON();
|
|
80
63
|
}
|
|
81
|
-
|
|
82
64
|
if (data.expiration_time && data.expiration_interval) {
|
|
83
65
|
throw new Error('expiration_time and expiration_interval cannot both be set.');
|
|
84
66
|
}
|
|
85
|
-
|
|
86
67
|
var pushOptions = {
|
|
87
68
|
useMasterKey: true
|
|
88
69
|
};
|
|
89
|
-
|
|
90
70
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
91
71
|
pushOptions.useMasterKey = options.useMasterKey;
|
|
92
72
|
}
|
|
93
|
-
|
|
94
73
|
return _CoreManager.default.getPushController().send(data, pushOptions);
|
|
95
74
|
}
|
|
75
|
+
|
|
96
76
|
/**
|
|
97
77
|
* Gets push status by Id
|
|
98
78
|
*
|
|
@@ -106,36 +86,20 @@ function send(data
|
|
|
106
86
|
* </ul>
|
|
107
87
|
* @returns {Parse.Object} Status of Push.
|
|
108
88
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
function getPushStatus(pushStatusId
|
|
112
|
-
/*: string*/
|
|
113
|
-
)
|
|
114
|
-
/*: Promise<string>*/
|
|
115
|
-
{
|
|
116
|
-
var options
|
|
117
|
-
/*:: ?: FullOptions*/
|
|
118
|
-
= 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] : {};
|
|
119
91
|
var pushOptions = {
|
|
120
92
|
useMasterKey: true
|
|
121
93
|
};
|
|
122
|
-
|
|
123
94
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
124
95
|
pushOptions.useMasterKey = options.useMasterKey;
|
|
125
96
|
}
|
|
126
|
-
|
|
127
97
|
var query = new _ParseQuery.default('_PushStatus');
|
|
128
98
|
return query.get(pushStatusId, pushOptions);
|
|
129
99
|
}
|
|
130
|
-
|
|
131
100
|
var DefaultController = {
|
|
132
|
-
send: function (data
|
|
133
|
-
/*: PushData*/
|
|
134
|
-
, options
|
|
135
|
-
/*:: ?: FullOptions*/
|
|
136
|
-
) {
|
|
101
|
+
send: function (data /*: PushData*/, options /*:: ?: FullOptions*/) {
|
|
137
102
|
return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
|
|
138
103
|
}
|
|
139
104
|
};
|
|
140
|
-
|
|
141
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,60 +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
44
|
* @flow
|
|
69
45
|
*/
|
|
70
|
-
|
|
71
46
|
/* global XMLHttpRequest, XDomainRequest */
|
|
72
|
-
|
|
73
|
-
|
|
74
47
|
var uuidv4 = require('./uuid');
|
|
75
|
-
|
|
76
48
|
var XHR = null;
|
|
77
|
-
|
|
78
49
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
79
50
|
XHR = XMLHttpRequest;
|
|
80
51
|
}
|
|
81
|
-
|
|
82
52
|
var useXDomainRequest = false;
|
|
83
|
-
|
|
84
53
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
85
54
|
useXDomainRequest = true;
|
|
86
55
|
}
|
|
87
|
-
|
|
88
|
-
function ajaxIE9(method
|
|
89
|
-
/*: string*/
|
|
90
|
-
, url
|
|
91
|
-
/*: string*/
|
|
92
|
-
, data
|
|
93
|
-
/*: any*/
|
|
94
|
-
, headers
|
|
95
|
-
/*:: ?: any*/
|
|
96
|
-
, options
|
|
97
|
-
/*:: ?: FullOptions*/
|
|
98
|
-
) {
|
|
56
|
+
function ajaxIE9(method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
|
|
99
57
|
return new _promise.default(function (resolve, reject) {
|
|
100
58
|
var xdr = new XDomainRequest();
|
|
101
|
-
|
|
102
59
|
xdr.onload = function () {
|
|
103
60
|
var response;
|
|
104
|
-
|
|
105
61
|
try {
|
|
106
62
|
response = JSON.parse(xdr.responseText);
|
|
107
63
|
} catch (e) {
|
|
108
64
|
reject(e);
|
|
109
65
|
}
|
|
110
|
-
|
|
111
66
|
if (response) {
|
|
112
67
|
resolve({
|
|
113
68
|
response: response
|
|
114
69
|
});
|
|
115
70
|
}
|
|
116
71
|
};
|
|
117
|
-
|
|
118
72
|
xdr.onerror = xdr.ontimeout = function () {
|
|
119
73
|
// Let's fake a real error message.
|
|
120
74
|
var fakeResponse = {
|
|
@@ -125,73 +79,48 @@ function ajaxIE9(method
|
|
|
125
79
|
};
|
|
126
80
|
reject(fakeResponse);
|
|
127
81
|
};
|
|
128
|
-
|
|
129
82
|
xdr.onprogress = function () {
|
|
130
83
|
if (options && typeof options.progress === 'function') {
|
|
131
84
|
options.progress(xdr.responseText);
|
|
132
85
|
}
|
|
133
86
|
};
|
|
134
|
-
|
|
135
87
|
xdr.open(method, url);
|
|
136
88
|
xdr.send(data);
|
|
137
|
-
|
|
138
89
|
if (options && typeof options.requestTask === 'function') {
|
|
139
90
|
options.requestTask(xdr);
|
|
140
91
|
}
|
|
141
92
|
});
|
|
142
93
|
}
|
|
143
|
-
|
|
144
94
|
var RESTController = {
|
|
145
|
-
ajax: function (method
|
|
146
|
-
/*: string*/
|
|
147
|
-
, url
|
|
148
|
-
/*: string*/
|
|
149
|
-
, data
|
|
150
|
-
/*: any*/
|
|
151
|
-
, headers
|
|
152
|
-
/*:: ?: any*/
|
|
153
|
-
, options
|
|
154
|
-
/*:: ?: FullOptions*/
|
|
155
|
-
) {
|
|
95
|
+
ajax: function (method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
|
|
156
96
|
var _context;
|
|
157
|
-
|
|
158
97
|
if (useXDomainRequest) {
|
|
159
98
|
return ajaxIE9(method, url, data, headers, options);
|
|
160
99
|
}
|
|
161
|
-
|
|
162
100
|
var promise = (0, _promiseUtils.resolvingPromise)();
|
|
163
101
|
var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
|
|
164
102
|
var requestId = isIdempotent ? uuidv4() : '';
|
|
165
103
|
var attempts = 0;
|
|
166
|
-
|
|
167
104
|
(function dispatch() {
|
|
168
105
|
if (XHR == null) {
|
|
169
106
|
throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
170
107
|
}
|
|
171
|
-
|
|
172
108
|
var handled = false;
|
|
173
109
|
var xhr = new XHR();
|
|
174
|
-
|
|
175
110
|
xhr.onreadystatechange = function () {
|
|
176
111
|
if (xhr.readyState !== 4 || handled || xhr._aborted) {
|
|
177
112
|
return;
|
|
178
113
|
}
|
|
179
|
-
|
|
180
114
|
handled = true;
|
|
181
|
-
|
|
182
115
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
183
116
|
var response;
|
|
184
|
-
|
|
185
117
|
try {
|
|
186
118
|
response = JSON.parse(xhr.responseText);
|
|
187
|
-
|
|
188
119
|
if (typeof xhr.getResponseHeader === 'function') {
|
|
189
120
|
var _context2, _context3;
|
|
190
|
-
|
|
191
121
|
if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
|
|
192
122
|
response = xhr.getResponseHeader('x-parse-job-status-id');
|
|
193
123
|
}
|
|
194
|
-
|
|
195
124
|
if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
|
|
196
125
|
response = xhr.getResponseHeader('x-parse-push-status-id');
|
|
197
126
|
}
|
|
@@ -199,7 +128,6 @@ var RESTController = {
|
|
|
199
128
|
} catch (e) {
|
|
200
129
|
promise.reject(e.toString());
|
|
201
130
|
}
|
|
202
|
-
|
|
203
131
|
if (response) {
|
|
204
132
|
promise.resolve({
|
|
205
133
|
response: response,
|
|
@@ -223,9 +151,7 @@ var RESTController = {
|
|
|
223
151
|
promise.reject(xhr);
|
|
224
152
|
}
|
|
225
153
|
};
|
|
226
|
-
|
|
227
154
|
headers = headers || {};
|
|
228
|
-
|
|
229
155
|
if (typeof headers['Content-Type'] !== 'string') {
|
|
230
156
|
headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
|
|
231
157
|
}
|
|
@@ -233,21 +159,16 @@ var RESTController = {
|
|
|
233
159
|
if (_CoreManager.default.get('IS_NODE')) {
|
|
234
160
|
headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
|
|
235
161
|
}
|
|
236
|
-
|
|
237
162
|
if (isIdempotent) {
|
|
238
163
|
headers['X-Parse-Request-Id'] = requestId;
|
|
239
164
|
}
|
|
240
|
-
|
|
241
165
|
if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
|
|
242
166
|
headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
243
167
|
}
|
|
244
|
-
|
|
245
168
|
var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
|
|
246
|
-
|
|
247
169
|
for (var key in customHeaders) {
|
|
248
170
|
headers[key] = customHeaders[key];
|
|
249
171
|
}
|
|
250
|
-
|
|
251
172
|
if (options && typeof options.progress === 'function') {
|
|
252
173
|
var handleProgress = function handleProgress(type, event) {
|
|
253
174
|
if (event.lengthComputable) {
|
|
@@ -260,24 +181,19 @@ var RESTController = {
|
|
|
260
181
|
});
|
|
261
182
|
}
|
|
262
183
|
};
|
|
263
|
-
|
|
264
184
|
xhr.onprogress = function (event) {
|
|
265
185
|
handleProgress('download', event);
|
|
266
186
|
};
|
|
267
|
-
|
|
268
187
|
if (xhr.upload) {
|
|
269
188
|
xhr.upload.onprogress = function (event) {
|
|
270
189
|
handleProgress('upload', event);
|
|
271
190
|
};
|
|
272
191
|
}
|
|
273
192
|
}
|
|
274
|
-
|
|
275
193
|
xhr.open(method, url, true);
|
|
276
|
-
|
|
277
194
|
for (var h in headers) {
|
|
278
195
|
xhr.setRequestHeader(h, headers[h]);
|
|
279
196
|
}
|
|
280
|
-
|
|
281
197
|
xhr.onabort = function () {
|
|
282
198
|
promise.resolve({
|
|
283
199
|
response: {
|
|
@@ -287,69 +203,46 @@ var RESTController = {
|
|
|
287
203
|
xhr: xhr
|
|
288
204
|
});
|
|
289
205
|
};
|
|
290
|
-
|
|
291
206
|
xhr.send(data);
|
|
292
|
-
|
|
293
207
|
if (options && typeof options.requestTask === 'function') {
|
|
294
208
|
options.requestTask(xhr);
|
|
295
209
|
}
|
|
296
210
|
})();
|
|
297
|
-
|
|
298
211
|
return promise;
|
|
299
212
|
},
|
|
300
|
-
request: function request(method
|
|
301
|
-
/*: string*/
|
|
302
|
-
, path
|
|
303
|
-
/*: string*/
|
|
304
|
-
, data
|
|
305
|
-
/*: mixed*/
|
|
306
|
-
, options
|
|
307
|
-
/*:: ?: RequestOptions*/
|
|
308
|
-
) {
|
|
213
|
+
request: function request(method /*: string*/, path /*: string*/, data /*: mixed*/, options /*:: ?: RequestOptions*/) {
|
|
309
214
|
options = options || {};
|
|
310
|
-
|
|
311
215
|
var url = _CoreManager.default.get('SERVER_URL');
|
|
312
|
-
|
|
313
216
|
if (url[url.length - 1] !== '/') {
|
|
314
217
|
url += '/';
|
|
315
218
|
}
|
|
316
|
-
|
|
317
219
|
url += path;
|
|
318
220
|
var payload = {};
|
|
319
|
-
|
|
320
221
|
if (data && (0, _typeof2.default)(data) === 'object') {
|
|
321
222
|
for (var k in data) {
|
|
322
223
|
payload[k] = data[k];
|
|
323
224
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
225
|
+
}
|
|
326
226
|
|
|
227
|
+
// Add context
|
|
327
228
|
var context = options.context;
|
|
328
|
-
|
|
329
229
|
if (context !== undefined) {
|
|
330
230
|
payload._context = context;
|
|
331
231
|
}
|
|
332
|
-
|
|
333
232
|
if (method !== 'POST') {
|
|
334
233
|
payload._method = method;
|
|
335
234
|
method = 'POST';
|
|
336
235
|
}
|
|
337
|
-
|
|
338
236
|
payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
|
|
339
|
-
|
|
340
237
|
var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
341
|
-
|
|
342
238
|
if (jsKey) {
|
|
343
239
|
payload._JavaScriptKey = jsKey;
|
|
344
240
|
}
|
|
345
|
-
|
|
346
241
|
payload._ClientVersion = _CoreManager.default.get('VERSION');
|
|
347
242
|
var useMasterKey = options.useMasterKey;
|
|
348
|
-
|
|
349
243
|
if (typeof useMasterKey === 'undefined') {
|
|
350
244
|
useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
|
|
351
245
|
}
|
|
352
|
-
|
|
353
246
|
if (useMasterKey) {
|
|
354
247
|
if (_CoreManager.default.get('MASTER_KEY')) {
|
|
355
248
|
delete payload._JavaScriptKey;
|
|
@@ -358,27 +251,20 @@ var RESTController = {
|
|
|
358
251
|
throw new Error('Cannot use the Master Key, it has not been provided.');
|
|
359
252
|
}
|
|
360
253
|
}
|
|
361
|
-
|
|
362
254
|
if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
|
|
363
255
|
payload._RevocableSession = '1';
|
|
364
256
|
}
|
|
365
|
-
|
|
366
257
|
var installationId = options.installationId;
|
|
367
258
|
var installationIdPromise;
|
|
368
|
-
|
|
369
259
|
if (installationId && typeof installationId === 'string') {
|
|
370
260
|
installationIdPromise = _promise.default.resolve(installationId);
|
|
371
261
|
} else {
|
|
372
262
|
var installationController = _CoreManager.default.getInstallationController();
|
|
373
|
-
|
|
374
263
|
installationIdPromise = installationController.currentInstallationId();
|
|
375
264
|
}
|
|
376
|
-
|
|
377
265
|
return installationIdPromise.then(function (iid) {
|
|
378
266
|
payload._InstallationId = iid;
|
|
379
|
-
|
|
380
267
|
var userController = _CoreManager.default.getUserController();
|
|
381
|
-
|
|
382
268
|
if (options && typeof options.sessionToken === 'string') {
|
|
383
269
|
return _promise.default.resolve(options.sessionToken);
|
|
384
270
|
} else if (userController) {
|
|
@@ -386,22 +272,18 @@ var RESTController = {
|
|
|
386
272
|
if (user) {
|
|
387
273
|
return _promise.default.resolve(user.getSessionToken());
|
|
388
274
|
}
|
|
389
|
-
|
|
390
275
|
return _promise.default.resolve(null);
|
|
391
276
|
});
|
|
392
277
|
}
|
|
393
|
-
|
|
394
278
|
return _promise.default.resolve(null);
|
|
395
279
|
}).then(function (token) {
|
|
396
280
|
if (token) {
|
|
397
281
|
payload._SessionToken = token;
|
|
398
282
|
}
|
|
399
|
-
|
|
400
283
|
var payloadString = (0, _stringify.default)(payload);
|
|
401
284
|
return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
|
|
402
285
|
var response = _ref.response,
|
|
403
|
-
|
|
404
|
-
|
|
286
|
+
status = _ref.status;
|
|
405
287
|
if (options.returnStatus) {
|
|
406
288
|
return _objectSpread(_objectSpread({}, response), {}, {
|
|
407
289
|
_status: status
|
|
@@ -416,7 +298,6 @@ var RESTController = {
|
|
|
416
298
|
// Transform the error into an instance of ParseError by trying to parse
|
|
417
299
|
// the error string as JSON
|
|
418
300
|
var error;
|
|
419
|
-
|
|
420
301
|
if (response && response.responseText) {
|
|
421
302
|
try {
|
|
422
303
|
var errorJSON = JSON.parse(response.responseText);
|
|
@@ -429,12 +310,9 @@ var RESTController = {
|
|
|
429
310
|
var message = response.message ? response.message : response;
|
|
430
311
|
error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
|
|
431
312
|
}
|
|
432
|
-
|
|
433
313
|
return _promise.default.reject(error);
|
|
434
314
|
},
|
|
435
|
-
_setXHR: function _setXHR(xhr
|
|
436
|
-
/*: any*/
|
|
437
|
-
) {
|
|
315
|
+
_setXHR: function _setXHR(xhr /*: any*/) {
|
|
438
316
|
XHR = xhr;
|
|
439
317
|
},
|
|
440
318
|
_getXHR: function _getXHR() {
|