export declare const Kind = "Core#Permission";
export type PermissionType = 'user' | 'group' | 'organization';
/**
 * - `owner`: Full control over the item.
 * - `writer`: Can view, comment, and edit the item.
 * - `commenter`: Can view and comment on the item.
 * - `reader`: Can only view the item.
 */
export type PermissionRole = 'owner' | 'reader' | 'commenter' | 'writer';
/**
 * A predefined set of rules that can be used to determine the source of the permission.
 * - `direct_user_grant`: The permission is granted directly to the user.
 * - `creator_default_owner`: The permission is granted to the creator of the item as the default owner.
 * - `parent_owner_editor_rule`: The object is placed in a folder and the owner of the folder
 *                               has automatically granted role to the object.
 */
export type PermissionSourceRule = 'direct_user_grant' | 'creator_default_owner' | 'parent_owner_editor_rule';
interface IBasePermission {
    /**
     * The type of the permission.
     *
     * - `user` can access the file by a specific user
     * - `group` can access the file by a group of users
     * - `organization` the object can be searched by anyone within the organization.
     */
    type: PermissionType;
    /**
     * It represents the ID of the entity (user, group,or organization)
     * that is being granted the permission on a file or folder.
     */
    granteeId: string;
    /**
     * The store id of the entity that is being granted the permission.
     */
    itemId: string;
    /**
     * The role granted by this permission.
     */
    role: PermissionRole;
    /**
     * The "pretty" name to render with the permission.
     *
     * - `user` type - user's full name
     * - `group` type - the name of the group
     * - `organization` type - no render name
     */
    displayName?: string;
    /**
     * Optional expiration date of the permission. This is the timestamp when the permission expires.
     * When creating / updating the permission the expiration date must:
     *
     * - be used on a user or a group
     * - the time must be in the future
     */
    expirationTime?: number;
    /**
     * The store id of the user that added this permission.
     */
    addingUser: string;
    /**
     * The depth of the permission in the hierarchy.
     * When `0` it means that the permissions do not use inheritance.
     * When `1` it means the permission is set on the item itself.
     * When `2` it means the permission is set on the parent item.
     * When `3` it means the permission is set on the grandparent item, and so on.
     * This is used to determine the depth of the permission in the hierarchy.
     */
    depth: number;
    /**
     * The source rule of the permission.
     * This is used to determine how the permission was granted.
     */
    sourceRule: PermissionSourceRule;
}
/**
 * A schema describing a permission to a store object.
 */
