@orpc/server 0.0.0-next.4fc998d → 0.0.0-next.50b03b7
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 +40 -31
- package/dist/adapters/aws-lambda/index.d.mts +46 -0
- package/dist/adapters/aws-lambda/index.d.ts +46 -0
- package/dist/adapters/aws-lambda/index.mjs +42 -0
- package/dist/adapters/bun-ws/index.d.mts +36 -0
- package/dist/adapters/bun-ws/index.d.ts +36 -0
- package/dist/adapters/bun-ws/index.mjs +47 -0
- package/dist/adapters/crossws/index.d.mts +33 -0
- package/dist/adapters/crossws/index.d.ts +33 -0
- package/dist/adapters/crossws/index.mjs +45 -0
- package/dist/adapters/fastify/index.d.mts +53 -0
- package/dist/adapters/fastify/index.d.ts +53 -0
- package/dist/adapters/fastify/index.mjs +54 -0
- package/dist/adapters/fetch/index.d.mts +107 -11
- package/dist/adapters/fetch/index.d.ts +107 -11
- package/dist/adapters/fetch/index.mjs +179 -8
- package/dist/adapters/message-port/index.d.mts +57 -0
- package/dist/adapters/message-port/index.d.ts +57 -0
- package/dist/adapters/message-port/index.mjs +55 -0
- package/dist/adapters/node/index.d.mts +85 -22
- package/dist/adapters/node/index.d.ts +85 -22
- package/dist/adapters/node/index.mjs +144 -24
- package/dist/adapters/standard/index.d.mts +8 -13
- package/dist/adapters/standard/index.d.ts +8 -13
- package/dist/adapters/standard/index.mjs +5 -3
- package/dist/adapters/standard-peer/index.d.mts +18 -0
- package/dist/adapters/standard-peer/index.d.ts +18 -0
- package/dist/adapters/standard-peer/index.mjs +7 -0
- package/dist/adapters/websocket/index.d.mts +56 -0
- package/dist/adapters/websocket/index.d.ts +56 -0
- package/dist/adapters/websocket/index.mjs +67 -0
- package/dist/adapters/ws/index.d.mts +31 -0
- package/dist/adapters/ws/index.d.ts +31 -0
- package/dist/adapters/ws/index.mjs +37 -0
- package/dist/helpers/index.d.mts +149 -0
- package/dist/helpers/index.d.ts +149 -0
- package/dist/helpers/index.mjs +198 -0
- package/dist/hibernation/index.d.mts +44 -0
- package/dist/hibernation/index.d.ts +44 -0
- package/dist/hibernation/index.mjs +65 -0
- package/dist/index.d.mts +609 -84
- package/dist/index.d.ts +609 -84
- package/dist/index.mjs +167 -17
- package/dist/plugins/index.d.mts +190 -17
- package/dist/plugins/index.d.ts +190 -17
- package/dist/plugins/index.mjs +240 -15
- package/dist/shared/server.7cEtMB30.d.ts +74 -0
- package/dist/shared/server.B8gYOD5g.d.mts +12 -0
- package/dist/shared/server.BqadksTP.d.mts +74 -0
- package/dist/shared/server.Bxx6tqNe.mjs +219 -0
- package/dist/shared/server.C8_sRzQB.d.mts +42 -0
- package/dist/shared/server.ChUyt5-i.d.mts +32 -0
- package/dist/shared/server.ChyoA9XY.d.ts +42 -0
- package/dist/shared/server.DZ5BIITo.mjs +9 -0
- package/dist/shared/{server.BtxZnWJ9.mjs → server.Ds4HPpvH.mjs} +125 -90
- package/dist/shared/server.EfTOZ2Q7.d.ts +12 -0
- package/dist/shared/server.TEVCLCFC.mjs +39 -0
- package/dist/shared/server.UVMTOWrk.mjs +26 -0
- package/dist/shared/{server.BYTulgUc.d.mts → server.qKsRrdxW.d.mts} +66 -17
- package/dist/shared/{server.BYTulgUc.d.ts → server.qKsRrdxW.d.ts} +66 -17
- package/dist/shared/server.yoEB3Fx4.d.ts +32 -0
- package/package.json +82 -23
- package/dist/adapters/hono/index.d.mts +0 -21
- package/dist/adapters/hono/index.d.ts +0 -21
- package/dist/adapters/hono/index.mjs +0 -32
- package/dist/adapters/next/index.d.mts +0 -28
- package/dist/adapters/next/index.d.ts +0 -28
- package/dist/adapters/next/index.mjs +0 -29
- package/dist/shared/server.B3Tm0IXY.d.ts +0 -75
- package/dist/shared/server.BeJithK4.d.mts +0 -75
- package/dist/shared/server.Bz_xNBjz.d.mts +0 -8
- package/dist/shared/server.DoP20NVH.mjs +0 -29
- package/dist/shared/server.EhgR_5_I.d.ts +0 -8
- package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
- package/dist/shared/server.jG7ZuX3S.mjs +0 -158
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
|
|
2
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
|
3
|
+
import { MaybeOptionalOptions, Promisable, Interceptor, PromiseWithError, Value } from '@orpc/shared';
|
|
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>;
|
|
9
|
-
type ContextExtendsGuard<T extends Context, U extends Context> = T extends U ? unknown : never;
|
|
10
9
|
|
|
11
10
|
type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
|
12
11
|
type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
|
@@ -14,7 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
14
13
|
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
|
|
15
14
|
};
|
|
16
15
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
17
|
-
declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
|
|
18
16
|
|
|
19
17
|
declare const LAZY_SYMBOL: unique symbol;
|
|
20
18
|
interface LazyMeta {
|
|
@@ -29,6 +27,11 @@ interface Lazy<T> {
|
|
|
29
27
|
};
|
|
30
28
|
}
|
|
31
29
|
type Lazyable<T> = T | Lazy<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a lazy-loaded item.
|
|
32
|
+
*
|
|
33
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazy(...)` instead.
|
|
34
|
+
*/
|
|
32
35
|
declare function lazy<T>(loader: () => Promise<{
|
|
33
36
|
default: T;
|
|
34
37
|
}>, meta?: LazyMeta): Lazy<T>;
|
|
@@ -57,7 +60,15 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
|
|
|
57
60
|
outputValidationIndex: number;
|
|
58
61
|
handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
|
|
59
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* This class represents a procedure.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link https://orpc.dev/docs/procedure Procedure Docs}
|
|
67
|
+
*/
|
|
60
68
|
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
69
|
+
/**
|
|
70
|
+
* This property holds the defined options.
|
|
71
|
+
*/
|
|
61
72
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
62
73
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
63
74
|
}
|
|
@@ -88,6 +99,11 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
|
|
|
88
99
|
next: MiddlewareNextFn<TOutput>;
|
|
89
100
|
errors: TErrorConstructorMap;
|
|
90
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* A function that represents a middleware.
|
|
104
|
+
*
|
|
105
|
+
* @see {@link https://orpc.dev/docs/middleware Middleware Docs}
|
|
106
|
+
*/
|
|
91
107
|
interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
92
108
|
(options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
|
|
93
109
|
}
|
|
@@ -98,47 +114,80 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
98
114
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
99
115
|
|
|
100
116
|
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
101
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context,
|
|
117
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
102
118
|
context: TInitialContext;
|
|
103
|
-
input:
|
|
119
|
+
input: unknown;
|
|
104
120
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
105
121
|
path: readonly string[];
|
|
106
122
|
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
107
123
|
signal?: AbortSignal;
|
|
108
124
|
lastEventId: string | undefined;
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
* Options for creating a procedure caller with comprehensive type safety
|
|
112
|
-
*/
|
|
113
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
126
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
114
127
|
/**
|
|
115
128
|
* This is helpful for logging and analytics.
|
|
116
129
|
*/
|
|
117
130
|
path?: readonly string[];
|
|
118
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext,
|
|
131
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
119
132
|
} & (Record<never, never> extends TInitialContext ? {
|
|
120
|
-
context?: Value<TInitialContext
|
|
133
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
121
134
|
} : {
|
|
122
|
-
context: Value<TInitialContext
|
|
135
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
123
136
|
});
|
|
124
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Create Server-side client from a procedure.
|
|
139
|
+
*
|
|
140
|
+
* @see {@link https://orpc.dev/docs/client/server-side Server-side Client Docs}
|
|
141
|
+
*/
|
|
142
|
+
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>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
125
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Represents a router, which defines a hierarchical structure of procedures.
|
|
146
|
+
*
|
|
147
|
+
* @info A procedure is a router too.
|
|
148
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
149
|
+
*/
|
|
126
150
|
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> : {
|
|
127
151
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
128
152
|
};
|
|
129
153
|
type AnyRouter = Router<any, any>;
|
|
130
154
|
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
|
155
|
+
/**
|
|
156
|
+
* Infer all initial context of the router.
|
|
157
|
+
*
|
|
158
|
+
* @info A procedure is a router too.
|
|
159
|
+
* @see {@link https://orpc.dev/docs/router#utilities Router Utilities Docs}
|
|
160
|
+
*/
|
|
131
161
|
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
|
132
162
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
133
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* Infer all current context of the router.
|
|
166
|
+
*
|
|
167
|
+
* @info A procedure is a router too.
|
|
168
|
+
* @see {@link https://orpc.dev/docs/router#utilities Router Utilities Docs}
|
|
169
|
+
*/
|
|
134
170
|
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
|
135
171
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
136
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Infer all router inputs
|
|
175
|
+
*
|
|
176
|
+
* @info A procedure is a router too.
|
|
177
|
+
* @see {@link https://orpc.dev/docs/router#utilities Router Utilities Docs}
|
|
178
|
+
*/
|
|
137
179
|
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
138
180
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
139
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* Infer all router outputs
|
|
184
|
+
*
|
|
185
|
+
* @info A procedure is a router too.
|
|
186
|
+
* @see {@link https://orpc.dev/docs/router#utilities Router Utilities Docs}
|
|
187
|
+
*/
|
|
140
188
|
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
141
189
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
142
190
|
};
|
|
143
191
|
|
|
144
|
-
export {
|
|
192
|
+
export { isProcedure as E, createProcedureClient as F, Procedure as P, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as z };
|
|
193
|
+
export type { AnyProcedure as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, AnyMiddleware as a, AnyRouter as b, Lazy as c, ProcedureClientInterceptorOptions as d, Middleware as e, MergedCurrentContext as f, MapInputMiddleware as g, CreateProcedureClientOptions as h, ProcedureClient as i, ProcedureHandler as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as t, MiddlewareNextFnOptions as v, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
|
2
|
+
import { b as AnyRouter, C as Context, R as Router } from './server.qKsRrdxW.js';
|
|
3
|
+
import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.7cEtMB30.js';
|
|
4
|
+
import { HTTPPath } from '@orpc/client';
|
|
5
|
+
import { Value } from '@orpc/shared';
|
|
6
|
+
import { T as TraverseContractProcedureCallbackOptions } from './server.ChyoA9XY.js';
|
|
7
|
+
|
|
8
|
+
interface StandardRPCMatcherOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
|
11
|
+
*
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
15
|
+
}
|
|
16
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
|
17
|
+
private readonly filter;
|
|
18
|
+
private readonly tree;
|
|
19
|
+
private pendingRouters;
|
|
20
|
+
constructor(options?: StandardRPCMatcherOptions);
|
|
21
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
22
|
+
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions, StandardRPCMatcherOptions {
|
|
26
|
+
}
|
|
27
|
+
declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
|
|
28
|
+
constructor(router: Router<any, T>, options?: StandardRPCHandlerOptions<T>);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { StandardRPCHandler as a, StandardRPCMatcher as c };
|
|
32
|
+
export type { StandardRPCHandlerOptions as S, StandardRPCMatcherOptions as b };
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.50b03b7",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/middleapi/orpc.git",
|
|
10
10
|
"directory": "packages/server"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
|
-
"unnoq",
|
|
14
13
|
"orpc"
|
|
15
14
|
],
|
|
16
15
|
"exports": {
|
|
@@ -19,54 +18,114 @@
|
|
|
19
18
|
"import": "./dist/index.mjs",
|
|
20
19
|
"default": "./dist/index.mjs"
|
|
21
20
|
},
|
|
21
|
+
"./helpers": {
|
|
22
|
+
"types": "./dist/helpers/index.d.mts",
|
|
23
|
+
"import": "./dist/helpers/index.mjs",
|
|
24
|
+
"default": "./dist/helpers/index.mjs"
|
|
25
|
+
},
|
|
22
26
|
"./plugins": {
|
|
23
27
|
"types": "./dist/plugins/index.d.mts",
|
|
24
28
|
"import": "./dist/plugins/index.mjs",
|
|
25
29
|
"default": "./dist/plugins/index.mjs"
|
|
26
30
|
},
|
|
31
|
+
"./hibernation": {
|
|
32
|
+
"types": "./dist/hibernation/index.d.mts",
|
|
33
|
+
"import": "./dist/hibernation/index.mjs",
|
|
34
|
+
"default": "./dist/hibernation/index.mjs"
|
|
35
|
+
},
|
|
27
36
|
"./standard": {
|
|
28
37
|
"types": "./dist/adapters/standard/index.d.mts",
|
|
29
38
|
"import": "./dist/adapters/standard/index.mjs",
|
|
30
39
|
"default": "./dist/adapters/standard/index.mjs"
|
|
31
40
|
},
|
|
41
|
+
"./standard-peer": {
|
|
42
|
+
"types": "./dist/adapters/standard-peer/index.d.mts",
|
|
43
|
+
"import": "./dist/adapters/standard-peer/index.mjs",
|
|
44
|
+
"default": "./dist/adapters/standard-peer/index.mjs"
|
|
45
|
+
},
|
|
32
46
|
"./fetch": {
|
|
33
47
|
"types": "./dist/adapters/fetch/index.d.mts",
|
|
34
48
|
"import": "./dist/adapters/fetch/index.mjs",
|
|
35
49
|
"default": "./dist/adapters/fetch/index.mjs"
|
|
36
50
|
},
|
|
37
|
-
"./hono": {
|
|
38
|
-
"types": "./dist/adapters/hono/index.d.mts",
|
|
39
|
-
"import": "./dist/adapters/hono/index.mjs",
|
|
40
|
-
"default": "./dist/adapters/hono/index.mjs"
|
|
41
|
-
},
|
|
42
|
-
"./next": {
|
|
43
|
-
"types": "./dist/adapters/next/index.d.mts",
|
|
44
|
-
"import": "./dist/adapters/next/index.mjs",
|
|
45
|
-
"default": "./dist/adapters/next/index.mjs"
|
|
46
|
-
},
|
|
47
51
|
"./node": {
|
|
48
52
|
"types": "./dist/adapters/node/index.d.mts",
|
|
49
53
|
"import": "./dist/adapters/node/index.mjs",
|
|
50
54
|
"default": "./dist/adapters/node/index.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./fastify": {
|
|
57
|
+
"types": "./dist/adapters/fastify/index.d.mts",
|
|
58
|
+
"import": "./dist/adapters/fastify/index.mjs",
|
|
59
|
+
"default": "./dist/adapters/fastify/index.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./aws-lambda": {
|
|
62
|
+
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
|
63
|
+
"import": "./dist/adapters/aws-lambda/index.mjs",
|
|
64
|
+
"default": "./dist/adapters/aws-lambda/index.mjs"
|
|
65
|
+
},
|
|
66
|
+
"./websocket": {
|
|
67
|
+
"types": "./dist/adapters/websocket/index.d.mts",
|
|
68
|
+
"import": "./dist/adapters/websocket/index.mjs",
|
|
69
|
+
"default": "./dist/adapters/websocket/index.mjs"
|
|
70
|
+
},
|
|
71
|
+
"./crossws": {
|
|
72
|
+
"types": "./dist/adapters/crossws/index.d.mts",
|
|
73
|
+
"import": "./dist/adapters/crossws/index.mjs",
|
|
74
|
+
"default": "./dist/adapters/crossws/index.mjs"
|
|
75
|
+
},
|
|
76
|
+
"./ws": {
|
|
77
|
+
"types": "./dist/adapters/ws/index.d.mts",
|
|
78
|
+
"import": "./dist/adapters/ws/index.mjs",
|
|
79
|
+
"default": "./dist/adapters/ws/index.mjs"
|
|
80
|
+
},
|
|
81
|
+
"./bun-ws": {
|
|
82
|
+
"types": "./dist/adapters/bun-ws/index.d.mts",
|
|
83
|
+
"import": "./dist/adapters/bun-ws/index.mjs",
|
|
84
|
+
"default": "./dist/adapters/bun-ws/index.mjs"
|
|
85
|
+
},
|
|
86
|
+
"./message-port": {
|
|
87
|
+
"types": "./dist/adapters/message-port/index.d.mts",
|
|
88
|
+
"import": "./dist/adapters/message-port/index.mjs",
|
|
89
|
+
"default": "./dist/adapters/message-port/index.mjs"
|
|
51
90
|
}
|
|
52
91
|
},
|
|
53
92
|
"files": [
|
|
54
93
|
"dist"
|
|
55
94
|
],
|
|
56
95
|
"peerDependencies": {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
96
|
+
"crossws": ">=0.3.4",
|
|
97
|
+
"ws": ">=8.18.1"
|
|
98
|
+
},
|
|
99
|
+
"peerDependenciesMeta": {
|
|
100
|
+
"crossws": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"ws": {
|
|
104
|
+
"optional": true
|
|
105
|
+
}
|
|
59
106
|
},
|
|
60
107
|
"dependencies": {
|
|
61
|
-
"
|
|
62
|
-
"@orpc/
|
|
63
|
-
"@orpc/
|
|
64
|
-
"@orpc/
|
|
65
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
66
|
-
"@orpc/standard-server-
|
|
108
|
+
"cookie": "^1.1.1",
|
|
109
|
+
"@orpc/client": "0.0.0-next.50b03b7",
|
|
110
|
+
"@orpc/contract": "0.0.0-next.50b03b7",
|
|
111
|
+
"@orpc/interop": "0.0.0-next.50b03b7",
|
|
112
|
+
"@orpc/standard-server": "0.0.0-next.50b03b7",
|
|
113
|
+
"@orpc/standard-server-aws-lambda": "0.0.0-next.50b03b7",
|
|
114
|
+
"@orpc/shared": "0.0.0-next.50b03b7",
|
|
115
|
+
"@orpc/standard-server-fetch": "0.0.0-next.50b03b7",
|
|
116
|
+
"@orpc/standard-server-fastify": "0.0.0-next.50b03b7",
|
|
117
|
+
"@orpc/standard-server-node": "0.0.0-next.50b03b7",
|
|
118
|
+
"@orpc/standard-server-peer": "0.0.0-next.50b03b7"
|
|
67
119
|
},
|
|
68
120
|
"devDependencies": {
|
|
69
|
-
"
|
|
121
|
+
"@tanstack/router-core": "^1.151.6",
|
|
122
|
+
"@types/ws": "^8.18.1",
|
|
123
|
+
"crossws": "^0.4.1",
|
|
124
|
+
"fastify": "^5.7.1",
|
|
125
|
+
"next": "^16.1.3",
|
|
126
|
+
"supertest": "^7.1.4",
|
|
127
|
+
"ws": "^8.18.3",
|
|
128
|
+
"zod": "^4.3.2"
|
|
70
129
|
},
|
|
71
130
|
"scripts": {
|
|
72
131
|
"build": "unbuild",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FetchHandler } from '../fetch/index.mjs';
|
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
-
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
|
5
|
-
import { C as Context } from '../../shared/server.BYTulgUc.mjs';
|
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.BeJithK4.mjs';
|
|
7
|
-
import '@orpc/standard-server-fetch';
|
|
8
|
-
import '../../shared/server.Bz_xNBjz.mjs';
|
|
9
|
-
import '@orpc/client/standard';
|
|
10
|
-
import '@orpc/client';
|
|
11
|
-
import '@orpc/contract';
|
|
12
|
-
import '@orpc/standard-server';
|
|
13
|
-
|
|
14
|
-
type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
15
|
-
context?: Value<T, [Context$1]>;
|
|
16
|
-
} : {
|
|
17
|
-
context: Value<T, [Context$1]>;
|
|
18
|
-
});
|
|
19
|
-
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
|
20
|
-
|
|
21
|
-
export { type CreateMiddlewareOptions, FetchHandler, createMiddleware };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FetchHandler } from '../fetch/index.js';
|
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
-
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
|
5
|
-
import { C as Context } from '../../shared/server.BYTulgUc.js';
|
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.B3Tm0IXY.js';
|
|
7
|
-
import '@orpc/standard-server-fetch';
|
|
8
|
-
import '../../shared/server.EhgR_5_I.js';
|
|
9
|
-
import '@orpc/client/standard';
|
|
10
|
-
import '@orpc/client';
|
|
11
|
-
import '@orpc/contract';
|
|
12
|
-
import '@orpc/standard-server';
|
|
13
|
-
|
|
14
|
-
type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
15
|
-
context?: Value<T, [Context$1]>;
|
|
16
|
-
} : {
|
|
17
|
-
context: Value<T, [Context$1]>;
|
|
18
|
-
});
|
|
19
|
-
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
|
20
|
-
|
|
21
|
-
export { type CreateMiddlewareOptions, FetchHandler, createMiddleware };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.DoP20NVH.mjs';
|
|
2
|
-
import { value } from '@orpc/shared';
|
|
3
|
-
import '@orpc/client/standard';
|
|
4
|
-
import '@orpc/standard-server-fetch';
|
|
5
|
-
import '../../shared/server.jG7ZuX3S.mjs';
|
|
6
|
-
import '@orpc/client';
|
|
7
|
-
import '../../shared/server.Q6ZmnTgO.mjs';
|
|
8
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
|
9
|
-
import '@orpc/contract';
|
|
10
|
-
|
|
11
|
-
function createMiddleware(handler, ...[options]) {
|
|
12
|
-
return async (c, next) => {
|
|
13
|
-
const bodyProps = /* @__PURE__ */ new Set(["arrayBuffer", "blob", "formData", "json", "text"]);
|
|
14
|
-
const request = c.req.method === "GET" || c.req.method === "HEAD" ? c.req.raw : new Proxy(c.req.raw, {
|
|
15
|
-
// https://github.com/honojs/middleware/blob/main/packages/trpc-server/src/index.ts#L39
|
|
16
|
-
get(target, prop) {
|
|
17
|
-
if (bodyProps.has(prop)) {
|
|
18
|
-
return () => c.req[prop]();
|
|
19
|
-
}
|
|
20
|
-
return Reflect.get(target, prop, target);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const context = await value(options?.context ?? {}, c);
|
|
24
|
-
const { matched, response } = await handler.handle(request, { ...options, context });
|
|
25
|
-
if (matched) {
|
|
26
|
-
return c.newResponse(response.body, response);
|
|
27
|
-
}
|
|
28
|
-
await next();
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { createMiddleware };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FetchHandler } from '../fetch/index.mjs';
|
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
-
import { NextRequest } from 'next/server';
|
|
5
|
-
import { C as Context } from '../../shared/server.BYTulgUc.mjs';
|
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.BeJithK4.mjs';
|
|
7
|
-
import '@orpc/standard-server-fetch';
|
|
8
|
-
import '../../shared/server.Bz_xNBjz.mjs';
|
|
9
|
-
import '@orpc/client/standard';
|
|
10
|
-
import '@orpc/client';
|
|
11
|
-
import '@orpc/contract';
|
|
12
|
-
import '@orpc/standard-server';
|
|
13
|
-
|
|
14
|
-
type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
15
|
-
context?: Value<T, [NextRequest]>;
|
|
16
|
-
} : {
|
|
17
|
-
context: Value<T, [NextRequest]>;
|
|
18
|
-
});
|
|
19
|
-
interface ServeResult {
|
|
20
|
-
GET(req: NextRequest): Promise<Response>;
|
|
21
|
-
POST(req: NextRequest): Promise<Response>;
|
|
22
|
-
PUT(req: NextRequest): Promise<Response>;
|
|
23
|
-
PATCH(req: NextRequest): Promise<Response>;
|
|
24
|
-
DELETE(req: NextRequest): Promise<Response>;
|
|
25
|
-
}
|
|
26
|
-
declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
|
27
|
-
|
|
28
|
-
export { FetchHandler, type ServeOptions, type ServeResult, serve };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FetchHandler } from '../fetch/index.js';
|
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
-
import { NextRequest } from 'next/server';
|
|
5
|
-
import { C as Context } from '../../shared/server.BYTulgUc.js';
|
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.B3Tm0IXY.js';
|
|
7
|
-
import '@orpc/standard-server-fetch';
|
|
8
|
-
import '../../shared/server.EhgR_5_I.js';
|
|
9
|
-
import '@orpc/client/standard';
|
|
10
|
-
import '@orpc/client';
|
|
11
|
-
import '@orpc/contract';
|
|
12
|
-
import '@orpc/standard-server';
|
|
13
|
-
|
|
14
|
-
type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
15
|
-
context?: Value<T, [NextRequest]>;
|
|
16
|
-
} : {
|
|
17
|
-
context: Value<T, [NextRequest]>;
|
|
18
|
-
});
|
|
19
|
-
interface ServeResult {
|
|
20
|
-
GET(req: NextRequest): Promise<Response>;
|
|
21
|
-
POST(req: NextRequest): Promise<Response>;
|
|
22
|
-
PUT(req: NextRequest): Promise<Response>;
|
|
23
|
-
PATCH(req: NextRequest): Promise<Response>;
|
|
24
|
-
DELETE(req: NextRequest): Promise<Response>;
|
|
25
|
-
}
|
|
26
|
-
declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
|
27
|
-
|
|
28
|
-
export { FetchHandler, type ServeOptions, type ServeResult, serve };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.DoP20NVH.mjs';
|
|
2
|
-
import { value } from '@orpc/shared';
|
|
3
|
-
import '@orpc/client/standard';
|
|
4
|
-
import '@orpc/standard-server-fetch';
|
|
5
|
-
import '../../shared/server.jG7ZuX3S.mjs';
|
|
6
|
-
import '@orpc/client';
|
|
7
|
-
import '../../shared/server.Q6ZmnTgO.mjs';
|
|
8
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
|
9
|
-
import '@orpc/contract';
|
|
10
|
-
|
|
11
|
-
function serve(handler, ...[options]) {
|
|
12
|
-
const main = async (req) => {
|
|
13
|
-
const context = await value(options?.context ?? {}, req);
|
|
14
|
-
const { matched, response } = await handler.handle(req, { ...options, context });
|
|
15
|
-
if (matched) {
|
|
16
|
-
return response;
|
|
17
|
-
}
|
|
18
|
-
return new Response(`Cannot find a matching procedure for ${req.url}`, { status: 404 });
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
GET: main,
|
|
22
|
-
POST: main,
|
|
23
|
-
PUT: main,
|
|
24
|
-
PATCH: main,
|
|
25
|
-
DELETE: main
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { serve };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
|
2
|
-
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
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.BYTulgUc.js';
|
|
5
|
-
import { ORPCError } from '@orpc/client';
|
|
6
|
-
|
|
7
|
-
type StandardParams = Record<string, string>;
|
|
8
|
-
type StandardMatchResult = {
|
|
9
|
-
path: readonly string[];
|
|
10
|
-
procedure: AnyProcedure;
|
|
11
|
-
params?: StandardParams;
|
|
12
|
-
} | undefined;
|
|
13
|
-
interface StandardMatcher {
|
|
14
|
-
init(router: AnyRouter): void;
|
|
15
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
16
|
-
}
|
|
17
|
-
interface StandardCodec {
|
|
18
|
-
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
19
|
-
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
20
|
-
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
type StandardHandleOptions<T extends Context> = {
|
|
24
|
-
prefix?: HTTPPath;
|
|
25
|
-
} & (Record<never, never> extends T ? {
|
|
26
|
-
context?: T;
|
|
27
|
-
} : {
|
|
28
|
-
context: T;
|
|
29
|
-
});
|
|
30
|
-
type StandardHandleResult = {
|
|
31
|
-
matched: true;
|
|
32
|
-
response: StandardResponse;
|
|
33
|
-
} | {
|
|
34
|
-
matched: false;
|
|
35
|
-
response: undefined;
|
|
36
|
-
};
|
|
37
|
-
type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
|
|
38
|
-
context: T;
|
|
39
|
-
request: StandardLazyRequest;
|
|
40
|
-
};
|
|
41
|
-
interface StandardHandlerOptions<TContext extends Context> {
|
|
42
|
-
plugins?: HandlerPlugin<TContext>[];
|
|
43
|
-
/**
|
|
44
|
-
* Interceptors at the request level, helpful when you want catch errors
|
|
45
|
-
*/
|
|
46
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
|
47
|
-
/**
|
|
48
|
-
* Interceptors at the root level, helpful when you want override the request/response
|
|
49
|
-
*/
|
|
50
|
-
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* Interceptors for procedure client.
|
|
54
|
-
*/
|
|
55
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
|
56
|
-
}
|
|
57
|
-
declare class StandardHandler<T extends Context> {
|
|
58
|
-
private readonly matcher;
|
|
59
|
-
private readonly codec;
|
|
60
|
-
private readonly options;
|
|
61
|
-
private readonly plugin;
|
|
62
|
-
constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
|
|
63
|
-
handle(request: StandardLazyRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface HandlerPlugin<TContext extends Context> {
|
|
67
|
-
init?(options: StandardHandlerOptions<TContext>): void;
|
|
68
|
-
}
|
|
69
|
-
declare class CompositePlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
|
70
|
-
private readonly plugins;
|
|
71
|
-
constructor(plugins?: HandlerPlugin<TContext>[]);
|
|
72
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions as b, type StandardCodec as c, type StandardParams as d, type StandardMatcher as e, type StandardMatchResult as f, type StandardHandleResult as g, StandardHandler as h };
|