mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 15:24:18 +00:00
Fix the Permissions typescript definitions
This commit is contained in:
parent
fadd35bb26
commit
d1a4e899d8
69
lib/index.d.ts
vendored
69
lib/index.d.ts
vendored
@ -81,7 +81,7 @@ declare namespace Realm {
|
|||||||
path?: string;
|
path?: string;
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
inMemory?: boolean;
|
inMemory?: boolean;
|
||||||
schema?: ObjectClass[] | ObjectSchema[];
|
schema?: (ObjectClass | ObjectSchema)[];
|
||||||
schemaVersion?: number;
|
schemaVersion?: number;
|
||||||
sync?: Realm.Sync.SyncConfiguration;
|
sync?: Realm.Sync.SyncConfiguration;
|
||||||
deleteRealmIfMigrationNeeded?: boolean;
|
deleteRealmIfMigrationNeeded?: boolean;
|
||||||
@ -483,6 +483,42 @@ declare namespace Realm.Sync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare namespace Realm.Permissions {
|
||||||
|
class Permission {
|
||||||
|
static schema: ObjectSchema;
|
||||||
|
|
||||||
|
identity: string;
|
||||||
|
canRead: boolean;
|
||||||
|
canUpdate: boolean;
|
||||||
|
canDelete: boolean;
|
||||||
|
canSetPermissions: boolean;
|
||||||
|
canQuery: boolean;
|
||||||
|
canCreate: boolean;
|
||||||
|
canModifySchema: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
class User {
|
||||||
|
static schema: ObjectSchema;
|
||||||
|
identity: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Role {
|
||||||
|
static schema: ObjectSchema;
|
||||||
|
name: string;
|
||||||
|
members: User[];
|
||||||
|
}
|
||||||
|
|
||||||
|
class Class {
|
||||||
|
static schema: ObjectSchema;
|
||||||
|
class_name: string;
|
||||||
|
permissions: Permission[];
|
||||||
|
}
|
||||||
|
|
||||||
|
class Realm {
|
||||||
|
static schema: ObjectSchema;
|
||||||
|
permissions: Permission[];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface ProgressPromise extends Promise<Realm> {
|
interface ProgressPromise extends Promise<Realm> {
|
||||||
progress(callback: Realm.Sync.ProgressNotificationCallback): Promise<Realm>
|
progress(callback: Realm.Sync.ProgressNotificationCallback): Promise<Realm>
|
||||||
@ -552,7 +588,7 @@ declare class Realm {
|
|||||||
* @param {boolean} update?
|
* @param {boolean} update?
|
||||||
* @returns T
|
* @returns T
|
||||||
*/
|
*/
|
||||||
create<T>(type: string | Realm.ObjectClass | Function, properties: T & Realm.ObjectPropsType, update?: boolean): T;
|
create<T>(type: string | Realm.ObjectClass | Function, properties: T | Realm.ObjectPropsType, update?: boolean): T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Realm.Object|Realm.Object[]|Realm.List<any>|Realm.Results<any>|any} object
|
* @param {Realm.Object|Realm.Object[]|Realm.List<any>|Realm.Results<any>|any} object
|
||||||
@ -628,33 +664,10 @@ declare class Realm {
|
|||||||
* @returns boolean
|
* @returns boolean
|
||||||
*/
|
*/
|
||||||
compact(): boolean;
|
compact(): boolean;
|
||||||
}
|
|
||||||
|
|
||||||
declare namespace Realm.Permissions {
|
privileges() : Realm.Permissions.Realm;
|
||||||
interface Permission {
|
privileges(objectType: string | Realm.ObjectSchema | Function) : Realm.Permissions.Class;
|
||||||
identity: string;
|
privileges(obj: Realm.Object) : Realm.Permissions.Class;
|
||||||
canRead: boolean;
|
|
||||||
canUpdate: boolean;
|
|
||||||
canDelete: boolean;
|
|
||||||
canSetPermissions: boolean;
|
|
||||||
canQuery: boolean;
|
|
||||||
canCreate: boolean;
|
|
||||||
canModifySchema: boolean;
|
|
||||||
}
|
|
||||||
interface User {
|
|
||||||
identity: string;
|
|
||||||
}
|
|
||||||
interface Role {
|
|
||||||
name: string;
|
|
||||||
members: User[];
|
|
||||||
}
|
|
||||||
interface Class {
|
|
||||||
class_name: string;
|
|
||||||
permissions: Permission[];
|
|
||||||
}
|
|
||||||
interface Realm {
|
|
||||||
permissions: Permission[];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'realm' {
|
declare module 'realm' {
|
||||||
|
@ -147,7 +147,7 @@ module.exports = {
|
|||||||
.then(t => { token = t; return user1.invalidatePermissionOffer(token); })
|
.then(t => { token = t; return user1.invalidatePermissionOffer(token); })
|
||||||
// Since we don't yet support notification when the invalidation has gone through,
|
// Since we don't yet support notification when the invalidation has gone through,
|
||||||
// wait for a bit and hope the server is done processing.
|
// wait for a bit and hope the server is done processing.
|
||||||
.then(wait(100))
|
.then(() => wait(100))
|
||||||
.then(() => user2.acceptPermissionOffer(token))
|
.then(() => user2.acceptPermissionOffer(token))
|
||||||
// We want the call to fail, i.e. the catch() below should be called.
|
// We want the call to fail, i.e. the catch() below should be called.
|
||||||
.then(() => { throw new Error("User was able to accept an invalid permission offer token"); })
|
.then(() => { throw new Error("User was able to accept an invalid permission offer token"); })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user