Template
1
0

feat: minor cleanup and doc update

This commit is contained in:
2025-04-21 00:27:34 +00:00
parent 3b9a5cb456
commit 22325285be
5 changed files with 38 additions and 40 deletions

View File

@@ -23,9 +23,11 @@ export class Procedure<TState extends State = State> {
* ```ts
* relay
* .method("user:create")
* .params({
* bar: z.number()
* })
* .params(
* z.object({
* bar: z.number()
* })
* )
* .handle(async ({ bar }) => {
* console.log(typeof bar); // => number
* });
@@ -46,7 +48,7 @@ export class Procedure<TState extends State = State> {
* ```ts
* const hasFooBar = action
* .make("hasFooBar")
* .response(z.object({ foobar: z.number() }))
* .output(z.object({ foobar: z.number() }))
* .handle(async () => {
* return {
* foobar: 1,

View File

@@ -16,15 +16,6 @@ export class Relay<TProcedures extends Procedures, TProcedureIndex = ProcedureIn
indexProcedures(procedures, this.#index);
}
/**
* Retrieve a registered procedure registered with the relay instance.
*
* @param method - Method name assigned to the procedure.
*/
procedure<TMethod extends keyof TProcedureIndex>(method: TMethod): TProcedureIndex[TMethod] {
return this.#index.get(method) as TProcedureIndex[TMethod];
}
/**
* Create a new relay client instance from the instance procedures.
*
@@ -33,6 +24,15 @@ export class Relay<TProcedures extends Procedures, TProcedureIndex = ProcedureIn
client(config: RelayClientConfig): this["$inferClient"] {
return makeRelayClient(config, this.procedures) as any;
}
/**
* Retrieve a registered procedure registered with the relay instance.
*
* @param method - Method name assigned to the procedure.
*/
method<TMethod extends keyof TProcedureIndex>(method: TMethod): TProcedureIndex[TMethod] {
return this.#index.get(method) as TProcedureIndex[TMethod];
}
}
/*