parse 4.1.0 → 4.2.0-alpha.10
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 +2123 -1542
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +2105 -1524
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/AnonymousUtils.js +1 -1
- package/lib/browser/Cloud.js +4 -2
- package/lib/browser/CoreManager.js +31 -4
- package/lib/browser/EventEmitter.js +7 -2
- package/lib/browser/EventuallyQueue.js +24 -4
- package/lib/browser/LiveQueryClient.js +59 -89
- package/lib/browser/LiveQuerySubscription.js +16 -51
- package/lib/browser/LocalDatastore.js +10 -1
- package/lib/browser/LocalDatastoreController.js +3 -1
- package/lib/browser/ObjectStateMutations.js +17 -2
- package/lib/browser/OfflineQuery.js +1 -1
- package/lib/browser/Parse.js +171 -135
- package/lib/browser/ParseACL.js +2 -1
- package/lib/browser/ParseCLP.js +6 -1
- package/lib/browser/ParseConfig.js +1 -0
- package/lib/browser/ParseError.js +12 -1
- package/lib/browser/ParseFile.js +5 -1
- package/lib/browser/ParseInstallation.js +4 -1
- package/lib/browser/ParseLiveQuery.js +79 -51
- package/lib/browser/ParseObject.js +11 -8
- package/lib/browser/ParseOp.js +3 -1
- package/lib/browser/ParseQuery.js +122 -72
- package/lib/browser/ParseRole.js +5 -1
- package/lib/browser/ParseSchema.js +23 -2
- package/lib/browser/ParseSession.js +1 -1
- package/lib/browser/ParseUser.js +107 -9
- package/lib/browser/Push.js +8 -2
- package/lib/browser/RESTController.js +20 -0
- package/lib/browser/SingleInstanceStateController.js +6 -1
- package/lib/browser/Storage.js +7 -0
- package/lib/browser/TaskQueue.js +4 -0
- package/lib/browser/UniqueInstanceStateController.js +3 -1
- package/lib/browser/unsavedChildren.js +4 -1
- package/lib/node/AnonymousUtils.js +1 -1
- package/lib/node/Cloud.js +4 -2
- package/lib/node/CoreManager.js +30 -4
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +23 -4
- package/lib/node/LiveQueryClient.js +10 -7
- package/lib/node/LiveQuerySubscription.js +5 -7
- package/lib/node/LocalDatastore.js +7 -1
- package/lib/node/ObjectStateMutations.js +14 -2
- package/lib/node/OfflineQuery.js +1 -1
- package/lib/node/Parse.js +162 -126
- package/lib/node/ParseACL.js +2 -1
- package/lib/node/ParseCLP.js +3 -1
- package/lib/node/ParseConfig.js +1 -2
- package/lib/node/ParseError.js +15 -1
- package/lib/node/ParseFile.js +2 -1
- package/lib/node/ParseInstallation.js +1 -1
- package/lib/node/ParseLiveQuery.js +32 -24
- package/lib/node/ParseObject.js +3 -2
- package/lib/node/ParseQuery.js +53 -7
- package/lib/node/ParseRole.js +2 -1
- package/lib/node/ParseSchema.js +21 -2
- package/lib/node/ParseSession.js +1 -5
- package/lib/node/ParseUser.js +95 -9
- package/lib/node/Push.js +8 -2
- package/lib/node/RESTController.js +20 -0
- package/lib/node/SingleInstanceStateController.js +6 -1
- package/lib/node/Storage.js +6 -0
- package/lib/node/TaskQueue.js +4 -1
- package/lib/node/UniqueInstanceStateController.js +3 -1
- package/lib/node/unsavedChildren.js +4 -1
- package/lib/react-native/Cloud.js +3 -0
- 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 +44 -70
- 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/ParseCLP.js +2 -2
- package/lib/react-native/ParseError.js +8 -1
- package/lib/react-native/ParseFile.js +1 -0
- package/lib/react-native/ParseLiveQuery.js +39 -11
- package/lib/react-native/ParseQuery.js +37 -17
- package/lib/react-native/ParseSchema.js +14 -1
- package/lib/react-native/ParseUser.js +74 -6
- package/lib/react-native/Storage.js +6 -0
- package/lib/weapp/AnonymousUtils.js +1 -1
- package/lib/weapp/Cloud.js +4 -2
- package/lib/weapp/CoreManager.js +31 -4
- package/lib/weapp/EventEmitter.js +7 -2
- package/lib/weapp/EventuallyQueue.js +24 -4
- package/lib/weapp/LiveQueryClient.js +59 -89
- package/lib/weapp/LiveQuerySubscription.js +16 -51
- package/lib/weapp/LocalDatastore.js +10 -1
- package/lib/weapp/LocalDatastoreController.js +3 -1
- package/lib/weapp/ObjectStateMutations.js +17 -2
- package/lib/weapp/OfflineQuery.js +1 -1
- package/lib/weapp/Parse.js +170 -134
- package/lib/weapp/ParseACL.js +2 -1
- package/lib/weapp/ParseCLP.js +6 -1
- package/lib/weapp/ParseConfig.js +1 -0
- package/lib/weapp/ParseError.js +12 -1
- package/lib/weapp/ParseFile.js +5 -1
- package/lib/weapp/ParseInstallation.js +4 -1
- package/lib/weapp/ParseLiveQuery.js +79 -51
- package/lib/weapp/ParseObject.js +11 -8
- package/lib/weapp/ParseOp.js +3 -1
- package/lib/weapp/ParseQuery.js +122 -72
- package/lib/weapp/ParseRole.js +5 -1
- package/lib/weapp/ParseSchema.js +23 -2
- package/lib/weapp/ParseSession.js +1 -1
- package/lib/weapp/ParseUser.js +107 -9
- package/lib/weapp/Push.js +8 -2
- package/lib/weapp/RESTController.js +20 -0
- package/lib/weapp/SingleInstanceStateController.js +6 -1
- package/lib/weapp/Storage.js +7 -0
- package/lib/weapp/TaskQueue.js +4 -0
- package/lib/weapp/UniqueInstanceStateController.js +3 -1
- package/lib/weapp/unsavedChildren.js +4 -1
- package/package.json +29 -25
package/lib/browser/ParseUser.js
CHANGED
|
@@ -49,7 +49,12 @@ function _isNativeReflectConstruct() {
|
|
|
49
49
|
} catch (e) {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
} /**
|
|
53
|
+
* @flow
|
|
54
|
+
*/
|
|
55
|
+
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
56
|
+
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
57
|
+
/*:: export type AuthData = ?{ [key: string]: mixed };*/
|
|
53
58
|
var CURRENT_USER_KEY = 'currentUser';
|
|
54
59
|
var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
|
|
55
60
|
var currentUserCacheMatchesDisk = false;
|
|
@@ -150,8 +155,14 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
|
|
|
150
155
|
throw new Error('Invalid type: authData field should be an object');
|
|
151
156
|
}
|
|
152
157
|
authData[authType] = options.authData;
|
|
158
|
+
var oldAnonymousData = authData.anonymous;
|
|
159
|
+
this.stripAnonymity();
|
|
153
160
|
var controller = _CoreManager.default.getUserController();
|
|
154
|
-
return controller.linkWith(this, authData, saveOpts)
|
|
161
|
+
return controller.linkWith(this, authData, saveOpts).catch(function (e) {
|
|
162
|
+
delete authData[authType];
|
|
163
|
+
_this2.restoreAnonimity(oldAnonymousData);
|
|
164
|
+
throw e;
|
|
165
|
+
});
|
|
155
166
|
} else {
|
|
156
167
|
return new _promise.default(function (resolve, reject) {
|
|
157
168
|
provider.authenticate({
|
|
@@ -382,6 +393,24 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
|
|
|
382
393
|
}
|
|
383
394
|
return isCurrentAsync;
|
|
384
395
|
}()
|
|
396
|
+
}, {
|
|
397
|
+
key: "stripAnonymity",
|
|
398
|
+
value: function () {
|
|
399
|
+
var authData = this.get('authData');
|
|
400
|
+
if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
401
|
+
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
|
|
402
|
+
authData.anonymous = null;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}, {
|
|
406
|
+
key: "restoreAnonimity",
|
|
407
|
+
value: function (anonymousData /*: any*/) {
|
|
408
|
+
if (anonymousData) {
|
|
409
|
+
var authData = this.get('authData');
|
|
410
|
+
authData.anonymous = anonymousData;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
385
414
|
/**
|
|
386
415
|
* Returns get("username").
|
|
387
416
|
*
|
|
@@ -405,12 +434,7 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
|
|
|
405
434
|
}, {
|
|
406
435
|
key: "setUsername",
|
|
407
436
|
value: function (username /*: string*/) {
|
|
408
|
-
|
|
409
|
-
var authData = this.get('authData');
|
|
410
|
-
if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
411
|
-
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
|
|
412
|
-
authData.anonymous = null;
|
|
413
|
-
}
|
|
437
|
+
this.stripAnonymity();
|
|
414
438
|
this.set('username', username);
|
|
415
439
|
}
|
|
416
440
|
|
|
@@ -539,6 +563,9 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
|
|
|
539
563
|
if (options.hasOwnProperty('usePost')) {
|
|
540
564
|
loginOptions.usePost = options.usePost;
|
|
541
565
|
}
|
|
566
|
+
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
567
|
+
loginOptions.context = options.context;
|
|
568
|
+
}
|
|
542
569
|
var controller = _CoreManager.default.getUserController();
|
|
543
570
|
return controller.logIn(this, loginOptions);
|
|
544
571
|
}
|
|
@@ -875,6 +902,61 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
|
|
|
875
902
|
return user.logIn(options);
|
|
876
903
|
}
|
|
877
904
|
|
|
905
|
+
/**
|
|
906
|
+
* Logs in a user with a username (or email) and password, and authData. On success, this
|
|
907
|
+
* saves the session to disk, so you can retrieve the currently logged in
|
|
908
|
+
* user using <code>current</code>.
|
|
909
|
+
*
|
|
910
|
+
* @param {string} username The username (or email) to log in with.
|
|
911
|
+
* @param {string} password The password to log in with.
|
|
912
|
+
* @param {object} authData The authData to log in with.
|
|
913
|
+
* @param {object} options
|
|
914
|
+
* @static
|
|
915
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
916
|
+
* the login completes.
|
|
917
|
+
*/
|
|
918
|
+
}, {
|
|
919
|
+
key: "logInWithAdditionalAuth",
|
|
920
|
+
value: function (username /*: string*/, password /*: string*/, authData /*: AuthData*/, options /*:: ?: FullOptions*/) {
|
|
921
|
+
if (typeof username !== 'string') {
|
|
922
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
923
|
+
}
|
|
924
|
+
if (typeof password !== 'string') {
|
|
925
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
926
|
+
}
|
|
927
|
+
if (Object.prototype.toString.call(authData) !== '[object Object]') {
|
|
928
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
|
|
929
|
+
}
|
|
930
|
+
var user = new this();
|
|
931
|
+
user._finishFetch({
|
|
932
|
+
username: username,
|
|
933
|
+
password: password,
|
|
934
|
+
authData: authData
|
|
935
|
+
});
|
|
936
|
+
return user.logIn(options);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Logs in a user with an objectId. On success, this saves the session
|
|
941
|
+
* to disk, so you can retrieve the currently logged in user using
|
|
942
|
+
* <code>current</code>.
|
|
943
|
+
*
|
|
944
|
+
* @param {string} userId The objectId for the user.
|
|
945
|
+
* @static
|
|
946
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
947
|
+
* the login completes.
|
|
948
|
+
*/
|
|
949
|
+
}, {
|
|
950
|
+
key: "loginAs",
|
|
951
|
+
value: function (userId /*: string*/) {
|
|
952
|
+
if (!userId) {
|
|
953
|
+
throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
|
|
954
|
+
}
|
|
955
|
+
var controller = _CoreManager.default.getUserController();
|
|
956
|
+
var user = new this();
|
|
957
|
+
return controller.loginAs(user, userId);
|
|
958
|
+
}
|
|
959
|
+
|
|
878
960
|
/**
|
|
879
961
|
* Logs in a user with a session token. On success, this saves the session
|
|
880
962
|
* to disk, so you can retrieve the currently logged in user using
|
|
@@ -1303,7 +1385,8 @@ var DefaultController = {
|
|
|
1303
1385
|
var stateController = _CoreManager.default.getObjectStateController();
|
|
1304
1386
|
var auth = {
|
|
1305
1387
|
username: user.get('username'),
|
|
1306
|
-
password: user.get('password')
|
|
1388
|
+
password: user.get('password'),
|
|
1389
|
+
authData: user.get('authData')
|
|
1307
1390
|
};
|
|
1308
1391
|
return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
|
|
1309
1392
|
user._migrateId(response.objectId);
|
|
@@ -1319,6 +1402,21 @@ var DefaultController = {
|
|
|
1319
1402
|
return DefaultController.setCurrentUser(user);
|
|
1320
1403
|
});
|
|
1321
1404
|
},
|
|
1405
|
+
loginAs: function (user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
|
|
1406
|
+
var RESTController = _CoreManager.default.getRESTController();
|
|
1407
|
+
return RESTController.request('POST', 'loginAs', {
|
|
1408
|
+
userId: userId
|
|
1409
|
+
}, {
|
|
1410
|
+
useMasterKey: true
|
|
1411
|
+
}).then(function (response) {
|
|
1412
|
+
user._finishFetch(response);
|
|
1413
|
+
user._setExisted(true);
|
|
1414
|
+
if (!canUseCurrentUser) {
|
|
1415
|
+
return _promise.default.resolve(user);
|
|
1416
|
+
}
|
|
1417
|
+
return DefaultController.setCurrentUser(user);
|
|
1418
|
+
});
|
|
1419
|
+
},
|
|
1322
1420
|
become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
|
|
1323
1421
|
var RESTController = _CoreManager.default.getRESTController();
|
|
1324
1422
|
return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
|
package/lib/browser/Push.js
CHANGED
|
@@ -13,7 +13,14 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
|
13
13
|
/**
|
|
14
14
|
* @flow
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
/*:: import type { WhereClause } from './ParseQuery';*/
|
|
17
|
+
/*:: import type { FullOptions } from './RESTController';*/
|
|
18
|
+
/*:: export type PushData = {
|
|
19
|
+
where?: WhereClause | ParseQuery,
|
|
20
|
+
push_time?: Date | string,
|
|
21
|
+
expiration_time?: Date | string,
|
|
22
|
+
expiration_interval?: number,
|
|
23
|
+
};*/
|
|
17
24
|
/**
|
|
18
25
|
* Contains functions to deal with Push in Parse.
|
|
19
26
|
*
|
|
@@ -21,7 +28,6 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
|
21
28
|
* @static
|
|
22
29
|
* @hideconstructor
|
|
23
30
|
*/
|
|
24
|
-
|
|
25
31
|
/**
|
|
26
32
|
* Sends a push notification.
|
|
27
33
|
* **Available in Cloud Code only.**
|
|
@@ -45,6 +45,26 @@ function _objectSpread(target) {
|
|
|
45
45
|
*/
|
|
46
46
|
/* global XMLHttpRequest, XDomainRequest */
|
|
47
47
|
var uuidv4 = require('./uuid');
|
|
48
|
+
/*:: export type RequestOptions = {
|
|
49
|
+
useMasterKey?: boolean,
|
|
50
|
+
sessionToken?: string,
|
|
51
|
+
installationId?: string,
|
|
52
|
+
returnStatus?: boolean,
|
|
53
|
+
batchSize?: number,
|
|
54
|
+
include?: any,
|
|
55
|
+
progress?: any,
|
|
56
|
+
context?: any,
|
|
57
|
+
usePost?: boolean,
|
|
58
|
+
};*/
|
|
59
|
+
/*:: export type FullOptions = {
|
|
60
|
+
success?: any,
|
|
61
|
+
error?: any,
|
|
62
|
+
useMasterKey?: boolean,
|
|
63
|
+
sessionToken?: string,
|
|
64
|
+
installationId?: string,
|
|
65
|
+
progress?: any,
|
|
66
|
+
usePost?: boolean,
|
|
67
|
+
};*/
|
|
48
68
|
var XHR = null;
|
|
49
69
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
50
70
|
XHR = XMLHttpRequest;
|
|
@@ -66,7 +66,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
66
66
|
/**
|
|
67
67
|
* @flow
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
/*:: import type { Op } from './ParseOp';*/
|
|
70
|
+
/*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
|
|
71
|
+
/*:: type ObjectIdentifier = {
|
|
72
|
+
className: string,
|
|
73
|
+
id: string,
|
|
74
|
+
};*/
|
|
70
75
|
var objectState
|
|
71
76
|
/*: {
|
|
72
77
|
[className: string]: {
|
package/lib/browser/Storage.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
4
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
5
10
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
6
11
|
/**
|
|
@@ -88,4 +93,6 @@ var Storage = {
|
|
|
88
93
|
}
|
|
89
94
|
};
|
|
90
95
|
module.exports = Storage;
|
|
96
|
+
var _default = Storage;
|
|
97
|
+
exports.default = _default;
|
|
91
98
|
_CoreManager.default.setStorageController(require('./StorageController.browser'));
|
package/lib/browser/TaskQueue.js
CHANGED
|
@@ -8,6 +8,10 @@ var _promiseUtils = require("./promiseUtils");
|
|
|
8
8
|
/**
|
|
9
9
|
* @flow
|
|
10
10
|
*/
|
|
11
|
+
/*:: type Task = {
|
|
12
|
+
task: () => Promise,
|
|
13
|
+
_completion: Promise,
|
|
14
|
+
};*/
|
|
11
15
|
var TaskQueue = /*#__PURE__*/function () {
|
|
12
16
|
function TaskQueue() {
|
|
13
17
|
(0, _classCallCheck2.default)(this, TaskQueue);
|
|
@@ -69,7 +69,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
69
69
|
/**
|
|
70
70
|
* @flow
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
/*:: import type { Op } from './ParseOp';*/
|
|
73
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
74
|
+
/*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
|
|
73
75
|
var objectState = new _weakMap.default();
|
|
74
76
|
function getState(obj /*: ParseObject*/) /*: ?State*/{
|
|
75
77
|
var classData = objectState.get(obj);
|
|
@@ -17,7 +17,10 @@ var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
|
17
17
|
/**
|
|
18
18
|
* @flow
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
/*:: type EncounterMap = {
|
|
21
|
+
objects: { [identifier: string]: ParseObject | boolean },
|
|
22
|
+
files: Array<ParseFile>,
|
|
23
|
+
};*/
|
|
21
24
|
/**
|
|
22
25
|
* Return an array of unsaved children, which are either Parse Objects or Files.
|
|
23
26
|
* If it encounters any dirty Objects without Ids, it will throw an exception.
|
package/lib/node/Cloud.js
CHANGED
|
@@ -21,7 +21,7 @@ function _interopRequireDefault(obj) {
|
|
|
21
21
|
/**
|
|
22
22
|
* @flow
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
/*:: import type { RequestOptions } from './RESTController';*/
|
|
25
25
|
/**
|
|
26
26
|
* Contains functions for calling and declaring
|
|
27
27
|
* <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
|
|
@@ -33,7 +33,6 @@ function _interopRequireDefault(obj) {
|
|
|
33
33
|
* @static
|
|
34
34
|
* @hideconstructor
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
36
|
/**
|
|
38
37
|
* Makes a call to a cloud function.
|
|
39
38
|
*
|
|
@@ -57,6 +56,9 @@ function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/)
|
|
|
57
56
|
if (options.sessionToken) {
|
|
58
57
|
requestOptions.sessionToken = options.sessionToken;
|
|
59
58
|
}
|
|
59
|
+
if (options.installationId) {
|
|
60
|
+
requestOptions.installationId = options.installationId;
|
|
61
|
+
}
|
|
60
62
|
if (options.context && typeof options.context === 'object') {
|
|
61
63
|
requestOptions.context = options.context;
|
|
62
64
|
}
|
package/lib/node/CoreManager.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
|
/*
|
|
4
8
|
* @flow
|
|
5
9
|
*/
|
|
@@ -179,7 +183,7 @@ const config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
179
183
|
SERVER_AUTH_TOKEN: null,
|
|
180
184
|
LIVEQUERY_SERVER_URL: null,
|
|
181
185
|
ENCRYPTED_KEY: null,
|
|
182
|
-
VERSION: 'js' + "4.
|
|
186
|
+
VERSION: 'js' + "4.2.0-alpha.10",
|
|
183
187
|
APPLICATION_ID: null,
|
|
184
188
|
JAVASCRIPT_KEY: null,
|
|
185
189
|
MASTER_KEY: null,
|
|
@@ -188,7 +192,8 @@ const config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
188
192
|
FORCE_REVOCABLE_SESSION: false,
|
|
189
193
|
ENCRYPTED_USER: false,
|
|
190
194
|
IDEMPOTENCY: false,
|
|
191
|
-
ALLOW_CUSTOM_OBJECT_ID: false
|
|
195
|
+
ALLOW_CUSTOM_OBJECT_ID: false,
|
|
196
|
+
PARSE_ERRORS: []
|
|
192
197
|
};
|
|
193
198
|
function requireMethods(name /*: string*/, methods /*: Array<string>*/, controller /*: any*/) {
|
|
194
199
|
methods.forEach(func => {
|
|
@@ -197,7 +202,7 @@ function requireMethods(name /*: string*/, methods /*: Array<string>*/, controll
|
|
|
197
202
|
}
|
|
198
203
|
});
|
|
199
204
|
}
|
|
200
|
-
|
|
205
|
+
const CoreManager = {
|
|
201
206
|
get: function (key /*: string*/) /*: any*/{
|
|
202
207
|
if (config.hasOwnProperty(key)) {
|
|
203
208
|
return config[key];
|
|
@@ -207,6 +212,12 @@ module.exports = {
|
|
|
207
212
|
set: function (key /*: string*/, value /*: any*/) /*: void*/{
|
|
208
213
|
config[key] = value;
|
|
209
214
|
},
|
|
215
|
+
setIfNeeded: function (key /*: string*/, value /*: any*/) /*: any*/{
|
|
216
|
+
if (!config.hasOwnProperty(key)) {
|
|
217
|
+
config[key] = value;
|
|
218
|
+
}
|
|
219
|
+
return config[key];
|
|
220
|
+
},
|
|
210
221
|
/* Specialized Controller Setters/Getters */
|
|
211
222
|
|
|
212
223
|
setAnalyticsController(controller /*: AnalyticsController*/) {
|
|
@@ -237,6 +248,12 @@ module.exports = {
|
|
|
237
248
|
getCryptoController() /*: CryptoController*/{
|
|
238
249
|
return config['CryptoController'];
|
|
239
250
|
},
|
|
251
|
+
setEventEmitter(eventEmitter /*: any*/) {
|
|
252
|
+
config['EventEmitter'] = eventEmitter;
|
|
253
|
+
},
|
|
254
|
+
getEventEmitter() /*: any*/{
|
|
255
|
+
return config['EventEmitter'];
|
|
256
|
+
},
|
|
240
257
|
setFileController(controller /*: FileController*/) {
|
|
241
258
|
requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
|
|
242
259
|
config['FileController'] = controller;
|
|
@@ -251,6 +268,12 @@ module.exports = {
|
|
|
251
268
|
getInstallationController() /*: InstallationController*/{
|
|
252
269
|
return config['InstallationController'];
|
|
253
270
|
},
|
|
271
|
+
setLiveQuery(liveQuery /*: any*/) {
|
|
272
|
+
config['LiveQuery'] = liveQuery;
|
|
273
|
+
},
|
|
274
|
+
getLiveQuery() /*: any*/{
|
|
275
|
+
return config['LiveQuery'];
|
|
276
|
+
},
|
|
254
277
|
setObjectController(controller /*: ObjectController*/) {
|
|
255
278
|
requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
|
|
256
279
|
config['ObjectController'] = controller;
|
|
@@ -357,4 +380,7 @@ module.exports = {
|
|
|
357
380
|
getHooksController() /*: HooksController*/{
|
|
358
381
|
return config['HooksController'];
|
|
359
382
|
}
|
|
360
|
-
};
|
|
383
|
+
};
|
|
384
|
+
module.exports = CoreManager;
|
|
385
|
+
var _default = CoreManager;
|
|
386
|
+
exports.default = _default;
|
package/lib/node/EventEmitter.js
CHANGED
|
@@ -3,4 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a simple wrapper to unify EventEmitter implementations across platforms.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
let EventEmitter;
|
|
7
|
+
try {
|
|
8
|
+
EventEmitter = require('events').EventEmitter;
|
|
9
|
+
} catch (_) {
|
|
10
|
+
// EventEmitter unavailable
|
|
11
|
+
}
|
|
12
|
+
module.exports = EventEmitter;
|
|
@@ -1,6 +1,11 @@
|
|
|
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"));
|
|
8
|
+
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
4
9
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
5
10
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
6
11
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
@@ -14,7 +19,19 @@ function _interopRequireDefault(obj) {
|
|
|
14
19
|
*
|
|
15
20
|
* @flow
|
|
16
21
|
*/
|
|
17
|
-
|
|
22
|
+
/*:: import type { SaveOptions } from './ParseObject';*/
|
|
23
|
+
/*:: import type { RequestOptions } from './RESTController';*/
|
|
24
|
+
/*:: type QueueObject = {
|
|
25
|
+
queueId: string,
|
|
26
|
+
action: string,
|
|
27
|
+
object: ParseObject,
|
|
28
|
+
serverOptions: SaveOptions | RequestOptions,
|
|
29
|
+
id: string,
|
|
30
|
+
className: string,
|
|
31
|
+
hash: string,
|
|
32
|
+
createdAt: Date,
|
|
33
|
+
};*/
|
|
34
|
+
/*:: type Queue = Array<QueueObject>;*/
|
|
18
35
|
const QUEUE_KEY = 'Parse/Eventually/Queue';
|
|
19
36
|
let queueCache = [];
|
|
20
37
|
let dirtyCache = true;
|
|
@@ -251,7 +268,7 @@ const EventuallyQueue = {
|
|
|
251
268
|
await object.save(queueObject.object, queueObject.serverOptions);
|
|
252
269
|
await this.remove(queueObject.queueId);
|
|
253
270
|
} catch (e) {
|
|
254
|
-
if (e.
|
|
271
|
+
if (e.code !== _ParseError.default.CONNECTION_FAILED) {
|
|
255
272
|
await this.remove(queueObject.queueId);
|
|
256
273
|
}
|
|
257
274
|
}
|
|
@@ -261,7 +278,7 @@ const EventuallyQueue = {
|
|
|
261
278
|
await object.destroy(queueObject.serverOptions);
|
|
262
279
|
await this.remove(queueObject.queueId);
|
|
263
280
|
} catch (e) {
|
|
264
|
-
if (e.
|
|
281
|
+
if (e.code !== _ParseError.default.CONNECTION_FAILED) {
|
|
265
282
|
await this.remove(queueObject.queueId);
|
|
266
283
|
}
|
|
267
284
|
}
|
|
@@ -350,4 +367,6 @@ const EventuallyQueue = {
|
|
|
350
367
|
}
|
|
351
368
|
}
|
|
352
369
|
};
|
|
353
|
-
module.exports = EventuallyQueue;
|
|
370
|
+
module.exports = EventuallyQueue;
|
|
371
|
+
var _default = EventuallyQueue;
|
|
372
|
+
exports.default = _default;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
8
|
-
var _EventEmitter = _interopRequireDefault(require("./EventEmitter"));
|
|
9
8
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
10
9
|
var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscription"));
|
|
11
10
|
var _promiseUtils = require("./promiseUtils");
|
|
@@ -72,7 +71,6 @@ const generateInterval = k => {
|
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
73
|
* Creates a new LiveQueryClient.
|
|
75
|
-
* Extends events.EventEmitter
|
|
76
74
|
* <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
|
|
77
75
|
*
|
|
78
76
|
* A wrapper of a standard WebSocket client. We add several useful methods to
|
|
@@ -114,7 +112,7 @@ const generateInterval = k => {
|
|
|
114
112
|
*
|
|
115
113
|
* @alias Parse.LiveQueryClient
|
|
116
114
|
*/
|
|
117
|
-
class LiveQueryClient
|
|
115
|
+
class LiveQueryClient {
|
|
118
116
|
/*:: attempts: number;*/
|
|
119
117
|
/*:: id: number;*/
|
|
120
118
|
/*:: requestId: number;*/
|
|
@@ -146,7 +144,6 @@ class LiveQueryClient extends _EventEmitter.default {
|
|
|
146
144
|
sessionToken,
|
|
147
145
|
installationId
|
|
148
146
|
}) {
|
|
149
|
-
super();
|
|
150
147
|
if (!serverURL || serverURL.indexOf('ws') !== 0) {
|
|
151
148
|
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
|
|
152
149
|
}
|
|
@@ -164,7 +161,10 @@ class LiveQueryClient extends _EventEmitter.default {
|
|
|
164
161
|
this.connectPromise = (0, _promiseUtils.resolvingPromise)();
|
|
165
162
|
this.subscriptions = new Map();
|
|
166
163
|
this.state = CLIENT_STATE.INITIALIZED;
|
|
167
|
-
|
|
164
|
+
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
165
|
+
this.emitter = new EventEmitter();
|
|
166
|
+
this.on = this.emitter.on;
|
|
167
|
+
this.emit = this.emitter.emit;
|
|
168
168
|
// adding listener so process does not crash
|
|
169
169
|
// best practice is for developer to register their own listener
|
|
170
170
|
this.on('error', () => {});
|
|
@@ -188,20 +188,23 @@ class LiveQueryClient extends _EventEmitter.default {
|
|
|
188
188
|
* @returns {LiveQuerySubscription | undefined}
|
|
189
189
|
*/
|
|
190
190
|
subscribe(query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
|
|
191
|
+
var _queryJSON$keys, _queryJSON$watch;
|
|
191
192
|
if (!query) {
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
195
|
const className = query.className;
|
|
195
196
|
const queryJSON = query.toJSON();
|
|
196
197
|
const where = queryJSON.where;
|
|
197
|
-
const fields = queryJSON.keys ?
|
|
198
|
+
const fields = (_queryJSON$keys = queryJSON.keys) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
|
|
199
|
+
const watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
|
|
198
200
|
const subscribeRequest = {
|
|
199
201
|
op: OP_TYPES.SUBSCRIBE,
|
|
200
202
|
requestId: this.requestId,
|
|
201
203
|
query: {
|
|
202
204
|
className,
|
|
203
205
|
where,
|
|
204
|
-
fields
|
|
206
|
+
fields,
|
|
207
|
+
watch
|
|
205
208
|
}
|
|
206
209
|
};
|
|
207
210
|
if (sessionToken) {
|
|
@@ -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 _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
9
8
|
var _promiseUtils = require("./promiseUtils");
|
|
10
9
|
function _interopRequireDefault(obj) {
|
|
@@ -14,7 +13,6 @@ function _interopRequireDefault(obj) {
|
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Creates a new LiveQuery Subscription.
|
|
17
|
-
* Extends events.EventEmitter
|
|
18
16
|
* <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
|
|
19
17
|
*
|
|
20
18
|
* <p>Response Object - Contains data from the client that made the request
|
|
@@ -94,24 +92,24 @@ function _interopRequireDefault(obj) {
|
|
|
94
92
|
* subscription.on('close', () => {
|
|
95
93
|
*
|
|
96
94
|
* });</pre></p>
|
|
97
|
-
*
|
|
98
|
-
* @alias Parse.LiveQuerySubscription
|
|
99
95
|
*/
|
|
100
|
-
class Subscription
|
|
96
|
+
class Subscription {
|
|
101
97
|
/*
|
|
102
98
|
* @param {string} id - subscription id
|
|
103
99
|
* @param {string} query - query to subscribe to
|
|
104
100
|
* @param {string} sessionToken - optional session token
|
|
105
101
|
*/
|
|
106
102
|
constructor(id, query, sessionToken) {
|
|
107
|
-
super();
|
|
108
103
|
this.id = id;
|
|
109
104
|
this.query = query;
|
|
110
105
|
this.sessionToken = sessionToken;
|
|
111
106
|
this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
|
|
112
107
|
this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
|
|
113
108
|
this.subscribed = false;
|
|
114
|
-
|
|
109
|
+
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
110
|
+
this.emitter = new EventEmitter();
|
|
111
|
+
this.on = this.emitter.on;
|
|
112
|
+
this.emit = this.emitter.emit;
|
|
115
113
|
// adding listener so process does not crash
|
|
116
114
|
// best practice is for developer to register their own listener
|
|
117
115
|
this.on('error', () => {});
|
|
@@ -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
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
5
9
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
@@ -11,7 +15,7 @@ function _interopRequireDefault(obj) {
|
|
|
11
15
|
/**
|
|
12
16
|
* @flow
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
15
19
|
/**
|
|
16
20
|
* Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
|
|
17
21
|
* To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
|
|
@@ -370,5 +374,7 @@ const LocalDatastore = {
|
|
|
370
374
|
}
|
|
371
375
|
};
|
|
372
376
|
module.exports = LocalDatastore;
|
|
377
|
+
var _default = LocalDatastore;
|
|
378
|
+
exports.default = _default;
|
|
373
379
|
_CoreManager.default.setLocalDatastoreController(require('./LocalDatastoreController'));
|
|
374
380
|
_CoreManager.default.setLocalDatastore(LocalDatastore);
|
|
@@ -26,7 +26,17 @@ function _interopRequireDefault(obj) {
|
|
|
26
26
|
/**
|
|
27
27
|
* @flow
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
/*:: import type { Op } from './ParseOp';*/
|
|
30
|
+
/*:: export type AttributeMap = { [attr: string]: any };*/
|
|
31
|
+
/*:: export type OpsMap = { [attr: string]: Op };*/
|
|
32
|
+
/*:: export type ObjectCache = { [attr: string]: string };*/
|
|
33
|
+
/*:: export type State = {
|
|
34
|
+
serverData: AttributeMap,
|
|
35
|
+
pendingOps: Array<OpsMap>,
|
|
36
|
+
objectCache: ObjectCache,
|
|
37
|
+
tasks: TaskQueue,
|
|
38
|
+
existed: boolean,
|
|
39
|
+
};*/
|
|
30
40
|
function defaultState() /*: State*/{
|
|
31
41
|
return {
|
|
32
42
|
serverData: {},
|
|
@@ -140,7 +150,9 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
|
|
|
140
150
|
function nestedSet(obj, key, value) {
|
|
141
151
|
const path = key.split('.');
|
|
142
152
|
for (let i = 0; i < path.length - 1; i++) {
|
|
143
|
-
if (!(path[i] in obj))
|
|
153
|
+
if (!(path[i] in obj)) {
|
|
154
|
+
obj[path[i]] = {};
|
|
155
|
+
}
|
|
144
156
|
obj = obj[path[i]];
|
|
145
157
|
}
|
|
146
158
|
if (typeof value === 'undefined') {
|
package/lib/node/OfflineQuery.js
CHANGED