@orpc/server 2.0.0-beta.23 → 2.0.0-beta.25
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 +4 -1
- package/dist/adapters/aws-lambda/index.d.mts +93 -0
- package/dist/adapters/aws-lambda/index.d.ts +93 -0
- package/dist/adapters/aws-lambda/index.mjs +66 -0
- package/dist/adapters/crossws/index.d.mts +10 -4
- package/dist/adapters/crossws/index.d.ts +10 -4
- package/dist/adapters/crossws/index.mjs +3 -3
- package/dist/adapters/fastify/index.d.mts +85 -0
- package/dist/adapters/fastify/index.d.ts +85 -0
- package/dist/adapters/fastify/index.mjs +66 -0
- package/dist/adapters/fetch/index.d.mts +13 -16
- package/dist/adapters/fetch/index.d.ts +13 -16
- package/dist/adapters/fetch/index.mjs +6 -12
- package/dist/adapters/message-port/index.d.mts +12 -7
- package/dist/adapters/message-port/index.d.ts +12 -7
- package/dist/adapters/message-port/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +12 -16
- package/dist/adapters/node/index.d.ts +12 -16
- package/dist/adapters/node/index.mjs +7 -12
- package/dist/adapters/standard/index.d.mts +5 -5
- package/dist/adapters/standard/index.d.ts +5 -5
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/standard-peer/index.d.mts +2 -2
- package/dist/adapters/standard-peer/index.d.ts +2 -2
- package/dist/adapters/websocket/index.d.mts +10 -4
- package/dist/adapters/websocket/index.d.ts +10 -4
- package/dist/adapters/websocket/index.mjs +3 -3
- package/dist/extensions/callable.d.mts +1 -1
- package/dist/extensions/callable.d.ts +1 -1
- package/dist/extensions/callable.mjs +2 -2
- package/dist/helpers/index.d.mts +20 -3
- package/dist/helpers/index.d.ts +20 -3
- package/dist/index.d.mts +39 -7
- package/dist/index.d.ts +39 -7
- package/dist/index.mjs +23 -18
- package/dist/plugins/index.d.mts +59 -48
- package/dist/plugins/index.d.ts +59 -48
- package/dist/plugins/index.mjs +34 -67
- package/dist/shared/{server.DofEOwf-.mjs → server.7T18Khvf.mjs} +6 -32
- package/dist/shared/{server.DBs0rrf9.mjs → server.B2pXdfpL.mjs} +1 -1
- package/dist/shared/server.BhHrioCw.d.ts +34 -0
- package/dist/shared/{server.DG9aQpJK.d.ts → server.C2n16pp0.d.ts} +27 -5
- package/dist/shared/{server.A8J9H8OE.mjs → server.Cbv46U7N.mjs} +21 -5
- package/dist/shared/server.Cd4Z1hpV.mjs +69 -0
- package/dist/shared/{server.omY4cUs0.d.mts → server.CkNnZ5F-.d.mts} +27 -5
- package/dist/shared/{server.CcR4kgje.d.ts → server.CwrYlF72.d.mts} +10 -42
- package/dist/shared/{server.CcR4kgje.d.mts → server.CwrYlF72.d.ts} +10 -42
- package/dist/shared/server.D0Ipbmdv.d.mts +34 -0
- package/dist/shared/{server.D4cnq66J.mjs → server.DgunZU0v.mjs} +3 -3
- package/dist/shared/{server.m3szVJGU.d.ts → server.Dm0os-OP.d.mts} +24 -12
- package/dist/shared/{server.BhsVw7m7.d.ts → server.DrN1Pj1-.d.ts} +3 -3
- package/dist/shared/{server.15O7oC1p.d.mts → server.DtfwuV6U.d.ts} +24 -12
- package/dist/shared/{server.DDFizwfU.d.mts → server.JbCIPL4P.d.mts} +3 -3
- package/package.json +26 -9
- package/dist/shared/server.D_QauotT.mjs +0 -30
package/dist/helpers/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ import { ParseOptions, SetCookie, StringifyOptions } from 'cookie';
|
|
|
11
11
|
* const decoded = decodeBase64url(encoded)
|
|
12
12
|
* expect(new TextDecoder().decode(decoded)).toEqual(text)
|
|
13
13
|
* ```
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://orpc.dev/docs/helpers/base64url | Base64Url Helpers}
|
|
14
16
|
*/
|
|
15
17
|
declare function encodeBase64url(data: Uint8Array): string;
|
|
16
18
|
/**
|
|
@@ -24,6 +26,8 @@ declare function encodeBase64url(data: Uint8Array): string;
|
|
|
24
26
|
* const decoded = decodeBase64url(encoded)
|
|
25
27
|
* expect(new TextDecoder().decode(decoded)).toEqual(text)
|
|
26
28
|
* ```
|
|
29
|
+
*
|
|
30
|
+
* @see {@link https://orpc.dev/docs/helpers/base64url | Base64Url Helpers}
|
|
27
31
|
*/
|
|
28
32
|
declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
|
|
29
33
|
|
|
@@ -36,7 +40,7 @@ interface SetCookieOptions extends Omit<SetCookie, 'name' | 'value'>, StringifyO
|
|
|
36
40
|
path?: string;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
|
-
* Sets a cookie in the response headers
|
|
43
|
+
* Sets a cookie in the response headers.
|
|
40
44
|
*
|
|
41
45
|
* Does nothing if `headers` is `undefined`.
|
|
42
46
|
*
|
|
@@ -49,6 +53,7 @@ interface SetCookieOptions extends Omit<SetCookie, 'name' | 'value'>, StringifyO
|
|
|
49
53
|
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; Max-Age=3600; Path=/; HttpOnly')
|
|
50
54
|
* ```
|
|
51
55
|
*
|
|
56
|
+
* @see {@link https://orpc.dev/docs/helpers/cookie | Cookie Helpers}
|
|
52
57
|
*/
|
|
53
58
|
declare function setCookie(headers: Headers | undefined, name: string, value: string, options?: SetCookieOptions): void;
|
|
54
59
|
interface GetCookieOptions extends ParseOptions {
|
|
@@ -66,10 +71,14 @@ interface GetCookieOptions extends ParseOptions {
|
|
|
66
71
|
*
|
|
67
72
|
* expect(sessionId).toEqual('abc123')
|
|
68
73
|
* ```
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://orpc.dev/docs/helpers/cookie | Cookie Helpers}
|
|
69
76
|
*/
|
|
70
77
|
declare function getCookie(headers: Headers | undefined, name: string, options?: GetCookieOptions): string | undefined;
|
|
71
78
|
/**
|
|
72
79
|
* Deletes a cookie by marking it expired.
|
|
80
|
+
*
|
|
81
|
+
* @see {@link https://orpc.dev/docs/helpers/cookie | Cookie Helpers}
|
|
73
82
|
*/
|
|
74
83
|
declare function deleteCookie(headers: Headers | undefined, name: string, options?: Omit<SetCookieOptions, 'maxAge'>): void;
|
|
75
84
|
|
|
@@ -83,6 +92,8 @@ declare function deleteCookie(headers: Headers | undefined, name: string, option
|
|
|
83
92
|
* const decrypted = await decrypt(encrypted, "test-secret-key")
|
|
84
93
|
* expect(decrypted).toBe("Hello, World!")
|
|
85
94
|
* ```
|
|
95
|
+
*
|
|
96
|
+
* @see {@link https://orpc.dev/docs/helpers/encryption | Encryption Helpers}
|
|
86
97
|
*/
|
|
87
98
|
declare function encrypt(value: string, secret: string): Promise<string>;
|
|
88
99
|
/**
|
|
@@ -95,6 +106,8 @@ declare function encrypt(value: string, secret: string): Promise<string>;
|
|
|
95
106
|
* const decrypted = await decrypt(encrypted, "test-secret-key")
|
|
96
107
|
* expect(decrypted).toBe("Hello, World!")
|
|
97
108
|
* ```
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://orpc.dev/docs/helpers/encryption | Encryption Helpers}
|
|
98
111
|
*/
|
|
99
112
|
declare function decrypt(encrypted: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
100
113
|
|
|
@@ -105,12 +118,13 @@ declare function decrypt(encrypted: string | undefined | null, secret: string):
|
|
|
105
118
|
* the integrity and authenticity of the data. The signature is appended to
|
|
106
119
|
* the original value, separated by a dot, using base64url encoding (no padding).
|
|
107
120
|
*
|
|
108
|
-
*
|
|
109
121
|
* @example
|
|
110
122
|
* ```ts
|
|
111
123
|
* const signedValue = await sign("user123", "my-secret-key")
|
|
112
124
|
* expect(signedValue).toEqual("user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA")
|
|
113
125
|
* ```
|
|
126
|
+
*
|
|
127
|
+
* @see {@link https://orpc.dev/docs/helpers/signing | Signing Helpers}
|
|
114
128
|
*/
|
|
115
129
|
declare function sign(value: string, secret: string): Promise<string>;
|
|
116
130
|
/**
|
|
@@ -120,13 +134,14 @@ declare function sign(value: string, secret: string): Promise<string>;
|
|
|
120
134
|
* secret key. If the signature is valid, it returns the original value. If the
|
|
121
135
|
* signature is invalid or the format is incorrect, it returns undefined.
|
|
122
136
|
*
|
|
123
|
-
*
|
|
124
137
|
* @example
|
|
125
138
|
* ```ts
|
|
126
139
|
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
127
140
|
* const originalValue = await unsign(signedValue, "my-secret-key")
|
|
128
141
|
* expect(originalValue).toEqual("user123")
|
|
129
142
|
* ```
|
|
143
|
+
*
|
|
144
|
+
* @see {@link https://orpc.dev/docs/helpers/signing | Signing Helpers}
|
|
130
145
|
*/
|
|
131
146
|
declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
132
147
|
/**
|
|
@@ -142,6 +157,8 @@ declare function unsign(signedValue: string | undefined | null, secret: string):
|
|
|
142
157
|
* const value = getSignedValue(signedValue)
|
|
143
158
|
* expect(value).toEqual("user123")
|
|
144
159
|
* ```
|
|
160
|
+
*
|
|
161
|
+
* @see {@link https://orpc.dev/docs/helpers/signing | Signing Helpers}
|
|
145
162
|
*/
|
|
146
163
|
declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
|
|
147
164
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
|
|
2
2
|
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, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
3
|
-
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
4
|
-
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
3
|
+
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, ORPCErrorConstructorMap, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
4
|
+
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
5
5
|
import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
6
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
7
|
-
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as ProcedureConfig, g as AnyMiddleware, h as Lazy, A as AnyProcedure, L as Lazyable, i as ProcedureHandler, O as
|
|
8
|
-
export {
|
|
9
|
-
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.
|
|
10
|
-
export { a as
|
|
7
|
+
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as ProcedureConfig, g as AnyMiddleware, h as Lazy, A as AnyProcedure, L as Lazyable, i as ProcedureHandler, O as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.CwrYlF72.mjs';
|
|
8
|
+
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.CwrYlF72.mjs';
|
|
9
|
+
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.Dm0os-OP.mjs';
|
|
10
|
+
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.Dm0os-OP.mjs';
|
|
11
11
|
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
12
12
|
|
|
13
13
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
|
|
@@ -47,6 +47,12 @@ declare function walkProcedureContractsAsync(router: RouterContract | AnyRouter,
|
|
|
47
47
|
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
48
48
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Fully resolves all lazy routers inside a router, returning a plain router.
|
|
52
|
+
* Useful for making a router with lazy parts contract-compatible.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://orpc.dev/docs/contract/router#router-to-contract | Router Contract - Router to Contract}
|
|
55
|
+
*/
|
|
50
56
|
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
51
57
|
|
|
52
58
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
|
|
@@ -114,6 +120,12 @@ declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMa
|
|
|
114
120
|
default: T;
|
|
115
121
|
}>): Lazy<AugmentedRouter<T, TErrorMap>>;
|
|
116
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* The oRPC procedure builder. Chain methods like `.input`, `.use`, and `.handler`
|
|
125
|
+
* to define procedures, then compose them into routers.
|
|
126
|
+
*
|
|
127
|
+
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
128
|
+
*/
|
|
117
129
|
declare const os: Builder<DefaultInitialContext & object, Record<never, never>>;
|
|
118
130
|
|
|
119
131
|
declare const DEFAULT_SUCCESS_STATUS = 200;
|
|
@@ -163,6 +175,12 @@ type Implementer<TContract extends RouterContract, TInitialContext extends Conte
|
|
|
163
175
|
$context<T extends Context = DefaultInitialContext>(): Implementer<TContract, T & object>;
|
|
164
176
|
$config(config: ProcedureConfig): Implementer<TContract, TInitialContext>;
|
|
165
177
|
} & RouterImplementer<TContract, TInitialContext>;
|
|
178
|
+
/**
|
|
179
|
+
* Turns a contract into an implementer, used to implement the contract's
|
|
180
|
+
* procedures, routers, and middleware with full type safety.
|
|
181
|
+
*
|
|
182
|
+
* @see {@link https://orpc.dev/docs/contract/implementation#implementer | Contract Implementation - Implementer}
|
|
183
|
+
*/
|
|
166
184
|
declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
|
|
167
185
|
|
|
168
186
|
declare function createGuardedProcedureLazy(lazy: Lazy<unknown>): Lazy<AnyProcedure>;
|
|
@@ -184,16 +202,30 @@ type CallRest<TInitialContext extends Context, TInputSchema extends AnySchema, T
|
|
|
184
202
|
* const output = await call(getting, 'input')
|
|
185
203
|
* const output = await call(getting, 'input', { context: { db: 'postgres' } })
|
|
186
204
|
* ```
|
|
205
|
+
*
|
|
206
|
+
* @see {@link https://orpc.dev/docs/client/server-side#one-off-calls | Server-Side Clients - One-Off Calls}
|
|
187
207
|
*/
|
|
188
208
|
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TReturnedError extends AnyORPCError>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TReturnedError>>, ...[input, options,]: CallRest<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TReturnedError>): PromiseWithError<InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | TReturnedError | ThrowableError>;
|
|
189
209
|
|
|
210
|
+
/**
|
|
211
|
+
* The client type derived from a router, exposing every procedure as a callable
|
|
212
|
+
* function while preserving the router's shape.
|
|
213
|
+
*
|
|
214
|
+
* @see {@link https://orpc.dev/docs/client/client-side#creating-a-client | Client-Side Clients - Creating a Client}
|
|
215
|
+
*/
|
|
190
216
|
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = object> = TRouter extends Procedure<any, any, infer $InputSchema, infer $OutputSchema, infer $ErrorMap, infer $ReturnedError> ? ProcedureClient<TClientContext, $InputSchema, $OutputSchema, $ErrorMap, $ReturnedError> : {
|
|
191
217
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
192
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* Creates a server-side client that calls the router's procedures directly,
|
|
221
|
+
* within the same process, without any network layer.
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://orpc.dev/docs/client/server-side#router-clients | Server-Side Clients - Router Clients}
|
|
224
|
+
*/
|
|
193
225
|
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext = object>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<ProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown>, ErrorMap, any, TClientContext>>): RouterClient<T, TClientContext>;
|
|
194
226
|
|
|
195
227
|
declare function withHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: RouterContract): T;
|
|
196
228
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | RouterContract>): RouterContract | undefined;
|
|
197
229
|
|
|
198
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware,
|
|
230
|
+
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, augmentImplementedRouter, augmentRouter, call, createContractProcedure, createGuardedProcedureLazy, createRouterClient, createRouterImplementer, decorateMiddleware, getHiddenRouterContract, getRouter, implement, os, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
199
231
|
export type { AugmentImplementedRouterOptions, AugmentRouterOptions, AugmentedRouter, AugmentedRouterWithMiddlewares, BuilderDefinition, BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput, CallOptions, CallRest, DecoratedMiddleware, DefaultInitialContext, Implementer, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementerWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
|
|
2
2
|
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, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
3
|
-
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
4
|
-
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
3
|
+
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, ORPCErrorConstructorMap, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
4
|
+
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
5
5
|
import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
6
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
7
|
-
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as ProcedureConfig, g as AnyMiddleware, h as Lazy, A as AnyProcedure, L as Lazyable, i as ProcedureHandler, O as
|
|
8
|
-
export {
|
|
9
|
-
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.
|
|
10
|
-
export { a as
|
|
7
|
+
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as ProcedureConfig, g as AnyMiddleware, h as Lazy, A as AnyProcedure, L as Lazyable, i as ProcedureHandler, O as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.CwrYlF72.js';
|
|
8
|
+
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.CwrYlF72.js';
|
|
9
|
+
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.DtfwuV6U.js';
|
|
10
|
+
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.DtfwuV6U.js';
|
|
11
11
|
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
12
12
|
|
|
13
13
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
|
|
@@ -47,6 +47,12 @@ declare function walkProcedureContractsAsync(router: RouterContract | AnyRouter,
|
|
|
47
47
|
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
48
48
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Fully resolves all lazy routers inside a router, returning a plain router.
|
|
52
|
+
* Useful for making a router with lazy parts contract-compatible.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://orpc.dev/docs/contract/router#router-to-contract | Router Contract - Router to Contract}
|
|
55
|
+
*/
|
|
50
56
|
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
51
57
|
|
|
52
58
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
|
|
@@ -114,6 +120,12 @@ declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMa
|
|
|
114
120
|
default: T;
|
|
115
121
|
}>): Lazy<AugmentedRouter<T, TErrorMap>>;
|
|
116
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* The oRPC procedure builder. Chain methods like `.input`, `.use`, and `.handler`
|
|
125
|
+
* to define procedures, then compose them into routers.
|
|
126
|
+
*
|
|
127
|
+
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
128
|
+
*/
|
|
117
129
|
declare const os: Builder<DefaultInitialContext & object, Record<never, never>>;
|
|
118
130
|
|
|
119
131
|
declare const DEFAULT_SUCCESS_STATUS = 200;
|
|
@@ -163,6 +175,12 @@ type Implementer<TContract extends RouterContract, TInitialContext extends Conte
|
|
|
163
175
|
$context<T extends Context = DefaultInitialContext>(): Implementer<TContract, T & object>;
|
|
164
176
|
$config(config: ProcedureConfig): Implementer<TContract, TInitialContext>;
|
|
165
177
|
} & RouterImplementer<TContract, TInitialContext>;
|
|
178
|
+
/**
|
|
179
|
+
* Turns a contract into an implementer, used to implement the contract's
|
|
180
|
+
* procedures, routers, and middleware with full type safety.
|
|
181
|
+
*
|
|
182
|
+
* @see {@link https://orpc.dev/docs/contract/implementation#implementer | Contract Implementation - Implementer}
|
|
183
|
+
*/
|
|
166
184
|
declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
|
|
167
185
|
|
|
168
186
|
declare function createGuardedProcedureLazy(lazy: Lazy<unknown>): Lazy<AnyProcedure>;
|
|
@@ -184,16 +202,30 @@ type CallRest<TInitialContext extends Context, TInputSchema extends AnySchema, T
|
|
|
184
202
|
* const output = await call(getting, 'input')
|
|
185
203
|
* const output = await call(getting, 'input', { context: { db: 'postgres' } })
|
|
186
204
|
* ```
|
|
205
|
+
*
|
|
206
|
+
* @see {@link https://orpc.dev/docs/client/server-side#one-off-calls | Server-Side Clients - One-Off Calls}
|
|
187
207
|
*/
|
|
188
208
|
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TReturnedError extends AnyORPCError>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TReturnedError>>, ...[input, options,]: CallRest<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TReturnedError>): PromiseWithError<InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | TReturnedError | ThrowableError>;
|
|
189
209
|
|
|
210
|
+
/**
|
|
211
|
+
* The client type derived from a router, exposing every procedure as a callable
|
|
212
|
+
* function while preserving the router's shape.
|
|
213
|
+
*
|
|
214
|
+
* @see {@link https://orpc.dev/docs/client/client-side#creating-a-client | Client-Side Clients - Creating a Client}
|
|
215
|
+
*/
|
|
190
216
|
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = object> = TRouter extends Procedure<any, any, infer $InputSchema, infer $OutputSchema, infer $ErrorMap, infer $ReturnedError> ? ProcedureClient<TClientContext, $InputSchema, $OutputSchema, $ErrorMap, $ReturnedError> : {
|
|
191
217
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
192
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* Creates a server-side client that calls the router's procedures directly,
|
|
221
|
+
* within the same process, without any network layer.
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://orpc.dev/docs/client/server-side#router-clients | Server-Side Clients - Router Clients}
|
|
224
|
+
*/
|
|
193
225
|
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext = object>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<ProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown>, ErrorMap, any, TClientContext>>): RouterClient<T, TClientContext>;
|
|
194
226
|
|
|
195
227
|
declare function withHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: RouterContract): T;
|
|
196
228
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | RouterContract>): RouterContract | undefined;
|
|
197
229
|
|
|
198
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware,
|
|
230
|
+
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, augmentImplementedRouter, augmentRouter, call, createContractProcedure, createGuardedProcedureLazy, createRouterClient, createRouterImplementer, decorateMiddleware, getHiddenRouterContract, getRouter, implement, os, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
199
231
|
export type { AugmentImplementedRouterOptions, AugmentRouterOptions, AugmentedRouter, AugmentedRouterWithMiddlewares, BuilderDefinition, BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput, CallOptions, CallRest, DecoratedMiddleware, DefaultInitialContext, Implementer, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementerWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mergeErrorMap, resolveMetaPlugins, getHiddenMetaPlugins, ProcedureContract } from '@orpc/contract';
|
|
2
|
-
export { ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
3
|
-
import { toArray, bindMethods,
|
|
2
|
+
export { ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
3
|
+
import { toArray, bindMethods, isTypescriptObject, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
5
|
-
import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.
|
|
6
|
-
export {
|
|
7
|
-
import { D as DecoratedProcedure } from './shared/server.
|
|
8
|
-
import { b as augmentRouter, d as augmentImplementedRouter, e as withHiddenRouterContract, f as createGuardedProcedureLazy, g as getRouter } from './shared/server.
|
|
9
|
-
export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, h as call, c as createContractProcedure, i as getHiddenRouterContract, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.
|
|
5
|
+
import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.7T18Khvf.mjs';
|
|
6
|
+
export { u as unlazy } from './shared/server.7T18Khvf.mjs';
|
|
7
|
+
import { D as DecoratedProcedure } from './shared/server.B2pXdfpL.mjs';
|
|
8
|
+
import { b as augmentRouter, d as augmentImplementedRouter, e as withHiddenRouterContract, f as createGuardedProcedureLazy, g as getRouter } from './shared/server.DgunZU0v.mjs';
|
|
9
|
+
export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, h as call, c as createContractProcedure, i as getHiddenRouterContract, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.DgunZU0v.mjs';
|
|
10
10
|
import { RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
|
|
11
11
|
export { COMMON_ERROR_STATUS_MAP, ORPCError, RPCJsonSerializer, RPCSerializer, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
12
12
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
@@ -334,7 +334,7 @@ function createRouterImplementerInternal(contract, config, middlewares) {
|
|
|
334
334
|
const child = implementer[key];
|
|
335
335
|
implementer[key] = new Proxy(method, {
|
|
336
336
|
get(_, p) {
|
|
337
|
-
return
|
|
337
|
+
return Reflect.get(child, p);
|
|
338
338
|
}
|
|
339
339
|
});
|
|
340
340
|
} else {
|
|
@@ -354,14 +354,14 @@ function implement(contract, config = {}) {
|
|
|
354
354
|
} else if (p === "$config") {
|
|
355
355
|
method = (incoming) => implement(contract, { ...config, ...incoming });
|
|
356
356
|
}
|
|
357
|
-
const value =
|
|
357
|
+
const value = Reflect.get(routerImplementer, p);
|
|
358
358
|
if (method) {
|
|
359
359
|
if (!isTypescriptObject(value)) {
|
|
360
360
|
return method;
|
|
361
361
|
}
|
|
362
362
|
return new Proxy(method, {
|
|
363
363
|
get(_2, p2) {
|
|
364
|
-
return
|
|
364
|
+
return Reflect.get(value, p2);
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
367
|
}
|
|
@@ -377,19 +377,24 @@ function createRouterClient(router, ...rest) {
|
|
|
377
377
|
return createProcedureClient(router, options);
|
|
378
378
|
}
|
|
379
379
|
const procedureCaller = router instanceof Lazy ? createProcedureClient(createGuardedProcedureLazy(router), options) : {};
|
|
380
|
+
const cache = /* @__PURE__ */ new Map();
|
|
380
381
|
const recursive = new Proxy(procedureCaller, {
|
|
381
382
|
get(target, key) {
|
|
382
383
|
if (typeof key !== "string" || router instanceof Lazy && RECURSIVE_CLIENT_UNWRAP_KEYS.has(key)) {
|
|
383
|
-
return
|
|
384
|
+
return Reflect.get(target, key);
|
|
384
385
|
}
|
|
385
|
-
|
|
386
|
-
if (
|
|
387
|
-
|
|
386
|
+
let nextClient = cache.get(key);
|
|
387
|
+
if (nextClient === void 0) {
|
|
388
|
+
const next = getRouter(router, [key]);
|
|
389
|
+
if (!next) {
|
|
390
|
+
return Reflect.get(target, key);
|
|
391
|
+
}
|
|
392
|
+
nextClient = createRouterClient(next, {
|
|
393
|
+
...options,
|
|
394
|
+
path: [...toArray(options.path), key]
|
|
395
|
+
});
|
|
396
|
+
cache.set(key, nextClient);
|
|
388
397
|
}
|
|
389
|
-
const nextClient = createRouterClient(next, {
|
|
390
|
-
...options,
|
|
391
|
-
path: [...toArray(options.path), key]
|
|
392
|
-
});
|
|
393
398
|
return nextClient;
|
|
394
399
|
}
|
|
395
400
|
});
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
2
2
|
import { StandardLazyRequest, StandardHeaders } from '@standardserver/core';
|
|
3
|
-
import { C as Context } from '../shared/server.
|
|
4
|
-
import {
|
|
3
|
+
import { C as Context } from '../shared/server.CwrYlF72.mjs';
|
|
4
|
+
import { S as StandardHandlerPlugin, f as StandardHandlerRoutingInterceptorOptions, a as StandardHandlerOptions, g as StandardHandlerInterceptorOptions } from '../shared/server.JbCIPL4P.mjs';
|
|
5
|
+
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.D0Ipbmdv.mjs';
|
|
5
6
|
import '@orpc/client';
|
|
6
7
|
import '@orpc/contract';
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Content type for batch responses that use the length-prefixed binary framing
|
|
11
|
+
* (streaming mode, and buffered mode when any sub-response contains binary).
|
|
12
|
+
*
|
|
13
|
+
* Decoding is driven by the `standard-server` body hint, not this header,
|
|
14
|
+
* so it only serves to describe the payload to logs, proxies, and dev tools.
|
|
15
|
+
*/
|
|
16
|
+
declare const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
|
|
8
17
|
interface BatchHandlerPluginOptions<T extends Context> {
|
|
9
18
|
/**
|
|
10
19
|
* The max size of the batch allowed.
|
|
@@ -54,6 +63,15 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
54
63
|
interval?: number;
|
|
55
64
|
};
|
|
56
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Handles batch requests sent by the client Batch Link Plugin, splitting each
|
|
68
|
+
* batch into sub-requests and streaming their responses back together.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
74
|
+
*/
|
|
57
75
|
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
58
76
|
name: string;
|
|
59
77
|
/**
|
|
@@ -119,9 +137,10 @@ interface CORSHandlerPluginOptions<T extends Context> {
|
|
|
119
137
|
exposeHeaders?: readonly string[];
|
|
120
138
|
}
|
|
121
139
|
/**
|
|
122
|
-
*
|
|
140
|
+
* Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
|
141
|
+
* for your API, including preflight requests.
|
|
123
142
|
*
|
|
124
|
-
* @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin
|
|
143
|
+
* @see {@link https://orpc.dev/docs/plugins/cors | CORS Handler Plugin}
|
|
125
144
|
*/
|
|
126
145
|
declare class CORSHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
127
146
|
private readonly options;
|
|
@@ -137,17 +156,11 @@ declare class CORSHandlerPlugin<T extends Context> implements StandardHandlerPlu
|
|
|
137
156
|
}
|
|
138
157
|
|
|
139
158
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* (for example, fetch/XHR) rather than from standard HTML forms or direct browser navigation.
|
|
159
|
+
* Decompresses incoming request bodies based on the Content-Encoding header,
|
|
160
|
+
* supporting gzip, deflate, and deflate-raw.
|
|
143
161
|
*
|
|
144
|
-
* @
|
|
162
|
+
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
145
163
|
*/
|
|
146
|
-
declare class CSRFGuardHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
147
|
-
name: string;
|
|
148
|
-
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
164
|
declare class RequestCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
152
165
|
name: string;
|
|
153
166
|
/**
|
|
@@ -157,6 +170,11 @@ declare class RequestCompressionHandlerPlugin<T extends Context> implements Stan
|
|
|
157
170
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
158
171
|
}
|
|
159
172
|
|
|
173
|
+
/**
|
|
174
|
+
* The context shape into which the Request Headers Plugin injects `reqHeaders`.
|
|
175
|
+
*
|
|
176
|
+
* @see {@link https://orpc.dev/docs/plugins/request-headers | Request Headers Plugin}
|
|
177
|
+
*/
|
|
160
178
|
interface RequestHeadersHandlerPluginContext {
|
|
161
179
|
/**
|
|
162
180
|
* Request headers as a Headers instance. This is injected by the Request Headers Plugin.
|
|
@@ -167,42 +185,13 @@ interface RequestHeadersHandlerPluginContext {
|
|
|
167
185
|
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
168
186
|
* allowing access to request headers in oRPC.
|
|
169
187
|
*
|
|
170
|
-
* @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin
|
|
188
|
+
* @see {@link https://orpc.dev/docs/plugins/request-headers | Request Headers Plugin}
|
|
171
189
|
*/
|
|
172
190
|
declare class RequestHeadersHandlerPlugin<T extends RequestHeadersHandlerPluginContext> implements StandardHandlerPlugin<T> {
|
|
173
191
|
name: string;
|
|
174
192
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
175
193
|
}
|
|
176
194
|
|
|
177
|
-
interface RequestLimitHandlerPluginOptions {
|
|
178
|
-
/**
|
|
179
|
-
* The maximum allowed request body size in bytes.
|
|
180
|
-
*/
|
|
181
|
-
maxBodySize: number;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Rejects requests whose body exceeds `maxBodySize`.
|
|
185
|
-
*
|
|
186
|
-
* When used with the request compression plugin, the limit applies to the
|
|
187
|
-
* decompressed payload rather than the compressed wire size.
|
|
188
|
-
*
|
|
189
|
-
* @see {@link https://orpc.dev/docs/plugins/request-limit Request Limit Plugin Docs}
|
|
190
|
-
*/
|
|
191
|
-
declare class RequestLimitHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
192
|
-
name: string;
|
|
193
|
-
/**
|
|
194
|
-
* Should limit the original batch request body instead of sub-requests.
|
|
195
|
-
*/
|
|
196
|
-
after: string[];
|
|
197
|
-
/**
|
|
198
|
-
* Should limit the final body size instead of the compressed one.
|
|
199
|
-
*/
|
|
200
|
-
before: string[];
|
|
201
|
-
private readonly maxBodySize;
|
|
202
|
-
constructor(options: RequestLimitHandlerPluginOptions);
|
|
203
|
-
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
195
|
interface ResponseCompressionHandlerPluginOptions<_T extends Context> {
|
|
207
196
|
/**
|
|
208
197
|
* The compression schemes to use for response compression.
|
|
@@ -225,7 +214,7 @@ interface ResponseCompressionHandlerPluginOptions<_T extends Context> {
|
|
|
225
214
|
* Compresses response bodies based on the client's Accept-Encoding header.
|
|
226
215
|
* Works at the standard handler level, so it supports all adapters.
|
|
227
216
|
*
|
|
228
|
-
* @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin
|
|
217
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
229
218
|
*/
|
|
230
219
|
declare class ResponseCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
231
220
|
name: string;
|
|
@@ -240,6 +229,11 @@ declare class ResponseCompressionHandlerPlugin<T extends Context> implements Sta
|
|
|
240
229
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
241
230
|
}
|
|
242
231
|
|
|
232
|
+
/**
|
|
233
|
+
* The context shape into which the Response Headers Plugin injects `resHeaders`.
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://orpc.dev/docs/plugins/response-headers | Response Headers Plugin}
|
|
236
|
+
*/
|
|
243
237
|
interface ResponseHeadersHandlerPluginContext {
|
|
244
238
|
/**
|
|
245
239
|
* Response headers as a Headers instance. This is injected by the Response Headers Plugin.
|
|
@@ -251,7 +245,7 @@ interface ResponseHeadersHandlerPluginContext {
|
|
|
251
245
|
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
252
246
|
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
253
247
|
*
|
|
254
|
-
* @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin
|
|
248
|
+
* @see {@link https://orpc.dev/docs/plugins/response-headers | Response Headers Plugin}
|
|
255
249
|
*/
|
|
256
250
|
declare class ResponseHeadersHandlerPlugin<T extends ResponseHeadersHandlerPluginContext> implements StandardHandlerPlugin<T> {
|
|
257
251
|
name: string;
|
|
@@ -283,7 +277,7 @@ interface RethrowHandlerPluginOptions<T extends Context> {
|
|
|
283
277
|
* and rethrow matching errors directly to your framework's error handling mechanism
|
|
284
278
|
* (e.g., NestJS exception filters, Express error middleware).
|
|
285
279
|
*
|
|
286
|
-
* @see {@link https://orpc.dev/docs/plugins/rethrow Rethrow Plugin
|
|
280
|
+
* @see {@link https://orpc.dev/docs/plugins/rethrow | Rethrow Handler Plugin}
|
|
287
281
|
*/
|
|
288
282
|
declare class RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
289
283
|
name: string;
|
|
@@ -293,5 +287,22 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
293
287
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
294
288
|
}
|
|
295
289
|
|
|
296
|
-
|
|
297
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
|
|
292
|
+
* When a request includes cookies, it helps ensure the request originates from JavaScript
|
|
293
|
+
* (for example, fetch/XHR) rather than from standard HTML forms or direct browser navigation.
|
|
294
|
+
*
|
|
295
|
+
* @remarks
|
|
296
|
+
* Unlike `SameSite` cookies, this protection also covers cross-site requests that
|
|
297
|
+
* still carry cookies, so it is the recommended safeguard when you enable the `GET`
|
|
298
|
+
* method on RPC handlers or rely on cookie-based authentication.
|
|
299
|
+
*
|
|
300
|
+
* @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection | Simple CSRF Protection Plugin}
|
|
301
|
+
*/
|
|
302
|
+
declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
303
|
+
name: string;
|
|
304
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
308
|
+
export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions };
|