Skip to content

Commit 4da37da

Browse files
committed
Merge pull request #166 from ParsePlatform/release-1.7.0
Merging 1.7.0 working branch into master
2 parents e76a624 + 26c016d commit 4da37da

29 files changed

+2064
-701
lines changed

src/Cloud.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function run(
4343
name: string,
4444
data: mixed,
4545
options: { [key: string]: mixed }
46-
) {
46+
): ParsePromise {
4747
options = options || {};
4848

4949
if (typeof name !== 'string' || name.length === 0) {

src/CoreManager.js

Lines changed: 123 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* @flow
1010
*/
1111

12-
import type { AttributeMap } from './ObjectState';
12+
import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';
1313
import type { FileSource } from './ParseFile';
14+
import type { Op } from './ParseOp';
1415
import type ParseObject from './ParseObject';
1516
import type ParsePromise from './ParsePromise';
1617
import type { QueryJSON } from './ParseQuery';
@@ -43,6 +44,24 @@ type ObjectController = {
4344
save: (object: ParseObject, options: RequestOptions) => ParsePromise;
4445
destroy: (object: ParseObject, options: RequestOptions) => ParsePromise;
4546
};
47+
type ObjectStateController = {
48+
getState: (obj: any) => ?State;
49+
initializeState: (obj: any, initial?: State) => State;
50+
removeState: (obj: any) => ?State;
51+
getServerData: (obj: any) => AttributeMap;
52+
setServerData: (obj: any, attributes: AttributeMap) => void;
53+
getPendingOps: (obj: any) => Array<OpsMap>;
54+
setPendingOp: (obj: any, attr: string, op: ?Op) => void;
55+
pushPendingState: (obj: any) => void;
56+
popPendingState: (obj: any) => OpsMap;
57+
mergeFirstPendingState: (obj: any) => void;
58+
getObjectCache: (obj: any) => ObjectCache;
59+
estimateAttribute: (obj: any, attr: string) => mixed;
60+
estimateAttributes: (obj: any) => AttributeMap;
61+
commitServerChanges: (obj: any, changes: AttributeMap) => void;
62+
enqueueTask: (obj: any, task: () => ParsePromise) => ParsePromise;
63+
clearAllState: () => void;
64+
};
4665
type PushController = {
4766
send: (data: PushData, options: RequestOptions) => ParsePromise;
4867
};
@@ -64,6 +83,7 @@ type StorageController = {
6483
getItemAsync?: (path: string) => ParsePromise;
6584
setItemAsync?: (path: string, value: string) => ParsePromise;
6685
removeItemAsync?: (path: string) => ParsePromise;
86+
clear: () => void;
6787
} | {
6888
async: 1;
6989
getItem?: (path: string) => ?string;
@@ -72,6 +92,7 @@ type StorageController = {
7292
getItemAsync: (path: string) => ParsePromise;
7393
setItemAsync: (path: string, value: string) => ParsePromise;
7494
removeItemAsync: (path: string) => ParsePromise;
95+
clear: () => void;
7596
};
7697
type UserController = {
7798
setCurrentUser: (user: ParseUser) => ParsePromise;
@@ -82,6 +103,7 @@ type UserController = {
82103
become: (options: RequestOptions) => ParsePromise;
83104
logOut: () => ParsePromise;
84105
requestPasswordReset: (email: string, options: RequestOptions) => ParsePromise;
106+
updateUserOnDisk: (user: ParseUser) => ParsePromise;
85107
upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => ParsePromise;
86108
linkWith: (user: ParseUser, authData: AuthData) => ParsePromise;
87109
};
@@ -179,17 +201,6 @@ module.exports = {
179201
return config['InstallationController'];
180202
},
181203

182-
setPushController(controller: PushController) {
183-
if (typeof controller.send !== 'function') {
184-
throw new Error('PushController must implement send()');
185-
}
186-
config['PushController'] = controller;
187-
},
188-
189-
getPushController(): PushController {
190-
return config['PushController'];
191-
},
192-
193204
setObjectController(controller: ObjectController) {
194205
if (typeof controller.save !== 'function') {
195206
throw new Error('ObjectController must implement save()');
@@ -207,6 +218,106 @@ module.exports = {
207218
return config['ObjectController'];
208219
},
209220

221+
setObjectStateController(controller: ObjectStateController) {
222+
if (typeof controller.getState !== 'function') {
223+
throw new Error(
224+
'ObjectStateController must implement getState()'
225+
);
226+
}
227+
if (typeof controller.initializeState !== 'function') {
228+
throw new Error(
229+
'ObjectStateController must implement initializeState()'
230+
);
231+
}
232+
if (typeof controller.removeState !== 'function') {
233+
throw new Error(
234+
'ObjectStateController must implement removeState()'
235+
);
236+
}
237+
if (typeof controller.getServerData !== 'function') {
238+
throw new Error(
239+
'ObjectStateController must implement getServerData()'
240+
);
241+
}
242+
if (typeof controller.setServerData !== 'function') {
243+
throw new Error(
244+
'ObjectStateController must implement setServerData()'
245+
);
246+
}
247+
if (typeof controller.getPendingOps !== 'function') {
248+
throw new Error(
249+
'ObjectStateController must implement getPendingOps()'
250+
);
251+
}
252+
if (typeof controller.setPendingOp !== 'function') {
253+
throw new Error(
254+
'ObjectStateController must implement setPendingOp()'
255+
);
256+
}
257+
if (typeof controller.pushPendingState !== 'function') {
258+
throw new Error(
259+
'ObjectStateController must implement pushPendingState()'
260+
);
261+
}
262+
if (typeof controller.popPendingState !== 'function') {
263+
throw new Error(
264+
'ObjectStateController must implement popPendingState()'
265+
);
266+
}
267+
if (typeof controller.mergeFirstPendingState !== 'function') {
268+
throw new Error(
269+
'ObjectStateController must implement mergeFirstPendingState()'
270+
);
271+
}
272+
if (typeof controller.getObjectCache !== 'function') {
273+
throw new Error(
274+
'ObjectStateController must implement getObjectCache()'
275+
);
276+
}
277+
if (typeof controller.estimateAttribute !== 'function') {
278+
throw new Error(
279+
'ObjectStateController must implement estimateAttribute()'
280+
);
281+
}
282+
if (typeof controller.estimateAttributes !== 'function') {
283+
throw new Error(
284+
'ObjectStateController must implement estimateAttributes()'
285+
);
286+
}
287+
if (typeof controller.commitServerChanges !== 'function') {
288+
throw new Error(
289+
'ObjectStateController must implement commitServerChanges()'
290+
);
291+
}
292+
if (typeof controller.enqueueTask !== 'function') {
293+
throw new Error(
294+
'ObjectStateController must implement enqueueTask()'
295+
);
296+
}
297+
if (typeof controller.clearAllState !== 'function') {
298+
throw new Error(
299+
'ObjectStateController must implement clearAllState()'
300+
);
301+
}
302+
303+
config['ObjectStateController'] = controller;
304+
},
305+
306+
getObjectStateController(): ObjectStateController {
307+
return config['ObjectStateController'];
308+
},
309+
310+
setPushController(controller: PushController) {
311+
if (typeof controller.send !== 'function') {
312+
throw new Error('PushController must implement send()');
313+
}
314+
config['PushController'] = controller;
315+
},
316+
317+
getPushController(): PushController {
318+
return config['PushController'];
319+
},
320+
210321
setQueryController(controller: QueryController) {
211322
if (typeof controller.find !== 'function') {
212323
throw new Error('QueryController must implement find()');

0 commit comments

Comments
 (0)