@orpc/server 0.0.0-next.b15d206 → 0.0.0-next.bc564a6

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 (100) hide show
  1. package/dist/chunk-ESTRJAOX.js +299 -0
  2. package/dist/chunk-KK4SDLC7.js +320 -0
  3. package/dist/chunk-WUOGVGWG.js +1 -0
  4. package/dist/fetch.js +12 -678
  5. package/dist/hono.js +30 -0
  6. package/dist/index.js +319 -322
  7. package/dist/next.js +36 -0
  8. package/dist/node.js +87 -0
  9. package/dist/src/adapters/fetch/index.d.ts +6 -0
  10. package/dist/src/adapters/fetch/orpc-handler.d.ts +20 -0
  11. package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +16 -0
  12. package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +12 -0
  13. package/dist/src/adapters/fetch/super-json.d.ts +12 -0
  14. package/dist/src/adapters/fetch/types.d.ts +21 -0
  15. package/dist/src/adapters/hono/index.d.ts +3 -0
  16. package/dist/src/adapters/hono/middleware.d.ts +12 -0
  17. package/dist/src/adapters/next/index.d.ts +3 -0
  18. package/dist/src/adapters/next/serve.d.ts +19 -0
  19. package/dist/src/adapters/node/index.d.ts +5 -0
  20. package/dist/src/adapters/node/orpc-handler.d.ts +12 -0
  21. package/dist/src/adapters/node/request-listener.d.ts +28 -0
  22. package/dist/src/adapters/node/types.d.ts +22 -0
  23. package/dist/src/builder-variants.d.ts +74 -0
  24. package/dist/src/builder.d.ts +47 -39
  25. package/dist/src/config.d.ts +6 -0
  26. package/dist/src/context.d.ts +9 -0
  27. package/dist/src/hidden.d.ts +8 -0
  28. package/dist/src/implementer-procedure.d.ts +30 -0
  29. package/dist/src/implementer-variants.d.ts +16 -0
  30. package/dist/src/implementer.d.ts +27 -0
  31. package/dist/src/index.d.ts +16 -10
  32. package/dist/src/lazy-utils.d.ts +6 -0
  33. package/dist/src/lazy.d.ts +22 -0
  34. package/dist/src/middleware-decorated.d.ts +10 -0
  35. package/dist/src/middleware-utils.d.ts +5 -0
  36. package/dist/src/middleware.d.ts +28 -17
  37. package/dist/src/procedure-client.d.ts +20 -0
  38. package/dist/src/procedure-decorated.d.ts +21 -0
  39. package/dist/src/procedure-utils.d.ts +17 -0
  40. package/dist/src/procedure.d.ts +25 -25
  41. package/dist/src/router-accessible-lazy.d.ts +8 -0
  42. package/dist/src/router-client.d.ts +22 -0
  43. package/dist/src/router.d.ts +25 -16
  44. package/package.json +29 -21
  45. package/dist/chunk-TDFYNRZV.js +0 -190
  46. package/dist/chunk-TDFYNRZV.js.map +0 -1
  47. package/dist/fetch.js.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/src/adapters/fetch.d.ts +0 -42
  50. package/dist/src/adapters/fetch.d.ts.map +0 -1
  51. package/dist/src/builder.d.ts.map +0 -1
  52. package/dist/src/index.d.ts.map +0 -1
  53. package/dist/src/middleware.d.ts.map +0 -1
  54. package/dist/src/procedure-builder.d.ts +0 -31
  55. package/dist/src/procedure-builder.d.ts.map +0 -1
  56. package/dist/src/procedure-caller.d.ts +0 -19
  57. package/dist/src/procedure-caller.d.ts.map +0 -1
  58. package/dist/src/procedure-implementer.d.ts +0 -18
  59. package/dist/src/procedure-implementer.d.ts.map +0 -1
  60. package/dist/src/procedure.d.ts.map +0 -1
  61. package/dist/src/router-builder.d.ts +0 -22
  62. package/dist/src/router-builder.d.ts.map +0 -1
  63. package/dist/src/router-caller.d.ts +0 -22
  64. package/dist/src/router-caller.d.ts.map +0 -1
  65. package/dist/src/router-implementer.d.ts +0 -20
  66. package/dist/src/router-implementer.d.ts.map +0 -1
  67. package/dist/src/router.d.ts.map +0 -1
  68. package/dist/src/types.d.ts +0 -8
  69. package/dist/src/types.d.ts.map +0 -1
  70. package/dist/src/utils.d.ts +0 -3
  71. package/dist/src/utils.d.ts.map +0 -1
  72. package/dist/tsconfig.tsbuildinfo +0 -1
  73. package/src/adapters/fetch.test.ts +0 -629
  74. package/src/adapters/fetch.ts +0 -290
  75. package/src/builder.test.ts +0 -371
  76. package/src/builder.ts +0 -238
  77. package/src/index.ts +0 -16
  78. package/src/middleware.test.ts +0 -260
  79. package/src/middleware.ts +0 -136
  80. package/src/procedure-builder.test.ts +0 -223
  81. package/src/procedure-builder.ts +0 -158
  82. package/src/procedure-caller.test.ts +0 -171
  83. package/src/procedure-caller.ts +0 -138
  84. package/src/procedure-implementer.test.ts +0 -220
  85. package/src/procedure-implementer.ts +0 -102
  86. package/src/procedure.test.ts +0 -317
  87. package/src/procedure.ts +0 -237
  88. package/src/router-builder.test.ts +0 -106
  89. package/src/router-builder.ts +0 -122
  90. package/src/router-caller.test.ts +0 -126
  91. package/src/router-caller.ts +0 -64
  92. package/src/router-implementer.test.ts +0 -116
  93. package/src/router-implementer.ts +0 -113
  94. package/src/router.test-d.ts +0 -48
  95. package/src/router.test.ts +0 -142
  96. package/src/router.ts +0 -91
  97. package/src/types.test.ts +0 -18
  98. package/src/types.ts +0 -13
  99. package/src/utils.test.ts +0 -16
  100. package/src/utils.ts +0 -16
