@orpc/server 0.0.0-next.c0afbea → 0.0.0-next.c0ca4c7

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 +38 -10
  3. package/dist/adapters/fetch/index.d.ts +38 -10
  4. package/dist/adapters/fetch/index.mjs +6 -6
  5. package/dist/adapters/hono/index.d.mts +6 -3
  6. package/dist/adapters/hono/index.d.ts +6 -3
  7. package/dist/adapters/hono/index.mjs +6 -6
  8. package/dist/adapters/next/index.d.mts +6 -3
  9. package/dist/adapters/next/index.d.ts +6 -3
  10. package/dist/adapters/next/index.mjs +6 -6
  11. package/dist/adapters/node/index.d.mts +40 -21
  12. package/dist/adapters/node/index.d.ts +40 -21
  13. package/dist/adapters/node/index.mjs +77 -23
  14. package/dist/adapters/standard/index.d.mts +11 -10
  15. package/dist/adapters/standard/index.d.ts +11 -10
  16. package/dist/adapters/standard/index.mjs +3 -3
  17. package/dist/index.d.mts +83 -61
  18. package/dist/index.d.ts +83 -61
  19. package/dist/index.mjs +45 -25
  20. package/dist/plugins/index.d.mts +12 -13
  21. package/dist/plugins/index.d.ts +12 -13
  22. package/dist/plugins/index.mjs +9 -5
  23. package/dist/shared/server.B77ImKAP.d.mts +8 -0
  24. package/dist/shared/{server.DmW25ynm.d.ts → server.BHlRCrf_.d.ts} +20 -29
  25. package/dist/shared/server.BVwwTHyO.mjs +9 -0
  26. package/dist/shared/server.Cud5qk0c.d.ts +10 -0
  27. package/dist/shared/{server.CM3tWr3C.d.mts → server.CzxlqYZL.d.mts} +20 -29
  28. package/dist/shared/server.DGnN7q3R.d.mts +10 -0
  29. package/dist/shared/{server.CPteJIPP.d.mts → server.DLt5njUb.d.mts} +19 -19
  30. package/dist/shared/{server.CPteJIPP.d.ts → server.DLt5njUb.d.ts} +19 -19
  31. package/dist/shared/server.DUF89eb-.d.ts +8 -0
  32. package/dist/shared/{server.CSZRzcSW.mjs → server.Dfx1jV-K.mjs} +33 -30
  33. package/dist/shared/server.T5WmDoWQ.mjs +98 -0
  34. package/dist/shared/{server.CMrS28Go.mjs → server.e3W6AG3-.mjs} +37 -13
  35. package/package.json +8 -8
  36. package/dist/shared/server.Cq3B6PoL.mjs +0 -28
  37. package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
@@ -1,31 +1,30 @@
1
- import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.DmW25ynm.js';
2
- export { C as CompositePlugin } from '../shared/server.DmW25ynm.js';
1
+ import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.BHlRCrf_.js';
3
2
  import { Value } from '@orpc/shared';
4
- import { C as Context } from '../shared/server.CPteJIPP.js';
3
+ import { C as Context } from '../shared/server.DLt5njUb.js';
4
+ import '@orpc/client';
5
5
  import '@orpc/contract';
6
6
  import '@orpc/standard-server';
7
- import '@orpc/client';
8
7
 
9
- interface CORSOptions<TContext extends Context> {
10
- origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
11
- timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
8
+ interface CORSOptions<T extends Context> {
9
+ origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
10
+ timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
12
11
  allowMethods?: readonly string[];
13
12
  allowHeaders?: readonly string[];
14
13
  maxAge?: number;
15
14
  credentials?: boolean;
16
15
  exposeHeaders?: readonly string[];
17
16
  }
18
- declare class CORSPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
17
+ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
19
18
  private readonly options;
20
- constructor(options?: CORSOptions<TContext>);
21
- init(options: StandardHandlerOptions<TContext>): void;
19
+ constructor(options?: CORSOptions<T>);
20
+ init(options: StandardHandlerOptions<T>): void;
22
21
  }
23
22
 
24
23
  interface ResponseHeadersPluginContext {
25
24
  resHeaders?: Headers;
26
25
  }
27
- declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements HandlerPlugin<TContext> {
28
- init(options: StandardHandlerOptions<TContext>): void;
26
+ declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
27
+ init(options: StandardHandlerOptions<T>): void;
29
28
  }
30
29
 
