Skip to content

Commit 4d57eca

Browse files
committed
feat: add TypeScript interfaces for database tables
- Added interfaces for Group, User, Warning, ApprovedUser, Channel, GroupAdminPermissions, Blacklist, GroupRule, and GroupMessageSettings - Defined primary keys, foreign keys, and relationships between entities - Included detailed comments for better understanding and maintainability
1 parent 160d2d0 commit 4d57eca

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

src/types/database/TablesTypes.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
export interface Group {
2+
id: number; // Primary Key
3+
group_id: number;
4+
group_name: string;
5+
rules: string[]; // Array of rules
6+
added_by_id: number;
7+
black_list: string[]; // Array of blacklisted words or user IDs
8+
chat_permissions: Record<string, boolean>; // Permissions for the group
9+
updated_at: string; // Date/Time of the last update (ISO 8601 string)
10+
joined_at: string; // Date/Time when the group was joined
11+
approved_users: number[]; // Array of user IDs of approved users
12+
warnings: number; // Number of warnings for the group
13+
is_spam_time: boolean; // Whether the group is flagged for spam
14+
members: number; // Number of members in the group
15+
}
16+
export interface User {
17+
id: number; // Primary Key
18+
telegram_id: number; // Telegram user ID
19+
username: string; // Telegram username
20+
role: 'admin' | 'moderator' | 'user'; // Role of the user
21+
warnings: number; // Number of warnings the user has received
22+
approved_groups: number[]; // List of approved group IDs for the user
23+
}
24+
export interface Warning {
25+
id: number; // Primary Key
26+
user_id: number; // Foreign Key to User table
27+
group_id: number; // Foreign Key to Group table
28+
warned_at: string; // Date/Time when the warning was issued
29+
reason: string; // Reason for the warning
30+
}
31+
export interface ApprovedUser {
32+
id: number; // Primary Key
33+
user_id: number; // Foreign Key to User table
34+
group_id: number; // Foreign Key to Group table
35+
username: string; // Username of the approved user
36+
}
37+
export interface Channel {
38+
id: number; // Primary Key
39+
name: string; // Name of the channel
40+
channel_id: number; // Unique identifier for the channel
41+
admins: number[]; // List of admin user IDs
42+
}
43+
export interface GroupAdminPermissions {
44+
id: number; // Primary Key
45+
group_id: number; // Foreign Key to Group table
46+
user_id: number; // Foreign Key to User table
47+
can_manage_approvals: boolean;
48+
can_manage_users: boolean;
49+
can_manage_blacklist: boolean;
50+
can_manage_rules: boolean;
51+
can_manage_pinning: boolean;
52+
can_manage_messages: boolean;
53+
can_manage_group_settings: boolean;
54+
can_view_group_stats: boolean;
55+
can_broadcast_message: boolean;
56+
can_view_admin_list: boolean;
57+
}
58+
export interface Blacklist {
59+
id: number; // Primary Key
60+
group_id: number; // Foreign Key to Group table
61+
blacklisted_word?: string; // Optional: blacklisted word
62+
blacklisted_user_id?: number; // Optional: blacklisted user ID
63+
}
64+
export interface GroupRule {
65+
id: number; // Primary Key
66+
group_id: number; // Foreign Key to Group table
67+
rule_text: string; // The rule text
68+
added_by: number; // User ID of the admin who added the rule
69+
}
70+
export interface GroupMessageSettings {
71+
id: number; // Primary Key
72+
group_id: number; // Foreign Key to Group table
73+
is_locked: boolean; // Whether the group is locked
74+
welcome_message: string; // Welcome message for new users
75+
}

0 commit comments

Comments
 (0)