@orpc/server 0.0.0-next.9b9ade5 → 0.0.0-next.9d7bfaa

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 (37) hide show
  1. package/README.md +25 -17
  2. package/dist/adapters/fetch/index.d.mts +54 -10
  3. package/dist/adapters/fetch/index.d.ts +54 -10
  4. package/dist/adapters/fetch/index.mjs +104 -8
  5. package/dist/adapters/node/index.d.mts +56 -21
  6. package/dist/adapters/node/index.d.ts +56 -21
  7. package/dist/adapters/node/index.mjs +82 -23
  8. package/dist/adapters/standard/index.d.mts +11 -10
  9. package/dist/adapters/standard/index.d.ts +11 -10
  10. package/dist/adapters/standard/index.mjs +6 -4
  11. package/dist/index.d.mts +625 -65
  12. package/dist/index.d.ts +625 -65
  13. package/dist/index.mjs +162 -34
  14. package/dist/plugins/index.d.mts +140 -15
  15. package/dist/plugins/index.d.ts +140 -15
  16. package/dist/plugins/index.mjs +156 -7
  17. package/dist/shared/server.BVwwTHyO.mjs +9 -0
  18. package/dist/shared/server.BW-nUGgA.mjs +36 -0
  19. package/dist/shared/server.CN0534_m.d.mts +18 -0
  20. package/dist/shared/server.CjlA3NKP.d.ts +10 -0
  21. package/dist/shared/server.CuD15qZB.d.ts +18 -0
  22. package/dist/shared/{server.CM3tWr3C.d.mts → server.D5fBlF9j.d.ts} +28 -29
  23. package/dist/shared/{server.CMrS28Go.mjs → server.DG7Tamti.mjs} +45 -24
  24. package/dist/shared/{server.CPteJIPP.d.mts → server.DPWk5pjW.d.mts} +71 -22
  25. package/dist/shared/{server.CPteJIPP.d.ts → server.DPWk5pjW.d.ts} +71 -22
  26. package/dist/shared/{server.DmW25ynm.d.ts → server.DY7OKEoj.d.mts} +28 -29
  27. package/dist/shared/server.DjgtLwKi.d.mts +10 -0
  28. package/dist/shared/{server.CSZRzcSW.mjs → server.qf03T-Xn.mjs} +62 -30
  29. package/package.json +8 -22
  30. package/dist/adapters/hono/index.d.mts +0 -19
  31. package/dist/adapters/hono/index.d.ts +0 -19
  32. package/dist/adapters/hono/index.mjs +0 -32
  33. package/dist/adapters/next/index.d.mts +0 -26
  34. package/dist/adapters/next/index.d.ts +0 -26
  35. package/dist/adapters/next/index.mjs +0 -29
  36. package/dist/shared/server.Cq3B6PoL.mjs +0 -28
  37. package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
@@ -1,6 +1,6 @@
1
1
  import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
2
2
  import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
3
- import { value, intercept, toError } from '@orpc/shared';
3
+ import { value, intercept } from '@orpc/shared';
4
4
 
5
5
  const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
