@orpc/server 0.0.0-next.9b9ade5 → 0.0.0-next.9fc14d1

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 (31) hide show
  1. package/README.md +2 -1
  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 +3 -3
  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 +3 -3
  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 +3 -3
  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 +7 -6
  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 +2 -2
  17. package/dist/index.d.mts +47 -38
  18. package/dist/index.d.ts +47 -38
  19. package/dist/index.mjs +22 -19
  20. package/dist/plugins/index.d.mts +3 -3
  21. package/dist/plugins/index.d.ts +3 -3
  22. package/dist/shared/server.BXfgvxK8.d.ts +8 -0
  23. package/dist/shared/{server.CMrS28Go.mjs → server.B_5ZADvP.mjs} +20 -3
  24. package/dist/shared/{server.Cq3B6PoL.mjs → server.D1vPuPwc.mjs} +6 -5
  25. package/dist/shared/server.DKCNBSd-.d.mts +8 -0
  26. package/dist/shared/{server.CSZRzcSW.mjs → server.DisswUB5.mjs} +4 -4
  27. package/dist/shared/{server.DmW25ynm.d.ts → server.Dj89-yLZ.d.ts} +2 -2
  28. package/dist/shared/{server.CPteJIPP.d.mts → server.DnmJuN02.d.mts} +12 -11
  29. package/dist/shared/{server.CPteJIPP.d.ts → server.DnmJuN02.d.ts} +12 -11
  30. package/dist/shared/{server.CM3tWr3C.d.mts → server.DpIMjOfC.d.mts} +2 -2
  31. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -1,14 +1,15 @@
1
1
  import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
2
2
  export { ValidationError, eventIterator, type } from '@orpc/contract';
3
- import { P as Procedure, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.CMrS28Go.mjs';
4
- export { L as LAZY_SYMBOL, k as call, o as createAccessibleLazyRouter, b as createContractedProcedure, n as getHiddenRouterContract, j as getLazyMeta, m as middlewareOutputFn, r as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, p as unlazyRouter } from './shared/server.CMrS28Go.mjs';
3
+ import { P as Procedure, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.B_5ZADvP.mjs';
4
+ export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, b as createContractedProcedure, j as createORPCErrorConstructorMap, q as getHiddenRouterContract, k as getLazyMeta, n as isStartWithMiddlewares, o as mergeMiddlewares, m as middlewareOutputFn, w as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.B_5ZADvP.mjs';
5
5
  export { ORPCError, isDefinedError, safe } from '@orpc/client';
6
6
  export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
7
7
  export { getEventMeta, withEventMeta } from '@orpc/standard-server';
8
8
 
9
9
  const DEFAULT_CONFIG = {
10
10
  initialInputValidationIndex: 0,
11
- initialOutputValidationIndex: 0
11
+ initialOutputValidationIndex: 0,
12
+ dedupeLeadingMiddlewares: true
12
13
  };
13
14
  function fallbackConfig(key, value) {
14
15
  if (value === void 0) {
@@ -104,6 +105,7 @@ class Builder {
104
105
  return new Builder({
105
106
  ...this["~orpc"],
106
107
  config,
108
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares),
107
109
  inputValidationIndex: fallbackConfig("initialInputValidationIndex", config.initialInputValidationIndex) + inputValidationCount,
108
110
  outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config.initialOutputValidationIndex) + outputValidationCount
109
111
  });
@@ -217,10 +219,11 @@ const os = new Builder({
217
219
  errorMap: {},
218
220
  inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
219
221
  outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
220
- middlewares: []
222
+ middlewares: [],
223
+ dedupeLeadingMiddlewares: true
221
224
  });
222
225
 
223
- function mergeContext(context, other) {
226
+ function mergeCurrentContext(context, other) {
224
227
  return { ...context, ...other };
225
228
  }
226
229
 
@@ -231,7 +234,8 @@ function implementerInternal(contract, config, middlewares) {
231
234
  config,
232
235
  middlewares,
233
236
  inputValidationIndex: fallbackConfig("initialInputValidationIndex", config?.initialInputValidationIndex) + middlewares.length,
234
- outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length
237
+ outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length,
238
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
235
239
  });
236
240
  return impl2;
237
241
  }
@@ -257,7 +261,8 @@ function implementerInternal(contract, config, middlewares) {
257
261
  middlewares,
258
262
  errorMap: {},
259
263
  prefix: void 0,
260
- tags: void 0
264
+ tags: void 0,
265
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
261
266
  });
262
267
  return setHiddenRouterContract(adapted, contract);
263
268
  };
