@orpc/server 0.0.0-next.8f101b9 → 0.0.0-next.905e81c
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 +118 -0
- package/dist/chunk-47YYO5JS.js +32 -0
- package/dist/chunk-77FU7QSO.js +181 -0
- package/dist/{chunk-KK4SDLC7.js → chunk-MHVECKBC.js} +132 -31
- package/dist/chunk-WQNNSBXW.js +120 -0
- package/dist/fetch.js +6 -11
- package/dist/hono.js +17 -13
- package/dist/index.js +30 -7
- package/dist/next.js +5 -10
- package/dist/node.js +18 -74
- package/dist/plugins.js +11 -0
- package/dist/src/adapters/fetch/index.d.ts +1 -4
- package/dist/src/adapters/fetch/rpc-handler.d.ts +11 -0
- package/dist/src/adapters/fetch/types.d.ts +3 -10
- package/dist/src/adapters/hono/middleware.d.ts +5 -5
- package/dist/src/adapters/next/serve.d.ts +5 -5
- package/dist/src/adapters/node/index.d.ts +1 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +11 -0
- package/dist/src/adapters/node/types.d.ts +14 -14
- package/dist/src/adapters/standard/handler.d.ts +53 -0
- package/dist/src/adapters/standard/index.d.ts +6 -0
- package/dist/src/adapters/standard/rpc-codec.d.ts +16 -0
- package/dist/src/adapters/standard/rpc-handler.d.ts +8 -0
- package/dist/src/adapters/standard/rpc-matcher.d.ts +10 -0
- package/dist/src/adapters/standard/types.d.ts +21 -0
- package/dist/src/builder-variants.d.ts +2 -1
- package/dist/src/builder.d.ts +2 -1
- package/dist/src/context.d.ts +0 -1
- package/dist/src/error.d.ts +12 -0
- package/dist/src/implementer-procedure.d.ts +7 -4
- package/dist/src/implementer-variants.d.ts +7 -5
- package/dist/src/implementer.d.ts +8 -6
- package/dist/src/index.d.ts +5 -1
- package/dist/src/middleware-decorated.d.ts +2 -1
- package/dist/src/middleware.d.ts +5 -4
- package/dist/src/plugins/base.d.ts +11 -0
- package/dist/src/plugins/cors.d.ts +19 -0
- package/dist/src/plugins/index.d.ts +4 -0
- package/dist/src/plugins/response-headers.d.ts +10 -0
- package/dist/src/procedure-client.d.ts +21 -8
- package/dist/src/procedure-decorated.d.ts +7 -4
- package/dist/src/procedure-utils.d.ts +5 -3
- package/dist/src/procedure.d.ts +5 -3
- package/dist/src/router-client.d.ts +7 -17
- package/dist/src/router.d.ts +1 -0
- package/dist/src/utils.d.ts +24 -0
- package/dist/standard.js +13 -0
- package/package.json +20 -3
- package/dist/chunk-ESTRJAOX.js +0 -299
- package/dist/chunk-WUOGVGWG.js +0 -1
- package/dist/src/adapters/fetch/orpc-handler.d.ts +0 -20
- package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +0 -16
- package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +0 -12
- package/dist/src/adapters/fetch/super-json.d.ts +0 -12
- package/dist/src/adapters/node/orpc-handler.d.ts +0 -12
- package/dist/src/adapters/node/request-listener.d.ts +0 -28
@@ -1,16 +1,18 @@
|
|
1
|
-
import type { AnyContractRouter, ContractProcedure,
|
1
|
+
import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta } from '@orpc/contract';
|
2
2
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
+
import type { ORPCErrorConstructorMap } from './error';
|
3
4
|
import type { ProcedureImplementer } from './implementer-procedure';
|
4
5
|
import type { FlattenLazy } from './lazy-utils';
|
5
6
|
import type { Middleware } from './middleware';
|
6
7
|
import type { AdaptedRouter, Router } from './router';
|
7
|
-
export
|
8
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>,
|
8
|
+
export interface RouterImplementerWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
9
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
9
10
|
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
10
11
|
lazy<U extends Router<TInitialContext, TContract>>(loader: () => Promise<{
|
11
12
|
default: U;
|
12
13
|
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
13
|
-
}
|
14
|
+
}
|
15
|
+
export type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
14
16
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
15
|
-
}
|
17
|
+
});
|
16
18
|
//# sourceMappingURL=implementer-variants.d.ts.map
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import type { AnyContractRouter, ContractProcedure,
|
1
|
+
import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta } from '@orpc/contract';
|
2
2
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
+
import type { ORPCErrorConstructorMap } from './error';
|
3
4
|
import type { ProcedureImplementer } from './implementer-procedure';
|
4
5
|
import type { ImplementerInternalWithMiddlewares } from './implementer-variants';
|
5
6
|
import type { AnyMiddleware, Middleware } from './middleware';
|
@@ -7,17 +8,18 @@ import { type BuilderConfig } from './builder';
|
|
7
8
|
import { type FlattenLazy } from './lazy-utils';
|
8
9
|
import { type DecoratedMiddleware } from './middleware-decorated';
|
9
10
|
import { type AdaptedRouter, type Router } from './router';
|
10
|
-
export
|
11
|
+
export interface RouterImplementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
11
12
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
12
|
-
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>,
|
13
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>,
|
13
|
+
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, ContractRouterToMeta<TContract>>;
|
14
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
14
15
|
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
15
16
|
lazy<U extends Router<TCurrentContext, TContract>>(loader: () => Promise<{
|
16
17
|
default: U;
|
17
18
|
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
18
|
-
}
|
19
|
+
}
|
20
|
+
export type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
|
19
21
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
20
|
-
}
|
22
|
+
});
|
21
23
|
export declare function implementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: TContract, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
22
24
|
export type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
23
25
|
$context<U extends Context>(): Implementer<TContract, U, U>;
|
package/dist/src/index.d.ts
CHANGED
@@ -17,5 +17,9 @@ export * from './procedure-utils';
|
|
17
17
|
export * from './router';
|
18
18
|
export * from './router-accessible-lazy';
|
19
19
|
export * from './router-client';
|
20
|
-
export
|
20
|
+
export * from './utils';
|
21
|
+
export { isDefinedError, ORPCError, safe } from '@orpc/client';
|
22
|
+
export { eventIterator, type, ValidationError } from '@orpc/contract';
|
23
|
+
export { getEventMeta, withEventMeta } from '@orpc/server-standard';
|
24
|
+
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
21
25
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import type { Meta
|
1
|
+
import type { Meta } from '@orpc/contract';
|
2
2
|
import type { Context, MergedContext } from './context';
|
3
|
+
import type { ORPCErrorConstructorMap } from './error';
|
3
4
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
5
|
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
6
|
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>;
|
package/dist/src/middleware.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
1
|
+
import type { ErrorMap, Meta, Schema } from '@orpc/contract';
|
2
|
+
import type { MaybeOptionalOptions, Promisable } from '@orpc/shared';
|
3
3
|
import type { Context } from './context';
|
4
|
+
import type { ORPCErrorConstructorMap } from './error';
|
4
5
|
import type { Procedure } from './procedure';
|
5
6
|
export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
6
7
|
output: TOutput;
|
@@ -11,9 +12,8 @@ export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never,
|
|
11
12
|
} : {
|
12
13
|
context: TOutContext;
|
13
14
|
};
|
14
|
-
export type MiddlewareNextFnRest<TOutContext extends Context> = [options: MiddlewareNextFnOptions<TOutContext>] | (Record<never, never> extends TOutContext ? [] : never);
|
15
15
|
export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
|
16
|
-
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest:
|
16
|
+
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
|
17
17
|
}
|
18
18
|
export interface MiddlewareOutputFn<TOutput> {
|
19
19
|
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
@@ -23,6 +23,7 @@ export interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorCo
|
|
23
23
|
path: string[];
|
24
24
|
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
25
25
|
signal?: AbortSignal;
|
26
|
+
lastEventId: string | undefined;
|
26
27
|
next: MiddlewareNextFn<TInContext, TOutput>;
|
27
28
|
errors: TErrorConstructorMap;
|
28
29
|
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { StandardHandlerOptions } from '../adapters/standard';
|
2
|
+
import type { Context } from '../context';
|
3
|
+
export interface Plugin<TContext extends Context> {
|
4
|
+
init?(options: StandardHandlerOptions<TContext>): void;
|
5
|
+
}
|
6
|
+
export declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
|
7
|
+
private readonly plugins;
|
8
|
+
constructor(plugins?: Plugin<TContext>[]);
|
9
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
10
|
+
}
|
11
|
+
//# sourceMappingURL=base.d.ts.map
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -0,0 +1,10 @@
|
|
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,20 +1,33 @@
|
|
1
|
-
import type { Client,
|
2
|
-
import type {
|
1
|
+
import type { Client, ClientContext } from '@orpc/client';
|
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
|
-
|
6
|
+
import { type ErrorFromErrorMap, type ErrorMap, type Meta, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
7
|
+
import { type ORPCErrorConstructorMap } from './error';
|
8
|
+
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>>;
|
9
|
+
export interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
10
|
+
context: TInitialContext;
|
11
|
+
input: SchemaInput<TInputSchema>;
|
12
|
+
errors: ORPCErrorConstructorMap<TErrorMap>;
|
13
|
+
path: string[];
|
14
|
+
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
15
|
+
signal?: AbortSignal;
|
16
|
+
lastEventId: string | undefined;
|
17
|
+
}
|
7
18
|
/**
|
8
19
|
* Options for creating a procedure caller with comprehensive type safety
|
9
20
|
*/
|
10
|
-
export type CreateProcedureClientOptions<TInitialContext extends Context,
|
21
|
+
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> = {
|
11
22
|
/**
|
12
23
|
* This is helpful for logging and analytics.
|
13
24
|
*/
|
14
25
|
path?: string[];
|
15
|
-
|
26
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>[];
|
27
|
+
} & (Record<never, never> extends TInitialContext ? {
|
28
|
+
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
29
|
+
} : {
|
16
30
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
17
|
-
}
|
18
|
-
export
|
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>;
|
31
|
+
});
|
32
|
+
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>;
|
20
33
|
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,7 +1,10 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ClientContext, ClientRest } from '@orpc/client';
|
2
|
+
import type { ErrorMap, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
4
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
5
|
+
import type { ORPCErrorConstructorMap } from './error';
|
3
6
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
|
-
import type {
|
7
|
+
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
5
8
|
import { Procedure } from './procedure';
|
6
9
|
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
10
|
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, MergedErrorMap<TErrorMap, U>, TMeta>;
|
@@ -12,10 +15,10 @@ export declare class DecoratedProcedure<TInitialContext extends Context, TCurren
|
|
12
15
|
/**
|
13
16
|
* Make this procedure callable (works like a function while still being a procedure).
|
14
17
|
*/
|
15
|
-
callable<TClientContext>(...rest:
|
18
|
+
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
19
|
/**
|
17
20
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
18
21
|
*/
|
19
|
-
actionable<TClientContext>(...rest:
|
22
|
+
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
23
|
}
|
21
24
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import type { ClientPromiseResult
|
1
|
+
import type { ClientPromiseResult } from '@orpc/client';
|
2
|
+
import type { ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
4
|
import type { Context } from './context';
|
3
5
|
import type { Lazyable } from './lazy';
|
4
6
|
import type { Procedure } from './procedure';
|
5
|
-
import {
|
7
|
+
import type { CreateProcedureClientOptions } from './procedure-client';
|
6
8
|
/**
|
7
9
|
* Directly call a procedure without creating a client.
|
8
10
|
*
|
@@ -13,5 +15,5 @@ import { type CreateProcedureClientRest } from './procedure-client';
|
|
13
15
|
* ```
|
14
16
|
*
|
15
17
|
*/
|
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,
|
18
|
+
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
19
|
//# sourceMappingURL=procedure-utils.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ContractProcedureDef, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
2
|
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type { Context
|
3
|
+
import type { Context } from './context';
|
4
|
+
import type { ORPCErrorConstructorMap } from './error';
|
4
5
|
import type { AnyMiddleware } from './middleware';
|
5
6
|
export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
6
7
|
context: TCurrentContext;
|
@@ -8,13 +9,14 @@ export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput
|
|
8
9
|
path: string[];
|
9
10
|
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
10
11
|
signal?: AbortSignal;
|
12
|
+
lastEventId: string | undefined;
|
11
13
|
errors: TErrorConstructorMap;
|
12
14
|
}
|
13
15
|
export interface ProcedureHandler<TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
14
16
|
(opt: ProcedureHandlerOptions<TCurrentContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
15
17
|
}
|
16
18
|
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?:
|
19
|
+
__initialContext?: (type: TInitialContext) => unknown;
|
18
20
|
middlewares: AnyMiddleware[];
|
19
21
|
inputValidationIndex: number;
|
20
22
|
outputValidationIndex: number;
|
@@ -1,22 +1,12 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ClientContext } from '@orpc/client';
|
2
|
+
import type { ErrorMap, Meta } from '@orpc/contract';
|
3
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
4
|
import type { Lazy } from './lazy';
|
3
5
|
import type { Procedure } from './procedure';
|
4
|
-
import type {
|
5
|
-
import type { AnyRouter,
|
6
|
-
export type RouterClient<TRouter extends AnyRouter, TClientContext
|
6
|
+
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
7
|
+
import type { AnyRouter, InferRouterInitialContext } from './router';
|
8
|
+
export type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = 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
9
|
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
8
10
|
};
|
9
|
-
export
|
10
|
-
/**
|
11
|
-
* This is helpful for logging and analytics.
|
12
|
-
*
|
13
|
-
* @internal
|
14
|
-
*/
|
15
|
-
path?: string[];
|
16
|
-
} & (TRouter extends Router<infer UContext, any> ? undefined extends UContext ? {
|
17
|
-
context?: Value<UContext>;
|
18
|
-
} : {
|
19
|
-
context: Value<UContext>;
|
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>;
|
11
|
+
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>;
|
22
12
|
//# 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
|
};
|
@@ -0,0 +1,24 @@
|
|
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
ADDED
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.905e81c",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -19,6 +19,16 @@
|
|
19
19
|
"import": "./dist/index.js",
|
20
20
|
"default": "./dist/index.js"
|
21
21
|
},
|
22
|
+
"./plugins": {
|
23
|
+
"types": "./dist/src/plugins/index.d.ts",
|
24
|
+
"import": "./dist/plugins.js",
|
25
|
+
"default": "./dist/plugins.js"
|
26
|
+
},
|
27
|
+
"./standard": {
|
28
|
+
"types": "./dist/src/adapters/standard/index.d.ts",
|
29
|
+
"import": "./dist/standard.js",
|
30
|
+
"default": "./dist/standard.js"
|
31
|
+
},
|
22
32
|
"./fetch": {
|
23
33
|
"types": "./dist/src/adapters/fetch/index.d.ts",
|
24
34
|
"import": "./dist/fetch.js",
|
@@ -53,8 +63,15 @@
|
|
53
63
|
"next": ">=14.0.0"
|
54
64
|
},
|
55
65
|
"dependencies": {
|
56
|
-
"@orpc/
|
57
|
-
"@orpc/
|
66
|
+
"@orpc/server-standard": "^0.4.0",
|
67
|
+
"@orpc/server-standard-fetch": "^0.4.0",
|
68
|
+
"@orpc/server-standard-node": "^0.4.0",
|
69
|
+
"@orpc/shared": "0.0.0-next.905e81c",
|
70
|
+
"@orpc/contract": "0.0.0-next.905e81c",
|
71
|
+
"@orpc/client": "0.0.0-next.905e81c"
|
72
|
+
},
|
73
|
+
"devDependencies": {
|
74
|
+
"light-my-request": "^6.5.1"
|
58
75
|
},
|
59
76
|
"scripts": {
|
60
77
|
"build": "tsup --onSuccess='tsc -b --noCheck'",
|