6
6
  function lazy(loader, meta = {}) {
@@ -21,7 +21,24 @@ function unlazy(lazied) {
21
21
  return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
22
22
  }
23
23
 
24
- function mergeMiddlewares(first, second) {
24
+ function isStartWithMiddlewares(middlewares, compare) {
25
+ if (compare.length > middlewares.length) {
26
+ return false;
27
+ }
28
+ for (let i = 0; i < middlewares.length; i++) {
29
+ if (compare[i] === void 0) {
30
+ return true;
31
+ }
32
+ if (middlewares[i] !== compare[i]) {
33
+ return false;
34
+ }
35
+ }
36
+ return true;
37
+ }
38
+ function mergeMiddlewares(first, second, options) {
39
+ if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
40
+ return second;
41
+ }
25
42
  return [...first, ...second];
26
43
  }
27
44
  function addMiddleware(middlewares, addition) {
@@ -29,6 +46,9 @@ function addMiddleware(middlewares, addition) {
29
46
  }
30
47
 
31
48
  class Procedure {
49
+ /**
50
+ * This property holds the defined options.
51
+ */
32
52
  "~orpc";
33
53
  constructor(def) {
34
54
  this["~orpc"] = def;
@@ -41,6 +61,10 @@ function isProcedure(item) {
41
61
  return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
42
62
  }
43
63
 
64
+ function mergeCurrentContext(context, other) {
65
+ return { ...context, ...other };
66
+ }
67
+
44
68
  function createORPCErrorConstructorMap(errors) {
45
69
  const proxy = new Proxy(errors, {
46
70
  get(target, code) {
@@ -106,7 +130,7 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
106
130
  );
107
131
  } catch (e) {
108
132
  if (!(e instanceof ORPCError)) {
109
- throw toError(e);
133
+ throw e;
110
134
  }
111
135
  const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
112
136
  throw validated;
@@ -148,28 +172,29 @@ async function executeProcedureInternal(procedure, options) {
148
172
  const middlewares = procedure["~orpc"].middlewares;
149
173
  const inputValidationIndex = Math.min(Math.max(0, procedure["~orpc"].inputValidationIndex), middlewares.length);
150
174
  const outputValidationIndex = Math.min(Math.max(0, procedure["~orpc"].outputValidationIndex), middlewares.length);
151
- let currentIndex = 0;
152
- let currentContext = options.context;
153
- let currentInput = options.input;
154
- const next = async (...[nextOptions]) => {
155
- const index = currentIndex;
156
- currentIndex += 1;
157
- currentContext = { ...currentContext, ...nextOptions?.context };
175
+ const next = async (index, context, input) => {
176
+ let currentInput = input;
158
177
  if (index === inputValidationIndex) {
159
178
  currentInput = await validateInput(procedure, currentInput);
160
179
  }
161
180
  const mid = middlewares[index];
162
- const result = mid ? await mid({ ...options, context: currentContext, next }, currentInput, middlewareOutputFn) : { output: await procedure["~orpc"].handler({ ...options, context: currentContext, input: currentInput }), context: currentContext };
181
+ const output = mid ? (await mid({
182
+ ...options,
183
+ context,
184
+ next: async (...[nextOptions]) => {
185
+ const nextContext = nextOptions?.context ?? {};
186
+ return {
187
+ output: await next(index + 1, mergeCurrentContext(context, nextContext), currentInput),
188
+ context: nextContext
189
+ };
190
+ }
191
+ }, currentInput, middlewareOutputFn)).output : await procedure["~orpc"].handler({ ...options, context, input: currentInput });
163
192
  if (index === outputValidationIndex) {
164
- const validatedOutput = await validateOutput(procedure, result.output);
165
- return {
166
- ...result,
167
- output: validatedOutput
168
- };
193
+ return await validateOutput(procedure, output);
169
194
  }
170
- return result;
195
+ return output;
171
196
  };
172
- return (await next({})).output;
197
+ return next(0, options.context, options.input);
173
198
  }
174
199
 
175
200
  const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
@@ -239,7 +264,7 @@ function enhanceRouter(router, options) {
239
264
  return accessible;
240
265
  }
241
266
  if (isProcedure(router)) {
242
- const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares);
267
+ const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, { dedupeLeading: options.dedupeLeadingMiddlewares });
243
268
  const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
244
269
  const enhanced2 = new Procedure({
245
270
  ...router["~orpc"],
@@ -339,8 +364,4 @@ function call(procedure, input, ...rest) {
339
364
  return createProcedureClient(procedure, ...rest)(input);
340
365
  }
341
366
 
342
- function toHttpPath(path) {
343
- return `/${path.map(encodeURIComponent).join("/")}`;
344
- }
345
-
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 };
367
+ export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, resolveContractProcedures as w, unlazyRouter as x };
@@ -1,19 +1,19 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
1
+ import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
4
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;
5
+ type Context = Record<PropertyKey, any>;
6
+ type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
7
+ type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
8
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
9
 
12
10
  type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
11
  type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
12
  type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
13
  [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
16
14
  };
15
+ declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
16
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
17
17
 
18
18
  declare const LAZY_SYMBOL: unique symbol;
19
19
  interface LazyMeta {
@@ -28,6 +28,9 @@ interface Lazy<T> {
28
28
  };
29
29
  }
30
30
  type Lazyable<T> = T | Lazy<T>;
31
+ /**
32
+ * Create a lazy thing.
33
+ */
31
34
  declare function lazy<T>(loader: () => Promise<{
32
35
  default: T;
33
36
  }>, meta?: LazyMeta): Lazy<T>;
@@ -51,12 +54,20 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutp
51
54
  }
52
55
  interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
53
56
  __initialContext?: (type: TInitialContext) => unknown;
54
- middlewares: AnyMiddleware[];
57
+ middlewares: readonly AnyMiddleware[];
55
58
  inputValidationIndex: number;
56
59
  outputValidationIndex: number;
57
60
  handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
58
61
  }
62
+ /**
63
+ * This class represents a procedure.
64
+ *
65
+ * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
66
+ */
59
67
  declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
68
+ /**
69
+ * This property holds the defined options.
70
+ */
60
71
  '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
61
72
  constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
62
73
  }
@@ -72,8 +83,8 @@ type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never>
72
83
  } : {
73
84
  context: TOutContext;
74
85
  };
75
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
76
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
86
+ interface MiddlewareNextFn<TOutput> {
87
+ <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
77
88
  }
78
89
  interface MiddlewareOutputFn<TOutput> {
79
90
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
@@ -84,9 +95,14 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
84
95
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
85
96
  signal?: AbortSignal;
86
97
  lastEventId: string | undefined;
87
- next: MiddlewareNextFn<TInContext, TOutput>;
98
+ next: MiddlewareNextFn<TOutput>;
88
99
  errors: TErrorConstructorMap;
89
100
  }
101
+ /**
102
+ * A function that represents a middleware.
103
+ *
104
+ * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
105
+ */
90
106
  interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
91
107
  (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
92
108
  }
@@ -97,47 +113,80 @@ interface MapInputMiddleware<TInput, TMappedInput> {
97
113
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
98
114
 
99
115
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
100
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
116
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
101
117
  context: TInitialContext;
102
- input: InferSchemaInput<TInputSchema>;
118
+ input: unknown;
103
119
  errors: ORPCErrorConstructorMap<TErrorMap>;
104
120
  path: readonly string[];
105
121
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
106
122
  signal?: AbortSignal;
107
123
  lastEventId: string | undefined;
108
124
  }
109
- /**
110
- * Options for creating a procedure caller with comprehensive type safety
111
- */
112
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
125
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
113
126
  /**
114
127
  * This is helpful for logging and analytics.
115
128
  */
116
129
  path?: readonly string[];
117
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
130
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
118
131
  } & (Record<never, never> extends TInitialContext ? {
119
132
  context?: Value<TInitialContext, [clientContext: TClientContext]>;
120
133
  } : {
121
134
  context: Value<TInitialContext, [clientContext: TClientContext]>;
122
135
  });
123
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
136
+ /**
137
+ * Create Server-side client from a procedure.
138
+ *
139
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
140
+ */
141
+ declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
124
142
 
143
+ /**
144
+ * Represents a router, which defines a hierarchical structure of procedures.
145
+ *
146
+ * @info A procedure is a router too.
147
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
148
+ */
125
149
  type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
126
150
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
127
151
  };
128
152
  type AnyRouter = Router<any, any>;
129
153
  type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
154
+ /**
155
+ * Infer all initial context of the router.
156
+ *
157
+ * @info A procedure is a router too.
158
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
159
+ */
130
160
  type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
131
161
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
132
162
  };
