@orpc/server 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adapters/fetch/index.d.mts +27 -0
- package/dist/adapters/fetch/index.d.ts +27 -0
- package/dist/adapters/fetch/index.mjs +9 -0
- package/dist/adapters/hono/index.d.mts +20 -0
- package/dist/adapters/hono/index.d.ts +20 -0
- package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
- package/dist/adapters/next/index.d.mts +27 -0
- package/dist/adapters/next/index.d.ts +27 -0
- package/dist/{next.js → adapters/next/index.mjs} +11 -13
- package/dist/adapters/node/index.d.mts +35 -0
- package/dist/adapters/node/index.d.ts +35 -0
- package/dist/adapters/node/index.mjs +28 -0
- package/dist/adapters/standard/index.d.mts +29 -0
- package/dist/adapters/standard/index.d.ts +29 -0
- package/dist/adapters/standard/index.mjs +7 -0
- package/dist/index.d.mts +253 -0
- package/dist/index.d.ts +253 -0
- package/dist/{index.js → index.mjs} +33 -113
- package/dist/plugins/index.d.mts +31 -0
- package/dist/plugins/index.d.ts +31 -0
- package/dist/{chunk-TXHKQO7N.js → plugins/index.mjs} +11 -28
- package/dist/{chunk-TV5DRAST.js → shared/server.BBGuTxHE.mjs} +12 -31
- package/dist/shared/server.BqEaivV1.d.ts +9 -0
- package/dist/shared/server.CHpDfeOK.d.mts +77 -0
- package/dist/shared/server.CI7U5gRZ.d.mts +152 -0
- package/dist/shared/server.CI7U5gRZ.d.ts +152 -0
- package/dist/{chunk-WDY5PTME.js → shared/server.CUE4Aija.mjs} +8 -16
- package/dist/shared/server.DSZ2XY8G.d.ts +77 -0
- package/dist/shared/server.MnOqRlBp.d.mts +9 -0
- package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
- package/dist/{chunk-MHVECKBC.js → shared/server.V6zT5iYQ.mjs} +48 -90
- package/package.json +29 -34
- package/dist/fetch.js +0 -10
- package/dist/node.js +0 -31
- package/dist/plugins.js +0 -11
- package/dist/src/adapters/fetch/index.d.ts +0 -3
- package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/fetch/types.d.ts +0 -14
- package/dist/src/adapters/hono/index.d.ts +0 -3
- package/dist/src/adapters/hono/middleware.d.ts +0 -12
- package/dist/src/adapters/next/index.d.ts +0 -3
- package/dist/src/adapters/next/serve.d.ts +0 -19
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/node/types.d.ts +0 -22
- package/dist/src/adapters/standard/handler.d.ts +0 -53
- package/dist/src/adapters/standard/index.d.ts +0 -6
- package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
- package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
- package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
- package/dist/src/adapters/standard/types.d.ts +0 -21
- package/dist/src/builder-variants.d.ts +0 -75
- package/dist/src/builder.d.ts +0 -58
- package/dist/src/config.d.ts +0 -6
- package/dist/src/context.d.ts +0 -8
- package/dist/src/error.d.ts +0 -12
- package/dist/src/hidden.d.ts +0 -8
- package/dist/src/implementer-procedure.d.ts +0 -33
- package/dist/src/implementer-variants.d.ts +0 -18
- package/dist/src/implementer.d.ts +0 -29
- package/dist/src/index.d.ts +0 -25
- package/dist/src/lazy-utils.d.ts +0 -6
- package/dist/src/lazy.d.ts +0 -22
- package/dist/src/middleware-decorated.d.ts +0 -11
- package/dist/src/middleware-utils.d.ts +0 -5
- package/dist/src/middleware.d.ts +0 -38
- package/dist/src/plugins/base.d.ts +0 -11
- package/dist/src/plugins/cors.d.ts +0 -19
- package/dist/src/plugins/index.d.ts +0 -4
- package/dist/src/plugins/response-headers.d.ts +0 -10
- package/dist/src/procedure-client.d.ts +0 -33
- package/dist/src/procedure-decorated.d.ts +0 -24
- package/dist/src/procedure-utils.d.ts +0 -19
- package/dist/src/procedure.d.ts +0 -31
- package/dist/src/router-accessible-lazy.d.ts +0 -8
- package/dist/src/router-client.d.ts +0 -12
- package/dist/src/router.d.ts +0 -30
- package/dist/src/utils.d.ts +0 -24
- package/dist/standard.js +0 -13
@@ -1,75 +0,0 @@
|
|
1
|
-
import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { BuilderDef } from './builder';
|
3
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
|
-
import type { ORPCErrorConstructorMap } from './error';
|
5
|
-
import type { FlattenLazy } from './lazy-utils';
|
6
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
7
|
-
import type { ProcedureHandler } from './procedure';
|
8
|
-
import type { DecoratedProcedure } from './procedure-decorated';
|
9
|
-
import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
|
10
|
-
export interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
11
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
12
|
-
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
|
-
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
15
|
-
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
-
'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
17
|
-
'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
18
|
-
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
19
|
-
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
20
|
-
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
21
|
-
'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
|
22
|
-
'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
|
23
|
-
default: U;
|
24
|
-
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
|
25
|
-
}
|
26
|
-
export interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
27
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
28
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
29
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
30
|
-
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
31
|
-
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
32
|
-
'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
33
|
-
'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
34
|
-
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
35
|
-
}
|
36
|
-
export interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
37
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
38
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
39
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
40
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
41
|
-
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
42
|
-
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
43
|
-
'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
44
|
-
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
45
|
-
}
|
46
|
-
export interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
47
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
48
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
49
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
50
|
-
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
51
|
-
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
52
|
-
'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
53
|
-
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
54
|
-
}
|
55
|
-
export interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
56
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
57
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
58
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
59
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
60
|
-
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
61
|
-
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
62
|
-
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
63
|
-
}
|
64
|
-
export interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
65
|
-
'~orpc': AdaptRouterOptions<TErrorMap>;
|
66
|
-
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
67
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & RouterBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
68
|
-
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
69
|
-
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
70
|
-
'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
|
71
|
-
'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
|
72
|
-
default: U;
|
73
|
-
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
|
74
|
-
}
|
75
|
-
//# sourceMappingURL=builder-variants.d.ts.map
|
package/dist/src/builder.d.ts
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { BuilderWithMiddlewares, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithOutput, RouterBuilder } from './builder-variants';
|
3
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
|
-
import type { ORPCErrorConstructorMap } from './error';
|
5
|
-
import type { FlattenLazy } from './lazy-utils';
|
6
|
-
import type { AnyMiddleware, MapInputMiddleware, Middleware } from './middleware';
|
7
|
-
import type { DecoratedMiddleware } from './middleware-decorated';
|
8
|
-
import type { ProcedureHandler } from './procedure';
|
9
|
-
import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
|
10
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
11
|
-
export interface BuilderConfig {
|
12
|
-
initialInputValidationIndex?: number;
|
13
|
-
initialOutputValidationIndex?: number;
|
14
|
-
}
|
15
|
-
export interface BuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptRouterOptions<TErrorMap> {
|
16
|
-
middlewares: AnyMiddleware[];
|
17
|
-
inputValidationIndex: number;
|
18
|
-
outputValidationIndex: number;
|
19
|
-
config: BuilderConfig;
|
20
|
-
}
|
21
|
-
export declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
22
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
23
|
-
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
24
|
-
/**
|
25
|
-
* Reset config
|
26
|
-
*/
|
27
|
-
$config(config: BuilderConfig): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
28
|
-
/**
|
29
|
-
* Reset initial context
|
30
|
-
*/
|
31
|
-
$context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
32
|
-
/**
|
33
|
-
* Reset initial meta
|
34
|
-
*/
|
35
|
-
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U>;
|
36
|
-
/**
|
37
|
-
* Reset initial route
|
38
|
-
*/
|
39
|
-
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
40
|
-
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
41
|
-
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
|
42
|
-
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
43
|
-
use<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
44
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
45
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
46
|
-
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
47
|
-
input<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
48
|
-
output<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
49
|
-
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
50
|
-
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
51
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
52
|
-
router<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
|
53
|
-
lazy<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
|
54
|
-
default: U;
|
55
|
-
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
|
56
|
-
}
|
57
|
-
export declare const os: Builder<Context, Context, undefined, undefined, {}, {}>;
|
58
|
-
//# sourceMappingURL=builder.d.ts.map
|
package/dist/src/config.d.ts
DELETED
package/dist/src/context.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { IsNever } from '@orpc/shared';
|
2
|
-
export type Context = Record<string, any>;
|
3
|
-
export type MergedContext<T extends Context, U extends Context> = T & U;
|
4
|
-
export declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
|
5
|
-
export type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
|
6
|
-
[K in keyof T]: IsNever<T[K]>;
|
7
|
-
}[keyof T] ? never : unknown;
|
8
|
-
//# sourceMappingURL=context.d.ts.map
|
package/dist/src/error.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { ORPCErrorCode, ORPCErrorOptions } from '@orpc/client';
|
2
|
-
import type { ErrorMap, ErrorMapItem, SchemaInput } from '@orpc/contract';
|
3
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import { ORPCError } from '@orpc/client';
|
5
|
-
export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
6
|
-
export type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
7
|
-
export type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
8
|
-
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, SchemaInput<UInputSchema>> : never : never;
|
9
|
-
};
|
10
|
-
export declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
11
|
-
export declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
|
12
|
-
//# sourceMappingURL=error.d.ts.map
|
package/dist/src/hidden.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { AnyContractRouter, ContractRouter, HTTPPath } from '@orpc/contract';
|
2
|
-
import type { Lazy } from './lazy';
|
3
|
-
import type { AnyRouter } from './router';
|
4
|
-
export declare function setRouterContract<T extends AnyRouter>(obj: T, contract: AnyContractRouter): T;
|
5
|
-
export declare function getRouterContract(obj: object): ContractRouter<any> | undefined;
|
6
|
-
export declare function deepSetLazyRouterPrefix<T extends Lazy<any>>(router: T, prefix: HTTPPath): T;
|
7
|
-
export declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
|
8
|
-
//# sourceMappingURL=hidden.d.ts.map
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { ClientContext, ClientRest } from '@orpc/client';
|
2
|
-
import type { ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import type { BuilderDef } from './builder';
|
5
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
6
|
-
import type { ORPCErrorConstructorMap } from './error';
|
7
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
8
|
-
import type { Procedure, ProcedureHandler } from './procedure';
|
9
|
-
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
10
|
-
import type { DecoratedProcedure } from './procedure-decorated';
|
11
|
-
/**
|
12
|
-
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
13
|
-
*/
|
14
|
-
export interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> {
|
15
|
-
use: (<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>) => ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>) & (<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>) => ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>);
|
16
|
-
/**
|
17
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
18
|
-
*/
|
19
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
20
|
-
/**
|
21
|
-
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
22
|
-
*/
|
23
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
24
|
-
}
|
25
|
-
/**
|
26
|
-
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
27
|
-
*/
|
28
|
-
export interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
29
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
30
|
-
'use': (<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>) => ConflictContextGuard<MergedContext<TCurrentContext, U>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>) & (<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>) => ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
31
|
-
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
32
|
-
}
|
33
|
-
//# sourceMappingURL=implementer-procedure.d.ts.map
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta } from '@orpc/contract';
|
2
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
4
|
-
import type { ProcedureImplementer } from './implementer-procedure';
|
5
|
-
import type { FlattenLazy } from './lazy-utils';
|
6
|
-
import type { Middleware } from './middleware';
|
7
|
-
import type { AdaptedRouter, Router } from './router';
|
8
|
-
export interface RouterImplementerWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
9
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
10
|
-
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
11
|
-
lazy<U extends Router<TInitialContext, TContract>>(loader: () => Promise<{
|
12
|
-
default: U;
|
13
|
-
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
14
|
-
}
|
15
|
-
export type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
16
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
17
|
-
});
|
18
|
-
//# sourceMappingURL=implementer-variants.d.ts.map
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta } from '@orpc/contract';
|
2
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
4
|
-
import type { ProcedureImplementer } from './implementer-procedure';
|
5
|
-
import type { ImplementerInternalWithMiddlewares } from './implementer-variants';
|
6
|
-
import type { AnyMiddleware, Middleware } from './middleware';
|
7
|
-
import { type BuilderConfig } from './builder';
|
8
|
-
import { type FlattenLazy } from './lazy-utils';
|
9
|
-
import { type DecoratedMiddleware } from './middleware-decorated';
|
10
|
-
import { type AdaptedRouter, type Router } from './router';
|
11
|
-
export interface RouterImplementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
12
|
-
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
13
|
-
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, ContractRouterToMeta<TContract>>;
|
14
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
15
|
-
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
16
|
-
lazy<U extends Router<TCurrentContext, TContract>>(loader: () => Promise<{
|
17
|
-
default: U;
|
18
|
-
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
19
|
-
}
|
20
|
-
export type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
|
21
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
22
|
-
});
|
23
|
-
export declare function implementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: TContract, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
24
|
-
export type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
25
|
-
$context<U extends Context>(): Implementer<TContract, U, U>;
|
26
|
-
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
27
|
-
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
28
|
-
export declare function implement<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: TContract, config?: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
29
|
-
//# sourceMappingURL=implementer.d.ts.map
|
package/dist/src/index.d.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
export * from './builder';
|
2
|
-
export * from './builder-variants';
|
3
|
-
export * from './config';
|
4
|
-
export * from './context';
|
5
|
-
export * from './hidden';
|
6
|
-
export * from './implementer';
|
7
|
-
export * from './implementer-procedure';
|
8
|
-
export * from './implementer-variants';
|
9
|
-
export * from './lazy';
|
10
|
-
export * from './lazy-utils';
|
11
|
-
export * from './middleware';
|
12
|
-
export * from './middleware-decorated';
|
13
|
-
export * from './procedure';
|
14
|
-
export * from './procedure-client';
|
15
|
-
export * from './procedure-decorated';
|
16
|
-
export * from './procedure-utils';
|
17
|
-
export * from './router';
|
18
|
-
export * from './router-accessible-lazy';
|
19
|
-
export * from './router-client';
|
20
|
-
export * from './utils';
|
21
|
-
export { isDefinedError, ORPCError, safe } from '@orpc/client';
|
22
|
-
export { eventIterator, type, ValidationError } from '@orpc/contract';
|
23
|
-
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
24
|
-
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/lazy-utils.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
import type { Lazy } from './lazy';
|
2
|
-
import { type AnyProcedure } from './procedure';
|
3
|
-
export type FlattenLazy<T> = T extends Lazy<infer U> ? FlattenLazy<U> : Lazy<T>;
|
4
|
-
export declare function flatLazy<T extends Lazy<any>>(lazied: T): FlattenLazy<T>;
|
5
|
-
export declare function createLazyProcedureFormAnyLazy(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
6
|
-
//# sourceMappingURL=lazy-utils.d.ts.map
|
package/dist/src/lazy.d.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { HTTPPath } from '@orpc/contract';
|
2
|
-
export declare const LAZY_LOADER_SYMBOL: unique symbol;
|
3
|
-
export interface LazyMeta {
|
4
|
-
prefix?: HTTPPath;
|
5
|
-
}
|
6
|
-
export interface Lazy<T> {
|
7
|
-
[LAZY_LOADER_SYMBOL](): Promise<{
|
8
|
-
default: T;
|
9
|
-
}>;
|
10
|
-
}
|
11
|
-
export type Lazyable<T> = T | Lazy<T>;
|
12
|
-
export interface LazyOptions {
|
13
|
-
prefix?: HTTPPath;
|
14
|
-
}
|
15
|
-
export declare function lazy<T>(loader: () => Promise<{
|
16
|
-
default: T;
|
17
|
-
}>): Lazy<T>;
|
18
|
-
export declare function isLazy(item: unknown): item is Lazy<any>;
|
19
|
-
export declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
20
|
-
default: T extends Lazy<infer U> ? U : T;
|
21
|
-
}>;
|
22
|
-
//# sourceMappingURL=lazy.d.ts.map
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { Meta } from '@orpc/contract';
|
2
|
-
import type { Context, MergedContext } from './context';
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
4
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
|
-
export 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> {
|
6
|
-
concat<UOutContext extends Context, UInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
|
7
|
-
concat<UOutContext extends Context, UInput, UMappedInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<UInput & TInput, UMappedInput>): DecoratedMiddleware<TInContext, TOutContext & UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
|
8
|
-
mapInput<UInput = unknown>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
9
|
-
}
|
10
|
-
export 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>;
|
11
|
-
//# sourceMappingURL=middleware-decorated.d.ts.map
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import type { AnyMiddleware } from './middleware';
|
2
|
-
export declare function dedupeMiddlewares(compare: AnyMiddleware[], middlewares: AnyMiddleware[]): AnyMiddleware[];
|
3
|
-
export declare function mergeMiddlewares(first: AnyMiddleware[], second: AnyMiddleware[]): AnyMiddleware[];
|
4
|
-
export declare function addMiddleware(middlewares: AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
5
|
-
//# sourceMappingURL=middleware-utils.d.ts.map
|
package/dist/src/middleware.d.ts
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import type { ErrorMap, Meta, Schema } from '@orpc/contract';
|
2
|
-
import type { MaybeOptionalOptions, Promisable } from '@orpc/shared';
|
3
|
-
import type { Context } from './context';
|
4
|
-
import type { ORPCErrorConstructorMap } from './error';
|
5
|
-
import type { Procedure } from './procedure';
|
6
|
-
export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
7
|
-
output: TOutput;
|
8
|
-
context: TOutContext;
|
9
|
-
}>;
|
10
|
-
export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
|
11
|
-
context?: TOutContext;
|
12
|
-
} : {
|
13
|
-
context: TOutContext;
|
14
|
-
};
|
15
|
-
export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
|
16
|
-
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
|
17
|
-
}
|
18
|
-
export interface MiddlewareOutputFn<TOutput> {
|
19
|
-
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
20
|
-
}
|
21
|
-
export interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
22
|
-
context: TInContext;
|
23
|
-
path: string[];
|
24
|
-
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
25
|
-
signal?: AbortSignal;
|
26
|
-
lastEventId: string | undefined;
|
27
|
-
next: MiddlewareNextFn<TInContext, TOutput>;
|
28
|
-
errors: TErrorConstructorMap;
|
29
|
-
}
|
30
|
-
export interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
31
|
-
(options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
|
32
|
-
}
|
33
|
-
export type AnyMiddleware = Middleware<any, any, any, any, any, any>;
|
34
|
-
export interface MapInputMiddleware<TInput, TMappedInput> {
|
35
|
-
(input: TInput): TMappedInput;
|
36
|
-
}
|
37
|
-
export declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
38
|
-
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { StandardHandlerOptions } from '../adapters/standard';
|
2
|
-
import type { Context } from '../context';
|
3
|
-
export interface Plugin<TContext extends Context> {
|
4
|
-
init?(options: StandardHandlerOptions<TContext>): void;
|
5
|
-
}
|
6
|
-
export declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
|
7
|
-
private readonly plugins;
|
8
|
-
constructor(plugins?: Plugin<TContext>[]);
|
9
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
10
|
-
}
|
11
|
-
//# sourceMappingURL=base.d.ts.map
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { StandardHandlerInterceptorOptions, StandardHandlerOptions } from '../adapters/standard';
|
2
|
-
import type { Context } from '../context';
|
3
|
-
import type { Plugin } from './base';
|
4
|
-
import { type Value } from '@orpc/shared';
|
5
|
-
export interface CORSOptions<TContext extends Context> {
|
6
|
-
origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
7
|
-
timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
8
|
-
allowMethods?: string[];
|
9
|
-
allowHeaders?: string[];
|
10
|
-
maxAge?: number;
|
11
|
-
credentials?: boolean;
|
12
|
-
exposeHeaders?: string[];
|
13
|
-
}
|
14
|
-
export declare class CORSPlugin<TContext extends Context> implements Plugin<TContext> {
|
15
|
-
private readonly options;
|
16
|
-
constructor(options?: Partial<CORSOptions<TContext>>);
|
17
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=cors.d.ts.map
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { StandardHandlerOptions } from '../adapters/standard';
|
2
|
-
import type { Context } from '../context';
|
3
|
-
import type { Plugin } from './base';
|
4
|
-
export interface ResponseHeadersPluginContext {
|
5
|
-
resHeaders?: Headers;
|
6
|
-
}
|
7
|
-
export declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements Plugin<TContext> {
|
8
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=response-headers.d.ts.map
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { Client, ClientContext } from '@orpc/client';
|
2
|
-
import type { Interceptor, MaybeOptionalOptions, Value } from '@orpc/shared';
|
3
|
-
import type { Context } from './context';
|
4
|
-
import type { Lazyable } from './lazy';
|
5
|
-
import type { Procedure } from './procedure';
|
6
|
-
import { type ErrorFromErrorMap, type ErrorMap, type Meta, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
7
|
-
import { type ORPCErrorConstructorMap } from './error';
|
8
|
-
export type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
9
|
-
export interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
10
|
-
context: TInitialContext;
|
11
|
-
input: SchemaInput<TInputSchema>;
|
12
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
13
|
-
path: string[];
|
14
|
-
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
15
|
-
signal?: AbortSignal;
|
16
|
-
lastEventId: string | undefined;
|
17
|
-
}
|
18
|
-
/**
|
19
|
-
* Options for creating a procedure caller with comprehensive type safety
|
20
|
-
*/
|
21
|
-
export type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
22
|
-
/**
|
23
|
-
* This is helpful for logging and analytics.
|
24
|
-
*/
|
25
|
-
path?: string[];
|
26
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>[];
|
27
|
-
} & (Record<never, never> extends TInitialContext ? {
|
28
|
-
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
29
|
-
} : {
|
30
|
-
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
31
|
-
});
|
32
|
-
export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
33
|
-
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { ClientContext, ClientRest } from '@orpc/client';
|
2
|
-
import type { ErrorMap, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
5
|
-
import type { ORPCErrorConstructorMap } from './error';
|
6
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
7
|
-
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
8
|
-
import { Procedure } from './procedure';
|
9
|
-
export declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> {
|
10
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, MergedErrorMap<TErrorMap, U>, TMeta>;
|
11
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
12
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
13
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
14
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
15
|
-
/**
|
16
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
17
|
-
*/
|
18
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
19
|
-
/**
|
20
|
-
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
21
|
-
*/
|
22
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
23
|
-
}
|
24
|
-
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { ClientPromiseResult } from '@orpc/client';
|
2
|
-
import type { ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import type { Context } from './context';
|
5
|
-
import type { Lazyable } from './lazy';
|
6
|
-
import type { Procedure } from './procedure';
|
7
|
-
import type { CreateProcedureClientOptions } from './procedure-client';
|
8
|
-
/**
|
9
|
-
* Directly call a procedure without creating a client.
|
10
|
-
*
|
11
|
-
* @example
|
12
|
-
* ```ts
|
13
|
-
* const output = await call(getting, 'input')
|
14
|
-
* const output = await call(getting, 'input', { context: { db: 'postgres' } })
|
15
|
-
* ```
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, input: SchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
19
|
-
//# sourceMappingURL=procedure-utils.d.ts.map
|
package/dist/src/procedure.d.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import type { ContractProcedureDef, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type { Context } from './context';
|
4
|
-
import type { ORPCErrorConstructorMap } from './error';
|
5
|
-
import type { AnyMiddleware } from './middleware';
|
6
|
-
export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
7
|
-
context: TCurrentContext;
|
8
|
-
input: TInput;
|
9
|
-
path: string[];
|
10
|
-
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
11
|
-
signal?: AbortSignal;
|
12
|
-
lastEventId: string | undefined;
|
13
|
-
errors: TErrorConstructorMap;
|
14
|
-
}
|
15
|
-
export interface ProcedureHandler<TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
16
|
-
(opt: ProcedureHandlerOptions<TCurrentContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
17
|
-
}
|
18
|
-
export interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
19
|
-
__initialContext?: (type: TInitialContext) => unknown;
|
20
|
-
middlewares: AnyMiddleware[];
|
21
|
-
inputValidationIndex: number;
|
22
|
-
outputValidationIndex: number;
|
23
|
-
handler: ProcedureHandler<TCurrentContext, any, any, THandlerOutput, any, any>;
|
24
|
-
}
|
25
|
-
export declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
26
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
27
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>);
|
28
|
-
}
|
29
|
-
export type AnyProcedure = Procedure<any, any, any, any, any, any, any>;
|
30
|
-
export declare function isProcedure(item: unknown): item is AnyProcedure;
|
31
|
-
//# sourceMappingURL=procedure.d.ts.map
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { Lazy } from './lazy';
|
2
|
-
import type { AnyProcedure } from './procedure';
|
3
|
-
import type { AnyRouter } from './router';
|
4
|
-
export type AccessibleLazyRouter<T extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : Lazy<T> & (T extends AnyProcedure | undefined ? unknown : {
|
5
|
-
[K in keyof T]: T[K] extends AnyRouter ? AccessibleLazyRouter<T[K]> : never;
|
6
|
-
});
|
7
|
-
export declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
8
|
-
//# sourceMappingURL=router-accessible-lazy.d.ts.map
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { ClientContext } from '@orpc/client';
|
2
|
-
import type { ErrorMap, Meta } from '@orpc/contract';
|
3
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import type { Lazy } from './lazy';
|
5
|
-
import type { Procedure } from './procedure';
|
6
|
-
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
7
|
-
import type { AnyRouter, InferRouterInitialContext } from './router';
|
8
|
-
export type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
9
|
-
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
10
|
-
};
|
11
|
-
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext>(router: TRouter | Lazy<undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<TRouter>, undefined, undefined, unknown, ErrorMap, Meta, TClientContext>>): RouterClient<TRouter, TClientContext>;
|
12
|
-
//# sourceMappingURL=router-client.d.ts.map
|