@orpc/server 0.0.0-next.f99e554 → 0.0.0-next.fe39bf3

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 (71) hide show
  1. package/dist/chunk-KPT6FDBK.js +32 -0
  2. package/dist/chunk-LXOL226G.js +182 -0
  3. package/dist/chunk-MHVECKBC.js +421 -0
  4. package/dist/chunk-XI6WGCB3.js +125 -0
  5. package/dist/fetch.js +6 -28
  6. package/dist/hono.js +34 -0
  7. package/dist/index.js +280 -385
  8. package/dist/next.js +31 -0
  9. package/dist/node.js +22 -36
  10. package/dist/plugins.js +11 -0
  11. package/dist/src/adapters/fetch/index.d.ts +1 -5
  12. package/dist/src/adapters/fetch/rpc-handler.d.ts +11 -0
  13. package/dist/src/adapters/fetch/types.d.ts +11 -13
  14. package/dist/src/adapters/hono/index.d.ts +3 -0
  15. package/dist/src/adapters/hono/middleware.d.ts +12 -0
  16. package/dist/src/adapters/next/index.d.ts +3 -0
  17. package/dist/src/adapters/next/serve.d.ts +19 -0
  18. package/dist/src/adapters/node/index.d.ts +1 -3
  19. package/dist/src/adapters/node/rpc-handler.d.ts +11 -0
  20. package/dist/src/adapters/node/types.d.ts +18 -17
  21. package/dist/src/adapters/standard/handler.d.ts +51 -0
  22. package/dist/src/adapters/standard/index.d.ts +6 -0
  23. package/dist/src/adapters/standard/rpc-codec.d.ts +16 -0
  24. package/dist/src/adapters/standard/rpc-handler.d.ts +8 -0
  25. package/dist/src/adapters/standard/rpc-matcher.d.ts +10 -0
  26. package/dist/src/adapters/standard/types.d.ts +21 -0
  27. package/dist/src/builder-variants.d.ts +75 -0
  28. package/dist/src/builder.d.ts +53 -30
  29. package/dist/src/config.d.ts +6 -0
  30. package/dist/src/context.d.ts +8 -0
  31. package/dist/src/error.d.ts +12 -0
  32. package/dist/src/hidden.d.ts +6 -4
  33. package/dist/src/implementer-procedure.d.ts +33 -0
  34. package/dist/src/implementer-variants.d.ts +18 -0
  35. package/dist/src/implementer.d.ts +29 -0
  36. package/dist/src/index.d.ts +13 -11
  37. package/dist/src/lazy-utils.d.ts +4 -2
  38. package/dist/src/lazy.d.ts +9 -5
  39. package/dist/src/middleware-decorated.d.ts +8 -5
  40. package/dist/src/middleware-utils.d.ts +5 -0
  41. package/dist/src/middleware.d.ts +30 -15
  42. package/dist/src/plugins/base.d.ts +13 -0
  43. package/dist/src/plugins/cors.d.ts +19 -0
  44. package/dist/src/plugins/index.d.ts +4 -0
  45. package/dist/src/plugins/response-headers.d.ts +10 -0
  46. package/dist/src/procedure-client.d.ts +22 -23
  47. package/dist/src/procedure-decorated.d.ts +21 -11
  48. package/dist/src/procedure-utils.d.ts +19 -0
  49. package/dist/src/procedure.d.ts +26 -18
  50. package/dist/src/router-accessible-lazy.d.ts +8 -0
  51. package/dist/src/router-client.d.ts +8 -21
  52. package/dist/src/router.d.ts +26 -12
  53. package/dist/src/utils.d.ts +23 -2
  54. package/dist/standard.js +13 -0
  55. package/package.json +33 -6
  56. package/dist/chunk-6A7XHEBH.js +0 -189
  57. package/dist/chunk-B2EZJB7X.js +0 -303
  58. package/dist/src/adapters/fetch/composite-handler.d.ts +0 -8
  59. package/dist/src/adapters/fetch/orpc-handler.d.ts +0 -20
  60. package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +0 -16
  61. package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +0 -12
  62. package/dist/src/adapters/fetch/super-json.d.ts +0 -12
  63. package/dist/src/adapters/node/composite-handler.d.ts +0 -9
  64. package/dist/src/adapters/node/orpc-handler.d.ts +0 -12
  65. package/dist/src/implementer-chainable.d.ts +0 -10
  66. package/dist/src/lazy-decorated.d.ts +0 -10
  67. package/dist/src/procedure-builder.d.ts +0 -22
  68. package/dist/src/procedure-implementer.d.ts +0 -18
  69. package/dist/src/router-builder.d.ts +0 -29
  70. package/dist/src/router-implementer.d.ts +0 -21
  71. package/dist/src/types.d.ts +0 -12
