parse 5.1.0-alpha.9 → 5.1.0
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 +243 -153
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1108 -154
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/CoreManager.js +31 -1
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/ObjectStateMutations.js +3 -2
- package/lib/browser/ParseACL.js +21 -11
- package/lib/browser/ParseGeoPoint.js +12 -8
- package/lib/browser/ParseInstallation.js +1 -1
- package/lib/browser/ParseObject.js +74 -68
- package/lib/browser/ParseOp.js +21 -7
- package/lib/browser/ParseQuery.js +1 -0
- package/lib/browser/ParseRelation.js +12 -7
- package/lib/browser/ParseRole.js +2 -0
- package/lib/browser/ParseUser.js +1 -0
- package/lib/browser/SingleInstanceStateController.js +2 -4
- package/lib/browser/arrayContainsObject.js +4 -3
- package/lib/browser/canBeSerialized.js +6 -4
- package/lib/browser/decode.js +8 -5
- package/lib/browser/encode.js +6 -4
- package/lib/browser/equals.js +4 -3
- package/lib/browser/unique.js +3 -2
- package/lib/browser/unsavedChildren.js +4 -2
- package/lib/browser/uuid.js +11 -5
- package/lib/node/CoreManager.js +31 -1
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/ObjectStateMutations.js +3 -2
- package/lib/node/ParseACL.js +21 -11
- package/lib/node/ParseGeoPoint.js +11 -11
- package/lib/node/ParseInstallation.js +2 -2
- package/lib/node/ParseObject.js +68 -66
- package/lib/node/ParseOp.js +21 -7
- package/lib/node/ParseQuery.js +1 -0
- package/lib/node/ParseRelation.js +14 -8
- package/lib/node/ParseRole.js +2 -0
- package/lib/node/ParseUser.js +1 -0
- package/lib/node/SingleInstanceStateController.js +2 -8
- package/lib/node/arrayContainsObject.js +4 -3
- package/lib/node/canBeSerialized.js +6 -4
- package/lib/node/decode.js +9 -5
- package/lib/node/encode.js +7 -4
- package/lib/node/equals.js +4 -3
- package/lib/node/unique.js +3 -2
- package/lib/node/unsavedChildren.js +4 -2
- package/lib/node/uuid.js +10 -8
- package/lib/react-native/CoreManager.js +31 -1
- package/lib/react-native/ObjectStateMutations.js +3 -2
- package/lib/react-native/ParseACL.js +19 -11
- package/lib/react-native/ParseGeoPoint.js +5 -3
- package/lib/react-native/ParseObject.js +8 -6
- package/lib/react-native/ParseOp.js +20 -6
- package/lib/react-native/ParseQuery.js +1 -0
- package/lib/react-native/ParseRelation.js +10 -7
- package/lib/react-native/ParseRole.js +2 -0
- package/lib/react-native/ParseUser.js +1 -0
- package/lib/react-native/SingleInstanceStateController.js +0 -2
- package/lib/react-native/arrayContainsObject.js +3 -2
- package/lib/react-native/canBeSerialized.js +5 -3
- package/lib/react-native/decode.js +7 -5
- package/lib/react-native/encode.js +6 -4
- package/lib/react-native/equals.js +4 -3
- package/lib/react-native/unique.js +3 -2
- package/lib/react-native/unsavedChildren.js +3 -2
- package/lib/react-native/uuid.js +9 -4
- package/lib/weapp/CoreManager.js +31 -1
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/ObjectStateMutations.js +3 -2
- package/lib/weapp/ParseACL.js +21 -11
- package/lib/weapp/ParseGeoPoint.js +12 -8
- package/lib/weapp/ParseInstallation.js +1 -1
- package/lib/weapp/ParseObject.js +74 -68
- package/lib/weapp/ParseOp.js +21 -7
- package/lib/weapp/ParseQuery.js +1 -0
- package/lib/weapp/ParseRelation.js +12 -7
- package/lib/weapp/ParseRole.js +2 -0
- package/lib/weapp/ParseUser.js +1 -0
- package/lib/weapp/SingleInstanceStateController.js +2 -4
- package/lib/weapp/arrayContainsObject.js +4 -3
- package/lib/weapp/canBeSerialized.js +6 -4
- package/lib/weapp/decode.js +8 -5
- package/lib/weapp/encode.js +6 -4
- package/lib/weapp/equals.js +4 -3
- package/lib/weapp/unique.js +3 -2
- package/lib/weapp/unsavedChildren.js +4 -2
- package/lib/weapp/uuid.js +12 -5
- package/package.json +4 -1
package/lib/node/ParseObject.js
CHANGED
|
@@ -15,8 +15,8 @@ var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
|
15
15
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
16
16
|
var _promiseUtils = require("./promiseUtils");
|
|
17
17
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
18
|
+
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
18
19
|
var _ParseOp = require("./ParseOp");
|
|
19
|
-
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
20
20
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
21
21
|
var SingleInstanceStateController = _interopRequireWildcard(require("./SingleInstanceStateController"));
|
|
22
22
|
var _unique = _interopRequireDefault(require("./unique"));
|
|
@@ -66,25 +66,16 @@ function _interopRequireDefault(obj) {
|
|
|
66
66
|
default: obj
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
70
|
-
* @flow
|
|
71
|
-
*/
|
|
72
|
-
/*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
|
|
73
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
74
|
-
const uuidv4 = require('./uuid');
|
|
75
69
|
/*:: export type Pointer = {
|
|
76
70
|
__type: string,
|
|
77
71
|
className: string,
|
|
78
|
-
objectId
|
|
79
|
-
|
|
80
|
-
/*:: type SaveParams = {
|
|
81
|
-
method: string,
|
|
82
|
-
path: string,
|
|
83
|
-
body: AttributeMap,
|
|
72
|
+
objectId?: string,
|
|
73
|
+
_localId?: string,
|
|
84
74
|
};*/
|
|
85
75
|
/*:: export type SaveOptions = FullOptions & {
|
|
86
76
|
cascadeSave?: boolean,
|
|
87
77
|
context?: AttributeMap,
|
|
78
|
+
batchSize?: number,
|
|
88
79
|
};*/
|
|
89
80
|
// Mapping of class names to constructors, so we can populate objects from the
|
|
90
81
|
// server with appropriate subclasses of ParseObject
|
|
@@ -134,7 +125,7 @@ class ParseObject {
|
|
|
134
125
|
* @param {object} attributes The initial set of data to store in the object.
|
|
135
126
|
* @param {object} options The options for this object instance.
|
|
136
127
|
*/
|
|
137
|
-
constructor(className
|
|
128
|
+
constructor(className /*:: ?: string | { className: string, [attr: string]: any }*/, attributes /*:: ?: { [attr: string]: any }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
|
|
138
129
|
// Enable legacy initializers
|
|
139
130
|
if (typeof this.initialize === 'function') {
|
|
140
131
|
this.initialize.apply(this, arguments);
|
|
@@ -168,10 +159,7 @@ class ParseObject {
|
|
|
168
159
|
*
|
|
169
160
|
* @property {string} id
|
|
170
161
|
*/
|
|
171
|
-
|
|
172
|
-
/*:: _localId: ?string;*/
|
|
173
|
-
/*:: _objCount: number;*/
|
|
174
|
-
/*:: className: string;*/
|
|
162
|
+
|
|
175
163
|
/* Prototype getters / setters */
|
|
176
164
|
|
|
177
165
|
get attributes() /*: AttributeMap*/{
|
|
@@ -185,7 +173,7 @@ class ParseObject {
|
|
|
185
173
|
* @property {Date} createdAt
|
|
186
174
|
* @returns {Date}
|
|
187
175
|
*/
|
|
188
|
-
get createdAt() /*:
|
|
176
|
+
get createdAt() /*: Date | undefined*/{
|
|
189
177
|
return this._getServerData().createdAt;
|
|
190
178
|
}
|
|
191
179
|
|
|
@@ -195,7 +183,7 @@ class ParseObject {
|
|
|
195
183
|
* @property {Date} updatedAt
|
|
196
184
|
* @returns {Date}
|
|
197
185
|
*/
|
|
198
|
-
get updatedAt() /*:
|
|
186
|
+
get updatedAt() /*: Date | undefined*/{
|
|
199
187
|
return this._getServerData().updatedAt;
|
|
200
188
|
}
|
|
201
189
|
|
|
@@ -213,7 +201,7 @@ class ParseObject {
|
|
|
213
201
|
if (typeof this._localId === 'string') {
|
|
214
202
|
return this._localId;
|
|
215
203
|
}
|
|
216
|
-
const localId = 'local' +
|
|
204
|
+
const localId = 'local' + (0, _uuid.default)();
|
|
217
205
|
this._localId = localId;
|
|
218
206
|
return localId;
|
|
219
207
|
}
|
|
@@ -293,7 +281,7 @@ class ParseObject {
|
|
|
293
281
|
return dirty;
|
|
294
282
|
}
|
|
295
283
|
_toFullJSON(seen /*:: ?: Array<any>*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
|
|
296
|
-
const json /*: { [key: string]:
|
|
284
|
+
const json /*: { [key: string]: any }*/ = this.toJSON(seen, offline);
|
|
297
285
|
json.__type = 'Object';
|
|
298
286
|
json.className = this.className;
|
|
299
287
|
return json;
|
|
@@ -354,7 +342,13 @@ class ParseObject {
|
|
|
354
342
|
}
|
|
355
343
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
356
344
|
stateController.initializeState(this._getStateIdentifier());
|
|
357
|
-
const decoded
|
|
345
|
+
const decoded
|
|
346
|
+
/*: Partial<{
|
|
347
|
+
createdAt?: Date,
|
|
348
|
+
updatedAt?: Date,
|
|
349
|
+
ACL?: any,
|
|
350
|
+
[key: string]: any,
|
|
351
|
+
}>*/ = {};
|
|
358
352
|
for (const attr in serverData) {
|
|
359
353
|
if (attr === 'ACL') {
|
|
360
354
|
decoded[attr] = new _ParseACL.default(serverData[attr]);
|
|
@@ -400,7 +394,12 @@ class ParseObject {
|
|
|
400
394
|
}
|
|
401
395
|
}
|
|
402
396
|
_handleSaveResponse(response /*: AttributeMap*/, status /*: number*/) {
|
|
403
|
-
const changes
|
|
397
|
+
const changes
|
|
398
|
+
/*: Partial<{
|
|
399
|
+
createdAt: string,
|
|
400
|
+
updatedAt: string,
|
|
401
|
+
[key: string]: any
|
|
402
|
+
}>*/ = {};
|
|
404
403
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
405
404
|
const pending = stateController.popPendingState(this._getStateIdentifier());
|
|
406
405
|
for (var attr in pending) {
|
|
@@ -464,7 +463,7 @@ class ParseObject {
|
|
|
464
463
|
toJSON(seen /*: Array<any> | void*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
|
|
465
464
|
const seenEntry = this.id ? this.className + ':' + this.id : this;
|
|
466
465
|
seen = seen || [seenEntry];
|
|
467
|
-
const json = {};
|
|
466
|
+
const json /*: AttributeMap*/ = {};
|
|
468
467
|
const attrs = this.attributes;
|
|
469
468
|
for (const attr in attrs) {
|
|
470
469
|
if ((attr === 'createdAt' || attr === 'updatedAt') && attrs[attr].toJSON) {
|
|
@@ -485,7 +484,7 @@ class ParseObject {
|
|
|
485
484
|
* @param {object} other - An other object ot compare
|
|
486
485
|
* @returns {boolean}
|
|
487
486
|
*/
|
|
488
|
-
equals(other /*:
|
|
487
|
+
equals(other /*: any*/) /*: boolean*/{
|
|
489
488
|
if (this === other) {
|
|
490
489
|
return true;
|
|
491
490
|
}
|
|
@@ -594,7 +593,7 @@ class ParseObject {
|
|
|
594
593
|
* @param {string} attr The string name of an attribute.
|
|
595
594
|
* @returns {*}
|
|
596
595
|
*/
|
|
597
|
-
get(attr /*: string*/) /*:
|
|
596
|
+
get(attr /*: string*/) /*: any*/{
|
|
598
597
|
return this.attributes[attr];
|
|
599
598
|
}
|
|
600
599
|
|
|
@@ -681,7 +680,7 @@ class ParseObject {
|
|
|
681
680
|
* The only supported option is <code>error</code>.
|
|
682
681
|
* @returns {(ParseObject|boolean)} true if the set succeeded.
|
|
683
682
|
*/
|
|
684
|
-
set(key /*:
|
|
683
|
+
set(key /*: any*/, value /*:: ?: any*/, options /*:: ?: any*/) /*: ParseObject | boolean*/{
|
|
685
684
|
let changes = {};
|
|
686
685
|
const newOps = {};
|
|
687
686
|
if (key && typeof key === 'object') {
|
|
@@ -768,7 +767,7 @@ class ParseObject {
|
|
|
768
767
|
* @param options
|
|
769
768
|
* @returns {(ParseObject | boolean)}
|
|
770
769
|
*/
|
|
771
|
-
unset(attr /*: string*/, options /*:: ?: { [opt: string]:
|
|
770
|
+
unset(attr /*: string*/, options /*:: ?: { [opt: string]: any }*/) /*: ParseObject | boolean*/{
|
|
772
771
|
options = options || {};
|
|
773
772
|
options.unset = true;
|
|
774
773
|
return this.set(attr, null, options);
|
|
@@ -818,7 +817,7 @@ class ParseObject {
|
|
|
818
817
|
* @param item {} The item to add.
|
|
819
818
|
* @returns {(ParseObject | boolean)}
|
|
820
819
|
*/
|
|
821
|
-
add(attr /*: string*/, item /*:
|
|
820
|
+
add(attr /*: string*/, item /*: any*/) /*: ParseObject | boolean*/{
|
|
822
821
|
return this.set(attr, new _ParseOp.AddOp([item]));
|
|
823
822
|
}
|
|
824
823
|
|
|
@@ -830,7 +829,7 @@ class ParseObject {
|
|
|
830
829
|
* @param items {Object[]} The items to add.
|
|
831
830
|
* @returns {(ParseObject | boolean)}
|
|
832
831
|
*/
|
|
833
|
-
addAll(attr /*: string*/, items /*: Array<
|
|
832
|
+
addAll(attr /*: string*/, items /*: Array<any>*/) /*: ParseObject | boolean*/{
|
|
834
833
|
return this.set(attr, new _ParseOp.AddOp(items));
|
|
835
834
|
}
|
|
836
835
|
|
|
@@ -843,7 +842,7 @@ class ParseObject {
|
|
|
843
842
|
* @param item {} The object to add.
|
|
844
843
|
* @returns {(ParseObject | boolean)}
|
|
845
844
|
*/
|
|
846
|
-
addUnique(attr /*: string*/, item /*:
|
|
845
|
+
addUnique(attr /*: string*/, item /*: any*/) /*: ParseObject | boolean*/{
|
|
847
846
|
return this.set(attr, new _ParseOp.AddUniqueOp([item]));
|
|
848
847
|
}
|
|
849
848
|
|
|
@@ -856,7 +855,7 @@ class ParseObject {
|
|
|
856
855
|
* @param items {Object[]} The objects to add.
|
|
857
856
|
* @returns {(ParseObject | boolean)}
|
|
858
857
|
*/
|
|
859
|
-
addAllUnique(attr /*: string*/, items /*: Array<
|
|
858
|
+
addAllUnique(attr /*: string*/, items /*: Array<any>*/) /*: ParseObject | boolean*/{
|
|
860
859
|
return this.set(attr, new _ParseOp.AddUniqueOp(items));
|
|
861
860
|
}
|
|
862
861
|
|
|
@@ -868,7 +867,7 @@ class ParseObject {
|
|
|
868
867
|
* @param item {} The object to remove.
|
|
869
868
|
* @returns {(ParseObject | boolean)}
|
|
870
869
|
*/
|
|
871
|
-
remove(attr /*: string*/, item /*:
|
|
870
|
+
remove(attr /*: string*/, item /*: any*/) /*: ParseObject | boolean*/{
|
|
872
871
|
return this.set(attr, new _ParseOp.RemoveOp([item]));
|
|
873
872
|
}
|
|
874
873
|
|
|
@@ -880,7 +879,7 @@ class ParseObject {
|
|
|
880
879
|
* @param items {Object[]} The object to remove.
|
|
881
880
|
* @returns {(ParseObject | boolean)}
|
|
882
881
|
*/
|
|
883
|
-
removeAll(attr /*: string*/, items /*: Array<
|
|
882
|
+
removeAll(attr /*: string*/, items /*: Array<any>*/) /*: ParseObject | boolean*/{
|
|
884
883
|
return this.set(attr, new _ParseOp.RemoveOp(items));
|
|
885
884
|
}
|
|
886
885
|
|
|
@@ -893,7 +892,7 @@ class ParseObject {
|
|
|
893
892
|
* @param attr {String} The key.
|
|
894
893
|
* @returns {Parse.Op | undefined} The operation, or undefined if none.
|
|
895
894
|
*/
|
|
896
|
-
op(attr /*: string*/) /*:
|
|
895
|
+
op(attr /*: string*/) /*: Op | undefined*/{
|
|
897
896
|
const pending = this._getPendingOps();
|
|
898
897
|
for (let i = pending.length; i--;) {
|
|
899
898
|
if (pending[i][attr]) {
|
|
@@ -992,7 +991,8 @@ class ParseObject {
|
|
|
992
991
|
return false;
|
|
993
992
|
}
|
|
994
993
|
try {
|
|
995
|
-
const
|
|
994
|
+
const ParseQuery = _CoreManager.default.getParseQuery();
|
|
995
|
+
const query = new ParseQuery(this.className);
|
|
996
996
|
await query.get(this.id, options);
|
|
997
997
|
return true;
|
|
998
998
|
} catch (e) {
|
|
@@ -1040,7 +1040,7 @@ class ParseObject {
|
|
|
1040
1040
|
* @returns {Parse.ACL|null} An instance of Parse.ACL.
|
|
1041
1041
|
* @see Parse.Object#get
|
|
1042
1042
|
*/
|
|
1043
|
-
getACL() /*:
|
|
1043
|
+
getACL() /*: ParseACL | null*/{
|
|
1044
1044
|
const acl = this.get('ACL');
|
|
1045
1045
|
if (acl instanceof _ParseACL.default) {
|
|
1046
1046
|
return acl;
|
|
@@ -1056,7 +1056,7 @@ class ParseObject {
|
|
|
1056
1056
|
* @returns {(ParseObject | boolean)} Whether the set passed validation.
|
|
1057
1057
|
* @see Parse.Object#set
|
|
1058
1058
|
*/
|
|
1059
|
-
setACL(acl /*: ParseACL*/, options /*:: ?:
|
|
1059
|
+
setACL(acl /*: ParseACL*/, options /*:: ?: any*/) /*: ParseObject | boolean*/{
|
|
1060
1060
|
return this.set('ACL', acl, options);
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
@@ -1065,7 +1065,7 @@ class ParseObject {
|
|
|
1065
1065
|
*
|
|
1066
1066
|
* @param {string} [keys] - specify which fields to revert
|
|
1067
1067
|
*/
|
|
1068
|
-
revert(...keys
|
|
1068
|
+
revert(...keys) /*: void*/{
|
|
1069
1069
|
let keysToRevert;
|
|
1070
1070
|
if (keys.length) {
|
|
1071
1071
|
keysToRevert = [];
|
|
@@ -1119,9 +1119,9 @@ class ParseObject {
|
|
|
1119
1119
|
* @returns {Promise} A promise that is fulfilled when the fetch
|
|
1120
1120
|
* completes.
|
|
1121
1121
|
*/
|
|
1122
|
-
fetch(options /*:
|
|
1122
|
+
fetch(options /*: FetchOptions*/) /*: Promise<any>*/{
|
|
1123
1123
|
options = options || {};
|
|
1124
|
-
const fetchOptions = {};
|
|
1124
|
+
const fetchOptions /*: FetchOptions*/ = {};
|
|
1125
1125
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1126
1126
|
fetchOptions.useMasterKey = options.useMasterKey;
|
|
1127
1127
|
}
|
|
@@ -1167,7 +1167,7 @@ class ParseObject {
|
|
|
1167
1167
|
* @returns {Promise} A promise that is fulfilled when the fetch
|
|
1168
1168
|
* completes.
|
|
1169
1169
|
*/
|
|
1170
|
-
fetchWithInclude(keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) /*: Promise
|
|
1170
|
+
fetchWithInclude(keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) /*: Promise<any>*/{
|
|
1171
1171
|
options = options || {};
|
|
1172
1172
|
options.include = keys;
|
|
1173
1173
|
return this.fetch(options);
|
|
@@ -1197,7 +1197,7 @@ class ParseObject {
|
|
|
1197
1197
|
* @returns {Promise} A promise that is fulfilled when the save
|
|
1198
1198
|
* completes.
|
|
1199
1199
|
*/
|
|
1200
|
-
async saveEventually(options /*: SaveOptions*/) /*: Promise
|
|
1200
|
+
async saveEventually(options /*: SaveOptions*/) /*: Promise<this>*/{
|
|
1201
1201
|
try {
|
|
1202
1202
|
await this.save(null, options);
|
|
1203
1203
|
} catch (e) {
|
|
@@ -1272,7 +1272,7 @@ class ParseObject {
|
|
|
1272
1272
|
* @returns {Promise} A promise that is fulfilled when the save
|
|
1273
1273
|
* completes.
|
|
1274
1274
|
*/
|
|
1275
|
-
save(arg1 /*:
|
|
1275
|
+
save(arg1 /*: undefined | string | { [attr: string]: any } | null*/, arg2 /*: SaveOptions | any*/, arg3 /*:: ?: SaveOptions*/) /*: Promise<this>*/{
|
|
1276
1276
|
let attrs;
|
|
1277
1277
|
let options;
|
|
1278
1278
|
if (typeof arg1 === 'object' || typeof arg1 === 'undefined') {
|
|
@@ -1296,7 +1296,7 @@ class ParseObject {
|
|
|
1296
1296
|
return Promise.reject(validationError);
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
|
-
const saveOptions = {};
|
|
1299
|
+
const saveOptions /*: SaveOptions*/ = {};
|
|
1300
1300
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1301
1301
|
saveOptions.useMasterKey = !!options.useMasterKey;
|
|
1302
1302
|
}
|
|
@@ -1338,7 +1338,7 @@ class ParseObject {
|
|
|
1338
1338
|
* @returns {Promise} A promise that is fulfilled when the destroy
|
|
1339
1339
|
* completes.
|
|
1340
1340
|
*/
|
|
1341
|
-
async destroyEventually(options /*: RequestOptions*/) /*: Promise
|
|
1341
|
+
async destroyEventually(options /*: RequestOptions*/) /*: Promise<this>*/{
|
|
1342
1342
|
try {
|
|
1343
1343
|
await this.destroy(options);
|
|
1344
1344
|
} catch (e) {
|
|
@@ -1364,9 +1364,9 @@ class ParseObject {
|
|
|
1364
1364
|
* @returns {Promise} A promise that is fulfilled when the destroy
|
|
1365
1365
|
* completes.
|
|
1366
1366
|
*/
|
|
1367
|
-
destroy(options /*: RequestOptions*/) /*: Promise
|
|
1367
|
+
destroy(options /*: RequestOptions*/) /*: Promise<void | ParseObject>*/{
|
|
1368
1368
|
options = options || {};
|
|
1369
|
-
const destroyOptions = {};
|
|
1369
|
+
const destroyOptions /*: RequestOptions*/ = {};
|
|
1370
1370
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1371
1371
|
destroyOptions.useMasterKey = options.useMasterKey;
|
|
1372
1372
|
}
|
|
@@ -1530,7 +1530,7 @@ class ParseObject {
|
|
|
1530
1530
|
* @returns {Parse.Object[]}
|
|
1531
1531
|
*/
|
|
1532
1532
|
static fetchAll(list /*: Array<ParseObject>*/, options /*: RequestOptions*/ = {}) {
|
|
1533
|
-
const queryOptions = {};
|
|
1533
|
+
const queryOptions /*: RequestOptions*/ = {};
|
|
1534
1534
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1535
1535
|
queryOptions.useMasterKey = options.useMasterKey;
|
|
1536
1536
|
}
|
|
@@ -1632,9 +1632,9 @@ class ParseObject {
|
|
|
1632
1632
|
* @static
|
|
1633
1633
|
* @returns {Parse.Object[]}
|
|
1634
1634
|
*/
|
|
1635
|
-
static fetchAllIfNeeded(list /*: Array<ParseObject>*/, options) {
|
|
1635
|
+
static fetchAllIfNeeded(list /*: Array<ParseObject>*/, options /*: FetchOptions*/) {
|
|
1636
1636
|
options = options || {};
|
|
1637
|
-
const queryOptions = {};
|
|
1637
|
+
const queryOptions /*: FetchOptions*/ = {};
|
|
1638
1638
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1639
1639
|
queryOptions.useMasterKey = options.useMasterKey;
|
|
1640
1640
|
}
|
|
@@ -1646,7 +1646,7 @@ class ParseObject {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
|
|
1648
1648
|
}
|
|
1649
|
-
static handleIncludeOptions(options) {
|
|
1649
|
+
static handleIncludeOptions(options /*: { include?: string | string[] }*/) {
|
|
1650
1650
|
let include = [];
|
|
1651
1651
|
if (Array.isArray(options.include)) {
|
|
1652
1652
|
options.include.forEach(key => {
|
|
@@ -1708,8 +1708,8 @@ class ParseObject {
|
|
|
1708
1708
|
* @returns {Promise} A promise that is fulfilled when the destroyAll
|
|
1709
1709
|
* completes.
|
|
1710
1710
|
*/
|
|
1711
|
-
static destroyAll(list /*: Array<ParseObject>*/, options = {}) {
|
|
1712
|
-
const destroyOptions = {};
|
|
1711
|
+
static destroyAll(list /*: Array<ParseObject>*/, options /*: SaveOptions*/ = {}) {
|
|
1712
|
+
const destroyOptions /*: SaveOptions*/ = {};
|
|
1713
1713
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1714
1714
|
destroyOptions.useMasterKey = options.useMasterKey;
|
|
1715
1715
|
}
|
|
@@ -1743,8 +1743,8 @@ class ParseObject {
|
|
|
1743
1743
|
* @static
|
|
1744
1744
|
* @returns {Parse.Object[]}
|
|
1745
1745
|
*/
|
|
1746
|
-
static saveAll(list /*: Array<ParseObject>*/, options /*:
|
|
1747
|
-
const saveOptions = {};
|
|
1746
|
+
static saveAll(list /*: Array<ParseObject>*/, options /*: SaveOptions*/ = {}) {
|
|
1747
|
+
const saveOptions /*: SaveOptions*/ = {};
|
|
1748
1748
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1749
1749
|
saveOptions.useMasterKey = options.useMasterKey;
|
|
1750
1750
|
}
|
|
@@ -1774,7 +1774,7 @@ class ParseObject {
|
|
|
1774
1774
|
* @static
|
|
1775
1775
|
* @returns {Parse.Object} A Parse.Object reference.
|
|
1776
1776
|
*/
|
|
1777
|
-
static createWithoutData(id /*: string*/) {
|
|
1777
|
+
static createWithoutData(id /*: string*/) /*: ParseObject*/{
|
|
1778
1778
|
const obj = new this();
|
|
1779
1779
|
obj.id = id;
|
|
1780
1780
|
return obj;
|
|
@@ -1790,13 +1790,13 @@ class ParseObject {
|
|
|
1790
1790
|
* @static
|
|
1791
1791
|
* @returns {Parse.Object} A Parse.Object reference
|
|
1792
1792
|
*/
|
|
1793
|
-
static fromJSON(json /*: any*/, override /*:: ?: boolean*/, dirty /*:: ?: boolean*/) {
|
|
1793
|
+
static fromJSON(json /*: any*/, override /*:: ?: boolean*/, dirty /*:: ?: boolean*/) /*: ParseObject*/{
|
|
1794
1794
|
if (!json.className) {
|
|
1795
1795
|
throw new Error('Cannot create an object without a className');
|
|
1796
1796
|
}
|
|
1797
1797
|
const constructor = classMap[json.className];
|
|
1798
1798
|
const o = constructor ? new constructor(json.className) : new ParseObject(json.className);
|
|
1799
|
-
const otherAttributes = {};
|
|
1799
|
+
const otherAttributes /*: AttributeMap*/ = {};
|
|
1800
1800
|
for (const attr in json) {
|
|
1801
1801
|
if (attr !== 'className' && attr !== '__type') {
|
|
1802
1802
|
otherAttributes[attr] = json[attr];
|
|
@@ -2149,7 +2149,7 @@ class ParseObject {
|
|
|
2149
2149
|
}
|
|
2150
2150
|
}
|
|
2151
2151
|
const DefaultController = {
|
|
2152
|
-
fetch(target /*: ParseObject | Array<ParseObject>*/, forceFetch /*: boolean*/, options /*: RequestOptions*/) /*: Promise<Array<
|
|
2152
|
+
fetch(target /*: ParseObject | Array<ParseObject>*/, forceFetch /*: boolean*/, options /*: RequestOptions*/) /*: Promise<Array<ParseObject | undefined> | ParseObject | undefined>*/{
|
|
2153
2153
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2154
2154
|
if (Array.isArray(target)) {
|
|
2155
2155
|
if (target.length < 1) {
|
|
@@ -2182,7 +2182,8 @@ const DefaultController = {
|
|
|
2182
2182
|
if (error) {
|
|
2183
2183
|
return Promise.reject(error);
|
|
2184
2184
|
}
|
|
2185
|
-
const
|
|
2185
|
+
const ParseQuery = _CoreManager.default.getParseQuery();
|
|
2186
|
+
const query = new ParseQuery(className);
|
|
2186
2187
|
query.containedIn('objectId', ids);
|
|
2187
2188
|
if (options && options.include) {
|
|
2188
2189
|
query.include(options.include);
|
|
@@ -2222,7 +2223,7 @@ const DefaultController = {
|
|
|
2222
2223
|
return Promise.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
|
|
2223
2224
|
}
|
|
2224
2225
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2225
|
-
const params = {};
|
|
2226
|
+
const params /*: RequestOptions*/ = {};
|
|
2226
2227
|
if (options && options.include) {
|
|
2227
2228
|
params.include = options.include.join();
|
|
2228
2229
|
}
|
|
@@ -2234,9 +2235,9 @@ const DefaultController = {
|
|
|
2234
2235
|
return target;
|
|
2235
2236
|
});
|
|
2236
2237
|
}
|
|
2237
|
-
return Promise.resolve();
|
|
2238
|
+
return Promise.resolve(undefined);
|
|
2238
2239
|
},
|
|
2239
|
-
async destroy(target /*: ParseObject | Array<ParseObject>*/, options /*: RequestOptions*/) /*: Promise<
|
|
2240
|
+
async destroy(target /*: ParseObject | Array<ParseObject>*/, options /*: RequestOptions*/) /*: Promise<ParseObject | Array<ParseObject>>*/{
|
|
2240
2241
|
const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2241
2242
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2242
2243
|
const RESTController = _CoreManager.default.getRESTController();
|
|
@@ -2300,7 +2301,7 @@ const DefaultController = {
|
|
|
2300
2301
|
}
|
|
2301
2302
|
return Promise.resolve(target);
|
|
2302
2303
|
},
|
|
2303
|
-
save(target /*: ParseObject | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) {
|
|
2304
|
+
save(target /*: ParseObject | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) /*: Promise<ParseObject | Array<ParseObject> | ParseFile>*/{
|
|
2304
2305
|
const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2305
2306
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2306
2307
|
const mapIdForPin = {};
|
|
@@ -2444,6 +2445,7 @@ const DefaultController = {
|
|
|
2444
2445
|
return Promise.resolve();
|
|
2445
2446
|
}
|
|
2446
2447
|
};
|
|
2448
|
+
_CoreManager.default.setParseObject(ParseObject);
|
|
2447
2449
|
_CoreManager.default.setObjectController(DefaultController);
|
|
2448
2450
|
var _default = ParseObject;
|
|
2449
2451
|
exports.default = _default;
|
package/lib/node/ParseOp.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.opFromJSON = opFromJSON;
|
|
|
8
8
|
var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
|
|
9
9
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
10
10
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
11
|
-
var
|
|
11
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
12
12
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
13
13
|
var _unique = _interopRequireDefault(require("./unique"));
|
|
14
14
|
function _interopRequireDefault(obj) {
|
|
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) {
|
|
|
19
19
|
/**
|
|
20
20
|
* @flow
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
23
23
|
function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
|
|
24
24
|
if (!json || !json.__op) {
|
|
25
25
|
return null;
|
|
@@ -195,9 +195,10 @@ class AddUniqueOp extends Op {
|
|
|
195
195
|
return this._value || [];
|
|
196
196
|
}
|
|
197
197
|
if (Array.isArray(value)) {
|
|
198
|
+
const ParseObject = _CoreManager.default.getParseObject();
|
|
198
199
|
const toAdd = [];
|
|
199
200
|
this._value.forEach(v => {
|
|
200
|
-
if (v instanceof
|
|
201
|
+
if (v instanceof ParseObject) {
|
|
201
202
|
if (!(0, _arrayContainsObject.default)(value, v)) {
|
|
202
203
|
toAdd.push(v);
|
|
203
204
|
}
|
|
@@ -245,6 +246,7 @@ class RemoveOp extends Op {
|
|
|
245
246
|
return [];
|
|
246
247
|
}
|
|
247
248
|
if (Array.isArray(value)) {
|
|
249
|
+
const ParseObject = _CoreManager.default.getParseObject();
|
|
248
250
|
// var i = value.indexOf(this._value);
|
|
249
251
|
const removed = value.concat([]);
|
|
250
252
|
for (let i = 0; i < this._value.length; i++) {
|
|
@@ -253,9 +255,9 @@ class RemoveOp extends Op {
|
|
|
253
255
|
removed.splice(index, 1);
|
|
254
256
|
index = removed.indexOf(this._value[i]);
|
|
255
257
|
}
|
|
256
|
-
if (this._value[i] instanceof
|
|
258
|
+
if (this._value[i] instanceof ParseObject && this._value[i].id) {
|
|
257
259
|
for (let j = 0; j < removed.length; j++) {
|
|
258
|
-
if (removed[j] instanceof
|
|
260
|
+
if (removed[j] instanceof ParseObject && this._value[i].id === removed[j].id) {
|
|
259
261
|
removed.splice(j, 1);
|
|
260
262
|
j--;
|
|
261
263
|
}
|
|
@@ -277,9 +279,10 @@ class RemoveOp extends Op {
|
|
|
277
279
|
return new UnsetOp();
|
|
278
280
|
}
|
|
279
281
|
if (previous instanceof RemoveOp) {
|
|
282
|
+
const ParseObject = _CoreManager.default.getParseObject();
|
|
280
283
|
const uniques = previous._value.concat([]);
|
|
281
284
|
for (let i = 0; i < this._value.length; i++) {
|
|
282
|
-
if (this._value[i] instanceof
|
|
285
|
+
if (this._value[i] instanceof ParseObject) {
|
|
283
286
|
if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
|
|
284
287
|
uniques.push(this._value[i]);
|
|
285
288
|
}
|
|
@@ -431,4 +434,15 @@ class RelationOp extends Op {
|
|
|
431
434
|
return adds || removes || {};
|
|
432
435
|
}
|
|
433
436
|
}
|
|
434
|
-
exports.RelationOp = RelationOp;
|
|
437
|
+
exports.RelationOp = RelationOp;
|
|
438
|
+
_CoreManager.default.setParseOp({
|
|
439
|
+
Op,
|
|
440
|
+
opFromJSON,
|
|
441
|
+
SetOp,
|
|
442
|
+
UnsetOp,
|
|
443
|
+
IncrementOp,
|
|
444
|
+
AddOp,
|
|
445
|
+
RelationOp,
|
|
446
|
+
RemoveOp,
|
|
447
|
+
AddUniqueOp
|
|
448
|
+
});
|
package/lib/node/ParseQuery.js
CHANGED
|
@@ -2039,6 +2039,7 @@ const DefaultController = {
|
|
|
2039
2039
|
return RESTController.request('GET', 'aggregate/' + className, params, options);
|
|
2040
2040
|
}
|
|
2041
2041
|
};
|
|
2042
|
+
_CoreManager.default.setParseQuery(ParseQuery);
|
|
2042
2043
|
_CoreManager.default.setQueryController(DefaultController);
|
|
2043
2044
|
var _default = ParseQuery;
|
|
2044
2045
|
exports.default = _default;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
9
|
-
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
7
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
10
8
|
function _interopRequireDefault(obj) {
|
|
11
9
|
return obj && obj.__esModule ? obj : {
|
|
12
10
|
default: obj
|
|
@@ -15,7 +13,8 @@ function _interopRequireDefault(obj) {
|
|
|
15
13
|
/**
|
|
16
14
|
* @flow
|
|
17
15
|
*/
|
|
18
|
-
|
|
16
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
17
|
+
/*:: import type ParseQuery from './ParseQuery';*/
|
|
19
18
|
/**
|
|
20
19
|
* Creates a new Relation for the given parent object and key. This
|
|
21
20
|
* constructor should rarely be used directly, but rather created by
|
|
@@ -77,7 +76,10 @@ class ParseRelation {
|
|
|
77
76
|
if (!Array.isArray(objects)) {
|
|
78
77
|
objects = [objects];
|
|
79
78
|
}
|
|
80
|
-
const
|
|
79
|
+
const {
|
|
80
|
+
RelationOp
|
|
81
|
+
} = _CoreManager.default.getParseOp();
|
|
82
|
+
const change = new RelationOp(objects, []);
|
|
81
83
|
const parent = this.parent;
|
|
82
84
|
if (!parent) {
|
|
83
85
|
throw new Error('Cannot add to a Relation without a parent');
|
|
@@ -99,7 +101,10 @@ class ParseRelation {
|
|
|
99
101
|
if (!Array.isArray(objects)) {
|
|
100
102
|
objects = [objects];
|
|
101
103
|
}
|
|
102
|
-
const
|
|
104
|
+
const {
|
|
105
|
+
RelationOp
|
|
106
|
+
} = _CoreManager.default.getParseOp();
|
|
107
|
+
const change = new RelationOp([], objects);
|
|
103
108
|
if (!this.parent) {
|
|
104
109
|
throw new Error('Cannot remove from a Relation without a parent');
|
|
105
110
|
}
|
|
@@ -134,11 +139,12 @@ class ParseRelation {
|
|
|
134
139
|
if (!parent) {
|
|
135
140
|
throw new Error('Cannot construct a query for a Relation without a parent');
|
|
136
141
|
}
|
|
142
|
+
const ParseQuery = _CoreManager.default.getParseQuery();
|
|
137
143
|
if (!this.targetClassName) {
|
|
138
|
-
query = new
|
|
144
|
+
query = new ParseQuery(parent.className);
|
|
139
145
|
query._extraOptions.redirectClassNameForKey = this.key;
|
|
140
146
|
} else {
|
|
141
|
-
query = new
|
|
147
|
+
query = new ParseQuery(this.targetClassName);
|
|
142
148
|
}
|
|
143
149
|
query._addCondition('$relatedTo', 'object', {
|
|
144
150
|
__type: 'Pointer',
|
package/lib/node/ParseRole.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
7
8
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
8
9
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
9
10
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
@@ -139,6 +140,7 @@ class ParseRole extends _ParseObject.default {
|
|
|
139
140
|
return false;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
143
|
+
_CoreManager.default.setParseRole(ParseRole);
|
|
142
144
|
_ParseObject.default.registerSubclass('_Role', ParseRole);
|
|
143
145
|
var _default = ParseRole;
|
|
144
146
|
exports.default = _default;
|
package/lib/node/ParseUser.js
CHANGED
|
@@ -21,12 +21,6 @@ exports.removeState = removeState;
|
|
|
21
21
|
exports.setPendingOp = setPendingOp;
|
|
22
22
|
exports.setServerData = setServerData;
|
|
23
23
|
var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
|
|
24
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
25
|
-
function _interopRequireDefault(obj) {
|
|
26
|
-
return obj && obj.__esModule ? obj : {
|
|
27
|
-
default: obj
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
24
|
function _getRequireWildcardCache(nodeInterop) {
|
|
31
25
|
if (typeof WeakMap !== "function") return null;
|
|
32
26
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -151,12 +145,12 @@ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
|
|
|
151
145
|
}
|
|
152
146
|
return {};
|
|
153
147
|
}
|
|
154
|
-
function estimateAttribute(obj /*:
|
|
148
|
+
function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
|
|
155
149
|
const serverData = getServerData(obj);
|
|
156
150
|
const pendingOps = getPendingOps(obj);
|
|
157
151
|
return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
|
|
158
152
|
}
|
|
159
|
-
function estimateAttributes(obj /*:
|
|
153
|
+
function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
|
|
160
154
|
const serverData = getServerData(obj);
|
|
161
155
|
const pendingOps = getPendingOps(obj);
|
|
162
156
|
return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
|