UNPKG

marzban-sdk

Version:

Fully typed client SDK for the Marzban API, supporting both browser and Node.js environments.

2,227 lines (2,124 loc) 158 kB
import { z } from 'zod/v4'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; declare const configSchema: z.ZodObject<{ baseUrl: z.ZodURL; username: z.ZodString; password: z.ZodString; timeout: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; retries: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; token: z.ZodOptional<z.ZodString>; authenticateOnInit: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; logger: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{ level: z.ZodOptional<z.ZodEnum<{ debug: "debug"; info: "info"; warn: "warn"; error: "error"; }>>; timestamp: z.ZodOptional<z.ZodBoolean>; }, z.core.$strip>, z.ZodObject<{ debug: z.ZodCustom<(message: string, context?: string) => void, (message: string, context?: string) => void>; info: z.ZodCustom<(message: string, context?: string) => void, (message: string, context?: string) => void>; warn: z.ZodCustom<(message: string, context?: string) => void, (message: string, context?: string) => void>; error: z.ZodCustom<(message: string, trace?: unknown, context?: string) => void, (message: string, trace?: unknown, context?: string) => void>; }, z.core.$strip>]>>; webhook: z.ZodOptional<z.ZodObject<{ secret: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; }, z.core.$strip>; /** * Configuration options for initializing the MarzbanSDK client. * * @property {string} baseUrl - Base URL of the Marzban API instance. Example: 'https://api.example.com'. * @property {string} username - Username for authentication. * @property {string} password - Password for authentication. * @property {string} [token] - Optional JWT token for authorization. If provided, SDK will use it instead of logging in. * @property {number} [retries=3] - Number of automatic retries for failed HTTP requests. * @property {boolean} [authenticateOnInit=true] - If false, SDK will not authenticate on instantiation (call `authorize()` manually). */ type Config = z.infer<typeof configSchema>; interface FormatCode { code: string; message: string; } declare const ERROR_CODES: { readonly CONFIG_INVALID: { readonly code: "CONFIG_INVALID"; readonly message: "Invalid SDK configuration"; }; readonly NETWORK_HTTP_ERROR: { readonly code: "NETWORK_HTTP_ERROR"; readonly message: "HTTP request failed"; }; readonly AUTH_TOKEN_FAILED: { readonly code: "AUTH_TOKEN_FAILED"; readonly message: "Failed to retrieve access token"; }; readonly AUTH_FAILED: { readonly code: "AUTH_FAILED"; readonly message: "Authentication failed"; }; readonly LOGGER_INVALID: { readonly code: "LOGGER_INVALID"; readonly message: "Invalid logger option: must be false, LoggerOptions, or Logger instance"; }; readonly WEBHOOK_SIGNATURE_ERROR: { readonly code: "WEBHOOK_SIGNATURE_ERROR"; readonly message: "Invalid webhook signature"; }; readonly WEBHOOK_VALIDATION_ERROR: { readonly code: "WEBHOOK_VALIDATION_ERROR"; readonly message: "Invalid webhook payload"; }; }; type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES]['code']; declare class SdkError<T = unknown> extends Error { readonly code: ErrorCode; readonly details?: T; constructor(options: FormatCode, details?: T); static fromCode<T = unknown>(code: ErrorCode, details?: T): SdkError<T>; toJSON(): { name: string; code: "CONFIG_INVALID" | "NETWORK_HTTP_ERROR" | "AUTH_TOKEN_FAILED" | "AUTH_FAILED" | "LOGGER_INVALID" | "WEBHOOK_SIGNATURE_ERROR" | "WEBHOOK_VALIDATION_ERROR"; message: string; details: T | undefined; }; } declare class AuthError extends SdkError { constructor(details?: unknown); } declare class AuthTokenError extends SdkError { constructor(details?: unknown); } declare class ConfigurationError extends SdkError { constructor(details?: unknown); } declare class HttpError extends SdkError { constructor(details?: unknown); } declare class WebhookSignatureError extends SdkError { constructor(details?: unknown); } declare class WebhookValidationError extends SdkError { constructor(details?: unknown); } declare const isAuthError: (error: unknown) => error is AuthError; declare const isConfigurationError: (error: unknown) => error is ConfigurationError; declare const isSdkError: (error: unknown) => error is SdkError; type Admin = { /** * @type string */ username: string; /** * @type boolean */ is_sudo: boolean; telegram_id?: number | null; discord_webhook?: string | null; users_usage?: number | null; }; type AdminCreate = { /** * @type string */ username: string; /** * @type boolean */ is_sudo: boolean; telegram_id?: number | null; discord_webhook?: string | null; users_usage?: number | null; /** * @type string */ password: string; }; type Forbidden = { /** * @default "You are not allowed to ..." * @type string | undefined */ detail?: string; }; type ValidationError = { /** * @type array */ loc: (string | number)[]; /** * @type string */ msg: string; /** * @type string */ type: string; }; type HTTPValidationError = { /** * @type array | undefined */ detail?: ValidationError[]; }; type NotFound = { /** * @default "Entity {} not found" * @type string | undefined */ detail?: string; }; type Unauthorized = { /** * @default "Not authenticated" * @type string | undefined */ detail?: string; }; type ActivateAllDisabledUsersPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type ActivateAllDisabledUsers200 = any; /** * @description Unauthorized */ type ActivateAllDisabledUsers401 = Unauthorized; /** * @description Forbidden */ type ActivateAllDisabledUsers403 = Forbidden; /** * @description Not found */ type ActivateAllDisabledUsers404 = NotFound; /** * @description Validation Error */ type ActivateAllDisabledUsers422 = HTTPValidationError; type ActivateAllDisabledUsersMutationResponse = ActivateAllDisabledUsers200; type ActivateAllDisabledUsersMutation = { Response: ActivateAllDisabledUsers200; PathParams: ActivateAllDisabledUsersPathParams; Errors: ActivateAllDisabledUsers401 | ActivateAllDisabledUsers403 | ActivateAllDisabledUsers404 | ActivateAllDisabledUsers422; }; type BodyAdminTokenApiAdminTokenPost = { grant_type?: string | null; /** * @type string */ username: string; /** * @type string */ password: string; /** * @default "" * @type string | undefined */ scope?: string; client_id?: string | null; client_secret?: string | null; }; type Token = { /** * @type string */ access_token: string; /** * @default "bearer" * @type string | undefined */ token_type?: string; }; /** * @description Successful Response */ type AdminToken200 = Token; /** * @description Unauthorized */ type AdminToken401 = Unauthorized; /** * @description Validation Error */ type AdminToken422 = HTTPValidationError; type AdminTokenMutationRequest = BodyAdminTokenApiAdminTokenPost; type AdminTokenMutationResponse = AdminToken200; type AdminTokenMutation = { Response: AdminToken200; Request: AdminTokenMutationRequest; Errors: AdminToken401 | AdminToken422; }; type Conflict = { /** * @default "Entity already exists" * @type string | undefined */ detail?: string; }; /** * @description Successful Response */ type CreateAdmin200 = Admin; /** * @description Unauthorized */ type CreateAdmin401 = Unauthorized; /** * @description Forbidden */ type CreateAdmin403 = Forbidden; /** * @description Conflict */ type CreateAdmin409 = Conflict; /** * @description Validation Error */ type CreateAdmin422 = HTTPValidationError; type CreateAdminMutationRequest = AdminCreate; type CreateAdminMutationResponse = CreateAdmin200; type CreateAdminMutation = { Response: CreateAdmin200; Request: CreateAdminMutationRequest; Errors: CreateAdmin401 | CreateAdmin403 | CreateAdmin409 | CreateAdmin422; }; type DisableAllActiveUsersPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type DisableAllActiveUsers200 = any; /** * @description Unauthorized */ type DisableAllActiveUsers401 = Unauthorized; /** * @description Forbidden */ type DisableAllActiveUsers403 = Forbidden; /** * @description Not found */ type DisableAllActiveUsers404 = NotFound; /** * @description Validation Error */ type DisableAllActiveUsers422 = HTTPValidationError; type DisableAllActiveUsersMutationResponse = DisableAllActiveUsers200; type DisableAllActiveUsersMutation = { Response: DisableAllActiveUsers200; PathParams: DisableAllActiveUsersPathParams; Errors: DisableAllActiveUsers401 | DisableAllActiveUsers403 | DisableAllActiveUsers404 | DisableAllActiveUsers422; }; type GetAdminsQueryParams = { offset?: number | null; limit?: number | null; username?: string | null; }; /** * @description Successful Response */ type GetAdmins200 = Admin[]; /** * @description Unauthorized */ type GetAdmins401 = Unauthorized; /** * @description Forbidden */ type GetAdmins403 = Forbidden; /** * @description Validation Error */ type GetAdmins422 = HTTPValidationError; type GetAdminsQueryResponse = GetAdmins200; type GetAdminsQuery = { Response: GetAdmins200; QueryParams: GetAdminsQueryParams; Errors: GetAdmins401 | GetAdmins403 | GetAdmins422; }; type GetAdminUsagePathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type GetAdminUsage200 = number; /** * @description Unauthorized */ type GetAdminUsage401 = Unauthorized; /** * @description Forbidden */ type GetAdminUsage403 = Forbidden; /** * @description Validation Error */ type GetAdminUsage422 = HTTPValidationError; type GetAdminUsageQueryResponse = GetAdminUsage200; type GetAdminUsageQuery = { Response: GetAdminUsage200; PathParams: GetAdminUsagePathParams; Errors: GetAdminUsage401 | GetAdminUsage403 | GetAdminUsage422; }; /** * @description Successful Response */ type GetCurrentAdmin200 = Admin; /** * @description Unauthorized */ type GetCurrentAdmin401 = Unauthorized; type GetCurrentAdminQueryResponse = GetCurrentAdmin200; type GetCurrentAdminQuery = { Response: GetCurrentAdmin200; Errors: GetCurrentAdmin401; }; type AdminModify = { password?: string | null; /** * @type boolean */ is_sudo: boolean; telegram_id?: number | null; discord_webhook?: string | null; }; type ModifyAdminPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type ModifyAdmin200 = Admin; /** * @description Unauthorized */ type ModifyAdmin401 = Unauthorized; /** * @description Forbidden */ type ModifyAdmin403 = Forbidden; /** * @description Validation Error */ type ModifyAdmin422 = HTTPValidationError; type ModifyAdminMutationRequest = AdminModify; type ModifyAdminMutationResponse = ModifyAdmin200; type ModifyAdminMutation = { Response: ModifyAdmin200; Request: ModifyAdminMutationRequest; PathParams: ModifyAdminPathParams; Errors: ModifyAdmin401 | ModifyAdmin403 | ModifyAdmin422; }; type RemoveAdminPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type RemoveAdmin200 = any; /** * @description Unauthorized */ type RemoveAdmin401 = Unauthorized; /** * @description Forbidden */ type RemoveAdmin403 = Forbidden; /** * @description Validation Error */ type RemoveAdmin422 = HTTPValidationError; type RemoveAdminMutationResponse = RemoveAdmin200; type RemoveAdminMutation = { Response: RemoveAdmin200; PathParams: RemoveAdminPathParams; Errors: RemoveAdmin401 | RemoveAdmin403 | RemoveAdmin422; }; type ResetAdminUsagePathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type ResetAdminUsage200 = Admin; /** * @description Unauthorized */ type ResetAdminUsage401 = Unauthorized; /** * @description Forbidden */ type ResetAdminUsage403 = Forbidden; /** * @description Validation Error */ type ResetAdminUsage422 = HTTPValidationError; type ResetAdminUsageMutationResponse = ResetAdminUsage200; type ResetAdminUsageMutation = { Response: ResetAdminUsage200; PathParams: ResetAdminUsagePathParams; Errors: ResetAdminUsage401 | ResetAdminUsage403 | ResetAdminUsage422; }; /** * @description Successful Response */ type GetCoreConfig200 = object; /** * @description Unauthorized */ type GetCoreConfig401 = Unauthorized; /** * @description Forbidden */ type GetCoreConfig403 = Forbidden; type GetCoreConfigQueryResponse = GetCoreConfig200; type GetCoreConfigQuery = { Response: GetCoreConfig200; Errors: GetCoreConfig401 | GetCoreConfig403; }; type CoreStats = { /** * @type string */ version: string; /** * @type boolean */ started: boolean; /** * @type string */ logs_websocket: string; }; /** * @description Successful Response */ type GetCoreStats200 = CoreStats; /** * @description Unauthorized */ type GetCoreStats401 = Unauthorized; type GetCoreStatsQueryResponse = GetCoreStats200; type GetCoreStatsQuery = { Response: GetCoreStats200; Errors: GetCoreStats401; }; /** * @description Successful Response */ type ModifyCoreConfig200 = object; /** * @description Unauthorized */ type ModifyCoreConfig401 = Unauthorized; /** * @description Forbidden */ type ModifyCoreConfig403 = Forbidden; /** * @description Validation Error */ type ModifyCoreConfig422 = HTTPValidationError; type ModifyCoreConfigMutationRequest = object; type ModifyCoreConfigMutationResponse = ModifyCoreConfig200; type ModifyCoreConfigMutation = { Response: ModifyCoreConfig200; Request: ModifyCoreConfigMutationRequest; Errors: ModifyCoreConfig401 | ModifyCoreConfig403 | ModifyCoreConfig422; }; /** * @description Successful Response */ type RestartCore200 = any; /** * @description Unauthorized */ type RestartCore401 = Unauthorized; /** * @description Forbidden */ type RestartCore403 = Forbidden; type RestartCoreMutationResponse = RestartCore200; type RestartCoreMutation = { Response: RestartCore200; Errors: RestartCore401 | RestartCore403; }; /** * @description Successful Response */ type Base200 = string; type BaseQueryResponse = Base200; type BaseQuery = { Response: Base200; Errors: any; }; type HTTPException = { /** * @type string */ detail: string; }; type NextPlanModel = { data_limit?: number | null; expire?: number | null; /** * @default false * @type boolean | undefined */ add_remaining_traffic?: boolean; /** * @default true * @type boolean | undefined */ fire_on_either?: boolean; }; /** * @example [object Object] */ type NodeCreate = { /** * @type string */ name: string; /** * @type string */ address: string; /** * @default 62050 * @type integer | undefined */ port?: number; /** * @default 62051 * @type integer | undefined */ api_port?: number; /** * @default 1 * @type number | undefined */ usage_coefficient?: number; /** * @default true * @type boolean | undefined */ add_as_new_host?: boolean; }; declare const nodeStatusEnum: { readonly connected: "connected"; readonly connecting: "connecting"; readonly error: "error"; readonly disabled: "disabled"; }; type NodeStatusEnumKey = (typeof nodeStatusEnum)[keyof typeof nodeStatusEnum]; type NodeStatus = NodeStatusEnumKey; type NodeResponse = { /** * @type string */ name: string; /** * @type string */ address: string; /** * @default 62050 * @type integer | undefined */ port?: number; /** * @default 62051 * @type integer | undefined */ api_port?: number; /** * @default 1 * @type number | undefined */ usage_coefficient?: number; /** * @type integer */ id: number; xray_version?: string | null; /** * @type string */ status: NodeStatus; message?: string | null; }; /** * @description Successful Response */ type AddNode200 = NodeResponse; /** * @description Unauthorized */ type AddNode401 = Unauthorized; /** * @description Forbidden */ type AddNode403 = Forbidden; /** * @description Conflict */ type AddNode409 = Conflict; /** * @description Validation Error */ type AddNode422 = HTTPValidationError; /** * @example [object Object] */ type AddNodeMutationRequest = NodeCreate; type AddNodeMutationResponse = AddNode200; type AddNodeMutation = { Response: AddNode200; Request: AddNodeMutationRequest; Errors: AddNode401 | AddNode403 | AddNode409 | AddNode422; }; type GetNodePathParams = { /** * @type integer */ node_id: number; }; /** * @description Successful Response */ type GetNode200 = NodeResponse; /** * @description Unauthorized */ type GetNode401 = Unauthorized; /** * @description Forbidden */ type GetNode403 = Forbidden; /** * @description Validation Error */ type GetNode422 = HTTPValidationError; type GetNodeQueryResponse = GetNode200; type GetNodeQuery = { Response: GetNode200; PathParams: GetNodePathParams; Errors: GetNode401 | GetNode403 | GetNode422; }; /** * @description Successful Response */ type GetNodes200 = NodeResponse[]; /** * @description Unauthorized */ type GetNodes401 = Unauthorized; /** * @description Forbidden */ type GetNodes403 = Forbidden; type GetNodesQueryResponse = GetNodes200; type GetNodesQuery = { Response: GetNodes200; Errors: GetNodes401 | GetNodes403; }; type NodeSettings = { /** * @default "v0.2.0" * @type string | undefined */ min_node_version?: string; /** * @type string */ certificate: string; }; /** * @description Successful Response */ type GetNodeSettings200 = NodeSettings; /** * @description Unauthorized */ type GetNodeSettings401 = Unauthorized; /** * @description Forbidden */ type GetNodeSettings403 = Forbidden; type GetNodeSettingsQueryResponse = GetNodeSettings200; type GetNodeSettingsQuery = { Response: GetNodeSettings200; Errors: GetNodeSettings401 | GetNodeSettings403; }; type NodeUsageResponse = { node_id?: number | null; /** * @type string */ node_name: string; /** * @type integer */ uplink: number; /** * @type integer */ downlink: number; }; type NodesUsageResponse = { /** * @type array */ usages: NodeUsageResponse[]; }; type GetUsageQueryParams = { /** * @default "" * @type string | undefined */ start?: string; /** * @default "" * @type string | undefined */ end?: string; }; /** * @description Successful Response */ type GetUsage200 = NodesUsageResponse; /** * @description Unauthorized */ type GetUsage401 = Unauthorized; /** * @description Forbidden */ type GetUsage403 = Forbidden; /** * @description Validation Error */ type GetUsage422 = HTTPValidationError; type GetUsageQueryResponse = GetUsage200; type GetUsageQuery = { Response: GetUsage200; QueryParams: GetUsageQueryParams; Errors: GetUsage401 | GetUsage403 | GetUsage422; }; /** * @example [object Object] */ type NodeModify = { name?: (string | null) | null; address?: (string | null) | null; port?: (number | null) | null; api_port?: (number | null) | null; usage_coefficient?: (number | null) | null; status?: (NodeStatus | null) | null; }; type ModifyNodePathParams = { /** * @type integer */ node_id: number; }; /** * @description Successful Response */ type ModifyNode200 = NodeResponse; /** * @description Unauthorized */ type ModifyNode401 = Unauthorized; /** * @description Forbidden */ type ModifyNode403 = Forbidden; /** * @description Validation Error */ type ModifyNode422 = HTTPValidationError; /** * @example [object Object] */ type ModifyNodeMutationRequest = NodeModify; type ModifyNodeMutationResponse = ModifyNode200; type ModifyNodeMutation = { Response: ModifyNode200; Request: ModifyNodeMutationRequest; PathParams: ModifyNodePathParams; Errors: ModifyNode401 | ModifyNode403 | ModifyNode422; }; type ReconnectNodePathParams = { /** * @type integer */ node_id: number; }; /** * @description Successful Response */ type ReconnectNode200 = any; /** * @description Unauthorized */ type ReconnectNode401 = Unauthorized; /** * @description Forbidden */ type ReconnectNode403 = Forbidden; /** * @description Validation Error */ type ReconnectNode422 = HTTPValidationError; type ReconnectNodeMutationResponse = ReconnectNode200; type ReconnectNodeMutation = { Response: ReconnectNode200; PathParams: ReconnectNodePathParams; Errors: ReconnectNode401 | ReconnectNode403 | ReconnectNode422; }; type RemoveNodePathParams = { /** * @type integer */ node_id: number; }; /** * @description Successful Response */ type RemoveNode200 = any; /** * @description Unauthorized */ type RemoveNode401 = Unauthorized; /** * @description Forbidden */ type RemoveNode403 = Forbidden; /** * @description Validation Error */ type RemoveNode422 = HTTPValidationError; type RemoveNodeMutationResponse = RemoveNode200; type RemoveNodeMutation = { Response: RemoveNode200; PathParams: RemoveNodePathParams; Errors: RemoveNode401 | RemoveNode403 | RemoveNode422; }; declare const proxyHostALPNEnum: { readonly h3: "h3"; readonly h2: "h2"; readonly 'http/1.1': "http/1.1"; readonly 'h3,h2,http/1.1': "h3,h2,http/1.1"; readonly 'h3,h2': "h3,h2"; readonly 'h2,http/1.1': "h2,http/1.1"; }; type ProxyHostALPNEnumKey = (typeof proxyHostALPNEnum)[keyof typeof proxyHostALPNEnum]; type ProxyHostALPN = ProxyHostALPNEnumKey; declare const proxyHostFingerprintEnum: { readonly chrome: "chrome"; readonly firefox: "firefox"; readonly safari: "safari"; readonly ios: "ios"; readonly android: "android"; readonly edge: "edge"; readonly '360': "360"; readonly qq: "qq"; readonly random: "random"; readonly randomized: "randomized"; }; type ProxyHostFingerprintEnumKey = (typeof proxyHostFingerprintEnum)[keyof typeof proxyHostFingerprintEnum]; type ProxyHostFingerprint = ProxyHostFingerprintEnumKey; declare const proxyHostSecurityEnum: { readonly inbound_default: "inbound_default"; readonly none: "none"; readonly tls: "tls"; }; type ProxyHostSecurityEnumKey = (typeof proxyHostSecurityEnum)[keyof typeof proxyHostSecurityEnum]; type ProxyHostSecurity = ProxyHostSecurityEnumKey; type ProxyHost = { /** * @type string */ remark: string; /** * @type string */ address: string; port?: (number | null) | null; sni?: (string | null) | null; host?: (string | null) | null; path?: (string | null) | null; /** * @type string | undefined */ security?: ProxyHostSecurity; /** * @type string | undefined */ alpn?: ProxyHostALPN; /** * @type string | undefined */ fingerprint?: ProxyHostFingerprint; allowinsecure?: boolean | null; is_disabled?: boolean | null; mux_enable?: boolean | null; fragment_setting?: (string | null) | null; noise_setting?: (string | null) | null; random_user_agent?: boolean | null; use_sni_as_host?: boolean | null; }; declare const proxyTypesEnum: { readonly vmess: "vmess"; readonly vless: "vless"; readonly trojan: "trojan"; readonly shadowsocks: "shadowsocks"; }; type ProxyTypesEnumKey = (typeof proxyTypesEnum)[keyof typeof proxyTypesEnum]; type ProxyTypes = ProxyTypesEnumKey; type ProxyInbound = { /** * @type string */ tag: string; /** * @type string */ protocol: ProxyTypes; /** * @type string */ network: string; /** * @type string */ tls: string; port: number | string; }; type ProxySettings = object; type UserGetUsagePathParams = { /** * @type string */ token: string; }; type UserGetUsageQueryParams = { /** * @default "" * @type string | undefined */ start?: string; /** * @default "" * @type string | undefined */ end?: string; }; /** * @description Successful Response */ type UserGetUsage200 = any; /** * @description Validation Error */ type UserGetUsage422 = HTTPValidationError; type UserGetUsageQueryResponse = UserGetUsage200; type UserGetUsageQuery = { Response: UserGetUsage200; PathParams: UserGetUsagePathParams; QueryParams: UserGetUsageQueryParams; Errors: UserGetUsage422; }; type UserSubscriptionPathParams = { /** * @type string */ token: string; }; type UserSubscriptionHeaderParams = { /** * @default "" * @type string | undefined */ 'user-agent'?: string; }; /** * @description Successful Response */ type UserSubscription200 = any; /** * @description Validation Error */ type UserSubscription422 = HTTPValidationError; type UserSubscriptionQueryResponse = UserSubscription200; type UserSubscriptionQuery = { Response: UserSubscription200; PathParams: UserSubscriptionPathParams; HeaderParams: UserSubscriptionHeaderParams; Errors: UserSubscription422; }; declare const userDataLimitResetStrategyEnum: { readonly no_reset: "no_reset"; readonly day: "day"; readonly week: "week"; readonly month: "month"; readonly year: "year"; }; type UserDataLimitResetStrategyEnumKey = (typeof userDataLimitResetStrategyEnum)[keyof typeof userDataLimitResetStrategyEnum]; type UserDataLimitResetStrategy = UserDataLimitResetStrategyEnumKey; declare const userStatusEnum: { readonly active: "active"; readonly disabled: "disabled"; readonly limited: "limited"; readonly expired: "expired"; readonly on_hold: "on_hold"; }; type UserStatusEnumKey = (typeof userStatusEnum)[keyof typeof userStatusEnum]; type UserStatus = UserStatusEnumKey; type SubscriptionUserResponse = { /** * @type object */ proxies: object; expire?: (number | null) | null; /** * @description data_limit can be 0 or greater */ data_limit?: number | null; /** * @type string | undefined */ data_limit_reset_strategy?: UserDataLimitResetStrategy; sub_updated_at?: (string | null) | null; sub_last_user_agent?: (string | null) | null; online_at?: (string | null) | null; on_hold_expire_duration?: (number | null) | null; on_hold_timeout?: (string | null) | null; next_plan?: (NextPlanModel | null) | null; /** * @type string */ username: string; /** * @type string */ status: UserStatus; /** * @type integer */ used_traffic: number; /** * @default 0 * @type integer | undefined */ lifetime_used_traffic?: number; /** * @type string, date-time */ created_at: string; /** * @type array | undefined */ links?: string[]; /** * @default "" * @type string | undefined */ subscription_url?: string; }; type UserSubscriptionInfoPathParams = { /** * @type string */ token: string; }; /** * @description Successful Response */ type UserSubscriptionInfo200 = SubscriptionUserResponse; /** * @description Validation Error */ type UserSubscriptionInfo422 = HTTPValidationError; type UserSubscriptionInfoQueryResponse = UserSubscriptionInfo200; type UserSubscriptionInfoQuery = { Response: UserSubscriptionInfo200; PathParams: UserSubscriptionInfoPathParams; Errors: UserSubscriptionInfo422; }; type UserSubscriptionWithClientTypePathParams = { /** * @pattern sing-box|clash-meta|clash|outline|v2ray|v2ray-json * @type string */ client_type: string; /** * @type string */ token: string; }; type UserSubscriptionWithClientTypeHeaderParams = { /** * @default "" * @type string | undefined */ 'user-agent'?: string; }; /** * @description Successful Response */ type UserSubscriptionWithClientType200 = any; /** * @description Validation Error */ type UserSubscriptionWithClientType422 = HTTPValidationError; type UserSubscriptionWithClientTypeQueryResponse = UserSubscriptionWithClientType200; type UserSubscriptionWithClientTypeQuery = { Response: UserSubscriptionWithClientType200; PathParams: UserSubscriptionWithClientTypePathParams; HeaderParams: UserSubscriptionWithClientTypeHeaderParams; Errors: UserSubscriptionWithClientType422; }; /** * @description Successful Response */ type GetHosts200 = { [key: string]: ProxyHost[]; }; /** * @description Unauthorized */ type GetHosts401 = Unauthorized; /** * @description Forbidden */ type GetHosts403 = Forbidden; type GetHostsQueryResponse = GetHosts200; type GetHostsQuery = { Response: GetHosts200; Errors: GetHosts401 | GetHosts403; }; /** * @description Successful Response */ type GetInbounds200 = { [key: string]: ProxyInbound[]; }; /** * @description Unauthorized */ type GetInbounds401 = Unauthorized; type GetInboundsQueryResponse = GetInbounds200; type GetInboundsQuery = { Response: GetInbounds200; Errors: GetInbounds401; }; type SystemStats = { /** * @type string */ version: string; /** * @type integer */ mem_total: number; /** * @type integer */ mem_used: number; /** * @type integer */ cpu_cores: number; /** * @type number */ cpu_usage: number; /** * @type integer */ total_user: number; /** * @type integer */ online_users: number; /** * @type integer */ users_active: number; /** * @type integer */ users_on_hold: number; /** * @type integer */ users_disabled: number; /** * @type integer */ users_expired: number; /** * @type integer */ users_limited: number; /** * @type integer */ incoming_bandwidth: number; /** * @type integer */ outgoing_bandwidth: number; /** * @type integer */ incoming_bandwidth_speed: number; /** * @type integer */ outgoing_bandwidth_speed: number; }; /** * @description Successful Response */ type GetSystemStats200 = SystemStats; /** * @description Unauthorized */ type GetSystemStats401 = Unauthorized; type GetSystemStatsQueryResponse = GetSystemStats200; type GetSystemStatsQuery = { Response: GetSystemStats200; Errors: GetSystemStats401; }; /** * @description Successful Response */ type ModifyHosts200 = { [key: string]: ProxyHost[]; }; /** * @description Unauthorized */ type ModifyHosts401 = Unauthorized; /** * @description Forbidden */ type ModifyHosts403 = Forbidden; /** * @description Validation Error */ type ModifyHosts422 = HTTPValidationError; type ModifyHostsMutationRequest = { [key: string]: ProxyHost[]; }; type ModifyHostsMutationResponse = ModifyHosts200; type ModifyHostsMutation = { Response: ModifyHosts200; Request: ModifyHostsMutationRequest; Errors: ModifyHosts401 | ModifyHosts403 | ModifyHosts422; }; declare const userStatusCreateEnum: { readonly active: "active"; readonly on_hold: "on_hold"; }; type UserStatusCreateEnumKey = (typeof userStatusCreateEnum)[keyof typeof userStatusCreateEnum]; type UserStatusCreate = UserStatusCreateEnumKey; /** * @example [object Object] */ type UserCreate = { /** * @default [object Object] * @type object | undefined */ proxies?: { [key: string]: ProxySettings; }; expire?: (number | null) | null; /** * @description data_limit can be 0 or greater */ data_limit?: number | null; /** * @type string | undefined */ data_limit_reset_strategy?: UserDataLimitResetStrategy; /** * @default [object Object] * @type object | undefined */ inbounds?: { [key: string]: string[]; }; note?: (string | null) | null; sub_updated_at?: (string | null) | null; sub_last_user_agent?: (string | null) | null; online_at?: (string | null) | null; on_hold_expire_duration?: (number | null) | null; on_hold_timeout?: (string | null) | null; auto_delete_in_days?: (number | null) | null; next_plan?: (NextPlanModel | null) | null; /** * @type string */ username: string; /** * @type string | undefined */ status?: UserStatusCreate; }; type UserResponse = { /** * @type object */ proxies: object; expire?: (number | null) | null; /** * @description data_limit can be 0 or greater */ data_limit?: number | null; /** * @type string | undefined */ data_limit_reset_strategy?: UserDataLimitResetStrategy; /** * @default [object Object] * @type object | undefined */ inbounds?: { [key: string]: string[]; }; note?: (string | null) | null; sub_updated_at?: (string | null) | null; sub_last_user_agent?: (string | null) | null; online_at?: (string | null) | null; on_hold_expire_duration?: (number | null) | null; on_hold_timeout?: (string | null) | null; auto_delete_in_days?: (number | null) | null; next_plan?: (NextPlanModel | null) | null; /** * @type string */ username: string; /** * @type string */ status: UserStatus; /** * @type integer */ used_traffic: number; /** * @default 0 * @type integer | undefined */ lifetime_used_traffic?: number; /** * @type string, date-time */ created_at: string; /** * @type array | undefined */ links?: string[]; /** * @default "" * @type string | undefined */ subscription_url?: string; /** * @default [object Object] * @type object | undefined */ excluded_inbounds?: { [key: string]: string[]; }; admin?: Admin | null; }; type ActiveNextPlanPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type ActiveNextPlan200 = UserResponse; /** * @description Unauthorized */ type ActiveNextPlan401 = Unauthorized; /** * @description Forbidden */ type ActiveNextPlan403 = Forbidden; /** * @description Not found */ type ActiveNextPlan404 = NotFound; /** * @description Validation Error */ type ActiveNextPlan422 = HTTPValidationError; type ActiveNextPlanMutationResponse = ActiveNextPlan200; type ActiveNextPlanMutation = { Response: ActiveNextPlan200; PathParams: ActiveNextPlanPathParams; Errors: ActiveNextPlan401 | ActiveNextPlan403 | ActiveNextPlan404 | ActiveNextPlan422; }; /** * @description Successful Response */ type AddUser200 = UserResponse; /** * @description Bad request */ type AddUser400 = HTTPException; /** * @description Unauthorized */ type AddUser401 = Unauthorized; /** * @description Conflict */ type AddUser409 = Conflict; /** * @description Validation Error */ type AddUser422 = HTTPValidationError; /** * @example [object Object] */ type AddUserMutationRequest = UserCreate; type AddUserMutationResponse = AddUser200; type AddUserMutation = { Response: AddUser200; Request: AddUserMutationRequest; Errors: AddUser400 | AddUser401 | AddUser409 | AddUser422; }; type DeleteExpiredUsersQueryParams = { expired_after?: string | null; expired_before?: string | null; }; /** * @description Successful Response */ type DeleteExpiredUsers200 = string[]; /** * @description Unauthorized */ type DeleteExpiredUsers401 = Unauthorized; /** * @description Validation Error */ type DeleteExpiredUsers422 = HTTPValidationError; type DeleteExpiredUsersMutationResponse = DeleteExpiredUsers200; type DeleteExpiredUsersMutation = { Response: DeleteExpiredUsers200; QueryParams: DeleteExpiredUsersQueryParams; Errors: DeleteExpiredUsers401 | DeleteExpiredUsers422; }; type GetExpiredUsersQueryParams = { expired_after?: string | null; expired_before?: string | null; }; /** * @description Successful Response */ type GetExpiredUsers200 = string[]; /** * @description Unauthorized */ type GetExpiredUsers401 = Unauthorized; /** * @description Validation Error */ type GetExpiredUsers422 = HTTPValidationError; type GetExpiredUsersQueryResponse = GetExpiredUsers200; type GetExpiredUsersQuery = { Response: GetExpiredUsers200; QueryParams: GetExpiredUsersQueryParams; Errors: GetExpiredUsers401 | GetExpiredUsers422; }; type GetUserPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type GetUser200 = UserResponse; /** * @description Unauthorized */ type GetUser401 = Unauthorized; /** * @description Forbidden */ type GetUser403 = Forbidden; /** * @description Not found */ type GetUser404 = NotFound; /** * @description Validation Error */ type GetUser422 = HTTPValidationError; type GetUserQueryResponse = GetUser200; type GetUserQuery = { Response: GetUser200; PathParams: GetUserPathParams; Errors: GetUser401 | GetUser403 | GetUser404 | GetUser422; }; type UsersResponse = { /** * @type array */ users: UserResponse[]; /** * @type integer */ total: number; }; type GetUsersQueryParams = { /** * @type integer | undefined */ offset?: number; /** * @type integer | undefined */ limit?: number; /** * @type array | undefined */ username?: string[]; search?: string | null; admin?: string[] | null; /** * @type string | undefined */ status?: UserStatus; /** * @type string | undefined */ sort?: string; }; /** * @description Successful Response */ type GetUsers200 = UsersResponse; /** * @description Bad request */ type GetUsers400 = HTTPException; /** * @description Unauthorized */ type GetUsers401 = Unauthorized; /** * @description Forbidden */ type GetUsers403 = Forbidden; /** * @description Not found */ type GetUsers404 = NotFound; /** * @description Validation Error */ type GetUsers422 = HTTPValidationError; type GetUsersQueryResponse = GetUsers200; type GetUsersQuery = { Response: GetUsers200; QueryParams: GetUsersQueryParams; Errors: GetUsers400 | GetUsers401 | GetUsers403 | GetUsers404 | GetUsers422; }; type UserUsageResponse = { node_id?: number | null; /** * @type string */ node_name: string; /** * @type integer */ used_traffic: number; }; type UsersUsagesResponse = { /** * @type array */ usages: UserUsageResponse[]; }; type GetUsersUsageQueryParams = { /** * @default "" * @type string | undefined */ start?: string; /** * @default "" * @type string | undefined */ end?: string; admin?: string[] | null; }; /** * @description Successful Response */ type GetUsersUsage200 = UsersUsagesResponse; /** * @description Unauthorized */ type GetUsersUsage401 = Unauthorized; /** * @description Validation Error */ type GetUsersUsage422 = HTTPValidationError; type GetUsersUsageQueryResponse = GetUsersUsage200; type GetUsersUsageQuery = { Response: GetUsersUsage200; QueryParams: GetUsersUsageQueryParams; Errors: GetUsersUsage401 | GetUsersUsage422; }; type UserUsagesResponse = { /** * @type string */ username: string; /** * @type array */ usages: UserUsageResponse[]; }; type GetUserUsagePathParams = { /** * @type string */ username: string; }; type GetUserUsageQueryParams = { /** * @default "" * @type string | undefined */ start?: string; /** * @default "" * @type string | undefined */ end?: string; }; /** * @description Successful Response */ type GetUserUsage200 = UserUsagesResponse; /** * @description Unauthorized */ type GetUserUsage401 = Unauthorized; /** * @description Forbidden */ type GetUserUsage403 = Forbidden; /** * @description Not found */ type GetUserUsage404 = NotFound; /** * @description Validation Error */ type GetUserUsage422 = HTTPValidationError; type GetUserUsageQueryResponse = GetUserUsage200; type GetUserUsageQuery = { Response: GetUserUsage200; PathParams: GetUserUsagePathParams; QueryParams: GetUserUsageQueryParams; Errors: GetUserUsage401 | GetUserUsage403 | GetUserUsage404 | GetUserUsage422; }; declare const userStatusModifyEnum: { readonly active: "active"; readonly disabled: "disabled"; readonly on_hold: "on_hold"; }; type UserStatusModifyEnumKey = (typeof userStatusModifyEnum)[keyof typeof userStatusModifyEnum]; type UserStatusModify = UserStatusModifyEnumKey; /** * @example [object Object] */ type UserModify = { /** * @default [object Object] * @type object | undefined */ proxies?: { [key: string]: ProxySettings; }; expire?: (number | null) | null; /** * @description data_limit can be 0 or greater */ data_limit?: number | null; /** * @type string | undefined */ data_limit_reset_strategy?: UserDataLimitResetStrategy; /** * @default [object Object] * @type object | undefined */ inbounds?: { [key: string]: string[]; }; note?: (string | null) | null; sub_updated_at?: (string | null) | null; sub_last_user_agent?: (string | null) | null; online_at?: (string | null) | null; on_hold_expire_duration?: (number | null) | null; on_hold_timeout?: (string | null) | null; auto_delete_in_days?: (number | null) | null; next_plan?: (NextPlanModel | null) | null; /** * @type string | undefined */ status?: UserStatusModify; }; type ModifyUserPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type ModifyUser200 = UserResponse; /** * @description Bad request */ type ModifyUser400 = HTTPException; /** * @description Unauthorized */ type ModifyUser401 = Unauthorized; /** * @description Forbidden */ type ModifyUser403 = Forbidden; /** * @description Not found */ type ModifyUser404 = NotFound; /** * @description Validation Error */ type ModifyUser422 = HTTPValidationError; /** * @example [object Object] */ type ModifyUserMutationRequest = UserModify; type ModifyUserMutationResponse = ModifyUser200; type ModifyUserMutation = { Response: ModifyUser200; Request: ModifyUserMutationRequest; PathParams: ModifyUserPathParams; Errors: ModifyUser400 | ModifyUser401 | ModifyUser403 | ModifyUser404 | ModifyUser422; }; type RemoveUserPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type RemoveUser200 = any; /** * @description Unauthorized */ type RemoveUser401 = Unauthorized; /** * @description Forbidden */ type RemoveUser403 = Forbidden; /** * @description Not found */ type RemoveUser404 = NotFound; /** * @description Validation Error */ type RemoveUser422 = HTTPValidationError; type RemoveUserMutationResponse = RemoveUser200; type RemoveUserMutation = { Response: RemoveUser200; PathParams: RemoveUserPathParams; Errors: RemoveUser401 | RemoveUser403 | RemoveUser404 | RemoveUser422; }; type ResetUserDataUsagePathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type ResetUserDataUsage200 = UserResponse; /** * @description Unauthorized */ type ResetUserDataUsage401 = Unauthorized; /** * @description Forbidden */ type ResetUserDataUsage403 = Forbidden; /** * @description Not found */ type ResetUserDataUsage404 = NotFound; /** * @description Validation Error */ type ResetUserDataUsage422 = HTTPValidationError; type ResetUserDataUsageMutationResponse = ResetUserDataUsage200; type ResetUserDataUsageMutation = { Response: ResetUserDataUsage200; PathParams: ResetUserDataUsagePathParams; Errors: ResetUserDataUsage401 | ResetUserDataUsage403 | ResetUserDataUsage404 | ResetUserDataUsage422; }; /** * @description Successful Response */ type ResetUsersDataUsage200 = any; /** * @description Unauthorized */ type ResetUsersDataUsage401 = Unauthorized; /** * @description Forbidden */ type ResetUsersDataUsage403 = Forbidden; /** * @description Not found */ type ResetUsersDataUsage404 = NotFound; type ResetUsersDataUsageMutationResponse = ResetUsersDataUsage200; type ResetUsersDataUsageMutation = { Response: ResetUsersDataUsage200; Errors: ResetUsersDataUsage401 | ResetUsersDataUsage403 | ResetUsersDataUsage404; }; type RevokeUserSubscriptionPathParams = { /** * @type string */ username: string; }; /** * @description Successful Response */ type RevokeUserSubscription200 = UserResponse; /** * @description Unauthorized */ type RevokeUserSubscription401 = Unauthorized; /** * @description Forbidden */ type RevokeUserSubscription403 = Forbidden; /** * @description Not found */ type RevokeUserSubscription404 = NotFound; /** * @description Validation Error */ type RevokeUserSubscription422 = HTTPValidationError; type RevokeUserSubscriptionMutationResponse = RevokeUserSubscription200; type RevokeUserSubscriptionMutation = { Response: RevokeUserSubscription200; PathParams: RevokeUserSubscriptionPathParams; Errors: RevokeUserSubscription401 | RevokeUserSubscription403 | RevokeUserSubscription404 | RevokeUserSubscription422; }; type SetOwnerPathParams = { /** * @type string */ username: string; }; type SetOwnerQueryParams = { /** * @type string */ admin_username: string; }; /** * @description Successful Response */ type SetOwner200 = UserResponse; /** * @description Unauthorized */ type SetOwner401 = Unauthorized; /** * @description Validation Error */ type SetOwner422 = HTTPValidationError; type SetOwnerMutationResponse = SetOwner200; type SetOwnerMutation = { Response: SetOwner200; PathParams: SetOwnerPathParams; QueryParams: SetOwnerQueryParams; Errors: SetOwner401 | SetOwner422; }; /** * @example [object Object] */ type UserTemplateCreate = { name?: (string | null) | null; /** * @description data_limit can be 0 or greater */ data_limit?: number | null; /** * @description expire_duration can be 0 or greater in seconds */ expire_duration?: number | null; username_prefix?: string | null; username_suffix?: string | null; /** * @default [object Object] * @type object | undefined */ inbounds?: { [key: string]: string[]; }; }; type UserTemplateResponse = { name?: (string | null) | null; /** * @description data_limit can be 0 or greater */ data_limit?: number | null; /** * @description expire_duration can be 0 or greater in seconds */ expire_duration?: number | null; username_prefix?: string | null; username_suffix?: string | null; /** * @default [object Object] * @type object | undefined */ inbounds?: { [key: string]: string[]; }; /** * @type integer */ id: number; }; /** * @description Successful Response */ type AddUserTemplate200 = UserTemplateResponse; /** * @description Validation Error */ type AddUserTemplate422 = HTTPValidationError; /** * @example [object Object] */ type AddUserTemplateMutationRequest = UserTemplateCreate; type AddUserTemplateMutationResponse = AddUserTemplate200; type AddUserTemplateMutation = { Response: AddUserTemplate200; Request: AddUserTemplateMutationRequest; Errors: AddUserTemplate422; }; type GetUserTemplateEndpointPathParams = { /** * @type integer */ template_id: number; }; /** * @description Successful Response */ type GetUserTemplateEndpoint200 = UserTemplateResponse; /** * @description Validation Error */ type GetUserTemplateEndpoint422 = HTTPValidationError; type GetUserTemplateEndpointQueryResponse = GetUserTemplateEndpoint200; type GetUserTemplateEndpointQuery = { Response: GetUserTemplateEndpoint200; PathParams: GetUserTemplateEndpointPathParams; Errors: GetUserTemplateEndpoint422; }; type GetUserTemplatesQueryParams = { /** * @type integer | undefined */ offset?: number; /** * @type integer | undefined */ limit?: number; }; /** * @description Successful Response */ type GetUserTemplates200 = UserTemplateResponse[]; /** * @description Validation Error */ type GetUserTemplates422 = HTTPValidationError; type GetUserTemplatesQueryResponse = GetUserTemplates200; type GetUserTemplatesQuery = { Response: GetUserTemplates200; QueryParams: GetUserTemplatesQueryParams; Errors: GetUserTemplates422; }; /** * @example [object Object] */ type UserTemplateModify = { name?: (string | null) | null; /** * @description data_limit can be 0 or greater