@orpc/server 0.0.0-next.c0088c7 → 0.0.0-next.c0afbea

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.
Files changed (32) hide show
  1. package/README.md +3 -1
  2. package/dist/adapters/fetch/index.d.mts +3 -3
  3. package/dist/adapters/fetch/index.d.ts +3 -3
  4. package/dist/adapters/fetch/index.mjs +3 -3
  5. package/dist/adapters/hono/index.d.mts +2 -2
  6. package/dist/adapters/hono/index.d.ts +2 -2
  7. package/dist/adapters/hono/index.mjs +3 -3
  8. package/dist/adapters/next/index.d.mts +2 -2
  9. package/dist/adapters/next/index.d.ts +2 -2
  10. package/dist/adapters/next/index.mjs +3 -3
  11. package/dist/adapters/node/index.d.mts +3 -3
  12. package/dist/adapters/node/index.d.ts +3 -3
  13. package/dist/adapters/node/index.mjs +2 -2
  14. package/dist/adapters/standard/index.d.mts +4 -4
  15. package/dist/adapters/standard/index.d.ts +4 -4
  16. package/dist/adapters/standard/index.mjs +2 -2
  17. package/dist/index.d.mts +120 -106
  18. package/dist/index.d.ts +120 -106
  19. package/dist/index.mjs +39 -29
  20. package/dist/plugins/index.d.mts +12 -12
  21. package/dist/plugins/index.d.ts +12 -12
  22. package/dist/plugins/index.mjs +1 -1
  23. package/dist/shared/{server.Drm1Lma3.d.ts → server.CM3tWr3C.d.mts} +12 -14
  24. package/dist/shared/{server.V6zT5iYQ.mjs → server.CMrS28Go.mjs} +124 -157
  25. package/dist/shared/server.CPteJIPP.d.mts +143 -0
  26. package/dist/shared/server.CPteJIPP.d.ts +143 -0
  27. package/dist/shared/{server.DKrKGnk2.mjs → server.CSZRzcSW.mjs} +8 -11
  28. package/dist/shared/{server.BHIDiY4a.mjs → server.Cq3B6PoL.mjs} +1 -1
  29. package/dist/shared/{server.CtBp-i4f.d.mts → server.DmW25ynm.d.ts} +12 -14
  30. package/package.json +7 -7
  31. package/dist/shared/server.ptXwNGQr.d.mts +0 -158
  32. package/dist/shared/server.ptXwNGQr.d.ts +0 -158
