@orpc/server 0.19.0 → 0.21.0
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-FN62GL22.js → chunk-37HIYNDO.js} +3 -3
- package/dist/fetch.js +33 -4
- package/dist/index.js +7 -7
- package/dist/src/builder.d.ts +1 -1
- package/dist/src/fetch/orpc-payload-codec.d.ts +9 -2
- package/dist/src/lazy-decorated.d.ts +1 -1
- package/dist/src/procedure-builder.d.ts +1 -1
- package/dist/src/procedure-client.d.ts +11 -6
- package/dist/src/procedure-decorated.d.ts +8 -8
- package/dist/src/procedure-implementer.d.ts +1 -1
- package/dist/src/procedure.d.ts +7 -7
- package/dist/src/router-client.d.ts +3 -3
- package/package.json +3 -3
@@ -23,7 +23,7 @@ function isProcedure(item) {
|
|
23
23
|
if (item instanceof Procedure) {
|
24
24
|
return true;
|
25
25
|
}
|
26
|
-
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) && "
|
26
|
+
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";
|
27
27
|
}
|
28
28
|
|
29
29
|
// src/lazy.ts
|
@@ -129,7 +129,7 @@ async function executeMiddlewareChain(procedure, input, context, meta) {
|
|
129
129
|
});
|
130
130
|
}
|
131
131
|
const result = {
|
132
|
-
output: await procedure["~orpc"].
|
132
|
+
output: await procedure["~orpc"].handler(input, currentContext, meta),
|
133
133
|
context: currentContext
|
134
134
|
};
|
135
135
|
return result;
|
@@ -179,4 +179,4 @@ export {
|
|
179
179
|
createProcedureClient,
|
180
180
|
getRouterChild
|
181
181
|
};
|
182
|
-
//# sourceMappingURL=chunk-
|
182
|
+
//# sourceMappingURL=chunk-37HIYNDO.js.map
|
package/dist/fetch.js
CHANGED
@@ -3,7 +3,7 @@ import {
|
|
3
3
|
getRouterChild,
|
4
4
|
isProcedure,
|
5
5
|
unlazy
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-37HIYNDO.js";
|
7
7
|
|
8
8
|
// src/fetch/composite-handler.ts
|
9
9
|
var CompositeHandler = class {
|
@@ -148,9 +148,24 @@ function deserialize({
|
|
148
148
|
|
149
149
|
// src/fetch/orpc-payload-codec.ts
|
150
150
|
var ORPCPayloadCodec = class {
|
151
|
-
|
151
|
+
/**
|
152
|
+
* If method is GET, the payload will be encoded as query string.
|
153
|
+
* If method is GET and payload contain file, the method will be fallback to fallbackMethod. (fallbackMethod = GET will force to use GET method)
|
154
|
+
*/
|
155
|
+
encode(payload, method = "POST", fallbackMethod = "POST") {
|
152
156
|
const { data, meta } = serialize(payload);
|
153
157
|
const { maps, values } = findDeepMatches((v) => v instanceof Blob, data);
|
158
|
+
if (method === "GET" && (values.length === 0 || fallbackMethod === "GET")) {
|
159
|
+
const query = new URLSearchParams({
|
160
|
+
data: JSON.stringify(data),
|
161
|
+
meta: JSON.stringify(meta)
|
162
|
+
});
|
163
|
+
return {
|
164
|
+
query,
|
165
|
+
method: "GET"
|
166
|
+
};
|
167
|
+
}
|
168
|
+
const nonGETMethod = method === "GET" ? fallbackMethod : method;
|
154
169
|
if (values.length > 0) {
|
155
170
|
const form = new FormData();
|
156
171
|
if (data !== void 0) {
|
@@ -162,17 +177,31 @@ var ORPCPayloadCodec = class {
|
|
162
177
|
const value = values[i];
|
163
178
|
form.append(i, value);
|
164
179
|
}
|
165
|
-
return {
|
180
|
+
return {
|
181
|
+
body: form,
|
182
|
+
method: nonGETMethod
|
183
|
+
};
|
166
184
|
}
|
167
185
|
return {
|
168
186
|
body: JSON.stringify({ data, meta }),
|
169
187
|
headers: new Headers({
|
170
188
|
"content-type": "application/json"
|
171
|
-
})
|
189
|
+
}),
|
190
|
+
method: nonGETMethod
|
172
191
|
};
|
173
192
|
}
|
174
193
|
async decode(re) {
|
175
194
|
try {
|
195
|
+
if ("method" in re && re.method === "GET") {
|
196
|
+
const url = new URL(re.url);
|
197
|
+
const query = url.searchParams;
|
198
|
+
const data = JSON.parse(query.getAll("data").at(-1));
|
199
|
+
const meta = JSON.parse(query.getAll("meta").at(-1));
|
200
|
+
return deserialize({
|
201
|
+
data,
|
202
|
+
meta
|
203
|
+
});
|
204
|
+
}
|
176
205
|
if (re.headers.get("content-type")?.startsWith("multipart/form-data")) {
|
177
206
|
const form = await re.formData();
|
178
207
|
const rawData = form.get("data");
|
package/dist/index.js
CHANGED
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
lazy,
|
10
10
|
mergeContext,
|
11
11
|
unlazy
|
12
|
-
} from "./chunk-
|
12
|
+
} from "./chunk-37HIYNDO.js";
|
13
13
|
|
14
14
|
// src/builder.ts
|
15
15
|
import { ContractProcedure } from "@orpc/contract";
|
@@ -110,11 +110,11 @@ var ProcedureImplementer = class _ProcedureImplementer {
|
|
110
110
|
middlewares: [...this["~orpc"].middlewares ?? [], mappedMiddleware]
|
111
111
|
});
|
112
112
|
}
|
113
|
-
|
113
|
+
handler(handler) {
|
114
114
|
return decorateProcedure(new Procedure({
|
115
115
|
middlewares: this["~orpc"].middlewares,
|
116
116
|
contract: this["~orpc"].contract,
|
117
|
-
|
117
|
+
handler
|
118
118
|
}));
|
119
119
|
}
|
120
120
|
};
|
@@ -358,11 +358,11 @@ var ProcedureBuilder = class _ProcedureBuilder {
|
|
358
358
|
middlewares: this["~orpc"].middlewares
|
359
359
|
}).use(middleware, mapInput);
|
360
360
|
}
|
361
|
-
|
361
|
+
handler(handler) {
|
362
362
|
return decorateProcedure(new Procedure({
|
363
363
|
middlewares: this["~orpc"].middlewares,
|
364
364
|
contract: this["~orpc"].contract,
|
365
|
-
|
365
|
+
handler
|
366
366
|
}));
|
367
367
|
}
|
368
368
|
};
|
@@ -416,14 +416,14 @@ var Builder = class _Builder {
|
|
416
416
|
})
|
417
417
|
});
|
418
418
|
}
|
419
|
-
|
419
|
+
handler(handler) {
|
420
420
|
return decorateProcedure(new Procedure({
|
421
421
|
middlewares: this["~orpc"].middlewares,
|
422
422
|
contract: new ContractProcedure({
|
423
423
|
InputSchema: void 0,
|
424
424
|
OutputSchema: void 0
|
425
425
|
}),
|
426
|
-
|
426
|
+
handler
|
427
427
|
}));
|
428
428
|
}
|
429
429
|
prefix(prefix) {
|
package/dist/src/builder.d.ts
CHANGED
@@ -23,7 +23,7 @@ export declare class Builder<TContext extends Context, TExtraContext extends Con
|
|
23
23
|
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, undefined, undefined>;
|
24
24
|
input<USchema extends Schema = undefined>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilder<TContext, TExtraContext, USchema, undefined>;
|
25
25
|
output<USchema extends Schema = undefined>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilder<TContext, TExtraContext, undefined, USchema>;
|
26
|
-
|
26
|
+
handler<UFuncOutput = undefined>(handler: ProcedureFunc<TContext, TExtraContext, undefined, undefined, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput>;
|
27
27
|
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
|
28
28
|
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
|
29
29
|
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U>;
|
@@ -1,7 +1,14 @@
|
|
1
|
+
import type { HTTPMethod } from '@orpc/contract';
|
1
2
|
export declare class ORPCPayloadCodec {
|
2
|
-
|
3
|
-
|
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;
|
4
10
|
headers?: Headers;
|
11
|
+
method: HTTPMethod;
|
5
12
|
};
|
6
13
|
decode(re: Request | Response): Promise<unknown>;
|
7
14
|
}
|
@@ -3,7 +3,7 @@ import type { Lazy } from './lazy';
|
|
3
3
|
import type { Procedure } from './procedure';
|
4
4
|
import type { ProcedureClient } from './procedure-client';
|
5
5
|
import { type ANY_ROUTER } from './router';
|
6
|
-
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : Lazy<T> & (T extends Procedure<infer UContext, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? undefined extends UContext ? ProcedureClient<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput
|
6
|
+
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : Lazy<T> & (T extends Procedure<infer UContext, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? undefined extends UContext ? ProcedureClient<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput>, unknown> : unknown : {
|
7
7
|
[K in keyof T]: T[K] extends object ? DecoratedLazy<T[K]> : never;
|
8
8
|
});
|
9
9
|
export declare function decorateLazy<T extends Lazy<ANY_ROUTER | undefined>>(lazied: T): DecoratedLazy<T>;
|
@@ -17,6 +17,6 @@ export declare class ProcedureBuilder<TContext extends Context, TExtraContext ex
|
|
17
17
|
output<U extends Schema = undefined>(schema: U, example?: SchemaOutput<U>): ProcedureBuilder<TContext, TExtraContext, TInputSchema, U>;
|
18
18
|
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema>;
|
19
19
|
use<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema>;
|
20
|
-
|
20
|
+
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
21
21
|
}
|
22
22
|
//# sourceMappingURL=procedure-builder.d.ts.map
|
@@ -3,14 +3,19 @@ import type { Hooks, Value } from '@orpc/shared';
|
|
3
3
|
import type { Lazyable } from './lazy';
|
4
4
|
import type { Procedure } from './procedure';
|
5
5
|
import type { Context, Meta, WELL_CONTEXT, WithSignal } from './types';
|
6
|
-
export
|
7
|
-
|
6
|
+
export type ProcedureClientOptions<TClientContext> = WithSignal & (undefined extends TClientContext ? {
|
7
|
+
context?: TClientContext;
|
8
|
+
} : {
|
9
|
+
context: TClientContext;
|
10
|
+
});
|
11
|
+
export interface ProcedureClient<TInput, TOutput, TClientContext> {
|
12
|
+
(...opts: [input: TInput, options: ProcedureClientOptions<TClientContext>] | (undefined extends TInput & TClientContext ? [] : never) | (undefined extends TClientContext ? [input: TInput] : never)): Promise<TOutput>;
|
8
13
|
}
|
9
14
|
/**
|
10
15
|
* Options for creating a procedure caller with comprehensive type safety
|
11
16
|
*/
|
12
|
-
export type CreateProcedureClientOptions<TContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema,
|
13
|
-
procedure: Lazyable<Procedure<TContext, any, TInputSchema, TOutputSchema,
|
17
|
+
export type CreateProcedureClientOptions<TContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> = {
|
18
|
+
procedure: Lazyable<Procedure<TContext, any, TInputSchema, TOutputSchema, THandlerOutput>>;
|
14
19
|
/**
|
15
20
|
* This is helpful for logging and analytics.
|
16
21
|
*
|
@@ -24,6 +29,6 @@ export type CreateProcedureClientOptions<TContext extends Context, TInputSchema
|
|
24
29
|
context: Value<TContext>;
|
25
30
|
} | (undefined extends TContext ? {
|
26
31
|
context?: undefined;
|
27
|
-
} : never)) & Hooks<unknown, SchemaOutput<TOutputSchema,
|
28
|
-
export declare function createProcedureClient<TContext extends Context = WELL_CONTEXT, TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined,
|
32
|
+
} : never)) & Hooks<unknown, SchemaOutput<TOutputSchema, THandlerOutput>, TContext, Meta>;
|
33
|
+
export declare function createProcedureClient<TContext extends Context = WELL_CONTEXT, TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, THandlerOutput extends SchemaInput<TOutputSchema> = SchemaInput<TOutputSchema>>(options: CreateProcedureClientOptions<TContext, TInputSchema, TOutputSchema, THandlerOutput>): ProcedureClient<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, unknown>;
|
29
34
|
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -3,12 +3,12 @@ import type { MapInputMiddleware, Middleware } from './middleware';
|
|
3
3
|
import type { ProcedureClient } from './procedure-client';
|
4
4
|
import type { Context, MergeContext } from './types';
|
5
5
|
import { Procedure } from './procedure';
|
6
|
-
export type DecoratedProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema,
|
7
|
-
prefix: (prefix: HTTPPath) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema,
|
8
|
-
route: (route: RouteOptions) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema,
|
9
|
-
use: (<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema,
|
10
|
-
unshiftTag: (...tags: string[]) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema,
|
11
|
-
unshiftMiddleware: <U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(...middlewares: Middleware<TContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema,
|
12
|
-
} & (undefined extends TContext ? ProcedureClient<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema,
|
13
|
-
export declare function decorateProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema,
|
6
|
+
export type DecoratedProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> = Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput> & {
|
7
|
+
prefix: (prefix: HTTPPath) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
8
|
+
route: (route: RouteOptions) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
9
|
+
use: (<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, THandlerOutput>>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema, THandlerOutput>) & (<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema, THandlerOutput>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema, THandlerOutput>);
|
10
|
+
unshiftTag: (...tags: string[]) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
11
|
+
unshiftMiddleware: <U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(...middlewares: Middleware<TContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, THandlerOutput>>[]) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
12
|
+
} & (undefined extends TContext ? ProcedureClient<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, unknown> : unknown);
|
13
|
+
export declare function decorateProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>>(procedure: Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
14
14
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -13,6 +13,6 @@ export declare class ProcedureImplementer<TContext extends Context, TExtraContex
|
|
13
13
|
constructor(def: ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema>);
|
14
14
|
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema>;
|
15
15
|
use<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema>;
|
16
|
-
|
16
|
+
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
17
17
|
}
|
18
18
|
//# sourceMappingURL=procedure-implementer.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -3,18 +3,18 @@ import type { Lazy } from './lazy';
|
|
3
3
|
import type { Middleware } from './middleware';
|
4
4
|
import type { Context, MergeContext, Meta } from './types';
|
5
5
|
import { type ContractProcedure, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
6
|
-
export interface ProcedureFunc<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema,
|
7
|
-
(input: SchemaOutput<TInputSchema>, context: MergeContext<TContext, TExtraContext>, meta: Meta): Promisable<SchemaInput<TOutputSchema,
|
6
|
+
export interface ProcedureFunc<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> {
|
7
|
+
(input: SchemaOutput<TInputSchema>, context: MergeContext<TContext, TExtraContext>, meta: Meta): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
8
8
|
}
|
9
|
-
export interface ProcedureDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema,
|
9
|
+
export interface ProcedureDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> {
|
10
10
|
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, SchemaOutput<TInputSchema>, any>[];
|
11
11
|
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
12
|
-
|
12
|
+
handler: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
13
13
|
}
|
14
|
-
export declare class Procedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema,
|
14
|
+
export declare class Procedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> {
|
15
15
|
'~type': "Procedure";
|
16
|
-
'~orpc': ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema,
|
17
|
-
constructor(def: ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema,
|
16
|
+
'~orpc': ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
17
|
+
constructor(def: ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>);
|
18
18
|
}
|
19
19
|
export type ANY_PROCEDURE = Procedure<any, any, any, any, any>;
|
20
20
|
export type WELL_PROCEDURE = Procedure<Context, Context, Schema, Schema, unknown>;
|
@@ -5,8 +5,8 @@ import type { Procedure } from './procedure';
|
|
5
5
|
import type { ProcedureClient } from './procedure-client';
|
6
6
|
import type { Meta } from './types';
|
7
7
|
import { type ANY_ROUTER, type Router } from './router';
|
8
|
-
export type RouterClient<
|
9
|
-
[K in keyof
|
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
10
|
};
|
11
11
|
export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
|
12
12
|
router: TRouter | Lazy<undefined>;
|
@@ -21,5 +21,5 @@ export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
|
|
21
21
|
} : {
|
22
22
|
context: Value<UContext>;
|
23
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>;
|
24
|
+
export declare function createRouterClient<TRouter extends ANY_ROUTER>(options: CreateRouterClientOptions<TRouter>): RouterClient<TRouter, unknown>;
|
25
25
|
//# sourceMappingURL=router-client.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.
|
4
|
+
"version": "0.21.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -34,8 +34,8 @@
|
|
34
34
|
"dist"
|
35
35
|
],
|
36
36
|
"dependencies": {
|
37
|
-
"@orpc/contract": "0.
|
38
|
-
"@orpc/shared": "0.
|
37
|
+
"@orpc/contract": "0.21.0",
|
38
|
+
"@orpc/shared": "0.21.0"
|
39
39
|
},
|
40
40
|
"devDependencies": {
|
41
41
|
"zod": "^3.24.1"
|