@temporary-name/server 1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0 → 1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46

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 (28) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -3
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -3
  3. package/dist/adapters/aws-lambda/index.mjs +3 -3
  4. package/dist/adapters/fetch/index.d.mts +3 -3
  5. package/dist/adapters/fetch/index.d.ts +3 -3
  6. package/dist/adapters/fetch/index.mjs +3 -3
  7. package/dist/adapters/node/index.d.mts +3 -3
  8. package/dist/adapters/node/index.d.ts +3 -3
  9. package/dist/adapters/node/index.mjs +3 -3
  10. package/dist/adapters/standard/index.d.mts +4 -4
  11. package/dist/adapters/standard/index.d.ts +4 -4
  12. package/dist/adapters/standard/index.mjs +3 -3
  13. package/dist/index.d.mts +45 -76
  14. package/dist/index.d.ts +45 -76
  15. package/dist/index.mjs +15 -205
  16. package/dist/openapi/index.mjs +30 -64
  17. package/dist/plugins/index.d.mts +2 -2
  18. package/dist/plugins/index.d.ts +2 -2
  19. package/dist/shared/{server.B93y_8tj.d.mts → server.B-pKBQ0r.d.mts} +2 -2
  20. package/dist/shared/{server.D_fags8X.d.ts → server.BQV-lt_s.d.ts} +2 -2
  21. package/dist/shared/{server.BYYf0Wn6.mjs → server.BdGbIyq8.mjs} +199 -5
  22. package/dist/shared/{server.cjcgLdr1.d.ts → server.DAzElr6Q.d.ts} +1 -1
  23. package/dist/shared/{server.C3RuMHWl.d.mts → server.Do2Whl-h.d.mts} +107 -64
  24. package/dist/shared/{server.C3RuMHWl.d.ts → server.Do2Whl-h.d.ts} +107 -64
  25. package/dist/shared/{server.CT1xhSmE.d.mts → server.KIlJQ8K_.d.mts} +1 -1
  26. package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
  27. package/dist/shared/{server.BeBVpcA9.mjs → server.SmOM3Fae.mjs} +17 -42
  28. package/package.json +10 -10
@@ -1,4 +1,4 @@
1
- import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
1
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, Schemas, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
2
2
  import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
3
 
4
4
  type Context = Record<PropertyKey, any>;
@@ -17,7 +17,7 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
17
17
  context: TCurrentContext;
18
18
  input: TInput;
19
19
  path: readonly string[];
20
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
20
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
21
21
  signal?: AbortSignal;
22
22
  lastEventId: string | undefined;
23
23
  errors: TErrorConstructorMap;
@@ -25,7 +25,7 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
25
25
  interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
26
  (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
27
27
  }
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> {
28
+ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
29
29
  __initialContext?: (type: TInitialContext) => unknown;
30
30
  middlewares: readonly AnyMiddleware[];
31
31
  inputValidationIndex: number;
@@ -37,14 +37,14 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
37
37
  *
38
38
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
39
39
  */
40
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
40
+ declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
41
41
  /**
42
42
  * This property holds the defined options.
43
43
  */
44
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
44
+ '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
45
+ constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
46
46
  }
47
- type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
47
+ type AnyProcedure = Procedure<any, any, Schemas, any, any>;
48
48
  declare function isProcedure(item: unknown): item is AnyProcedure;
49
49
 
50
50
  type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
