@orpc/server 0.0.0-next.9dfcee8 → 0.0.0-next.9f70405
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 +24 -17
- package/dist/adapters/bun-ws/index.d.mts +35 -0
- package/dist/adapters/bun-ws/index.d.ts +35 -0
- package/dist/adapters/bun-ws/index.mjs +50 -0
- package/dist/adapters/crossws/index.d.mts +30 -0
- package/dist/adapters/crossws/index.d.ts +30 -0
- package/dist/adapters/crossws/index.mjs +50 -0
- package/dist/adapters/fetch/index.d.mts +61 -11
- package/dist/adapters/fetch/index.d.ts +61 -11
- package/dist/adapters/fetch/index.mjs +109 -8
- package/dist/adapters/node/index.d.mts +63 -22
- package/dist/adapters/node/index.d.ts +63 -22
- package/dist/adapters/node/index.mjs +87 -24
- 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 -3
- package/dist/adapters/websocket/index.d.mts +27 -0
- package/dist/adapters/websocket/index.d.ts +27 -0
- package/dist/adapters/websocket/index.mjs +37 -0
- package/dist/adapters/ws/index.d.mts +28 -0
- package/dist/adapters/ws/index.d.ts +28 -0
- package/dist/adapters/ws/index.mjs +37 -0
- package/dist/index.d.mts +598 -47
- package/dist/index.d.ts +598 -47
- package/dist/index.mjs +147 -15
- package/dist/plugins/index.d.mts +140 -15
- package/dist/plugins/index.d.ts +140 -15
- package/dist/plugins/index.mjs +162 -14
- package/dist/shared/server.BRoxSiSC.d.mts +12 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/server.BW-nUGgA.mjs +36 -0
- package/dist/shared/server.BjiJH9Vo.d.ts +10 -0
- package/dist/shared/server.Cy1vfSiG.d.ts +12 -0
- package/dist/shared/{server.BtxZnWJ9.mjs → server.DG7Tamti.mjs} +22 -29
- package/dist/shared/{server.BYTulgUc.d.mts → server.DPWk5pjW.d.mts} +61 -13
- package/dist/shared/{server.BYTulgUc.d.ts → server.DPWk5pjW.d.ts} +61 -13
- package/dist/shared/server.QUe9N8P4.d.mts +10 -0
- package/dist/shared/{server.jG7ZuX3S.mjs → server.SxlTJfG2.mjs} +53 -28
- package/dist/shared/server.YZzrREz9.d.ts +74 -0
- package/dist/shared/server.eWLxY3lq.d.mts +74 -0
- package/package.json +43 -20
- 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
@@ -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 };
|
@@ -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.mjs';
|
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 };
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { C as Context } from './server.BYTulgUc.mjs';
|
3
|
-
import { a as StandardHandlerOptions } from './server.BeJithK4.mjs';
|
4
|
-
|
5
|
-
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
-
}
|
7
|
-
|
8
|
-
export type { StandardRPCHandlerOptions as S };
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
2
|
-
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
3
|
-
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.jG7ZuX3S.mjs';
|
4
|
-
|
5
|
-
class RPCHandler {
|
6
|
-
standardHandler;
|
7
|
-
constructor(router, options = {}) {
|
8
|
-
const jsonSerializer = new StandardRPCJsonSerializer(options);
|
9
|
-
const serializer = new StandardRPCSerializer(jsonSerializer);
|
10
|
-
const matcher = new StandardRPCMatcher();
|
11
|
-
const codec = new StandardRPCCodec(serializer);
|
12
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
13
|
-
}
|
14
|
-
async handle(request, ...[
|
15
|
-
options = {}
|
16
|
-
]) {
|
17
|
-
const standardRequest = toStandardLazyRequest(request);
|
18
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
19
|
-
if (!result.matched) {
|
20
|
-
return result;
|
21
|
-
}
|
22
|
-
return {
|
23
|
-
matched: true,
|
24
|
-
response: toFetchResponse(result.response, options)
|
25
|
-
};
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
export { RPCHandler as R };
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { C as Context } from './server.BYTulgUc.js';
|
3
|
-
import { a as StandardHandlerOptions } from './server.B3Tm0IXY.js';
|
4
|
-
|
5
|
-
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
-
}
|
7
|
-
|
8
|
-
export type { StandardRPCHandlerOptions as S };
|