package/dist/next.js ADDED
@@ -0,0 +1,36 @@
1
+ import "./chunk-WUOGVGWG.js";
2
+ import {
3
+ ORPCPayloadCodec,
4
+ ORPCProcedureMatcher,
5
+ RPCHandler,
6
+ super_json_exports
7
+ } from "./chunk-ESTRJAOX.js";
8
+ import "./chunk-KK4SDLC7.js";
9
+
10
+ // src/adapters/next/serve.ts
11
+ import { value } from "@orpc/shared";
12
+ function serve(handler, ...[options]) {
13
+ const main = async (req) => {
14
+ const context = await value(options?.context ?? {}, req);
15
+ const { matched, response } = await handler.handle(req, { ...options, context });
16
+ if (matched) {
17
+ return response;
18
+ }
19
+ return new Response(`Cannot find a matching procedure for ${req.url}`, { status: 404 });
20
+ };
21
+ return {
22
+ GET: main,
23
+ POST: main,
24
+ PUT: main,
25
+ PATCH: main,
26
+ DELETE: main
27
+ };
28
+ }
29
+ export {
30
+ ORPCPayloadCodec,
31
+ ORPCProcedureMatcher,
32
+ RPCHandler,
33
+ super_json_exports as SuperJSON,
34
+ serve
35
+ };
36
+ //# sourceMappingURL=next.js.map
package/dist/node.js ADDED
@@ -0,0 +1,87 @@
1
+ import {
2
+ RPCHandler
3
+ } from "./chunk-ESTRJAOX.js";
4
+ import "./chunk-KK4SDLC7.js";
5
+
6
+ // src/adapters/node/request-listener.ts
7
+ function createRequest(req, res) {
8
+ const controller = new AbortController();
9
+ res.on("close", () => {
10
+ controller.abort();
11
+ });
12
+ const method = req.method ?? "GET";
13
+ const headers = createHeaders(req);
14
+ const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
15
+ const host = headers.get("Host") ?? "localhost";
16
+ const url = new URL(req.originalUrl ?? req.url ?? "/", `${protocol}//${host}`);
17
+ const init = { method, headers, signal: controller.signal };
18
+ if (method !== "GET" && method !== "HEAD") {
19
+ init.body = new ReadableStream({
20
+ start(controller2) {
21
+ req.on("data", (chunk) => {
22
+ controller2.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
23
+ });
24
+ req.on("end", () => {
25
+ controller2.close();
26
+ });
27
+ }
28
+ });
29
+ init.duplex = "half";
30
+ }
31
+ return new Request(url, init);
32
+ }
33
+ function createHeaders(req) {
34
+ const headers = new Headers();
35
+ const rawHeaders = req.rawHeaders;
36
+ for (let i = 0; i < rawHeaders.length; i += 2) {
37
+ headers.append(rawHeaders[i], rawHeaders[i + 1]);
38
+ }
39
+ return headers;
40
+ }
41
+ async function sendResponse(res, response) {
42
+ const headers = {};
43
+ for (const [key, value] of response.headers) {
44
+ if (key in headers) {
45
+ if (Array.isArray(headers[key])) {
46
+ headers[key].push(value);
47
+ } else {
48
+ headers[key] = [headers[key], value];
49
+ }
50
+ } else {
51
+ headers[key] = value;
52
+ }
53
+ }
54
+ res.writeHead(response.status, headers);
55
+ if (response.body != null && res.req.method !== "HEAD") {
56
+ for await (const chunk of response.body) {
57
+ res.write(chunk);
58
+ }
59
+ }
60
+ res.end();
61
+ }
62
+
63
+ // src/adapters/node/orpc-handler.ts
64
+ var RPCHandler2 = class {
65
+ orpcFetchHandler;
66
+ constructor(router, options) {
67
+ this.orpcFetchHandler = new RPCHandler(router, options);
68
+ }
69
+ async handle(req, res, ...rest) {
70
+ const request = createRequest(req, res);
71
+ const result = await this.orpcFetchHandler.handle(request, ...rest);
72
+ if (result.matched === false) {
73
+ return { matched: false };
74
+ }
75
+ const context = rest[0]?.context ?? {};
76
+ await rest[0]?.beforeSend?.(result.response, context);
77
+ await sendResponse(res, result.response);
78
+ return { matched: true };
79
+ }
80
+ };
81
+ export {
82
+ RPCHandler2 as RPCHandler,
83
+ createHeaders,
84
+ createRequest,
85
+ sendResponse
86
+ };
87
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1,6 @@
1
+ export * from './orpc-handler';
2
+ export * from './orpc-payload-codec';
3
+ export * from './orpc-procedure-matcher';
4
+ export * as SuperJSON from './super-json';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ import type { Hooks } from '@orpc/shared';
2
+ import type { Context } from '../../context';
3
+ import type { Router } from '../../router';
4
+ import type { FetchHandler, FetchHandleRest, FetchHandleResult } from './types';
5
+ import { type PublicORPCPayloadCodec } from './orpc-payload-codec';
6
+ import { type PublicORPCProcedureMatcher } from './orpc-procedure-matcher';
7
+ export type RPCHandlerOptions<T extends Context> = Hooks<Request, FetchHandleResult, T, {
8
+ signal?: AbortSignal;
9
+ }> & {
10
+ procedureMatcher?: PublicORPCProcedureMatcher;
11
+ payloadCodec?: PublicORPCPayloadCodec;
12
+ };
13
+ export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
14
+ private readonly options?;
15
+ private readonly procedureMatcher;
16
+ private readonly payloadCodec;
17
+ constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>> | undefined);
18
+ handle(request: Request, ...[options]: FetchHandleRest<T>): Promise<FetchHandleResult>;
19
+ }
20
+ //# sourceMappingURL=orpc-handler.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { type HTTPMethod } from '@orpc/contract';
2
+ export declare class ORPCPayloadCodec {
3
+ /**
4
+ * If method is GET, the payload will be encoded as query string.
5
+ * If method is GET and payload contain file, the method will be fallback to fallbackMethod. (fallbackMethod = GET will force to use GET method)
6
+ */
7
+ encode(payload: unknown, method?: HTTPMethod, fallbackMethod?: HTTPMethod): {
8
+ query?: URLSearchParams;
9
+ body?: FormData | string;
10
+ headers?: Headers;
11
+ method: HTTPMethod;
12
+ };
13
+ decode(re: Request | Response): Promise<unknown>;
14
+ }
15
+ export type PublicORPCPayloadCodec = Pick<ORPCPayloadCodec, keyof ORPCPayloadCodec>;
16
+ //# sourceMappingURL=orpc-payload-codec.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { AnyProcedure } from '../../procedure';
2
+ import type { AnyRouter } from '../../router';
3
+ export declare class ORPCProcedureMatcher {
4
+ private readonly router;
5
+ constructor(router: AnyRouter);
6
+ match(pathname: string): Promise<{
7
+ path: string[];
8
+ procedure: AnyProcedure;
9
+ } | undefined>;
10
+ }
11
+ export type PublicORPCProcedureMatcher = Pick<ORPCProcedureMatcher, keyof ORPCProcedureMatcher>;
12
+ //# sourceMappingURL=orpc-procedure-matcher.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { Segment } from '@orpc/shared';
2
+ export type JSONExtraType = 'bigint' | 'date' | 'nan' | 'undefined' | 'set' | 'map' | 'regexp' | 'url';
3
+ export type JSONMeta = [JSONExtraType, Segment[]][];
4
+ export declare function serialize(value: unknown, segments?: Segment[], meta?: JSONMeta): {
5
+ data: unknown;
6
+ meta: JSONMeta;
7
+ };
8
+ export declare function deserialize({ data, meta, }: {
9
+ data: unknown;
10
+ meta: JSONMeta;
11
+ }): unknown;
12
+ //# sourceMappingURL=super-json.d.ts.map
@@ -0,0 +1,21 @@
1
+ import type { HTTPPath } from '@orpc/contract';
2
+ import type { Context } from '../../context';
3
+ export type FetchHandleOptions<T extends Context> = {
4
+ prefix?: HTTPPath;
5
+ } & (Record<never, never> extends T ? {
6
+ context?: T;
7
+ } : {
8
+ context: T;
9
+ });
10
+ export type FetchHandleRest<T extends Context> = [options: FetchHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
11
+ export type FetchHandleResult = {
12
+ matched: true;
13
+ response: Response;
14
+ } | {
15
+ matched: false;
16
+ response: undefined;
17
+ };
18
+ export interface FetchHandler<T extends Context> {
19
+ handle(request: Request, ...rest: FetchHandleRest<T>): Promise<FetchHandleResult>;
20
+ }
21
+ //# 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 { Context as HonoContext, MiddlewareHandler } from 'hono';
2
+ import type { Context } from '../../context';
3
+ import type { FetchHandleOptions, FetchHandler } from '../fetch';
4
+ import { type Value } from '@orpc/shared';
5
+ export type CreateMiddlewareOptions<T extends Context> = Omit<FetchHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
+ context?: Value<T, [HonoContext]>;
7
+ } : {
8
+ context: Value<T, [HonoContext]>;
9
+ });
10
+ export type CreateMiddlewareRest<T extends Context> = [options: CreateMiddlewareOptions<T>] | (Record<never, never> extends T ? [] : never);
11
+ export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: CreateMiddlewareRest<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 { NextRequest } from 'next/server';
2
+ import type { Context } from '../../context';
3
+ import type { FetchHandleOptions, FetchHandler } from '../fetch';
4
+ import { type Value } from '@orpc/shared';
5
+ export type ServeOptions<T extends Context> = Omit<FetchHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
+ context?: Value<T, [NextRequest]>;
7
+ } : {
8
+ context: Value<T, [NextRequest]>;
9
+ });
10
+ export type ServeRest<T extends Context> = [options: ServeOptions<T>] | (Record<never, never> extends T ? [] : never);
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]: ServeRest<T>): ServeResult;
19
+ //# sourceMappingURL=serve.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from './orpc-handler';
2
+ export * from './orpc-handler';
3
+ export * from './request-listener';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ import type { Context } from '../../context';
3
+ import type { Router } from '../../router';
4
+ import type { RPCHandlerOptions } from '../fetch/orpc-handler';
5
+ import type { RequestHandler, RequestHandleRest, RequestHandleResult } from './types';
6
+ import { type ExpressableIncomingMessage } from './request-listener';
7
+ export declare class RPCHandler<T extends Context> implements RequestHandler<T> {
8
+ private readonly orpcFetchHandler;
9
+ constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
10
+ handle(req: ExpressableIncomingMessage, res: ServerResponse, ...rest: RequestHandleRest<T>): Promise<RequestHandleResult>;
11
+ }
12
+ //# sourceMappingURL=orpc-handler.d.ts.map
@@ -0,0 +1,28 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export interface ExpressableIncomingMessage extends IncomingMessage {
3
+ originalUrl?: string;
4
+ }
5
+ /**
6
+ * Creates a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) object from a Node.js
7
+ * [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) and
8
+ * [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) pair.
9
+ *
10
+ */
11
+ export declare function createRequest(req: ExpressableIncomingMessage, res: ServerResponse): Request;
12
+ /**
13
+ * Creates a [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object from the headers
14
+ * in a Node.js [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage).
15
+ *
16
+ * @param req The incoming request object.
17
+ * @returns A headers object.
18
+ */
19
+ export declare function createHeaders(req: IncomingMessage): Headers;
20
+ /**
21
+ * Sends a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) to the client using the
22
+ * Node.js [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) object.
23
+ *
24
+ * @param res The server response object.
25
+ * @param response The response to send.
26
+ */
27
+ export declare function sendResponse(res: ServerResponse, response: Response): Promise<void>;
28
+ //# sourceMappingURL=request-listener.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { HTTPPath } from '@orpc/contract';
2
+ import type { Promisable } from '@orpc/shared';
3
+ import type { IncomingMessage, ServerResponse } from 'node:http';
4
+ import type { Context } from '../../context';
5
+ export type RequestHandleOptions<T extends Context> = {
6
+ prefix?: HTTPPath;
7
+ beforeSend?(response: Response, context: T): Promisable<void>;
8
+ } & (Record<never, never> extends T ? {
9
+ context?: T;
10
+ } : {
11
+ context: T;
12
+ });
13
+ export type RequestHandleRest<T extends Context> = [options: RequestHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
14
+ export type RequestHandleResult = {
15
+ matched: true;
16
+ } | {
17
+ matched: false;
18
+ };
19
+ export interface RequestHandler<T extends Context> {
20
+ handle(req: IncomingMessage, res: ServerResponse, ...rest: RequestHandleRest<T>): Promise<RequestHandleResult>;
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,74 @@
1
+ import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
+ import type { BuilderDef } from './builder';
3
+ import type { ConflictContextGuard, Context, MergedContext } from './context';
4
+ import type { FlattenLazy } from './lazy-utils';
5
+ import type { MapInputMiddleware, Middleware } from './middleware';
6
+ import type { ProcedureHandler } from './procedure';
7
+ import type { DecoratedProcedure } from './procedure-decorated';
8
+ import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
9
+ export interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
10
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
11
+ 'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
12
+ '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>;
13
+ 'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
14
+ 'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
15
+ 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
16
+ 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
17
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
18
+ 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
19
+ 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
20
+ 'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
21
+ 'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
22
+ default: U;
23
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
24
+ }
25
+ export interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
27
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
28
+ '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>;
29
+ 'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
30
+ 'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
31
+ 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
32
+ 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
33
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
34
+ }
35
+ export interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
36
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
37
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
38
+ '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>;
39
+ '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>;
40
+ 'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
41
+ 'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
42
+ 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
43
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
44
+ }
45
+ export interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
46
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
47
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
48
+ '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>;
49
+ 'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
50
+ 'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
51
+ 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
52
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
53
+ }
54
+ export interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
55
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
56
+ 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
57
+ '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>;
58
+ '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>;
59
+ 'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
60
+ 'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
61
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
62
+ }
63
+ export interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
64
+ '~orpc': AdaptRouterOptions<TErrorMap>;
65
+ 'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
66
+ 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & RouterBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
67
+ 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
68
+ 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
69
+ 'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
70
+ 'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
71
+ default: U;
72
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
73
+ }
74
+ //# sourceMappingURL=builder-variants.d.ts.map
@@ -1,49 +1,57 @@
1
- import type { IsEqual } from '@orpc/shared';
2
- import type { HandledRouter, Router } from './router';
3
- import type { Context, MergeContext } from './types';
4
- import { ContractProcedure, type ContractRouter, type HTTPPath, type RouteOptions, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
5
- import { type DecoratedMiddleware, type MapInputMiddleware, type Middleware } from './middleware';
6
- import { type DecoratedProcedure, type ProcedureFunc } from './procedure';
7
- import { ProcedureBuilder } from './procedure-builder';
8
- import { ProcedureImplementer } from './procedure-implementer';
9
- import { RouterBuilder } from './router-builder';
10
- import { type ChainedRouterImplementer } from './router-implementer';
11
- export declare class Builder<TContext extends Context, TExtraContext extends Context> {
12
- zz$b: {
13
- middlewares?: Middleware<any, any, any, any>[];
14
- };
15
- constructor(zz$b?: {
16
- middlewares?: Middleware<any, any, any, any>[];
17
- });
18
- /**
19
- * Self chainable
20
- */
21
- context<UContext extends Context>(): IsEqual<UContext, Context> extends true ? Builder<TContext, TExtraContext> : Builder<UContext, TExtraContext>;
22
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, unknown, unknown>): Builder<TContext, MergeContext<TExtraContext, UExtraContext>>;
23
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, unknown>, mapInput: MapInputMiddleware<unknown, UMappedInput>): Builder<TContext, MergeContext<TExtraContext, UExtraContext>>;
24
- /**
25
- * Convert to ContractProcedureBuilder
26
- */
27
- route(opts: RouteOptions): ProcedureBuilder<TContext, TExtraContext, undefined, undefined>;
28
- input<USchema extends Schema = undefined>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilder<TContext, TExtraContext, USchema, undefined>;
29
- output<USchema extends Schema = undefined>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilder<TContext, TExtraContext, undefined, USchema>;
1
+ import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, ORPCErrorConstructorMap, 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 { FlattenLazy } from './lazy-utils';
5
+ import type { AnyMiddleware, MapInputMiddleware, Middleware } from './middleware';
6
+ import type { DecoratedMiddleware } from './middleware-decorated';
7
+ import type { ProcedureHandler } from './procedure';
8
+ import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
9
+ import { DecoratedProcedure } from './procedure-decorated';
10
+ export interface BuilderConfig {
11
+ initialInputValidationIndex?: number;
12
+ initialOutputValidationIndex?: number;
13
+ }
14
+ export interface BuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptRouterOptions<TErrorMap> {
15
+ middlewares: AnyMiddleware[];
16
+ inputValidationIndex: number;
17
+ outputValidationIndex: number;
18
+ config: BuilderConfig;
19
+ }
20
+ export declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
21
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
22
+ constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
30
23
  /**
31
- * Convert to Procedure
24
+ * Reset config
32
25
  */
