Route guards, WS lifecycle, ticket stats. Refs EventHub/EventHubFrontAdmin#3

This commit is contained in:
2026-07-07 21:03:46 +03:00
parent 896e3bcd35
commit ecfa1a66bb
18 changed files with 1331 additions and 955 deletions
+331 -298
View File
@@ -1,299 +1,332 @@
// ===================== Event (Событие) =====================
export interface Event {
id: string;
calendar_id: string;
title: string;
description: string;
event_type: 'single' | 'recurring';
start_time: string; // ISO8601
duration: number;
recurrence: object | null;
master_id: string | null;
is_instance: boolean;
specialist_id: string | null;
location: object | null;
tags: string[];
capacity: number | null;
online_link: string | null;
status: 'active' | 'cancelled' | 'completed';
reason: string | null;
rating_avg: number;
rating_count: number;
attachments: string[] | null;
edit_history: object[] | null;
created_at: string; // ISO8601
updated_at: string; // ISO8601
}
export interface EventListParams {
from?: string;
to?: string;
status?: 'active' | 'cancelled' | 'completed';
calendar_id?: string;
title?: string;
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== User (Пользователь) =====================
export interface User {
id: string;
email: string;
role: 'user' | 'bot';
status: 'active' | 'frozen' | 'deleted';
reason: string | null;
nickname: string | null;
avatar_url: string | null;
timezone: string | null;
language: string | null;
social_links: string[] | null;
phone: string | null;
preferences: object | null;
last_login: string; // ISO8601
created_at: string; // ISO8601
updated_at: string; // ISO8601
}
export interface UserListParams {
role?: 'user' | 'bot';
status?: 'active' | 'frozen' | 'deleted';
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Report (Жалоба) =====================
export interface Report {
id: string;
reporter_id: string;
target_type: 'calendar' | 'event' | 'review';
target_id: string;
reason: string;
status: 'pending' | 'reviewed' | 'dismissed';
created_at: string;
resolved_at: string | null;
resolved_by: string | null;
}
export interface ReportListParams {
status?: 'pending' | 'reviewed' | 'dismissed';
target_type?: 'calendar' | 'event' | 'review';
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Review (Отзыв) =====================
export interface Review {
id: string;
user_id: string;
target_type: 'calendar' | 'event';
target_id: string;
rating: number; // 1-5
comment: string;
status: 'visible' | 'hidden' | 'deleted';
reason: string | null;
likes: number;
dislikes: number;
created_at: string;
updated_at: string;
}
export interface ReviewListParams {
target_type?: 'calendar' | 'event';
target_id?: string;
user_id?: string;
status?: 'visible' | 'hidden' | 'deleted';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Banned Word (Бан-слово) =====================
export interface BannedWord {
id: string;
word: string;
added_by: string | null;
added_at: string | null;
}
// ===================== Ticket (Тикет баг-трекера) =====================
export interface Ticket {
id: string;
reporter_id: string;
error_hash: string;
error_message: string;
stacktrace: string;
context: string;
count: number;
first_seen: string;
last_seen: string;
status: 'open' | 'in_progress' | 'resolved' | 'closed';
assigned_to: string | null;
resolution_note: string | null;
}
export interface TicketListParams {
status?: 'open' | 'in_progress' | 'resolved' | 'closed';
assigned_to?: string;
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
export interface TicketStats {
open: number;
in_progress: number;
resolved: number;
closed: number;
total: number;
}
// ===================== Subscription (Подписка) =====================
export interface Subscription {
id: string;
user_id: string;
plan: 'monthly' | 'quarterly' | 'biannual' | 'annual';
status: 'active' | 'expired' | 'cancelled';
trial_used: boolean;
started_at: string;
expires_at: string;
created_at: string;
updated_at: string;
}
export interface SubscriptionListParams {
plan?: 'monthly' | 'quarterly' | 'biannual' | 'annual';
status?: 'active' | 'expired' | 'cancelled';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Admin (Администратор) =====================
export interface Admin {
id: string;
email: string;
role: 'superadmin' | 'admin' | 'moderator' | 'support';
status: 'active' | 'blocked';
nickname: string | null;
avatar_url: string | null;
timezone: string | null;
language: string | null;
phone: string | null;
preferences: object | null;
last_login: string;
created_at: string;
updated_at: string;
}
export interface AdminListParams {
role?: 'superadmin' | 'admin' | 'moderator' | 'support';
status?: 'active' | 'blocked';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Audit (Запись аудита) =====================
export interface AuditRecord {
id: string;
admin_id: string;
email: string;
role: string;
action: string;
entity_type: string;
entity_id: string;
timestamp: string;
ip: string;
reason: string | null;
}
export interface AuditListParams {
admin_id?: string;
action?: string;
date_from?: string;
date_to?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Dashboard Stats =====================
export interface DashboardStats {
users_total: number;
events_total: number;
reviews_total: number;
calendars_total: number;
reports_total: number;
tickets_total: number;
tickets_open: number;
avg_ticket_resolution_h: number;
admin_activity: AdminActivity[];
events_by_day: DayCount[];
registrations_by_day: DayCount[];
}
export interface AdminActivity {
admin_id: string;
email: string;
role: string;
last_login: string;
nickname: string;
actions: number;
}
export interface DayCount {
date: string;
count: number;
}
// ===================== Moderation =====================
export type TargetType = 'calendar' | 'event' | 'review' | 'user';
export type ModerationAction = {
calendar: 'freeze' | 'unfreeze';
event: 'freeze' | 'unfreeze';
review: 'hide' | 'unhide';
user: 'block' | 'unblock';
};
export interface ModerationPayload {
action: string;
reason?: string;
}
// ===================== Auth =====================
export interface LoginRequest {
email: string;
password: string;
}
export interface LoginResponse {
access_token: string;
refresh_token: string;
}
export interface RefreshResponse {
access_token: string;
refresh_token: string;
}
// ===================== Pagination =====================
export interface PaginatedResponse<T> {
data: T[];
total: number;
// ===================== Calendar =====================
export interface Calendar {
id: string;
title: string;
description: string;
type: 'personal' | 'commercial';
category: string;
owner_id: string;
status: 'active' | 'frozen' | 'deleted';
reason: string | null;
tags: string[];
color: string;
image_url: string;
rating_avg: number;
rating_count: number;
short_name: string;
confirmation: string;
settings: object | null;
created_at: string;
updated_at: string;
}
export interface CalendarListParams {
q?: string;
status?: 'active' | 'frozen' | 'deleted';
type?: 'personal' | 'commercial';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Event (Событие) =====================
export interface Event {
id: string;
calendar_id: string;
title: string;
description: string;
event_type: 'single' | 'recurring';
start_time: string; // ISO8601
duration: number;
recurrence: object | null;
master_id: string | null;
is_instance: boolean;
specialist_id: string | null;
location: object | null;
tags: string[];
capacity: number | null;
online_link: string | null;
status: 'active' | 'cancelled' | 'completed';
reason: string | null;
rating_avg: number;
rating_count: number;
attachments: string[] | null;
edit_history: object[] | null;
created_at: string; // ISO8601
updated_at: string; // ISO8601
}
export interface EventListParams {
from?: string;
to?: string;
status?: 'active' | 'cancelled' | 'completed';
calendar_id?: string;
title?: string;
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== User (Пользователь) =====================
export interface User {
id: string;
email: string;
role: 'user' | 'bot';
status: 'active' | 'frozen' | 'deleted';
reason: string | null;
nickname: string | null;
avatar_url: string | null;
timezone: string | null;
language: string | null;
social_links: string[] | null;
phone: string | null;
preferences: object | null;
last_login: string; // ISO8601
created_at: string; // ISO8601
updated_at: string; // ISO8601
}
export interface UserListParams {
role?: 'user' | 'bot';
status?: 'active' | 'frozen' | 'deleted';
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Report (Жалоба) =====================
export interface Report {
id: string;
reporter_id: string;
target_type: 'calendar' | 'event' | 'review';
target_id: string;
reason: string;
status: 'pending' | 'reviewed' | 'dismissed';
created_at: string;
resolved_at: string | null;
resolved_by: string | null;
}
export interface ReportListParams {
status?: 'pending' | 'reviewed' | 'dismissed';
target_type?: 'calendar' | 'event' | 'review';
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Review (Отзыв) =====================
export interface Review {
id: string;
user_id: string;
target_type: 'calendar' | 'event';
target_id: string;
rating: number; // 1-5
comment: string;
status: 'visible' | 'hidden' | 'deleted';
reason: string | null;
likes: number;
dislikes: number;
created_at: string;
updated_at: string;
}
export interface ReviewListParams {
target_type?: 'calendar' | 'event';
target_id?: string;
user_id?: string;
status?: 'visible' | 'hidden' | 'deleted';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Banned Word (Бан-слово) =====================
export interface BannedWord {
id: string;
word: string;
added_by: string | null;
added_at: string | null;
}
// ===================== Ticket (Тикет баг-трекера) =====================
export interface Ticket {
id: string;
reporter_id: string;
error_hash: string;
error_message: string;
stacktrace: string;
context: string;
count: number;
first_seen: string;
last_seen: string;
status: 'open' | 'in_progress' | 'resolved' | 'closed';
assigned_to: string | null;
resolution_note: string | null;
}
export interface TicketListParams {
status?: 'open' | 'in_progress' | 'resolved' | 'closed';
assigned_to?: string;
q?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
export interface TicketStats {
open: number;
in_progress: number;
resolved: number;
closed: number;
total_tickets: number;
total_errors: number;
}
// ===================== Subscription (Подписка) =====================
export interface Subscription {
id: string;
user_id: string;
plan: 'monthly' | 'quarterly' | 'biannual' | 'annual';
status: 'active' | 'expired' | 'cancelled';
trial_used: boolean;
started_at: string;
expires_at: string;
created_at: string;
updated_at: string;
}
export interface SubscriptionListParams {
plan?: 'monthly' | 'quarterly' | 'biannual' | 'annual';
status?: 'active' | 'expired' | 'cancelled';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Admin (Администратор) =====================
export interface Admin {
id: string;
email: string;
role: 'superadmin' | 'admin' | 'moderator' | 'support';
status: 'active' | 'blocked';
nickname: string | null;
avatar_url: string | null;
timezone: string | null;
language: string | null;
phone: string | null;
preferences: object | null;
last_login: string;
created_at: string;
updated_at: string;
}
export interface AdminListParams {
role?: 'superadmin' | 'admin' | 'moderator' | 'support';
status?: 'active' | 'blocked';
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Audit (Запись аудита) =====================
export interface AuditRecord {
id: string;
admin_id: string;
email: string;
role: string;
action: string;
entity_type: string;
entity_id: string;
timestamp: string;
ip: string;
reason: string | null;
}
export interface AuditListParams {
admin_id?: string;
action?: string;
date_from?: string;
date_to?: string;
limit?: number;
offset?: number;
sort?: string;
order?: 'asc' | 'desc';
}
// ===================== Dashboard Stats =====================
export interface DashboardStats {
users_total: number;
events_total: number;
reviews_total: number;
calendars_total: number;
reports_total: number;
tickets_total: number;
tickets_open: number;
avg_ticket_resolution_h: number;
admin_activity: AdminActivity[];
events_by_day: DayCount[];
registrations_by_day: DayCount[];
}
export interface AdminActivity {
admin_id: string;
email: string;
role: string;
last_login: string;
nickname: string;
actions: number;
}
export interface DayCount {
date: string;
count: number;
}
// ===================== Moderation =====================
export type TargetType = 'calendar' | 'event' | 'review' | 'user';
export type ModerationAction = {
calendar: 'freeze' | 'unfreeze';
event: 'freeze' | 'unfreeze';
review: 'hide' | 'unhide';
user: 'block' | 'unblock';
};
export interface ModerationPayload {
action: string;
reason?: string;
}
// ===================== Auth =====================
export interface LoginRequest {
email: string;
password: string;
}
export interface LoginResponse {
access_token: string;
refresh_token: string;
}
export interface RefreshResponse {
access_token: string;
refresh_token: string;
}
// ===================== Pagination =====================
export interface PaginatedResponse<T> {
data: T[];
total: number;
}