@temporary-name/server 1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a → 1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6

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 (31) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -4
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -4
  3. package/dist/adapters/aws-lambda/index.mjs +3 -3
  4. package/dist/adapters/fetch/index.d.mts +3 -4
  5. package/dist/adapters/fetch/index.d.ts +3 -4
  6. package/dist/adapters/fetch/index.mjs +3 -3
  7. package/dist/adapters/node/index.d.mts +3 -4
  8. package/dist/adapters/node/index.d.ts +3 -4
  9. package/dist/adapters/node/index.mjs +3 -3
  10. package/dist/adapters/standard/index.d.mts +10 -6
  11. package/dist/adapters/standard/index.d.ts +10 -6
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/index.d.mts +51 -43
  14. package/dist/index.d.ts +51 -43
  15. package/dist/index.mjs +42 -14
  16. package/dist/openapi/index.d.mts +1 -1
  17. package/dist/openapi/index.d.ts +1 -1
  18. package/dist/openapi/index.mjs +52 -35
  19. package/dist/plugins/index.d.mts +4 -80
  20. package/dist/plugins/index.d.ts +4 -80
  21. package/dist/plugins/index.mjs +17 -189
  22. package/dist/shared/{server.BYnDyuDL.d.mts → server.7aL9gcoU.d.mts} +2 -2
  23. package/dist/shared/{server.WsFQIubj.d.mts → server.BL2R5jcp.d.mts} +36 -43
  24. package/dist/shared/{server.WsFQIubj.d.ts → server.BL2R5jcp.d.ts} +36 -43
  25. package/dist/shared/{server.CjkiSCui.mjs → server.C61o1Zch.mjs} +36 -19
  26. package/dist/shared/{server.C-tNYmY_.d.ts → server.D6Qs_UcF.d.mts} +2 -3
  27. package/dist/shared/{server.JI4dqTgD.d.ts → server.DFptr1Nz.d.ts} +2 -2
  28. package/dist/shared/{server.BlJrjUA9.d.mts → server.DpoO_ER_.d.ts} +2 -3
  29. package/dist/shared/{server.DdHBdcen.mjs → server.DwbIdsnK.mjs} +18 -26
  30. package/dist/shared/{server.Kxw442A9.mjs → server.JtIZ8YG7.mjs} +1 -11
  31. package/package.json +10 -10
@@ -1,5 +1,5 @@
1
- import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, ErrorFromErrorMap } from '@temporary-name/contract';
2
- import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
1
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, Meta, Schemas, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
2
+ import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, StandardLazyRequest, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
3
 
4
4
  type Context = Record<PropertyKey, any>;
5
5
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -13,19 +13,23 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
13
13
  };
14
14
  declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
15
15
 
16
- interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
16
+ interface ProcedureHandlerOptions<TCurrentContext extends Context, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
17
17
  context: TCurrentContext;
18
- input: TInput;
19
18
  path: readonly string[];
20
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
19
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
21
20
  signal?: AbortSignal;
21
+ request?: StandardLazyRequest;
22
22
  lastEventId: string | undefined;
23
23
  errors: TErrorConstructorMap;
24
24
  }
25
- interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
- (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
25
+ interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
26
+ path: any;
27
+ query: any;
28
+ body: any;
29
+ }, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
30
+ (input: TInput, opt: ProcedureHandlerOptions<TCurrentContext, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
27
31
  }
28
- 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> {
32
+ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
29
33
  __initialContext?: (type: TInitialContext) => unknown;
30
34
  middlewares: readonly AnyMiddleware[];
31
35
  inputValidationIndex: number;
@@ -37,39 +41,30 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
37
41
  *
38
42
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
39
43
  */
40
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
44
+ declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
41
45
  /**
42
46
  * This property holds the defined options.
43
47
  */
44
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
48
+ '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
49
+ constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
46
50
  }
47
- type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
51
+ type AnyProcedure = Procedure<any, any, Schemas, any, any>;
48
52
  declare function isProcedure(item: unknown): item is AnyProcedure;
49
53
 
50
54
  type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
51
55
  output: TOutput;
52
56
  context: TOutContext;
53
57
  }>;
54
- type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
55
- context?: TOutContext;
56
- } : {
57
- context: TOutContext;
58
- };
59
58
  interface MiddlewareNextFn<TOutput> {
60
- <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
59
+ <U extends Context = {}>(options?: {
60
+ context?: U;
61
+ }): MiddlewareResult<U, TOutput>;
61
62
  }
