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
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
2026-05-25 14:30:48 +00:00
|
|
|
const nullableStringArray = z.array(z.string()).nullable().transform((v) => v ?? []);
|
|
|
|
|
const nullableNumberArray = z.array(z.number()).nullable().transform((v) => v ?? []);
|
|
|
|
|
|
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 ClientTrafficSchema = z.object({
|
|
|
|
|
up: z.number().optional(),
|
|
|
|
|
down: z.number().optional(),
|
|
|
|
|
total: z.number().optional(),
|
|
|
|
|
expiryTime: z.number().optional(),
|
|
|
|
|
enable: z.boolean().optional(),
|
|
|
|
|
lastOnline: z.number().optional(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const ClientRecordSchema = z.object({
|
2026-05-25 14:30:48 +00:00
|
|
|
id: z.number().optional(),
|
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
|
|
|
email: z.string(),
|
|
|
|
|
subId: z.string().optional(),
|
|
|
|
|
uuid: z.string().optional(),
|
|
|
|
|
password: z.string().optional(),
|
|
|
|
|
auth: z.string().optional(),
|
|
|
|
|
flow: z.string().optional(),
|
2026-05-25 14:30:48 +00:00
|
|
|
security: z.string().optional(),
|
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
|
|
|
totalGB: z.number().optional(),
|
|
|
|
|
expiryTime: z.number().optional(),
|
|
|
|
|
limitIp: z.number().optional(),
|
|
|
|
|
tgId: z.union([z.number(), z.string()]).optional(),
|
|
|
|
|
comment: z.string().optional(),
|
|
|
|
|
enable: z.boolean().optional(),
|
2026-05-25 14:30:48 +00:00
|
|
|
reset: z.number().optional(),
|
|
|
|
|
inboundIds: nullableNumberArray.optional(),
|
|
|
|
|
traffic: ClientTrafficSchema.nullable().optional(),
|
|
|
|
|
reverse: z.object({ tag: z.string().optional() }).loose().nullable().optional(),
|
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
|
|
|
createdAt: z.number().optional(),
|
|
|
|
|
updatedAt: z.number().optional(),
|
|
|
|
|
}).loose();
|
|
|
|
|
|
|
|
|
|
export const InboundOptionSchema = z.object({
|
|
|
|
|
id: z.number(),
|
|
|
|
|
remark: z.string().optional(),
|
|
|
|
|
protocol: z.string().optional(),
|
|
|
|
|
port: z.number().optional(),
|
|
|
|
|
tlsFlowCapable: z.boolean().optional(),
|
|
|
|
|
}).loose();
|
|
|
|
|
|
|
|
|
|
export const InboundOptionsSchema = z.array(InboundOptionSchema);
|
|
|
|
|
|
|
|
|
|
export const ClientsSummarySchema = z.object({
|
|
|
|
|
total: z.number(),
|
|
|
|
|
active: z.number(),
|
2026-05-25 14:30:48 +00:00
|
|
|
online: nullableStringArray,
|
|
|
|
|
depleted: nullableStringArray,
|
|
|
|
|
expiring: nullableStringArray,
|
|
|
|
|
deactive: nullableStringArray,
|
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
|
|
|
});
|
|
|
|
|
|
2026-05-25 14:30:48 +00:00
|
|
|
const nullableClientArray = z.array(ClientRecordSchema).nullable().transform((v) => v ?? []);
|
|
|
|
|
|
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 ClientPageResponseSchema = z.object({
|
2026-05-25 14:30:48 +00:00
|
|
|
items: nullableClientArray,
|
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
|
|
|
total: z.number(),
|
|
|
|
|
filtered: z.number(),
|
|
|
|
|
page: z.number(),
|
|
|
|
|
pageSize: z.number(),
|
2026-05-25 14:30:48 +00:00
|
|
|
summary: ClientsSummarySchema.nullable().optional(),
|
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 ClientHydrateSchema = z.object({
|
|
|
|
|
client: ClientRecordSchema,
|
2026-05-25 14:30:48 +00:00
|
|
|
inboundIds: nullableNumberArray,
|
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 BulkAdjustResultSchema = z.object({
|
|
|
|
|
adjusted: z.number(),
|
|
|
|
|
skipped: z
|
|
|
|
|
.array(z.object({ email: z.string(), reason: z.string() }))
|
|
|
|
|
.optional(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const DelDepletedResultSchema = z.object({
|
|
|
|
|
deleted: z.number().optional(),
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-25 14:30:48 +00:00
|
|
|
export const OnlinesSchema = nullableStringArray;
|
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 ClientRecord = z.infer<typeof ClientRecordSchema>;
|
|
|
|
|
export type ClientTraffic = z.infer<typeof ClientTrafficSchema>;
|
|
|
|
|
export type InboundOption = z.infer<typeof InboundOptionSchema>;
|
|
|
|
|
export type ClientsSummary = z.infer<typeof ClientsSummarySchema>;
|
|
|
|
|
export type ClientPageResponse = z.infer<typeof ClientPageResponseSchema>;
|
|
|
|
|
export type ClientHydrate = z.infer<typeof ClientHydrateSchema>;
|
|
|
|
|
export type BulkAdjustResult = z.infer<typeof BulkAdjustResultSchema>;
|