@orpc/server 2.0.0-beta.49 → 2.0.0-beta.50
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/dist/adapters/aws-lambda/handler.d.ts +17 -15
- package/dist/adapters/aws-lambda/handler.js +23 -23
- package/dist/adapters/aws-lambda/index.d.ts +4 -16
- package/dist/adapters/aws-lambda/index.js +2 -2
- package/dist/adapters/aws-lambda/rpc-handler.d.ts +9 -9
- package/dist/adapters/aws-lambda/rpc-handler.js +20 -17
- package/dist/adapters/crossws/handler.d.ts +44 -42
- package/dist/adapters/crossws/handler.js +53 -60
- package/dist/adapters/crossws/index.d.ts +3 -2
- package/dist/adapters/crossws/index.js +2 -2
- package/dist/adapters/crossws/rpc-handler.d.ts +10 -10
- package/dist/adapters/crossws/rpc-handler.js +17 -14
- package/dist/adapters/fastify/handler.d.ts +17 -15
- package/dist/adapters/fastify/handler.js +20 -20
- package/dist/adapters/fastify/index.d.ts +3 -2
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/fastify/rpc-handler.d.ts +9 -9
- package/dist/adapters/fastify/rpc-handler.js +16 -13
- package/dist/adapters/fetch/handler.d.ts +19 -17
- package/dist/adapters/fetch/handler.js +22 -22
- package/dist/adapters/fetch/index.d.ts +4 -7
- package/dist/adapters/fetch/index.js +3 -7
- package/dist/adapters/fetch/rpc-handler.d.ts +9 -9
- package/dist/adapters/fetch/rpc-handler.js +18 -15
- package/dist/adapters/message-port/handler.d.ts +58 -60
- package/dist/adapters/message-port/handler.js +72 -86
- package/dist/adapters/message-port/index.d.ts +3 -2
- package/dist/adapters/message-port/index.js +2 -2
- package/dist/adapters/message-port/rpc-handler.d.ts +9 -9
- package/dist/adapters/message-port/rpc-handler.js +17 -14
- package/dist/adapters/node/handler.d.ts +17 -15
- package/dist/adapters/node/handler.js +20 -20
- package/dist/adapters/node/index.d.ts +4 -7
- package/dist/adapters/node/index.js +3 -7
- package/dist/adapters/node/rpc-handler.d.ts +9 -9
- package/dist/adapters/node/rpc-handler.js +17 -14
- package/dist/adapters/standard/codec.d.ts +13 -13
- package/dist/adapters/standard/handler.d.ts +49 -49
- package/dist/adapters/standard/handler.js +205 -205
- package/dist/adapters/standard/index.d.ts +7 -6
- package/dist/adapters/standard/index.js +4 -5
- package/dist/adapters/standard/plugin.d.ts +25 -31
- package/dist/adapters/standard/plugin.js +14 -16
- package/dist/adapters/standard/rpc-handler-codec.d.ts +39 -43
- package/dist/adapters/standard/rpc-handler-codec.js +50 -51
- package/dist/adapters/standard/rpc-matcher.d.ts +40 -40
- package/dist/adapters/standard/rpc-matcher.js +103 -149
- package/dist/adapters/standard/utils.d.ts +8 -8
- package/dist/adapters/standard/utils.js +7 -5
- package/dist/adapters/standard-peer/index.d.ts +2 -1
- package/dist/adapters/standard-peer/index.js +1 -1
- package/dist/adapters/standard-peer/utils.d.ts +6 -4
- package/dist/adapters/standard-peer/utils.js +12 -6
- package/dist/adapters/websocket/handler.d.ts +52 -50
- package/dist/adapters/websocket/handler.js +75 -85
- package/dist/adapters/websocket/index.d.ts +3 -2
- package/dist/adapters/websocket/index.js +2 -2
- package/dist/adapters/websocket/rpc-handler.d.ts +9 -9
- package/dist/adapters/websocket/rpc-handler.js +17 -14
- package/dist/builder-variants.d.ts +195 -195
- package/dist/builder.d.ts +103 -104
- package/dist/builder.js +198 -224
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +4 -2
- package/dist/context.d.ts +3 -3
- package/dist/extensions/callable.d.ts +11 -11
- package/dist/extensions/callable.js +6 -5
- package/dist/helpers/base64url.d.ts +1 -1
- package/dist/helpers/base64url.js +44 -49
- package/dist/helpers/cookie.d.ts +10 -11
- package/dist/helpers/cookie.js +56 -63
- package/dist/helpers/encryption.d.ts +1 -1
- package/dist/helpers/encryption.js +80 -70
- package/dist/helpers/index.d.ts +5 -4
- package/dist/helpers/index.js +4 -4
- package/dist/helpers/signing.d.ts +1 -1
- package/dist/helpers/signing.js +72 -82
- package/dist/implementer-procedure.d.ts +12 -13
- package/dist/implementer-procedure.js +37 -44
- package/dist/implementer-router.d.ts +30 -36
- package/dist/implementer-router.js +92 -111
- package/dist/implementer.d.ts +8 -8
- package/dist/implementer.js +28 -35
- package/dist/index.d.ts +22 -61
- package/dist/index.js +16 -48
- package/dist/lazy.d.ts +14 -14
- package/dist/lazy.js +19 -30
- package/dist/middleware-decorated.d.ts +8 -9
- package/dist/middleware-decorated.js +66 -70
- package/dist/middleware.d.ts +34 -34
- package/dist/plugins/batch.d.ts +75 -75
- package/dist/plugins/batch.js +345 -379
- package/dist/plugins/cors.d.ts +60 -64
- package/dist/plugins/cors.js +118 -111
- package/dist/plugins/get-method-csrf-protection.d.ts +8 -6
- package/dist/plugins/get-method-csrf-protection.js +47 -63
- package/dist/plugins/head-method.d.ts +11 -9
- package/dist/plugins/head-method.js +97 -94
- package/dist/plugins/index.d.ts +15 -39
- package/dist/plugins/index.js +14 -29
- package/dist/plugins/method-override.d.ts +30 -28
- package/dist/plugins/method-override.js +53 -49
- package/dist/plugins/request-compression.d.ts +11 -9
- package/dist/plugins/request-compression.js +52 -79
- package/dist/plugins/request-headers.d.ts +10 -8
- package/dist/plugins/request-headers.js +27 -29
- package/dist/plugins/request-limit.d.ts +21 -19
- package/dist/plugins/request-limit.js +60 -67
- package/dist/plugins/response-compression.d.ts +42 -39
- package/dist/plugins/response-compression.js +150 -202
- package/dist/plugins/response-headers.d.ts +15 -13
- package/dist/plugins/response-headers.js +43 -46
- package/dist/plugins/rethrow.d.ts +25 -23
- package/dist/plugins/rethrow.js +46 -58
- package/dist/plugins/signal-sync.d.ts +7 -5
- package/dist/plugins/signal-sync.js +71 -86
- package/dist/plugins/timeout.d.ts +29 -27
- package/dist/plugins/timeout.js +61 -58
- package/dist/procedure-client.d.ts +14 -15
- package/dist/procedure-client.js +149 -166
- package/dist/procedure-decorated.d.ts +9 -9
- package/dist/procedure-decorated.js +36 -44
- package/dist/procedure-utils.d.ts +10 -30
- package/dist/procedure-utils.js +39 -40
- package/dist/procedure.d.ts +60 -60
- package/dist/procedure.js +18 -24
- package/dist/router-client.d.ts +9 -11
- package/dist/router-client.js +33 -41
- package/dist/router-hidden.js +10 -12
- package/dist/router-utils.d.ts +13 -30
- package/dist/router-utils.js +146 -191
- package/dist/router.d.ts +12 -26
- package/package.json +10 -10
- package/dist/adapters/standard/codec.js +0 -1
- package/dist/builder-variants.js +0 -1
- package/dist/context.js +0 -1
- package/dist/middleware.js +0 -1
- package/dist/router-hidden.d.ts +0 -5
- package/dist/router.js +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import { BuilderDefinition } from "./builder.js";
|
|
2
|
+
import { Context, MergedContext, MergedInitialContext } from "./context.js";
|
|
3
|
+
import { Lazy } from "./lazy.js";
|
|
4
|
+
import { Middleware } from "./middleware.js";
|
|
5
|
+
import { DecoratedMiddleware } from "./middleware-decorated.js";
|
|
6
|
+
import { ProcedureHandler } from "./procedure.js";
|
|
7
|
+
import { DecoratedProcedure } from "./procedure-decorated.js";
|
|
8
|
+
import { Router } from "./router.js";
|
|
9
|
+
import { AugmentedRouterWithMiddlewares } from "./router-utils.js";
|
|
10
|
+
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, MergedSchema, MetaPlugin, ORPCErrorConstructorMap, Schema } from "@orpc/contract";
|
|
11
|
+
import { IntersectPick } from "@orpc/shared";
|
|
12
12
|
/**
|
|
13
13
|
* The builder variant returned after `.use` is called.
|
|
14
14
|
* `.$context` and `.$config` are no longer available once middleware is applied.
|
|
@@ -16,69 +16,69 @@ import type { Router } from './router.ts';
|
|
|
16
16
|
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
17
17
|
*/
|
|
18
18
|
export interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
19
|
+
"~orpc": BuilderDefinition<InitialInputSchema, InitialOutputSchema, TErrorMap>;
|
|
20
|
+
/**
|
|
21
|
+
* Applies metadata plugins to procedures built from this builder.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://orpc.dev/docs/metadata | Metadata}
|
|
24
|
+
*/
|
|
25
|
+
"meta"(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
|
|
26
|
+
/**
|
|
27
|
+
* Defines typesafe errors that procedures built from this builder can throw
|
|
28
|
+
* via the `errors` utility in handlers and middleware.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
|
|
31
|
+
*/
|
|
32
|
+
"errors"<T extends ErrorMap>(errors: T): BuilderWithMiddlewares<TInitialContext, TInjectedContext, MergedErrorMap<TErrorMap, T>>;
|
|
33
|
+
/**
|
|
34
|
+
* Applies a middleware that runs before the handler of every procedure
|
|
35
|
+
* built from this builder.
|
|
36
|
+
*
|
|
37
|
+
* @see {@link https://orpc.dev/docs/middleware | Middleware}
|
|
38
|
+
*/
|
|
39
|
+
"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>>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a standalone middleware that can be composed and applied to any
|
|
42
|
+
* compatible builder or procedure with `.use`.
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://orpc.dev/docs/middleware | Middleware}
|
|
45
|
+
*/
|
|
46
|
+
"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>;
|
|
47
|
+
/**
|
|
48
|
+
* Defines the input schema used to validate and type the procedure input.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
|
|
51
|
+
*/
|
|
52
|
+
"input"<T extends AnySchema>(schema: T): BuilderWithInput<TInitialContext, TInjectedContext, T, TErrorMap>;
|
|
53
|
+
/**
|
|
54
|
+
* Defines the output schema used to validate and type the procedure output.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
|
|
57
|
+
*/
|
|
58
|
+
"output"<T extends AnySchema>(schema: T): BuilderWithOutput<TInitialContext, TInjectedContext, T, TErrorMap>;
|
|
59
|
+
/**
|
|
60
|
+
* Defines the function that implements the procedure and completes the
|
|
61
|
+
* chain, returning a callable procedure.
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
64
|
+
*/
|
|
65
|
+
"handler"<T>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<InitialInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, InitialInputSchema, Schema<T>, TErrorMap>;
|
|
66
|
+
/**
|
|
67
|
+
* Applies the builder's middleware, errors, and metadata to every procedure
|
|
68
|
+
* in the given router.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link https://orpc.dev/docs/router#extending-router | Router - Extending Router}
|
|
71
|
+
*/
|
|
72
|
+
"router"<T extends Router<MergedContext<TInitialContext, TInjectedContext>>>(router: T): AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, TErrorMap>;
|
|
73
|
+
/**
|
|
74
|
+
* Like `.router`, but loads the router lazily on first access, which helps
|
|
75
|
+
* reduce startup time for large applications.
|
|
76
|
+
*
|
|
77
|
+
* @see {@link https://orpc.dev/docs/router#lazy-router | Router - Lazy Router}
|
|
78
|
+
*/
|
|
79
|
+
"lazy"<T extends Router<MergedContext<TInitialContext, TInjectedContext>>>(loader: () => Promise<{
|
|
80
|
+
default: T;
|
|
81
|
+
}>): Lazy<AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, TErrorMap>>;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* The builder variant returned after `.input` is called.
|
|
@@ -87,46 +87,46 @@ export interface BuilderWithMiddlewares<TInitialContext extends Context, TInject
|
|
|
87
87
|
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
88
88
|
*/
|
|
89
89
|
export interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
90
|
+
"~orpc": BuilderDefinition<TInputSchema, InitialOutputSchema, TErrorMap>;
|
|
91
|
+
/**
|
|
92
|
+
* Applies metadata plugins to procedures built from this builder.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link https://orpc.dev/docs/metadata | Metadata}
|
|
95
|
+
*/
|
|
96
|
+
"meta"(...plugins: MetaPlugin<TInputSchema, InitialOutputSchema, TErrorMap>[]): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
|
|
97
|
+
/**
|
|
98
|
+
* Defines typesafe errors that procedures built from this builder can throw
|
|
99
|
+
* via the `errors` utility in handlers and middleware.
|
|
100
|
+
*
|
|
101
|
+
* @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
|
|
102
|
+
*/
|
|
103
|
+
"errors"<T extends ErrorMap>(errors: T): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, MergedErrorMap<TErrorMap, T>>;
|
|
104
|
+
/**
|
|
105
|
+
* Applies a middleware that runs before the handler and can access the
|
|
106
|
+
* validated input.
|
|
107
|
+
*
|
|
108
|
+
* @see {@link https://orpc.dev/docs/middleware | Middleware}
|
|
109
|
+
*/
|
|
110
|
+
"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>>;
|
|
111
|
+
/**
|
|
112
|
+
* Adds an additional input schema, merged with the previously defined one.
|
|
113
|
+
*
|
|
114
|
+
* @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
|
|
115
|
+
*/
|
|
116
|
+
"input"<T extends AnySchema>(schema: T): BuilderWithInput<TInitialContext, TInjectedContext, MergedSchema<T, TInputSchema>, TErrorMap>;
|
|
117
|
+
/**
|
|
118
|
+
* Defines the output schema used to validate and type the procedure output.
|
|
119
|
+
*
|
|
120
|
+
* @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
|
|
121
|
+
*/
|
|
122
|
+
"output"<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, T, TErrorMap>;
|
|
123
|
+
/**
|
|
124
|
+
* Defines the function that implements the procedure and completes the
|
|
125
|
+
* chain, returning a callable procedure.
|
|
126
|
+
*
|
|
127
|
+
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
128
|
+
*/
|
|
129
|
+
"handler"<T>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<TInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, Schema<T>, TErrorMap>;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* The builder variant returned after `.output` is called.
|
|
@@ -135,46 +135,46 @@ export interface BuilderWithInput<TInitialContext extends Context, TInjectedCont
|
|
|
135
135
|
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
136
136
|
*/
|
|
137
137
|
export interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
138
|
+
"~orpc": BuilderDefinition<InitialInputSchema, TOutputSchema, TErrorMap>;
|
|
139
|
+
/**
|
|
140
|
+
* Applies metadata plugins to procedures built from this builder.
|
|
141
|
+
*
|
|
142
|
+
* @see {@link https://orpc.dev/docs/metadata | Metadata}
|
|
143
|
+
*/
|
|
144
|
+
"meta"(...plugins: MetaPlugin<InitialInputSchema, TOutputSchema, TErrorMap>[]): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
|
|
145
|
+
/**
|
|
146
|
+
* Defines typesafe errors that procedures built from this builder can throw
|
|
147
|
+
* via the `errors` utility in handlers and middleware.
|
|
148
|
+
*
|
|
149
|
+
* @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
|
|
150
|
+
*/
|
|
151
|
+
"errors"<T extends ErrorMap>(errors: T): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
|
|
152
|
+
/**
|
|
153
|
+
* Applies a middleware that runs before the handler and can access the
|
|
154
|
+
* typed output.
|
|
155
|
+
*
|
|
156
|
+
* @see {@link https://orpc.dev/docs/middleware | Middleware}
|
|
157
|
+
*/
|
|
158
|
+
"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>>;
|
|
159
|
+
/**
|
|
160
|
+
* Defines the input schema used to validate and type the procedure input.
|
|
161
|
+
*
|
|
162
|
+
* @see {@link https://orpc.dev/docs/procedure#inputoutput-validation | Procedure - Input/Output Validation}
|
|
163
|
+
*/
|
|
164
|
+
"input"<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, T, TOutputSchema, TErrorMap>;
|
|
165
|
+
/**
|
|
166
|
+
* Adds an additional output schema, merged with the previously defined one.
|
|
167
|
+
*
|
|
168
|
+
* @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
|
|
169
|
+
*/
|
|
170
|
+
"output"<T extends AnySchema>(schema: T): BuilderWithOutput<TInitialContext, TInjectedContext, MergedSchema<T, TOutputSchema>, TErrorMap>;
|
|
171
|
+
/**
|
|
172
|
+
* Defines the function that implements the procedure and completes the
|
|
173
|
+
* chain, returning a callable procedure.
|
|
174
|
+
*
|
|
175
|
+
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
176
|
+
*/
|
|
177
|
+
"handler"<T extends InferSchemaInput<TOutputSchema>>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<InitialInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, InitialInputSchema, TOutputSchema, TErrorMap>;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* The builder variant returned after both `.input` and `.output` are called.
|
|
@@ -183,44 +183,44 @@ export interface BuilderWithOutput<TInitialContext extends Context, TInjectedCon
|
|
|
183
183
|
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
184
184
|
*/
|
|
185
185
|
export interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
186
|
+
"~orpc": BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>;
|
|
187
|
+
/**
|
|
188
|
+
* Applies metadata plugins to procedures built from this builder.
|
|
189
|
+
*
|
|
190
|
+
* @see {@link https://orpc.dev/docs/metadata | Metadata}
|
|
191
|
+
*/
|
|
192
|
+
"meta"(...plugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[]): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
193
|
+
/**
|
|
194
|
+
* Defines typesafe errors that procedures built from this builder can throw
|
|
195
|
+
* via the `errors` utility in handlers and middleware.
|
|
196
|
+
*
|
|
197
|
+
* @see {@link https://orpc.dev/docs/error-handling#typesafe-errors | Error Handling - Typesafe Errors}
|
|
198
|
+
*/
|
|
199
|
+
"errors"<T extends ErrorMap>(errors: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
|
|
200
|
+
/**
|
|
201
|
+
* Applies a middleware that runs before the handler and can access the
|
|
202
|
+
* validated input and typed output.
|
|
203
|
+
*
|
|
204
|
+
* @see {@link https://orpc.dev/docs/middleware | Middleware}
|
|
205
|
+
*/
|
|
206
|
+
"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>>;
|
|
207
|
+
/**
|
|
208
|
+
* Adds an additional input schema, merged with the previously defined one.
|
|
209
|
+
*
|
|
210
|
+
* @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
|
|
211
|
+
*/
|
|
212
|
+
"input"<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, MergedSchema<T, TInputSchema>, TOutputSchema, TErrorMap>;
|
|
213
|
+
/**
|
|
214
|
+
* Adds an additional output schema, merged with the previously defined one.
|
|
215
|
+
*
|
|
216
|
+
* @see {@link https://orpc.dev/docs/procedure#multiple-schemas | Procedure - Multiple Schemas}
|
|
217
|
+
*/
|
|
218
|
+
"output"<T extends AnySchema>(schema: T): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, MergedSchema<T, TOutputSchema>, TErrorMap>;
|
|
219
|
+
/**
|
|
220
|
+
* Defines the function that implements the procedure and completes the
|
|
221
|
+
* chain, returning a callable procedure.
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
224
|
+
*/
|
|
225
|
+
"handler"<T extends InferSchemaInput<TOutputSchema>>(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<TInputSchema>, T, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
226
|
+
}
|