@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.
- package/README.md +6 -4
- package/dist/adapters/aws-lambda/handler.d.mts +25 -0
- package/dist/adapters/aws-lambda/handler.mjs +21 -0
- package/dist/adapters/aws-lambda/index.d.mts +14 -49
- package/dist/adapters/aws-lambda/index.mjs +2 -39
- package/dist/adapters/aws-lambda/rpc-handler.d.mts +18 -0
- package/dist/adapters/aws-lambda/rpc-handler.mjs +10 -0
- package/dist/adapters/crossws/handler.d.mts +41 -0
- package/dist/adapters/crossws/handler.mjs +38 -0
- package/dist/adapters/crossws/index.d.mts +2 -63
- package/dist/adapters/crossws/index.mjs +2 -68
- package/dist/adapters/crossws/rpc-handler.d.mts +15 -0
- package/dist/adapters/crossws/rpc-handler.mjs +10 -0
- package/dist/adapters/fastify/handler.d.mts +21 -0
- package/dist/adapters/fastify/handler.mjs +20 -0
- package/dist/adapters/fastify/index.d.mts +2 -42
- package/dist/adapters/fastify/index.mjs +2 -39
- package/dist/adapters/fastify/rpc-handler.d.mts +14 -0
- package/dist/adapters/fastify/rpc-handler.mjs +10 -0
- package/dist/adapters/fetch/handler.d.mts +23 -0
- package/dist/adapters/fetch/handler.mjs +22 -0
- package/dist/adapters/fetch/index.d.mts +6 -46
- package/dist/adapters/fetch/index.mjs +4 -41
- package/dist/adapters/fetch/rpc-handler.d.mts +16 -0
- package/dist/adapters/fetch/rpc-handler.mjs +10 -0
- package/dist/adapters/message-port/handler.d.mts +57 -0
- package/dist/adapters/message-port/handler.mjs +62 -0
- package/dist/adapters/message-port/index.d.mts +2 -77
- package/dist/adapters/message-port/index.mjs +2 -87
- package/dist/adapters/message-port/rpc-handler.d.mts +15 -0
- package/dist/adapters/message-port/rpc-handler.mjs +10 -0
- package/dist/adapters/node/handler.d.mts +21 -0
- package/dist/adapters/node/handler.mjs +20 -0
- package/dist/adapters/node/index.d.mts +6 -43
- package/dist/adapters/node/index.mjs +4 -40
- package/dist/adapters/node/rpc-handler.d.mts +15 -0
- package/dist/adapters/node/rpc-handler.mjs +10 -0
- package/dist/adapters/standard/codec.d.mts +16 -0
- package/dist/adapters/standard/codec.mjs +1 -0
- package/dist/adapters/standard/handler.d.mts +68 -0
- package/dist/adapters/standard/handler.mjs +185 -0
- package/dist/adapters/standard/index.d.mts +6 -95
- package/dist/adapters/standard/index.mjs +5 -8
- package/dist/adapters/standard/plugin.d.mts +32 -0
- package/dist/adapters/standard/plugin.mjs +16 -0
- package/dist/adapters/standard/rpc-handler-codec.d.mts +42 -0
- package/dist/adapters/standard/rpc-handler-codec.mjs +51 -0
- package/dist/adapters/standard/rpc-matcher.d.mts +53 -0
- package/dist/adapters/standard/rpc-matcher.mjs +140 -0
- package/dist/adapters/standard/utils.d.mts +10 -0
- package/dist/adapters/standard/utils.mjs +6 -0
- package/dist/adapters/standard-peer/index.d.mts +1 -11
- package/dist/adapters/standard-peer/index.mjs +1 -10
- package/dist/adapters/standard-peer/utils.d.mts +4 -0
- package/dist/adapters/standard-peer/utils.mjs +11 -0
- package/dist/adapters/websocket/handler.d.mts +55 -0
- package/dist/adapters/websocket/handler.mjs +55 -0
- package/dist/adapters/websocket/index.d.mts +2 -77
- package/dist/adapters/websocket/index.mjs +2 -87
- package/dist/adapters/websocket/rpc-handler.d.mts +15 -0
- package/dist/adapters/websocket/rpc-handler.mjs +10 -0
- package/dist/builder-variants.d.mts +267 -0
- package/dist/builder-variants.mjs +1 -0
- package/dist/builder.d.mts +141 -0
- package/dist/builder.mjs +145 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +2 -0
- package/dist/context.d.mts +13 -0
- package/dist/context.mjs +1 -0
- package/dist/extensions/callable.d.mts +16 -9
- package/dist/extensions/callable.mjs +5 -9
- package/dist/helpers/base64url.d.mts +31 -0
- package/dist/helpers/base64url.mjs +25 -0
- package/dist/helpers/cookie.d.mts +50 -0
- package/dist/helpers/cookie.mjs +35 -0
- package/dist/helpers/encryption.d.mts +28 -0
- package/dist/helpers/encryption.mjs +62 -0
- package/dist/helpers/index.d.mts +4 -167
- package/dist/helpers/index.mjs +4 -200
- package/dist/helpers/signing.d.mts +50 -0
- package/dist/helpers/signing.mjs +43 -0
- package/dist/implementer-procedure.d.mts +36 -0
- package/dist/implementer-procedure.mjs +38 -0
- package/dist/implementer-router.d.mts +78 -0
- package/dist/implementer-router.mjs +77 -0
- package/dist/implementer.d.mts +22 -0
- package/dist/implementer.mjs +30 -0
- package/dist/index.d.mts +57 -476
- package/dist/index.mjs +25 -458
- package/dist/lazy.d.mts +20 -0
- package/dist/lazy.mjs +22 -0
- package/dist/middleware-decorated.d.mts +27 -0
- package/dist/middleware-decorated.mjs +65 -0
- package/dist/middleware.d.mts +70 -0
- package/dist/middleware.mjs +1 -0
- package/dist/plugins/batch.d.mts +104 -0
- package/dist/plugins/batch.mjs +373 -0
- package/dist/plugins/cors.d.mts +67 -0
- package/dist/plugins/cors.mjs +134 -0
- package/dist/plugins/get-method-csrf-protection.d.mts +23 -0
- package/dist/plugins/get-method-csrf-protection.mjs +45 -0
- package/dist/plugins/head-method.d.mts +23 -0
- package/dist/plugins/head-method.mjs +95 -0
- package/dist/plugins/index.d.mts +39 -432
- package/dist/plugins/index.mjs +23 -967
- package/dist/plugins/method-override.d.mts +38 -0
- package/dist/plugins/method-override.mjs +50 -0
- package/dist/plugins/request-compression.d.mts +16 -0
- package/dist/plugins/request-compression.mjs +67 -0
- package/dist/plugins/request-headers.d.mts +22 -0
- package/dist/plugins/request-headers.mjs +21 -0
- package/dist/plugins/request-limit.d.mts +30 -0
- package/dist/plugins/request-limit.mjs +53 -0
- package/dist/plugins/response-compression.d.mts +59 -0
- package/dist/plugins/response-compression.mjs +172 -0
- package/dist/plugins/response-headers.d.mts +30 -0
- package/dist/plugins/response-headers.mjs +34 -0
- package/dist/plugins/rethrow.d.mts +33 -0
- package/dist/plugins/rethrow.mjs +46 -0
- package/dist/plugins/signal-sync.d.mts +13 -0
- package/dist/plugins/signal-sync.mjs +84 -0
- package/dist/plugins/timeout.d.mts +37 -0
- package/dist/plugins/timeout.mjs +56 -0
- package/dist/procedure-client.d.mts +41 -0
- package/dist/procedure-client.mjs +157 -0
- package/dist/procedure-decorated.d.mts +20 -0
- package/dist/procedure-decorated.mjs +41 -0
- package/dist/procedure-utils.d.mts +52 -0
- package/dist/procedure-utils.mjs +33 -0
- package/dist/procedure.d.mts +93 -0
- package/dist/procedure.mjs +20 -0
- package/dist/router-client.d.mts +27 -0
- package/dist/router-client.mjs +35 -0
- package/dist/router-hidden.d.mts +5 -0
- package/dist/router-hidden.mjs +12 -0
- package/dist/router-utils.d.mts +59 -0
- package/dist/router-utils.mjs +191 -0
- package/dist/router.d.mts +61 -0
- package/dist/router.mjs +1 -0
- package/package.json +11 -11
- package/dist/adapters/aws-lambda/index.d.ts +0 -51
- package/dist/adapters/crossws/index.d.ts +0 -63
- package/dist/adapters/fastify/index.d.ts +0 -42
- package/dist/adapters/fetch/index.d.ts +0 -47
- package/dist/adapters/message-port/index.d.ts +0 -77
- package/dist/adapters/node/index.d.ts +0 -44
- package/dist/adapters/standard/index.d.ts +0 -95
- package/dist/adapters/standard-peer/index.d.ts +0 -11
- package/dist/adapters/websocket/index.d.ts +0 -77
- package/dist/extensions/callable.d.ts +0 -10
- package/dist/helpers/index.d.ts +0 -167
- package/dist/index.d.ts +0 -476
- package/dist/plugins/index.d.ts +0 -432
- package/dist/shared/server.1ExWFMze.mjs +0 -69
- package/dist/shared/server.9B1jEm5a.d.mts +0 -105
- package/dist/shared/server.BB464y-6.mjs +0 -207
- package/dist/shared/server.BC5BIu02.d.mts +0 -73
- package/dist/shared/server.BSYGskId.d.ts +0 -14
- package/dist/shared/server.BvG3boBj.d.mts +0 -14
- package/dist/shared/server.CTV_mC2P.d.mts +0 -34
- package/dist/shared/server.CYbIpHbH.mjs +0 -239
- package/dist/shared/server.CgBF3Vj1.d.ts +0 -34
- package/dist/shared/server.Chq5FpXf.mjs +0 -353
- package/dist/shared/server.DFPxP2v3.d.mts +0 -166
- package/dist/shared/server.DFPxP2v3.d.ts +0 -166
- package/dist/shared/server.DOg7ke6y.d.ts +0 -105
- package/dist/shared/server.Dz7j9BEh.d.ts +0 -73
- package/dist/shared/server.W91HSRkE.mjs +0 -9
- package/dist/shared/server.sBQSgqK3.mjs +0 -41
package/dist/index.d.mts
CHANGED
|
@@ -1,476 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type AugmentedRouter
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
type
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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";
|