parse 4.0.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 +45 -43
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,45 +1,32 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
4
|
-
|
|
5
3
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
6
|
-
|
|
7
4
|
var _promiseUtils = require("./promiseUtils");
|
|
8
|
-
|
|
9
5
|
var uuidv4 = require('./uuid');
|
|
10
|
-
|
|
11
6
|
var XHR = null;
|
|
12
|
-
|
|
13
7
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
14
8
|
XHR = XMLHttpRequest;
|
|
15
9
|
}
|
|
16
|
-
|
|
17
10
|
var useXDomainRequest = false;
|
|
18
|
-
|
|
19
11
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
20
12
|
useXDomainRequest = true;
|
|
21
13
|
}
|
|
22
|
-
|
|
23
14
|
function ajaxIE9(method, url, data, headers, options) {
|
|
24
15
|
return new Promise(function (resolve, reject) {
|
|
25
16
|
var xdr = new XDomainRequest();
|
|
26
|
-
|
|
27
17
|
xdr.onload = function () {
|
|
28
18
|
var response;
|
|
29
|
-
|
|
30
19
|
try {
|
|
31
20
|
response = JSON.parse(xdr.responseText);
|
|
32
21
|
} catch (e) {
|
|
33
22
|
reject(e);
|
|
34
23
|
}
|
|
35
|
-
|
|
36
24
|
if (response) {
|
|
37
25
|
resolve({
|
|
38
26
|
response: response
|
|
39
27
|
});
|
|
40
28
|
}
|
|
41
29
|
};
|
|
42
|
-
|
|
43
30
|
xdr.onerror = xdr.ontimeout = function () {
|
|
44
31
|
var fakeResponse = {
|
|
45
32
|
responseText: JSON.stringify({
|
|
@@ -49,59 +36,46 @@ function ajaxIE9(method, url, data, headers, options) {
|
|
|
49
36
|
};
|
|
50
37
|
reject(fakeResponse);
|
|
51
38
|
};
|
|
52
|
-
|
|
53
39
|
xdr.onprogress = function () {
|
|
54
40
|
if (options && typeof options.progress === 'function') {
|
|
55
41
|
options.progress(xdr.responseText);
|
|
56
42
|
}
|
|
57
43
|
};
|
|
58
|
-
|
|
59
44
|
xdr.open(method, url);
|
|
60
45
|
xdr.send(data);
|
|
61
|
-
|
|
62
46
|
if (options && typeof options.requestTask === 'function') {
|
|
63
47
|
options.requestTask(xdr);
|
|
64
48
|
}
|
|
65
49
|
});
|
|
66
50
|
}
|
|
67
|
-
|
|
68
51
|
var RESTController = {
|
|
69
52
|
ajax: function (method, url, data, headers, options) {
|
|
70
53
|
if (useXDomainRequest) {
|
|
71
54
|
return ajaxIE9(method, url, data, headers, options);
|
|
72
55
|
}
|
|
73
|
-
|
|
74
56
|
var promise = (0, _promiseUtils.resolvingPromise)();
|
|
75
57
|
var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && ['POST', 'PUT'].includes(method);
|
|
76
58
|
var requestId = isIdempotent ? uuidv4() : '';
|
|
77
59
|
var attempts = 0;
|
|
78
|
-
|
|
79
60
|
(function dispatch() {
|
|
80
61
|
if (XHR == null) {
|
|
81
62
|
throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
82
63
|
}
|
|
83
|
-
|
|
84
64
|
var handled = false;
|
|
85
65
|
var xhr = new XHR();
|
|
86
|
-
|
|
87
66
|
xhr.onreadystatechange = function () {
|
|
88
67
|
if (xhr.readyState !== 4 || handled || xhr._aborted) {
|
|
89
68
|
return;
|
|
90
69
|
}
|
|
91
|
-
|
|
92
70
|
handled = true;
|
|
93
|
-
|
|
94
71
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
95
72
|
var response;
|
|
96
|
-
|
|
97
73
|
try {
|
|
98
74
|
response = JSON.parse(xhr.responseText);
|
|
99
|
-
|
|
100
75
|
if (typeof xhr.getResponseHeader === 'function') {
|
|
101
76
|
if ((xhr.getAllResponseHeaders() || '').includes('x-parse-job-status-id: ')) {
|
|
102
77
|
response = xhr.getResponseHeader('x-parse-job-status-id');
|
|
103
78
|
}
|
|
104
|
-
|
|
105
79
|
if ((xhr.getAllResponseHeaders() || '').includes('x-parse-push-status-id: ')) {
|
|
106
80
|
response = xhr.getResponseHeader('x-parse-push-status-id');
|
|
107
81
|
}
|
|
@@ -109,7 +83,6 @@ var RESTController = {
|
|
|
109
83
|
} catch (e) {
|
|
110
84
|
promise.reject(e.toString());
|
|
111
85
|
}
|
|
112
|
-
|
|
113
86
|
if (response) {
|
|
114
87
|
promise.resolve({
|
|
115
88
|
response: response,
|
|
@@ -130,31 +103,23 @@ var RESTController = {
|
|
|
130
103
|
promise.reject(xhr);
|
|
131
104
|
}
|
|
132
105
|
};
|
|
133
|
-
|
|
134
106
|
headers = headers || {};
|
|
135
|
-
|
|
136
107
|
if (typeof headers['Content-Type'] !== 'string') {
|
|
137
108
|
headers['Content-Type'] = 'text/plain';
|
|
138
109
|
}
|
|
139
|
-
|
|
140
110
|
if (_CoreManager.default.get('IS_NODE')) {
|
|
141
111
|
headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
|
|
142
112
|
}
|
|
143
|
-
|
|
144
113
|
if (isIdempotent) {
|
|
145
114
|
headers['X-Parse-Request-Id'] = requestId;
|
|
146
115
|
}
|
|
147
|
-
|
|
148
116
|
if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
|
|
149
117
|
headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
150
118
|
}
|
|
151
|
-
|
|
152
119
|
var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
|
|
153
|
-
|
|
154
120
|
for (var key in customHeaders) {
|
|
155
121
|
headers[key] = customHeaders[key];
|
|
156
122
|
}
|
|
157
|
-
|
|
158
123
|
if (options && typeof options.progress === 'function') {
|
|
159
124
|
var handleProgress = function handleProgress(type, event) {
|
|
160
125
|
if (event.lengthComputable) {
|
|
@@ -167,24 +132,19 @@ var RESTController = {
|
|
|
167
132
|
});
|
|
168
133
|
}
|
|
169
134
|
};
|
|
170
|
-
|
|
171
135
|
xhr.onprogress = function (event) {
|
|
172
136
|
handleProgress('download', event);
|
|
173
137
|
};
|
|
174
|
-
|
|
175
138
|
if (xhr.upload) {
|
|
176
139
|
xhr.upload.onprogress = function (event) {
|
|
177
140
|
handleProgress('upload', event);
|
|
178
141
|
};
|
|
179
142
|
}
|
|
180
143
|
}
|
|
181
|
-
|
|
182
144
|
xhr.open(method, url, true);
|
|
183
|
-
|
|
184
145
|
for (var h in headers) {
|
|
185
146
|
xhr.setRequestHeader(h, headers[h]);
|
|
186
147
|
}
|
|
187
|
-
|
|
188
148
|
xhr.onabort = function () {
|
|
189
149
|
promise.resolve({
|
|
190
150
|
response: {
|
|
@@ -194,60 +154,44 @@ var RESTController = {
|
|
|
194
154
|
xhr: xhr
|
|
195
155
|
});
|
|
196
156
|
};
|
|
197
|
-
|
|
198
157
|
xhr.send(data);
|
|
199
|
-
|
|
200
158
|
if (options && typeof options.requestTask === 'function') {
|
|
201
159
|
options.requestTask(xhr);
|
|
202
160
|
}
|
|
203
161
|
})();
|
|
204
|
-
|
|
205
162
|
return promise;
|
|
206
163
|
},
|
|
207
164
|
request: function request(method, path, data, options) {
|
|
208
165
|
options = options || {};
|
|
209
|
-
|
|
210
166
|
var url = _CoreManager.default.get('SERVER_URL');
|
|
211
|
-
|
|
212
167
|
if (url[url.length - 1] !== '/') {
|
|
213
168
|
url += '/';
|
|
214
169
|
}
|
|
215
|
-
|
|
216
170
|
url += path;
|
|
217
171
|
var payload = {};
|
|
218
|
-
|
|
219
172
|
if (data && typeof data === 'object') {
|
|
220
173
|
for (var k in data) {
|
|
221
174
|
payload[k] = data[k];
|
|
222
175
|
}
|
|
223
176
|
}
|
|
224
|
-
|
|
225
177
|
var context = options.context;
|
|
226
|
-
|
|
227
178
|
if (context !== undefined) {
|
|
228
179
|
payload._context = context;
|
|
229
180
|
}
|
|
230
|
-
|
|
231
181
|
if (method !== 'POST') {
|
|
232
182
|
payload._method = method;
|
|
233
183
|
method = 'POST';
|
|
234
184
|
}
|
|
235
|
-
|
|
236
185
|
payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
|
|
237
|
-
|
|
238
186
|
var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
239
|
-
|
|
240
187
|
if (jsKey) {
|
|
241
188
|
payload._JavaScriptKey = jsKey;
|
|
242
189
|
}
|
|
243
|
-
|
|
244
190
|
payload._ClientVersion = _CoreManager.default.get('VERSION');
|
|
245
191
|
var useMasterKey = options.useMasterKey;
|
|
246
|
-
|
|
247
192
|
if (typeof useMasterKey === 'undefined') {
|
|
248
193
|
useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
|
|
249
194
|
}
|
|
250
|
-
|
|
251
195
|
if (useMasterKey) {
|
|
252
196
|
if (_CoreManager.default.get('MASTER_KEY')) {
|
|
253
197
|
delete payload._JavaScriptKey;
|
|
@@ -256,27 +200,20 @@ var RESTController = {
|
|
|
256
200
|
throw new Error('Cannot use the Master Key, it has not been provided.');
|
|
257
201
|
}
|
|
258
202
|
}
|
|
259
|
-
|
|
260
203
|
if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
|
|
261
204
|
payload._RevocableSession = '1';
|
|
262
205
|
}
|
|
263
|
-
|
|
264
206
|
var installationId = options.installationId;
|
|
265
207
|
var installationIdPromise;
|
|
266
|
-
|
|
267
208
|
if (installationId && typeof installationId === 'string') {
|
|
268
209
|
installationIdPromise = Promise.resolve(installationId);
|
|
269
210
|
} else {
|
|
270
211
|
var installationController = _CoreManager.default.getInstallationController();
|
|
271
|
-
|
|
272
212
|
installationIdPromise = installationController.currentInstallationId();
|
|
273
213
|
}
|
|
274
|
-
|
|
275
214
|
return installationIdPromise.then(function (iid) {
|
|
276
215
|
payload._InstallationId = iid;
|
|
277
|
-
|
|
278
216
|
var userController = _CoreManager.default.getUserController();
|
|
279
|
-
|
|
280
217
|
if (options && typeof options.sessionToken === 'string') {
|
|
281
218
|
return Promise.resolve(options.sessionToken);
|
|
282
219
|
} else if (userController) {
|
|
@@ -284,22 +221,18 @@ var RESTController = {
|
|
|
284
221
|
if (user) {
|
|
285
222
|
return Promise.resolve(user.getSessionToken());
|
|
286
223
|
}
|
|
287
|
-
|
|
288
224
|
return Promise.resolve(null);
|
|
289
225
|
});
|
|
290
226
|
}
|
|
291
|
-
|
|
292
227
|
return Promise.resolve(null);
|
|
293
228
|
}).then(function (token) {
|
|
294
229
|
if (token) {
|
|
295
230
|
payload._SessionToken = token;
|
|
296
231
|
}
|
|
297
|
-
|
|
298
232
|
var payloadString = JSON.stringify(payload);
|
|
299
233
|
return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
|
|
300
234
|
var response = _ref.response,
|
|
301
|
-
|
|
302
|
-
|
|
235
|
+
status = _ref.status;
|
|
303
236
|
if (options.returnStatus) {
|
|
304
237
|
return Object.assign({}, response, {
|
|
305
238
|
_status: status
|
|
@@ -312,7 +245,6 @@ var RESTController = {
|
|
|
312
245
|
},
|
|
313
246
|
handleError: function handleError(response) {
|
|
314
247
|
var error;
|
|
315
|
-
|
|
316
248
|
if (response && response.responseText) {
|
|
317
249
|
try {
|
|
318
250
|
var errorJSON = JSON.parse(response.responseText);
|
|
@@ -324,7 +256,6 @@ var RESTController = {
|
|
|
324
256
|
var message = response.message ? response.message : response;
|
|
325
257
|
error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + JSON.stringify(message));
|
|
326
258
|
}
|
|
327
|
-
|
|
328
259
|
return Promise.reject(error);
|
|
329
260
|
},
|
|
330
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,31 +1,22 @@
|
|
|
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
|
});
|
|
24
15
|
wx.onSocketMessage(function (msg) {
|
|
25
16
|
_this.onmessage(msg);
|
|
26
17
|
});
|
|
27
|
-
wx.onSocketClose(function () {
|
|
28
|
-
_this.onclose();
|
|
18
|
+
wx.onSocketClose(function (event) {
|
|
19
|
+
_this.onclose(event);
|
|
29
20
|
});
|
|
30
21
|
wx.onSocketError(function (error) {
|
|
31
22
|
_this.onerror(error);
|
|
@@ -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) {
|
|
@@ -1,108 +1,84 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
4
|
-
|
|
5
3
|
var Storage = {
|
|
6
4
|
async: function () {
|
|
7
5
|
var controller = _CoreManager.default.getStorageController();
|
|
8
|
-
|
|
9
6
|
return !!controller.async;
|
|
10
7
|
},
|
|
11
8
|
getItem: function (path) {
|
|
12
9
|
var controller = _CoreManager.default.getStorageController();
|
|
13
|
-
|
|
14
10
|
if (controller.async === 1) {
|
|
15
11
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
16
12
|
}
|
|
17
|
-
|
|
18
13
|
return controller.getItem(path);
|
|
19
14
|
},
|
|
20
15
|
getItemAsync: function (path) {
|
|
21
16
|
var controller = _CoreManager.default.getStorageController();
|
|
22
|
-
|
|
23
17
|
if (controller.async === 1) {
|
|
24
18
|
return controller.getItemAsync(path);
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
return Promise.resolve(controller.getItem(path));
|
|
28
21
|
},
|
|
29
22
|
setItem: function (path, value) {
|
|
30
23
|
var controller = _CoreManager.default.getStorageController();
|
|
31
|
-
|
|
32
24
|
if (controller.async === 1) {
|
|
33
25
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
return controller.setItem(path, value);
|
|
37
28
|
},
|
|
38
29
|
setItemAsync: function (path, value) {
|
|
39
30
|
var controller = _CoreManager.default.getStorageController();
|
|
40
|
-
|
|
41
31
|
if (controller.async === 1) {
|
|
42
32
|
return controller.setItemAsync(path, value);
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
return Promise.resolve(controller.setItem(path, value));
|
|
46
35
|
},
|
|
47
36
|
removeItem: function (path) {
|
|
48
37
|
var controller = _CoreManager.default.getStorageController();
|
|
49
|
-
|
|
50
38
|
if (controller.async === 1) {
|
|
51
39
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
52
40
|
}
|
|
53
|
-
|
|
54
41
|
return controller.removeItem(path);
|
|
55
42
|
},
|
|
56
43
|
removeItemAsync: function (path) {
|
|
57
44
|
var controller = _CoreManager.default.getStorageController();
|
|
58
|
-
|
|
59
45
|
if (controller.async === 1) {
|
|
60
46
|
return controller.removeItemAsync(path);
|
|
61
47
|
}
|
|
62
|
-
|
|
63
48
|
return Promise.resolve(controller.removeItem(path));
|
|
64
49
|
},
|
|
65
50
|
getAllKeys: function () {
|
|
66
51
|
var controller = _CoreManager.default.getStorageController();
|
|
67
|
-
|
|
68
52
|
if (controller.async === 1) {
|
|
69
53
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
return controller.getAllKeys();
|
|
73
56
|
},
|
|
74
57
|
getAllKeysAsync: function () {
|
|
75
58
|
var controller = _CoreManager.default.getStorageController();
|
|
76
|
-
|
|
77
59
|
if (controller.async === 1) {
|
|
78
60
|
return controller.getAllKeysAsync();
|
|
79
61
|
}
|
|
80
|
-
|
|
81
62
|
return Promise.resolve(controller.getAllKeys());
|
|
82
63
|
},
|
|
83
64
|
generatePath: function (path) {
|
|
84
65
|
if (!_CoreManager.default.get('APPLICATION_ID')) {
|
|
85
66
|
throw new Error('You need to call Parse.initialize before using Parse.');
|
|
86
67
|
}
|
|
87
|
-
|
|
88
68
|
if (typeof path !== 'string') {
|
|
89
69
|
throw new Error('Tried to get a Storage path that was not a String.');
|
|
90
70
|
}
|
|
91
|
-
|
|
92
71
|
if (path[0] === '/') {
|
|
93
72
|
path = path.substr(1);
|
|
94
73
|
}
|
|
95
|
-
|
|
96
74
|
return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
|
|
97
75
|
},
|
|
98
76
|
_clear: function () {
|
|
99
77
|
var controller = _CoreManager.default.getStorageController();
|
|
100
|
-
|
|
101
78
|
if (controller.hasOwnProperty('clear')) {
|
|
102
79
|
controller.clear();
|
|
103
80
|
}
|
|
104
81
|
}
|
|
105
82
|
};
|
|
106
83
|
module.exports = Storage;
|
|
107
|
-
|
|
108
84
|
_CoreManager.default.setStorageController(require('./StorageController.react-native'));
|