Template
1
0

fix: zod request type

This commit is contained in:
2025-04-21 23:15:08 +00:00
parent 425439e493
commit 1701a07a6c

View File

@@ -1,10 +1,37 @@
import z from "zod"; import z, { ZodLiteral, ZodNumber, ZodObject, ZodOptional, ZodString, ZodUnion, ZodUnknown } from "zod";
export const request = z.object({ export const request: ZodObject<{
relay: ZodLiteral<"1.0">;
method: ZodString;
params: ZodOptional<ZodUnknown>;
id: ZodUnion<[ZodString, ZodNumber]>;
}> = z.object({
relay: z.literal("1.0"), relay: z.literal("1.0"),
method: z.string(), method: z.string(),
params: z.unknown(), params: z.unknown().optional(),
id: z.string().or(z.number()), id: z.string().or(z.number()),
}); });
export type RelayRequest = z.infer<typeof request>; export type RelayRequest = {
/**
* String specifying the version of the relay protocol. MUST be exactly "1.0".
*/
relay: "1.0";
/**
* String containing the name of the method to be invoked.
*/
method: string;
/**
* Structured value that holds the parameter values to be used during the
* invocation of the method.
*/
params?: unknown;
/**
* An identifier established by the Client that MUST contain a String, or non
* fractional Number value.
*/
id: string | number;
};