2026-05-25 14:02:27 +00:00
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
|
|
|
|
export const NodeRecordSchema = z.object({
|
|
|
|
|
id: z.number(),
|
|
|
|
|
name: z.string().optional(),
|
|
|
|
|
remark: z.string().optional(),
|
|
|
|
|
scheme: z.string().optional(),
|
|
|
|
|
address: z.string().optional(),
|
|
|
|
|
port: z.number().optional(),
|
|
|
|
|
basePath: z.string().optional(),
|
|
|
|
|
apiToken: z.string().optional(),
|
|
|
|
|
enable: z.boolean().optional(),
|
|
|
|
|
status: z.string().optional(),
|
|
|
|
|
latencyMs: z.number().optional(),
|
|
|
|
|
cpuPct: z.number().optional(),
|
|
|
|
|
memPct: z.number().optional(),
|
|
|
|
|
xrayVersion: z.string().optional(),
|
|
|
|
|
panelVersion: z.string().optional(),
|
|
|
|
|
uptimeSecs: z.number().optional(),
|
|
|
|
|
inboundCount: z.number().optional(),
|
|
|
|
|
clientCount: z.number().optional(),
|
|
|
|
|
onlineCount: z.number().optional(),
|
|
|
|
|
depletedCount: z.number().optional(),
|
|
|
|
|
lastHeartbeat: z.number().optional(),
|
|
|
|
|
lastError: z.string().optional(),
|
|
|
|
|
allowPrivateAddress: z.boolean().optional(),
|
|
|
|
|
}).loose();
|
|
|
|
|
|
|
|
|
|
export const NodeListSchema = z.array(NodeRecordSchema);
|
|
|
|
|
|
feat(frontend): extend Zod validation to remaining query/mutation hooks
Adds Zod schemas for client/inbound/xray/node-probe endpoints and wires
useNodeMutations, useClients, useInbounds, useXraySetting, useDatepicker
through parseMsg. Drops the duplicated per-file ApiMsg<T> interfaces and
the local ClientRecord / OutboundTrafficRow / XraySettingsValue / DefaultsPayload
declarations in favour of schema-inferred types re-exported from the
new src/schemas/ modules.
API boundary now validates: clients list/paged, clients onlines,
clients lastOnline, clients get/hydrate, inbounds slim, inbounds get,
inbounds options, defaultSettings, xray config, xray outbounds traffic,
xray testOutbound, xray getXrayResult, getDefaultJsonConfig, nodes probe,
nodes test. Mutation responses that consume obj (bulkAdjust, delDepleted,
nodes probe / test) get response validation; pass-through mutations stay
agnostic. NodeFormModal type-aligned to Msg<ProbeResult>.
2026-05-25 14:14:00 +00:00
|
|
|
export const ProbeResultSchema = z.object({
|
|
|
|
|
status: z.string(),
|
|
|
|
|
latencyMs: z.number().optional(),
|
|
|
|
|
xrayVersion: z.string().optional(),
|
|
|
|
|
error: z.string().optional(),
|
|
|
|
|
}).loose();
|
|
|
|
|
|
2026-05-25 14:02:27 +00:00
|
|
|
export type NodeRecord = z.infer<typeof NodeRecordSchema>;
|
feat(frontend): extend Zod validation to remaining query/mutation hooks
Adds Zod schemas for client/inbound/xray/node-probe endpoints and wires
useNodeMutations, useClients, useInbounds, useXraySetting, useDatepicker
through parseMsg. Drops the duplicated per-file ApiMsg<T> interfaces and
the local ClientRecord / OutboundTrafficRow / XraySettingsValue / DefaultsPayload
declarations in favour of schema-inferred types re-exported from the
new src/schemas/ modules.
API boundary now validates: clients list/paged, clients onlines,
clients lastOnline, clients get/hydrate, inbounds slim, inbounds get,
inbounds options, defaultSettings, xray config, xray outbounds traffic,
xray testOutbound, xray getXrayResult, getDefaultJsonConfig, nodes probe,
nodes test. Mutation responses that consume obj (bulkAdjust, delDepleted,
nodes probe / test) get response validation; pass-through mutations stay
agnostic. NodeFormModal type-aligned to Msg<ProbeResult>.
2026-05-25 14:14:00 +00:00
|
|
|
export type ProbeResult = z.infer<typeof ProbeResultSchema>;
|