@orpc/server 0.0.0-next.a5c2886 → 0.0.0-next.a7609ce

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.
Files changed (37) hide show
  1. package/README.md +11 -0
  2. package/dist/adapters/fetch/index.d.mts +43 -10
  3. package/dist/adapters/fetch/index.d.ts +43 -10
  4. package/dist/adapters/fetch/index.mjs +104 -8
  5. package/dist/adapters/node/index.d.mts +45 -21
  6. package/dist/adapters/node/index.d.ts +45 -21
  7. package/dist/adapters/node/index.mjs +82 -23
  8. package/dist/adapters/standard/index.d.mts +11 -10
  9. package/dist/adapters/standard/index.d.ts +11 -10
  10. package/dist/adapters/standard/index.mjs +6 -4
  11. package/dist/index.d.mts +84 -61
  12. package/dist/index.d.ts +84 -61
  13. package/dist/index.mjs +50 -30
  14. package/dist/plugins/index.d.mts +109 -15
  15. package/dist/plugins/index.d.ts +109 -15
  16. package/dist/plugins/index.mjs +156 -7
  17. package/dist/shared/{server.DmW25ynm.d.ts → server.B1oIHH_j.d.mts} +28 -29
  18. package/dist/shared/{server.CPteJIPP.d.mts → server.BVHsfJ99.d.mts} +20 -19
  19. package/dist/shared/{server.CPteJIPP.d.ts → server.BVHsfJ99.d.ts} +20 -19
  20. package/dist/shared/server.BVwwTHyO.mjs +9 -0
  21. package/dist/shared/server.BW-nUGgA.mjs +36 -0
  22. package/dist/shared/server.BuLPHTX1.d.mts +18 -0
  23. package/dist/shared/{server.CMrS28Go.mjs → server.C37gDhSZ.mjs} +42 -24
  24. package/dist/shared/{server.CM3tWr3C.d.mts → server.CaWivVk3.d.ts} +28 -29
  25. package/dist/shared/{server.CSZRzcSW.mjs → server.DFuJLDuo.mjs} +62 -30
  26. package/dist/shared/server.DMhSfHk1.d.ts +10 -0
  27. package/dist/shared/server.D_vpYits.d.ts +18 -0
  28. package/dist/shared/server.Dwnm6cSk.d.mts +10 -0
  29. package/package.json +8 -22
  30. package/dist/adapters/hono/index.d.mts +0 -19
  31. package/dist/adapters/hono/index.d.ts +0 -19
  32. package/dist/adapters/hono/index.mjs +0 -32
  33. package/dist/adapters/next/index.d.mts +0 -26
  34. package/dist/adapters/next/index.d.ts +0 -26
  35. package/dist/adapters/next/index.mjs +0 -29
  36. package/dist/shared/server.Cq3B6PoL.mjs +0 -28
  37. package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
@@ -1,19 +1,19 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
1
+ import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
4
4
 
5
- type Context = Record<string, any>;
6
- type MergedContext<T extends Context, U extends Context> = T & U;
7
- declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
8
- type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
9
- [K in keyof T]: IsNever<T[K]>;
10
- }[keyof T] ? never : unknown;
5
+ type Context = Record<PropertyKey, any>;
6
+ type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
7
+ type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
8
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
9
 
12
10
  type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
11
  type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
12
  type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
13
  [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
16
14
  };
15
+ declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
16
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
17
17
 
18
18
  declare const LAZY_SYMBOL: unique symbol;
19
19
  interface LazyMeta {
@@ -51,7 +51,7 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutp
51
51
  }
52
52
  interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
53
53
  __initialContext?: (type: TInitialContext) => unknown;
54
- middlewares: AnyMiddleware[];
54
+ middlewares: readonly AnyMiddleware[];
55
55
  inputValidationIndex: number;
56
56
  outputValidationIndex: number;
57
57
  handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
@@ -72,8 +72,8 @@ type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never>
72
72
  } : {
73
73
  context: TOutContext;
74
74
  };
75
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
76
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
75
+ interface MiddlewareNextFn<TOutput> {
76
+ <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
77
77
  }
