parse 5.2.0-alpha.1 → 5.2.0-alpha.3
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 +10519 -15246
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10499 -15371
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +23 -41
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -485
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +258 -624
- package/lib/browser/LocalDatastoreController.default.js +42 -226
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +66 -160
- package/lib/browser/LocalDatastoreUtils.js +4 -7
- package/lib/browser/ObjectStateMutations.js +54 -96
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +44 -60
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -572
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +294 -438
- package/lib/browser/ParseGeoPoint.js +121 -146
- package/lib/browser/ParseHooks.js +23 -25
- package/lib/browser/ParseInstallation.js +225 -367
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2014 -2621
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1708 -2052
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -140
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +941 -1284
- package/lib/browser/Push.js +15 -38
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +31 -43
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +5 -9
- package/lib/node/AnonymousUtils.js +10 -15
- package/lib/node/Cloud.js +11 -11
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +20 -39
- package/lib/node/FacebookUtils.js +4 -8
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +12 -13
- package/lib/node/LiveQueryClient.js +23 -21
- package/lib/node/LiveQuerySubscription.js +6 -7
- package/lib/node/LocalDatastore.js +23 -23
- package/lib/node/LocalDatastoreController.default.js +11 -12
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +25 -21
- package/lib/node/LocalDatastoreUtils.js +4 -7
- package/lib/node/ObjectStateMutations.js +12 -22
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +36 -50
- package/lib/node/ParseACL.js +21 -30
- package/lib/node/ParseCLP.js +38 -40
- package/lib/node/ParseConfig.js +10 -17
- package/lib/node/ParseError.js +460 -461
- package/lib/node/ParseFile.js +27 -47
- package/lib/node/ParseGeoPoint.js +16 -17
- package/lib/node/ParseHooks.js +16 -18
- package/lib/node/ParseInstallation.js +10 -11
- package/lib/node/ParseLiveQuery.js +9 -14
- package/lib/node/ParseObject.js +142 -173
- package/lib/node/ParseOp.js +35 -47
- package/lib/node/ParsePolygon.js +14 -20
- package/lib/node/ParseQuery.js +100 -123
- package/lib/node/ParseRelation.js +10 -19
- package/lib/node/ParseRole.js +10 -11
- package/lib/node/ParseSchema.js +29 -42
- package/lib/node/ParseSession.js +10 -11
- package/lib/node/ParseUser.js +76 -87
- package/lib/node/Push.js +7 -12
- package/lib/node/RESTController.js +24 -36
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +14 -19
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +20 -20
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +2 -3
- package/lib/node/UniqueInstanceStateController.js +43 -63
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +4 -4
- package/lib/node/canBeSerialized.js +5 -5
- package/lib/node/decode.js +4 -4
- package/lib/node/encode.js +5 -5
- package/lib/node/equals.js +4 -4
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +5 -5
- package/lib/node/unsavedChildren.js +5 -5
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +8 -7
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +3 -3
- package/lib/react-native/LocalDatastoreController.default.js +1 -2
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +2 -4
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +3 -4
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +77 -87
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +43 -45
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +13 -30
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +24 -49
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +2 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +23 -41
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -485
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +258 -624
- package/lib/weapp/LocalDatastoreController.default.js +42 -226
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
- package/lib/weapp/LocalDatastoreUtils.js +4 -7
- package/lib/weapp/ObjectStateMutations.js +54 -96
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +44 -59
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -572
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +295 -440
- package/lib/weapp/ParseGeoPoint.js +121 -146
- package/lib/weapp/ParseHooks.js +23 -25
- package/lib/weapp/ParseInstallation.js +225 -367
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2014 -2621
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1708 -2052
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -140
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +941 -1284
- package/lib/weapp/Push.js +15 -38
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +31 -43
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +24 -30
package/lib/node/ParseObject.js
CHANGED
|
@@ -22,61 +22,36 @@ var SingleInstanceStateController = _interopRequireWildcard(require("./SingleIns
|
|
|
22
22
|
var _unique = _interopRequireDefault(require("./unique"));
|
|
23
23
|
var UniqueInstanceStateController = _interopRequireWildcard(require("./UniqueInstanceStateController"));
|
|
24
24
|
var _unsavedChildren = _interopRequireDefault(require("./unsavedChildren"));
|
|
25
|
-
function _getRequireWildcardCache(
|
|
26
|
-
if (typeof WeakMap
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
return (_getRequireWildcardCache = function (
|
|
30
|
-
return
|
|
31
|
-
})(
|
|
25
|
+
function _getRequireWildcardCache(e) {
|
|
26
|
+
if ("function" != typeof WeakMap) return null;
|
|
27
|
+
var r = new WeakMap(),
|
|
28
|
+
t = new WeakMap();
|
|
29
|
+
return (_getRequireWildcardCache = function (e) {
|
|
30
|
+
return e ? t : r;
|
|
31
|
+
})(e);
|
|
32
32
|
}
|
|
33
|
-
function _interopRequireWildcard(
|
|
34
|
-
if (!
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
50
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
51
|
-
if (desc && (desc.get || desc.set)) {
|
|
52
|
-
Object.defineProperty(newObj, key, desc);
|
|
53
|
-
} else {
|
|
54
|
-
newObj[key] = obj[key];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
newObj.default = obj;
|
|
59
|
-
if (cache) {
|
|
60
|
-
cache.set(obj, newObj);
|
|
61
|
-
}
|
|
62
|
-
return newObj;
|
|
33
|
+
function _interopRequireWildcard(e, r) {
|
|
34
|
+
if (!r && e && e.__esModule) return e;
|
|
35
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
36
|
+
default: e
|
|
37
|
+
};
|
|
38
|
+
var t = _getRequireWildcardCache(r);
|
|
39
|
+
if (t && t.has(e)) return t.get(e);
|
|
40
|
+
var n = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
},
|
|
43
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
45
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
46
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
47
|
+
}
|
|
48
|
+
return n.default = e, t && t.set(e, n), n;
|
|
63
49
|
}
|
|
64
|
-
function _interopRequireDefault(
|
|
65
|
-
return
|
|
66
|
-
default:
|
|
50
|
+
function _interopRequireDefault(e) {
|
|
51
|
+
return e && e.__esModule ? e : {
|
|
52
|
+
default: e
|
|
67
53
|
};
|
|
68
54
|
}
|
|
69
|
-
/*:: export type Pointer = {
|
|
70
|
-
__type: string,
|
|
71
|
-
className: string,
|
|
72
|
-
objectId?: string,
|
|
73
|
-
_localId?: string,
|
|
74
|
-
};*/
|
|
75
|
-
/*:: export type SaveOptions = FullOptions & {
|
|
76
|
-
cascadeSave?: boolean,
|
|
77
|
-
context?: AttributeMap,
|
|
78
|
-
batchSize?: number,
|
|
79
|
-
};*/
|
|
80
55
|
// Mapping of class names to constructors, so we can populate objects from the
|
|
81
56
|
// server with appropriate subclasses of ParseObject
|
|
82
57
|
const classMap = {};
|
|
@@ -124,9 +99,9 @@ class ParseObject {
|
|
|
124
99
|
* @param {string} className The class name for the object
|
|
125
100
|
* @param {object} attributes The initial set of data to store in the object.
|
|
126
101
|
* @param {object} options The options for this object instance.
|
|
127
|
-
* @param {boolean} [options.ignoreValidation
|
|
102
|
+
* @param {boolean} [options.ignoreValidation] Set to `true` ignore any attribute validation errors.
|
|
128
103
|
*/
|
|
129
|
-
constructor(className
|
|
104
|
+
constructor(className, attributes, options) {
|
|
130
105
|
// Enable legacy initializers
|
|
131
106
|
if (typeof this.initialize === 'function') {
|
|
132
107
|
this.initialize.apply(this, arguments);
|
|
@@ -163,7 +138,7 @@ class ParseObject {
|
|
|
163
138
|
|
|
164
139
|
/* Prototype getters / setters */
|
|
165
140
|
|
|
166
|
-
get attributes()
|
|
141
|
+
get attributes() {
|
|
167
142
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
168
143
|
return Object.freeze(stateController.estimateAttributes(this._getStateIdentifier()));
|
|
169
144
|
}
|
|
@@ -174,7 +149,7 @@ class ParseObject {
|
|
|
174
149
|
* @property {Date} createdAt
|
|
175
150
|
* @returns {Date}
|
|
176
151
|
*/
|
|
177
|
-
get createdAt()
|
|
152
|
+
get createdAt() {
|
|
178
153
|
return this._getServerData().createdAt;
|
|
179
154
|
}
|
|
180
155
|
|
|
@@ -184,7 +159,7 @@ class ParseObject {
|
|
|
184
159
|
* @property {Date} updatedAt
|
|
185
160
|
* @returns {Date}
|
|
186
161
|
*/
|
|
187
|
-
get updatedAt()
|
|
162
|
+
get updatedAt() {
|
|
188
163
|
return this._getServerData().updatedAt;
|
|
189
164
|
}
|
|
190
165
|
|
|
@@ -195,7 +170,7 @@ class ParseObject {
|
|
|
195
170
|
*
|
|
196
171
|
* @returns {string}
|
|
197
172
|
*/
|
|
198
|
-
_getId()
|
|
173
|
+
_getId() {
|
|
199
174
|
if (typeof this.id === 'string') {
|
|
200
175
|
return this.id;
|
|
201
176
|
}
|
|
@@ -212,7 +187,7 @@ class ParseObject {
|
|
|
212
187
|
*
|
|
213
188
|
* @returns {Parse.Object|object}
|
|
214
189
|
*/
|
|
215
|
-
_getStateIdentifier()
|
|
190
|
+
_getStateIdentifier() {
|
|
216
191
|
if (singleInstance) {
|
|
217
192
|
let id = this.id;
|
|
218
193
|
if (!id) {
|
|
@@ -226,7 +201,7 @@ class ParseObject {
|
|
|
226
201
|
return this;
|
|
227
202
|
}
|
|
228
203
|
}
|
|
229
|
-
_getServerData()
|
|
204
|
+
_getServerData() {
|
|
230
205
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
231
206
|
return stateController.getServerData(this._getStateIdentifier());
|
|
232
207
|
}
|
|
@@ -239,7 +214,7 @@ class ParseObject {
|
|
|
239
214
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
240
215
|
stateController.setServerData(this._getStateIdentifier(), unset);
|
|
241
216
|
}
|
|
242
|
-
_getPendingOps()
|
|
217
|
+
_getPendingOps() {
|
|
243
218
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
244
219
|
return stateController.getPendingOps(this._getStateIdentifier());
|
|
245
220
|
}
|
|
@@ -248,7 +223,7 @@ class ParseObject {
|
|
|
248
223
|
* @param {Array<string>} [keysToClear] - if specified, only ops matching
|
|
249
224
|
* these fields will be cleared
|
|
250
225
|
*/
|
|
251
|
-
_clearPendingOps(keysToClear
|
|
226
|
+
_clearPendingOps(keysToClear) {
|
|
252
227
|
const pending = this._getPendingOps();
|
|
253
228
|
const latest = pending[pending.length - 1];
|
|
254
229
|
const keys = keysToClear || Object.keys(latest);
|
|
@@ -256,7 +231,7 @@ class ParseObject {
|
|
|
256
231
|
delete latest[key];
|
|
257
232
|
});
|
|
258
233
|
}
|
|
259
|
-
_getDirtyObjectAttributes()
|
|
234
|
+
_getDirtyObjectAttributes() {
|
|
260
235
|
const attributes = this.attributes;
|
|
261
236
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
262
237
|
const objectCache = stateController.getObjectCache(this._getStateIdentifier());
|
|
@@ -281,13 +256,13 @@ class ParseObject {
|
|
|
281
256
|
}
|
|
282
257
|
return dirty;
|
|
283
258
|
}
|
|
284
|
-
_toFullJSON(seen
|
|
285
|
-
const json
|
|
259
|
+
_toFullJSON(seen, offline) {
|
|
260
|
+
const json = this.toJSON(seen, offline);
|
|
286
261
|
json.__type = 'Object';
|
|
287
262
|
json.className = this.className;
|
|
288
263
|
return json;
|
|
289
264
|
}
|
|
290
|
-
_getSaveJSON()
|
|
265
|
+
_getSaveJSON() {
|
|
291
266
|
const pending = this._getPendingOps();
|
|
292
267
|
const dirtyObjects = this._getDirtyObjectAttributes();
|
|
293
268
|
const json = {};
|
|
@@ -314,7 +289,7 @@ class ParseObject {
|
|
|
314
289
|
}
|
|
315
290
|
return json;
|
|
316
291
|
}
|
|
317
|
-
_getSaveParams()
|
|
292
|
+
_getSaveParams() {
|
|
318
293
|
let method = this.id ? 'PUT' : 'POST';
|
|
319
294
|
const body = this._getSaveJSON();
|
|
320
295
|
let path = 'classes/' + this.className;
|
|
@@ -337,19 +312,13 @@ class ParseObject {
|
|
|
337
312
|
path
|
|
338
313
|
};
|
|
339
314
|
}
|
|
340
|
-
_finishFetch(serverData
|
|
315
|
+
_finishFetch(serverData) {
|
|
341
316
|
if (!this.id && serverData.objectId) {
|
|
342
317
|
this.id = serverData.objectId;
|
|
343
318
|
}
|
|
344
319
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
345
320
|
stateController.initializeState(this._getStateIdentifier());
|
|
346
|
-
const decoded
|
|
347
|
-
/*: Partial<{
|
|
348
|
-
createdAt?: Date,
|
|
349
|
-
updatedAt?: Date,
|
|
350
|
-
ACL?: any,
|
|
351
|
-
[key: string]: any,
|
|
352
|
-
}>*/ = {};
|
|
321
|
+
const decoded = {};
|
|
353
322
|
for (const attr in serverData) {
|
|
354
323
|
if (attr === 'ACL') {
|
|
355
324
|
decoded[attr] = new _ParseACL.default(serverData[attr]);
|
|
@@ -371,14 +340,14 @@ class ParseObject {
|
|
|
371
340
|
}
|
|
372
341
|
stateController.commitServerChanges(this._getStateIdentifier(), decoded);
|
|
373
342
|
}
|
|
374
|
-
_setExisted(existed
|
|
343
|
+
_setExisted(existed) {
|
|
375
344
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
376
345
|
const state = stateController.getState(this._getStateIdentifier());
|
|
377
346
|
if (state) {
|
|
378
347
|
state.existed = existed;
|
|
379
348
|
}
|
|
380
349
|
}
|
|
381
|
-
_migrateId(serverId
|
|
350
|
+
_migrateId(serverId) {
|
|
382
351
|
if (this._localId && serverId) {
|
|
383
352
|
if (singleInstance) {
|
|
384
353
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
@@ -394,13 +363,8 @@ class ParseObject {
|
|
|
394
363
|
}
|
|
395
364
|
}
|
|
396
365
|
}
|
|
397
|
-
_handleSaveResponse(response
|
|
398
|
-
const changes
|
|
399
|
-
/*: Partial<{
|
|
400
|
-
createdAt: string,
|
|
401
|
-
updatedAt: string,
|
|
402
|
-
[key: string]: any
|
|
403
|
-
}>*/ = {};
|
|
366
|
+
_handleSaveResponse(response, status) {
|
|
367
|
+
const changes = {};
|
|
404
368
|
const stateController = _CoreManager.default.getObjectStateController();
|
|
405
369
|
const pending = stateController.popPendingState(this._getStateIdentifier());
|
|
406
370
|
for (var attr in pending) {
|
|
@@ -461,10 +425,10 @@ class ParseObject {
|
|
|
461
425
|
* @param offline
|
|
462
426
|
* @returns {object}
|
|
463
427
|
*/
|
|
464
|
-
toJSON(seen
|
|
428
|
+
toJSON(seen, offline) {
|
|
465
429
|
const seenEntry = this.id ? this.className + ':' + this.id : this;
|
|
466
430
|
seen = seen || [seenEntry];
|
|
467
|
-
const json
|
|
431
|
+
const json = {};
|
|
468
432
|
const attrs = this.attributes;
|
|
469
433
|
for (const attr in attrs) {
|
|
470
434
|
if ((attr === 'createdAt' || attr === 'updatedAt') && attrs[attr].toJSON) {
|
|
@@ -473,6 +437,12 @@ class ParseObject {
|
|
|
473
437
|
json[attr] = (0, _encode.default)(attrs[attr], false, false, seen, offline);
|
|
474
438
|
}
|
|
475
439
|
}
|
|
440
|
+
const pending = this._getPendingOps();
|
|
441
|
+
for (const attr in pending[0]) {
|
|
442
|
+
if (attr.indexOf('.') < 0) {
|
|
443
|
+
json[attr] = pending[0][attr].toJSON(offline);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
476
446
|
if (this.id) {
|
|
477
447
|
json.objectId = this.id;
|
|
478
448
|
}
|
|
@@ -485,7 +455,7 @@ class ParseObject {
|
|
|
485
455
|
* @param {object} other - An other object ot compare
|
|
486
456
|
* @returns {boolean}
|
|
487
457
|
*/
|
|
488
|
-
equals(other
|
|
458
|
+
equals(other) {
|
|
489
459
|
if (this === other) {
|
|
490
460
|
return true;
|
|
491
461
|
}
|
|
@@ -500,7 +470,7 @@ class ParseObject {
|
|
|
500
470
|
* @param {string} attr An attribute name (optional).
|
|
501
471
|
* @returns {boolean}
|
|
502
472
|
*/
|
|
503
|
-
dirty(attr
|
|
473
|
+
dirty(attr) {
|
|
504
474
|
if (!this.id) {
|
|
505
475
|
return true;
|
|
506
476
|
}
|
|
@@ -531,7 +501,7 @@ class ParseObject {
|
|
|
531
501
|
*
|
|
532
502
|
* @returns {string[]}
|
|
533
503
|
*/
|
|
534
|
-
dirtyKeys()
|
|
504
|
+
dirtyKeys() {
|
|
535
505
|
const pendingOps = this._getPendingOps();
|
|
536
506
|
const keys = {};
|
|
537
507
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
@@ -551,7 +521,7 @@ class ParseObject {
|
|
|
551
521
|
*
|
|
552
522
|
* @returns {boolean}
|
|
553
523
|
*/
|
|
554
|
-
isDataAvailable()
|
|
524
|
+
isDataAvailable() {
|
|
555
525
|
const serverData = this._getServerData();
|
|
556
526
|
return !!Object.keys(serverData).length;
|
|
557
527
|
}
|
|
@@ -561,7 +531,7 @@ class ParseObject {
|
|
|
561
531
|
*
|
|
562
532
|
* @returns {Pointer}
|
|
563
533
|
*/
|
|
564
|
-
toPointer()
|
|
534
|
+
toPointer() {
|
|
565
535
|
if (!this.id) {
|
|
566
536
|
throw new Error('Cannot create a pointer to an unsaved ParseObject');
|
|
567
537
|
}
|
|
@@ -577,7 +547,7 @@ class ParseObject {
|
|
|
577
547
|
*
|
|
578
548
|
* @returns {Pointer}
|
|
579
549
|
*/
|
|
580
|
-
toOfflinePointer()
|
|
550
|
+
toOfflinePointer() {
|
|
581
551
|
if (!this._localId) {
|
|
582
552
|
throw new Error('Cannot create a offline pointer to a saved ParseObject');
|
|
583
553
|
}
|
|
@@ -594,7 +564,7 @@ class ParseObject {
|
|
|
594
564
|
* @param {string} attr The string name of an attribute.
|
|
595
565
|
* @returns {*}
|
|
596
566
|
*/
|
|
597
|
-
get(attr
|
|
567
|
+
get(attr) {
|
|
598
568
|
return this.attributes[attr];
|
|
599
569
|
}
|
|
600
570
|
|
|
@@ -604,7 +574,7 @@ class ParseObject {
|
|
|
604
574
|
* @param {string} attr The attribute to get the relation for.
|
|
605
575
|
* @returns {Parse.Relation}
|
|
606
576
|
*/
|
|
607
|
-
relation(attr
|
|
577
|
+
relation(attr) {
|
|
608
578
|
const value = this.get(attr);
|
|
609
579
|
if (value) {
|
|
610
580
|
if (!(value instanceof _ParseRelation.default)) {
|
|
@@ -622,7 +592,7 @@ class ParseObject {
|
|
|
622
592
|
* @param {string} attr The string name of an attribute.
|
|
623
593
|
* @returns {string}
|
|
624
594
|
*/
|
|
625
|
-
escape(attr
|
|
595
|
+
escape(attr) {
|
|
626
596
|
let val = this.attributes[attr];
|
|
627
597
|
if (val == null) {
|
|
628
598
|
return '';
|
|
@@ -643,7 +613,7 @@ class ParseObject {
|
|
|
643
613
|
* @param {string} attr The string name of the attribute.
|
|
644
614
|
* @returns {boolean}
|
|
645
615
|
*/
|
|
646
|
-
has(attr
|
|
616
|
+
has(attr) {
|
|
647
617
|
const attributes = this.attributes;
|
|
648
618
|
if (attributes.hasOwnProperty(attr)) {
|
|
649
619
|
return attributes[attr] != null;
|
|
@@ -681,7 +651,7 @@ class ParseObject {
|
|
|
681
651
|
* The only supported option is <code>error</code>.
|
|
682
652
|
* @returns {(ParseObject|boolean)} true if the set succeeded.
|
|
683
653
|
*/
|
|
684
|
-
set(key
|
|
654
|
+
set(key, value, options) {
|
|
685
655
|
let changes = {};
|
|
686
656
|
const newOps = {};
|
|
687
657
|
if (key && typeof key === 'object') {
|
|
@@ -768,7 +738,7 @@ class ParseObject {
|
|
|
768
738
|
* @param options
|
|
769
739
|
* @returns {(ParseObject | boolean)}
|
|
770
740
|
*/
|
|
771
|
-
unset(attr
|
|
741
|
+
unset(attr, options) {
|
|
772
742
|
options = options || {};
|
|
773
743
|
options.unset = true;
|
|
774
744
|
return this.set(attr, null, options);
|
|
@@ -782,7 +752,7 @@ class ParseObject {
|
|
|
782
752
|
* @param amount {Number} The amount to increment by (optional).
|
|
783
753
|
* @returns {(ParseObject|boolean)}
|
|
784
754
|
*/
|
|
785
|
-
increment(attr
|
|
755
|
+
increment(attr, amount) {
|
|
786
756
|
if (typeof amount === 'undefined') {
|
|
787
757
|
amount = 1;
|
|
788
758
|
}
|
|
@@ -800,7 +770,7 @@ class ParseObject {
|
|
|
800
770
|
* @param amount {Number} The amount to decrement by (optional).
|
|
801
771
|
* @returns {(ParseObject | boolean)}
|
|
802
772
|
*/
|
|
803
|
-
decrement(attr
|
|
773
|
+
decrement(attr, amount) {
|
|
804
774
|
if (typeof amount === 'undefined') {
|
|
805
775
|
amount = 1;
|
|
806
776
|
}
|
|
@@ -818,7 +788,7 @@ class ParseObject {
|
|
|
818
788
|
* @param item {} The item to add.
|
|
819
789
|
* @returns {(ParseObject | boolean)}
|
|
820
790
|
*/
|
|
821
|
-
add(attr
|
|
791
|
+
add(attr, item) {
|
|
822
792
|
return this.set(attr, new _ParseOp.AddOp([item]));
|
|
823
793
|
}
|
|
824
794
|
|
|
@@ -830,7 +800,7 @@ class ParseObject {
|
|
|
830
800
|
* @param items {Object[]} The items to add.
|
|
831
801
|
* @returns {(ParseObject | boolean)}
|
|
832
802
|
*/
|
|
833
|
-
addAll(attr
|
|
803
|
+
addAll(attr, items) {
|
|
834
804
|
return this.set(attr, new _ParseOp.AddOp(items));
|
|
835
805
|
}
|
|
836
806
|
|
|
@@ -843,7 +813,7 @@ class ParseObject {
|
|
|
843
813
|
* @param item {} The object to add.
|
|
844
814
|
* @returns {(ParseObject | boolean)}
|
|
845
815
|
*/
|
|
846
|
-
addUnique(attr
|
|
816
|
+
addUnique(attr, item) {
|
|
847
817
|
return this.set(attr, new _ParseOp.AddUniqueOp([item]));
|
|
848
818
|
}
|
|
849
819
|
|
|
@@ -856,7 +826,7 @@ class ParseObject {
|
|
|
856
826
|
* @param items {Object[]} The objects to add.
|
|
857
827
|
* @returns {(ParseObject | boolean)}
|
|
858
828
|
*/
|
|
859
|
-
addAllUnique(attr
|
|
829
|
+
addAllUnique(attr, items) {
|
|
860
830
|
return this.set(attr, new _ParseOp.AddUniqueOp(items));
|
|
861
831
|
}
|
|
862
832
|
|
|
@@ -868,7 +838,7 @@ class ParseObject {
|
|
|
868
838
|
* @param item {} The object to remove.
|
|
869
839
|
* @returns {(ParseObject | boolean)}
|
|
870
840
|
*/
|
|
871
|
-
remove(attr
|
|
841
|
+
remove(attr, item) {
|
|
872
842
|
return this.set(attr, new _ParseOp.RemoveOp([item]));
|
|
873
843
|
}
|
|
874
844
|
|
|
@@ -880,7 +850,7 @@ class ParseObject {
|
|
|
880
850
|
* @param items {Object[]} The object to remove.
|
|
881
851
|
* @returns {(ParseObject | boolean)}
|
|
882
852
|
*/
|
|
883
|
-
removeAll(attr
|
|
853
|
+
removeAll(attr, items) {
|
|
884
854
|
return this.set(attr, new _ParseOp.RemoveOp(items));
|
|
885
855
|
}
|
|
886
856
|
|
|
@@ -893,7 +863,7 @@ class ParseObject {
|
|
|
893
863
|
* @param attr {String} The key.
|
|
894
864
|
* @returns {Parse.Op | undefined} The operation, or undefined if none.
|
|
895
865
|
*/
|
|
896
|
-
op(attr
|
|
866
|
+
op(attr) {
|
|
897
867
|
const pending = this._getPendingOps();
|
|
898
868
|
for (let i = pending.length; i--;) {
|
|
899
869
|
if (pending[i][attr]) {
|
|
@@ -907,7 +877,7 @@ class ParseObject {
|
|
|
907
877
|
*
|
|
908
878
|
* @returns {Parse.Object}
|
|
909
879
|
*/
|
|
910
|
-
clone()
|
|
880
|
+
clone() {
|
|
911
881
|
const clone = new this.constructor(this.className);
|
|
912
882
|
let attributes = this.attributes;
|
|
913
883
|
if (typeof this.constructor.readOnlyAttributes === 'function') {
|
|
@@ -933,7 +903,7 @@ class ParseObject {
|
|
|
933
903
|
*
|
|
934
904
|
* @returns {Parse.Object}
|
|
935
905
|
*/
|
|
936
|
-
newInstance()
|
|
906
|
+
newInstance() {
|
|
937
907
|
const clone = new this.constructor(this.className);
|
|
938
908
|
clone.id = this.id;
|
|
939
909
|
if (singleInstance) {
|
|
@@ -952,7 +922,7 @@ class ParseObject {
|
|
|
952
922
|
*
|
|
953
923
|
* @returns {boolean}
|
|
954
924
|
*/
|
|
955
|
-
isNew()
|
|
925
|
+
isNew() {
|
|
956
926
|
return !this.id;
|
|
957
927
|
}
|
|
958
928
|
|
|
@@ -963,7 +933,7 @@ class ParseObject {
|
|
|
963
933
|
*
|
|
964
934
|
* @returns {boolean}
|
|
965
935
|
*/
|
|
966
|
-
existed()
|
|
936
|
+
existed() {
|
|
967
937
|
if (!this.id) {
|
|
968
938
|
return false;
|
|
969
939
|
}
|
|
@@ -987,7 +957,7 @@ class ParseObject {
|
|
|
987
957
|
* </ul>
|
|
988
958
|
* @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
|
|
989
959
|
*/
|
|
990
|
-
async exists(options
|
|
960
|
+
async exists(options) {
|
|
991
961
|
if (!this.id) {
|
|
992
962
|
return false;
|
|
993
963
|
}
|
|
@@ -1009,7 +979,7 @@ class ParseObject {
|
|
|
1009
979
|
*
|
|
1010
980
|
* @returns {boolean}
|
|
1011
981
|
*/
|
|
1012
|
-
isValid()
|
|
982
|
+
isValid() {
|
|
1013
983
|
return !this.validate(this.attributes);
|
|
1014
984
|
}
|
|
1015
985
|
|
|
@@ -1023,7 +993,7 @@ class ParseObject {
|
|
|
1023
993
|
* @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
|
|
1024
994
|
* @see Parse.Object#set
|
|
1025
995
|
*/
|
|
1026
|
-
validate(attrs
|
|
996
|
+
validate(attrs) {
|
|
1027
997
|
if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
|
|
1028
998
|
return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
|
|
1029
999
|
}
|
|
@@ -1041,7 +1011,7 @@ class ParseObject {
|
|
|
1041
1011
|
* @returns {Parse.ACL|null} An instance of Parse.ACL.
|
|
1042
1012
|
* @see Parse.Object#get
|
|
1043
1013
|
*/
|
|
1044
|
-
getACL()
|
|
1014
|
+
getACL() {
|
|
1045
1015
|
const acl = this.get('ACL');
|
|
1046
1016
|
if (acl instanceof _ParseACL.default) {
|
|
1047
1017
|
return acl;
|
|
@@ -1057,7 +1027,7 @@ class ParseObject {
|
|
|
1057
1027
|
* @returns {(ParseObject | boolean)} Whether the set passed validation.
|
|
1058
1028
|
* @see Parse.Object#set
|
|
1059
1029
|
*/
|
|
1060
|
-
setACL(acl
|
|
1030
|
+
setACL(acl, options) {
|
|
1061
1031
|
return this.set('ACL', acl, options);
|
|
1062
1032
|
}
|
|
1063
1033
|
|
|
@@ -1066,7 +1036,7 @@ class ParseObject {
|
|
|
1066
1036
|
*
|
|
1067
1037
|
* @param {string} [keys] - specify which fields to revert
|
|
1068
1038
|
*/
|
|
1069
|
-
revert(...keys)
|
|
1039
|
+
revert(...keys) {
|
|
1070
1040
|
let keysToRevert;
|
|
1071
1041
|
if (keys.length) {
|
|
1072
1042
|
keysToRevert = [];
|
|
@@ -1086,7 +1056,7 @@ class ParseObject {
|
|
|
1086
1056
|
*
|
|
1087
1057
|
* @returns {(ParseObject | boolean)}
|
|
1088
1058
|
*/
|
|
1089
|
-
clear()
|
|
1059
|
+
clear() {
|
|
1090
1060
|
const attributes = this.attributes;
|
|
1091
1061
|
const erasable = {};
|
|
1092
1062
|
let readonly = ['createdAt', 'updatedAt'];
|
|
@@ -1120,9 +1090,9 @@ class ParseObject {
|
|
|
1120
1090
|
* @returns {Promise} A promise that is fulfilled when the fetch
|
|
1121
1091
|
* completes.
|
|
1122
1092
|
*/
|
|
1123
|
-
fetch(options
|
|
1093
|
+
fetch(options) {
|
|
1124
1094
|
options = options || {};
|
|
1125
|
-
const fetchOptions
|
|
1095
|
+
const fetchOptions = {};
|
|
1126
1096
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1127
1097
|
fetchOptions.useMasterKey = options.useMasterKey;
|
|
1128
1098
|
}
|
|
@@ -1168,7 +1138,7 @@ class ParseObject {
|
|
|
1168
1138
|
* @returns {Promise} A promise that is fulfilled when the fetch
|
|
1169
1139
|
* completes.
|
|
1170
1140
|
*/
|
|
1171
|
-
fetchWithInclude(keys
|
|
1141
|
+
fetchWithInclude(keys, options) {
|
|
1172
1142
|
options = options || {};
|
|
1173
1143
|
options.include = keys;
|
|
1174
1144
|
return this.fetch(options);
|
|
@@ -1198,7 +1168,7 @@ class ParseObject {
|
|
|
1198
1168
|
* @returns {Promise} A promise that is fulfilled when the save
|
|
1199
1169
|
* completes.
|
|
1200
1170
|
*/
|
|
1201
|
-
async saveEventually(options
|
|
1171
|
+
async saveEventually(options) {
|
|
1202
1172
|
try {
|
|
1203
1173
|
await this.save(null, options);
|
|
1204
1174
|
} catch (e) {
|
|
@@ -1273,7 +1243,7 @@ class ParseObject {
|
|
|
1273
1243
|
* @returns {Promise} A promise that is fulfilled when the save
|
|
1274
1244
|
* completes.
|
|
1275
1245
|
*/
|
|
1276
|
-
save(arg1
|
|
1246
|
+
save(arg1, arg2, arg3) {
|
|
1277
1247
|
let attrs;
|
|
1278
1248
|
let options;
|
|
1279
1249
|
if (typeof arg1 === 'object' || typeof arg1 === 'undefined') {
|
|
@@ -1297,7 +1267,7 @@ class ParseObject {
|
|
|
1297
1267
|
return Promise.reject(validationError);
|
|
1298
1268
|
}
|
|
1299
1269
|
}
|
|
1300
|
-
const saveOptions
|
|
1270
|
+
const saveOptions = {};
|
|
1301
1271
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1302
1272
|
saveOptions.useMasterKey = !!options.useMasterKey;
|
|
1303
1273
|
}
|
|
@@ -1339,7 +1309,7 @@ class ParseObject {
|
|
|
1339
1309
|
* @returns {Promise} A promise that is fulfilled when the destroy
|
|
1340
1310
|
* completes.
|
|
1341
1311
|
*/
|
|
1342
|
-
async destroyEventually(options
|
|
1312
|
+
async destroyEventually(options) {
|
|
1343
1313
|
try {
|
|
1344
1314
|
await this.destroy(options);
|
|
1345
1315
|
} catch (e) {
|
|
@@ -1365,9 +1335,9 @@ class ParseObject {
|
|
|
1365
1335
|
* @returns {Promise} A promise that is fulfilled when the destroy
|
|
1366
1336
|
* completes.
|
|
1367
1337
|
*/
|
|
1368
|
-
destroy(options
|
|
1338
|
+
destroy(options) {
|
|
1369
1339
|
options = options || {};
|
|
1370
|
-
const destroyOptions
|
|
1340
|
+
const destroyOptions = {};
|
|
1371
1341
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1372
1342
|
destroyOptions.useMasterKey = options.useMasterKey;
|
|
1373
1343
|
}
|
|
@@ -1399,7 +1369,7 @@ class ParseObject {
|
|
|
1399
1369
|
*
|
|
1400
1370
|
* @returns {Promise} A promise that is fulfilled when the pin completes.
|
|
1401
1371
|
*/
|
|
1402
|
-
pin()
|
|
1372
|
+
pin() {
|
|
1403
1373
|
return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
|
|
1404
1374
|
}
|
|
1405
1375
|
|
|
@@ -1413,7 +1383,7 @@ class ParseObject {
|
|
|
1413
1383
|
*
|
|
1414
1384
|
* @returns {Promise} A promise that is fulfilled when the unPin completes.
|
|
1415
1385
|
*/
|
|
1416
|
-
unPin()
|
|
1386
|
+
unPin() {
|
|
1417
1387
|
return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
|
|
1418
1388
|
}
|
|
1419
1389
|
|
|
@@ -1426,7 +1396,7 @@ class ParseObject {
|
|
|
1426
1396
|
*
|
|
1427
1397
|
* @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
|
|
1428
1398
|
*/
|
|
1429
|
-
async isPinned()
|
|
1399
|
+
async isPinned() {
|
|
1430
1400
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
1431
1401
|
if (!localDatastore.isEnabled) {
|
|
1432
1402
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -1452,7 +1422,7 @@ class ParseObject {
|
|
|
1452
1422
|
* @param {string} name Name of Pin.
|
|
1453
1423
|
* @returns {Promise} A promise that is fulfilled when the pin completes.
|
|
1454
1424
|
*/
|
|
1455
|
-
pinWithName(name
|
|
1425
|
+
pinWithName(name) {
|
|
1456
1426
|
return ParseObject.pinAllWithName(name, [this]);
|
|
1457
1427
|
}
|
|
1458
1428
|
|
|
@@ -1466,7 +1436,7 @@ class ParseObject {
|
|
|
1466
1436
|
* @param {string} name Name of Pin.
|
|
1467
1437
|
* @returns {Promise} A promise that is fulfilled when the unPin completes.
|
|
1468
1438
|
*/
|
|
1469
|
-
unPinWithName(name
|
|
1439
|
+
unPinWithName(name) {
|
|
1470
1440
|
return ParseObject.unPinAllWithName(name, [this]);
|
|
1471
1441
|
}
|
|
1472
1442
|
|
|
@@ -1482,7 +1452,7 @@ class ParseObject {
|
|
|
1482
1452
|
*
|
|
1483
1453
|
* @returns {Promise} A promise that is fulfilled when the fetch completes.
|
|
1484
1454
|
*/
|
|
1485
|
-
async fetchFromLocalDatastore()
|
|
1455
|
+
async fetchFromLocalDatastore() {
|
|
1486
1456
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
1487
1457
|
if (!localDatastore.isEnabled) {
|
|
1488
1458
|
throw new Error('Parse.enableLocalDatastore() must be called first');
|
|
@@ -1530,8 +1500,8 @@ class ParseObject {
|
|
|
1530
1500
|
* @static
|
|
1531
1501
|
* @returns {Parse.Object[]}
|
|
1532
1502
|
*/
|
|
1533
|
-
static fetchAll(list
|
|
1534
|
-
const queryOptions
|
|
1503
|
+
static fetchAll(list, options = {}) {
|
|
1504
|
+
const queryOptions = {};
|
|
1535
1505
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1536
1506
|
queryOptions.useMasterKey = options.useMasterKey;
|
|
1537
1507
|
}
|
|
@@ -1573,7 +1543,7 @@ class ParseObject {
|
|
|
1573
1543
|
* @static
|
|
1574
1544
|
* @returns {Parse.Object[]}
|
|
1575
1545
|
*/
|
|
1576
|
-
static fetchAllWithInclude(list
|
|
1546
|
+
static fetchAllWithInclude(list, keys, options) {
|
|
1577
1547
|
options = options || {};
|
|
1578
1548
|
options.include = keys;
|
|
1579
1549
|
return ParseObject.fetchAll(list, options);
|
|
@@ -1609,7 +1579,7 @@ class ParseObject {
|
|
|
1609
1579
|
* @static
|
|
1610
1580
|
* @returns {Parse.Object[]}
|
|
1611
1581
|
*/
|
|
1612
|
-
static fetchAllIfNeededWithInclude(list
|
|
1582
|
+
static fetchAllIfNeededWithInclude(list, keys, options) {
|
|
1613
1583
|
options = options || {};
|
|
1614
1584
|
options.include = keys;
|
|
1615
1585
|
return ParseObject.fetchAllIfNeeded(list, options);
|
|
@@ -1633,9 +1603,9 @@ class ParseObject {
|
|
|
1633
1603
|
* @static
|
|
1634
1604
|
* @returns {Parse.Object[]}
|
|
1635
1605
|
*/
|
|
1636
|
-
static fetchAllIfNeeded(list
|
|
1606
|
+
static fetchAllIfNeeded(list, options) {
|
|
1637
1607
|
options = options || {};
|
|
1638
|
-
const queryOptions
|
|
1608
|
+
const queryOptions = {};
|
|
1639
1609
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1640
1610
|
queryOptions.useMasterKey = options.useMasterKey;
|
|
1641
1611
|
}
|
|
@@ -1647,7 +1617,7 @@ class ParseObject {
|
|
|
1647
1617
|
}
|
|
1648
1618
|
return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
|
|
1649
1619
|
}
|
|
1650
|
-
static handleIncludeOptions(options
|
|
1620
|
+
static handleIncludeOptions(options) {
|
|
1651
1621
|
let include = [];
|
|
1652
1622
|
if (Array.isArray(options.include)) {
|
|
1653
1623
|
options.include.forEach(key => {
|
|
@@ -1709,8 +1679,8 @@ class ParseObject {
|
|
|
1709
1679
|
* @returns {Promise} A promise that is fulfilled when the destroyAll
|
|
1710
1680
|
* completes.
|
|
1711
1681
|
*/
|
|
1712
|
-
static destroyAll(list
|
|
1713
|
-
const destroyOptions
|
|
1682
|
+
static destroyAll(list, options = {}) {
|
|
1683
|
+
const destroyOptions = {};
|
|
1714
1684
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1715
1685
|
destroyOptions.useMasterKey = options.useMasterKey;
|
|
1716
1686
|
}
|
|
@@ -1744,8 +1714,8 @@ class ParseObject {
|
|
|
1744
1714
|
* @static
|
|
1745
1715
|
* @returns {Parse.Object[]}
|
|
1746
1716
|
*/
|
|
1747
|
-
static saveAll(list
|
|
1748
|
-
const saveOptions
|
|
1717
|
+
static saveAll(list, options = {}) {
|
|
1718
|
+
const saveOptions = {};
|
|
1749
1719
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
1750
1720
|
saveOptions.useMasterKey = options.useMasterKey;
|
|
1751
1721
|
}
|
|
@@ -1775,7 +1745,7 @@ class ParseObject {
|
|
|
1775
1745
|
* @static
|
|
1776
1746
|
* @returns {Parse.Object} A Parse.Object reference.
|
|
1777
1747
|
*/
|
|
1778
|
-
static createWithoutData(id
|
|
1748
|
+
static createWithoutData(id) {
|
|
1779
1749
|
const obj = new this();
|
|
1780
1750
|
obj.id = id;
|
|
1781
1751
|
return obj;
|
|
@@ -1791,13 +1761,13 @@ class ParseObject {
|
|
|
1791
1761
|
* @static
|
|
1792
1762
|
* @returns {Parse.Object} A Parse.Object reference
|
|
1793
1763
|
*/
|
|
1794
|
-
static fromJSON(json
|
|
1764
|
+
static fromJSON(json, override, dirty) {
|
|
1795
1765
|
if (!json.className) {
|
|
1796
1766
|
throw new Error('Cannot create an object without a className');
|
|
1797
1767
|
}
|
|
1798
1768
|
const constructor = classMap[json.className];
|
|
1799
1769
|
const o = constructor ? new constructor(json.className) : new ParseObject(json.className);
|
|
1800
|
-
const otherAttributes
|
|
1770
|
+
const otherAttributes = {};
|
|
1801
1771
|
for (const attr in json) {
|
|
1802
1772
|
if (attr !== 'className' && attr !== '__type') {
|
|
1803
1773
|
otherAttributes[attr] = json[attr];
|
|
@@ -1836,7 +1806,7 @@ class ParseObject {
|
|
|
1836
1806
|
* @param {string} className The class name of the subclass
|
|
1837
1807
|
* @param {Function} constructor The subclass
|
|
1838
1808
|
*/
|
|
1839
|
-
static registerSubclass(className
|
|
1809
|
+
static registerSubclass(className, constructor) {
|
|
1840
1810
|
if (typeof className !== 'string') {
|
|
1841
1811
|
throw new TypeError('The first argument must be a valid class name.');
|
|
1842
1812
|
}
|
|
@@ -1857,7 +1827,7 @@ class ParseObject {
|
|
|
1857
1827
|
*
|
|
1858
1828
|
* @param {string} className The class name of the subclass
|
|
1859
1829
|
*/
|
|
1860
|
-
static unregisterSubclass(className
|
|
1830
|
+
static unregisterSubclass(className) {
|
|
1861
1831
|
if (typeof className !== 'string') {
|
|
1862
1832
|
throw new TypeError('The first argument must be a valid class name.');
|
|
1863
1833
|
}
|
|
@@ -1895,13 +1865,13 @@ class ParseObject {
|
|
|
1895
1865
|
* });</pre></p>
|
|
1896
1866
|
*
|
|
1897
1867
|
* @param {string} className The name of the Parse class backing this model.
|
|
1898
|
-
* @param {object} protoProps Instance properties to add to instances of the
|
|
1868
|
+
* @param {object} [protoProps] Instance properties to add to instances of the
|
|
1899
1869
|
* class returned from this method.
|
|
1900
|
-
* @param {object} classProps Class properties to add the class returned from
|
|
1870
|
+
* @param {object} [classProps] Class properties to add the class returned from
|
|
1901
1871
|
* this method.
|
|
1902
1872
|
* @returns {Parse.Object} A new subclass of Parse.Object.
|
|
1903
1873
|
*/
|
|
1904
|
-
static extend(className
|
|
1874
|
+
static extend(className, protoProps, classProps) {
|
|
1905
1875
|
if (typeof className !== 'string') {
|
|
1906
1876
|
if (className && typeof className.className === 'string') {
|
|
1907
1877
|
return ParseObject.extend(className.className, className, protoProps);
|
|
@@ -2037,7 +2007,7 @@ class ParseObject {
|
|
|
2037
2007
|
* @returns {Promise} A promise that is fulfilled when the pin completes.
|
|
2038
2008
|
* @static
|
|
2039
2009
|
*/
|
|
2040
|
-
static pinAll(objects
|
|
2010
|
+
static pinAll(objects) {
|
|
2041
2011
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2042
2012
|
if (!localDatastore.isEnabled) {
|
|
2043
2013
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -2063,7 +2033,7 @@ class ParseObject {
|
|
|
2063
2033
|
* @returns {Promise} A promise that is fulfilled when the pin completes.
|
|
2064
2034
|
* @static
|
|
2065
2035
|
*/
|
|
2066
|
-
static pinAllWithName(name
|
|
2036
|
+
static pinAllWithName(name, objects) {
|
|
2067
2037
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2068
2038
|
if (!localDatastore.isEnabled) {
|
|
2069
2039
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -2083,7 +2053,7 @@ class ParseObject {
|
|
|
2083
2053
|
* @returns {Promise} A promise that is fulfilled when the unPin completes.
|
|
2084
2054
|
* @static
|
|
2085
2055
|
*/
|
|
2086
|
-
static unPinAll(objects
|
|
2056
|
+
static unPinAll(objects) {
|
|
2087
2057
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2088
2058
|
if (!localDatastore.isEnabled) {
|
|
2089
2059
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -2103,7 +2073,7 @@ class ParseObject {
|
|
|
2103
2073
|
* @returns {Promise} A promise that is fulfilled when the unPin completes.
|
|
2104
2074
|
* @static
|
|
2105
2075
|
*/
|
|
2106
|
-
static unPinAllWithName(name
|
|
2076
|
+
static unPinAllWithName(name, objects) {
|
|
2107
2077
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2108
2078
|
if (!localDatastore.isEnabled) {
|
|
2109
2079
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -2121,7 +2091,7 @@ class ParseObject {
|
|
|
2121
2091
|
* @returns {Promise} A promise that is fulfilled when the unPin completes.
|
|
2122
2092
|
* @static
|
|
2123
2093
|
*/
|
|
2124
|
-
static unPinAllObjects()
|
|
2094
|
+
static unPinAllObjects() {
|
|
2125
2095
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2126
2096
|
if (!localDatastore.isEnabled) {
|
|
2127
2097
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -2141,7 +2111,7 @@ class ParseObject {
|
|
|
2141
2111
|
* @returns {Promise} A promise that is fulfilled when the unPin completes.
|
|
2142
2112
|
* @static
|
|
2143
2113
|
*/
|
|
2144
|
-
static unPinAllObjectsWithName(name
|
|
2114
|
+
static unPinAllObjectsWithName(name) {
|
|
2145
2115
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2146
2116
|
if (!localDatastore.isEnabled) {
|
|
2147
2117
|
return Promise.reject('Parse.enableLocalDatastore() must be called first');
|
|
@@ -2150,17 +2120,17 @@ class ParseObject {
|
|
|
2150
2120
|
}
|
|
2151
2121
|
}
|
|
2152
2122
|
const DefaultController = {
|
|
2153
|
-
fetch(target
|
|
2123
|
+
fetch(target, forceFetch, options) {
|
|
2154
2124
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2155
2125
|
if (Array.isArray(target)) {
|
|
2156
2126
|
if (target.length < 1) {
|
|
2157
2127
|
return Promise.resolve([]);
|
|
2158
2128
|
}
|
|
2159
|
-
const objs
|
|
2160
|
-
const ids
|
|
2161
|
-
let className
|
|
2162
|
-
const results
|
|
2163
|
-
let error
|
|
2129
|
+
const objs = [];
|
|
2130
|
+
const ids = [];
|
|
2131
|
+
let className = null;
|
|
2132
|
+
const results = [];
|
|
2133
|
+
let error = null;
|
|
2164
2134
|
target.forEach(el => {
|
|
2165
2135
|
if (error) {
|
|
2166
2136
|
return;
|
|
@@ -2224,7 +2194,7 @@ const DefaultController = {
|
|
|
2224
2194
|
return Promise.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
|
|
2225
2195
|
}
|
|
2226
2196
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2227
|
-
const params
|
|
2197
|
+
const params = {};
|
|
2228
2198
|
if (options && options.include) {
|
|
2229
2199
|
params.include = options.include.join();
|
|
2230
2200
|
}
|
|
@@ -2238,7 +2208,7 @@ const DefaultController = {
|
|
|
2238
2208
|
}
|
|
2239
2209
|
return Promise.resolve(undefined);
|
|
2240
2210
|
},
|
|
2241
|
-
async destroy(target
|
|
2211
|
+
async destroy(target, options) {
|
|
2242
2212
|
const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2243
2213
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2244
2214
|
const RESTController = _CoreManager.default.getRESTController();
|
|
@@ -2302,7 +2272,7 @@ const DefaultController = {
|
|
|
2302
2272
|
}
|
|
2303
2273
|
return Promise.resolve(target);
|
|
2304
2274
|
},
|
|
2305
|
-
save(target
|
|
2275
|
+
save(target, options) {
|
|
2306
2276
|
const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2307
2277
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2308
2278
|
const mapIdForPin = {};
|
|
@@ -2323,8 +2293,8 @@ const DefaultController = {
|
|
|
2323
2293
|
}
|
|
2324
2294
|
}
|
|
2325
2295
|
unsaved = (0, _unique.default)(unsaved);
|
|
2326
|
-
const filesSaved
|
|
2327
|
-
let pending
|
|
2296
|
+
const filesSaved = [];
|
|
2297
|
+
let pending = [];
|
|
2328
2298
|
unsaved.forEach(el => {
|
|
2329
2299
|
if (el instanceof _ParseFile.default) {
|
|
2330
2300
|
filesSaved.push(el.save(options));
|
|
@@ -2357,8 +2327,8 @@ const DefaultController = {
|
|
|
2357
2327
|
// Queue up tasks for each object in the batch.
|
|
2358
2328
|
// When every task is ready, the API request will execute
|
|
2359
2329
|
const batchReturned = (0, _promiseUtils.resolvingPromise)();
|
|
2360
|
-
const batchReady
|
|
2361
|
-
const batchTasks
|
|
2330
|
+
const batchReady = [];
|
|
2331
|
+
const batchTasks = [];
|
|
2362
2332
|
batch.forEach((obj, index) => {
|
|
2363
2333
|
const ready = (0, _promiseUtils.resolvingPromise)();
|
|
2364
2334
|
batchReady.push(ready);
|
|
@@ -2420,7 +2390,7 @@ const DefaultController = {
|
|
|
2420
2390
|
// generate _localId in case if cascadeSave=false
|
|
2421
2391
|
target._getId();
|
|
2422
2392
|
const localId = target._localId;
|
|
2423
|
-
// copying target lets
|
|
2393
|
+
// copying target lets guarantee the pointer isn't modified elsewhere
|
|
2424
2394
|
const targetCopy = target;
|
|
2425
2395
|
const task = function () {
|
|
2426
2396
|
const params = targetCopy._getSaveParams();
|
|
@@ -2449,5 +2419,4 @@ const DefaultController = {
|
|
|
2449
2419
|
};
|
|
2450
2420
|
_CoreManager.default.setParseObject(ParseObject);
|
|
2451
2421
|
_CoreManager.default.setObjectController(DefaultController);
|
|
2452
|
-
var _default = ParseObject;
|
|
2453
|
-
exports.default = _default;
|
|
2422
|
+
var _default = exports.default = ParseObject;
|