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

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 (33) hide show
  1. package/README.md +2 -0
  2. package/dist/adapters/fetch/index.d.mts +5 -3
  3. package/dist/adapters/fetch/index.d.ts +5 -3
  4. package/dist/adapters/fetch/index.mjs +4 -4
  5. package/dist/adapters/hono/index.d.mts +4 -2
  6. package/dist/adapters/hono/index.d.ts +4 -2
  7. package/dist/adapters/hono/index.mjs +4 -4
  8. package/dist/adapters/next/index.d.mts +4 -2
  9. package/dist/adapters/next/index.d.ts +4 -2
  10. package/dist/adapters/next/index.mjs +4 -4
  11. package/dist/adapters/node/index.d.mts +5 -3
  12. package/dist/adapters/node/index.d.ts +5 -3
  13. package/dist/adapters/node/index.mjs +8 -7
  14. package/dist/adapters/standard/index.d.mts +9 -8
  15. package/dist/adapters/standard/index.d.ts +9 -8
  16. package/dist/adapters/standard/index.mjs +3 -3
  17. package/dist/index.d.mts +53 -45
  18. package/dist/index.d.ts +53 -45
  19. package/dist/index.mjs +21 -22
  20. package/dist/plugins/index.d.mts +3 -3
  21. package/dist/plugins/index.d.ts +3 -3
  22. package/dist/plugins/index.mjs +1 -1
  23. package/dist/shared/{server.CSZRzcSW.mjs → server.BY9sDlwl.mjs} +6 -6
  24. package/dist/shared/server.BqBN5WhH.d.mts +8 -0
  25. package/dist/shared/{server.CMrS28Go.mjs → server.BtxZnWJ9.mjs} +35 -7
  26. package/dist/shared/{server.CM3tWr3C.d.mts → server.CPqNKiJp.d.ts} +3 -3
  27. package/dist/shared/{server.Q6ZmnTgO.mjs → server.Dba3Iiyp.mjs} +2 -2
  28. package/dist/shared/{server.Cq3B6PoL.mjs → server.Del5OmaY.mjs} +6 -5
  29. package/dist/shared/server.Dm3ZuTuI.d.ts +8 -0
  30. package/dist/shared/{server.CPteJIPP.d.mts → server.MZvbGc3n.d.mts} +11 -11
  31. package/dist/shared/{server.CPteJIPP.d.ts → server.MZvbGc3n.d.ts} +11 -11
  32. package/dist/shared/{server.DmW25ynm.d.ts → server.P4_D9lKb.d.mts} +3 -3
  33. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- class CompositePlugin {
1
+ class CompositeHandlerPlugin {
2
2
  constructor(plugins = []) {
3
3
  this.plugins = plugins;
4
4
  }
@@ -9,4 +9,4 @@ class CompositePlugin {
9
9
  }
10
10
  }
11
11
 
12
- export { CompositePlugin as C };
12
+ export { CompositeHandlerPlugin as C };
@@ -1,13 +1,14 @@
1
- import { RPCSerializer } from '@orpc/client/standard';
1
+ import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
2
2
  import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
3
- import { S as StandardHandler, a as RPCMatcher, R as RPCCodec } from './server.CSZRzcSW.mjs';
3
+ import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.BY9sDlwl.mjs';
4
4
 
5
5
  class RPCHandler {
6
6
  standardHandler;
7
7
  constructor(router, options = {}) {
8
- const serializer = new RPCSerializer();
9
- const matcher = new RPCMatcher();
10
- const codec = new RPCCodec(serializer);
8
+ const jsonSerializer = new StandardRPCJsonSerializer(options);
9
+ const serializer = new StandardRPCSerializer(jsonSerializer);
10
+ const matcher = new StandardRPCMatcher();
11
+ const codec = new StandardRPCCodec(serializer);
11
12
  this.standardHandler = new StandardHandler(router, matcher, codec, options);
12
13
  }
13
14
  async handle(request, ...[
@@ -0,0 +1,8 @@
1
+ import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
+ import { C as Context } from './server.MZvbGc3n.js';
3
+ import { a as StandardHandlerOptions } from './server.CPqNKiJp.js';
4
+
5
+ interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
+ }
7
+
8
+ export type { StandardRPCHandlerOptions as S };
@@ -1,19 +1,19 @@
1
1
  import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
2
+ import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
3
  import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
4
4
 
5
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;
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> {
@@ -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
1
  import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
2
+ import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
3
  import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
4
4
 
5
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;
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> {
@@ -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,7 +1,7 @@
1
1
  import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
2
2
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
3
  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';
4
+ import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.MZvbGc3n.mjs';
5
5
  import { ORPCError } from '@orpc/client';
6
6
 
7
7
  type StandardParams = Record<string, string>;
@@ -66,10 +66,10 @@ declare class StandardHandler<T extends Context> {
66
66
  interface HandlerPlugin<TContext extends Context> {
67
67
  init?(options: StandardHandlerOptions<TContext>): void;
68
68
  }
69
- declare class CompositePlugin<TContext extends Context> implements HandlerPlugin<TContext> {
69
+ declare class CompositeHandlerPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
70
70
  private readonly plugins;
71
71
  constructor(plugins?: HandlerPlugin<TContext>[]);
72
72
  init(options: StandardHandlerOptions<TContext>): void;
73
73
  }
74
74
 
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 };
75
+ export { CompositeHandlerPlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions 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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.0.0-next.c0afbea",
4
+ "version": "0.0.0-next.c0dd7cd",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -58,12 +58,12 @@
58
58
  "next": ">=14.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@orpc/client": "0.0.0-next.c0afbea",
62
- "@orpc/contract": "0.0.0-next.c0afbea",
63
- "@orpc/shared": "0.0.0-next.c0afbea",
64
- "@orpc/standard-server-node": "0.0.0-next.c0afbea",
65
- "@orpc/standard-server-fetch": "0.0.0-next.c0afbea",
66
- "@orpc/standard-server": "0.0.0-next.c0afbea"
61
+ "@orpc/client": "0.0.0-next.c0dd7cd",
62
+ "@orpc/shared": "0.0.0-next.c0dd7cd",
63
+ "@orpc/contract": "0.0.0-next.c0dd7cd",
64
+ "@orpc/standard-server": "0.0.0-next.c0dd7cd",
65
+ "@orpc/standard-server-fetch": "0.0.0-next.c0dd7cd",
66
+ "@orpc/standard-server-node": "0.0.0-next.c0dd7cd"
67
67
  },
68
68
  "devDependencies": {
69
69
  "light-my-request": "^6.5.1"