78
78
  interface MiddlewareOutputFn<TOutput> {
79
79
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
@@ -84,7 +84,7 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
84
84
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
85
85
  signal?: AbortSignal;
86
86
  lastEventId: string | undefined;
87
- next: MiddlewareNextFn<TInContext, TOutput>;
87
+ next: MiddlewareNextFn<TOutput>;
88
88
  errors: TErrorConstructorMap;
89
89
  }
90
90
  interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
@@ -97,9 +97,9 @@ interface MapInputMiddleware<TInput, TMappedInput> {
97
97
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
98
98
 
99
99
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
100
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
100
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
101
101
  context: TInitialContext;
102
- input: InferSchemaInput<TInputSchema>;
102
+ input: unknown;
103
103
  errors: ORPCErrorConstructorMap<TErrorMap>;
104
104
  path: readonly string[];
105
105
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
@@ -109,18 +109,18 @@ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TIn
109
109
  /**
110
110
  * Options for creating a procedure caller with comprehensive type safety
111
111
  */
112
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
112
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
113
113
  /**
114
114
  * This is helpful for logging and analytics.
115
115
  */
116
116
  path?: readonly string[];
117
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
117
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
118
118
  } & (Record<never, never> extends TInitialContext ? {
119
119
  context?: Value<TInitialContext, [clientContext: TClientContext]>;
120
120
  } : {
121
121
  context: Value<TInitialContext, [clientContext: TClientContext]>;
122
122
  });
123
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
123
+ declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
124
124
 
125
125
  type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
126
126
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
@@ -140,4 +140,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
140
140
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
141
141
  };
142
142
 
143
- export { type AnyProcedure as A, createProcedureClient as B, type Context as C, type InferRouterInitialContexts as D, type InferRouterCurrentContexts as E, type InferRouterInputs as F, type InferRouterOutputs as G, type InferRouterInitialContext as I, type Lazyable as L, type Middleware as M, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, type AnyRouter as a, Procedure as b, type ConflictContextGuard as c, type MergedContext as d, type MapInputMiddleware as e, type CreateProcedureClientOptions as f, type ProcedureClient as g, type AnyMiddleware as h, type Lazy as i, type ProcedureHandler as j, LAZY_SYMBOL as k, type LazyMeta as l, mergeContext as m, lazy as n, isLazy as o, getLazyMeta as p, type MiddlewareResult as q, type MiddlewareNextFnOptions as r, type MiddlewareNextFn as s, type MiddlewareOutputFn as t, unlazy as u, type MiddlewareOptions as v, middlewareOutputFn as w, type ProcedureHandlerOptions as x, type ProcedureDef as y, isProcedure as z };
143
+ export { isProcedure as E, createProcedureClient as G, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, validateORPCError as v, middlewareOutputFn as z };
144
+ export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, ProcedureClientInterceptorOptions as F, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
@@ -1,19 +1,19 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
1
+ import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
4
4
 
5
- type Context = Record<string, any>;
6
- type MergedContext<T extends Context, U extends Context> = T & U;
7
- declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
8
- type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
9
- [K in keyof T]: IsNever<T[K]>;
10
- }[keyof T] ? never : unknown;
5
+ type Context = Record<PropertyKey, any>;
6
+ type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
7
+ type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
8
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
9
 
12
10
  type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
11
  type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
12
  type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
13
  [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
16
14
  };
15
+ declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
16
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
17
17
 
18
18
  declare const LAZY_SYMBOL: unique symbol;
19
19
  interface LazyMeta {
@@ -51,7 +51,7 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutp
51
51
  }
52
52
  interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
53
53
  __initialContext?: (type: TInitialContext) => unknown;
54
- middlewares: AnyMiddleware[];
54
+ middlewares: readonly AnyMiddleware[];
55
55
  inputValidationIndex: number;
56
56
  outputValidationIndex: number;
57
57
  handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
@@ -72,8 +72,8 @@ type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never>
72
72
  } : {
73
73
  context: TOutContext;
74
74
  };
75
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
76
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
75
+ interface MiddlewareNextFn<TOutput> {
76
+ <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
77
77
  }
