parse 4.1.0 → 4.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 +253 -58
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +253 -58
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/AnonymousUtils.js +1 -1
- package/lib/browser/Cloud.js +1 -2
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/EventuallyQueue.js +13 -1
- package/lib/browser/LiveQueryClient.js +8 -4
- package/lib/browser/LocalDatastore.js +3 -1
- package/lib/browser/LocalDatastoreController.js +3 -1
- package/lib/browser/ObjectStateMutations.js +14 -1
- package/lib/browser/ParseACL.js +2 -1
- package/lib/browser/ParseCLP.js +6 -1
- package/lib/browser/ParseConfig.js +1 -0
- package/lib/browser/ParseFile.js +5 -1
- package/lib/browser/ParseInstallation.js +4 -1
- package/lib/browser/ParseObject.js +10 -7
- package/lib/browser/ParseOp.js +3 -1
- package/lib/browser/ParseQuery.js +79 -24
- package/lib/browser/ParseRole.js +5 -1
- package/lib/browser/ParseSchema.js +1 -1
- package/lib/browser/ParseSession.js +5 -1
- package/lib/browser/ParseUser.js +42 -1
- package/lib/browser/Push.js +8 -2
- package/lib/browser/RESTController.js +20 -0
- package/lib/browser/SingleInstanceStateController.js +6 -1
- 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 +1 -2
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/EventuallyQueue.js +13 -1
- package/lib/node/LiveQueryClient.js +5 -2
- package/lib/node/LocalDatastore.js +1 -1
- package/lib/node/ObjectStateMutations.js +11 -1
- package/lib/node/ParseACL.js +2 -1
- package/lib/node/ParseCLP.js +3 -1
- package/lib/node/ParseConfig.js +1 -2
- package/lib/node/ParseFile.js +2 -1
- package/lib/node/ParseInstallation.js +1 -1
- package/lib/node/ParseObject.js +2 -1
- package/lib/node/ParseQuery.js +50 -1
- package/lib/node/ParseRole.js +2 -1
- package/lib/node/ParseSchema.js +1 -1
- package/lib/node/ParseSession.js +2 -1
- package/lib/node/ParseUser.js +37 -1
- package/lib/node/Push.js +8 -2
- package/lib/node/RESTController.js +20 -0
- package/lib/node/SingleInstanceStateController.js +6 -1
- 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/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +7 -3
- package/lib/react-native/ParseCLP.js +2 -2
- package/lib/react-native/ParseFile.js +1 -0
- package/lib/react-native/ParseQuery.js +34 -11
- package/lib/react-native/ParseUser.js +25 -0
- package/lib/weapp/AnonymousUtils.js +1 -1
- package/lib/weapp/Cloud.js +1 -2
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/EventuallyQueue.js +13 -1
- package/lib/weapp/LiveQueryClient.js +8 -4
- package/lib/weapp/LocalDatastore.js +3 -1
- package/lib/weapp/LocalDatastoreController.js +3 -1
- package/lib/weapp/ObjectStateMutations.js +14 -1
- package/lib/weapp/ParseACL.js +2 -1
- package/lib/weapp/ParseCLP.js +6 -1
- package/lib/weapp/ParseConfig.js +1 -0
- package/lib/weapp/ParseFile.js +5 -1
- package/lib/weapp/ParseInstallation.js +4 -1
- package/lib/weapp/ParseObject.js +10 -7
- package/lib/weapp/ParseOp.js +3 -1
- package/lib/weapp/ParseQuery.js +79 -24
- package/lib/weapp/ParseRole.js +5 -1
- package/lib/weapp/ParseSchema.js +1 -1
- package/lib/weapp/ParseSession.js +5 -1
- package/lib/weapp/ParseUser.js +42 -1
- package/lib/weapp/Push.js +8 -2
- package/lib/weapp/RESTController.js +20 -0
- package/lib/weapp/SingleInstanceStateController.js +6 -1
- package/lib/weapp/TaskQueue.js +4 -0
- package/lib/weapp/UniqueInstanceStateController.js +3 -1
- package/lib/weapp/unsavedChildren.js +4 -1
- package/package.json +18 -18
|
@@ -131,6 +131,7 @@ var ParseQuery = function () {
|
|
|
131
131
|
throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
|
|
132
132
|
}
|
|
133
133
|
this._where = {};
|
|
134
|
+
this._watch = [];
|
|
134
135
|
this._include = [];
|
|
135
136
|
this._exclude = [];
|
|
136
137
|
this._count = false;
|
|
@@ -262,6 +263,9 @@ var ParseQuery = function () {
|
|
|
262
263
|
var params = {
|
|
263
264
|
where: this._where
|
|
264
265
|
};
|
|
266
|
+
if (this._watch.length) {
|
|
267
|
+
params.watch = this._watch.join(',');
|
|
268
|
+
}
|
|
265
269
|
if (this._include.length) {
|
|
266
270
|
params.include = this._include.join(',');
|
|
267
271
|
}
|
|
@@ -309,6 +313,9 @@ var ParseQuery = function () {
|
|
|
309
313
|
if (json.where) {
|
|
310
314
|
this._where = json.where;
|
|
311
315
|
}
|
|
316
|
+
if (json.watch) {
|
|
317
|
+
this._watch = json.watch.split(',');
|
|
318
|
+
}
|
|
312
319
|
if (json.include) {
|
|
313
320
|
this._include = json.include.split(',');
|
|
314
321
|
}
|
|
@@ -1144,6 +1151,22 @@ var ParseQuery = function () {
|
|
|
1144
1151
|
});
|
|
1145
1152
|
return this;
|
|
1146
1153
|
}
|
|
1154
|
+
}, {
|
|
1155
|
+
key: "watch",
|
|
1156
|
+
value: function () {
|
|
1157
|
+
var _this14 = this;
|
|
1158
|
+
for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
|
|
1159
|
+
keys[_key12] = arguments[_key12];
|
|
1160
|
+
}
|
|
1161
|
+
keys.forEach(function (key) {
|
|
1162
|
+
if (Array.isArray(key)) {
|
|
1163
|
+
_this14._watch = _this14._watch.concat(key);
|
|
1164
|
+
} else {
|
|
1165
|
+
_this14._watch.push(key);
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
return this;
|
|
1169
|
+
}
|
|
1147
1170
|
}, {
|
|
1148
1171
|
key: "readPreference",
|
|
1149
1172
|
value: function (_readPreference, includeReadPreference, subqueryReadPreference) {
|
|
@@ -1204,7 +1227,7 @@ var ParseQuery = function () {
|
|
|
1204
1227
|
}, {
|
|
1205
1228
|
key: "cancel",
|
|
1206
1229
|
value: function () {
|
|
1207
|
-
var
|
|
1230
|
+
var _this15 = this;
|
|
1208
1231
|
if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
|
|
1209
1232
|
this._xhrRequest.task._aborted = true;
|
|
1210
1233
|
this._xhrRequest.task.abort();
|
|
@@ -1213,16 +1236,16 @@ var ParseQuery = function () {
|
|
|
1213
1236
|
return this;
|
|
1214
1237
|
}
|
|
1215
1238
|
return this._xhrRequest.onchange = function () {
|
|
1216
|
-
return
|
|
1239
|
+
return _this15.cancel();
|
|
1217
1240
|
};
|
|
1218
1241
|
}
|
|
1219
1242
|
}, {
|
|
1220
1243
|
key: "_setRequestTask",
|
|
1221
1244
|
value: function (options) {
|
|
1222
|
-
var
|
|
1245
|
+
var _this16 = this;
|
|
1223
1246
|
options.requestTask = function (task) {
|
|
1224
|
-
|
|
1225
|
-
|
|
1247
|
+
_this16._xhrRequest.task = task;
|
|
1248
|
+
_this16._xhrRequest.onchange();
|
|
1226
1249
|
};
|
|
1227
1250
|
}
|
|
1228
1251
|
}], [{
|
|
@@ -1234,8 +1257,8 @@ var ParseQuery = function () {
|
|
|
1234
1257
|
}, {
|
|
1235
1258
|
key: "or",
|
|
1236
1259
|
value: function () {
|
|
1237
|
-
for (var
|
|
1238
|
-
queries[
|
|
1260
|
+
for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
|
|
1261
|
+
queries[_key13] = arguments[_key13];
|
|
1239
1262
|
}
|
|
1240
1263
|
var className = _getClassNameFromQueries(queries);
|
|
1241
1264
|
var query = new ParseQuery(className);
|
|
@@ -1245,8 +1268,8 @@ var ParseQuery = function () {
|
|
|
1245
1268
|
}, {
|
|
1246
1269
|
key: "and",
|
|
1247
1270
|
value: function () {
|
|
1248
|
-
for (var
|
|
1249
|
-
queries[
|
|
1271
|
+
for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
|
|
1272
|
+
queries[_key14] = arguments[_key14];
|
|
1250
1273
|
}
|
|
1251
1274
|
var className = _getClassNameFromQueries(queries);
|
|
1252
1275
|
var query = new ParseQuery(className);
|
|
@@ -1256,8 +1279,8 @@ var ParseQuery = function () {
|
|
|
1256
1279
|
}, {
|
|
1257
1280
|
key: "nor",
|
|
1258
1281
|
value: function () {
|
|
1259
|
-
for (var
|
|
1260
|
-
queries[
|
|
1282
|
+
for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
|
|
1283
|
+
queries[_key15] = arguments[_key15];
|
|
1261
1284
|
}
|
|
1262
1285
|
var className = _getClassNameFromQueries(queries);
|
|
1263
1286
|
var query = new ParseQuery(className);
|
|
@@ -500,6 +500,16 @@ var ParseUser = function (_ParseObject) {
|
|
|
500
500
|
});
|
|
501
501
|
return user.logIn(options);
|
|
502
502
|
}
|
|
503
|
+
}, {
|
|
504
|
+
key: "loginAs",
|
|
505
|
+
value: function (userId) {
|
|
506
|
+
if (!userId) {
|
|
507
|
+
throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
|
|
508
|
+
}
|
|
509
|
+
var controller = _CoreManager.default.getUserController();
|
|
510
|
+
var user = new this();
|
|
511
|
+
return controller.loginAs(user, userId);
|
|
512
|
+
}
|
|
503
513
|
}, {
|
|
504
514
|
key: "become",
|
|
505
515
|
value: function (sessionToken, options) {
|
|
@@ -793,6 +803,21 @@ var DefaultController = {
|
|
|
793
803
|
return DefaultController.setCurrentUser(user);
|
|
794
804
|
});
|
|
795
805
|
},
|
|
806
|
+
loginAs: function (user, userId) {
|
|
807
|
+
var RESTController = _CoreManager.default.getRESTController();
|
|
808
|
+
return RESTController.request('POST', 'loginAs', {
|
|
809
|
+
userId: userId
|
|
810
|
+
}, {
|
|
811
|
+
useMasterKey: true
|
|
812
|
+
}).then(function (response) {
|
|
813
|
+
user._finishFetch(response);
|
|
814
|
+
user._setExisted(true);
|
|
815
|
+
if (!canUseCurrentUser) {
|
|
816
|
+
return Promise.resolve(user);
|
|
817
|
+
}
|
|
818
|
+
return DefaultController.setCurrentUser(user);
|
|
819
|
+
});
|
|
820
|
+
},
|
|
796
821
|
become: function (user, options) {
|
|
797
822
|
var RESTController = _CoreManager.default.getRESTController();
|
|
798
823
|
return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
|
package/lib/weapp/Cloud.js
CHANGED
|
@@ -21,7 +21,7 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
|
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 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
|
33
33
|
* @static
|
|
34
34
|
* @hideconstructor
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
36
|
/**
|
|
38
37
|
* Makes a call to a cloud function.
|
|
39
38
|
*
|
package/lib/weapp/CoreManager.js
CHANGED
|
@@ -182,7 +182,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
182
182
|
SERVER_AUTH_TOKEN: null,
|
|
183
183
|
LIVEQUERY_SERVER_URL: null,
|
|
184
184
|
ENCRYPTED_KEY: null,
|
|
185
|
-
VERSION: 'js' + "4.
|
|
185
|
+
VERSION: 'js' + "4.2.0-alpha.1",
|
|
186
186
|
APPLICATION_ID: null,
|
|
187
187
|
JAVASCRIPT_KEY: null,
|
|
188
188
|
MASTER_KEY: null,
|
|
@@ -18,7 +18,19 @@ var _Storage = _interopRequireDefault(require("./Storage"));
|
|
|
18
18
|
*
|
|
19
19
|
* @flow
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
/*:: import type { SaveOptions } from './ParseObject';*/
|
|
22
|
+
/*:: import type { RequestOptions } from './RESTController';*/
|
|
23
|
+
/*:: type QueueObject = {
|
|
24
|
+
queueId: string,
|
|
25
|
+
action: string,
|
|
26
|
+
object: ParseObject,
|
|
27
|
+
serverOptions: SaveOptions | RequestOptions,
|
|
28
|
+
id: string,
|
|
29
|
+
className: string,
|
|
30
|
+
hash: string,
|
|
31
|
+
createdAt: Date,
|
|
32
|
+
};*/
|
|
33
|
+
/*:: type Queue = Array<QueueObject>;*/
|
|
22
34
|
var QUEUE_KEY = 'Parse/Eventually/Queue';
|
|
23
35
|
var queueCache = [];
|
|
24
36
|
var dirtyCache = true;
|
|
@@ -123,7 +123,7 @@ function _isNativeReflectConstruct() {
|
|
|
123
123
|
} catch (e) {
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
|
-
}
|
|
126
|
+
} /* global WebSocket */
|
|
127
127
|
// The LiveQuery client inner state
|
|
128
128
|
var CLIENT_STATE = {
|
|
129
129
|
INITIALIZED: 'initialized',
|
|
@@ -303,21 +303,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
303
303
|
}, {
|
|
304
304
|
key: "subscribe",
|
|
305
305
|
value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
|
|
306
|
-
var
|
|
306
|
+
var _queryJSON$keys,
|
|
307
|
+
_queryJSON$watch,
|
|
308
|
+
_this2 = this;
|
|
307
309
|
if (!query) {
|
|
308
310
|
return;
|
|
309
311
|
}
|
|
310
312
|
var className = query.className;
|
|
311
313
|
var queryJSON = query.toJSON();
|
|
312
314
|
var where = queryJSON.where;
|
|
313
|
-
var fields = (0, _keys.default)(queryJSON) ?
|
|
315
|
+
var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
|
|
316
|
+
var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
|
|
314
317
|
var subscribeRequest = {
|
|
315
318
|
op: OP_TYPES.SUBSCRIBE,
|
|
316
319
|
requestId: this.requestId,
|
|
317
320
|
query: {
|
|
318
321
|
className: className,
|
|
319
322
|
where: where,
|
|
320
|
-
fields: fields
|
|
323
|
+
fields: fields,
|
|
324
|
+
watch: watch
|
|
321
325
|
}
|
|
322
326
|
};
|
|
323
327
|
if (sessionToken) {
|
|
@@ -89,7 +89,9 @@ function _arrayLikeToArray(arr, len) {
|
|
|
89
89
|
if (len == null || len > arr.length) len = arr.length;
|
|
90
90
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
91
91
|
return arr2;
|
|
92
|
-
}
|
|
92
|
+
} /**
|
|
93
|
+
* @flow
|
|
94
|
+
*/ /*:: import type ParseObject from './ParseObject';*/
|
|
93
95
|
/**
|
|
94
96
|
* Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
|
|
95
97
|
* To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
|
|
@@ -78,7 +78,9 @@ function _arrayLikeToArray(arr, len) {
|
|
|
78
78
|
if (len == null || len > arr.length) len = arr.length;
|
|
79
79
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
80
80
|
return arr2;
|
|
81
|
-
}
|
|
81
|
+
} /**
|
|
82
|
+
* @flow
|
|
83
|
+
*/
|
|
82
84
|
var LocalDatastoreController = {
|
|
83
85
|
fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
|
|
84
86
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
@@ -52,7 +52,20 @@ function _objectSpread(target) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
return target;
|
|
55
|
-
}
|
|
55
|
+
} /**
|
|
56
|
+
* @flow
|
|
57
|
+
*/
|
|
58
|
+
/*:: import type { Op } from './ParseOp';*/
|
|
59
|
+
/*:: export type AttributeMap = { [attr: string]: any };*/
|
|
60
|
+
/*:: export type OpsMap = { [attr: string]: Op };*/
|
|
61
|
+
/*:: export type ObjectCache = { [attr: string]: string };*/
|
|
62
|
+
/*:: export type State = {
|
|
63
|
+
serverData: AttributeMap,
|
|
64
|
+
pendingOps: Array<OpsMap>,
|
|
65
|
+
objectCache: ObjectCache,
|
|
66
|
+
tasks: TaskQueue,
|
|
67
|
+
existed: boolean,
|
|
68
|
+
};*/
|
|
56
69
|
function defaultState() /*: State*/{
|
|
57
70
|
return {
|
|
58
71
|
serverData: {},
|
package/lib/weapp/ParseACL.js
CHANGED
package/lib/weapp/ParseCLP.js
CHANGED
|
@@ -119,7 +119,12 @@ function _arrayLikeToArray(arr, len) {
|
|
|
119
119
|
if (len == null || len > arr.length) len = arr.length;
|
|
120
120
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
121
121
|
return arr2;
|
|
122
|
-
}
|
|
122
|
+
} /**
|
|
123
|
+
* @flow
|
|
124
|
+
*/
|
|
125
|
+
/*:: type Entity = Entity;*/
|
|
126
|
+
/*:: type UsersMap = { [userId: string]: boolean | any };*/
|
|
127
|
+
/*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
|
|
123
128
|
var PUBLIC_KEY = '*';
|
|
124
129
|
var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
|
|
125
130
|
/*:: <string, UsersMap>*/
|
package/lib/weapp/ParseConfig.js
CHANGED
|
@@ -21,6 +21,7 @@ var _Storage = _interopRequireDefault(require("./Storage"));
|
|
|
21
21
|
/**
|
|
22
22
|
* @flow
|
|
23
23
|
*/
|
|
24
|
+
/*:: import type { RequestOptions } from './RESTController';*/
|
|
24
25
|
/**
|
|
25
26
|
* Parse.Config is a local representation of configuration data that
|
|
26
27
|
* can be set from the Parse dashboard.
|
package/lib/weapp/ParseFile.js
CHANGED
|
@@ -48,7 +48,10 @@ function _objectSpread(target) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
return target;
|
|
51
|
-
}
|
|
51
|
+
} /**
|
|
52
|
+
* @flow
|
|
53
|
+
*/ /* global XMLHttpRequest, Blob */
|
|
54
|
+
/*:: import type { FullOptions } from './RESTController';*/
|
|
52
55
|
var ParseError = require('./ParseError').default;
|
|
53
56
|
var XHR = null;
|
|
54
57
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
@@ -371,6 +374,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
371
374
|
key: "cancel",
|
|
372
375
|
value: function () {
|
|
373
376
|
if (this._requestTask && typeof this._requestTask.abort === 'function') {
|
|
377
|
+
this._requestTask._aborted = true;
|
|
374
378
|
this._requestTask.abort();
|
|
375
379
|
}
|
|
376
380
|
this._requestTask = null;
|
|
@@ -38,7 +38,10 @@ function _isNativeReflectConstruct() {
|
|
|
38
38
|
} catch (e) {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
} /**
|
|
42
|
+
* @flow
|
|
43
|
+
*/
|
|
44
|
+
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
42
45
|
var Installation = /*#__PURE__*/function (_ParseObject) {
|
|
43
46
|
(0, _inherits2.default)(Installation, _ParseObject);
|
|
44
47
|
var _super = _createSuper(Installation);
|
package/lib/weapp/ParseObject.js
CHANGED
|
@@ -184,7 +184,11 @@ function _objectSpread(target) {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
return target;
|
|
187
|
-
}
|
|
187
|
+
} /**
|
|
188
|
+
* @flow
|
|
189
|
+
*/
|
|
190
|
+
/*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
|
|
191
|
+
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
188
192
|
var uuidv4 = require('./uuid');
|
|
189
193
|
/*:: export type Pointer = {
|
|
190
194
|
__type: string,
|
|
@@ -250,6 +254,11 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
250
254
|
*/
|
|
251
255
|
function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
|
|
252
256
|
(0, _classCallCheck2.default)(this, ParseObject);
|
|
257
|
+
/**
|
|
258
|
+
* The ID of this object, unique within its class.
|
|
259
|
+
*
|
|
260
|
+
* @property {string} id
|
|
261
|
+
*/
|
|
253
262
|
(0, _defineProperty2.default)(this, "id", void 0);
|
|
254
263
|
(0, _defineProperty2.default)(this, "_localId", void 0);
|
|
255
264
|
(0, _defineProperty2.default)(this, "_objCount", void 0);
|
|
@@ -281,12 +290,6 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
281
290
|
throw new Error("Can't create an invalid Parse Object");
|
|
282
291
|
}
|
|
283
292
|
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* The ID of this object, unique within its class.
|
|
287
|
-
*
|
|
288
|
-
* @property {string} id
|
|
289
|
-
*/
|
|
290
293
|
(0, _createClass2.default)(ParseObject, [{
|
|
291
294
|
key: "attributes",
|
|
292
295
|
get: /* Prototype getters / setters */
|
package/lib/weapp/ParseOp.js
CHANGED
package/lib/weapp/ParseQuery.js
CHANGED
|
@@ -40,7 +40,29 @@ var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
|
40
40
|
/*
|
|
41
41
|
* @flow
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
/*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
|
|
44
|
+
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
45
|
+
/*:: type BatchOptions = FullOptions & { batchSize?: number };*/
|
|
46
|
+
/*:: export type WhereClause = {
|
|
47
|
+
[attr: string]: mixed,
|
|
48
|
+
};*/
|
|
49
|
+
/*:: export type QueryJSON = {
|
|
50
|
+
where: WhereClause,
|
|
51
|
+
watch?: string,
|
|
52
|
+
include?: string,
|
|
53
|
+
excludeKeys?: string,
|
|
54
|
+
keys?: string,
|
|
55
|
+
limit?: number,
|
|
56
|
+
skip?: number,
|
|
57
|
+
order?: string,
|
|
58
|
+
className?: string,
|
|
59
|
+
count?: number,
|
|
60
|
+
hint?: mixed,
|
|
61
|
+
explain?: boolean,
|
|
62
|
+
readPreference?: string,
|
|
63
|
+
includeReadPreference?: string,
|
|
64
|
+
subqueryReadPreference?: string,
|
|
65
|
+
};*/
|
|
44
66
|
/**
|
|
45
67
|
* Converts a string into a regex that matches it.
|
|
46
68
|
* Surrounding with \Q .. \E does this, we just need to escape any \E's in
|
|
@@ -215,17 +237,17 @@ function handleOfflineSort(a, b, sorts) {
|
|
|
215
237
|
* @alias Parse.Query
|
|
216
238
|
*/
|
|
217
239
|
var ParseQuery = /*#__PURE__*/function () {
|
|
218
|
-
/**
|
|
219
|
-
* @property {string} className
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
240
|
/**
|
|
223
241
|
* @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
|
|
224
242
|
*/
|
|
225
243
|
function ParseQuery(objectClass /*: string | ParseObject*/) {
|
|
226
244
|
(0, _classCallCheck2.default)(this, ParseQuery);
|
|
245
|
+
/**
|
|
246
|
+
* @property {string} className
|
|
247
|
+
*/
|
|
227
248
|
(0, _defineProperty2.default)(this, "className", void 0);
|
|
228
249
|
(0, _defineProperty2.default)(this, "_where", void 0);
|
|
250
|
+
(0, _defineProperty2.default)(this, "_watch", void 0);
|
|
229
251
|
(0, _defineProperty2.default)(this, "_include", void 0);
|
|
230
252
|
(0, _defineProperty2.default)(this, "_exclude", void 0);
|
|
231
253
|
(0, _defineProperty2.default)(this, "_select", void 0);
|
|
@@ -261,6 +283,7 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
261
283
|
throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
|
|
262
284
|
}
|
|
263
285
|
this._where = {};
|
|
286
|
+
this._watch = [];
|
|
264
287
|
this._include = [];
|
|
265
288
|
this._exclude = [];
|
|
266
289
|
this._count = false;
|
|
@@ -453,6 +476,9 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
453
476
|
var params /*: QueryJSON*/ = {
|
|
454
477
|
where: this._where
|
|
455
478
|
};
|
|
479
|
+
if (this._watch.length) {
|
|
480
|
+
params.watch = this._watch.join(',');
|
|
481
|
+
}
|
|
456
482
|
if (this._include.length) {
|
|
457
483
|
params.include = this._include.join(',');
|
|
458
484
|
}
|
|
@@ -522,6 +548,9 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
522
548
|
if (json.where) {
|
|
523
549
|
this._where = json.where;
|
|
524
550
|
}
|
|
551
|
+
if (json.watch) {
|
|
552
|
+
this._watch = json.watch.split(',');
|
|
553
|
+
}
|
|
525
554
|
if (json.include) {
|
|
526
555
|
this._include = json.include.split(',');
|
|
527
556
|
}
|
|
@@ -2111,6 +2140,32 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2111
2140
|
return this;
|
|
2112
2141
|
}
|
|
2113
2142
|
|
|
2143
|
+
/**
|
|
2144
|
+
* Restricts live query to trigger only for watched fields.
|
|
2145
|
+
*
|
|
2146
|
+
* Requires Parse Server 6.0.0+
|
|
2147
|
+
*
|
|
2148
|
+
* @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
|
|
2149
|
+
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
2150
|
+
*/
|
|
2151
|
+
}, {
|
|
2152
|
+
key: "watch",
|
|
2153
|
+
value: function () /*: ParseQuery*/{
|
|
2154
|
+
var _this14 = this;
|
|
2155
|
+
for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
|
|
2156
|
+
keys[_key12] = arguments[_key12];
|
|
2157
|
+
}
|
|
2158
|
+
(0, _forEach.default)(keys).call(keys, function (key) {
|
|
2159
|
+
if ((0, _isArray.default)(key)) {
|
|
2160
|
+
var _context22;
|
|
2161
|
+
_this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
|
|
2162
|
+
} else {
|
|
2163
|
+
_this14._watch.push(key);
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
return this;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2114
2169
|
/**
|
|
2115
2170
|
* Changes the read preference that the backend will use when performing the query to the database.
|
|
2116
2171
|
*
|
|
@@ -2140,30 +2195,30 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2140
2195
|
value: function () {
|
|
2141
2196
|
var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
|
|
2142
2197
|
var currentUser, liveQueryClient, subscription;
|
|
2143
|
-
return _regenerator.default.wrap(function (
|
|
2144
|
-
while (1) switch (
|
|
2198
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
2199
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2145
2200
|
case 0:
|
|
2146
|
-
|
|
2201
|
+
_context23.next = 2;
|
|
2147
2202
|
return _CoreManager.default.getUserController().currentUserAsync();
|
|
2148
2203
|
case 2:
|
|
2149
|
-
currentUser =
|
|
2204
|
+
currentUser = _context23.sent;
|
|
2150
2205
|
if (!sessionToken) {
|
|
2151
2206
|
sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
|
|
2152
2207
|
}
|
|
2153
|
-
|
|
2208
|
+
_context23.next = 6;
|
|
2154
2209
|
return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
2155
2210
|
case 6:
|
|
2156
|
-
liveQueryClient =
|
|
2211
|
+
liveQueryClient = _context23.sent;
|
|
2157
2212
|
if (liveQueryClient.shouldOpen()) {
|
|
2158
2213
|
liveQueryClient.open();
|
|
2159
2214
|
}
|
|
2160
2215
|
subscription = liveQueryClient.subscribe(this, sessionToken);
|
|
2161
|
-
return
|
|
2216
|
+
return _context23.abrupt("return", subscription.subscribePromise.then(function () {
|
|
2162
2217
|
return subscription;
|
|
2163
2218
|
}));
|
|
2164
2219
|
case 10:
|
|
2165
2220
|
case "end":
|
|
2166
|
-
return
|
|
2221
|
+
return _context23.stop();
|
|
2167
2222
|
}
|
|
2168
2223
|
}, _callee7, this);
|
|
2169
2224
|
}));
|
|
@@ -2245,7 +2300,7 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2245
2300
|
}, {
|
|
2246
2301
|
key: "cancel",
|
|
2247
2302
|
value: function () /*: ParseQuery*/{
|
|
2248
|
-
var
|
|
2303
|
+
var _this15 = this;
|
|
2249
2304
|
if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
|
|
2250
2305
|
this._xhrRequest.task._aborted = true;
|
|
2251
2306
|
this._xhrRequest.task.abort();
|
|
@@ -2254,16 +2309,16 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2254
2309
|
return this;
|
|
2255
2310
|
}
|
|
2256
2311
|
return this._xhrRequest.onchange = function () {
|
|
2257
|
-
return
|
|
2312
|
+
return _this15.cancel();
|
|
2258
2313
|
};
|
|
2259
2314
|
}
|
|
2260
2315
|
}, {
|
|
2261
2316
|
key: "_setRequestTask",
|
|
2262
2317
|
value: function (options) {
|
|
2263
|
-
var
|
|
2318
|
+
var _this16 = this;
|
|
2264
2319
|
options.requestTask = function (task) {
|
|
2265
|
-
|
|
2266
|
-
|
|
2320
|
+
_this16._xhrRequest.task = task;
|
|
2321
|
+
_this16._xhrRequest.onchange();
|
|
2267
2322
|
};
|
|
2268
2323
|
}
|
|
2269
2324
|
}], [{
|
|
@@ -2275,8 +2330,8 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2275
2330
|
}, {
|
|
2276
2331
|
key: "or",
|
|
2277
2332
|
value: function () /*: ParseQuery*/{
|
|
2278
|
-
for (var
|
|
2279
|
-
queries[
|
|
2333
|
+
for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
|
|
2334
|
+
queries[_key13] = arguments[_key13];
|
|
2280
2335
|
}
|
|
2281
2336
|
var className = _getClassNameFromQueries(queries);
|
|
2282
2337
|
var query = new ParseQuery(className);
|
|
@@ -2299,8 +2354,8 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2299
2354
|
}, {
|
|
2300
2355
|
key: "and",
|
|
2301
2356
|
value: function () /*: ParseQuery*/{
|
|
2302
|
-
for (var
|
|
2303
|
-
queries[
|
|
2357
|
+
for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
|
|
2358
|
+
queries[_key14] = arguments[_key14];
|
|
2304
2359
|
}
|
|
2305
2360
|
var className = _getClassNameFromQueries(queries);
|
|
2306
2361
|
var query = new ParseQuery(className);
|
|
@@ -2323,8 +2378,8 @@ var ParseQuery = /*#__PURE__*/function () {
|
|
|
2323
2378
|
}, {
|
|
2324
2379
|
key: "nor",
|
|
2325
2380
|
value: function () /*: ParseQuery*/{
|
|
2326
|
-
for (var
|
|
2327
|
-
queries[
|
|
2381
|
+
for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
|
|
2382
|
+
queries[_key15] = arguments[_key15];
|
|
2328
2383
|
}
|
|
2329
2384
|
var className = _getClassNameFromQueries(queries);
|
|
2330
2385
|
var query = new ParseQuery(className);
|
package/lib/weapp/ParseRole.js
CHANGED
|
@@ -40,7 +40,11 @@ function _isNativeReflectConstruct() {
|
|
|
40
40
|
} catch (e) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
} /**
|
|
44
|
+
* @flow
|
|
45
|
+
*/
|
|
46
|
+
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
47
|
+
/*:: import type ParseRelation from './ParseRelation';*/
|
|
44
48
|
/**
|
|
45
49
|
* Represents a Role on the Parse server. Roles represent groupings of
|
|
46
50
|
* Users for the purposes of granting permissions (e.g. specifying an ACL
|
package/lib/weapp/ParseSchema.js
CHANGED
|
@@ -16,7 +16,7 @@ var _ParseCLP = _interopRequireDefault(require("./ParseCLP"));
|
|
|
16
16
|
/**
|
|
17
17
|
* @flow
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
/*:: import type { PermissionsMap } from './ParseCLP';*/
|
|
20
20
|
var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
21
21
|
/*:: type FieldOptions = {
|
|
22
22
|
required: boolean,
|
|
@@ -42,7 +42,11 @@ function _isNativeReflectConstruct() {
|
|
|
42
42
|
} catch (e) {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
} /**
|
|
46
|
+
* @flow
|
|
47
|
+
*/
|
|
48
|
+
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
49
|
+
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
46
50
|
/**
|
|
47
51
|
* <p>A Parse.Session object is a local representation of a revocable session.
|
|
48
52
|
* This class is a subclass of a Parse.Object, and retains the same
|