Live query CLP (#4387)

* Auth module refactoring in order to be reusable

* Ensure cache controller is properly forwarded from helpers

* Nits

* Adds support for static validation

* Adds support for CLP in Live query (no support for roles yet)

* Adds e2e test to validate liveQuery hooks is properly called

* Adds tests over LiveQueryController to ensure data is correctly transmitted

* nits

* Fixes for flow types

* Removes usage of Parse.Promise

* Use the Auth module for authentication and caches

* Cleaner implementation of getting auth

* Adds authCache that stores auth promises

* Proper testing of the caching

* nits
This commit is contained in:
Florent Vilmart
2018-10-17 17:53:49 -04:00
committed by GitHub
parent 17bd5c3adb
commit 7c81290252
12 changed files with 829 additions and 237 deletions

View File

@@ -16,19 +16,37 @@ export class LiveQueryController {
this.liveQueryPublisher = new ParseCloudCodePublisher(config);
}
onAfterSave(className: string, currentObject: any, originalObject: any) {
onAfterSave(
className: string,
currentObject: any,
originalObject: any,
classLevelPermissions: ?any
) {
if (!this.hasLiveQuery(className)) {
return;
}
const req = this._makePublisherRequest(currentObject, originalObject);
const req = this._makePublisherRequest(
currentObject,
originalObject,
classLevelPermissions
);
this.liveQueryPublisher.onCloudCodeAfterSave(req);
}
onAfterDelete(className: string, currentObject: any, originalObject: any) {
onAfterDelete(
className: string,
currentObject: any,
originalObject: any,
classLevelPermissions: any
) {
if (!this.hasLiveQuery(className)) {
return;
}
const req = this._makePublisherRequest(currentObject, originalObject);
const req = this._makePublisherRequest(
currentObject,
originalObject,
classLevelPermissions
);
this.liveQueryPublisher.onCloudCodeAfterDelete(req);
}
@@ -36,13 +54,20 @@ export class LiveQueryController {
return this.classNames.has(className);
}
_makePublisherRequest(currentObject: any, originalObject: any): any {
_makePublisherRequest(
currentObject: any,
originalObject: any,
classLevelPermissions: ?any
): any {
const req = {
object: currentObject,
};
if (currentObject) {
req.original = originalObject;
}
if (classLevelPermissions) {
req.classLevelPermissions = classLevelPermissions;
}
return req;
}
}