78
78
  interface MiddlewareOutputFn<TOutput> {
79
79
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
@@ -84,7 +84,7 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
84
84
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
85
85
  signal?: AbortSignal;
86
86
  lastEventId: string | undefined;
87
- next: MiddlewareNextFn<TInContext, TOutput>;
87
+ next: MiddlewareNextFn<TOutput>;
88
88
  errors: TErrorConstructorMap;
89
89
  }
90
90
  interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
@@ -97,9 +97,9 @@ interface MapInputMiddleware<TInput, TMappedInput> {
97
97
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
98
98
 
99
99
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
100
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
100
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
101
101
  context: TInitialContext;
102
- input: InferSchemaInput<TInputSchema>;
102
+ input: unknown;
103
103
  errors: ORPCErrorConstructorMap<TErrorMap>;
104
104
  path: readonly string[];
105
105
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
@@ -109,18 +109,18 @@ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TIn
109
109
  /**
110
110
  * Options for creating a procedure caller with comprehensive type safety
111
111
  */
112
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
112
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
113
113
  /**
114
114
  * This is helpful for logging and analytics.
115
115
  */
116
116
  path?: readonly string[];
117
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
117
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
118
118
  } & (Record<never, never> extends TInitialContext ? {
119
119
  context?: Value<TInitialContext, [clientContext: TClientContext]>;
120
120
  } : {
121
121
  context: Value<TInitialContext, [clientContext: TClientContext]>;
122
122
  });
123
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
123
+ declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
124
124
 
125
125
  type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
126
126
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
@@ -140,4 +140,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
140
140
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
141
141
  };
142
142
 
143
- export { type AnyProcedure as A, createProcedureClient as B, type Context as C, type InferRouterInitialContexts as D, type InferRouterCurrentContexts as E, type InferRouterInputs as F, type InferRouterOutputs as G, type InferRouterInitialContext as I, type Lazyable as L, type Middleware as M, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, type AnyRouter as a, Procedure as b, type ConflictContextGuard as c, type MergedContext as d, type MapInputMiddleware as e, type CreateProcedureClientOptions as f, type ProcedureClient as g, type AnyMiddleware as h, type Lazy as i, type ProcedureHandler as j, LAZY_SYMBOL as k, type LazyMeta as l, mergeContext as m, lazy as n, isLazy as o, getLazyMeta as p, type MiddlewareResult as q, type MiddlewareNextFnOptions as r, type MiddlewareNextFn as s, type MiddlewareOutputFn as t, unlazy as u, type MiddlewareOptions as v, middlewareOutputFn as w, type ProcedureHandlerOptions as x, type ProcedureDef as y, isProcedure as z };
143
+ export { isProcedure as E, createProcedureClient as G, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, validateORPCError as v, middlewareOutputFn as z };
144
+ export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, ProcedureClientInterceptorOptions as F, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
@@ -0,0 +1,9 @@
1
+ function resolveFriendlyStandardHandleOptions(options) {
2
+ return {
3
+ ...options,
4
+ context: options?.context ?? {}
5
+ // Context only optional if all fields are optional
6
+ };
7
+ }
8
+
9
+ export { resolveFriendlyStandardHandleOptions as r };
@@ -0,0 +1,36 @@
1
+ import { ORPCError, fallbackContractConfig } from '@orpc/contract';
2
+
3
+ const STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT_SYMBOL = Symbol("STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT");
4
+ class StrictGetMethodPlugin {
5
+ error;
6
+ order = 7e6;
7
+ constructor(options = {}) {
8
+ this.error = options.error ?? new ORPCError("METHOD_NOT_SUPPORTED");
9
+ }
10
+ init(options) {
11
+ options.rootInterceptors ??= [];
12
+ options.clientInterceptors ??= [];
13
+ options.rootInterceptors.unshift((options2) => {
14
+ const isGetMethod = options2.request.method === "GET";
15
+ return options2.next({
16
+ ...options2,
17
+ context: {
18
+ ...options2.context,
19
+ [STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT_SYMBOL]: isGetMethod
20
+ }
21
+ });
22
+ });
23
+ options.clientInterceptors.unshift((options2) => {
24
+ if (typeof options2.context[STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT_SYMBOL] !== "boolean") {
25
+ throw new TypeError("[StrictGetMethodPlugin] strict GET method context has been corrupted or modified by another plugin or interceptor");
26
+ }
27
+ const procedureMethod = fallbackContractConfig("defaultMethod", options2.procedure["~orpc"].route.method);
28
+ if (options2.context[STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT_SYMBOL] && procedureMethod !== "GET") {
29
+ throw this.error;
30
+ }
31
+ return options2.next();
32
+ });
33
+ }
34
+ }
35
+
36
+ export { StrictGetMethodPlugin as S };
@@ -0,0 +1,18 @@
1
+ import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
+ import { C as Context, R as Router } from './server.BVHsfJ99.mjs';
3
+ import { b as StandardHandlerOptions, i as StandardHandler } from './server.B1oIHH_j.mjs';
4
+
5
+ interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
+ /**
7
+ * Enables or disables the StrictGetMethodPlugin.
8
+ *
9
+ * @default true
10
+ */
11
+ strictGetMethodPluginEnabled?: boolean;
12
+ }
13
+ declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
14
+ constructor(router: Router<any, T>, options: StandardRPCHandlerOptions<T>);
15
+ }
16
+
17
+ export { StandardRPCHandler as a };
18
+ export type { StandardRPCHandlerOptions as S };
@@ -1,6 +1,6 @@
1
1
  import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
