parse 4.2.0 → 4.3.0-alpha.2
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 +2172 -1735
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +2154 -1717
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +25 -3
- package/lib/browser/CoreManager.js +31 -4
- package/lib/browser/EventEmitter.js +7 -2
- package/lib/browser/EventuallyQueue.js +11 -3
- package/lib/browser/LiveQueryClient.js +52 -86
- package/lib/browser/LiveQuerySubscription.js +16 -51
- package/lib/browser/LocalDatastore.js +7 -0
- package/lib/browser/ObjectStateMutations.js +3 -1
- package/lib/browser/OfflineQuery.js +1 -1
- package/lib/browser/Parse.js +171 -135
- package/lib/browser/ParseError.js +12 -1
- package/lib/browser/ParseLiveQuery.js +79 -51
- package/lib/browser/ParseObject.js +5 -1
- package/lib/browser/ParseQuery.js +53 -58
- package/lib/browser/ParseSchema.js +22 -1
- package/lib/browser/ParseSession.js +2 -6
- package/lib/browser/ParseUser.js +65 -8
- package/lib/browser/Push.js +20 -1
- package/lib/browser/RESTController.js +18 -14
- package/lib/browser/Storage.js +7 -0
- package/lib/node/Cloud.js +8 -2
- package/lib/node/CoreManager.js +30 -4
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +10 -3
- package/lib/node/LiveQueryClient.js +5 -5
- package/lib/node/LiveQuerySubscription.js +5 -7
- package/lib/node/LocalDatastore.js +6 -0
- package/lib/node/ObjectStateMutations.js +3 -1
- package/lib/node/OfflineQuery.js +1 -1
- package/lib/node/Parse.js +162 -126
- package/lib/node/ParseError.js +15 -1
- package/lib/node/ParseLiveQuery.js +32 -24
- package/lib/node/ParseObject.js +5 -1
- package/lib/node/ParseQuery.js +3 -6
- package/lib/node/ParseSchema.js +20 -1
- package/lib/node/ParseSession.js +1 -6
- package/lib/node/ParseUser.js +58 -8
- package/lib/node/Push.js +5 -2
- package/lib/node/RESTController.js +13 -9
- package/lib/node/Storage.js +6 -0
- package/lib/react-native/Cloud.js +18 -5
- package/lib/react-native/CoreManager.js +30 -4
- package/lib/react-native/EventEmitter.js +8 -5
- package/lib/react-native/EventuallyQueue.js +10 -3
- package/lib/react-native/LiveQueryClient.js +38 -68
- package/lib/react-native/LiveQuerySubscription.js +16 -46
- package/lib/react-native/LocalDatastore.js +6 -0
- package/lib/react-native/ObjectStateMutations.js +3 -1
- package/lib/react-native/OfflineQuery.js +1 -1
- package/lib/react-native/Parse.js +127 -90
- package/lib/react-native/ParseError.js +8 -1
- package/lib/react-native/ParseLiveQuery.js +39 -11
- package/lib/react-native/ParseObject.js +4 -0
- package/lib/react-native/ParseQuery.js +3 -6
- package/lib/react-native/ParseSchema.js +14 -1
- package/lib/react-native/ParseUser.js +49 -6
- package/lib/react-native/Push.js +13 -3
- package/lib/react-native/RESTController.js +13 -9
- package/lib/react-native/Storage.js +6 -0
- package/lib/weapp/Cloud.js +25 -3
- package/lib/weapp/CoreManager.js +31 -4
- package/lib/weapp/EventEmitter.js +7 -2
- package/lib/weapp/EventuallyQueue.js +11 -3
- package/lib/weapp/LiveQueryClient.js +52 -86
- package/lib/weapp/LiveQuerySubscription.js +16 -51
- package/lib/weapp/LocalDatastore.js +7 -0
- package/lib/weapp/ObjectStateMutations.js +3 -1
- package/lib/weapp/OfflineQuery.js +1 -1
- package/lib/weapp/Parse.js +170 -134
- package/lib/weapp/ParseError.js +12 -1
- package/lib/weapp/ParseLiveQuery.js +79 -51
- package/lib/weapp/ParseObject.js +5 -1
- package/lib/weapp/ParseQuery.js +53 -58
- package/lib/weapp/ParseSchema.js +22 -1
- package/lib/weapp/ParseSession.js +2 -6
- package/lib/weapp/ParseUser.js +65 -8
- package/lib/weapp/Push.js +20 -1
- package/lib/weapp/RESTController.js +18 -14
- package/lib/weapp/Storage.js +7 -0
- package/package.json +22 -18
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _EventEmitter = _interopRequireDefault(require("./EventEmitter"));
|
|
8
7
|
var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
|
|
9
8
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
10
9
|
function _interopRequireDefault(obj) {
|
|
@@ -16,7 +15,7 @@ function _interopRequireDefault(obj) {
|
|
|
16
15
|
* @flow
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
|
-
function getLiveQueryClient() /*: LiveQueryClient
|
|
18
|
+
function getLiveQueryClient() /*: Promise<LiveQueryClient>*/{
|
|
20
19
|
return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -47,31 +46,39 @@ function getLiveQueryClient() /*: LiveQueryClient*/{
|
|
|
47
46
|
* @class Parse.LiveQuery
|
|
48
47
|
* @static
|
|
49
48
|
*/
|
|
50
|
-
|
|
49
|
+
class LiveQuery {
|
|
50
|
+
constructor() {
|
|
51
|
+
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
52
|
+
this.emitter = new EventEmitter();
|
|
53
|
+
this.on = this.emitter.on;
|
|
54
|
+
this.emit = this.emitter.emit;
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
LiveQuery.open = async () => {
|
|
57
|
-
const liveQueryClient = await getLiveQueryClient();
|
|
58
|
-
liveQueryClient.open();
|
|
59
|
-
};
|
|
56
|
+
// adding listener so process does not crash
|
|
57
|
+
// best practice is for developer to register their own listener
|
|
58
|
+
this.on('error', () => {});
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const liveQueryClient = await getLiveQueryClient();
|
|
70
|
-
liveQueryClient.close();
|
|
71
|
-
};
|
|
61
|
+
/**
|
|
62
|
+
* After open is called, the LiveQuery will try to send a connect request
|
|
63
|
+
* to the LiveQuery server.
|
|
64
|
+
*/
|
|
65
|
+
async open() /*: void*/{
|
|
66
|
+
const liveQueryClient = await getLiveQueryClient();
|
|
67
|
+
liveQueryClient.open();
|
|
68
|
+
}
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
LiveQuery
|
|
70
|
+
/**
|
|
71
|
+
* When you're done using LiveQuery, you can call Parse.LiveQuery.close().
|
|
72
|
+
* This function will close the WebSocket connection to the LiveQuery server,
|
|
73
|
+
* cancel the auto reconnect, and unsubscribe all subscriptions based on it.
|
|
74
|
+
* If you call query.subscribe() after this, we'll create a new WebSocket
|
|
75
|
+
* connection to the LiveQuery server.
|
|
76
|
+
*/
|
|
77
|
+
async close() /*: void*/{
|
|
78
|
+
const liveQueryClient = await getLiveQueryClient();
|
|
79
|
+
liveQueryClient.close();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
75
82
|
var _default = LiveQuery;
|
|
76
83
|
exports.default = _default;
|
|
77
84
|
let defaultLiveQueryClient;
|
|
@@ -109,6 +116,7 @@ const DefaultLiveQueryController = {
|
|
|
109
116
|
sessionToken,
|
|
110
117
|
installationId
|
|
111
118
|
});
|
|
119
|
+
const LiveQuery = _CoreManager.default.getLiveQuery();
|
|
112
120
|
defaultLiveQueryClient.on('error', error => {
|
|
113
121
|
LiveQuery.emit('error', error);
|
|
114
122
|
});
|
package/lib/node/ParseObject.js
CHANGED
|
@@ -1042,7 +1042,7 @@ class ParseObject {
|
|
|
1042
1042
|
/**
|
|
1043
1043
|
* Returns the ACL for this object.
|
|
1044
1044
|
*
|
|
1045
|
-
* @returns {Parse.ACL} An instance of Parse.ACL.
|
|
1045
|
+
* @returns {Parse.ACL|null} An instance of Parse.ACL.
|
|
1046
1046
|
* @see Parse.Object#get
|
|
1047
1047
|
*/
|
|
1048
1048
|
getACL() /*: ?ParseACL*/{
|
|
@@ -2369,6 +2369,8 @@ const DefaultController = {
|
|
|
2369
2369
|
const objectId = responses[index].success.objectId;
|
|
2370
2370
|
const status = responses[index]._status;
|
|
2371
2371
|
delete responses[index]._status;
|
|
2372
|
+
delete responses[index]._headers;
|
|
2373
|
+
delete responses[index]._xhr;
|
|
2372
2374
|
mapIdForPin[objectId] = obj._localId;
|
|
2373
2375
|
obj._handleSaveResponse(responses[index].success, status);
|
|
2374
2376
|
} else {
|
|
@@ -2424,6 +2426,8 @@ const DefaultController = {
|
|
|
2424
2426
|
return RESTController.request(params.method, params.path, params.body, options).then(response => {
|
|
2425
2427
|
const status = response._status;
|
|
2426
2428
|
delete response._status;
|
|
2429
|
+
delete response._headers;
|
|
2430
|
+
delete response._xhr;
|
|
2427
2431
|
targetCopy._handleSaveResponse(response, status);
|
|
2428
2432
|
}, error => {
|
|
2429
2433
|
targetCopy._handleSaveError();
|
package/lib/node/ParseQuery.js
CHANGED
|
@@ -875,13 +875,10 @@ class ParseQuery {
|
|
|
875
875
|
}
|
|
876
876
|
const query = new ParseQuery(this.className);
|
|
877
877
|
query._limit = options.batchSize || 100;
|
|
878
|
-
query._include = this._include
|
|
879
|
-
|
|
880
|
-
});
|
|
878
|
+
query._include = [...this._include];
|
|
879
|
+
query._exclude = [...this._exclude];
|
|
881
880
|
if (this._select) {
|
|
882
|
-
query._select = this._select
|
|
883
|
-
return s;
|
|
884
|
-
});
|
|
881
|
+
query._select = [...this._select];
|
|
885
882
|
}
|
|
886
883
|
query._hint = this._hint;
|
|
887
884
|
query._where = {};
|
package/lib/node/ParseSchema.js
CHANGED
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) {
|
|
|
16
16
|
* @flow
|
|
17
17
|
*/
|
|
18
18
|
/*:: import type { PermissionsMap } from './ParseCLP';*/
|
|
19
|
-
const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
19
|
+
const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
20
20
|
/*:: type FieldOptions = {
|
|
21
21
|
required: boolean,
|
|
22
22
|
defaultValue: mixed,
|
|
@@ -226,6 +226,14 @@ class ParseSchema {
|
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
+
if (type === 'Bytes') {
|
|
230
|
+
if (options && options.defaultValue) {
|
|
231
|
+
fieldOptions.defaultValue = {
|
|
232
|
+
__type: 'Bytes',
|
|
233
|
+
base64: options.defaultValue
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
229
237
|
this._fields[name] = fieldOptions;
|
|
230
238
|
return this;
|
|
231
239
|
}
|
|
@@ -285,6 +293,17 @@ class ParseSchema {
|
|
|
285
293
|
return this.addField(name, 'Boolean', options);
|
|
286
294
|
}
|
|
287
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Adding Bytes Field
|
|
298
|
+
*
|
|
299
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
300
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
301
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
302
|
+
*/
|
|
303
|
+
addBytes(name /*: string*/, options /*: FieldOptions*/) {
|
|
304
|
+
return this.addField(name, 'Bytes', options);
|
|
305
|
+
}
|
|
306
|
+
|
|
288
307
|
/**
|
|
289
308
|
* Adding Date Field
|
|
290
309
|
*
|
package/lib/node/ParseSession.js
CHANGED
|
@@ -13,11 +13,6 @@ function _interopRequireDefault(obj) {
|
|
|
13
13
|
default: obj
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* @flow
|
|
18
|
-
*/
|
|
19
|
-
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
20
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
21
16
|
/**
|
|
22
17
|
* <p>A Parse.Session object is a local representation of a revocable session.
|
|
23
18
|
* This class is a subclass of a Parse.Object, and retains the same
|
|
@@ -30,7 +25,7 @@ class ParseSession extends _ParseObject.default {
|
|
|
30
25
|
/**
|
|
31
26
|
* @param {object} attributes The initial set of data to store in the user.
|
|
32
27
|
*/
|
|
33
|
-
constructor(attributes
|
|
28
|
+
constructor(attributes /*:: ?: any*/) {
|
|
34
29
|
super('_Session');
|
|
35
30
|
if (attributes && typeof attributes === 'object') {
|
|
36
31
|
if (!this.set(attributes || {})) {
|
package/lib/node/ParseUser.js
CHANGED
|
@@ -110,8 +110,14 @@ class ParseUser extends _ParseObject.default {
|
|
|
110
110
|
throw new Error('Invalid type: authData field should be an object');
|
|
111
111
|
}
|
|
112
112
|
authData[authType] = options.authData;
|
|
113
|
+
const oldAnonymousData = authData.anonymous;
|
|
114
|
+
this.stripAnonymity();
|
|
113
115
|
const controller = _CoreManager.default.getUserController();
|
|
114
|
-
return controller.linkWith(this, authData, saveOpts)
|
|
116
|
+
return controller.linkWith(this, authData, saveOpts).catch(e => {
|
|
117
|
+
delete authData[authType];
|
|
118
|
+
this.restoreAnonimity(oldAnonymousData);
|
|
119
|
+
throw e;
|
|
120
|
+
});
|
|
115
121
|
} else {
|
|
116
122
|
return new Promise((resolve, reject) => {
|
|
117
123
|
provider.authenticate({
|
|
@@ -300,6 +306,19 @@ class ParseUser extends _ParseObject.default {
|
|
|
300
306
|
const current = await ParseUser.currentAsync();
|
|
301
307
|
return !!current && current.id === this.id;
|
|
302
308
|
}
|
|
309
|
+
stripAnonymity() {
|
|
310
|
+
const authData = this.get('authData');
|
|
311
|
+
if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
312
|
+
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
|
|
313
|
+
authData.anonymous = null;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
restoreAnonimity(anonymousData /*: any*/) {
|
|
317
|
+
if (anonymousData) {
|
|
318
|
+
const authData = this.get('authData');
|
|
319
|
+
authData.anonymous = anonymousData;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
303
322
|
|
|
304
323
|
/**
|
|
305
324
|
* Returns get("username").
|
|
@@ -320,12 +339,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
320
339
|
* @param {string} username
|
|
321
340
|
*/
|
|
322
341
|
setUsername(username /*: string*/) {
|
|
323
|
-
|
|
324
|
-
const authData = this.get('authData');
|
|
325
|
-
if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
326
|
-
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
|
|
327
|
-
authData.anonymous = null;
|
|
328
|
-
}
|
|
342
|
+
this.stripAnonymity();
|
|
329
343
|
this.set('username', username);
|
|
330
344
|
}
|
|
331
345
|
|
|
@@ -440,6 +454,9 @@ class ParseUser extends _ParseObject.default {
|
|
|
440
454
|
if (options.hasOwnProperty('usePost')) {
|
|
441
455
|
loginOptions.usePost = options.usePost;
|
|
442
456
|
}
|
|
457
|
+
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
458
|
+
loginOptions.context = options.context;
|
|
459
|
+
}
|
|
443
460
|
const controller = _CoreManager.default.getUserController();
|
|
444
461
|
return controller.logIn(this, loginOptions);
|
|
445
462
|
}
|
|
@@ -638,6 +655,38 @@ class ParseUser extends _ParseObject.default {
|
|
|
638
655
|
return user.logIn(options);
|
|
639
656
|
}
|
|
640
657
|
|
|
658
|
+
/**
|
|
659
|
+
* Logs in a user with a username (or email) and password, and authData. On success, this
|
|
660
|
+
* saves the session to disk, so you can retrieve the currently logged in
|
|
661
|
+
* user using <code>current</code>.
|
|
662
|
+
*
|
|
663
|
+
* @param {string} username The username (or email) to log in with.
|
|
664
|
+
* @param {string} password The password to log in with.
|
|
665
|
+
* @param {object} authData The authData to log in with.
|
|
666
|
+
* @param {object} options
|
|
667
|
+
* @static
|
|
668
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
669
|
+
* the login completes.
|
|
670
|
+
*/
|
|
671
|
+
static logInWithAdditionalAuth(username /*: string*/, password /*: string*/, authData /*: AuthData*/, options /*:: ?: FullOptions*/) {
|
|
672
|
+
if (typeof username !== 'string') {
|
|
673
|
+
return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
674
|
+
}
|
|
675
|
+
if (typeof password !== 'string') {
|
|
676
|
+
return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
677
|
+
}
|
|
678
|
+
if (Object.prototype.toString.call(authData) !== '[object Object]') {
|
|
679
|
+
return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
|
|
680
|
+
}
|
|
681
|
+
const user = new this();
|
|
682
|
+
user._finishFetch({
|
|
683
|
+
username: username,
|
|
684
|
+
password: password,
|
|
685
|
+
authData
|
|
686
|
+
});
|
|
687
|
+
return user.logIn(options);
|
|
688
|
+
}
|
|
689
|
+
|
|
641
690
|
/**
|
|
642
691
|
* Logs in a user with an objectId. On success, this saves the session
|
|
643
692
|
* to disk, so you can retrieve the currently logged in user using
|
|
@@ -1049,7 +1098,8 @@ const DefaultController = {
|
|
|
1049
1098
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
1050
1099
|
const auth = {
|
|
1051
1100
|
username: user.get('username'),
|
|
1052
|
-
password: user.get('password')
|
|
1101
|
+
password: user.get('password'),
|
|
1102
|
+
authData: user.get('authData')
|
|
1053
1103
|
};
|
|
1054
1104
|
return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(response => {
|
|
1055
1105
|
user._migrateId(response.objectId);
|
package/lib/node/Push.js
CHANGED
|
@@ -104,8 +104,11 @@ function getPushStatus(pushStatusId /*: string*/, options /*:: ?: FullOptions*/
|
|
|
104
104
|
return query.get(pushStatusId, pushOptions);
|
|
105
105
|
}
|
|
106
106
|
const DefaultController = {
|
|
107
|
-
send(data /*: PushData*/, options /*:: ?: FullOptions*/) {
|
|
108
|
-
|
|
107
|
+
async send(data /*: PushData*/, options /*:: ?: FullOptions*/) {
|
|
108
|
+
var _response$_headers;
|
|
109
|
+
options.returnStatus = true;
|
|
110
|
+
const response = await _CoreManager.default.getRESTController().request('POST', 'push', data, options);
|
|
111
|
+
return (_response$_headers = response._headers) === null || _response$_headers === void 0 ? void 0 : _response$_headers['X-Parse-Push-Status-Id'];
|
|
109
112
|
}
|
|
110
113
|
};
|
|
111
114
|
_CoreManager.default.setPushController(DefaultController);
|
|
@@ -104,13 +104,12 @@ const RESTController = {
|
|
|
104
104
|
let response;
|
|
105
105
|
try {
|
|
106
106
|
response = JSON.parse(xhr.responseText);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
107
|
+
headers = {};
|
|
108
|
+
if (typeof xhr.getResponseHeader === 'function' && xhr.getResponseHeader('access-control-expose-headers')) {
|
|
109
|
+
const responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
|
|
110
|
+
responseHeaders.forEach(header => {
|
|
111
|
+
headers[header] = xhr.getResponseHeader(header.toLowerCase());
|
|
112
|
+
});
|
|
114
113
|
}
|
|
115
114
|
} catch (e) {
|
|
116
115
|
promise.reject(e.toString());
|
|
@@ -118,6 +117,7 @@ const RESTController = {
|
|
|
118
117
|
if (response) {
|
|
119
118
|
promise.resolve({
|
|
120
119
|
response,
|
|
120
|
+
headers,
|
|
121
121
|
status: xhr.status,
|
|
122
122
|
xhr
|
|
123
123
|
});
|
|
@@ -271,12 +271,16 @@ const RESTController = {
|
|
|
271
271
|
const payloadString = JSON.stringify(payload);
|
|
272
272
|
return RESTController.ajax(method, url, payloadString, {}, options).then(({
|
|
273
273
|
response,
|
|
274
|
-
status
|
|
274
|
+
status,
|
|
275
|
+
headers,
|
|
276
|
+
xhr
|
|
275
277
|
}) => {
|
|
276
278
|
if (options.returnStatus) {
|
|
277
279
|
return {
|
|
278
280
|
...response,
|
|
279
|
-
_status: status
|
|
281
|
+
_status: status,
|
|
282
|
+
_headers: headers,
|
|
283
|
+
_xhr: xhr
|
|
280
284
|
};
|
|
281
285
|
} else {
|
|
282
286
|
return response;
|
package/lib/node/Storage.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
4
8
|
function _interopRequireDefault(obj) {
|
|
5
9
|
return obj && obj.__esModule ? obj : {
|
|
@@ -91,4 +95,6 @@ const Storage = {
|
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
97
|
module.exports = Storage;
|
|
98
|
+
var _default = Storage;
|
|
99
|
+
exports.default = _default;
|
|
94
100
|
_CoreManager.default.setStorageController(require('./StorageController.default'));
|
|
@@ -6,6 +6,7 @@ exports.getJobStatus = getJobStatus;
|
|
|
6
6
|
exports.getJobsData = getJobsData;
|
|
7
7
|
exports.run = run;
|
|
8
8
|
exports.startJob = startJob;
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
10
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
10
11
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
11
12
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
@@ -24,6 +25,9 @@ function run(name, data, options) {
|
|
|
24
25
|
if (options.sessionToken) {
|
|
25
26
|
requestOptions.sessionToken = options.sessionToken;
|
|
26
27
|
}
|
|
28
|
+
if (options.installationId) {
|
|
29
|
+
requestOptions.installationId = options.installationId;
|
|
30
|
+
}
|
|
27
31
|
if (options.context && typeof options.context === 'object') {
|
|
28
32
|
requestOptions.context = options.context;
|
|
29
33
|
}
|
|
@@ -68,10 +72,19 @@ var DefaultController = {
|
|
|
68
72
|
var RESTController = _CoreManager.default.getRESTController();
|
|
69
73
|
return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
|
|
70
74
|
},
|
|
71
|
-
startJob: function (
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
startJob: function () {
|
|
76
|
+
var _startJob = (0, _asyncToGenerator2.default)(function* (name, data, options) {
|
|
77
|
+
var _response$_headers;
|
|
78
|
+
var RESTController = _CoreManager.default.getRESTController();
|
|
79
|
+
var payload = (0, _encode.default)(data, true);
|
|
80
|
+
options.returnStatus = true;
|
|
81
|
+
var response = yield RESTController.request('POST', 'jobs/' + name, payload, options);
|
|
82
|
+
return (_response$_headers = response._headers) == null ? void 0 : _response$_headers['X-Parse-Job-Status-Id'];
|
|
83
|
+
});
|
|
84
|
+
function startJob() {
|
|
85
|
+
return _startJob.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
return startJob;
|
|
88
|
+
}()
|
|
76
89
|
};
|
|
77
90
|
_CoreManager.default.setCloudController(DefaultController);
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.default = void 0;
|
|
1
5
|
var config = {
|
|
2
6
|
IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
|
|
3
7
|
REQUEST_ATTEMPT_LIMIT: 5,
|
|
@@ -8,7 +12,7 @@ var config = {
|
|
|
8
12
|
SERVER_AUTH_TOKEN: null,
|
|
9
13
|
LIVEQUERY_SERVER_URL: null,
|
|
10
14
|
ENCRYPTED_KEY: null,
|
|
11
|
-
VERSION: 'js' + "4.
|
|
15
|
+
VERSION: 'js' + "4.3.0-alpha.2",
|
|
12
16
|
APPLICATION_ID: null,
|
|
13
17
|
JAVASCRIPT_KEY: null,
|
|
14
18
|
MASTER_KEY: null,
|
|
@@ -17,7 +21,8 @@ var config = {
|
|
|
17
21
|
FORCE_REVOCABLE_SESSION: false,
|
|
18
22
|
ENCRYPTED_USER: false,
|
|
19
23
|
IDEMPOTENCY: false,
|
|
20
|
-
ALLOW_CUSTOM_OBJECT_ID: false
|
|
24
|
+
ALLOW_CUSTOM_OBJECT_ID: false,
|
|
25
|
+
PARSE_ERRORS: []
|
|
21
26
|
};
|
|
22
27
|
function requireMethods(name, methods, controller) {
|
|
23
28
|
methods.forEach(function (func) {
|
|
@@ -26,7 +31,7 @@ function requireMethods(name, methods, controller) {
|
|
|
26
31
|
}
|
|
27
32
|
});
|
|
28
33
|
}
|
|
29
|
-
|
|
34
|
+
var CoreManager = {
|
|
30
35
|
get: function (key) {
|
|
31
36
|
if (config.hasOwnProperty(key)) {
|
|
32
37
|
return config[key];
|
|
@@ -36,6 +41,12 @@ module.exports = {
|
|
|
36
41
|
set: function (key, value) {
|
|
37
42
|
config[key] = value;
|
|
38
43
|
},
|
|
44
|
+
setIfNeeded: function (key, value) {
|
|
45
|
+
if (!config.hasOwnProperty(key)) {
|
|
46
|
+
config[key] = value;
|
|
47
|
+
}
|
|
48
|
+
return config[key];
|
|
49
|
+
},
|
|
39
50
|
setAnalyticsController: function (controller) {
|
|
40
51
|
requireMethods('AnalyticsController', ['track'], controller);
|
|
41
52
|
config['AnalyticsController'] = controller;
|
|
@@ -64,6 +75,12 @@ module.exports = {
|
|
|
64
75
|
getCryptoController: function () {
|
|
65
76
|
return config['CryptoController'];
|
|
66
77
|
},
|
|
78
|
+
setEventEmitter: function (eventEmitter) {
|
|
79
|
+
config['EventEmitter'] = eventEmitter;
|
|
80
|
+
},
|
|
81
|
+
getEventEmitter: function () {
|
|
82
|
+
return config['EventEmitter'];
|
|
83
|
+
},
|
|
67
84
|
setFileController: function (controller) {
|
|
68
85
|
requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
|
|
69
86
|
config['FileController'] = controller;
|
|
@@ -78,6 +95,12 @@ module.exports = {
|
|
|
78
95
|
getInstallationController: function () {
|
|
79
96
|
return config['InstallationController'];
|
|
80
97
|
},
|
|
98
|
+
setLiveQuery: function (liveQuery) {
|
|
99
|
+
config['LiveQuery'] = liveQuery;
|
|
100
|
+
},
|
|
101
|
+
getLiveQuery: function () {
|
|
102
|
+
return config['LiveQuery'];
|
|
103
|
+
},
|
|
81
104
|
setObjectController: function (controller) {
|
|
82
105
|
requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
|
|
83
106
|
config['ObjectController'] = controller;
|
|
@@ -184,4 +207,7 @@ module.exports = {
|
|
|
184
207
|
getHooksController: function () {
|
|
185
208
|
return config['HooksController'];
|
|
186
209
|
}
|
|
187
|
-
};
|
|
210
|
+
};
|
|
211
|
+
module.exports = CoreManager;
|
|
212
|
+
var _default = CoreManager;
|
|
213
|
+
exports.default = _default;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
var EventEmitter
|
|
2
|
-
|
|
3
|
-
EventEmitter = EventEmitter
|
|
4
|
-
|
|
5
|
-
EventEmitter
|
|
1
|
+
var EventEmitter;
|
|
2
|
+
try {
|
|
3
|
+
EventEmitter = require('react-native/Libraries/vendor/emitter/EventEmitter');
|
|
4
|
+
if (EventEmitter.default) {
|
|
5
|
+
EventEmitter = EventEmitter.default;
|
|
6
|
+
}
|
|
7
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
8
|
+
} catch (_) {}
|
|
6
9
|
module.exports = EventEmitter;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = void 0;
|
|
2
6
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
3
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
4
8
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
9
|
+
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
5
10
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
6
11
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
7
12
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
@@ -155,7 +160,7 @@ var EventuallyQueue = {
|
|
|
155
160
|
yield object.save(queueObject.object, queueObject.serverOptions);
|
|
156
161
|
yield this.remove(queueObject.queueId);
|
|
157
162
|
} catch (e) {
|
|
158
|
-
if (e.
|
|
163
|
+
if (e.code !== _ParseError.default.CONNECTION_FAILED) {
|
|
159
164
|
yield this.remove(queueObject.queueId);
|
|
160
165
|
}
|
|
161
166
|
}
|
|
@@ -165,7 +170,7 @@ var EventuallyQueue = {
|
|
|
165
170
|
yield object.destroy(queueObject.serverOptions);
|
|
166
171
|
yield this.remove(queueObject.queueId);
|
|
167
172
|
} catch (e) {
|
|
168
|
-
if (e.
|
|
173
|
+
if (e.code !== _ParseError.default.CONNECTION_FAILED) {
|
|
169
174
|
yield this.remove(queueObject.queueId);
|
|
170
175
|
}
|
|
171
176
|
}
|
|
@@ -246,4 +251,6 @@ var EventuallyQueue = {
|
|
|
246
251
|
}()
|
|
247
252
|
}
|
|
248
253
|
};
|
|
249
|
-
module.exports = EventuallyQueue;
|
|
254
|
+
module.exports = EventuallyQueue;
|
|
255
|
+
var _default = EventuallyQueue;
|
|
256
|
+
exports.default = _default;
|