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