2
2
  import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
3
- import { value, intercept, toError } from '@orpc/shared';
3
+ import { value, intercept } from '@orpc/shared';
4
4
 
5
5
  const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
6
6
  function lazy(loader, meta = {}) {
@@ -21,7 +21,24 @@ function unlazy(lazied) {
21
21
  return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
22
22
  }
23
23
 
24
- function mergeMiddlewares(first, second) {
24
+ function isStartWithMiddlewares(middlewares, compare) {
25
+ if (compare.length > middlewares.length) {
26
+ return false;
27
+ }
28
+ for (let i = 0; i < middlewares.length; i++) {
29
+ if (compare[i] === void 0) {
30
+ return true;
31
+ }
32
+ if (middlewares[i] !== compare[i]) {
33
+ return false;
34
+ }
35
+ }
36
+ return true;
37
+ }
38
+ function mergeMiddlewares(first, second, options) {
39
+ if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
40
+ return second;
41
+ }
25
42
  return [...first, ...second];
26
43
  }
27
44
  function addMiddleware(middlewares, addition) {
@@ -41,6 +58,10 @@ function isProcedure(item) {
41
58
  return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
42
59
  }
43
60
 
61
+ function mergeCurrentContext(context, other) {
62
+ return { ...context, ...other };
63
+ }
64
+
44
65
  function createORPCErrorConstructorMap(errors) {
45
66
  const proxy = new Proxy(errors, {
46
67
  get(target, code) {
@@ -106,7 +127,7 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
106
127
  );
107
128
  } catch (e) {
108
129
  if (!(e instanceof ORPCError)) {
109
- throw toError(e);
130
+ throw e;
110
131
  }
111
132
  const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
112
133
  throw validated;
@@ -148,28 +169,29 @@ async function executeProcedureInternal(procedure, options) {
148
169
  const middlewares = procedure["~orpc"].middlewares;
149
170
  const inputValidationIndex = Math.min(Math.max(0, procedure["~orpc"].inputValidationIndex), middlewares.length);
150
171
  const outputValidationIndex = Math.min(Math.max(0, procedure["~orpc"].outputValidationIndex), middlewares.length);
151
- let currentIndex = 0;
152
- let currentContext = options.context;
153
- let currentInput = options.input;
154
- const next = async (...[nextOptions]) => {
155
- const index = currentIndex;
156
- currentIndex += 1;
157
- currentContext = { ...currentContext, ...nextOptions?.context };
172
+ const next = async (index, context, input) => {
173
+ let currentInput = input;
158
174
  if (index === inputValidationIndex) {
159
175
  currentInput = await validateInput(procedure, currentInput);
160
176
  }
161
177
  const mid = middlewares[index];
162
- const result = mid ? await mid({ ...options, context: currentContext, next }, currentInput, middlewareOutputFn) : { output: await procedure["~orpc"].handler({ ...options, context: currentContext, input: currentInput }), context: currentContext };
178
+ const output = mid ? (await mid({
179
+ ...options,
180
+ context,
181
+ next: async (...[nextOptions]) => {
182
+ const nextContext = nextOptions?.context ?? {};
183
+ return {
184
+ output: await next(index + 1, mergeCurrentContext(context, nextContext), currentInput),
185
+ context: nextContext
186
+ };
187
+ }
188
+ }, currentInput, middlewareOutputFn)).output : await procedure["~orpc"].handler({ ...options, context, input: currentInput });
163
189
  if (index === outputValidationIndex) {
164
- const validatedOutput = await validateOutput(procedure, result.output);
165
- return {
166
- ...result,
167
- output: validatedOutput
168
- };
190
+ return await validateOutput(procedure, output);
169
191
  }
170
- return result;
192
+ return output;
171
193
  };
172
- return (await next({})).output;
194
+ return next(0, options.context, options.input);
173
195
  }
174
196
 
175
197
  const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
@@ -239,7 +261,7 @@ function enhanceRouter(router, options) {
239
261
  return accessible;
240
262
  }
241
263
  if (isProcedure(router)) {
242
- const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares);
264
+ const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, { dedupeLeading: options.dedupeLeadingMiddlewares });
243
265
  const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
244
266
  const enhanced2 = new Procedure({
245
267
  ...router["~orpc"],
@@ -339,8 +361,4 @@ function call(procedure, input, ...rest) {
339
361
  return createProcedureClient(procedure, ...rest)(input);
340
362
  }
341
363
 
342
- function toHttpPath(path) {
343
- return `/${path.map(encodeURIComponent).join("/")}`;
344
- }
345
-
346
- export { LAZY_SYMBOL as L, Procedure as P, toHttpPath as a, createContractedProcedure as b, createProcedureClient as c, addMiddleware as d, enhanceRouter as e, isLazy as f, getRouter as g, createAssertedLazyProcedure as h, isProcedure as i, getLazyMeta as j, call as k, lazy as l, middlewareOutputFn as m, getHiddenRouterContract as n, createAccessibleLazyRouter as o, unlazyRouter as p, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
364
+ export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, resolveContractProcedures as w, unlazyRouter as x };
@@ -1,8 +1,18 @@
1
- import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
2
- import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
1
+ import { HTTPPath, ORPCError } from '@orpc/client';
2
+ import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
3
+ import { Interceptor, ThrowableError } from '@orpc/shared';
3
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
4
- import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CPteJIPP.mjs';
5
- import { ORPCError } from '@orpc/client';
5
+ import { C as Context, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions, R as Router } from './server.BVHsfJ99.js';
6
+
7
+ interface StandardHandlerPlugin<TContext extends Context> {
8
+ order?: number;
9
+ init?(options: StandardHandlerOptions<TContext>): void;
10
+ }
11
+ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
12
+ protected readonly plugins: TPlugin[];
13
+ constructor(plugins?: readonly TPlugin[]);
14
+ init(options: StandardHandlerOptions<T>): void;
15
+ }
6
16
 
7
17
  type StandardParams = Record<string, string>;
8
18
  type StandardMatchResult = {
@@ -20,13 +30,10 @@ interface StandardCodec {
20
30
  decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
21
31
  }
22
32
 
23
- type StandardHandleOptions<T extends Context> = {
33
+ interface StandardHandleOptions<T extends Context> {
24
34
  prefix?: HTTPPath;
25
- } & (Record<never, never> extends T ? {
26
- context?: T;
27
- } : {
28
35
  context: T;
29
- });
36
+ }
30
37
  type StandardHandleResult = {
31
38
  matched: true;
32
39
  response: StandardResponse;
@@ -34,42 +41,34 @@ type StandardHandleResult = {
34
41
  matched: false;
35
42
  response: undefined;
36
43
  };
37
- type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
38
- context: T;
44
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
39
45
  request: StandardLazyRequest;
40
- };
46
+ }
41
47
  interface StandardHandlerOptions<TContext extends Context> {
42
- plugins?: HandlerPlugin<TContext>[];
48
+ plugins?: StandardHandlerPlugin<TContext>[];
43
49
  /**
44
50
  * Interceptors at the request level, helpful when you want catch errors
45
51
  */
46
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
52
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
47
53
  /**
48
54
  * Interceptors at the root level, helpful when you want override the request/response
49
55
  */
50
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
56
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
51
57
  /**
52
58
  *
53
59
  * Interceptors for procedure client.
54
60
  */
55
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
61
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
56
62
  }
57
63
  declare class StandardHandler<T extends Context> {
58
64
  private readonly matcher;
59
65
  private readonly codec;
60
- private readonly options;
61
- private readonly plugin;
66
+ private readonly interceptors;
67
+ private readonly clientInterceptors;
68
+ private readonly rootInterceptors;
62
69
  constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
63
- handle(request: StandardLazyRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
64
- }
65
-
66
- interface HandlerPlugin<TContext extends Context> {
67
- init?(options: StandardHandlerOptions<TContext>): void;
68
- }
69
- declare class CompositePlugin<TContext extends Context> implements HandlerPlugin<TContext> {
70
- private readonly plugins;
71
- constructor(plugins?: HandlerPlugin<TContext>[]);
72
- init(options: StandardHandlerOptions<TContext>): void;
70
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
73
71
  }
74
72
 
75
- export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerInterceptorOptions as a, type StandardHandlerOptions as b, type StandardCodec as c, type StandardParams as d, type StandardMatcher as e, type StandardMatchResult as f, type StandardHandleResult as g, StandardHandler as h };
73
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as i };
74
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardCodec as c, StandardParams as d, StandardMatcher as e, StandardMatchResult as f, StandardHandleOptions as g, StandardHandleResult as h };
@@ -1,51 +1,68 @@
1
+ import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
2
+ import { toArray, intercept, parseEmptyableJSON } from '@orpc/shared';
3
+ import '@orpc/standard-server/batch';
1
4
  import { ORPCError, toORPCError } from '@orpc/client';
2
- import { intercept, trim, parseEmptyableJSON } from '@orpc/shared';
3
- import { C as CompositePlugin } from './server.Q6ZmnTgO.mjs';
4
- import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.CMrS28Go.mjs';
5
+ import { S as StrictGetMethodPlugin } from './server.BW-nUGgA.mjs';
6
+ import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.C37gDhSZ.mjs';
7
+
8
+ class CompositeStandardHandlerPlugin {
9
+ plugins;
10
+ constructor(plugins = []) {
11
+ this.plugins = [...plugins].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
12
+ }
13
+ init(options) {
14
+ for (const plugin of this.plugins) {
15
+ plugin.init?.(options);
16
+ }
17
+ }
18
+ }
5
19
 
6
20
  class StandardHandler {
7
21
  constructor(router, matcher, codec, options) {
8
22
  this.matcher = matcher;
9
23
  this.codec = codec;
10
- this.options = options;
11
- this.plugin = new CompositePlugin(options.plugins);
12
- this.plugin.init(this.options);
24
+ const plugins = new CompositeStandardHandlerPlugin(options.plugins);
25
+ plugins.init(options);
26
+ this.interceptors = toArray(options.interceptors);
27
+ this.clientInterceptors = toArray(options.clientInterceptors);
28
+ this.rootInterceptors = toArray(options.rootInterceptors);
13
29
  this.matcher.init(router);
14
30
  }
15
- plugin;
16
- handle(request, ...[options]) {
31
+ interceptors;
32
+ clientInterceptors;
33
+ rootInterceptors;
34
+ async handle(request, options) {
35
+ const prefix = options.prefix?.replace(/\/$/, "") || void 0;
36
+ if (prefix && !request.url.pathname.startsWith(`${prefix}/`) && request.url.pathname !== prefix) {
37
+ return { matched: false, response: void 0 };
38
+ }
17
39
  return intercept(
18
- this.options.rootInterceptors ?? [],
19
- {
20
- request,
21
- ...options,
22
- context: options?.context ?? {}
23
- // context is optional only when all fields are optional so we can safely force it to have a context
24
- },
40
+ this.rootInterceptors,
41
+ { ...options, request, prefix },
25
42
  async (interceptorOptions) => {
26
43
  let isDecoding = false;
27
44
  try {
28
45
  return await intercept(
29
- this.options.interceptors ?? [],
46
+ this.interceptors,
30
47
  interceptorOptions,
31
- async (interceptorOptions2) => {
32
- const method = interceptorOptions2.request.method;
33
- const url = interceptorOptions2.request.url;
34
- const pathname = `/${trim(url.pathname.replace(interceptorOptions2.prefix ?? "", ""), "/")}`;
35
- const match = await this.matcher.match(method, pathname);
48
+ async ({ request: request2, context, prefix: prefix2 }) => {
49
+ const method = request2.method;
50
+ const url = request2.url;
51
+ const pathname = prefix2 ? url.pathname.replace(prefix2, "") : url.pathname;
52
+ const match = await this.matcher.match(method, `/${pathname.replace(/^\/|\/$/g, "")}`);
36
53
  if (!match) {
37
54
  return { matched: false, response: void 0 };
38
55
  }
39
56
  const client = createProcedureClient(match.procedure, {
40
- context: interceptorOptions2.context,
57
+ context,
41
58
  path: match.path,
42
- interceptors: this.options.clientInterceptors
59
+ interceptors: this.clientInterceptors
43
60
  });
44
61
  isDecoding = true;
45
- const input = await this.codec.decode(request, match.params, match.procedure);
62
+ const input = await this.codec.decode(request2, match.params, match.procedure);
46
63
  isDecoding = false;
47
- const lastEventId = Array.isArray(request.headers["last-event-id"]) ? request.headers["last-event-id"].at(-1) : request.headers["last-event-id"];
48
- const output = await client(input, { signal: request.signal, lastEventId });
64
+ const lastEventId = Array.isArray(request2.headers["last-event-id"]) ? request2.headers["last-event-id"].at(-1) : request2.headers["last-event-id"];
65
+ const output = await client(input, { signal: request2.signal, lastEventId });
49
66
  const response = this.codec.encode(output, match.procedure);
50
67
  return {
51
68
  matched: true,
@@ -54,7 +71,7 @@ class StandardHandler {
54
71
  }
55
72
  );
56
73
  } catch (e) {
57
- const error = isDecoding ? new ORPCError("BAD_REQUEST", {
74
+ const error = isDecoding && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
58
75
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
59
76
  cause: e
60
77
  }) : toORPCError(e);
@@ -69,7 +86,7 @@ class StandardHandler {
69
86
  }
70
87
  }
71
88
 
72
- class RPCCodec {
89
+ class StandardRPCCodec {
73
90
  constructor(serializer) {
74
91
  this.serializer = serializer;
75
92
  }
@@ -93,7 +110,7 @@ class RPCCodec {
93
110
  }
94
111
  }
95
112
 
96
- class RPCMatcher {
113
+ class StandardRPCMatcher {
97
114
  tree = {};
98
115
  pendingRouters = [];
99
116
  init(router, path = []) {
@@ -155,4 +172,19 @@ class RPCMatcher {
155
172
  }
156
173
  }
157
174
 
158
- export { RPCCodec as R, StandardHandler as S, RPCMatcher as a };
175
+ class StandardRPCHandler extends StandardHandler {
176
+ constructor(router, options) {
177
+ options.plugins ??= [];
178
+ const strictGetMethodPluginEnabled = options.strictGetMethodPluginEnabled ?? true;
179
+ if (strictGetMethodPluginEnabled) {
180
+ options.plugins.push(new StrictGetMethodPlugin());
181
+ }
182
+ const jsonSerializer = new StandardRPCJsonSerializer(options);
183
+ const serializer = new StandardRPCSerializer(jsonSerializer);
184
+ const matcher = new StandardRPCMatcher();
185
+ const codec = new StandardRPCCodec(serializer);
186
+ super(router, matcher, codec, options);
187
+ }
188
+ }
189
+
190
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as S, StandardRPCCodec as a, StandardRPCHandler as b, StandardRPCMatcher as c };