export interface IPermission extends IBasePermission {
    kind: typeof Kind;
    /**
     * The data store key of the permission.
     * This property is generated by the store and is not writable.
     */
    key: string;
}
export declare class Permission {
    kind: string;
    /**
     * The data store key of the permission.
     * This property is generated by the store and is not writable.
     */
    key: string;
    /**
     * The type of the permission.
     *
     * - `user` can access the file by a specific user
     * - `group` can access the file by a group of users
     * - - `organization` the object can be searched by anyone within the organization.
     */
    type: PermissionType;
    /**
     * It represents the ID of the entity (user, group, or organization)
     * that is being granted the permission on a file or folder.
     */
    granteeId: string;
    /**
     * The role granted by this permission.
     */
    role: PermissionRole;
    /**
     * The "pretty" name to render with the permission.
     *
     * - `user` type - user's full name
     * - `group` type - the name of the group
     * - `organization` type - the organization name.
     */
    displayName?: string;
    /**
     * Optional expiration date of the permission. This is the timestamp when the permission expires.
     * When creating / updating the permission the expiration date must:
     *
     * - be used on a user or a group
     * - the time must be in the future
     */
    expirationTime?: number;
    /**
     * The store id of the user that added this permission.
     */
    addingUser: string;
    /**
     * The store id of the entity that is being granted the permission.
     */
    itemId: string;
    /**
     * The depth of the permission in the hierarchy.
     * When `0` it means that the permissions do not use inheritance.
     * When `1` it means the permission is set on the item itself.
     * When `2` it means the permission is set on the parent item.
     * When `3` it means the permission is set on the grandparent item, and so on.
     * This is used to determine the depth of the permission in the hierarchy.
     */
    depth: number;
    /**
     * The source rule of the permission.
     * This is used to determine how the permission was granted.
     */
    sourceRule: PermissionSourceRule;
    /**
     * Creates a Permission object for a user.
     *
     * @param role The user role to set.
     * @param itemId The store id of the entity that is being granted the permission.
     * @param user The user id that has the role.
     * @param addingUser The key of the user that created this permission
     */
    static fromUserRole(role: PermissionRole, itemId: string, user: string, addingUser: string): Permission;
    /**
     * Creates a Permission object for a group.
     *
     * @param role The group role to set.
     * @param itemId The store id of the entity that is being granted the permission.
     * @param group The group id that has the role.
     * @param addingUser The key of the user that created this permission
     */
    static fromGroupRole(role: PermissionRole, itemId: string, group: string, addingUser: string): Permission;
    /**
     * Creates a Permission object for a group.
     *
     * @param role The group role to set.
     * @param itemId The store id of the entity that is being granted the permission.
     * @param addingUser The key of the user that created this permission
     */
    static fromOrganizationRole(role: PermissionRole, itemId: string, organizationId: string, addingUser: string): Permission;
    /**
     * Creates a permission object from other than key and kind values.
     */
    static fromValues(init: IBasePermission): Permission;
    constructor(input?: string | IPermission);
    new(init: IPermission): void;
    static isPermission(input: unknown): boolean;
    /**
     * Checks whether the current user role meets the minimum required role.
     *
     * @param minimumLevel The minimum requested role
     * @param currentRole The user role. When not set it always returns false.
     * @returns True if the `currentRole` is at least the `minimumRole`
     */
    static hasRole(minimumLevel: PermissionRole, currentRole?: PermissionRole): boolean;
    /**
     * Checks if role1 is higher than role2 in the permission hierarchy.
     *
     * @param role1 The first role to compare.
     * @param role2 The second role to compare.
     * @returns `true` if `role1` is higher than `role2`, `false` otherwise.
     */
    static isHigherRole(role1: PermissionRole, role2: PermissionRole): boolean;
    /**
     * Link to the `Permission.hasRole(minimumLevel, currentRole)`.
     * @see {@link Permission.hasRole}
     */
    hasRole(minimumLevel: PermissionRole): boolean;
    /**
     * Checks if the user has the required role in the list of permissions.
     * The permissions list must be filtered for the user, user's organization, and user's groups.
     *
     * @param minimumLevel The minimum requested role
     * @param permissions The list of permissions to check.
     * @returns True if the user has the required role.
     */
    static hasRoleIn(minimumLevel: PermissionRole, permissions: IPermission[]): boolean;
    toJSON(): IPermission;
}
/**
 * This is used in the communication with the backend to add/change user's access to the resource.
 */
export interface IAccessOperation {
    /**
     * The user, group, or organization id that this permission affects.
     */
    id: string;
    /**
     * The permission type: user, group, or organization
     */
    type: PermissionType;
}
interface IUpdatingOperation {
    /**
     * The level that the user or the group has access to:
     * - owner
     * - reader
     * - commenter
     * - writer
     */
    value: PermissionRole;
    /**
     * The timestamp when the permission expires.
     */
    expirationTime?: number;
}
export interface IAccessAddOperation extends IAccessOperation, IUpdatingOperation {
    op: 'add';
}
export interface IAccessRemoveOperation extends IAccessOperation {
    op: 'remove';
}
export interface IAccessUpdateOperation extends IAccessOperation, IUpdatingOperation {
    op: 'update';
    /**
     * The ID of the permission to update.
     */
    id: string;
}
export type AccessOperation = IAccessAddOperation | IAccessRemoveOperation | IAccessUpdateOperation;
export {};
//# sourceMappingURL=Permission.d.ts.map