@orpc/server 0.0.0-next.8b5a6d6 → 0.0.0-next.8f101b9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) 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 +11 -108
  5. package/dist/hono.js +30 -0
  6. package/dist/index.js +298 -375
  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 +46 -42
  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 +15 -11
  32. package/dist/src/lazy-utils.d.ts +6 -0
  33. package/dist/src/lazy.d.ts +13 -14
  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 -28
  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 -17
  44. package/package.json +22 -11
  45. package/dist/chunk-3JMSDC5L.js +0 -274
  46. package/dist/src/fetch/handle.d.ts +0 -7
  47. package/dist/src/fetch/handler.d.ts +0 -3
  48. package/dist/src/fetch/index.d.ts +0 -4
  49. package/dist/src/fetch/types.d.ts +0 -28
  50. package/dist/src/procedure-builder.d.ts +0 -31
  51. package/dist/src/procedure-caller.d.ts +0 -26
  52. package/dist/src/procedure-implementer.d.ts +0 -22
  53. package/dist/src/router-builder.d.ts +0 -27
  54. package/dist/src/router-caller.d.ts +0 -25
  55. package/dist/src/router-implementer.d.ts +0 -24
  56. package/dist/src/types.d.ts +0 -14
  57. package/dist/src/utils.d.ts +0 -3