33
- func<UFuncOutput = undefined>(func: ProcedureFunc<TContext, TExtraContext, undefined, undefined, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput>;
26
+ $config(config: BuilderConfig): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
34
27
  /**
35
- * Convert to ProcedureImplementer | RouterBuilder
28
+ * Reset initial context
36
29
  */
37
- contract<UContract extends ContractProcedure<any, any> | ContractRouter>(contract: UContract): UContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema> : UContract extends ContractRouter ? ChainedRouterImplementer<TContext, UContract, TExtraContext> : never;
30
+ $context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
38
31
  /**
39
- * Create ExtendedMiddleware
32
+ * Reset initial meta
40
33
  */
41
- middleware<UExtraContext extends Context = undefined, TInput = unknown, TOutput = any>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>): DecoratedMiddleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>;
42
- prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
43
- tags(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
34
+ $meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U>;
44
35
  /**
45
- * Create DecoratedRouter
36
+ * Reset initial route
46
37
  */
47
- router<URouter extends Router<TContext>>(router: URouter): HandledRouter<URouter>;
38
+ $route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
39
+ middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
40
+ middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
41
+ errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
42
+ 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>;
43
+ 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>;
44
+ meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
+ route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
46
+ input<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
47
+ output<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
48
+ handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
49
+ prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
50
+ tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
51
+ router<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
52
+ lazy<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
53
+ default: U;
54
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
48
55
  }
