@orpc/server 0.0.0-next.aa57fb6 → 0.0.0-next.b6be6f0
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-37HIYNDO.js +182 -0
- package/dist/fetch.js +282 -74
- package/dist/index.js +370 -320
- package/dist/src/builder.d.ts +26 -44
- package/dist/src/fetch/composite-handler.d.ts +8 -0
- package/dist/src/fetch/index.d.ts +4 -2
- package/dist/src/fetch/orpc-handler.d.ts +20 -0
- package/dist/src/fetch/orpc-payload-codec.d.ts +16 -0
- package/dist/src/fetch/orpc-procedure-matcher.d.ts +12 -0
- package/dist/src/fetch/super-json.d.ts +12 -0
- package/dist/src/fetch/types.d.ts +14 -33
- package/dist/src/hidden.d.ts +6 -0
- package/dist/src/implementer-chainable.d.ts +10 -0
- package/dist/src/index.d.ts +9 -3
- package/dist/src/lazy-decorated.d.ts +10 -0
- package/dist/src/lazy-utils.d.ts +4 -0
- package/dist/src/lazy.d.ts +6 -11
- package/dist/src/middleware-decorated.d.ts +8 -0
- package/dist/src/middleware.d.ts +3 -6
- package/dist/src/procedure-builder.d.ts +15 -24
- package/dist/src/procedure-client.d.ts +34 -0
- package/dist/src/procedure-decorated.d.ts +14 -0
- package/dist/src/procedure-implementer.d.ts +13 -17
- package/dist/src/procedure.d.ts +15 -24
- package/dist/src/router-builder.d.ts +23 -21
- package/dist/src/router-client.d.ts +25 -0
- package/dist/src/router-implementer.d.ts +18 -21
- package/dist/src/router.d.ts +11 -16
- package/dist/src/types.d.ts +8 -4
- package/package.json +4 -9
- package/dist/chunk-FL4ZAGNE.js +0 -267
- package/dist/src/fetch/handle.d.ts +0 -7
- package/dist/src/fetch/handler.d.ts +0 -3
- package/dist/src/procedure-caller.d.ts +0 -20
- package/dist/src/router-caller.d.ts +0 -22
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Hooks, Value } from '@orpc/shared';
|
3
|
+
import type { Lazy } from './lazy';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
import type { ProcedureClient } from './procedure-client';
|
6
|
+
import type { Meta } from './types';
|
7
|
+
import { type ANY_ROUTER, type Router } from './router';
|
8
|
+
export type RouterClient<TRouter extends ANY_ROUTER | ContractRouter, TClientContext> = TRouter extends Lazy<infer U extends ANY_ROUTER | ContractRouter> ? RouterClient<U, TClientContext> : TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema> | Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? ProcedureClient<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput>, TClientContext> : {
|
9
|
+
[K in keyof TRouter]: TRouter[K] extends ANY_ROUTER | ContractRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
10
|
+
};
|
11
|
+
export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
|
12
|
+
router: TRouter | Lazy<undefined>;
|
13
|
+
/**
|
14
|
+
* This is helpful for logging and analytics.
|
15
|
+
*
|
16
|
+
* @internal
|
17
|
+
*/
|
18
|
+
path?: string[];
|
19
|
+
} & (TRouter extends Router<infer UContext, any> ? undefined extends UContext ? {
|
20
|
+
context?: Value<UContext>;
|
21
|
+
} : {
|
22
|
+
context: Value<UContext>;
|
23
|
+
} : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never, Meta>;
|
24
|
+
export declare function createRouterClient<TRouter extends ANY_ROUTER>(options: CreateRouterClientOptions<TRouter>): RouterClient<TRouter, unknown>;
|
25
|
+
//# sourceMappingURL=router-client.d.ts.map
|
@@ -1,24 +1,21 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ContractRouter } from '@orpc/contract';
|
2
|
+
import type { FlattenLazy } from './lazy';
|
2
3
|
import type { Middleware } from './middleware';
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
router
|
16
|
-
lazy(loader: () => Promise<{
|
17
|
-
default:
|
18
|
-
}>):
|
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>[];
|
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>): 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>>;
|
19
20
|
}
|
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
21
|
//# sourceMappingURL=router-implementer.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { ANY_LAZY,
|
2
|
+
import type { ANY_LAZY, Lazy, Lazyable } from './lazy';
|
3
|
+
import type { ANY_PROCEDURE, Procedure } from './procedure';
|
3
4
|
import type { Context } from './types';
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
export type
|
9
|
-
[K in keyof
|
5
|
+
export type Router<TContext extends Context, TContract extends ContractRouter> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? Procedure<TContext, any, UInputSchema, UOutputSchema, any> : {
|
6
|
+
[K in keyof TContract]: TContract[K] extends ContractRouter ? Router<TContext, TContract[K]> : never;
|
7
|
+
}>;
|
8
|
+
export type ANY_ROUTER = Router<any, any>;
|
9
|
+
export type InferRouterInputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any> ? SchemaInput<UInputSchema> : {
|
10
|
+
[K in keyof T]: T[K] extends ANY_ROUTER ? InferRouterInputs<T[K]> : never;
|
10
11
|
};
|
11
|
-
export type
|
12
|
-
[K in keyof
|
13
|
-
};
|
14
|
-
export declare function toContractRouter(router: ContractRouter | Router<any>): ContractRouter;
|
15
|
-
export type InferRouterInputs<T extends Router<any>> = {
|
16
|
-
[K in keyof T]: T[K] extends Procedure<any, any, infer UInputSchema, any, any> ? SchemaInput<UInputSchema> : T[K] extends Router<any> ? InferRouterInputs<T[K]> : never;
|
17
|
-
};
|
18
|
-
export type InferRouterOutputs<T extends Router<any>> = {
|
19
|
-
[K in keyof T]: T[K] extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput> ? SchemaOutput<UOutputSchema, UFuncOutput> : T[K] extends Router<any> ? InferRouterOutputs<T[K]> : never;
|
12
|
+
export type InferRouterOutputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
|
13
|
+
[K in keyof T]: T[K] extends ANY_ROUTER ? InferRouterOutputs<T[K]> : never;
|
20
14
|
};
|
15
|
+
export declare function getRouterChild<T extends ANY_ROUTER | Lazy<undefined>>(router: T, ...path: string[]): T extends ANY_LAZY ? Lazy<ANY_PROCEDURE | Record<string, ANY_ROUTER> | undefined> : ANY_ROUTER | Lazy<undefined> | undefined;
|
21
16
|
//# sourceMappingURL=router.d.ts.map
|
package/dist/src/types.d.ts
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
import type {
|
2
|
-
export type Context = Record<string,
|
1
|
+
import type { ANY_PROCEDURE } from './procedure';
|
2
|
+
export type Context = Record<string, any> | undefined;
|
3
|
+
export type WELL_CONTEXT = Record<string, unknown> | undefined;
|
3
4
|
export type MergeContext<TA extends Context, TB extends Context> = TA extends undefined ? TB : TB extends undefined ? TA : TA & TB;
|
4
|
-
export interface
|
5
|
+
export interface WithSignal {
|
6
|
+
signal?: AbortSignal;
|
7
|
+
}
|
8
|
+
export interface Meta extends WithSignal {
|
5
9
|
path: string[];
|
6
|
-
procedure:
|
10
|
+
procedure: ANY_PROCEDURE;
|
7
11
|
}
|
8
12
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.b6be6f0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -33,17 +33,12 @@
|
|
33
33
|
"!**/*.tsbuildinfo",
|
34
34
|
"dist"
|
35
35
|
],
|
36
|
-
"peerDependencies": {
|
37
|
-
"zod": ">=3.23.0",
|
38
|
-
"@orpc/zod": "0.0.0-next.aa57fb6"
|
39
|
-
},
|
40
36
|
"dependencies": {
|
41
|
-
"@orpc/contract": "0.0.0-next.
|
42
|
-
"@orpc/shared": "0.0.0-next.
|
43
|
-
"@orpc/transformer": "0.0.0-next.aa57fb6"
|
37
|
+
"@orpc/contract": "0.0.0-next.b6be6f0",
|
38
|
+
"@orpc/shared": "0.0.0-next.b6be6f0"
|
44
39
|
},
|
45
40
|
"devDependencies": {
|
46
|
-
"
|
41
|
+
"zod": "^3.24.1"
|
47
42
|
},
|
48
43
|
"scripts": {
|
49
44
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|
package/dist/chunk-FL4ZAGNE.js
DELETED
@@ -1,267 +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 { trim, value } from "@orpc/shared";
|
49
|
-
import { ORPCError } from "@orpc/shared/error";
|
50
|
-
import { OpenAPIDeserializer } from "@orpc/transformer";
|
51
|
-
|
52
|
-
// src/procedure.ts
|
53
|
-
import {
|
54
|
-
DecoratedContractProcedure,
|
55
|
-
isContractProcedure
|
56
|
-
} from "@orpc/contract";
|
57
|
-
var Procedure = class {
|
58
|
-
constructor(zz$p) {
|
59
|
-
this.zz$p = zz$p;
|
60
|
-
}
|
61
|
-
};
|
62
|
-
var DECORATED_PROCEDURE_SYMBOL = Symbol("DECORATED_PROCEDURE");
|
63
|
-
function decorateProcedure(procedure) {
|
64
|
-
if (DECORATED_PROCEDURE_SYMBOL in procedure) {
|
65
|
-
return procedure;
|
66
|
-
}
|
67
|
-
return Object.assign(createProcedureCaller({
|
68
|
-
procedure,
|
69
|
-
context: void 0
|
70
|
-
}), {
|
71
|
-
[DECORATED_PROCEDURE_SYMBOL]: true,
|
72
|
-
zz$p: procedure.zz$p,
|
73
|
-
prefix(prefix) {
|
74
|
-
return decorateProcedure({
|
75
|
-
zz$p: {
|
76
|
-
...procedure.zz$p,
|
77
|
-
contract: DecoratedContractProcedure.decorate(
|
78
|
-
procedure.zz$p.contract
|
79
|
-
).prefix(prefix)
|
80
|
-
}
|
81
|
-
});
|
82
|
-
},
|
83
|
-
route(opts) {
|
84
|
-
return decorateProcedure({
|
85
|
-
zz$p: {
|
86
|
-
...procedure.zz$p,
|
87
|
-
contract: DecoratedContractProcedure.decorate(
|
88
|
-
procedure.zz$p.contract
|
89
|
-
).route(opts)
|
90
|
-
}
|
91
|
-
});
|
92
|
-
},
|
93
|
-
use(middleware, mapInput) {
|
94
|
-
const middleware_ = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
95
|
-
return decorateProcedure({
|
96
|
-
zz$p: {
|
97
|
-
...procedure.zz$p,
|
98
|
-
middlewares: [middleware_, ...procedure.zz$p.middlewares ?? []]
|
99
|
-
}
|
100
|
-
});
|
101
|
-
}
|
102
|
-
});
|
103
|
-
}
|
104
|
-
function isProcedure(item) {
|
105
|
-
if (item instanceof Procedure)
|
106
|
-
return true;
|
107
|
-
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";
|
108
|
-
}
|
109
|
-
|
110
|
-
// src/procedure-caller.ts
|
111
|
-
function createProcedureCaller(options) {
|
112
|
-
const loadProcedure = async () => {
|
113
|
-
let procedure;
|
114
|
-
if (isLazy(options.procedure)) {
|
115
|
-
procedure = (await loadLazy(options.procedure)).default;
|
116
|
-
} else {
|
117
|
-
procedure = options.procedure;
|
118
|
-
}
|
119
|
-
if (!isProcedure(procedure)) {
|
120
|
-
throw new ORPCError({
|
121
|
-
code: "NOT_FOUND",
|
122
|
-
message: "Not found",
|
123
|
-
cause: new Error(trim(`
|
124
|
-
This error should be caught by the typescript compiler.
|
125
|
-
But if you still see this error, it means that you trying to call a lazy router (expected to be a lazy procedure).
|
126
|
-
`))
|
127
|
-
});
|
128
|
-
}
|
129
|
-
return procedure;
|
130
|
-
};
|
131
|
-
const caller = async (input) => {
|
132
|
-
const path = options.path ?? [];
|
133
|
-
const procedure = await loadProcedure();
|
134
|
-
const input_ = (() => {
|
135
|
-
if (!(input instanceof FormData)) {
|
136
|
-
return input;
|
137
|
-
}
|
138
|
-
const transformer = new OpenAPIDeserializer({
|
139
|
-
schema: procedure.zz$p.contract.zz$cp.InputSchema
|
140
|
-
});
|
141
|
-
return transformer.deserializeAsFormData(input);
|
142
|
-
})();
|
143
|
-
const validInput = (() => {
|
144
|
-
const schema = procedure.zz$p.contract.zz$cp.InputSchema;
|
145
|
-
if (!schema) {
|
146
|
-
return input_;
|
147
|
-
}
|
148
|
-
try {
|
149
|
-
return schema.parse(input_);
|
150
|
-
} catch (e) {
|
151
|
-
throw new ORPCError({
|
152
|
-
message: "Validation input failed",
|
153
|
-
code: "BAD_REQUEST",
|
154
|
-
cause: e
|
155
|
-
});
|
156
|
-
}
|
157
|
-
})();
|
158
|
-
const middlewares = procedure.zz$p.middlewares ?? [];
|
159
|
-
let currentMidIndex = 0;
|
160
|
-
let currentContext = await value(options.context);
|
161
|
-
const next = async (nextOptions) => {
|
162
|
-
const mid = middlewares[currentMidIndex];
|
163
|
-
currentMidIndex += 1;
|
164
|
-
currentContext = mergeContext(currentContext, nextOptions.context);
|
165
|
-
if (mid) {
|
166
|
-
return await mid(validInput, currentContext, {
|
167
|
-
path,
|
168
|
-
procedure,
|
169
|
-
next,
|
170
|
-
output: (output2) => ({ output: output2, context: void 0 })
|
171
|
-
});
|
172
|
-
} else {
|
173
|
-
return {
|
174
|
-
output: await await procedure.zz$p.func(validInput, currentContext, {
|
175
|
-
path,
|
176
|
-
procedure
|
177
|
-
}),
|
178
|
-
context: currentContext
|
179
|
-
};
|
180
|
-
}
|
181
|
-
};
|
182
|
-
const output = (await next({})).output;
|
183
|
-
const validOutput = await (async () => {
|
184
|
-
const schema = procedure.zz$p.contract.zz$cp.OutputSchema;
|
185
|
-
if (!schema) {
|
186
|
-
return output;
|
187
|
-
}
|
188
|
-
const result = await schema.safeParseAsync(output);
|
189
|
-
if (result.error) {
|
190
|
-
throw new ORPCError({
|
191
|
-
message: "Validation output failed",
|
192
|
-
code: "INTERNAL_SERVER_ERROR",
|
193
|
-
cause: result.error
|
194
|
-
});
|
195
|
-
}
|
196
|
-
return result.data;
|
197
|
-
})();
|
198
|
-
return validOutput;
|
199
|
-
};
|
200
|
-
return caller;
|
201
|
-
}
|
202
|
-
|
203
|
-
// src/lazy.ts
|
204
|
-
var LAZY_LOADER_SYMBOL = Symbol("ORPC_LAZY_LOADER");
|
205
|
-
function createLazy(loader) {
|
206
|
-
return {
|
207
|
-
[LAZY_LOADER_SYMBOL]: loader
|
208
|
-
};
|
209
|
-
}
|
210
|
-
function loadLazy(lazy) {
|
211
|
-
return lazy[LAZY_LOADER_SYMBOL]();
|
212
|
-
}
|
213
|
-
function isLazy(item) {
|
214
|
-
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_LOADER_SYMBOL in item && typeof item[LAZY_LOADER_SYMBOL] === "function";
|
215
|
-
}
|
216
|
-
function createFlattenLazy(lazy) {
|
217
|
-
const flattenLoader = async () => {
|
218
|
-
let current = await loadLazy(lazy);
|
219
|
-
while (true) {
|
220
|
-
if (!isLazy(current.default)) {
|
221
|
-
break;
|
222
|
-
}
|
223
|
-
current = await loadLazy(current.default);
|
224
|
-
}
|
225
|
-
return current;
|
226
|
-
};
|
227
|
-
const flattenLazy = {
|
228
|
-
[LAZY_LOADER_SYMBOL]: flattenLoader
|
229
|
-
};
|
230
|
-
return flattenLazy;
|
231
|
-
}
|
232
|
-
function decorateLazy(lazy) {
|
233
|
-
const flattenLazy = createFlattenLazy(lazy);
|
234
|
-
const procedureCaller = createProcedureCaller({
|
235
|
-
procedure: flattenLazy,
|
236
|
-
context: void 0
|
237
|
-
});
|
238
|
-
Object.assign(procedureCaller, flattenLazy);
|
239
|
-
const recursive = new Proxy(procedureCaller, {
|
240
|
-
get(target, key) {
|
241
|
-
if (typeof key !== "string") {
|
242
|
-
return Reflect.get(target, key);
|
243
|
-
}
|
244
|
-
return decorateLazy(createLazy(async () => {
|
245
|
-
const current = await loadLazy(flattenLazy);
|
246
|
-
return { default: current.default[key] };
|
247
|
-
}));
|
248
|
-
}
|
249
|
-
});
|
250
|
-
return recursive;
|
251
|
-
}
|
252
|
-
|
253
|
-
export {
|
254
|
-
mergeContext,
|
255
|
-
decorateMiddleware,
|
256
|
-
LAZY_LOADER_SYMBOL,
|
257
|
-
createLazy,
|
258
|
-
loadLazy,
|
259
|
-
isLazy,
|
260
|
-
createFlattenLazy,
|
261
|
-
decorateLazy,
|
262
|
-
createProcedureCaller,
|
263
|
-
Procedure,
|
264
|
-
decorateProcedure,
|
265
|
-
isProcedure
|
266
|
-
};
|
267
|
-
//# sourceMappingURL=chunk-FL4ZAGNE.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,20 +0,0 @@
|
|
1
|
-
import type { SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Lazy } from './lazy';
|
3
|
-
import { type Value } from '@orpc/shared';
|
4
|
-
import { type ANY_LAZY_PROCEDURE, type ANY_PROCEDURE, type Procedure } from './procedure';
|
5
|
-
export interface CreateProcedureCallerOptions<TProcedure extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE> {
|
6
|
-
procedure: TProcedure;
|
7
|
-
/**
|
8
|
-
* The context used when calling the procedure.
|
9
|
-
*/
|
10
|
-
context: Value<TProcedure extends Procedure<infer UContext, any, any, any, any> | Lazy<Procedure<infer UContext, any, any, any, any>> ? UContext : never>;
|
11
|
-
/**
|
12
|
-
* This is helpful for logging and analytics.
|
13
|
-
*
|
14
|
-
* @internal
|
15
|
-
*/
|
16
|
-
path?: string[];
|
17
|
-
}
|
18
|
-
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>> ? (...input: [input: SchemaInput<UInputSchema> | FormData] | (undefined extends SchemaInput<UInputSchema> ? [] : never)) => Promise<SchemaOutput<UOutputSchema, UFuncOutput>> : never;
|
19
|
-
export declare function createProcedureCaller<TProcedure extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE>(options: CreateProcedureCallerOptions<TProcedure>): ProcedureCaller<TProcedure>;
|
20
|
-
//# sourceMappingURL=procedure-caller.d.ts.map
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { 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>> {
|
6
|
-
router: TRouter;
|
7
|
-
/**
|
8
|
-
* The context used when calling the procedure.
|
9
|
-
*/
|
10
|
-
context: Value<TRouter extends Router<infer UContext> ? UContext : never>;
|
11
|
-
/**
|
12
|
-
* This is helpful for logging and analytics.
|
13
|
-
*
|
14
|
-
* @internal
|
15
|
-
*/
|
16
|
-
basePath?: string[];
|
17
|
-
}
|
18
|
-
export type RouterCaller<TRouter extends Router<any>> = {
|
19
|
-
[K in keyof TRouter]: TRouter[K] extends ANY_PROCEDURE | ANY_LAZY_PROCEDURE ? ProcedureCaller<TRouter[K]> : TRouter[K] extends Router<any> ? RouterCaller<TRouter[K]> : never;
|
20
|
-
};
|
21
|
-
export declare function createRouterCaller<TRouter extends Router<any>>(options: CreateRouterCallerOptions<TRouter>): RouterCaller<TRouter>;
|
22
|
-
//# sourceMappingURL=router-caller.d.ts.map
|