package/dist/next.js ADDED
@@ -0,0 +1,31 @@
1
+ import {
2
+ RPCHandler
3
+ } from "./chunk-KPT6FDBK.js";
4
+ import "./chunk-LXOL226G.js";
5
+ import "./chunk-MHVECKBC.js";
6
+ import "./chunk-XI6WGCB3.js";
7
+
8
+ // src/adapters/next/serve.ts
9
+ import { value } from "@orpc/shared";
10
+ function serve(handler, ...[options]) {
11
+ const main = async (req) => {
12
+ const context = await value(options?.context ?? {}, req);
13
+ const { matched, response } = await handler.handle(req, { ...options, context });
14
+ if (matched) {
15
+ return response;
16
+ }
17
+ return new Response(`Cannot find a matching procedure for ${req.url}`, { status: 404 });
18
+ };
19
+ return {
20
+ GET: main,
21
+ POST: main,
22
+ PUT: main,
23
+ PATCH: main,
24
+ DELETE: main
25
+ };
26
+ }
27
+ export {
28
+ RPCHandler,
29
+ serve
30
+ };
31
+ //# sourceMappingURL=next.js.map
package/dist/node.js CHANGED
@@ -1,45 +1,31 @@
1
1
  import {
2
- ORPCHandler
3
- } from "./chunk-B2EZJB7X.js";
4
- import "./chunk-6A7XHEBH.js";
2
+ RPCCodec,
3
+ RPCMatcher,
4
+ StandardHandler
5
+ } from "./chunk-LXOL226G.js";
6
+ import "./chunk-MHVECKBC.js";
7
+ import "./chunk-XI6WGCB3.js";
5
8
 
