parse 4.0.0-alpha.1 → 4.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +167 -25
- package/NOTICE +10 -0
- package/README.md +6 -5
- package/dist/parse.js +12838 -21190
- package/dist/parse.min.js +7 -6
- package/dist/parse.weapp.js +7921 -17062
- package/dist/parse.weapp.min.js +7 -6
- package/lib/browser/Analytics.js +2 -27
- package/lib/browser/AnonymousUtils.js +6 -42
- package/lib/browser/Cloud.js +12 -77
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -191
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -8
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -42
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -20
- package/lib/browser/LiveQueryClient.js +105 -213
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -19
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +61 -222
- package/lib/browser/Parse.js +12 -115
- package/lib/browser/ParseACL.js +33 -148
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -95
- package/lib/browser/ParseError.js +63 -99
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -89
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +665 -1845
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -70
- package/lib/browser/ParseQuery.js +403 -1504
- package/lib/browser/ParseRelation.js +12 -68
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -208
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -50
- package/lib/browser/RESTController.js +28 -157
- package/lib/browser/SingleInstanceStateController.js +19 -144
- package/lib/browser/Socket.weapp.js +0 -10
- package/lib/browser/Storage.js +10 -80
- package/lib/browser/StorageController.browser.js +4 -24
- package/lib/browser/StorageController.default.js +4 -24
- package/lib/browser/StorageController.react-native.js +6 -40
- package/lib/browser/StorageController.weapp.js +5 -23
- package/lib/browser/TaskQueue.js +1 -29
- package/lib/browser/UniqueInstanceStateController.js +19 -149
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -23
- package/lib/browser/canBeSerialized.js +3 -40
- package/lib/browser/decode.js +3 -40
- package/lib/browser/encode.js +9 -77
- package/lib/browser/equals.js +2 -34
- package/lib/browser/escape.js +1 -15
- package/lib/browser/isRevocableSession.js +2 -18
- package/lib/browser/parseDate.js +2 -20
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -24
- package/lib/browser/unsavedChildren.js +6 -57
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -25
- package/lib/node/AnonymousUtils.js +5 -44
- package/lib/node/Cloud.js +10 -73
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -227
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -8
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -44
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -22
- package/lib/node/LiveQueryClient.js +72 -154
- package/lib/node/LiveQuerySubscription.js +7 -26
- package/lib/node/LocalDatastore.js +19 -182
- package/lib/node/LocalDatastoreController.js +6 -45
- package/lib/node/LocalDatastoreController.react-native.js +6 -52
- package/lib/node/LocalDatastoreUtils.js +1 -13
- package/lib/node/ObjectStateMutations.js +13 -100
- package/lib/node/OfflineQuery.js +27 -151
- package/lib/node/Parse.js +11 -108
- package/lib/node/ParseACL.js +32 -157
- package/lib/node/ParseCLP.js +69 -269
- package/lib/node/ParseConfig.js +16 -91
- package/lib/node/ParseError.js +61 -74
- package/lib/node/ParseFile.js +49 -212
- package/lib/node/ParseGeoPoint.js +21 -89
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -17
- package/lib/node/ParseLiveQuery.js +10 -43
- package/lib/node/ParseObject.js +229 -964
- package/lib/node/ParseOp.js +31 -262
- package/lib/node/ParsePolygon.js +12 -69
- package/lib/node/ParseQuery.js +169 -888
- package/lib/node/ParseRelation.js +11 -68
- package/lib/node/ParseRole.js +10 -64
- package/lib/node/ParseSchema.js +46 -229
- package/lib/node/ParseSession.js +8 -57
- package/lib/node/ParseUser.js +107 -583
- package/lib/node/Push.js +4 -44
- package/lib/node/RESTController.js +18 -127
- package/lib/node/SingleInstanceStateController.js +17 -137
- package/lib/node/Socket.weapp.js +0 -7
- package/lib/node/Storage.js +10 -90
- package/lib/node/StorageController.browser.js +4 -30
- package/lib/node/StorageController.default.js +5 -28
- package/lib/node/StorageController.react-native.js +6 -47
- package/lib/node/StorageController.weapp.js +6 -28
- package/lib/node/TaskQueue.js +1 -24
- package/lib/node/UniqueInstanceStateController.js +16 -140
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -19
- package/lib/node/canBeSerialized.js +2 -35
- package/lib/node/decode.js +1 -33
- package/lib/node/encode.js +3 -61
- package/lib/node/equals.js +0 -27
- package/lib/node/escape.js +1 -13
- package/lib/node/isRevocableSession.js +1 -12
- package/lib/node/parseDate.js +1 -14
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -18
- package/lib/node/unsavedChildren.js +2 -45
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +2 -6
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +156 -711
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +46 -157
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +281 -948
- package/lib/react-native/LocalDatastoreController.js +71 -552
- package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +2 -65
- package/lib/react-native/OfflineQuery.js +25 -196
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +23 -161
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +55 -529
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +55 -472
- package/lib/react-native/ParseObject.js +245 -1246
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +182 -874
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +3 -54
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +95 -773
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +12 -109
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +0 -10
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -27
- package/lib/weapp/AnonymousUtils.js +6 -42
- package/lib/weapp/Cloud.js +12 -77
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -191
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -8
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -42
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -20
- package/lib/weapp/LiveQueryClient.js +105 -213
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -19
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +61 -222
- package/lib/weapp/Parse.js +12 -115
- package/lib/weapp/ParseACL.js +33 -148
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -95
- package/lib/weapp/ParseError.js +63 -99
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -89
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +665 -1845
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -70
- package/lib/weapp/ParseQuery.js +403 -1504
- package/lib/weapp/ParseRelation.js +12 -68
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -208
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -50
- package/lib/weapp/RESTController.js +28 -157
- package/lib/weapp/SingleInstanceStateController.js +19 -144
- package/lib/weapp/Socket.weapp.js +0 -10
- package/lib/weapp/Storage.js +10 -80
- package/lib/weapp/StorageController.browser.js +4 -24
- package/lib/weapp/StorageController.default.js +4 -24
- package/lib/weapp/StorageController.react-native.js +6 -40
- package/lib/weapp/StorageController.weapp.js +5 -23
- package/lib/weapp/TaskQueue.js +1 -29
- package/lib/weapp/UniqueInstanceStateController.js +19 -149
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -23
- package/lib/weapp/canBeSerialized.js +3 -40
- package/lib/weapp/decode.js +3 -40
- package/lib/weapp/encode.js +9 -77
- package/lib/weapp/equals.js +2 -34
- package/lib/weapp/escape.js +1 -15
- package/lib/weapp/isRevocableSession.js +2 -18
- package/lib/weapp/parseDate.js +2 -20
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -24
- package/lib/weapp/unsavedChildren.js +6 -57
- package/lib/weapp/uuid.js +1 -6
- package/package.json +35 -31
- package/PATENTS +0 -37
package/lib/react-native/Push.js
CHANGED
|
@@ -1,63 +1,47 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.getPushStatus = getPushStatus;
|
|
7
6
|
exports.send = send;
|
|
8
|
-
|
|
9
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
10
|
-
|
|
11
8
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
12
|
-
|
|
13
9
|
function send(data) {
|
|
14
10
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15
|
-
|
|
16
11
|
if (data.where && data.where instanceof _ParseQuery.default) {
|
|
17
12
|
data.where = data.where.toJSON().where;
|
|
18
13
|
}
|
|
19
|
-
|
|
20
14
|
if (data.push_time && typeof data.push_time === 'object') {
|
|
21
15
|
data.push_time = data.push_time.toJSON();
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
if (data.expiration_time && typeof data.expiration_time === 'object') {
|
|
25
18
|
data.expiration_time = data.expiration_time.toJSON();
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
if (data.expiration_time && data.expiration_interval) {
|
|
29
21
|
throw new Error('expiration_time and expiration_interval cannot both be set.');
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
var pushOptions = {
|
|
33
24
|
useMasterKey: true
|
|
34
25
|
};
|
|
35
|
-
|
|
36
26
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
37
27
|
pushOptions.useMasterKey = options.useMasterKey;
|
|
38
28
|
}
|
|
39
|
-
|
|
40
29
|
return _CoreManager.default.getPushController().send(data, pushOptions);
|
|
41
30
|
}
|
|
42
|
-
|
|
43
31
|
function getPushStatus(pushStatusId) {
|
|
44
32
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
33
|
var pushOptions = {
|
|
46
34
|
useMasterKey: true
|
|
47
35
|
};
|
|
48
|
-
|
|
49
36
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
50
37
|
pushOptions.useMasterKey = options.useMasterKey;
|
|
51
38
|
}
|
|
52
|
-
|
|
53
39
|
var query = new _ParseQuery.default('_PushStatus');
|
|
54
40
|
return query.get(pushStatusId, pushOptions);
|
|
55
41
|
}
|
|
56
|
-
|
|
57
42
|
var DefaultController = {
|
|
58
43
|
send: function (data, options) {
|
|
59
44
|
return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
|
|
60
45
|
}
|
|
61
46
|
};
|
|
62
|
-
|
|
63
47
|
_CoreManager.default.setPushController(DefaultController);
|
|
@@ -1,73 +1,32 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
4
|
-
|
|
5
2
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
6
|
-
|
|
7
3
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
8
|
-
|
|
9
4
|
var _promiseUtils = require("./promiseUtils");
|
|
10
|
-
|
|
11
|
-
function ownKeys(object, enumerableOnly) {
|
|
12
|
-
var keys = Object.keys(object);
|
|
13
|
-
|
|
14
|
-
if (Object.getOwnPropertySymbols) {
|
|
15
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
17
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
18
|
-
})), keys.push.apply(keys, symbols);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return keys;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _objectSpread(target) {
|
|
25
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
26
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
27
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
28
|
-
(0, _defineProperty2.default)(target, key, source[key]);
|
|
29
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
30
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return target;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
5
|
var uuidv4 = require('./uuid');
|
|
38
|
-
|
|
39
6
|
var XHR = null;
|
|
40
|
-
|
|
41
7
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
42
8
|
XHR = XMLHttpRequest;
|
|
43
9
|
}
|
|
44
|
-
|
|
45
10
|
var useXDomainRequest = false;
|
|
46
|
-
|
|
47
11
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
48
12
|
useXDomainRequest = true;
|
|
49
13
|
}
|
|
50
|
-
|
|
51
14
|
function ajaxIE9(method, url, data, headers, options) {
|
|
52
15
|
return new Promise(function (resolve, reject) {
|
|
53
16
|
var xdr = new XDomainRequest();
|
|
54
|
-
|
|
55
17
|
xdr.onload = function () {
|
|
56
18
|
var response;
|
|
57
|
-
|
|
58
19
|
try {
|
|
59
20
|
response = JSON.parse(xdr.responseText);
|
|
60
21
|
} catch (e) {
|
|
61
22
|
reject(e);
|
|
62
23
|
}
|
|
63
|
-
|
|
64
24
|
if (response) {
|
|
65
25
|
resolve({
|
|
66
26
|
response: response
|
|
67
27
|
});
|
|
68
28
|
}
|
|
69
29
|
};
|
|
70
|
-
|
|
71
30
|
xdr.onerror = xdr.ontimeout = function () {
|
|
72
31
|
var fakeResponse = {
|
|
73
32
|
responseText: JSON.stringify({
|
|
@@ -77,59 +36,46 @@ function ajaxIE9(method, url, data, headers, options) {
|
|
|
77
36
|
};
|
|
78
37
|
reject(fakeResponse);
|
|
79
38
|
};
|
|
80
|
-
|
|
81
39
|
xdr.onprogress = function () {
|
|
82
40
|
if (options && typeof options.progress === 'function') {
|
|
83
41
|
options.progress(xdr.responseText);
|
|
84
42
|
}
|
|
85
43
|
};
|
|
86
|
-
|
|
87
44
|
xdr.open(method, url);
|
|
88
45
|
xdr.send(data);
|
|
89
|
-
|
|
90
46
|
if (options && typeof options.requestTask === 'function') {
|
|
91
47
|
options.requestTask(xdr);
|
|
92
48
|
}
|
|
93
49
|
});
|
|
94
50
|
}
|
|
95
|
-
|
|
96
51
|
var RESTController = {
|
|
97
52
|
ajax: function (method, url, data, headers, options) {
|
|
98
53
|
if (useXDomainRequest) {
|
|
99
54
|
return ajaxIE9(method, url, data, headers, options);
|
|
100
55
|
}
|
|
101
|
-
|
|
102
56
|
var promise = (0, _promiseUtils.resolvingPromise)();
|
|
103
57
|
var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && ['POST', 'PUT'].includes(method);
|
|
104
58
|
var requestId = isIdempotent ? uuidv4() : '';
|
|
105
59
|
var attempts = 0;
|
|
106
|
-
|
|
107
60
|
(function dispatch() {
|
|
108
61
|
if (XHR == null) {
|
|
109
62
|
throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
110
63
|
}
|
|
111
|
-
|
|
112
64
|
var handled = false;
|
|
113
65
|
var xhr = new XHR();
|
|
114
|
-
|
|
115
66
|
xhr.onreadystatechange = function () {
|
|
116
67
|
if (xhr.readyState !== 4 || handled || xhr._aborted) {
|
|
117
68
|
return;
|
|
118
69
|
}
|
|
119
|
-
|
|
120
70
|
handled = true;
|
|
121
|
-
|
|
122
71
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
123
72
|
var response;
|
|
124
|
-
|
|
125
73
|
try {
|
|
126
74
|
response = JSON.parse(xhr.responseText);
|
|
127
|
-
|
|
128
75
|
if (typeof xhr.getResponseHeader === 'function') {
|
|
129
76
|
if ((xhr.getAllResponseHeaders() || '').includes('x-parse-job-status-id: ')) {
|
|
130
77
|
response = xhr.getResponseHeader('x-parse-job-status-id');
|
|
131
78
|
}
|
|
132
|
-
|
|
133
79
|
if ((xhr.getAllResponseHeaders() || '').includes('x-parse-push-status-id: ')) {
|
|
134
80
|
response = xhr.getResponseHeader('x-parse-push-status-id');
|
|
135
81
|
}
|
|
@@ -137,7 +83,6 @@ var RESTController = {
|
|
|
137
83
|
} catch (e) {
|
|
138
84
|
promise.reject(e.toString());
|
|
139
85
|
}
|
|
140
|
-
|
|
141
86
|
if (response) {
|
|
142
87
|
promise.resolve({
|
|
143
88
|
response: response,
|
|
@@ -158,33 +103,25 @@ var RESTController = {
|
|
|
158
103
|
promise.reject(xhr);
|
|
159
104
|
}
|
|
160
105
|
};
|
|
161
|
-
|
|
162
106
|
headers = headers || {};
|
|
163
|
-
|
|
164
107
|
if (typeof headers['Content-Type'] !== 'string') {
|
|
165
108
|
headers['Content-Type'] = 'text/plain';
|
|
166
109
|
}
|
|
167
|
-
|
|
168
110
|
if (_CoreManager.default.get('IS_NODE')) {
|
|
169
111
|
headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
|
|
170
112
|
}
|
|
171
|
-
|
|
172
113
|
if (isIdempotent) {
|
|
173
114
|
headers['X-Parse-Request-Id'] = requestId;
|
|
174
115
|
}
|
|
175
|
-
|
|
176
116
|
if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
|
|
177
117
|
headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
178
118
|
}
|
|
179
|
-
|
|
180
119
|
var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
|
|
181
|
-
|
|
182
120
|
for (var key in customHeaders) {
|
|
183
121
|
headers[key] = customHeaders[key];
|
|
184
122
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (options && typeof options.progress === 'function') {
|
|
123
|
+
if (options && typeof options.progress === 'function') {
|
|
124
|
+
var handleProgress = function handleProgress(type, event) {
|
|
188
125
|
if (event.lengthComputable) {
|
|
189
126
|
options.progress(event.loaded / event.total, event.loaded, event.total, {
|
|
190
127
|
type: type
|
|
@@ -194,25 +131,20 @@ var RESTController = {
|
|
|
194
131
|
type: type
|
|
195
132
|
});
|
|
196
133
|
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
xhr.onprogress = function (event) {
|
|
201
|
-
handleProgress('download', event);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
if (xhr.upload) {
|
|
205
|
-
xhr.upload.onprogress = function (event) {
|
|
206
|
-
handleProgress('upload', event);
|
|
207
134
|
};
|
|
135
|
+
xhr.onprogress = function (event) {
|
|
136
|
+
handleProgress('download', event);
|
|
137
|
+
};
|
|
138
|
+
if (xhr.upload) {
|
|
139
|
+
xhr.upload.onprogress = function (event) {
|
|
140
|
+
handleProgress('upload', event);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
208
143
|
}
|
|
209
|
-
|
|
210
144
|
xhr.open(method, url, true);
|
|
211
|
-
|
|
212
145
|
for (var h in headers) {
|
|
213
146
|
xhr.setRequestHeader(h, headers[h]);
|
|
214
147
|
}
|
|
215
|
-
|
|
216
148
|
xhr.onabort = function () {
|
|
217
149
|
promise.resolve({
|
|
218
150
|
response: {
|
|
@@ -222,60 +154,44 @@ var RESTController = {
|
|
|
222
154
|
xhr: xhr
|
|
223
155
|
});
|
|
224
156
|
};
|
|
225
|
-
|
|
226
157
|
xhr.send(data);
|
|
227
|
-
|
|
228
158
|
if (options && typeof options.requestTask === 'function') {
|
|
229
159
|
options.requestTask(xhr);
|
|
230
160
|
}
|
|
231
161
|
})();
|
|
232
|
-
|
|
233
162
|
return promise;
|
|
234
163
|
},
|
|
235
164
|
request: function request(method, path, data, options) {
|
|
236
165
|
options = options || {};
|
|
237
|
-
|
|
238
166
|
var url = _CoreManager.default.get('SERVER_URL');
|
|
239
|
-
|
|
240
167
|
if (url[url.length - 1] !== '/') {
|
|
241
168
|
url += '/';
|
|
242
169
|
}
|
|
243
|
-
|
|
244
170
|
url += path;
|
|
245
171
|
var payload = {};
|
|
246
|
-
|
|
247
172
|
if (data && typeof data === 'object') {
|
|
248
173
|
for (var k in data) {
|
|
249
174
|
payload[k] = data[k];
|
|
250
175
|
}
|
|
251
176
|
}
|
|
252
|
-
|
|
253
177
|
var context = options.context;
|
|
254
|
-
|
|
255
178
|
if (context !== undefined) {
|
|
256
179
|
payload._context = context;
|
|
257
180
|
}
|
|
258
|
-
|
|
259
181
|
if (method !== 'POST') {
|
|
260
182
|
payload._method = method;
|
|
261
183
|
method = 'POST';
|
|
262
184
|
}
|
|
263
|
-
|
|
264
185
|
payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
|
|
265
|
-
|
|
266
186
|
var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
267
|
-
|
|
268
187
|
if (jsKey) {
|
|
269
188
|
payload._JavaScriptKey = jsKey;
|
|
270
189
|
}
|
|
271
|
-
|
|
272
190
|
payload._ClientVersion = _CoreManager.default.get('VERSION');
|
|
273
191
|
var useMasterKey = options.useMasterKey;
|
|
274
|
-
|
|
275
192
|
if (typeof useMasterKey === 'undefined') {
|
|
276
193
|
useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
|
|
277
194
|
}
|
|
278
|
-
|
|
279
195
|
if (useMasterKey) {
|
|
280
196
|
if (_CoreManager.default.get('MASTER_KEY')) {
|
|
281
197
|
delete payload._JavaScriptKey;
|
|
@@ -284,27 +200,20 @@ var RESTController = {
|
|
|
284
200
|
throw new Error('Cannot use the Master Key, it has not been provided.');
|
|
285
201
|
}
|
|
286
202
|
}
|
|
287
|
-
|
|
288
203
|
if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
|
|
289
204
|
payload._RevocableSession = '1';
|
|
290
205
|
}
|
|
291
|
-
|
|
292
206
|
var installationId = options.installationId;
|
|
293
207
|
var installationIdPromise;
|
|
294
|
-
|
|
295
208
|
if (installationId && typeof installationId === 'string') {
|
|
296
209
|
installationIdPromise = Promise.resolve(installationId);
|
|
297
210
|
} else {
|
|
298
211
|
var installationController = _CoreManager.default.getInstallationController();
|
|
299
|
-
|
|
300
212
|
installationIdPromise = installationController.currentInstallationId();
|
|
301
213
|
}
|
|
302
|
-
|
|
303
214
|
return installationIdPromise.then(function (iid) {
|
|
304
215
|
payload._InstallationId = iid;
|
|
305
|
-
|
|
306
216
|
var userController = _CoreManager.default.getUserController();
|
|
307
|
-
|
|
308
217
|
if (options && typeof options.sessionToken === 'string') {
|
|
309
218
|
return Promise.resolve(options.sessionToken);
|
|
310
219
|
} else if (userController) {
|
|
@@ -312,24 +221,20 @@ var RESTController = {
|
|
|
312
221
|
if (user) {
|
|
313
222
|
return Promise.resolve(user.getSessionToken());
|
|
314
223
|
}
|
|
315
|
-
|
|
316
224
|
return Promise.resolve(null);
|
|
317
225
|
});
|
|
318
226
|
}
|
|
319
|
-
|
|
320
227
|
return Promise.resolve(null);
|
|
321
228
|
}).then(function (token) {
|
|
322
229
|
if (token) {
|
|
323
230
|
payload._SessionToken = token;
|
|
324
231
|
}
|
|
325
|
-
|
|
326
232
|
var payloadString = JSON.stringify(payload);
|
|
327
233
|
return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
|
|
328
234
|
var response = _ref.response,
|
|
329
|
-
|
|
330
|
-
|
|
235
|
+
status = _ref.status;
|
|
331
236
|
if (options.returnStatus) {
|
|
332
|
-
return
|
|
237
|
+
return Object.assign({}, response, {
|
|
333
238
|
_status: status
|
|
334
239
|
});
|
|
335
240
|
} else {
|
|
@@ -340,7 +245,6 @@ var RESTController = {
|
|
|
340
245
|
},
|
|
341
246
|
handleError: function handleError(response) {
|
|
342
247
|
var error;
|
|
343
|
-
|
|
344
248
|
if (response && response.responseText) {
|
|
345
249
|
try {
|
|
346
250
|
var errorJSON = JSON.parse(response.responseText);
|
|
@@ -352,7 +256,6 @@ var RESTController = {
|
|
|
352
256
|
var message = response.message ? response.message : response;
|
|
353
257
|
error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + JSON.stringify(message));
|
|
354
258
|
}
|
|
355
|
-
|
|
356
259
|
return Promise.reject(error);
|
|
357
260
|
},
|
|
358
261
|
_setXHR: function _setXHR(xhr) {
|
|
@@ -18,9 +18,7 @@ exports.pushPendingState = pushPendingState;
|
|
|
18
18
|
exports.removeState = removeState;
|
|
19
19
|
exports.setPendingOp = setPendingOp;
|
|
20
20
|
exports.setServerData = setServerData;
|
|
21
|
-
|
|
22
21
|
var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
|
|
23
|
-
|
|
24
22
|
function _getRequireWildcardCache(nodeInterop) {
|
|
25
23
|
if (typeof WeakMap !== "function") return null;
|
|
26
24
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -29,31 +27,24 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
29
27
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
30
28
|
})(nodeInterop);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
function _interopRequireWildcard(obj, nodeInterop) {
|
|
34
31
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
32
|
return obj;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
39
35
|
return {
|
|
40
36
|
default: obj
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
var cache = _getRequireWildcardCache(nodeInterop);
|
|
45
|
-
|
|
46
40
|
if (cache && cache.has(obj)) {
|
|
47
41
|
return cache.get(obj);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
var newObj = {};
|
|
51
44
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
52
|
-
|
|
53
45
|
for (var key in obj) {
|
|
54
46
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
47
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
56
|
-
|
|
57
48
|
if (desc && (desc.get || desc.set)) {
|
|
58
49
|
Object.defineProperty(newObj, key, desc);
|
|
59
50
|
} else {
|
|
@@ -61,139 +52,104 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
61
52
|
}
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
|
-
|
|
65
55
|
newObj.default = obj;
|
|
66
|
-
|
|
67
56
|
if (cache) {
|
|
68
57
|
cache.set(obj, newObj);
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
return newObj;
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
var objectState = {};
|
|
75
|
-
|
|
76
62
|
function getState(obj) {
|
|
77
63
|
var classData = objectState[obj.className];
|
|
78
|
-
|
|
79
64
|
if (classData) {
|
|
80
65
|
return classData[obj.id] || null;
|
|
81
66
|
}
|
|
82
|
-
|
|
83
67
|
return null;
|
|
84
68
|
}
|
|
85
|
-
|
|
86
69
|
function initializeState(obj, initial) {
|
|
87
70
|
var state = getState(obj);
|
|
88
|
-
|
|
89
71
|
if (state) {
|
|
90
72
|
return state;
|
|
91
73
|
}
|
|
92
|
-
|
|
93
74
|
if (!objectState[obj.className]) {
|
|
94
75
|
objectState[obj.className] = {};
|
|
95
76
|
}
|
|
96
|
-
|
|
97
77
|
if (!initial) {
|
|
98
78
|
initial = ObjectStateMutations.defaultState();
|
|
99
79
|
}
|
|
100
|
-
|
|
101
80
|
state = objectState[obj.className][obj.id] = initial;
|
|
102
81
|
return state;
|
|
103
82
|
}
|
|
104
|
-
|
|
105
83
|
function removeState(obj) {
|
|
106
84
|
var state = getState(obj);
|
|
107
|
-
|
|
108
85
|
if (state === null) {
|
|
109
86
|
return null;
|
|
110
87
|
}
|
|
111
|
-
|
|
112
88
|
delete objectState[obj.className][obj.id];
|
|
113
89
|
return state;
|
|
114
90
|
}
|
|
115
|
-
|
|
116
91
|
function getServerData(obj) {
|
|
117
92
|
var state = getState(obj);
|
|
118
|
-
|
|
119
93
|
if (state) {
|
|
120
94
|
return state.serverData;
|
|
121
95
|
}
|
|
122
|
-
|
|
123
96
|
return {};
|
|
124
97
|
}
|
|
125
|
-
|
|
126
98
|
function setServerData(obj, attributes) {
|
|
127
99
|
var serverData = initializeState(obj).serverData;
|
|
128
100
|
ObjectStateMutations.setServerData(serverData, attributes);
|
|
129
101
|
}
|
|
130
|
-
|
|
131
102
|
function getPendingOps(obj) {
|
|
132
103
|
var state = getState(obj);
|
|
133
|
-
|
|
134
104
|
if (state) {
|
|
135
105
|
return state.pendingOps;
|
|
136
106
|
}
|
|
137
|
-
|
|
138
107
|
return [{}];
|
|
139
108
|
}
|
|
140
|
-
|
|
141
109
|
function setPendingOp(obj, attr, op) {
|
|
142
110
|
var pendingOps = initializeState(obj).pendingOps;
|
|
143
111
|
ObjectStateMutations.setPendingOp(pendingOps, attr, op);
|
|
144
112
|
}
|
|
145
|
-
|
|
146
113
|
function pushPendingState(obj) {
|
|
147
114
|
var pendingOps = initializeState(obj).pendingOps;
|
|
148
115
|
ObjectStateMutations.pushPendingState(pendingOps);
|
|
149
116
|
}
|
|
150
|
-
|
|
151
117
|
function popPendingState(obj) {
|
|
152
118
|
var pendingOps = initializeState(obj).pendingOps;
|
|
153
119
|
return ObjectStateMutations.popPendingState(pendingOps);
|
|
154
120
|
}
|
|
155
|
-
|
|
156
121
|
function mergeFirstPendingState(obj) {
|
|
157
122
|
var pendingOps = getPendingOps(obj);
|
|
158
123
|
ObjectStateMutations.mergeFirstPendingState(pendingOps);
|
|
159
124
|
}
|
|
160
|
-
|
|
161
125
|
function getObjectCache(obj) {
|
|
162
126
|
var state = getState(obj);
|
|
163
|
-
|
|
164
127
|
if (state) {
|
|
165
128
|
return state.objectCache;
|
|
166
129
|
}
|
|
167
|
-
|
|
168
130
|
return {};
|
|
169
131
|
}
|
|
170
|
-
|
|
171
132
|
function estimateAttribute(obj, attr) {
|
|
172
133
|
var serverData = getServerData(obj);
|
|
173
134
|
var pendingOps = getPendingOps(obj);
|
|
174
135
|
return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
|
|
175
136
|
}
|
|
176
|
-
|
|
177
137
|
function estimateAttributes(obj) {
|
|
178
138
|
var serverData = getServerData(obj);
|
|
179
139
|
var pendingOps = getPendingOps(obj);
|
|
180
140
|
return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
|
|
181
141
|
}
|
|
182
|
-
|
|
183
142
|
function commitServerChanges(obj, changes) {
|
|
184
143
|
var state = initializeState(obj);
|
|
185
144
|
ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
|
|
186
145
|
}
|
|
187
|
-
|
|
188
146
|
function enqueueTask(obj, task) {
|
|
189
147
|
var state = initializeState(obj);
|
|
190
148
|
return state.tasks.enqueue(task);
|
|
191
149
|
}
|
|
192
|
-
|
|
193
150
|
function clearAllState() {
|
|
194
151
|
objectState = {};
|
|
195
152
|
}
|
|
196
|
-
|
|
197
153
|
function duplicateState(source, dest) {
|
|
198
154
|
dest.id = source.id;
|
|
199
155
|
}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
4
|
-
|
|
5
3
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
6
|
-
|
|
7
4
|
module.exports = function () {
|
|
8
5
|
function SocketWeapp(serverURL) {
|
|
9
6
|
var _this = this;
|
|
10
|
-
|
|
11
7
|
(0, _classCallCheck2.default)(this, SocketWeapp);
|
|
12
|
-
|
|
13
8
|
this.onopen = function () {};
|
|
14
|
-
|
|
15
9
|
this.onmessage = function () {};
|
|
16
|
-
|
|
17
10
|
this.onclose = function () {};
|
|
18
|
-
|
|
19
11
|
this.onerror = function () {};
|
|
20
|
-
|
|
21
12
|
wx.onSocketOpen(function () {
|
|
22
13
|
_this.onopen();
|
|
23
14
|
});
|
|
@@ -34,7 +25,6 @@ module.exports = function () {
|
|
|
34
25
|
url: serverURL
|
|
35
26
|
});
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
(0, _createClass2.default)(SocketWeapp, [{
|
|
39
29
|
key: "send",
|
|
40
30
|
value: function (data) {
|