@orpc/server 2.0.0-beta.46 → 2.0.0-beta.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +6 -4
  2. package/dist/adapters/aws-lambda/handler.d.mts +25 -0
  3. package/dist/adapters/aws-lambda/handler.mjs +21 -0
  4. package/dist/adapters/aws-lambda/index.d.mts +14 -49
  5. package/dist/adapters/aws-lambda/index.mjs +2 -39
  6. package/dist/adapters/aws-lambda/rpc-handler.d.mts +18 -0
  7. package/dist/adapters/aws-lambda/rpc-handler.mjs +10 -0
  8. package/dist/adapters/crossws/handler.d.mts +41 -0
  9. package/dist/adapters/crossws/handler.mjs +38 -0
  10. package/dist/adapters/crossws/index.d.mts +2 -63
  11. package/dist/adapters/crossws/index.mjs +2 -68
  12. package/dist/adapters/crossws/rpc-handler.d.mts +15 -0
  13. package/dist/adapters/crossws/rpc-handler.mjs +10 -0
  14. package/dist/adapters/fastify/handler.d.mts +21 -0
  15. package/dist/adapters/fastify/handler.mjs +20 -0
  16. package/dist/adapters/fastify/index.d.mts +2 -42
  17. package/dist/adapters/fastify/index.mjs +2 -39
  18. package/dist/adapters/fastify/rpc-handler.d.mts +14 -0
  19. package/dist/adapters/fastify/rpc-handler.mjs +10 -0
  20. package/dist/adapters/fetch/handler.d.mts +23 -0
  21. package/dist/adapters/fetch/handler.mjs +22 -0
  22. package/dist/adapters/fetch/index.d.mts +6 -46
  23. package/dist/adapters/fetch/index.mjs +4 -41
  24. package/dist/adapters/fetch/rpc-handler.d.mts +16 -0
  25. package/dist/adapters/fetch/rpc-handler.mjs +10 -0
  26. package/dist/adapters/message-port/handler.d.mts +57 -0
  27. package/dist/adapters/message-port/handler.mjs +62 -0
  28. package/dist/adapters/message-port/index.d.mts +2 -77
  29. package/dist/adapters/message-port/index.mjs +2 -87
  30. package/dist/adapters/message-port/rpc-handler.d.mts +15 -0
  31. package/dist/adapters/message-port/rpc-handler.mjs +10 -0
  32. package/dist/adapters/node/handler.d.mts +21 -0
  33. package/dist/adapters/node/handler.mjs +20 -0
  34. package/dist/adapters/node/index.d.mts +6 -43
  35. package/dist/adapters/node/index.mjs +4 -40
  36. package/dist/adapters/node/rpc-handler.d.mts +15 -0
  37. package/dist/adapters/node/rpc-handler.mjs +10 -0
  38. package/dist/adapters/standard/codec.d.mts +16 -0
  39. package/dist/adapters/standard/codec.mjs +1 -0
  40. package/dist/adapters/standard/handler.d.mts +68 -0
  41. package/dist/adapters/standard/handler.mjs +185 -0
  42. package/dist/adapters/standard/index.d.mts +6 -95
  43. package/dist/adapters/standard/index.mjs +5 -8
  44. package/dist/adapters/standard/plugin.d.mts +32 -0
  45. package/dist/adapters/standard/plugin.mjs +16 -0
  46. package/dist/adapters/standard/rpc-handler-codec.d.mts +42 -0
  47. package/dist/adapters/standard/rpc-handler-codec.mjs +51 -0
  48. package/dist/adapters/standard/rpc-matcher.d.mts +53 -0
  49. package/dist/adapters/standard/rpc-matcher.mjs +140 -0
  50. package/dist/adapters/standard/utils.d.mts +10 -0
  51. package/dist/adapters/standard/utils.mjs +6 -0
  52. package/dist/adapters/standard-peer/index.d.mts +1 -11
  53. package/dist/adapters/standard-peer/index.mjs +1 -10
  54. package/dist/adapters/standard-peer/utils.d.mts +4 -0
  55. package/dist/adapters/standard-peer/utils.mjs +11 -0
  56. package/dist/adapters/websocket/handler.d.mts +55 -0
  57. package/dist/adapters/websocket/handler.mjs +55 -0
  58. package/dist/adapters/websocket/index.d.mts +2 -77
  59. package/dist/adapters/websocket/index.mjs +2 -87
  60. package/dist/adapters/websocket/rpc-handler.d.mts +15 -0
  61. package/dist/adapters/websocket/rpc-handler.mjs +10 -0
  62. package/dist/builder-variants.d.mts +267 -0
  63. package/dist/builder-variants.mjs +1 -0
  64. package/dist/builder.d.mts +141 -0
  65. package/dist/builder.mjs +145 -0
  66. package/dist/constants.d.mts +2 -0
  67. package/dist/constants.mjs +2 -0
  68. package/dist/context.d.mts +13 -0
  69. package/dist/context.mjs +1 -0
  70. package/dist/extensions/callable.d.mts +16 -9
  71. package/dist/extensions/callable.mjs +5 -9
  72. package/dist/helpers/base64url.d.mts +31 -0
  73. package/dist/helpers/base64url.mjs +25 -0
  74. package/dist/helpers/cookie.d.mts +50 -0
  75. package/dist/helpers/cookie.mjs +35 -0
  76. package/dist/helpers/encryption.d.mts +28 -0
  77. package/dist/helpers/encryption.mjs +62 -0
  78. package/dist/helpers/index.d.mts +4 -167
  79. package/dist/helpers/index.mjs +4 -200
  80. package/dist/helpers/signing.d.mts +50 -0
  81. package/dist/helpers/signing.mjs +43 -0
  82. package/dist/implementer-procedure.d.mts +36 -0
  83. package/dist/implementer-procedure.mjs +38 -0
  84. package/dist/implementer-router.d.mts +78 -0
  85. package/dist/implementer-router.mjs +77 -0
  86. package/dist/implementer.d.mts +22 -0
  87. package/dist/implementer.mjs +30 -0
  88. package/dist/index.d.mts +57 -476
  89. package/dist/index.mjs +25 -458
  90. package/dist/lazy.d.mts +20 -0
  91. package/dist/lazy.mjs +22 -0
  92. package/dist/middleware-decorated.d.mts +27 -0
  93. package/dist/middleware-decorated.mjs +65 -0
  94. package/dist/middleware.d.mts +70 -0
  95. package/dist/middleware.mjs +1 -0
  96. package/dist/plugins/batch.d.mts +104 -0
  97. package/dist/plugins/batch.mjs +373 -0
  98. package/dist/plugins/cors.d.mts +67 -0
  99. package/dist/plugins/cors.mjs +134 -0
  100. package/dist/plugins/get-method-csrf-protection.d.mts +23 -0
  101. package/dist/plugins/get-method-csrf-protection.mjs +45 -0
  102. package/dist/plugins/head-method.d.mts +23 -0
  103. package/dist/plugins/head-method.mjs +95 -0
  104. package/dist/plugins/index.d.mts +39 -432
  105. package/dist/plugins/index.mjs +23 -967
  106. package/dist/plugins/method-override.d.mts +38 -0
  107. package/dist/plugins/method-override.mjs +50 -0
  108. package/dist/plugins/request-compression.d.mts +16 -0
  109. package/dist/plugins/request-compression.mjs +67 -0
  110. package/dist/plugins/request-headers.d.mts +22 -0
  111. package/dist/plugins/request-headers.mjs +21 -0
  112. package/dist/plugins/request-limit.d.mts +30 -0
  113. package/dist/plugins/request-limit.mjs +53 -0
  114. package/dist/plugins/response-compression.d.mts +59 -0
  115. package/dist/plugins/response-compression.mjs +172 -0
  116. package/dist/plugins/response-headers.d.mts +30 -0
  117. package/dist/plugins/response-headers.mjs +34 -0
  118. package/dist/plugins/rethrow.d.mts +33 -0
  119. package/dist/plugins/rethrow.mjs +46 -0
  120. package/dist/plugins/signal-sync.d.mts +13 -0
  121. package/dist/plugins/signal-sync.mjs +84 -0
  122. package/dist/plugins/timeout.d.mts +37 -0
  123. package/dist/plugins/timeout.mjs +56 -0
  124. package/dist/procedure-client.d.mts +41 -0
  125. package/dist/procedure-client.mjs +157 -0
  126. package/dist/procedure-decorated.d.mts +20 -0
  127. package/dist/procedure-decorated.mjs +41 -0
  128. package/dist/procedure-utils.d.mts +52 -0
  129. package/dist/procedure-utils.mjs +33 -0
  130. package/dist/procedure.d.mts +93 -0
  131. package/dist/procedure.mjs +20 -0
  132. package/dist/router-client.d.mts +27 -0
  133. package/dist/router-client.mjs +35 -0
  134. package/dist/router-hidden.d.mts +5 -0
  135. package/dist/router-hidden.mjs +12 -0
  136. package/dist/router-utils.d.mts +59 -0
  137. package/dist/router-utils.mjs +191 -0
  138. package/dist/router.d.mts +61 -0
  139. package/dist/router.mjs +1 -0
  140. package/package.json +11 -11
  141. package/dist/adapters/aws-lambda/index.d.ts +0 -51
  142. package/dist/adapters/crossws/index.d.ts +0 -63
  143. package/dist/adapters/fastify/index.d.ts +0 -42
  144. package/dist/adapters/fetch/index.d.ts +0 -47
  145. package/dist/adapters/message-port/index.d.ts +0 -77
  146. package/dist/adapters/node/index.d.ts +0 -44
  147. package/dist/adapters/standard/index.d.ts +0 -95
  148. package/dist/adapters/standard-peer/index.d.ts +0 -11
  149. package/dist/adapters/websocket/index.d.ts +0 -77
  150. package/dist/extensions/callable.d.ts +0 -10
  151. package/dist/helpers/index.d.ts +0 -167
  152. package/dist/index.d.ts +0 -476
  153. package/dist/plugins/index.d.ts +0 -432
  154. package/dist/shared/server.1ExWFMze.mjs +0 -69
  155. package/dist/shared/server.9B1jEm5a.d.mts +0 -105
  156. package/dist/shared/server.BB464y-6.mjs +0 -207
  157. package/dist/shared/server.BC5BIu02.d.mts +0 -73
  158. package/dist/shared/server.BSYGskId.d.ts +0 -14
  159. package/dist/shared/server.BvG3boBj.d.mts +0 -14
  160. package/dist/shared/server.CTV_mC2P.d.mts +0 -34
  161. package/dist/shared/server.CYbIpHbH.mjs +0 -239
  162. package/dist/shared/server.CgBF3Vj1.d.ts +0 -34
  163. package/dist/shared/server.Chq5FpXf.mjs +0 -353
  164. package/dist/shared/server.DFPxP2v3.d.mts +0 -166
  165. package/dist/shared/server.DFPxP2v3.d.ts +0 -166
  166. package/dist/shared/server.DOg7ke6y.d.ts +0 -105
  167. package/dist/shared/server.Dz7j9BEh.d.ts +0 -73
  168. package/dist/shared/server.W91HSRkE.mjs +0 -9
  169. package/dist/shared/server.sBQSgqK3.mjs +0 -41