6
- // src/adapters/node/composite-handler.ts
7
- var CompositeHandler = class {
8
- constructor(handlers) {
9
- this.handlers = handlers;
10
- }
11
- async handle(req, res, ...opt) {
12
- for (const handler of this.handlers) {
13
- if (handler.condition(req)) {
14
- return handler.handle(req, res, ...opt);
15
- }
16
- }
17
- res.statusCode = 404;
18
- res.end("None of the handlers can handle the request.");
19
- }
20
- };
21
-
22
- // src/adapters/node/orpc-handler.ts
23
- import { createRequest, sendResponse } from "@mjackson/node-fetch-server";
24
- import { ORPC_HANDLER_HEADER, ORPC_HANDLER_VALUE } from "@orpc/shared";
25
- var ORPCHandler2 = class {
26
- orpcFetchHandler;
9
+ // src/adapters/node/rpc-handler.ts
10
+ import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
11
+ var RPCHandler = class {
12
+ standardHandler;
27
13
  constructor(router, options) {
28
- this.orpcFetchHandler = new ORPCHandler(router, options);
29
- }
30
- condition(request) {
31
- return Boolean(request.headers[ORPC_HANDLER_HEADER]?.includes(ORPC_HANDLER_VALUE));
14
+ const codec = options?.codec ?? new RPCCodec();
15
+ const matcher = options?.matcher ?? new RPCMatcher();
16
+ this.standardHandler = new StandardHandler(router, matcher, codec, options);
32
17
  }
33
- async handle(req, res, ...[options]) {
34
- const request = createRequest(req, res, options);
35
- const castedOptions = options ?? {};
36
- const response = await this.orpcFetchHandler.fetch(request, castedOptions);
37
- await options?.beforeSend?.(response, castedOptions.context);
38
- return await sendResponse(res, response);
18
+ async handle(req, res, ...rest) {
19
+ const standardRequest = toStandardRequest(req, res);
20
+ const result = await this.standardHandler.handle(standardRequest, ...rest);
21
+ if (!result.matched) {
22
+ return { matched: false };
23
+ }
24
+ await sendStandardResponse(res, result.response);
25
+ return { matched: true };
39
26
  }
40
27
  };
41
28
  export {
42
- CompositeHandler,
43
- ORPCHandler2 as ORPCHandler
29
+ RPCHandler
44
30
  };
45
31
  //# sourceMappingURL=node.js.map
@@ -0,0 +1,11 @@
1
+ import {
2
+ CORSPlugin,
3
+ CompositePlugin,
4
+ ResponseHeadersPlugin
5
+ } from "./chunk-XI6WGCB3.js";
6
+ export {
7
+ CORSPlugin,
8
+ CompositePlugin,
9
+ ResponseHeadersPlugin
10
+ };
11
+ //# sourceMappingURL=plugins.js.map
@@ -1,7 +1,3 @@
1
- export * from './composite-handler';
2
- export * from './orpc-handler';
3
- export * from './orpc-payload-codec';
4
- export * from './orpc-procedure-matcher';
5
- export * as SuperJSON from './super-json';
1
+ export * from './rpc-handler';
6
2
  export * from './types';
7
3
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { MaybeOptionalOptions } from '@orpc/shared';
2
+ import type { Context } from '../../context';
3
+ import type { Router } from '../../router';
4
+ import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
5
+ import type { FetchHandler, FetchHandleResult } from './types';
6
+ export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
7
+ private readonly standardHandler;
8
+ constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
9
+ handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
10
+ }
11
+ //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,16 +1,14 @@
1
- import type { HTTPPath } from '@orpc/contract';
2
- import type { Context, WithSignal } from '../../types';
3
- export type FetchOptions<T extends Context> = WithSignal & {
4
- prefix?: HTTPPath;
5
- } & (undefined extends T ? {
6
- context?: T;
7
- } : {
8
- context: T;
9
- });
1
+ import type { MaybeOptionalOptions } from '@orpc/shared';
2
+ import type { Context } from '../../context';
3
+ import type { StandardHandleOptions } from '../standard';
4
+ export type FetchHandleResult = {
5
+ matched: true;
6
+ response: Response;
7
+ } | {
8
+ matched: false;
9
+ response: undefined;
10
+ };
10
11
  export interface FetchHandler<T extends Context> {
11
- fetch: (request: Request, ...opt: [options: FetchOptions<T>] | (undefined extends T ? [] : never)) => Promise<Response>;
12
- }
13
- export interface ConditionalFetchHandler<T extends Context> extends FetchHandler<T> {
14
- condition: (request: Request) => boolean;
12
+ handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
15
13
  }
16
14
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from '../fetch';
2
+ export * from './middleware';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { MaybeOptionalOptions, Value } from '@orpc/shared';
2
+ import type { Context as HonoContext, MiddlewareHandler } from 'hono';
3
+ import type { Context } from '../../context';
4
+ import type { FetchHandler } from '../fetch';
5
+ import type { StandardHandleOptions } from '../standard';
6
+ export type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
7
+ context?: Value<T, [HonoContext]>;
8
+ } : {
9
+ context: Value<T, [HonoContext]>;
10
+ });
11
+ export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
12
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from '../fetch';
2
+ export * from './serve';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { MaybeOptionalOptions, Value } from '@orpc/shared';
2
+ import type { NextRequest } from 'next/server';
3
+ import type { Context } from '../../context';
4
+ import type { FetchHandler } from '../fetch';
5
+ import type { StandardHandleOptions } from '../standard';
6
+ export type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
7
+ context?: Value<T, [NextRequest]>;
8
+ } : {
9
+ context: Value<T, [NextRequest]>;
10
+ });
11
+ export interface ServeResult {
12
+ GET(req: NextRequest): Promise<Response>;
13
+ POST(req: NextRequest): Promise<Response>;
14
+ PUT(req: NextRequest): Promise<Response>;
15
+ PATCH(req: NextRequest): Promise<Response>;
16
+ DELETE(req: NextRequest): Promise<Response>;
17
+ }
18
+ export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
19
+ //# sourceMappingURL=serve.d.ts.map
@@ -1,5 +1,3 @@
1
- export * from './composite-handler';
2
- export * from './orpc-handler';
3
- export * from './orpc-handler';
1
+ export * from './rpc-handler';
4
2
  export * from './types';
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { MaybeOptionalOptions } from '@orpc/shared';
2
+ import type { Context } from '../../context';
3
+ import type { Router } from '../../router';
4
+ import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
5
+ import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
6
+ export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
7
+ private readonly standardHandler;
8
+ constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
9
+ handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
10
+ }
11
+ //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,21 +1,22 @@
1
- import type { RequestOptions as BaseRequestOptions } from '@mjackson/node-fetch-server';
2
- import type { HTTPPath } from '@orpc/contract';
3
- import type { Promisable } from '@orpc/shared';
1
+ import type { MaybeOptionalOptions } from '@orpc/shared';
4
2
  import type { IncomingMessage, ServerResponse } from 'node:http';