@@ -1,158 +0,0 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, SchemaInput, HTTPPath, Meta, Schema, ContractProcedureDef, SchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure, MergedErrorMap } from '@orpc/contract';
4
-
5
- type Context = Record<string, any>;
6
- type MergedContext<T extends Context, U extends Context> = T & U;
7
- declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
8
- type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
9
- [K in keyof T]: IsNever<T[K]>;
10
- }[keyof T] ? never : unknown;
11
-
12
- type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
- type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
- type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
- [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, SchemaInput<UInputSchema>> : never : never;
16
- };
17
-
18
- declare const LAZY_LOADER_SYMBOL: unique symbol;
19
- interface LazyMeta {
20
- prefix?: HTTPPath;
21
- }
22
- interface Lazy<T> {
23
- [LAZY_LOADER_SYMBOL](): Promise<{
24
- default: T;
25
- }>;
26
- }
27
- type Lazyable<T> = T | Lazy<T>;
28
- interface LazyOptions {
29
- prefix?: HTTPPath;
30
- }
31
- declare function lazy<T>(loader: () => Promise<{
32
- default: T;
33
- }>): Lazy<T>;
34
- declare function isLazy(item: unknown): item is Lazy<any>;
35
- declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
36
- default: T extends Lazy<infer U> ? U : T;
37
- }>;
38
-
39
- type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
40
- output: TOutput;
41
- context: TOutContext;
42
- }>;
43
- type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
44
- context?: TOutContext;
45
- } : {
46
- context: TOutContext;
47
- };
48
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
49
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
50
- }
51
- interface MiddlewareOutputFn<TOutput> {
52
- (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
53
- }
54
- interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
55
- context: TInContext;
56
- path: string[];
57
- procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
58
- signal?: AbortSignal;
59
- lastEventId: string | undefined;
60
- next: MiddlewareNextFn<TInContext, TOutput>;
61
- errors: TErrorConstructorMap;
62
- }
63
- interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
64
- (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
65
- }
66
- type AnyMiddleware = Middleware<any, any, any, any, any, any>;
67
- interface MapInputMiddleware<TInput, TMappedInput> {
68
- (input: TInput): TMappedInput;
69
- }
70
- declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
71
-
72
- interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
73
- context: TCurrentContext;
74
- input: TInput;
75
- path: string[];
76
- procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
77
- signal?: AbortSignal;
78
- lastEventId: string | undefined;
79
- errors: TErrorConstructorMap;
80
- }
81
- interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
82
- (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
83
- }
84
- interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
85
- __initialContext?: (type: TInitialContext) => unknown;
86
- middlewares: AnyMiddleware[];
87
- inputValidationIndex: number;
88
- outputValidationIndex: number;
89
- handler: ProcedureHandler<TCurrentContext, any, THandlerOutput, any, any>;
90
- }
91
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
92
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
93
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>);
94
- }
95
- type AnyProcedure = Procedure<any, any, any, any, any, any, any>;
96
- declare function isProcedure(item: unknown): item is AnyProcedure;
97
-
98
- type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
99
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
100
- context: TInitialContext;
101
- input: SchemaInput<TInputSchema>;
102
- errors: ORPCErrorConstructorMap<TErrorMap>;
103
- path: string[];
104
- procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
105
- signal?: AbortSignal;
106
- lastEventId: string | undefined;
107
- }
108
- /**
109
- * Options for creating a procedure caller with comprehensive type safety
110
- */
111
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
112
- /**
113
- * This is helpful for logging and analytics.
114
- */
115
- path?: string[];
116
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>[];
117
- } & (Record<never, never> extends TInitialContext ? {
118
- context?: Value<TInitialContext, [clientContext: TClientContext]>;
119
- } : {
120
- context: Value<TInitialContext, [clientContext: TClientContext]>;
121
- });
122
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput, 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>;
123
-
124
- 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 : {
125
- [K in keyof T]: T[K] extends AnyRouter ? AccessibleLazyRouter<T[K]> : never;
126
- });
127
- declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
128
-
129
- type Router<TInitialContext extends Context, TContract extends AnyContractRouter> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, any, UErrorMap, UMeta> : {
130
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? Router<TInitialContext, TContract[K]> : never;
131
- }>;
132
- type AnyRouter = Router<any, any>;
133
- type InferRouterInitialContext<T extends AnyRouter> = T extends Router<infer UInitialContext, any> ? UInitialContext : never;
134
- type InferRouterInitialContexts<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : T extends Procedure<infer UInitialContext, any, any, any, any, any, any> ? UInitialContext : {
135
- [K in keyof T]: T[K] extends AnyRouter ? InferRouterInitialContexts<T[K]> : never;
136
- };
137
- type InferRouterCurrentContexts<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : T extends Procedure<any, infer UCurrentContext, any, any, any, any, any> ? UCurrentContext : {
138
- [K in keyof T]: T[K] extends AnyRouter ? InferRouterCurrentContexts<T[K]> : never;
139
- };
140
- type InferRouterInputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any, any, any> ? SchemaInput<UInputSchema> : {
141
- [K in keyof T]: T[K] extends AnyRouter ? InferRouterInputs<T[K]> : never;
142
- };
143
- type InferRouterOutputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput, any, any> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
144
- [K in keyof T]: T[K] extends AnyRouter ? InferRouterOutputs<T[K]> : never;
145
- };
146
- type AdaptedRouter<TRouter extends AnyRouter, TInitialContext extends Context, TErrorMap extends ErrorMap> = TRouter extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<AdaptedRouter<U, TInitialContext, TErrorMap>> : TRouter extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UFuncOutput, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
147
- [K in keyof TRouter]: TRouter[K] extends AnyRouter ? AdaptedRouter<TRouter[K], TInitialContext, TErrorMap> : never;
148
- };
149
- interface AdaptRouterOptions<TErrorMap extends ErrorMap> {
150
- middlewares: AnyMiddleware[];
151
- tags?: readonly string[];
152
- prefix?: HTTPPath;
153
- errorMap: TErrorMap;
154
- }
155
- declare function adaptRouter<TRouter extends AnyRouter, TInitialContext extends Context, TErrorMap extends ErrorMap>(router: TRouter, options: AdaptRouterOptions<TErrorMap>): AdaptedRouter<TRouter, TInitialContext, TErrorMap>;
156
- declare function getRouterChild<T extends AnyRouter | Lazy<undefined>>(router: T, ...path: string[]): T extends Lazy<any> ? Lazy<AnyProcedure> | Lazy<Record<string, AnyRouter>> | Lazy<undefined> : AnyRouter | Lazy<undefined> | undefined;
157
-
158
- export { type AnyProcedure as A, type ProcedureDef as B, type Context as C, isProcedure as D, createProcedureClient as E, type InferRouterInitialContexts as F, type InferRouterCurrentContexts as G, type InferRouterInputs as H, type InferRouterInitialContext as I, type InferRouterOutputs as J, adaptRouter as K, type Lazy as L, type Middleware as M, getRouterChild as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type AccessibleLazyRouter as Q, type Router as R, createAccessibleLazyRouter as S, type AnyRouter as a, Procedure as b, type ConflictContextGuard as c, type MergedContext as d, type MapInputMiddleware as e, type CreateProcedureClientOptions as f, type ProcedureClient as g, type ProcedureHandler as h, type AdaptRouterOptions as i, type AdaptedRouter as j, type AnyMiddleware as k, type Lazyable as l, mergeContext as m, LAZY_LOADER_SYMBOL as n, type LazyMeta as o, type LazyOptions as p, lazy as q, isLazy as r, type MiddlewareResult as s, type MiddlewareNextFnOptions as t, unlazy as u, type MiddlewareNextFn as v, type MiddlewareOutputFn as w, type MiddlewareOptions as x, middlewareOutputFn as y, type ProcedureHandlerOptions as z };