diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b8d2b60..5fc09464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/realm.js b/docs/realm.js index 4c959690..7d232aba 100644 --- a/docs/realm.js +++ b/docs/realm.js @@ -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) {} diff --git a/lib/index.d.ts b/lib/index.d.ts index 55e0b86d..ff728a7a 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -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 { @@ -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' {