You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

55 lines
1.3 KiB

/**
* Represents user roles within the application, each with specific permissions :
*
* - `ADMIN`: Full permissions to all resources, including the app, database, etc
* - `EDITOR`: Granted write and read permissions on their own resources as well as
* `CLIENT` resources, but without `ADMIN` privileges
* - `CLIENT`: Granted write and read permissions only on their own resources.
*/
export type ROLE = 'ADMIN' | 'EDITOR' | 'CLIENT';
/**
* Representing a user data structure.
*/
export type User = {
id: string;
role: ROLE;
username: string;
password: string;
name?: string;
address?: string;
privateKey?: string;
publicKey?: string;
preSharedKey?: string;
createdAt: Date;
updatedAt: Date;
enabled: boolean;
};
/**
* Interface for user-related database operations.
* This interface provides methods for managing user data.
*/
export interface UserRepository {
/**
* Retrieves all users from the database.
*/
getUsers(): Promise<User[]>;
/**
* Retrieves a user by their ID or User object from the database.
*/
getUser(id: string): Promise<User | undefined>;
newUserWithPassword(username: string, password: string): Promise<void>;
/**
* Updates a user in the database.
*/
updateUser(user: User): Promise<void>;
/**
* Deletes a user from the database.
*/
deleteUser(id: string): Promise<void>;
}