Fix typescript definitions for privileges() methods (#2030)

This commit is contained in:
Christian Melchior 2018-09-19 13:16:26 +02:00 committed by GitHub
parent 37d04c4df2
commit 79759dce29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 9 deletions

View File

@ -1,7 +1,9 @@
X.Y.Z Release notes
=============================================================
### Bug fixes
* Fixed the type definition for `Realm.Permissions.User`. Thanks to @apperside! ([#2012](https://github.com/realm/realm-js/issues/2012), since v2.3.0-beta.2)
* Fixed the type definition for `Realm.getPrivileges()`, `Realm.getPrivileges(className)` and `Realm.getPrivileges(object)`. ([#2030](https://github.com/realm/realm-js/pull/2030), since v2.2.14)
### Compatibility
* Realm Object Server: 3.0.0 or later

View File

@ -153,7 +153,7 @@ class Realm {
close() {}
/**
* Returns the granted privilges.
* Returns the granted privileges.
*
* This combines all privileges granted on the Realm/Class/Object by all Roles which
* the current User is a member of into the final privileges which will
@ -166,10 +166,11 @@ class Realm {
*
* Non-synchronized Realms always have permission to perform all operations.
*
* @param {(Realm~ObjectType|Realm.Object)} arg - the object type or the object to compute priviliges from
* @returns {Object} as the computed priviliges as properties
* @param {(Realm~ObjectType|Realm.Object)} arg - the object type or the object to compute privileges from. If no
* argument is given, the privileges for the Realm is returned.
* @returns {Object} as the computed privileges as properties
* @since 2.3.0
* @see {Realm.Permissions} for details of priviliges and roles.
* @see {Realm.Permissions} for details of privileges and roles.
*/
privileges(arg) {}

33
lib/index.d.ts vendored
View File

@ -580,13 +580,13 @@ declare namespace Realm.Permissions {
static schema: ObjectSchema;
identity: string;
canCreate: boolean;
canRead: boolean;
canUpdate: boolean;
canDelete: boolean;
canSetPermissions: boolean;
canQuery: boolean;
canCreate: boolean;
canModifySchema: boolean;
canSetPermissions: boolean;
}
class User {
@ -610,6 +610,29 @@ declare namespace Realm.Permissions {
static schema: ObjectSchema;
permissions: Permission[];
}
class RealmPrivileges {
canRead: boolean;
canUpdate: boolean;
canModifySchema: boolean;
canSetPermissions: boolean;
}
class ClassPrivileges {
canCreate: boolean
canRead: boolean;
canUpdate: boolean;
canQuery: boolean;
canModifySchema: boolean;
canSetPermissions: boolean;
}
class ObjectPrivileges {
canRead: boolean;
canUpdate: boolean;
canDelete: boolean;
canSetPermissions: boolean;
}
}
interface ProgressPromise extends Promise<Realm> {
@ -778,9 +801,9 @@ declare class Realm {
*/
writeCopyTo(path: string, encryptionKey?: ArrayBuffer | ArrayBufferView): void;
privileges() : Realm.Permissions.Realm;
privileges(objectType: string | Realm.ObjectSchema | Function) : Realm.Permissions.Class;
privileges(obj: Realm.Object) : Realm.Permissions.Class;
privileges() : Realm.Permissions.RealmPrivileges;
privileges(objectType: string | Realm.ObjectSchema | Function) : Realm.Permissions.ClassPrivileges;
privileges(obj: Realm.Object) : Realm.Permissions.ObjectPrivileges;
}
declare module 'realm' {