@orpc/server 0.0.0-next.9adcd05 → 0.0.0-next.9b9ade5
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 +2 -1
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/hono/index.d.mts +1 -1
- package/dist/adapters/hono/index.d.ts +1 -1
- package/dist/adapters/hono/index.mjs +3 -3
- package/dist/adapters/next/index.d.mts +1 -1
- package/dist/adapters/next/index.d.ts +1 -1
- package/dist/adapters/next/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +2 -2
- package/dist/adapters/standard/index.d.ts +2 -2
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.mjs +16 -6
- package/dist/plugins/index.d.mts +8 -8
- package/dist/plugins/index.d.ts +8 -8
- package/dist/plugins/index.mjs +1 -1
- package/dist/shared/{server.iM8li30u.d.mts → server.CM3tWr3C.d.mts} +3 -5
- package/dist/shared/{server.BFBhsdJr.mjs → server.CMrS28Go.mjs} +14 -13
- package/dist/shared/{server.3cSam35R.mjs → server.CSZRzcSW.mjs} +1 -1
- package/dist/shared/{server.CjB_m7jG.mjs → server.Cq3B6PoL.mjs} +1 -1
- package/dist/shared/{server.BZRSVRDu.d.ts → server.DmW25ynm.d.ts} +3 -5
- package/package.json +7 -7
package/README.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid), Pinia Colada, and more.
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
@@ -55,6 +55,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
56
56
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
57
57
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
58
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
58
59
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
59
60
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
60
61
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
3
|
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.mjs';
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.CM3tWr3C.mjs';
|
5
5
|
import '@orpc/client';
|
6
6
|
import '@orpc/contract';
|
7
7
|
import '@orpc/standard-server';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
3
|
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.js';
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.DmW25ynm.js';
|
5
5
|
import '@orpc/client';
|
6
6
|
import '@orpc/contract';
|
7
7
|
import '@orpc/standard-server';
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { R as RPCHandler } from '../../shared/server.Cq3B6PoL.mjs';
|
2
2
|
import '@orpc/client/standard';
|
3
3
|
import '@orpc/standard-server-fetch';
|
4
|
-
import '../../shared/server.
|
4
|
+
import '../../shared/server.CSZRzcSW.mjs';
|
5
5
|
import '@orpc/client';
|
6
6
|
import '@orpc/shared';
|
7
7
|
import '../../shared/server.Q6ZmnTgO.mjs';
|
8
|
-
import '../../shared/server.
|
8
|
+
import '../../shared/server.CMrS28Go.mjs';
|
9
9
|
import '@orpc/contract';
|
@@ -3,7 +3,7 @@ export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
5
|
import { C as Context } from '../../shared/server.CPteJIPP.mjs';
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.CM3tWr3C.mjs';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -3,7 +3,7 @@ export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
5
|
import { C as Context } from '../../shared/server.CPteJIPP.js';
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DmW25ynm.js';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -1,11 +1,11 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { R as RPCHandler } from '../../shared/server.Cq3B6PoL.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
3
|
import '@orpc/client/standard';
|
4
4
|
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.
|
5
|
+
import '../../shared/server.CSZRzcSW.mjs';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '../../shared/server.Q6ZmnTgO.mjs';
|
8
|
-
import '../../shared/server.
|
8
|
+
import '../../shared/server.CMrS28Go.mjs';
|
9
9
|
import '@orpc/contract';
|
10
10
|
|
11
11
|
function createMiddleware(handler, ...[options]) {
|
@@ -3,7 +3,7 @@ export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
5
|
import { C as Context } from '../../shared/server.CPteJIPP.mjs';
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.CM3tWr3C.mjs';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -3,7 +3,7 @@ export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
5
|
import { C as Context } from '../../shared/server.CPteJIPP.js';
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DmW25ynm.js';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -1,11 +1,11 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { R as RPCHandler } from '../../shared/server.Cq3B6PoL.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
3
|
import '@orpc/client/standard';
|
4
4
|
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.
|
5
|
+
import '../../shared/server.CSZRzcSW.mjs';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '../../shared/server.Q6ZmnTgO.mjs';
|
8
|
-
import '../../shared/server.
|
8
|
+
import '../../shared/server.CMrS28Go.mjs';
|
9
9
|
import '@orpc/contract';
|
10
10
|
|
11
11
|
function serve(handler, ...[options]) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
3
|
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.mjs';
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.CM3tWr3C.mjs';
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
6
6
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
7
7
|
import '@orpc/client';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
3
|
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.js';
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.DmW25ynm.js';
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
6
6
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
7
7
|
import '@orpc/client';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { RPCSerializer } from '@orpc/client/standard';
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
3
|
-
import { S as StandardHandler, a as RPCMatcher, R as RPCCodec } from '../../shared/server.
|
3
|
+
import { S as StandardHandler, a as RPCMatcher, R as RPCCodec } from '../../shared/server.CSZRzcSW.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/shared';
|
6
6
|
import '../../shared/server.Q6ZmnTgO.mjs';
|
7
|
-
import '../../shared/server.
|
7
|
+
import '../../shared/server.CMrS28Go.mjs';
|
8
8
|
import '@orpc/contract';
|
9
9
|
|
10
10
|
class RPCHandler {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.CM3tWr3C.mjs';
|
2
|
+
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions } from '../../shared/server.CM3tWr3C.mjs';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
4
|
import { RPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.DmW25ynm.js';
|
2
|
+
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions } from '../../shared/server.DmW25ynm.js';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
4
|
import { RPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export { R as RPCCodec, a as RPCMatcher, S as StandardHandler } from '../../shared/server.
|
1
|
+
export { R as RPCCodec, a as RPCMatcher, S as StandardHandler } from '../../shared/server.CSZRzcSW.mjs';
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/shared';
|
4
4
|
import '../../shared/server.Q6ZmnTgO.mjs';
|
5
|
-
import '../../shared/server.
|
5
|
+
import '../../shared/server.CMrS28Go.mjs';
|
6
6
|
import '@orpc/contract';
|
package/dist/index.d.mts
CHANGED
@@ -17,11 +17,11 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
|
|
17
17
|
/**
|
18
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
19
|
*/
|
20
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
20
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
21
21
|
/**
|
22
22
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
23
23
|
*/
|
24
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
24
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
25
25
|
}
|
26
26
|
|
27
27
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
@@ -51,6 +51,10 @@ interface LazyTraverseContractProceduresOptions {
|
|
51
51
|
}
|
52
52
|
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
53
53
|
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
54
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
55
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
56
|
+
};
|
57
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
54
58
|
|
55
59
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
56
60
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -119,9 +123,9 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
119
123
|
}
|
120
124
|
|
121
125
|
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> {
|
122
|
-
|
123
|
-
concat<UOutContext extends Context
|
124
|
-
|
126
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
127
|
+
concat<UOutContext extends Context>(middleware: Middleware<TInContext & TOutContext, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
128
|
+
concat<UOutContext extends Context, UMappedInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
125
129
|
}
|
126
130
|
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>;
|
127
131
|
|
@@ -154,6 +158,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
154
158
|
* Reset initial route
|
155
159
|
*/
|
156
160
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
161
|
+
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
157
162
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
158
163
|
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
|
159
164
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
@@ -188,11 +193,11 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
188
193
|
/**
|
189
194
|
* Make this procedure callable (works like a function while still being a procedure).
|
190
195
|
*/
|
191
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
196
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
192
197
|
/**
|
193
198
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
194
199
|
*/
|
195
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
200
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
196
201
|
}
|
197
202
|
/**
|
198
203
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
@@ -261,4 +266,4 @@ declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContrac
|
|
261
266
|
|
262
267
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
263
268
|
|
264
|
-
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, ConflictContextGuard, 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, MergedContext, Middleware, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures };
|
269
|
+
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, ConflictContextGuard, 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, MergedContext, Middleware, 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, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
|
package/dist/index.d.ts
CHANGED
@@ -17,11 +17,11 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
|
|
17
17
|
/**
|
18
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
19
|
*/
|
20
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
20
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
21
21
|
/**
|
22
22
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
23
23
|
*/
|
24
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
24
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
25
25
|
}
|
26
26
|
|
27
27
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
@@ -51,6 +51,10 @@ interface LazyTraverseContractProceduresOptions {
|
|
51
51
|
}
|
52
52
|
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
53
53
|
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
54
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
55
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
56
|
+
};
|
57
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
54
58
|
|
55
59
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
56
60
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -119,9 +123,9 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
119
123
|
}
|
120
124
|
|
121
125
|
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> {
|
122
|
-
|
123
|
-
concat<UOutContext extends Context
|
124
|
-
|
126
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
127
|
+
concat<UOutContext extends Context>(middleware: Middleware<TInContext & TOutContext, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
128
|
+
concat<UOutContext extends Context, UMappedInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
125
129
|
}
|
126
130
|
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>;
|
127
131
|
|
@@ -154,6 +158,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
154
158
|
* Reset initial route
|
155
159
|
*/
|
156
160
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
161
|
+
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
157
162
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
158
163
|
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
|
159
164
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
@@ -188,11 +193,11 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
188
193
|
/**
|
189
194
|
* Make this procedure callable (works like a function while still being a procedure).
|
190
195
|
*/
|
191
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
196
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
192
197
|
/**
|
193
198
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
194
199
|
*/
|
195
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>):
|
200
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
196
201
|
}
|
197
202
|
/**
|
198
203
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
@@ -261,4 +266,4 @@ declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContrac
|
|
261
266
|
|
262
267
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
263
268
|
|
264
|
-
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, ConflictContextGuard, 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, MergedContext, Middleware, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures };
|
269
|
+
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, ConflictContextGuard, 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, MergedContext, Middleware, 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, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
|
package/dist/index.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
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, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.
|
4
|
-
export { L as LAZY_SYMBOL, k as call, o as createAccessibleLazyRouter, b as createContractedProcedure, n as getHiddenRouterContract, j as getLazyMeta, m as middlewareOutputFn, r as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy } from './shared/server.
|
3
|
+
import { P as Procedure, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.CMrS28Go.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, k as call, o as createAccessibleLazyRouter, b as createContractedProcedure, n as getHiddenRouterContract, j as getLazyMeta, m as middlewareOutputFn, r as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, p as unlazyRouter } from './shared/server.CMrS28Go.mjs';
|
5
5
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
6
6
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
7
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
@@ -18,7 +18,7 @@ function fallbackConfig(key, value) {
|
|
18
18
|
}
|
19
19
|
|
20
20
|
function decorateMiddleware(middleware) {
|
21
|
-
const decorated = middleware;
|
21
|
+
const decorated = (...args) => middleware(...args);
|
22
22
|
decorated.mapInput = (mapInput) => {
|
23
23
|
const mapped = decorateMiddleware(
|
24
24
|
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
@@ -73,9 +73,13 @@ class DecoratedProcedure extends Procedure {
|
|
73
73
|
* Make this procedure callable (works like a function while still being a procedure).
|
74
74
|
*/
|
75
75
|
callable(...rest) {
|
76
|
-
return
|
77
|
-
|
78
|
-
|
76
|
+
return new Proxy(createProcedureClient(this, ...rest), {
|
77
|
+
get: (target, key) => {
|
78
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
79
|
+
},
|
80
|
+
has: (target, key) => {
|
81
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
82
|
+
}
|
79
83
|
});
|
80
84
|
}
|
81
85
|
/**
|
@@ -133,6 +137,12 @@ class Builder {
|
|
133
137
|
route: initialRoute
|
134
138
|
});
|
135
139
|
}
|
140
|
+
$input(initialInputSchema) {
|
141
|
+
return new Builder({
|
142
|
+
...this["~orpc"],
|
143
|
+
inputSchema: initialInputSchema
|
144
|
+
});
|
145
|
+
}
|
136
146
|
middleware(middleware) {
|
137
147
|
return decorateMiddleware(middleware);
|
138
148
|
}
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.
|
2
|
-
export { C as CompositePlugin } from '../shared/server.
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CM3tWr3C.mjs';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.CM3tWr3C.mjs';
|
3
3
|
import { Value } from '@orpc/shared';
|
4
4
|
import { C as Context } from '../shared/server.CPteJIPP.mjs';
|
5
5
|
import '@orpc/contract';
|
@@ -7,17 +7,17 @@ import '@orpc/standard-server';
|
|
7
7
|
import '@orpc/client';
|
8
8
|
|
9
9
|
interface CORSOptions<TContext extends Context> {
|
10
|
-
origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
11
|
-
timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
12
|
-
allowMethods?: string[];
|
13
|
-
allowHeaders?: string[];
|
10
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
11
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
12
|
+
allowMethods?: readonly string[];
|
13
|
+
allowHeaders?: readonly string[];
|
14
14
|
maxAge?: number;
|
15
15
|
credentials?: boolean;
|
16
|
-
exposeHeaders?: string[];
|
16
|
+
exposeHeaders?: readonly string[];
|
17
17
|
}
|
18
18
|
declare class CORSPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
19
19
|
private readonly options;
|
20
|
-
constructor(options?:
|
20
|
+
constructor(options?: CORSOptions<TContext>);
|
21
21
|
init(options: StandardHandlerOptions<TContext>): void;
|
22
22
|
}
|
23
23
|
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.
|
2
|
-
export { C as CompositePlugin } from '../shared/server.
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.DmW25ynm.js';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.DmW25ynm.js';
|
3
3
|
import { Value } from '@orpc/shared';
|
4
4
|
import { C as Context } from '../shared/server.CPteJIPP.js';
|
5
5
|
import '@orpc/contract';
|
@@ -7,17 +7,17 @@ import '@orpc/standard-server';
|
|
7
7
|
import '@orpc/client';
|
8
8
|
|
9
9
|
interface CORSOptions<TContext extends Context> {
|
10
|
-
origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
11
|
-
timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
12
|
-
allowMethods?: string[];
|
13
|
-
allowHeaders?: string[];
|
10
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
11
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
12
|
+
allowMethods?: readonly string[];
|
13
|
+
allowHeaders?: readonly string[];
|
14
14
|
maxAge?: number;
|
15
15
|
credentials?: boolean;
|
16
|
-
exposeHeaders?: string[];
|
16
|
+
exposeHeaders?: readonly string[];
|
17
17
|
}
|
18
18
|
declare class CORSPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
19
19
|
private readonly options;
|
20
|
-
constructor(options?:
|
20
|
+
constructor(options?: CORSOptions<TContext>);
|
21
21
|
init(options: StandardHandlerOptions<TContext>): void;
|
22
22
|
}
|
23
23
|
|
package/dist/plugins/index.mjs
CHANGED
@@ -27,9 +27,6 @@ type StandardHandleOptions<T extends Context> = {
|
|
27
27
|
} : {
|
28
28
|
context: T;
|
29
29
|
});
|
30
|
-
type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
|
31
|
-
context: T;
|
32
|
-
};
|
33
30
|
type StandardHandleResult = {
|
34
31
|
matched: true;
|
35
32
|
response: StandardResponse;
|
@@ -37,7 +34,8 @@ type StandardHandleResult = {
|
|
37
34
|
matched: false;
|
38
35
|
response: undefined;
|
39
36
|
};
|
40
|
-
type StandardHandlerInterceptorOptions<
|
37
|
+
type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
|
38
|
+
context: T;
|
41
39
|
request: StandardLazyRequest;
|
42
40
|
};
|
43
41
|
interface StandardHandlerOptions<TContext extends Context> {
|
@@ -74,4 +72,4 @@ declare class CompositePlugin<TContext extends Context> implements HandlerPlugin
|
|
74
72
|
init(options: StandardHandlerOptions<TContext>): void;
|
75
73
|
}
|
76
74
|
|
77
|
-
export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type
|
75
|
+
export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerInterceptorOptions as a, type StandardHandlerOptions 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 };
|
@@ -21,19 +21,8 @@ function unlazy(lazied) {
|
|
21
21
|
return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
|
22
22
|
}
|
23
23
|
|
24
|
-
function dedupeMiddlewares(compare, middlewares) {
|
25
|
-
let min = 0;
|
26
|
-
for (let i = 0; i < middlewares.length; i++) {
|
27
|
-
const index = compare.indexOf(middlewares[i], min);
|
28
|
-
if (index === -1) {
|
29
|
-
return middlewares.slice(i);
|
30
|
-
}
|
31
|
-
min = index + 1;
|
32
|
-
}
|
33
|
-
return [];
|
34
|
-
}
|
35
24
|
function mergeMiddlewares(first, second) {
|
36
|
-
return [...first, ...
|
25
|
+
return [...first, ...second];
|
37
26
|
}
|
38
27
|
function addMiddleware(middlewares, addition) {
|
39
28
|
return [...middlewares, addition];
|
@@ -311,6 +300,18 @@ async function resolveContractProcedures(options, callback) {
|
|
311
300
|
}
|
312
301
|
}
|
313
302
|
}
|
303
|
+
async function unlazyRouter(router) {
|
304
|
+
if (isProcedure(router)) {
|
305
|
+
return router;
|
306
|
+
}
|
307
|
+
const unlazied = {};
|
308
|
+
for (const key in router) {
|
309
|
+
const item = router[key];
|
310
|
+
const { default: unlaziedRouter } = await unlazy(item);
|
311
|
+
unlazied[key] = await unlazyRouter(unlaziedRouter);
|
312
|
+
}
|
313
|
+
return unlazied;
|
314
|
+
}
|
314
315
|
|
315
316
|
function createAssertedLazyProcedure(lazied) {
|
316
317
|
const lazyProcedure = lazy(async () => {
|
@@ -342,4 +343,4 @@ function toHttpPath(path) {
|
|
342
343
|
return `/${path.map(encodeURIComponent).join("/")}`;
|
343
344
|
}
|
344
345
|
|
345
|
-
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, getLazyMeta as j, call as k, lazy as l, middlewareOutputFn as m, getHiddenRouterContract as n, createAccessibleLazyRouter as o, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
|
346
|
+
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, getLazyMeta as j, call as k, lazy as l, middlewareOutputFn as m, getHiddenRouterContract as n, createAccessibleLazyRouter as o, unlazyRouter as p, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ORPCError, toORPCError } from '@orpc/client';
|
2
2
|
import { intercept, trim, parseEmptyableJSON } from '@orpc/shared';
|
3
3
|
import { C as CompositePlugin } from './server.Q6ZmnTgO.mjs';
|
4
|
-
import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.
|
4
|
+
import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.CMrS28Go.mjs';
|
5
5
|
|
6
6
|
class StandardHandler {
|
7
7
|
constructor(router, matcher, codec, options) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { RPCSerializer } from '@orpc/client/standard';
|
2
2
|
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
3
|
-
import { S as StandardHandler, a as RPCMatcher, R as RPCCodec } from './server.
|
3
|
+
import { S as StandardHandler, a as RPCMatcher, R as RPCCodec } from './server.CSZRzcSW.mjs';
|
4
4
|
|
5
5
|
class RPCHandler {
|
6
6
|
standardHandler;
|
@@ -27,9 +27,6 @@ type StandardHandleOptions<T extends Context> = {
|
|
27
27
|
} : {
|
28
28
|
context: T;
|
29
29
|
});
|
30
|
-
type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
|
31
|
-
context: T;
|
32
|
-
};
|
33
30
|
type StandardHandleResult = {
|
34
31
|
matched: true;
|
35
32
|
response: StandardResponse;
|
@@ -37,7 +34,8 @@ type StandardHandleResult = {
|
|
37
34
|
matched: false;
|
38
35
|
response: undefined;
|
39
36
|
};
|
40
|
-
type StandardHandlerInterceptorOptions<
|
37
|
+
type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
|
38
|
+
context: T;
|
41
39
|
request: StandardLazyRequest;
|
42
40
|
};
|
43
41
|
interface StandardHandlerOptions<TContext extends Context> {
|
@@ -74,4 +72,4 @@ declare class CompositePlugin<TContext extends Context> implements HandlerPlugin
|
|
74
72
|
init(options: StandardHandlerOptions<TContext>): void;
|
75
73
|
}
|
76
74
|
|
77
|
-
export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type
|
75
|
+
export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerInterceptorOptions as a, type StandardHandlerOptions 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 };
|
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.9b9ade5",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -58,12 +58,12 @@
|
|
58
58
|
"next": ">=14.0.0"
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
|
-
"@orpc/
|
62
|
-
"@orpc/
|
63
|
-
"@orpc/
|
64
|
-
"@orpc/
|
65
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
66
|
-
"@orpc/standard-server-node": "0.0.0-next.
|
61
|
+
"@orpc/contract": "0.0.0-next.9b9ade5",
|
62
|
+
"@orpc/client": "0.0.0-next.9b9ade5",
|
63
|
+
"@orpc/shared": "0.0.0-next.9b9ade5",
|
64
|
+
"@orpc/standard-server": "0.0.0-next.9b9ade5",
|
65
|
+
"@orpc/standard-server-fetch": "0.0.0-next.9b9ade5",
|
66
|
+
"@orpc/standard-server-node": "0.0.0-next.9b9ade5"
|
67
67
|
},
|
68
68
|
"devDependencies": {
|
69
69
|
"light-my-request": "^6.5.1"
|