@orpc/server 2.0.0-beta.43 → 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 +56 -57
- 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 +10 -8
- package/dist/adapters/standard/index.d.ts +10 -8
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/helpers/index.d.mts +2 -1
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.mjs +3 -9
- 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 +64 -55
- package/dist/plugins/index.d.ts +64 -55
- package/dist/plugins/index.mjs +232 -146
- 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.B1ecixZJ.mjs → server.Kbq-C85k.mjs} +7 -20
- 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 +15 -15
package/dist/helpers/index.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ import { ParseOptions, SetCookie, StringifyOptions } from 'cookie';
|
|
|
17
17
|
declare function encodeBase64url(data: Uint8Array): string;
|
|
18
18
|
/**
|
|
19
19
|
* Decodes a base64url string to Uint8Array
|
|
20
|
-
*
|
|
20
|
+
* Only accepts canonical, unpadded base64url (the form produced by `encodeBase64url`),
|
|
21
|
+
* returns undefined for anything else, including padded or standard base64 input
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
24
|
* ```ts
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
import { encodeBase64 } from '@orpc/shared';
|
|
1
2
|
import { parseCookie, stringifySetCookie } from 'cookie';
|
|
2
3
|
|
|
3
4
|
function encodeBase64url(data) {
|
|
4
|
-
|
|
5
|
-
let binaryString = "";
|
|
6
|
-
for (let i = 0; i < data.length; i += chunkSize) {
|
|
7
|
-
const chunk = data.subarray(i, i + chunkSize);
|
|
8
|
-
binaryString += String.fromCharCode(...chunk);
|
|
9
|
-
}
|
|
10
|
-
const base64 = btoa(binaryString);
|
|
11
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
5
|
+
return encodeBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
12
6
|
}
|
|
13
7
|
function decodeBase64url(base64url) {
|
|
14
8
|
try {
|
|
@@ -24,7 +18,7 @@ function decodeBase64url(base64url) {
|
|
|
24
18
|
for (let i = 0; i < binaryString.length; i++) {
|
|
25
19
|
bytes[i] = binaryString.charCodeAt(i);
|
|
26
20
|
}
|
|
27
|
-
return bytes;
|
|
21
|
+
return encodeBase64url(bytes) === base64url ? bytes : void 0;
|
|
28
22
|
} catch {
|
|
29
23
|
return void 0;
|
|
30
24
|
}
|
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 mode.
|
|
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,14 +73,17 @@ 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
|
|
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.
|
|
86
|
+
*
|
|
72
87
|
* **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
|
|
73
88
|
*
|
|
74
89
|
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
@@ -82,6 +97,7 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
|
|
|
82
97
|
after: string[];
|
|
83
98
|
private readonly maxSize;
|
|
84
99
|
private readonly mapSubrequest;
|
|
100
|
+
private readonly mapSubresponse;
|
|
85
101
|
private readonly successStatus;
|
|
86
102
|
private readonly headers;
|
|
87
103
|
private readonly keepAliveEnabled;
|
|
@@ -95,39 +111,45 @@ interface CORSHandlerPluginOptions<T extends Context> {
|
|
|
95
111
|
* Configures the `Access-Control-Allow-Origin` header.
|
|
96
112
|
* Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
|
|
97
113
|
*
|
|
114
|
+
* A function must only return origins it has validated: returning the incoming origin
|
|
115
|
+
* unchecked allows every origin.
|
|
116
|
+
*
|
|
98
117
|
* @default '*'
|
|
99
118
|
*/
|
|
100
|
-
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;
|
|
101
120
|
/**
|
|
102
121
|
* Configures the `Timing-Allow-Origin` header.
|
|
103
122
|
* Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
|
|
104
123
|
*/
|
|
105
|
-
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;
|
|
106
125
|
/**
|
|
107
126
|
* Configures the `Access-Control-Allow-Methods` header for preflight requests.
|
|
108
127
|
*
|
|
109
128
|
* @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']
|
|
110
129
|
*/
|
|
111
|
-
allowMethods?: readonly string[];
|
|
130
|
+
allowMethods?: readonly string[] | undefined;
|
|
112
131
|
/**
|
|
113
132
|
* Configures the `Access-Control-Allow-Headers` header for preflight requests.
|
|
114
133
|
* Falls back to the request's `Access-Control-Request-Headers` if not set.
|
|
115
134
|
* When set, it replaces that fallback, so include every non-safelisted header
|
|
116
135
|
* clients send, such as `Content-Type`.
|
|
117
136
|
*/
|
|
118
|
-
allowHeaders?: readonly string[];
|
|
137
|
+
allowHeaders?: readonly string[] | undefined;
|
|
119
138
|
/**
|
|
120
139
|
* Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
|
|
121
140
|
*/
|
|
122
|
-
maxAge?: number;
|
|
141
|
+
maxAge?: number | undefined;
|
|
123
142
|
/**
|
|
124
143
|
* Configures the `Access-Control-Allow-Credentials` header.
|
|
144
|
+
*
|
|
145
|
+
* When enabled, `origin` must allow trusted origins only: every allowed origin can send
|
|
146
|
+
* authenticated requests as your users and read the responses.
|
|
125
147
|
*/
|
|
126
|
-
credentials?: boolean;
|
|
148
|
+
credentials?: boolean | undefined;
|
|
127
149
|
/**
|
|
128
150
|
* Configures the `Access-Control-Expose-Headers` header.
|
|
129
151
|
*/
|
|
130
|
-
exposeHeaders?: readonly string[];
|
|
152
|
+
exposeHeaders?: readonly string[] | undefined;
|
|
131
153
|
}
|
|
132
154
|
/**
|
|
133
155
|
* Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
|
@@ -177,7 +199,7 @@ interface MethodOverrideHandlerPluginOptions {
|
|
|
177
199
|
*
|
|
178
200
|
* @default 'method'
|
|
179
201
|
*/
|
|
180
|
-
param?: string;
|
|
202
|
+
param?: string | undefined;
|
|
181
203
|
/**
|
|
182
204
|
* The methods a POST request may be overridden to.
|
|
183
205
|
*
|
|
@@ -186,7 +208,7 @@ interface MethodOverrideHandlerPluginOptions {
|
|
|
186
208
|
*
|
|
187
209
|
* @default ['PUT', 'PATCH', 'DELETE']
|
|
188
210
|
*/
|
|
189
|
-
methods?: readonly StandardMethod[];
|
|
211
|
+
methods?: readonly StandardMethod[] | undefined;
|
|
190
212
|
}
|
|
191
213
|
/**
|
|
192
214
|
* Overrides the HTTP method of a POST request based on a query parameter,
|
|
@@ -207,31 +229,6 @@ declare class MethodOverrideHandlerPlugin<T extends Context> implements Standard
|
|
|
207
229
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
208
230
|
}
|
|
209
231
|
|
|
210
|
-
/**
|
|
211
|
-
* Rejects requests whose decoded input contains prototype-polluting keys: an own
|
|
212
|
-
* `__proto__` key, or an own `constructor` key holding a `prototype` key. oRPC's own
|
|
213
|
-
* decoding never assigns through the prototype chain, so this plugin exists to stop such
|
|
214
|
-
* keys from reaching application code that merges, clones, or path-sets input with a
|
|
215
|
-
* library vulnerable to prototype pollution. An `AsyncIteratorObject` input is checked
|
|
216
|
-
* value by value as it arrives, and a polluting value fails that iteration instead.
|
|
217
|
-
*
|
|
218
|
-
* @see {@link https://orpc.dev/docs/plugins/prototype-pollution-protection | Prototype Pollution Protection Plugin}
|
|
219
|
-
*/
|
|
220
|
-
declare class PrototypePollutionProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
221
|
-
name: string;
|
|
222
|
-
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
223
|
-
private rejectPollutingInput;
|
|
224
|
-
/**
|
|
225
|
-
* Walks the containers the built-in codecs can produce: arrays, maps, sets, and plain
|
|
226
|
-
* objects, including null-prototype ones. Arrays get the same key checks as plain objects,
|
|
227
|
-
* since structured clone, as used over MessagePort, keeps named keys like `__proto__` on
|
|
228
|
-
* them. Other objects, such as files and dates, carry no attacker-authored keys and are
|
|
229
|
-
* left alone. The walk is iterative, so input nested deeper than the call stack allows
|
|
230
|
-
* still gets the intended verdict instead of a `RangeError`.
|
|
231
|
-
*/
|
|
232
|
-
private containsPollutingKey;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
232
|
/**
|
|
236
233
|
* Decompresses incoming request bodies based on the Content-Encoding header,
|
|
237
234
|
* supporting gzip, deflate, and deflate-raw.
|
|
@@ -277,7 +274,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
277
274
|
*
|
|
278
275
|
* @default ['gzip', 'deflate']
|
|
279
276
|
*/
|
|
280
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
277
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
|
|
281
278
|
/**
|
|
282
279
|
* The minimum response size in bytes required to trigger compression.
|
|
283
280
|
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
@@ -285,7 +282,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
285
282
|
*
|
|
286
283
|
* @default 1024 (1KB)
|
|
287
284
|
*/
|
|
288
|
-
threshold?: number;
|
|
285
|
+
threshold?: number | undefined;
|
|
289
286
|
/**
|
|
290
287
|
* Determines whether a response with the given Content-Type should be compressed.
|
|
291
288
|
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
@@ -293,7 +290,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
|
|
|
293
290
|
*
|
|
294
291
|
* @default isCompressibleContentType (covers common text-based formats)
|
|
295
292
|
*/
|
|
296
|
-
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean;
|
|
293
|
+
isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean) | undefined;
|
|
297
294
|
}
|
|
298
295
|
/**
|
|
299
296
|
* Compresses response bodies based on the client's Accept-Encoding header.
|
|
@@ -384,6 +381,18 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
384
381
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
385
382
|
}
|
|
386
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
|
+
|
|
387
396
|
interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
388
397
|
/**
|
|
389
398
|
* Timeout in milliseconds before the request signal is aborted.
|
|
@@ -402,7 +411,7 @@ interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
|
402
411
|
*
|
|
403
412
|
* @default undefined (streaming responses run without limit)
|
|
404
413
|
*/
|
|
405
|
-
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]
|
|
414
|
+
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]> | undefined;
|
|
406
415
|
}
|
|
407
416
|
/**
|
|
408
417
|
* The Timeout Handler Plugin aborts the request signal with an `AbortError`
|
|
@@ -419,5 +428,5 @@ declare class TimeoutHandlerPlugin<T extends Context> implements StandardHandler
|
|
|
419
428
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
420
429
|
}
|
|
421
430
|
|
|
422
|
-
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin,
|
|
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 };
|
|
423
432
|
export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, MethodOverrideHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions, TimeoutHandlerPluginOptions };
|