@orpc/server 0.51.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/adapters/fetch/index.d.mts +6 -6
- package/dist/adapters/fetch/index.d.ts +6 -6
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/hono/index.d.mts +4 -4
- package/dist/adapters/hono/index.d.ts +4 -4
- package/dist/adapters/hono/index.mjs +3 -3
- package/dist/adapters/next/index.d.mts +4 -4
- package/dist/adapters/next/index.d.ts +4 -4
- package/dist/adapters/next/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +6 -6
- package/dist/adapters/node/index.d.ts +6 -6
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +3 -2
- package/dist/index.d.mts +50 -36
- package/dist/index.d.ts +50 -36
- package/dist/index.mjs +27 -6
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/shared/{server.CIbpOMZX.d.mts → server.B77ImKAP.d.mts} +2 -2
- package/dist/shared/{server.23VRZIfj.d.ts → server.BHlRCrf_.d.ts} +7 -7
- package/dist/shared/{server.BG5ftPWa.d.ts → server.Cud5qk0c.d.ts} +2 -2
- package/dist/shared/{server.DJqfB27m.d.mts → server.CzxlqYZL.d.mts} +7 -7
- package/dist/shared/{server.C-CCcROC.d.mts → server.DGnN7q3R.d.mts} +2 -2
- package/dist/shared/{server.MZvbGc3n.d.mts → server.DLt5njUb.d.mts} +8 -8
- package/dist/shared/{server.MZvbGc3n.d.ts → server.DLt5njUb.d.ts} +8 -8
- package/dist/shared/{server.DCcCuA52.d.ts → server.DUF89eb-.d.ts} +2 -2
- package/dist/shared/{server.DnR6v9pj.mjs → server.Dfx1jV-K.mjs} +2 -1
- package/dist/shared/{server.B4eSvRkD.mjs → server.T5WmDoWQ.mjs} +1 -1
- package/dist/shared/{server.BtxZnWJ9.mjs → server.e3W6AG3-.mjs} +3 -7
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
@@ -1,13 +1,29 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
3
|
-
import {
|
4
|
-
export {
|
5
|
-
import {
|
6
|
-
export {
|
7
|
-
import {
|
8
|
-
export {
|
1
|
+
import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, ClientPromiseResult } from '@orpc/client';
|
2
|
+
export { HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe } from '@orpc/client';
|
3
|
+
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta } from '@orpc/contract';
|
4
|
+
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
5
|
+
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
6
|
+
export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.DLt5njUb.js';
|
8
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.DLt5njUb.js';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
|
+
type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
|
12
|
+
defined: true;
|
13
|
+
} : ORPCErrorJSON<string, unknown> & {
|
14
|
+
defined: false;
|
15
|
+
};
|
16
|
+
type UnactionableError<T> = T extends {
|
17
|
+
defined: true;
|
18
|
+
} & ORPCErrorJSON<infer U, infer V> ? ORPCError<U, V> : ThrowableError;
|
19
|
+
type ActionableClientRest<TInput> = [input: TInput] | (undefined extends TInput ? [input?: TInput] : [input: TInput]);
|
20
|
+
type ActionableClientResult<TOutput, TError extends ORPCErrorJSON<any, any>> = [error: null, data: TOutput] | [error: TError, data: undefined];
|
21
|
+
interface ActionableClient<TInput, TOutput, TError extends ORPCErrorJSON<any, any>> {
|
22
|
+
(...rest: ActionableClientRest<TInput>): Promise<ActionableClientResult<TOutput, TError>>;
|
23
|
+
}
|
24
|
+
type ProcedureActionableClient<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = ActionableClient<InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ActionableError<ErrorFromErrorMap<TErrorMap>>>;
|
25
|
+
declare function createActionableClient<TInput, TOutput, TError>(client: Client<Record<never, never>, TInput, TOutput, TError>): ActionableClient<TInput, TOutput, ActionableError<TError>>;
|
26
|
+
|
11
27
|
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
12
28
|
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
29
|
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -17,11 +33,11 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
|
|
17
33
|
/**
|
18
34
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
35
|
*/
|
20
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
36
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
21
37
|
/**
|
22
|
-
* Make this procedure compatible with server action
|
38
|
+
* Make this procedure compatible with server action.
|
23
39
|
*/
|
24
|
-
actionable
|
40
|
+
actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
|
25
41
|
}
|
26
42
|
|
27
43
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
@@ -60,7 +76,7 @@ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedR
|
|
60
76
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
61
77
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
62
78
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
63
|
-
'use'<UOutContext extends
|
79
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
64
80
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
65
81
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
66
82
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -76,7 +92,7 @@ interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContex
|
|
76
92
|
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
77
93
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
78
94
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
79
|
-
'use'<UOutContext extends
|
95
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
80
96
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
81
97
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
82
98
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -86,8 +102,8 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
|
|
86
102
|
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
87
103
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
88
104
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
89
|
-
'use'<UOutContext extends
|
90
|
-
'use'<UOutContext extends
|
105
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
106
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
91
107
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
92
108
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
93
109
|
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
@@ -96,7 +112,7 @@ interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentCon
|
|
96
112
|
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
97
113
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
98
114
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
99
|
-
'use'<UOutContext extends
|
115
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
100
116
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
101
117
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
102
118
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -105,8 +121,8 @@ interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentCo
|
|
105
121
|
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
106
122
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
107
123
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
108
|
-
'use'<UOutContext extends
|
109
|
-
'use'<UOutContext extends
|
124
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
125
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
110
126
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
111
127
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
112
128
|
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -114,7 +130,7 @@ interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurr
|
|
114
130
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
115
131
|
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
116
132
|
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
117
|
-
'use'<UOutContext extends
|
133
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): RouterBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
118
134
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
119
135
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
120
136
|
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
@@ -125,8 +141,8 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
125
141
|
|
126
142
|
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> {
|
127
143
|
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
128
|
-
concat<UOutContext extends
|
129
|
-
concat<UOutContext extends
|
144
|
+
concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
145
|
+
concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
130
146
|
}
|
131
147
|
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>;
|
132
148
|
|
@@ -161,10 +177,10 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
161
177
|
*/
|
162
178
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
163
179
|
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
164
|
-
middleware<UOutContext extends
|
180
|
+
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
165
181
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
166
182
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
167
|
-
use<UOutContext extends
|
183
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
168
184
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
169
185
|
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
170
186
|
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -195,24 +211,24 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
195
211
|
/**
|
196
212
|
* Make this procedure callable (works like a function while still being a procedure).
|
197
213
|
*/
|
198
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
214
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
199
215
|
/**
|
200
|
-
* Make this procedure compatible with server action
|
216
|
+
* Make this procedure compatible with server action.
|
201
217
|
*/
|
202
|
-
actionable
|
218
|
+
actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
|
203
219
|
}
|
204
220
|
/**
|
205
221
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
206
222
|
*/
|
207
223
|
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
208
224
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
209
|
-
'use'<UOutContext extends
|
210
|
-
'use'<UOutContext extends
|
225
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
226
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
211
227
|
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
212
228
|
}
|
213
229
|
|
214
230
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
215
|
-
use<UOutContext extends
|
231
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
216
232
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
217
233
|
lazy<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
218
234
|
default: U;
|
@@ -223,9 +239,9 @@ type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TIn
|
|
223
239
|
});
|
224
240
|
|
225
241
|
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
226
|
-
middleware<UOutContext extends
|
242
|
+
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
227
243
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
228
|
-
use<UOutContext extends
|
244
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
229
245
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
230
246
|
lazy<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
231
247
|
default: U;
|
@@ -262,16 +278,14 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
262
278
|
* ```
|
263
279
|
*
|
264
280
|
*/
|
265
|
-
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
281
|
+
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
266
282
|
|
267
283
|
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
268
284
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
269
285
|
};
|
270
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>,
|
286
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
|
271
287
|
|
272
288
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
273
289
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
274
290
|
|
275
|
-
|
276
|
-
|
277
|
-
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
|
291
|
+
export { type AccessibleLazyRouter, type ActionableClient, type ActionableClientRest, type ActionableClientResult, type ActionableError, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureActionableClient, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnactionableError, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|
package/dist/index.mjs
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
|
2
2
|
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
-
import { P as Procedure,
|
4
|
-
export { L as LAZY_SYMBOL,
|
3
|
+
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure, g as getRouter } from './shared/server.e3W6AG3-.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.e3W6AG3-.mjs';
|
5
|
+
import { toORPCError } from '@orpc/client';
|
5
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
6
7
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
8
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
@@ -44,6 +45,17 @@ function decorateMiddleware(middleware) {
|
|
44
45
|
return decorated;
|
45
46
|
}
|
46
47
|
|
48
|
+
function createActionableClient(client) {
|
49
|
+
const action = async (input) => {
|
50
|
+
try {
|
51
|
+
return [null, await client(input)];
|
52
|
+
} catch (error) {
|
53
|
+
return [toORPCError(error).toJSON(), void 0];
|
54
|
+
}
|
55
|
+
};
|
56
|
+
return action;
|
57
|
+
}
|
58
|
+
|
47
59
|
class DecoratedProcedure extends Procedure {
|
48
60
|
errors(errors) {
|
49
61
|
return new DecoratedProcedure({
|
@@ -74,7 +86,8 @@ class DecoratedProcedure extends Procedure {
|
|
74
86
|
* Make this procedure callable (works like a function while still being a procedure).
|
75
87
|
*/
|
76
88
|
callable(...rest) {
|
77
|
-
|
89
|
+
const client = createProcedureClient(this, ...rest);
|
90
|
+
return new Proxy(client, {
|
78
91
|
get: (target, key) => {
|
79
92
|
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
80
93
|
},
|
@@ -84,10 +97,18 @@ class DecoratedProcedure extends Procedure {
|
|
84
97
|
});
|
85
98
|
}
|
86
99
|
/**
|
87
|
-
* Make this procedure compatible with server action
|
100
|
+
* Make this procedure compatible with server action.
|
88
101
|
*/
|
89
102
|
actionable(...rest) {
|
90
|
-
|
103
|
+
const action = createActionableClient(createProcedureClient(this, ...rest));
|
104
|
+
return new Proxy(action, {
|
105
|
+
get: (target, key) => {
|
106
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
107
|
+
},
|
108
|
+
has: (target, key) => {
|
109
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
110
|
+
}
|
111
|
+
});
|
91
112
|
}
|
92
113
|
}
|
93
114
|
|
@@ -339,4 +360,4 @@ function createRouterClient(router, ...[options]) {
|
|
339
360
|
return recursive;
|
340
361
|
}
|
341
362
|
|
342
|
-
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
|
363
|
+
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.
|
1
|
+
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.CzxlqYZL.mjs';
|
2
2
|
import { Value } from '@orpc/shared';
|
3
|
-
import { C as Context } from '../shared/server.
|
3
|
+
import { C as Context } from '../shared/server.DLt5njUb.mjs';
|
4
|
+
import '@orpc/client';
|
4
5
|
import '@orpc/contract';
|
5
6
|
import '@orpc/standard-server';
|
6
|
-
import '@orpc/client';
|
7
7
|
|
8
8
|
interface CORSOptions<T extends Context> {
|
9
9
|
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.
|
1
|
+
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.BHlRCrf_.js';
|
2
2
|
import { Value } from '@orpc/shared';
|
3
|
-
import { C as Context } from '../shared/server.
|
3
|
+
import { C as Context } from '../shared/server.DLt5njUb.js';
|
4
|
+
import '@orpc/client';
|
4
5
|
import '@orpc/contract';
|
5
6
|
import '@orpc/standard-server';
|
6
|
-
import '@orpc/client';
|
7
7
|
|
8
8
|
interface CORSOptions<T extends Context> {
|
9
9
|
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { C as Context } from './server.
|
3
|
-
import { a as StandardHandlerOptions } from './server.
|
2
|
+
import { C as Context } from './server.DLt5njUb.mjs';
|
3
|
+
import { a as StandardHandlerOptions } from './server.CzxlqYZL.mjs';
|
4
4
|
|
5
5
|
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
6
|
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { HTTPPath,
|
2
|
-
import {
|
1
|
+
import { HTTPPath, ORPCError } from '@orpc/client';
|
2
|
+
import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
|
3
|
+
import { Interceptor, ThrowableError } from '@orpc/shared';
|
3
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
5
|
-
import { ORPCError } from '@orpc/client';
|
5
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.DLt5njUb.js';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
8
8
|
type StandardMatchResult = {
|
@@ -42,16 +42,16 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
42
42
|
/**
|
43
43
|
* Interceptors at the request level, helpful when you want catch errors
|
44
44
|
*/
|
45
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult,
|
45
|
+
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
|
46
46
|
/**
|
47
47
|
* Interceptors at the root level, helpful when you want override the request/response
|
48
48
|
*/
|
49
|
-
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult,
|
49
|
+
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
|
50
50
|
/**
|
51
51
|
*
|
52
52
|
* Interceptors for procedure client.
|
53
53
|
*/
|
54
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
54
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
55
55
|
}
|
56
56
|
declare class StandardHandler<T extends Context> {
|
57
57
|
private readonly matcher;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { C as Context } from './server.
|
2
|
-
import { S as StandardHandleOptions } from './server.
|
1
|
+
import { C as Context } from './server.DLt5njUb.js';
|
2
|
+
import { S as StandardHandleOptions } from './server.BHlRCrf_.js';
|
3
3
|
|
4
4
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
5
5
|
context?: T;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { HTTPPath,
|
2
|
-
import {
|
1
|
+
import { HTTPPath, ORPCError } from '@orpc/client';
|
2
|
+
import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
|
3
|
+
import { Interceptor, ThrowableError } from '@orpc/shared';
|
3
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
5
|
-
import { ORPCError } from '@orpc/client';
|
5
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.DLt5njUb.mjs';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
8
8
|
type StandardMatchResult = {
|
@@ -42,16 +42,16 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
42
42
|
/**
|
43
43
|
* Interceptors at the request level, helpful when you want catch errors
|
44
44
|
*/
|
45
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult,
|
45
|
+
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
|
46
46
|
/**
|
47
47
|
* Interceptors at the root level, helpful when you want override the request/response
|
48
48
|
*/
|
49
|
-
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult,
|
49
|
+
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
|
50
50
|
/**
|
51
51
|
*
|
52
52
|
* Interceptors for procedure client.
|
53
53
|
*/
|
54
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
54
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
55
55
|
}
|
56
56
|
declare class StandardHandler<T extends Context> {
|
57
57
|
private readonly matcher;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { C as Context } from './server.
|
2
|
-
import { S as StandardHandleOptions } from './server.
|
1
|
+
import { C as Context } from './server.DLt5njUb.mjs';
|
2
|
+
import { S as StandardHandleOptions } from './server.CzxlqYZL.mjs';
|
3
3
|
|
4
4
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
5
5
|
context?: T;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
|
1
|
+
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
|
2
2
|
import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
3
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput,
|
3
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
4
4
|
|
5
|
-
type Context = Record<
|
5
|
+
type Context = Record<PropertyKey, any>;
|
6
6
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
7
7
|
type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
|
8
8
|
declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
|
@@ -97,9 +97,9 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
97
97
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
98
98
|
|
99
99
|
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
100
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context,
|
100
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
101
101
|
context: TInitialContext;
|
102
|
-
input:
|
102
|
+
input: unknown;
|
103
103
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
104
104
|
path: readonly string[];
|
105
105
|
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
@@ -109,18 +109,18 @@ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TIn
|
|
109
109
|
/**
|
110
110
|
* Options for creating a procedure caller with comprehensive type safety
|
111
111
|
*/
|
112
|
-
type CreateProcedureClientOptions<TInitialContext extends Context,
|
112
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
113
113
|
/**
|
114
114
|
* This is helpful for logging and analytics.
|
115
115
|
*/
|
116
116
|
path?: readonly string[];
|
117
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext,
|
117
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
|
118
118
|
} & (Record<never, never> extends TInitialContext ? {
|
119
119
|
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
120
120
|
} : {
|
121
121
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
122
122
|
});
|
123
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
123
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
124
124
|
|
125
125
|
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
126
126
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
|
1
|
+
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
|
2
2
|
import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
3
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput,
|
3
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
4
4
|
|
5
|
-
type Context = Record<
|
5
|
+
type Context = Record<PropertyKey, any>;
|
6
6
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
7
7
|
type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
|
8
8
|
declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
|
@@ -97,9 +97,9 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
97
97
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
98
98
|
|
99
99
|
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
100
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context,
|
100
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
101
101
|
context: TInitialContext;
|
102
|
-
input:
|
102
|
+
input: unknown;
|
103
103
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
104
104
|
path: readonly string[];
|
105
105
|
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
@@ -109,18 +109,18 @@ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TIn
|
|
109
109
|
/**
|
110
110
|
* Options for creating a procedure caller with comprehensive type safety
|
111
111
|
*/
|
112
|
-
type CreateProcedureClientOptions<TInitialContext extends Context,
|
112
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
113
113
|
/**
|
114
114
|
* This is helpful for logging and analytics.
|
115
115
|
*/
|
116
116
|
path?: readonly string[];
|
117
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext,
|
117
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
|
118
118
|
} & (Record<never, never> extends TInitialContext ? {
|
119
119
|
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
120
120
|
} : {
|
121
121
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
122
122
|
});
|
123
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
123
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
124
124
|
|
125
125
|
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
126
126
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { C as Context } from './server.
|
3
|
-
import { a as StandardHandlerOptions } from './server.
|
2
|
+
import { C as Context } from './server.DLt5njUb.js';
|
3
|
+
import { a as StandardHandlerOptions } from './server.BHlRCrf_.js';
|
4
4
|
|
5
5
|
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
6
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { ORPCError, toORPCError } from '@orpc/client';
|
2
2
|
import { toArray, intercept, parseEmptyableJSON } from '@orpc/shared';
|
3
|
-
import { c as createProcedureClient, t as traverseContractProcedures,
|
3
|
+
import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.e3W6AG3-.mjs';
|
4
|
+
import { toHttpPath } from '@orpc/client/standard';
|
4
5
|
|
5
6
|
class StandardHandler {
|
6
7
|
constructor(router, matcher, codec, options) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ORPCError } from '@orpc/client';
|
2
2
|
import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
3
|
-
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.
|
3
|
+
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.Dfx1jV-K.mjs';
|
4
4
|
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
5
5
|
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
6
6
|
import { r as resolveFriendlyStandardHandleOptions } from './server.BVwwTHyO.mjs';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
2
2
|
import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
|
3
|
-
import { value, intercept
|
3
|
+
import { value, intercept } from '@orpc/shared';
|
4
4
|
|
5
5
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
6
6
|
function lazy(loader, meta = {}) {
|
@@ -127,7 +127,7 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
|
|
127
127
|
);
|
128
128
|
} catch (e) {
|
129
129
|
if (!(e instanceof ORPCError)) {
|
130
|
-
throw
|
130
|
+
throw e;
|
131
131
|
}
|
132
132
|
const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
|
133
133
|
throw validated;
|
@@ -367,8 +367,4 @@ function call(procedure, input, ...rest) {
|
|
367
367
|
return createProcedureClient(procedure, ...rest)(input);
|
368
368
|
}
|
369
369
|
|
370
|
-
|
371
|
-
return `/${path.map(encodeURIComponent).join("/")}`;
|
372
|
-
}
|
373
|
-
|
374
|
-
export { LAZY_SYMBOL as L, Procedure as P, toHttpPath as a, createContractedProcedure as b, createProcedureClient as c, addMiddleware as d, enhanceRouter as e, isLazy as f, getRouter as g, createAssertedLazyProcedure as h, isProcedure as i, createORPCErrorConstructorMap as j, getLazyMeta as k, lazy as l, mergeCurrentContext as m, middlewareOutputFn as n, isStartWithMiddlewares as o, mergeMiddlewares as p, call as q, getHiddenRouterContract as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, createAccessibleLazyRouter as w, resolveContractProcedures as x, unlazyRouter as y };
|
370
|
+
export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, resolveContractProcedures as w, unlazyRouter as x };
|