@orpc/server 2.0.0-beta.44 → 2.0.0-beta.45
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 +55 -48
- package/dist/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/crossws/index.mjs +2 -2
- package/dist/adapters/fastify/index.mjs +2 -2
- package/dist/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/message-port/index.d.mts +1 -1
- package/dist/adapters/message-port/index.d.ts +1 -1
- package/dist/adapters/message-port/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +8 -7
- package/dist/adapters/standard/index.d.ts +8 -7
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/helpers/index.mjs +2 -8
- package/dist/index.d.mts +14 -7
- package/dist/index.d.ts +14 -7
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.d.mts +57 -32
- package/dist/plugins/index.d.ts +57 -32
- package/dist/plugins/index.mjs +183 -45
- package/dist/shared/{server.BllfVJLm.d.mts → server.B4hFgqPr.d.mts} +2 -2
- package/dist/shared/{server.BEdOJs6S.d.mts → server.BWhT-63L.d.mts} +5 -5
- package/dist/shared/{server.BEdOJs6S.d.ts → server.BWhT-63L.d.ts} +5 -5
- package/dist/shared/{server.CVO0hWyj.d.mts → server.BYNQ06wN.d.ts} +5 -5
- package/dist/shared/{server.BgvqVW_v.mjs → server.BcxD3fmU.mjs} +15 -3
- package/dist/shared/{server.COfbQ0D8.d.ts → server.CI0qiBzm.d.ts} +2 -2
- package/dist/shared/{server.DFEuNUt4.d.ts → server.CO_upro1.d.ts} +3 -3
- package/dist/shared/{server.DZeVx8K9.d.ts → server.DcDZdSrg.d.ts} +1 -1
- package/dist/shared/{server.UG_xdTub.d.mts → server.DgcwQ-Wr.d.mts} +3 -3
- package/dist/shared/{server.B34dZrzY.mjs → server.Kbq-C85k.mjs} +2 -8
- package/dist/shared/{server.DJNkZPfD.d.ts → server.TVSii8T9.d.mts} +5 -5
- package/dist/shared/{server.DD1roZl9.d.mts → server.TjEHK8V3.d.mts} +1 -1
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions,
|
|
1
|
+
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, AnyProcedureContract, RouterContract, InitialInputSchema, InitialOutputSchema, MergedSchema, ORPCErrorConstructorMap, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
2
2
|
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';
|
|
3
3
|
import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
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';
|
|
5
|
-
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.
|
|
6
|
-
export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, c as ProcedureClientInterceptor, r as ProcedureClientInterceptorOptions, s as ProcedureDefinition, t as ProcedureHandlerOptions, u as createProcedureClient, v as unlazy } from './shared/server.
|
|
7
|
-
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.
|
|
8
|
-
export { a as InferRouterCurrentContexts, b as InferRouterError, c as InferRouterErrors, a as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.
|
|
5
|
+
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.BWhT-63L.mjs';
|
|
6
|
+
export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, c as ProcedureClientInterceptor, r as ProcedureClientInterceptorOptions, s as ProcedureDefinition, t as ProcedureHandlerOptions, u as createProcedureClient, v as unlazy } from './shared/server.BWhT-63L.mjs';
|
|
7
|
+
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.TjEHK8V3.mjs';
|
|
8
|
+
export { a as InferRouterCurrentContexts, b as InferRouterError, c as InferRouterErrors, a as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.TjEHK8V3.mjs';
|
|
9
9
|
import { ClientOptions, ClientContext } from '@orpc/client';
|
|
10
10
|
export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, safe, toORPCError } from '@orpc/client';
|
|
11
11
|
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
@@ -37,6 +37,13 @@ interface AugmentImplementedRouterOptions extends ProcedureConfig {
|
|
|
37
37
|
middlewares: AnyMiddleware[];
|
|
38
38
|
}
|
|
39
39
|
declare function augmentImplementedRouter<T extends AnyRouter, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: AugmentImplementedRouterOptions): AugmentedRouter<T, object> | AugmentedRouterWithMiddlewares<T, TInitialContext, TCurrentContext, object>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the procedure of a contract walked from a router: the procedure itself,
|
|
42
|
+
* or the implementation of a contract-first procedure, looked up by its path.
|
|
43
|
+
*
|
|
44
|
+
* @throws {TypeError} If a contract-first procedure has no valid implementation.
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveContractProcedure(router: AnyRouter, contract: AnyProcedureContract, path: readonly string[]): Promise<AnyProcedure>;
|
|
40
47
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
41
48
|
interface WalkProcedureContractsLazyResult {
|
|
42
49
|
router: Lazy<AnyRouter>;
|
|
@@ -389,7 +396,7 @@ declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMa
|
|
|
389
396
|
declare const os: Builder<DefaultInitialContext & object, Record<never, never>>;
|
|
390
397
|
|
|
391
398
|
declare const DEFAULT_SUCCESS_STATUS = 200;
|
|
392
|
-
declare const DEFAULT_ERROR_STATUS =
|
|
399
|
+
declare const DEFAULT_ERROR_STATUS = 400;
|
|
393
400
|
|
|
394
401
|
declare class ProcedureImplementer<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
395
402
|
'~orpc': BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>;
|
|
@@ -487,5 +494,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
487
494
|
declare function withHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: RouterContract): T;
|
|
488
495
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | RouterContract>): RouterContract | undefined;
|
|
489
496
|
|
|
490
|
-
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 };
|
|
497
|
+
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, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
491
498
|
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,11 +1,11 @@
|
|
|
1
|
-
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions,
|
|
1
|
+
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, AnyProcedureContract, RouterContract, InitialInputSchema, InitialOutputSchema, MergedSchema, ORPCErrorConstructorMap, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
2
2
|
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';
|
|
3
3
|
import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
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';
|
|
5
|
-
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.
|
|
6
|
-
export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, c as ProcedureClientInterceptor, r as ProcedureClientInterceptorOptions, s as ProcedureDefinition, t as ProcedureHandlerOptions, u as createProcedureClient, v as unlazy } from './shared/server.
|
|
7
|
-
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.
|
|
8
|
-
export { a as InferRouterCurrentContexts, b as InferRouterError, c as InferRouterErrors, a as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.
|
|
5
|
+
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.BWhT-63L.js';
|
|
6
|
+
export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, c as ProcedureClientInterceptor, r as ProcedureClientInterceptorOptions, s as ProcedureDefinition, t as ProcedureHandlerOptions, u as createProcedureClient, v as unlazy } from './shared/server.BWhT-63L.js';
|
|
7
|
+
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.DcDZdSrg.js';
|
|
8
|
+
export { a as InferRouterCurrentContexts, b as InferRouterError, c as InferRouterErrors, a as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.DcDZdSrg.js';
|
|
9
9
|
import { ClientOptions, ClientContext } from '@orpc/client';
|
|
10
10
|
export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, safe, toORPCError } from '@orpc/client';
|
|
11
11
|
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
@@ -37,6 +37,13 @@ interface AugmentImplementedRouterOptions extends ProcedureConfig {
|
|
|
37
37
|
middlewares: AnyMiddleware[];
|
|
38
38
|
}
|
|
39
39
|
declare function augmentImplementedRouter<T extends AnyRouter, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: AugmentImplementedRouterOptions): AugmentedRouter<T, object> | AugmentedRouterWithMiddlewares<T, TInitialContext, TCurrentContext, object>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the procedure of a contract walked from a router: the procedure itself,
|
|
42
|
+
* or the implementation of a contract-first procedure, looked up by its path.
|
|
43
|
+
*
|
|
44
|
+
* @throws {TypeError} If a contract-first procedure has no valid implementation.
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveContractProcedure(router: AnyRouter, contract: AnyProcedureContract, path: readonly string[]): Promise<AnyProcedure>;
|
|
40
47
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
41
48
|
interface WalkProcedureContractsLazyResult {
|
|
42
49
|
router: Lazy<AnyRouter>;
|
|
@@ -389,7 +396,7 @@ declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMa
|
|
|
389
396
|
declare const os: Builder<DefaultInitialContext & object, Record<never, never>>;
|
|
390
397
|
|
|
391
398
|
declare const DEFAULT_SUCCESS_STATUS = 200;
|
|
392
|
-
declare const DEFAULT_ERROR_STATUS =
|
|
399
|
+
declare const DEFAULT_ERROR_STATUS = 400;
|
|
393
400
|
|
|
394
401
|
declare class ProcedureImplementer<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
395
402
|
'~orpc': BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>;
|
|
@@ -487,5 +494,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
487
494
|
declare function withHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: RouterContract): T;
|
|
488
495
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | RouterContract>): RouterContract | undefined;
|
|
489
496
|
|
|
490
|
-
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 };
|
|
497
|
+
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, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
491
498
|
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
|
@@ -5,8 +5,8 @@ export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedData
|
|
|
5
5
|
import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.FEqy7Hrj.mjs';
|
|
6
6
|
export { u as unlazy } from './shared/server.FEqy7Hrj.mjs';
|
|
7
7
|
import { D as DecoratedProcedure } from './shared/server.AVQWL-DI.mjs';
|
|
8
|
-
import { b as augmentRouter,
|
|
9
|
-
export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS,
|
|
8
|
+
import { b as augmentRouter, c as augmentImplementedRouter, d as withHiddenRouterContract, e as createGuardedProcedureLazy, g as getRouter } from './shared/server.BcxD3fmU.mjs';
|
|
9
|
+
export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, f as call, h as createContractProcedure, i as getHiddenRouterContract, r as resolveContractProcedure, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.BcxD3fmU.mjs';
|
|
10
10
|
import { RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
|
|
11
11
|
export { COMMON_ERROR_STATUS_MAP, ORPCError, RPCJsonSerializer, RPCSerializer, cloneORPCError, isDefinedError, safe, toORPCError } from '@orpc/client';
|
|
12
12
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
2
|
-
import { StandardLazyRequest, StandardHeaders, StandardMethod
|
|
2
|
+
import { StandardLazyRequest, StandardResponse, StandardHeaders, StandardMethod } from '@standard-server/core';
|
|
3
3
|
import { Context } from '../index.mjs';
|
|
4
4
|
import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.mjs';
|
|
5
|
-
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.
|
|
5
|
+
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.B4hFgqPr.mjs';
|
|
6
|
+
export { BATCH_HEADER, DEFAULT_BATCH_MAX_SIZE } from '@orpc/client/plugins';
|
|
6
7
|
import '@orpc/client';
|
|
7
8
|
import '@orpc/contract';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* Content type for batch responses that use the length-prefixed binary framing
|
|
11
|
-
*
|
|
11
|
+
* Content type for batch responses that use the length-prefixed binary framing,
|
|
12
|
+
* which they do when any sub-response contains binary or is a stream.
|
|
12
13
|
*
|
|
13
14
|
* Decoding is driven by the `standard-server` body hint, not this header,
|
|
14
15
|
* so it only serves to describe the payload to logs, proxies, and dev tools.
|
|
@@ -16,40 +17,51 @@ import '@orpc/contract';
|
|
|
16
17
|
declare const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
|
|
17
18
|
interface BatchHandlerPluginOptions<T extends Context> {
|
|
18
19
|
/**
|
|
19
|
-
* The max size of the batch allowed.
|
|
20
|
+
* The max size of the batch allowed. Larger batches are rejected with a `413`,
|
|
21
|
+
* so keep the client Batch Link Plugin's `maxSize` at or below it.
|
|
20
22
|
*
|
|
21
|
-
* @default 10
|
|
23
|
+
* @default DEFAULT_BATCH_MAX_SIZE (10)
|
|
24
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
22
25
|
*/
|
|
23
|
-
maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]
|
|
26
|
+
maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
24
27
|
/**
|
|
25
28
|
* Map each subrequest in the batch before it is processed.
|
|
26
29
|
*
|
|
27
30
|
* @default merges the batch request headers into the subrequest, giving them priority over
|
|
28
31
|
* the subrequest headers, and removes the `orpc-batch` header to prevent nested batching
|
|
29
32
|
*/
|
|
30
|
-
mapSubrequest?: (subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest;
|
|
33
|
+
mapSubrequest?: ((subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest) | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Map each sub-response in the batch before it is sent.
|
|
36
|
+
*
|
|
37
|
+
* @default removes the headers the batch response already has with the same value, which the client
|
|
38
|
+
* merges back, and `set-cookie`, which the browser ignores there and JavaScript could read
|
|
39
|
+
*/
|
|
40
|
+
mapSubresponse?: ((subresponse: StandardResponse, partialBatchResponse: Pick<StandardResponse, 'status' | 'headers'>, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardResponse) | undefined;
|
|
31
41
|
/**
|
|
32
42
|
* Success batch response status code.
|
|
33
43
|
*
|
|
34
44
|
* @default 207
|
|
35
45
|
*/
|
|
36
|
-
successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]
|
|
46
|
+
successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
37
47
|
/**
|
|
38
48
|
* Success batch response headers.
|
|
39
49
|
*
|
|
50
|
+
* The batch response also gets the cookies its sub-responses set, and the headers they all share.
|
|
51
|
+
* Headers set here win, and setting one to `undefined` keeps it off, except `set-cookie` and `vary`, which merge.
|
|
52
|
+
*
|
|
40
53
|
* @default {}
|
|
41
54
|
*/
|
|
42
|
-
headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]
|
|
55
|
+
headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
43
56
|
/**
|
|
44
|
-
* Keep-alive settings for
|
|
57
|
+
* Keep-alive settings for batch responses that stream.
|
|
45
58
|
*
|
|
46
59
|
* When enabled, a zero-length length-prefixed frame is sent periodically while the
|
|
47
60
|
* stream is idle (no message sent for `interval` ms). Clients ignore these frames.
|
|
48
|
-
* Only applies to streaming responses: streaming mode, or a buffered batch with a stream sub-response.
|
|
49
61
|
*
|
|
50
62
|
* @default { enabled: true, interval: 15000 }
|
|
51
63
|
*/
|
|
52
|
-
keepAlive?:
|
|
64
|
+
keepAlive?: {
|
|
53
65
|
/**
|
|
54
66
|
* If true, a keep-alive frame is sent periodically while the stream is idle.
|
|
55
67
|
*
|
|
@@ -61,16 +73,16 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
61
73
|
*
|
|
62
74
|
* @default 15000
|
|
63
75
|
*/
|
|
64
|
-
interval?: number;
|
|
65
|
-
};
|
|
76
|
+
interval?: number | undefined;
|
|
77
|
+
} | undefined;
|
|
66
78
|
}
|
|
67
79
|
/**
|
|
68
80
|
* Handles batch requests sent by the client Batch Link Plugin, splitting each
|
|
69
|
-
* batch into sub-requests and
|
|
81
|
+
* batch into sub-requests and sending their responses back together.
|
|
70
82
|
*
|
|
71
83
|
* @remarks
|
|
72
|
-
*
|
|
73
|
-
*
|
|
84
|
+
* The batch starts the response once every sub-response is ready, so it carries the cookies sub-requests
|
|
85
|
+
* set and the headers every sub-response shares. It streams when a sub-response is a stream.
|
|
74
86
|
*
|
|
75
87
|
* **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
|
|
76
88
|
*
|
|
@@ -85,6 +97,7 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
|
|
|
85
97
|
after: string[];
|
|
86
98
|
private readonly maxSize;
|
|
87
99
|
private readonly mapSubrequest;
|
|
100
|
+
private readonly mapSubresponse;
|
|
88
101
|
private readonly successStatus;
|
|
89
102
|
private readonly headers;
|
|
90
103
|
private readonly keepAliveEnabled;
|
|
@@ -103,40 +116,40 @@ interface CORSHandlerPluginOptions<T extends Context> {
|
|
|
103
116
|
*
|
|
104
117
|
* @default '*'
|
|
105
118
|
*/
|
|
106
|
-
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]
|
|
119
|
+
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
107
120
|
/**
|
|
108
121
|
* Configures the `Timing-Allow-Origin` header.
|
|
109
122
|
* Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
|
|
110
123
|
*/
|
|
111
|
-
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]
|
|
124
|
+
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
112
125
|
/**
|
|
113
126
|
* Configures the `Access-Control-Allow-Methods` header for preflight requests.
|
|
114
127
|
*
|
|
115
128
|
* @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']
|
|
116
129
|
*/
|
|
117
|
-
allowMethods?: readonly string[];
|
|
130
|
+
allowMethods?: readonly string[] | undefined;
|
|
118
131
|
/**
|
|
119
132
|
* Configures the `Access-Control-Allow-Headers` header for preflight requests.
|
|
120
133
|
* Falls back to the request's `Access-Control-Request-Headers` if not set.
|
|
121
134
|
* When set, it replaces that fallback, so include every non-safelisted header
|
|
122
135
|
* clients send, such as `Content-Type`.
|
|
123
136
|
*/
|
|
124
|
-
allowHeaders?: readonly string[];
|
|
137
|
+
allowHeaders?: readonly string[] | undefined;
|
|
125
138
|
/**
|
|
126
139
|
* Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
|
|
127
140
|
*/
|
|
128
|
-
maxAge?: number;
|
|
141
|
+
maxAge?: number | undefined;
|
|
129
142
|
/**
|
|
130
143
|
* Configures the `Access-Control-Allow-Credentials` header.
|
|
131
144
|
*
|
|
132
145
|
* When enabled, `origin` must allow trusted origins only: every allowed origin can send
|
|
133
146
|
* authenticated requests as your users and read the responses.
|
|
134
147
|
*/
|
|
135
|
-
credentials?: boolean;
|
|
148
|
+
credentials?: boolean | undefined;
|
|
136
149
|
/**
|
|
137
150
|
* Configures the `Access-Control-Expose-Headers` header.
|
|
138
151
|
*/
|
|
139
|
-
exposeHeaders?: readonly string[];
|
|
152
|
+
exposeHeaders?: readonly string[] | undefined;
|
|
140
153
|
}
|
|
141
154
|
/**
|
|
142
155
|
* Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
|
@@ -186,7 +199,7 @@ interface MethodOverrideHandlerPluginOptions {
|
|
|
186
199
|
*
|
|
187
200
|
* @default 'method'
|
|
188
201
|
*/
|
|
189
|
-
param?: string;
|
|
202
|
+
param?: string | undefined;
|
|
190
203
|
/**
|
|
191
204
|
* The methods a POST request may be overridden to.
|
|
192
205
|
*
|
|
@@ -195,7 +208,7 @@ interface MethodOverrideHandlerPluginOptions {
|
|
|
195
208
|
*
|
|
196
209
|
* @default ['PUT', 'PATCH', 'DELETE']
|
|
197
210
|
*/
|
|
198
|
-
methods?: readonly StandardMethod[];
|
|
211
|
+
methods?: readonly StandardMethod[] | undefined;
|
|
199
212
|
}
|
|
200
213
|
/**
|
|
201
214
|
* Overrides the HTTP method of a POST request based on a query parameter,
|
|
@@ -261,7 +274,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
261
274
|
*
|
|
262
275
|
* @default ['gzip', 'deflate']
|
|
263
276
|
*/
|
|
264
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
277
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
|
|
265
278
|
/**
|
|
266
279
|
* The minimum response size in bytes required to trigger compression.
|
|
267
280
|
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
@@ -269,7 +282,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
269
282
|
*
|
|
270
283
|
* @default 1024 (1KB)
|
|
271
284
|
*/
|
|
272
|
-
threshold?: number;
|
|
285
|
+
threshold?: number | undefined;
|
|
273
286
|
/**
|
|
274
287
|
* Determines whether a response with the given Content-Type should be compressed.
|
|
275
288
|
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
@@ -277,7 +290,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
277
290
|
*
|
|
278
291
|
* @default isCompressibleContentType (covers common text-based formats)
|
|
279
292
|
*/
|
|
280
|
-
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean;
|
|
293
|
+
isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean) | undefined;
|
|
281
294
|
}
|
|
282
295
|
/**
|
|
283
296
|
* Compresses response bodies based on the client's Accept-Encoding header.
|
|
@@ -368,6 +381,18 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
368
381
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
369
382
|
}
|
|
370
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Keeps the request signal and a streaming output (async iterator object or readable stream) in sync:
|
|
386
|
+
* cancelling the output aborts the signal with an `AbortError`,
|
|
387
|
+
* and aborting the signal ends the output with the abort reason and cancels it.
|
|
388
|
+
*
|
|
389
|
+
* @see {@link https://orpc.dev/docs/plugins/signal-sync | Signal Sync Plugin}
|
|
390
|
+
*/
|
|
391
|
+
declare class SignalSyncHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
392
|
+
name: string;
|
|
393
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
394
|
+
}
|
|
395
|
+
|
|
371
396
|
interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
372
397
|
/**
|
|
373
398
|
* Timeout in milliseconds before the request signal is aborted.
|
|
@@ -386,7 +411,7 @@ interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
|
386
411
|
*
|
|
387
412
|
* @default undefined (streaming responses run without limit)
|
|
388
413
|
*/
|
|
389
|
-
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]
|
|
414
|
+
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]> | undefined;
|
|
390
415
|
}
|
|
391
416
|
/**
|
|
392
417
|
* The Timeout Handler Plugin aborts the request signal with an `AbortError`
|
|
@@ -403,5 +428,5 @@ declare class TimeoutHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
403
428
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
404
429
|
}
|
|
405
430
|
|
|
406
|
-
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
|
|
431
|
+
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, SignalSyncHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
|
|
407
432
|
export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, MethodOverrideHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions, TimeoutHandlerPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
2
|
-
import { StandardLazyRequest, StandardHeaders, StandardMethod
|
|
2
|
+
import { StandardLazyRequest, StandardResponse, StandardHeaders, StandardMethod } from '@standard-server/core';
|
|
3
3
|
import { Context } from '../index.js';
|
|
4
4
|
import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.js';
|
|
5
|
-
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.
|
|
5
|
+
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.CI0qiBzm.js';
|
|
6
|
+
export { BATCH_HEADER, DEFAULT_BATCH_MAX_SIZE } from '@orpc/client/plugins';
|
|
6
7
|
import '@orpc/client';
|
|
7
8
|
import '@orpc/contract';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* Content type for batch responses that use the length-prefixed binary framing
|
|
11
|
-
*
|
|
11
|
+
* Content type for batch responses that use the length-prefixed binary framing,
|
|
12
|
+
* which they do when any sub-response contains binary or is a stream.
|
|
12
13
|
*
|
|
13
14
|
* Decoding is driven by the `standard-server` body hint, not this header,
|
|
14
15
|
* so it only serves to describe the payload to logs, proxies, and dev tools.
|
|
@@ -16,40 +17,51 @@ import '@orpc/contract';
|
|
|
16
17
|
declare const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
|
|
17
18
|
interface BatchHandlerPluginOptions<T extends Context> {
|
|
18
19
|
/**
|
|
19
|
-
* The max size of the batch allowed.
|
|
20
|
+
* The max size of the batch allowed. Larger batches are rejected with a `413`,
|
|
21
|
+
* so keep the client Batch Link Plugin's `maxSize` at or below it.
|
|
20
22
|
*
|
|
21
|
-
* @default 10
|
|
23
|
+
* @default DEFAULT_BATCH_MAX_SIZE (10)
|
|
24
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
22
25
|
*/
|
|
23
|
-
maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]
|
|
26
|
+
maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
24
27
|
/**
|
|
25
28
|
* Map each subrequest in the batch before it is processed.
|
|
26
29
|
*
|
|
27
30
|
* @default merges the batch request headers into the subrequest, giving them priority over
|
|
28
31
|
* the subrequest headers, and removes the `orpc-batch` header to prevent nested batching
|
|
29
32
|
*/
|
|
30
|
-
mapSubrequest?: (subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest;
|
|
33
|
+
mapSubrequest?: ((subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest) | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Map each sub-response in the batch before it is sent.
|
|
36
|
+
*
|
|
37
|
+
* @default removes the headers the batch response already has with the same value, which the client
|
|
38
|
+
* merges back, and `set-cookie`, which the browser ignores there and JavaScript could read
|
|
39
|
+
*/
|
|
40
|
+
mapSubresponse?: ((subresponse: StandardResponse, partialBatchResponse: Pick<StandardResponse, 'status' | 'headers'>, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardResponse) | undefined;
|
|
31
41
|
/**
|
|
32
42
|
* Success batch response status code.
|
|
33
43
|
*
|
|
34
44
|
* @default 207
|
|
35
45
|
*/
|
|
36
|
-
successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]
|
|
46
|
+
successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
37
47
|
/**
|
|
38
48
|
* Success batch response headers.
|
|
39
49
|
*
|
|
50
|
+
* The batch response also gets the cookies its sub-responses set, and the headers they all share.
|
|
51
|
+
* Headers set here win, and setting one to `undefined` keeps it off, except `set-cookie` and `vary`, which merge.
|
|
52
|
+
*
|
|
40
53
|
* @default {}
|
|
41
54
|
*/
|
|
42
|
-
headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]
|
|
55
|
+
headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
43
56
|
/**
|
|
44
|
-
* Keep-alive settings for
|
|
57
|
+
* Keep-alive settings for batch responses that stream.
|
|
45
58
|
*
|
|
46
59
|
* When enabled, a zero-length length-prefixed frame is sent periodically while the
|
|
47
60
|
* stream is idle (no message sent for `interval` ms). Clients ignore these frames.
|
|
48
|
-
* Only applies to streaming responses: streaming mode, or a buffered batch with a stream sub-response.
|
|
49
61
|
*
|
|
50
62
|
* @default { enabled: true, interval: 15000 }
|
|
51
63
|
*/
|
|
52
|
-
keepAlive?:
|
|
64
|
+
keepAlive?: {
|
|
53
65
|
/**
|
|
54
66
|
* If true, a keep-alive frame is sent periodically while the stream is idle.
|
|
55
67
|
*
|
|
@@ -61,16 +73,16 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
61
73
|
*
|
|
62
74
|
* @default 15000
|
|
63
75
|
*/
|
|
64
|
-
interval?: number;
|
|
65
|
-
};
|
|
76
|
+
interval?: number | undefined;
|
|
77
|
+
} | undefined;
|
|
66
78
|
}
|
|
67
79
|
/**
|
|
68
80
|
* Handles batch requests sent by the client Batch Link Plugin, splitting each
|
|
69
|
-
* batch into sub-requests and
|
|
81
|
+
* batch into sub-requests and sending their responses back together.
|
|
70
82
|
*
|
|
71
83
|
* @remarks
|
|
72
|
-
*
|
|
73
|
-
*
|
|
84
|
+
* The batch starts the response once every sub-response is ready, so it carries the cookies sub-requests
|
|
85
|
+
* set and the headers every sub-response shares. It streams when a sub-response is a stream.
|
|
74
86
|
*
|
|
75
87
|
* **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
|
|
76
88
|
*
|
|
@@ -85,6 +97,7 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
|
|
|
85
97
|
after: string[];
|
|
86
98
|
private readonly maxSize;
|
|
87
99
|
private readonly mapSubrequest;
|
|
100
|
+
private readonly mapSubresponse;
|
|
88
101
|
private readonly successStatus;
|
|
89
102
|
private readonly headers;
|
|
90
103
|
private readonly keepAliveEnabled;
|
|
@@ -103,40 +116,40 @@ interface CORSHandlerPluginOptions<T extends Context> {
|
|
|
103
116
|
*
|
|
104
117
|
* @default '*'
|
|
105
118
|
*/
|
|
106
|
-
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]
|
|
119
|
+
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
107
120
|
/**
|
|
108
121
|
* Configures the `Timing-Allow-Origin` header.
|
|
109
122
|
* Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
|
|
110
123
|
*/
|
|
111
|
-
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]
|
|
124
|
+
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
|
|
112
125
|
/**
|
|
113
126
|
* Configures the `Access-Control-Allow-Methods` header for preflight requests.
|
|
114
127
|
*
|
|
115
128
|
* @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']
|
|
116
129
|
*/
|
|
117
|
-
allowMethods?: readonly string[];
|
|
130
|
+
allowMethods?: readonly string[] | undefined;
|
|
118
131
|
/**
|
|
119
132
|
* Configures the `Access-Control-Allow-Headers` header for preflight requests.
|
|
120
133
|
* Falls back to the request's `Access-Control-Request-Headers` if not set.
|
|
121
134
|
* When set, it replaces that fallback, so include every non-safelisted header
|
|
122
135
|
* clients send, such as `Content-Type`.
|
|
123
136
|
*/
|
|
124
|
-
allowHeaders?: readonly string[];
|
|
137
|
+
allowHeaders?: readonly string[] | undefined;
|
|
125
138
|
/**
|
|
126
139
|
* Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
|
|
127
140
|
*/
|
|
128
|
-
maxAge?: number;
|
|
141
|
+
maxAge?: number | undefined;
|
|
129
142
|
/**
|
|
130
143
|
* Configures the `Access-Control-Allow-Credentials` header.
|
|
131
144
|
*
|
|
132
145
|
* When enabled, `origin` must allow trusted origins only: every allowed origin can send
|
|
133
146
|
* authenticated requests as your users and read the responses.
|
|
134
147
|
*/
|
|
135
|
-
credentials?: boolean;
|
|
148
|
+
credentials?: boolean | undefined;
|
|
136
149
|
/**
|
|
137
150
|
* Configures the `Access-Control-Expose-Headers` header.
|
|
138
151
|
*/
|
|
139
|
-
exposeHeaders?: readonly string[];
|
|
152
|
+
exposeHeaders?: readonly string[] | undefined;
|
|
140
153
|
}
|
|
141
154
|
/**
|
|
142
155
|
* Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
|
@@ -186,7 +199,7 @@ interface MethodOverrideHandlerPluginOptions {
|
|
|
186
199
|
*
|
|
187
200
|
* @default 'method'
|
|
188
201
|
*/
|
|
189
|
-
param?: string;
|
|
202
|
+
param?: string | undefined;
|
|
190
203
|
/**
|
|
191
204
|
* The methods a POST request may be overridden to.
|
|
192
205
|
*
|
|
@@ -195,7 +208,7 @@ interface MethodOverrideHandlerPluginOptions {
|
|
|
195
208
|
*
|
|
196
209
|
* @default ['PUT', 'PATCH', 'DELETE']
|
|
197
210
|
*/
|
|
198
|
-
methods?: readonly StandardMethod[];
|
|
211
|
+
methods?: readonly StandardMethod[] | undefined;
|
|
199
212
|
}
|
|
200
213
|
/**
|
|
201
214
|
* Overrides the HTTP method of a POST request based on a query parameter,
|
|
@@ -261,7 +274,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
261
274
|
*
|
|
262
275
|
* @default ['gzip', 'deflate']
|
|
263
276
|
*/
|
|
264
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
277
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
|
|
265
278
|
/**
|
|
266
279
|
* The minimum response size in bytes required to trigger compression.
|
|
267
280
|
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
@@ -269,7 +282,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
269
282
|
*
|
|
270
283
|
* @default 1024 (1KB)
|
|
271
284
|
*/
|
|
272
|
-
threshold?: number;
|
|
285
|
+
threshold?: number | undefined;
|
|
273
286
|
/**
|
|
274
287
|
* Determines whether a response with the given Content-Type should be compressed.
|
|
275
288
|
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
@@ -277,7 +290,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
277
290
|
*
|
|
278
291
|
* @default isCompressibleContentType (covers common text-based formats)
|
|
279
292
|
*/
|
|
280
|
-
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean;
|
|
293
|
+
isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean) | undefined;
|
|
281
294
|
}
|
|
282
295
|
/**
|
|
283
296
|
* Compresses response bodies based on the client's Accept-Encoding header.
|
|
@@ -368,6 +381,18 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
368
381
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
369
382
|
}
|
|
370
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Keeps the request signal and a streaming output (async iterator object or readable stream) in sync:
|
|
386
|
+
* cancelling the output aborts the signal with an `AbortError`,
|
|
387
|
+
* and aborting the signal ends the output with the abort reason and cancels it.
|
|
388
|
+
*
|
|
389
|
+
* @see {@link https://orpc.dev/docs/plugins/signal-sync | Signal Sync Plugin}
|
|
390
|
+
*/
|
|
391
|
+
declare class SignalSyncHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
392
|
+
name: string;
|
|
393
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
394
|
+
}
|
|
395
|
+
|
|
371
396
|
interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
372
397
|
/**
|
|
373
398
|
* Timeout in milliseconds before the request signal is aborted.
|
|
@@ -386,7 +411,7 @@ interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
|
386
411
|
*
|
|
387
412
|
* @default undefined (streaming responses run without limit)
|
|
388
413
|
*/
|
|
389
|
-
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]
|
|
414
|
+
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]> | undefined;
|
|
390
415
|
}
|
|
391
416
|
/**
|
|
392
417
|
* The Timeout Handler Plugin aborts the request signal with an `AbortError`
|
|
@@ -403,5 +428,5 @@ declare class TimeoutHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
403
428
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
404
429
|
}
|
|
405
430
|
|
|
406
|
-
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
|
|
431
|
+
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, SignalSyncHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
|
|
407
432
|
export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, MethodOverrideHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions, TimeoutHandlerPluginOptions };
|