2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Module: Models for Library entities and Users.
|
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Represents user detailed information.
|
2023-12-26 14:23:51 +03:00
|
|
|
* Some information should only be accessible to authorized users
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export interface IUser {
|
2023-12-28 14:04:44 +03:00
|
|
|
id: number | null;
|
|
|
|
username: string;
|
|
|
|
is_staff: boolean;
|
|
|
|
email: string;
|
|
|
|
first_name: string;
|
|
|
|
last_name: string;
|
2023-09-11 20:31:54 +03:00
|
|
|
}
|
2023-11-17 20:51:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents CurrentUser information.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export interface ICurrentUser extends Pick<IUser, 'id' | 'username' | 'is_staff'> {
|
2023-12-28 14:04:44 +03:00
|
|
|
subscriptions: number[];
|
2023-09-11 20:31:54 +03:00
|
|
|
}
|
2023-11-17 20:51:13 +03:00
|
|
|
|
|
|
|
/**
|
2023-12-26 14:23:51 +03:00
|
|
|
* Represents login data, used to authenticate users.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export interface IUserLoginData extends Pick<IUser, 'username'> {
|
2023-12-28 14:04:44 +03:00
|
|
|
password: string;
|
2023-09-11 20:31:54 +03:00
|
|
|
}
|
2023-11-17 20:51:13 +03:00
|
|
|
|
2024-02-25 20:55:30 +03:00
|
|
|
/**
|
|
|
|
* Represents password reset data.
|
|
|
|
*/
|
|
|
|
export interface IResetPasswordData {
|
|
|
|
password: string;
|
|
|
|
token: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents password token data.
|
|
|
|
*/
|
|
|
|
export interface IPasswordTokenData extends Pick<IResetPasswordData, 'token'> {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents password reset request data.
|
|
|
|
*/
|
|
|
|
export interface IRequestPasswordData extends Pick<IUser, 'email'> {}
|
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Represents signup data, used to create new users.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export interface IUserSignupData extends Omit<IUser, 'is_staff' | 'id'> {
|
2023-12-28 14:04:44 +03:00
|
|
|
password: string;
|
|
|
|
password2: string;
|
2023-09-11 20:31:54 +03:00
|
|
|
}
|
2023-11-17 20:51:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents user data, intended to update user profile in persistent storage.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
|
|
|
export interface IUserUpdateData extends Omit<IUser, 'is_staff' | 'id'> {}
|
2023-09-11 20:31:54 +03:00
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Represents user profile for viewing and editing {@link IUser}.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
|
|
|
export interface IUserProfile extends Omit<IUser, 'is_staff'> {}
|
2023-11-17 20:51:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents user reference information.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2024-02-22 19:09:24 +03:00
|
|
|
export interface IUserInfo extends Omit<IUserProfile, 'email' | 'username'> {}
|
2023-11-17 20:51:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents data needed to update password for current user.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export interface IUserUpdatePassword {
|
2023-12-28 14:04:44 +03:00
|
|
|
old_password: string;
|
|
|
|
new_password: string;
|
2023-09-11 20:31:54 +03:00
|
|
|
}
|
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Represents type of library items.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export enum LibraryItemType {
|
|
|
|
RSFORM = 'rsform',
|
|
|
|
OPERATIONS_SCHEMA = 'oss'
|
|
|
|
}
|
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Represents library item common data typical for all item types.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
2023-09-11 20:31:54 +03:00
|
|
|
export interface ILibraryItem {
|
2023-12-28 14:04:44 +03:00
|
|
|
id: number;
|
|
|
|
item_type: LibraryItemType;
|
|
|
|
title: string;
|
|
|
|
alias: string;
|
|
|
|
comment: string;
|
|
|
|
is_common: boolean;
|
|
|
|
is_canonical: boolean;
|
|
|
|
time_create: string;
|
|
|
|
time_update: string;
|
|
|
|
owner: number | null;
|
2023-09-11 20:31:54 +03:00
|
|
|
}
|
|
|
|
|
2023-11-30 02:14:24 +03:00
|
|
|
/**
|
|
|
|
* Represents library item extended data.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
|
|
|
export interface ILibraryItemEx extends ILibraryItem {
|
|
|
|
subscribers: number[];
|
2023-11-30 02:14:24 +03:00
|
|
|
}
|
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Represents update data for editing {@link ILibraryItem}.
|
2023-12-28 14:04:44 +03:00
|
|
|
*/
|
|
|
|
export interface ILibraryUpdateData extends Omit<ILibraryItem, 'time_create' | 'time_update' | 'id' | 'owner'> {}
|