@orpc/server 0.37.0 → 0.38.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-BFGSRNYZ.js → chunk-GIXDBJGV.js} +2 -2
- package/dist/{chunk-2OH4QMZ4.js → chunk-WJ2G7572.js} +2 -2
- package/dist/{chunk-EDQKEHUX.js → chunk-XP6YRLY2.js} +3 -2
- package/dist/fetch.js +3 -3
- package/dist/hono.js +3 -3
- package/dist/index.js +1 -1
- package/dist/next.js +3 -3
- package/dist/node.js +2 -2
- package/dist/src/adapters/fetch/rpc-handler.d.ts +3 -2
- package/dist/src/adapters/fetch/types.d.ts +3 -2
- package/dist/src/adapters/hono/middleware.d.ts +2 -3
- package/dist/src/adapters/next/serve.d.ts +2 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +3 -2
- package/dist/src/adapters/node/types.d.ts +3 -2
- package/dist/src/adapters/standard/handler.d.ts +5 -6
- package/dist/src/implementer-procedure.d.ts +5 -4
- package/dist/src/middleware.d.ts +2 -3
- package/dist/src/procedure-client.d.ts +5 -6
- package/dist/src/procedure-decorated.d.ts +5 -4
- package/dist/src/procedure-utils.d.ts +3 -2
- package/dist/src/router-client.d.ts +6 -6
- package/dist/src/router.d.ts +1 -0
- package/dist/standard.js +2 -2
- package/package.json +3 -3
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
getRouterChild,
|
7
7
|
isProcedure,
|
8
8
|
unlazy
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-XP6YRLY2.js";
|
10
10
|
import {
|
11
11
|
CompositePlugin
|
12
12
|
} from "./chunk-XFBAK67J.js";
|
@@ -316,4 +316,4 @@ export {
|
|
316
316
|
RPCCodec,
|
317
317
|
RPCMatcher
|
318
318
|
};
|
319
|
-
//# sourceMappingURL=chunk-
|
319
|
+
//# sourceMappingURL=chunk-GIXDBJGV.js.map
|
@@ -2,7 +2,7 @@ import {
|
|
2
2
|
RPCCodec,
|
3
3
|
RPCMatcher,
|
4
4
|
StandardHandler
|
5
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-GIXDBJGV.js";
|
6
6
|
|
7
7
|
// src/adapters/fetch/utils.ts
|
8
8
|
import { once } from "@orpc/shared";
|
@@ -142,4 +142,4 @@ export {
|
|
142
142
|
standardResponseToFetchResponse,
|
143
143
|
RPCHandler
|
144
144
|
};
|
145
|
-
//# sourceMappingURL=chunk-
|
145
|
+
//# sourceMappingURL=chunk-WJ2G7572.js.map
|
@@ -68,7 +68,8 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
|
|
68
68
|
return async (...[input, callerOptions]) => {
|
69
69
|
const path = options?.path ?? [];
|
70
70
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
71
|
-
const
|
71
|
+
const clientContext = callerOptions?.context ?? {};
|
72
|
+
const context = await value(options?.context ?? {}, clientContext);
|
72
73
|
const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
|
73
74
|
try {
|
74
75
|
return await intercept(
|
@@ -374,4 +375,4 @@ export {
|
|
374
375
|
convertPathToHttpPath,
|
375
376
|
createContractedProcedure
|
376
377
|
};
|
377
|
-
//# sourceMappingURL=chunk-
|
378
|
+
//# sourceMappingURL=chunk-XP6YRLY2.js.map
|
package/dist/fetch.js
CHANGED
@@ -3,9 +3,9 @@ import {
|
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
5
|
standardResponseToFetchResponse
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
8
|
-
import "./chunk-
|
6
|
+
} from "./chunk-WJ2G7572.js";
|
7
|
+
import "./chunk-GIXDBJGV.js";
|
8
|
+
import "./chunk-XP6YRLY2.js";
|
9
9
|
import "./chunk-XFBAK67J.js";
|
10
10
|
export {
|
11
11
|
RPCHandler,
|
package/dist/hono.js
CHANGED
@@ -3,9 +3,9 @@ import {
|
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
5
|
standardResponseToFetchResponse
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
8
|
-
import "./chunk-
|
6
|
+
} from "./chunk-WJ2G7572.js";
|
7
|
+
import "./chunk-GIXDBJGV.js";
|
8
|
+
import "./chunk-XP6YRLY2.js";
|
9
9
|
import "./chunk-XFBAK67J.js";
|
10
10
|
|
11
11
|
// src/adapters/hono/middleware.ts
|
package/dist/index.js
CHANGED
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
middlewareOutputFn,
|
22
22
|
setRouterContract,
|
23
23
|
unlazy
|
24
|
-
} from "./chunk-
|
24
|
+
} from "./chunk-XP6YRLY2.js";
|
25
25
|
|
26
26
|
// src/builder.ts
|
27
27
|
import { mergeErrorMap as mergeErrorMap2, mergeMeta as mergeMeta2, mergePrefix, mergeRoute as mergeRoute2, mergeTags } from "@orpc/contract";
|
package/dist/next.js
CHANGED
@@ -3,9 +3,9 @@ import {
|
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
5
|
standardResponseToFetchResponse
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
8
|
-
import "./chunk-
|
6
|
+
} from "./chunk-WJ2G7572.js";
|
7
|
+
import "./chunk-GIXDBJGV.js";
|
8
|
+
import "./chunk-XP6YRLY2.js";
|
9
9
|
import "./chunk-XFBAK67J.js";
|
10
10
|
|
11
11
|
// src/adapters/next/serve.ts
|
package/dist/node.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
2
|
import type { Context } from '../../context';
|
2
3
|
import type { Router } from '../../router';
|
3
|
-
import type { RPCHandlerOptions,
|
4
|
+
import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
|
4
5
|
import type { FetchHandler, FetchHandleResult } from './types';
|
5
6
|
export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
|
6
7
|
private readonly standardHandler;
|
7
8
|
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
8
|
-
handle(request: Request, ...rest:
|
9
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
9
10
|
}
|
10
11
|
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,5 +1,6 @@
|
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
2
|
import type { Context } from '../../context';
|
2
|
-
import type {
|
3
|
+
import type { StandardHandleOptions } from '../standard';
|
3
4
|
export type FetchHandleResult = {
|
4
5
|
matched: true;
|
5
6
|
response: Response;
|
@@ -8,6 +9,6 @@ export type FetchHandleResult = {
|
|
8
9
|
response: undefined;
|
9
10
|
};
|
10
11
|
export interface FetchHandler<T extends Context> {
|
11
|
-
handle(request: Request, ...rest:
|
12
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
12
13
|
}
|
13
14
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,13 +1,12 @@
|
|
1
|
+
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
1
2
|
import type { Context as HonoContext, MiddlewareHandler } from 'hono';
|
2
3
|
import type { Context } from '../../context';
|
3
4
|
import type { FetchHandler } from '../fetch';
|
4
5
|
import type { StandardHandleOptions } from '../standard';
|
5
|
-
import { type Value } from '@orpc/shared';
|
6
6
|
export type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
7
7
|
context?: Value<T, [HonoContext]>;
|
8
8
|
} : {
|
9
9
|
context: Value<T, [HonoContext]>;
|
10
10
|
});
|
11
|
-
export
|
12
|
-
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: CreateMiddlewareRest<T>): MiddlewareHandler;
|
11
|
+
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
13
12
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,14 +1,13 @@
|
|
1
|
+
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
1
2
|
import type { NextRequest } from 'next/server';
|
2
3
|
import type { Context } from '../../context';
|
3
4
|
import type { FetchHandler } from '../fetch';
|
4
5
|
import type { StandardHandleOptions } from '../standard';
|
5
|
-
import { type Value } from '@orpc/shared';
|
6
6
|
export type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
7
7
|
context?: Value<T, [NextRequest]>;
|
8
8
|
} : {
|
9
9
|
context: Value<T, [NextRequest]>;
|
10
10
|
});
|
11
|
-
export type ServeRest<T extends Context> = [options: ServeOptions<T>] | (Record<never, never> extends T ? [] : never);
|
12
11
|
export interface ServeResult {
|
13
12
|
GET(req: NextRequest): Promise<Response>;
|
14
13
|
POST(req: NextRequest): Promise<Response>;
|
@@ -16,5 +15,5 @@ export interface ServeResult {
|
|
16
15
|
PATCH(req: NextRequest): Promise<Response>;
|
17
16
|
DELETE(req: NextRequest): Promise<Response>;
|
18
17
|
}
|
19
|
-
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]:
|
18
|
+
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
20
19
|
//# sourceMappingURL=serve.d.ts.map
|
@@ -1,10 +1,11 @@
|
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
2
|
import type { Context } from '../../context';
|
2
3
|
import type { Router } from '../../router';
|
3
|
-
import type { RPCHandlerOptions,
|
4
|
+
import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
|
4
5
|
import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
|
5
6
|
export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
|
6
7
|
private readonly standardHandler;
|
7
8
|
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
8
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest:
|
9
|
+
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
9
10
|
}
|
10
11
|
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,7 +1,8 @@
|
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
2
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
2
3
|
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
3
4
|
import type { Context } from '../../context';
|
4
|
-
import type {
|
5
|
+
import type { StandardHandleOptions } from '../standard';
|
5
6
|
export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
6
7
|
/**
|
7
8
|
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
@@ -16,6 +17,6 @@ export type NodeHttpHandleResult = {
|
|
16
17
|
matched: false;
|
17
18
|
};
|
18
19
|
export interface NodeHttpHandler<T extends Context> {
|
19
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest:
|
20
|
+
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
20
21
|
}
|
21
22
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
|
2
|
-
import type { Interceptor } from '@orpc/shared';
|
2
|
+
import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import type { Context } from '../../context';
|
4
4
|
import type { Plugin } from '../../plugins';
|
5
5
|
import type { CreateProcedureClientOptions } from '../../procedure-client';
|
@@ -15,7 +15,6 @@ export type StandardHandleOptions<T extends Context> = {
|
|
15
15
|
export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
|
16
16
|
context: T;
|
17
17
|
};
|
18
|
-
export type StandardHandleRest<T extends Context> = [options: StandardHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
|
19
18
|
export type StandardHandleResult = {
|
20
19
|
matched: true;
|
21
20
|
response: StandardResponse;
|
@@ -26,7 +25,7 @@ export type StandardHandleResult = {
|
|
26
25
|
export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
|
27
26
|
request: StandardRequest;
|
28
27
|
};
|
29
|
-
export type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta,
|
28
|
+
export type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, Record<never, never>> & {
|
30
29
|
context: TContext;
|
31
30
|
};
|
32
31
|
export interface StandardHandlerOptions<TContext extends Context> {
|
@@ -40,12 +39,12 @@ export interface StandardHandlerOptions<TContext extends Context> {
|
|
40
39
|
*/
|
41
40
|
interceptorsRoot?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
42
41
|
}
|
43
|
-
export declare class StandardHandler<
|
42
|
+
export declare class StandardHandler<T extends Context> {
|
44
43
|
private readonly matcher;
|
45
44
|
private readonly codec;
|
46
45
|
private readonly options;
|
47
46
|
private readonly plugin;
|
48
|
-
constructor(router: Router<
|
49
|
-
handle(request: StandardRequest, ...[options]:
|
47
|
+
constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
|
48
|
+
handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
|
50
49
|
}
|
51
50
|
//# sourceMappingURL=handler.d.ts.map
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import type { ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
1
|
+
import type { ClientContext, ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import type { BuilderDef } from './builder';
|
3
4
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
5
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
6
|
import type { Procedure, ProcedureHandler } from './procedure';
|
6
|
-
import type {
|
7
|
+
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
7
8
|
import type { DecoratedProcedure } from './procedure-decorated';
|
8
9
|
/**
|
9
10
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
@@ -13,11 +14,11 @@ export interface ImplementedProcedure<TInitialContext extends Context, TCurrentC
|
|
13
14
|
/**
|
14
15
|
* Make this procedure callable (works like a function while still being a procedure).
|
15
16
|
*/
|
16
|
-
callable<TClientContext>(...rest:
|
17
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
17
18
|
/**
|
18
19
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
19
20
|
*/
|
20
|
-
actionable<TClientContext>(...rest:
|
21
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
21
22
|
}
|
22
23
|
/**
|
23
24
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
package/dist/src/middleware.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ErrorMap, Meta, ORPCErrorConstructorMap, Schema } from '@orpc/contract';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
2
|
+
import type { MaybeOptionalOptions, Promisable } from '@orpc/shared';
|
3
3
|
import type { Context } from './context';
|
4
4
|
import type { Procedure } from './procedure';
|
5
5
|
export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
@@ -11,9 +11,8 @@ export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never,
|
|
11
11
|
} : {
|
12
12
|
context: TOutContext;
|
13
13
|
};
|
14
|
-
export type MiddlewareNextFnRest<TOutContext extends Context> = [options: MiddlewareNextFnOptions<TOutContext>] | (Record<never, never> extends TOutContext ? [] : never);
|
15
14
|
export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
|
16
|
-
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest:
|
15
|
+
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
|
17
16
|
}
|
18
17
|
export interface MiddlewareOutputFn<TOutput> {
|
19
18
|
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import type { Client, ErrorFromErrorMap, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Interceptor, Value } from '@orpc/shared';
|
1
|
+
import type { Client, ClientContext, ErrorFromErrorMap, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Interceptor, MaybeOptionalOptions, Value } from '@orpc/shared';
|
3
3
|
import type { Context } from './context';
|
4
4
|
import type { Lazyable } from './lazy';
|
5
5
|
import type { Procedure } from './procedure';
|
6
|
-
export type ProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
6
|
+
export type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
7
7
|
export interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
8
8
|
context: TInitialContext;
|
9
9
|
input: SchemaInput<TInputSchema>;
|
@@ -15,7 +15,7 @@ export interface ProcedureClientInterceptorOptions<TInitialContext extends Conte
|
|
15
15
|
/**
|
16
16
|
* Options for creating a procedure caller with comprehensive type safety
|
17
17
|
*/
|
18
|
-
export type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext> = {
|
18
|
+
export type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
19
19
|
/**
|
20
20
|
* This is helpful for logging and analytics.
|
21
21
|
*/
|
@@ -26,6 +26,5 @@ export type CreateProcedureClientOptions<TInitialContext extends Context, TInput
|
|
26
26
|
} : {
|
27
27
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
28
28
|
});
|
29
|
-
export
|
30
|
-
export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, ...[options]: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
29
|
+
export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
31
30
|
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import type { ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
1
|
+
import type { ClientContext, ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
4
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
|
-
import type {
|
5
|
+
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
5
6
|
import { Procedure } from './procedure';
|
6
7
|
export declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> {
|
7
8
|
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, MergedErrorMap<TErrorMap, U>, TMeta>;
|
@@ -12,10 +13,10 @@ export declare class DecoratedProcedure<TInitialContext extends Context, TCurren
|
|
12
13
|
/**
|
13
14
|
* Make this procedure callable (works like a function while still being a procedure).
|
14
15
|
*/
|
15
|
-
callable<TClientContext>(...rest:
|
16
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
16
17
|
/**
|
17
18
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
18
19
|
*/
|
19
|
-
actionable<TClientContext>(...rest:
|
20
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
20
21
|
}
|
21
22
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import type { Context } from './context';
|
3
4
|
import type { Lazyable } from './lazy';
|
4
5
|
import type { Procedure } from './procedure';
|
5
|
-
import {
|
6
|
+
import type { CreateProcedureClientOptions } from './procedure-client';
|
6
7
|
/**
|
7
8
|
* Directly call a procedure without creating a client.
|
8
9
|
*
|
@@ -13,5 +14,5 @@ import { type CreateProcedureClientRest } from './procedure-client';
|
|
13
14
|
* ```
|
14
15
|
*
|
15
16
|
*/
|
16
|
-
export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, input: SchemaInput<TInputSchema>, ...rest:
|
17
|
+
export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, input: SchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
17
18
|
//# sourceMappingURL=procedure-utils.d.ts.map
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import type { ErrorMap, Meta } from '@orpc/contract';
|
1
|
+
import type { ClientContext, ErrorMap, Meta } from '@orpc/contract';
|
2
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import type { Lazy } from './lazy';
|
3
4
|
import type { Procedure } from './procedure';
|
4
|
-
import type {
|
5
|
-
import type { AnyRouter,
|
6
|
-
export type RouterClient<TRouter extends AnyRouter, TClientContext> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
5
|
+
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
6
|
+
import type { AnyRouter, InferRouterInitialContext } from './router';
|
7
|
+
export type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
7
8
|
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
8
9
|
};
|
9
|
-
export
|
10
|
-
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateRouterClientRest<TRouter, TClientContext>): RouterClient<TRouter, TClientContext>;
|
10
|
+
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext>(router: TRouter | Lazy<undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<TRouter>, undefined, undefined, unknown, ErrorMap, Meta, TClientContext>>): RouterClient<TRouter, TClientContext>;
|
11
11
|
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
@@ -9,6 +9,7 @@ export type Router<TInitialContext extends Context, TContract extends AnyContrac
|
|
9
9
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? Router<TInitialContext, TContract[K]> : never;
|
10
10
|
}>;
|
11
11
|
export type AnyRouter = Router<any, any>;
|
12
|
+
export type InferRouterInitialContext<T extends AnyRouter> = T extends Router<infer UInitialContext, any> ? UInitialContext : never;
|
12
13
|
export type InferRouterInputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any, any, any> ? SchemaInput<UInputSchema> : {
|
13
14
|
[K in keyof T]: T[K] extends AnyRouter ? InferRouterInputs<T[K]> : never;
|
14
15
|
};
|
package/dist/standard.js
CHANGED
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.38.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -64,8 +64,8 @@
|
|
64
64
|
},
|
65
65
|
"dependencies": {
|
66
66
|
"@tinyhttp/content-disposition": "^2.2.2",
|
67
|
-
"@orpc/contract": "0.
|
68
|
-
"@orpc/shared": "0.
|
67
|
+
"@orpc/contract": "0.38.0",
|
68
|
+
"@orpc/shared": "0.38.0"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
71
|
"light-my-request": "^6.5.1"
|