📝 Типы: Marzban API структуры и Telegram WebApp интерфейсы
This commit is contained in:
75
types/marzban.ts
Normal file
75
types/marzban.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Marzban API Types
|
||||
* Типы для работы с Marzban Panel API
|
||||
*/
|
||||
|
||||
export interface MarzbanUser {
|
||||
username: string;
|
||||
status: 'active' | 'limited' | 'expired' | 'disabled';
|
||||
used_traffic: number; // bytes
|
||||
data_limit: number | null; // bytes, null = unlimited
|
||||
data_limit_reset_strategy: string;
|
||||
expire: number | null; // Unix timestamp, null = unlimited
|
||||
sub_updated_at: string; // ISO 8601 datetime
|
||||
on_hold_expire_duration: number;
|
||||
on_hold_timeout: string | null;
|
||||
subscription_url?: string; // URL подписки (опционально)
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface MarzbanUsage {
|
||||
date: string; // YYYY-MM-DD
|
||||
upload: number; // bytes
|
||||
download: number; // bytes
|
||||
total: number; // bytes
|
||||
}
|
||||
|
||||
export interface MarzbanUsageResponse {
|
||||
username: string;
|
||||
usages: MarzbanUsage[];
|
||||
}
|
||||
|
||||
export interface SubscriptionUserInfo {
|
||||
upload: number;
|
||||
download: number;
|
||||
total: number;
|
||||
expire: number;
|
||||
}
|
||||
|
||||
export interface MarzbanUsersListResponse {
|
||||
users: MarzbanUser[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface CreateUserRequest {
|
||||
username: string;
|
||||
status: 'active' | 'disabled';
|
||||
expire: number;
|
||||
data_limit: number;
|
||||
data_limit_reset_strategy: string;
|
||||
proxies: {
|
||||
vmess?: { id: string };
|
||||
vless?: {};
|
||||
trojan?: {};
|
||||
};
|
||||
inbounds: {
|
||||
vless?: string[];
|
||||
vmess?: string[];
|
||||
trojan?: string[];
|
||||
};
|
||||
note: string;
|
||||
}
|
||||
|
||||
export interface CreateUserResponse {
|
||||
username: string;
|
||||
subscription_url?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type PlanType = 'trial' | 'start' | 'plus' | 'max';
|
||||
|
||||
export interface PlanConfig {
|
||||
name: string;
|
||||
expireTimestamp: number;
|
||||
dataLimitBytes: number;
|
||||
}
|
||||
65
types/telegram.ts
Normal file
65
types/telegram.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Telegram WebApp Types
|
||||
* Типы для работы с Telegram Mini App API
|
||||
*/
|
||||
|
||||
export interface TelegramUser {
|
||||
id: number;
|
||||
first_name: string;
|
||||
last_name?: string;
|
||||
username?: string;
|
||||
language_code?: string;
|
||||
is_premium?: boolean;
|
||||
photo_url?: string;
|
||||
}
|
||||
|
||||
export interface TelegramWebAppInitData {
|
||||
query_id?: string;
|
||||
user?: TelegramUser;
|
||||
receiver?: TelegramUser;
|
||||
chat?: any;
|
||||
start_param?: string;
|
||||
auth_date: number;
|
||||
hash: string;
|
||||
}
|
||||
|
||||
export interface TelegramWebApp {
|
||||
initData: string;
|
||||
initDataUnsafe: TelegramWebAppInitData;
|
||||
version: string;
|
||||
platform: string;
|
||||
colorScheme: 'light' | 'dark';
|
||||
themeParams: any;
|
||||
isExpanded: boolean;
|
||||
viewportHeight: number;
|
||||
viewportStableHeight: number;
|
||||
headerColor: string;
|
||||
backgroundColor: string;
|
||||
isClosingConfirmationEnabled: boolean;
|
||||
|
||||
// Methods
|
||||
ready(): void;
|
||||
expand(): void;
|
||||
close(): void;
|
||||
showAlert(message: string, callback?: () => void): void;
|
||||
showConfirm(message: string, callback?: (confirmed: boolean) => void): void;
|
||||
showPopup(params: any, callback?: () => void): void;
|
||||
onEvent(eventType: string, callback: () => void): void;
|
||||
offEvent(eventType: string, callback: () => void): void;
|
||||
}
|
||||
|
||||
export interface TelegramUserData {
|
||||
webApp: TelegramWebApp | null;
|
||||
telegramId: number | null;
|
||||
telegramUsername: string | null;
|
||||
firstName: string | null;
|
||||
lastName: string | null;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Telegram?: {
|
||||
WebApp: TelegramWebApp;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user