@orpc/server 0.0.0-next.7b4c812 → 0.0.0-next.7ea4bbf
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-3BAPJGK6.js +302 -0
- package/dist/chunk-E7GUWVR4.js +186 -0
- package/dist/chunk-WUOGVGWG.js +1 -0
- package/dist/fetch.js +11 -108
- package/dist/hono.js +30 -0
- package/dist/index.js +371 -317
- package/dist/next.js +36 -0
- package/dist/node.js +87 -0
- package/dist/src/adapters/fetch/index.d.ts +6 -0
- package/dist/src/adapters/fetch/orpc-handler.d.ts +20 -0
- package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +16 -0
- package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +12 -0
- package/dist/src/adapters/fetch/super-json.d.ts +12 -0
- package/dist/src/adapters/fetch/types.d.ts +21 -0
- package/dist/src/adapters/hono/index.d.ts +3 -0
- package/dist/src/adapters/hono/middleware.d.ts +12 -0
- package/dist/src/adapters/next/index.d.ts +3 -0
- package/dist/src/adapters/next/serve.d.ts +19 -0
- package/dist/src/adapters/node/index.d.ts +5 -0
- package/dist/src/adapters/node/orpc-handler.d.ts +12 -0
- package/dist/src/adapters/node/request-listener.d.ts +28 -0
- package/dist/src/adapters/node/types.d.ts +22 -0
- package/dist/src/builder.d.ts +26 -44
- package/dist/src/hidden.d.ts +6 -0
- package/dist/src/implementer-chainable.d.ts +10 -0
- package/dist/src/index.d.ts +10 -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 +18 -11
- 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 +23 -25
- 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 +17 -20
- package/dist/src/router.d.ts +11 -16
- package/dist/src/types.d.ts +8 -8
- package/package.json +22 -10
- package/dist/chunk-Z2PQ6UAM.js +0 -273
- package/dist/src/fetch/handle.d.ts +0 -7
- package/dist/src/fetch/handler.d.ts +0 -3
- package/dist/src/fetch/index.d.ts +0 -4
- package/dist/src/fetch/types.d.ts +0 -28
- package/dist/src/procedure-caller.d.ts +0 -26
- package/dist/src/router-caller.d.ts +0 -25
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Hooks, Value } from '@orpc/shared';
|
3
|
+
import type { Lazyable } from './lazy';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
import type { Context, Meta, WELL_CONTEXT, WithSignal } from './types';
|
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>;
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Options for creating a procedure caller with comprehensive type safety
|
16
|
+
*/
|
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>>;
|
19
|
+
/**
|
20
|
+
* This is helpful for logging and analytics.
|
21
|
+
*
|
22
|
+
* @internal
|
23
|
+
*/
|
24
|
+
path?: string[];
|
25
|
+
} & ({
|
26
|
+
/**
|
27
|
+
* The context used when calling the procedure.
|
28
|
+
*/
|
29
|
+
context: Value<TContext>;
|
30
|
+
} | (undefined extends TContext ? {
|
31
|
+
context?: 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>;
|
34
|
+
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
3
|
+
import type { ProcedureClient } from './procedure-client';
|
4
|
+
import type { Context, MergeContext } from './types';
|
5
|
+
import { Procedure } from './procedure';
|
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
|
+
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,22 +1,18 @@
|
|
1
1
|
import type { ContractProcedure, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type {
|
3
|
-
import type {
|
2
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
3
|
+
import type { ProcedureHandler } from './procedure';
|
4
|
+
import type { DecoratedProcedure } from './procedure-decorated';
|
4
5
|
import type { Context, MergeContext } from './types';
|
5
|
-
|
6
|
+
export type ProcedureImplementerDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> = {
|
7
|
+
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
8
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>[];
|
9
|
+
};
|
6
10
|
export declare class ProcedureImplementer<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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>;
|
11
|
+
'~type': "ProcedureImplementer";
|
12
|
+
'~orpc': ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema>;
|
13
|
+
constructor(def: ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema>);
|
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
|
+
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
|
+
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
21
17
|
}
|
22
18
|
//# sourceMappingURL=procedure-implementer.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -1,32 +1,30 @@
|
|
1
1
|
import type { Promisable } from '@orpc/shared';
|
2
2
|
import type { Lazy } from './lazy';
|
3
|
-
import type {
|
4
|
-
import type { Context, MergeContext
|
5
|
-
import { type ContractProcedure, type
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
import type { Middleware } from './middleware';
|
4
|
+
import type { AbortSignal, Context, MergeContext } from './types';
|
5
|
+
import { type ContractProcedure, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
6
|
+
export interface ProcedureHandlerOptions<TContext extends Context, TInput> {
|
7
|
+
context: TContext;
|
8
|
+
input: TInput;
|
9
|
+
path: string[];
|
10
|
+
procedure: ANY_PROCEDURE;
|
11
|
+
signal?: AbortSignal;
|
12
|
+
}
|
13
|
+
export interface ProcedureHandler<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> {
|
14
|
+
(opt: ProcedureHandlerOptions<MergeContext<TContext, TExtraContext>, SchemaOutput<TInputSchema>>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
15
|
+
}
|
16
|
+
export interface ProcedureDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> {
|
17
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, SchemaOutput<TInputSchema>, any>[];
|
18
|
+
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
19
|
+
handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
20
|
+
}
|
21
|
+
export declare class Procedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>> {
|
22
|
+
'~type': "Procedure";
|
23
|
+
'~orpc': ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
24
|
+
constructor(def: ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>);
|
18
25
|
}
|
19
26
|
export type ANY_PROCEDURE = Procedure<any, any, any, any, any>;
|
20
|
-
export type
|
27
|
+
export type WELL_PROCEDURE = Procedure<Context, Context, Schema, Schema, unknown>;
|
21
28
|
export type ANY_LAZY_PROCEDURE = Lazy<ANY_PROCEDURE>;
|
22
|
-
export type DecoratedProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> = Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput> & {
|
23
|
-
prefix: (prefix: HTTPPath) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
24
|
-
route: (opts: RouteOptions) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
25
|
-
use: (<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, TFuncOutput>>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema, TFuncOutput>) & (<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, SchemaInput<TOutputSchema, TFuncOutput>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, TFuncOutput>, UMappedInput>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema, TFuncOutput>);
|
26
|
-
} & (undefined extends TContext ? ProcedureCaller<Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>> : unknown);
|
27
|
-
export interface ProcedureFunc<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TOutput extends SchemaOutput<TOutputSchema>> {
|
28
|
-
(input: SchemaOutput<TInputSchema>, context: MergeContext<TContext, TExtraContext>, meta: Meta): Promisable<SchemaInput<TOutputSchema, TOutput>>;
|
29
|
-
}
|
30
|
-
export declare function decorateProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>>(procedure: Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
31
29
|
export declare function isProcedure(item: unknown): item is ANY_PROCEDURE;
|
32
30
|
//# sourceMappingURL=procedure.d.ts.map
|
@@ -1,27 +1,29 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
2
|
+
import type { FlattenLazy, Lazy } from './lazy';
|
3
|
+
import type { Middleware } from './middleware';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
import type { ANY_ROUTER, Router } from './router';
|
3
6
|
import type { Context, MergeContext } from './types';
|
4
|
-
import { type
|
5
|
-
import { type
|
6
|
-
export
|
7
|
+
import { type DecoratedLazy } from './lazy-decorated';
|
8
|
+
import { type DecoratedProcedure } from './procedure-decorated';
|
9
|
+
export type AdaptedRouter<TContext extends Context, TRouter extends ANY_ROUTER> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? DecoratedLazy<AdaptedRouter<TContext, U>> : TRouter extends Procedure<any, infer UExtraContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? DecoratedProcedure<TContext, UExtraContext, UInputSchema, UOutputSchema, UFuncOutput> : {
|
10
|
+
[K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? AdaptedRouter<TContext, TRouter[K]> : never;
|
11
|
+
};
|
12
|
+
export type RouterBuilderDef<TContext extends Context, TExtraContext extends Context> = {
|
13
|
+
prefix?: HTTPPath;
|
14
|
+
tags?: readonly string[];
|
15
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[];
|
16
|
+
};
|
7
17
|
export declare class RouterBuilder<TContext extends Context, TExtraContext extends Context> {
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
+
'~type': "RouterBuilder";
|
19
|
+
'~orpc': RouterBuilderDef<TContext, TExtraContext>;
|
20
|
+
constructor(def: RouterBuilderDef<TContext, TExtraContext>);
|
18
21
|
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
|
19
|
-
|
20
|
-
use<
|
21
|
-
|
22
|
-
|
23
|
-
lazy<U extends Router<TContext>>(loader: () => Promise<{
|
22
|
+
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
|
23
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown>): RouterBuilder<TContext, MergeContext<TExtraContext, U>>;
|
24
|
+
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U>;
|
25
|
+
lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
|
24
26
|
default: U;
|
25
|
-
}>):
|
27
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
26
28
|
}
|
27
29
|
//# sourceMappingURL=router-builder.d.ts.map
|
@@ -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<U extends
|
16
|
-
lazy<U extends
|
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<{
|
17
18
|
default: U;
|
18
|
-
}>):
|
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> | Lazy<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> | Lazy<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,14 +1,14 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { FindGlobalInstanceType } from '@orpc/shared';
|
2
|
+
import type { ANY_PROCEDURE } from './procedure';
|
3
|
+
export type Context = Record<string, any> | undefined;
|
4
|
+
export type WELL_CONTEXT = Record<string, unknown> | undefined;
|
3
5
|
export type MergeContext<TA extends Context, TB extends Context> = TA extends undefined ? TB : TB extends undefined ? TA : TA & TB;
|
4
|
-
export
|
6
|
+
export type AbortSignal = FindGlobalInstanceType<'AbortSignal'>;
|
7
|
+
export interface WithSignal {
|
5
8
|
signal?: AbortSignal;
|
6
9
|
}
|
7
|
-
export interface
|
8
|
-
(...opts: [input: TInput, options?: CallerOptions] | (undefined extends TInput ? [] : never)): Promise<TOutput>;
|
9
|
-
}
|
10
|
-
export interface Meta extends CallerOptions {
|
10
|
+
export interface Meta extends WithSignal {
|
11
11
|
path: string[];
|
12
|
-
procedure:
|
12
|
+
procedure: ANY_PROCEDURE;
|
13
13
|
}
|
14
14
|
//# 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.7ea4bbf",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -20,10 +20,25 @@
|
|
20
20
|
"default": "./dist/index.js"
|
21
21
|
},
|
22
22
|
"./fetch": {
|
23
|
-
"types": "./dist/src/fetch/index.d.ts",
|
23
|
+
"types": "./dist/src/adapters/fetch/index.d.ts",
|
24
24
|
"import": "./dist/fetch.js",
|
25
25
|
"default": "./dist/fetch.js"
|
26
26
|
},
|
27
|
+
"./hono": {
|
28
|
+
"types": "./dist/src/adapters/hono/index.d.ts",
|
29
|
+
"import": "./dist/hono.js",
|
30
|
+
"default": "./dist/hono.js"
|
31
|
+
},
|
32
|
+
"./next": {
|
33
|
+
"types": "./dist/src/adapters/next/index.d.ts",
|
34
|
+
"import": "./dist/next.js",
|
35
|
+
"default": "./dist/next.js"
|
36
|
+
},
|
37
|
+
"./node": {
|
38
|
+
"types": "./dist/src/adapters/node/index.d.ts",
|
39
|
+
"import": "./dist/node.js",
|
40
|
+
"default": "./dist/node.js"
|
41
|
+
},
|
27
42
|
"./🔒/*": {
|
28
43
|
"types": "./dist/src/*.d.ts"
|
29
44
|
}
|
@@ -34,18 +49,15 @@
|
|
34
49
|
"dist"
|
35
50
|
],
|
36
51
|
"peerDependencies": {
|
37
|
-
"
|
52
|
+
"hono": ">=4.6.0",
|
53
|
+
"next": ">=14.0.0"
|
38
54
|
},
|
39
55
|
"dependencies": {
|
40
|
-
"@orpc/
|
41
|
-
"@orpc/
|
42
|
-
"@orpc/transformer": "0.0.0-next.7b4c812"
|
43
|
-
},
|
44
|
-
"devDependencies": {
|
45
|
-
"@orpc/openapi": "0.0.0-next.7b4c812"
|
56
|
+
"@orpc/contract": "0.0.0-next.7ea4bbf",
|
57
|
+
"@orpc/shared": "0.0.0-next.7ea4bbf"
|
46
58
|
},
|
47
59
|
"scripts": {
|
48
|
-
"build": "tsup --
|
60
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
49
61
|
"build:watch": "pnpm run build --watch",
|
50
62
|
"type:check": "tsc -b"
|
51
63
|
}
|