@orpc/server 0.0.0-next.b42ba03 → 0.0.0-next.b47b94e
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/README.md +128 -0
- package/dist/adapters/bun-ws/index.d.mts +35 -0
- package/dist/adapters/bun-ws/index.d.ts +35 -0
- package/dist/adapters/bun-ws/index.mjs +50 -0
- package/dist/adapters/crossws/index.d.mts +30 -0
- package/dist/adapters/crossws/index.d.ts +30 -0
- package/dist/adapters/crossws/index.mjs +50 -0
- package/dist/adapters/fetch/index.d.mts +78 -0
- package/dist/adapters/fetch/index.d.ts +78 -0
- package/dist/adapters/fetch/index.mjs +110 -0
- package/dist/adapters/node/index.d.mts +77 -0
- package/dist/adapters/node/index.d.ts +77 -0
- package/dist/adapters/node/index.mjs +95 -0
- package/dist/adapters/standard/index.d.mts +26 -0
- package/dist/adapters/standard/index.d.ts +26 -0
- package/dist/adapters/standard/index.mjs +6 -0
- package/dist/adapters/websocket/index.d.mts +27 -0
- package/dist/adapters/websocket/index.d.ts +27 -0
- package/dist/adapters/websocket/index.mjs +37 -0
- package/dist/adapters/ws/index.d.mts +28 -0
- package/dist/adapters/ws/index.d.ts +28 -0
- package/dist/adapters/ws/index.mjs +37 -0
- package/dist/index.d.mts +829 -0
- package/dist/index.d.ts +829 -0
- package/dist/index.mjs +474 -0
- package/dist/plugins/index.d.mts +156 -0
- package/dist/plugins/index.d.ts +156 -0
- package/dist/plugins/index.mjs +251 -0
- package/dist/shared/server.BRoxSiSC.d.mts +12 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/server.BW-nUGgA.mjs +36 -0
- package/dist/shared/server.BjiJH9Vo.d.ts +10 -0
- package/dist/shared/server.Cy1vfSiG.d.ts +12 -0
- package/dist/shared/server.DG7Tamti.mjs +367 -0
- package/dist/shared/server.DPWk5pjW.d.mts +192 -0
- package/dist/shared/server.DPWk5pjW.d.ts +192 -0
- package/dist/shared/server.QUe9N8P4.d.mts +10 -0
- package/dist/shared/server.SxlTJfG2.mjs +183 -0
- package/dist/shared/server.YZzrREz9.d.ts +74 -0
- package/dist/shared/server.eWLxY3lq.d.mts +74 -0
- package/package.json +57 -36
- package/dist/chunk-2OH4QMZ4.js +0 -145
- package/dist/chunk-BFGSRNYZ.js +0 -319
- package/dist/chunk-EDQKEHUX.js +0 -377
- package/dist/chunk-XFBAK67J.js +0 -128
- package/dist/fetch.js +0 -16
- package/dist/hono.js +0 -40
- package/dist/index.js +0 -404
- package/dist/next.js +0 -37
- package/dist/node.js +0 -170
- package/dist/plugins.js +0 -11
- package/dist/src/adapters/fetch/index.d.ts +0 -4
- package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -10
- package/dist/src/adapters/fetch/types.d.ts +0 -13
- package/dist/src/adapters/fetch/utils.d.ts +0 -5
- package/dist/src/adapters/hono/index.d.ts +0 -3
- package/dist/src/adapters/hono/middleware.d.ts +0 -13
- package/dist/src/adapters/next/index.d.ts +0 -3
- package/dist/src/adapters/next/serve.d.ts +0 -20
- package/dist/src/adapters/node/index.d.ts +0 -4
- package/dist/src/adapters/node/rpc-handler.d.ts +0 -10
- package/dist/src/adapters/node/types.d.ts +0 -21
- package/dist/src/adapters/node/utils.d.ts +0 -5
- package/dist/src/adapters/standard/handler.d.ts +0 -51
- package/dist/src/adapters/standard/index.d.ts +0 -7
- package/dist/src/adapters/standard/rpc-codec.d.ts +0 -15
- package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
- package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
- package/dist/src/adapters/standard/rpc-serializer.d.ts +0 -16
- package/dist/src/adapters/standard/types.d.ts +0 -44
- package/dist/src/builder-variants.d.ts +0 -74
- package/dist/src/builder.d.ts +0 -57
- package/dist/src/config.d.ts +0 -6
- package/dist/src/context.d.ts +0 -9
- package/dist/src/hidden.d.ts +0 -8
- package/dist/src/implementer-procedure.d.ts +0 -30
- package/dist/src/implementer-variants.d.ts +0 -17
- package/dist/src/implementer.d.ts +0 -28
- package/dist/src/index.d.ts +0 -23
- package/dist/src/lazy-utils.d.ts +0 -6
- package/dist/src/lazy.d.ts +0 -22
- package/dist/src/middleware-decorated.d.ts +0 -10
- package/dist/src/middleware-utils.d.ts +0 -5
- package/dist/src/middleware.d.ts +0 -37
- package/dist/src/plugins/base.d.ts +0 -13
- package/dist/src/plugins/cors.d.ts +0 -19
- package/dist/src/plugins/index.d.ts +0 -4
- package/dist/src/plugins/response-headers.d.ts +0 -10
- package/dist/src/procedure-client.d.ts +0 -31
- package/dist/src/procedure-decorated.d.ts +0 -21
- package/dist/src/procedure-utils.d.ts +0 -17
- package/dist/src/procedure.d.ts +0 -29
- package/dist/src/router-accessible-lazy.d.ts +0 -8
- package/dist/src/router-client.d.ts +0 -11
- package/dist/src/router.d.ts +0 -29
- package/dist/src/utils.d.ts +0 -24
- package/dist/standard.js +0 -17
@@ -1,13 +0,0 @@
|
|
1
|
-
import type { StandardHandlerInterceptorOptions, StandardHandlerOptions, WellCreateProcedureClientOptions } from '../adapters/standard';
|
2
|
-
import type { Context } from '../context';
|
3
|
-
export interface Plugin<TContext extends Context> {
|
4
|
-
init?(options: StandardHandlerOptions<TContext>): void;
|
5
|
-
beforeCreateProcedureClient?(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
|
6
|
-
}
|
7
|
-
export declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
|
8
|
-
private readonly plugins;
|
9
|
-
constructor(plugins?: Plugin<TContext>[]);
|
10
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
11
|
-
beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
|
12
|
-
}
|
13
|
-
//# sourceMappingURL=base.d.ts.map
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { StandardHandlerInterceptorOptions, StandardHandlerOptions } from '../adapters/standard';
|
2
|
-
import type { Context } from '../context';
|
3
|
-
import type { Plugin } from './base';
|
4
|
-
import { type Value } from '@orpc/shared';
|
5
|
-
export interface CORSOptions<TContext extends Context> {
|
6
|
-
origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
7
|
-
timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
8
|
-
allowMethods?: string[];
|
9
|
-
allowHeaders?: string[];
|
10
|
-
maxAge?: number;
|
11
|
-
credentials?: boolean;
|
12
|
-
exposeHeaders?: string[];
|
13
|
-
}
|
14
|
-
export declare class CORSPlugin<TContext extends Context> implements Plugin<TContext> {
|
15
|
-
private readonly options;
|
16
|
-
constructor(options?: Partial<CORSOptions<TContext>>);
|
17
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=cors.d.ts.map
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { StandardHandlerOptions } from '../adapters/standard';
|
2
|
-
import type { Context } from '../context';
|
3
|
-
import type { Plugin } from './base';
|
4
|
-
export interface ResponseHeadersPluginContext {
|
5
|
-
resHeaders?: Headers;
|
6
|
-
}
|
7
|
-
export declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements Plugin<TContext> {
|
8
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=response-headers.d.ts.map
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import type { Client, ErrorFromErrorMap, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Interceptor, Value } from '@orpc/shared';
|
3
|
-
import type { Context } from './context';
|
4
|
-
import type { Lazyable } from './lazy';
|
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>>;
|
7
|
-
export interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
8
|
-
context: TInitialContext;
|
9
|
-
input: SchemaInput<TInputSchema>;
|
10
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
11
|
-
path: string[];
|
12
|
-
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
13
|
-
signal?: AbortSignal;
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* Options for creating a procedure caller with comprehensive type safety
|
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> = {
|
19
|
-
/**
|
20
|
-
* This is helpful for logging and analytics.
|
21
|
-
*/
|
22
|
-
path?: string[];
|
23
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>[];
|
24
|
-
} & (Record<never, never> extends TInitialContext ? {
|
25
|
-
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
26
|
-
} : {
|
27
|
-
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
28
|
-
});
|
29
|
-
export type CreateProcedureClientRest<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext> = [options: CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>] | (Record<never, never> extends TInitialContext ? [] : never);
|
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>;
|
31
|
-
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
|
-
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
5
|
-
import { Procedure } from './procedure';
|
6
|
-
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
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, MergedErrorMap<TErrorMap, U>, TMeta>;
|
8
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
9
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
10
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
11
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
12
|
-
/**
|
13
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
14
|
-
*/
|
15
|
-
callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
16
|
-
/**
|
17
|
-
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
18
|
-
*/
|
19
|
-
actionable<TClientContext>(...rest: CreateProcedureClientRest<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
|
-
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Context } from './context';
|
3
|
-
import type { Lazyable } from './lazy';
|
4
|
-
import type { Procedure } from './procedure';
|
5
|
-
import { type CreateProcedureClientRest } from './procedure-client';
|
6
|
-
/**
|
7
|
-
* Directly call a procedure without creating a client.
|
8
|
-
*
|
9
|
-
* @example
|
10
|
-
* ```ts
|
11
|
-
* const output = await call(getting, 'input')
|
12
|
-
* const output = await call(getting, 'input', { context: { db: 'postgres' } })
|
13
|
-
* ```
|
14
|
-
*
|
15
|
-
*/
|
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: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, unknown>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
17
|
-
//# sourceMappingURL=procedure-utils.d.ts.map
|
package/dist/src/procedure.d.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
import type { ContractProcedureDef, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type { Context, TypeInitialContext } from './context';
|
4
|
-
import type { AnyMiddleware } from './middleware';
|
5
|
-
export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
6
|
-
context: TCurrentContext;
|
7
|
-
input: TInput;
|
8
|
-
path: string[];
|
9
|
-
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
10
|
-
signal?: AbortSignal;
|
11
|
-
errors: TErrorConstructorMap;
|
12
|
-
}
|
13
|
-
export interface ProcedureHandler<TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
14
|
-
(opt: ProcedureHandlerOptions<TCurrentContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
15
|
-
}
|
16
|
-
export interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
17
|
-
__initialContext?: TypeInitialContext<TInitialContext>;
|
18
|
-
middlewares: AnyMiddleware[];
|
19
|
-
inputValidationIndex: number;
|
20
|
-
outputValidationIndex: number;
|
21
|
-
handler: ProcedureHandler<TCurrentContext, any, any, THandlerOutput, any, any>;
|
22
|
-
}
|
23
|
-
export declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
24
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
25
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>);
|
26
|
-
}
|
27
|
-
export type AnyProcedure = Procedure<any, any, any, any, any, any, any>;
|
28
|
-
export declare function isProcedure(item: unknown): item is AnyProcedure;
|
29
|
-
//# sourceMappingURL=procedure.d.ts.map
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { Lazy } from './lazy';
|
2
|
-
import type { AnyProcedure } from './procedure';
|
3
|
-
import type { AnyRouter } from './router';
|
4
|
-
export type AccessibleLazyRouter<T extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : Lazy<T> & (T extends AnyProcedure | undefined ? unknown : {
|
5
|
-
[K in keyof T]: T[K] extends AnyRouter ? AccessibleLazyRouter<T[K]> : never;
|
6
|
-
});
|
7
|
-
export declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
8
|
-
//# sourceMappingURL=router-accessible-lazy.d.ts.map
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { ErrorMap, Meta } from '@orpc/contract';
|
2
|
-
import type { Lazy } from './lazy';
|
3
|
-
import type { Procedure } from './procedure';
|
4
|
-
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
5
|
-
import type { AnyRouter, Router } from './router';
|
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> : {
|
7
|
-
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
8
|
-
};
|
9
|
-
export type CreateRouterClientRest<TRouter extends AnyRouter, TClientContext> = CreateProcedureClientRest<TRouter extends Router<infer UContext, any> ? UContext : never, undefined, undefined, unknown, ErrorMap, Meta, TClientContext>;
|
10
|
-
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateRouterClientRest<TRouter, TClientContext>): RouterClient<TRouter, TClientContext>;
|
11
|
-
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/src/router.d.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
import type { AnyContractRouter, ContractProcedure, ErrorMap, HTTPPath, MergedErrorMap, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Context } from './context';
|
3
|
-
import type { Lazy, Lazyable } from './lazy';
|
4
|
-
import type { AnyMiddleware } from './middleware';
|
5
|
-
import type { AnyProcedure } from './procedure';
|
6
|
-
import { Procedure } from './procedure';
|
7
|
-
import { type AccessibleLazyRouter } from './router-accessible-lazy';
|
8
|
-
export type Router<TInitialContext extends Context, TContract extends AnyContractRouter> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, any, UErrorMap, UMeta> : {
|
9
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? Router<TInitialContext, TContract[K]> : never;
|
10
|
-
}>;
|
11
|
-
export type AnyRouter = Router<any, any>;
|
12
|
-
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
|
-
[K in keyof T]: T[K] extends AnyRouter ? InferRouterInputs<T[K]> : never;
|
14
|
-
};
|
15
|
-
export type InferRouterOutputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput, any, any> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
|
16
|
-
[K in keyof T]: T[K] extends AnyRouter ? InferRouterOutputs<T[K]> : never;
|
17
|
-
};
|
18
|
-
export type AdaptedRouter<TRouter extends AnyRouter, TInitialContext extends Context, TErrorMap extends ErrorMap> = TRouter extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<AdaptedRouter<U, TInitialContext, TErrorMap>> : TRouter extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UFuncOutput, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
19
|
-
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? AdaptedRouter<TRouter[K], TInitialContext, TErrorMap> : never;
|
20
|
-
};
|
21
|
-
export interface AdaptRouterOptions<TErrorMap extends ErrorMap> {
|
22
|
-
middlewares: AnyMiddleware[];
|
23
|
-
tags?: readonly string[];
|
24
|
-
prefix?: HTTPPath;
|
25
|
-
errorMap: TErrorMap;
|
26
|
-
}
|
27
|
-
export declare function adaptRouter<TRouter extends AnyRouter, TInitialContext extends Context, TErrorMap extends ErrorMap>(router: TRouter, options: AdaptRouterOptions<TErrorMap>): AdaptedRouter<TRouter, TInitialContext, TErrorMap>;
|
28
|
-
export declare function getRouterChild<T extends AnyRouter | Lazy<undefined>>(router: T, ...path: string[]): T extends Lazy<any> ? Lazy<AnyProcedure> | Lazy<Record<string, AnyRouter>> | Lazy<undefined> : AnyRouter | Lazy<undefined> | undefined;
|
29
|
-
//# sourceMappingURL=router.d.ts.map
|
package/dist/src/utils.d.ts
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { AnyContractProcedure, AnyContractRouter, HTTPPath } from '@orpc/contract';
|
2
|
-
import type { Lazy } from './lazy';
|
3
|
-
import type { AnyProcedure } from './procedure';
|
4
|
-
import type { AnyRouter } from './router';
|
5
|
-
export interface EachContractProcedureOptions {
|
6
|
-
router: AnyRouter | AnyContractRouter;
|
7
|
-
path: string[];
|
8
|
-
}
|
9
|
-
export interface EachContractProcedureCallbackOptions {
|
10
|
-
contract: AnyContractProcedure;
|
11
|
-
path: string[];
|
12
|
-
}
|
13
|
-
export interface EachContractProcedureLaziedOptions {
|
14
|
-
lazied: Lazy<AnyProcedure> | Lazy<Record<string, AnyRouter> | AnyProcedure>;
|
15
|
-
path: string[];
|
16
|
-
}
|
17
|
-
export declare function eachContractProcedure(options: EachContractProcedureOptions, callback: (options: EachContractProcedureCallbackOptions) => void, laziedOptions?: EachContractProcedureLaziedOptions[]): EachContractProcedureLaziedOptions[];
|
18
|
-
export declare function eachAllContractProcedure(options: EachContractProcedureOptions, callback: (options: EachContractProcedureCallbackOptions) => void): Promise<void>;
|
19
|
-
export declare function convertPathToHttpPath(path: string[]): HTTPPath;
|
20
|
-
/**
|
21
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
22
|
-
*/
|
23
|
-
export declare function createContractedProcedure(contract: AnyContractProcedure, procedure: AnyProcedure): AnyProcedure;
|
24
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/standard.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
RPCCodec,
|
3
|
-
RPCMatcher,
|
4
|
-
RPCSerializer,
|
5
|
-
StandardHandler,
|
6
|
-
serializeRPCJson
|
7
|
-
} from "./chunk-BFGSRNYZ.js";
|
8
|
-
import "./chunk-EDQKEHUX.js";
|
9
|
-
import "./chunk-XFBAK67J.js";
|
10
|
-
export {
|
11
|
-
RPCCodec,
|
12
|
-
RPCMatcher,
|
13
|
-
RPCSerializer,
|
14
|
-
StandardHandler,
|
15
|
-
serializeRPCJson
|
16
|
-
};
|
17
|
-
//# sourceMappingURL=standard.js.map
|