31
- export { type CORSOptions, CORSPlugin, HandlerPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
30
+ export { type CORSOptions, CORSPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
@@ -1,4 +1,3 @@
1
- export { C as CompositePlugin } from '../shared/server.Q6ZmnTgO.mjs';
2
1
  import { value } from '@orpc/shared';
3
2
 
4
3
  class CORSPlugin {
@@ -79,14 +78,19 @@ class ResponseHeadersPlugin {
79
78
  init(options) {
80
79
  options.rootInterceptors ??= [];
81
80
  options.rootInterceptors.push(async (interceptorOptions) => {
82
- const headers = new Headers();
83
- interceptorOptions.context.resHeaders = headers;
84
- const result = await interceptorOptions.next();
81
+ const resHeaders = interceptorOptions.context.resHeaders ?? new Headers();
82
+ const result = await interceptorOptions.next({
83
+ ...interceptorOptions,
84
+ context: {
85
+ ...interceptorOptions.context,
86
+ resHeaders
87
+ }
88
+ });
85
89
  if (!result.matched) {
86
90
  return result;
87
91
  }
88
92
  const responseHeaders = result.response.headers;
89
- for (const [key, value] of headers) {
93
+ for (const [key, value] of resHeaders) {
90
94
  if (Array.isArray(responseHeaders[key])) {
91
95
  responseHeaders[key].push(value);
92
96
  } else if (responseHeaders[key] !== void 0) {
@@ -0,0 +1,8 @@
1
+ import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
+ import { C as Context } from './server.DLt5njUb.mjs';
3
+ import { a as StandardHandlerOptions } from './server.CzxlqYZL.mjs';
4
+
5
+ interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
+ }
7
+
8
+ export type { StandardRPCHandlerOptions as S };
@@ -1,8 +1,8 @@
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.js';
5
- import { ORPCError } from '@orpc/client';
5
+ import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.DLt5njUb.js';
6
6
 
7
7
  type StandardParams = Record<string, string>;
8
8
  type StandardMatchResult = {
@@ -20,13 +20,10 @@ interface StandardCodec {
20
20
  decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
21
21
  }
22
22
 
23
- type StandardHandleOptions<T extends Context> = {
23
+ interface StandardHandleOptions<T extends Context> {
24
24
  prefix?: HTTPPath;
25
- } & (Record<never, never> extends T ? {
26
- context?: T;
27
- } : {
28
25
  context: T;
29
- });
26
+ }
30
27
  type StandardHandleResult = {
31
28
  matched: true;
32
29
  response: StandardResponse;
@@ -34,42 +31,36 @@ type StandardHandleResult = {
34
31
  matched: false;
35
32
  response: undefined;
36
33
  };
37
- type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
38
- context: T;
34
+ interface StandardHandlerPlugin<TContext extends Context> {
35
+ init?(options: StandardHandlerOptions<TContext>): void;
36
+ }
37
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
39
38
  request: StandardLazyRequest;
40
- };
39
+ }
41
40
  interface StandardHandlerOptions<TContext extends Context> {
42
- plugins?: HandlerPlugin<TContext>[];
41
+ plugins?: StandardHandlerPlugin<TContext>[];
43
42
  /**
44
43
  * Interceptors at the request level, helpful when you want catch errors
45
44
  */
46
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
45
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
47
46
  /**
48
47
  * Interceptors at the root level, helpful when you want override the request/response
49
48
  */
50
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
49
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
51
50
  /**
52
51
  *
53
52
  * Interceptors for procedure client.
54
53
  */
55
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
54
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
56
55
  }
57
56
  declare class StandardHandler<T extends Context> {
58
57
  private readonly matcher;
59
58
  private readonly codec;
60
- private readonly options;
61
- private readonly plugin;
59
+ private readonly interceptors;
60
+ private readonly clientInterceptors;
61
+ private readonly rootInterceptors;
62
62
  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;
63
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
73
64
  }
74
65
 
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 };
66
+ export { type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions as b, type StandardHandlerPlugin as c, type StandardCodec as d, type StandardParams as e, type StandardMatcher as f, type StandardMatchResult as g, type StandardHandleResult as h, StandardHandler as i };
@@ -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,10 @@
1
+ import { C as Context } from './server.DLt5njUb.js';
2
+ import { S as StandardHandleOptions } from './server.BHlRCrf_.js';
3
+
4
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
+ context?: T;
6
+ } : {
7
+ context: T;
8
+ });
9
+
10
+ export type { FriendlyStandardHandleOptions as F };
@@ -1,8 +1,8 @@
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 { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.DLt5njUb.mjs';
6
6
 
7
7
  type StandardParams = Record<string, string>;
8
8
  type StandardMatchResult = {
@@ -20,13 +20,10 @@ interface StandardCodec {
20
20
  decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
21
21
  }
22
22
 
23
- type StandardHandleOptions<T extends Context> = {
23
+ interface StandardHandleOptions<T extends Context> {
24
24
  prefix?: HTTPPath;
25
- } & (Record<never, never> extends T ? {
26
- context?: T;
27
- } : {
28
25
  context: T;
29
- });
26
+ }
30
27
  type StandardHandleResult = {
31
28
  matched: true;
32
29
  response: StandardResponse;
@@ -34,42 +31,36 @@ type StandardHandleResult = {
34
31
  matched: false;
35
32
  response: undefined;
36
33
  };
37
- type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
38
- context: T;
34
+ interface StandardHandlerPlugin<TContext extends Context> {
35
+ init?(options: StandardHandlerOptions<TContext>): void;
36
+ }
37
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
39
38
  request: StandardLazyRequest;
40
- };
39
+ }
41
40
  interface StandardHandlerOptions<TContext extends Context> {
42
- plugins?: HandlerPlugin<TContext>[];
41
+ plugins?: StandardHandlerPlugin<TContext>[];
43
42
  /**
44
43
  * Interceptors at the request level, helpful when you want catch errors
45
44
  */
46
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
45
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
47
46
  /**
48
47
  * Interceptors at the root level, helpful when you want override the request/response
49
48
  */
50
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
49
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
51
50
  /**
52
51
  *
53
52
  * Interceptors for procedure client.
54
53
  */
55
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
54
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
56
55
  }
57
56
  declare class StandardHandler<T extends Context> {
58
57
  private readonly matcher;
59
58
  private readonly codec;
60
- private readonly options;
61
- private readonly plugin;
59
+ private readonly interceptors;
60
+ private readonly clientInterceptors;
61
+ private readonly rootInterceptors;
62
62
  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;
63
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
73
64
  }
74
65
 
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 };
66
+ export { type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions as b, type StandardHandlerPlugin as c, type StandardCodec as d, type StandardParams as e, type StandardMatcher as f, type StandardMatchResult as g, type StandardHandleResult as h, StandardHandler as i };
@@ -0,0 +1,10 @@
1
+ import { C as Context } from './server.DLt5njUb.mjs';
2
+ import { S as StandardHandleOptions } from './server.CzxlqYZL.mjs';
3
+
4
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
+ context?: T;
6
+ } : {
7
+ context: T;
8
+ });
9
+
10
+ export type { FriendlyStandardHandleOptions as F };
@@ -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 { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
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,4 @@ 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 { type AnyProcedure as A, middlewareOutputFn as B, type Context as C, type ProcedureHandlerOptions as D, type ProcedureDef as E, isProcedure as F, createProcedureClient as G, type InferRouterInitialContexts as H, type InferRouterInitialContext as I, type InferRouterCurrentContexts as J, type InferRouterInputs as K, type Lazyable as L, type Middleware as M, type InferRouterOutputs as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, type AnyRouter as a, Procedure as b, type MergedInitialContext as c, type MergedCurrentContext 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, type ORPCErrorConstructorMapItemOptions as k, type ORPCErrorConstructorMapItem as l, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, type LazyMeta as p, lazy as q, isLazy as r, getLazyMeta as s, type MiddlewareResult as t, unlazy as u, validateORPCError as v, type MiddlewareNextFnOptions as w, type MiddlewareNextFn as x, type MiddlewareOutputFn as y, type MiddlewareOptions as z };
@@ -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 { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
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,4 @@ 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 { type AnyProcedure as A, middlewareOutputFn as B, type Context as C, type ProcedureHandlerOptions as D, type ProcedureDef as E, isProcedure as F, createProcedureClient as G, type InferRouterInitialContexts as H, type InferRouterInitialContext as I, type InferRouterCurrentContexts as J, type InferRouterInputs as K, type Lazyable as L, type Middleware as M, type InferRouterOutputs as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, type AnyRouter as a, Procedure as b, type MergedInitialContext as c, type MergedCurrentContext 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, type ORPCErrorConstructorMapItemOptions as k, type ORPCErrorConstructorMapItem as l, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, type LazyMeta as p, lazy as q, isLazy as r, getLazyMeta as s, type MiddlewareResult as t, unlazy as u, validateORPCError as v, type MiddlewareNextFnOptions as w, type MiddlewareNextFn as x, type MiddlewareOutputFn as y, type MiddlewareOptions as z };
@@ -0,0 +1,8 @@
1
+ import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
+ import { C as Context } from './server.DLt5njUb.js';
3
+ import { a as StandardHandlerOptions } from './server.BHlRCrf_.js';
4
+
5
+ interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
+ }
7
+
8
+ export type { StandardRPCHandlerOptions as S };
@@ -1,51 +1,54 @@
1
1
  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';
2
+ import { toArray, intercept, parseEmptyableJSON } from '@orpc/shared';
3
+ import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.e3W6AG3-.mjs';
4
+ import { toHttpPath } from '@orpc/client/standard';
5
5
 
6
6
  class StandardHandler {
7
7
  constructor(router, matcher, codec, options) {
8
8
  this.matcher = matcher;
9
9
  this.codec = codec;
10
- this.options = options;
11
- this.plugin = new CompositePlugin(options.plugins);
12
- this.plugin.init(this.options);
10
+ for (const plugin of toArray(options.plugins)) {
11
+ plugin.init?.(options);
12
+ }
13
+ this.interceptors = toArray(options.interceptors);
14
+ this.clientInterceptors = toArray(options.clientInterceptors);
15
+ this.rootInterceptors = toArray(options.rootInterceptors);
13
16
  this.matcher.init(router);
14
17
  }
15
- plugin;
16
- handle(request, ...[options]) {
18
+ interceptors;
19
+ clientInterceptors;
20
+ rootInterceptors;
21
+ handle(request, options) {
17
22
  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
- },
23
+ this.rootInterceptors,
24
+ { ...options, request },
25
25
  async (interceptorOptions) => {
26
26
  let isDecoding = false;
27
27
  try {
28
28
  return await intercept(
29
- this.options.interceptors ?? [],
29
+ this.interceptors,
30
30
  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);
31
+ async ({ request: request2, context, prefix }) => {
32
+ const method = request2.method;
33
+ const url = request2.url;
34
+ if (prefix && !url.pathname.startsWith(prefix)) {
35
+ return { matched: false, response: void 0 };
36
+ }
37
+ const pathname = prefix ? url.pathname.replace(prefix, "") : url.pathname;
38
+ const match = await this.matcher.match(method, `/${pathname.replace(/^\/|\/$/g, "")}`);
36
39
  if (!match) {
37
40
  return { matched: false, response: void 0 };
38
41
  }
39
42
  const client = createProcedureClient(match.procedure, {
40
- context: interceptorOptions2.context,
43
+ context,
41
44
  path: match.path,
42
- interceptors: this.options.clientInterceptors
45
+ interceptors: this.clientInterceptors
43
46
  });
44
47
  isDecoding = true;
45
- const input = await this.codec.decode(request, match.params, match.procedure);
48
+ const input = await this.codec.decode(request2, match.params, match.procedure);
46
49
  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 });
50
+ const lastEventId = Array.isArray(request2.headers["last-event-id"]) ? request2.headers["last-event-id"].at(-1) : request2.headers["last-event-id"];
51
+ const output = await client(input, { signal: request2.signal, lastEventId });
49
52
  const response = this.codec.encode(output, match.procedure);
50
53
  return {
51
54
  matched: true,
@@ -54,7 +57,7 @@ class StandardHandler {
54
57
  }
55
58
  );
56
59
  } catch (e) {
57
- const error = isDecoding ? new ORPCError("BAD_REQUEST", {
60
+ const error = isDecoding && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
58
61
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
59
62
  cause: e
60
63
  }) : toORPCError(e);
@@ -69,7 +72,7 @@ class StandardHandler {
69
72
  }
70
73
  }
71
74
 
72
- class RPCCodec {
75
+ class StandardRPCCodec {
73
76
  constructor(serializer) {
74
77
  this.serializer = serializer;
75
78
  }
@@ -93,7 +96,7 @@ class RPCCodec {
93
96
  }
94
97
  }
95
98
 
96
- class RPCMatcher {
99
+ class StandardRPCMatcher {
97
100
  tree = {};
98
101
  pendingRouters = [];
99
102
  init(router, path = []) {
@@ -155,4 +158,4 @@ class RPCMatcher {
155
158
  }
156
159
  }
157
160
 
158
- export { RPCCodec as R, StandardHandler as S, RPCMatcher as a };
161
+ export { StandardHandler as S, StandardRPCCodec as a, StandardRPCMatcher as b };