marzban-sdk
Version:
Fully typed client SDK for the Marzban API, supporting both browser and Node.js environments.
1,361 lines (1,319 loc) • 116 kB
JavaScript
import z, { z as z$1 } from 'zod/v4';
import axios from 'axios';
import axiosRetry from 'axios-retry';
import chalk from 'chalk';
import crypto from 'crypto';
// src/config/config.ts
var logLevelSchema = z.enum(["debug", "info", "warn", "error"]);
var loggerOptionsSchema = z.object({
level: logLevelSchema.optional(),
timestamp: z.boolean().optional()
});
var loggerMethodSchema = z.custom((v) => typeof v === "function");
var loggerErrorMethodSchema = z.custom(
(v) => typeof v === "function"
);
var loggerObjectSchema = z.object({
debug: loggerMethodSchema,
info: loggerMethodSchema,
warn: loggerMethodSchema,
error: loggerErrorMethodSchema
});
var loggerConfigSchema = z.union([z.literal(false), loggerOptionsSchema, loggerObjectSchema]);
var webhookSchema = z.object({
secret: z.string().optional()
});
// src/config/config.ts
var configSchema = z$1.object({
baseUrl: z$1.url(),
username: z$1.string(),
password: z$1.string(),
timeout: z$1.number().int().positive().default(0).optional(),
retries: z$1.number().int().nonnegative().default(3).optional(),
token: z$1.string().optional(),
authenticateOnInit: z$1.boolean().default(true).optional(),
logger: loggerConfigSchema.optional(),
webhook: webhookSchema.optional()
});
// src/core/errors/codes.ts
var ERROR_CODES = {
CONFIG_INVALID: { code: "CONFIG_INVALID", message: "Invalid SDK configuration" },
NETWORK_HTTP_ERROR: { code: "NETWORK_HTTP_ERROR", message: "HTTP request failed" },
AUTH_TOKEN_FAILED: { code: "AUTH_TOKEN_FAILED", message: "Failed to retrieve access token" },
AUTH_FAILED: { code: "AUTH_FAILED", message: "Authentication failed" },
LOGGER_INVALID: {
code: "LOGGER_INVALID",
message: "Invalid logger option: must be false, LoggerOptions, or Logger instance"
},
WEBHOOK_SIGNATURE_ERROR: { code: "WEBHOOK_SIGNATURE_ERROR", message: "Invalid webhook signature" },
WEBHOOK_VALIDATION_ERROR: { code: "WEBHOOK_VALIDATION_ERROR", message: "Invalid webhook payload" }
};
// src/core/errors/sdk.error.ts
var SdkError = class _SdkError extends Error {
constructor(options, details) {
super(options.message);
this.name = new.target.name;
this.code = options.code;
this.details = details;
Object.setPrototypeOf(this, new.target.prototype);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, new.target);
}
}
static fromCode(code, details) {
const entry = Object.values(ERROR_CODES).find((e) => e.code === code);
const format = entry ?? { code, message: code };
return new _SdkError(format, details);
}
toJSON() {
return {
name: this.name,
code: this.code,
message: this.message,
details: this.details
};
}
};
// src/core/errors/categories/auth.error.ts
var AuthError = class extends SdkError {
constructor(details) {
super(ERROR_CODES.AUTH_FAILED, details);
}
};
var AuthTokenError = class extends SdkError {
constructor(details) {
super(ERROR_CODES.AUTH_TOKEN_FAILED, details);
}
};
// src/core/errors/categories/configuration.error.ts
var ConfigurationError = class extends SdkError {
constructor(details) {
super(ERROR_CODES.CONFIG_INVALID, details);
}
};
// src/core/errors/categories/http.error.ts
var HttpError = class extends SdkError {
constructor(details) {
super(ERROR_CODES.NETWORK_HTTP_ERROR, details);
}
};
// src/core/errors/categories/webhook.error.ts
var WebhookSignatureError = class extends SdkError {
constructor(details) {
super(ERROR_CODES.WEBHOOK_SIGNATURE_ERROR, details);
}
};
var WebhookValidationError = class extends SdkError {
constructor(details) {
super(ERROR_CODES.WEBHOOK_VALIDATION_ERROR, details);
}
};
// src/core/errors/guards/auth.guard.ts
var isAuthError = (error) => {
return error instanceof AuthError;
};
// src/core/errors/guards/configuration.guard.ts
var isConfigurationError = (error) => {
return error instanceof ConfigurationError;
};
// src/core/errors/guards/sdk.guard.ts
var isSdkError = (error) => {
return error instanceof SdkError;
};
// src/config/validate.ts
function validateConfig(config) {
const { data, success, error } = configSchema.safeParse(config);
if (!success) {
throw new ConfigurationError(error.issues);
}
return data;
}
// src/core/http/interceptors/auth.interceptors.ts
var setupAuthInterceptors = (client2, authService, config, logger) => {
logger.debug("Setting up authentication request interceptor", "AuthInterceptor");
client2.interceptors.request.use(
async (requestConfig) => {
await authService.waitForCurrentAuth();
const accessToken = authService.accessToken;
if (accessToken) {
requestConfig.headers.authorization = `Bearer ${accessToken}`;
logger.debug("Authorization header added to request", "AuthInterceptor");
} else {
logger.warn("No access token available for request", "AuthInterceptor");
}
return requestConfig;
},
(error) => {
logger.error("Request interceptor error", error, "AuthInterceptor");
if (error instanceof SdkError) return Promise.reject(error);
return Promise.reject(new HttpError(error));
}
);
logger.debug("Setting up authentication response interceptor", "AuthInterceptor");
client2.interceptors.response.use(
(response) => response,
async (error) => {
const retryConfig = error?.config;
if (error?.response?.status === 401 && !retryConfig?.sent) {
logger.warn("Received 401 Unauthorized, attempting to re-authenticate", "AuthInterceptor");
retryConfig.sent = true;
try {
await authService.authenticate(config.username, config.password);
const accessToken = authService.accessToken;
if (accessToken) {
retryConfig.headers.authorization = `Bearer ${accessToken}`;
logger.info("Re-authentication successful, retrying request", "AuthInterceptor");
return client2(retryConfig);
}
logger.error("Re-authentication failed: No access token received", null, "AuthInterceptor");
return Promise.reject(new HttpError("No access token after re-authentication"));
} catch (err) {
logger.error("Re-authentication failed", err, "AuthInterceptor");
if (err instanceof SdkError) return Promise.reject(err);
return Promise.reject(new HttpError(err));
}
}
if (error instanceof SdkError) return Promise.reject(error);
return Promise.reject(new HttpError(error));
}
);
};
// src/core/http/client.ts
function createClientFromAxios(instance) {
return async (requestConfig) => {
const promise = instance.request(requestConfig).catch((e) => {
throw e;
});
return promise;
};
}
var configureHttpClient = (baseUrl, authService, config, logger) => {
logger.info(`Configuring HTTP client with base URL: ${baseUrl}`, "HttpClient");
logger.debug(`HTTP client configuration: timeout=${config.timeout}s, retries=${config.retries}`, "HttpClient");
const instanceAxios = axios.create({ baseURL: baseUrl });
const instancePublic = axios.create({ baseURL: baseUrl });
logger.debug("Setting up authentication interceptors", "HttpClient");
setupAuthInterceptors(instanceAxios, authService, config, logger);
logger.debug(`Configuring retry logic: ${config?.retries ?? 3} retries with exponential backoff`, "HttpClient");
axiosRetry(instanceAxios, {
retries: config?.retries ?? 3,
retryDelay: (retryCount) => {
const delay = retryCount * 1e3;
logger.debug(`Retry attempt ${retryCount}, delay: ${delay}ms`, "HttpClient");
return delay;
}
});
axiosRetry(instancePublic, {
retries: config?.retries ?? 3,
retryDelay: (retryCount) => {
const delay = retryCount * 1e3;
logger.debug(`Public instance retry attempt ${retryCount}, delay: ${delay}ms`, "HttpClient");
return delay;
}
});
logger.info("HTTP client configuration completed successfully", "HttpClient");
return {
client: createClientFromAxios(instanceAxios),
getPublicInstance: () => instancePublic,
publicClient: createClientFromAxios(instancePublic)
};
};
var client = () => {
throw new Error("The http layer instance is not specified. You must use a pre-configured configureHttpClient layer");
};
var client_default = client;
var forbiddenSchema = z$1.object({
detail: z$1.optional(z$1.string().default("You are not allowed to ..."))
});
var validationErrorSchema = z$1.object({
loc: z$1.array(z$1.union([z$1.int(), z$1.string()])),
msg: z$1.string(),
type: z$1.string()
});
// src/gen/schemas/HTTPValidationErrorSchema.ts
var HTTPValidationErrorSchema = z$1.object({
get detail() {
return z$1.array(validationErrorSchema).optional();
}
});
var notFoundSchema = z$1.object({
detail: z$1.optional(z$1.string().default("Entity {} not found"))
});
var unauthorizedSchema = z$1.object({
detail: z$1.optional(z$1.string().default("Not authenticated"))
});
// src/gen/schemas/AdminSchema/activateAllDisabledUsersSchema.ts
var activateAllDisabledUsersPathParamsSchema = z$1.object({
username: z$1.string()
});
var activateAllDisabledUsers200Schema = z$1.any();
var activateAllDisabledUsers401Schema = z$1.lazy(
() => unauthorizedSchema
);
var activateAllDisabledUsers403Schema = z$1.lazy(
() => forbiddenSchema
);
var activateAllDisabledUsers404Schema = z$1.lazy(
() => notFoundSchema
);
var activateAllDisabledUsers422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var activateAllDisabledUsersMutationResponseSchema = z$1.lazy(
() => activateAllDisabledUsers200Schema
);
var bodyAdminTokenApiAdminTokenPostSchema = z$1.object({
grant_type: z$1.optional(z$1.union([z$1.string().regex(/password/), z$1.null()])),
username: z$1.string(),
password: z$1.string(),
scope: z$1.optional(z$1.string().default("")),
client_id: z$1.optional(z$1.union([z$1.string(), z$1.null()])),
client_secret: z$1.optional(z$1.union([z$1.string(), z$1.null()]))
});
var tokenSchema = z$1.object({
access_token: z$1.string(),
token_type: z$1.optional(z$1.string().default("bearer"))
});
// src/gen/schemas/AdminSchema/adminTokenSchema.ts
var adminToken200Schema = z$1.lazy(() => tokenSchema);
var adminToken401Schema = z$1.lazy(() => unauthorizedSchema);
var adminToken422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var adminTokenMutationRequestSchema = z$1.lazy(
() => bodyAdminTokenApiAdminTokenPostSchema
);
var adminTokenMutationResponseSchema = z$1.lazy(
() => adminToken200Schema
);
var adminCreateSchema = z$1.object({
username: z$1.string(),
is_sudo: z$1.boolean(),
telegram_id: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
discord_webhook: z$1.optional(z$1.union([z$1.string(), z$1.null()])),
users_usage: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
password: z$1.string()
});
var adminSchema = z$1.object({
username: z$1.string(),
is_sudo: z$1.boolean(),
telegram_id: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
discord_webhook: z$1.optional(z$1.union([z$1.string(), z$1.null()])),
users_usage: z$1.optional(z$1.union([z$1.int(), z$1.null()]))
});
var conflictSchema = z$1.object({
detail: z$1.optional(z$1.string().default("Entity already exists"))
});
// src/gen/schemas/AdminSchema/createAdminSchema.ts
var createAdmin200Schema = z$1.lazy(() => adminSchema);
var createAdmin401Schema = z$1.lazy(() => unauthorizedSchema);
var createAdmin403Schema = z$1.lazy(() => forbiddenSchema);
var createAdmin409Schema = z$1.lazy(() => conflictSchema);
var createAdmin422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var createAdminMutationRequestSchema = z$1.lazy(
() => adminCreateSchema
);
var createAdminMutationResponseSchema = z$1.lazy(
() => createAdmin200Schema
);
var disableAllActiveUsersPathParamsSchema = z$1.object({
username: z$1.string()
});
var disableAllActiveUsers200Schema = z$1.any();
var disableAllActiveUsers401Schema = z$1.lazy(
() => unauthorizedSchema
);
var disableAllActiveUsers403Schema = z$1.lazy(
() => forbiddenSchema
);
var disableAllActiveUsers404Schema = z$1.lazy(
() => notFoundSchema
);
var disableAllActiveUsers422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var disableAllActiveUsersMutationResponseSchema = z$1.lazy(
() => disableAllActiveUsers200Schema
);
var getAdminsQueryParamsSchema = z$1.object({
offset: z$1.optional(z$1.union([z$1.coerce.number().int(), z$1.null()])),
limit: z$1.optional(z$1.union([z$1.coerce.number().int(), z$1.null()])),
username: z$1.optional(z$1.union([z$1.string(), z$1.null()]))
}).optional();
var getAdmins200Schema = z$1.array(z$1.lazy(() => adminSchema));
var getAdmins401Schema = z$1.lazy(() => unauthorizedSchema);
var getAdmins403Schema = z$1.lazy(() => forbiddenSchema);
var getAdmins422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var getAdminsQueryResponseSchema = z$1.lazy(
() => getAdmins200Schema
);
var getAdminUsagePathParamsSchema = z$1.object({
username: z$1.string()
});
var getAdminUsage200Schema = z$1.int();
var getAdminUsage401Schema = z$1.lazy(() => unauthorizedSchema);
var getAdminUsage403Schema = z$1.lazy(() => forbiddenSchema);
var getAdminUsage422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var getAdminUsageQueryResponseSchema = z$1.lazy(
() => getAdminUsage200Schema
);
var getCurrentAdmin200Schema = z$1.lazy(() => adminSchema);
var getCurrentAdmin401Schema = z$1.lazy(() => unauthorizedSchema);
var getCurrentAdminQueryResponseSchema = z$1.lazy(
() => getCurrentAdmin200Schema
);
var adminModifySchema = z$1.object({
password: z$1.optional(z$1.union([z$1.string(), z$1.null()])),
is_sudo: z$1.boolean(),
telegram_id: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
discord_webhook: z$1.optional(z$1.union([z$1.string(), z$1.null()]))
});
// src/gen/schemas/AdminSchema/modifyAdminSchema.ts
var modifyAdminPathParamsSchema = z$1.object({
username: z$1.string()
});
var modifyAdmin200Schema = z$1.lazy(() => adminSchema);
var modifyAdmin401Schema = z$1.lazy(() => unauthorizedSchema);
var modifyAdmin403Schema = z$1.lazy(() => forbiddenSchema);
var modifyAdmin422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var modifyAdminMutationRequestSchema = z$1.lazy(
() => adminModifySchema
);
var modifyAdminMutationResponseSchema = z$1.lazy(
() => modifyAdmin200Schema
);
var removeAdminPathParamsSchema = z$1.object({
username: z$1.string()
});
var removeAdmin200Schema = z$1.any();
var removeAdmin401Schema = z$1.lazy(() => unauthorizedSchema);
var removeAdmin403Schema = z$1.lazy(() => forbiddenSchema);
var removeAdmin422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var removeAdminMutationResponseSchema = z$1.lazy(
() => removeAdmin200Schema
);
var resetAdminUsagePathParamsSchema = z$1.object({
username: z$1.string()
});
var resetAdminUsage200Schema = z$1.lazy(() => adminSchema);
var resetAdminUsage401Schema = z$1.lazy(() => unauthorizedSchema);
var resetAdminUsage403Schema = z$1.lazy(() => forbiddenSchema);
var resetAdminUsage422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var resetAdminUsageMutationResponseSchema = z$1.lazy(
() => resetAdminUsage200Schema
);
// src/gen/api/AdminApi/adminApi.ts
var adminApi = class {
#client;
constructor(config = {}) {
this.#client = config.client || client_default;
}
/**
* @description Authenticate an admin and issue a token.
* @summary Admin Token
* {@link /api/admin/token}
*/
async adminToken(data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = adminTokenMutationRequestSchema.parse(data);
const res = await request({
method: "POST",
url: `/api/admin/token`,
data: requestData,
...requestConfig,
headers: { "Content-Type": "application/x-www-form-urlencoded", ...requestConfig.headers }
});
return adminTokenMutationResponseSchema.parse(res.data);
}
/**
* @description Retrieve the current authenticated admin.
* @summary Get Current Admin
* {@link /api/admin}
*/
async getCurrentAdmin(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/api/admin`,
...requestConfig
});
return getCurrentAdminQueryResponseSchema.parse(res.data);
}
/**
* @description Create a new admin if the current admin has sudo privileges.
* @summary Create Admin
* {@link /api/admin}
*/
async createAdmin(data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = createAdminMutationRequestSchema.parse(data);
const res = await request({ method: "POST", url: `/api/admin`, data: requestData, ...requestConfig });
return createAdminMutationResponseSchema.parse(res.data);
}
/**
* @description Modify an existing admin's details.
* @summary Modify Admin
* {@link /api/admin/:username}
*/
async modifyAdmin(username, data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = modifyAdminMutationRequestSchema.parse(data);
const res = await request({ method: "PUT", url: `/api/admin/${username}`, data: requestData, ...requestConfig });
return modifyAdminMutationResponseSchema.parse(res.data);
}
/**
* @description Remove an admin from the database.
* @summary Remove Admin
* {@link /api/admin/:username}
*/
async removeAdmin(username, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "DELETE", url: `/api/admin/${username}`, ...requestConfig });
return removeAdminMutationResponseSchema.parse(res.data);
}
/**
* @description Fetch a list of admins with optional filters for pagination and username.
* @summary Get Admins
* {@link /api/admins}
*/
async getAdmins(params, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "GET", url: `/api/admins`, params, ...requestConfig });
return getAdminsQueryResponseSchema.parse(res.data);
}
/**
* @description Disable all active users under a specific admin
* @summary Disable All Active Users
* {@link /api/admin/:username/users/disable}
*/
async disableAllActiveUsers(username, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "POST", url: `/api/admin/${username}/users/disable`, ...requestConfig });
return disableAllActiveUsersMutationResponseSchema.parse(res.data);
}
/**
* @description Activate all disabled users under a specific admin
* @summary Activate All Disabled Users
* {@link /api/admin/:username/users/activate}
*/
async activateAllDisabledUsers(username, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "POST", url: `/api/admin/${username}/users/activate`, ...requestConfig });
return activateAllDisabledUsersMutationResponseSchema.parse(res.data);
}
/**
* @description Resets usage of admin.
* @summary Reset Admin Usage
* {@link /api/admin/usage/reset/:username}
*/
async resetAdminUsage(username, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "POST", url: `/api/admin/usage/reset/${username}`, ...requestConfig });
return resetAdminUsageMutationResponseSchema.parse(res.data);
}
/**
* @description Retrieve the usage of given admin.
* @summary Get Admin Usage
* {@link /api/admin/usage/:username}
*/
async getAdminUsage(username, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "GET", url: `/api/admin/usage/${username}`, ...requestConfig });
return getAdminUsageQueryResponseSchema.parse(res.data);
}
};
var getCoreConfig200Schema = z$1.object({});
var getCoreConfig401Schema = z$1.lazy(() => unauthorizedSchema);
var getCoreConfig403Schema = z$1.lazy(() => forbiddenSchema);
var getCoreConfigQueryResponseSchema = z$1.lazy(
() => getCoreConfig200Schema
);
var coreStatsSchema = z$1.object({
version: z$1.string(),
started: z$1.boolean(),
logs_websocket: z$1.string()
});
// src/gen/schemas/CoreSchema/getCoreStatsSchema.ts
var getCoreStats200Schema = z$1.lazy(() => coreStatsSchema);
var getCoreStats401Schema = z$1.lazy(() => unauthorizedSchema);
var getCoreStatsQueryResponseSchema = z$1.lazy(
() => getCoreStats200Schema
);
var modifyCoreConfig200Schema = z$1.object({});
var modifyCoreConfig401Schema = z$1.lazy(() => unauthorizedSchema);
var modifyCoreConfig403Schema = z$1.lazy(() => forbiddenSchema);
var modifyCoreConfig422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var modifyCoreConfigMutationRequestSchema = z$1.object(
{}
);
var modifyCoreConfigMutationResponseSchema = z$1.lazy(
() => modifyCoreConfig200Schema
);
var restartCore200Schema = z$1.any();
var restartCore401Schema = z$1.lazy(() => unauthorizedSchema);
var restartCore403Schema = z$1.lazy(() => forbiddenSchema);
var restartCoreMutationResponseSchema = z$1.lazy(
() => restartCore200Schema
);
// src/gen/api/CoreApi/coreApi.ts
var coreApi = class {
#client;
constructor(config = {}) {
this.#client = config.client || client_default;
}
/**
* @description Retrieve core statistics such as version and uptime.
* @summary Get Core Stats
* {@link /api/core}
*/
async getCoreStats(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/api/core`,
...requestConfig
});
return getCoreStatsQueryResponseSchema.parse(res.data);
}
/**
* @description Restart the core and all connected nodes.
* @summary Restart Core
* {@link /api/core/restart}
*/
async restartCore(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "POST", url: `/api/core/restart`, ...requestConfig });
return restartCoreMutationResponseSchema.parse(res.data);
}
/**
* @description Get the current core configuration.
* @summary Get Core Config
* {@link /api/core/config}
*/
async getCoreConfig(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "GET", url: `/api/core/config`, ...requestConfig });
return getCoreConfigQueryResponseSchema.parse(res.data);
}
/**
* @description Modify the core configuration and restart the core.
* @summary Modify Core Config
* {@link /api/core/config}
*/
async modifyCoreConfig(data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = modifyCoreConfigMutationRequestSchema.parse(data);
const res = await request({ method: "PUT", url: `/api/core/config`, data: requestData, ...requestConfig });
return modifyCoreConfigMutationResponseSchema.parse(res.data);
}
};
var nodeCreateSchema = z$1.object({
name: z$1.string(),
address: z$1.string(),
port: z$1.optional(z$1.int().default(62050)),
api_port: z$1.optional(z$1.int().default(62051)),
usage_coefficient: z$1.optional(z$1.number().gt(0).default(1)),
add_as_new_host: z$1.optional(z$1.boolean().default(true))
});
var nodeStatusSchema = z$1.enum([
"connected",
"connecting",
"error",
"disabled"
]);
// src/gen/schemas/nodeResponseSchema.ts
var nodeResponseSchema = z$1.object({
name: z$1.string(),
address: z$1.string(),
port: z$1.optional(z$1.int().default(62050)),
api_port: z$1.optional(z$1.int().default(62051)),
usage_coefficient: z$1.optional(z$1.number().gt(0).default(1)),
id: z$1.int(),
xray_version: z$1.optional(z$1.union([z$1.string(), z$1.null()])),
get status() {
return nodeStatusSchema;
},
message: z$1.optional(z$1.union([z$1.string(), z$1.null()]))
});
// src/gen/schemas/NodeSchema/addNodeSchema.ts
var addNode200Schema = z$1.lazy(() => nodeResponseSchema);
var addNode401Schema = z$1.lazy(() => unauthorizedSchema);
var addNode403Schema = z$1.lazy(() => forbiddenSchema);
var addNode409Schema = z$1.lazy(() => conflictSchema);
var addNode422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var addNodeMutationRequestSchema = z$1.lazy(
() => nodeCreateSchema
);
var addNodeMutationResponseSchema = z$1.lazy(
() => addNode200Schema
);
var getNodePathParamsSchema = z$1.object({
node_id: z$1.coerce.number().int()
});
var getNode200Schema = z$1.lazy(() => nodeResponseSchema);
var getNode401Schema = z$1.lazy(() => unauthorizedSchema);
var getNode403Schema = z$1.lazy(() => forbiddenSchema);
var getNode422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var getNodeQueryResponseSchema = z$1.lazy(() => getNode200Schema);
var nodeSettingsSchema = z$1.object({
min_node_version: z$1.optional(z$1.string().default("v0.2.0")),
certificate: z$1.string()
});
// src/gen/schemas/NodeSchema/getNodeSettingsSchema.ts
var getNodeSettings200Schema = z$1.lazy(() => nodeSettingsSchema);
var getNodeSettings401Schema = z$1.lazy(() => unauthorizedSchema);
var getNodeSettings403Schema = z$1.lazy(() => forbiddenSchema);
var getNodeSettingsQueryResponseSchema = z$1.lazy(
() => getNodeSettings200Schema
);
var getNodes200Schema = z$1.array(z$1.lazy(() => nodeResponseSchema));
var getNodes401Schema = z$1.lazy(() => unauthorizedSchema);
var getNodes403Schema = z$1.lazy(() => forbiddenSchema);
var getNodesQueryResponseSchema = z$1.lazy(
() => getNodes200Schema
);
var nodeUsageResponseSchema = z$1.object({
node_id: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
node_name: z$1.string(),
uplink: z$1.int(),
downlink: z$1.int()
});
// src/gen/schemas/nodesUsageResponseSchema.ts
var nodesUsageResponseSchema = z$1.object({
get usages() {
return z$1.array(nodeUsageResponseSchema);
}
});
// src/gen/schemas/NodeSchema/getUsageSchema.ts
var getUsageQueryParamsSchema = z$1.object({
start: z$1.string().default(""),
end: z$1.string().default("")
});
var getUsage200Schema = z$1.lazy(() => nodesUsageResponseSchema);
var getUsage401Schema = z$1.lazy(() => unauthorizedSchema);
var getUsage403Schema = z$1.lazy(() => forbiddenSchema);
var getUsage422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var getUsageQueryResponseSchema = z$1.lazy(
() => getUsage200Schema
);
var nodeModifySchema = z$1.object({
name: z$1.union([z$1.string(), z$1.null()]).nullish(),
address: z$1.union([z$1.string(), z$1.null()]).nullish(),
port: z$1.union([z$1.int(), z$1.null()]).nullish(),
api_port: z$1.union([z$1.int(), z$1.null()]).nullish(),
usage_coefficient: z$1.union([z$1.number(), z$1.null()]).nullish(),
get status() {
return z$1.union([nodeStatusSchema, z$1.null()]).nullish();
}
});
// src/gen/schemas/NodeSchema/modifyNodeSchema.ts
var modifyNodePathParamsSchema = z$1.object({
node_id: z$1.coerce.number().int()
});
var modifyNode200Schema = z$1.lazy(() => nodeResponseSchema);
var modifyNode401Schema = z$1.lazy(() => unauthorizedSchema);
var modifyNode403Schema = z$1.lazy(() => forbiddenSchema);
var modifyNode422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var modifyNodeMutationRequestSchema = z$1.lazy(
() => nodeModifySchema
);
var modifyNodeMutationResponseSchema = z$1.lazy(
() => modifyNode200Schema
);
var reconnectNodePathParamsSchema = z$1.object({
node_id: z$1.coerce.number().int()
});
var reconnectNode200Schema = z$1.any();
var reconnectNode401Schema = z$1.lazy(() => unauthorizedSchema);
var reconnectNode403Schema = z$1.lazy(() => forbiddenSchema);
var reconnectNode422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var reconnectNodeMutationResponseSchema = z$1.lazy(
() => reconnectNode200Schema
);
var removeNodePathParamsSchema = z$1.object({
node_id: z$1.coerce.number().int()
});
var removeNode200Schema = z$1.any();
var removeNode401Schema = z$1.lazy(() => unauthorizedSchema);
var removeNode403Schema = z$1.lazy(() => forbiddenSchema);
var removeNode422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var removeNodeMutationResponseSchema = z$1.lazy(
() => removeNode200Schema
);
// src/gen/api/NodeApi/nodeApi.ts
var nodeApi = class {
#client;
constructor(config = {}) {
this.#client = config.client || client_default;
}
/**
* @description Retrieve the current node settings, including TLS certificate.
* @summary Get Node Settings
* {@link /api/node/settings}
*/
async getNodeSettings(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "GET", url: `/api/node/settings`, ...requestConfig });
return getNodeSettingsQueryResponseSchema.parse(res.data);
}
/**
* @description Add a new node to the database and optionally add it as a host.
* @summary Add Node
* {@link /api/node}
*/
async addNode(data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = addNodeMutationRequestSchema.parse(data);
const res = await request({ method: "POST", url: `/api/node`, data: requestData, ...requestConfig });
return addNodeMutationResponseSchema.parse(res.data);
}
/**
* @description Retrieve details of a specific node by its ID.
* @summary Get Node
* {@link /api/node/:node_id}
*/
async getNode(nodeId, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request(
{ method: "GET", url: `/api/node/${nodeId}`, ...requestConfig }
);
return getNodeQueryResponseSchema.parse(res.data);
}
/**
* @description Update a node's details. Only accessible to sudo admins.
* @summary Modify Node
* {@link /api/node/:node_id}
*/
async modifyNode(nodeId, data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = modifyNodeMutationRequestSchema.parse(data);
const res = await request({ method: "PUT", url: `/api/node/${nodeId}`, data: requestData, ...requestConfig });
return modifyNodeMutationResponseSchema.parse(res.data);
}
/**
* @description Delete a node and remove it from xray in the background.
* @summary Remove Node
* {@link /api/node/:node_id}
*/
async removeNode(nodeId, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "DELETE", url: `/api/node/${nodeId}`, ...requestConfig });
return removeNodeMutationResponseSchema.parse(res.data);
}
/**
* @description Retrieve a list of all nodes. Accessible only to sudo admins.
* @summary Get Nodes
* {@link /api/nodes}
*/
async getNodes(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/api/nodes`,
...requestConfig
});
return getNodesQueryResponseSchema.parse(res.data);
}
/**
* @description Trigger a reconnection for the specified node. Only accessible to sudo admins.
* @summary Reconnect Node
* {@link /api/node/:node_id/reconnect}
*/
async reconnectNode(nodeId, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "POST", url: `/api/node/${nodeId}/reconnect`, ...requestConfig });
return reconnectNodeMutationResponseSchema.parse(res.data);
}
/**
* @description Retrieve usage statistics for nodes within a specified date range.
* @summary Get Usage
* {@link /api/nodes/usage}
*/
async getUsage(params, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({ method: "GET", url: `/api/nodes/usage`, params, ...requestConfig });
return getUsageQueryResponseSchema.parse(res.data);
}
};
var userGetUsagePathParamsSchema = z$1.object({
token: z$1.string()
});
var userGetUsageQueryParamsSchema = z$1.object({
start: z$1.string().default(""),
end: z$1.string().default("")
});
var userGetUsage200Schema = z$1.any();
var userGetUsage422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var userGetUsageQueryResponseSchema = z$1.lazy(
() => userGetUsage200Schema
);
var nextPlanModelSchema = z$1.object({
data_limit: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
expire: z$1.optional(z$1.union([z$1.int(), z$1.null()])),
add_remaining_traffic: z$1.optional(z$1.boolean().default(false)),
fire_on_either: z$1.optional(z$1.boolean().default(true))
});
var userDataLimitResetStrategySchema = z$1.enum([
"no_reset",
"day",
"week",
"month",
"year"
]);
var userStatusSchema = z$1.enum([
"active",
"disabled",
"limited",
"expired",
"on_hold"
]);
// src/gen/schemas/subscriptionUserResponseSchema.ts
var subscriptionUserResponseSchema = z$1.object({
proxies: z$1.object({}),
expire: z$1.union([z$1.int(), z$1.null()]).nullish(),
data_limit: z$1.optional(z$1.union([z$1.int(), z$1.null()]).describe("data_limit can be 0 or greater")),
get data_limit_reset_strategy() {
return userDataLimitResetStrategySchema.optional();
},
sub_updated_at: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
sub_last_user_agent: z$1.union([z$1.string(), z$1.null()]).nullish(),
online_at: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
on_hold_expire_duration: z$1.union([z$1.int(), z$1.null()]).nullish(),
on_hold_timeout: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
get next_plan() {
return z$1.union([nextPlanModelSchema, z$1.null()]).nullish();
},
username: z$1.string(),
get status() {
return userStatusSchema;
},
used_traffic: z$1.int(),
lifetime_used_traffic: z$1.optional(z$1.int().default(0)),
created_at: z$1.iso.datetime({ local: true }),
links: z$1.optional(z$1.array(z$1.string())),
subscription_url: z$1.optional(z$1.string().default(""))
});
// src/gen/schemas/SubscriptionSchema/userSubscriptionInfoSchema.ts
var userSubscriptionInfoPathParamsSchema = z$1.object({
token: z$1.string()
});
var userSubscriptionInfo200Schema = z$1.lazy(
() => subscriptionUserResponseSchema
);
var userSubscriptionInfo422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var userSubscriptionInfoQueryResponseSchema = z$1.lazy(
() => userSubscriptionInfo200Schema
);
var userSubscriptionPathParamsSchema = z$1.object({
token: z$1.string()
});
var userSubscriptionHeaderParamsSchema = z$1.object({
"user-agent": z$1.string().default("")
});
var userSubscription200Schema = z$1.any();
var userSubscription422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var userSubscriptionQueryResponseSchema = z$1.lazy(
() => userSubscription200Schema
);
var userSubscriptionWithClientTypePathParamsSchema = z$1.object({
client_type: z$1.string().regex(/sing-box|clash-meta|clash|outline|v2ray|v2ray-json/),
token: z$1.string()
});
var userSubscriptionWithClientTypeHeaderParamsSchema = z$1.object({
"user-agent": z$1.string().default("")
});
var userSubscriptionWithClientType200Schema = z$1.any();
var userSubscriptionWithClientType422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var userSubscriptionWithClientTypeQueryResponseSchema = z$1.lazy(
() => userSubscriptionWithClientType200Schema
);
// src/gen/api/SubscriptionApi/subscriptionApi.ts
var subscriptionApi = class {
#client;
constructor(config = {}) {
this.#client = config.client || client_default;
}
/**
* @description Provides a subscription link based on the user agent (Clash, V2Ray, etc.).
* @summary User Subscription
* {@link /sub/:token/}
*/
async userSubscription(token, headers, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/sub/${token}/`,
...requestConfig,
headers: { ...headers, ...requestConfig.headers }
});
return userSubscriptionQueryResponseSchema.parse(res.data);
}
/**
* @description Retrieves detailed information about the user's subscription.
* @summary User Subscription Info
* {@link /sub/:token/info}
*/
async userSubscriptionInfo(token, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request(
{ method: "GET", url: `/sub/${token}/info`, ...requestConfig }
);
return userSubscriptionInfoQueryResponseSchema.parse(res.data);
}
/**
* @description Fetches the usage statistics for the user within a specified date range.
* @summary User Get Usage
* {@link /sub/:token/usage}
*/
async userGetUsage(token, params, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/sub/${token}/usage`,
params,
...requestConfig
});
return userGetUsageQueryResponseSchema.parse(res.data);
}
/**
* @description Provides a subscription link based on the specified client type (e.g., Clash, V2Ray).
* @summary User Subscription With Client Type
* {@link /sub/:token/:client_type}
*/
async userSubscriptionWithClientType(clientType, token, headers, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/sub/${token}/${clientType}`,
...requestConfig,
headers: { ...headers, ...requestConfig.headers }
});
return userSubscriptionWithClientTypeQueryResponseSchema.parse(res.data);
}
};
var proxyHostALPNSchema = z$1.enum([
"",
"h3",
"h2",
"http/1.1",
"h3,h2,http/1.1",
"h3,h2",
"h2,http/1.1"
]);
var proxyHostFingerprintSchema = z$1.enum([
"",
"chrome",
"firefox",
"safari",
"ios",
"android",
"edge",
"360",
"qq",
"random",
"randomized"
]);
var proxyHostSecuritySchema = z$1.enum([
"inbound_default",
"none",
"tls"
]);
// src/gen/schemas/proxyHostSchema.ts
var proxyHostSchema = z$1.object({
remark: z$1.string(),
address: z$1.string(),
port: z$1.union([z$1.int(), z$1.null()]).nullish(),
sni: z$1.union([z$1.string(), z$1.null()]).nullish(),
host: z$1.union([z$1.string(), z$1.null()]).nullish(),
path: z$1.union([z$1.string(), z$1.null()]).nullish(),
get security() {
return proxyHostSecuritySchema.optional();
},
get alpn() {
return proxyHostALPNSchema.optional();
},
get fingerprint() {
return proxyHostFingerprintSchema.optional();
},
allowinsecure: z$1.optional(z$1.union([z$1.boolean(), z$1.null()])),
is_disabled: z$1.optional(z$1.union([z$1.boolean(), z$1.null()])),
mux_enable: z$1.optional(z$1.union([z$1.boolean(), z$1.null()])),
fragment_setting: z$1.union([z$1.string(), z$1.null()]).nullish(),
noise_setting: z$1.union([z$1.string(), z$1.null()]).nullish(),
random_user_agent: z$1.optional(z$1.union([z$1.boolean(), z$1.null()])),
use_sni_as_host: z$1.optional(z$1.union([z$1.boolean(), z$1.null()]))
});
// src/gen/schemas/SystemSchema/getHostsSchema.ts
var getHosts200Schema = z$1.object({}).catchall(z$1.array(z$1.lazy(() => proxyHostSchema)));
var getHosts401Schema = z$1.lazy(() => unauthorizedSchema);
var getHosts403Schema = z$1.lazy(() => forbiddenSchema);
var getHostsQueryResponseSchema = z$1.lazy(
() => getHosts200Schema
);
var proxyTypesSchema = z$1.enum(["vmess", "vless", "trojan", "shadowsocks"]);
// src/gen/schemas/proxyInboundSchema.ts
var proxyInboundSchema = z$1.object({
tag: z$1.string(),
get protocol() {
return proxyTypesSchema;
},
network: z$1.string(),
tls: z$1.string(),
port: z$1.union([z$1.int(), z$1.string()])
});
// src/gen/schemas/SystemSchema/getInboundsSchema.ts
var getInbounds200Schema = z$1.object({}).catchall(z$1.array(z$1.lazy(() => proxyInboundSchema)));
var getInbounds401Schema = z$1.lazy(() => unauthorizedSchema);
var getInboundsQueryResponseSchema = z$1.lazy(
() => getInbounds200Schema
);
var systemStatsSchema = z$1.object({
version: z$1.string(),
mem_total: z$1.int(),
mem_used: z$1.int(),
cpu_cores: z$1.int(),
cpu_usage: z$1.number(),
total_user: z$1.int(),
online_users: z$1.int(),
users_active: z$1.int(),
users_on_hold: z$1.int(),
users_disabled: z$1.int(),
users_expired: z$1.int(),
users_limited: z$1.int(),
incoming_bandwidth: z$1.int(),
outgoing_bandwidth: z$1.int(),
incoming_bandwidth_speed: z$1.int(),
outgoing_bandwidth_speed: z$1.int()
});
// src/gen/schemas/SystemSchema/getSystemStatsSchema.ts
var getSystemStats200Schema = z$1.lazy(() => systemStatsSchema);
var getSystemStats401Schema = z$1.lazy(() => unauthorizedSchema);
var getSystemStatsQueryResponseSchema = z$1.lazy(
() => getSystemStats200Schema
);
var modifyHosts200Schema = z$1.object({}).catchall(z$1.array(z$1.lazy(() => proxyHostSchema)));
var modifyHosts401Schema = z$1.lazy(() => unauthorizedSchema);
var modifyHosts403Schema = z$1.lazy(() => forbiddenSchema);
var modifyHosts422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var modifyHostsMutationRequestSchema = z$1.object({}).catchall(z$1.array(z$1.lazy(() => proxyHostSchema)));
var modifyHostsMutationResponseSchema = z$1.lazy(
() => modifyHosts200Schema
);
// src/gen/api/SystemApi/systemApi.ts
var systemApi = class {
#client;
constructor(config = {}) {
this.#client = config.client || client_default;
}
/**
* @description Fetch system stats including memory, CPU, and user metrics.
* @summary Get System Stats
* {@link /api/system}
*/
async getSystemStats(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/api/system`,
...requestConfig
});
return getSystemStatsQueryResponseSchema.parse(res.data);
}
/**
* @description Retrieve inbound configurations grouped by protocol.
* @summary Get Inbounds
* {@link /api/inbounds}
*/
async getInbounds(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/api/inbounds`,
...requestConfig
});
return getInboundsQueryResponseSchema.parse(res.data);
}
/**
* @description Get a list of proxy hosts grouped by inbound tag.
* @summary Get Hosts
* {@link /api/hosts}
*/
async getHosts(config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const res = await request({
method: "GET",
url: `/api/hosts`,
...requestConfig
});
return getHostsQueryResponseSchema.parse(res.data);
}
/**
* @description Modify proxy hosts and update the configuration.
* @summary Modify Hosts
* {@link /api/hosts}
*/
async modifyHosts(data, config = {}) {
const { client: request = this.#client, ...requestConfig } = config;
const requestData = modifyHostsMutationRequestSchema.parse(data);
const res = await request({ method: "PUT", url: `/api/hosts`, data: requestData, ...requestConfig });
return modifyHostsMutationResponseSchema.parse(res.data);
}
};
var userResponseSchema = z$1.object({
proxies: z$1.object({}),
expire: z$1.union([z$1.int(), z$1.null()]).nullish(),
data_limit: z$1.optional(z$1.union([z$1.int(), z$1.null()]).describe("data_limit can be 0 or greater")),
get data_limit_reset_strategy() {
return userDataLimitResetStrategySchema.optional();
},
inbounds: z$1.optional(z$1.object({}).catchall(z$1.array(z$1.string())).default({})),
note: z$1.union([z$1.string(), z$1.null()]).nullish(),
sub_updated_at: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
sub_last_user_agent: z$1.union([z$1.string(), z$1.null()]).nullish(),
online_at: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
on_hold_expire_duration: z$1.union([z$1.int(), z$1.null()]).nullish(),
on_hold_timeout: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
auto_delete_in_days: z$1.union([z$1.int(), z$1.null()]).nullish(),
get next_plan() {
return z$1.union([nextPlanModelSchema, z$1.null()]).nullish();
},
username: z$1.string(),
get status() {
return userStatusSchema;
},
used_traffic: z$1.int(),
lifetime_used_traffic: z$1.optional(z$1.int().default(0)),
created_at: z$1.iso.datetime({ local: true }),
links: z$1.optional(z$1.array(z$1.string())),
subscription_url: z$1.optional(z$1.string().default("")),
excluded_inbounds: z$1.optional(z$1.object({}).catchall(z$1.array(z$1.string())).default({})),
get admin() {
return z$1.union([adminSchema, z$1.null()]).optional();
}
});
// src/gen/schemas/UserSchema/activeNextPlanSchema.ts
var activeNextPlanPathParamsSchema = z$1.object({
username: z$1.string()
});
var activeNextPlan200Schema = z$1.lazy(() => userResponseSchema);
var activeNextPlan401Schema = z$1.lazy(() => unauthorizedSchema);
var activeNextPlan403Schema = z$1.lazy(() => forbiddenSchema);
var activeNextPlan404Schema = z$1.lazy(() => notFoundSchema);
var activeNextPlan422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var activeNextPlanMutationResponseSchema = z$1.lazy(
() => activeNextPlan200Schema
);
var HTTPExceptionSchema = z$1.object({
detail: z$1.string()
});
var proxySettingsSchema = z$1.object({});
var userStatusCreateSchema = z$1.enum(["active", "on_hold"]);
// src/gen/schemas/userCreateSchema.ts
var userCreateSchema = z$1.object({
proxies: z$1.optional(
z$1.object({}).catchall(z$1.lazy(() => proxySettingsSchema)).default({})
),
expire: z$1.union([z$1.int(), z$1.null()]).nullish(),
data_limit: z$1.optional(z$1.union([z$1.int(), z$1.null()]).describe("data_limit can be 0 or greater")),
get data_limit_reset_strategy() {
return userDataLimitResetStrategySchema.optional();
},
inbounds: z$1.optional(z$1.object({}).catchall(z$1.array(z$1.string())).default({})),
note: z$1.union([z$1.string(), z$1.null()]).nullish(),
sub_updated_at: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
sub_last_user_agent: z$1.union([z$1.string(), z$1.null()]).nullish(),
online_at: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
on_hold_expire_duration: z$1.union([z$1.int(), z$1.null()]).nullish(),
on_hold_timeout: z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]).nullish(),
auto_delete_in_days: z$1.union([z$1.int(), z$1.null()]).nullish(),
get next_plan() {
return z$1.union([nextPlanModelSchema, z$1.null()]).nullish();
},
username: z$1.string(),
get status() {
return userStatusCreateSchema.optional();
}
});
// src/gen/schemas/UserSchema/addUserSchema.ts
var addUser200Schema = z$1.lazy(() => userResponseSchema);
var addUser400Schema = z$1.lazy(() => HTTPExceptionSchema);
var addUser401Schema = z$1.lazy(() => unauthorizedSchema);
var addUser409Schema = z$1.lazy(() => conflictSchema);
var addUser422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var addUserMutationRequestSchema = z$1.lazy(
() => userCreateSchema
);
var addUserMutationResponseSchema = z$1.lazy(
() => addUser200Schema
);
var deleteExpiredUsersQueryParamsSchema = z$1.object({
expired_after: z$1.optional(z$1.union([z$1.iso.datetime({ local: true }), z$1.null()])),
expired_before: z$1.optional(z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]))
}).optional();
var deleteExpiredUsers200Schema = z$1.array(z$1.string());
var deleteExpiredUsers401Schema = z$1.lazy(
() => unauthorizedSchema
);
var deleteExpiredUsers422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var deleteExpiredUsersMutationResponseSchema = z$1.lazy(
() => deleteExpiredUsers200Schema
);
var getExpiredUsersQueryParamsSchema = z$1.object({
expired_after: z$1.optional(z$1.union([z$1.iso.datetime({ local: true }), z$1.null()])),
expired_before: z$1.optional(z$1.union([z$1.iso.datetime({ local: true }), z$1.null()]))
}).optional();
var getExpiredUsers200Schema = z$1.array(z$1.string());
var getExpiredUsers401Schema = z$1.lazy(() => unauthorizedSchema);
var getExpiredUsers422Schema = z$1.lazy(
() => HTTPValidationErrorSchema
);
var getExpiredUsersQueryResponseSchema = z$1.lazy(
() => getExpiredUsers200Schema
);
var getUserPathParamsSchema = z$1.object({
username: z$1.string()
});
var getUser200Schema = z$1.lazy(() => userResponseSchema);
var getUser401Schema = z$1.lazy(() => unauthorizedSchema);
var getUser403Schema = z$1.lazy(() => forbiddenSchema);
var getUser404Schema = z$1.lazy(() => notFoundSchema);
var getUser422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var getUserQueryResponseSchema = z$1.lazy(() => getUser200Schema);
var usersResponseSchema = z$1.object({
get users() {
return z$1.array(userResponseSchema);
},
total: z$1.int()
});
// src/gen/schemas/UserSchema/getUsersSchema.ts
var getUsersQueryParamsSchema = z$1.object({
offset: z$1.optional(z$1.coerce.number().int()),
limit: z$1.optional(z$1.coerce.number().int()),
username: z$1.optional(z$1.array(z$1.string())),
search: z$1.optional(z$1.union([z$1.string(), z$1.null()])),
admin: z$1.optional(z$1.union([z$1.array(z$1.string()), z$1.null()])),
get status() {
return userStatusSchema.optional();
},
sort: z$1.optional(z$1.string())
}).optional();
var getUsers200Schema = z$1.lazy(() => usersResponseSchema);
var getUsers400Schema = z$1.lazy(() => HTTPExceptionSchema);
var getUsers401Schema = z$1.lazy(() => unauthorizedSchema);
var getUsers403Schema = z$1.lazy(() => forbiddenSchema);
var getUsers404Schema = z$1.lazy(() => notFoundSchema);
var getUsers422Schema = z$1.lazy(() => HTTPValidationErrorSchema);
var getUsersQueryResponseSchema = z$1.lazy(
() => getUs