@orpc/server 0.0.0-next.b6be6f0 → 0.0.0-next.bc564a6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-ESTRJAOX.js +299 -0
- package/dist/chunk-KK4SDLC7.js +320 -0
- package/dist/chunk-WUOGVGWG.js +1 -0
- package/dist/fetch.js +10 -310
- package/dist/hono.js +30 -0
- package/dist/index.js +256 -383
- package/dist/next.js +36 -0
- package/dist/node.js +87 -0
- package/dist/src/{fetch → adapters/fetch}/index.d.ts +1 -1
- package/dist/src/adapters/fetch/orpc-handler.d.ts +20 -0
- package/dist/src/{fetch → adapters/fetch}/orpc-payload-codec.d.ts +1 -1
- package/dist/src/{fetch → adapters/fetch}/orpc-procedure-matcher.d.ts +4 -4
- 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-variants.d.ts +74 -0
- package/dist/src/builder.d.ts +52 -30
- package/dist/src/config.d.ts +6 -0
- package/dist/src/context.d.ts +9 -0
- package/dist/src/hidden.d.ts +6 -4
- package/dist/src/implementer-procedure.d.ts +30 -0
- package/dist/src/implementer-variants.d.ts +16 -0
- package/dist/src/implementer.d.ts +27 -0
- package/dist/src/index.d.ts +10 -12
- package/dist/src/lazy-utils.d.ts +4 -2
- package/dist/src/lazy.d.ts +9 -5
- package/dist/src/middleware-decorated.d.ts +7 -5
- package/dist/src/middleware-utils.d.ts +5 -0
- package/dist/src/middleware.d.ts +28 -14
- package/dist/src/procedure-client.d.ts +8 -22
- package/dist/src/procedure-decorated.d.ts +18 -11
- package/dist/src/procedure-utils.d.ts +17 -0
- package/dist/src/procedure.d.ts +24 -18
- package/dist/src/router-accessible-lazy.d.ts +8 -0
- package/dist/src/router-client.d.ts +7 -10
- package/dist/src/router.d.ts +25 -12
- package/package.json +24 -8
- package/dist/chunk-37HIYNDO.js +0 -182
- package/dist/src/fetch/composite-handler.d.ts +0 -8
- package/dist/src/fetch/orpc-handler.d.ts +0 -20
- package/dist/src/fetch/types.d.ts +0 -16
- package/dist/src/implementer-chainable.d.ts +0 -10
- package/dist/src/lazy-decorated.d.ts +0 -10
- package/dist/src/procedure-builder.d.ts +0 -22
- package/dist/src/procedure-implementer.d.ts +0 -18
- package/dist/src/router-builder.d.ts +0 -29
- package/dist/src/router-implementer.d.ts +0 -21
- package/dist/src/types.d.ts +0 -12
- package/dist/src/utils.d.ts +0 -3
- /package/dist/src/{fetch → adapters/fetch}/super-json.d.ts +0 -0
package/dist/src/index.d.ts
CHANGED
@@ -1,23 +1,21 @@
|
|
1
|
-
import type { WELL_CONTEXT } from './types';
|
2
|
-
import { Builder } from './builder';
|
3
1
|
export * from './builder';
|
2
|
+
export * from './builder-variants';
|
3
|
+
export * from './config';
|
4
|
+
export * from './context';
|
4
5
|
export * from './hidden';
|
5
|
-
export * from './implementer
|
6
|
+
export * from './implementer';
|
7
|
+
export * from './implementer-procedure';
|
8
|
+
export * from './implementer-variants';
|
6
9
|
export * from './lazy';
|
7
|
-
export * from './lazy-
|
10
|
+
export * from './lazy-utils';
|
8
11
|
export * from './middleware';
|
9
12
|
export * from './middleware-decorated';
|
10
13
|
export * from './procedure';
|
11
|
-
export * from './procedure-builder';
|
12
14
|
export * from './procedure-client';
|
13
15
|
export * from './procedure-decorated';
|
14
|
-
export * from './procedure-
|
16
|
+
export * from './procedure-utils';
|
15
17
|
export * from './router';
|
16
|
-
export * from './router-
|
18
|
+
export * from './router-accessible-lazy';
|
17
19
|
export * from './router-client';
|
18
|
-
export
|
19
|
-
export * from './types';
|
20
|
-
export * from './utils';
|
21
|
-
export * from '@orpc/shared/error';
|
22
|
-
export declare const os: Builder<WELL_CONTEXT, undefined>;
|
20
|
+
export { isDefinedError, ORPCError, safe, type, ValidationError } from '@orpc/contract';
|
23
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/lazy-utils.d.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import type { Lazy } from './lazy';
|
2
|
-
import { type
|
3
|
-
export
|
2
|
+
import { type AnyProcedure } from './procedure';
|
3
|
+
export type FlattenLazy<T> = T extends Lazy<infer U> ? FlattenLazy<U> : Lazy<T>;
|
4
|
+
export declare function flatLazy<T extends Lazy<any>>(lazied: T): FlattenLazy<T>;
|
5
|
+
export declare function createLazyProcedureFormAnyLazy(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
4
6
|
//# sourceMappingURL=lazy-utils.d.ts.map
|
package/dist/src/lazy.d.ts
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
1
2
|
export declare const LAZY_LOADER_SYMBOL: unique symbol;
|
3
|
+
export interface LazyMeta {
|
4
|
+
prefix?: HTTPPath;
|
5
|
+
}
|
2
6
|
export interface Lazy<T> {
|
3
|
-
[LAZY_LOADER_SYMBOL]
|
7
|
+
[LAZY_LOADER_SYMBOL](): Promise<{
|
4
8
|
default: T;
|
5
9
|
}>;
|
6
10
|
}
|
7
11
|
export type Lazyable<T> = T | Lazy<T>;
|
8
|
-
export
|
12
|
+
export interface LazyOptions {
|
13
|
+
prefix?: HTTPPath;
|
14
|
+
}
|
9
15
|
export declare function lazy<T>(loader: () => Promise<{
|
10
16
|
default: T;
|
11
17
|
}>): Lazy<T>;
|
12
|
-
export declare function isLazy(item: unknown): item is
|
18
|
+
export declare function isLazy(item: unknown): item is Lazy<any>;
|
13
19
|
export declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
14
20
|
default: T extends Lazy<infer U> ? U : T;
|
15
21
|
}>;
|
16
|
-
export type FlattenLazy<T> = T extends Lazy<infer U> ? FlattenLazy<U> : Lazy<T>;
|
17
|
-
export declare function flatLazy<T extends ANY_LAZY>(lazied: T): FlattenLazy<T>;
|
18
22
|
//# sourceMappingURL=lazy.d.ts.map
|
@@ -1,8 +1,10 @@
|
|
1
|
+
import type { Meta, ORPCErrorConstructorMap } from '@orpc/contract';
|
2
|
+
import type { Context, MergedContext } from './context';
|
1
3
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
2
|
-
|
3
|
-
|
4
|
-
concat
|
5
|
-
mapInput
|
4
|
+
export interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
|
5
|
+
concat<UOutContext extends Context, UInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
|
6
|
+
concat<UOutContext extends Context, UInput, UMappedInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<UInput & TInput, UMappedInput>): DecoratedMiddleware<TInContext, TOutContext & UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
|
7
|
+
mapInput<UInput = unknown>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
6
8
|
}
|
7
|
-
export declare function decorateMiddleware<
|
9
|
+
export declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
8
10
|
//# sourceMappingURL=middleware-decorated.d.ts.map
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { AnyMiddleware } from './middleware';
|
2
|
+
export declare function dedupeMiddlewares(compare: AnyMiddleware[], middlewares: AnyMiddleware[]): AnyMiddleware[];
|
3
|
+
export declare function mergeMiddlewares(first: AnyMiddleware[], second: AnyMiddleware[]): AnyMiddleware[];
|
4
|
+
export declare function addMiddleware(middlewares: AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
5
|
+
//# sourceMappingURL=middleware-utils.d.ts.map
|
package/dist/src/middleware.d.ts
CHANGED
@@ -1,23 +1,37 @@
|
|
1
|
+
import type { AbortSignal, ErrorMap, Meta, ORPCErrorConstructorMap, Schema } from '@orpc/contract';
|
1
2
|
import type { Promisable } from '@orpc/shared';
|
2
|
-
import type { Context
|
3
|
-
|
3
|
+
import type { Context } from './context';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
4
6
|
output: TOutput;
|
5
|
-
context:
|
7
|
+
context: TOutContext;
|
6
8
|
}>;
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
|
10
|
+
context?: TOutContext;
|
11
|
+
} : {
|
12
|
+
context: TOutContext;
|
13
|
+
};
|
14
|
+
export type MiddlewareNextFnRest<TOutContext extends Context> = [options: MiddlewareNextFnOptions<TOutContext>] | (Record<never, never> extends TOutContext ? [] : never);
|
15
|
+
export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
|
16
|
+
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MiddlewareNextFnRest<U>): MiddlewareResult<U, TOutput>;
|
14
17
|
}
|
15
|
-
export interface
|
16
|
-
(
|
18
|
+
export interface MiddlewareOutputFn<TOutput> {
|
19
|
+
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
17
20
|
}
|
18
|
-
export
|
21
|
+
export interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
22
|
+
context: TInContext;
|
23
|
+
path: string[];
|
24
|
+
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
25
|
+
signal?: AbortSignal;
|
26
|
+
next: MiddlewareNextFn<TInContext, TOutput>;
|
27
|
+
errors: TErrorConstructorMap;
|
28
|
+
}
|
29
|
+
export interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
30
|
+
(options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
|
31
|
+
}
|
32
|
+
export type AnyMiddleware = Middleware<any, any, any, any, any, any>;
|
19
33
|
export interface MapInputMiddleware<TInput, TMappedInput> {
|
20
34
|
(input: TInput): TMappedInput;
|
21
35
|
}
|
22
|
-
export
|
36
|
+
export declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
23
37
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,34 +1,20 @@
|
|
1
|
-
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
1
|
+
import type { Client, ErrorFromErrorMap, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
2
|
import type { Hooks, Value } from '@orpc/shared';
|
3
|
+
import type { Context } from './context';
|
3
4
|
import type { Lazyable } from './lazy';
|
4
5
|
import type { Procedure } from './procedure';
|
5
|
-
|
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
|
-
}
|
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>>;
|
14
7
|
/**
|
15
8
|
* Options for creating a procedure caller with comprehensive type safety
|
16
9
|
*/
|
17
|
-
export type CreateProcedureClientOptions<
|
18
|
-
procedure: Lazyable<Procedure<TContext, any, TInputSchema, TOutputSchema, THandlerOutput>>;
|
10
|
+
export type CreateProcedureClientOptions<TInitialContext extends Context, TCurrentContext extends Schema, THandlerOutput extends SchemaInput<TCurrentContext>, TClientContext> = {
|
19
11
|
/**
|
20
12
|
* This is helpful for logging and analytics.
|
21
|
-
*
|
22
|
-
* @internal
|
23
13
|
*/
|
24
14
|
path?: string[];
|
25
15
|
} & ({
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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>;
|
16
|
+
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
17
|
+
} | (Record<never, never> extends TInitialContext ? Record<never, never> : never)) & Hooks<unknown, SchemaOutput<TCurrentContext, THandlerOutput>, TInitialContext, any>;
|
18
|
+
export type CreateProcedureClientRest<TInitialContext extends Context, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TClientContext> = [options: CreateProcedureClientOptions<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>] | (Record<never, never> extends TInitialContext ? [] : never);
|
19
|
+
export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, any>>, ...[options]: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
34
20
|
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,14 +1,21 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
2
3
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
3
|
-
import type { ProcedureClient } from './procedure-client';
|
4
|
-
import type { Context, MergeContext } from './types';
|
4
|
+
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
5
5
|
import { Procedure } from './procedure';
|
6
|
-
export
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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, TOutputSchema, THandlerOutput, 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, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
20
|
+
}
|
14
21
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, 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>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, any>>, input: SchemaInput<TInputSchema>, ...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, unknown>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
17
|
+
//# sourceMappingURL=procedure-utils.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -1,23 +1,29 @@
|
|
1
|
+
import type { AbortSignal, ContractProcedureDef, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
1
2
|
import type { Promisable } from '@orpc/shared';
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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;
|
8
12
|
}
|
9
|
-
export interface
|
10
|
-
|
11
|
-
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
12
|
-
handler: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput>;
|
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>>;
|
13
15
|
}
|
14
|
-
export
|
15
|
-
|
16
|
-
|
17
|
-
|
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>;
|
18
22
|
}
|
19
|
-
export
|
20
|
-
|
21
|
-
|
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;
|
23
29
|
//# sourceMappingURL=procedure.d.ts.map
|
@@ -0,0 +1,8 @@
|
|
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,15 +1,12 @@
|
|
1
|
-
import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
1
|
import type { Hooks, Value } from '@orpc/shared';
|
3
2
|
import type { Lazy } from './lazy';
|
4
3
|
import type { Procedure } from './procedure';
|
5
|
-
import type { ProcedureClient } from './procedure-client';
|
6
|
-
import type {
|
7
|
-
|
8
|
-
|
9
|
-
[K in keyof TRouter]: TRouter[K] extends ANY_ROUTER | ContractRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
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;
|
10
8
|
};
|
11
|
-
export type CreateRouterClientOptions<TRouter extends
|
12
|
-
router: TRouter | Lazy<undefined>;
|
9
|
+
export type CreateRouterClientOptions<TRouter extends AnyRouter> = {
|
13
10
|
/**
|
14
11
|
* This is helpful for logging and analytics.
|
15
12
|
*
|
@@ -20,6 +17,6 @@ export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
|
|
20
17
|
context?: Value<UContext>;
|
21
18
|
} : {
|
22
19
|
context: Value<UContext>;
|
23
|
-
} : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never,
|
24
|
-
export declare function createRouterClient<TRouter extends
|
20
|
+
} : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never, any>;
|
21
|
+
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateProcedureClientRest<TRouter extends Router<infer UContext, any> ? UContext : never, undefined, unknown, TClientContext>): RouterClient<TRouter, TClientContext>;
|
25
22
|
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
@@ -1,16 +1,29 @@
|
|
1
|
-
import type { ContractProcedure,
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
|
6
|
-
|
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;
|
7
10
|
}>;
|
8
|
-
export type
|
9
|
-
export type InferRouterInputs<T extends
|
10
|
-
[K in keyof T]: T[K] extends
|
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;
|
11
14
|
};
|
12
|
-
export type InferRouterOutputs<T extends
|
13
|
-
[K in keyof T]: T[K] extends
|
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;
|
14
17
|
};
|
15
|
-
export
|
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;
|
16
29
|
//# sourceMappingURL=router.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.bc564a6",
|
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
|
}
|
@@ -33,15 +48,16 @@
|
|
33
48
|
"!**/*.tsbuildinfo",
|
34
49
|
"dist"
|
35
50
|
],
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
51
|
+
"peerDependencies": {
|
52
|
+
"hono": ">=4.6.0",
|
53
|
+
"next": ">=14.0.0"
|
39
54
|
},
|
40
|
-
"
|
41
|
-
"
|
55
|
+
"dependencies": {
|
56
|
+
"@orpc/contract": "0.0.0-next.bc564a6",
|
57
|
+
"@orpc/shared": "0.0.0-next.bc564a6"
|
42
58
|
},
|
43
59
|
"scripts": {
|
44
|
-
"build": "tsup --
|
60
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
45
61
|
"build:watch": "pnpm run build --watch",
|
46
62
|
"type:check": "tsc -b"
|
47
63
|
}
|