5
- import type { Context, WithSignal } from '../../types';
6
- export type RequestOptions<T extends Context> = BaseRequestOptions & WithSignal & {
7
- prefix?: HTTPPath;
8
- } & (undefined extends T ? {
9
- context?: T;
10
- } : {
11
- context: T;
12
- }) & {
13
- beforeSend?: (response: Response, context: T) => Promisable<void>;
3
+ import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
4
+ import type { Context } from '../../context';
5
+ import type { StandardHandleOptions } from '../standard';
6
+ export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
7
+ /**
8
+ * Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
9
+ * This is useful for `express.js` middleware.
10
+ */
11
+ originalUrl?: string;
14
12
  };
15
- export interface RequestHandler<T extends Context> {
16
- handle: (req: IncomingMessage, res: ServerResponse, ...opt: [options: RequestOptions<T>] | (undefined extends T ? [] : never)) => void;
17
- }
18
- export interface ConditionalRequestHandler<T extends Context> extends RequestHandler<T> {
19
- condition: (request: IncomingMessage) => boolean;
13
+ export type NodeHttpResponse = ServerResponse | Http2ServerResponse;
14
+ export type NodeHttpHandleResult = {
15
+ matched: true;
16
+ } | {
17
+ matched: false;
18
+ };
19
+ export interface NodeHttpHandler<T extends Context> {
20
+ handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
20
21
  }
21
22
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,51 @@
1
+ import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
2
+ import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
3
+ import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
+ import type { Context } from '../../context';
5
+ import type { Plugin } from '../../plugins';
6
+ import type { CreateProcedureClientOptions } from '../../procedure-client';
7
+ import type { Router } from '../../router';
8
+ import type { StandardCodec, StandardMatcher } from './types';
9
+ export type StandardHandleOptions<T extends Context> = {
10
+ prefix?: HTTPPath;
11
+ } & (Record<never, never> extends T ? {
12
+ context?: T;
13
+ } : {
14
+ context: T;
15
+ });
16
+ export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
17
+ context: T;
18
+ };
19
+ export type StandardHandleResult = {
20
+ matched: true;
21
+ response: StandardResponse;
22
+ } | {
23
+ matched: false;
24
+ response: undefined;
25
+ };
26
+ export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
27
+ request: StandardRequest;
28
+ };
29
+ export type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, Record<never, never>> & {
30
+ context: TContext;
31
+ };
32
+ export interface StandardHandlerOptions<TContext extends Context> {
33
+ plugins?: Plugin<TContext>[];
34
+ /**
35
+ * Interceptors at the request level, helpful when you want catch errors
36
+ */
37
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
38
+ /**
39
+ * Interceptors at the root level, helpful when you want override the response
40
+ */
41
+ interceptorsRoot?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
42
+ }
43
+ export declare class StandardHandler<T extends Context> {
44
+ private readonly matcher;
45
+ private readonly codec;
46
+ private readonly options;
47
+ private readonly plugin;
48
+ constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
49
+ handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
50
+ }
51
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from './handler';
2
+ export * from './rpc-codec';
3
+ export * from './rpc-handler';
4
+ export * from './rpc-matcher';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { ORPCError } from '@orpc/client';
2
+ import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
3
+ import type { AnyProcedure } from '../../procedure';
4
+ import type { StandardCodec, StandardParams } from './types';
5
+ import { RPCSerializer } from '@orpc/client/rpc';
6
+ export interface StandardCodecOptions {
7
+ serializer?: RPCSerializer;
8
+ }
9
+ export declare class RPCCodec implements StandardCodec {
10
+ private readonly serializer;
11
+ constructor(options?: StandardCodecOptions);
12
+ decode(request: StandardRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
13
+ encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
14
+ encodeError(error: ORPCError<any, any>): StandardResponse;
15
+ }
16
+ //# sourceMappingURL=rpc-codec.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { Context } from '../../context';
2
+ import type { StandardHandlerOptions } from './handler';
3
+ import type { StandardCodec, StandardMatcher } from './types';
4
+ export interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T> {
5
+ matcher?: StandardMatcher;
6
+ codec?: StandardCodec;
7
+ }
8
+ //# sourceMappingURL=rpc-handler.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { HTTPPath } from '@orpc/contract';
2
+ import type { StandardMatcher, StandardMatchResult } from './types';
3
+ import { type AnyRouter } from '../../router';
4
+ export declare class RPCMatcher implements StandardMatcher {
5
+ private readonly tree;
6
+ private pendingRouters;
7
+ init(router: AnyRouter, path?: string[]): void;
8
+ match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
9
+ }
10
+ //# sourceMappingURL=rpc-matcher.d.ts.map
@@ -0,0 +1,21 @@
1
+ import type { ORPCError } from '@orpc/client';
2
+ import type { HTTPPath } from '@orpc/contract';
3
+ import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
4
+ import type { AnyProcedure } from '../../procedure';
5
+ import type { AnyRouter } from '../../router';
6
+ export type StandardParams = Record<string, string>;
7
+ export type StandardMatchResult = {
8
+ path: string[];
9
+ procedure: AnyProcedure;
10
+ params?: StandardParams;
11
+ } | undefined;
12
+ export interface StandardMatcher {
13
+ init(router: AnyRouter): void;
14
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
15
+ }
16
+ export interface StandardCodec {
17
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
18
+ encodeError(error: ORPCError<any, any>): StandardResponse;
19
+ decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,75 @@
1
+ import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
+ import type { BuilderDef } from './builder';
3
+ import type { ConflictContextGuard, Context, MergedContext } from './context';
4
+ import type { ORPCErrorConstructorMap } from './error';
5
+ import type { FlattenLazy } from './lazy-utils';
6
+ import type { MapInputMiddleware, Middleware } from './middleware';
7
+ import type { ProcedureHandler } from './procedure';
8
+ import type { DecoratedProcedure } from './procedure-decorated';
9
+ import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
10
+ export interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
11
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
12
+ 'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
13
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
14
+ 'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
15
+ 'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
16
+ 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
17
+ 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
18
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
19
+ 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
20
+ 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
21
+ 'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
22
+ 'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
23
+ default: U;
24
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
25
+ }
26
+ export interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
27
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
28
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
29
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
30
+ 'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
31
+ 'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
32
+ 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
33
+ 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
34
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
35
+ }
36
+ export interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
37
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
38
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
39
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
40
+ 'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
41
+ 'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
42
+ 'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
43
+ 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
44
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
45
+ }
46
+ export interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
47
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
48
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
49
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
50
+ 'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
51
+ 'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
52
+ 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
53
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
54
+ }
55
+ export interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
56
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
57
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
58
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
59
+ 'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
60
+ 'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
61
+ 'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
62
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
63
+ }
64
+ export interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
65
+ '~orpc': AdaptRouterOptions<TErrorMap>;
66
+ 'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
67
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & RouterBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
68
+ 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
69
+ 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
70
+ 'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
71
+ 'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
72
+ default: U;
73
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
74
+ }
75
+ //# sourceMappingURL=builder-variants.d.ts.map
@@ -1,35 +1,58 @@
1
- import type { ANY_CONTRACT_PROCEDURE, ContractRouter, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { FlattenLazy } from './lazy';
3
- import type { Middleware } from './middleware';
1
+ import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
+ import type { BuilderWithMiddlewares, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithOutput, RouterBuilder } from './builder-variants';
3
+ import type { ConflictContextGuard, Context, MergedContext } from './context';
4
+ import type { ORPCErrorConstructorMap } from './error';
5
+ import type { FlattenLazy } from './lazy-utils';
6
+ import type { AnyMiddleware, MapInputMiddleware, Middleware } from './middleware';
4
7
  import type { DecoratedMiddleware } from './middleware-decorated';
5
- import type { Router } from './router';
6
- import type { AdaptedRouter } from './router-builder';
7
- import type { Context, MergeContext, WELL_CONTEXT } from './types';
8
- import { type ChainableImplementer } from './implementer-chainable';
9
- import { type ProcedureFunc } from './procedure';
10
- import { ProcedureBuilder } from './procedure-builder';
11
- import { type DecoratedProcedure } from './procedure-decorated';
12
- import { RouterBuilder } from './router-builder';
13
- export interface BuilderDef<TContext extends Context, TExtraContext extends Context> {
14
- middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[];
8
+ import type { ProcedureHandler } from './procedure';
9
+ import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
10
+ import { DecoratedProcedure } from './procedure-decorated';
11
+ export interface BuilderConfig {
12
+ initialInputValidationIndex?: number;
13
+ initialOutputValidationIndex?: number;
15
14
  }
16
- export declare class Builder<TContext extends Context, TExtraContext extends Context> {
17
- '~type': "Builder";
18
- '~orpc': BuilderDef<TContext, TExtraContext>;
19
- constructor(def: BuilderDef<TContext, TExtraContext>);
20
- context<UContext extends Context = WELL_CONTEXT>(): Builder<UContext, undefined>;
21
- use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown>): Builder<TContext, MergeContext<TExtraContext, U>>;
22
- middleware<UExtraContext extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, TInput = unknown, TOutput = any>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>): DecoratedMiddleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>;
23
- route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, undefined, undefined>;
24
- input<USchema extends Schema = undefined>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilder<TContext, TExtraContext, USchema, undefined>;
25
- output<USchema extends Schema = undefined>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilder<TContext, TExtraContext, undefined, USchema>;
26
- handler<UFuncOutput = undefined>(handler: ProcedureFunc<TContext, TExtraContext, undefined, undefined, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput>;
27
- prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
28
- tag(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
29
- router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U>;
30
- lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
15
+ export interface BuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptRouterOptions<TErrorMap> {
16
+ middlewares: AnyMiddleware[];
17
+ inputValidationIndex: number;
18
+ outputValidationIndex: number;
19
+ config: BuilderConfig;
20
+ }
21
+ export declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
22
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
23
+ constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
24
+ /**
25
+ * Reset config
26
+ */
27
+ $config(config: BuilderConfig): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
28
+ /**
29
+ * Reset initial context
30
+ */
31
+ $context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
32
+ /**
33
+ * Reset initial meta
34
+ */
35
+ $meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U>;
36
+ /**
37
+ * Reset initial route
38
+ */
39
+ $route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
40
+ middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
41
+ middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
42
+ errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
43
+ use<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
44
+ use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
+ meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
46
+ route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
47
+ input<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
48
+ output<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
49
+ handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
50
+ prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
51
+ tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
52
+ router<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
53
+ lazy<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
31
54
  default: U;
32
- }>): AdaptedRouter<TContext, FlattenLazy<U>>;
33
- contract<U extends ANY_CONTRACT_PROCEDURE | ContractRouter>(contract: U): ChainableImplementer<TContext, TExtraContext, U>;
55
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
34
56
  }
