import type { Space, SpaceEntity } from "./SpaceService"; import type { Team, TeamEntity } from "./TeamService"; import { K8sCluster, K8sClusterEntity } from "./K8sCluster"; export declare enum Roles { Admin = "Admin", Owner = "Owner", Member = "Member", None = "None" } /** * Space Actions */ export declare enum Actions { DeleteSpace = 0, PatchSpace = 1, RenameSpace = 2, CreateInvitation = 3, PatchInvitation = 4, RevokeInvitation = 5, AddInvitationDomain = 6, DeleteInvitationDomain = 7, CreateTeam = 8, DeleteTeam = 9, PatchTeam = 10, GetBillingPageToken = 11, ChangeSpacePlan = 12 } export declare enum K8sClusterActions { AccessK8sCluster = 0, PatchK8sCluster = 1, DeleteK8sCluster = 2 } export declare enum TeamActions { AddUser = 0, RemoveUser = 1 } type RevokeInvitation = { invitationId: string; invitationIdsCreatedByUserId: string[]; }; export declare class Permissions { /** * Clarifies whether a given user can perform an action in a given space. * @param action - `Actions` enum value * @param forSpace - Space object that must contain `{ teams: Team[] }` * @param forUserId - string userId * @param forRevokeInvitation - Additional information to determine if a user can revoke invitation * @returns boolean * @throws "Could not get role for space with no teams" exception */ canSpace(action: Actions, forSpace: Space | SpaceEntity, forUserId: string, forRevokeInvitation?: RevokeInvitation): boolean; /** * Clarifies whether a given user can execute the specified Team action * @param action - 'TeamActions' enum value * @param space - Space object that must contain `{ teams: Team[] }` * @param team - Team object * @param forUserId - User that is executing the action * @param targetUserId - User that is the target of the exection, e.g. user to be removed * @returns */ canTeam(action: TeamActions, space: Space | SpaceEntity, team: Team | TeamEntity, forUserId: string, targetUserId?: string): boolean; /** * Clarifies whether a given user can perform an action for a given K8sCluster. * @param action - `Actions` enum value * @param forSpace - Space object that must contain `{ teams: Team[] }` * @param forK8sCluster - K8sCluster * @param forUserId - string userId * @returns boolean * @throws "Could not get role for space with no teams" exception */ canK8sCluster(action: K8sClusterActions, forSpace: Space | SpaceEntity, forK8sCluster: K8sCluster | K8sClusterEntity, forUserId: string): boolean; /** * DEPRECATED. WILL BE REMOVED. * Clarifies whether a given user can perform an action in a given space. * @param action - `Actions` enum value * @param forSpace - Space object that must contain `{ teams: Team[] }` * @param forUserId - string userId * @returns boolean * @throws "Could not get role for space with no teams" exception * @deprecated Use .canSpace instead. */ canI(action: Actions, forSpace: Space | SpaceEntity, forUserId: string): boolean; /** * Gets a role the user with specified user Id has in specified `space`. * @param space - Space object that must contain `{ teams: Team[] }` * @param forUserId - string userId * @returns Role enum value * @throws "Could not get role for space with no teams" exception */ getRole(space: Space | SpaceEntity, forUserId: string): Roles; protected getOwnerTeams: (space: Space | SpaceEntity) => Team[]; protected getAdminTeams: (space: Space | SpaceEntity) => Team[]; protected getNormalTeams: (space: Space | SpaceEntity) => Team[]; protected isUserInTeam: (team: Team | TeamEntity, userId: string) => boolean; protected canPatchOrRevokeInvitation: (forRevokeInvitation: RevokeInvitation | undefined, role: Roles) => boolean; } export {};