package/dist/index.d.mts CHANGED
@@ -1,476 +1,57 @@
1
- import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AnyProcedureContract, RouterContract, InitialInputSchema, InitialOutputSchema, MergedSchema, ORPCErrorConstructorMap, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
2
- export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, MergedSchema, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, type } from '@orpc/contract';
3
- import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
4
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, DistributiveOmit, IntersectPick, MaybeOptionalOptions, PromiseWithError, Public, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
5
- import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as Lazy, A as AnyProcedure, L as Lazyable, g as ProcedureHandler, h as ProcedureConfig, O as OrderedMiddleware, i as AnyMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.DFPxP2v3.mjs';
6
- export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, c as ProcedureClientInterceptor, r as ProcedureClientInterceptorOptions, s as ProcedureDefinition, t as ProcedureHandlerOptions, u as createProcedureClient, v as unlazy } from './shared/server.DFPxP2v3.mjs';
7
- import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.BC5BIu02.mjs';
8
- export { a as InferRouterCurrentContexts, b as InferRouterError, c as InferRouterErrors, a as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.BC5BIu02.mjs';
9
- import { ClientOptions, ClientContext } from '@orpc/client';
10
- export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, isDefinedError, safe, toORPCError } from '@orpc/client';
11
- export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
12
-
13
- interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
14
- adaptInput<T>(adapt: (input: T) => TInput): DecoratedMiddleware<TInContext, TOutContext, T, TOutput, TErrorMap>;
15
- errors<T extends ErrorMap>(errors: T): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, MergedErrorMap<TErrorMap, T>>;
16
- use<$OutContext extends IntersectPick<MergedContext<TInContext, TOutContext>, $OutContext>, $Input extends TInput, $InContext extends Context = MergedContext<TInContext, TOutContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInContext, TOutContext>, $OutContext, $Input, TOutput, $ErrorMap>): DecoratedMiddleware<MergedInitialContext<TInContext, TOutContext, $InContext>, MergedContext<TOutContext, $OutContext>, $Input, TOutput, MergedErrorMap<$ErrorMap, TErrorMap>>;
17
- }
18
-
19
- declare class DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends Procedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap> {
20
- meta(...plugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[]): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
21
- errors<T extends ErrorMap>(errors: T): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
22
- use<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): DecoratedProcedure<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, TOutputSchema, MergedErrorMap<$ErrorMap, TErrorMap>>;
23
- }
24
-
25
- type AugmentedRouter<T extends AnyRouter, TErrorMap extends ErrorMap> = T extends Procedure<infer $InitialContext, infer $CurrentContext, infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? Procedure<$InitialContext, $CurrentContext, $InputSchema, $OutputSchema, MergedErrorMap<TErrorMap, $ErrorMap>> : {
26
- [K in keyof T]: T[K] extends Lazy<infer $ extends AnyRouter> ? Lazy<AugmentedRouter<$, TErrorMap>> : T[K] extends AnyRouter ? AugmentedRouter<T[K], TErrorMap> : never;
27
- };
28
- type AugmentedRouterWithMiddlewares<T extends AnyRouter, TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> = T extends Procedure<infer $InitialContext, infer $CurrentContext, infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? Procedure<MergedInitialContext<TInitialContext, TInjectedContext, $InitialContext>, $CurrentContext, $InputSchema, $OutputSchema, MergedErrorMap<TErrorMap, $ErrorMap>> : {
29
- [K in keyof T]: T[K] extends Lazy<infer $ extends AnyRouter> ? Lazy<AugmentedRouterWithMiddlewares<$, TInitialContext, TInjectedContext, TErrorMap>> : T[K] extends AnyRouter ? AugmentedRouterWithMiddlewares<T[K], TInitialContext, TInjectedContext, TErrorMap> : never;
30
- };
31
- /**
32
- * Resolves the procedure of a contract walked from a router: the procedure itself,
33
- * or the implementation of a contract-first procedure, looked up by its path.
34
- *
35
- * @throws {TypeError} If a contract-first procedure has no valid implementation.
36
- */
37
- declare function resolveContractProcedure(router: AnyRouter, contract: AnyProcedureContract, path: readonly string[]): Promise<AnyProcedure>;
38
- declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
39
- interface WalkProcedureContractsLazyResult {
40
- router: Lazy<AnyRouter>;
41
- path: string[];
42
- }
43
- declare function walkProcedureContractsSync(router: RouterContract | AnyRouter, callback: (contract: AnyProcedureContract | AnyProcedure, path: string[]) => void, path?: string[]): WalkProcedureContractsLazyResult[];
44
- declare function walkProcedureContractsAsync(router: RouterContract | AnyRouter, callback: (contract: AnyProcedureContract | AnyProcedure, path: string[]) => Promisable<void>, path?: string[]): Promise<void>;
45
- type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
46
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
47
- };
48
- /**
49
- * Fully resolves all lazy routers inside a router, returning a plain router.
50
- * Useful for making a router with lazy parts contract-compatible.
51
- *
52
- * @see {@link https://orpc.dev/docs/contract/router#router-to-contract | Router Contract - Router to Contract}
53
- */
54
- declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
55
-
56
- /**
57
- * The builder variant returned after `.use` is called.
58
- * `.$context` and `.$config` are no longer available once middleware is applied.
59
- *
60
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
61
- */
62
- interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
63
- '~orpc': BuilderDefinition<InitialInputSchema, InitialOutputSchema, TErrorMap>;
64
- /**
65
- * Applies metadata plugins to procedures built from this builder.
66
- *
67
- * @see {@link https://orpc.dev/docs/metadata | Metadata}
68
- */
69
- 'meta'(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
70
- /**
71
- * Defines typesafe errors that procedures built from this builder can throw
72
- * via the `errors` utility in handlers and middleware.
73
- *
74
- * @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
75
- */
76
- 'errors'<T extends ErrorMap>(errors: T): BuilderWithMiddlewares<TInitialContext, TInjectedContext, MergedErrorMap<TErrorMap, T>>;
77
- /**
78
- * Applies a middleware that runs before the handler of every procedure
79
- * built from this builder.
80
- *
81
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
82
- */
83
- 'use'<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<InitialInputSchema>, InferSchemaInput<InitialOutputSchema>, $ErrorMap>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, MergedErrorMap<$ErrorMap, TErrorMap>>;
84
- /**
85
- * Creates a standalone middleware that can be composed and applied to any
86
- * compatible builder or procedure with `.use`.
87
- *
88
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
89
- */
90
- 'middleware'<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $Input, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $Output = any>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, $Input, $Output, TErrorMap>): DecoratedMiddleware<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, $Input, $Output, TErrorMap>;
91
- /**
92
- * Defines the input schema used to validate and type the procedure input.
93
- *
94
- * @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
95
- */
96
- 'input'<T extends AnySchema>(schema: T): BuilderWithInput<TInitialContext, TInjectedContext, T, TErrorMap>;
97
- /**
98
- * Defines the output schema used to validate and type the procedure output.
99
- *
100
- * @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
101
- */
102
- 'output'<T extends AnySchema>(schema: T): BuilderWithOutput<TInitialContext, TInjectedContext, T, TErrorMap>;
103
- /**
104
- * Defines the function that implements the procedure and completes the
105
- * chain, returning a callable procedure.
106
- *
107
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
108
- */
109
- 'handler'<T>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<InitialInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, InitialInputSchema, Schema<T>, TErrorMap>;
110
- /**
111
- * Applies the builder's middleware, errors, and metadata to every procedure
112
- * in the given router.
113
- *
114
- * @see {@link https://orpc.dev/docs/router#extending-router | Router - Extending Router}
115
- */
116
- 'router'<T extends Router<MergedContext<TInitialContext, TInjectedContext>>>(router: T): AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, TErrorMap>;
117
- /**
118
- * Like `.router`, but loads the router lazily on first access, which helps
119
- * reduce startup time for large applications.
120
- *
121
- * @see {@link https://orpc.dev/docs/router#lazy-router | Router - Lazy Router}
122
- */
123
- 'lazy'<T extends Router<MergedContext<TInitialContext, TInjectedContext>>>(loader: () => Promise<{
124
- default: T;
125
- }>): Lazy<AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, TErrorMap>>;
126
- }
127
- /**
128
- * The builder variant returned after `.input` is called.
129
- * Only procedure-level methods remain available once an input schema is defined.
130
- *
131
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
132
- */
133
- interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
134
- '~orpc': BuilderDefinition<TInputSchema, InitialOutputSchema, TErrorMap>;
135
- /**
136
- * Applies metadata plugins to procedures built from this builder.
137
- *
138
- * @see {@link https://orpc.dev/docs/metadata | Metadata}
139
- */
140
- 'meta'(...plugins: MetaPlugin<TInputSchema, InitialOutputSchema, TErrorMap>[]): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
141
- /**
142
- * Defines typesafe errors that procedures built from this builder can throw
143
- * via the `errors` utility in handlers and middleware.
144
- *
145
- * @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
146
- */
147
- 'errors'<T extends ErrorMap>(errors: T): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, MergedErrorMap<TErrorMap, T>>;
148
- /**
149
- * Applies a middleware that runs before the handler and can access the
150
- * validated input.
151
- *
152
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
153
- */
154
- 'use'<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<InitialOutputSchema>, $ErrorMap>): BuilderWithInput<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, MergedErrorMap<$ErrorMap, TErrorMap>>;
155
- /**
156
- * Adds an additional input schema, merged with the previously defined one.
157
- *
158
- * @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
159
- */
160
- 'input'<T extends AnySchema>(schema: T): BuilderWithInput<TInitialContext, TInjectedContext, MergedSchema<T, TInputSchema>, TErrorMap>;
161
- /**
162
- * Defines the output schema used to validate and type the procedure output.
163
- *
164
- * @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
165
- */
166
- 'output'<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, T, TErrorMap>;
167
- /**
168
- * Defines the function that implements the procedure and completes the
169
- * chain, returning a callable procedure.
170
- *
171
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
172
- */
173
- 'handler'<T>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<TInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, Schema<T>, TErrorMap>;
174
- }
175
- /**
176
- * The builder variant returned after `.output` is called.
177
- * Only procedure-level methods remain available once an output schema is defined.
178
- *
179
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
180
- */
181
- interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
182
- '~orpc': BuilderDefinition<InitialInputSchema, TOutputSchema, TErrorMap>;
183
- /**
184
- * Applies metadata plugins to procedures built from this builder.
185
- *
186
- * @see {@link https://orpc.dev/docs/metadata | Metadata}
187
- */
188
- 'meta'(...plugins: MetaPlugin<InitialInputSchema, TOutputSchema, TErrorMap>[]): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
189
- /**
190
- * Defines typesafe errors that procedures built from this builder can throw
191
- * via the `errors` utility in handlers and middleware.
192
- *
193
- * @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
194
- */
195
- 'errors'<T extends ErrorMap>(errors: T): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
196
- /**
197
- * Applies a middleware that runs before the handler and can access the
198
- * typed output.
199
- *
200
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
201
- */
202
- 'use'<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<InitialInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): BuilderWithOutput<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TOutputSchema, MergedErrorMap<$ErrorMap, TErrorMap>>;
203
- /**
204
- * Defines the input schema used to validate and type the procedure input.
205
- *
206
- * @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
207
- */
208
- 'input'<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, T, TOutputSchema, TErrorMap>;
209
- /**
210
- * Adds an additional output schema, merged with the previously defined one.
211
- *
212
- * @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
213
- */
214
- 'output'<T extends AnySchema>(schema: T): BuilderWithOutput<TInitialContext, TInjectedContext, MergedSchema<T, TOutputSchema>, TErrorMap>;
215
- /**
216
- * Defines the function that implements the procedure and completes the
217
- * chain, returning a callable procedure.
218
- *
219
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
220
- */
221
- 'handler'<T extends InferSchemaInput<TOutputSchema>>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<InitialInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, InitialInputSchema, TOutputSchema, TErrorMap>;
222
- }
223
- /**
224
- * The builder variant returned after both `.input` and `.output` are called.
225
- * Only procedure-level methods remain available.
226
- *
227
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
228
- */
229
- interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
230
- '~orpc': BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>;
231
- /**
232
- * Applies metadata plugins to procedures built from this builder.
233
- *
234
- * @see {@link https://orpc.dev/docs/metadata | Metadata}
235
- */
236
- 'meta'(...plugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[]): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
237
- /**
238
- * Defines typesafe errors that procedures built from this builder can throw
239
- * via the `errors` utility in handlers and middleware.
240
- *
241
- * @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
242
- */
243
- 'errors'<T extends ErrorMap>(errors: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
244
- /**
245
- * Applies a middleware that runs before the handler and can access the
246
- * validated input and typed output.
247
- *
248
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
249
- */
250
- 'use'<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): BuilderWithInputOutput<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, TOutputSchema, MergedErrorMap<$ErrorMap, TErrorMap>>;
251
- /**
252
- * Adds an additional input schema, merged with the previously defined one.
253
- *
254
- * @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
255
- */
256
- 'input'<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, MergedSchema<T, TInputSchema>, TOutputSchema, TErrorMap>;
257
- /**
258
- * Adds an additional output schema, merged with the previously defined one.
259
- *
260
- * @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
261
- */
262
- 'output'<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, MergedSchema<T, TOutputSchema>, TErrorMap>;
263
- /**
264
- * Defines the function that implements the procedure and completes the
265
- * chain, returning a callable procedure.
266
- *
267
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
268
- */
269
- 'handler'<T extends InferSchemaInput<TOutputSchema>>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<TInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
270
- }
271
-
272
- /**
273
- * The initial context type used when `.$context` is not called.
274
- * Augment this interface with `declare module '@orpc/server'` to define
275
- * a default initial context type globally.
276
- *
277
- * @see {@link https://orpc.dev/docs/context#default-initial-context | Context - Default Initial Context}
278
- */
279
- interface DefaultInitialContext {
280
- }
281
- interface BuilderDefinition<TInputSchema extends AnySchema, TInjectedContext extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContractDefinition<TInputSchema, TInjectedContext, TErrorMap>, ProcedureConfig {
282
- orderedMiddlewares: OrderedMiddleware[];
283
- }
284
- /**
285
- * The procedure builder behind `os`. Chain its methods to gradually define
286
- * context, middleware, errors, schemas, and finally a handler or router.
287
- *
288
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
289
- */
290
- declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
291
- '~orpc': BuilderDefinition<InitialInputSchema, InitialOutputSchema, TErrorMap>;
292
- /**
293
- * Private constructor to prevent direct instantiation.
294
- * Use the static `create` method to initialize a new instance with a safe initial definition.
295
- */
296
- private constructor();
297
- /**
298
- * Creates a fresh builder with an empty definition.
299
- * Prefer the exported `os` instance over calling this directly.
300
- *
301
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
302
- */
303
- static create<T extends Context = DefaultInitialContext>(): Builder<T & object, Record<never, never>>;
304
- /**
305
- * Declares the initial context type that must be provided when executing
306
- * procedures built from this builder.
307
- *
308
- * @see {@link https://orpc.dev/docs/context#initial-context | Context - Initial Context}
309
- */
310
- $context<T extends Context = DefaultInitialContext>(): Builder<T & object, TErrorMap>;
311
- /**
312
- * Overrides the procedure configuration, such as disabling runtime
313
- * input/output validation.
314
- *
315
- * @see {@link https://orpc.dev/docs/recipes/validation-customization | Validation Customization}
316
- */
317
- $config(config: ProcedureConfig): Builder<TInitialContext, TErrorMap>;
318
- /**
319
- * Applies metadata plugins to procedures built from this builder.
320
- *
321
- * @see {@link https://orpc.dev/docs/metadata | Metadata}
322
- */
323
- meta(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): Builder<TInitialContext, TErrorMap>;
324
- /**
325
- * Defines typesafe errors that procedures built from this builder can throw
326
- * via the `errors` utility in handlers and middleware.
327
- *
328
- * @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
329
- */
330
- errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, MergedErrorMap<TErrorMap, U>>;
331
- /**
332
- * Applies a middleware that runs before the handler of every procedure
333
- * built from this builder.
334
- *
335
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
336
- */
337
- use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | TInitialContext, $OutContext, InferSchemaOutput<InitialInputSchema>, InferSchemaInput<InitialOutputSchema>, $ErrorMap>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, MergedErrorMap<$ErrorMap, TErrorMap>>;
338
- /**
339
- * Creates a standalone middleware that can be composed and applied to any
340
- * compatible builder or procedure with `.use`.
341
- *
342
- * @see {@link https://orpc.dev/docs/middleware | Middleware}
343
- */
344
- middleware<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $Input, $Output = any>(middleware: Middleware<TInitialContext, $OutContext, $Input, $Output, TErrorMap>): DecoratedMiddleware<TInitialContext, $OutContext, $Input, $Output, TErrorMap>;
345
- /**
346
- * Defines the input schema used to validate and type the procedure input.
347
- *
348
- * @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
349
- */
350
- input<$ extends AnySchema>(schema: $): BuilderWithInput<TInitialContext, object, $, TErrorMap>;
351
- /**
352
- * Defines the output schema used to validate and type the procedure output.
353
- *
354
- * @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
355
- */
356
- output<$ extends AnySchema>(schema: $): BuilderWithOutput<TInitialContext, object, $, TErrorMap>;
357
- /**
358
- * Defines the function that implements the procedure and completes the
359
- * chain, returning a callable procedure.
360
- *
361
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
362
- */
363
- handler<T>(handler: ProcedureHandler<TInitialContext, InferSchemaOutput<InitialInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, object, InitialInputSchema, Schema<T>, TErrorMap>;
364
- /**
365
- * Applies the builder's middleware, errors, and metadata to every procedure
366
- * in the given router.
367
- *
368
- * @see {@link https://orpc.dev/docs/router#extending-router | Router - Extending Router}
369
- */
370
- router<T extends AnyRouter>(router: T): AugmentedRouter<T, TErrorMap>;
371
- /**
372
- * Like `.router`, but loads the router lazily on first access, which helps
373
- * reduce startup time for large applications.
374
- *
375
- * @see {@link https://orpc.dev/docs/router#lazy-router | Router - Lazy Router}
376
- */
377
- lazy<T extends AnyRouter>(loader: () => Promise<{
378
- default: T;
379
- }>): Lazy<AugmentedRouter<T, TErrorMap>>;
380
- }
381
- /**
382
- * The oRPC procedure builder. Chain methods like `.input`, `.use`, and `.handler`
383
- * to define procedures, then compose them into routers.
384
- *
385
- * @see {@link https://orpc.dev/docs/procedure | Procedure}
386
- */
387
- declare const os: Builder<DefaultInitialContext & object, Record<never, never>>;
388
-
389
- declare const DEFAULT_SUCCESS_STATUS = 200;
390
- declare const DEFAULT_ERROR_STATUS = 400;
391
-
392
- declare class ProcedureImplementer<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
393
- '~orpc': BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>;
394
- constructor(definition: BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>);
395
- 'use'<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): ProcedureImplementer<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, TOutputSchema, TErrorMap>;
396
- 'handler'(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ImplementedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
397
- }
398
- declare class ImplementedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends Procedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap> {
399
- use<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): ImplementedProcedure<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, TOutputSchema, TErrorMap>;
400
- }
401
-
402
- declare class SharedRouterImplementer<TContract extends RouterContract, TInitialContext extends Context> {
403
- private readonly contract;
404
- private readonly config;
405
- private readonly middlewares;
406
- private constructor();
407
- static create<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): SharedRouterImplementer<TContract, TInitialContext>;
408
- static create<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context>(contract: TContract, config: ProcedureConfig, middlewares: AnyMiddleware[]): SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext>;
409
- use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = InferRouterContractErrorMap<TContract>>(middleware: Middleware<$InContext | TInitialContext, $OutContext, unknown, unknown, $ErrorMap>): RouterImplementerWithMiddlewares<TContract, MergedInitialContext<TInitialContext, object, $InContext>, $OutContext>;
410
- middleware<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $Input, $InContext extends Context = TInitialContext, $Output = any>(middleware: Middleware<$InContext | TInitialContext, $OutContext, $Input, $Output, InferRouterContractErrorMap<TContract>>): DecoratedMiddleware<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, $Input, $Output, object>;
411
- router<T extends ContractedRouter<TContract, any>>(router: T): T;
412
- lazy<T extends ContractedRouter<TContract, any>>(loader: () => Promise<{
413
- default: T;
414
- }>): Lazy<T>;
415
- }
416
- interface SharedRouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> {
417
- use<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = InferRouterContractErrorMap<TContract>>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, unknown, unknown, $ErrorMap>): RouterImplementerWithMiddlewares<TContract, MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>>;
418
- middleware<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $Input, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $Output = any>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, $Input, $Output, InferRouterContractErrorMap<TContract>>): DecoratedMiddleware<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, $Input, $Output, object>;
419
- router<T extends ContractedRouter<TContract, MergedContext<TInitialContext, TInjectedContext>>>(router: T): AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, object>;
420
- lazy<T extends ContractedRouter<TContract, any>>(loader: () => Promise<{
421
- default: T;
422
- }>): Lazy<AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, object>>;
423
- }
424
- type RouterImplementer<TContract extends RouterContract, TInitialContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, object, $InputSchema, $OutputSchema, $ErrorMap> : Public<SharedRouterImplementer<TContract, TInitialContext>> & {
425
- [K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementer<TContract[K], TInitialContext> : never;
426
- };
427
- type RouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, TInjectedContext, $InputSchema, $OutputSchema, $ErrorMap> : SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext> & {
428
- [K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementerWithMiddlewares<TContract[K], TInitialContext, TInjectedContext> : never;
429
- };
430
-
431
- type Implementer<TContract extends RouterContract, TInitialContext extends Context> = {
432
- $context<T extends Context = DefaultInitialContext>(): Implementer<TContract, T & object>;
433
- $config(config: ProcedureConfig): Implementer<TContract, TInitialContext>;
434
- } & RouterImplementer<TContract, TInitialContext>;
435
- /**
436
- * Turns a contract into an implementer, used to implement the contract's
437
- * procedures, routers, and middleware with full type safety.
438
- *
439
- * @see {@link https://orpc.dev/docs/contract/implementation#implementer | Contract Implementation - Implementer}
440
- */
441
- declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
442
-
443
- type CallOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = ProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, object> & Omit<ClientOptions<object>, 'context'>;
444
- type CallRest<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = object extends CallOptions<TInitialContext, TOutputSchema, TErrorMap> ? undefined extends InferSchemaInput<TInputSchema> ? [input?: InferSchemaInput<TInputSchema>, options?: CallOptions<TInitialContext, TOutputSchema, TErrorMap>] : [input: InferSchemaInput<TInputSchema>, options?: CallOptions<TInitialContext, TOutputSchema, TErrorMap>] : [input: InferSchemaInput<TInputSchema>, options: CallOptions<TInitialContext, TOutputSchema, TErrorMap>];
445
- /**
446
- * Quickly call a procedure without creating a client.
447
- *
448
- * @example
449
- * ```ts
450
- * const output = await call(getting, 'input')
451
- * const output = await call(getting, 'input', { context: { db: 'postgres' } })
452
- * ```
453
- *
454
- * @see {@link https://orpc.dev/docs/client/server-side#one-off-calls | Server-Side Clients - One-Off Calls}
455
- */
456
- declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap>>, ...[input, options,]: CallRest<TInitialContext, TInputSchema, TOutputSchema, TErrorMap>): PromiseWithError<InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>;
457
-
458
- /**
459
- * The client type derived from a router, exposing every procedure as a callable
460
- * function while preserving the router's shape.
461
- *
462
- * @see {@link https://orpc.dev/docs/client/client-side#creating-a-client | Client-Side Clients - Creating a Client}
463
- */
464
- type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = object> = TRouter extends Procedure<any, any, infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureClient<TClientContext, $InputSchema, $OutputSchema, $ErrorMap> : {
465
- [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
466
- };
467
- /**
468
- * Creates a server-side client that calls the router's procedures directly,
469
- * within the same process, without any network layer.
470
- *
471
- * @see {@link https://orpc.dev/docs/client/server-side#router-clients | Server-Side Clients - Router Clients}
472
- */
473
- declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext = object>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<ProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown>, ErrorMap, TClientContext>>): RouterClient<T, TClientContext>;
474
-
475
- export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware, OrderedMiddleware, Procedure, ProcedureClient, ProcedureClientOptions, ProcedureConfig, ProcedureHandler, ProcedureImplementer, Router, SharedRouterImplementer, call, createRouterClient, getRouter, implement, os, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync };
476
- export type { AugmentedRouter, AugmentedRouterWithMiddlewares, BuilderDefinition, BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput, CallOptions, CallRest, DecoratedMiddleware, DefaultInitialContext, Implementer, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementerWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult };
1
+ export * from "./builder.mjs";
2
+ export * from "./builder-variants.mjs";
3
+ export * from "./constants.mjs";
4
+ export * from "./context.mjs";
5
+ export * from "./implementer.mjs";
6
+ export * from "./implementer-procedure.mjs";
7
+ export { SharedRouterImplementer } from "./implementer-router.mjs";
8
+ export type { RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementerWithMiddlewares } from "./implementer-router.mjs";
9
+ export * from "./lazy.mjs";
10
+ export * from "./middleware.mjs";
11
+ export type { DecoratedMiddleware } from "./middleware-decorated.mjs";
12
+ export * from "./procedure.mjs";
13
+ export * from "./procedure-client.mjs";
14
+ export * from "./procedure-decorated.mjs";
15
+ export { call } from "./procedure-utils.mjs";
16
+ export type { CallOptions, CallRest } from "./procedure-utils.mjs";
17
+ export * from "./router.mjs";
18
+ export type {
19
+ /**
20
+ * @deprecated Use `InferRouterFinalContexts` instead.
21
+ */
22
+ InferRouterFinalContexts as InferRouterCurrentContexts } from "./router.mjs";
23
+ export * from "./router-client.mjs";
24
+ export { getRouter, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync } from "./router-utils.mjs";
25
+ export type { AugmentedRouter, AugmentedRouterWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult } from "./router-utils.mjs";
26
+ export type { AnyORPCError, AnyORPCErrorJSON, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult } from "@orpc/client";
27
+ export { COMMON_ERROR_STATUS_MAP, isDefinedError, ORPCError, RPCJsonSerializer, RPCSerializer, safe, toORPCError } from "@orpc/client";
28
+ export type { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, MergedSchema, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema } from "@orpc/contract";
29
+ export { asyncIteratorObject, defineMeta, error, eventIterator, type, ValidationError } from "@orpc/contract";
30
+ export type { AsyncCleanupFn, AsyncIteratorClassNextFn, DistributiveOmit, IntersectPick, MaybeOptionalOptions, PromiseWithError, Public, Registry, ThrowableError } from "@orpc/shared";
31
+ export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream,
32
+ /**
33
+ * @deprecated Use `asyncIteratorToStream` instead.
34
+ */
35
+ asyncIteratorToStream as eventIteratorToStream,
36
+ /**
37
+ * @deprecated Use `asyncIteratorToUnproxiedDataStream` instead.
38
+ */
39
+ asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject,
40
+ /**
41
+ * @deprecated Use `streamToAsyncIteratorObject` instead.
42
+ */
43
+ streamToAsyncIteratorObject as streamToEventIterator } from "@orpc/shared";
44
+ export type { EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from "@standard-server/core";
45
+ export { ErrorEvent,
46
+ /**
47
+ * Retrieves metadata attached to a single iterator event value.
48
+ *
49
+ * @see {@link https://orpc.dev/docs/helpers/publisher | Publisher Helpers}
50
+ */
51
+ getEventMeta, unwrapEvent,
52
+ /**
53
+ * Returns a new iterator event value with attached, validated metadata.
54
+ *
55
+ * @see {@link https://orpc.dev/docs/async-iterator-object#last-event-id--event-metadata | AsyncIteratorObject (SSE) - Last Event ID & Event Metadata}
56
+ */
57
+ withEventMeta } from "@standard-server/core";