Template
1
0

feat: add rest support

This commit is contained in:
2025-04-25 18:41:23 +00:00
parent 1701a07a6c
commit becae62e2a
11 changed files with 980 additions and 143 deletions

View File

@@ -3,7 +3,9 @@ import z, { ZodObject, ZodType } from "zod";
import { Action } from "./action.ts";
import { RelayError } from "./errors.ts";
export class Procedure<TState extends State = State> {
export class Procedure<const TState extends State = State> {
readonly type = "rpc" as const;
declare readonly args: Args<TState>;
constructor(readonly state: TState) {}
@@ -110,11 +112,11 @@ export class Procedure<TState extends State = State> {
|--------------------------------------------------------------------------------
*/
export const procedure: {
method<const TMethod extends string>(method: TMethod): Procedure<{ method: TMethod }>;
export const rpc: {
method<const TMethod extends string>(method: TMethod): Procedure<{ type: "rpc"; method: TMethod }>;
} = {
method<const TMethod extends string>(method: TMethod): Procedure<{ method: TMethod }> {
return new Procedure({ method });
method<const TMethod extends string>(method: TMethod): Procedure<{ type: "rpc"; method: TMethod }> {
return new Procedure({ type: "rpc", method });
},
};
@@ -124,10 +126,6 @@ export const procedure: {
|--------------------------------------------------------------------------------
*/
export type Procedures = {
[key: string]: Procedures | Procedure;
};
type State = {
method: string;
params?: ZodType;