@orpc/server 0.0.0-next.c6c659d → 0.0.0-next.caefe3a
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.
- package/dist/chunk-M65OCXNG.js +136 -0
- package/dist/chunk-OEPDHGQ4.js +378 -0
- package/dist/chunk-OWMUECGT.js +111 -0
- package/dist/chunk-PZ44ZPVC.js +308 -0
- package/dist/fetch.js +12 -9
- package/dist/hono.js +26 -14
- package/dist/index.js +226 -372
- package/dist/next.js +14 -11
- package/dist/node.js +150 -62
- package/dist/plugins.js +11 -0
- package/dist/src/adapters/fetch/index.d.ts +2 -4
- package/dist/src/adapters/fetch/rpc-handler.d.ts +10 -0
- package/dist/src/adapters/fetch/types.d.ts +3 -11
- package/dist/src/adapters/fetch/utils.d.ts +6 -0
- package/dist/src/adapters/hono/middleware.d.ts +5 -4
- package/dist/src/adapters/next/serve.d.ts +10 -9
- package/dist/src/adapters/node/index.d.ts +2 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +10 -0
- package/dist/src/adapters/node/types.d.ts +14 -15
- package/dist/src/adapters/node/utils.d.ts +5 -0
- package/dist/src/adapters/standard/handler.d.ts +47 -0
- package/dist/src/adapters/standard/index.d.ts +7 -0
- package/dist/src/adapters/standard/rpc-codec.d.ts +15 -0
- package/dist/src/adapters/standard/rpc-handler.d.ts +8 -0
- package/dist/src/adapters/standard/rpc-matcher.d.ts +10 -0
- package/dist/src/adapters/standard/rpc-serializer.d.ts +16 -0
- package/dist/src/adapters/standard/types.d.ts +44 -0
- package/dist/src/builder-variants.d.ts +74 -0
- package/dist/src/builder.d.ts +50 -29
- package/dist/src/config.d.ts +6 -0
- package/dist/src/context.d.ts +9 -0
- package/dist/src/hidden.d.ts +6 -4
- package/dist/src/implementer-procedure.d.ts +30 -0
- package/dist/src/implementer-variants.d.ts +17 -0
- package/dist/src/implementer.d.ts +28 -0
- package/dist/src/index.d.ts +10 -12
- package/dist/src/lazy-utils.d.ts +4 -2
- package/dist/src/lazy.d.ts +9 -5
- package/dist/src/middleware-decorated.d.ts +7 -6
- package/dist/src/middleware-utils.d.ts +5 -0
- package/dist/src/middleware.d.ts +22 -20
- package/dist/src/plugins/base.d.ts +11 -0
- package/dist/src/plugins/cors.d.ts +18 -0
- package/dist/src/plugins/index.d.ts +4 -0
- package/dist/src/plugins/response-headers.d.ts +10 -0
- package/dist/src/procedure-client.d.ts +21 -12
- package/dist/src/procedure-decorated.d.ts +11 -16
- package/dist/src/procedure-utils.d.ts +3 -3
- package/dist/src/procedure.d.ts +19 -33
- package/dist/src/router-accessible-lazy.d.ts +8 -0
- package/dist/src/router-client.d.ts +5 -22
- package/dist/src/router.d.ts +25 -12
- package/dist/src/utils.d.ts +23 -2
- package/dist/standard.js +17 -0
- package/package.json +17 -3
- package/dist/chunk-MB74GD7C.js +0 -301
- package/dist/chunk-WUOGVGWG.js +0 -1
- package/dist/chunk-ZBJYYEII.js +0 -227
- package/dist/src/adapters/fetch/orpc-handler.d.ts +0 -20
- package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +0 -16
- package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +0 -12
- package/dist/src/adapters/fetch/super-json.d.ts +0 -12
- package/dist/src/adapters/node/orpc-handler.d.ts +0 -12
- package/dist/src/adapters/node/request-listener.d.ts +0 -28
- package/dist/src/error.d.ts +0 -10
- package/dist/src/implementer-chainable.d.ts +0 -10
- package/dist/src/lazy-decorated.d.ts +0 -7
- package/dist/src/procedure-builder.d.ts +0 -24
- package/dist/src/procedure-implementer.d.ts +0 -19
- package/dist/src/router-builder.d.ts +0 -29
- package/dist/src/router-implementer.d.ts +0 -21
- package/dist/src/types.d.ts +0 -14
package/dist/chunk-ZBJYYEII.js
DELETED
@@ -1,227 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __export = (target, all) => {
|
3
|
-
for (var name in all)
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
5
|
-
};
|
6
|
-
|
7
|
-
// src/utils.ts
|
8
|
-
function mergeContext(a, b) {
|
9
|
-
if (!a)
|
10
|
-
return b;
|
11
|
-
if (!b)
|
12
|
-
return a;
|
13
|
-
return {
|
14
|
-
...a,
|
15
|
-
...b
|
16
|
-
};
|
17
|
-
}
|
18
|
-
|
19
|
-
// src/procedure.ts
|
20
|
-
import { isContractProcedure } from "@orpc/contract";
|
21
|
-
var Procedure = class {
|
22
|
-
"~type" = "Procedure";
|
23
|
-
"~orpc";
|
24
|
-
constructor(def) {
|
25
|
-
this["~orpc"] = def;
|
26
|
-
}
|
27
|
-
};
|
28
|
-
function isProcedure(item) {
|
29
|
-
if (item instanceof Procedure) {
|
30
|
-
return true;
|
31
|
-
}
|
32
|
-
return (typeof item === "object" || typeof item === "function") && item !== null && "~type" in item && item["~type"] === "Procedure" && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "contract" in item["~orpc"] && isContractProcedure(item["~orpc"].contract) && "handler" in item["~orpc"] && typeof item["~orpc"].handler === "function";
|
33
|
-
}
|
34
|
-
|
35
|
-
// src/error.ts
|
36
|
-
import { ORPCError } from "@orpc/contract";
|
37
|
-
function createORPCErrorConstructorMap(errors) {
|
38
|
-
const constructors = {};
|
39
|
-
if (!errors) {
|
40
|
-
return constructors;
|
41
|
-
}
|
42
|
-
for (const code in errors) {
|
43
|
-
const config = errors[code];
|
44
|
-
if (!config) {
|
45
|
-
continue;
|
46
|
-
}
|
47
|
-
const constructor = (...[options]) => {
|
48
|
-
return new ORPCError({
|
49
|
-
code,
|
50
|
-
defined: true,
|
51
|
-
status: config.status,
|
52
|
-
message: options?.message ?? config.message,
|
53
|
-
data: options?.data,
|
54
|
-
cause: options?.cause
|
55
|
-
});
|
56
|
-
};
|
57
|
-
constructors[code] = constructor;
|
58
|
-
}
|
59
|
-
return constructors;
|
60
|
-
}
|
61
|
-
|
62
|
-
// src/lazy.ts
|
63
|
-
var LAZY_LOADER_SYMBOL = Symbol("ORPC_LAZY_LOADER");
|
64
|
-
function lazy(loader) {
|
65
|
-
return {
|
66
|
-
[LAZY_LOADER_SYMBOL]: loader
|
67
|
-
};
|
68
|
-
}
|
69
|
-
function isLazy(item) {
|
70
|
-
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_LOADER_SYMBOL in item && typeof item[LAZY_LOADER_SYMBOL] === "function";
|
71
|
-
}
|
72
|
-
function unlazy(lazied) {
|
73
|
-
return isLazy(lazied) ? lazied[LAZY_LOADER_SYMBOL]() : Promise.resolve({ default: lazied });
|
74
|
-
}
|
75
|
-
function flatLazy(lazied) {
|
76
|
-
const flattenLoader = async () => {
|
77
|
-
let current = await unlazy(lazied);
|
78
|
-
while (true) {
|
79
|
-
if (!isLazy(current.default)) {
|
80
|
-
break;
|
81
|
-
}
|
82
|
-
current = await unlazy(current.default);
|
83
|
-
}
|
84
|
-
return current;
|
85
|
-
};
|
86
|
-
return lazy(flattenLoader);
|
87
|
-
}
|
88
|
-
|
89
|
-
// src/procedure-client.ts
|
90
|
-
import { ORPCError as ORPCError2, validateORPCError, ValidationError } from "@orpc/contract";
|
91
|
-
import { executeWithHooks, toError, value } from "@orpc/shared";
|
92
|
-
function createProcedureClient(lazyableProcedure, ...[options]) {
|
93
|
-
return async (...[input, callerOptions]) => {
|
94
|
-
const path = options?.path ?? [];
|
95
|
-
const { default: procedure } = await unlazy(lazyableProcedure);
|
96
|
-
const context = await value(options?.context, callerOptions?.context);
|
97
|
-
const meta = {
|
98
|
-
path,
|
99
|
-
procedure,
|
100
|
-
signal: callerOptions?.signal
|
101
|
-
};
|
102
|
-
const executeWithValidation = async () => {
|
103
|
-
const validInput = await validateInput(procedure, input);
|
104
|
-
const output = await executeMiddlewareChain({
|
105
|
-
context,
|
106
|
-
input: validInput,
|
107
|
-
path,
|
108
|
-
procedure,
|
109
|
-
signal: callerOptions?.signal,
|
110
|
-
errors: createORPCErrorConstructorMap(procedure["~orpc"].contract["~orpc"].errorMap)
|
111
|
-
});
|
112
|
-
return validateOutput(procedure, output);
|
113
|
-
};
|
114
|
-
try {
|
115
|
-
const output = await executeWithHooks({
|
116
|
-
hooks: options,
|
117
|
-
input,
|
118
|
-
context,
|
119
|
-
meta,
|
120
|
-
execute: executeWithValidation
|
121
|
-
});
|
122
|
-
return output;
|
123
|
-
} catch (e) {
|
124
|
-
if (!(e instanceof ORPCError2)) {
|
125
|
-
throw toError(e);
|
126
|
-
}
|
127
|
-
const validated = await validateORPCError(procedure["~orpc"].contract["~orpc"].errorMap, e);
|
128
|
-
throw validated;
|
129
|
-
}
|
130
|
-
};
|
131
|
-
}
|
132
|
-
async function validateInput(procedure, input) {
|
133
|
-
const schema = procedure["~orpc"].contract["~orpc"].InputSchema;
|
134
|
-
if (!schema)
|
135
|
-
return input;
|
136
|
-
const result = await schema["~standard"].validate(input);
|
137
|
-
if (result.issues) {
|
138
|
-
throw new ORPCError2({
|
139
|
-
message: "Input validation failed",
|
140
|
-
code: "BAD_REQUEST",
|
141
|
-
data: {
|
142
|
-
issues: result.issues
|
143
|
-
},
|
144
|
-
cause: new ValidationError({ message: "Input validation failed", issues: result.issues })
|
145
|
-
});
|
146
|
-
}
|
147
|
-
return result.value;
|
148
|
-
}
|
149
|
-
async function validateOutput(procedure, output) {
|
150
|
-
const schema = procedure["~orpc"].contract["~orpc"].OutputSchema;
|
151
|
-
if (!schema)
|
152
|
-
return output;
|
153
|
-
const result = await schema["~standard"].validate(output);
|
154
|
-
if (result.issues) {
|
155
|
-
throw new ORPCError2({
|
156
|
-
message: "Output validation failed",
|
157
|
-
code: "INTERNAL_SERVER_ERROR",
|
158
|
-
cause: new ValidationError({ message: "Output validation failed", issues: result.issues })
|
159
|
-
});
|
160
|
-
}
|
161
|
-
return result.value;
|
162
|
-
}
|
163
|
-
async function executeMiddlewareChain(opt) {
|
164
|
-
const middlewares = opt.procedure["~orpc"].middlewares ?? [];
|
165
|
-
let currentMidIndex = 0;
|
166
|
-
let currentContext = opt.context;
|
167
|
-
const next = async (nextOptions) => {
|
168
|
-
const mid = middlewares[currentMidIndex];
|
169
|
-
currentMidIndex += 1;
|
170
|
-
currentContext = mergeContext(currentContext, nextOptions.context);
|
171
|
-
if (mid) {
|
172
|
-
return await mid({ ...opt, context: currentContext, next }, opt.input, (output) => ({ output, context: void 0 }));
|
173
|
-
}
|
174
|
-
const result = {
|
175
|
-
output: await opt.procedure["~orpc"].handler({ ...opt, context: currentContext }),
|
176
|
-
context: currentContext
|
177
|
-
};
|
178
|
-
return result;
|
179
|
-
};
|
180
|
-
return (await next({})).output;
|
181
|
-
}
|
182
|
-
|
183
|
-
// src/router.ts
|
184
|
-
function getRouterChild(router, ...path) {
|
185
|
-
let current = router;
|
186
|
-
for (let i = 0; i < path.length; i++) {
|
187
|
-
const segment = path[i];
|
188
|
-
if (!current) {
|
189
|
-
return void 0;
|
190
|
-
}
|
191
|
-
if (isProcedure(current)) {
|
192
|
-
return void 0;
|
193
|
-
}
|
194
|
-
if (!isLazy(current)) {
|
195
|
-
current = current[segment];
|
196
|
-
continue;
|
197
|
-
}
|
198
|
-
const lazied = current;
|
199
|
-
const rest = path.slice(i);
|
200
|
-
const newLazy = lazy(async () => {
|
201
|
-
const unwrapped = await unlazy(lazied);
|
202
|
-
if (!unwrapped.default) {
|
203
|
-
return unwrapped;
|
204
|
-
}
|
205
|
-
const next = getRouterChild(unwrapped.default, ...rest);
|
206
|
-
return { default: next };
|
207
|
-
});
|
208
|
-
return flatLazy(newLazy);
|
209
|
-
}
|
210
|
-
return current;
|
211
|
-
}
|
212
|
-
|
213
|
-
export {
|
214
|
-
__export,
|
215
|
-
mergeContext,
|
216
|
-
Procedure,
|
217
|
-
isProcedure,
|
218
|
-
createORPCErrorConstructorMap,
|
219
|
-
LAZY_LOADER_SYMBOL,
|
220
|
-
lazy,
|
221
|
-
isLazy,
|
222
|
-
unlazy,
|
223
|
-
flatLazy,
|
224
|
-
createProcedureClient,
|
225
|
-
getRouterChild
|
226
|
-
};
|
227
|
-
//# sourceMappingURL=chunk-ZBJYYEII.js.map
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import type { Hooks } from '@orpc/shared';
|
2
|
-
import type { Router } from '../../router';
|
3
|
-
import type { Context } from '../../types';
|
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
|
@@ -1,16 +0,0 @@
|
|
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
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { ANY_PROCEDURE } from '../../procedure';
|
2
|
-
import { type ANY_ROUTER } from '../../router';
|
3
|
-
export declare class ORPCProcedureMatcher {
|
4
|
-
private readonly router;
|
5
|
-
constructor(router: ANY_ROUTER);
|
6
|
-
match(pathname: string): Promise<{
|
7
|
-
path: string[];
|
8
|
-
procedure: ANY_PROCEDURE;
|
9
|
-
} | undefined>;
|
10
|
-
}
|
11
|
-
export type PublicORPCProcedureMatcher = Pick<ORPCProcedureMatcher, keyof ORPCProcedureMatcher>;
|
12
|
-
//# sourceMappingURL=orpc-procedure-matcher.d.ts.map
|
@@ -1,12 +0,0 @@
|
|
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
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { ServerResponse } from 'node:http';
|
2
|
-
import type { Router } from '../../router';
|
3
|
-
import type { Context } from '../../types';
|
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, ...[options]: RequestHandleRest<T>): Promise<RequestHandleResult>;
|
11
|
-
}
|
12
|
-
//# sourceMappingURL=orpc-handler.d.ts.map
|
@@ -1,28 +0,0 @@
|
|
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
|
package/dist/src/error.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { ErrorMap, ErrorMapItem, ORPCErrorOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import { ORPCError } from '@orpc/contract';
|
3
|
-
export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<any, TData>, 'defined' | 'code' | 'status'>;
|
4
|
-
export type ORPCErrorConstructorMapItemRest<TData> = [options: ORPCErrorConstructorMapItemOptions<TData>] | (undefined extends TData ? [] : never);
|
5
|
-
export type ORPCErrorConstructorMapItem<TCode extends string, TDataSchema extends Schema> = (...rest: ORPCErrorConstructorMapItemRest<SchemaInput<TDataSchema>>) => ORPCError<TCode, SchemaOutput<TDataSchema>>;
|
6
|
-
export type ORPCErrorConstructorMap<T extends ErrorMap> = T extends undefined ? Record<string, unknown> : {
|
7
|
-
[K in keyof T]: K extends string ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, UInputSchema> : never : never;
|
8
|
-
};
|
9
|
-
export declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
10
|
-
//# sourceMappingURL=error.d.ts.map
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { Middleware } from './middleware';
|
2
|
-
import type { Context, MergeContext, WELL_CONTEXT } from './types';
|
3
|
-
import { type ContractProcedure, type ContractRouter } from '@orpc/contract';
|
4
|
-
import { ProcedureImplementer } from './procedure-implementer';
|
5
|
-
import { RouterImplementer } from './router-implementer';
|
6
|
-
export type ChainableImplementer<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
7
|
-
[K in keyof TContract]: TContract[K] extends ContractRouter ? ChainableImplementer<TContext, TExtraContext, TContract[K]> : never;
|
8
|
-
} & Omit<RouterImplementer<TContext, TExtraContext, TContract>, '~type' | '~orpc'>;
|
9
|
-
export declare function createChainableImplementer<TContext extends Context = WELL_CONTEXT, TExtraContext extends Context = undefined, TContract extends ContractRouter = any>(contract: TContract, middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<string, unknown>>[]): ChainableImplementer<TContext, TExtraContext, TContract>;
|
10
|
-
//# sourceMappingURL=implementer-chainable.d.ts.map
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { Lazy } from './lazy';
|
2
|
-
import { type ANY_ROUTER } from './router';
|
3
|
-
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : Lazy<T> & (T extends ANY_ROUTER ? {
|
4
|
-
[K in keyof T]: DecoratedLazy<T[K]>;
|
5
|
-
} : unknown);
|
6
|
-
export declare function decorateLazy<T extends Lazy<ANY_ROUTER | undefined>>(lazied: T): DecoratedLazy<T>;
|
7
|
-
//# sourceMappingURL=lazy-decorated.d.ts.map
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ErrorMap, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { ORPCErrorConstructorMap } from './error';
|
3
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
|
-
import type { ProcedureHandler } from './procedure';
|
5
|
-
import type { Context, MergeContext } from './types';
|
6
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
7
|
-
import { ProcedureImplementer } from './procedure-implementer';
|
8
|
-
export interface ProcedureBuilderDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
|
9
|
-
contract: ContractProcedure<TInputSchema, TOutputSchema, TErrorMap>;
|
10
|
-
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<string, unknown>>[];
|
11
|
-
}
|
12
|
-
export declare class ProcedureBuilder<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
|
13
|
-
'~type': "ProcedureBuilder";
|
14
|
-
'~orpc': ProcedureBuilderDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>;
|
15
|
-
constructor(def: ProcedureBuilderDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>);
|
16
|
-
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>;
|
17
|
-
input<U extends Schema>(schema: U, example?: SchemaInput<U>): ProcedureBuilder<TContext, TExtraContext, U, TOutputSchema, TErrorMap>;
|
18
|
-
output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ProcedureBuilder<TContext, TExtraContext, TInputSchema, U, TErrorMap>;
|
19
|
-
errors<UErrorMap extends ErrorMap>(errors: UErrorMap): ProcedureBuilder<TContext, TExtraContext, TInputSchema, TOutputSchema, UErrorMap>;
|
20
|
-
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema, TErrorMap>;
|
21
|
-
use<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema, TErrorMap>;
|
22
|
-
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>;
|
23
|
-
}
|
24
|
-
//# sourceMappingURL=procedure-builder.d.ts.map
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { ORPCErrorConstructorMap } from './error';
|
3
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
|
-
import type { ProcedureHandler } from './procedure';
|
5
|
-
import type { Context, MergeContext } from './types';
|
6
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
7
|
-
export type ProcedureImplementerDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = {
|
8
|
-
contract: ContractProcedure<TInputSchema, TOutputSchema, TErrorMap>;
|
9
|
-
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>[];
|
10
|
-
};
|
11
|
-
export declare class ProcedureImplementer<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
|
12
|
-
'~type': "ProcedureImplementer";
|
13
|
-
'~orpc': ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>;
|
14
|
-
constructor(def: ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>);
|
15
|
-
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema, TErrorMap>;
|
16
|
-
use<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema, TErrorMap>;
|
17
|
-
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>;
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=procedure-implementer.d.ts.map
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import type { HTTPPath } from '@orpc/contract';
|
2
|
-
import type { FlattenLazy, Lazy } from './lazy';
|
3
|
-
import type { Middleware } from './middleware';
|
4
|
-
import type { Procedure } from './procedure';
|
5
|
-
import type { ANY_ROUTER, Router } from './router';
|
6
|
-
import type { Context, MergeContext } from './types';
|
7
|
-
import { type DecoratedLazy } from './lazy-decorated';
|
8
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
9
|
-
export type AdaptedRouter<TContext extends Context, TRouter extends ANY_ROUTER> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? DecoratedLazy<AdaptedRouter<TContext, U>> : TRouter extends Procedure<any, infer UExtraContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap> ? DecoratedProcedure<TContext, UExtraContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
10
|
-
[K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? AdaptedRouter<TContext, TRouter[K]> : never;
|
11
|
-
};
|
12
|
-
export type RouterBuilderDef<TContext extends Context, TExtraContext extends Context> = {
|
13
|
-
prefix?: HTTPPath;
|
14
|
-
tags?: readonly string[];
|
15
|
-
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<string, unknown>>[];
|
16
|
-
};
|
17
|
-
export declare class RouterBuilder<TContext extends Context, TExtraContext extends Context> {
|
18
|
-
'~type': "RouterBuilder";
|
19
|
-
'~orpc': RouterBuilderDef<TContext, TExtraContext>;
|
20
|
-
constructor(def: RouterBuilderDef<TContext, TExtraContext>);
|
21
|
-
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
|
22
|
-
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
|
23
|
-
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<string, unknown>>): RouterBuilder<TContext, MergeContext<TExtraContext, U>>;
|
24
|
-
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U>;
|
25
|
-
lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
|
26
|
-
default: U;
|
27
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
28
|
-
}
|
29
|
-
//# sourceMappingURL=router-builder.d.ts.map
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { ContractRouter } from '@orpc/contract';
|
2
|
-
import type { FlattenLazy } from './lazy';
|
3
|
-
import type { Middleware } from './middleware';
|
4
|
-
import type { Router } from './router';
|
5
|
-
import type { AdaptedRouter } from './router-builder';
|
6
|
-
import type { Context, MergeContext } from './types';
|
7
|
-
export interface RouterImplementerDef<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> {
|
8
|
-
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<string, unknown>>[];
|
9
|
-
contract: TContract;
|
10
|
-
}
|
11
|
-
export declare class RouterImplementer<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> {
|
12
|
-
'~type': "RouterImplementer";
|
13
|
-
'~orpc': RouterImplementerDef<TContext, TExtraContext, TContract>;
|
14
|
-
constructor(def: RouterImplementerDef<TContext, TExtraContext, TContract>);
|
15
|
-
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<string, unknown>>): RouterImplementer<TContext, MergeContext<TExtraContext, U>, TContract>;
|
16
|
-
router<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(router: U): AdaptedRouter<TContext, U>;
|
17
|
-
lazy<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(loader: () => Promise<{
|
18
|
-
default: U;
|
19
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
20
|
-
}
|
21
|
-
//# sourceMappingURL=router-implementer.d.ts.map
|
package/dist/src/types.d.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { FindGlobalInstanceType } from '@orpc/shared';
|
2
|
-
import type { ANY_PROCEDURE } from './procedure';
|
3
|
-
export type Context = Record<string, any> | undefined;
|
4
|
-
export type WELL_CONTEXT = Record<string, unknown> | undefined;
|
5
|
-
export type MergeContext<TA extends Context, TB extends Context> = TA extends undefined ? TB : TB extends undefined ? TA : TA & TB;
|
6
|
-
export type AbortSignal = FindGlobalInstanceType<'AbortSignal'>;
|
7
|
-
export interface WithSignal {
|
8
|
-
signal?: AbortSignal;
|
9
|
-
}
|
10
|
-
export interface Meta extends WithSignal {
|
11
|
-
path: string[];
|
12
|
-
procedure: ANY_PROCEDURE;
|
13
|
-
}
|
14
|
-
//# sourceMappingURL=types.d.ts.map
|