163
+ /**
164
+ * Infer all current context of the router.
165
+ *
166
+ * @info A procedure is a router too.
167
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
168
+ */
133
169
  type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
134
170
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
135
171
  };
172
+ /**
173
+ * Infer all router inputs
174
+ *
175
+ * @info A procedure is a router too.
176
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
177
+ */
136
178
  type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
137
179
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
138
180
  };
181
+ /**
182
+ * Infer all router outputs
183
+ *
184
+ * @info A procedure is a router too.
185
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
186
+ */
139
187
  type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
140
188
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
141
189
  };
142
190
 
143
- export { type AnyProcedure as A, createProcedureClient as B, type Context as C, type InferRouterInitialContexts as D, type InferRouterCurrentContexts as E, type InferRouterInputs as F, type InferRouterOutputs as G, type InferRouterInitialContext as I, type Lazyable as L, type Middleware as M, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, 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 AnyMiddleware as h, type Lazy as i, type ProcedureHandler as j, LAZY_SYMBOL as k, type LazyMeta as l, mergeContext as m, lazy as n, isLazy as o, getLazyMeta as p, type MiddlewareResult as q, type MiddlewareNextFnOptions as r, type MiddlewareNextFn as s, type MiddlewareOutputFn as t, unlazy as u, type MiddlewareOptions as v, middlewareOutputFn as w, type ProcedureHandlerOptions as x, type ProcedureDef as y, isProcedure as z };
191
+ export { isProcedure as E, createProcedureClient as G, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, validateORPCError as v, middlewareOutputFn as z };
192
+ export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, ProcedureClientInterceptorOptions as F, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
@@ -1,19 +1,19 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
2
- import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
1
+ import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
4
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;
5
+ type Context = Record<PropertyKey, any>;
6
+ type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
7
+ type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
8
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
9
 
12
10
  type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
13
11
  type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