@@ -267,7 +272,8 @@ function implementerInternal(contract, config, middlewares) {
267
272
  middlewares,
268
273
  errorMap: {},
269
274
  prefix: void 0,
270
- tags: void 0
275
+ tags: void 0,
276
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
271
277
  });
272
278
  return setHiddenRouterContract(adapted, contract);
273
279
  };
@@ -300,17 +306,14 @@ function implement(contract, config = {}) {
300
306
  method = (config2) => implement(contract, config2);
301
307
  }
302
308
  const next = Reflect.get(target, key);
303
- if (!next || typeof next !== "function" && typeof next !== "object") {
304
- return method ?? next;
305
- }
306
- if (method) {
307
- return new Proxy(method, {
308
- get(_, key2) {
309
- return Reflect.get(next, key2);
310
- }
311
- });
309
+ if (!method || !next || typeof next !== "function" && typeof next !== "object") {
310
+ return method || next;
312
311
  }
313
- return next;
312
+ return new Proxy(method, {
313
+ get(_, key2) {
314
+ return Reflect.get(next, key2);
315
+ }
316
+ });
314
317
  }
315
318
  });
316
319
  return impl;
@@ -340,4 +343,4 @@ function createRouterClient(router, ...[options]) {
340
343
  return recursive;
341
344
  }
342
345
 
343
- export { Builder, DecoratedProcedure, Procedure, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, mergeContext, os, setHiddenRouterContract };
346
+ export { Builder, DecoratedProcedure, Procedure, addMiddleware, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, mergeCurrentContext, os, setHiddenRouterContract };
@@ -1,7 +1,7 @@
1
- import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CM3tWr3C.mjs';
2
- export { C as CompositePlugin } from '../shared/server.CM3tWr3C.mjs';
1
+ import { b as StandardHandlerInterceptorOptions, H as HandlerPlugin, a as StandardHandlerOptions } from '../shared/server.DpIMjOfC.mjs';
2
+ export { C as CompositePlugin } from '../shared/server.DpIMjOfC.mjs';
3
3
  import { Value } from '@orpc/shared';
4
- import { C as Context } from '../shared/server.CPteJIPP.mjs';
4
+ import { C as Context } from '../shared/server.DnmJuN02.mjs';
5
5
  import '@orpc/contract';
6
6
  import '@orpc/standard-server';
7
7
  import '@orpc/client';
@@ -1,7 +1,7 @@
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, H as HandlerPlugin, a as StandardHandlerOptions } from '../shared/server.Dj89-yLZ.js';
2
+ export { C as CompositePlugin } from '../shared/server.Dj89-yLZ.js';
3
3
  import { Value } from '@orpc/shared';
4
- import { C as Context } from '../shared/server.CPteJIPP.js';
4
+ import { C as Context } from '../shared/server.DnmJuN02.js';
5
5
  import '@orpc/contract';
6
6
  import '@orpc/standard-server';
7
7
  import '@orpc/client';
@@ -0,0 +1,8 @@
1
+ import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
+ import { C as Context } from './server.DnmJuN02.js';
3
+ import { a as StandardHandlerOptions } from './server.Dj89-yLZ.js';
4
+
5
+ interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
+ }
7
+
8
+ export type { StandardRPCHandlerOptions as S };
@@ -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) {
@@ -239,7 +256,7 @@ function enhanceRouter(router, options) {
239
256
  return accessible;
240
257
  }
241
258
  if (isProcedure(router)) {
242
- const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares);
259
+ const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, { dedupeLeading: options.dedupeLeadingMiddlewares });
243
260
  const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
244
261
  const enhanced2 = new Procedure({
245
262
  ...router["~orpc"],
@@ -343,4 +360,4 @@ function toHttpPath(path) {
343
360
  return `/${path.map(encodeURIComponent).join("/")}`;
344
361
  }
345
362
 
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 };
363
+ 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, createORPCErrorConstructorMap as j, getLazyMeta as k, lazy as l, middlewareOutputFn 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,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.DisswUB5.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.DnmJuN02.mjs';
3
+ import { a as StandardHandlerOptions } from './server.DpIMjOfC.mjs';
4
+
5
+ interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
+ }
7
+
8
+ export type { StandardRPCHandlerOptions as S };
@@ -1,7 +1,7 @@
1
1
  import { ORPCError, toORPCError } from '@orpc/client';
