Metadata
Metadata lets you attach extra information to procedures. Middleware, plugins, and tooling can read it later to control behavior.
Quickly Define Meta
In most cases, use defineMeta to create a metadata plugin. It takes a unique name and a merge function that defines how metadata is combined across repeated calls, then returns a tuple of [metaPlugin, getMeta]:
import { function defineMeta<TName extends string, TData>(name: TName, merge: (incoming: TData, current: TData | undefined) => TData): [metaPlugin: (meta: TData) => AnyMetaPlugin & {
name: TName;
}, getMeta: (procedureOrLazy: {
"~orpc": {
meta: Meta;
};
}) => TData | undefined]
Quickly defines a meta plugin factory and reader.defineMeta } from '@orpc/server'
type type CacheMeta = booleanCacheMeta = boolean
const [const cacheMeta: (meta: boolean) => AnyMetaPlugin & {
name: "cache";
}
cacheMeta, const getCacheMeta: (procedureOrLazy: {
"~orpc": {
meta: Meta;
};
}) => boolean | undefined
getCacheMeta] = defineMeta<"cache", boolean>(name: "cache", merge: (incoming: boolean, current: boolean | undefined) => boolean): [metaPlugin: (meta: boolean) => AnyMetaPlugin & {
name: "cache";
}, getMeta: (procedureOrLazy: {
"~orpc": {
meta: Meta;
};
}) => boolean | undefined]
Quickly defines a meta plugin factory and reader.defineMeta(
'cache',
(incoming: booleanincoming: type CacheMeta = booleanCacheMeta, current: boolean | undefinedcurrent) => incoming: booleanincoming,
)
const const base: BuilderWithMiddlewares<DefaultInitialContext & object, object, Record<never, never>>base = const os: Builder<DefaultInitialContext & object, Record<never, never>>The oRPC procedure builder. Chain methods like `.input`, `.use`, and `.handler`
to define procedures, then compose them into routers.os.Builder<DefaultInitialContext & object, Record<never, never>>.use<object, DefaultInitialContext & object, Record<never, never>>(middleware: Middleware<DefaultInitialContext & object, object, unknown, unknown, Record<never, never>>): BuilderWithMiddlewares<DefaultInitialContext & object, object, Record<never, never>>use(async ({ procedure: AnyProcedureprocedure, next: MiddlewareNext<unknown>Invoke to continue the middleware chain.next, path: string[]path }, input: unknowninput, done: MiddlewareDone<unknown>done) => {
if (const getCacheMeta: (procedureOrLazy: {
"~orpc": {
meta: Meta;
};
}) => boolean | undefined
getCacheMeta(procedure: AnyProcedureprocedure) !== true) {
return next: MiddlewareNext
<object>(options?: {
context?: object | undefined;
} | undefined) => MiddlewareResult<object, unknown>
Invoke to continue the middleware chain.next()
}
const const key: stringkey = path: string[]path.Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.join('/') + var JSON: JSONAn intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.JSON.JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)Converts a JavaScript value to a JavaScript Object Notation (JSON) string.stringify(input: unknowninput)
if (const store: Map<string, unknown>store.Map<string, unknown>.has(key: string): booleanhas(const key: stringkey)) {
return done: MiddlewareDone
<object>(options: MiddlewareDoneOptions<object, unknown>) => MiddlewareResult<object, unknown>
Create a successful result and terminate the middleware chain early.done({ output: unknownoutput: const store: Map<string, unknown>store.Map<string, unknown>.get(key: string): unknownReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.get(const key: stringkey)! })
}
const const result: {
output: unknown;
context: object;
}
result = await next: MiddlewareNext
<object>(options?: {
context?: object | undefined;
} | undefined) => MiddlewareResult<object, unknown>
Invoke to continue the middleware chain.next()
const store: Map<string, unknown>store.Map<string, unknown>.set(key: string, value: unknown): Map<string, unknown>Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.set(const key: stringkey, const result: {
output: unknown;
context: object;
}
result.output: unknownoutput)
return const result: {
output: unknown;
context: object;
}
result
})
const const cachedProcedure: DecoratedProcedure<DefaultInitialContext & object, object, InitialInputSchema, Schema<string>, Record<never, never>, never>cachedProcedure = const base: BuilderWithMiddlewares<DefaultInitialContext & object, object, Record<never, never>>base
.BuilderWithMiddlewares<DefaultInitialContext & object, object, Record<never, never>>['meta'](...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, Record<never, never>>[]): BuilderWithMiddlewares<DefaultInitialContext & object, object, Record<never, never>>meta(const cacheMeta: (meta: boolean) => AnyMetaPlugin & {
name: "cache";
}
cacheMeta(true))
.BuilderWithMiddlewares<DefaultInitialContext & object, object, Record<never, never>>['handler']<string>(handler: ProcedureHandler<DefaultInitialContext & object, unknown, string, ORPCErrorConstructorMap<Record<never, never>>>): DecoratedProcedure<DefaultInitialContext & object, object, InitialInputSchema, Schema<string>, Record<never, never>, never>handler(async () => {
return 'Earth'
})
Manually Define Meta
If defineMeta is not flexible enough, define a plugin directly with MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>. This gives you full control and lets the plugin infer or restrict procedure types.
import type {
type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
type ErrorMap = {
[x: string & {}]: ErrorMapItem | undefined;
BAD_REQUEST?: ErrorMapItem | undefined;
UNAUTHORIZED?: ErrorMapItem | undefined;
PAYMENT_REQUIRED?: ErrorMapItem | undefined;
FORBIDDEN?: ErrorMapItem | undefined;
NOT_FOUND?: ErrorMapItem | undefined;
METHOD_NOT_SUPPORTED?: ErrorMapItem | undefined;
NOT_ACCEPTABLE?: ErrorMapItem | undefined;
TIMEOUT?: ErrorMapItem | undefined;
CONFLICT?: ErrorMapItem | undefined;
... 12 more ...;
GATEWAY_TIMEOUT?: ErrorMapItem | undefined;
}
Map of error codes to their definitions, as passed to `.errors(...)`.
Errors defined here remain properly typed on the client.ErrorMap,
type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : neverInfers the input type of a schema.InferSchemaInput,
type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : neverInfers the output type of a schema.InferSchemaOutput,
Meta,
interface MetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>A metadata plugin passed to `.meta(...)`.
Defines how metadata is initialized and merged, and can infer or restrict procedure types.MetaPlugin,
} from '@orpc/server'
interface interface ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMeta<
function (type parameter) TInputSchema in ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TInputSchema extends type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
function (type parameter) TOutputSchema in ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TOutputSchema extends type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
function (type parameter) TErrorMap in ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TErrorMap extends type ErrorMap = {
[x: string & {}]: ErrorMapItem | undefined;
BAD_REQUEST?: ErrorMapItem | undefined;
UNAUTHORIZED?: ErrorMapItem | undefined;
PAYMENT_REQUIRED?: ErrorMapItem | undefined;
FORBIDDEN?: ErrorMapItem | undefined;
NOT_FOUND?: ErrorMapItem | undefined;
METHOD_NOT_SUPPORTED?: ErrorMapItem | undefined;
NOT_ACCEPTABLE?: ErrorMapItem | undefined;
TIMEOUT?: ErrorMapItem | undefined;
CONFLICT?: ErrorMapItem | undefined;
... 12 more ...;
GATEWAY_TIMEOUT?: ErrorMapItem | undefined;
}
Map of error codes to their definitions, as passed to `.errors(...)`.
Errors defined here remain properly typed on the client.ErrorMap
> {
ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>.inputExamples?: InferSchemaInput<TInputSchema>[] | undefinedinputExamples?: type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : neverInfers the input type of a schema.InferSchemaInput<function (type parameter) TInputSchema in ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TInputSchema>[]
ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>.outputExamples?: InferSchemaOutput<TOutputSchema>[] | undefinedoutputExamples?: type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : neverInfers the output type of a schema.InferSchemaOutput<function (type parameter) TOutputSchema in ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TOutputSchema>[]
}
interface interface ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMetaPlugin<
function (type parameter) TInputSchema in ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TInputSchema extends type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
function (type parameter) TOutputSchema in ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TOutputSchema extends type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
function (type parameter) TErrorMap in ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TErrorMap extends type ErrorMap = {
[x: string & {}]: ErrorMapItem | undefined;
BAD_REQUEST?: ErrorMapItem | undefined;
UNAUTHORIZED?: ErrorMapItem | undefined;
PAYMENT_REQUIRED?: ErrorMapItem | undefined;
FORBIDDEN?: ErrorMapItem | undefined;
NOT_FOUND?: ErrorMapItem | undefined;
METHOD_NOT_SUPPORTED?: ErrorMapItem | undefined;
NOT_ACCEPTABLE?: ErrorMapItem | undefined;
TIMEOUT?: ErrorMapItem | undefined;
CONFLICT?: ErrorMapItem | undefined;
... 12 more ...;
GATEWAY_TIMEOUT?: ErrorMapItem | undefined;
}
Map of error codes to their definitions, as passed to `.errors(...)`.
Errors defined here remain properly typed on the client.ErrorMap
> extends interface MetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>A metadata plugin passed to `.meta(...)`.
Defines how metadata is initialized and merged, and can infer or restrict procedure types.MetaPlugin<function (type parameter) TInputSchema in ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TInputSchema, function (type parameter) TOutputSchema in ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TOutputSchema, function (type parameter) TErrorMap in ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>TErrorMap> {
ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>.name: "example"Unique name of the plugin, used for identification.name: 'example'
}
function function exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>exampleMeta<
function (type parameter) TInputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TInputSchema extends type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
function (type parameter) TOutputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TOutputSchema extends type AnySchema = StandardSchemaV1<any, any>Any Standard Schema compatible schema, regardless of its input and output types.AnySchema,
function (type parameter) TErrorMap in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TErrorMap extends type ErrorMap = {
[x: string & {}]: ErrorMapItem | undefined;
BAD_REQUEST?: ErrorMapItem | undefined;
UNAUTHORIZED?: ErrorMapItem | undefined;
PAYMENT_REQUIRED?: ErrorMapItem | undefined;
FORBIDDEN?: ErrorMapItem | undefined;
NOT_FOUND?: ErrorMapItem | undefined;
METHOD_NOT_SUPPORTED?: ErrorMapItem | undefined;
NOT_ACCEPTABLE?: ErrorMapItem | undefined;
TIMEOUT?: ErrorMapItem | undefined;
CONFLICT?: ErrorMapItem | undefined;
... 12 more ...;
GATEWAY_TIMEOUT?: ErrorMapItem | undefined;
}
Map of error codes to their definitions, as passed to `.errors(...)`.
Errors defined here remain properly typed on the client.ErrorMap,
>(
incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>incoming: interface ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMeta<function (type parameter) TInputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TInputSchema, function (type parameter) TOutputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TOutputSchema, function (type parameter) TErrorMap in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TErrorMap>
): interface ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMetaPlugin<function (type parameter) TInputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TInputSchema, function (type parameter) TOutputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TOutputSchema, function (type parameter) TErrorMap in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TErrorMap> {
return {
ExampleMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>.name: "example"Unique name of the plugin, used for identification.name: 'example',
MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>['apply']?: ((meta: Meta) => Meta) | undefinedRuns every time metadata is updated.
This is called for all plugins in the chain whenever a new plugin is added.apply(meta: Metameta) {
const const current: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap> | undefinedcurrent = meta: Metameta.Meta[string | number | symbol]: unknownexample as interface ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMeta<function (type parameter) TInputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TInputSchema, function (type parameter) TOutputSchema in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TOutputSchema, function (type parameter) TErrorMap in exampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>): ExampleMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>TErrorMap> | undefined
return {
...meta: Metameta,
example: {
inputExamples?: InferSchemaInput<TInputSchema>[] | undefined;
outputExamples?: InferSchemaOutput<TOutputSchema>[] | undefined;
}
example: {
...const current: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap> | undefinedcurrent,
...incoming: ExampleMeta<TInputSchema, TOutputSchema, TErrorMap>incoming,
}
}
},
}
}
function function getExampleMeta(procedureOrLazy: {
"~orpc": {
meta: Meta;
};
}): ExampleMeta<any, any, any> | undefined
getExampleMeta(
procedureOrLazy: {
'~orpc': {
meta: Meta;
};
}
procedureOrLazy: { '~orpc': { meta: Metameta: Meta } }
): interface ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMeta<any, any, any> | undefined {
return procedureOrLazy: {
'~orpc': {
meta: Meta;
};
}
procedureOrLazy['~orpc'].meta: Metameta.Meta[string | number | symbol]: unknownexample as interface ExampleMeta<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>ExampleMeta<any, any, any> | undefined
}
const const procedure: DecoratedProcedure<DefaultInitialContext & object, object, z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>, never>
procedure = const os: Builder<DefaultInitialContext & object, Record<never, never>>The oRPC procedure builder. Chain methods like `.input`, `.use`, and `.handler`
to define procedures, then compose them into routers.os
.Builder<DefaultInitialContext & object, Record<never, never>>.input<z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>>(schema: z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>): BuilderWithInput<DefaultInitialContext & object, object, z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>
input(import zz.function object<{
name: z.ZodString;
}>(shape?: {
name: z.ZodString;
} | undefined, params?: string | {
error?: string | z.core.$ZodErrorMap<NonNullable<z.core.$ZodIssueInvalidType<unknown> | z.core.$ZodIssueUnrecognizedKeys>> | undefined;
message?: string | undefined | undefined;
} | undefined): z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>
object({ name: z.ZodStringname: import zz.function string(params?: string | z.core.$ZodStringParams): z.ZodString (+1 overload)string() }))
.BuilderWithInput<DefaultInitialContext & object, object, ZodObject<{ name: ZodString; }, $strip>, Record<never, never>>['output']<z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>>(schema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>): BuilderWithInputOutput<DefaultInitialContext & object, object, z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>
output(import zz.function object<{
id: z.ZodString;
name: z.ZodString;
}>(shape?: {
id: z.ZodString;
name: z.ZodString;
} | undefined, params?: string | {
error?: string | z.core.$ZodErrorMap<NonNullable<z.core.$ZodIssueInvalidType<unknown> | z.core.$ZodIssueUnrecognizedKeys>> | undefined;
message?: string | undefined | undefined;
} | undefined): z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>
object({ id: z.ZodStringid: import zz.function string(params?: string | z.core.$ZodStringParams): z.ZodString (+1 overload)string(), name: z.ZodStringname: import zz.function string(params?: string | z.core.$ZodStringParams): z.ZodString (+1 overload)string() }))
.BuilderWithInputOutput<DefaultInitialContext & object, object, ZodObject<{ name: ZodString; }, $strip>, ZodObject<{ id: ZodString; name: ZodString; }, $strip>, Record<...>>['meta'](...plugins: MetaPlugin<z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>[]): BuilderWithInputOutput<DefaultInitialContext & object, object, z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>
meta(function exampleMeta<z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>(incoming: ExampleMeta<z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>): ExampleMetaPlugin<z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>>
exampleMeta({
ExampleMeta<ZodObject<{ name: ZodString; }, $strip>, ZodObject<{ id: ZodString; name: ZodString; }, $strip>, Record<...>>.inputExamples?: {
name: string;
}[] | undefined
inputExamples: [{ name: stringname: 'Alice' }], // <- typesafe
ExampleMeta<ZodObject<{ name: ZodString; }, $strip>, ZodObject<{ id: ZodString; name: ZodString; }, $strip>, Record<...>>.outputExamples?: {
id: string;
name: string;
}[] | undefined
outputExamples: [{ id: stringid: '1', name: stringname: 'Alice' }], // <- typesafe
}))
.BuilderWithInputOutput<DefaultInitialContext & object, object, ZodObject<{ name: ZodString; }, $strip>, ZodObject<{ id: ZodString; name: ZodString; }, $strip>, Record<...>>['handler']<{
id: string;
name: "Alice";
}>(handler: ProcedureHandler<DefaultInitialContext & object, {
name: string;
}, {
id: string;
name: "Alice";
}, ORPCErrorConstructorMap<Record<never, never>>>): DecoratedProcedure<DefaultInitialContext & object, object, z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, z.core.$strip>, Record<never, never>, never>
handler(async ({ input: {
name: string;
}
input }) => {
return { id: stringid: '1', name: "Alice"name: 'Alice' }
})