@@ -65,7 +65,7 @@ interface MiddlewareOutputFn<TOutput> {
65
65
  interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
66
66
  context: TInContext;
67
67
  path: readonly string[];
68
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
68
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
69
69
  signal?: AbortSignal;
70
70
  lastEventId: string | undefined;
71
71
  next: MiddlewareNextFn<TOutput>;
@@ -85,6 +85,91 @@ interface MapInputMiddleware<TInput, TMappedInput> {
85
85
  }
86
86
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
87
87
 
88
+ /**
89
+ * Represents a router, which defines a hierarchical structure of procedures.
90
+ *
91
+ * @info A procedure is a router too.
92
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
93
+ */
94
+ type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
95
+ [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
96
+ };
97
+ type AnyRouter = Router<any, any>;
98
+ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
99
+ /**
100
+ * Infer all initial context of the router.
101
+ *
102
+ * @info A procedure is a router too.
103
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
104
+ */
105
+ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
106
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
107
+ };
108
+ /**
109
+ * Infer all current context of the router.
110
+ *
111
+ * @info A procedure is a router too.
112
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
113
+ */
114
+ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
115
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
116
+ };
117
+ /**
118
+ * Infer all router inputs
119
+ *
120
+ * @info A procedure is a router too.
121
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
122
+ */
123
+ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaInput<USchemas['inputSchema']> : {
124
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
125
+ };
126
+ /**
127
+ * Infer all router outputs
128
+ *
129
+ * @info A procedure is a router too.
130
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
131
+ */
132
+ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
133
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
134
+ };
135
+
136
+ declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
137
+ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
138
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
139
+ };
140
+ 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 USchemas, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
142
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
143
+ };
144
+ interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
145
+ middlewares: readonly AnyMiddleware[];
146
+ errorMap: TErrorMap;
147
+ dedupeLeadingMiddlewares: boolean;
148
+ }
149
+ declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
150
+ interface TraverseContractProceduresOptions {
151
+ router: AnyContractRouter | AnyRouter;
152
+ path: readonly string[];
153
+ }
154
+ interface TraverseContractProcedureCallbackOptions {
155
+ contract: AnyContractProcedure | AnyProcedure;
156
+ path: readonly string[];
157
+ }
158
+ /**
159
+ * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
160
+ */
161
+ type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
162
+ interface LazyTraverseContractProceduresOptions {
163
+ router: Lazy<AnyRouter>;
164
+ path: readonly string[];
165
+ }
166
+ declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
167
+ declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
168
+ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
169
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
170
+ };
171
+ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
172
+
88
173
  declare const LAZY_SYMBOL: unique symbol;
89
174
  interface LazyMeta {
90
175
  prefix?: HTTPPath;
@@ -98,31 +183,37 @@ interface Lazy<T> {
98
183
  };
99
184
  }
100
185
  type Lazyable<T> = T | Lazy<T>;
186
+ /**
187
+ * @internal
188
+ */
189
+ declare function lazyInternal<T>(loader: () => Promise<{
190
+ default: T;
191
+ }>, meta?: LazyMeta): Lazy<T>;
101
192
  /**
102
193
  * Creates a lazy-loaded item.
103
194
  *
104
195
  * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
105
196
  */
106
- declare function lazy<T>(loader: () => Promise<{
197
+ declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
107
198
  default: T;
108
- }>, meta?: LazyMeta): Lazy<T>;
199
+ }>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
109
200
  declare function isLazy(item: unknown): item is Lazy<any>;
110
201
  declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
111
202
  declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
112
203
  default: T extends Lazy<infer U> ? U : T;
113
204
  }>;
114
205
 
115
- type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
206
+ type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TSchemas['inputSchema']>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
116
207
  interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
117
208
  context: TInitialContext;
118
209
  input: unknown;
119
210
  errors: ORPCErrorConstructorMap<TErrorMap>;
120
211
  path: readonly string[];
121
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
212
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
122
213
  signal?: AbortSignal;
123
214
  lastEventId: string | undefined;
124
215
  }
125
- type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
216
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema | undefined, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
126
217
  /**
127
218
  * This is helpful for logging and analytics.
128
219
  */
@@ -138,55 +229,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
138
229
  *
139
230
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
140
231
  */
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>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
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
- */
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> : {
150
- [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
151
- };
152
- type AnyRouter = Router<any, any>;
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
- */
160
- type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
161
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
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
- */
169
- type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
170
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
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
- */
178
- type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
179
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
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
- */
187
- type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
188
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
189
- };
232
+ 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>;
190
233
 
191
- export { isProcedure as D, createProcedureClient as F, 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, middlewareOutputFn as y };
192
- export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
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 };
@@ -1,4 +1,4 @@
1
- import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
1
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, Schemas, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
2
2
  import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
3
 
4
4
  type Context = Record<PropertyKey, any>;
@@ -17,7 +17,7 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
17
17
  context: TCurrentContext;
18
18
  input: TInput;
19
19
  path: readonly string[];
20
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
20
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
21
21
  signal?: AbortSignal;
22
22
  lastEventId: string | undefined;
23
23
  errors: TErrorConstructorMap;
@@ -25,7 +25,7 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
25
25
  interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
26
  (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
27
27
  }
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> {
28
+ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
29
29
  __initialContext?: (type: TInitialContext) => unknown;
30
30
  middlewares: readonly AnyMiddleware[];
31
31
  inputValidationIndex: number;
@@ -37,14 +37,14 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
37
37
  *
38
38
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
39
39
  */
40
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
40
+ declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
41
41
  /**
42
42
  * This property holds the defined options.
43
43
  */
44
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
44
+ '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
45
+ constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
46
46
  }