14
12
  type ORPCErrorConstructorMap<T extends ErrorMap> = {
15
13
  [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
16
14
  };
15
+ declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
16
+ declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
17
17
 
18
18
  declare const LAZY_SYMBOL: unique symbol;
19
19
  interface LazyMeta {
@@ -28,6 +28,9 @@ interface Lazy<T> {
28
28
  };
29
29
  }
30
30
  type Lazyable<T> = T | Lazy<T>;
31
+ /**
32
+ * Create a lazy thing.
33
+ */
31
34
  declare function lazy<T>(loader: () => Promise<{
32
35
  default: T;
33
36
  }>, meta?: LazyMeta): Lazy<T>;
@@ -51,12 +54,20 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutp
51
54
  }
52
55
  interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
53
56
  __initialContext?: (type: TInitialContext) => unknown;
54
- middlewares: AnyMiddleware[];
57
+ middlewares: readonly AnyMiddleware[];
55
58
  inputValidationIndex: number;
56
59
  outputValidationIndex: number;
57
60
  handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
58
61
  }
62
+ /**
63
+ * This class represents a procedure.
64
+ *
65
+ * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
66
+ */
59
67
  declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
68
+ /**
69
+ * This property holds the defined options.
70
+ */
60
71
  '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
61
72
  constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
62
73
  }
@@ -72,8 +83,8 @@ type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never>
72
83
  } : {
73
84
  context: TOutContext;
74
85
  };
75
- interface MiddlewareNextFn<TInContext extends Context, TOutput> {
76
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
86
+ interface MiddlewareNextFn<TOutput> {
87
+ <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
77
88
  }
78
89
  interface MiddlewareOutputFn<TOutput> {
79
90
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
@@ -84,9 +95,14 @@ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstruct
84
95
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
85
96
  signal?: AbortSignal;
86
97
  lastEventId: string | undefined;
87
- next: MiddlewareNextFn<TInContext, TOutput>;
98
+ next: MiddlewareNextFn<TOutput>;
88
99
  errors: TErrorConstructorMap;
89
100
  }
101
+ /**
102
+ * A function that represents a middleware.
103
+ *
104
+ * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
105
+ */
90
106
  interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
91
107
  (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
92
108
  }
@@ -97,47 +113,80 @@ interface MapInputMiddleware<TInput, TMappedInput> {
97
113
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
98
114
 
99
115
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
100
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
116
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
101
117
  context: TInitialContext;
102
- input: InferSchemaInput<TInputSchema>;
118
+ input: unknown;
103
119
  errors: ORPCErrorConstructorMap<TErrorMap>;
104
120
  path: readonly string[];
105
121
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
106
122
  signal?: AbortSignal;
107
123
  lastEventId: string | undefined;
108
124
  }
109
- /**
110
- * Options for creating a procedure caller with comprehensive type safety
111
- */
112
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
125
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
113
126
  /**
114
127
  * This is helpful for logging and analytics.
115
128
  */
116
129
  path?: readonly string[];
117
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
130
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
118
131
  } & (Record<never, never> extends TInitialContext ? {
119
132
  context?: Value<TInitialContext, [clientContext: TClientContext]>;
120
133
  } : {
121
134
  context: Value<TInitialContext, [clientContext: TClientContext]>;
122
135
  });
123
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
136
+ /**
137
+ * Create Server-side client from a procedure.
138
+ *
139
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
140
+ */
141
+ declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
124
142
 
143
+ /**
144
+ * Represents a router, which defines a hierarchical structure of procedures.
145
+ *
146
+ * @info A procedure is a router too.
147
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
148
+ */
125
149
  type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
126
150
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
127
151
  };
128
152
  type AnyRouter = Router<any, any>;
129
153
  type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
154
+ /**
155
+ * Infer all initial context of the router.
156
+ *
157
+ * @info A procedure is a router too.
158
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
159
+ */
130
160
  type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
131
161
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
132
162
  };
163
+ /**
164
+ * Infer all current context of the router.
165
+ *
166
+ * @info A procedure is a router too.
167
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
168
+ */
133
169
  type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
134
170
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
135
171
  };
172
+ /**
173
+ * Infer all router inputs
174
+ *
175
+ * @info A procedure is a router too.
176
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
177
+ */
136
178
  type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
137
179
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
138
180
  };
181
+ /**
182
+ * Infer all router outputs
183
+ *
184
+ * @info A procedure is a router too.
185
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
186
+ */
139
187
  type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
140
188
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
141
189
  };
142
190
 
