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/ParseQuery.js
CHANGED
|
@@ -17,14 +17,8 @@ function _interopRequireDefault(obj) {
|
|
|
17
17
|
default: obj
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
/*
|
|
21
|
-
* @flow
|
|
22
|
-
*/
|
|
23
|
-
/*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
|
|
24
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
25
|
-
/*:: type BatchOptions = FullOptions & { batchSize?: number };*/
|
|
26
20
|
/*:: export type WhereClause = {
|
|
27
|
-
[attr: string]:
|
|
21
|
+
[attr: string]: any,
|
|
28
22
|
};*/
|
|
29
23
|
/*:: export type QueryJSON = {
|
|
30
24
|
where: WhereClause,
|
|
@@ -37,7 +31,7 @@ function _interopRequireDefault(obj) {
|
|
|
37
31
|
order?: string,
|
|
38
32
|
className?: string,
|
|
39
33
|
count?: number,
|
|
40
|
-
hint?:
|
|
34
|
+
hint?: any,
|
|
41
35
|
explain?: boolean,
|
|
42
36
|
readPreference?: string,
|
|
43
37
|
includeReadPreference?: string,
|
|
@@ -65,8 +59,8 @@ function quote(s /*: string*/) /*: string*/{
|
|
|
65
59
|
* @private
|
|
66
60
|
* @returns {string}
|
|
67
61
|
*/
|
|
68
|
-
function _getClassNameFromQueries(queries /*: Array<ParseQuery>*/) /*:
|
|
69
|
-
let className = null;
|
|
62
|
+
function _getClassNameFromQueries(queries /*: Array<ParseQuery>*/) /*: string | null*/{
|
|
63
|
+
let className /*: string | null*/ = null;
|
|
70
64
|
queries.forEach(q => {
|
|
71
65
|
if (!className) {
|
|
72
66
|
className = q.className;
|
|
@@ -221,26 +215,7 @@ class ParseQuery {
|
|
|
221
215
|
/**
|
|
222
216
|
* @property {string} className
|
|
223
217
|
*/
|
|
224
|
-
|
|
225
|
-
/*:: _where: any;*/
|
|
226
|
-
/*:: _watch: Array<string>;*/
|
|
227
|
-
/*:: _include: Array<string>;*/
|
|
228
|
-
/*:: _exclude: Array<string>;*/
|
|
229
|
-
/*:: _select: Array<string>;*/
|
|
230
|
-
/*:: _limit: number;*/
|
|
231
|
-
/*:: _skip: number;*/
|
|
232
|
-
/*:: _count: boolean;*/
|
|
233
|
-
/*:: _order: Array<string>;*/
|
|
234
|
-
/*:: _readPreference: string;*/
|
|
235
|
-
/*:: _includeReadPreference: string;*/
|
|
236
|
-
/*:: _subqueryReadPreference: string;*/
|
|
237
|
-
/*:: _queriesLocalDatastore: boolean;*/
|
|
238
|
-
/*:: _localDatastorePinName: any;*/
|
|
239
|
-
/*:: _extraOptions: { [key: string]: mixed };*/
|
|
240
|
-
/*:: _hint: mixed;*/
|
|
241
|
-
/*:: _explain: boolean;*/
|
|
242
|
-
/*:: _xhrRequest: any;*/
|
|
243
|
-
/*:: _comment: string;*/
|
|
218
|
+
|
|
244
219
|
/**
|
|
245
220
|
* @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
|
|
246
221
|
*/
|
|
@@ -254,10 +229,11 @@ class ParseQuery {
|
|
|
254
229
|
} else if (objectClass instanceof _ParseObject.default) {
|
|
255
230
|
this.className = objectClass.className;
|
|
256
231
|
} else if (typeof objectClass === 'function') {
|
|
257
|
-
|
|
258
|
-
|
|
232
|
+
const objClass = objectClass;
|
|
233
|
+
if (typeof objClass.className === 'string') {
|
|
234
|
+
this.className = objClass.className;
|
|
259
235
|
} else {
|
|
260
|
-
const obj = new
|
|
236
|
+
const obj = new objClass();
|
|
261
237
|
this.className = obj.className;
|
|
262
238
|
}
|
|
263
239
|
} else {
|
|
@@ -333,7 +309,7 @@ class ParseQuery {
|
|
|
333
309
|
* @param value
|
|
334
310
|
* @returns {Parse.Query}
|
|
335
311
|
*/
|
|
336
|
-
_addCondition(key /*: string*/, condition /*: string*/, value /*:
|
|
312
|
+
_addCondition(key /*: string*/, condition /*: string*/, value /*: any*/) /*: ParseQuery*/{
|
|
337
313
|
if (!this._where[key] || typeof this._where[key] === 'string') {
|
|
338
314
|
this._where[key] = {};
|
|
339
315
|
}
|
|
@@ -350,7 +326,7 @@ class ParseQuery {
|
|
|
350
326
|
_regexStartWith(string /*: string*/) /*: string*/{
|
|
351
327
|
return '^' + quote(string);
|
|
352
328
|
}
|
|
353
|
-
async _handleOfflineQuery(params /*:
|
|
329
|
+
async _handleOfflineQuery(params /*: QueryJSON*/) {
|
|
354
330
|
_OfflineQuery.default.validateQuery(this);
|
|
355
331
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
356
332
|
const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
|
|
@@ -573,9 +549,9 @@ class ParseQuery {
|
|
|
573
549
|
* @returns {Promise} A promise that is resolved with the result when
|
|
574
550
|
* the query completes.
|
|
575
551
|
*/
|
|
576
|
-
get(objectId /*: string*/, options /*:: ?:
|
|
552
|
+
get(objectId /*: string*/, options /*:: ?: QueryOptions*/) /*: Promise<ParseObject>*/{
|
|
577
553
|
this.equalTo('objectId', objectId);
|
|
578
|
-
const firstOptions = {};
|
|
554
|
+
const firstOptions /*: QueryOptions*/ = {};
|
|
579
555
|
if (options && options.hasOwnProperty('useMasterKey')) {
|
|
580
556
|
firstOptions.useMasterKey = options.useMasterKey;
|
|
581
557
|
}
|
|
@@ -612,9 +588,9 @@ class ParseQuery {
|
|
|
612
588
|
* @returns {Promise} A promise that is resolved with the results when
|
|
613
589
|
* the query completes.
|
|
614
590
|
*/
|
|
615
|
-
find(options /*:: ?:
|
|
591
|
+
find(options /*:: ?: QueryOptions*/) /*: Promise<Array<ParseObject>>*/{
|
|
616
592
|
options = options || {};
|
|
617
|
-
const findOptions = {};
|
|
593
|
+
const findOptions /*: QueryOptions*/ = {};
|
|
618
594
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
619
595
|
findOptions.useMasterKey = options.useMasterKey;
|
|
620
596
|
}
|
|
@@ -631,11 +607,12 @@ class ParseQuery {
|
|
|
631
607
|
return this._handleOfflineQuery(this.toJSON());
|
|
632
608
|
}
|
|
633
609
|
return controller.find(this.className, this.toJSON(), findOptions).then(response => {
|
|
610
|
+
var _response$results;
|
|
634
611
|
// Return generic object when explain is used
|
|
635
612
|
if (this._explain) {
|
|
636
613
|
return response.results;
|
|
637
614
|
}
|
|
638
|
-
const results = response.results.map(data => {
|
|
615
|
+
const results = (_response$results = response.results) === null || _response$results === void 0 ? void 0 : _response$results.map(data => {
|
|
639
616
|
// In cases of relations, the server may send back a className
|
|
640
617
|
// on the top level of the payload
|
|
641
618
|
const override = response.className || this.className;
|
|
@@ -693,6 +670,8 @@ class ParseQuery {
|
|
|
693
670
|
* Counts the number of objects that match this query.
|
|
694
671
|
*
|
|
695
672
|
* @param {object} options
|
|
673
|
+
* @param {boolean} [options.useMasterKey]
|
|
674
|
+
* @param {string} [options.sessionToken]
|
|
696
675
|
* Valid options are:<ul>
|
|
697
676
|
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
698
677
|
* be used for this request.
|
|
@@ -702,9 +681,9 @@ class ParseQuery {
|
|
|
702
681
|
* @returns {Promise} A promise that is resolved with the count when
|
|
703
682
|
* the query completes.
|
|
704
683
|
*/
|
|
705
|
-
count(options /*:: ?:
|
|
684
|
+
count(options /*:: ?: { useMasterKey?: boolean, sessionToken?: string }*/) /*: Promise<number>*/{
|
|
706
685
|
options = options || {};
|
|
707
|
-
const findOptions = {};
|
|
686
|
+
const findOptions /*: { useMasterKey?: boolean, sessionToken?: string }*/ = {};
|
|
708
687
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
709
688
|
findOptions.useMasterKey = options.useMasterKey;
|
|
710
689
|
}
|
|
@@ -726,16 +705,14 @@ class ParseQuery {
|
|
|
726
705
|
*
|
|
727
706
|
* @param {string} key A field to find distinct values
|
|
728
707
|
* @param {object} options
|
|
729
|
-
*
|
|
730
|
-
* <li>sessionToken: A valid session token, used for making a request on
|
|
731
|
-
* behalf of a specific user.
|
|
732
|
-
* </ul>
|
|
708
|
+
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
|
|
733
709
|
* @returns {Promise} A promise that is resolved with the query completes.
|
|
734
710
|
*/
|
|
735
|
-
distinct(key /*: string*/, options /*:: ?:
|
|
711
|
+
distinct(key /*: string*/, options /*:: ?: { sessionToken?: string }*/) /*: Promise<Array<any>>*/{
|
|
736
712
|
options = options || {};
|
|
737
|
-
const distinctOptions = {
|
|
738
|
-
|
|
713
|
+
const distinctOptions /*: { sessionToken?: string, useMasterKey: boolean }*/ = {
|
|
714
|
+
useMasterKey: true
|
|
715
|
+
};
|
|
739
716
|
if (options.hasOwnProperty('sessionToken')) {
|
|
740
717
|
distinctOptions.sessionToken = options.sessionToken;
|
|
741
718
|
}
|
|
@@ -755,16 +732,15 @@ class ParseQuery {
|
|
|
755
732
|
* Executes an aggregate query and returns aggregate results
|
|
756
733
|
*
|
|
757
734
|
* @param {(Array|object)} pipeline Array or Object of stages to process query
|
|
758
|
-
* @param {object} options
|
|
759
|
-
*
|
|
760
|
-
* behalf of a specific user.
|
|
761
|
-
* </ul>
|
|
735
|
+
* @param {object} options
|
|
736
|
+
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
|
|
762
737
|
* @returns {Promise} A promise that is resolved with the query completes.
|
|
763
738
|
*/
|
|
764
|
-
aggregate(pipeline /*:
|
|
739
|
+
aggregate(pipeline /*: any*/, options /*:: ?: { sessionToken?: string }*/) /*: Promise<Array<any>>*/{
|
|
765
740
|
options = options || {};
|
|
766
|
-
const aggregateOptions = {
|
|
767
|
-
|
|
741
|
+
const aggregateOptions /*: { sessionToken?: string, useMasterKey: boolean }*/ = {
|
|
742
|
+
useMasterKey: true
|
|
743
|
+
};
|
|
768
744
|
if (options.hasOwnProperty('sessionToken')) {
|
|
769
745
|
aggregateOptions.sessionToken = options.sessionToken;
|
|
770
746
|
}
|
|
@@ -808,9 +784,8 @@ class ParseQuery {
|
|
|
808
784
|
* @returns {Promise} A promise that is resolved with the object when
|
|
809
785
|
* the query completes.
|
|
810
786
|
*/
|
|
811
|
-
first(options
|
|
812
|
-
|
|
813
|
-
const findOptions = {};
|
|
787
|
+
first(options /*: QueryOptions*/ = {}) /*: Promise<ParseObject | void>*/{
|
|
788
|
+
const findOptions /*: QueryOptions*/ = {};
|
|
814
789
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
815
790
|
findOptions.useMasterKey = options.useMasterKey;
|
|
816
791
|
}
|
|
@@ -877,7 +852,7 @@ class ParseQuery {
|
|
|
877
852
|
* @returns {Promise} A promise that will be fulfilled once the
|
|
878
853
|
* iteration has completed.
|
|
879
854
|
*/
|
|
880
|
-
eachBatch(callback /*: (objs: Array<ParseObject>) =>
|
|
855
|
+
eachBatch(callback /*: (objs: Array<ParseObject>) => void*/, options /*:: ?: BatchOptions*/) /*: Promise<void>*/{
|
|
881
856
|
options = options || {};
|
|
882
857
|
if (this._order || this._skip || this._limit >= 0) {
|
|
883
858
|
return Promise.reject('Cannot iterate on a query with sort, skip, or limit.');
|
|
@@ -908,7 +883,7 @@ class ParseQuery {
|
|
|
908
883
|
}
|
|
909
884
|
}
|
|
910
885
|
query.ascending('objectId');
|
|
911
|
-
const findOptions = {};
|
|
886
|
+
const findOptions /*: BatchOptions*/ = {};
|
|
912
887
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
913
888
|
findOptions.useMasterKey = options.useMasterKey;
|
|
914
889
|
}
|
|
@@ -922,7 +897,7 @@ class ParseQuery {
|
|
|
922
897
|
findOptions.json = options.json;
|
|
923
898
|
}
|
|
924
899
|
let finished = false;
|
|
925
|
-
let previousResults = [];
|
|
900
|
+
let previousResults /*: ParseObject[]*/ = [];
|
|
926
901
|
return (0, _promiseUtils.continueWhile)(() => {
|
|
927
902
|
return !finished;
|
|
928
903
|
}, async () => {
|
|
@@ -977,7 +952,7 @@ class ParseQuery {
|
|
|
977
952
|
* @param {(string|object)} value String or Object of index that should be used when executing query
|
|
978
953
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
979
954
|
*/
|
|
980
|
-
hint(value /*:
|
|
955
|
+
hint(value /*: any*/) /*: ParseQuery*/{
|
|
981
956
|
if (typeof value === 'undefined') {
|
|
982
957
|
delete this._hint;
|
|
983
958
|
}
|
|
@@ -991,7 +966,7 @@ class ParseQuery {
|
|
|
991
966
|
* @param {boolean} explain Used to toggle the information on the query plan.
|
|
992
967
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
993
968
|
*/
|
|
994
|
-
explain(explain
|
|
969
|
+
explain(explain = true) /*: ParseQuery*/{
|
|
995
970
|
if (typeof explain !== 'boolean') {
|
|
996
971
|
throw new Error('You can only set explain to a boolean value');
|
|
997
972
|
}
|
|
@@ -1022,7 +997,7 @@ class ParseQuery {
|
|
|
1022
997
|
* iteration has completed.
|
|
1023
998
|
*/
|
|
1024
999
|
async map(callback /*: (currentObject: ParseObject, index: number, query: ParseQuery) => any*/, options /*:: ?: BatchOptions*/) /*: Promise<Array<any>>*/{
|
|
1025
|
-
const array = [];
|
|
1000
|
+
const array /*: ParseObject[]*/ = [];
|
|
1026
1001
|
let index = 0;
|
|
1027
1002
|
await this.each(object => {
|
|
1028
1003
|
return Promise.resolve(callback(object, index, this)).then(result => {
|
|
@@ -1103,7 +1078,7 @@ class ParseQuery {
|
|
|
1103
1078
|
* iteration has completed.
|
|
1104
1079
|
*/
|
|
1105
1080
|
async filter(callback /*: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean*/, options /*:: ?: BatchOptions*/) /*: Promise<Array<ParseObject>>*/{
|
|
1106
|
-
const array = [];
|
|
1081
|
+
const array /*: ParseObject[]*/ = [];
|
|
1107
1082
|
let index = 0;
|
|
1108
1083
|
await this.each(object => {
|
|
1109
1084
|
return Promise.resolve(callback(object, index, this)).then(flag => {
|
|
@@ -1126,7 +1101,7 @@ class ParseQuery {
|
|
|
1126
1101
|
* @param value The value that the Parse.Object must contain.
|
|
1127
1102
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1128
1103
|
*/
|
|
1129
|
-
equalTo(key /*: string | { [key: string]: any }*/, value
|
|
1104
|
+
equalTo(key /*: string | { [key: string]: any }*/, value /*:: ?: any*/) /*: ParseQuery*/{
|
|
1130
1105
|
if (key && typeof key === 'object') {
|
|
1131
1106
|
Object.entries(key).forEach(([k, val]) => this.equalTo(k, val));
|
|
1132
1107
|
return this;
|
|
@@ -1146,7 +1121,7 @@ class ParseQuery {
|
|
|
1146
1121
|
* @param value The value that must not be equalled.
|
|
1147
1122
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1148
1123
|
*/
|
|
1149
|
-
notEqualTo(key /*: string | { [key: string]: any }*/, value
|
|
1124
|
+
notEqualTo(key /*: string | { [key: string]: any }*/, value /*:: ?: any*/) /*: ParseQuery*/{
|
|
1150
1125
|
if (key && typeof key === 'object') {
|
|
1151
1126
|
Object.entries(key).forEach(([k, val]) => this.notEqualTo(k, val));
|
|
1152
1127
|
return this;
|
|
@@ -1162,7 +1137,7 @@ class ParseQuery {
|
|
|
1162
1137
|
* @param value The value that provides an upper bound.
|
|
1163
1138
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1164
1139
|
*/
|
|
1165
|
-
lessThan(key /*: string*/, value /*:
|
|
1140
|
+
lessThan(key /*: string*/, value /*: any*/) /*: ParseQuery*/{
|
|
1166
1141
|
return this._addCondition(key, '$lt', value);
|
|
1167
1142
|
}
|
|
1168
1143
|
|
|
@@ -1174,7 +1149,7 @@ class ParseQuery {
|
|
|
1174
1149
|
* @param value The value that provides an lower bound.
|
|
1175
1150
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1176
1151
|
*/
|
|
1177
|
-
greaterThan(key /*: string*/, value /*:
|
|
1152
|
+
greaterThan(key /*: string*/, value /*: any*/) /*: ParseQuery*/{
|
|
1178
1153
|
return this._addCondition(key, '$gt', value);
|
|
1179
1154
|
}
|
|
1180
1155
|
|
|
@@ -1186,7 +1161,7 @@ class ParseQuery {
|
|
|
1186
1161
|
* @param value The value that provides an upper bound.
|
|
1187
1162
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1188
1163
|
*/
|
|
1189
|
-
lessThanOrEqualTo(key /*: string*/, value /*:
|
|
1164
|
+
lessThanOrEqualTo(key /*: string*/, value /*: any*/) /*: ParseQuery*/{
|
|
1190
1165
|
return this._addCondition(key, '$lte', value);
|
|
1191
1166
|
}
|
|
1192
1167
|
|
|
@@ -1198,7 +1173,7 @@ class ParseQuery {
|
|
|
1198
1173
|
* @param {*} value The value that provides an lower bound.
|
|
1199
1174
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1200
1175
|
*/
|
|
1201
|
-
greaterThanOrEqualTo(key /*: string*/, value /*:
|
|
1176
|
+
greaterThanOrEqualTo(key /*: string*/, value /*: any*/) /*: ParseQuery*/{
|
|
1202
1177
|
return this._addCondition(key, '$gte', value);
|
|
1203
1178
|
}
|
|
1204
1179
|
|
|
@@ -1210,7 +1185,7 @@ class ParseQuery {
|
|
|
1210
1185
|
* @param {Array<*>} value The values that will match.
|
|
1211
1186
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1212
1187
|
*/
|
|
1213
|
-
containedIn(key /*: string*/, value /*: Array<
|
|
1188
|
+
containedIn(key /*: string*/, value /*: Array<any>*/) /*: ParseQuery*/{
|
|
1214
1189
|
return this._addCondition(key, '$in', value);
|
|
1215
1190
|
}
|
|
1216
1191
|
|
|
@@ -1222,7 +1197,7 @@ class ParseQuery {
|
|
|
1222
1197
|
* @param {Array<*>} value The values that will not match.
|
|
1223
1198
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1224
1199
|
*/
|
|
1225
|
-
notContainedIn(key /*: string*/, value /*: Array<
|
|
1200
|
+
notContainedIn(key /*: string*/, value /*: Array<any>*/) /*: ParseQuery*/{
|
|
1226
1201
|
return this._addCondition(key, '$nin', value);
|
|
1227
1202
|
}
|
|
1228
1203
|
|
|
@@ -1234,7 +1209,7 @@ class ParseQuery {
|
|
|
1234
1209
|
* @param {Array} values The values that will match.
|
|
1235
1210
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1236
1211
|
*/
|
|
1237
|
-
containedBy(key /*: string*/, values /*: Array<
|
|
1212
|
+
containedBy(key /*: string*/, values /*: Array<any>*/) /*: ParseQuery*/{
|
|
1238
1213
|
return this._addCondition(key, '$containedBy', values);
|
|
1239
1214
|
}
|
|
1240
1215
|
|
|
@@ -1246,7 +1221,7 @@ class ParseQuery {
|
|
|
1246
1221
|
* @param {Array} values The values that will match.
|
|
1247
1222
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1248
1223
|
*/
|
|
1249
|
-
containsAll(key /*: string*/, values /*: Array<
|
|
1224
|
+
containsAll(key /*: string*/, values /*: Array<any>*/) /*: ParseQuery*/{
|
|
1250
1225
|
return this._addCondition(key, '$all', values);
|
|
1251
1226
|
}
|
|
1252
1227
|
|
|
@@ -1259,13 +1234,12 @@ class ParseQuery {
|
|
|
1259
1234
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1260
1235
|
*/
|
|
1261
1236
|
containsAllStartingWith(key /*: string*/, values /*: Array<string>*/) /*: ParseQuery*/{
|
|
1262
|
-
const _this = this;
|
|
1263
1237
|
if (!Array.isArray(values)) {
|
|
1264
1238
|
values = [values];
|
|
1265
1239
|
}
|
|
1266
1240
|
const regexObject = values.map(value => {
|
|
1267
1241
|
return {
|
|
1268
|
-
$regex:
|
|
1242
|
+
$regex: this._regexStartWith(value)
|
|
1269
1243
|
};
|
|
1270
1244
|
});
|
|
1271
1245
|
return this.containsAll(key, regexObject);
|
|
@@ -1297,20 +1271,22 @@ class ParseQuery {
|
|
|
1297
1271
|
* This may be slow for large datasets.
|
|
1298
1272
|
*
|
|
1299
1273
|
* @param {string} key The key that the string to match is stored in.
|
|
1300
|
-
* @param {RegExp} regex The regular expression pattern to match.
|
|
1274
|
+
* @param {RegExp | string} regex The regular expression pattern to match.
|
|
1301
1275
|
* @param {string} modifiers The regular expression mode.
|
|
1302
1276
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1303
1277
|
*/
|
|
1304
|
-
matches(key /*: string*/, regex /*: RegExp*/, modifiers /*: string*/) /*: ParseQuery*/{
|
|
1278
|
+
matches(key /*: string*/, regex /*: RegExp | string*/, modifiers /*: string*/) /*: ParseQuery*/{
|
|
1305
1279
|
this._addCondition(key, '$regex', regex);
|
|
1306
1280
|
if (!modifiers) {
|
|
1307
1281
|
modifiers = '';
|
|
1308
1282
|
}
|
|
1309
|
-
if (regex
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1283
|
+
if (typeof regex !== 'string') {
|
|
1284
|
+
if (regex.ignoreCase) {
|
|
1285
|
+
modifiers += 'i';
|
|
1286
|
+
}
|
|
1287
|
+
if (regex.multiline) {
|
|
1288
|
+
modifiers += 'm';
|
|
1289
|
+
}
|
|
1314
1290
|
}
|
|
1315
1291
|
if (modifiers.length) {
|
|
1316
1292
|
this._addCondition(key, '$options', modifiers);
|
|
@@ -1432,7 +1408,7 @@ class ParseQuery {
|
|
|
1432
1408
|
* @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
|
|
1433
1409
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1434
1410
|
*/
|
|
1435
|
-
fullText(key /*: string*/, value /*: string*/, options /*:
|
|
1411
|
+
fullText(key /*: string*/, value /*: string*/, options /*: FullTextQueryOptions*/ = {}) /*: ParseQuery*/{
|
|
1436
1412
|
options = options || {};
|
|
1437
1413
|
if (!key) {
|
|
1438
1414
|
throw new Error('A key is required.');
|
|
@@ -1443,7 +1419,7 @@ class ParseQuery {
|
|
|
1443
1419
|
if (typeof value !== 'string') {
|
|
1444
1420
|
throw new Error('The value being searched for must be a string.');
|
|
1445
1421
|
}
|
|
1446
|
-
const fullOptions = {};
|
|
1422
|
+
const fullOptions /*: { $term?: string, $language?: string, $caseSensitive?: boolean, $diacriticSensitive?: boolean }*/ = {};
|
|
1447
1423
|
fullOptions.$term = value;
|
|
1448
1424
|
for (const option in options) {
|
|
1449
1425
|
switch (option) {
|
|
@@ -1647,7 +1623,7 @@ class ParseQuery {
|
|
|
1647
1623
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1648
1624
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1649
1625
|
*/
|
|
1650
|
-
ascending(...keys
|
|
1626
|
+
ascending(...keys) /*: ParseQuery*/{
|
|
1651
1627
|
this._order = [];
|
|
1652
1628
|
return this.addAscending.apply(this, keys);
|
|
1653
1629
|
}
|
|
@@ -1660,7 +1636,7 @@ class ParseQuery {
|
|
|
1660
1636
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1661
1637
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1662
1638
|
*/
|
|
1663
|
-
addAscending(...keys
|
|
1639
|
+
addAscending(...keys) /*: ParseQuery*/{
|
|
1664
1640
|
if (!this._order) {
|
|
1665
1641
|
this._order = [];
|
|
1666
1642
|
}
|
|
@@ -1680,7 +1656,7 @@ class ParseQuery {
|
|
|
1680
1656
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1681
1657
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1682
1658
|
*/
|
|
1683
|
-
descending(...keys
|
|
1659
|
+
descending(...keys) /*: ParseQuery*/{
|
|
1684
1660
|
this._order = [];
|
|
1685
1661
|
return this.addDescending.apply(this, keys);
|
|
1686
1662
|
}
|
|
@@ -1693,7 +1669,7 @@ class ParseQuery {
|
|
|
1693
1669
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1694
1670
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1695
1671
|
*/
|
|
1696
|
-
addDescending(...keys
|
|
1672
|
+
addDescending(...keys) /*: ParseQuery*/{
|
|
1697
1673
|
if (!this._order) {
|
|
1698
1674
|
this._order = [];
|
|
1699
1675
|
}
|
|
@@ -1749,7 +1725,7 @@ class ParseQuery {
|
|
|
1749
1725
|
* @param {boolean} includeCount false - disable, true - enable.
|
|
1750
1726
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1751
1727
|
*/
|
|
1752
|
-
withCount(includeCount
|
|
1728
|
+
withCount(includeCount = true) /*: ParseQuery*/{
|
|
1753
1729
|
if (typeof includeCount !== 'boolean') {
|
|
1754
1730
|
throw new Error('You can only set withCount to a boolean value');
|
|
1755
1731
|
}
|
|
@@ -1767,7 +1743,7 @@ class ParseQuery {
|
|
|
1767
1743
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to include.
|
|
1768
1744
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1769
1745
|
*/
|
|
1770
|
-
include(...keys
|
|
1746
|
+
include(...keys) /*: ParseQuery*/{
|
|
1771
1747
|
keys.forEach(key => {
|
|
1772
1748
|
if (Array.isArray(key)) {
|
|
1773
1749
|
this._include = this._include.concat(key);
|
|
@@ -1797,7 +1773,7 @@ class ParseQuery {
|
|
|
1797
1773
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to include.
|
|
1798
1774
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1799
1775
|
*/
|
|
1800
|
-
select(...keys
|
|
1776
|
+
select(...keys) /*: ParseQuery*/{
|
|
1801
1777
|
if (!this._select) {
|
|
1802
1778
|
this._select = [];
|
|
1803
1779
|
}
|
|
@@ -1820,7 +1796,7 @@ class ParseQuery {
|
|
|
1820
1796
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
|
|
1821
1797
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1822
1798
|
*/
|
|
1823
|
-
exclude(...keys
|
|
1799
|
+
exclude(...keys) /*: ParseQuery*/{
|
|
1824
1800
|
keys.forEach(key => {
|
|
1825
1801
|
if (Array.isArray(key)) {
|
|
1826
1802
|
this._exclude = this._exclude.concat(key);
|
|
@@ -1839,7 +1815,7 @@ class ParseQuery {
|
|
|
1839
1815
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
|
|
1840
1816
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1841
1817
|
*/
|
|
1842
|
-
watch(...keys
|
|
1818
|
+
watch(...keys) /*: ParseQuery*/{
|
|
1843
1819
|
keys.forEach(key => {
|
|
1844
1820
|
if (Array.isArray(key)) {
|
|
1845
1821
|
this._watch = this._watch.concat(key);
|
|
@@ -1860,8 +1836,8 @@ class ParseQuery {
|
|
|
1860
1836
|
*/
|
|
1861
1837
|
readPreference(readPreference /*: string*/, includeReadPreference /*:: ?: string*/, subqueryReadPreference /*:: ?: string*/) /*: ParseQuery*/{
|
|
1862
1838
|
this._readPreference = readPreference;
|
|
1863
|
-
this._includeReadPreference = includeReadPreference;
|
|
1864
|
-
this._subqueryReadPreference = subqueryReadPreference;
|
|
1839
|
+
this._includeReadPreference = includeReadPreference || null;
|
|
1840
|
+
this._subqueryReadPreference = subqueryReadPreference || null;
|
|
1865
1841
|
return this;
|
|
1866
1842
|
}
|
|
1867
1843
|
|
|
@@ -1875,7 +1851,7 @@ class ParseQuery {
|
|
|
1875
1851
|
async subscribe(sessionToken /*:: ?: string*/) /*: Promise<LiveQuerySubscription>*/{
|
|
1876
1852
|
const currentUser = await _CoreManager.default.getUserController().currentUserAsync();
|
|
1877
1853
|
if (!sessionToken) {
|
|
1878
|
-
sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
|
|
1854
|
+
sessionToken = currentUser ? currentUser.getSessionToken() || undefined : undefined;
|
|
1879
1855
|
}
|
|
1880
1856
|
const liveQueryClient = await _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
1881
1857
|
if (liveQueryClient.shouldOpen()) {
|
|
@@ -1899,7 +1875,7 @@ class ParseQuery {
|
|
|
1899
1875
|
* @static
|
|
1900
1876
|
* @returns {Parse.Query} The query that is the OR of the passed in queries.
|
|
1901
1877
|
*/
|
|
1902
|
-
static or(...queries
|
|
1878
|
+
static or(...queries) /*: ParseQuery*/{
|
|
1903
1879
|
const className = _getClassNameFromQueries(queries);
|
|
1904
1880
|
const query = new ParseQuery(className);
|
|
1905
1881
|
query._orQuery(queries);
|
|
@@ -1918,7 +1894,7 @@ class ParseQuery {
|
|
|
1918
1894
|
* @static
|
|
1919
1895
|
* @returns {Parse.Query} The query that is the AND of the passed in queries.
|
|
1920
1896
|
*/
|
|
1921
|
-
static and(...queries
|
|
1897
|
+
static and(...queries) /*: ParseQuery*/{
|
|
1922
1898
|
const className = _getClassNameFromQueries(queries);
|
|
1923
1899
|
const query = new ParseQuery(className);
|
|
1924
1900
|
query._andQuery(queries);
|
|
@@ -1937,7 +1913,7 @@ class ParseQuery {
|
|
|
1937
1913
|
* @static
|
|
1938
1914
|
* @returns {Parse.Query} The query that is the NOR of the passed in queries.
|
|
1939
1915
|
*/
|
|
1940
|
-
static nor(...queries
|
|
1916
|
+
static nor(...queries) /*: ParseQuery*/{
|
|
1941
1917
|
const className = _getClassNameFromQueries(queries);
|
|
1942
1918
|
const query = new ParseQuery(className);
|
|
1943
1919
|
query._norQuery(queries);
|
|
@@ -1979,7 +1955,7 @@ class ParseQuery {
|
|
|
1979
1955
|
* @param {string} name The name of query source.
|
|
1980
1956
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1981
1957
|
*/
|
|
1982
|
-
fromPinWithName(name /*:: ?: string*/) /*: ParseQuery*/{
|
|
1958
|
+
fromPinWithName(name /*:: ?: string | null*/) /*: ParseQuery*/{
|
|
1983
1959
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
1984
1960
|
if (localDatastore.checkIfEnabled()) {
|
|
1985
1961
|
this._queriesLocalDatastore = true;
|
|
@@ -2001,7 +1977,8 @@ class ParseQuery {
|
|
|
2001
1977
|
this._xhrRequest.onchange = () => {};
|
|
2002
1978
|
return this;
|
|
2003
1979
|
}
|
|
2004
|
-
|
|
1980
|
+
this._xhrRequest.onchange = () => this.cancel();
|
|
1981
|
+
return this;
|
|
2005
1982
|
}
|
|
2006
1983
|
_setRequestTask(options) {
|
|
2007
1984
|
options.requestTask = task => {
|
|
@@ -2012,7 +1989,7 @@ class ParseQuery {
|
|
|
2012
1989
|
|
|
2013
1990
|
/**
|
|
2014
1991
|
* Sets a comment to the query so that the query
|
|
2015
|
-
*can be identified when using a the profiler for MongoDB.
|
|
1992
|
+
* can be identified when using a the profiler for MongoDB.
|
|
2016
1993
|
*
|
|
2017
1994
|
* @param {string} value a comment can make your profile data easier to interpret and trace.
|
|
2018
1995
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
@@ -2030,11 +2007,11 @@ class ParseQuery {
|
|
|
2030
2007
|
}
|
|
2031
2008
|
}
|
|
2032
2009
|
const DefaultController = {
|
|
2033
|
-
find(className /*: string*/, params /*: QueryJSON*/, options /*: RequestOptions*/) /*: Promise<Array<ParseObject
|
|
2010
|
+
find(className /*: string*/, params /*: QueryJSON*/, options /*: RequestOptions*/) /*: Promise<{ results: Array<ParseObject> }>*/{
|
|
2034
2011
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2035
2012
|
return RESTController.request('GET', 'classes/' + className, params, options);
|
|
2036
2013
|
},
|
|
2037
|
-
aggregate(className /*: string*/, params /*: any*/, options /*: RequestOptions*/) /*: Promise<Array<
|
|
2014
|
+
aggregate(className /*: string*/, params /*: any*/, options /*: RequestOptions*/) /*: Promise<{ results: Array<any> }>*/{
|
|
2038
2015
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2039
2016
|
return RESTController.request('GET', 'aggregate/' + className, params, options);
|
|
2040
2017
|
}
|
package/lib/node/ParseRole.js
CHANGED
|
@@ -13,11 +13,6 @@ function _interopRequireDefault(obj) {
|
|
|
13
13
|
default: obj
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* @flow
|
|
18
|
-
*/
|
|
19
|
-
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
20
|
-
/*:: import type ParseRelation from './ParseRelation';*/
|
|
21
16
|
/**
|
|
22
17
|
* Represents a Role on the Parse server. Roles represent groupings of
|
|
23
18
|
* Users for the purposes of granting permissions (e.g. specifying an ACL
|
|
@@ -51,7 +46,7 @@ class ParseRole extends _ParseObject.default {
|
|
|
51
46
|
*
|
|
52
47
|
* @returns {string} the name of the role.
|
|
53
48
|
*/
|
|
54
|
-
getName() /*:
|
|
49
|
+
getName() /*: string | null*/{
|
|
55
50
|
const name = this.get('name');
|
|
56
51
|
if (name == null || typeof name === 'string') {
|
|
57
52
|
return name;
|
|
@@ -76,7 +71,7 @@ class ParseRole extends _ParseObject.default {
|
|
|
76
71
|
* callbacks.
|
|
77
72
|
* @returns {(ParseObject|boolean)} true if the set succeeded.
|
|
78
73
|
*/
|
|
79
|
-
setName(name /*: string*/, options /*:: ?:
|
|
74
|
+
setName(name /*: string*/, options /*:: ?: any*/) /*: ParseObject | boolean*/{
|
|
80
75
|
this._validateName(name);
|
|
81
76
|
return this.set('name', name, options);
|
|
82
77
|
}
|
|
@@ -118,7 +113,7 @@ class ParseRole extends _ParseObject.default {
|
|
|
118
113
|
throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
|
|
119
114
|
}
|
|
120
115
|
}
|
|
121
|
-
validate(attrs /*: AttributeMap*/, options /*:: ?:
|
|
116
|
+
validate(attrs /*: AttributeMap*/, options /*:: ?: any*/) /*: ParseError | boolean*/{
|
|
122
117
|
const isInvalid = super.validate(attrs, options);
|
|
123
118
|
if (isInvalid) {
|
|
124
119
|
return isInvalid;
|
package/lib/node/ParseSchema.js
CHANGED
|
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) {
|
|
|
19
19
|
const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
20
20
|
/*:: type FieldOptions = {
|
|
21
21
|
required: boolean,
|
|
22
|
-
defaultValue:
|
|
22
|
+
defaultValue: any,
|
|
23
23
|
};*/
|
|
24
24
|
/**
|
|
25
25
|
* A Parse.Schema object is for handling schema data from Parse.
|
|
@@ -40,9 +40,9 @@ const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'Ge
|
|
|
40
40
|
*/
|
|
41
41
|
class ParseSchema {
|
|
42
42
|
/*:: className: string;*/
|
|
43
|
-
/*:: _fields: { [key: string]:
|
|
44
|
-
/*:: _indexes: { [key: string]:
|
|
45
|
-
/*:: _clp: { [key: string]:
|
|
43
|
+
/*:: _fields: { [key: string]: any };*/
|
|
44
|
+
/*:: _indexes: { [key: string]: any };*/
|
|
45
|
+
/*:: _clp: { [key: string]: any };*/
|
|
46
46
|
/**
|
|
47
47
|
* @param {string} className Parse Class string.
|
|
48
48
|
*/
|