62
63
  interface MiddlewareOutputFn<TOutput> {
63
64
  (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
64
65
  }
65
- interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
66
- context: TInContext;
67
- path: readonly string[];
68
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
69
- signal?: AbortSignal;
70
- lastEventId: string | undefined;
66
+ interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends ProcedureHandlerOptions<TInContext, TErrorConstructorMap, TMeta> {
71
67
  next: MiddlewareNextFn<TOutput>;
72
- errors: TErrorConstructorMap;
73
68
  }
74
69
  /**
75
70
  * A function that represents a middleware.
@@ -91,7 +86,7 @@ declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<
91
86
  * @info A procedure is a router too.
92
87
  * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
93
88
  */
94
- 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> : {
89
+ type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
95
90
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
96
91
  };
97
92
  type AnyRouter = Router<any, any>;
@@ -102,7 +97,7 @@ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infe
102
97
  * @info A procedure is a router too.
103
98
  * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
104
99
  */
105
- type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
100
+ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
106
101
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
107
102
  };
108
103
  /**
@@ -111,7 +106,7 @@ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer
111
106
  * @info A procedure is a router too.
112
107
  * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
113
108
  */
114
- type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
109
+ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
115
110
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
116
111
  };
117
112
  /**
@@ -120,7 +115,7 @@ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any,
120
115
  * @info A procedure is a router too.
121
116
  * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
122
117
  */
123
- type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
118
+ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferProcedureClientInputs<USchemas> : {
124
119
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
125
120
  };
126
121
  /**
@@ -129,7 +124,7 @@ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infe
129
124
  * @info A procedure is a router too.
130
125
  * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
131
126
  */
132
- type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
127
+ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
133
128
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
134
129
  };
135
130
 
@@ -138,7 +133,7 @@ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends
138
133
  [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
139
134
  };
140
135
  declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
141
- type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
136
+ type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer USchemas, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
142
137
  [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
143
138
  };
144
139
  interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
@@ -203,15 +198,13 @@ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
203
198
  default: T extends Lazy<infer U> ? U : T;
204
199
  }>;
205
200
 
206
- type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
207
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
208
- context: TInitialContext;
209
- input: unknown;
210
- errors: ORPCErrorConstructorMap<TErrorMap>;
211
- path: readonly string[];
212
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
213
- signal?: AbortSignal;
214
- lastEventId: string | undefined;
201
+ type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
202
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends ProcedureHandlerOptions<TInitialContext, ORPCErrorConstructorMap<TErrorMap>, TMeta> {
203
+ input: {
204
+ path: unknown;
205
+ query: unknown;
206
+ body: unknown;
207
+ };
215
208
  }
216
209
  type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
217
210
  /**
@@ -229,7 +222,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
229
222
  *
230
223
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
231
224
  */
232
- 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>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
225
+ declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TSchemas, TErrorMap>;
233
226
 
234
- export { traverseContractProcedures as $, middlewareOutputFn as B, isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as T, createAccessibleLazyRouter as V, enhanceRouter as W, resolveContractProcedures as a0, unlazyRouter as a2, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazyInternal as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u };
235
- export type { AnyMiddleware as A, Context as C, ProcedureHandlerOptions as D, EnhanceRouterOptions as E, ProcedureDef as F, ProcedureClientInterceptorOptions as H, InferRouterInitialContext as I, InferRouterInitialContexts as K, Lazy as L, Middleware as M, InferRouterCurrentContexts as N, ORPCErrorConstructorMap as O, InferRouterInputs as Q, Router as R, InferRouterOutputs as S, AccessibleLazyRouter as U, TraverseContractProceduresOptions as X, TraverseContractProcedureCallbackOptions as Y, ContractProcedureCallbackOptions as Z, LazyTraverseContractProceduresOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a1, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, AnyProcedure as h, Lazyable as i, AnyRouter as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as v, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
227
+ export { resolveContractProcedures as $, isProcedure as F, createProcedureClient as H, Procedure as P, getRouter as S, createAccessibleLazyRouter as U, enhanceRouter as V, traverseContractProcedures as _, unlazyRouter as a1, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazyInternal as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u, middlewareOutputFn as z };
228
+ export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, EnhanceRouterOptions as E, ProcedureClientInterceptorOptions as G, InferRouterInitialContext as I, InferRouterInitialContexts as J, InferRouterCurrentContexts as K, Lazy as L, Middleware as M, InferRouterInputs as N, ORPCErrorConstructorMap as O, InferRouterOutputs as Q, Router as R, AccessibleLazyRouter as T, TraverseContractProceduresOptions as W, TraverseContractProcedureCallbackOptions as X, ContractProcedureCallbackOptions as Y, LazyTraverseContractProceduresOptions as Z, CreateProcedureClientOptions as a, UnlaziedRouter as a0, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, AnyProcedure as h, Lazyable as i, AnyRouter as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as v, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
@@ -1,7 +1,7 @@
1
1
  import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, validateORPCError, ValidationError } from '@temporary-name/contract';