@@ -1,274 +0,0 @@
1
- // src/utils.ts
2
- function mergeContext(a, b) {
3
- if (!a)
4
- return b;
5
- if (!b)
6
- return a;
7
- return {
8
- ...a,
9
- ...b
10
- };
11
- }
12
-
13
- // src/middleware.ts
14
- var decoratedMiddlewareSymbol = Symbol("\u{1F512}decoratedMiddleware");
15
- function decorateMiddleware(middleware) {
16
- if (Reflect.get(middleware, decoratedMiddlewareSymbol)) {
17
- return middleware;
18
- }
19
- const concat = (concatMiddleware, mapInput2) => {
20
- const concatMiddleware_ = mapInput2 ? decorateMiddleware(concatMiddleware).mapInput(mapInput2) : concatMiddleware;
21
- return decorateMiddleware(async (input, context, meta, ...rest) => {
22
- const input_ = input;
23
- const context_ = context;
24
- const meta_ = meta;
25
- const next = async (options) => {
26
- return concatMiddleware_(input_, mergeContext(context_, options.context), meta_, ...rest);
27
- };
28
- const m1 = await middleware(input_, context_, {
29
- ...meta_,
30
- next
31
- }, ...rest);
32
- return m1;
33
- });
34
- };
35
- const mapInput = (map) => {
36
- return decorateMiddleware(
37
- (input, ...rest) => middleware(map(input), ...rest)
38
- );
39
- };
40
- return Object.assign(middleware, {
41
- [decoratedMiddlewareSymbol]: true,
42
- concat,
43
- mapInput
44
- });
45
- }
46
-
47
- // src/procedure-caller.ts
48
- import { executeWithHooks, trim, value } from "@orpc/shared";
49
- import { ORPCError } from "@orpc/shared/error";
50
-
51
- // src/procedure.ts
52
- import {
53
- DecoratedContractProcedure,
54
- isContractProcedure
55
- } from "@orpc/contract";
56
- var Procedure = class {
57
- constructor(zz$p) {
58
- this.zz$p = zz$p;
59
- }
60
- };
61
- var DECORATED_PROCEDURE_SYMBOL = Symbol("DECORATED_PROCEDURE");
62
- function decorateProcedure(procedure) {
63
- if (DECORATED_PROCEDURE_SYMBOL in procedure) {
64
- return procedure;
65
- }
66
- return Object.assign(createProcedureCaller({
67
- procedure,
68
- context: void 0
69
- }), {
70
- [DECORATED_PROCEDURE_SYMBOL]: true,
71
- zz$p: procedure.zz$p,
72
- prefix(prefix) {
73
- return decorateProcedure({
74
- zz$p: {
75
- ...procedure.zz$p,
76
- contract: DecoratedContractProcedure.decorate(
77
- procedure.zz$p.contract
78
- ).prefix(prefix)
79
- }
80
- });
81
- },
82
- route(opts) {
83
- return decorateProcedure({
84
- zz$p: {
85
- ...procedure.zz$p,
86
- contract: DecoratedContractProcedure.decorate(
87
- procedure.zz$p.contract
88
- ).route(opts)
89
- }
90
- });
91
- },
92
- use(middleware, mapInput) {
93
- const middleware_ = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
94
- return decorateProcedure({
95
- zz$p: {
96
- ...procedure.zz$p,
97
- middlewares: [middleware_, ...procedure.zz$p.middlewares ?? []]
98
- }
99
- });
100
- }
101
- });
102
- }
103
- function isProcedure(item) {
104
- if (item instanceof Procedure)
105
- return true;
106
- return (typeof item === "object" || typeof item === "function") && item !== null && "zz$p" in item && typeof item.zz$p === "object" && item.zz$p !== null && "contract" in item.zz$p && isContractProcedure(item.zz$p.contract) && "func" in item.zz$p && typeof item.zz$p.func === "function";
107
- }
108
-
109
- // src/procedure-caller.ts
110
- function createProcedureCaller(options) {
111
- const caller = async (...args) => {
112
- const [input, callerOptions] = args;
113
- const path = options.path ?? [];
114
- const procedure = await loadProcedure(options.procedure);
115
- const context = await value(options.context);
116
- const execute = async () => {
117
- const validInput = (() => {
118
- const schema = procedure.zz$p.contract.zz$cp.InputSchema;
119
- if (!schema) {
120
- return input;
121
- }
122
- try {
123
- return schema.parse(input);
124
- } catch (e) {
125
- throw new ORPCError({
126
- message: "Validation input failed",
127
- code: "BAD_REQUEST",
128
- cause: e
129
- });
130
- }
131
- })();
132
- const meta = {
133
- path,
134
- procedure,
135
- signal: callerOptions?.signal
136
- };
137
- const middlewares = procedure.zz$p.middlewares ?? [];
138
- let currentMidIndex = 0;
139
- let currentContext = context;
140
- const next = async (nextOptions) => {
141
- const mid = middlewares[currentMidIndex];
142
- currentMidIndex += 1;
143
- currentContext = mergeContext(currentContext, nextOptions.context);
144
- if (mid) {
145
- return await mid(validInput, currentContext, {
146
- ...meta,
147
- next,
148
- output: (output3) => ({ output: output3, context: void 0 })
149
- });
150
- } else {
151
- return {
152
- output: await await procedure.zz$p.func(validInput, currentContext, meta),
153
- context: currentContext
154
- };
155
- }
156
- };
157
- const output2 = (await next({})).output;
158
- const validOutput = await (async () => {
159
- const schema = procedure.zz$p.contract.zz$cp.OutputSchema;
160
- if (!schema) {
161
- return output2;
162
- }
163
- const result = await schema.safeParseAsync(output2);
164
- if (result.error) {
165
- throw new ORPCError({
166
- message: "Validation output failed",
167
- code: "INTERNAL_SERVER_ERROR",
168
- cause: result.error
169
- });
170
- }
171
- return result.data;
172
- })();
173
- return validOutput;
174
- };
175
- const output = await executeWithHooks({
176
- hooks: options,
177
- input,
178
- context,
179
- meta: {
180
- path,
181
- procedure
182
- },
183
- execute
184
- });
185
- return output;
186
- };
187
- return caller;
188
- }
189
- async function loadProcedure(procedure) {
190
- let loadedProcedure;
191
- if (isLazy(procedure)) {
192
- loadedProcedure = (await loadLazy(procedure)).default;
193
- } else {
194
- loadedProcedure = procedure;
195
- }
196
- if (!isProcedure(loadedProcedure)) {
197
- throw new ORPCError({
198
- code: "NOT_FOUND",
199
- message: "Not found",
200
- cause: new Error(trim(`
201
- This error should be caught by the typescript compiler.
202
- But if you still see this error, it means that you trying to call a lazy router (expected to be a lazy procedure).
203
- `))
204
- });
205
- }
206
- return loadedProcedure;
207
- }
208
-
209
- // src/lazy.ts
210
- var LAZY_LOADER_SYMBOL = Symbol("ORPC_LAZY_LOADER");
211
- function createLazy(loader) {
212
- return {
213
- [LAZY_LOADER_SYMBOL]: loader
214
- };
215
- }
216
- function loadLazy(lazy) {
217
- return lazy[LAZY_LOADER_SYMBOL]();
218
- }
219
- function isLazy(item) {
220
- return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_LOADER_SYMBOL in item && typeof item[LAZY_LOADER_SYMBOL] === "function";
221
- }
222
- function createFlattenLazy(lazy) {
223
- const flattenLoader = async () => {
224
- let current = await loadLazy(lazy);
225
- while (true) {
226
- if (!isLazy(current.default)) {
227
- break;
228
- }
229
- current = await loadLazy(current.default);
230
- }
231
- return current;
232
- };
233
- const flattenLazy = {
234
- [LAZY_LOADER_SYMBOL]: flattenLoader
235
- };
236
- return flattenLazy;
237
- }
238
- function decorateLazy(lazy) {
239
- const flattenLazy = createFlattenLazy(lazy);
240
- const procedureCaller = createProcedureCaller({
241
- procedure: flattenLazy,
242
- context: void 0
243
- });
244
- Object.assign(procedureCaller, flattenLazy);
245
- const recursive = new Proxy(procedureCaller, {
246
- get(target, key) {
247
- if (typeof key !== "string") {
248
- return Reflect.get(target, key);
249
- }
250
- return decorateLazy(createLazy(async () => {
251
- const current = await loadLazy(flattenLazy);
252
- return { default: current.default[key] };
253
- }));
254
- }
255
- });
256
- return recursive;
257
- }
258
-
259
- export {
260
- mergeContext,
261
- decorateMiddleware,
262
- LAZY_LOADER_SYMBOL,
263
- createLazy,
264
- loadLazy,
265
- isLazy,
266
- createFlattenLazy,
267
- decorateLazy,
268
- createProcedureCaller,
269
- loadProcedure,
270
- Procedure,
271
- decorateProcedure,
272
- isProcedure
273
- };
274
- //# sourceMappingURL=chunk-3JMSDC5L.js.map
@@ -1,7 +0,0 @@
1
- import type { Router } from '../router';
2
- import type { FetchHandler, FetchHandlerOptions } from './types';
3
- export type HandleFetchRequestOptions<TRouter extends Router<any>> = FetchHandlerOptions<TRouter> & {
4
- handlers: readonly [FetchHandler, ...FetchHandler[]];
5
- };
6
- export declare function handleFetchRequest<TRouter extends Router<any>>(options: HandleFetchRequestOptions<TRouter>): Promise<Response>;
7
- //# sourceMappingURL=handle.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { FetchHandler } from './types';
2
- export declare function createORPCHandler(): FetchHandler;
3
- //# sourceMappingURL=handler.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from './handle';
2
- export * from './handler';
3
- export * from './types';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,28 +0,0 @@
1
- import type { Hooks, PartialOnUndefinedDeep, Value } from '@orpc/shared';
2
- import type { Router } from '../router';
3
- import type { CallerOptions } from '../types';
4
- export type FetchHandlerOptions<TRouter extends Router<any>> = {
5
- /**
6
- * The `router` used for handling the request and routing,
7
- *
8
- */
9
- router: TRouter;
10
- /**
11
- * The request need to be handled.
12
- */
13
- request: Request;
14
- /**
15
- * Remove the prefix from the request path.
16
- *
17
- * @example /orpc
18
- * @example /api
19
- */
20
- prefix?: string;
21
- } & PartialOnUndefinedDeep<{
22
- /**
23
- * The context used to handle the request.
24
- */
25
- context: Value<TRouter extends Router<infer UContext> ? UContext : never>;
26
- }> & CallerOptions & Hooks<Request, Response, TRouter extends Router<infer UContext> ? UContext : never, CallerOptions>;
27
- export type FetchHandler = <TRouter extends Router<any>>(options: FetchHandlerOptions<TRouter>) => Promise<Response | undefined>;
28
- //# sourceMappingURL=types.d.ts.map
@@ -1,31 +0,0 @@
1
- import type { MapInputMiddleware, Middleware } from './middleware';
2
- import type { Context, MergeContext } from './types';
3
- import { type ContractProcedure, type RouteOptions, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
4
- import { type DecoratedProcedure, type ProcedureFunc } from './procedure';
5
- import { ProcedureImplementer } from './procedure-implementer';
6
- export declare class ProcedureBuilder<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> {
7
- zz$pb: {
8
- contract: ContractProcedure<TInputSchema, TOutputSchema>;
9
- middlewares?: Middleware<any, any, any, any>[];
10
- };
11
- constructor(zz$pb: {
12
- contract: ContractProcedure<TInputSchema, TOutputSchema>;
13
- middlewares?: Middleware<any, any, any, any>[];
14
- });
15
- /**
16
- * Self chainable
17
- */
18
- route(opts: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TInputSchema, TOutputSchema>;
19
- input<USchema extends Schema = undefined>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilder<TContext, TExtraContext, USchema, TOutputSchema>;
20
- output<USchema extends Schema = undefined>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilder<TContext, TExtraContext, TInputSchema, USchema>;
21
- /**
22
- * Convert to ProcedureBuilder
23
- */
24
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
25
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UMappedInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
26
- /**
27
- * Convert to Procedure
28
- */
29
- func<UFuncOutput extends SchemaOutput<TOutputSchema>>(func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
30
- }
31
- //# sourceMappingURL=procedure-builder.d.ts.map
@@ -1,26 +0,0 @@
1
- import type { SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { Hooks, PartialOnUndefinedDeep, Value } from '@orpc/shared';
3
- import type { Lazy } from './lazy';
4
- import type { ANY_LAZY_PROCEDURE, ANY_PROCEDURE, Procedure } from './procedure';
5
- import type { Caller } from './types';
6
- export type CreateProcedureCallerOptions<T extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE> = T extends Procedure<infer UContext, any, any, infer UOutputSchema, infer UFuncOutput> | Lazy<Procedure<infer UContext, any, any, infer UOutputSchema, infer UFuncOutput>> ? {
7
- procedure: T;
8
- /**
9
- * This is helpful for logging and analytics.
10
- *
11
- * @internal
12
- */
13
- path?: string[];
14
- } & PartialOnUndefinedDeep<{
15
- /**
16
- * The context used when calling the procedure.
17
- */
18
- context: Value<UContext>;
19
- }> & Hooks<unknown, SchemaOutput<UOutputSchema, UFuncOutput>, UContext, {
20
- path: string[];
21
- procedure: ANY_PROCEDURE;
22
- }> : never;
23
- export type ProcedureCaller<TProcedure extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE> = TProcedure extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> | Lazy<Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput>> ? Caller<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput>> : never;
24
- export declare function createProcedureCaller<TProcedure extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE>(options: CreateProcedureCallerOptions<TProcedure>): ProcedureCaller<TProcedure>;
25
- export declare function loadProcedure(procedure: ANY_PROCEDURE | ANY_LAZY_PROCEDURE): Promise<ANY_PROCEDURE>;
26
- //# sourceMappingURL=procedure-caller.d.ts.map
@@ -1,22 +0,0 @@
1
- import type { ContractProcedure, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { DecoratedLazy } from './lazy';
3
- import type { DecoratedProcedure, Procedure, ProcedureFunc } from './procedure';
4
- import type { Context, MergeContext } from './types';
5
- import { type MapInputMiddleware, type Middleware } from './middleware';
6
- export declare class ProcedureImplementer<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> {
7
- zz$pi: {
8
- contract: ContractProcedure<TInputSchema, TOutputSchema>;
9
- middlewares?: Middleware<any, any, any, any>[];
10
- };
11
- constructor(zz$pi: {
12
- contract: ContractProcedure<TInputSchema, TOutputSchema>;
13
- middlewares?: Middleware<any, any, any, any>[];
14
- });
15
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
16
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UMappedInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
17
- func<UFuncOutput extends SchemaOutput<TOutputSchema>>(func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
18
- lazy<U extends Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, SchemaOutput<TOutputSchema>>>(loader: () => Promise<{
19
- default: U;
20
- }>): DecoratedLazy<U>;
21
- }
22
- //# sourceMappingURL=procedure-implementer.d.ts.map
@@ -1,27 +0,0 @@
1
- import type { DecoratedLazy } from './lazy';
2
- import type { HandledRouter, Router } from './router';
3
- import type { Context, MergeContext } from './types';
4
- import { type HTTPPath } from '@orpc/contract';
5
- import { type MapInputMiddleware, type Middleware } from './middleware';
6
- export declare const LAZY_ROUTER_PREFIX_SYMBOL: unique symbol;
7
- export declare class RouterBuilder<TContext extends Context, TExtraContext extends Context> {
8
- zz$rb: {
9
- prefix?: HTTPPath;
10
- tags?: string[];
11
- middlewares?: Middleware<any, any, any, any>[];
12
- };
13
- constructor(zz$rb: {
14
- prefix?: HTTPPath;
15
- tags?: string[];
16
- middlewares?: Middleware<any, any, any, any>[];
17
- });
18
- prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
19
- tags(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
20
- use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, unknown, unknown>): RouterBuilder<TContext, MergeContext<TExtraContext, UExtraContext>>;
21
- 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>): RouterBuilder<TContext, MergeContext<TExtraContext, UExtraContext>>;
22
- router<URouter extends Router<TContext>>(router: URouter): HandledRouter<URouter>;
23
- lazy<U extends Router<TContext>>(loader: () => Promise<{
24
- default: U;
25
- }>): DecoratedLazy<U>;
26
- }
27
- //# sourceMappingURL=router-builder.d.ts.map
@@ -1,25 +0,0 @@
1
- import type { Hooks, Value } from '@orpc/shared';
2
- import type { ANY_LAZY_PROCEDURE, ANY_PROCEDURE } from './procedure';
3
- import type { Router } from './router';
4
- import { type ProcedureCaller } from './procedure-caller';
5
- export interface CreateRouterCallerOptions<TRouter extends Router<any>> extends Hooks<unknown, unknown, TRouter extends Router<infer UContext> ? UContext : never, {
6
- path: string[];
7
- procedure: ANY_PROCEDURE;
8
- }> {
9
- router: TRouter;
10
- /**
11
- * The context used when calling the procedure.
12
- */
13
- context: Value<TRouter extends Router<infer UContext> ? UContext : never>;
14
- /**
15
- * This is helpful for logging and analytics.
16
- *
17
- * @internal
18
- */
19
- basePath?: string[];
20
- }
21
- export type RouterCaller<TRouter extends Router<any>> = {
22
- [K in keyof TRouter]: TRouter[K] extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE ? ProcedureCaller<TRouter[K]> : TRouter[K] extends Router<any> ? RouterCaller<TRouter[K]> : never;
23
- };
24
- export declare function createRouterCaller<TRouter extends Router<any>>(options: CreateRouterCallerOptions<TRouter>): RouterCaller<TRouter>;
25
- //# sourceMappingURL=router-caller.d.ts.map
@@ -1,24 +0,0 @@
1
- import type { DecoratedLazy } from './lazy';
2
- import type { Middleware } from './middleware';
3
- import type { HandledRouter, RouterWithContract } from './router';
4
- import type { Context } from './types';
5
- import { type ContractProcedure, type ContractRouter } from '@orpc/contract';
6
- import { ProcedureImplementer } from './procedure-implementer';
7
- export declare const ROUTER_CONTRACT_SYMBOL: unique symbol;
8
- export declare class RouterImplementer<TContext extends Context, TContract extends ContractRouter> {
9
- zz$ri: {
10
- contract: TContract;
11
- };
12
- constructor(zz$ri: {
13
- contract: TContract;
14
- });
15
- router(router: RouterWithContract<TContext, TContract>): HandledRouter<RouterWithContract<TContext, TContract>>;
16
- lazy(loader: () => Promise<{
17
- default: RouterWithContract<TContext, TContract>;
18
- }>): DecoratedLazy<RouterWithContract<TContext, TContract>>;
19
- }
20
- export type ChainedRouterImplementer<TContext extends Context, TContract extends ContractRouter, TExtraContext extends Context> = {
21
- [K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? ChainedRouterImplementer<TContext, TContract[K], TExtraContext> : never;
22
- } & RouterImplementer<TContext, TContract>;
23
- export declare function chainRouterImplementer<TContext extends Context, TContract extends ContractRouter, TExtraContext extends Context>(contract: TContract, middlewares?: Middleware<any, any, any, any>[]): ChainedRouterImplementer<TContext, TContract, TExtraContext>;
24
- //# sourceMappingURL=router-implementer.d.ts.map
@@ -1,14 +0,0 @@
1
- import type { WELL_DEFINED_PROCEDURE } from './procedure';
2
- export type Context = Record<string, unknown> | undefined;
3
- export type MergeContext<TA extends Context, TB extends Context> = TA extends undefined ? TB : TB extends undefined ? TA : TA & TB;
4
- export interface CallerOptions {
5
- signal?: AbortSignal;
6
- }
7
- export interface Caller<TInput, TOutput> {
8
- (...opts: [input: TInput, options?: CallerOptions] | (undefined extends TInput ? [] : never)): Promise<TOutput>;
9
- }
10
- export interface Meta extends CallerOptions {
11
- path: string[];
12
- procedure: WELL_DEFINED_PROCEDURE;
13
- }
14
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { Context, MergeContext } from './types';
2
- export declare function mergeContext<A extends Context, B extends Context>(a: A, b: B): MergeContext<A, B>;
3
- //# sourceMappingURL=utils.d.ts.map