2
2
  import { intercept, trim, parseEmptyableJSON } from '@orpc/shared';
3
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';
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.B_5ZADvP.mjs';
5
5
 
6
6
  class StandardHandler {
7
7
  constructor(router, matcher, codec, options) {
@@ -69,7 +69,7 @@ class StandardHandler {
69
69
  }
70
70
  }
71
71
 
72
- class RPCCodec {
72
+ class StandardRPCCodec {
73
73
  constructor(serializer) {
74
74
  this.serializer = serializer;
75
75
  }
@@ -93,7 +93,7 @@ class RPCCodec {
93
93
  }
94
94
  }
95
95
 
96
- class RPCMatcher {
96
+ class StandardRPCMatcher {
97
97
  tree = {};
98
98
  pendingRouters = [];
99
99
  init(router, path = []) {
@@ -155,4 +155,4 @@ class RPCMatcher {
155
155
  }
156
156
  }
157
157
 
158
- export { RPCCodec as R, StandardHandler as S, RPCMatcher as a };
158
+ export { StandardHandler as S, StandardRPCCodec as a, StandardRPCMatcher as b };
@@ -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.DnmJuN02.js';
5
5
  import { ORPCError } from '@orpc/client';
6
6
 
7
7
  type StandardParams = Record<string, string>;
@@ -72,4 +72,4 @@ declare class CompositePlugin<TContext extends Context> implements HandlerPlugin
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 { CompositePlugin 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 };
@@ -1,19 +1,20 @@
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>;
9
+ type ContextExtendsGuard<T extends Context, U extends Context> = T extends T & U ? unknown : never;
11
10
 
12
11
  type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
12
  type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
13
  type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
14
  [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
16
15
  };
16
+ declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
17
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
17
18
 
18
19
  declare const LAZY_SYMBOL: unique symbol;
19
20
  interface LazyMeta {
@@ -51,7 +52,7 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutp
51
52
  }
52
53
  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
54
  __initialContext?: (type: TInitialContext) => unknown;
54
- middlewares: AnyMiddleware[];
55
+ middlewares: readonly AnyMiddleware[];
55
56
  inputValidationIndex: number;
56
57
  outputValidationIndex: number;
57
58
  handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
@@ -72,8 +73,8 @@ type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never>
72
73
  } : {
73
74
  context: TOutContext;
74
75
  };
75
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
76
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
76
+ interface MiddlewareNextFn<TOutput> {
77
+ <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
77
78
  }
78
79
  interface MiddlewareOutputFn<TOutput> {
79
80
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
@@ -84,7 +85,7 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
84
85
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
85
86
  signal?: AbortSignal;
86
87
  lastEventId: string | undefined;
87
- next: MiddlewareNextFn<TInContext, TOutput>;
88
+ next: MiddlewareNextFn<TOutput>;
88
89
  errors: TErrorConstructorMap;
89
90
  }
90
91
  interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
@@ -140,4 +141,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
140
141
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
141
142
  };
142
143
 
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 };
144
+ export { type AnyProcedure as A, type MiddlewareOptions as B, type Context as C, middlewareOutputFn as D, type ProcedureHandlerOptions as E, type ProcedureDef as F, isProcedure as G, createProcedureClient as H, type InferRouterInitialContext as I, type InferRouterInitialContexts as J, type InferRouterCurrentContexts as K, type Lazyable as L, type Middleware as M, type InferRouterInputs as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type InferRouterOutputs as Q, type Router as R, type AnyRouter as a, Procedure as b, type ContextExtendsGuard as c, type MergedCurrentContext as d, type MergedInitialContext as e, type MapInputMiddleware as f, type CreateProcedureClientOptions as g, type ProcedureClient as h, type AnyMiddleware as i, type Lazy as j, type ProcedureHandler as k, type ORPCErrorConstructorMapItemOptions as l, mergeCurrentContext as m, type ORPCErrorConstructorMapItem as n, createORPCErrorConstructorMap as o, LAZY_SYMBOL as p, type LazyMeta as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u, validateORPCError as v, type MiddlewareResult as w, type MiddlewareNextFnOptions as x, type MiddlewareNextFn as y, type MiddlewareOutputFn as z };
@@ -1,19 +1,20 @@
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>;
9
+ type ContextExtendsGuard<T extends Context, U extends Context> = T extends T & U ? unknown : never;
11
10
 
12
11
  type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
12
  type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
13
  type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
14
  [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
16
15
  };
16
+ declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
17
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
17
18
 
18
19
  declare const LAZY_SYMBOL: unique symbol;
19
20
  interface LazyMeta {
@@ -51,7 +52,7 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutp
51
52
  }
52
53
  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
54
  __initialContext?: (type: TInitialContext) => unknown;
54
- middlewares: AnyMiddleware[];
55
+ middlewares: readonly AnyMiddleware[];
55
56
  inputValidationIndex: number;
56
57
  outputValidationIndex: number;
57
58
  handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
@@ -72,8 +73,8 @@ type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never>
72
73
  } : {
73
74
  context: TOutContext;
74
75
  };