2
2
  import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
3
3
  import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
4
- import { safeParseAsync } from '@temporary-name/zod';
4
+ import { safeDecodeAsync, safeEncodeAsync } from '@temporary-name/zod';
5
5
 
6
6
  function isStartWithMiddlewares(middlewares, compare) {
7
7
  if (compare.length > middlewares.length) {
@@ -269,14 +269,17 @@ function createProcedureClient(lazyableProcedure, ...rest) {
269
269
  {
270
270
  context,
271
271
  input,
272
- // input only optional when it undefinable so we can safely cast it
273
272
  errors,
274
273
  path,
275
274
  procedure,
275
+ request: callerOptions?.request,
276
276
  signal: callerOptions?.signal,
277
277
  lastEventId: callerOptions?.lastEventId
278
278
  },
279
- (interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
279
+ (interceptorOptions) => {
280
+ const { input: input2, ...opts } = interceptorOptions;
281
+ return executeProcedureInternal(interceptorOptions.procedure, input2, opts);
282
+ }
280
283
  );
281
284
  });
282
285
  if (isAsyncIteratorObject(output)) {
@@ -304,35 +307,49 @@ function createProcedureClient(lazyableProcedure, ...rest) {
304
307
  };
305
308
  }
306
309
  async function validateInput(procedure, input) {
307
- const schema = procedure["~orpc"].inputSchema;
308
- if (!schema) {
309
- return input;
310
- }
310
+ const schemas = procedure["~orpc"].schemas;
311
311
  return runWithSpan({ name: "validate_input" }, async () => {
312
- const result = await safeParseAsync(schema, input);
313
- if (!result.success) {
312
+ const resultBody = await safeDecodeAsync(schemas.bodySchema, input.body, { parseType: "body" });
313
+ const resultPath = await safeDecodeAsync(schemas.pathSchema, input.path, { parseType: "path" });
314
+ const resultQuery = await safeDecodeAsync(schemas.querySchema, input.query, { parseType: "query" });
315
+ const issues = [];
316
+ if (!resultBody.success) {
317
+ issues.push(...resultBody.error.issues.map((i) => ({ ...i, path: ["body", ...i.path] })));
318
+ }
319
+ if (!resultPath.success) {
320
+ issues.push(...resultPath.error.issues.map((i) => ({ ...i, path: ["path", ...i.path] })));
321
+ }
322
+ if (!resultQuery.success) {
323
+ issues.push(...resultQuery.error.issues.map((i) => ({ ...i, path: ["query", ...i.path] })));
324
+ }
325
+ if (issues.length > 0) {
314
326
  throw new ORPCError("BAD_REQUEST", {
315
327
  message: "Input validation failed",
316
328
  data: {
317
- issues: result.error.issues
329
+ issues
318
330
  },
319
331
  cause: new ValidationError({
320
332
  message: "Input validation failed",
321
- issues: result.error.issues,
333
+ issues,
322
334
  data: input
323
335
  })
324
336
  });
325
337
  }
326
- return result.data;
338
+ const results = {
339
+ body: resultBody.data,
340
+ path: resultPath.data,
341
+ query: resultQuery.data
342
+ };
343
+ return results;
327
344
  });
328
345
  }
329
346
  async function validateOutput(procedure, output) {
330
- const schema = procedure["~orpc"].outputSchema;
347
+ const schema = procedure["~orpc"].schemas.outputSchema;
331
348
  if (!schema) {
332
349
  return output;
333
350
  }
334
351
  return runWithSpan({ name: "validate_output" }, async () => {
335
- const result = await safeParseAsync(schema, output);
352
+ const result = await safeEncodeAsync(schema, output, { parseType: "output" });
336
353
  if (!result.success) {
337
354
  throw new ORPCError("INTERNAL_SERVER_ERROR", {
338
355
  message: "Output validation failed",
@@ -346,7 +363,7 @@ async function validateOutput(procedure, output) {
346
363
  return result.data;
347
364
  });
348
365
  }
349
- async function executeProcedureInternal(procedure, options) {
366
+ async function executeProcedureInternal(procedure, input, options) {
350
367
  const middlewares = procedure["~orpc"].middlewares;
351
368
  const inputValidationIndex = Math.min(
352
369
  Math.max(0, procedure["~orpc"].inputValidationIndex),
@@ -356,8 +373,8 @@ async function executeProcedureInternal(procedure, options) {
356
373
  Math.max(0, procedure["~orpc"].outputValidationIndex),
357
374
  middlewares.length
358
375
  );
359
- const next = async (index, context, input) => {
360
- let currentInput = input;
376
+ const next = async (index, context, input2) => {
377
+ let currentInput = input2;
361
378
  if (index === inputValidationIndex) {
362
379
  currentInput = await validateInput(procedure, currentInput);
363
380
  }
@@ -383,14 +400,14 @@ async function executeProcedureInternal(procedure, options) {
383
400
  return result.output;
384
401
  }) : await runWithSpan(
385
402
  { name: "handler", signal: options.signal },
386
- () => procedure["~orpc"].handler({ ...options, context, input: currentInput })
403
+ () => procedure["~orpc"].handler(currentInput, { ...options, context })
387
404
  );
388
405
  if (index === outputValidationIndex) {
389
406
  return await validateOutput(procedure, output);
390
407
  }
391
408
  return output;
392
409
  };
393
- return next(0, options.context, options.input);
410
+ return next(0, options.context, input);
394
411
  }
395
412
 
396
413
  export { LAZY_SYMBOL as L, Procedure as P, addMiddleware as a, isLazy as b, createProcedureClient as c, getRouter as d, enhanceRouter as e, createORPCErrorConstructorMap as f, getLazyMeta as g, lazy as h, isProcedure as i, middlewareOutputFn as j, isStartWithMiddlewares as k, lazyInternal as l, mergeCurrentContext as m, mergeMiddlewares as n, getHiddenRouterContract as o, createAccessibleLazyRouter as p, unlazyRouter as q, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
@@ -1,7 +1,6 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
- import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.WsFQIubj.js';
2
+ import { HTTPPath, StandardLazyRequest, Interceptor, StandardResponse } from '@temporary-name/shared';
3
+ import { C as Context, R as Router, G as ProcedureClientInterceptorOptions } from './server.BL2R5jcp.mjs';
5
4
 
6
5
  interface StandardHandlerPlugin<T extends Context> {
7
6
  order?: number;
@@ -1,6 +1,6 @@
1
1
  import { HTTPPath } from '@temporary-name/shared';
2
- import { C as Context } from './server.WsFQIubj.js';
3
- import { c as StandardHandleOptions } from './server.C-tNYmY_.js';
2
+ import { C as Context } from './server.BL2R5jcp.js';
3
+ import { c as StandardHandleOptions } from './server.DpoO_ER_.js';
4
4
 
5
5
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
6
  context?: T;
@@ -1,7 +1,6 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
- import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.WsFQIubj.mjs';
2
+ import { HTTPPath, StandardLazyRequest, Interceptor, StandardResponse } from '@temporary-name/shared';
3
+ import { C as Context, R as Router, G as ProcedureClientInterceptorOptions } from './server.BL2R5jcp.js';
5
4
 
6
5
  interface StandardHandlerPlugin<T extends Context> {
7
6
  order?: number;
@@ -1,26 +1,17 @@
1
- import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
2
- import { flattenHeader } from '@temporary-name/standard-server';
3
- import { c as createProcedureClient } from './server.CjkiSCui.mjs';
4
- import { fallbackContractConfig } from '@temporary-name/contract';
5
- import { d as deserialize, s as serialize, b as bracketNotationDeserialize, a as standardizeHTTPPath } from './server.Kxw442A9.mjs';
1
+ import { stringifyJSON, isObject, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
2
+ import { c as createProcedureClient } from './server.C61o1Zch.mjs';
3
+ import { fallbackContractConfig, standardizeHTTPPath } from '@temporary-name/contract';
4
+ import { d as deserialize, b as bracketNotationDeserialize, s as serialize } from './server.JtIZ8YG7.mjs';
6
5
  import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
7
6
  import { createRouter, addRoute, findRoute } from 'rou3';
8
7
 
9
8
  async function decode(request, pathParams) {
10
- const deserializeSearchParams = () => {
11
- return bracketNotationDeserialize(Array.from(request.url.searchParams.entries()));
9
+ return {
10
+ path: pathParams ?? {},
11
+ query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
12
+ headers: request.headers,
13
+ body: deserialize(await request.body()) ?? {}
12
14
  };
13
- const data = request.method === "GET" ? deserializeSearchParams() : deserialize(await request.body());
14
- if (data === void 0) {
15
- return pathParams;
16
- }
17
- if (isObject(data)) {
18
- return {
19
- ...pathParams,
20
- ...data
21
- };
22
- }
23
- return data;
24
15
  }
25
16
  function encode(output, procedure) {
26
17
  const successStatus = fallbackContractConfig(
@@ -34,7 +25,7 @@ function encode(output, procedure) {
34
25
  if (outputStructure === "compact") {
35
26
  return {
36
27
  status: successStatus,
37
- headers: {},
28
+ headers: new Headers(),
38
29
  body: serialize(output)
39
30
  };
40
31
  }
@@ -53,14 +44,14 @@ function encode(output, procedure) {
53
44
  }
54
45
  return {
55
46
  status: output.status ?? successStatus,
56
- headers: output.headers ?? {},
47
+ headers: output.headers ?? new Headers(),
57
48
  body: serialize(output.body)
58
49
  };
59
50
  }
60
51
  function encodeError(error) {
61
52
  return {
62
53
  status: error.status,
63
- headers: {},
54
+ headers: new Headers(),
64
55
  body: serialize(error.toJSON(), { outputFormat: "plain" })
65
56
  };
66
57
  }
@@ -214,12 +205,12 @@ class StandardHandler {
214
205
  span?.setAttribute("rpc.system", ORPC_NAME);
215
206
  span?.setAttribute("rpc.method", match.path.join("."));
216
207
  step = "decode_input";
217
- let input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
208
+ const input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
218
209
  step = void 0;
219
- if (isAsyncIteratorObject(input)) {
220
- input = asyncIteratorWithSpan(
210
+ if (isAsyncIteratorObject(input.body)) {
211
+ input.body = asyncIteratorWithSpan(
221
212
  { name: "consume_event_iterator_input", signal: request2.signal },
222
- input
213
+ input.body
223
214
  );
224
215
  }
225
216
  const client = createProcedureClient(match.procedure, {
@@ -229,8 +220,9 @@ class StandardHandler {
229
220
  });
230
221
  step = "call_procedure";
231
222
  const output = await client(input, {
223
+ request: request2,
232
224
  signal: request2.signal,
233
- lastEventId: flattenHeader(request2.headers["last-event-id"])
225
+ lastEventId: request2.headers.get("last-event-id") ?? void 0
234
226
  });
235
227
  step = void 0;
236
228
  const response = encode(output, match.procedure);
@@ -234,14 +234,4 @@ function deserialize(data) {
234
234
  return data;
235
235
  }
236
236
 
237
- function standardizeHTTPPath(path) {
238
- return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
239
- }
240
- function getDynamicParams(path) {
241
- return path ? standardizeHTTPPath(path).match(/\/\{[^}]+\}/g)?.map((v) => ({
242
- raw: v,
243
- name: v.match(/\{\+?([^}]+)\}/)[1]
244
- })) : void 0;
245
- }
246
-
247
- export { standardizeHTTPPath as a, bracketNotationDeserialize as b, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
237
+ export { bracketNotationDeserialize as b, deserialize as d, jsonSerialize as j, serialize as s };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temporary-name/server",
3
3
  "type": "module",
4
- "version": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
4
+ "version": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -73,15 +73,15 @@
73
73
  "cookie": "^1.0.2",
74
74
  "rou3": "^0.7.7",
75
75
  "zod": "^4.1.12",
76
- "@temporary-name/contract": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
77
- "@temporary-name/interop": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
78
- "@temporary-name/json-schema": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
79
- "@temporary-name/shared": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
80
- "@temporary-name/standard-server": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
81
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
82
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
83
- "@temporary-name/zod": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
84
- "@temporary-name/standard-server-node": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a"
76
+ "@temporary-name/contract": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
77
+ "@temporary-name/interop": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
78
+ "@temporary-name/json-schema": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
79
+ "@temporary-name/standard-server": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
80
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
81
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
82
+ "@temporary-name/standard-server-node": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
83
+ "@temporary-name/zod": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
84
+ "@temporary-name/shared": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/supertest": "^6.0.3",