143
- export { type AnyProcedure as A, createProcedureClient as B, type Context as C, type InferRouterInitialContexts as D, type InferRouterCurrentContexts as E, type InferRouterInputs as F, type InferRouterOutputs as G, type InferRouterInitialContext as I, type Lazyable as L, type Middleware as M, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, 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 AnyMiddleware as h, type Lazy as i, type ProcedureHandler as j, LAZY_SYMBOL as k, type LazyMeta as l, mergeContext as m, lazy as n, isLazy as o, getLazyMeta as p, type MiddlewareResult as q, type MiddlewareNextFnOptions as r, type MiddlewareNextFn as s, type MiddlewareOutputFn as t, unlazy as u, type MiddlewareOptions as v, middlewareOutputFn as w, type ProcedureHandlerOptions as x, type ProcedureDef as y, isProcedure as z };
191
+ export { isProcedure as E, createProcedureClient as G, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, validateORPCError as v, middlewareOutputFn as z };
192
+ export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, ProcedureClientInterceptorOptions as F, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
@@ -1,8 +1,18 @@
1
- import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
2
- import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
1
+ import { HTTPPath, ORPCError } from '@orpc/client';
2
+ import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
3
+ import { Interceptor, ThrowableError } from '@orpc/shared';
3
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
4
- import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CPteJIPP.js';
5
- import { ORPCError } from '@orpc/client';
5
+ import { C as Context, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions, R as Router } from './server.DPWk5pjW.mjs';
6
+
7
+ interface StandardHandlerPlugin<TContext extends Context> {
8
+ order?: number;
9
+ init?(options: StandardHandlerOptions<TContext>): void;
10
+ }
11
+ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
12
+ protected readonly plugins: TPlugin[];
13
+ constructor(plugins?: readonly TPlugin[]);
14
+ init(options: StandardHandlerOptions<T>): void;
15
+ }
6
16
 
7
17
  type StandardParams = Record<string, string>;
8
18
  type StandardMatchResult = {
@@ -20,13 +30,10 @@ interface StandardCodec {
20
30
  decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
21
31
  }
22
32
 
23
- type StandardHandleOptions<T extends Context> = {
33
+ interface StandardHandleOptions<T extends Context> {
24
34
  prefix?: HTTPPath;
25
- } & (Record<never, never> extends T ? {
26
- context?: T;
27
- } : {
28
35
  context: T;
29
- });
36
+ }
30
37
  type StandardHandleResult = {
31
38
  matched: true;
32
39
  response: StandardResponse;
@@ -34,42 +41,34 @@ type StandardHandleResult = {
34
41
  matched: false;
35
42
  response: undefined;
36
43
  };
37
- type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
38
- context: T;
44
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
39
45
  request: StandardLazyRequest;
40
- };
46
+ }
41
47
  interface StandardHandlerOptions<TContext extends Context> {
42
- plugins?: HandlerPlugin<TContext>[];
48
+ plugins?: StandardHandlerPlugin<TContext>[];
43
49
  /**
44
50
  * Interceptors at the request level, helpful when you want catch errors
45
51
  */
46
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
52
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
47
53
  /**
48
54
  * Interceptors at the root level, helpful when you want override the request/response
49
55
  */
50
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
56
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
51
57
  /**
52
58
  *
53
59
  * Interceptors for procedure client.
54
60
  */
55
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
61
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
56
62
  }
57
63
  declare class StandardHandler<T extends Context> {
58
64
  private readonly matcher;
59
65
  private readonly codec;
60
- private readonly options;
61
- private readonly plugin;
66
+ private readonly interceptors;
67
+ private readonly clientInterceptors;
68
+ private readonly rootInterceptors;
62
69
  constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
63
- handle(request: StandardLazyRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
64
- }
65
-
66
- interface HandlerPlugin<TContext extends Context> {
67
- init?(options: StandardHandlerOptions<TContext>): void;
68
- }
69
- declare class CompositePlugin<TContext extends Context> implements HandlerPlugin<TContext> {
70
- private readonly plugins;
71
- constructor(plugins?: HandlerPlugin<TContext>[]);
72
- init(options: StandardHandlerOptions<TContext>): void;
70
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
73
71
  }
74
72
 
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 };
73
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as i };
74
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardCodec as c, StandardParams as d, StandardMatcher as e, StandardMatchResult as f, StandardHandleOptions as g, StandardHandleResult as h };
@@ -0,0 +1,10 @@
1
+ import { C as Context } from './server.DPWk5pjW.mjs';
2
+ import { g as StandardHandleOptions } from './server.DY7OKEoj.mjs';
3
+
4
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
+ context?: T;
6
+ } : {
7
+ context: T;
8
+ });
9
+
10
+ export type { FriendlyStandardHandleOptions as F };