57
+ export declare const os: Builder<Context, Context, undefined, undefined, {}, {}>;
35
58
  //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1,6 @@
1
+ export interface Config {
2
+ initialInputValidationIndex: number;
3
+ initialOutputValidationIndex: number;
4
+ }
5
+ export declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T]): Config[T];
6
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { IsNever } from '@orpc/shared';
2
+ export type Context = Record<string, any>;
3
+ export type MergedContext<T extends Context, U extends Context> = T & U;
4
+ export declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
5
+ export type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
6
+ [K in keyof T]: IsNever<T[K]>;
7
+ }[keyof T] ? never : unknown;
8
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { ORPCErrorCode, ORPCErrorOptions } from '@orpc/client';
2
+ import type { ErrorMap, ErrorMapItem, SchemaInput } from '@orpc/contract';
3
+ import type { MaybeOptionalOptions } from '@orpc/shared';
4
+ import { ORPCError } from '@orpc/client';
5
+ export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
6
+ export type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
7
+ export type ORPCErrorConstructorMap<T extends ErrorMap> = {
8
+ [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, SchemaInput<UInputSchema>> : never : never;
9
+ };
10
+ export declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
11
+ export declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
12
+ //# sourceMappingURL=error.d.ts.map
@@ -1,6 +1,8 @@
1
- import type { ContractRouter, HTTPPath } from '@orpc/contract';
2
- export declare function setRouterContract<T extends object>(obj: T, contract: ContractRouter): T;
3
- export declare function getRouterContract(obj: object): ContractRouter | undefined;
4
- export declare function deepSetLazyRouterPrefix<T extends object>(router: T, prefix: HTTPPath): T;
1
+ import type { AnyContractRouter, ContractRouter, HTTPPath } from '@orpc/contract';
2
+ import type { Lazy } from './lazy';
3
+ import type { AnyRouter } from './router';
4
+ export declare function setRouterContract<T extends AnyRouter>(obj: T, contract: AnyContractRouter): T;
5
+ export declare function getRouterContract(obj: object): ContractRouter<any> | undefined;
6
+ export declare function deepSetLazyRouterPrefix<T extends Lazy<any>>(router: T, prefix: HTTPPath): T;
5
7
  export declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
6
8
  //# sourceMappingURL=hidden.d.ts.map