75
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
76
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
76
+ interface MiddlewareNextFn<TOutput> {
77
+ <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
77
78
  }
78
79
  interface MiddlewareOutputFn<TOutput> {
79
80
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
@@ -84,7 +85,7 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
84
85
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
85
86
  signal?: AbortSignal;
86
87
  lastEventId: string | undefined;
87
- next: MiddlewareNextFn<TInContext, TOutput>;
88
+ next: MiddlewareNextFn<TOutput>;
88
89
  errors: TErrorConstructorMap;
89
90
  }
90
91
  interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
@@ -140,4 +141,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
140
141
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
141
142
  };
142
143
 
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 };
144
+ export { type AnyProcedure as A, type MiddlewareOptions as B, type Context as C, middlewareOutputFn as D, type ProcedureHandlerOptions as E, type ProcedureDef as F, isProcedure as G, createProcedureClient as H, type InferRouterInitialContext as I, type InferRouterInitialContexts as J, type InferRouterCurrentContexts as K, type Lazyable as L, type Middleware as M, type InferRouterInputs as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type InferRouterOutputs as Q, type Router as R, type AnyRouter as a, Procedure as b, type ContextExtendsGuard as c, type MergedCurrentContext as d, type MergedInitialContext as e, type MapInputMiddleware as f, type CreateProcedureClientOptions as g, type ProcedureClient as h, type AnyMiddleware as i, type Lazy as j, type ProcedureHandler as k, type ORPCErrorConstructorMapItemOptions as l, mergeCurrentContext as m, type ORPCErrorConstructorMapItem as n, createORPCErrorConstructorMap as o, LAZY_SYMBOL as p, type LazyMeta as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u, validateORPCError as v, type MiddlewareResult as w, type MiddlewareNextFnOptions as x, type MiddlewareNextFn as y, type MiddlewareOutputFn 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.mjs';
4
+ import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.DnmJuN02.mjs';
5
5
  import { ORPCError } from '@orpc/client';
6
6
 
7
7
  type StandardParams = Record<string, string>;
@@ -72,4 +72,4 @@ declare class CompositePlugin<TContext extends Context> implements HandlerPlugin
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 { CompositePlugin 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.9b9ade5",
4
+ "version": "0.0.0-next.9fc14d1",
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/contract": "0.0.0-next.9b9ade5",
62
- "@orpc/client": "0.0.0-next.9b9ade5",
63
- "@orpc/shared": "0.0.0-next.9b9ade5",
64
- "@orpc/standard-server": "0.0.0-next.9b9ade5",
65
- "@orpc/standard-server-fetch": "0.0.0-next.9b9ade5",
66
- "@orpc/standard-server-node": "0.0.0-next.9b9ade5"
61
+ "@orpc/contract": "0.0.0-next.9fc14d1",
62
+ "@orpc/shared": "0.0.0-next.9fc14d1",
63
+ "@orpc/standard-server-fetch": "0.0.0-next.9fc14d1",
64
+ "@orpc/client": "0.0.0-next.9fc14d1",
65
+ "@orpc/standard-server": "0.0.0-next.9fc14d1",
66
+ "@orpc/standard-server-node": "0.0.0-next.9fc14d1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "light-my-request": "^6.5.1"