parse 5.1.1-alpha.1 → 5.2.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 +1411 -1216
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1414 -1219
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +7 -11
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/InstallationController.js +3 -3
- package/lib/browser/LiveQueryClient.js +102 -60
- package/lib/browser/LocalDatastore.js +189 -147
- package/lib/browser/LocalDatastoreController.default.js +14 -9
- package/lib/browser/LocalDatastoreController.react-native.js +14 -12
- package/lib/browser/LocalDatastoreUtils.js +0 -5
- package/lib/browser/ObjectStateMutations.js +57 -21
- package/lib/browser/Parse.js +2 -2
- package/lib/browser/ParseCLP.js +9 -17
- package/lib/browser/ParseFile.js +27 -31
- package/lib/browser/ParseGeoPoint.js +9 -3
- package/lib/browser/ParseHooks.js +13 -13
- package/lib/browser/ParseInstallation.js +14 -0
- package/lib/browser/ParseObject.js +15 -13
- package/lib/browser/ParseOp.js +17 -17
- package/lib/browser/ParsePolygon.js +1 -1
- package/lib/browser/ParseQuery.js +147 -149
- package/lib/browser/ParseRole.js +5 -9
- package/lib/browser/ParseSchema.js +1 -1
- package/lib/browser/ParseUser.js +66 -51
- package/lib/browser/Push.js +5 -10
- package/lib/browser/RESTController.js +1 -1
- package/lib/browser/SingleInstanceStateController.js +1 -1
- package/lib/browser/TaskQueue.js +10 -10
- package/lib/browser/UniqueInstanceStateController.js +1 -1
- package/lib/node/Cloud.js +7 -11
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/InstallationController.js +3 -3
- package/lib/node/LiveQueryClient.js +14 -24
- package/lib/node/LocalDatastore.js +7 -11
- package/lib/node/LocalDatastoreController.default.js +12 -10
- package/lib/node/LocalDatastoreController.react-native.js +13 -12
- package/lib/node/LocalDatastoreUtils.js +0 -5
- package/lib/node/ObjectStateMutations.js +45 -19
- package/lib/node/Parse.js +2 -2
- package/lib/node/ParseCLP.js +8 -18
- package/lib/node/ParseFile.js +27 -40
- package/lib/node/ParseGeoPoint.js +9 -3
- package/lib/node/ParseHooks.js +13 -13
- package/lib/node/ParseInstallation.js +14 -0
- package/lib/node/ParseObject.js +15 -13
- package/lib/node/ParseOp.js +21 -21
- package/lib/node/ParsePolygon.js +1 -1
- package/lib/node/ParseQuery.js +84 -107
- package/lib/node/ParseRole.js +3 -8
- package/lib/node/ParseSchema.js +4 -4
- package/lib/node/ParseUser.js +42 -37
- package/lib/node/Push.js +3 -8
- package/lib/node/RESTController.js +1 -1
- package/lib/node/SingleInstanceStateController.js +1 -1
- package/lib/node/TaskQueue.js +9 -11
- package/lib/node/UniqueInstanceStateController.js +1 -1
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +49 -32
- package/lib/react-native/LocalDatastore.js +38 -14
- package/lib/react-native/LocalDatastoreController.default.js +7 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/ParseCLP.js +3 -3
- package/lib/react-native/ParseFile.js +7 -6
- package/lib/react-native/ParseObject.js +4 -3
- package/lib/react-native/ParseQuery.js +45 -37
- package/lib/react-native/ParseRole.js +1 -1
- package/lib/react-native/ParseUser.js +22 -16
- package/lib/react-native/TaskQueue.js +8 -2
- package/lib/weapp/Cloud.js +7 -11
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/InstallationController.js +3 -3
- package/lib/weapp/LiveQueryClient.js +102 -60
- package/lib/weapp/LocalDatastore.js +189 -147
- package/lib/weapp/LocalDatastoreController.default.js +14 -9
- package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
- package/lib/weapp/LocalDatastoreUtils.js +0 -5
- package/lib/weapp/ObjectStateMutations.js +57 -21
- package/lib/weapp/Parse.js +2 -2
- package/lib/weapp/ParseCLP.js +9 -17
- package/lib/weapp/ParseFile.js +27 -31
- package/lib/weapp/ParseGeoPoint.js +9 -3
- package/lib/weapp/ParseHooks.js +13 -13
- package/lib/weapp/ParseInstallation.js +14 -0
- package/lib/weapp/ParseObject.js +15 -13
- package/lib/weapp/ParseOp.js +17 -17
- package/lib/weapp/ParsePolygon.js +1 -1
- package/lib/weapp/ParseQuery.js +147 -149
- package/lib/weapp/ParseRole.js +5 -9
- package/lib/weapp/ParseSchema.js +1 -1
- package/lib/weapp/ParseUser.js +66 -51
- package/lib/weapp/Push.js +5 -10
- package/lib/weapp/RESTController.js +1 -1
- package/lib/weapp/SingleInstanceStateController.js +1 -1
- package/lib/weapp/TaskQueue.js +10 -10
- package/lib/weapp/UniqueInstanceStateController.js +1 -1
- package/package.json +5 -6
package/lib/node/ParseUser.js
CHANGED
|
@@ -8,24 +8,27 @@ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
|
8
8
|
var _isRevocableSession = _interopRequireDefault(require("./isRevocableSession"));
|
|
9
9
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
10
10
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
11
|
-
var _ParseSession = _interopRequireDefault(require("./ParseSession"));
|
|
12
11
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
13
12
|
function _interopRequireDefault(obj) {
|
|
14
13
|
return obj && obj.__esModule ? obj : {
|
|
15
14
|
default: obj
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
/*:: export type AuthData = { [key: string]: any };*/
|
|
18
|
+
/*:: export type AuthProviderType = {
|
|
19
|
+
authenticate?(options: {
|
|
20
|
+
error?: (provider: AuthProviderType, error: string | any) => void,
|
|
21
|
+
success?: (provider: AuthProviderType, result: AuthData) => void,
|
|
22
|
+
}): void,
|
|
23
|
+
restoreAuthentication(authData: any): boolean;
|
|
24
|
+
getAuthType(): string;
|
|
25
|
+
deauthenticate?(): void;
|
|
26
|
+
};*/
|
|
24
27
|
const CURRENT_USER_KEY = 'currentUser';
|
|
25
28
|
let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
|
|
26
29
|
let currentUserCacheMatchesDisk = false;
|
|
27
|
-
let currentUserCache = null;
|
|
28
|
-
const authProviders = {};
|
|
30
|
+
let currentUserCache /*: ParseUser | null*/ = null;
|
|
31
|
+
const authProviders /*: { [key: string]: AuthProviderType }*/ = {};
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* <p>A Parse.User object is a local representation of a user persisted to the
|
|
@@ -41,7 +44,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
41
44
|
/**
|
|
42
45
|
* @param {object} attributes The initial set of data to store in the user.
|
|
43
46
|
*/
|
|
44
|
-
constructor(attributes
|
|
47
|
+
constructor(attributes /*:: ?: AttributeMap*/) {
|
|
45
48
|
super('_User');
|
|
46
49
|
if (attributes && typeof attributes === 'object') {
|
|
47
50
|
if (!this.set(attributes || {})) {
|
|
@@ -59,7 +62,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
59
62
|
*/
|
|
60
63
|
_upgradeToRevocableSession(options /*: RequestOptions*/) /*: Promise<void>*/{
|
|
61
64
|
options = options || {};
|
|
62
|
-
const upgradeOptions = {};
|
|
65
|
+
const upgradeOptions /*: RequestOptions*/ = {};
|
|
63
66
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
64
67
|
upgradeOptions.useMasterKey = options.useMasterKey;
|
|
65
68
|
}
|
|
@@ -75,6 +78,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
75
78
|
* @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
|
|
76
79
|
* @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
|
|
77
80
|
* @param {object} options
|
|
81
|
+
* @param {object} [options.authData] AuthData to link with
|
|
78
82
|
* <ul>
|
|
79
83
|
* <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
|
|
80
84
|
* <li>If provider is AuthProvider, options is saveOpts
|
|
@@ -82,7 +86,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
82
86
|
* @param {object} saveOpts useMasterKey / sessionToken
|
|
83
87
|
* @returns {Promise} A promise that is fulfilled with the user is linked
|
|
84
88
|
*/
|
|
85
|
-
linkWith(provider /*:
|
|
89
|
+
linkWith(provider /*: AuthProviderType*/, options /*: { authData?: AuthData }*/, saveOpts /*: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
|
|
86
90
|
saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
|
|
87
91
|
let authType;
|
|
88
92
|
if (typeof provider === 'string') {
|
|
@@ -122,7 +126,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
122
126
|
return new Promise((resolve, reject) => {
|
|
123
127
|
provider.authenticate({
|
|
124
128
|
success: (provider, result) => {
|
|
125
|
-
const opts = {};
|
|
129
|
+
const opts /*: { authData?: AuthData }*/ = {};
|
|
126
130
|
opts.authData = result;
|
|
127
131
|
this.linkWith(provider, opts, saveOpts).then(() => {
|
|
128
132
|
resolve(this);
|
|
@@ -141,11 +145,12 @@ class ParseUser extends _ParseObject.default {
|
|
|
141
145
|
/**
|
|
142
146
|
* @param provider
|
|
143
147
|
* @param options
|
|
148
|
+
* @param {object} [options.authData]
|
|
144
149
|
* @param saveOpts
|
|
145
150
|
* @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
|
|
146
151
|
* @returns {Promise}
|
|
147
152
|
*/
|
|
148
|
-
_linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts
|
|
153
|
+
_linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
|
|
149
154
|
return this.linkWith(provider, options, saveOpts);
|
|
150
155
|
}
|
|
151
156
|
|
|
@@ -155,7 +160,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
155
160
|
*
|
|
156
161
|
* @param provider
|
|
157
162
|
*/
|
|
158
|
-
_synchronizeAuthData(provider /*: string*/) {
|
|
163
|
+
_synchronizeAuthData(provider /*: string | AuthProviderType*/) {
|
|
159
164
|
if (!this.isCurrent() || !provider) {
|
|
160
165
|
return;
|
|
161
166
|
}
|
|
@@ -325,7 +330,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
325
330
|
*
|
|
326
331
|
* @returns {string}
|
|
327
332
|
*/
|
|
328
|
-
getUsername() /*:
|
|
333
|
+
getUsername() /*: string | null*/{
|
|
329
334
|
const username = this.get('username');
|
|
330
335
|
if (username == null || typeof username === 'string') {
|
|
331
336
|
return username;
|
|
@@ -357,7 +362,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
357
362
|
*
|
|
358
363
|
* @returns {string} User's Email
|
|
359
364
|
*/
|
|
360
|
-
getEmail() /*:
|
|
365
|
+
getEmail() /*: string | null*/{
|
|
361
366
|
const email = this.get('email');
|
|
362
367
|
if (email == null || typeof email === 'string') {
|
|
363
368
|
return email;
|
|
@@ -382,7 +387,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
382
387
|
*
|
|
383
388
|
* @returns {string} the session token, or undefined
|
|
384
389
|
*/
|
|
385
|
-
getSessionToken() /*:
|
|
390
|
+
getSessionToken() /*: string | null*/{
|
|
386
391
|
const token = this.get('sessionToken');
|
|
387
392
|
if (token == null || typeof token === 'string') {
|
|
388
393
|
return token;
|
|
@@ -413,9 +418,9 @@ class ParseUser extends _ParseObject.default {
|
|
|
413
418
|
* @returns {Promise} A promise that is fulfilled when the signup
|
|
414
419
|
* finishes.
|
|
415
420
|
*/
|
|
416
|
-
signUp(attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
|
|
421
|
+
signUp(attrs /*: AttributeMap*/, options /*:: ?: FullOptions & { context?: AttributeMap }*/) /*: Promise<ParseUser>*/{
|
|
417
422
|
options = options || {};
|
|
418
|
-
const signupOptions = {};
|
|
423
|
+
const signupOptions /*: FullOptions & { context?: AttributeMap }*/ = {};
|
|
419
424
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
420
425
|
signupOptions.useMasterKey = options.useMasterKey;
|
|
421
426
|
}
|
|
@@ -440,9 +445,9 @@ class ParseUser extends _ParseObject.default {
|
|
|
440
445
|
* @returns {Promise} A promise that is fulfilled with the user when
|
|
441
446
|
* the login is complete.
|
|
442
447
|
*/
|
|
443
|
-
logIn(options
|
|
448
|
+
logIn(options /*: FullOptions & { context?: AttributeMap }*/ = {}) /*: Promise<ParseUser>*/{
|
|
444
449
|
options = options || {};
|
|
445
|
-
const loginOptions = {
|
|
450
|
+
const loginOptions /*: FullOptions & { context?: AttributeMap }*/ = {
|
|
446
451
|
usePost: true
|
|
447
452
|
};
|
|
448
453
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
@@ -468,7 +473,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
468
473
|
* @param {...any} args
|
|
469
474
|
* @returns {Promise}
|
|
470
475
|
*/
|
|
471
|
-
async save(...args
|
|
476
|
+
async save(...args) /*: Promise<this>*/{
|
|
472
477
|
await super.save.apply(this, args);
|
|
473
478
|
const current = await this.isCurrentAsync();
|
|
474
479
|
if (current) {
|
|
@@ -484,7 +489,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
484
489
|
* @param {...any} args
|
|
485
490
|
* @returns {Parse.User}
|
|
486
491
|
*/
|
|
487
|
-
async destroy(...args
|
|
492
|
+
async destroy(...args) /*: Promise<ParseUser | void>*/{
|
|
488
493
|
await super.destroy.apply(this, args);
|
|
489
494
|
const current = await this.isCurrentAsync();
|
|
490
495
|
if (current) {
|
|
@@ -500,7 +505,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
500
505
|
* @param {...any} args
|
|
501
506
|
* @returns {Parse.User}
|
|
502
507
|
*/
|
|
503
|
-
async fetch(...args
|
|
508
|
+
async fetch(...args) /*: Promise<ParseUser>*/{
|
|
504
509
|
await super.fetch.apply(this, args);
|
|
505
510
|
const current = await this.isCurrentAsync();
|
|
506
511
|
if (current) {
|
|
@@ -516,7 +521,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
516
521
|
* @param {...any} args
|
|
517
522
|
* @returns {Parse.User}
|
|
518
523
|
*/
|
|
519
|
-
async fetchWithInclude(...args
|
|
524
|
+
async fetchWithInclude(...args) /*: Promise<ParseUser>*/{
|
|
520
525
|
await super.fetchWithInclude.apply(this, args);
|
|
521
526
|
const current = await this.isCurrentAsync();
|
|
522
527
|
if (current) {
|
|
@@ -585,7 +590,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
585
590
|
* @static
|
|
586
591
|
* @returns {Parse.Object} The currently logged in Parse.User.
|
|
587
592
|
*/
|
|
588
|
-
static current() /*:
|
|
593
|
+
static current() /*: ParseUser | null*/{
|
|
589
594
|
if (!canUseCurrentUser) {
|
|
590
595
|
return null;
|
|
591
596
|
}
|
|
@@ -600,7 +605,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
600
605
|
* @returns {Promise} A Promise that is resolved with the currently
|
|
601
606
|
* logged in Parse User
|
|
602
607
|
*/
|
|
603
|
-
static currentAsync() /*: Promise
|
|
608
|
+
static currentAsync() /*: Promise<ParseUser | null>*/{
|
|
604
609
|
if (!canUseCurrentUser) {
|
|
605
610
|
return Promise.resolve(null);
|
|
606
611
|
}
|
|
@@ -742,7 +747,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
742
747
|
* @static
|
|
743
748
|
* @returns {Promise} A promise that is fulfilled with the user is fetched.
|
|
744
749
|
*/
|
|
745
|
-
static me(sessionToken /*: string*/, options
|
|
750
|
+
static me(sessionToken /*: string*/, options /*: RequestOptions*/ = {}) {
|
|
746
751
|
const controller = _CoreManager.default.getUserController();
|
|
747
752
|
const meOptions /*: RequestOptions*/ = {
|
|
748
753
|
sessionToken: sessionToken
|
|
@@ -775,6 +780,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
775
780
|
*
|
|
776
781
|
* @param provider
|
|
777
782
|
* @param options
|
|
783
|
+
* @param {object} [options.authData]
|
|
778
784
|
* @param saveOpts
|
|
779
785
|
* @static
|
|
780
786
|
* @returns {Promise}
|
|
@@ -812,7 +818,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
812
818
|
*/
|
|
813
819
|
static requestPasswordReset(email /*: string*/, options /*:: ?: RequestOptions*/) {
|
|
814
820
|
options = options || {};
|
|
815
|
-
const requestOptions = {};
|
|
821
|
+
const requestOptions /*: RequestOptions*/ = {};
|
|
816
822
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
817
823
|
requestOptions.useMasterKey = options.useMasterKey;
|
|
818
824
|
}
|
|
@@ -831,7 +837,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
831
837
|
*/
|
|
832
838
|
static requestEmailVerification(email /*: string*/, options /*:: ?: RequestOptions*/) {
|
|
833
839
|
options = options || {};
|
|
834
|
-
const requestOptions = {};
|
|
840
|
+
const requestOptions /*: RequestOptions*/ = {};
|
|
835
841
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
836
842
|
requestOptions.useMasterKey = options.useMasterKey;
|
|
837
843
|
}
|
|
@@ -947,6 +953,7 @@ class ParseUser extends _ParseObject.default {
|
|
|
947
953
|
/**
|
|
948
954
|
* @param provider
|
|
949
955
|
* @param options
|
|
956
|
+
* @param {object} [options.authData]
|
|
950
957
|
* @param saveOpts
|
|
951
958
|
* @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
|
|
952
959
|
* @static
|
|
@@ -992,7 +999,7 @@ const DefaultController = {
|
|
|
992
999
|
user._synchronizeAllAuthData();
|
|
993
1000
|
return DefaultController.updateUserOnDisk(user);
|
|
994
1001
|
},
|
|
995
|
-
currentUser() /*:
|
|
1002
|
+
currentUser() /*: ParseUser | null*/{
|
|
996
1003
|
if (currentUserCache) {
|
|
997
1004
|
return currentUserCache;
|
|
998
1005
|
}
|
|
@@ -1032,7 +1039,7 @@ const DefaultController = {
|
|
|
1032
1039
|
current._synchronizeAllAuthData();
|
|
1033
1040
|
return current;
|
|
1034
1041
|
},
|
|
1035
|
-
currentUserAsync() /*: Promise
|
|
1042
|
+
currentUserAsync() /*: Promise<ParseUser | null>*/{
|
|
1036
1043
|
if (currentUserCache) {
|
|
1037
1044
|
return Promise.resolve(currentUserCache);
|
|
1038
1045
|
}
|
|
@@ -1152,7 +1159,7 @@ const DefaultController = {
|
|
|
1152
1159
|
return user;
|
|
1153
1160
|
});
|
|
1154
1161
|
},
|
|
1155
|
-
logOut(options /*: RequestOptions*/) /*: Promise<
|
|
1162
|
+
logOut(options /*: RequestOptions*/) /*: Promise<void>*/{
|
|
1156
1163
|
const RESTController = _CoreManager.default.getRESTController();
|
|
1157
1164
|
if (options.sessionToken) {
|
|
1158
1165
|
return RESTController.request('POST', 'logout', {}, options);
|
|
@@ -1193,10 +1200,8 @@ const DefaultController = {
|
|
|
1193
1200
|
options.sessionToken = token;
|
|
1194
1201
|
const RESTController = _CoreManager.default.getRESTController();
|
|
1195
1202
|
const result = await RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
|
|
1196
|
-
const session = new _ParseSession.default();
|
|
1197
|
-
session._finishFetch(result);
|
|
1198
1203
|
user._finishFetch({
|
|
1199
|
-
sessionToken:
|
|
1204
|
+
sessionToken: (result === null || result === void 0 ? void 0 : result.sessionToken) || ''
|
|
1200
1205
|
});
|
|
1201
1206
|
const current = await user.isCurrentAsync();
|
|
1202
1207
|
if (current) {
|
package/lib/node/Push.js
CHANGED
|
@@ -12,11 +12,6 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
default: obj
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* @flow
|
|
17
|
-
*/
|
|
18
|
-
/*:: import type { WhereClause } from './ParseQuery';*/
|
|
19
|
-
/*:: import type { FullOptions } from './RESTController';*/
|
|
20
15
|
/*:: export type PushData = {
|
|
21
16
|
where?: WhereClause | ParseQuery,
|
|
22
17
|
push_time?: Date | string,
|
|
@@ -56,9 +51,9 @@ function _interopRequireDefault(obj) {
|
|
|
56
51
|
* be used for this request.
|
|
57
52
|
* </ul>
|
|
58
53
|
* @returns {Promise} A promise that is fulfilled when the push request
|
|
59
|
-
* completes
|
|
54
|
+
* completes and returns `pushStatusId`.
|
|
60
55
|
*/
|
|
61
|
-
function send(data /*: PushData*/, options
|
|
56
|
+
function send(data /*: PushData*/, options /*: FullOptions*/ = {}) /*: Promise<string>*/{
|
|
62
57
|
if (data.where && data.where instanceof _ParseQuery.default) {
|
|
63
58
|
data.where = data.where.toJSON().where;
|
|
64
59
|
}
|
|
@@ -93,7 +88,7 @@ function send(data /*: PushData*/, options /*:: ?: FullOptions*/ = {}) /*: Promi
|
|
|
93
88
|
* </ul>
|
|
94
89
|
* @returns {Parse.Object} Status of Push.
|
|
95
90
|
*/
|
|
96
|
-
function getPushStatus(pushStatusId /*: string*/, options
|
|
91
|
+
function getPushStatus(pushStatusId /*: string*/, options /*: FullOptions*/ = {}) /*: Promise<ParseObject>*/{
|
|
97
92
|
const pushOptions = {
|
|
98
93
|
useMasterKey: true
|
|
99
94
|
};
|
|
@@ -202,7 +202,7 @@ const RESTController = {
|
|
|
202
202
|
dispatch();
|
|
203
203
|
return promise;
|
|
204
204
|
},
|
|
205
|
-
request(method /*: string*/, path /*: string*/, data /*:
|
|
205
|
+
request(method /*: string*/, path /*: string*/, data /*: any*/, options /*:: ?: RequestOptions*/) {
|
|
206
206
|
options = options || {};
|
|
207
207
|
let url = _CoreManager.default.get('SERVER_URL');
|
|
208
208
|
if (url[url.length - 1] !== '/') {
|
|
@@ -145,7 +145,7 @@ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
|
|
|
145
145
|
}
|
|
146
146
|
return {};
|
|
147
147
|
}
|
|
148
|
-
function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*:
|
|
148
|
+
function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: any*/{
|
|
149
149
|
const serverData = getServerData(obj);
|
|
150
150
|
const pendingOps = getPendingOps(obj);
|
|
151
151
|
return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
|
package/lib/node/TaskQueue.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
var _promiseUtils = require("./promiseUtils");
|
|
4
|
-
/**
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
/*:: type Task = {
|
|
8
|
-
task: () => Promise,
|
|
9
|
-
_completion: Promise,
|
|
10
|
-
};*/
|
|
11
8
|
class TaskQueue {
|
|
12
|
-
/*:: queue: Array<Task>;*/
|
|
13
9
|
constructor() {
|
|
14
10
|
this.queue = [];
|
|
15
11
|
}
|
|
16
|
-
enqueue(task /*: () => Promise
|
|
17
|
-
const taskComplete =
|
|
12
|
+
enqueue(task /*: () => Promise<void>*/) /*: Promise<void>*/{
|
|
13
|
+
const taskComplete = (0, _promiseUtils.resolvingPromise)();
|
|
18
14
|
this.queue.push({
|
|
19
15
|
task: task,
|
|
20
16
|
_completion: taskComplete
|
|
@@ -44,4 +40,6 @@ class TaskQueue {
|
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
|
-
module.exports = TaskQueue;
|
|
43
|
+
module.exports = TaskQueue;
|
|
44
|
+
var _default = TaskQueue;
|
|
45
|
+
exports.default = _default;
|
|
@@ -144,7 +144,7 @@ function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
|
|
|
144
144
|
}
|
|
145
145
|
return {};
|
|
146
146
|
}
|
|
147
|
-
function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*:
|
|
147
|
+
function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: any*/{
|
|
148
148
|
const serverData = getServerData(obj);
|
|
149
149
|
const pendingOps = getPendingOps(obj);
|
|
150
150
|
return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
|
|
@@ -12,7 +12,6 @@ var _decode = _interopRequireDefault(require("./decode"));
|
|
|
12
12
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
13
13
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
14
14
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
15
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
16
15
|
function run(name, data, options) {
|
|
17
16
|
options = options || {};
|
|
18
17
|
if (typeof name !== 'string' || name.length === 0) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = void 0;
|
|
6
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
7
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
8
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
9
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
@@ -121,7 +122,8 @@ var LiveQueryClient = function () {
|
|
|
121
122
|
where: where,
|
|
122
123
|
keys: keys,
|
|
123
124
|
watch: watch
|
|
124
|
-
}
|
|
125
|
+
},
|
|
126
|
+
sessionToken: undefined
|
|
125
127
|
};
|
|
126
128
|
if (sessionToken) {
|
|
127
129
|
subscribeRequest.sessionToken = sessionToken;
|
|
@@ -138,21 +140,27 @@ var LiveQueryClient = function () {
|
|
|
138
140
|
}
|
|
139
141
|
}, {
|
|
140
142
|
key: "unsubscribe",
|
|
141
|
-
value: function (
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
value: function () {
|
|
144
|
+
var _unsubscribe = (0, _asyncToGenerator2.default)(function* (subscription) {
|
|
145
|
+
var _this3 = this;
|
|
146
|
+
if (!subscription) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
var unsubscribeRequest = {
|
|
150
|
+
op: OP_TYPES.UNSUBSCRIBE,
|
|
151
|
+
requestId: subscription.id
|
|
152
|
+
};
|
|
153
|
+
return this.connectPromise.then(function () {
|
|
154
|
+
return _this3.socket.send(JSON.stringify(unsubscribeRequest));
|
|
155
|
+
}).then(function () {
|
|
156
|
+
return subscription.unsubscribePromise;
|
|
157
|
+
});
|
|
154
158
|
});
|
|
155
|
-
|
|
159
|
+
function unsubscribe() {
|
|
160
|
+
return _unsubscribe.apply(this, arguments);
|
|
161
|
+
}
|
|
162
|
+
return unsubscribe;
|
|
163
|
+
}()
|
|
156
164
|
}, {
|
|
157
165
|
key: "open",
|
|
158
166
|
value: function () {
|
|
@@ -174,7 +182,8 @@ var LiveQueryClient = function () {
|
|
|
174
182
|
_this4._handleWebSocketMessage(event);
|
|
175
183
|
};
|
|
176
184
|
this.socket.onclose = function (event) {
|
|
177
|
-
_this4
|
|
185
|
+
var _this4$socket$closing;
|
|
186
|
+
(_this4$socket$closing = _this4.socket.closingPromise) == null ? void 0 : _this4$socket$closing.resolve(event);
|
|
178
187
|
_this4._handleWebSocketClose();
|
|
179
188
|
};
|
|
180
189
|
this.socket.onerror = function (error) {
|
|
@@ -199,7 +208,8 @@ var LiveQueryClient = function () {
|
|
|
199
208
|
className: className,
|
|
200
209
|
where: where,
|
|
201
210
|
fields: fields
|
|
202
|
-
}
|
|
211
|
+
},
|
|
212
|
+
sessionToken: undefined
|
|
203
213
|
};
|
|
204
214
|
if (sessionToken) {
|
|
205
215
|
subscribeRequest.sessionToken = sessionToken;
|
|
@@ -212,20 +222,26 @@ var LiveQueryClient = function () {
|
|
|
212
222
|
}, {
|
|
213
223
|
key: "close",
|
|
214
224
|
value: function () {
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
subscription.
|
|
223
|
-
|
|
225
|
+
var _close = (0, _asyncToGenerator2.default)(function* () {
|
|
226
|
+
var _this$socket, _this$socket2;
|
|
227
|
+
if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.state = CLIENT_STATE.DISCONNECTED;
|
|
231
|
+
(_this$socket = this.socket) == null ? void 0 : _this$socket.close();
|
|
232
|
+
for (var subscription of this.subscriptions.values()) {
|
|
233
|
+
subscription.subscribed = false;
|
|
234
|
+
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
|
|
235
|
+
}
|
|
236
|
+
this._handleReset();
|
|
237
|
+
this.emit(CLIENT_EMMITER_TYPES.CLOSE);
|
|
238
|
+
return (_this$socket2 = this.socket) == null ? void 0 : _this$socket2.closingPromise;
|
|
239
|
+
});
|
|
240
|
+
function close() {
|
|
241
|
+
return _close.apply(this, arguments);
|
|
224
242
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return (_this$socket2 = this.socket) == null ? void 0 : _this$socket2.closingPromise;
|
|
228
|
-
}
|
|
243
|
+
return close;
|
|
244
|
+
}()
|
|
229
245
|
}, {
|
|
230
246
|
key: "_handleReset",
|
|
231
247
|
value: function () {
|
|
@@ -244,7 +260,8 @@ var LiveQueryClient = function () {
|
|
|
244
260
|
applicationId: this.applicationId,
|
|
245
261
|
javascriptKey: this.javascriptKey,
|
|
246
262
|
masterKey: this.masterKey,
|
|
247
|
-
sessionToken: this.sessionToken
|
|
263
|
+
sessionToken: this.sessionToken,
|
|
264
|
+
installationId: undefined
|
|
248
265
|
};
|
|
249
266
|
if (this.additionalProperties) {
|
|
250
267
|
connectRequest.installationId = this.installationId;
|
|
@@ -260,7 +277,7 @@ var LiveQueryClient = function () {
|
|
|
260
277
|
}
|
|
261
278
|
var subscription = null;
|
|
262
279
|
if (data.requestId) {
|
|
263
|
-
subscription = this.subscriptions.get(data.requestId);
|
|
280
|
+
subscription = this.subscriptions.get(data.requestId) || null;
|
|
264
281
|
}
|
|
265
282
|
var response = {
|
|
266
283
|
clientId: data.clientId,
|
|
@@ -16,26 +16,50 @@ var LocalDatastore = {
|
|
|
16
16
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
17
17
|
return controller.fromPinWithName(name);
|
|
18
18
|
},
|
|
19
|
-
pinWithName: function (
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
pinWithName: function () {
|
|
20
|
+
var _pinWithName = (0, _asyncToGenerator2.default)(function* (name, value) {
|
|
21
|
+
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
22
|
+
return controller.pinWithName(name, value);
|
|
23
|
+
});
|
|
24
|
+
function pinWithName() {
|
|
25
|
+
return _pinWithName.apply(this, arguments);
|
|
26
|
+
}
|
|
27
|
+
return pinWithName;
|
|
28
|
+
}(),
|
|
29
|
+
unPinWithName: function () {
|
|
30
|
+
var _unPinWithName = (0, _asyncToGenerator2.default)(function* (name) {
|
|
31
|
+
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
32
|
+
return controller.unPinWithName(name);
|
|
33
|
+
});
|
|
34
|
+
function unPinWithName() {
|
|
35
|
+
return _unPinWithName.apply(this, arguments);
|
|
36
|
+
}
|
|
37
|
+
return unPinWithName;
|
|
38
|
+
}(),
|
|
27
39
|
_getAllContents: function () {
|
|
28
40
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
29
41
|
return controller.getAllContents();
|
|
30
42
|
},
|
|
31
43
|
_getRawStorage: function () {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
var _getRawStorage2 = (0, _asyncToGenerator2.default)(function* () {
|
|
45
|
+
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
46
|
+
return controller.getRawStorage();
|
|
47
|
+
});
|
|
48
|
+
function _getRawStorage() {
|
|
49
|
+
return _getRawStorage2.apply(this, arguments);
|
|
50
|
+
}
|
|
51
|
+
return _getRawStorage;
|
|
52
|
+
}(),
|
|
35
53
|
_clear: function () {
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
var _clear2 = (0, _asyncToGenerator2.default)(function* () {
|
|
55
|
+
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
56
|
+
return controller.clear();
|
|
57
|
+
});
|
|
58
|
+
function _clear() {
|
|
59
|
+
return _clear2.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
return _clear;
|
|
62
|
+
}(),
|
|
39
63
|
_handlePinAllWithName: function () {
|
|
40
64
|
var _handlePinAllWithName2 = (0, _asyncToGenerator2.default)(function* (name, objects) {
|
|
41
65
|
var pinName = this.getPinName(name);
|
|
@@ -1,4 +1,8 @@
|
|
|
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 _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
3
7
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
4
8
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
@@ -88,4 +92,6 @@ var LocalDatastoreController = {
|
|
|
88
92
|
return clear;
|
|
89
93
|
}()
|
|
90
94
|
};
|
|
91
|
-
module.exports = LocalDatastoreController;
|
|
95
|
+
module.exports = LocalDatastoreController;
|
|
96
|
+
var _default = LocalDatastoreController;
|
|
97
|
+
exports.default = _default;
|
|
@@ -1,4 +1,8 @@
|
|
|
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
3
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
4
8
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
@@ -108,4 +112,6 @@ var LocalDatastoreController = {
|
|
|
108
112
|
return clear;
|
|
109
113
|
}()
|
|
110
114
|
};
|
|
111
|
-
module.exports = LocalDatastoreController;
|
|
115
|
+
module.exports = LocalDatastoreController;
|
|
116
|
+
var _default = LocalDatastoreController;
|
|
117
|
+
exports.default = _default;
|