56
+ export declare const os: Builder<Context, Context, undefined, undefined, {}, {}>;
49
57
  //# 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,9 @@
1
+ import type { IsNever } from '@orpc/shared';
2
+ export type Context = Record<string, any>;
3
+ export type TypeInitialContext<T extends Context> = (type: T) => unknown;
4
+ export type MergedContext<T extends Context, U extends Context> = T & U;
5
+ export declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
6
+ export type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
7
+ [K in keyof T]: IsNever<T[K]>;
8
+ }[keyof T] ? never : unknown;
9
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,8 @@
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;
7
+ export declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
8
+ //# sourceMappingURL=hidden.d.ts.map
@@ -0,0 +1,30 @@
1
+ import type { ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
+ import type { BuilderDef } from './builder';
3
+ import type { ConflictContextGuard, Context, MergedContext } from './context';
4
+ import type { MapInputMiddleware, Middleware } from './middleware';
5
+ import type { Procedure, ProcedureHandler } from './procedure';
6
+ import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
7
+ import type { DecoratedProcedure } from './procedure-decorated';
8
+ /**
9
+ * Like `DecoratedProcedure`, but removed all method that can change the contract.
10
+ */
11
+ export interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> {
12
+ use: (<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>) => ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>) & (<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>) => ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>);
13
+ /**
14
+ * Make this procedure callable (works like a function while still being a procedure).
15
+ */
16
+ callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
17
+ /**
18
+ * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
19
+ */
20
+ actionable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
21
+ }
22
+ /**
23
+ * Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
24
+ */
25
+ export interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
+ '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
27
+ 'use': (<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>) => ConflictContextGuard<MergedContext<TCurrentContext, U>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>) & (<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>) => ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
28
+ 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
29
+ }
30
+ //# sourceMappingURL=implementer-procedure.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { AnyContractRouter, ContractProcedure, ContractRouter, ContractRouterToErrorMap, ORPCErrorConstructorMap } from '@orpc/contract';
2
+ import type { ConflictContextGuard, Context, MergedContext } from './context';
3
+ import type { ProcedureImplementer } from './implementer-procedure';
4
+ import type { FlattenLazy } from './lazy-utils';
5
+ import type { Middleware } from './middleware';
6
+ import type { AdaptedRouter, Router } from './router';
7
+ export type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : TContract extends ContractRouter<infer UMeta> ? {
8
+ use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, UMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
9
+ router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
10
+ lazy<U extends Router<TInitialContext, TContract>>(loader: () => Promise<{
11
+ default: U;
12
+ }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
13
+ } & {
14
+ [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
15
+ } : never);
16
+ //# sourceMappingURL=implementer-variants.d.ts.map