47
- type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
47
+ type AnyProcedure = Procedure<any, any, Schemas, any, any>;
48
48
  declare function isProcedure(item: unknown): item is AnyProcedure;
49
49
 
50
50
  type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
@@ -65,7 +65,7 @@ interface MiddlewareOutputFn<TOutput> {
65
65
  interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
66
66
  context: TInContext;
67
67
  path: readonly string[];
68
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
68
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
69
69
  signal?: AbortSignal;
70
70
  lastEventId: string | undefined;
71
71
  next: MiddlewareNextFn<TOutput>;
@@ -85,6 +85,91 @@ interface MapInputMiddleware<TInput, TMappedInput> {
85
85
  }
86
86
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
87
87
 
88
+ /**
89
+ * Represents a router, which defines a hierarchical structure of procedures.
90
+ *
91
+ * @info A procedure is a router too.
92
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
93
+ */
94
+ type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
95
+ [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
96
+ };
97
+ type AnyRouter = Router<any, any>;
98
+ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
99
+ /**
100
+ * Infer all initial context of the router.
101
+ *
102
+ * @info A procedure is a router too.
103
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
104
+ */
105
+ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
106
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
107
+ };
108
+ /**
109
+ * Infer all current context of the router.
110
+ *
111
+ * @info A procedure is a router too.
112
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
113
+ */
114
+ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
115
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
116
+ };
117
+ /**
118
+ * Infer all router inputs
119
+ *
120
+ * @info A procedure is a router too.
121
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
122
+ */
123
+ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaInput<USchemas['inputSchema']> : {
124
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
125
+ };
126
+ /**
127
+ * Infer all router outputs
128
+ *
129
+ * @info A procedure is a router too.
130
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
131
+ */
132
+ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
133
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
134
+ };
135
+
136
+ declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
137
+ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
138
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
139
+ };
140
+ 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 USchemas, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
142
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
143
+ };
144
+ interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
145
+ middlewares: readonly AnyMiddleware[];
146
+ errorMap: TErrorMap;
147
+ dedupeLeadingMiddlewares: boolean;
148
+ }
149
+ declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
150
+ interface TraverseContractProceduresOptions {
151
+ router: AnyContractRouter | AnyRouter;
152
+ path: readonly string[];
153
+ }
154
+ interface TraverseContractProcedureCallbackOptions {
155
+ contract: AnyContractProcedure | AnyProcedure;
156
+ path: readonly string[];
157
+ }
158
+ /**
159
+ * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
160
+ */
161
+ type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
162
+ interface LazyTraverseContractProceduresOptions {
163
+ router: Lazy<AnyRouter>;
164
+ path: readonly string[];
165
+ }
166
+ declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
167
+ declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
168
+ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
169
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
170
+ };
171
+ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
172
+
88
173
  declare const LAZY_SYMBOL: unique symbol;
89
174
  interface LazyMeta {
90
175
  prefix?: HTTPPath;
@@ -98,31 +183,37 @@ interface Lazy<T> {
98
183
  };
99
184
  }
100
185
  type Lazyable<T> = T | Lazy<T>;
186
+ /**
187
+ * @internal
188
+ */
189
+ declare function lazyInternal<T>(loader: () => Promise<{
190
+ default: T;
191
+ }>, meta?: LazyMeta): Lazy<T>;
101
192
  /**
102
193
  * Creates a lazy-loaded item.
103
194
  *
104
195
  * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
105
196
  */
106
- declare function lazy<T>(loader: () => Promise<{
197
+ declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
107
198
  default: T;
108
- }>, meta?: LazyMeta): Lazy<T>;
199
+ }>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
109
200
  declare function isLazy(item: unknown): item is Lazy<any>;
110
201
  declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
111
202
  declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
112
203
  default: T extends Lazy<infer U> ? U : T;
113
204
  }>;
114
205
 
115
- type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
206
+ type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TSchemas['inputSchema']>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
116
207
  interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
117
208
  context: TInitialContext;
118
209
  input: unknown;
119
210
  errors: ORPCErrorConstructorMap<TErrorMap>;
120
211
  path: readonly string[];
121
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
212
+ procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
122
213
  signal?: AbortSignal;
123
214
  lastEventId: string | undefined;
124
215
  }
125
- type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
216
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema | undefined, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
126
217
  /**
127
218
  * This is helpful for logging and analytics.
128
219
  */
@@ -138,55 +229,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
138
229
  *
