@orpc/server 0.0.0-next.2281fcb → 0.0.0-next.23aa4be
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-5IM453DN.js +301 -0
- package/dist/chunk-WUOGVGWG.js +1 -0
- package/dist/{chunk-FN62GL22.js → chunk-ZBJYYEII.js} +78 -33
- package/dist/fetch.js +11 -108
- package/dist/hono.js +30 -0
- package/dist/index.js +143 -111
- package/dist/next.js +36 -0
- package/dist/node.js +87 -0
- package/dist/src/adapters/fetch/index.d.ts +6 -0
- package/dist/src/adapters/fetch/orpc-handler.d.ts +20 -0
- package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +16 -0
- package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +12 -0
- package/dist/src/adapters/fetch/super-json.d.ts +12 -0
- package/dist/src/adapters/fetch/types.d.ts +21 -0
- package/dist/src/adapters/hono/index.d.ts +3 -0
- package/dist/src/adapters/hono/middleware.d.ts +12 -0
- package/dist/src/adapters/next/index.d.ts +3 -0
- package/dist/src/adapters/next/serve.d.ts +19 -0
- package/dist/src/adapters/node/index.d.ts +5 -0
- package/dist/src/adapters/node/orpc-handler.d.ts +12 -0
- package/dist/src/adapters/node/request-listener.d.ts +28 -0
- package/dist/src/adapters/node/types.d.ts +22 -0
- package/dist/src/builder.d.ts +11 -10
- package/dist/src/error.d.ts +10 -0
- package/dist/src/implementer-chainable.d.ts +2 -2
- package/dist/src/index.d.ts +3 -1
- package/dist/src/lazy-decorated.d.ts +3 -6
- package/dist/src/middleware-decorated.d.ts +6 -5
- package/dist/src/middleware.d.ts +20 -8
- package/dist/src/procedure-builder.d.ts +17 -15
- package/dist/src/procedure-client.d.ts +9 -16
- package/dist/src/procedure-decorated.d.ts +22 -10
- package/dist/src/procedure-implementer.d.ts +13 -12
- package/dist/src/procedure-utils.d.ts +17 -0
- package/dist/src/procedure.d.ts +33 -13
- package/dist/src/router-builder.d.ts +4 -4
- package/dist/src/router-client.d.ts +8 -6
- package/dist/src/router-implementer.d.ts +2 -2
- package/dist/src/router.d.ts +4 -4
- package/dist/src/types.d.ts +2 -0
- package/package.json +22 -10
- package/dist/src/fetch/handle-request.d.ts +0 -7
- package/dist/src/fetch/index.d.ts +0 -4
- package/dist/src/fetch/orpc-handler.d.ts +0 -3
- package/dist/src/fetch/types.d.ts +0 -28
@@ -5,14 +5,14 @@ import type { Router } from './router';
|
|
5
5
|
import type { AdaptedRouter } from './router-builder';
|
6
6
|
import type { Context, MergeContext } from './types';
|
7
7
|
export interface RouterImplementerDef<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> {
|
8
|
-
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any
|
8
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<string, unknown>>[];
|
9
9
|
contract: TContract;
|
10
10
|
}
|
11
11
|
export declare class RouterImplementer<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> {
|
12
12
|
'~type': "RouterImplementer";
|
13
13
|
'~orpc': RouterImplementerDef<TContext, TExtraContext, TContract>;
|
14
14
|
constructor(def: RouterImplementerDef<TContext, TExtraContext, TContract>);
|
15
|
-
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown
|
15
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<string, unknown>>): RouterImplementer<TContext, MergeContext<TExtraContext, U>, TContract>;
|
16
16
|
router<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(router: U): AdaptedRouter<TContext, U>;
|
17
17
|
lazy<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(loader: () => Promise<{
|
18
18
|
default: U;
|
package/dist/src/router.d.ts
CHANGED
@@ -2,15 +2,15 @@ import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } fro
|
|
2
2
|
import type { ANY_LAZY, Lazy, Lazyable } from './lazy';
|
3
3
|
import type { ANY_PROCEDURE, Procedure } from './procedure';
|
4
4
|
import type { Context } from './types';
|
5
|
-
export type Router<TContext extends Context, TContract extends ContractRouter> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? Procedure<TContext, any, UInputSchema, UOutputSchema, any> : {
|
5
|
+
export type Router<TContext extends Context, TContract extends ContractRouter> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap> ? Procedure<TContext, any, UInputSchema, UOutputSchema, any, UErrorMap> : {
|
6
6
|
[K in keyof TContract]: TContract[K] extends ContractRouter ? Router<TContext, TContract[K]> : never;
|
7
7
|
}>;
|
8
8
|
export type ANY_ROUTER = Router<any, any>;
|
9
|
-
export type InferRouterInputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any> ? SchemaInput<UInputSchema> : {
|
9
|
+
export type InferRouterInputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any, any> ? SchemaInput<UInputSchema> : {
|
10
10
|
[K in keyof T]: T[K] extends ANY_ROUTER ? InferRouterInputs<T[K]> : never;
|
11
11
|
};
|
12
|
-
export type InferRouterOutputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
|
12
|
+
export type InferRouterOutputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput, any> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
|
13
13
|
[K in keyof T]: T[K] extends ANY_ROUTER ? InferRouterOutputs<T[K]> : never;
|
14
14
|
};
|
15
|
-
export declare function getRouterChild<T extends ANY_ROUTER | Lazy<undefined>>(router: T, ...path: string[]): T extends ANY_LAZY ? Lazy<ANY_PROCEDURE | Record<string, ANY_ROUTER
|
15
|
+
export declare function getRouterChild<T extends ANY_ROUTER | Lazy<undefined>>(router: T, ...path: string[]): T extends ANY_LAZY ? Lazy<ANY_PROCEDURE> | Lazy<Record<string, ANY_ROUTER>> | Lazy<undefined> : ANY_ROUTER | Lazy<undefined> | undefined;
|
16
16
|
//# sourceMappingURL=router.d.ts.map
|
package/dist/src/types.d.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
import type { FindGlobalInstanceType } from '@orpc/shared';
|
1
2
|
import type { ANY_PROCEDURE } from './procedure';
|
2
3
|
export type Context = Record<string, any> | undefined;
|
3
4
|
export type WELL_CONTEXT = Record<string, unknown> | undefined;
|
4
5
|
export type MergeContext<TA extends Context, TB extends Context> = TA extends undefined ? TB : TB extends undefined ? TA : TA & TB;
|
6
|
+
export type AbortSignal = FindGlobalInstanceType<'AbortSignal'>;
|
5
7
|
export interface WithSignal {
|
6
8
|
signal?: AbortSignal;
|
7
9
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.23aa4be",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -20,10 +20,25 @@
|
|
20
20
|
"default": "./dist/index.js"
|
21
21
|
},
|
22
22
|
"./fetch": {
|
23
|
-
"types": "./dist/src/fetch/index.d.ts",
|
23
|
+
"types": "./dist/src/adapters/fetch/index.d.ts",
|
24
24
|
"import": "./dist/fetch.js",
|
25
25
|
"default": "./dist/fetch.js"
|
26
26
|
},
|
27
|
+
"./hono": {
|
28
|
+
"types": "./dist/src/adapters/hono/index.d.ts",
|
29
|
+
"import": "./dist/hono.js",
|
30
|
+
"default": "./dist/hono.js"
|
31
|
+
},
|
32
|
+
"./next": {
|
33
|
+
"types": "./dist/src/adapters/next/index.d.ts",
|
34
|
+
"import": "./dist/next.js",
|
35
|
+
"default": "./dist/next.js"
|
36
|
+
},
|
37
|
+
"./node": {
|
38
|
+
"types": "./dist/src/adapters/node/index.d.ts",
|
39
|
+
"import": "./dist/node.js",
|
40
|
+
"default": "./dist/node.js"
|
41
|
+
},
|
27
42
|
"./🔒/*": {
|
28
43
|
"types": "./dist/src/*.d.ts"
|
29
44
|
}
|
@@ -34,18 +49,15 @@
|
|
34
49
|
"dist"
|
35
50
|
],
|
36
51
|
"peerDependencies": {
|
37
|
-
"
|
52
|
+
"hono": ">=4.6.0",
|
53
|
+
"next": ">=14.0.0"
|
38
54
|
},
|
39
55
|
"dependencies": {
|
40
|
-
"@orpc/
|
41
|
-
"@orpc/
|
42
|
-
"@orpc/transformer": "0.0.0-next.2281fcb"
|
43
|
-
},
|
44
|
-
"devDependencies": {
|
45
|
-
"zod": "^3.24.1"
|
56
|
+
"@orpc/contract": "0.0.0-next.23aa4be",
|
57
|
+
"@orpc/shared": "0.0.0-next.23aa4be"
|
46
58
|
},
|
47
59
|
"scripts": {
|
48
|
-
"build": "tsup --
|
60
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
49
61
|
"build:watch": "pnpm run build --watch",
|
50
62
|
"type:check": "tsc -b"
|
51
63
|
}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { Context } from '../types';
|
2
|
-
import type { FetchHandler, FetchHandlerOptions } from './types';
|
3
|
-
export type HandleFetchRequestOptions<T extends Context> = FetchHandlerOptions<T> & {
|
4
|
-
handlers: readonly [FetchHandler, ...FetchHandler[]];
|
5
|
-
};
|
6
|
-
export declare function handleFetchRequest<T extends Context>(options: HandleFetchRequestOptions<T>): Promise<Response>;
|
7
|
-
//# sourceMappingURL=handle-request.d.ts.map
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import type { HTTPPath } from '@orpc/contract';
|
2
|
-
import type { Hooks, Value } from '@orpc/shared';
|
3
|
-
import type { Router } from '../router';
|
4
|
-
import type { Context, WithSignal } from '../types';
|
5
|
-
export type FetchHandlerOptions<T extends Context> = {
|
6
|
-
/**
|
7
|
-
* The `router` used for handling the request and routing,
|
8
|
-
*
|
9
|
-
*/
|
10
|
-
router: Router<T, any>;
|
11
|
-
/**
|
12
|
-
* The request need to be handled.
|
13
|
-
*/
|
14
|
-
request: Request;
|
15
|
-
/**
|
16
|
-
* Remove the prefix from the request path.
|
17
|
-
*
|
18
|
-
* @example /orpc
|
19
|
-
* @example /api
|
20
|
-
*/
|
21
|
-
prefix?: HTTPPath;
|
22
|
-
} & NoInfer<(undefined extends T ? {
|
23
|
-
context?: Value<T>;
|
24
|
-
} : {
|
25
|
-
context: Value<T>;
|
26
|
-
})> & WithSignal & Hooks<Request, Response, T, WithSignal>;
|
27
|
-
export type FetchHandler = <T extends Context>(options: FetchHandlerOptions<T>) => Promise<Response | undefined>;
|
28
|
-
//# sourceMappingURL=types.d.ts.map
|