139
230
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
140
231
  */
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>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
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
- */
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> : {
150
- [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
151
- };
152
- type AnyRouter = Router<any, any>;
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
- */
160
- type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
161
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
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
- */
169
- type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
170
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
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
- */
178
- type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
179
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
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
- */
187
- type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
188
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
189
- };
232
+ 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>;
190
233
 
191
- export { isProcedure as D, createProcedureClient as F, 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, middlewareOutputFn as y };
192
- export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
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 };
@@ -1,7 +1,7 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
2
  import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
3
  import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.C3RuMHWl.mjs';
4
+ import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.Do2Whl-h.mjs';
5
5
 
6
6
  interface StandardHandlerPlugin<T extends Context> {
7
7
  order?: number;
@@ -244,4 +244,4 @@ function getDynamicParams(path) {
244
244
  })) : void 0;
245
245
  }
246
246
 
247
- export { standardizeHTTPPath as a, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
247
+ export { standardizeHTTPPath as a, bracketNotationDeserialize as b, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
@@ -1,45 +1,26 @@
1
- import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, value, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
1
+ import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
2
2
  import { flattenHeader } from '@temporary-name/standard-server';
3
- import { c as createProcedureClient } from './server.BYYf0Wn6.mjs';
3
+ import { c as createProcedureClient } from './server.BdGbIyq8.mjs';
4
4
  import { fallbackContractConfig } from '@temporary-name/contract';
5
- import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.BEHw7Eyx.mjs';
5
+ import { d as deserialize, s as serialize, b as bracketNotationDeserialize, a as standardizeHTTPPath } from './server.Kxw442A9.mjs';
6
6
  import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
7
7
  import { createRouter, addRoute, findRoute } from 'rou3';
8
8
 
9
- async function decode(request, params, procedure) {
10
- const inputStructure = fallbackContractConfig(
11
- "defaultInputStructure",
12
- procedure["~orpc"].route.inputStructure
13
- );
14
- if (inputStructure === "compact") {
15
- const data = request.method === "GET" ? deserialize(request.url.searchParams) : deserialize(await request.body());
16
- if (data === void 0) {
17
- return params;
18
- }
19
- if (isObject(data)) {
20
- return {
21
- ...params,
22
- ...data
23
- };
24
- }
25
- return data;
26
- }
9
+ async function decode(request, pathParams) {
27
10
  const deserializeSearchParams = () => {
28
- return deserialize(request.url.searchParams);
29
- };
30
- return {
31
- params,
32
- get query() {
33
- const value = deserializeSearchParams();
34
- Object.defineProperty(this, "query", { value, writable: true });
35
- return value;
36
- },
37
- set query(value) {
38
- Object.defineProperty(this, "query", { value, writable: true });
39
- },
40
- headers: request.headers,
41
- body: deserialize(await request.body())
11
+ return bracketNotationDeserialize(Array.from(request.url.searchParams.entries()));
42
12
  };
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;
43
24
  }
44
25
  function encode(output, procedure) {
45
26
  const successStatus = fallbackContractConfig(
@@ -117,9 +98,6 @@ class StandardOpenAPIMatcher {
117
98
  pendingRouters = [];
118
99
  init(router, path = []) {
119
100
  const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
120
- if (!value(true, traverseOptions)) {
121
- return;
122
- }
123
101
  const { path: path2, contract } = traverseOptions;
124
102
  const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
125
103
  const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
@@ -236,10 +214,7 @@ class StandardHandler {
236
214
  span?.setAttribute("rpc.system", ORPC_NAME);
237
215
  span?.setAttribute("rpc.method", match.path.join("."));
238
216
  step = "decode_input";
239
- let input = await runWithSpan(
240
- { name: "decode_input" },
241
- () => decode(request2, match.params, match.procedure)
242
- );
217
+ let input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
243
218
  step = void 0;
244
219
  if (isAsyncIteratorObject(input)) {
245
220
  input = asyncIteratorWithSpan(
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.d9b25e999833b2b788712bccd5957f10e42416b0",
4
+ "version": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
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/interop": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
77
- "@temporary-name/json-schema": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
78
- "@temporary-name/standard-server": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
79
- "@temporary-name/shared": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
80
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
81
- "@temporary-name/standard-server-node": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
82
- "@temporary-name/zod": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
83
- "@temporary-name/contract": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0",
84
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0"
76
+ "@temporary-name/contract": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
77
+ "@temporary-name/interop": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
78
+ "@temporary-name/json-schema": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
79
+ "@temporary-name/shared": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
80
+ "@temporary-name/standard-server": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
81
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
82
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
83
+ "@temporary-name/standard-server-node": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
84
+ "@temporary-name/zod": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/supertest": "^6.0.3",